Compare commits
10 Commits
2025-12
...
ef757c52ea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef757c52ea | ||
|
|
4110a835c8 | ||
|
|
e78ce544e3 | ||
|
|
c10d54e79a | ||
|
|
2796558040 | ||
|
|
920a808729 | ||
|
|
8e24ac4b71 | ||
|
|
3eb2736edb | ||
|
|
8c3eba9224 | ||
|
|
6288aa565e |
@@ -10,6 +10,7 @@ import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
|||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||||
import com.njcn.gather.detection.service.PreDetectionService;
|
import com.njcn.gather.detection.service.PreDetectionService;
|
||||||
|
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import com.njcn.web.utils.HttpResultUtil;
|
import com.njcn.web.utils.HttpResultUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -155,4 +156,47 @@ public class PreDetectionController extends BaseController {
|
|||||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||||
preDetectionService.exportAlignData();
|
preDetectionService.exportAlignData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@GetMapping("/canCoefficient")
|
||||||
|
@ApiOperation("比对模式是否能够进行系数校验")
|
||||||
|
public HttpResult<Boolean> canCoefficient() {
|
||||||
|
String methodDescribe = getMethodDescribe("canCoefficient");
|
||||||
|
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||||
|
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, preDetectionService.getCanCoefficient(), methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@GetMapping("/startCoefficient")
|
||||||
|
@ApiOperation("比对模式开启系数校验")
|
||||||
|
public HttpResult<String> startCoefficient() {
|
||||||
|
String methodDescribe = getMethodDescribe("startCoefficient");
|
||||||
|
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||||
|
|
||||||
|
preDetectionService.startCoefficient();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@GetMapping("/startFreqConverter")
|
||||||
|
@ApiOperation("开启变频器测试")
|
||||||
|
public HttpResult<String> startFreqConverter(@RequestParam("loginName") String loginName, @RequestParam("converterId") String converterId, @RequestParam("monitorId") String monitorId) {
|
||||||
|
String methodDescribe = getMethodDescribe("startFreqConverter");
|
||||||
|
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||||
|
|
||||||
|
preDetectionService.startFreqConverter(loginName, converterId, monitorId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@GetMapping("/stopFreqConverter")
|
||||||
|
@ApiOperation("关闭变频器测试")
|
||||||
|
public HttpResult<String> stopFreqConverter(@RequestParam("loginName") String loginName) {
|
||||||
|
String methodDescribe = getMethodDescribe("stopFreqConverter");
|
||||||
|
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||||
|
|
||||||
|
preDetectionService.stopFreqConverter(loginName + CnSocketUtil.FREQ_CONVERTER_TAG, loginName + CnSocketUtil.DEV_TAG);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.gather.detection.pojo.dto.DevXiNumData;
|
||||||
import com.njcn.gather.detection.pojo.dto.WaveCommandDTO;
|
import com.njcn.gather.detection.pojo.dto.WaveCommandDTO;
|
||||||
import com.njcn.gather.detection.pojo.dto.WaveResultDTO;
|
import com.njcn.gather.detection.pojo.dto.WaveResultDTO;
|
||||||
import com.njcn.gather.detection.pojo.enums.*;
|
import com.njcn.gather.detection.pojo.enums.*;
|
||||||
@@ -24,15 +26,17 @@ import com.njcn.gather.detection.pojo.vo.*;
|
|||||||
import com.njcn.gather.detection.service.IAdPariService;
|
import com.njcn.gather.detection.service.IAdPariService;
|
||||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||||
import com.njcn.gather.detection.util.DetectionUtil;
|
import com.njcn.gather.detection.util.DetectionUtil;
|
||||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
import com.njcn.gather.detection.util.socket.*;
|
||||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
|
||||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
|
||||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord;
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
|
import com.njcn.gather.device.service.IPqStandardDevGainRecordService;
|
||||||
|
import com.njcn.gather.device.service.IPqStandardDevGainService;
|
||||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||||
|
import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
||||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||||
import com.njcn.gather.plan.service.IAdPlanService;
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
@@ -62,6 +66,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
@@ -92,6 +97,8 @@ public class SocketContrastResponseService {
|
|||||||
private final IAdPariService adPairService;
|
private final IAdPariService adPairService;
|
||||||
private final ICompareWaveService compareWaveService;
|
private final ICompareWaveService compareWaveService;
|
||||||
private final IAdPlanTestConfigService adPlanTestConfigService;
|
private final IAdPlanTestConfigService adPlanTestConfigService;
|
||||||
|
private final IPqStandardDevGainService pqStandardDevGainService;
|
||||||
|
private final IPqStandardDevGainRecordService pqStandardDevGainRecordService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,6 +192,7 @@ public class SocketContrastResponseService {
|
|||||||
FormalTestManager.isXu = param.getPhaseCheck() == 1 ? true : false;
|
FormalTestManager.isXu = param.getPhaseCheck() == 1 ? true : false;
|
||||||
// FormalTestManager.isXu = true;
|
// FormalTestManager.isXu = true;
|
||||||
FormalTestManager.nonWaveDataSourceEnum = null;
|
FormalTestManager.nonWaveDataSourceEnum = null;
|
||||||
|
DetectionServiceImpl.vAndIResultMap = new HashMap<>();
|
||||||
|
|
||||||
String[] datasourceIds = FormalTestManager.currentTestPlan.getDatasourceId().split(",");
|
String[] datasourceIds = FormalTestManager.currentTestPlan.getDatasourceId().split(",");
|
||||||
for (String datasourceId : datasourceIds) {
|
for (String datasourceId : datasourceIds) {
|
||||||
@@ -377,6 +385,10 @@ public class SocketContrastResponseService {
|
|||||||
case RECORD_WAVE_STEP1:
|
case RECORD_WAVE_STEP1:
|
||||||
this.recordWave(param, socketDataMsg);
|
this.recordWave(param, socketDataMsg);
|
||||||
break;
|
break;
|
||||||
|
//系数校验
|
||||||
|
case Coefficient_Check:
|
||||||
|
this.coefficient(param, socketDataMsg);
|
||||||
|
break;
|
||||||
//退出关闭
|
//退出关闭
|
||||||
case QUITE:
|
case QUITE:
|
||||||
quitDeal(socketDataMsg, param);
|
quitDeal(socketDataMsg, param);
|
||||||
@@ -1405,6 +1417,28 @@ public class SocketContrastResponseService {
|
|||||||
pqDevService.updateResult(id1.split(CnSocketUtil.SPLIT_TAG)[0], param.getUserId());
|
pqDevService.updateResult(id1.split(CnSocketUtil.SPLIT_TAG)[0], param.getUserId());
|
||||||
});
|
});
|
||||||
FormalTestManager.isTesting = false;
|
FormalTestManager.isTesting = false;
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(DetectionServiceImpl.vAndIResultMap)) {
|
||||||
|
// 是否进行系数校准
|
||||||
|
//万一录波了这里就进不来了,但是在误差处理的时候DetectionServiceImpl.vAndIResultMap该集合会保留不符合的结果
|
||||||
|
|
||||||
|
XiNumberManager.xiDevList.clear();
|
||||||
|
XiNumberManager.devXiNumDataMap.clear();
|
||||||
|
List<String> stdIpList = DetectionServiceImpl.vAndIResultMap.values().stream().map(DetectionServiceImpl.VAndIResult::getIp).collect(Collectors.toList());
|
||||||
|
XiNumberManager.xiDevList = FormalTestManager.standardDevList.stream().filter(d -> stdIpList.contains(d.getDevIP())).collect(Collectors.toList());
|
||||||
|
// 逐一设备向通讯模块要原始系数
|
||||||
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
|
||||||
|
PreDetection preDetection = XiNumberManager.xiDevList.get(0);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("devIP", preDetection.getDevIP());
|
||||||
|
map.put("chnNum", preDetection.getDevChns());
|
||||||
|
socketMsg.setData(JSON.toJSONString(map));
|
||||||
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(socketMsg));
|
||||||
|
|
||||||
|
FormalTestManager.currentStep = SourceOperateCodeEnum.Coefficient_Check;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 配对关系入库
|
// 配对关系入库
|
||||||
@@ -1682,6 +1716,160 @@ public class SocketContrastResponseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void coefficient(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||||
|
SourceOperateCodeEnum sourceOperateCodeEnum = SourceOperateCodeEnum.getDictDataEnumByCode(socketDataMsg.getOperateCode());
|
||||||
|
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||||
|
SocketMsg<String> xiSocket = new SocketMsg<>();
|
||||||
|
xiSocket.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||||
|
|
||||||
|
switch (Objects.requireNonNull(sourceOperateCodeEnum)) {
|
||||||
|
case DATA_CHNFACTOR$01:
|
||||||
|
//获取系数
|
||||||
|
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||||
|
case SUCCESS:
|
||||||
|
if (CollUtil.isNotEmpty(XiNumberManager.xiDevList)) {
|
||||||
|
List<DevXiNumData.GF> gfList = JSON.parseArray(socketDataMsg.getData(), DevXiNumData.GF.class);
|
||||||
|
DevXiNumData devXiNumData = new DevXiNumData();
|
||||||
|
String ip = XiNumberManager.xiDevList.get(0).getDevIP();
|
||||||
|
devXiNumData.setDevIP(ip);
|
||||||
|
//String stdMonitorId = DetectionServiceImpl.vAndIResultMap.keySet().stream().filter(key -> key.contains(ip)).findFirst().get();
|
||||||
|
|
||||||
|
List<PqStandardDevGain> pqStandardDevGainList = new ArrayList<>();
|
||||||
|
List<PqStandardDevGainRecord> recordList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < gfList.size(); i++) {
|
||||||
|
DevXiNumData.GF gf = gfList.get(i);
|
||||||
|
String stdDevMonitorId = FormalTestManager.devIdMapComm.get(ip) + CnSocketUtil.SPLIT_TAG + (gf.getUMonitorPoint() + 1);
|
||||||
|
String devMonitorId = FormalTestManager.pairsIdMap.inverse().get(stdDevMonitorId);
|
||||||
|
PqStandardDevGain pqStandardDevGain = new PqStandardDevGain();
|
||||||
|
pqStandardDevGain.setStdDevMonitorId(stdDevMonitorId);
|
||||||
|
|
||||||
|
DevXiNumData.F f = gf.getF();
|
||||||
|
pqStandardDevGain.setUaGain(f.getUa_gain());
|
||||||
|
pqStandardDevGain.setUbGain(f.getUb_gain());
|
||||||
|
pqStandardDevGain.setUcGain(f.getUc_gain());
|
||||||
|
pqStandardDevGain.setU0Gain(f.getU0_gain());
|
||||||
|
pqStandardDevGain.setIaGain(f.getIa_gain());
|
||||||
|
pqStandardDevGain.setIbGain(f.getIb_gain());
|
||||||
|
pqStandardDevGain.setIcGain(f.getIc_gain());
|
||||||
|
pqStandardDevGain.setI0Gain(f.getI0_gain());
|
||||||
|
pqStandardDevGain.setUabGain(f.getUab_gain());
|
||||||
|
pqStandardDevGain.setUbcGain(f.getUbc_gain());
|
||||||
|
pqStandardDevGain.setUcaGain(f.getUca_gain());
|
||||||
|
pqStandardDevGain.setState(DataStateEnum.ENABLE.getCode());
|
||||||
|
pqStandardDevGainList.add(pqStandardDevGain);
|
||||||
|
DetectionServiceImpl.VAndIResult vAndIResult = DetectionServiceImpl.vAndIResultMap.get(ip + CnSocketUtil.SPLIT_TAG + (gf.getUMonitorPoint() + 1));
|
||||||
|
if (ObjectUtil.isNotNull(vAndIResult)) {
|
||||||
|
int maxNum = pqStandardDevGainRecordService.getMaxNum(stdDevMonitorId, devMonitorId);
|
||||||
|
PqStandardDevGainRecord record = new PqStandardDevGainRecord();
|
||||||
|
record.setStdDevMonitorId(stdDevMonitorId);
|
||||||
|
record.setDevMonitorId(devMonitorId);
|
||||||
|
record.setNum(maxNum + 1);
|
||||||
|
recordList.add(record);
|
||||||
|
updateGfList(f, vAndIResult, stdDevMonitorId, maxNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$02.getValue());
|
||||||
|
devXiNumData.setGf(gfList);
|
||||||
|
xiSocket.setData(JSON.toJSONString(devXiNumData));
|
||||||
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(xiSocket));
|
||||||
|
|
||||||
|
// 原始系数入库
|
||||||
|
pqStandardDevGainService.add(pqStandardDevGainList);
|
||||||
|
pqStandardDevGainRecordService.addOrUpdate(recordList);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case UNPROCESSED_BUSINESS:
|
||||||
|
break;
|
||||||
|
case NORMAL_RESPONSE:
|
||||||
|
break;
|
||||||
|
case DATA_RESOLVE:
|
||||||
|
break;
|
||||||
|
case COMMUNICATION_ERR:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case DATA_CHNFACTOR$02:
|
||||||
|
//系数下发后的响应
|
||||||
|
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||||
|
case SUCCESS:
|
||||||
|
//单台装置系数下发后,需要删除集合中存在的当前装置
|
||||||
|
XiNumberManager.xiDevList.remove(0);
|
||||||
|
//继续下发每台装置系数,只到集合为空
|
||||||
|
if (CollUtil.isNotEmpty(XiNumberManager.xiDevList)) {
|
||||||
|
xiSocket.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
|
||||||
|
xiSocket.setData(JSON.toJSONString(XiNumberManager.devXiNumDataMap.get(XiNumberManager.xiDevList.get(0))));
|
||||||
|
PreDetection preDetection = XiNumberManager.xiDevList.get(0);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("devIP", preDetection.getDevIP());
|
||||||
|
map.put("chnNum", preDetection.getDevChns());
|
||||||
|
xiSocket.setData(JSON.toJSONString(map));
|
||||||
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(xiSocket));
|
||||||
|
} else {
|
||||||
|
//{"requestId":"Coefficient_Check","operateCode":"DATA_CHNFACTOR$02","data":"end","code":10200}
|
||||||
|
// 通知前端全部下发系数完成
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case UNPROCESSED_BUSINESS:
|
||||||
|
break;
|
||||||
|
case NORMAL_RESPONSE:
|
||||||
|
break;
|
||||||
|
case DATA_RESOLVE:
|
||||||
|
//quitSend(param);
|
||||||
|
break;
|
||||||
|
case COMMUNICATION_ERR:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// case DEV_DATA_REQUEST_02:
|
||||||
|
// //实时采集申请
|
||||||
|
// String data = socketDataMsg.getData();
|
||||||
|
// DevData devData = JSON.parseObject(data, DevData.class);
|
||||||
|
// if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||||
|
// switch (dictDataEnumByCode) {
|
||||||
|
// case SUCCESS:
|
||||||
|
// if (devData.getResult()) {
|
||||||
|
// FormalTestManager.realDataXiList.add(devData);
|
||||||
|
// successComm.add(devData.getId());
|
||||||
|
// System.out.println(successComm.size() + " ==" + FormalTestManager.monitorIdListComm.size() + "FormalTestManager.realDataXiList:" + FormalTestManager.realDataXiList.size() + "当前步骤" + XiNumberManager.stepNumber);
|
||||||
|
// if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||||
|
// processData(param, xiSocket);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// System.out.println("系数校准抛除数据" + devData);
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// case UNPROCESSED_BUSINESS:
|
||||||
|
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
|
// break;
|
||||||
|
// case NORMAL_RESPONSE:
|
||||||
|
// if (devData.getResult()) {
|
||||||
|
// FormalTestManager.realDataXiList.add(devData);
|
||||||
|
// } else {
|
||||||
|
// System.out.println("系数校准抛除数据" + devData);
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// xiSocket.setRequestId(socketDataMsg.getRequestId());
|
||||||
|
// xiSocket.setOperateCode(socketDataMsg.getOperateCode());
|
||||||
|
// xiSocket.setData(dictDataEnumByCode.getMessage());
|
||||||
|
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(xiSocket));
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
WebServiceManager.sendUnknownErrorMessage(param.getUserPageId());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出检测返回
|
* 退出检测返回
|
||||||
@@ -1856,13 +2044,13 @@ public class SocketContrastResponseService {
|
|||||||
*/
|
*/
|
||||||
private Integer getTargetCount() {
|
private Integer getTargetCount() {
|
||||||
if (FormalTestManager.isPstData) {
|
if (FormalTestManager.isPstData) {
|
||||||
return FormalTestManager.curretntTestPlanConfig.getFlicker();
|
return FormalTestManager.curretntTestPlanConfig.getFlicker() * 2;
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
||||||
if (FormalTestManager.nonWaveDataSourceEnum == DataSourceEnum.REAL_DATA) {
|
if (FormalTestManager.nonWaveDataSourceEnum == DataSourceEnum.REAL_DATA) {
|
||||||
return FormalTestManager.curretntTestPlanConfig.getRealTime();
|
return FormalTestManager.curretntTestPlanConfig.getRealTime() * 2;
|
||||||
} else {
|
} else {
|
||||||
return FormalTestManager.curretntTestPlanConfig.getStatistics();
|
return FormalTestManager.curretntTestPlanConfig.getStatistics() * 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1948,8 +2136,13 @@ public class SocketContrastResponseService {
|
|||||||
isStar = true;
|
isStar = true;
|
||||||
isDelta = false;
|
isDelta = false;
|
||||||
} else {
|
} else {
|
||||||
isStar = false;
|
if (DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection())) {
|
||||||
isDelta = true;
|
isStar = true;
|
||||||
|
isDelta = false;
|
||||||
|
} else {
|
||||||
|
isStar = false;
|
||||||
|
isDelta = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2052,8 +2245,13 @@ public class SocketContrastResponseService {
|
|||||||
isStar = true;
|
isStar = true;
|
||||||
isDelta = false;
|
isDelta = false;
|
||||||
} else {
|
} else {
|
||||||
isStar = false;
|
if (DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection())) {
|
||||||
isDelta = true;
|
isStar = true;
|
||||||
|
isDelta = false;
|
||||||
|
} else {
|
||||||
|
isStar = false;
|
||||||
|
isDelta = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2273,8 +2471,13 @@ public class SocketContrastResponseService {
|
|||||||
isStar = true;
|
isStar = true;
|
||||||
isDelta = false;
|
isDelta = false;
|
||||||
} else {
|
} else {
|
||||||
isStar = false;
|
if (DetectionCodeEnum.STAR.getCode().equals(monitorListDTO.getConnection())) {
|
||||||
isDelta = true;
|
isStar = true;
|
||||||
|
isDelta = false;
|
||||||
|
} else {
|
||||||
|
isStar = false;
|
||||||
|
isDelta = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2592,18 +2795,30 @@ public class SocketContrastResponseService {
|
|||||||
devInfo = pqDevService.getDevInfo(Collections.singletonList(devId));
|
devInfo = pqDevService.getDevInfo(Collections.singletonList(devId));
|
||||||
}
|
}
|
||||||
Integer usePhaseIndex = devInfo.get(0).getUsePhaseIndex();
|
Integer usePhaseIndex = devInfo.get(0).getUsePhaseIndex();
|
||||||
|
|
||||||
List<String> allDesc = data.getSqlData().stream().map(x -> x.getDesc()).collect(Collectors.toList());
|
List<String> allDesc = data.getSqlData().stream().map(x -> x.getDesc()).collect(Collectors.toList());
|
||||||
allDesc.addAll(data.getSqlDataHarm().stream().map(x -> x.getDesc()).collect(Collectors.toList()));
|
allDesc.addAll(data.getSqlDataHarm().stream().map(x -> x.getDesc()).collect(Collectors.toList()));
|
||||||
|
|
||||||
|
String bzDevId = devId;
|
||||||
|
if (isStdDev) {
|
||||||
|
String s = FormalTestManager.pairsIdMap.inverse().get(devId + CnSocketUtil.SPLIT_TAG + splitArr[1]);
|
||||||
|
bzDevId = s.split(CnSocketUtil.SPLIT_TAG)[0];
|
||||||
|
}
|
||||||
|
PqMonitor monitor = pqMonitorService.getByDevIdAndNum(bzDevId, Integer.parseInt(splitArr[1]));
|
||||||
|
DictData dictData = dictDataService.getById(monitor.getConnection());
|
||||||
for (DevData.SqlDataDTO sqlDataDTO : data.getSqlData()) {
|
for (DevData.SqlDataDTO sqlDataDTO : data.getSqlData()) {
|
||||||
if (usePhaseIndex.equals(1)) {
|
if (usePhaseIndex.equals(1)) {
|
||||||
if (DetectionCodeEnum.PVRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PU1.getCode().equals(sqlDataDTO.getDesc())) {
|
if (DetectionCodeEnum.PVRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PU1.getCode().equals(sqlDataDTO.getDesc())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (DetectionCodeEnum.VRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.U1.getCode().equals(sqlDataDTO.getDesc())) {
|
if (DetectionCodeEnum.STAR.getCode().equals(dictData.getCode())) {
|
||||||
continue;
|
if (DetectionCodeEnum.PVRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PU1.getCode().equals(sqlDataDTO.getDesc())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((DetectionCodeEnum.VRMS.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.U1.getCode().equals(sqlDataDTO.getDesc()))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2651,8 +2866,14 @@ public class SocketContrastResponseService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (DetectionCodeEnum.V2_50.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.SV_1_49.getCode().equals(sqlDataDTO.getDesc())) {
|
if (DetectionCodeEnum.STAR.getCode().equals(dictData.getCode())) {
|
||||||
continue;
|
if (DetectionCodeEnum.PV2_50.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.PSV_1_49.getCode().equals(sqlDataDTO.getDesc())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (DetectionCodeEnum.V2_50.getCode().equals(sqlDataDTO.getDesc()) || DetectionCodeEnum.SV_1_49.getCode().equals(sqlDataDTO.getDesc())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3289,4 +3510,46 @@ public class SocketContrastResponseService {
|
|||||||
devData.setSqlDataHarm(sqlDataHarmDTOS);
|
devData.setSqlDataHarm(sqlDataHarmDTOS);
|
||||||
return devData;
|
return devData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改通道系数
|
||||||
|
*
|
||||||
|
* @param f
|
||||||
|
*/
|
||||||
|
private void updateGfList(DevXiNumData.F f, DetectionServiceImpl.VAndIResult vAndIResult, String stdDevMonitorId, int maxNum) {
|
||||||
|
DevXiNumData.F originF = BeanUtil.copyProperties(f, DevXiNumData.F.class);
|
||||||
|
if (maxNum != 0) {
|
||||||
|
PqStandardDevGain pqStandardDevGain = pqStandardDevGainService.get(stdDevMonitorId);
|
||||||
|
originF.setUa_gain(pqStandardDevGain.getUaGain());
|
||||||
|
originF.setUb_gain(pqStandardDevGain.getUbGain());
|
||||||
|
originF.setUc_gain(pqStandardDevGain.getUcGain());
|
||||||
|
originF.setU0_gain(pqStandardDevGain.getU0Gain());
|
||||||
|
originF.setIa_gain(pqStandardDevGain.getIaGain());
|
||||||
|
originF.setIb_gain(pqStandardDevGain.getIbGain());
|
||||||
|
originF.setIc_gain(pqStandardDevGain.getIcGain());
|
||||||
|
originF.setI0_gain(pqStandardDevGain.getI0Gain());
|
||||||
|
originF.setUab_gain(pqStandardDevGain.getUabGain());
|
||||||
|
originF.setUbc_gain(pqStandardDevGain.getUbcGain());
|
||||||
|
originF.setUca_gain(pqStandardDevGain.getUcaGain());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vAndIResult.getVa() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getVaXi() * 10000), BigDecimal.valueOf(originF.getUa_gain() * 0.95), BigDecimal.valueOf(originF.getUa_gain() * 1.05))) {
|
||||||
|
f.setUa_gain(BigDecimal.valueOf(f.getUa_gain()).multiply(BigDecimal.valueOf(vAndIResult.getVaXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||||
|
}
|
||||||
|
if (vAndIResult.getVb() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getVbXi() * 10000), BigDecimal.valueOf(originF.getUb_gain() * 0.95), BigDecimal.valueOf(originF.getUb_gain() * 1.05))) {
|
||||||
|
f.setUb_gain(BigDecimal.valueOf(f.getUb_gain()).multiply(BigDecimal.valueOf(vAndIResult.getVbXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||||
|
}
|
||||||
|
if (vAndIResult.getVc() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getVcXi() * 10000), BigDecimal.valueOf(originF.getUc_gain() * 0.95), BigDecimal.valueOf(originF.getUc_gain() * 1.05))) {
|
||||||
|
f.setUc_gain(BigDecimal.valueOf(f.getUc_gain()).multiply(BigDecimal.valueOf(vAndIResult.getVcXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||||
|
}
|
||||||
|
if (vAndIResult.getIa() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getIaXi() * 10000), BigDecimal.valueOf(originF.getIa_gain() * 0.95), BigDecimal.valueOf(originF.getIa_gain() * 1.05))) {
|
||||||
|
f.setIa_gain(BigDecimal.valueOf(f.getIa_gain()).multiply(BigDecimal.valueOf(vAndIResult.getIaXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||||
|
}
|
||||||
|
if (vAndIResult.getIb() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getIbXi() * 10000), BigDecimal.valueOf(originF.getIb_gain() * 0.95), BigDecimal.valueOf(originF.getIb_gain() * 1.05))) {
|
||||||
|
f.setIb_gain(BigDecimal.valueOf(f.getIb_gain()).multiply(BigDecimal.valueOf(vAndIResult.getIbXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||||
|
}
|
||||||
|
if (vAndIResult.getIc() && NumberUtil.isIn(BigDecimal.valueOf(vAndIResult.getIcXi() * 10000), BigDecimal.valueOf(originF.getIc_gain() * 0.95), BigDecimal.valueOf(originF.getIc_gain() * 1.05))) {
|
||||||
|
f.setIc_gain(BigDecimal.valueOf(f.getIc_gain()).multiply(BigDecimal.valueOf(vAndIResult.getIcXi())).setScale(0, RoundingMode.HALF_UP).intValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,267 @@
|
|||||||
|
package com.njcn.gather.detection.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||||
|
import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam;
|
||||||
|
import com.njcn.gather.detection.pojo.po.DevData;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||||
|
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||||
|
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||||
|
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||||
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
|
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||||
|
import com.njcn.gather.detection.util.socket.cilent.NettyFreqConverterDevClientHandler;
|
||||||
|
import com.njcn.gather.detection.util.socket.config.SocketConnectionConfig;
|
||||||
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
|
import com.njcn.gather.dip.pojo.po.PqDipData;
|
||||||
|
import com.njcn.gather.dip.service.IPqDipDataService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SocketFreqConverterDevService {
|
||||||
|
|
||||||
|
private final SocketConnectionConfig socketConnectionConfig;
|
||||||
|
private final IPqDevService pqDevService;
|
||||||
|
private final IPqDipDataService pqDipDataService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接设备Socket
|
||||||
|
*
|
||||||
|
* @param devTag 设备Channel唯一标识符
|
||||||
|
*/
|
||||||
|
public void connectSocket(String devTag) {
|
||||||
|
if (SocketManager.isChannelActive(devTag)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String ip = socketConnectionConfig.getDevice().getIp();
|
||||||
|
Integer port = socketConnectionConfig.getDevice().getPort();
|
||||||
|
|
||||||
|
NettyFreqConverterDevClientHandler handler = new NettyFreqConverterDevClientHandler(devTag, this);
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
NettyClient.commonConnect(ip, port, devTag, handler);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(String converterId, String monitorId) {
|
||||||
|
FormalTestManager.freqConverterDevStep = null;
|
||||||
|
FormalTestManager.stopFlag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接设备
|
||||||
|
*/
|
||||||
|
public void connectionDev(String devTag, String converterId, String monitorId) {
|
||||||
|
this.init(converterId, monitorId);
|
||||||
|
|
||||||
|
String payload = buildSingleMonitorPayload(monitorId);
|
||||||
|
if (StrUtil.isBlank(payload)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue());
|
||||||
|
socketMsg.setData(payload);
|
||||||
|
SocketManager.sendMsg(devTag, JSON.toJSONString(socketMsg));
|
||||||
|
FormalTestManager.freqConverterDevStep = SourceOperateCodeEnum.YJC_SBTXJY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleRead(String devTag, String msg) {
|
||||||
|
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||||
|
|
||||||
|
switch (FormalTestManager.freqConverterDevStep) {
|
||||||
|
case YJC_SBTXJY:
|
||||||
|
handleYjcSbtxjy(devTag, socketDataMsg);
|
||||||
|
break;
|
||||||
|
case FORMAL_REAL:
|
||||||
|
handleFormalReal(devTag, socketDataMsg);
|
||||||
|
break;
|
||||||
|
case QUITE:
|
||||||
|
handleQuit(devTag, socketDataMsg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleYjcSbtxjy(String devTag, SocketDataMsg socketDataMsg) {
|
||||||
|
SourceResponseCodeEnum responseCodeEnum = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||||
|
switch (Objects.requireNonNull(responseCodeEnum)) {
|
||||||
|
case SUCCESS:
|
||||||
|
this.sendGetDipDataMsg(devTag);
|
||||||
|
FormalTestManager.freqConverterDevStep = SourceOperateCodeEnum.FORMAL_REAL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log.info("设备响应异常,devTag={}, operateCode={}, code={}, data={}", devTag, socketDataMsg.getOperateCode(), socketDataMsg.getCode(), socketDataMsg.getData());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleFormalReal(String devTag, SocketDataMsg socketDataMsg) {
|
||||||
|
SourceResponseCodeEnum responseCodeEnum = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||||
|
|
||||||
|
switch (responseCodeEnum) {
|
||||||
|
case UNPROCESSED_BUSINESS:
|
||||||
|
break;
|
||||||
|
case SUCCESS:
|
||||||
|
case NORMAL_RESPONSE:
|
||||||
|
DevData devData = JSON.parseObject(socketDataMsg.getData(), DevData.class);
|
||||||
|
// 如果变频器不是处于 “故障中” 状态,就保存数据,反之,这段时期内的数据不保存
|
||||||
|
if (!FormalTestManager.stopFlag) {
|
||||||
|
saveDipData(devData);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DEV_ERROR:
|
||||||
|
case DEV_TARGET:
|
||||||
|
case COMMUNICATION_ERR:
|
||||||
|
case DATA_RESOLVE:
|
||||||
|
case NO_INIT_DEV:
|
||||||
|
default:
|
||||||
|
log.info("设备响应异常,devTag={}, operateCode={}, code={}, data={}", devTag, socketDataMsg.getOperateCode(), socketDataMsg.getCode(), socketDataMsg.getData());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleQuit(String devTag, SocketDataMsg socketDataMsg) {
|
||||||
|
SourceResponseCodeEnum responseCodeEnum = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||||
|
|
||||||
|
switch (responseCodeEnum) {
|
||||||
|
case SUCCESS:
|
||||||
|
cleanup(devTag, true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log.warn("设备关闭响应失败,devTag={}, operateCode={}, code={}, data={}", devTag, socketDataMsg.getOperateCode(), socketDataMsg.getCode(), socketDataMsg.getData());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopTest(String converterTag, String devTag) {
|
||||||
|
FormalTestManager.freqConverterDevStep = SourceOperateCodeEnum.QUITE;
|
||||||
|
sendQuitMsg(devTag, SourceOperateCodeEnum.QUIT_INIT_03);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String buildSingleMonitorPayload(String monitorId) {
|
||||||
|
String[] split = monitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||||
|
if (split.length < 2 || StrUtil.isBlank(split[0]) || StrUtil.isBlank(split[1])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PreDetection> preDetections = pqDevService.getDevInfo(Collections.singletonList(split[0]));
|
||||||
|
if (CollUtil.isEmpty(preDetections)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
PreDetection preDetection = preDetections.get(0);
|
||||||
|
List<PreDetection.MonitorListDTO> monitorList = preDetection.getMonitorList();
|
||||||
|
if (CollUtil.isEmpty(monitorList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PreDetection.MonitorListDTO> matchedMonitorList = monitorList.stream()
|
||||||
|
.filter(item -> split[1].equals(item.getLineId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isEmpty(matchedMonitorList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
preDetection.setMonitorList(matchedMonitorList);
|
||||||
|
Map<String, List<PreDetection>> payload = new HashMap<>(1);
|
||||||
|
payload.put("deviceList", Collections.singletonList(preDetection));
|
||||||
|
return JSON.toJSONString(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendGetDipDataMsg(String monitorId) {
|
||||||
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue());
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
|
|
||||||
|
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||||
|
// 设置监测点ID列表
|
||||||
|
phaseSequenceParam.setMoniterIdList(ListUtil.of(monitorId));
|
||||||
|
|
||||||
|
// 设置数据类型列表
|
||||||
|
phaseSequenceParam.setDataType(ListUtil.of("avg$MAG", "avg$DUR"));
|
||||||
|
// 设置读取次数
|
||||||
|
phaseSequenceParam.setReadCount(0);
|
||||||
|
// 设置忽略次数
|
||||||
|
phaseSequenceParam.setIgnoreCount(0);
|
||||||
|
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_03.getValue());
|
||||||
|
SocketManager.sendMsg(monitorId, JSON.toJSONString(socketMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendQuitMsg(String devTag, SourceOperateCodeEnum operateCodeEnum) {
|
||||||
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||||
|
socketMsg.setOperateCode(operateCodeEnum.getValue());
|
||||||
|
SocketManager.sendMsg(devTag, JSON.toJSONString(socketMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveDipData(DevData devData) {
|
||||||
|
if (Objects.isNull(devData) || CollUtil.isEmpty(devData.getSqlData())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Double residualVoltage = null;
|
||||||
|
Integer durationMs = null;
|
||||||
|
for (DevData.SqlDataDTO sqlDataDTO : devData.getSqlData()) {
|
||||||
|
if (Objects.isNull(sqlDataDTO) || Objects.isNull(sqlDataDTO.getList())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Double value = getSqlDataValue(sqlDataDTO.getList());
|
||||||
|
if (Objects.isNull(value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DetectionCodeEnum.MAG.getCode().equalsIgnoreCase(sqlDataDTO.getDesc())) {
|
||||||
|
residualVoltage = value;
|
||||||
|
} else if (DetectionCodeEnum.DUR.getCode().equalsIgnoreCase(sqlDataDTO.getDesc())) {
|
||||||
|
durationMs = (int) Math.round(value * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PqDipData pqDipData = new PqDipData();
|
||||||
|
pqDipData.setStartTime(LocalDateTime.parse(devData.getTime()));
|
||||||
|
pqDipData.setResidualVoltage(residualVoltage);
|
||||||
|
pqDipData.setDurationMs(durationMs);
|
||||||
|
pqDipDataService.save(pqDipData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Double getSqlDataValue(DevData.SqlDataDTO.ListDTO listDTO) {
|
||||||
|
if (Objects.nonNull(listDTO.getA())) {
|
||||||
|
return listDTO.getA();
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(listDTO.getB())) {
|
||||||
|
return listDTO.getB();
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(listDTO.getC())) {
|
||||||
|
return listDTO.getC();
|
||||||
|
}
|
||||||
|
return listDTO.getT();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanup(String devTag, boolean removeSocket) {
|
||||||
|
FormalTestManager.freqConverterDevStep = null;
|
||||||
|
if (removeSocket) {
|
||||||
|
SocketManager.removeUser(devTag);
|
||||||
|
} else {
|
||||||
|
SocketManager.clearUser(devTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
package com.njcn.gather.detection.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.njcn.gather.detection.pojo.dto.FreqConverterRespDTO;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||||
|
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||||
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
|
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||||
|
import com.njcn.gather.detection.util.socket.cilent.NettyFreqConverterClientHandler;
|
||||||
|
import com.njcn.gather.detection.util.socket.config.SocketConnectionConfig;
|
||||||
|
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||||
|
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterConfig;
|
||||||
|
import com.njcn.gather.freqConverter.service.IFreqConverterService;
|
||||||
|
import com.njcn.gather.freqConverter.service.IPqFreqConverterConfigService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author czh
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SocketFreqConverterService {
|
||||||
|
private final IFreqConverterService freqConverterService;
|
||||||
|
|
||||||
|
private final SocketConnectionConfig socketConnectionConfig;
|
||||||
|
|
||||||
|
private final IPqFreqConverterConfigService pqFreqConverterConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接变频器Socket
|
||||||
|
*
|
||||||
|
* @param converterChannelTag 变频器Channel唯一标识符
|
||||||
|
*/
|
||||||
|
public void connectSocket(String converterChannelTag) {
|
||||||
|
if (SocketManager.isChannelActive(converterChannelTag)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String ip = socketConnectionConfig.getFreqConverter().getIp();
|
||||||
|
Integer port = socketConnectionConfig.getFreqConverter().getPort();
|
||||||
|
|
||||||
|
NettyFreqConverterClientHandler handler = new NettyFreqConverterClientHandler(converterChannelTag, this);
|
||||||
|
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
NettyClient.commonConnect(ip, port, converterChannelTag, handler);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(String converterId, String monitorId) {
|
||||||
|
FormalTestManager.freqConverterStep = null;
|
||||||
|
FormalTestManager.pairsIpMap.put(converterId, monitorId);
|
||||||
|
clearScheduleTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接变频器
|
||||||
|
*/
|
||||||
|
public void connectionFreqConverter(String freqConverterTag, String converterId, String monitorId) {
|
||||||
|
this.init(converterId, monitorId);
|
||||||
|
|
||||||
|
SocketMsg<Map<String, Object>> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.CMD_INIT_SERIAL.getValue());
|
||||||
|
String requestId = IdUtil.fastSimpleUUID();
|
||||||
|
socketMsg.setRequestId(requestId);
|
||||||
|
|
||||||
|
PqFreqConverterConfig freqConverterConfig = pqFreqConverterConfigService.getById(converterId);
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("portName", freqConverterConfig.getPortName());
|
||||||
|
map.put("slaveAddress", freqConverterConfig.getSlaveAddress());
|
||||||
|
map.put("baudRate", freqConverterConfig.getBaudRate());
|
||||||
|
map.put("parity", freqConverterConfig.getParity());
|
||||||
|
map.put("dataBits", freqConverterConfig.getDataBits());
|
||||||
|
map.put("stopBits", freqConverterConfig.getStopBits());
|
||||||
|
map.put("timeoutMs", freqConverterConfig.getTimeoutMs());
|
||||||
|
socketMsg.setData(map);
|
||||||
|
|
||||||
|
SocketManager.sendMsg(freqConverterTag, JSON.toJSONString(socketMsg));
|
||||||
|
FormalTestManager.freqConverterStep = SourceOperateCodeEnum.CMD_INIT_SERIAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleRead(String converterChannelTag, String msg) {
|
||||||
|
FreqConverterRespDTO respDTO = JSON.parseObject(msg, FreqConverterRespDTO.class);
|
||||||
|
|
||||||
|
switch (FormalTestManager.freqConverterStep) {
|
||||||
|
case CMD_PING:
|
||||||
|
handlePing(converterChannelTag, respDTO);
|
||||||
|
break;
|
||||||
|
case CMD_INIT_SERIAL:
|
||||||
|
handleInitSerial(converterChannelTag, respDTO);
|
||||||
|
break;
|
||||||
|
case CMD_GET_SERIAL_CONFIG:
|
||||||
|
handleGetSerialConfig(converterChannelTag, respDTO);
|
||||||
|
break;
|
||||||
|
case CMD_GET_DEVICE_STATUS:
|
||||||
|
handleGetDeviceStatus(converterChannelTag, respDTO);
|
||||||
|
break;
|
||||||
|
case CMD_CLOSE_SERIAL:
|
||||||
|
handleCloseSerial(converterChannelTag, respDTO);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopTest(String converterTag, String devTag) {
|
||||||
|
FormalTestManager.freqConverterStep = SourceOperateCodeEnum.CMD_CLOSE_SERIAL;
|
||||||
|
this.sendClose(converterTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void handlePing(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
||||||
|
if (respDTO.getCode() == 0 && respDTO.getSuccess() && respDTO.getMessage().equals("pong")) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleInitSerial(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
||||||
|
if (respDTO.getCode() == 0 && respDTO.getSuccess()) {
|
||||||
|
|
||||||
|
FormalTestManager.freqConverterStep = SourceOperateCodeEnum.CMD_GET_DEVICE_STATUS;
|
||||||
|
freqConverterService.clearAllData();
|
||||||
|
if (Objects.isNull(FormalTestManager.scheduler)) {
|
||||||
|
FormalTestManager.scheduler = Executors.newScheduledThreadPool(1);
|
||||||
|
FormalTestManager.scheduledFuture = FormalTestManager.scheduler.scheduleAtFixedRate(() -> {
|
||||||
|
this.sendGetDeviceStatusMsg(converterChannelTag);
|
||||||
|
}, 0l, 200l, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleGetSerialConfig(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleGetDeviceStatus(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
||||||
|
JSONObject obj = JSONUtil.parseObj(respDTO.getData().toString());
|
||||||
|
String timestamp = (String) obj.get("Timestamp");
|
||||||
|
timestamp = timestamp.replace("+08:00", StrUtil.EMPTY);
|
||||||
|
obj.set("Timestamp", timestamp);
|
||||||
|
|
||||||
|
FreqConverterStatus freqConverterStatus = JSON.parseObject(obj.toString(), FreqConverterStatus.class);
|
||||||
|
// 变频器故障中,移除这段时期内的设备数据
|
||||||
|
if (freqConverterStatus.getStatusWord1() == 4) {
|
||||||
|
FormalTestManager.stopFlag = true;
|
||||||
|
} else {
|
||||||
|
FormalTestManager.stopFlag = false;
|
||||||
|
}
|
||||||
|
freqConverterService.saveFreqConverterStatus(freqConverterStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleCloseSerial(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
||||||
|
if (respDTO.getCode() == 0 && respDTO.getSuccess()) {
|
||||||
|
cleanup(converterChannelTag, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void sendGetDeviceStatusMsg(String converterId) {
|
||||||
|
SocketMsg<Map<String, Object>> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.CMD_GET_DEVICE_STATUS.getValue());
|
||||||
|
String requestId = IdUtil.fastSimpleUUID();
|
||||||
|
socketMsg.setRequestId(requestId);
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
socketMsg.setData(map);
|
||||||
|
SocketManager.sendMsg(converterId, JSON.toJSONString(socketMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendClose(String converterTag) {
|
||||||
|
SocketMsg<Map<String, Object>> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.CMD_CLOSE_SERIAL.getValue());
|
||||||
|
String requestId = IdUtil.fastSimpleUUID();
|
||||||
|
socketMsg.setRequestId(requestId);
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
socketMsg.setData(map);
|
||||||
|
SocketManager.sendMsg(converterTag, JSON.toJSONString(socketMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanup(String converterChannelTag, boolean removeSocket) {
|
||||||
|
clearScheduleTask();
|
||||||
|
FormalTestManager.freqConverterStep = null;
|
||||||
|
FormalTestManager.stopFlag = false;
|
||||||
|
FormalTestManager.pairsIpMap.clear();
|
||||||
|
if (removeSocket) {
|
||||||
|
SocketManager.removeUser(converterChannelTag);
|
||||||
|
} else {
|
||||||
|
SocketManager.clearUser(converterChannelTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearScheduleTask() {
|
||||||
|
if (FormalTestManager.scheduledFuture != null) {
|
||||||
|
FormalTestManager.scheduledFuture.cancel(true);
|
||||||
|
FormalTestManager.scheduledFuture = null;
|
||||||
|
}
|
||||||
|
if (FormalTestManager.scheduler != null) {
|
||||||
|
FormalTestManager.scheduler.shutdown();
|
||||||
|
FormalTestManager.scheduler = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.njcn.gather.detection.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-08
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FreqConverterRespDTO {
|
||||||
|
/**
|
||||||
|
* 请求编号
|
||||||
|
*/
|
||||||
|
@JsonAlias({"RequestId"})
|
||||||
|
private String requestId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否成功
|
||||||
|
*/
|
||||||
|
@JsonAlias({"Success"})
|
||||||
|
private Boolean success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态码
|
||||||
|
*/
|
||||||
|
@JsonAlias({"Code"})
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息
|
||||||
|
*/
|
||||||
|
@JsonAlias({"Message"})
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据
|
||||||
|
*/
|
||||||
|
@JsonAlias({"Data"})
|
||||||
|
private Object data;
|
||||||
|
}
|
||||||
@@ -70,9 +70,6 @@ public enum SourceOperateCodeEnum {
|
|||||||
FLICKER_DATA_CHECK("flicker_data_check","闪变数据校验"),
|
FLICKER_DATA_CHECK("flicker_data_check","闪变数据校验"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -100,12 +97,17 @@ public enum SourceOperateCodeEnum {
|
|||||||
small_comp_start("small_comp_start","小电压校准开始"),
|
small_comp_start("small_comp_start","小电压校准开始"),
|
||||||
small_comp_end("small_comp_end","小电压校准结束"),
|
small_comp_end("small_comp_end","小电压校准结束"),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ftp文件传送指令
|
* ftp文件传送指令
|
||||||
*/
|
*/
|
||||||
FTP_SEND_01("FTP_SEND$01", "发送文件"),
|
FTP_SEND_01("FTP_SEND$01", "发送文件"),
|
||||||
RDRE$01("RDRE$01", "启动录波");
|
RDRE$01("RDRE$01", "启动录波"),
|
||||||
|
|
||||||
|
CMD_PING("ping", "检查 TCP 服务是否在线"),
|
||||||
|
CMD_INIT_SERIAL("initSerial", "初始化并打开串口连接"),
|
||||||
|
CMD_GET_SERIAL_CONFIG("getSerialConfig", "获取当前串口配置"),
|
||||||
|
CMD_GET_DEVICE_STATUS("getDeviceStatus", "读取变频器运行状态"),
|
||||||
|
CMD_CLOSE_SERIAL("closeSerial", "关闭串口"),;
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
private final String msg;
|
private final String msg;
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
|||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wr
|
* @author wr
|
||||||
@@ -54,7 +52,6 @@ public interface PreDetectionService {
|
|||||||
void closeTestSimulate(SimulateDetectionParam param);
|
void closeTestSimulate(SimulateDetectionParam param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param param
|
* @param param
|
||||||
*/
|
*/
|
||||||
void startContrastTest(ContrastDetectionParam param);
|
void startContrastTest(ContrastDetectionParam param);
|
||||||
@@ -63,4 +60,12 @@ public interface PreDetectionService {
|
|||||||
* 导出实时数据对齐过程中的数据
|
* 导出实时数据对齐过程中的数据
|
||||||
*/
|
*/
|
||||||
void exportAlignData();
|
void exportAlignData();
|
||||||
|
|
||||||
|
boolean getCanCoefficient();
|
||||||
|
|
||||||
|
void startCoefficient();
|
||||||
|
|
||||||
|
void startFreqConverter(String name, String converterId, String monitorId);
|
||||||
|
|
||||||
|
void stopFreqConverter(String converterId, String monitorId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ import com.njcn.gather.detection.pojo.vo.DetectionData;
|
|||||||
import com.njcn.gather.detection.pojo.vo.DevLineTestResult;
|
import com.njcn.gather.detection.pojo.vo.DevLineTestResult;
|
||||||
import com.njcn.gather.detection.util.DetectionUtil;
|
import com.njcn.gather.detection.util.DetectionUtil;
|
||||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||||
|
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
|
import com.njcn.gather.device.service.IPqStandardDevGainRecordService;
|
||||||
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
import com.njcn.gather.err.pojo.param.PqErrSysParam;
|
||||||
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
import com.njcn.gather.err.pojo.po.PqErrSysDtls;
|
||||||
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
|
import com.njcn.gather.err.pojo.vo.ErrDtlsCheckDataVO;
|
||||||
@@ -36,7 +38,10 @@ import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
|
|||||||
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
import com.njcn.gather.util.StorageUtil;
|
import com.njcn.gather.util.StorageUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -56,6 +61,7 @@ import java.util.stream.Stream;
|
|||||||
* @description
|
* @description
|
||||||
* @date 2024/12/20 13:52
|
* @date 2024/12/20 13:52
|
||||||
*/
|
*/
|
||||||
|
@Log4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class DetectionServiceImpl {
|
public class DetectionServiceImpl {
|
||||||
@@ -66,6 +72,7 @@ public class DetectionServiceImpl {
|
|||||||
private final ISysTestConfigService sysTestConfigService;
|
private final ISysTestConfigService sysTestConfigService;
|
||||||
private final IPqMonitorService pqMonitorService;
|
private final IPqMonitorService pqMonitorService;
|
||||||
private final IPqDevService pqDevService;
|
private final IPqDevService pqDevService;
|
||||||
|
private final IPqStandardDevGainRecordService pqStandardDevGainRecordService;
|
||||||
|
|
||||||
public static final String TYPE_A = "A";
|
public static final String TYPE_A = "A";
|
||||||
public static final String TYPE_B = "B";
|
public static final String TYPE_B = "B";
|
||||||
@@ -82,6 +89,44 @@ public class DetectionServiceImpl {
|
|||||||
private static final Integer INHARMONIC_FLAG = 1;
|
private static final Integer INHARMONIC_FLAG = 1;
|
||||||
private static final Integer HARMONIC_FLAG = 2;
|
private static final Integer HARMONIC_FLAG = 2;
|
||||||
|
|
||||||
|
// @Value("${error.removeCount:14}")
|
||||||
|
// private Integer removeErrorValueCount;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class VAndIResult {
|
||||||
|
private String ip;
|
||||||
|
private Integer chnNum;
|
||||||
|
private Boolean va;
|
||||||
|
private Boolean vb;
|
||||||
|
private Boolean vc;
|
||||||
|
private Boolean ia;
|
||||||
|
private Boolean ib;
|
||||||
|
private Boolean ic;
|
||||||
|
private Double vaXi;
|
||||||
|
private Double vbXi;
|
||||||
|
private Double vcXi;
|
||||||
|
private Double iaXi;
|
||||||
|
private Double ibXi;
|
||||||
|
private Double icXi;
|
||||||
|
// 皮尔逊相关系数
|
||||||
|
private BigDecimal pearsonCorrelationCoefficientVa;
|
||||||
|
private BigDecimal pearsonCorrelationCoefficientVb;
|
||||||
|
private BigDecimal pearsonCorrelationCoefficientVc;
|
||||||
|
private BigDecimal pearsonCorrelationCoefficientIa;
|
||||||
|
private BigDecimal pearsonCorrelationCoefficientIb;
|
||||||
|
private BigDecimal pearsonCorrelationCoefficientIc;
|
||||||
|
// 比值一致性 CV 系数
|
||||||
|
private BigDecimal cVCoefficientVa;
|
||||||
|
private BigDecimal cVCoefficientVb;
|
||||||
|
private BigDecimal cVCoefficientVc;
|
||||||
|
private BigDecimal cVCoefficientIa;
|
||||||
|
private BigDecimal cVCoefficientIb;
|
||||||
|
private BigDecimal cVCoefficientIc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, VAndIResult> vAndIResultMap = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始处理指标类型
|
* 开始处理指标类型
|
||||||
@@ -1572,6 +1617,23 @@ public class DetectionServiceImpl {
|
|||||||
if (CollUtil.isNotEmpty(devDataList) && CollUtil.isNotEmpty(standardDevDataList) && CollUtil.isNotEmpty(testItemCodeList)) {
|
if (CollUtil.isNotEmpty(devDataList) && CollUtil.isNotEmpty(standardDevDataList) && CollUtil.isNotEmpty(testItemCodeList)) {
|
||||||
devDataList = devDataList.stream().sorted(Comparator.comparing(DevData::getTime)).collect(Collectors.toList());
|
devDataList = devDataList.stream().sorted(Comparator.comparing(DevData::getTime)).collect(Collectors.toList());
|
||||||
standardDevDataList = standardDevDataList.stream().sorted(Comparator.comparing(DevData::getTime)).collect(Collectors.toList());
|
standardDevDataList = standardDevDataList.stream().sorted(Comparator.comparing(DevData::getTime)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
boolean isRemoveMaxElement = ObjectUtil.isNotNull(waveNum) ? false : true;
|
||||||
|
// List<Double> freqStdDevData = standardDevDataList.stream().flatMap(standardDevData -> standardDevData.getSqlData().stream())
|
||||||
|
// .filter(sqlDataDTO -> DetectionCodeEnum.FREQ.getCode().equals(sqlDataDTO.getDesc()))
|
||||||
|
// .map(sqlDataDTO -> sqlDataDTO.getList().getT()).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// Double maxFreq = CollUtil.isNotEmpty(freqStdDevData) ? CollUtil.max(freqStdDevData) : null;
|
||||||
|
// Double minFreq = CollUtil.isNotEmpty(freqStdDevData) ? CollUtil.min(freqStdDevData) : null;
|
||||||
|
|
||||||
|
// if (maxFreq != null && minFreq != null) {
|
||||||
|
// isRemoveMaxElement = DictDataEnum.AVG_VALUE.equals(dataRule);
|
||||||
|
// double freqErrorValue = maxFreq - minFreq;
|
||||||
|
// if (NumberUtil.isGreaterOrEqual(BigDecimal.valueOf(freqErrorValue), BigDecimal.valueOf(0.02))) {
|
||||||
|
// isRemoveMaxElement = isRemoveMaxElement && true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// 处理谐波数据
|
// 处理谐波数据
|
||||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||||
String[] split1 = devDataList.get(0).getId().split("_");
|
String[] split1 = devDataList.get(0).getId().split("_");
|
||||||
@@ -1618,12 +1680,12 @@ public class DetectionServiceImpl {
|
|||||||
// sqlData.setList(listDTO);
|
// sqlData.setList(listDTO);
|
||||||
// }));
|
// }));
|
||||||
// }
|
// }
|
||||||
resultMap.put(PowerIndexEnum.FREQ.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fHz, DetectionCodeEnum.FREQ.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.FREQ.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fHz, DetectionCodeEnum.FREQ.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case VRMS:
|
case VRMS:
|
||||||
case PVRMS:
|
case PVRMS:
|
||||||
// 如果是角型接法且存在角型接法的一些指标,则不进行使用角型接线的指标。反之,则使用相别的指标。
|
// 如果是角型接法且存在角型接法的一些指标,则不进行使用角型接线的指标。反之,则使用相别的指标。
|
||||||
resultMap.put(PowerIndexEnum.V.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fUn, (isDelta && isExitDelta ? DetectionCodeEnum.PVRMS.getCode() : DetectionCodeEnum.VRMS.getCode()), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.V.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fUn, (isDelta && isExitDelta ? DetectionCodeEnum.PVRMS.getCode() : DetectionCodeEnum.VRMS.getCode()), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case IRMS:
|
case IRMS:
|
||||||
// if (ObjectUtil.isNotNull(waveNum) && (waveNum.equals(2) || waveNum.equals(5))) {
|
// if (ObjectUtil.isNotNull(waveNum) && (waveNum.equals(2) || waveNum.equals(5))) {
|
||||||
@@ -1634,33 +1696,33 @@ public class DetectionServiceImpl {
|
|||||||
// sqlData.setList(listDTO);
|
// sqlData.setList(listDTO);
|
||||||
// }));
|
// }));
|
||||||
// }
|
// }
|
||||||
resultMap.put(PowerIndexEnum.I.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fIn, DetectionCodeEnum.IRMS.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.I.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fIn, DetectionCodeEnum.IRMS.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case V_UNBAN:
|
case V_UNBAN:
|
||||||
resultMap.put(PowerIndexEnum.IMBV.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, false, fUn, DetectionCodeEnum.V_UNBAN.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.IMBV.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, false, fUn, DetectionCodeEnum.V_UNBAN.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case I_UNBAN:
|
case I_UNBAN:
|
||||||
resultMap.put(PowerIndexEnum.IMBA.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, false, fIn, DetectionCodeEnum.I_UNBAN.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.IMBA.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, false, fIn, DetectionCodeEnum.I_UNBAN.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case V2_50:
|
case V2_50:
|
||||||
case PV2_50:
|
case PV2_50:
|
||||||
resultMap.put(PowerIndexEnum.HV.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, U, fUn, HARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.HV.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, U, fUn, HARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case I2_50:
|
case I2_50:
|
||||||
resultMap.put(PowerIndexEnum.HI.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, I, fIn, HARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.HI.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, I, fIn, HARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case P2_50:
|
case P2_50:
|
||||||
resultMap.put(PowerIndexEnum.HP.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, HP, fUn * fIn, HARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.HP.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, HP, fUn * fIn, HARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case SV_1_49:
|
case SV_1_49:
|
||||||
case PSV_1_49:
|
case PSV_1_49:
|
||||||
resultMap.put(PowerIndexEnum.HSV.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, U, fUn, INHARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.HSV.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, U, fUn, INHARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case SI_1_49:
|
case SI_1_49:
|
||||||
resultMap.put(PowerIndexEnum.HSI.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, I, fIn, INHARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum));
|
resultMap.put(PowerIndexEnum.HSI.getKey(), isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, I, fIn, INHARMONIC_FLAG, isDelta && isExitDelta, dataRule, num, code, oneConfig.getScale(), waveNum, dataSourceEnum, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case PST:
|
case PST:
|
||||||
resultMap.put(PowerIndexEnum.F.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fUn, DetectionCodeEnum.PST.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, DataSourceEnum.MINUTE_STATISTICS_AVG));
|
resultMap.put(PowerIndexEnum.F.getKey(), isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, true, fUn, DetectionCodeEnum.PST.getCode(), dataRule, num, code, oneConfig.getScale(), waveNum, DataSourceEnum.MINUTE_STATISTICS_AVG, isRemoveMaxElement));
|
||||||
break;
|
break;
|
||||||
case UNKNOWN_ERROR:
|
case UNKNOWN_ERROR:
|
||||||
break;
|
break;
|
||||||
@@ -1734,22 +1796,29 @@ public class DetectionServiceImpl {
|
|||||||
String code,
|
String code,
|
||||||
Integer scale,
|
Integer scale,
|
||||||
Integer waveNum,
|
Integer waveNum,
|
||||||
DataSourceEnum dataSourceEnum) {
|
DataSourceEnum dataSourceEnum,
|
||||||
|
boolean isRemoveMaxElement) {
|
||||||
List<ContrastNonHarmonicResult> info = new ArrayList<>();
|
List<ContrastNonHarmonicResult> info = new ArrayList<>();
|
||||||
if (CollUtil.isNotEmpty(devDataList) && CollUtil.isNotEmpty(standardDevDataList) && CollUtil.isNotEmpty(errSysDtls)) {
|
if (CollUtil.isNotEmpty(devDataList) && CollUtil.isNotEmpty(standardDevDataList) && CollUtil.isNotEmpty(errSysDtls)) {
|
||||||
|
|
||||||
Map<String, List<List<Double>>> map = devListMap(devDataList, standardDevDataList, desc, dataRule);
|
Map<String, List<List<Double>>> phaseValueList = this.getPhaseValueList(devDataList, standardDevDataList, desc);
|
||||||
|
Map<String, List<List<Double>>> map = devListMap(phaseValueList, dataRule, isRemoveMaxElement);
|
||||||
if (ObjectUtil.isNull(map)) {
|
if (ObjectUtil.isNull(map)) {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
ContrastNonHarmonicResult result = new ContrastNonHarmonicResult();
|
ContrastNonHarmonicResult result = new ContrastNonHarmonicResult();
|
||||||
result.setWaveNum(waveNum);
|
result.setWaveNum(waveNum);
|
||||||
|
|
||||||
String[] split1 = devDataList.get(0).getId().split(CnSocketUtil.SPLIT_TAG);
|
String devId = devDataList.get(0).getId();
|
||||||
String[] split2 = standardDevDataList.get(0).getId().split(CnSocketUtil.SPLIT_TAG);
|
String stdId = standardDevDataList.get(0).getId();
|
||||||
|
|
||||||
|
String[] split1 = devId.split(CnSocketUtil.SPLIT_TAG);
|
||||||
|
String[] split2 = stdId.split(CnSocketUtil.SPLIT_TAG);
|
||||||
result.setNum(num);
|
result.setNum(num);
|
||||||
result.setDevMonitorId(devIdMapComm.get(split1[0]) + "_" + split1[1]);
|
String devMonitorId = devIdMapComm.get(split1[0]) + "_" + split1[1];
|
||||||
result.setStdDevMonitorId(devIdMapComm.get(split2[0]) + "_" + split2[1]);
|
result.setDevMonitorId(devMonitorId);
|
||||||
|
String stdDevMonitorId = devIdMapComm.get(split2[0]) + "_" + split2[1];
|
||||||
|
result.setStdDevMonitorId(stdDevMonitorId);
|
||||||
result.setAdType(errSysDtls.get(0).getScriptType());
|
result.setAdType(errSysDtls.get(0).getScriptType());
|
||||||
result.setDataType(dataSourceEnum.getValue());
|
result.setDataType(dataSourceEnum.getValue());
|
||||||
if (ObjectUtil.isNotNull(waveNum)) {
|
if (ObjectUtil.isNotNull(waveNum)) {
|
||||||
@@ -1790,6 +1859,78 @@ public class DetectionServiceImpl {
|
|||||||
List<DetectionData> phaseList = rangeComparisonList(map.get(phase).get(0), map.get(phase).get(1), errSysDtls, fData, scale, dataRule);
|
List<DetectionData> phaseList = rangeComparisonList(map.get(phase).get(0), map.get(phase).get(1), errSysDtls, fData, scale, dataRule);
|
||||||
this.setValidGroupNum(phaseList, validGroupNum);
|
this.setValidGroupNum(phaseList, validGroupNum);
|
||||||
resultFlag.addAll(phaseList);
|
resultFlag.addAll(phaseList);
|
||||||
|
if (FormalTestManager.isTesting && ObjectUtil.isNull(waveNum)) { //只有“正式检测并且不是录波数据”的时候才能进入这段代码,重新计算、切换误差体系额操作不会进入这段代码,提升效率。
|
||||||
|
// if (true) { //只有“正式检测并且不是录波数据”的时候才能进入这段代码,重新计算、切换误差体系额操作不会进入这段代码,提升效率。
|
||||||
|
if (DetectionCodeEnum.PVRMS.getCode().equals(desc) || DetectionCodeEnum.VRMS.getCode().equals(desc) || DetectionCodeEnum.IRMS.getCode().equals(desc)) {
|
||||||
|
Integer phaseResultFlag = setResultFlag(phaseList);
|
||||||
|
boolean b = phaseResultFlag == 2 ? true : false;
|
||||||
|
|
||||||
|
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||||
|
if (b && oneConfig.getCoefficient() == 1) {
|
||||||
|
BigDecimal pearsonCorrelationCoefficient = DetectionUtil.getPearsonCorrelationCoefficient(phaseValueList.get(phase).get(0), phaseValueList.get(phase).get(1));
|
||||||
|
if (NumberUtil.isGreaterOrEqual(pearsonCorrelationCoefficient, BigDecimal.valueOf(0.8))) {
|
||||||
|
BigDecimal cvCoefficient = DetectionUtil.getCvCoefficient(phaseValueList.get(phase).get(0), phaseValueList.get(phase).get(1));
|
||||||
|
if (NumberUtil.isLess(cvCoefficient, BigDecimal.valueOf(0.05))) {
|
||||||
|
int maxNum = pqStandardDevGainRecordService.getMaxNum(stdDevMonitorId, devMonitorId);
|
||||||
|
// 如果没有超出次数限制
|
||||||
|
if (maxNum + 1 <= 5) {
|
||||||
|
VAndIResult vAndIResult = vAndIResultMap.getOrDefault(stdId, new VAndIResult(split2[0], Integer.valueOf(split2[1]), false, false, false, false, false, false,
|
||||||
|
1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||||
|
BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO,
|
||||||
|
BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2), BigDecimal.valueOf(0.2)));
|
||||||
|
|
||||||
|
Double newXi = DetectionUtil.getNewXi(map.get(phase).get(0), map.get(phase).get(1));
|
||||||
|
switch (phase) {
|
||||||
|
case TYPE_A:
|
||||||
|
if (DetectionCodeEnum.IRMS.getCode().equals(desc)) {
|
||||||
|
vAndIResult.setIa(b);
|
||||||
|
vAndIResult.setIaXi(newXi);
|
||||||
|
vAndIResult.setPearsonCorrelationCoefficientIa(pearsonCorrelationCoefficient);
|
||||||
|
vAndIResult.setCVCoefficientIa(cvCoefficient);
|
||||||
|
} else {
|
||||||
|
vAndIResult.setVa(b);
|
||||||
|
vAndIResult.setVaXi(newXi);
|
||||||
|
vAndIResult.setPearsonCorrelationCoefficientVa(pearsonCorrelationCoefficient);
|
||||||
|
vAndIResult.setCVCoefficientVa(cvCoefficient);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TYPE_B:
|
||||||
|
if (DetectionCodeEnum.IRMS.getCode().equals(desc)) {
|
||||||
|
vAndIResult.setIb(b);
|
||||||
|
vAndIResult.setIbXi(newXi);
|
||||||
|
vAndIResult.setPearsonCorrelationCoefficientIb(pearsonCorrelationCoefficient);
|
||||||
|
vAndIResult.setCVCoefficientIb(cvCoefficient);
|
||||||
|
} else {
|
||||||
|
vAndIResult.setVb(b);
|
||||||
|
vAndIResult.setVbXi(newXi);
|
||||||
|
vAndIResult.setPearsonCorrelationCoefficientVb(pearsonCorrelationCoefficient);
|
||||||
|
vAndIResult.setCVCoefficientVb(cvCoefficient);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TYPE_C:
|
||||||
|
if (DetectionCodeEnum.IRMS.getCode().equals(desc)) {
|
||||||
|
vAndIResult.setIc(b);
|
||||||
|
vAndIResult.setIcXi(newXi);
|
||||||
|
vAndIResult.setPearsonCorrelationCoefficientIc(pearsonCorrelationCoefficient);
|
||||||
|
vAndIResult.setCVCoefficientIc(cvCoefficient);
|
||||||
|
} else {
|
||||||
|
vAndIResult.setVc(b);
|
||||||
|
vAndIResult.setVcXi(newXi);
|
||||||
|
vAndIResult.setPearsonCorrelationCoefficientVc(pearsonCorrelationCoefficient);
|
||||||
|
vAndIResult.setCVCoefficientVc(cvCoefficient);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
vAndIResultMap.put(stdId, vAndIResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BiConsumer<ContrastNonHarmonicResult, List<DetectionData>> setter = setters.get(phase);
|
BiConsumer<ContrastNonHarmonicResult, List<DetectionData>> setter = setters.get(phase);
|
||||||
setter.accept(result, phaseList);
|
setter.accept(result, phaseList);
|
||||||
}
|
}
|
||||||
@@ -1999,7 +2140,8 @@ public class DetectionServiceImpl {
|
|||||||
String code,
|
String code,
|
||||||
Integer scale,
|
Integer scale,
|
||||||
Integer waveNum,
|
Integer waveNum,
|
||||||
DataSourceEnum dataSourceEnum) {
|
DataSourceEnum dataSourceEnum,
|
||||||
|
boolean isRemoveMaxElement) {
|
||||||
List<ContrastHarmonicResult> info = new ArrayList<>();
|
List<ContrastHarmonicResult> info = new ArrayList<>();
|
||||||
if (CollUtil.isNotEmpty(devDataList) && CollUtil.isNotEmpty(standardDevDataList) && CollUtil.isNotEmpty(errSysDtls)) {
|
if (CollUtil.isNotEmpty(devDataList) && CollUtil.isNotEmpty(standardDevDataList) && CollUtil.isNotEmpty(errSysDtls)) {
|
||||||
String fundCode = "";
|
String fundCode = "";
|
||||||
@@ -2034,7 +2176,7 @@ public class DetectionServiceImpl {
|
|||||||
harmCode = DetectionCodeEnum.P2_50.getCode();
|
harmCode = DetectionCodeEnum.P2_50.getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, List<Map<Double, List<Double>>>> devMap = devHarmListMap(devDataList, standardDevDataList, fundCode, harmCode, harmonicFlag, dataRule);
|
Map<String, List<Map<Double, List<Double>>>> devMap = devHarmListMap(devDataList, standardDevDataList, fundCode, harmCode, harmonicFlag, dataRule, isRemoveMaxElement);
|
||||||
if (ObjectUtil.isNull(devMap)) {
|
if (ObjectUtil.isNull(devMap)) {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
@@ -2141,14 +2283,285 @@ public class DetectionServiceImpl {
|
|||||||
/**
|
/**
|
||||||
* 处理非谐波类取值
|
* 处理非谐波类取值
|
||||||
*
|
*
|
||||||
* @param dev 被检设备原始数据
|
* @param dataRule 数据处理原则
|
||||||
* @param standardDev 与之对齐的标准设备原始数据
|
|
||||||
* @param desc 检测项
|
|
||||||
* @param dataRule 数据处理原则
|
|
||||||
*/
|
*/
|
||||||
public Map<String, List<List<Double>>> devListMap(List<DevData> dev, List<DevData> standardDev, String desc, DictDataEnum dataRule) {
|
public Map<String, List<List<Double>>> devListMap(Map<String, List<List<Double>>> phaseValueList, DictDataEnum dataRule, boolean isRemoveMaxElement) {
|
||||||
Map<String, List<List<Double>>> resultMap = new HashMap<>(3);
|
Map<String, List<List<Double>>> resultMap = new HashMap<>(3);
|
||||||
|
|
||||||
|
List<Double> aDev = new ArrayList<>();
|
||||||
|
List<Double> aStandardDev = new ArrayList<>();
|
||||||
|
|
||||||
|
if (phaseValueList.containsKey(TYPE_A)) {
|
||||||
|
if (phaseValueList.get(TYPE_A).size() >= 1) {
|
||||||
|
aDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_A).get(0), Double.class));
|
||||||
|
aStandardDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_A).get(1), Double.class));
|
||||||
|
} else {
|
||||||
|
log.error("数据异常,phaseValueList.get(TYPE_A).size()=" + phaseValueList.get(TYPE_A).size());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.equals("数据异常,phaseValueList.containsKey(TYPE_A)=" + phaseValueList.containsKey(TYPE_A));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Double> bDev = new ArrayList<>();
|
||||||
|
List<Double> bStandardDev = new ArrayList<>();
|
||||||
|
|
||||||
|
if (phaseValueList.containsKey(TYPE_B)) {
|
||||||
|
if (phaseValueList.get(TYPE_B).size() >= 1) {
|
||||||
|
bDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_B).get(0), Double.class));
|
||||||
|
bStandardDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_B).get(1), Double.class));
|
||||||
|
} else {
|
||||||
|
log.error("数据异常,phaseValueList.get(TYPE_B).size()=" + phaseValueList.get(TYPE_B).size());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.equals("数据异常,phaseValueList.containsKey(TYPE_B)=" + phaseValueList.containsKey(TYPE_B));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Double> cDev = new ArrayList<>();
|
||||||
|
List<Double> cStandardDev = new ArrayList<>();
|
||||||
|
if (phaseValueList.containsKey(TYPE_C)) {
|
||||||
|
if (phaseValueList.get(TYPE_C).size() >= 1) {
|
||||||
|
cDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_C).get(0), Double.class));
|
||||||
|
cStandardDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_C).get(1), Double.class));
|
||||||
|
} else {
|
||||||
|
log.error("数据异常,phaseValueList.get(TYPE_C).size()=" + phaseValueList.get(TYPE_C).size());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.equals("数据异常,phaseValueList.containsKey(TYPE_C)=" + phaseValueList.containsKey(TYPE_C));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Double> tDev = new ArrayList<>();
|
||||||
|
List<Double> tStandardDev = new ArrayList<>();
|
||||||
|
if (phaseValueList.containsKey(TYPE_T)) {
|
||||||
|
if (phaseValueList.get(TYPE_T).size() >= 1) {
|
||||||
|
tDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_T).get(0), Double.class));
|
||||||
|
tStandardDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_T).get(1), Double.class));
|
||||||
|
} else {
|
||||||
|
log.error("数据异常,phaseValueList.get(TYPE_T).size()=" + phaseValueList.get(TYPE_T).size());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.equals("数据异常,phaseValueList.containsKey(TYPE_T)=" + phaseValueList.containsKey(TYPE_T));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRemoveMaxElement) {
|
||||||
|
List<Double> aErrorValueList = new ArrayList<>();
|
||||||
|
List<Double> bErrorValueList = new ArrayList<>();
|
||||||
|
List<Double> cErrorValueList = new ArrayList<>();
|
||||||
|
List<Double> tErrorValueList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < aStandardDev.size(); i++) {
|
||||||
|
aErrorValueList.add(Math.abs(aStandardDev.get(i) - aDev.get(i)));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < bStandardDev.size(); i++) {
|
||||||
|
bErrorValueList.add(Math.abs(bStandardDev.get(i) - bDev.get(i)));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < cStandardDev.size(); i++) {
|
||||||
|
cErrorValueList.add(Math.abs(cStandardDev.get(i) - cDev.get(i)));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < tStandardDev.size(); i++) {
|
||||||
|
tErrorValueList.add(Math.abs(tStandardDev.get(i) - tDev.get(i)));
|
||||||
|
}
|
||||||
|
List<Integer> aErrorValueIdxs = DetectionUtil.sort(aErrorValueList, false);
|
||||||
|
List<Integer> bErrorValueIdxs = DetectionUtil.sort(bErrorValueList, false);
|
||||||
|
List<Integer> cErrorValueIdxs = DetectionUtil.sort(cErrorValueList, false);
|
||||||
|
List<Integer> tErrorValueIdxs = DetectionUtil.sort(tErrorValueList, false);
|
||||||
|
|
||||||
|
int removeCount = aErrorValueIdxs.size() / 2;
|
||||||
|
List<Double> newArray = DetectionUtil.getNewArray(aStandardDev, aErrorValueIdxs.subList(removeCount, aErrorValueIdxs.size()));
|
||||||
|
aStandardDev.clear();
|
||||||
|
aStandardDev.addAll(newArray);
|
||||||
|
newArray = DetectionUtil.getNewArray(aDev, aErrorValueIdxs.subList(removeCount, aErrorValueIdxs.size()));
|
||||||
|
aDev.clear();
|
||||||
|
aDev.addAll(newArray);
|
||||||
|
|
||||||
|
removeCount = bErrorValueIdxs.size() / 2;
|
||||||
|
newArray = DetectionUtil.getNewArray(bStandardDev, bErrorValueIdxs.subList(removeCount, bErrorValueIdxs.size()));
|
||||||
|
bStandardDev.clear();
|
||||||
|
bStandardDev.addAll(newArray);
|
||||||
|
newArray = DetectionUtil.getNewArray(bDev, bErrorValueIdxs.subList(removeCount, bErrorValueIdxs.size()));
|
||||||
|
bDev.clear();
|
||||||
|
bDev.addAll(newArray);
|
||||||
|
|
||||||
|
removeCount = cErrorValueIdxs.size() / 2;
|
||||||
|
newArray = DetectionUtil.getNewArray(cStandardDev, cErrorValueIdxs.subList(removeCount, cErrorValueIdxs.size()));
|
||||||
|
cStandardDev.clear();
|
||||||
|
cStandardDev.addAll(newArray);
|
||||||
|
newArray = DetectionUtil.getNewArray(cDev, cErrorValueIdxs.subList(removeCount, cErrorValueIdxs.size()));
|
||||||
|
cDev.clear();
|
||||||
|
cDev.addAll(newArray);
|
||||||
|
|
||||||
|
removeCount = tErrorValueIdxs.size() / 2;
|
||||||
|
newArray = DetectionUtil.getNewArray(tStandardDev, tErrorValueIdxs.subList(removeCount, tErrorValueIdxs.size()));
|
||||||
|
tStandardDev.clear();
|
||||||
|
tStandardDev.addAll(newArray);
|
||||||
|
newArray = DetectionUtil.getNewArray(tDev, tErrorValueIdxs.subList(removeCount, tErrorValueIdxs.size()));
|
||||||
|
tDev.clear();
|
||||||
|
tDev.addAll(newArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (dataRule) {
|
||||||
|
case SECTION_VALUE: {
|
||||||
|
List<Integer> aIdxs = DetectionUtil.sort(aStandardDev, false);
|
||||||
|
List<Integer> bIdxs = DetectionUtil.sort(bStandardDev, false);
|
||||||
|
List<Integer> cIdxs = DetectionUtil.sort(cStandardDev, false);
|
||||||
|
List<Integer> tIdxs = DetectionUtil.sort(tStandardDev, false);
|
||||||
|
if (aStandardDev.size() > 2) {
|
||||||
|
aStandardDev.remove(0);
|
||||||
|
aStandardDev.remove(aStandardDev.size() - 1);
|
||||||
|
List<Double> newArray = DetectionUtil.getNewArray(aDev, aIdxs.subList(1, aIdxs.size() - 1));
|
||||||
|
aDev.clear();
|
||||||
|
aDev.addAll(newArray);
|
||||||
|
}
|
||||||
|
if (bStandardDev.size() > 2) {
|
||||||
|
bStandardDev.remove(0);
|
||||||
|
bStandardDev.remove(bStandardDev.size() - 1);
|
||||||
|
List<Double> newArray = DetectionUtil.getNewArray(bDev, bIdxs.subList(1, bIdxs.size() - 1));
|
||||||
|
bDev.clear();
|
||||||
|
bDev.addAll(newArray);
|
||||||
|
}
|
||||||
|
if (cStandardDev.size() > 2) {
|
||||||
|
cStandardDev.remove(0);
|
||||||
|
cStandardDev.remove(cStandardDev.size() - 1);
|
||||||
|
List<Double> newArray = DetectionUtil.getNewArray(cDev, cIdxs.subList(1, cIdxs.size() - 1));
|
||||||
|
cDev.clear();
|
||||||
|
cDev.addAll(newArray);
|
||||||
|
}
|
||||||
|
if (tStandardDev.size() > 2) {
|
||||||
|
tStandardDev.remove(0);
|
||||||
|
tStandardDev.remove(tStandardDev.size() - 1);
|
||||||
|
List<Double> newArray = DetectionUtil.getNewArray(tDev, tIdxs.subList(1, tIdxs.size() - 1));
|
||||||
|
tDev.clear();
|
||||||
|
tDev.addAll(newArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CP95_VALUE: {
|
||||||
|
List<Integer> aIdxs = DetectionUtil.sort(aStandardDev, false);
|
||||||
|
List<Integer> bIdxs = DetectionUtil.sort(bStandardDev, false);
|
||||||
|
List<Integer> cIdxs = DetectionUtil.sort(cStandardDev, false);
|
||||||
|
List<Integer> tIdxs = DetectionUtil.sort(tStandardDev, false);
|
||||||
|
if (CollUtil.isNotEmpty(aStandardDev)) {
|
||||||
|
int cp95Idx = DetectionUtil.getCP95Idx(aStandardDev);
|
||||||
|
aStandardDev = Collections.singletonList(aStandardDev.get(cp95Idx));
|
||||||
|
aDev = Collections.singletonList(aDev.get(aIdxs.get(cp95Idx)));
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(bStandardDev)) {
|
||||||
|
int cp95Idx = DetectionUtil.getCP95Idx(bStandardDev);
|
||||||
|
bStandardDev = Collections.singletonList(bStandardDev.get(cp95Idx));
|
||||||
|
bDev = Collections.singletonList(bDev.get(bIdxs.get(cp95Idx)));
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(cStandardDev)) {
|
||||||
|
int cp95Idx = DetectionUtil.getCP95Idx(cStandardDev);
|
||||||
|
cStandardDev = Collections.singletonList(cStandardDev.get(cp95Idx));
|
||||||
|
cDev = Collections.singletonList(cDev.get(cIdxs.get(cp95Idx)));
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(tStandardDev)) {
|
||||||
|
int cp95Idx = DetectionUtil.getCP95Idx(tStandardDev);
|
||||||
|
tStandardDev = Collections.singletonList(tStandardDev.get(cp95Idx));
|
||||||
|
tDev = Collections.singletonList(tDev.get(tIdxs.get(cp95Idx)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AVG_VALUE:
|
||||||
|
aDev = DetectionUtil.getAvgDoubles(aDev);
|
||||||
|
bDev = DetectionUtil.getAvgDoubles(bDev);
|
||||||
|
cDev = DetectionUtil.getAvgDoubles(cDev);
|
||||||
|
tDev = DetectionUtil.getAvgDoubles(tDev);
|
||||||
|
|
||||||
|
aStandardDev = DetectionUtil.getAvgDoubles(aStandardDev);
|
||||||
|
bStandardDev = DetectionUtil.getAvgDoubles(bStandardDev);
|
||||||
|
cStandardDev = DetectionUtil.getAvgDoubles(cStandardDev);
|
||||||
|
tStandardDev = DetectionUtil.getAvgDoubles(tStandardDev);
|
||||||
|
break;
|
||||||
|
case Own_value:
|
||||||
|
break;
|
||||||
|
case AT_WILL_VALUE:
|
||||||
|
if (isRemoveMaxElement) {
|
||||||
|
if (CollUtil.isNotEmpty(aStandardDev) && CollUtil.isNotEmpty(aDev)) {
|
||||||
|
aStandardDev = aStandardDev.subList(aStandardDev.size() - 1, aStandardDev.size());
|
||||||
|
aDev = aDev.subList(aDev.size() - 1, aDev.size());
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(bStandardDev) && CollUtil.isNotEmpty(bDev)) {
|
||||||
|
bStandardDev = bStandardDev.subList(bStandardDev.size() - 1, bStandardDev.size());
|
||||||
|
bDev = bDev.subList(bDev.size() - 1, bDev.size());
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(cStandardDev) && CollUtil.isNotEmpty(cDev)) {
|
||||||
|
cStandardDev = cStandardDev.subList(cStandardDev.size() - 1, cStandardDev.size());
|
||||||
|
cDev = cDev.subList(cDev.size() - 1, cDev.size());
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(tStandardDev) && CollUtil.isNotEmpty(tDev)) {
|
||||||
|
tStandardDev = tStandardDev.subList(tStandardDev.size() - 1, tStandardDev.size());
|
||||||
|
tDev = tDev.subList(tDev.size() - 1, tDev.size());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
List<Double> aErrorValueList = new ArrayList<>();
|
||||||
|
List<Double> bErrorValueList = new ArrayList<>();
|
||||||
|
List<Double> cErrorValueList = new ArrayList<>();
|
||||||
|
List<Double> tErrorValueList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < aStandardDev.size(); i++) {
|
||||||
|
aErrorValueList.add(Math.abs(aStandardDev.get(i) - aDev.get(i)));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < bStandardDev.size(); i++) {
|
||||||
|
bErrorValueList.add(Math.abs(bStandardDev.get(i) - bDev.get(i)));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < cStandardDev.size(); i++) {
|
||||||
|
cErrorValueList.add(Math.abs(cStandardDev.get(i) - cDev.get(i)));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < tStandardDev.size(); i++) {
|
||||||
|
tErrorValueList.add(Math.abs(tStandardDev.get(i) - tDev.get(i)));
|
||||||
|
}
|
||||||
|
List<Integer> aErrorValueIdxs = DetectionUtil.sort(aErrorValueList, true);
|
||||||
|
List<Integer> bErrorValueIdxs = DetectionUtil.sort(bErrorValueList, true);
|
||||||
|
List<Integer> cErrorValueIdxs = DetectionUtil.sort(cErrorValueList, true);
|
||||||
|
List<Integer> tErrorValueIdxs = DetectionUtil.sort(tErrorValueList, true);
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(aStandardDev) && CollUtil.isNotEmpty(aDev)) {
|
||||||
|
Double v = aStandardDev.get(aErrorValueIdxs.get(0));
|
||||||
|
aStandardDev.clear();
|
||||||
|
aStandardDev.add(v);
|
||||||
|
v = aDev.get(aErrorValueIdxs.get(0));
|
||||||
|
aDev.clear();
|
||||||
|
aDev.add(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(bStandardDev) && CollUtil.isNotEmpty(bDev)) {
|
||||||
|
Double v = bStandardDev.get(bErrorValueIdxs.get(0));
|
||||||
|
bStandardDev.clear();
|
||||||
|
bStandardDev.add(v);
|
||||||
|
v = bDev.get(bErrorValueIdxs.get(0));
|
||||||
|
bDev.clear();
|
||||||
|
bDev.add(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(cStandardDev) && CollUtil.isNotEmpty(cDev)) {
|
||||||
|
Double v = cStandardDev.get(cErrorValueIdxs.get(0));
|
||||||
|
cStandardDev.clear();
|
||||||
|
cStandardDev.add(v);
|
||||||
|
v = cDev.get(cErrorValueIdxs.get(0));
|
||||||
|
cDev.clear();
|
||||||
|
cDev.add(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(tStandardDev) && CollUtil.isNotEmpty(tDev)) {
|
||||||
|
Double v = tStandardDev.get(tErrorValueIdxs.get(0));
|
||||||
|
tStandardDev.clear();
|
||||||
|
tStandardDev.add(v);
|
||||||
|
v = tDev.get(tErrorValueIdxs.get(0));
|
||||||
|
tDev.clear();
|
||||||
|
tDev.add(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
resultMap.put(TYPE_A, Arrays.asList(aDev, aStandardDev));
|
||||||
|
resultMap.put(TYPE_B, Arrays.asList(bDev, bStandardDev));
|
||||||
|
resultMap.put(TYPE_C, Arrays.asList(cDev, cStandardDev));
|
||||||
|
if (CollUtil.isNotEmpty(tDev)) {
|
||||||
|
resultMap.put(TYPE_T, Arrays.asList(tDev, tStandardDev));
|
||||||
|
}
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, List<List<Double>>> getPhaseValueList(List<DevData> dev, List<DevData> standardDev, String desc) {
|
||||||
|
Map<String, List<List<Double>>> resultMap = new HashMap<>(3);
|
||||||
List<Double> aDev = new ArrayList<>();
|
List<Double> aDev = new ArrayList<>();
|
||||||
List<Double> aStandardDev = new ArrayList<>();
|
List<Double> aStandardDev = new ArrayList<>();
|
||||||
List<Double> bDev = new ArrayList<>();
|
List<Double> bDev = new ArrayList<>();
|
||||||
@@ -2202,87 +2615,12 @@ public class DetectionServiceImpl {
|
|||||||
.map(x -> x.getT().doubleValue())
|
.map(x -> x.getT().doubleValue())
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
List<Integer> aIdxs = DetectionUtil.sort(aStandardDev, false);
|
|
||||||
List<Integer> bIdxs = DetectionUtil.sort(bStandardDev, false);
|
|
||||||
List<Integer> cIdxs = DetectionUtil.sort(cStandardDev, false);
|
|
||||||
List<Integer> tIdxs = DetectionUtil.sort(tStandardDev, false);
|
|
||||||
switch (dataRule) {
|
|
||||||
case SECTION_VALUE:
|
|
||||||
if (aStandardDev.size() > 2) {
|
|
||||||
aStandardDev.remove(0);
|
|
||||||
aStandardDev.remove(aStandardDev.size() - 1);
|
|
||||||
List<Double> newArray = DetectionUtil.getNewArray(aDev, aIdxs.subList(1, aIdxs.size() - 1));
|
|
||||||
aDev.clear();
|
|
||||||
aDev.addAll(newArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bStandardDev.size() > 2) {
|
|
||||||
bStandardDev.remove(0);
|
|
||||||
bStandardDev.remove(bStandardDev.size() - 1);
|
|
||||||
List<Double> newArray = DetectionUtil.getNewArray(bDev, bIdxs.subList(1, bIdxs.size() - 1));
|
|
||||||
bDev.clear();
|
|
||||||
bDev.addAll(newArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cStandardDev.size() > 2) {
|
|
||||||
cStandardDev.remove(0);
|
|
||||||
cStandardDev.remove(cStandardDev.size() - 1);
|
|
||||||
List<Double> newArray = DetectionUtil.getNewArray(cDev, cIdxs.subList(1, cIdxs.size() - 1));
|
|
||||||
cDev.clear();
|
|
||||||
cDev.addAll(newArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tStandardDev.size() > 2) {
|
|
||||||
tStandardDev.remove(0);
|
|
||||||
tStandardDev.remove(tStandardDev.size() - 1);
|
|
||||||
List<Double> newArray = DetectionUtil.getNewArray(tDev, tIdxs.subList(1, tIdxs.size() - 1));
|
|
||||||
tDev.clear();
|
|
||||||
tDev.addAll(newArray);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CP95_VALUE:
|
|
||||||
if (CollUtil.isNotEmpty(aStandardDev)) {
|
|
||||||
int cp95Idx = DetectionUtil.getCP95Idx(aStandardDev);
|
|
||||||
aStandardDev = Collections.singletonList(aStandardDev.get(cp95Idx));
|
|
||||||
aDev = Collections.singletonList(aDev.get(aIdxs.get(cp95Idx)));
|
|
||||||
}
|
|
||||||
if (CollUtil.isNotEmpty(bStandardDev)) {
|
|
||||||
int cp95Idx = DetectionUtil.getCP95Idx(bStandardDev);
|
|
||||||
bStandardDev = Collections.singletonList(bStandardDev.get(cp95Idx));
|
|
||||||
bDev = Collections.singletonList(bDev.get(bIdxs.get(cp95Idx)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(cStandardDev)) {
|
|
||||||
int cp95Idx = DetectionUtil.getCP95Idx(cStandardDev);
|
|
||||||
cStandardDev = Collections.singletonList(cStandardDev.get(cp95Idx));
|
|
||||||
cDev = Collections.singletonList(cDev.get(cIdxs.get(cp95Idx)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(tStandardDev)) {
|
|
||||||
int cp95Idx = DetectionUtil.getCP95Idx(tStandardDev);
|
|
||||||
tStandardDev = Collections.singletonList(tStandardDev.get(cp95Idx));
|
|
||||||
tDev = Collections.singletonList(tDev.get(tIdxs.get(cp95Idx)));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case AVG_VALUE:
|
|
||||||
aDev = DetectionUtil.getAvgDoubles(aDev);
|
|
||||||
bDev = DetectionUtil.getAvgDoubles(bDev);
|
|
||||||
cDev = DetectionUtil.getAvgDoubles(cDev);
|
|
||||||
tDev = DetectionUtil.getAvgDoubles(tDev);
|
|
||||||
|
|
||||||
aStandardDev = DetectionUtil.getAvgDoubles(aStandardDev);
|
|
||||||
bStandardDev = DetectionUtil.getAvgDoubles(bStandardDev);
|
|
||||||
cStandardDev = DetectionUtil.getAvgDoubles(cStandardDev);
|
|
||||||
tStandardDev = DetectionUtil.getAvgDoubles(tStandardDev);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
resultMap.put(TYPE_A, Arrays.asList(aDev, aStandardDev));
|
resultMap.put(TYPE_A, Arrays.asList(aDev, aStandardDev));
|
||||||
resultMap.put(TYPE_B, Arrays.asList(bDev, bStandardDev));
|
resultMap.put(TYPE_B, Arrays.asList(bDev, bStandardDev));
|
||||||
resultMap.put(TYPE_C, Arrays.asList(cDev, cStandardDev));
|
resultMap.put(TYPE_C, Arrays.asList(cDev, cStandardDev));
|
||||||
if (CollUtil.isNotEmpty(tDev)) {
|
resultMap.put(TYPE_T, Arrays.asList(tDev, tStandardDev));
|
||||||
resultMap.put(TYPE_T, Arrays.asList(tDev, tStandardDev));
|
|
||||||
}
|
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2302,8 +2640,7 @@ public class DetectionServiceImpl {
|
|||||||
String fundCode,
|
String fundCode,
|
||||||
String harmCode,
|
String harmCode,
|
||||||
Integer harmonicFlag,
|
Integer harmonicFlag,
|
||||||
DictDataEnum dataRule) {
|
DictDataEnum dataRule, boolean isRemoveMaxElement) {
|
||||||
System.out.println("aaa" + dev.size() + " " + standardDev.size());
|
|
||||||
Map<String, List<Map<Double, List<Double>>>> resultMap = new HashMap<>(3);
|
Map<String, List<Map<Double, List<Double>>>> resultMap = new HashMap<>(3);
|
||||||
|
|
||||||
// key为相别、value{key为谐波次数,value为按数据处理原则处理后的数据}
|
// key为相别、value{key为谐波次数,value为按数据处理原则处理后的数据}
|
||||||
@@ -2328,27 +2665,6 @@ public class DetectionServiceImpl {
|
|||||||
first1 = devSqlData.stream().filter(j -> fundCode.equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
first1 = devSqlData.stream().filter(j -> fundCode.equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||||
first2 = standardDevSqlData.stream().filter(j -> fundCode.equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
first2 = standardDevSqlData.stream().filter(j -> fundCode.equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||||
}
|
}
|
||||||
// // 如果角型接法中,不存在线电压谐波电压基波有效值,则取相电压谐波电压基波有效值进行计算
|
|
||||||
// if (!first1.isPresent()) {
|
|
||||||
// if (DetectionCodeEnum.PU1.getCode().equals(fundCode)) {
|
|
||||||
// first1 = devSqlData.stream().filter(j -> DetectionCodeEnum.U1.getCode().equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// // 防止出现有PU1而没有PV2_50、SV_1_49的情况
|
|
||||||
// if ((DetectionCodeEnum.PV2_50.getCode().equals(harmCode) || DetectionCodeEnum.PSV_1_49.getCode().equals(harmCode)) && DetectionCodeEnum.PU1.getCode().equals(fundCode)) {
|
|
||||||
// first1 = devSqlData.stream().filter(j -> DetectionCodeEnum.U1.getCode().equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (!first2.isPresent()) {
|
|
||||||
// if (DetectionCodeEnum.PU1.getCode().equals(fundCode)) {
|
|
||||||
// first2 = devSqlData.stream().filter(j -> DetectionCodeEnum.U1.getCode().equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// // 防止出现有PU1而没有PV2_50、SV_1_49的情况
|
|
||||||
// if ((DetectionCodeEnum.PV2_50.getCode().equals(harmCode) || DetectionCodeEnum.PSV_1_49.getCode().equals(harmCode)) && DetectionCodeEnum.PU1.getCode().equals(fundCode)) {
|
|
||||||
// first2 = devSqlData.stream().filter(j -> DetectionCodeEnum.U1.getCode().equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
DevData.SqlDataDTO fund1 = null;
|
DevData.SqlDataDTO fund1 = null;
|
||||||
DevData.SqlDataDTO fund2 = null;
|
DevData.SqlDataDTO fund2 = null;
|
||||||
@@ -2365,23 +2681,6 @@ public class DetectionServiceImpl {
|
|||||||
if (CollUtil.isEmpty(devHarmList) || CollUtil.isEmpty(stdDevHarmList)) {
|
if (CollUtil.isEmpty(devHarmList) || CollUtil.isEmpty(stdDevHarmList)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// // 如果角型接法中,不存在线电压谐波电压含有率,则取相电压谐波电压含有率进行计算
|
|
||||||
// if (CollUtil.isEmpty(devHarmList)) {
|
|
||||||
// if (DetectionCodeEnum.PV2_50.getCode().equals(harmCode)) {
|
|
||||||
// devHarmList = dev.get(i).getSqlDataHarm().stream().filter(x -> DetectionCodeEnum.V2_50.getCode().equals(x.getDesc())).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
// if (DetectionCodeEnum.PSV_1_49.getCode().equals(harmCode)) {
|
|
||||||
// devHarmList = dev.get(i).getSqlDataHarm().stream().filter(x -> DetectionCodeEnum.SV_1_49.getCode().equals(x.getDesc())).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (CollUtil.isEmpty(stdDevHarmList)) {
|
|
||||||
// if (DetectionCodeEnum.PV2_50.getCode().equals(harmCode)) {
|
|
||||||
// stdDevHarmList = standardDev.get(i).getSqlDataHarm().stream().filter(x -> DetectionCodeEnum.V2_50.getCode().equals(x.getDesc())).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
// if (DetectionCodeEnum.PSV_1_49.getCode().equals(harmCode)) {
|
|
||||||
// stdDevHarmList = standardDev.get(i).getSqlDataHarm().stream().filter(x -> DetectionCodeEnum.SV_1_49.getCode().equals(x.getDesc())).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(devHarmList) && CollUtil.isNotEmpty(stdDevHarmList)) {
|
if (CollUtil.isNotEmpty(devHarmList) && CollUtil.isNotEmpty(stdDevHarmList)) {
|
||||||
DevData.SqlDataHarmDTO devHarm = devHarmList.get(0);
|
DevData.SqlDataHarmDTO devHarm = devHarmList.get(0);
|
||||||
@@ -2403,38 +2702,87 @@ public class DetectionServiceImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
standardDevMap.forEach((typeKey, typeValue) -> {
|
standardDevMap.forEach((phase, harmonicMap) -> {
|
||||||
typeValue.forEach((key, value) -> {
|
harmonicMap.forEach((harmonicNum, value) -> {
|
||||||
|
List<Double> devPhaseHarmData = devMap.get(phase).get(harmonicNum);
|
||||||
|
if (isRemoveMaxElement) {
|
||||||
|
List<Double> errorValueList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < value.size(); i++) {
|
||||||
|
errorValueList.add(Math.abs(value.get(i) - devPhaseHarmData.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> idxErrorValueList = DetectionUtil.sort(errorValueList, false);
|
||||||
|
int removeCount = idxErrorValueList.size() / 2;
|
||||||
|
List<Double> newArray = DetectionUtil.getNewArray(value, idxErrorValueList.subList(removeCount, idxErrorValueList.size()));
|
||||||
|
value.clear();
|
||||||
|
value.addAll(newArray);
|
||||||
|
newArray = DetectionUtil.getNewArray(devPhaseHarmData, idxErrorValueList.subList(removeCount, idxErrorValueList.size()));
|
||||||
|
devPhaseHarmData.clear();
|
||||||
|
devPhaseHarmData.addAll(newArray);
|
||||||
|
}
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(value)) {
|
if (CollUtil.isNotEmpty(value)) {
|
||||||
List<Integer> idx = DetectionUtil.sort(value, false);
|
|
||||||
switch (dataRule) {
|
switch (dataRule) {
|
||||||
case SECTION_VALUE:
|
case SECTION_VALUE: {
|
||||||
|
List<Integer> idx = DetectionUtil.sort(value, false);
|
||||||
if (value.size() > 2) {
|
if (value.size() > 2) {
|
||||||
value.remove(0);
|
value.remove(0);
|
||||||
value.remove(value.size() - 1);
|
value.remove(value.size() - 1);
|
||||||
List<Double> newArray = DetectionUtil.getNewArray(devMap.get(typeKey).get(key), idx.subList(1, idx.size() - 1));
|
List<Double> newArray = DetectionUtil.getNewArray(devPhaseHarmData, idx.subList(1, idx.size() - 1));
|
||||||
devMap.get(typeKey).get(key).clear();
|
devPhaseHarmData.clear();
|
||||||
devMap.get(typeKey).get(key).addAll(newArray);
|
devPhaseHarmData.addAll(newArray);
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case CP95_VALUE:
|
case CP95_VALUE:
|
||||||
if (CollUtil.isNotEmpty(value)) {
|
if (CollUtil.isNotEmpty(value)) {
|
||||||
|
List<Integer> idx = DetectionUtil.sort(value, false);
|
||||||
int cp95Idx = DetectionUtil.getCP95Idx(value);
|
int cp95Idx = DetectionUtil.getCP95Idx(value);
|
||||||
List<Double> newValue = Collections.singletonList(value.get(cp95Idx));
|
List<Double> newValue = Collections.singletonList(value.get(cp95Idx));
|
||||||
value.clear();
|
value.clear();
|
||||||
value.addAll(newValue);
|
value.addAll(newValue);
|
||||||
Double devCP95Data = devMap.get(typeKey).get(key).get(idx.get(cp95Idx));
|
Double devCP95Data = devPhaseHarmData.get(idx.get(cp95Idx));
|
||||||
devMap.get(typeKey).get(key).clear();
|
devPhaseHarmData.clear();
|
||||||
devMap.get(typeKey).get(key).add(devCP95Data);
|
devPhaseHarmData.add(devCP95Data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AVG_VALUE:
|
case AVG_VALUE:
|
||||||
List<Double> avgDoubles = DetectionUtil.getAvgDoubles(value);
|
List<Double> avgDoubles = DetectionUtil.getAvgDoubles(value);
|
||||||
value.clear();
|
value.clear();
|
||||||
value.addAll(avgDoubles);
|
value.addAll(avgDoubles);
|
||||||
List<Double> devAvgData = DetectionUtil.getAvgDoubles(devMap.get(typeKey).get(key));
|
List<Double> devAvgData = DetectionUtil.getAvgDoubles(devMap.get(phase).get(harmonicNum));
|
||||||
devMap.get(typeKey).get(key).clear();
|
devPhaseHarmData.clear();
|
||||||
devMap.get(typeKey).get(key).addAll(devAvgData);
|
devPhaseHarmData.addAll(devAvgData);
|
||||||
|
break;
|
||||||
|
case Own_value:
|
||||||
|
break;
|
||||||
|
case AT_WILL_VALUE:
|
||||||
|
if (isRemoveMaxElement) {
|
||||||
|
if (CollUtil.isNotEmpty(value)) {
|
||||||
|
Double v = value.get(value.size() - 1);
|
||||||
|
value.clear();
|
||||||
|
value.add(v);
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(devPhaseHarmData)) {
|
||||||
|
Double v = devPhaseHarmData.get(devPhaseHarmData.size() - 1);
|
||||||
|
devPhaseHarmData.clear();
|
||||||
|
devPhaseHarmData.add(v);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
List<Double> errorValueList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < value.size(); i++) {
|
||||||
|
errorValueList.add(Math.abs(value.get(i) - devPhaseHarmData.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> idxErrorValueList = DetectionUtil.sort(errorValueList, true);
|
||||||
|
Double v = value.get(idxErrorValueList.get(0));
|
||||||
|
value.clear();
|
||||||
|
value.add(v);
|
||||||
|
v = devPhaseHarmData.get(idxErrorValueList.get(0));
|
||||||
|
devPhaseHarmData.clear();
|
||||||
|
devPhaseHarmData.add(v);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.gather.detection.handler.SocketContrastResponseService;
|
import com.njcn.gather.detection.handler.*;
|
||||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
|
||||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
|
||||||
import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
|
import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
|
||||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
@@ -21,6 +19,8 @@ import com.njcn.gather.detection.util.business.DetectionCommunicateUtil;
|
|||||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
|
import com.njcn.gather.detection.util.socket.XiNumberManager;
|
||||||
|
import com.njcn.gather.detection.util.socket.cilent.NettyContrastClientHandler;
|
||||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||||
import com.njcn.gather.device.pojo.po.PqDev;
|
import com.njcn.gather.device.pojo.po.PqDev;
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
@@ -38,6 +38,7 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
|||||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||||
import com.njcn.gather.source.service.IPqSourceService;
|
import com.njcn.gather.source.service.IPqSourceService;
|
||||||
|
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import com.njcn.web.utils.HttpServletUtil;
|
import com.njcn.web.utils.HttpServletUtil;
|
||||||
@@ -73,8 +74,12 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
private final SocketDevResponseService socketDevResponseService;
|
private final SocketDevResponseService socketDevResponseService;
|
||||||
private final SocketSourceResponseService socketSourceResponseService;
|
private final SocketSourceResponseService socketSourceResponseService;
|
||||||
private final SocketContrastResponseService socketContrastResponseService;
|
private final SocketContrastResponseService socketContrastResponseService;
|
||||||
|
private final SocketFreqConverterService socketFreqConverterService;
|
||||||
|
private final SocketFreqConverterDevService socketFreqConverterDevService;
|
||||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||||
private final SocketManager socketManager;
|
private final SocketManager socketManager;
|
||||||
|
private final ISysTestConfigService sysTestConfigService;
|
||||||
|
|
||||||
|
|
||||||
@Value("${report.reportDir}")
|
@Value("${report.reportDir}")
|
||||||
private String alignDataFilePath;
|
private String alignDataFilePath;
|
||||||
@@ -358,6 +363,59 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getCanCoefficient() {
|
||||||
|
return CollUtil.isNotEmpty(DetectionServiceImpl.vAndIResultMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startCoefficient() {
|
||||||
|
if (CollUtil.isNotEmpty(DetectionServiceImpl.vAndIResultMap)) {
|
||||||
|
// 是否进行系数校准
|
||||||
|
//万一录波了这里就进不来了,但是在误差处理的时候DetectionServiceImpl.vAndIResultMap该集合会保留不符合的结果
|
||||||
|
|
||||||
|
XiNumberManager.xiDevList.clear();
|
||||||
|
XiNumberManager.devXiNumDataMap.clear();
|
||||||
|
List<String> stdIpList = DetectionServiceImpl.vAndIResultMap.values().stream().map(DetectionServiceImpl.VAndIResult::getIp).collect(Collectors.toList());
|
||||||
|
XiNumberManager.xiDevList = FormalTestManager.standardDevList.stream().filter(d -> stdIpList.contains(d.getDevIP())).collect(Collectors.toList());
|
||||||
|
// 逐一设备向通讯模块要原始系数
|
||||||
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
|
||||||
|
PreDetection preDetection = XiNumberManager.xiDevList.get(0);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("devIP", preDetection.getDevIP());
|
||||||
|
map.put("chnNum", preDetection.getDevChns());
|
||||||
|
socketMsg.setData(JSON.toJSONString(map));
|
||||||
|
SocketManager.sendMsg(NettyContrastClientHandler.param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, JSON.toJSONString(socketMsg));
|
||||||
|
|
||||||
|
FormalTestManager.currentStep = SourceOperateCodeEnum.Coefficient_Check;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startFreqConverter(String loginName, String converterId, String monitorId) {
|
||||||
|
String freqConverterTag = loginName + CnSocketUtil.FREQ_CONVERTER_TAG;
|
||||||
|
String devTag = loginName + CnSocketUtil.DEV_TAG;
|
||||||
|
socketFreqConverterService.connectSocket(freqConverterTag);
|
||||||
|
socketFreqConverterDevService.connectSocket(devTag);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (SocketManager.isChannelActive(freqConverterTag) && SocketManager.isChannelActive(devTag)) {
|
||||||
|
socketFreqConverterService.connectionFreqConverter(freqConverterTag, converterId, monitorId);
|
||||||
|
socketFreqConverterDevService.connectionDev(devTag, converterId, monitorId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopFreqConverter(String converterTag, String devTag) {
|
||||||
|
socketFreqConverterService.stopTest(converterTag, devTag);
|
||||||
|
socketFreqConverterDevService.stopTest(converterTag, converterTag);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 比对式-与通信模块进行连接
|
* 比对式-与通信模块进行连接
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.gather.detection.util;
|
package com.njcn.gather.detection.util;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.njcn.gather.detection.pojo.po.DevData;
|
import com.njcn.gather.detection.pojo.po.DevData;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -421,7 +422,7 @@ public class DetectionUtil {
|
|||||||
}
|
}
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -437,4 +438,94 @@ public class DetectionUtil {
|
|||||||
System.out.println(" 文件大小: " + file.length() + " bytes");
|
System.out.println(" 文件大小: " + file.length() + " bytes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取皮尔逊系数
|
||||||
|
*
|
||||||
|
* <p>相关系数绝对值|r|所代表的相关强度</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>0.8 - 1.0:极强相关</li>
|
||||||
|
* <li>0.6 - 0.8:强相关</li>
|
||||||
|
* <li>0.4 - 0.6:中等程度相关</li>
|
||||||
|
* <li>0.2 - 0.4:弱相关</li>
|
||||||
|
* <li>0.0 - 0.2:极弱相关或无相关</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static BigDecimal getPearsonCorrelationCoefficient(List<Double> x, List<Double> y) {
|
||||||
|
Double xAvg = x.parallelStream().mapToDouble(Double::doubleValue).average().orElse(0.0);
|
||||||
|
Double yAvg = y.parallelStream().mapToDouble(Double::doubleValue).average().orElse(0.0);
|
||||||
|
|
||||||
|
// 协方差求和
|
||||||
|
BigDecimal covarianceSum = BigDecimal.ZERO;
|
||||||
|
// x的方差
|
||||||
|
BigDecimal varianceX = BigDecimal.ZERO;
|
||||||
|
// y的方差
|
||||||
|
BigDecimal varianceY = BigDecimal.ZERO;
|
||||||
|
for (int i = 0; i < x.size(); i++) {
|
||||||
|
covarianceSum = covarianceSum.add(BigDecimal.valueOf((x.get(i) - xAvg) * (y.get(i) - yAvg)));
|
||||||
|
varianceX = varianceX.add(BigDecimal.valueOf(Math.pow(x.get(i) - xAvg, 2)));
|
||||||
|
varianceY = varianceY.add(BigDecimal.valueOf(Math.pow(y.get(i) - yAvg, 2)));
|
||||||
|
}
|
||||||
|
BigDecimal fm = BigDecimal.valueOf(Math.sqrt(varianceX.doubleValue()) * Math.sqrt(varianceY.doubleValue()));
|
||||||
|
if (NumberUtil.equals(fm.doubleValue(), BigDecimal.ZERO.doubleValue())) {
|
||||||
|
if (NumberUtil.equals(covarianceSum, BigDecimal.ZERO)) {
|
||||||
|
return BigDecimal.valueOf(1.0);
|
||||||
|
} else {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return BigDecimal.valueOf(Math.abs(covarianceSum.divide(fm, 8, BigDecimal.ROUND_HALF_UP).doubleValue())); //相关系数
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比值一致性,获取CV系数
|
||||||
|
*
|
||||||
|
* <p>一致性等级</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>CV<1%:非常优秀</li>
|
||||||
|
* <li>1%≤CV<5%:优良</li>
|
||||||
|
* <li>5%≤CV<10%:良好</li>
|
||||||
|
* <li>10%≤CV<20%:中等</li>
|
||||||
|
* <li>20%≤CV:较差</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static BigDecimal getCvCoefficient(List<Double> x, List<Double> y) {
|
||||||
|
List<BigDecimal> ratioList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < x.size(); i++) {
|
||||||
|
ratioList.add(BigDecimal.valueOf(x.get(i) / y.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal avg = BigDecimal.valueOf(ratioList.parallelStream().mapToDouble(BigDecimal::doubleValue).average().orElse(0.0));
|
||||||
|
BigDecimal variance = BigDecimal.valueOf(
|
||||||
|
ratioList.parallelStream().mapToDouble(BigDecimal::doubleValue)
|
||||||
|
.map(v -> Math.pow(v - avg.doubleValue(), 2)).average().orElse(0.0));
|
||||||
|
|
||||||
|
return BigDecimal.valueOf(Math.sqrt(variance.doubleValue()) / avg.doubleValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算新的系数
|
||||||
|
*
|
||||||
|
* @param devList
|
||||||
|
* @param stdDevList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Double getNewXi(List<Double> devList, List<Double> stdDevList) {
|
||||||
|
ArrayList<Double> xiList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < stdDevList.size(); i++) {
|
||||||
|
if (!stdDevList.get(i).equals(0)) {
|
||||||
|
BigDecimal bigDecimalDev = BigDecimal.valueOf(devList.get(i));
|
||||||
|
BigDecimal bigDecimalStdDev = BigDecimal.valueOf(stdDevList.get(i));
|
||||||
|
xiList.add((bigDecimalDev.subtract(bigDecimalStdDev)).divide(BigDecimal.valueOf(2.0).multiply(bigDecimalDev), 8, BigDecimal.ROUND_HALF_UP).doubleValue() + 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return xiList.stream().mapToDouble(Double::doubleValue).average().orElse(1.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
|||||||
*/
|
*/
|
||||||
public class CnSocketUtil {
|
public class CnSocketUtil {
|
||||||
|
|
||||||
|
public final static String FREQ_CONVERTER_TAG="_FreqConverter";
|
||||||
|
|
||||||
public final static String DEV_TAG = "_Dev";
|
public final static String DEV_TAG = "_Dev";
|
||||||
|
|
||||||
public final static String CONTRAST_DEV_TAG = "_Contrast_Dev";
|
public final static String CONTRAST_DEV_TAG = "_Contrast_Dev";
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ public class FormalTestManager {
|
|||||||
// 当前步骤
|
// 当前步骤
|
||||||
public static SourceOperateCodeEnum currentStep;
|
public static SourceOperateCodeEnum currentStep;
|
||||||
|
|
||||||
|
public static SourceOperateCodeEnum freqConverterStep;
|
||||||
|
public static SourceOperateCodeEnum freqConverterDevStep;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* key:设备ip,value:当前设备下面的监测点ID(ip_通道号)
|
* key:设备ip,value:当前设备下面的监测点ID(ip_通道号)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -81,6 +81,17 @@ public class SocketManager {
|
|||||||
socketGroup.remove(userId);
|
socketGroup.remove(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearUser(String userId) {
|
||||||
|
Channel channel = socketSessions.remove(userId);
|
||||||
|
NioEventLoopGroup eventExecutors = socketGroup.remove(userId);
|
||||||
|
if (ObjectUtil.isNotNull(eventExecutors)) {
|
||||||
|
eventExecutors.shutdownGracefully();
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(channel)) {
|
||||||
|
log.info("{}__{}已清理客户端会话", userId, channel.id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Channel getChannelByUserId(String userId) {
|
public static Channel getChannelByUserId(String userId) {
|
||||||
return socketSessions.get(userId);
|
return socketSessions.get(userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,109 @@ public class NettyClient {
|
|||||||
*/
|
*/
|
||||||
private static NettyClient instance;
|
private static NettyClient instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 静态方法:智能连接变频器设备(兼容性包装)
|
||||||
|
*
|
||||||
|
* @param ip IP地址
|
||||||
|
* @param port 端口号
|
||||||
|
* @param ChannelId Channel唯一标识
|
||||||
|
* @param handler 变频器处理器
|
||||||
|
*/
|
||||||
|
public static void commonConnect(String ip, Integer port, String ChannelId,
|
||||||
|
SimpleChannelInboundHandler handler) {
|
||||||
|
if (instance != null) {
|
||||||
|
instance.executeCommonConnect(ip, port, ChannelId, handler);
|
||||||
|
} else {
|
||||||
|
log.error("NettyClient未初始化,无法创建连接");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行变频器Socket连接建立流程
|
||||||
|
*
|
||||||
|
* @param ip 目标服务器IP地址
|
||||||
|
* @param port 目标服务器端口号
|
||||||
|
* @param ChannelId Channel唯一标识id
|
||||||
|
* @param handler 变频器业务处理器
|
||||||
|
*/
|
||||||
|
private static void executeCommonConnect(String ip, Integer port,
|
||||||
|
String ChannelId,
|
||||||
|
SimpleChannelInboundHandler handler) {
|
||||||
|
NioEventLoopGroup group = createEventLoopGroup();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Bootstrap bootstrap = configureBootstrap(group);
|
||||||
|
ChannelInitializer<NioSocketChannel> initializer = createCommonChannelInitializer(ChannelId, handler);
|
||||||
|
bootstrap.handler(initializer);
|
||||||
|
ChannelFuture channelFuture = bootstrap.connect(ip, port).sync();
|
||||||
|
handleCommonConnectionResult(channelFuture, ChannelId, handler, group);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleCommonConnectionException(e, ChannelId, handler, group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建通用通道初始化器
|
||||||
|
*
|
||||||
|
* @param channelId Channel唯一标识id
|
||||||
|
* @param handler 通用业务处理器
|
||||||
|
* @return ChannelInitializer 通道初始化器
|
||||||
|
*/
|
||||||
|
private static ChannelInitializer<NioSocketChannel> createCommonChannelInitializer(
|
||||||
|
String channelId, SimpleChannelInboundHandler handler) {
|
||||||
|
return new ChannelInitializer<NioSocketChannel>() {
|
||||||
|
@Override
|
||||||
|
protected void initChannel(NioSocketChannel ch) {
|
||||||
|
ch.pipeline()
|
||||||
|
.addLast(new LineBasedFrameDecoder(10240 * 2))
|
||||||
|
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||||
|
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||||
|
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
|
||||||
|
.addLast(handler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理通用连接结果
|
||||||
|
*
|
||||||
|
* @param channelFuture 连接Future对象
|
||||||
|
* @param channelId Channel唯一标识符
|
||||||
|
* @param handler 通用业务处理器
|
||||||
|
* @param group 事件循环组
|
||||||
|
*/
|
||||||
|
private static void handleCommonConnectionResult(ChannelFuture channelFuture,
|
||||||
|
String channelId,
|
||||||
|
SimpleChannelInboundHandler handler,
|
||||||
|
NioEventLoopGroup group) {
|
||||||
|
channelFuture.addListener((ChannelFutureListener) ch -> {
|
||||||
|
if (!ch.isSuccess()) {
|
||||||
|
log.error("连接Socket失败,channelId={}", channelId);
|
||||||
|
group.shutdownGracefully();
|
||||||
|
} else {
|
||||||
|
log.info("连接Socket成功,channel={}, channelId={}",
|
||||||
|
channelId, channelFuture.channel().id());
|
||||||
|
SocketManager.addGroup(channelId, group);
|
||||||
|
SocketManager.addUser(channelId, channelFuture.channel());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理通用连接异常
|
||||||
|
*
|
||||||
|
* @param e 异常对象
|
||||||
|
* @param channelId Channel唯一标识id
|
||||||
|
* @param handler 通用业务处理器
|
||||||
|
* @param group 事件循环组
|
||||||
|
*/
|
||||||
|
private static void handleCommonConnectionException(Exception e, String channelId,
|
||||||
|
SimpleChannelInboundHandler handler,
|
||||||
|
NioEventLoopGroup group) {
|
||||||
|
log.error("连接Socket服务端发生异常,channelId={}, error={}", channelId, e.getMessage(), e);
|
||||||
|
group.shutdownGracefully();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package com.njcn.gather.detection.util.socket.cilent;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.njcn.gather.detection.handler.SocketFreqConverterService;
|
||||||
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
|
import io.netty.handler.timeout.IdleState;
|
||||||
|
import io.netty.handler.timeout.IdleStateEvent;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变频器Netty客户端处理器
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class NettyFreqConverterClientHandler extends SimpleChannelInboundHandler<String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变频器Channel唯一标识符
|
||||||
|
*/
|
||||||
|
private final String converterChannelTag;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变频器Socket响应服务
|
||||||
|
*/
|
||||||
|
private final SocketFreqConverterService socketFreqConverterService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重连次数
|
||||||
|
*/
|
||||||
|
private int reconnectAttempts = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大重连次数
|
||||||
|
*/
|
||||||
|
private static final int MAX_RECONNECT_ATTEMPTS = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重连间隔(毫秒)
|
||||||
|
*/
|
||||||
|
private static final long RECONNECT_INTERVAL_MS = 5000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造方法
|
||||||
|
*
|
||||||
|
* @param converterChannelTag 变频器Chanel唯一标识符
|
||||||
|
* @param socketFreqConverterService 变频器Socket响应服务
|
||||||
|
*/
|
||||||
|
public NettyFreqConverterClientHandler(String converterChannelTag, SocketFreqConverterService socketFreqConverterService) {
|
||||||
|
this.converterChannelTag = converterChannelTag;
|
||||||
|
this.socketFreqConverterService = socketFreqConverterService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
log.info("变频器连接已建立,converterChannelTag={}, channelId={}", converterChannelTag, ctx.channel().id());
|
||||||
|
|
||||||
|
// 注册Channel到SocketManager
|
||||||
|
SocketManager.addUser(converterChannelTag, ctx.channel());
|
||||||
|
|
||||||
|
super.channelActive(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||||
|
if (StrUtil.isBlank(msg)) {
|
||||||
|
log.debug("收到空消息,忽略,converterChannelTag={}", converterChannelTag);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("收到变频器消息,converterChannelTag={}, msg={}", converterChannelTag, msg);
|
||||||
|
|
||||||
|
// 处理状态数据
|
||||||
|
socketFreqConverterService.handleRead(converterChannelTag, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
log.warn("变频器连接已断开,converterChannelTag={}", converterChannelTag);
|
||||||
|
|
||||||
|
// 移除Channel
|
||||||
|
socketFreqConverterService.cleanup(converterChannelTag, false);
|
||||||
|
|
||||||
|
// 尝试重连
|
||||||
|
if (reconnectAttempts < MAX_RECONNECT_ATTEMPTS) {
|
||||||
|
reconnectAttempts++;
|
||||||
|
log.info("尝试重连变频器,converterChannelTag={}, 第{}次重连", converterChannelTag, reconnectAttempts);
|
||||||
|
|
||||||
|
ctx.executor().schedule(() -> {
|
||||||
|
try {
|
||||||
|
// 获取连接信息并重连
|
||||||
|
// 注意:这里需要根据实际情况实现重连逻辑
|
||||||
|
log.info("变频器重连逻辑待实现,converterChannelTag={}", converterChannelTag);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("变频器重连失败,converterChannelTag={}, error={}", converterChannelTag, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}, RECONNECT_INTERVAL_MS, java.util.concurrent.TimeUnit.MILLISECONDS);
|
||||||
|
} else {
|
||||||
|
log.error("变频器重连失败,已达到最大重连次数,converterChannelTag={}", converterChannelTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.channelInactive(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||||
|
log.error("变频器连接发生异常,converterChannelTag={}, error={}", converterChannelTag, cause.getMessage(), cause);
|
||||||
|
ctx.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||||
|
if (evt instanceof IdleStateEvent) {
|
||||||
|
IdleStateEvent event = (IdleStateEvent) evt;
|
||||||
|
if (event.state() == IdleState.READER_IDLE) {
|
||||||
|
log.warn("变频器连接读空闲,converterChannelTag={}", converterChannelTag);
|
||||||
|
// 可以选择发送心跳或关闭连接
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.userEventTriggered(ctx, evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.njcn.gather.detection.util.socket.cilent;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.njcn.gather.detection.handler.SocketFreqConverterDevService;
|
||||||
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
|
import io.netty.handler.timeout.IdleState;
|
||||||
|
import io.netty.handler.timeout.IdleStateEvent;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备 Netty 客户端处理器
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class NettyFreqConverterDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||||
|
|
||||||
|
private final String devChannelTag;
|
||||||
|
private final SocketFreqConverterDevService socketFreqConverterDevService;
|
||||||
|
|
||||||
|
public NettyFreqConverterDevClientHandler(String devChannelTag, SocketFreqConverterDevService socketFreqConverterDevService) {
|
||||||
|
this.devChannelTag = devChannelTag;
|
||||||
|
this.socketFreqConverterDevService = socketFreqConverterDevService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
log.info("设备连接已建立,devChannelTag={}, channelId={}", devChannelTag, ctx.channel().id());
|
||||||
|
SocketManager.addUser(devChannelTag, ctx.channel());
|
||||||
|
super.channelActive(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||||
|
if (StrUtil.isBlank(msg)) {
|
||||||
|
log.debug("收到空消息,忽略,devChannelTag={}", devChannelTag);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("收到设备消息,devChannelTag={}, msg={}", devChannelTag, msg);
|
||||||
|
socketFreqConverterDevService.handleRead(devChannelTag, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
log.warn("设备连接已断开,devChannelTag={}", devChannelTag);
|
||||||
|
socketFreqConverterDevService.cleanup(devChannelTag, false);
|
||||||
|
super.channelInactive(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||||
|
log.error("设备连接发生异常,devChannelTag={}, error={}", devChannelTag, cause.getMessage(), cause);
|
||||||
|
ctx.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||||
|
if (evt instanceof IdleStateEvent) {
|
||||||
|
IdleStateEvent event = (IdleStateEvent) evt;
|
||||||
|
if (event.state() == IdleState.READER_IDLE) {
|
||||||
|
log.warn("设备连接读空闲,devChannelTag={}", devChannelTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.userEventTriggered(ctx, evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,29 +18,21 @@ import java.util.Set;
|
|||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "socket")
|
@ConfigurationProperties(prefix = "socket")
|
||||||
public class SocketConnectionConfig {
|
public class SocketConnectionConfig {
|
||||||
|
/**
|
||||||
|
* 被检设备配置
|
||||||
|
*/
|
||||||
|
private DeviceConfig device = new DeviceConfig();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 程控源设备配置
|
* 程控源设备配置
|
||||||
*/
|
*/
|
||||||
private SourceConfig source = new SourceConfig();
|
private SourceConfig source = new SourceConfig();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 被检设备配置
|
* 变频器配置
|
||||||
*/
|
*/
|
||||||
private DeviceConfig device = new DeviceConfig();
|
private DeviceConfig freqConverter = new DeviceConfig();
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class SourceConfig {
|
|
||||||
/**
|
|
||||||
* 程控源IP地址
|
|
||||||
*/
|
|
||||||
private String ip;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 程控源端口号
|
|
||||||
*/
|
|
||||||
private Integer port;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class DeviceConfig {
|
public static class DeviceConfig {
|
||||||
@@ -55,6 +47,26 @@ public class SocketConnectionConfig {
|
|||||||
private Integer port;
|
private Integer port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class SourceConfig {
|
||||||
|
/**
|
||||||
|
* 程控源IP地址
|
||||||
|
*/
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 程控源端口号
|
||||||
|
*/
|
||||||
|
private Integer port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取被检设备配置
|
||||||
|
*/
|
||||||
|
public DeviceConfig getDevice() {
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取程控源配置
|
* 获取程控源配置
|
||||||
*/
|
*/
|
||||||
@@ -63,10 +75,10 @@ public class SocketConnectionConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取被检设备配置
|
* 获取变频器配置
|
||||||
*/
|
*/
|
||||||
public DeviceConfig getDevice() {
|
public DeviceConfig getFreqConverter() {
|
||||||
return device;
|
return freqConverter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||||
|
import com.njcn.gather.device.pojo.vo.PqStandardDevVO;
|
||||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import com.njcn.web.utils.FileUtil;
|
import com.njcn.web.utils.FileUtil;
|
||||||
@@ -55,10 +56,10 @@ public class PqStandardDevController extends BaseController {
|
|||||||
@GetMapping("/getById")
|
@GetMapping("/getById")
|
||||||
@ApiOperation("根据id查询标准设备")
|
@ApiOperation("根据id查询标准设备")
|
||||||
@ApiImplicitParam(name = "id", value = "标准设备id", required = true)
|
@ApiImplicitParam(name = "id", value = "标准设备id", required = true)
|
||||||
public HttpResult<PqStandardDev> getById(@RequestParam("id") String id) {
|
public HttpResult<PqStandardDevVO> getById(@RequestParam("id") String id) {
|
||||||
String methodDescribe = getMethodDescribe("getById");
|
String methodDescribe = getMethodDescribe("getById");
|
||||||
LogUtil.njcnDebug(log, "{},查询ID为:{}", methodDescribe, id);
|
LogUtil.njcnDebug(log, "{},查询ID为:{}", methodDescribe, id);
|
||||||
PqStandardDev result = pqStandardDevService.getPqStandardDevById(id);
|
PqStandardDevVO result = pqStandardDevService.getPqStandardDevById(id);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.njcn.gather.device.mapper;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-01-12
|
||||||
|
*/
|
||||||
|
public interface PqStandardDevGainMapper extends MPJBaseMapper<PqStandardDevGain> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.njcn.gather.device.mapper;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-01-15
|
||||||
|
*/
|
||||||
|
public interface PqStandardDevGainRecordMapper extends MPJBaseMapper<PqStandardDevGainRecord> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.gather.device.mapper.PqStandardDevGainMapper">
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.gather.device.mapper.PqStandardDevGainRecordMapper">
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.njcn.gather.device.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-01-12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("pq_standard_dev_gain")
|
||||||
|
public class PqStandardDevGain extends BaseEntity implements Serializable {
|
||||||
|
private static final long serialVersionUID = -46280767885558804L;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准设备Id_通道号
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private String stdDevMonitorId;
|
||||||
|
|
||||||
|
private Integer uaGain;
|
||||||
|
|
||||||
|
private Integer ubGain;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer ucGain;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer u0Gain;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer iaGain;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer ibGain;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer icGain;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer i0Gain;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer uabGain;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer ubcGain;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer ucaGain;
|
||||||
|
|
||||||
|
private Integer state;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.njcn.gather.device.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-01-15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("pq_standard_dev_gain_record")
|
||||||
|
public class PqStandardDevGainRecord implements Serializable {
|
||||||
|
private static final long serialVersionUID = 477276215572686991L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准设备监测点id,由设备id_通道号组成
|
||||||
|
*/
|
||||||
|
private String stdDevMonitorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 被检设备监测点id,由设备id_通道号组成
|
||||||
|
*/
|
||||||
|
private String devMonitorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系数下发次数
|
||||||
|
*/
|
||||||
|
private Integer num;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.njcn.gather.device.pojo.vo;
|
||||||
|
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-01-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PqStandardDevVO extends PqStandardDev {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通道系数
|
||||||
|
*/
|
||||||
|
List<PqStandardDevGain> gainList;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.njcn.gather.device.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-01-15
|
||||||
|
*/
|
||||||
|
public interface IPqStandardDevGainRecordService extends IService<PqStandardDevGainRecord> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最大下发系数的次数
|
||||||
|
*
|
||||||
|
* @param stdDevMonitorId
|
||||||
|
* @param devMonitorId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int getMaxNum(String stdDevMonitorId, String devMonitorId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增或更新记录
|
||||||
|
* @param recordList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean addOrUpdate(List<PqStandardDevGainRecord> recordList);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.gather.device.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-01-12
|
||||||
|
*/
|
||||||
|
public interface IPqStandardDevGainService extends IService<PqStandardDevGain> {
|
||||||
|
|
||||||
|
boolean add(List<PqStandardDevGain> pqStandardDevGainList);
|
||||||
|
|
||||||
|
PqStandardDevGain get(String stdDevMonitorId);
|
||||||
|
|
||||||
|
List<PqStandardDevGain> list(String stdDevId);
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||||
|
import com.njcn.gather.device.pojo.vo.PqStandardDevVO;
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ public interface IPqStandardDevService extends IService<PqStandardDev> {
|
|||||||
* @param id 设备id
|
* @param id 设备id
|
||||||
* @return 设备对象
|
* @return 设备对象
|
||||||
*/
|
*/
|
||||||
PqStandardDev getPqStandardDevById(String id);
|
PqStandardDevVO getPqStandardDevById(String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增标准设备
|
* 新增标准设备
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.njcn.gather.device.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.gather.device.mapper.PqStandardDevGainRecordMapper;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGainRecord;
|
||||||
|
import com.njcn.gather.device.service.IPqStandardDevGainRecordService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-01-15
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PqStandardDevGainRecordServiceImpl extends ServiceImpl<PqStandardDevGainRecordMapper, PqStandardDevGainRecord> implements IPqStandardDevGainRecordService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxNum(String stdDevMonitorId, String devMonitorId) {
|
||||||
|
return this.lambdaQuery().eq(PqStandardDevGainRecord::getStdDevMonitorId, stdDevMonitorId)
|
||||||
|
.eq(PqStandardDevGainRecord::getDevMonitorId, devMonitorId)
|
||||||
|
.list().stream().mapToInt(PqStandardDevGainRecord::getNum).max().orElse(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addOrUpdate(List<PqStandardDevGainRecord> recordList) {
|
||||||
|
recordList.forEach(record -> {
|
||||||
|
List<PqStandardDevGainRecord> list = this.lambdaQuery().eq(PqStandardDevGainRecord::getStdDevMonitorId, record.getStdDevMonitorId())
|
||||||
|
.eq(PqStandardDevGainRecord::getDevMonitorId, record.getDevMonitorId()).list();
|
||||||
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
|
this.lambdaUpdate().eq(PqStandardDevGainRecord::getStdDevMonitorId, record.getStdDevMonitorId())
|
||||||
|
.eq(PqStandardDevGainRecord::getDevMonitorId, record.getDevMonitorId())
|
||||||
|
.set(PqStandardDevGainRecord::getNum, record.getNum()).update();
|
||||||
|
} else {
|
||||||
|
this.save(record);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.njcn.gather.device.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.gather.device.mapper.PqStandardDevGainMapper;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||||
|
import com.njcn.gather.device.service.IPqStandardDevGainService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-01-12
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PqStandardDevGainServiceImpl extends ServiceImpl<PqStandardDevGainMapper, PqStandardDevGain> implements IPqStandardDevGainService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean add(List<PqStandardDevGain> pqStandardDevGainList) {
|
||||||
|
log.info("add PqStandardDevGainList: {}", pqStandardDevGainList.size());
|
||||||
|
List<String> stdMonitorIdList = pqStandardDevGainList.stream().map(PqStandardDevGain::getStdDevMonitorId).distinct().collect(Collectors.toList());
|
||||||
|
List<String> existingStdMonitorIdList = this.listByIds(stdMonitorIdList).stream().map(PqStandardDevGain::getStdDevMonitorId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
pqStandardDevGainList = pqStandardDevGainList.stream().filter(pqStandardDevGain -> !existingStdMonitorIdList.contains(pqStandardDevGain.getStdDevMonitorId())).collect(Collectors.toList());
|
||||||
|
return this.saveBatch(pqStandardDevGainList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PqStandardDevGain get(String stdDevMonitorId) {
|
||||||
|
return this.lambdaQuery().eq(PqStandardDevGain::getStdDevMonitorId, stdDevMonitorId).one();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PqStandardDevGain> list(String stdDevId) {
|
||||||
|
return this.lambdaQuery().likeRight(PqStandardDevGain::getStdDevMonitorId, stdDevId).orderByAsc(PqStandardDevGain::getStdDevMonitorId).list();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,8 +19,11 @@ import com.njcn.common.utils.EncryptionUtil;
|
|||||||
import com.njcn.gather.device.mapper.PqStandardDevMapper;
|
import com.njcn.gather.device.mapper.PqStandardDevMapper;
|
||||||
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
import com.njcn.gather.device.pojo.param.PqStandardDevParam;
|
||||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqStandardDevGain;
|
||||||
import com.njcn.gather.device.pojo.vo.PqStandardDevExcel;
|
import com.njcn.gather.device.pojo.vo.PqStandardDevExcel;
|
||||||
|
import com.njcn.gather.device.pojo.vo.PqStandardDevVO;
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
|
import com.njcn.gather.device.service.IPqStandardDevGainService;
|
||||||
import com.njcn.gather.device.service.IPqStandardDevService;
|
import com.njcn.gather.device.service.IPqStandardDevService;
|
||||||
import com.njcn.gather.plan.mapper.AdPlanStandardDevMapper;
|
import com.njcn.gather.plan.mapper.AdPlanStandardDevMapper;
|
||||||
import com.njcn.gather.plan.service.IAdPlanStandardDevService;
|
import com.njcn.gather.plan.service.IAdPlanStandardDevService;
|
||||||
@@ -58,8 +61,7 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
|||||||
private final IDevTypeService devTypeService;
|
private final IDevTypeService devTypeService;
|
||||||
private final IDictDataService dictDataService;
|
private final IDictDataService dictDataService;
|
||||||
private final IDictTypeService dictTypeService;
|
private final IDictTypeService dictTypeService;
|
||||||
private final AdPlanStandardDevMapper adPlanStandardDevMapper;
|
private final IPqStandardDevGainService pqStandardDevGainService;
|
||||||
private final IAdPlanStandardDevService adPlanStandardDevService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<PqStandardDev> listPqStandardDevs(PqStandardDevParam.QueryParam queryParam) {
|
public Page<PqStandardDev> listPqStandardDevs(PqStandardDevParam.QueryParam queryParam) {
|
||||||
@@ -73,13 +75,17 @@ public class PqStandardDevServiceImpl extends ServiceImpl<PqStandardDevMapper, P
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PqStandardDev getPqStandardDevById(String id) {
|
public PqStandardDevVO getPqStandardDevById(String id) {
|
||||||
PqStandardDev standardDev = this.getById(id);
|
PqStandardDev standardDev = this.getById(id);
|
||||||
|
PqStandardDevVO pqStandardDevVO = BeanUtil.copyProperties(standardDev, PqStandardDevVO.class);
|
||||||
if (standardDev.getEncryptionFlag() == 1) {
|
if (standardDev.getEncryptionFlag() == 1) {
|
||||||
standardDev.setSeries(EncryptionUtil.decoderString(1, standardDev.getSeries()));
|
pqStandardDevVO.setSeries(EncryptionUtil.decoderString(1, standardDev.getSeries()));
|
||||||
standardDev.setDevKey(EncryptionUtil.decoderString(1, standardDev.getDevKey()));
|
pqStandardDevVO.setDevKey(EncryptionUtil.decoderString(1, standardDev.getDevKey()));
|
||||||
}
|
}
|
||||||
return standardDev;
|
|
||||||
|
List<PqStandardDevGain> gainList = pqStandardDevGainService.list(id);
|
||||||
|
pqStandardDevVO.setGainList(gainList);
|
||||||
|
return pqStandardDevVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.njcn.gather.dip.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.gather.dip.pojo.po.PqDipData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-04-09
|
||||||
|
*/
|
||||||
|
public interface PqDipDataMapper extends BaseMapper<PqDipData> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.njcn.gather.dip.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电压暂降数据
|
||||||
|
*
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-04-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("pq_dip_data")
|
||||||
|
public class PqDipData extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 起始时间戳
|
||||||
|
*/
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 残余电压,单位:%Ur
|
||||||
|
*/
|
||||||
|
private Double residualVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 持续时间,单位:ms
|
||||||
|
*/
|
||||||
|
private Integer durationMs;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.njcn.gather.dip.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.dip.pojo.po.PqDipData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-04-09
|
||||||
|
*/
|
||||||
|
public interface IPqDipDataService extends IService<PqDipData> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.njcn.gather.dip.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.gather.dip.mapper.PqDipDataMapper;
|
||||||
|
import com.njcn.gather.dip.pojo.po.PqDipData;
|
||||||
|
import com.njcn.gather.dip.service.IPqDipDataService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @date 2026-04-09
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PqDipDataServiceImpl extends ServiceImpl<PqDipDataMapper, PqDipData> implements IPqDipDataService {
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.njcn.gather.freqConverter.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-07
|
||||||
|
*/
|
||||||
|
public interface FreqConverterStatusMapper extends BaseMapper<FreqConverterStatus> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.njcn.gather.freqConverter.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||||
|
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-08
|
||||||
|
*/
|
||||||
|
public interface PqFreqConverterConfigMapper extends BaseMapper<PqFreqConverterConfig> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.njcn.gather.freqConverter.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||||
|
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-07
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("pq_freq_converter_status")
|
||||||
|
public class FreqConverterStatus extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private Integer slaveAddress;
|
||||||
|
|
||||||
|
private Integer statusWord1;
|
||||||
|
|
||||||
|
private String statusWord1Hex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态记录时刻(时间戳)
|
||||||
|
*/
|
||||||
|
private LocalDateTime timestamp;
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.njcn.gather.freqConverter.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变频器配置实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("pq_freq_converter_config")
|
||||||
|
public class PqFreqConverterConfig extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电脑串口名,如COM1
|
||||||
|
*/
|
||||||
|
private String portName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变频器设置从机地址,范围1~127
|
||||||
|
*/
|
||||||
|
private Integer slaveAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变频器设置波特率,如19200
|
||||||
|
*/
|
||||||
|
private Integer baudRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 奇偶校验类型: None, Even, Odd
|
||||||
|
*/
|
||||||
|
private String parity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变频器数据位
|
||||||
|
*/
|
||||||
|
private Integer dataBits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变频器停止位,当前只支持 1 或 2
|
||||||
|
*/
|
||||||
|
private Integer stopBits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 串口读写超时,单位毫秒
|
||||||
|
*/
|
||||||
|
private Integer timeoutMs;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.njcn.gather.freqConverter.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-07
|
||||||
|
*/
|
||||||
|
public interface IFreqConverterService extends IService<FreqConverterStatus> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存变频器状态数据
|
||||||
|
*
|
||||||
|
* @param status 变频器状态数据
|
||||||
|
* @return 是否保存成功
|
||||||
|
*/
|
||||||
|
boolean saveFreqConverterStatus(FreqConverterStatus status);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指定变频器的状态历史
|
||||||
|
*
|
||||||
|
* @param converterId 变频器ID
|
||||||
|
* @return 状态数据列表
|
||||||
|
*/
|
||||||
|
List<FreqConverterStatus> listStatusHistory(String converterId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空所有数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean clearAllData();
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.njcn.gather.freqConverter.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-08
|
||||||
|
*/
|
||||||
|
public interface IPqFreqConverterConfigService extends IService<PqFreqConverterConfig> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.njcn.gather.freqConverter.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.gather.freqConverter.mapper.FreqConverterStatusMapper;
|
||||||
|
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||||
|
import com.njcn.gather.freqConverter.service.IFreqConverterService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变频器状态数据Service实现类
|
||||||
|
* <p>
|
||||||
|
* 实现变频器状态数据的存储、查询和清理功能。
|
||||||
|
* 当数据量超过阈值时,自动清理无效或过期数据,避免内存和数据库资源浪费。
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author CN_Gather Detection Team
|
||||||
|
* @version 1.0
|
||||||
|
* @since 2026
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMapper, FreqConverterStatus> implements IFreqConverterService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean saveFreqConverterStatus(FreqConverterStatus status) {
|
||||||
|
return this.save(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FreqConverterStatus> listStatusHistory(String converterId) {
|
||||||
|
return this.lambdaQuery().list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean clearAllData() {
|
||||||
|
return this.remove(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.njcn.gather.freqConverter.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.gather.freqConverter.mapper.PqFreqConverterConfigMapper;
|
||||||
|
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterConfig;
|
||||||
|
import com.njcn.gather.freqConverter.service.IPqFreqConverterConfigService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-08
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverterConfigMapper, PqFreqConverterConfig> implements IPqFreqConverterConfigService {
|
||||||
|
}
|
||||||
@@ -121,8 +121,8 @@ public interface IPqMonitorService extends IService<PqMonitor> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据被检设备id和监测点编号获取监测点信息
|
* 根据被检设备id和监测点编号获取监测点信息
|
||||||
* @param id 被检设备id
|
* @param devId 设备id
|
||||||
* @param monitorNum 监测点编号
|
* @param monitorNum 监测点编号
|
||||||
*/
|
*/
|
||||||
PqMonitor getByDevAndNum(String id, int monitorNum);
|
PqMonitor getByDevIdAndNum(String devId, int monitorNum);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
|||||||
if (ObjectUtil.isNotNull(pqMonitor)) {
|
if (ObjectUtil.isNotNull(pqMonitor)) {
|
||||||
BeanUtil.copyProperties(monitorList.get(0), pqMonitor, "id", "realtimeResult", "statisticsResult", "recordedResult", "realtimeNum", "statisticsNum", "recordedNum", "resultType", "qualifiedNum");
|
BeanUtil.copyProperties(monitorList.get(0), pqMonitor, "id", "realtimeResult", "statisticsResult", "recordedResult", "realtimeNum", "statisticsNum", "recordedNum", "resultType", "qualifiedNum");
|
||||||
newMonitorList.add(pqMonitor);
|
newMonitorList.add(pqMonitor);
|
||||||
|
existedMonitorList.remove(pqMonitor);
|
||||||
} else {
|
} else {
|
||||||
newMonitorList.addAll(monitorList);
|
newMonitorList.addAll(monitorList);
|
||||||
}
|
}
|
||||||
@@ -168,6 +169,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
|||||||
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
this.baseMapper.updatePlanReportRState(plan.getId(), PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.removeByIds(existedMonitorList.stream().map(PqMonitor::getId).collect(Collectors.toList()));
|
||||||
return this.saveOrUpdateBatch(newMonitorList);
|
return this.saveOrUpdateBatch(newMonitorList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +440,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PqMonitor getByDevAndNum(String devId, int monitorNum) {
|
public PqMonitor getByDevIdAndNum(String devId, int monitorNum) {
|
||||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("pq_monitor.Dev_Id", devId)
|
wrapper.eq("pq_monitor.Dev_Id", devId)
|
||||||
.eq("pq_monitor.Num", monitorNum);
|
.eq("pq_monitor.Num", monitorNum);
|
||||||
|
|||||||
@@ -1173,7 +1173,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
Integer monitorNum = next.getKey();
|
Integer monitorNum = next.getKey();
|
||||||
// 线路下的指标数据
|
// 线路下的指标数据
|
||||||
List<ContrastTestResult> contrastTestResults = next.getValue();
|
List<ContrastTestResult> contrastTestResults = next.getValue();
|
||||||
PqMonitor pqMonitor = pqMonitorService.getByDevAndNum(pqDevVO.getId(), monitorNum);
|
PqMonitor pqMonitor = pqMonitorService.getByDevIdAndNum(pqDevVO.getId(), monitorNum);
|
||||||
// 插入回路号前,先换个页
|
// 插入回路号前,先换个页
|
||||||
todoInsertList.add(Docx4jUtil.createPageBreakParagraph());
|
todoInsertList.add(Docx4jUtil.createPageBreakParagraph());
|
||||||
// 回路标题
|
// 回路标题
|
||||||
@@ -2063,7 +2063,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
// 委托方
|
// 委托方
|
||||||
String delegate = pqDevVO.getDelegate();
|
String delegate = pqDevVO.getDelegate();
|
||||||
if (StrUtil.isNotBlank(delegate)) {
|
if (StrUtil.isNotBlank(delegate)) {
|
||||||
DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getManufacturer());
|
DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getDelegate());
|
||||||
if (ObjectUtil.isNotNull(delegateDictData)) {
|
if (ObjectUtil.isNotNull(delegateDictData)) {
|
||||||
baseModelMap.put(BaseReportKeyEnum.DELEGATE.getKey(), delegateDictData.getName());
|
baseModelMap.put(BaseReportKeyEnum.DELEGATE.getKey(), delegateDictData.getName());
|
||||||
} else {
|
} else {
|
||||||
@@ -2503,7 +2503,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
* 创建回路标题到报告中
|
* 创建回路标题到报告中
|
||||||
*/
|
*/
|
||||||
private P getContrastLineTitle(Map<String, List<Docx4jUtil.HeadingContent>> contentMap, int monitorNum, int index, ObjectFactory factory, PqDevVO pqDevVO) {
|
private P getContrastLineTitle(Map<String, List<Docx4jUtil.HeadingContent>> contentMap, int monitorNum, int index, ObjectFactory factory, PqDevVO pqDevVO) {
|
||||||
PqMonitor pqMonitor = pqMonitorService.getByDevAndNum(pqDevVO.getId(), monitorNum);
|
PqMonitor pqMonitor = pqMonitorService.getByDevIdAndNum(pqDevVO.getId(), monitorNum);
|
||||||
String monitorInfoName = "";
|
String monitorInfoName = "";
|
||||||
if (StrUtil.isNotBlank(pqDevVO.getSubName()) && Objects.nonNull(pqMonitor)) {
|
if (StrUtil.isNotBlank(pqDevVO.getSubName()) && Objects.nonNull(pqMonitor)) {
|
||||||
monitorInfoName = "(" + pqDevVO.getSubName() + "-" + pqMonitor.getName() + ")";
|
monitorInfoName = "(" + pqDevVO.getSubName() + "-" + pqMonitor.getName() + ")";
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ public class ResultController extends BaseController {
|
|||||||
String methodDescribe = getMethodDescribe("getCheckItem");
|
String methodDescribe = getMethodDescribe("getCheckItem");
|
||||||
|
|
||||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, monitorQueryParam);
|
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, monitorQueryParam);
|
||||||
List<ContrastTestItemVO> result = resultService.getCheckItem(monitorQueryParam.getPlanId(), monitorQueryParam.getDevId(), monitorQueryParam.getChnNum(), monitorQueryParam.getNum());
|
List<ContrastTestItemVO> result = resultService.getCheckItem(monitorQueryParam.getPlanId(), monitorQueryParam.getDevId(), monitorQueryParam.getChnNum(), monitorQueryParam.getNum(), monitorQueryParam.getCode());
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,6 @@ public class MonitorQueryParam {
|
|||||||
private Integer waveNum;
|
private Integer waveNum;
|
||||||
|
|
||||||
private String planId;
|
private String planId;
|
||||||
|
|
||||||
|
private String code;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,9 +123,10 @@ public interface IResultService {
|
|||||||
* @param devId
|
* @param devId
|
||||||
* @param chnNum
|
* @param chnNum
|
||||||
* @param num
|
* @param num
|
||||||
|
* @param code
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ContrastTestItemVO> getCheckItem(String planId, String devId, String chnNum, Integer num);
|
List<ContrastTestItemVO> getCheckItem(String planId, String devId, String chnNum, Integer num,String code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备比对式结果,用于出比对检测的报告
|
* 获取设备比对式结果,用于出比对检测的报告
|
||||||
|
|||||||
@@ -341,10 +341,19 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
private void dipScriptTypeName(List<PqScriptDtls> subValue, List<TreeDataVO> subTypeList, Map<Integer, Set<Integer>> finalResultMap, Boolean isValueType, String name, Integer start, Integer end) {
|
private void dipScriptTypeName(List<PqScriptDtls> subValue, List<TreeDataVO> subTypeList, Map<Integer, Set<Integer>> finalResultMap, Boolean isValueType, String name, Integer start, Integer end) {
|
||||||
List<TreeDataVO> info = new ArrayList<>();
|
List<TreeDataVO> info = new ArrayList<>();
|
||||||
List<PqScriptDtls> dip = subValue.stream()
|
List<PqScriptDtls> dip = subValue.stream()
|
||||||
.filter(x -> "Dip".equals(x.getValueType()) && "A".equals(x.getPhase()))
|
// .filter(x -> "Dip".equals(x.getValueType()) && "A".equals(x.getPhase()))
|
||||||
|
.filter(x -> "Dip".equals(x.getValueType()))
|
||||||
.filter(x -> x.getTransValue() >= start && x.getTransValue() <= end)
|
.filter(x -> x.getTransValue() >= start && x.getTransValue() <= end)
|
||||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
LinkedHashMap<Integer, List<PqScriptDtls>> idxDipMap = dip.stream().collect(Collectors.groupingBy(d -> d.getScriptIndex(), LinkedHashMap::new, Collectors.toList()));
|
||||||
|
|
||||||
|
dip.clear();
|
||||||
|
idxDipMap.forEach((idx, scriptDtlList) -> {
|
||||||
|
scriptDtlList.sort(Comparator.comparing(PqScriptDtls::getPhase));
|
||||||
|
dip.add(scriptDtlList.get(0));
|
||||||
|
});
|
||||||
|
|
||||||
TreeDataVO vo = new TreeDataVO();
|
TreeDataVO vo = new TreeDataVO();
|
||||||
vo.setScriptTypeName(name);
|
vo.setScriptTypeName(name);
|
||||||
vo.setScriptTypeCode("Base_" + start + "_" + end);
|
vo.setScriptTypeCode("Base_" + start + "_" + end);
|
||||||
@@ -1883,10 +1892,10 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ContrastTestItemVO> getCheckItem(String planId, String devId, String chnNum, Integer num) {
|
public List<ContrastTestItemVO> getCheckItem(String planId, String devId, String chnNum, Integer num, String code) {
|
||||||
// PqDev dev = pqDevService.getById(devId);
|
// PqDev dev = pqDevService.getById(devId);
|
||||||
AdPlan plan = adPlanService.getById(planId);
|
AdPlan plan = adPlanService.getById(planId);
|
||||||
String code = String.valueOf(plan.getCode());
|
// String code = String.valueOf(plan.getCode());
|
||||||
|
|
||||||
String monitorId = devId + CnSocketUtil.SPLIT_TAG + chnNum;
|
String monitorId = devId + CnSocketUtil.SPLIT_TAG + chnNum;
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
druid:
|
druid:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
# url: jdbc:mysql://192.168.1.24:13306/pqs91002?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
# url: jdbc:mysql://192.168.1.24:13306/pqs91002?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||||
# username: root
|
# username: root
|
||||||
# password: njcnpqs
|
# password: njcnpqs
|
||||||
url: jdbc:mysql://192.168.1.24:13306/pqs9100_nx?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
url: jdbc:mysql://192.168.1.24:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||||
username: root
|
username: root
|
||||||
password: njcnpqs
|
password: njcnpqs
|
||||||
#初始化建立物理连接的个数、最小、最大连接数
|
#初始化建立物理连接的个数、最小、最大连接数
|
||||||
@@ -36,9 +36,9 @@ mybatis-plus:
|
|||||||
#驼峰命名
|
#驼峰命名
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
#配置sql日志输出
|
#配置sql日志输出
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
#关闭日志输出
|
#关闭日志输出
|
||||||
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||||
global-config:
|
global-config:
|
||||||
db-config:
|
db-config:
|
||||||
#指定主键生成策略
|
#指定主键生成策略
|
||||||
@@ -46,12 +46,15 @@ mybatis-plus:
|
|||||||
|
|
||||||
|
|
||||||
socket:
|
socket:
|
||||||
source:
|
|
||||||
ip: 127.0.0.1
|
|
||||||
port: 62000
|
|
||||||
device:
|
device:
|
||||||
ip: 127.0.0.1
|
ip: 127.0.0.1
|
||||||
port: 61000
|
port: 61000
|
||||||
|
source:
|
||||||
|
ip: 127.0.0.1
|
||||||
|
port: 63000
|
||||||
|
freqConverter:
|
||||||
|
ip: 127.0.0.1
|
||||||
|
port: 63000
|
||||||
# source:
|
# source:
|
||||||
# ip: 192.168.1.121
|
# ip: 192.168.1.121
|
||||||
# port: 10086
|
# port: 10086
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ public class SysTestConfigParam {
|
|||||||
@ApiModelProperty(value = "场景")
|
@ApiModelProperty(value = "场景")
|
||||||
private String scene;
|
private String scene;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "比对监测后,当电压、电流不符合时,是否对标准设备进行系数校准")
|
||||||
|
private Integer coefficient;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class UpdateParam extends SysTestConfigParam {
|
public static class UpdateParam extends SysTestConfigParam {
|
||||||
@ApiModelProperty("id")
|
@ApiModelProperty("id")
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ public class SysTestConfig extends BaseEntity implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer scale;
|
private Integer scale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比对监测后,当电压、电流不符合时,是否对标准设备进行系数校准
|
||||||
|
*/
|
||||||
|
private Integer coefficient;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态:0-删除 1-正常
|
* 状态:0-删除 1-正常
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class SysTestConfigServiceImpl extends ServiceImpl<SysTestConfigMapper, S
|
|||||||
oneConfig.setScale(ObjectUtil.isNotNull(param.getScale()) ? param.getScale() : oneConfig.getScale());
|
oneConfig.setScale(ObjectUtil.isNotNull(param.getScale()) ? param.getScale() : oneConfig.getScale());
|
||||||
oneConfig.setMaxTime(ObjectUtil.isNotNull(param.getMaxTime()) ? param.getMaxTime() : oneConfig.getMaxTime());
|
oneConfig.setMaxTime(ObjectUtil.isNotNull(param.getMaxTime()) ? param.getMaxTime() : oneConfig.getMaxTime());
|
||||||
oneConfig.setScene(StringUtils.isNotBlank(param.getScene()) ? param.getScene() : oneConfig.getScene());
|
oneConfig.setScene(StringUtils.isNotBlank(param.getScene()) ? param.getScene() : oneConfig.getScene());
|
||||||
|
oneConfig.setCoefficient(param.getCoefficient());
|
||||||
return this.updateById(oneConfig);
|
return this.updateById(oneConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user