微调
This commit is contained in:
@@ -7,6 +7,7 @@ import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
@@ -102,19 +103,30 @@ public class PqErrSysController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@GetMapping("/copy")
|
||||
@ApiOperation("复制误差体系")
|
||||
@OperateInfo()
|
||||
@GetMapping("/getDetail")
|
||||
@ApiOperation("查看误差体系项详情")
|
||||
@ApiImplicitParam(name = "id", value = "误差体系id", required = true)
|
||||
public HttpResult<Object> copy(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("copy");
|
||||
LogUtil.njcnDebug(log, "{},复制ID为:{}", methodDescribe, id);
|
||||
boolean result = pqErrSysService.copyPqErrSys(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
public HttpResult<List<PqErrSysDtlsVO>> getDetail(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getDetail");
|
||||
LogUtil.njcnDebug(log, "{},查看ID为:{}", methodDescribe, id);
|
||||
List<PqErrSysDtlsVO> result = pqErrSysService.getDetail(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
// @OperateInfo(operateType = OperateType.ADD)
|
||||
// @GetMapping("/copy")
|
||||
// @ApiOperation("复制误差体系")
|
||||
// @ApiImplicitParam(name = "id", value = "误差体系id", required = true)
|
||||
// public HttpResult<Object> copy(@RequestParam("id") String id) {
|
||||
// String methodDescribe = getMethodDescribe("copy");
|
||||
// LogUtil.njcnDebug(log, "{},复制ID为:{}", methodDescribe, id);
|
||||
// boolean result = pqErrSysService.copyPqErrSys(id);
|
||||
// if (result) {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
// } else {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,11 @@ public class PqErrSysDtlsParam {
|
||||
@NotNull(message = DeviceValidMessage.END_FLAG_NOT_NULL)
|
||||
private Integer endFlag;
|
||||
|
||||
// @ApiModelProperty(value = "单位", required = true)
|
||||
// @NotBlank(message = DeviceValidMessage.UNIT_NOT_BLANK)
|
||||
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.UNIT_FORMAT_ERROR)
|
||||
// private String unit;
|
||||
|
||||
@ApiModelProperty(value = "判断条件值类型", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.CONDITION_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ERROR_VALUE_FORMAT_ERROR)
|
||||
|
||||
@@ -13,8 +13,6 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ public class PqErrSysDtls implements Serializable {
|
||||
private String errorSysId;
|
||||
|
||||
/**
|
||||
* 检测脚本类型
|
||||
* 电能质量检测指标类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
@@ -48,6 +48,11 @@ public class PqErrSysDtls implements Serializable {
|
||||
*/
|
||||
private Integer endFlag;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
// private String unit;
|
||||
|
||||
/**
|
||||
* 判断条件值类型(包括值类型,绝对值、相对值)
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.device.err.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
|
||||
@@ -53,11 +54,13 @@ public interface IPqErrSysService extends IService<PqErrSys> {
|
||||
*/
|
||||
boolean deletePqErrSys(List<String> ids);
|
||||
|
||||
List<PqErrSysDtlsVO> getDetail(String id);
|
||||
|
||||
/**
|
||||
* 复制误差体系
|
||||
*
|
||||
* @param id 误差体系id
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean copyPqErrSys(String id);
|
||||
//boolean copyPqErrSys(String id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.device.err.service.impl;
|
||||
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -8,8 +9,12 @@ import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.gather.device.err.mapper.PqErrSysMapper;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -17,8 +22,8 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -30,6 +35,7 @@ import java.util.UUID;
|
||||
public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> implements IPqErrSysService {
|
||||
|
||||
private final IPqErrSysDtlsService pqErrSysDtlsService;
|
||||
private final IDictTreeService dictTreeService;
|
||||
|
||||
@Override
|
||||
public Page<PqErrSys> listPqErrSys(PqErrSysParam.QueryParam param) {
|
||||
@@ -81,12 +87,68 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyPqErrSys(String id) {
|
||||
PqErrSys pqErrSys = this.getPqErrSysById(id);
|
||||
pqErrSys.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
pqErrSys.setName(pqErrSys.getName() + "_副本");
|
||||
pqErrSys.setStandardTime(LocalDate.of(pqErrSys.getStandardTime().getYear(), 1, 1));
|
||||
pqErrSys.getPqErrSysDtlsList().forEach(pqErrSysDtls -> pqErrSysDtls.setId(UUID.randomUUID().toString().replaceAll("-", "")));
|
||||
return this.save(pqErrSys);
|
||||
public List<PqErrSysDtlsVO> getDetail(String id) {
|
||||
List<PqErrSysDtlsVO> result = new ArrayList<>();
|
||||
List<PqErrSysDtls> pqErrSysDtls = pqErrSysDtlsService.listPqErrSysDtlsByPqErrSysId(id);
|
||||
if (ObjectUtil.isNotEmpty(pqErrSysDtls)) {
|
||||
PqErrSysDtlsVO temp = new PqErrSysDtlsVO();
|
||||
temp.setDevLevel(this.getById(id).getDevLevel());
|
||||
//按照测量项分组
|
||||
Map<String, List<PqErrSysDtls>> map = pqErrSysDtls.stream().collect(Collectors.groupingBy(PqErrSysDtls::getType));
|
||||
map.forEach((key, value) -> {
|
||||
this.visualize(value, temp);
|
||||
result.add(temp);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将检测项可视化
|
||||
*
|
||||
* @param list
|
||||
* @param temp
|
||||
*/
|
||||
private void visualize(List<PqErrSysDtls> list, PqErrSysDtlsVO temp) {
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
String type = list.get(0).getType();
|
||||
DictTree dictTree = dictTreeService.queryById(type);
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
String[] pids = dictTree.getPids().split(StrPool.COMMA);
|
||||
temp.setTestType(dictTree.getName());
|
||||
temp.setCol1(dictTreeService.queryById(pids[1]).getName());
|
||||
if (pids.length == 3) {
|
||||
temp.setCol2(dictTreeService.queryById(pids[2]).getName());
|
||||
}
|
||||
if (pids.length == 2) {
|
||||
temp.setCol2(dictTreeService.queryById(pids[1]).getName());
|
||||
}
|
||||
}
|
||||
|
||||
list.forEach(pqErrSysDtls -> {
|
||||
if (ObjectUtil.isNull(temp.getInfo())) {
|
||||
temp.setInfo(new ArrayList<>());
|
||||
}
|
||||
Map<String, Object> map1 = new HashMap();
|
||||
map1.put("startValue", pqErrSysDtls.getStartValue());
|
||||
map1.put("startFlag", pqErrSysDtls.getStartFlag());
|
||||
map1.put("endValue", pqErrSysDtls.getEndValue());
|
||||
map1.put("endFlag", pqErrSysDtls.getEndFlag());
|
||||
map1.put("conditionType", pqErrSysDtls.getConditionType());
|
||||
map1.put("maxErrorValue", pqErrSysDtls.getMaxErrorValue());
|
||||
map1.put("errorValueType", pqErrSysDtls.getErrorValueType());
|
||||
temp.getInfo().add(map1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean copyPqErrSys(String id) {
|
||||
// PqErrSys pqErrSys = this.getPqErrSysById(id);
|
||||
// pqErrSys.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
// pqErrSys.setName(pqErrSys.getName() + "_副本");
|
||||
// pqErrSys.setStandardTime(LocalDate.of(pqErrSys.getStandardTime().getYear(), 1, 1));
|
||||
// pqErrSys.getPqErrSysDtlsList().forEach(pqErrSysDtls -> pqErrSysDtls.setId(UUID.randomUUID().toString().replaceAll("-", "")));
|
||||
// return this.save(pqErrSys);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -129,4 +129,8 @@ public interface DeviceValidMessage {
|
||||
String PQ_SOURCE_PARAMETER_REMARK_NOT_BLANK = "检测源参数描述不能为空,请检查pqSourceParameterRemark参数";
|
||||
|
||||
String PQ_SOURCE_PARAMETER_VALUE_NOT_BLANK = "参数值不能为空,请检查pqSourceParameterValue参数";
|
||||
|
||||
// String UNIT_NOT_BLANK = "单位不能为空,请检查unit参数";
|
||||
//
|
||||
// String UNIT_FORMAT_ERROR = "单位格式错误,请检查unit参数";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user