代码调整

This commit is contained in:
caozehui
2025-03-28 15:06:57 +08:00
parent 48408859b1
commit 71ba7fa139
31 changed files with 296 additions and 414 deletions

View File

@@ -1,7 +1,7 @@
package com.njcn.gather.err.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -17,13 +17,13 @@ import javax.validation.constraints.Pattern;
public class PqErrSysDtlsParam {
@ApiModelProperty(value = "误差项类型", required = true)
@NotBlank(message = DevValidMessage.ERR_SYS_DTLS_ERROR_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERR_SYS_DTLS_ERROR_TYPE_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.ERR_SYS_DTLS_ERROR_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ERR_SYS_DTLS_ERROR_TYPE_FORMAT_ERROR)
private String errorType;
@ApiModelProperty(value = "脚本项类型", required = true)
@NotBlank(message = DevValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ERR_SYS_DTLS_SCRIPT_TYPE_FORMAT_ERROR)
private String scriptType;
@ApiModelProperty(value = "误差判断起始值", required = true)
@@ -47,15 +47,15 @@ public class PqErrSysDtlsParam {
private Integer conditionType;
@ApiModelProperty(value = "最大值误差", required = true)
@NotNull(message = DevValidMessage.MAX_ERROR_VALUE_NOT_NULL)
@NotNull(message = DetectionValidMessage.MAX_ERROR_VALUE_NOT_NULL)
private Double maxErrorValue;
@ApiModelProperty(value = "误差值类型", required = true)
@NotNull(message = DevValidMessage.ERROR_VALUE_TYPE_NOT_BLANK)
@NotNull(message = DetectionValidMessage.ERROR_VALUE_TYPE_NOT_BLANK)
private Integer errorValueType;
@ApiModelProperty("排序")
@NotNull(message = DevValidMessage.SORT_NOT_NULL)
@NotNull(message = DetectionValidMessage.SORT_NOT_NULL)
private Integer sort;
}

View File

@@ -1,7 +1,7 @@
package com.njcn.gather.err.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage;
import com.njcn.gather.pojo.constant.DetectionValidMessage;
import com.njcn.web.pojo.annotation.DateTimeStrValid;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
@@ -20,24 +20,24 @@ import java.util.List;
public class PqErrSysParam {
@ApiModelProperty(value = "参照标准名称", required = true)
@NotBlank(message = DevValidMessage.STANDARD_NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DevValidMessage.STANDARD_NAME_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.STANDARD_NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DetectionValidMessage.STANDARD_NAME_FORMAT_ERROR)
private String standardName;
@ApiModelProperty(value = "标准实施年份", required = true)
@NotBlank(message = DevValidMessage.STANDARD_TIME_NOT_BLANK)
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.STANDARD_TIME_NOT_BLANK)
@DateTimeStrValid(format = "yyyy", message = DetectionValidMessage.STANDARD_TIME_FORMAT_ERROR)
private String standardTime;
@ApiModelProperty(value = "设备等级", required = true)
@NotBlank(message = DevValidMessage.DEV_LEVEL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_LEVEL_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.DEV_LEVEL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_LEVEL_FORMAT_ERROR)
private String devLevel;
@ApiModelProperty("状态")
@NotNull(message = DevValidMessage.ENABLE_NOT_NULL)
@Min(value = 0, message = DevValidMessage.ENABLE_FORMAT_ERROR)
@Max(value = 1, message = DevValidMessage.ENABLE_FORMAT_ERROR)
@NotNull(message = DetectionValidMessage.ENABLE_NOT_NULL)
@Min(value = 0, message = DetectionValidMessage.ENABLE_FORMAT_ERROR)
@Max(value = 1, message = DetectionValidMessage.ENABLE_FORMAT_ERROR)
private Integer enable;
@ApiModelProperty(value = "误差详情列表", required = true)
@@ -48,11 +48,11 @@ public class PqErrSysParam {
@EqualsAndHashCode(callSuper = false)
public static class QueryParam extends BaseParam {
@ApiModelProperty("标准实施年份")
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR)
@DateTimeStrValid(format = "yyyy", message = DetectionValidMessage.STANDARD_TIME_FORMAT_ERROR)
private String standardTime;
@ApiModelProperty("设备等级")
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_LEVEL_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.DEV_LEVEL_FORMAT_ERROR)
private String devLevel;
}
@@ -60,14 +60,14 @@ public class PqErrSysParam {
@EqualsAndHashCode(callSuper = false)
public static class UpdateParam extends PqErrSysParam {
@ApiModelProperty("id")
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
@NotBlank(message = DetectionValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DetectionValidMessage.ID_FORMAT_ERROR)
private String id;
}
@Data
@EqualsAndHashCode(callSuper = false)
public static class DetectionParam{
public static class DetectionParam {
@ApiModelProperty("所属误差体系ID")
private String errorSysId;

View File

@@ -68,6 +68,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
@Override
@Transactional
public boolean addPqErrSys(PqErrSysParam param) {
this.checkRepeat(param, false);
PqErrSys pqErrSys = new PqErrSys();
BeanUtils.copyProperties(param, pqErrSys);
String id = UUID.randomUUID().toString().replaceAll("-", "");
@@ -80,9 +81,11 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
return result1 && result2;
}
@Override
@Transactional
public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) {
this.checkRepeat(param, true);
PqErrSys pqErrSys = new PqErrSys();
BeanUtils.copyProperties(param, pqErrSys);
pqErrSys.setName(generateErrSysName(param));
@@ -123,7 +126,9 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
@Override
public List<Map<String, Object>> listAllPqErrSys() {
List<PqErrSys> pqErrSysList = this.lambdaQuery().eq(PqErrSys::getState, DataStateEnum.ENABLE.getCode()).list();
List<PqErrSys> pqErrSysList = this.lambdaQuery()
.eq(PqErrSys::getEnable,DataStateEnum.ENABLE.getCode())
.eq(PqErrSys::getState, DataStateEnum.ENABLE.getCode()).list();
List<Map<String, Object>> result = pqErrSysList.stream().map(pqErrSys -> {
Map<String, Object> map = new HashMap<>();
map.put("id", pqErrSys.getId());
@@ -203,15 +208,25 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
}
/**
* 生成误差体系名称(标准号+年份+设备等级)
* 检查重复
*
* @return 检测源名称
* @param param 检测参数
* @param isExcludeSelf 是否排除自己
*/
private String generatePqSourceName(PqErrSysParam param) {
DictData devLevel = dictDataService.getDictDataById(param.getDevLevel());
if (ObjectUtils.allNotNull(param.getStandardName(), param.getStandardTime(), devLevel)) {
return param.getStandardName() + "-" + param.getStandardTime() + "-" + devLevel.getName();
private void checkRepeat(PqErrSysParam param, boolean isExcludeSelf) {
QueryWrapper<PqErrSys> wrapper = new QueryWrapper<>();
wrapper.eq("Standard_Name", param.getStandardName())
.eq("Standard_Time",param.getStandardTime()+"-01-01")
.eq("Dev_Level",param.getDevLevel())
.eq("state", DataStateEnum.ENABLE.getCode());
if (isExcludeSelf) {
if(param instanceof PqErrSysParam.UpdateParam){
wrapper.ne("Id", ((PqErrSysParam.UpdateParam) param).getId());
}
}
int count = this.count(wrapper);
if (count > 0) {
throw new BusinessException(DetectionResponseEnum.ERR_SYS_REPEAT);
}
throw new BusinessException(DetectionResponseEnum.ERR_SOURCE_GEN_NAME_ERROR);
}
}