Commit 4e3cfb57 authored by hkl's avatar hkl

feat:1.动静态分析-参数配置

parent 35a12266
package org.jeecg.modules.constant;
/**
* @Description: 通用常量
* @author: hkl
* @data: 2023-08-01 16:41:33
*/
public class DictConstant {
/**
* 设备速度等级
*/
public static final String EQUIPMENT_SPEED_OPTS = "equipment_speed_opts";
}
...@@ -26,16 +26,17 @@ import java.util.List; ...@@ -26,16 +26,17 @@ import java.util.List;
@RequestMapping("/dynamicStaticAnalysis/configGradeLimit") @RequestMapping("/dynamicStaticAnalysis/configGradeLimit")
@Api(tags = "动静态分析-配置参数-单元化管理阈值") @Api(tags = "动静态分析-配置参数-单元化管理阈值")
public class ConfigGradeLimitController extends JeecgController<ConfigGradeLimit, IConfigGradeLimitService> { public class ConfigGradeLimitController extends JeecgController<ConfigGradeLimit, IConfigGradeLimitService> {
@AutoLog(value = "动静态分析-配置参数-轨检车检查超限权值-获取记录")
@ApiOperation(value = "动静态分析-配置参数-轨检车检查超限权值-获取记录", notes = "动静态分析-配置参数-轨检车检查超限权值-获取记录") @AutoLog(value = "动静态分析-配置参数-单元化管理阈值-获取记录")
@ApiOperation(value = "动静态分析-配置参数-单元化管理阈值-获取记录", notes = "动静态分析-配置参数-单元化管理阈值-获取记录")
@GetMapping(value = "/listRecord") @GetMapping(value = "/listRecord")
public Result<List<ConfigGradeLimit>> listRecord() { public Result<List<ConfigGradeLimit>> listRecord() {
List<ConfigGradeLimit> records = this.service.listRecord(); List<ConfigGradeLimit> records = this.service.listRecord();
return Result.OK(records); return Result.OK(records);
} }
@AutoLog(value = "动静态分析-配置参数-轨检车检查超限权值-更新参数") @AutoLog(value = "动静态分析-配置参数-单元化管理阈值-更新参数")
@ApiOperation(value = "动静态分析-配置参数-轨检车检查超限权值-更新参数", notes = "动静态分析-配置参数-轨检车检查超限权值-更新参数") @ApiOperation(value = "动静态分析-配置参数-单元化管理阈值-更新参数", notes = "动静态分析-配置参数-单元化管理阈值-更新参数")
@PostMapping(value = "/updateRecord") @PostMapping(value = "/updateRecord")
public Result<String> updateRecord(@RequestBody ConfigGradeLimit record) { public Result<String> updateRecord(@RequestBody ConfigGradeLimit record) {
......
package org.jeecg.modules.dynamicStaticAnalysis.service.impl; package org.jeecg.modules.dynamicStaticAnalysis.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.common.util.UUIDGenerator;
import org.jeecg.modules.constant.DictConstant;
import org.jeecg.modules.dynamicStaticAnalysis.entity.ConfigGradeLimit; import org.jeecg.modules.dynamicStaticAnalysis.entity.ConfigGradeLimit;
import org.jeecg.modules.dynamicStaticAnalysis.mapper.ConfigGradeLimitMapper; import org.jeecg.modules.dynamicStaticAnalysis.mapper.ConfigGradeLimitMapper;
import org.jeecg.modules.dynamicStaticAnalysis.service.IConfigGradeLimitService; import org.jeecg.modules.dynamicStaticAnalysis.service.IConfigGradeLimitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.system.entity.SysDict;
import org.jeecg.modules.system.entity.SysDictItem;
import org.jeecg.modules.system.mapper.SysDictItemMapper;
import org.jeecg.modules.system.mapper.SysDictMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/** /**
* <p> * <p>
...@@ -19,9 +33,86 @@ import java.util.List; ...@@ -19,9 +33,86 @@ import java.util.List;
@Service @Service
public class ConfigGradeLimitServiceImpl extends ServiceImpl<ConfigGradeLimitMapper, ConfigGradeLimit> implements IConfigGradeLimitService { public class ConfigGradeLimitServiceImpl extends ServiceImpl<ConfigGradeLimitMapper, ConfigGradeLimit> implements IConfigGradeLimitService {
@Resource
private SysDictMapper sysDictMapper;
@Resource
private SysDictItemMapper sysDictItemMapper;
@Override @Override
public List<ConfigGradeLimit> listRecord() { public List<ConfigGradeLimit> listRecord() {
List<ConfigGradeLimit> list = this.lambdaQuery().eq(ConfigGradeLimit::getDelFlag, "0").list(); List<ConfigGradeLimit> records = this.lambdaQuery().eq(ConfigGradeLimit::getDelFlag, "0").list();
return list; if (ObjectUtil.isEmpty(records)) {
records = this.initConfigGradeLimit();
}
return records;
}
/**
* 初始化参数
*
* @return
*/
private List<ConfigGradeLimit> initConfigGradeLimit() {
List<ConfigGradeLimit> result = new ArrayList<>(64);
// 1.动态查找速度等级
// 字典
LambdaQueryWrapper<SysDict> sysDictWrapper = Wrappers.lambdaQuery();
sysDictWrapper.eq(SysDict::getDictCode, DictConstant.EQUIPMENT_SPEED_OPTS).last("limit 1");
SysDict sysDict = sysDictMapper.selectOne(sysDictWrapper);
// 字典项目
LambdaQueryWrapper<SysDictItem> sysDictItemWrapper = Wrappers.lambdaQuery();
sysDictItemWrapper.eq(SysDictItem::getDictId, sysDict.getId());
List<SysDictItem> sysDictItems = sysDictItemMapper.selectList(sysDictItemWrapper);
// 2.循环生成
// 1-钢轨 2-道岔 3-曲线 4-竖曲线
List<Integer> deviceTypeList = IntStream.range(1, 5).boxed().collect(Collectors.toList());
for (Integer deviceType : deviceTypeList) {
for (SysDictItem sysDictItem : sysDictItems) {
// 优良
ConfigGradeLimit a = new ConfigGradeLimit();
a.setId(UUIDGenerator.generate());
a.setDictLabel(sysDictItem.getItemText());
a.setDictValue(sysDictItem.getItemValue());
a.setDeviceType(deviceType);
a.setGradeLevel(1); //1-优良
a.setGradeMin(0);
a.setGradeMax(100);
result.add(a);
// 合格
ConfigGradeLimit b = new ConfigGradeLimit();
b.setId(UUIDGenerator.generate());
b.setDictLabel(sysDictItem.getItemText());
b.setDictValue(sysDictItem.getItemValue());
b.setDeviceType(deviceType);
b.setGradeLevel(1); //2-合格
b.setGradeMin(100);
b.setGradeMax(200);
result.add(b);
// 失格
ConfigGradeLimit c = new ConfigGradeLimit();
c.setId(UUIDGenerator.generate());
c.setDictLabel(sysDictItem.getItemText());
c.setDictValue(sysDictItem.getItemValue());
c.setDeviceType(deviceType);
c.setGradeLevel(3); //3-失格
c.setGradeMin(200);
c.setGradeMax(99999);
result.add(c);
}
}
this.saveBatch(result);
return result;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment