完善监测点结果、设备结果
This commit is contained in:
@@ -13,10 +13,7 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.pojo.dto.WaveCommandDTO;
|
||||
import com.njcn.gather.detection.pojo.dto.WaveResultDTO;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.*;
|
||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
@@ -954,6 +951,7 @@ public class SocketContrastResponseService {
|
||||
webSend.setData(JSON.toJSONString(allResultList));
|
||||
|
||||
List<String> adTypes = FormalTestManager.testItemMap.values().stream().collect(Collectors.toList());
|
||||
|
||||
Map<String, Integer> result = detectionDataDealService.devResult(true, FormalTestManager.pairsIdMap.keySet().stream().collect(Collectors.toList()), adTypes, code);
|
||||
// 若有不符合的
|
||||
// if (result.values().stream().anyMatch(r -> r.equals(ResultEnum.NOT_QUALIFIED.getValue()))) {
|
||||
@@ -962,42 +960,42 @@ public class SocketContrastResponseService {
|
||||
webSend.setCode(SourceResponseCodeEnum.REAL_DATA_CHECK_FAIL.getCode());// 实时数据检测失败,最终错误推送
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend));
|
||||
|
||||
System.out.println("实时数据校验失败!》》》》》》》》》》》》》》》》》》》》》》》》》》》》》开始录波》》》》》》》》》》》》》》》》");
|
||||
// 判断是否启用录波
|
||||
String datasourceId = FormalTestManager.currentTestPlan.getDatasourceId();
|
||||
if (datasourceId.contains(DataSourceEnum.WAVE_DATA.getValue())) {
|
||||
System.out.println("实时数据校验失败!》》》》》》》》》》》》》》》》》》》》》》》》》》》》》开始录波》》》》》》》》》》》》》》》》");
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue());
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
|
||||
// Set<String> delSet = new HashSet<>();
|
||||
// for (int i = 0; i < FormalTestManager.devList.size(); i++) {
|
||||
// PreDetection preDetection = FormalTestManager.devList.get(i);
|
||||
// List<PreDetection.MonitorListDTO> monitorList = preDetection.getMonitorList();
|
||||
// for (int j = monitorList.size() - 1; j >= 0; j--) {
|
||||
// String lineId = monitorList.get(j).getLineId();
|
||||
// String[] split = lineId.split(CnSocketUtil.SPLIT_TAG);
|
||||
// Integer res = result.get(FormalTestManager.devIdMapComm.get(split[1]));
|
||||
// if (res.equals(ResultEnum.NOT_QUALIFIED.getValue())) {
|
||||
// monitorList.remove(j);
|
||||
// delSet.add(lineId);
|
||||
// FormalTestManager.monitorMap.remove(lineId);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (int i = 0; i < FormalTestManager.standardDevList.size(); i++) {
|
||||
// PreDetection preDetection = FormalTestManager.standardDevList.get(i);
|
||||
// List<PreDetection.MonitorListDTO> monitorList = preDetection.getMonitorList();
|
||||
// for (int j = monitorList.size() - 1; j >= 0; j--) {
|
||||
// String lineId = monitorList.get(j).getLineId();
|
||||
// String s1 = FormalTestManager.pairsIpMap.inverse().get(lineId);
|
||||
// if (delSet.contains(s1)) {
|
||||
// monitorList.remove(j);
|
||||
// FormalTestManager.monitorMap.remove(lineId);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Set<String> delSet = new HashSet<>();
|
||||
for (int i = 0; i < FormalTestManager.devList.size(); i++) {
|
||||
PreDetection preDetection = FormalTestManager.devList.get(i);
|
||||
List<PreDetection.MonitorListDTO> monitorList = preDetection.getMonitorList();
|
||||
for (int j = monitorList.size() - 1; j >= 0; j--) {
|
||||
String lineId = monitorList.get(j).getLineId();
|
||||
String[] split = lineId.split(CnSocketUtil.SPLIT_TAG);
|
||||
Integer res = result.get(FormalTestManager.devIdMapComm.get(split[0]) + split[1]);
|
||||
if (ObjectUtil.isNotNull(res) && res.equals(ResultEnum.NOT_QUALIFIED.getValue())) {
|
||||
monitorList.remove(j);
|
||||
delSet.add(lineId);
|
||||
FormalTestManager.monitorMap.remove(lineId);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < FormalTestManager.standardDevList.size(); i++) {
|
||||
PreDetection preDetection = FormalTestManager.standardDevList.get(i);
|
||||
List<PreDetection.MonitorListDTO> monitorList = preDetection.getMonitorList();
|
||||
for (int j = monitorList.size() - 1; j >= 0; j--) {
|
||||
String lineId = monitorList.get(j).getLineId();
|
||||
String s1 = FormalTestManager.pairsIpMap.inverse().get(lineId);
|
||||
if (delSet.contains(s1)) {
|
||||
monitorList.remove(j);
|
||||
FormalTestManager.monitorMap.remove(lineId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<PreDetection> preDetectionList = new ArrayList<>();
|
||||
preDetectionList.addAll(FormalTestManager.devList);
|
||||
@@ -1012,9 +1010,11 @@ public class SocketContrastResponseService {
|
||||
// 最终将检测结果推送到前端
|
||||
webSend.setCode(SourceResponseCodeEnum.ALL_SUCCESS.getCode());//最终成功推送
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSend));
|
||||
// 修改设备状态
|
||||
|
||||
pqDevService.updateResult(true, param.getDevIds(), adTypes, code, param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
// 修改检测点状态、设备状态
|
||||
FormalTestManager.pairsIdMap.forEach((id1, id2) -> {
|
||||
pqMonitorService.updateMonitorResult(id1, adTypes, DataSourceEnum.REAL_DATA, FormalTestManager.numMap.get(id1), null, code);
|
||||
pqDevService.updateResult(id1.split(CnSocketUtil.SPLIT_TAG)[0], param.getUserId());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1190,9 +1190,15 @@ public class SocketContrastResponseService {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
||||
|
||||
List<String> adTypes = FormalTestManager.testItemMap.values().stream().collect(Collectors.toList());
|
||||
// 修改设备状态
|
||||
//pqDevService.updateResult(true, param.getDevIds(), adTypes, code, param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
|
||||
// 修改检测点状态、设备状态
|
||||
FormalTestManager.pairsIpMap.forEach((ip1, ip2) -> {
|
||||
if (FormalTestManager.monitorMap.containsKey(ip1)) {
|
||||
String[] split = ip1.split(CnSocketUtil.SPLIT_TAG);
|
||||
String id = FormalTestManager.devIdMapComm.get(split[0]);
|
||||
pqMonitorService.updateMonitorResult(id + CnSocketUtil.SPLIT_TAG + split[1], adTypes, DataSourceEnum.WAVE_DATA, FormalTestManager.numMap.get(id + CnSocketUtil.SPLIT_TAG + split[1]), FormalTestManager.waveNum, code);
|
||||
pqDevService.updateResult(id, param.getUserId());
|
||||
}
|
||||
});
|
||||
// 最终将检测结果推送到前端
|
||||
webSend.setCode(SourceResponseCodeEnum.ALL_SUCCESS.getCode());
|
||||
webSend.setData(JSON.toJSONString(FormalTestManager.preNumTestResultList));
|
||||
|
||||
@@ -1371,7 +1371,7 @@ public class SocketDevResponseService {
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(false, param.getDevIds(), valueType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
iPqDevService.updateResult( param.getDevIds(), valueType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
successComm.clear();
|
||||
|
||||
@@ -1741,6 +1741,9 @@ public class DetectionServiceImpl {
|
||||
result.setStdDevMonitorId(devIdMapComm.get(split2[0]) + "_" + split2[1]);
|
||||
result.setAdType(errSysDtls.get(0).getScriptType());
|
||||
result.setDataType(DataSourceEnum.REAL_DATA.getValue());
|
||||
if (ObjectUtil.isNotNull(waveNum)) {
|
||||
result.setDataType(DataSourceEnum.WAVE_DATA.getValue());
|
||||
}
|
||||
|
||||
if (map.containsKey(TYPE_T)) {
|
||||
List<DetectionData> tList = rangeComparisonList(map.get(TYPE_T).get(0), map.get(TYPE_T).get(1), errSysDtls, fData, scale, dataRule);
|
||||
@@ -1852,6 +1855,9 @@ public class DetectionServiceImpl {
|
||||
result.setStdDevMonitorId(devIdMapComm.get(split2[0]) + "_" + split2[1]);
|
||||
result.setAdType(errSysDtls.get(0).getScriptType());
|
||||
result.setDataType(DataSourceEnum.REAL_DATA.getValue());
|
||||
if (ObjectUtil.isNotNull(waveNum)) {
|
||||
result.setDataType(DataSourceEnum.WAVE_DATA.getValue());
|
||||
}
|
||||
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(devMap.get(TYPE_A).get(0), devMap.get(TYPE_A).get(1), errSysDtls, type, fData, scale, dataRule);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(devMap.get(TYPE_B).get(0), devMap.get(TYPE_A).get(1), errSysDtls, type, fData, scale, dataRule);
|
||||
|
||||
@@ -252,7 +252,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> adType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(false, param.getDevIds(), adType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
iPqDevService.updateResult(param.getDevIds(), adType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,9 +193,9 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
} else if (CnSocketUtil.SOURCE_TAG.equals(handlerType)) {
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
} else {
|
||||
if(FormalTestManager.currentStep==SourceOperateCodeEnum.RECORD_WAVE_STEP1 || FormalTestManager.currentStep==SourceOperateCodeEnum.RECORD_WAVE_STEP2){
|
||||
if (FormalTestManager.currentStep == SourceOperateCodeEnum.RECORD_WAVE_STEP1 || FormalTestManager.currentStep == SourceOperateCodeEnum.RECORD_WAVE_STEP2) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, true);
|
||||
}else{
|
||||
} else {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
} else if (FormalTestManager.currentStep != SourceOperateCodeEnum.QUITE) {
|
||||
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, true);
|
||||
} else {
|
||||
SocketManager.removeUser(preDetectionParam.getUserPageId());
|
||||
SocketManager.removeUser(preDetectionParam.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
|
||||
}
|
||||
} else {
|
||||
boolean channelActive = SocketManager.isChannelActive(preDetectionParam.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
|
||||
|
||||
@@ -108,7 +108,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
/**
|
||||
* 正式监测完成,修改中断状态
|
||||
*
|
||||
* @param isContrast
|
||||
* @param ids
|
||||
* @param adType
|
||||
* @param code
|
||||
@@ -117,7 +116,15 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param humidity
|
||||
* @return
|
||||
*/
|
||||
boolean updateResult(boolean isContrast, List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity);
|
||||
boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity);
|
||||
|
||||
/**
|
||||
* 比对式-修改设备状态
|
||||
*
|
||||
* @param devId
|
||||
* @param userId
|
||||
*/
|
||||
void updateResult(String devId,String userId);
|
||||
|
||||
void updatePqDevReportState(String devId, int i);
|
||||
|
||||
|
||||
@@ -434,11 +434,11 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateResult(boolean isContrast, List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity) {
|
||||
public boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
|
||||
SysTestConfig config = sysTestConfigService.getOneConfig();
|
||||
Map<String, Integer> result = detectionDataDealService.devResult(isContrast, ids, adType, code);
|
||||
Map<String, Integer> result = detectionDataDealService.devResult(false, ids, adType, code);
|
||||
List<PqDevVO> list = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
list.addAll(this.baseMapper.listByDevIds(ids));
|
||||
@@ -508,6 +508,39 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateResult(String devId, String userId) {
|
||||
PqDev dev = this.getById(devId);
|
||||
Integer checkState = pqMonitorService.getDevCheckState(devId);
|
||||
Integer checkResult = pqMonitorService.getDevCheckResult(devId);
|
||||
|
||||
pqDevSubService.lambdaUpdate()
|
||||
.set(PqDevSub::getCheckState, checkState)
|
||||
.set(PqDevSub::getCheckResult, checkResult)
|
||||
.eq(PqDevSub::getDevId, devId).update();
|
||||
|
||||
PqDevParam.QueryParam param = new PqDevParam.QueryParam();
|
||||
String planId = dev.getPlanId();
|
||||
param.setPlanIdList(Arrays.asList(planId));
|
||||
List<PqDevVO> pqDevVOList = this.baseMapper.selectByQueryParam(param);
|
||||
|
||||
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
||||
Set<Integer> set = pqDevVOList.stream().map(PqDevVO::getCheckResult).collect(Collectors.toSet());
|
||||
if (set.contains(CheckResultEnum.NOT_ACCORD.getValue())) {
|
||||
this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.NOT_ACCORD.getValue());
|
||||
} else if (set.contains(CheckResultEnum.UNCHECKED.getValue())) {
|
||||
this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.UNCHECKED.getValue());
|
||||
} else {
|
||||
this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.ACCORD.getValue());
|
||||
}
|
||||
|
||||
set = pqDevVOList.stream().map(PqDevVO::getCheckState).collect(Collectors.toSet());
|
||||
if (set.contains(CheckStateEnum.UNCHECKED.getValue())) {
|
||||
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKING.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePqDevReportState(String devId, int reportState) {
|
||||
LambdaUpdateWrapper<PqDevSub> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.njcn.gather.monitor.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -66,16 +68,45 @@ public class PqMonitor implements Serializable {
|
||||
/**
|
||||
* 实时数据结果 0:不合格,1:合格,2:未检
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer realtimeResult;
|
||||
|
||||
/**
|
||||
* 统计数据结果 0:不合格,1:合格,2:未检
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer statisticsResult;
|
||||
|
||||
/**
|
||||
* 录波数据结果 0:不合格,1:合格,2:未检
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer recordedResult;
|
||||
|
||||
/**
|
||||
* 实时数据使用哪一次的检测数据来表示结论
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String realtimeNum;
|
||||
|
||||
/**
|
||||
* 统计数据使用哪一次的检测数据来表示结论
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String statisticsNum;
|
||||
|
||||
/**
|
||||
* 录波数据使用哪一次、哪一组的检测数据来表示结论 例如 3_2,第三次检测第二组
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String recordedNum;
|
||||
|
||||
/**
|
||||
* 整个通道的结果使用那种数据。real、wave_data、statistics
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String resultType;
|
||||
|
||||
private Integer qualifiedNum; // 合格次数
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.njcn.gather.monitor.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -13,14 +15,13 @@ import java.util.List;
|
||||
public interface IPqMonitorService extends IService<PqMonitor> {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据设备id获取所有监测点信息
|
||||
*
|
||||
* @param devIds 被检设备id列表
|
||||
* @return 监测点信息列表
|
||||
*/
|
||||
List<PqMonitor> listPqMonitorByDevIds(List<String> devId);
|
||||
List<PqMonitor> listPqMonitorByDevIds(List<String> devIds);
|
||||
|
||||
/**
|
||||
* 根据设备id批量新增监测点信息
|
||||
@@ -72,6 +73,7 @@ public interface IPqMonitorService extends IService<PqMonitor> {
|
||||
|
||||
/**
|
||||
* 根据被检设备id获取额定电流
|
||||
*
|
||||
* @param devMonitorId 被检设备监测点id
|
||||
* @return 额定电流
|
||||
*/
|
||||
@@ -79,8 +81,34 @@ public interface IPqMonitorService extends IService<PqMonitor> {
|
||||
|
||||
/**
|
||||
* 根据被检设备id获取额定电压
|
||||
*
|
||||
* @param devMonitorId 被检设备监测点id
|
||||
* @return 额定电压
|
||||
*/
|
||||
Double getRatedVoltage(String devMonitorId);
|
||||
|
||||
/**
|
||||
* @param monitorId 监测点id
|
||||
* @param adTypes 检测项指标id列表
|
||||
* @param dataSourceEnum 那种数据源
|
||||
* @param code 结果表后缀
|
||||
* @return
|
||||
*/
|
||||
boolean updateMonitorResult(String monitorId, List<String> adTypes, DataSourceEnum dataSourceEnum, Integer num, Integer waveNum, String code);
|
||||
|
||||
/**
|
||||
* 查询设备的检测状态
|
||||
*
|
||||
* @param devId
|
||||
* @return
|
||||
*/
|
||||
Integer getDevCheckState(String devId);
|
||||
|
||||
/**
|
||||
* 查询设备的检测结果
|
||||
*
|
||||
* @param devId
|
||||
* @return
|
||||
*/
|
||||
Integer getDevCheckResult(String devId);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,17 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.device.pojo.enums.CheckResultEnum;
|
||||
import com.njcn.gather.device.pojo.enums.CheckStateEnum;
|
||||
import com.njcn.gather.monitor.mapper.PqMonitorMapper;
|
||||
import com.njcn.gather.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.storage.service.impl.DetectionDataServiceImpl;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -19,7 +25,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -31,6 +39,7 @@ import java.util.List;
|
||||
public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor> implements IPqMonitorService {
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
private final DetectionDataDealService detectionDataDealService;
|
||||
|
||||
@Override
|
||||
public List<PqMonitor> listPqMonitorByDevIds(List<String> devIds) {
|
||||
@@ -121,4 +130,121 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
}
|
||||
throw new BusinessException(DetectionResponseEnum.RATED_PT_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateMonitorResult(String monitorId, List<String> adTypes, DataSourceEnum dataSourceEnum, Integer num, Integer waveNum, String code) {
|
||||
Integer newMonitorResult = detectionDataDealService.getMonitorResult(monitorId, adTypes, dataSourceEnum.getValue(), num, waveNum, code);
|
||||
String[] split = monitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pq_monitor.Dev_Id", split[0])
|
||||
.eq("pq_monitor.Num", split[1])
|
||||
.last("LIMIT 1");
|
||||
PqMonitor monitor = this.getOne(wrapper);
|
||||
String resultType = monitor.getResultType();
|
||||
Integer qualifiedNum = monitor.getQualifiedNum();
|
||||
boolean updateFlag = false;
|
||||
|
||||
if (StrUtil.isBlank(resultType)) {
|
||||
updateFlag = true;
|
||||
if (CheckResultEnum.ACCORD.getValue().equals(newMonitorResult)) {
|
||||
qualifiedNum += 1;
|
||||
}
|
||||
} else {
|
||||
Integer oldMonitorResult = null;
|
||||
if (DataSourceEnum.REAL_DATA.getValue().equals(resultType)) {
|
||||
oldMonitorResult = monitor.getRealtimeResult();
|
||||
} else if (DataSourceEnum.WAVE_DATA.getValue().equals(resultType)) {
|
||||
oldMonitorResult = monitor.getRecordedResult();
|
||||
} else {
|
||||
oldMonitorResult = monitor.getStatisticsResult();
|
||||
}
|
||||
|
||||
if (CheckResultEnum.ACCORD.getValue().equals(oldMonitorResult)) {
|
||||
if (CheckResultEnum.ACCORD.getValue().equals(newMonitorResult)) {
|
||||
qualifiedNum += 1;
|
||||
updateFlag = true;
|
||||
}
|
||||
} else {
|
||||
updateFlag = true;
|
||||
if (CheckResultEnum.ACCORD.getValue().equals(newMonitorResult)) {
|
||||
qualifiedNum += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateFlag) {
|
||||
monitor.setResultType(dataSourceEnum.getValue());
|
||||
|
||||
if (DataSourceEnum.REAL_DATA.getValue().equals(dataSourceEnum.getValue())) {
|
||||
monitor.setRealtimeResult(newMonitorResult);
|
||||
monitor.setRealtimeNum(String.valueOf(num));
|
||||
} else if (DataSourceEnum.WAVE_DATA.getValue().equals(dataSourceEnum.getValue())) {
|
||||
monitor.setRecordedResult(newMonitorResult);
|
||||
monitor.setRecordedNum(num + CnSocketUtil.SPLIT_TAG + waveNum);
|
||||
} else {
|
||||
monitor.setStatisticsResult(newMonitorResult);
|
||||
monitor.setStatisticsNum(String.valueOf(num));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(resultType) && !resultType.equals(dataSourceEnum.getValue())) {
|
||||
if (DataSourceEnum.REAL_DATA.getValue().equals(resultType)) {
|
||||
monitor.setRealtimeResult(null);
|
||||
monitor.setRealtimeNum(null);
|
||||
} else if (DataSourceEnum.WAVE_DATA.getValue().equals(resultType)) {
|
||||
monitor.setRecordedResult(null);
|
||||
monitor.setRecordedNum(null);
|
||||
} else {
|
||||
monitor.setStatisticsResult(null);
|
||||
monitor.setStatisticsNum(null);
|
||||
}
|
||||
}
|
||||
monitor.setQualifiedNum(qualifiedNum);
|
||||
}
|
||||
|
||||
return this.updateById(monitor);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getDevCheckState(String devId) {
|
||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pq_monitor.Dev_Id", devId);
|
||||
List<PqMonitor> monitorList = this.list(wrapper);
|
||||
if (CollUtil.isNotEmpty(monitorList)) {
|
||||
List<Integer> allNumList = monitorList.stream().map(PqMonitor::getNum).collect(Collectors.toList());
|
||||
List<Integer> checkedNumList = monitorList.stream().filter(obj -> ObjectUtil.isNotNull(obj.getResultType())).map(PqMonitor::getNum).collect(Collectors.toList());
|
||||
|
||||
if (checkedNumList.containsAll(allNumList)) {
|
||||
return CheckStateEnum.CHECKED.getValue();
|
||||
} else {
|
||||
if (checkedNumList.size() > 0) {
|
||||
return CheckStateEnum.CHECKING.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return CheckStateEnum.UNCHECKED.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDevCheckResult(String devId) {
|
||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pq_monitor.Dev_Id", devId);
|
||||
List<PqMonitor> monitorList = this.list(wrapper);
|
||||
|
||||
List<Integer> allResultFlags = new ArrayList<>();
|
||||
for (PqMonitor monitor : monitorList) {
|
||||
String resultType = monitor.getResultType();
|
||||
if (StrUtil.isNotBlank(resultType)) {
|
||||
if (DataSourceEnum.REAL_DATA.getValue().equals(resultType)) {
|
||||
allResultFlags.add(monitor.getRealtimeResult());
|
||||
} else if (DataSourceEnum.WAVE_DATA.getValue().equals(resultType)) {
|
||||
allResultFlags.add(monitor.getRecordedResult());
|
||||
} else {
|
||||
allResultFlags.add(monitor.getStatisticsResult());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DetectionDataServiceImpl.isResultFlag(allResultFlags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,10 @@ import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
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.result.pojo.vo.ContrastResultVO;
|
||||
import com.njcn.gather.detection.service.IAdPariService;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.result.pojo.param.ResultParam;
|
||||
import com.njcn.gather.result.pojo.vo.FormContentVO;
|
||||
import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
import com.njcn.gather.result.pojo.vo.*;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
@@ -26,6 +23,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -151,4 +149,29 @@ public class ResultController extends BaseController {
|
||||
ContrastResultVO result = resultService.getContrastResult(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getMonitorResult")
|
||||
@ApiOperation("获取监测点的检测结果")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<MonitorResultVO> getMonitorResult(@RequestParam("devId") String devId) {
|
||||
String methodDescribe = getMethodDescribe("getMonitorResult");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, devId);
|
||||
|
||||
MonitorResultVO result = resultService.getMonitorResult(devId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getMonitorDataSourceResult")
|
||||
@ApiOperation("获取监测点的检测结果下拉框")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Map<Integer, DataSourceResultVO>> getMonitorDataSourceResult(@RequestParam("monitorId") String monitorId) {
|
||||
String methodDescribe = getMethodDescribe("getMonitorDataSourceResult");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, monitorId);
|
||||
|
||||
Map<Integer, DataSourceResultVO> result = resultService.getMonitorDataSourceResult(monitorId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.gather.result.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-09-12
|
||||
*/
|
||||
@Data
|
||||
public class DataSourceResultVO {
|
||||
|
||||
/**
|
||||
* 通道所使用的数据源名称
|
||||
*/
|
||||
private String dataSourceName;
|
||||
|
||||
/**
|
||||
* 通道所使用的数据源code
|
||||
*/
|
||||
private String dataSourceCode;
|
||||
|
||||
/**
|
||||
* 通道检测结果
|
||||
*/
|
||||
private Integer checkResult;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.gather.result.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-09-10
|
||||
*/
|
||||
@Data
|
||||
public class MonitorResultVO {
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
*/
|
||||
private Integer monitorId;
|
||||
|
||||
/**
|
||||
* 监测点序号
|
||||
*/
|
||||
private Integer monitorNum;
|
||||
|
||||
/**
|
||||
* 总检测次数
|
||||
*/
|
||||
private Integer totalNum;
|
||||
|
||||
/**
|
||||
* 合格检测次数
|
||||
*/
|
||||
private Integer qualifiedNum;
|
||||
|
||||
/**
|
||||
* 不合格检测次数
|
||||
*/
|
||||
private Integer unQualifiedNum;
|
||||
|
||||
/**
|
||||
* 误差体系名称
|
||||
*/
|
||||
private String errorSysName;
|
||||
|
||||
/**
|
||||
* 检测结果
|
||||
*/
|
||||
private Integer checkResult;
|
||||
|
||||
/**
|
||||
* 结论来源
|
||||
*/
|
||||
private String resultOrigin;
|
||||
}
|
||||
@@ -2,10 +2,7 @@ package com.njcn.gather.result.service;
|
||||
|
||||
import com.njcn.gather.report.pojo.result.SingleTestResult;
|
||||
import com.njcn.gather.result.pojo.param.ResultParam;
|
||||
import com.njcn.gather.result.pojo.vo.ContrastResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.FormContentVO;
|
||||
import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
import com.njcn.gather.result.pojo.vo.*;
|
||||
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -116,4 +113,8 @@ public interface IResultService {
|
||||
*/
|
||||
ContrastResultVO getContrastResult(ResultParam.QueryParam queryParam);
|
||||
|
||||
|
||||
MonitorResultVO getMonitorResult(String devId);
|
||||
|
||||
Map<Integer, DataSourceResultVO> getMonitorDataSourceResult(String monitorId);
|
||||
}
|
||||
|
||||
@@ -1636,6 +1636,18 @@ public class ResultServiceImpl implements IResultService {
|
||||
return contrastResultVO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MonitorResultVO getMonitorResult(String devId) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, DataSourceResultVO> getMonitorDataSourceResult(String monitorId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
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<>();
|
||||
|
||||
@@ -1999,7 +2011,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(false, param.getDevIds(), valueType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.njcn.gather.storage.service;
|
||||
|
||||
import com.njcn.db.mybatisplus.service.IReplenishMybatisService;
|
||||
import com.njcn.gather.storage.pojo.po.BaseResult;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -12,14 +10,13 @@ import java.util.Map;
|
||||
public interface DetectionDataDealService extends IReplenishMybatisService<SimAndDigHarmonicResult> {
|
||||
|
||||
|
||||
Boolean acceptNonHarmonic(List<? extends BaseResult> nonHarmonicResultList, String code);
|
||||
|
||||
Boolean acceptNonHarmonic(List<? extends BaseResult> nonHarmonicResultList,String code);
|
||||
|
||||
Boolean acceptHarmonic(List<? extends BaseResult> harmonicResultList,String code);
|
||||
Boolean acceptHarmonic(List<? extends BaseResult> harmonicResultList, String code);
|
||||
|
||||
Boolean acceptNonHarmonicResult(List<? extends BaseResult> nonHarmonicResultList, String code);
|
||||
|
||||
Boolean acceptHarmonicResult(List<? extends BaseResult> SimAndDigHarmonicResultList,String code);
|
||||
Boolean acceptHarmonicResult(List<? extends BaseResult> SimAndDigHarmonicResultList, String code);
|
||||
|
||||
/**
|
||||
* 根据终端id查询终端所有监测项目是否合格
|
||||
@@ -30,5 +27,18 @@ public interface DetectionDataDealService extends IReplenishMybatisService<SimAn
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
Map<String,Integer> devResult(boolean isContrast,List<String> ids,List<String> adType,String code);
|
||||
Map<String, Integer> devResult(boolean isContrast, List<String> ids, List<String> adType, String code);
|
||||
|
||||
/**
|
||||
* 获取检测点的检测结果
|
||||
*
|
||||
* @param monitorId
|
||||
* @param adTypes
|
||||
* @param dataSource
|
||||
* @param num
|
||||
* @param waveNum
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
Integer getMonitorResult(String monitorId, List<String> adTypes, String dataSource, Integer num, Integer waveNum, String code);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.storage.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.db.mybatisplus.service.impl.ReplenishMybatisServiceImpl;
|
||||
@@ -206,19 +207,50 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
|
||||
Map<String, List<Integer>> harmMap = harm.stream().collect(Collectors.groupingBy(x -> x.getDevMonitorId().split("_")[0],
|
||||
Collectors.mapping(BaseResult::getResultFlag, Collectors.toList())));
|
||||
for (String id : ids) {
|
||||
String s = id.split("_")[0];
|
||||
List<Integer> resultFlags = new ArrayList<>();
|
||||
if (noHarmMap.containsKey(id)) {
|
||||
resultFlags.addAll(noHarmMap.get(id));
|
||||
if (noHarmMap.containsKey(s)) {
|
||||
resultFlags.addAll(noHarmMap.get(s));
|
||||
}
|
||||
if (harmMap.containsKey(id)) {
|
||||
resultFlags.addAll(harmMap.get(id));
|
||||
if (harmMap.containsKey(s)) {
|
||||
resultFlags.addAll(harmMap.get(s));
|
||||
}
|
||||
map.put(id, isResultFlag(resultFlags));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Integer isResultFlag(List<Integer> resultFlags) {
|
||||
@Override
|
||||
public Integer getMonitorResult(String monitorId, List<String> adTypes, String dataSource, Integer num, Integer waveNum, String code) {
|
||||
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
||||
LambdaQueryWrapper<ContrastNonHarmonicResult> wrapper1 = new LambdaQueryWrapper<ContrastNonHarmonicResult>()
|
||||
.like(ContrastNonHarmonicResult::getDevMonitorId, monitorId)
|
||||
.in(CollUtil.isNotEmpty(adTypes), ContrastNonHarmonicResult::getAdType, adTypes)
|
||||
.eq(ContrastNonHarmonicResult::getDataType, dataSource)
|
||||
.eq(ContrastNonHarmonicResult::getNum, num)
|
||||
.eq(ObjectUtil.isNotEmpty(waveNum), ContrastNonHarmonicResult::getWaveNum, waveNum);
|
||||
|
||||
List<ContrastNonHarmonicResult> nonHarmonicResultList = contrastNonHarmonicService.list(wrapper1);
|
||||
DynamicTableNameHandler.remove();
|
||||
|
||||
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
|
||||
LambdaQueryWrapper<ContrastHarmonicResult> wrapper2 = new LambdaQueryWrapper<ContrastHarmonicResult>()
|
||||
.like(ContrastHarmonicResult::getDevMonitorId, monitorId)
|
||||
.in(CollUtil.isNotEmpty(adTypes), ContrastHarmonicResult::getAdType, adTypes)
|
||||
.eq(ContrastHarmonicResult::getDataType, dataSource)
|
||||
.eq(ContrastHarmonicResult::getNum, num)
|
||||
.eq(ObjectUtil.isNotEmpty(waveNum), ContrastHarmonicResult::getWaveNum, waveNum);
|
||||
|
||||
List<ContrastHarmonicResult> harmonicResultList = contrastHarmonicService.list(wrapper2);
|
||||
DynamicTableNameHandler.remove();
|
||||
|
||||
List<Integer> resultFlagList = nonHarmonicResultList.stream().map(ContrastNonHarmonicResult::getResultFlag).collect(Collectors.toList());
|
||||
resultFlagList.addAll(harmonicResultList.stream().map(ContrastHarmonicResult::getResultFlag).collect(Collectors.toList()));
|
||||
|
||||
return isResultFlag(resultFlagList);
|
||||
}
|
||||
|
||||
public static Integer isResultFlag(List<Integer> resultFlags) {
|
||||
// 检测结果(0:不符合 1:符合 2:/[未检测无结果])
|
||||
//脚本结果是 1.符合 2.不符合 4.未检测无结果 5.不参与误差比较
|
||||
resultFlags = resultFlags.stream().filter(x -> 4 != x && 5 != x).distinct().collect(Collectors.toList());
|
||||
|
||||
Reference in New Issue
Block a user