ADD: 1、更新监测点的检测结果接口。

This commit is contained in:
贾同学
2025-09-15 10:39:09 +08:00
parent 9deaea9e81
commit 4532f2242b
5 changed files with 62 additions and 0 deletions

View File

@@ -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 = "设备监测点结果使用批次不能为空";
}

View File

@@ -174,4 +174,17 @@ public class ResultController extends BaseController {
Map<Integer, List<DataSourceResultVO>> 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<Boolean> 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);
}
}

View File

@@ -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;
}

View File

@@ -116,4 +116,6 @@ public interface IResultService {
List<MonitorResultVO> getMonitorResult(String devId);
Map<Integer, List<DataSourceResultVO>> getMonitorDataSourceResult(String monitorId);
Boolean updateMonitorResult(MonitorResultVO result);
}

View File

@@ -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<String> 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<String, List<RawResultDataVO>> getResultMap(DictTree dictTree, List<String> adTypeList, String monitorId, String unit, Integer num, Integer waveNum, Boolean isWave, String code) {
Map<String, List<RawResultDataVO>> resultMap = new LinkedHashMap<>();