diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index 4e09c077..51483934 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java @@ -21,6 +21,7 @@ import com.njcn.gather.detection.util.socket.*; import com.njcn.gather.device.pojo.po.PqDev; import com.njcn.gather.device.pojo.vo.PreDetection; import com.njcn.gather.device.service.IPqDevService; +import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam; import com.njcn.gather.script.pojo.param.PqScriptIssueParam; @@ -32,9 +33,10 @@ import com.njcn.gather.storage.pojo.po.AdHarmonicResult; import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult; import com.njcn.gather.storage.service.AdHarmonicService; import com.njcn.gather.storage.service.DetectionDataDealService; -import com.njcn.gather.system.cfg.pojo.po.SysTestConfig; import com.njcn.gather.system.cfg.service.ISysTestConfigService; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; +import com.njcn.gather.system.dictionary.pojo.po.DictData; +import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.pojo.enums.DicDataEnum; import com.njcn.gather.system.reg.service.ISysRegResService; import lombok.RequiredArgsConstructor; @@ -93,6 +95,7 @@ public class SocketDevResponseService { private final AdHarmonicService adHarmonicService; private final IAdPlanService adPlanService; private final IPqScriptCheckDataService pqScriptCheckDataService; + private final IDictDataService dictDataService; @Value("${phaseAngle.isEnable}") private Boolean isPhaseAngle; @@ -1619,11 +1622,13 @@ public class SocketDevResponseService { //初始化有效数据数 //Map sysRegResMap = iSysRegResService.listRegRes(); - SysTestConfig oneConfig = sysTestConfigService.getOneConfig(); - if (ObjectUtil.isNotNull(oneConfig)) { - dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule()); + //SysTestConfig oneConfig = sysTestConfigService.getOneConfig(); + AdPlan plan = adPlanService.getById(param.getPlanId()); + DictData dictData = dictDataService.getDictDataById(plan.getDataRule()); + if (ObjectUtil.isNotNull(dictData)) { + dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode()); } else { - dataRule = DictDataEnum.AT_WILL_VALUE; + dataRule = DictDataEnum.SECTION_VALUE; } //字典树 SocketManager.valueTypeMap = iPqScriptCheckDataService.getValueTypeMap(param.getScriptId()); diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java b/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java index 93aa506f..d77b19b2 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java @@ -65,6 +65,10 @@ public class AdPlanParam { @ApiModelProperty(value = "报告模板名称") private String reportTemplateName; + @ApiModelProperty(value = "数据处理原则") + @NotBlank(message = DetectionValidMessage.DATA_RULE_NOT_BLANK) + private String dataRule; + /** * 分页查询实体 */ diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/po/AdPlan.java b/detection/src/main/java/com/njcn/gather/plan/pojo/po/AdPlan.java index fcf1a388..a5292ebf 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/po/AdPlan.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/po/AdPlan.java @@ -94,5 +94,10 @@ public class AdPlan extends BaseEntity implements Serializable { * 状态:0-删除 1-正常 */ private Integer state; + + /** + * 数据处理原则。任意值、部分值、所有值、cp95值、平均值 + */ + private String dataRule; } diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanVO.java b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanVO.java index cfb6a3d8..b62fa8c7 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanVO.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/vo/AdPlanVO.java @@ -108,4 +108,6 @@ public class AdPlanVO { * 报告模板名称 */ private String reportTemplateName; + + private String dataRule; } diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index 8aac6e2c..11460c0d 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -761,12 +761,9 @@ public class AdPlanServiceImpl extends ServiceImpl impleme } }); PqErrSys errSys = pqErrSysService.getById(plan.getErrorSysId()); - SysTestConfig config1 = sysTestConfigService.getConfig(); - if (ObjectUtil.isNotNull(config1)) { - DictData dictData = dictDataService.getDictDataById(config1.getDataRule()); - if (ObjectUtil.isNotNull(errSys) && ObjectUtil.isNotNull(dictData)) { - note.append("测试结果采用\"" + errSys.getName() + "\"误差体系结合\"" + dictData.getName() + "\"数据原则计算得出。"); - } + DictData dictData1 = dictDataService.getDictDataById(plan.getDataRule()); + if (ObjectUtil.isNotNull(dictData1) && ObjectUtil.isNotNull(errSys)) { + note.append("测试结果采用\"" + errSys.getName() + "\"误差体系结合\"" + dictData1.getName() + "\"数据原则计算得出。"); } return note.toString(); } diff --git a/detection/src/main/java/com/njcn/gather/pojo/constant/DetectionValidMessage.java b/detection/src/main/java/com/njcn/gather/pojo/constant/DetectionValidMessage.java index b5fc68e5..235349b8 100644 --- a/detection/src/main/java/com/njcn/gather/pojo/constant/DetectionValidMessage.java +++ b/detection/src/main/java/com/njcn/gather/pojo/constant/DetectionValidMessage.java @@ -179,4 +179,5 @@ public interface DetectionValidMessage { String DEV_TYPE_NAME_FORMAT_ERROR = "设备类型名称格式错误,只能包含字母、数字、中文、下划线、中划线、点号、空格,长度为1-32个字符"; String REPORT_NAME_NOT_BLANK = "报告模板不能为空"; + String DATA_RULE_NOT_BLANK = "数据处理原则不能为空"; } diff --git a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java index 9a9c2ba9..e47b331a 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java @@ -53,10 +53,11 @@ import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult; import com.njcn.gather.storage.pojo.vo.RawDataVO; import com.njcn.gather.storage.service.AdHarmonicService; import com.njcn.gather.storage.service.AdNonHarmonicService; -import com.njcn.gather.system.cfg.pojo.po.SysTestConfig; import com.njcn.gather.system.cfg.service.ISysTestConfigService; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; +import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictTree; +import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.dictionary.service.IDictTreeService; import com.njcn.web.utils.ExcelUtil; import lombok.RequiredArgsConstructor; @@ -90,6 +91,7 @@ public class ResultServiceImpl implements IResultService { private final IPqScriptCheckDataService pqScriptCheckDataService; private final TableGenMapper tableGenMapper; private final DetectionServiceImpl detectionServiceImpl; + private final IDictDataService dictDataService; /** * 谐波类code,取树形字典表中的code @@ -108,7 +110,7 @@ public class ResultServiceImpl implements IResultService { adPlanService.visualize(Collections.singletonList(plan)); } formContentVO.setScriptName(plan.getScriptId()); - formContentVO.setDataRule(sysTestConfigService.getConfig().getDataRule()); + formContentVO.setDataRule(plan.getDataRule()); formContentVO.setDeviceName(pqDevService.getById(queryParam.getDeviceId()).getName()); List> chnList = new ArrayList<>(); @@ -1510,12 +1512,19 @@ public class ResultServiceImpl implements IResultService { // PqDev dev = pqDevService.getById(devId); devIdMapComm.put(devId, devId); - SysTestConfig oneConfig = sysTestConfigService.getOneConfig(); DictDataEnum dataRule; - if (ObjectUtil.isNotNull(oneConfig)) { - dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule()); +// SysTestConfig oneConfig = sysTestConfigService.getOneConfig(); +// if (ObjectUtil.isNotNull(oneConfig)) { +// dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule()); +// } else { +// dataRule = DictDataEnum.SECTION_VALUE; +// } + AdPlan plan = adPlanService.getById(planId); + DictData dictData = dictDataService.getDictDataById(plan.getDataRule()); + if (ObjectUtil.isNotNull(dictData)) { + dataRule = DictDataEnum.getDictDataEnumByCode(dictData.getCode()); } else { - dataRule = DictDataEnum.AT_WILL_VALUE; + dataRule = DictDataEnum.SECTION_VALUE; } List allNonHarmonicRawData = adNonHarmonicService.listAllRawData(scriptId, oldCode, devId); diff --git a/system/src/main/java/com/njcn/gather/system/cfg/controller/SysTestConfigController.java b/system/src/main/java/com/njcn/gather/system/cfg/controller/SysTestConfigController.java index 8b70523c..784af704 100644 --- a/system/src/main/java/com/njcn/gather/system/cfg/controller/SysTestConfigController.java +++ b/system/src/main/java/com/njcn/gather/system/cfg/controller/SysTestConfigController.java @@ -36,9 +36,9 @@ public class SysTestConfigController extends BaseController { @GetMapping("/getConfig") @ApiOperation("获取检测相关配置信息") public HttpResult getConfig() { - String methodDescribe = getMethodDescribe("list"); + String methodDescribe = getMethodDescribe("getConfig"); LogUtil.njcnDebug(log, "{}", methodDescribe); - SysTestConfig sysTestConfig = sysTestConfigService.getConfig(); + SysTestConfig sysTestConfig = sysTestConfigService.getOneConfig(); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sysTestConfig, methodDescribe); } diff --git a/system/src/main/java/com/njcn/gather/system/cfg/pojo/param/SysTestConfigParam.java b/system/src/main/java/com/njcn/gather/system/cfg/pojo/param/SysTestConfigParam.java index 249a20b7..fad2142d 100644 --- a/system/src/main/java/com/njcn/gather/system/cfg/pojo/param/SysTestConfigParam.java +++ b/system/src/main/java/com/njcn/gather/system/cfg/pojo/param/SysTestConfigParam.java @@ -24,10 +24,10 @@ public class SysTestConfigParam { @NotNull(message = SystemValidMessage.MAX_RECHECK_NOT_NULL) private Integer maxTime; - @ApiModelProperty(value = "数据处理规则") - @NotBlank(message = SystemValidMessage.DATA_RULE_NOT_BLANK) - @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DATA_RULE_FORMAT_ERROR) - private String dataRule; +// @ApiModelProperty(value = "数据处理规则") +// @NotBlank(message = SystemValidMessage.DATA_RULE_NOT_BLANK) +// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DATA_RULE_FORMAT_ERROR) +// private String dataRule; @Data public static class UpdateParam extends SysTestConfigParam { diff --git a/system/src/main/java/com/njcn/gather/system/cfg/pojo/po/SysTestConfig.java b/system/src/main/java/com/njcn/gather/system/cfg/pojo/po/SysTestConfig.java index 6a347c35..df0e9514 100644 --- a/system/src/main/java/com/njcn/gather/system/cfg/pojo/po/SysTestConfig.java +++ b/system/src/main/java/com/njcn/gather/system/cfg/pojo/po/SysTestConfig.java @@ -37,8 +37,8 @@ public class SysTestConfig extends BaseEntity implements Serializable { /** * 数据处理规则, 关联字典(所有值、部分值、cp95值、平均值、任意值),默认任意值 */ - @TableField("Data_Rule") - private String dataRule; +// @TableField("Data_Rule") +// private String dataRule; /** * 业务场景 diff --git a/system/src/main/java/com/njcn/gather/system/cfg/service/ISysTestConfigService.java b/system/src/main/java/com/njcn/gather/system/cfg/service/ISysTestConfigService.java index 00fef95b..c490339d 100644 --- a/system/src/main/java/com/njcn/gather/system/cfg/service/ISysTestConfigService.java +++ b/system/src/main/java/com/njcn/gather/system/cfg/service/ISysTestConfigService.java @@ -10,12 +10,6 @@ import com.njcn.gather.system.cfg.pojo.po.SysTestConfig; */ public interface ISysTestConfigService extends IService { - /** - * 获取检测配置 - * @return - */ - SysTestConfig getConfig(); - /** * 添加检测配置 * @param scene 场景 diff --git a/system/src/main/java/com/njcn/gather/system/cfg/service/impl/SysTestConfigServiceImpl.java b/system/src/main/java/com/njcn/gather/system/cfg/service/impl/SysTestConfigServiceImpl.java index 855f7993..fd4b2658 100644 --- a/system/src/main/java/com/njcn/gather/system/cfg/service/impl/SysTestConfigServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/cfg/service/impl/SysTestConfigServiceImpl.java @@ -28,10 +28,6 @@ public class SysTestConfigServiceImpl extends ServiceImpl().last("LIMIT 1")); - } @Override @Transactional @@ -40,7 +36,7 @@ public class SysTestConfigServiceImpl extends ServiceImpl queryWrapper = new MPJLambdaWrapper<>(); - queryWrapper.selectAll(SysTestConfig.class) - .selectAs(DictData::getCode, SysTestConfig::getDataRule) - .leftJoin(DictData.class, DictData::getId, SysTestConfig::getDataRule) - .eq(SysTestConfig::getState, DataStateEnum.ENABLE.getCode()); - return this.getBaseMapper().selectJoinOne(SysTestConfig.class, queryWrapper); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("state", DataStateEnum.ENABLE.getCode()); + queryWrapper.last("LIMIT 1"); + return this.getOne(queryWrapper); } @Override