From 4532f2242b58d49954fdf3530e850a78b1981537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BE=E5=90=8C=E5=AD=A6?= Date: Mon, 15 Sep 2025 10:39:09 +0800 Subject: [PATCH] =?UTF-8?q?ADD:=201=E3=80=81=E6=9B=B4=E6=96=B0=E7=9B=91?= =?UTF-8?q?=E6=B5=8B=E7=82=B9=E7=9A=84=E6=A3=80=E6=B5=8B=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/constant/DetectionValidMessage.java | 4 +++ .../result/controller/ResultController.java | 13 ++++++++ .../result/pojo/vo/MonitorResultVO.java | 13 ++++++++ .../gather/result/service/IResultService.java | 2 ++ .../service/impl/ResultServiceImpl.java | 30 +++++++++++++++++++ 5 files changed, 62 insertions(+) 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 2d6f8321..5528fe59 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 @@ -199,4 +199,8 @@ public interface DetectionValidMessage { String DEV_IDS_NOT_EMPTY = "被检设备不能为空"; String STANDARD_DEV_IDS_NOT_EMPTY = "标准设备不能为空"; String PAIRS_NOT_EMPTY = "配对关系不能为空"; + String DEV_MONITOR_ID_NOT_BLANK = "设备监测点ID不能为空"; + String DEV_MONITOR_RESULT_NOT_NULL = "设备监测点结果不能为空"; + String DEV_MONITOR_RESULT_TYPE_NOT_BLANK = "设备监测点结果来源类型不能为空"; + String DEV_MONITOR_RESULT_NUM_NOT_BLANK = "设备监测点结果使用批次不能为空"; } diff --git a/detection/src/main/java/com/njcn/gather/result/controller/ResultController.java b/detection/src/main/java/com/njcn/gather/result/controller/ResultController.java index 2708c207..008e9e15 100644 --- a/detection/src/main/java/com/njcn/gather/result/controller/ResultController.java +++ b/detection/src/main/java/com/njcn/gather/result/controller/ResultController.java @@ -174,4 +174,17 @@ public class ResultController extends BaseController { Map> result = resultService.getMonitorDataSourceResult(monitorId); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } + + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/updateMonitorResult") + @ApiOperation("更新监测点的检测结果") + @ApiImplicitParam(name = "result", value = "更新内容", required = true) + public HttpResult updateMonitorResult(@RequestBody @Validated MonitorResultVO resultParams) { + String methodDescribe = getMethodDescribe("updateMonitorResult"); + LogUtil.njcnDebug(log, "{},更新数据为:{}", methodDescribe, resultParams); + + boolean result = resultService.updateMonitorResult(resultParams); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } } diff --git a/detection/src/main/java/com/njcn/gather/result/pojo/vo/MonitorResultVO.java b/detection/src/main/java/com/njcn/gather/result/pojo/vo/MonitorResultVO.java index 00ccb2fe..52857acf 100644 --- a/detection/src/main/java/com/njcn/gather/result/pojo/vo/MonitorResultVO.java +++ b/detection/src/main/java/com/njcn/gather/result/pojo/vo/MonitorResultVO.java @@ -1,7 +1,12 @@ package com.njcn.gather.result.pojo.vo; +import com.njcn.gather.pojo.constant.DetectionValidMessage; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + /** * @author caozehui * @data 2025-09-10 @@ -12,6 +17,8 @@ public class MonitorResultVO { /** * 监测点id */ + @ApiModelProperty(value = "监测点id", required = true) + @NotBlank(message = DetectionValidMessage.DEV_MONITOR_ID_NOT_BLANK) private String monitorId; /** @@ -42,6 +49,8 @@ public class MonitorResultVO { /** * 检测结果 */ + @ApiModelProperty(value = "检测结果", required = true) + @NotNull(message = DetectionValidMessage.DEV_MONITOR_RESULT_NOT_NULL) private Integer checkResult; /** @@ -51,9 +60,13 @@ public class MonitorResultVO { /** * 哪次 */ + @ApiModelProperty(value = "使用哪次检测结果", required = true) + @NotNull(message = DetectionValidMessage.DEV_MONITOR_RESULT_NUM_NOT_BLANK) private String whichTime; /** * 数据源类型 */ + @ApiModelProperty(value = "数据源类型", required = true) + @NotBlank(message = DetectionValidMessage.DEV_MONITOR_RESULT_TYPE_NOT_BLANK) private String resultType; } diff --git a/detection/src/main/java/com/njcn/gather/result/service/IResultService.java b/detection/src/main/java/com/njcn/gather/result/service/IResultService.java index 4c4c8d48..90974f05 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/IResultService.java +++ b/detection/src/main/java/com/njcn/gather/result/service/IResultService.java @@ -116,4 +116,6 @@ public interface IResultService { List getMonitorResult(String devId); Map> getMonitorDataSourceResult(String monitorId); + + Boolean updateMonitorResult(MonitorResultVO result); } 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 abe91c49..5d189f81 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 @@ -16,6 +16,7 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.njcn.common.pojo.enums.common.DataStateEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.utils.PubUtils; import com.njcn.gather.detection.handler.SocketContrastResponseService; @@ -1669,6 +1670,7 @@ public class ResultServiceImpl implements IResultService { break; case WAVE_DATA: result.setCheckResult(pqMonitor.getRecordedResult()); + // 1_2 第【1】次录波【2】数据 List waveData = StrUtil.split(pqMonitor.getRecordedNum(), CnSocketUtil.SPLIT_TAG); result.setWhichTime(waveData.get(0)); result.setResultType(resultType + CnSocketUtil.SPLIT_TAG + waveData.get(1)); @@ -1736,6 +1738,34 @@ public class ResultServiceImpl implements IResultService { return result; } + @Override + public Boolean updateMonitorResult(MonitorResultVO resultParams) { + String monitorId = resultParams.getMonitorId(); + String[] split = monitorId.split(CnSocketUtil.SPLIT_TAG); + PqMonitor monitor = pqMonitorService.lambdaQuery().eq(PqMonitor::getDevId, split[0]).eq(PqMonitor::getNum, split[1]).one(); + if (monitor == null) { + throw new BusinessException(CommonResponseEnum.FAIL, "该设备监测点不存在"); + } + String whichTime = resultParams.getWhichTime(); + Integer checkResult = resultParams.getCheckResult(); + String resultType = resultParams.getResultType(); + if (StrUtil.contains(resultType, DataSourceEnum.WAVE_DATA.getValue())) { + monitor.setResultType(resultType.substring(0, resultType.lastIndexOf(CnSocketUtil.SPLIT_TAG))); + monitor.setRecordedResult(checkResult); + monitor.setRecordedNum(whichTime + resultType.substring(resultType.lastIndexOf(CnSocketUtil.SPLIT_TAG))); + } else if (StrUtil.equals(resultType, DataSourceEnum.REAL_DATA.getValue())) { + monitor.setResultType(resultType); + monitor.setRealtimeResult(checkResult); + monitor.setRealtimeNum(whichTime); + } else { + monitor.setResultType(resultType); + monitor.setStatisticsResult(checkResult); + monitor.setStatisticsNum(whichTime); + } + + return pqMonitorService.updateById(monitor); + } + private Map> getResultMap(DictTree dictTree, List adTypeList, String monitorId, String unit, Integer num, Integer waveNum, Boolean isWave, String code) { Map> resultMap = new LinkedHashMap<>();