比对预检测
This commit is contained in:
@@ -9,6 +9,7 @@ import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
import com.njcn.gather.detection.service.PreDetectionService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@ import com.njcn.gather.detection.util.DetectionUtil;
|
||||
import com.njcn.gather.detection.util.socket.*;
|
||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.gather.device.pojo.po.PqDevSub;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
@@ -50,7 +51,6 @@ import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
@@ -63,8 +63,6 @@ import static com.njcn.gather.detection.util.socket.FormalTestManager.harmonicRe
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SocketDevResponseService {
|
||||
// ISO 8601格式
|
||||
private final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
|
||||
|
||||
private List<String> dataTypeList;
|
||||
|
||||
@@ -409,7 +407,7 @@ public class SocketDevResponseService {
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
//不合格项复检
|
||||
Set<Integer> indexes = new HashSet<>();
|
||||
StorageParam storageParam = new StorageParam();
|
||||
@@ -717,7 +715,7 @@ public class SocketDevResponseService {
|
||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
// 通知前端整个装置通讯检测过程成功
|
||||
SocketDataMsg temMsg = new SocketDataMsg();
|
||||
temMsg.setCode(SourceResponseCodeEnum.DEV_COMM_ALL_SUCCESS.getCode());
|
||||
temMsg.setCode(SourceResponseCodeEnum.ALL_SUCCESS.getCode());
|
||||
temMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
|
||||
temMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(temMsg));
|
||||
@@ -874,7 +872,7 @@ public class SocketDevResponseService {
|
||||
//System.out.println("icdCheckDataMap.size()="+icdCheckDataMap.size()+",icdTypeList.size()="+icdTypeList.size());
|
||||
if (icdCheckDataMap.size() == icdTypeList.size()) {
|
||||
SocketDataMsg temMsg = new SocketDataMsg();
|
||||
temMsg.setCode(SourceResponseCodeEnum.DEV_COMM_ALL_SUCCESS.getCode());
|
||||
temMsg.setCode(SourceResponseCodeEnum.ALL_SUCCESS.getCode());
|
||||
temMsg.setOperateCode(SourceOperateCodeEnum.VERIFY_MAPPING$01.getValue());
|
||||
temMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(temMsg));
|
||||
@@ -897,7 +895,7 @@ public class SocketDevResponseService {
|
||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||
} else if (param.getTestItemList().get(2)) {
|
||||
// 后续做正式检测
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
//不合格项复检
|
||||
Set<Integer> indexes = new HashSet<>();
|
||||
StorageParam storageParam = new StorageParam();
|
||||
@@ -1076,8 +1074,8 @@ public class SocketDevResponseService {
|
||||
WebSocketVO<String> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
webSocketVO.setCode(SourceResponseCodeEnum.PHASE_CHECK_FAIL.getCode());
|
||||
webSocketVO.setData(SourceResponseCodeEnum.PHASE_CHECK_FAIL.getMessage());
|
||||
webSocketVO.setCode(SourceResponseCodeEnum.ALL_FAIL.getCode());
|
||||
webSocketVO.setData(SourceResponseCodeEnum.ALL_FAIL.getMessage());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
|
||||
CnSocketUtil.quitSend(param);
|
||||
@@ -1087,7 +1085,7 @@ public class SocketDevResponseService {
|
||||
|
||||
//向前端推送消息
|
||||
SocketDataMsg temMsg = new SocketDataMsg();
|
||||
temMsg.setCode(SourceResponseCodeEnum.DEV_COMM_ALL_SUCCESS.getCode());
|
||||
temMsg.setCode(SourceResponseCodeEnum.ALL_SUCCESS.getCode());
|
||||
temMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||
temMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(temMsg));
|
||||
@@ -1127,7 +1125,7 @@ public class SocketDevResponseService {
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
//不合格项复检
|
||||
Set<Integer> indexes = new HashSet<>();
|
||||
StorageParam storageParam = new StorageParam();
|
||||
@@ -1453,7 +1451,7 @@ public class SocketDevResponseService {
|
||||
case QUIT_INIT_01:
|
||||
//关闭所有
|
||||
SocketManager.removeUser(s);
|
||||
// CnSocketUtil.quitSendSource(param);
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
break;
|
||||
case QUIT_INIT_02:
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
@@ -1720,6 +1718,9 @@ public class SocketDevResponseService {
|
||||
} else {
|
||||
dataRule = DictDataEnum.SECTION_VALUE;
|
||||
}
|
||||
|
||||
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
||||
FormalTestManager.patternEnum = PatternEnum.getEnum(code);
|
||||
//字典树
|
||||
SocketManager.valueTypeMap = iPqScriptCheckDataService.getValueTypeMap(param.getScriptId());
|
||||
|
||||
@@ -1794,7 +1795,7 @@ public class SocketDevResponseService {
|
||||
List<SimAndDigNonHarmonicResult> simAndDigNonHarmonicResultList = new ArrayList<>();
|
||||
List<SimAndDigHarmonicResult> adHarmonicResultList = new ArrayList<>();
|
||||
for (DevData data : devDataList) {
|
||||
LocalDateTime localDateTime = DetectionUtil.timeFormat(data.getTime(), formatter);
|
||||
LocalDateTime localDateTime = DetectionUtil.timeFormat(data.getTime(), DetectionUtil.FORMATTER);
|
||||
if (Objects.nonNull(localDateTime)) {
|
||||
|
||||
String[] splitArr = data.getId().split(CnSocketUtil.SPLIT_TAG);
|
||||
@@ -1958,7 +1959,8 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
public void backCheckState(PreDetectionParam param) {
|
||||
if (CollUtil.isNotEmpty(param.getDevIds()) && StrUtil.isNotBlank(param.getPlanId()) && "1".equals(param.getOperateType())) {
|
||||
// if (CollUtil.isNotEmpty(param.getDevIds()) && StrUtil.isNotBlank(param.getPlanId()) && "1".equals(param.getOperateType())) {
|
||||
if (CollUtil.isNotEmpty(param.getDevIds()) && StrUtil.isNotBlank(param.getPlanId())) {
|
||||
adPlanService.updateBackTestState(param.getPlanId(), param.getDevIds());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public enum SourceOperateCodeEnum {
|
||||
YJC_SBTXJY("yjc_sbtxjy", "设备通讯检测"),
|
||||
YJC_XYJY("yjc_xyjy", "协议校验"),
|
||||
YJC_XUJY("YJC_xujy", "相序校验"),
|
||||
YJC_ALIGN("YJC_align","实时数据对齐校验"),
|
||||
YJC_MXYZXJY("YJC_mxyzxjy", "模型一致性校验"),
|
||||
YJC_ALIGN("yjc_align","实时数据对齐校验"),
|
||||
YJC_MXYZXJY("yjc_mxyzxjy", "模型一致性校验"),
|
||||
FORMAL_REAL("formal_real","正式检测"),
|
||||
// SIMULATE_REAL("simulate_real","模拟检测"),
|
||||
Coefficient_Check("Coefficient_Check","系数校验"),
|
||||
|
||||
@@ -37,9 +37,10 @@ public enum SourceResponseCodeEnum {
|
||||
|
||||
//自定义前端展示消息
|
||||
SOCKET_ERROR(25000,"服务端连接失败"),
|
||||
DEV_COMM_ALL_SUCCESS(25001,"校验成功"),
|
||||
DEV_COMM_TEST_FAIL(25002,"设备通讯校验失败"),
|
||||
PHASE_CHECK_FAIL(25003,"相序校验未通过"),
|
||||
ALL_SUCCESS(25001,"校验成功"),
|
||||
FAIL(25002,"失败"),
|
||||
ALL_FAIL(25003,"校验失败"),
|
||||
ALIGN_CHECK_FAIL(25007,"实时数据对齐校验未通过"),
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ContrastDetectionParam {
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty("用户ID,唯一标识")
|
||||
private String userId;
|
||||
private String loginName;
|
||||
|
||||
@ApiModelProperty("被检设备ID列表")
|
||||
@NotEmpty(message = DetectionValidMessage.DEV_IDS_NOT_EMPTY)
|
||||
@@ -32,7 +32,7 @@ public class ContrastDetectionParam {
|
||||
private List<String> standardDevIds;
|
||||
|
||||
/**
|
||||
* key为 标准设备ID_检测点序号、value为 被检设备ID_检测点序号
|
||||
* key为被检设备ID_检测点序号、value为 标准设备ID_检测点序号
|
||||
*/
|
||||
@ApiModelProperty("配对关系")
|
||||
@NotEmpty(message = DetectionValidMessage.PAIRS_NOT_EMPTY)
|
||||
|
||||
@@ -14,7 +14,8 @@ import java.util.List;
|
||||
@Data
|
||||
public class PreDetectionParam {
|
||||
|
||||
private String operateType;
|
||||
// "1"-"全部检测" , "2"-"不合格项复检"
|
||||
private String reCheckType;
|
||||
|
||||
/**
|
||||
* 检测计划id
|
||||
@@ -23,11 +24,6 @@ public class PreDetectionParam {
|
||||
private String planId;
|
||||
|
||||
|
||||
/**
|
||||
* 数字、模拟、比对
|
||||
*/
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 用户功能组成唯一标识 zhangsan_test
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.gather.detection.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-08-07
|
||||
*/
|
||||
@Data
|
||||
public class AlignDataExcel {
|
||||
|
||||
private ExcelConfig devDataConfig = new ExcelConfig("");
|
||||
private ExcelConfig standardDevDataConfig = new ExcelConfig("");
|
||||
|
||||
@Excel(name = "时间", width = 20, groupName = "被检设备")
|
||||
private String timeDev;
|
||||
|
||||
@Excel(name = "Ua", groupName = "被检设备")
|
||||
private Double uaDev;
|
||||
|
||||
@Excel(name = "Ub", groupName = "被检设备")
|
||||
private Double ubDev;
|
||||
|
||||
@Excel(name = "Uc", groupName = "被检设备")
|
||||
private Double ucDev;
|
||||
|
||||
|
||||
@Excel(name = "时间", width = 20, groupName = "标准设备")
|
||||
private String timeStdDev;
|
||||
|
||||
@Excel(name = "Ua", groupName = "标准设备")
|
||||
private Double uaStdDev;
|
||||
|
||||
@Excel(name = "Ub", groupName = "标准设备")
|
||||
private Double ubStdDev;
|
||||
|
||||
@Excel(name = "Uc", groupName = "标准设备")
|
||||
private Double ucStdDev;
|
||||
|
||||
|
||||
@Data
|
||||
public static class ExcelConfig {
|
||||
private String name;
|
||||
|
||||
public ExcelConfig(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.njcn.gather.detection.pojo.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-08-06
|
||||
*/
|
||||
@Data
|
||||
public class AlignDataVO {
|
||||
|
||||
private String devName;
|
||||
|
||||
private List<ChannelData> channelDataList;
|
||||
|
||||
|
||||
// 通道数据
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class ChannelData {
|
||||
|
||||
// 被检设备通道号
|
||||
private String devNum;
|
||||
|
||||
// 与之对应的标准设备名称_通道号
|
||||
private String standardDevInfo;
|
||||
|
||||
// 数据
|
||||
private List<RawData> dataList;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class RawData {
|
||||
private String timeDev;
|
||||
|
||||
private Double uaDev;
|
||||
|
||||
private Double ubDev;
|
||||
|
||||
private Double ucDev;
|
||||
|
||||
private String timeStdDev;
|
||||
|
||||
private Double uaStdDev;
|
||||
|
||||
private Double ubStdDev;
|
||||
|
||||
private Double ucStdDev;
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,7 @@ import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.*;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||
@@ -72,6 +69,9 @@ public class DetectionServiceImpl {
|
||||
private final String MAG = "MAG";
|
||||
private final String DUR = "DUR";
|
||||
|
||||
private static final Integer INHARMONIC_FLAG = 1;
|
||||
private static final Integer HARMONIC_FLAG = 2;
|
||||
|
||||
|
||||
/**
|
||||
* 开始处理指标类型
|
||||
@@ -129,16 +129,16 @@ public class DetectionServiceImpl {
|
||||
*/
|
||||
case HV:
|
||||
case HI:
|
||||
SimAndDigHarmonicResult harmV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 2);
|
||||
SimAndDigHarmonicResult harmI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 2);
|
||||
SimAndDigHarmonicResult harmV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, HARMONIC_FLAG);
|
||||
SimAndDigHarmonicResult harmI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, HARMONIC_FLAG);
|
||||
return resultFlag(harmV, harmI, code);
|
||||
/**
|
||||
* 间谐波
|
||||
*/
|
||||
case HSV:
|
||||
case HSI:
|
||||
SimAndDigHarmonicResult harmInV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, 1);
|
||||
SimAndDigHarmonicResult harmInI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, 1);
|
||||
SimAndDigHarmonicResult harmInV = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, INHARMONIC_FLAG);
|
||||
SimAndDigHarmonicResult harmInI = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, INHARMONIC_FLAG);
|
||||
return resultFlag(harmInV, harmInI, code);
|
||||
/**
|
||||
* 三相电压不平衡度
|
||||
@@ -166,7 +166,7 @@ public class DetectionServiceImpl {
|
||||
case HP:
|
||||
SimAndDigHarmonicResult harmP = isHarmQualified(dev, devIdMapComm, errDtlsCheckData, HP, sourceIssue, dataRule, 2);
|
||||
if (ObjectUtil.isNotNull(harmP)) {
|
||||
detectionDataDealService.acceptAdResult(Arrays.asList(harmP), code);
|
||||
detectionDataDealService.acceptHarmonicResult(Arrays.asList(harmP), code);
|
||||
return harmP.getResultFlag();
|
||||
}
|
||||
return 4;
|
||||
@@ -193,8 +193,8 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
public Integer resultFlag(SimAndDigHarmonicResult v, SimAndDigHarmonicResult i, String code) {
|
||||
List<SimAndDigHarmonicResult> info = new ArrayList<>();
|
||||
public <T extends BaseResult> Integer resultFlag(T v, T i, String code) {
|
||||
List<T> info = new ArrayList<>();
|
||||
if (ObjectUtil.isNotNull(v)) {
|
||||
info.add(v);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public class DetectionServiceImpl {
|
||||
info.add(i);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
detectionDataDealService.acceptAdResult(info, code);
|
||||
detectionDataDealService.acceptHarmonicResult(info, code);
|
||||
return getInteger(info.stream().map(x -> x.getResultFlag()).distinct().collect(Collectors.toList()));
|
||||
}
|
||||
return 4;
|
||||
@@ -344,7 +344,7 @@ public class DetectionServiceImpl {
|
||||
detectionDataDealService.acceptNonHarmonicResult(info, code);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(harmonicResultList)) {
|
||||
detectionDataDealService.acceptAdResult(harmonicResultList, code);
|
||||
detectionDataDealService.acceptHarmonicResult(harmonicResultList, code);
|
||||
}
|
||||
return 4;
|
||||
}
|
||||
@@ -904,12 +904,15 @@ public class DetectionServiceImpl {
|
||||
return map;
|
||||
}
|
||||
|
||||
private void reflectHarmonic(String phase, List<DetectionData> integerBooleanA, SimAndDigHarmonicResult harmonicResult, Integer num) {
|
||||
private <T extends BaseResult> void reflectHarmonic(String phase, List<DetectionData> integerBooleanA, T harmonicResult, Integer num) {
|
||||
Map<Double, DetectionData> dataMap = integerBooleanA.stream().collect(Collectors.toMap(DetectionData::getNum, Function.identity()));
|
||||
dataMap.forEach((key, value) -> {
|
||||
try {
|
||||
// 设置 id 字段;
|
||||
Field idField = SimAndDigHarmonicResult.class.getDeclaredField(phase + "Value" + (num == 1 ? (int) (key + 0.5) : key.intValue()));
|
||||
if(harmonicResult instanceof ContrastNonHarmonicResult){
|
||||
idField = ContrastNonHarmonicResult.class.getDeclaredField(phase + "Value" + (num == 1 ? (int) (key + 0.5) : key.intValue()));
|
||||
}
|
||||
idField.setAccessible(true);
|
||||
if (ObjectUtil.isNull(value.getIsData())) {
|
||||
idField.set(harmonicResult, value.getData());
|
||||
@@ -995,8 +998,8 @@ public class DetectionServiceImpl {
|
||||
DetectionData data = new DetectionData();
|
||||
data.setIsData(isQualified);
|
||||
data.setNum(harm);
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
if (CollUtil.isNotEmpty(harmDataList)) {
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
BigDecimal bd = BigDecimal.valueOf(harmDataList.get(0));
|
||||
bd = bd.setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
|
||||
data.setData(bd.doubleValue());
|
||||
@@ -1005,10 +1008,10 @@ public class DetectionServiceImpl {
|
||||
data.setResultData(channelData);
|
||||
if (ObjectUtil.isNotNull(errSysDtl)) {
|
||||
PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class);
|
||||
errSys.setMaxErrorValue(maxErrorMultiply(errSys, fData, issueHarmMap.get(harm)));
|
||||
errSys.setMaxErrorValue(maxErrorMultiply(errSys, fData, issueHarmMap.get(harm), oneConfig.getScale()));
|
||||
data.setUnit(errSysDtl.getErrorUnit());
|
||||
data.setRadius(-errSys.getMaxErrorValue() + "~" + errSys.getMaxErrorValue());
|
||||
setDetection(dataRule, harmDataList, errSys, data, channelData, fData);
|
||||
setDetection(dataRule, harmDataList, errSys, data, channelData, fData, oneConfig.getScale());
|
||||
}
|
||||
info.add(data);
|
||||
});
|
||||
@@ -1170,9 +1173,9 @@ public class DetectionServiceImpl {
|
||||
if (CollUtil.isNotEmpty(errSysDtls)) {
|
||||
PqErrSysDtls errSysDtl = BeanUtil.copyProperties(errSysDtls.get(0), PqErrSysDtls.class);
|
||||
detectionData.setUnit(errSysDtl.getErrorUnit());
|
||||
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl, data, channelData));
|
||||
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl, data, channelData, oneConfig.getScale()));
|
||||
detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
|
||||
setDetection(dataRule, list, errSysDtl, detectionData, channelData, data);
|
||||
setDetection(dataRule, list, errSysDtl, detectionData, channelData, data, oneConfig.getScale());
|
||||
}
|
||||
}
|
||||
return detectionData;
|
||||
@@ -1329,9 +1332,9 @@ public class DetectionServiceImpl {
|
||||
* @param ratedData 额定值
|
||||
* @param harmData 谐波下发值(百分数->含油率)
|
||||
* @return
|
||||
* @parm scale 小数点位数
|
||||
*/
|
||||
public Double maxErrorMultiply(PqErrSysDtls error, Double ratedData, Double harmData) {
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
public Double maxErrorMultiply(PqErrSysDtls error, Double ratedData, Double harmData, Integer scale) {
|
||||
Double errorValue = error.getMaxErrorValue();
|
||||
//1绝对值
|
||||
if (1 == error.getValueType()) {
|
||||
@@ -1339,11 +1342,11 @@ public class DetectionServiceImpl {
|
||||
//绝对值-标称值= 最大误差值 * 额定电压
|
||||
case 0:
|
||||
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(ratedData))
|
||||
.setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
|
||||
.setScale(scale, RoundingMode.HALF_UP).doubleValue();
|
||||
//绝对值-标准值 = 最大误差值 * 谐波下发值
|
||||
case 1:
|
||||
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(harmData))
|
||||
.setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
|
||||
.setScale(scale, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
}
|
||||
//2相对值
|
||||
@@ -1353,7 +1356,7 @@ public class DetectionServiceImpl {
|
||||
case 0:
|
||||
case 1:
|
||||
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(100))
|
||||
.setScale(oneConfig.getScale(), RoundingMode.HALF_UP).doubleValue();
|
||||
.setScale(scale, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
}
|
||||
return errorValue;
|
||||
@@ -1467,28 +1470,28 @@ public class DetectionServiceImpl {
|
||||
|
||||
List<PqErrSysDtls> pqErrSysDtls = pqErrSysDtlsService.listPqErrSysDtlsByPqErrSysIdAndScriptType(errorSysId, split[1]);
|
||||
DetectionCodeEnum anEnum = DetectionCodeEnum.getDetectionCodeByCode(split[1]);
|
||||
Double fData = null;
|
||||
Double fUn = Double.valueOf(monitorDto.getPtStr().split(":")[1]);
|
||||
Double fIn = Double.valueOf(monitorDto.getCtStr().split(":")[1]);
|
||||
Double fHz = 50.0;
|
||||
switch (anEnum) {
|
||||
case FREQ:
|
||||
fData = 50.0;
|
||||
return isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, fData, DetectionCodeEnum.FREQ.getCode(), dataRule, num, code);
|
||||
return isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, fHz, DetectionCodeEnum.FREQ.getCode(), dataRule, num, code);
|
||||
case VRMS:
|
||||
fData = Double.valueOf(monitorDto.getPt().split(":")[1]);
|
||||
return isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, fData, DetectionCodeEnum.VRMS.getCode(), dataRule, num, code);
|
||||
return isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, fUn, DetectionCodeEnum.VRMS.getCode(), dataRule, num, code);
|
||||
case IRMS:
|
||||
break;
|
||||
return isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, fIn, DetectionCodeEnum.IRMS.getCode(), dataRule, num, code);
|
||||
case V_UNBAN:
|
||||
break;
|
||||
return isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, fUn, DetectionCodeEnum.V_UNBAN.getCode(), dataRule, num, code);
|
||||
case I_UNBAN:
|
||||
break;
|
||||
case U1:
|
||||
break;
|
||||
return isQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, fIn, DetectionCodeEnum.I_UNBAN.getCode(), dataRule, num, code);
|
||||
//case U1:
|
||||
case V2_50:
|
||||
break;
|
||||
case I1:
|
||||
break;
|
||||
ContrastHarmonicResult harmV = isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, fUn, fIn, DetectionCodeEnum.V2_50.getCode(), dataRule, num, HARMONIC_FLAG);
|
||||
return resultFlag(harmV, null, code);
|
||||
//case I1:
|
||||
case I2_50:
|
||||
break;
|
||||
ContrastHarmonicResult harmI = isHarmQualified(devDataList, standardDevDataList, devIdMapComm, pqErrSysDtls, fUn, fIn, DetectionCodeEnum.V2_50.getCode(), dataRule, num, HARMONIC_FLAG);
|
||||
return resultFlag(null, harmI, code);
|
||||
case MAG:
|
||||
break;
|
||||
case DUR:
|
||||
@@ -1636,22 +1639,14 @@ public class DetectionServiceImpl {
|
||||
harmonicResult.setDataType(DataSourceEnum.REAL_DATA.getValue());
|
||||
List<PqErrSysDtls> pqErrSysDtls = new ArrayList<>();
|
||||
Integer isQualified = 4;
|
||||
// if (CollUtil.isNotEmpty(errDtlsCheckData)) {
|
||||
// String finalHarmCode = harmCode;
|
||||
// List<ErrDtlsCheckDataVO> adDtlsCheckData = errDtlsCheckData.stream().filter(x -> finalHarmCode.equals(x.getValueTypeCode())).collect(Collectors.toList());
|
||||
// harmonicResult.setAdType(adDtlsCheckData.get(0).getValueType());
|
||||
// isQualified = adDtlsCheckData.get(0).getIsQualified();
|
||||
// if (CollUtil.isNotEmpty(adDtlsCheckData.get(0).getErrSysDtls())) {
|
||||
// pqErrSysDtls = adDtlsCheckData.get(0).getErrSysDtls();
|
||||
// }
|
||||
// }
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, pqErrSysDtls, dataRule, devMap.get(TYPE_A).get(0), fData, harmonicFlag);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, pqErrSysDtls, dataRule, devMap.get(TYPE_B).get(0), fData, harmonicFlag);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, pqErrSysDtls, dataRule, devMap.get(TYPE_C).get(0), fData, harmonicFlag);
|
||||
|
||||
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, pqErrSysDtls, dataRule, devMap.get(TYPE_A).get(0), devMap.get(TYPE_A).get(1), fData);
|
||||
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, pqErrSysDtls, dataRule, devMap.get(TYPE_B).get(0), devMap.get(TYPE_A).get(1), fData);
|
||||
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, pqErrSysDtls, dataRule, devMap.get(TYPE_C).get(0), devMap.get(TYPE_A).get(1), fData);
|
||||
harmonicResult.setDataType(DataSourceEnum.REAL_DATA.getValue());
|
||||
// reflectHarmonic("a", integerBooleanA, harmonicResult, humonicFlag);
|
||||
// reflectHarmonic("b", integerBooleanB, harmonicResult, humonicFlag);
|
||||
// reflectHarmonic("c", integerBooleanC, harmonicResult, humonicFlag);
|
||||
reflectHarmonic("a", integerBooleanA, harmonicResult, harmonicFlag);
|
||||
reflectHarmonic("b", integerBooleanB, harmonicResult, harmonicFlag);
|
||||
reflectHarmonic("c", integerBooleanC, harmonicResult, harmonicFlag);
|
||||
List<DetectionData> list = new ArrayList<>();
|
||||
list.addAll(integerBooleanA.stream().filter(x -> 1 != x.getNum()).distinct().collect(Collectors.toList()));
|
||||
list.addAll(integerBooleanB.stream().filter(x -> 1 != x.getNum()).distinct().collect(Collectors.toList()));
|
||||
@@ -1894,52 +1889,24 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pqErrSysDtls 误差体系
|
||||
* @param dataRule 数据处理原则
|
||||
* @param devMap
|
||||
* @param fData 额定值
|
||||
* @param harmonicFlag 1:间谐波,2:谐波
|
||||
* @param isQualified 检测结果
|
||||
* @param pqErrSysDtls 误差体系
|
||||
* @param dataRule 数据处理原则
|
||||
* @param devMap 被检设备(间)谐波数据
|
||||
* @param standardDevMap 与之对齐的标准设备(间)谐波数据
|
||||
* @param fData 额定值
|
||||
* @return
|
||||
*/
|
||||
public List<DetectionData> harmRangeComparison(Integer isQualified,
|
||||
List<PqErrSysDtls> pqErrSysDtls,
|
||||
DictDataEnum dataRule,
|
||||
Map<Double, List<Double>> devMap,
|
||||
Double fData,
|
||||
Integer harmonicFlag) {
|
||||
Map<Double, List<Double>> standardDevMap,
|
||||
Double fData) {
|
||||
List<DetectionData> info = new ArrayList<>();
|
||||
//根据谐波几次相值/额定值
|
||||
Map<Double, Double> issueHarmMap=devMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, x -> x.getValue().get(0)));
|
||||
Map<Double, Double> issueHarmMap = standardDevMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, x -> x.getValue().get(0)));
|
||||
|
||||
|
||||
// if (HP.equals(type)) {
|
||||
// List<PqScriptCheckData> checkData = pqScriptCheckDataService.list(new MPJLambdaWrapper<PqScriptCheckData>()
|
||||
// .eq(PqScriptCheckData::getScriptIndex, sourceIssue.getIndex())
|
||||
// .eq(PqScriptCheckData::getPhase, phase)
|
||||
// .eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
||||
// );
|
||||
// issueHarmMap = checkData.stream().collect(Collectors.toMap(PqScriptCheckData::getHarmNum, x -> x.getValue() * fData));
|
||||
// } else {
|
||||
// Double percent;
|
||||
// if (I.equals(type)) {
|
||||
// //电流是百分比转换成赋值算的
|
||||
// percent = fData * 0.01;
|
||||
// } else {
|
||||
// //电压是百分比算的
|
||||
// percent = 1.0;
|
||||
// }
|
||||
// if (1 == harmonicFlag) {
|
||||
// issueHarmMap = sourceIssue.getChannelList().stream()
|
||||
// .filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
||||
// .flatMap(x -> x.getInharmList().stream())
|
||||
// .collect(Collectors.toMap(SourceIssue.ChannelListDTO.InharmModel::getInharm, x -> BigDecimal.valueOf(x.getFAmp()).multiply(BigDecimal.valueOf(percent)).doubleValue()));
|
||||
// } else {
|
||||
// issueHarmMap = sourceIssue.getChannelList().stream()
|
||||
// .filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
||||
// .flatMap(x -> x.getHarmList().stream())
|
||||
// .collect(Collectors.toMap(SourceIssue.ChannelListDTO.HarmModel::getHarm, x -> BigDecimal.valueOf(x.getFAmp()).multiply(BigDecimal.valueOf(percent)).doubleValue()));
|
||||
// }
|
||||
// }
|
||||
Map<Double, PqErrSysDtls> errSysDtlMap = new LinkedHashMap<>();
|
||||
issueHarmMap.forEach((key, value) -> {
|
||||
//获得误差体系
|
||||
@@ -1960,8 +1927,8 @@ public class DetectionServiceImpl {
|
||||
DetectionData data = new DetectionData();
|
||||
data.setIsData(isQualified);
|
||||
data.setNum(harm);
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
if (CollUtil.isNotEmpty(harmDataList)) {
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
BigDecimal bd = BigDecimal.valueOf(harmDataList.get(0));
|
||||
bd = bd.setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
|
||||
data.setData(bd.doubleValue());
|
||||
@@ -1970,10 +1937,10 @@ public class DetectionServiceImpl {
|
||||
data.setResultData(channelData);
|
||||
if (ObjectUtil.isNotNull(errSysDtl)) {
|
||||
PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class);
|
||||
errSys.setMaxErrorValue(maxErrorMultiply(errSys, fData, issueHarmMap.get(harm)));
|
||||
errSys.setMaxErrorValue(maxErrorMultiply(errSys, fData, issueHarmMap.get(harm), oneConfig.getScale()));
|
||||
data.setUnit(errSysDtl.getErrorUnit());
|
||||
data.setRadius(-errSys.getMaxErrorValue() + "~" + errSys.getMaxErrorValue());
|
||||
setDetection(dataRule, harmDataList, errSys, data, channelData, fData);
|
||||
setDetection(dataRule, harmDataList, errSys, data, channelData, fData, oneConfig.getScale());
|
||||
}
|
||||
info.add(data);
|
||||
});
|
||||
@@ -2060,16 +2027,15 @@ public class DetectionServiceImpl {
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/29 18:10
|
||||
*/
|
||||
private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double channelData, Double ratedValue) {
|
||||
private void setDetection(DictDataEnum dataRule, List<Double> harmDataList, PqErrSysDtls errSysDtl, DetectionData data, Double channelData, Double ratedValue, Integer scale) {
|
||||
if (CollUtil.isNotEmpty(harmDataList)) {
|
||||
// 存放合格的数据
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
List<Double> qualifiedList = harmDataList.stream()
|
||||
.filter(x -> channelData == 0 ? NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl, oneConfig.getScale()),
|
||||
.filter(x -> channelData == 0 ? NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl, scale),
|
||||
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
|
||||
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))
|
||||
:
|
||||
x != 0 && NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl, oneConfig.getScale()),
|
||||
x != 0 && NumberUtil.isIn(devSubtractChannelData(x, channelData, ratedValue, errSysDtl, scale),
|
||||
BigDecimal.valueOf(-errSysDtl.getMaxErrorValue()),
|
||||
BigDecimal.valueOf(errSysDtl.getMaxErrorValue()))).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(qualifiedList)) {
|
||||
@@ -2077,23 +2043,23 @@ public class DetectionServiceImpl {
|
||||
case AT_WILL_VALUE:
|
||||
case CP95_VALUE:
|
||||
case AVG_VALUE:
|
||||
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl, oneConfig.getScale()));
|
||||
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl, scale));
|
||||
break;
|
||||
case SECTION_VALUE:
|
||||
case Own_value:
|
||||
if (qualifiedList.size() == harmDataList.size()) {
|
||||
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl, oneConfig.getScale()));
|
||||
data.setErrorData(devSubtractChannelData(qualifiedList.get(0), channelData, ratedValue, errSysDtl, scale));
|
||||
} else {
|
||||
List<Double> subtract = CollectionUtils.subtract(harmDataList, qualifiedList).stream().collect(Collectors.toList());
|
||||
BigDecimal bd = BigDecimal.valueOf(subtract.get(0));
|
||||
bd = bd.setScale(oneConfig.getScale(), RoundingMode.HALF_UP);
|
||||
bd = bd.setScale(scale, RoundingMode.HALF_UP);
|
||||
data.setData(bd.doubleValue());
|
||||
data.setErrorData(devSubtractChannelData(subtract.get(0), channelData, ratedValue, errSysDtl, oneConfig.getScale()));
|
||||
data.setErrorData(devSubtractChannelData(subtract.get(0), channelData, ratedValue, errSysDtl, scale));
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
data.setErrorData(devSubtractChannelData(harmDataList.get(0), channelData, ratedValue, errSysDtl, oneConfig.getScale()));
|
||||
data.setErrorData(devSubtractChannelData(harmDataList.get(0), channelData, ratedValue, errSysDtl, scale));
|
||||
}
|
||||
isData(dataRule, harmDataList, data, qualifiedList);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.njcn.gather.detection.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -22,11 +21,10 @@ import com.njcn.gather.detection.util.business.DetectionCommunicateUtil;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyContrastClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
@@ -43,6 +41,7 @@ import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -50,10 +49,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -77,10 +73,10 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
private final SocketContrastResponseService socketContrastResponseService;
|
||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||
|
||||
@Value("${socket.source.ip:192.168.1.138}")
|
||||
@Value("${socket.device.ip:127.0.0.1}")
|
||||
private String ip;
|
||||
|
||||
@Value("${socket.source.port:61000}")
|
||||
@Value("${socket.device.port:61000}")
|
||||
private Integer port;
|
||||
|
||||
//private final SocketSourceResponseService sourceResponseService;
|
||||
@@ -323,9 +319,9 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
public void startContrastTest(ContrastDetectionParam param) {
|
||||
// 参数校验,目前仅检查IP是否重复,后续可在里面扩展
|
||||
checkDevIp(param.getDevIds());
|
||||
//用于处理异常导致的socket通道未关闭,socket交互异常
|
||||
DetectionCommunicateUtil.checkContrastCommunicateChannel(param.getUserId());
|
||||
socketContrastResponseService.init(param);
|
||||
//用于处理异常导致的socket通道未关闭,socket交互异常
|
||||
DetectionCommunicateUtil.checkContrastCommunicateChannel(param.getLoginName());
|
||||
|
||||
// 和通信模块进行连接
|
||||
this.sendContrastSocket(param);
|
||||
@@ -337,22 +333,22 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
* @param param
|
||||
*/
|
||||
private void sendContrastSocket(ContrastDetectionParam param) {
|
||||
String s = param.getUserId() + CnSocketUtil.DEV_TAG;
|
||||
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
List<PreDetection> preDetections = BeanUtil.copyToList(FormalTestManager.devList, PreDetection.class);
|
||||
preDetections.addAll(BeanUtil.copyToList(FormalTestManager.standardDevList, PreDetection.class));
|
||||
List<PreDetection> preDetections = new ArrayList<>();
|
||||
preDetections.addAll(FormalTestManager.devList);
|
||||
preDetections.addAll(FormalTestManager.standardDevList);
|
||||
|
||||
preDetections.forEach(x -> {
|
||||
x.setDevType(x.getIcdType());
|
||||
x.getMonitorList().forEach(y -> {
|
||||
|
||||
String pt = y.getPt();
|
||||
int i = pt.indexOf(":");
|
||||
y.setPt(BigDecimal.valueOf(Double.parseDouble(pt.substring(0, i))).divide(BigDecimal.valueOf(Double.parseDouble(pt.substring(i + 1))), 5, BigDecimal.ROUND_HALF_UP) + "");
|
||||
String ptStr = y.getPtStr();
|
||||
int i = ptStr.indexOf(":");
|
||||
y.setPt(BigDecimal.valueOf(Double.parseDouble(ptStr.substring(0, i))).divide(BigDecimal.valueOf(Double.parseDouble(ptStr.substring(i + 1))), 5, BigDecimal.ROUND_HALF_UP).doubleValue());
|
||||
|
||||
String ct = y.getCt();
|
||||
i = ct.indexOf(":");
|
||||
y.setCt(BigDecimal.valueOf(Double.parseDouble(ct.substring(0, i))).divide(BigDecimal.valueOf(Double.parseDouble(ct.substring(i + 1))), 5, BigDecimal.ROUND_HALF_UP) + "");
|
||||
String ctStr = y.getCtStr();
|
||||
i = ctStr.indexOf(":");
|
||||
y.setCt(BigDecimal.valueOf(Double.parseDouble(ctStr.substring(0, i))).divide(BigDecimal.valueOf(Double.parseDouble(ctStr.substring(i + 1))), 5, BigDecimal.ROUND_HALF_UP).doubleValue());
|
||||
});
|
||||
});
|
||||
map.put("deviceList", preDetections);
|
||||
@@ -360,13 +356,13 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_02.getValue());
|
||||
socketMsg.setData(jsonString);
|
||||
String json = JSON.toJSONString(socketMsg);
|
||||
SocketManager.sendMsg(s, json);
|
||||
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setUserPageId(param.getUserId());
|
||||
preDetectionParam.setUserPageId(param.getLoginName());
|
||||
WebServiceManager.addPreDetectionParam(param.getLoginName(), preDetectionParam);
|
||||
NettyClient.socketClient(ip, port, preDetectionParam, json, new NettyContrastClientHandler(preDetectionParam, socketContrastResponseService));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.njcn.gather.detection.util;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -22,6 +21,10 @@ import java.util.stream.Stream;
|
||||
* @data 2025-07-28
|
||||
*/
|
||||
public class DetectionUtil {
|
||||
// ISO 8601格式
|
||||
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_DATE_TIME;
|
||||
|
||||
|
||||
/**
|
||||
* 相角矫正到统一个区间
|
||||
*
|
||||
@@ -50,7 +53,7 @@ public class DetectionUtil {
|
||||
|
||||
long devMillis = getMillis(devData.getTime());
|
||||
long standardMillis = getMillis(standardDevData.getTime());
|
||||
if (BigDecimal.valueOf(devMillis).divide(BigDecimal.valueOf(10), 0, BigDecimal.ROUND_HALF_UP).compareTo(BigDecimal.valueOf(standardMillis).divide(BigDecimal.valueOf(10), 0, BigDecimal.ROUND_HALF_UP)) == 0) {
|
||||
if (BigDecimal.valueOf(devMillis).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_HALF_UP).compareTo(BigDecimal.valueOf(standardMillis).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_HALF_UP)) == 0) {
|
||||
return true;
|
||||
} else if (Math.abs(devMillis - standardMillis) < 100) {
|
||||
return true;
|
||||
@@ -84,7 +87,7 @@ public class DetectionUtil {
|
||||
* @return
|
||||
*/
|
||||
public static long getMillis(String dateTimeStr) {
|
||||
LocalDateTime localDateTime = timeFormat(dateTimeStr, DateTimeFormatter.ISO_DATE_TIME);
|
||||
LocalDateTime localDateTime = timeFormat(dateTimeStr, FORMATTER);
|
||||
return getMillis(localDateTime);
|
||||
}
|
||||
|
||||
@@ -100,12 +103,15 @@ public class DetectionUtil {
|
||||
|
||||
/**
|
||||
* 判断value是否为0
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static boolean isZero(Double value) {
|
||||
// todo 电流为0判断
|
||||
|
||||
BigDecimal bd = BigDecimal.valueOf(value);
|
||||
if(bd.subtract(BigDecimal.ZERO).abs().compareTo(BigDecimal.valueOf(0.001)) < 0){
|
||||
if (bd.subtract(BigDecimal.ZERO).abs().compareTo(BigDecimal.valueOf(0.01)) < 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -60,27 +60,20 @@ public class DetectionCommunicateUtil {
|
||||
/**
|
||||
* 比对式-检测是否存在已有的Socket通道,有则强行关闭
|
||||
*
|
||||
* @param userId
|
||||
* @param loginName
|
||||
*/
|
||||
public static void checkContrastCommunicateChannel(String userId) {
|
||||
Channel channel = SocketManager.getChannelByUserId(userId);
|
||||
public static void checkContrastCommunicateChannel(String loginName) {
|
||||
Channel channel = SocketManager.getChannelByUserId(loginName + CnSocketUtil.CONTRAST_DEV_TAG);
|
||||
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("存在已有的Socket通道,强行关闭。。。。。。。。");
|
||||
CnSocketUtil.contrastSendquit(userId);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
SocketManager.removeUser(userId);
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
CnSocketUtil.contrastSendquit(loginName);
|
||||
SocketManager.removeUser(loginName + CnSocketUtil.CONTRAST_DEV_TAG);
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ public class CnSocketUtil {
|
||||
|
||||
public final static String DEV_TAG = "_Dev";
|
||||
|
||||
public final static String CONTRAST_DEV_TAG = "_Contrast_Dev";
|
||||
|
||||
public final static String SOURCE_TAG = "_Source";
|
||||
|
||||
public final static String START_TAG = "_Start";
|
||||
@@ -57,12 +59,13 @@ public class CnSocketUtil {
|
||||
/**
|
||||
* 比对式-退出检测
|
||||
*/
|
||||
public static void contrastSendquit(String userId) {
|
||||
public static void contrastSendquit(String loginName) {
|
||||
System.out.println("比对式-发送关闭备通讯模块指令。。。。。。。。");
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||
SocketManager.sendMsg(userId + DEV_TAG, JSON.toJSONString(socketMsg));
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_02.getValue());
|
||||
SocketManager.sendMsg(loginName + CONTRAST_DEV_TAG, JSON.toJSONString(socketMsg));
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
FormalTestManager.currentStep=SourceOperateCodeEnum.QUITE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.device.pojo.po.PqStandardDev;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
@@ -20,9 +21,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
public class FormalTestManager {
|
||||
|
||||
// 当前步骤
|
||||
public static SourceOperateCodeEnum currentStep;
|
||||
|
||||
/**
|
||||
* key:设备ip,value:当前设备下面的通道号
|
||||
* key:设备ip,value:当前设备下面的监测点ID(ip_通道号)
|
||||
*/
|
||||
public static Map<String, List<String>> devMapMonitorNum = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -59,7 +62,7 @@ public class FormalTestManager {
|
||||
/**
|
||||
* key:设备ip,value:装置id
|
||||
*/
|
||||
public static Map<String, String> devIdMapComm = new HashMap<>();
|
||||
public static Map<String, String> devIdMapComm = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* 停止触发标识
|
||||
@@ -86,6 +89,11 @@ public class FormalTestManager {
|
||||
*/
|
||||
public static AdPlan currentTestPlan;
|
||||
|
||||
/**
|
||||
* 当前正在检测的模式
|
||||
*/
|
||||
public static PatternEnum patternEnum;
|
||||
|
||||
/**
|
||||
* 比对式检测-检测项。
|
||||
*/
|
||||
@@ -97,9 +105,9 @@ public class FormalTestManager {
|
||||
public static DictDataEnum dataRule;
|
||||
|
||||
/**
|
||||
* 所有参与比对式检测的被检设备、标准设备配对关系。key:标准设备id_通道号,value:被检设备id_通道号
|
||||
* 所有参与比对式检测的被检设备、标准设备配对关系。key:被检设备id_通道号,value:标准设备id_通道号
|
||||
*/
|
||||
public static Map<String, String> pairsMap = HashBiMap.create();
|
||||
public static HashBiMap<String, String> pairsMap = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* 被检设备的数据。key:设备ip_通道号,value:DevData数据集合
|
||||
|
||||
@@ -65,4 +65,22 @@ public class MsgUtil {
|
||||
}
|
||||
return JSON.toJSONString(socketDataMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一组监测点配对的字符串
|
||||
*
|
||||
* @param devMonitorId
|
||||
* @param standardDevId
|
||||
* @param devMap
|
||||
* @return
|
||||
*/
|
||||
public static String getPairStr(String devMonitorId, String standardDevId, Map<String, String> devMap) {
|
||||
if (StrUtil.isBlank(devMonitorId) || StrUtil.isBlank(standardDevId)) {
|
||||
return "";
|
||||
} else {
|
||||
String[] split1 = devMonitorId.split("_");
|
||||
String[] split2 = standardDevId.split("_");
|
||||
return "被检设备" + devMap.get(split1[0]) + CnSocketUtil.SPLIT_TAG + split1[1] + "路" + " -> 标准设备" + devMap.get(split2[0]) + CnSocketUtil.SPLIT_TAG + split2[1] + "路";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,8 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
if (CnSocketUtil.DEV_TAG.equals(handlerType)) {
|
||||
//CnSocketUtil.sendToWebSocket(param.getUserPageId(),);
|
||||
CnSocketUtil.quitSend(param);
|
||||
} else if (CnSocketUtil.CONTRAST_DEV_TAG.equals(handlerType)) {
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId());
|
||||
} else {
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
@@ -81,7 +83,7 @@ public class HeartbeatHandler extends SimpleChannelInboundHandler<String> {
|
||||
Thread.currentThread().interrupt();
|
||||
System.err.println("线程中断异常: " + e.getMessage());
|
||||
}
|
||||
String key = CnSocketUtil.DEV_TAG.equals(handlerType) ? param.getUserPageId() + CnSocketUtil.DEV_TAG : param.getUserPageId() + CnSocketUtil.SOURCE_TAG;
|
||||
String key = param.getUserPageId() + handlerType;
|
||||
SocketManager.removeUser(key);
|
||||
consecutiveHeartbeatMisses = 0; // 重置连续心跳丢失次数
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class NettyClient {
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(new HeartbeatHandler(param, CnSocketUtil.SOURCE_TAG))
|
||||
.addLast(handler);
|
||||
} else {
|
||||
} else if (handler instanceof NettyDevClientHandler) {
|
||||
ch.pipeline()
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
@@ -64,8 +64,21 @@ public class NettyClient {
|
||||
//allIdleTimeSeconds:在指定的秒数内如果没有发生任何读取或写入操作,则触发IdleState.ALL_IDLE事件。
|
||||
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(handler);
|
||||
}
|
||||
} else if (handler instanceof NettyContrastClientHandler) {
|
||||
ch.pipeline()
|
||||
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(new HeartbeatHandler(param, CnSocketUtil.CONTRAST_DEV_TAG))
|
||||
//空闲状态的handler
|
||||
//readerIdleTimeSeconds:在指定的秒数内如果没有读取到任何数据,则触发IdleState.READER_IDLE事件。
|
||||
//writerIdleTimeSeconds:在指定的秒数内如果没有写入任何数据,则触发IdleState.WRITER_IDLE事件。
|
||||
//allIdleTimeSeconds:在指定的秒数内如果没有发生任何读取或写入操作,则触发IdleState.ALL_IDLE事件。
|
||||
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(handler);
|
||||
}
|
||||
}
|
||||
});
|
||||
ChannelFuture channelFuture = bootstrap.connect(ip, port).sync();
|
||||
@@ -82,12 +95,18 @@ public class NettyClient {
|
||||
groupByUserId.shutdownGracefully().sync();
|
||||
}
|
||||
SocketManager.addGroup(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, group);
|
||||
} else {
|
||||
} else if(handler instanceof NettyDevClientHandler){
|
||||
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + CnSocketUtil.DEV_TAG);
|
||||
if (ObjectUtil.isNotNull(groupByUserId)) {
|
||||
groupByUserId.shutdownGracefully().sync();
|
||||
}
|
||||
SocketManager.addGroup(param.getUserPageId() + CnSocketUtil.DEV_TAG, group);
|
||||
}else if(handler instanceof NettyContrastClientHandler){
|
||||
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
|
||||
if (ObjectUtil.isNotNull(groupByUserId)) {
|
||||
groupByUserId.shutdownGracefully().sync();
|
||||
}
|
||||
SocketManager.addGroup(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, group);
|
||||
}
|
||||
|
||||
System.out.println("客户端向服务端发送消息:" + port + msg);
|
||||
@@ -109,8 +128,8 @@ public class NettyClient {
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
socketDataMsg.setOperateCode("Dev");
|
||||
} else {
|
||||
socketDataMsg.setOperateCode("Dev");
|
||||
CnSocketUtil.quitSend(param);
|
||||
socketDataMsg.setOperateCode("Contrast_Dev");
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId());
|
||||
}
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
} finally {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler<Stri
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("客户端通道已建立" + ctx.channel().id());
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + CnSocketUtil.DEV_TAG);
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
|
||||
if (Objects.nonNull(channel)) {
|
||||
try {
|
||||
channel.close().sync();
|
||||
@@ -43,7 +43,7 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler<Stri
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
SocketManager.addUser(param.getUserPageId() + CnSocketUtil.DEV_TAG, ctx.channel());
|
||||
SocketManager.addUser(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG, ctx.channel());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,7 +53,7 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler<Stri
|
||||
socketContrastResponseService.deal(param, msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
CnSocketUtil.quitSend(param);
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler<Stri
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("与通信模块端断线");
|
||||
ctx.close();
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.DEV_TAG);
|
||||
SocketManager.removeUser(param.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,66 +79,12 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler<Stri
|
||||
|
||||
//实时数据
|
||||
if (SocketManager.contrastClockMap.get(DataSourceEnum.REAL_DATA) >= 60) {
|
||||
CnSocketUtil.quitSend(param);
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId());
|
||||
System.out.println("超时处理-----》" + "实时数据已超时----------------关闭");
|
||||
timeoutSend();
|
||||
}
|
||||
// if (!FormalTestManager.hasStopFlag) {
|
||||
// if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
// SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
// if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
// SocketManager.clockMap.put(sourceIssue.getIndex(), SocketManager.clockMap.get(sourceIssue.getIndex()) + 60L);
|
||||
// } else {
|
||||
// SocketManager.clockMap.put(sourceIssue.getIndex(), 60L);
|
||||
// }
|
||||
//
|
||||
// if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
|
||||
// //闪变,正常抛一轮最大等待20分钟超时
|
||||
// if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 1300) {
|
||||
// fly = true;
|
||||
// System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// timeoutSend(sourceIssue);
|
||||
// }
|
||||
// } else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
|
||||
// //统计数据项,正常抛一轮数据,超时
|
||||
// if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 180) {
|
||||
// fly = true;
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
// timeoutSend(sourceIssue);
|
||||
// }
|
||||
// } else {
|
||||
// //实时数据
|
||||
// if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 60) {
|
||||
// fly = true;
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
// timeoutSend(sourceIssue);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// fly = true;
|
||||
// //为空则认为是常规步骤,设定一分钟超时
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue(), SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg(), null);
|
||||
// }
|
||||
// if (fly) {
|
||||
// socketContrastResponseService.backCheckState(param);
|
||||
// }
|
||||
// } else {
|
||||
// //如果是暂停操作后
|
||||
// FormalTestManager.stopTime += 60;
|
||||
// System.out.println("当前进入暂停操作超时函数-----------------" + FormalTestManager.stopTime);
|
||||
// if (FormalTestManager.stopTime > 600) {
|
||||
// CnSocketUtil.quitSend(param);
|
||||
// CnSocketUtil.sendToWebSocket(param.getUserPageId(), SourceOperateCodeEnum.FORMAL_REAL.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getValue(), SourceOperateCodeEnum.STOP_TIMEOUT.getMsg(), null);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,7 +112,7 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler<Stri
|
||||
System.out.println("Unknown exception caught: " + cause.getMessage());
|
||||
WebServiceManager.sendDetectionErrorMessage(param.getUserPageId(), SourceOperateCodeEnum.DEVICE_ERROR);
|
||||
}
|
||||
CnSocketUtil.quitSend(param);
|
||||
CnSocketUtil.contrastSendquit(param.getUserPageId());
|
||||
// socketContrastResponseService.backCheckState(param);
|
||||
ctx.close();
|
||||
}
|
||||
@@ -176,7 +122,7 @@ public class NettyContrastClientHandler extends SimpleChannelInboundHandler<Stri
|
||||
* 接收数据超时处理
|
||||
*/
|
||||
private void timeoutSend() {
|
||||
|
||||
System.out.println("接收数据超时处理。todo...");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.net.ProtocolException;
|
||||
public class NettySourceClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
private final PreDetectionParam webUser;
|
||||
private final String sourceTag = "_Source";
|
||||
private final SocketSourceResponseService sourceResponseService;
|
||||
|
||||
/**
|
||||
@@ -40,7 +39,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("客户端通道已建立" + ctx.channel().id());
|
||||
|
||||
SocketManager.addUser(webUser.getUserPageId() + sourceTag, ctx.channel());
|
||||
SocketManager.addUser(webUser.getUserPageId() + CnSocketUtil.SOURCE_TAG, ctx.channel());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +67,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("源通讯客户端断线");
|
||||
ctx.close();
|
||||
SocketManager.removeUser(webUser.getUserPageId() + sourceTag);
|
||||
SocketManager.removeUser(webUser.getUserPageId() + CnSocketUtil.SOURCE_TAG);
|
||||
// System.out.println("断线了......" + ctx.channel());
|
||||
// ctx.channel().eventLoop().schedule(() -> {
|
||||
// System.out.println("断线重连......");
|
||||
|
||||
@@ -3,13 +3,15 @@ package com.njcn.gather.detection.util.socket.websocket;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketHandshakeException;
|
||||
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import io.netty.util.AttributeKey;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -368,17 +370,14 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
if (ObjectUtil.isNotNull(preDetectionParam)) {
|
||||
// 使用该用户的检测参数关闭Socket连接
|
||||
log.info("使用用户检测参数关闭Socket连接,userId: {}", userId);
|
||||
CnSocketUtil.quitSendSource(preDetectionParam);
|
||||
CnSocketUtil.quitSend(preDetectionParam);
|
||||
if (FormalTestManager.patternEnum.equals(PatternEnum.CONTRAST)) {
|
||||
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId());
|
||||
} else {
|
||||
CnSocketUtil.quitSendSource(preDetectionParam);
|
||||
CnSocketUtil.quitSend(preDetectionParam);
|
||||
}
|
||||
// 清理完成后移除该用户的检测参数
|
||||
WebServiceManager.removePreDetectionParam(userId);
|
||||
} else {
|
||||
// 使用当前Handler的userId创建检测参数进行清理
|
||||
log.info("未找到用户检测参数,使用默认参数关闭Socket连接,userId: {}", userId);
|
||||
preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setUserPageId(userId);
|
||||
// 只关闭设备Socket,因为没有sourceId等其他参数
|
||||
CnSocketUtil.quitSend(preDetectionParam);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("清理Socket连接时发生异常,userId: {}", userId, e);
|
||||
|
||||
@@ -13,6 +13,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface PqStandardDevMapper extends MPJBaseMapper<PqStandardDev> {
|
||||
|
||||
List<PreDetection> listStandardDevPreDetection(@Param("devIds") List<String> ids);
|
||||
List<PreDetection> listStandardDevPreDetection(@Param("ids") List<String> ids);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,15 +30,16 @@
|
||||
standard_dev.Name,
|
||||
standard_dev.IP,
|
||||
standard_dev.Port,
|
||||
standard_dev.Dev_Type,
|
||||
dev_type.name as Dev_Type,
|
||||
standard_dev.Series,
|
||||
standard_dev.Dev_Key,
|
||||
dev_type.icdType,
|
||||
icd_path.Name as icdType,
|
||||
dev_type.Dev_Chns,
|
||||
dev_type.Dev_Volt,
|
||||
dev_type.Dev_Curr
|
||||
from pq_standard_dev standard_dev
|
||||
inner join pq_dev_type dev_type on standard_dev.Dev_Type = dev_type.id
|
||||
inner join pq_icd_path icd_path on dev_type.icd = icd_path.id
|
||||
where standard_dev.Id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
|
||||
@@ -19,4 +19,13 @@ public enum PatternEnum {
|
||||
this.value = value;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static PatternEnum getEnum(String value) {
|
||||
for (PatternEnum patternEnum : PatternEnum.values()) {
|
||||
if (patternEnum.getValue().equals(value)) {
|
||||
return patternEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,25 +97,37 @@ public class PreDetection {
|
||||
/**
|
||||
* pt
|
||||
*/
|
||||
@JSONField(name = "pt")
|
||||
private String pt;
|
||||
@JSONField(serialize = false)
|
||||
private String ptStr;
|
||||
|
||||
/**
|
||||
* ct
|
||||
*/
|
||||
@JSONField(name = "ct") //todo 是否改为ct
|
||||
private String ct;
|
||||
@JSONField(serialize = false)
|
||||
private String ctStr;
|
||||
|
||||
/**
|
||||
* pt
|
||||
*/
|
||||
@JSONField(name = "pt")
|
||||
private Double pt;
|
||||
|
||||
/**
|
||||
* ct
|
||||
*/
|
||||
@JSONField(name = "ct")
|
||||
private Double ct;
|
||||
|
||||
/**
|
||||
* 统计间隔
|
||||
*/
|
||||
@JSONField(name = "statInterval")
|
||||
@JSONField(serialize = false)
|
||||
private Integer statInterval;
|
||||
|
||||
/**
|
||||
* 接线方式
|
||||
*/
|
||||
@JSONField(name = "connection")
|
||||
@JSONField(serialize = false)
|
||||
private String connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -418,8 +418,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
monitorListDTO = new PreDetection.MonitorListDTO();
|
||||
monitorListDTO.setLineId(preDetection.getDevIP() + "_" + i);
|
||||
monitorListDTO.setLine(i);
|
||||
monitorListDTO.setPt("1");
|
||||
monitorListDTO.setCt("1");
|
||||
monitorListDTO.setPt(1.0);
|
||||
monitorListDTO.setCt(1.0);
|
||||
monitorList.add(monitorListDTO);
|
||||
}
|
||||
preDetection.setMonitorList(monitorList);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
resultType="com.njcn.gather.device.pojo.vo.PreDetection$MonitorListDTO">
|
||||
SELECT CONCAT(pq_dev.IP, '_', Num) as lineId,
|
||||
Num as line,
|
||||
pt as pt,
|
||||
ct as ct,
|
||||
pt as ptStr,
|
||||
ct as ctStr,
|
||||
Stat_Interval,
|
||||
sys_dict_data.Code as `Connection`
|
||||
FROM pq_monitor
|
||||
|
||||
@@ -74,6 +74,7 @@ import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.http.util.RestTemplateUtil;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -698,11 +699,11 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
||||
data.set("file", base64String);
|
||||
sendFileMsg.setData(data.toString());
|
||||
String msg = JSON.toJSONString(sendFileMsg);
|
||||
Channel channel = SocketManager.getChannelByUserId("cdf" + DetectionCommunicateConstant.DEV);
|
||||
Channel channel = SocketManager.getChannelByUserId(RequestUtil.getLoginName()+ DetectionCommunicateConstant.DEV);
|
||||
if (Objects.isNull(channel) || !channel.isActive()) {
|
||||
// 进行源通信连接
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setUserPageId("cdf");
|
||||
preDetectionParam.setUserPageId(RequestUtil.getLoginName());
|
||||
preDetectionParam.setSendWebMsg(false);
|
||||
|
||||
NettyClient.socketClient(ip, port, preDetectionParam, msg, new NettyDevClientHandler(preDetectionParam, socketDevResponseService));
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.njcn.gather.result.pojo.vo.FormContentVO;
|
||||
import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.gather.system.log.pojo.param.SysLogParam;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -119,4 +120,13 @@ public class ResultController extends BaseController {
|
||||
resultService.deleteTempTable(code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/exportAlignData")
|
||||
@ApiOperation("实时对齐数据导出为csv文件")
|
||||
public void exportAlignData() {
|
||||
String methodDescribe = getMethodDescribe("exportAlignData");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
resultService.exportAlignData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,14 +86,20 @@ public interface IResultService {
|
||||
* @param planCode 计划编号
|
||||
* @param devId 被检设备id
|
||||
* @param lineNo 回路号
|
||||
* @param tableKeys 表格key
|
||||
* @param tableKeys 表格key
|
||||
*/
|
||||
SingleTestResult getFinalContent(List<PqScriptDtlDataVO> checkDataVOList, String planCode, String devId, Integer lineNo, List<String> tableKeys);
|
||||
|
||||
/**
|
||||
* 获取段落中指定的key对应的值
|
||||
*
|
||||
* @param itemCode 测试大项code
|
||||
* @param pKeys 待填充的值
|
||||
* @param pKeys 待填充的值
|
||||
*/
|
||||
Map<String, String> getParagraphKeysValue(String itemCode, List<String> pKeys);
|
||||
|
||||
/**
|
||||
* 导出实时数据对齐过程中的数据
|
||||
*/
|
||||
void exportAlignData();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,12 @@ import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.vo.AlignDataExcel;
|
||||
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.detection.util.DetectionUtil;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
@@ -1491,6 +1495,73 @@ public class ResultServiceImpl implements IResultService {
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportAlignData() {
|
||||
List<Map<String, Object>> sheetsList = new ArrayList<>();
|
||||
|
||||
// key为被检设备的ip, value为该ip下所有通道的设备数据
|
||||
Map<String, List<DevData>> ipDevDataMap = FormalTestManager.devDataMap.values().stream().flatMap(List::stream).collect(Collectors.groupingBy(obj -> obj.getId().split(CnSocketUtil.SPLIT_TAG)[0]));
|
||||
|
||||
ipDevDataMap.forEach((ip, devDataList) -> {
|
||||
// 按照通道号分组。key为通道号,value为该通道号下所有设备数据
|
||||
Map<String, List<DevData>> channelDataMap = devDataList.stream().collect(Collectors.groupingBy(obj -> obj.getId().split(CnSocketUtil.SPLIT_TAG)[1]));
|
||||
|
||||
channelDataMap.forEach((channel, channelDevDataList) -> {
|
||||
String standardDevMonitorId = FormalTestManager.pairsMap.get(ip + channel);
|
||||
List<DevData> standarDevDataList = BeanUtil.copyToList(FormalTestManager.standardDevDataMap.get(standardDevMonitorId), DevData.class);
|
||||
channelDevDataList.sort(Comparator.comparing(obj -> DetectionUtil.getMillis(obj.getTime())));
|
||||
|
||||
HashMap sheet = new HashMap<>();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
String devName = FormalTestManager.devNameMapComm.get(ip);
|
||||
String[] split = standardDevMonitorId.split(CnSocketUtil.SPLIT_TAG);
|
||||
String standardDevName = FormalTestManager.devNameMapComm.get(split[0]);
|
||||
exportParams.setSheetName(devName + "通道" + channel);
|
||||
sheet.put("title", exportParams);
|
||||
|
||||
List<AlignDataExcel> dataList = new ArrayList<>();
|
||||
channelDevDataList.stream().forEach(obj -> {
|
||||
AlignDataExcel alignDataExcel = new AlignDataExcel();
|
||||
alignDataExcel.getDevDataConfig().setName(devName + "通道" + channel);
|
||||
alignDataExcel.getStandardDevDataConfig().setName(standardDevName + "通道" + split[1]);
|
||||
DevData.SqlDataDTO.ListDTO list1 = obj.getSqlData().get(0).getList();
|
||||
alignDataExcel.setTimeDev(obj.getTime());
|
||||
alignDataExcel.setUaDev(list1.getA());
|
||||
alignDataExcel.setUbDev(list1.getB());
|
||||
alignDataExcel.setUcDev(list1.getC());
|
||||
|
||||
DevData devData = standarDevDataList.stream().filter(obj1 -> DetectionUtil.isAlignData(obj1, obj)).findFirst().get();
|
||||
if (ObjectUtil.isNotNull(devData)) {
|
||||
DevData.SqlDataDTO.ListDTO list2 = devData.getSqlData().get(0).getList();
|
||||
alignDataExcel.setTimeStdDev(devData.getTime());
|
||||
alignDataExcel.setUaStdDev(list2.getA());
|
||||
alignDataExcel.setUbStdDev(list2.getB());
|
||||
alignDataExcel.setUcStdDev(list2.getC());
|
||||
standarDevDataList.remove(devData);
|
||||
}
|
||||
dataList.add(alignDataExcel);
|
||||
});
|
||||
standarDevDataList.sort(Comparator.comparing(obj -> DetectionUtil.getMillis(obj.getTime())));
|
||||
standarDevDataList.stream().forEach(obj -> {
|
||||
AlignDataExcel alignDataExcel = new AlignDataExcel();
|
||||
alignDataExcel.getDevDataConfig().setName(devName + "通道" + channel);
|
||||
alignDataExcel.getStandardDevDataConfig().setName(standardDevName + "通道" + split[1]);
|
||||
DevData.SqlDataDTO.ListDTO list2 = obj.getSqlData().get(0).getList();
|
||||
alignDataExcel.setTimeStdDev(obj.getTime());
|
||||
alignDataExcel.setUaStdDev(list2.getA());
|
||||
alignDataExcel.setUbStdDev(list2.getB());
|
||||
alignDataExcel.setUcStdDev(list2.getC());
|
||||
dataList.add(alignDataExcel);
|
||||
});
|
||||
|
||||
sheet.put("data", dataList);
|
||||
sheet.put("entity", AlignDataExcel.class);
|
||||
});
|
||||
});
|
||||
|
||||
ExcelUtil.exportExcel("实时数据.xlsx", sheetsList);
|
||||
}
|
||||
|
||||
private Integer conform(Set<Integer> numbers) {
|
||||
if (CollUtil.isNotEmpty(numbers)) {
|
||||
if (numbers.size() > 1) {
|
||||
|
||||
@@ -13,13 +13,13 @@ public interface DetectionDataDealService extends IReplenishMybatisService<SimAn
|
||||
|
||||
|
||||
|
||||
Boolean acceptAdNon(List<SimAndDigNonHarmonicResult> SimAndDigNonHarmonicResultList,String code);
|
||||
Boolean acceptAdNon(List<? extends BaseResult> nonHarmonicResultList,String code);
|
||||
|
||||
Boolean acceptAd(List<SimAndDigHarmonicResult> SimAndDigHarmonicResultList,String code);
|
||||
Boolean acceptAd(List<? extends BaseResult> harmonicResultList,String code);
|
||||
|
||||
Boolean acceptNonHarmonicResult(List<? extends BaseResult> nonHarmonicResultList, String code);
|
||||
|
||||
Boolean acceptAdResult(List<SimAndDigHarmonicResult> SimAndDigHarmonicResultList,String code);
|
||||
Boolean acceptHarmonicResult(List<? extends BaseResult> SimAndDigHarmonicResultList,String code);
|
||||
|
||||
/**
|
||||
* 根据终端id查询终端所有监测项目是否合格
|
||||
|
||||
@@ -6,13 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.db.mybatisplus.service.impl.ReplenishMybatisServiceImpl;
|
||||
import com.njcn.gather.storage.mapper.DetectionDataDealMapper;
|
||||
import com.njcn.gather.storage.pojo.po.BaseResult;
|
||||
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
import com.njcn.gather.storage.service.ContrastNonHarmonicService;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.storage.service.SimAndDigNonHarmonicService;
|
||||
import com.njcn.gather.storage.pojo.po.*;
|
||||
import com.njcn.gather.storage.service.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -32,42 +27,81 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<DetectionDataDealMapper, SimAndDigHarmonicResult> implements DetectionDataDealService {
|
||||
|
||||
private final SimAndDigNonHarmonicService adNonHarmonicService;
|
||||
private final SimAndDigNonHarmonicService simAndDigNonHarmonicService;
|
||||
private final SimAndDigHarmonicService simAndDigHarmonicService;
|
||||
private final ContrastNonHarmonicService contrastNonHarmonicService;
|
||||
private final ContrastHarmonicService contrastHarmonicService;
|
||||
private final DetectionDataDealMapper detectionDataDealMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean acceptAdNon(List<SimAndDigNonHarmonicResult> SimAndDigNonHarmonicResultList, String code) {
|
||||
String adNonTable = "ad_non_harmonic_";
|
||||
DynamicTableNameHandler.setTableName(adNonTable + code);
|
||||
List<String> monitorIds = SimAndDigNonHarmonicResultList.stream().map(SimAndDigNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
adNonHarmonicService.remove(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>().in(SimAndDigNonHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(SimAndDigNonHarmonicResult::getScriptId, SimAndDigNonHarmonicResultList.get(0).getScriptId())
|
||||
.eq(SimAndDigNonHarmonicResult::getSort, SimAndDigNonHarmonicResultList.get(0).getSort()));
|
||||
adNonHarmonicService.saveBatch(SimAndDigNonHarmonicResultList, 100);
|
||||
public Boolean acceptAdNon(List<? extends BaseResult> nonHarmonicResultList, String code) {
|
||||
if (CollUtil.isNotEmpty(nonHarmonicResultList)) {
|
||||
String adNonTable = "ad_non_harmonic_";
|
||||
DynamicTableNameHandler.setTableName(adNonTable + code);
|
||||
|
||||
if (nonHarmonicResultList.get(0) instanceof SimAndDigNonHarmonicResult) {
|
||||
List<SimAndDigNonHarmonicResult> simAndDigNonHarmonicResults = BeanUtil.copyToList(nonHarmonicResultList, SimAndDigNonHarmonicResult.class);
|
||||
List<String> monitorIds = simAndDigNonHarmonicResults.stream().map(SimAndDigNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
simAndDigNonHarmonicService.remove(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>().in(SimAndDigNonHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(SimAndDigNonHarmonicResult::getScriptId, simAndDigNonHarmonicResults.get(0).getScriptId())
|
||||
.eq(SimAndDigNonHarmonicResult::getSort, simAndDigNonHarmonicResults.get(0).getSort()));
|
||||
simAndDigNonHarmonicService.saveBatch(simAndDigNonHarmonicResults, 100);
|
||||
}
|
||||
}
|
||||
|
||||
if (nonHarmonicResultList.get(0) instanceof ContrastNonHarmonicResult) {
|
||||
List<ContrastNonHarmonicResult> contrastNonHarmonicResults = BeanUtil.copyToList(nonHarmonicResultList, ContrastNonHarmonicResult.class);
|
||||
List<String> monitorIds = contrastNonHarmonicResults.stream().map(ContrastNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
contrastNonHarmonicService.remove(new LambdaQueryWrapper<ContrastNonHarmonicResult>().in(ContrastNonHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(ContrastNonHarmonicResult::getErrorId, contrastNonHarmonicResults.get(0).getErrorId())
|
||||
.eq(ContrastNonHarmonicResult::getNum, contrastNonHarmonicResults.get(0).getNum()));
|
||||
contrastNonHarmonicService.saveBatch(contrastNonHarmonicResults, 100);
|
||||
}
|
||||
}
|
||||
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean acceptAd(List<SimAndDigHarmonicResult> SimAndDigHarmonicResultList, String code) {
|
||||
String adTable = "ad_harmonic_";
|
||||
DynamicTableNameHandler.setTableName(adTable + code);
|
||||
List<String> monitorIds = SimAndDigHarmonicResultList.stream().map(SimAndDigHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
this.remove(new LambdaQueryWrapper<SimAndDigHarmonicResult>().in(SimAndDigHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(SimAndDigHarmonicResult::getScriptId, SimAndDigHarmonicResultList.get(0).getScriptId())
|
||||
.eq(SimAndDigHarmonicResult::getSort, SimAndDigHarmonicResultList.get(0).getSort()));
|
||||
this.saveBatch(SimAndDigHarmonicResultList, 100);
|
||||
public Boolean acceptAd(List<? extends BaseResult> harmonicResultList, String code) {
|
||||
if (CollUtil.isEmpty(harmonicResultList)) {
|
||||
String adTable = "ad_harmonic_";
|
||||
DynamicTableNameHandler.setTableName(adTable + code);
|
||||
|
||||
if (harmonicResultList.get(0) instanceof SimAndDigHarmonicResult) {
|
||||
List<SimAndDigHarmonicResult> simAndDigHarmonicResultList = BeanUtil.copyToList(harmonicResultList, SimAndDigHarmonicResult.class);
|
||||
List<String> monitorIds = simAndDigHarmonicResultList.stream().map(SimAndDigHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
simAndDigHarmonicService.remove(new LambdaQueryWrapper<SimAndDigHarmonicResult>().in(SimAndDigHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(SimAndDigHarmonicResult::getScriptId, simAndDigHarmonicResultList.get(0).getScriptId())
|
||||
.eq(SimAndDigHarmonicResult::getSort, simAndDigHarmonicResultList.get(0).getSort()));
|
||||
simAndDigHarmonicService.saveBatch(simAndDigHarmonicResultList, 100);
|
||||
}
|
||||
}
|
||||
|
||||
if (harmonicResultList.get(0) instanceof ContrastHarmonicResult) {
|
||||
List<ContrastHarmonicResult> contrastHarmonicResultList = BeanUtil.copyToList(harmonicResultList, ContrastHarmonicResult.class);
|
||||
List<String> monitorIds = contrastHarmonicResultList.stream().map(ContrastHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
contrastHarmonicService.remove(new LambdaQueryWrapper<ContrastHarmonicResult>().in(ContrastHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(ContrastHarmonicResult::getErrorId, contrastHarmonicResultList.get(0).getErrorId())
|
||||
.eq(ContrastHarmonicResult::getNum, contrastHarmonicResultList.get(0).getNum()));
|
||||
contrastHarmonicService.saveBatch(contrastHarmonicResultList, 100);
|
||||
}
|
||||
}
|
||||
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,10 +114,10 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
|
||||
List<SimAndDigNonHarmonicResult> simAndDigNonHarmonicResultList = BeanUtil.copyToList(nonHarmonicResultList, SimAndDigNonHarmonicResult.class);
|
||||
List<String> monitorIds = simAndDigNonHarmonicResultList.stream().map(SimAndDigNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
adNonHarmonicService.remove(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>().in(SimAndDigNonHarmonicResult::getMonitorId, monitorIds)
|
||||
simAndDigNonHarmonicService.remove(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>().in(SimAndDigNonHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(SimAndDigNonHarmonicResult::getScriptId, simAndDigNonHarmonicResultList.get(0).getScriptId())
|
||||
.eq(SimAndDigNonHarmonicResult::getSort, simAndDigNonHarmonicResultList.get(0).getSort()));
|
||||
adNonHarmonicService.saveBatch(simAndDigNonHarmonicResultList, 100);
|
||||
simAndDigNonHarmonicService.saveBatch(simAndDigNonHarmonicResultList, 100);
|
||||
}
|
||||
}
|
||||
if (nonHarmonicResultList.get(0) instanceof ContrastNonHarmonicResult) {
|
||||
@@ -103,18 +137,35 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean acceptAdResult(List<SimAndDigHarmonicResult> simAndDigHarmonicResultList, String code) {
|
||||
String adTableResult = "ad_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(adTableResult + code);
|
||||
List<String> monitorIds = simAndDigHarmonicResultList.stream().map(SimAndDigHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
this.remove(new LambdaQueryWrapper<SimAndDigHarmonicResult>().in(SimAndDigHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(SimAndDigHarmonicResult::getScriptId, simAndDigHarmonicResultList.get(0).getScriptId())
|
||||
.eq(SimAndDigHarmonicResult::getSort, simAndDigHarmonicResultList.get(0).getSort()));
|
||||
this.saveBatch(simAndDigHarmonicResultList, 100);
|
||||
public Boolean acceptHarmonicResult(List<? extends BaseResult> harmonicResultList, String code) {
|
||||
if (CollUtil.isNotEmpty(harmonicResultList)) {
|
||||
String adTableResult = "ad_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(adTableResult + code);
|
||||
if (harmonicResultList.get(0) instanceof SimAndDigHarmonicResult) {
|
||||
List<SimAndDigHarmonicResult> simAndDigHarmonicResultList = BeanUtil.copyToList(harmonicResultList, SimAndDigHarmonicResult.class);
|
||||
List<String> monitorIds = simAndDigHarmonicResultList.stream().map(SimAndDigHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
simAndDigHarmonicService.remove(new LambdaQueryWrapper<SimAndDigHarmonicResult>().in(SimAndDigHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(SimAndDigHarmonicResult::getScriptId, simAndDigHarmonicResultList.get(0).getScriptId())
|
||||
.eq(SimAndDigHarmonicResult::getSort, simAndDigHarmonicResultList.get(0).getSort()));
|
||||
simAndDigHarmonicService.saveBatch(simAndDigHarmonicResultList, 100);
|
||||
}
|
||||
}
|
||||
|
||||
if (harmonicResultList.get(0) instanceof ContrastHarmonicResult) {
|
||||
List<ContrastHarmonicResult> contrastHarmonicResultList = BeanUtil.copyToList(harmonicResultList, ContrastHarmonicResult.class);
|
||||
List<String> monitorIds = contrastHarmonicResultList.stream().map(ContrastHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(monitorIds)) {
|
||||
contrastHarmonicService.remove(new LambdaQueryWrapper<ContrastHarmonicResult>().in(ContrastHarmonicResult::getMonitorId, monitorIds)
|
||||
.eq(ContrastHarmonicResult::getErrorId, contrastHarmonicResultList.get(0).getErrorId())
|
||||
.eq(ContrastHarmonicResult::getNum, contrastHarmonicResultList.get(0).getNum()));
|
||||
contrastHarmonicService.saveBatch(contrastHarmonicResultList, 100);
|
||||
}
|
||||
}
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,7 +174,7 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
|
||||
List<SimAndDigNonHarmonicResult> noHarm = new ArrayList<>();
|
||||
for (String id : ids) {
|
||||
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
||||
noHarm.addAll(adNonHarmonicService.list(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>()
|
||||
noHarm.addAll(simAndDigNonHarmonicService.list(new LambdaQueryWrapper<SimAndDigNonHarmonicResult>()
|
||||
.like(SimAndDigNonHarmonicResult::getMonitorId, id)
|
||||
.notIn(CollUtil.isNotEmpty(disabledScriptDtlIndexs), SimAndDigNonHarmonicResult::getSort, disabledScriptDtlIndexs)
|
||||
.in(CollUtil.isNotEmpty(valueType), SimAndDigNonHarmonicResult::getAdType, valueType)
|
||||
|
||||
Reference in New Issue
Block a user