From c80ae2f95f667bb5c7cd954bab5c2538c6937727 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Wed, 12 Mar 2025 10:36:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/SocketSourceResponseService.java | 6 +- .../service/impl/DetectionServiceImpl.java | 6 +- .../gather/detection/util/socket/MsgUtil.java | 127 ++++++++++-------- .../service/impl/ResultServiceImpl.java | 69 ++++++++-- .../service/impl/TableGenServiceImpl.java | 2 +- 5 files changed, 134 insertions(+), 76 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java index eb5acdf5..4f45494c 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java @@ -100,10 +100,10 @@ public class SocketSourceResponseService { if (ObjectUtil.isNotNull(dictDataEnumByCode)) { switch (dictDataEnumByCode) { case SUCCESS: - if(param.getSendWebMsg()){ + if (param.getSendWebMsg()) { WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); } - System.out.println("模拟检测-源初始化成功"); + System.out.println(param.getSendWebMsg() + "模拟检测-源初始化成功"); break; case UNPROCESSED_BUSINESS: WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); @@ -159,7 +159,7 @@ public class SocketSourceResponseService { switch (dictDataEnumByCode) { case SUCCESS: WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); - System.out.println("模拟检测-源成功执行脚本"+JSON.toJSONString(socketDataMsg)); + System.out.println("模拟检测-源成功执行脚本" + JSON.toJSONString(socketDataMsg)); break; case UNPROCESSED_BUSINESS: WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java index 74cb1951..6ab05e61 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java @@ -950,10 +950,10 @@ public class DetectionServiceImpl { .sorted().distinct().collect(Collectors.toList())); } for (DevData devData : dev) { - List sqlDataDTOList = devData.getSqlData(); + List sqlDataDTOS = devData.getSqlData(); Optional first = Optional.empty(); - if (CollUtil.isNotEmpty(sqlDataDTOList)) { - first = sqlDataDTOList.stream().filter(x -> x.getDesc().equals(fundCode)).collect(Collectors.toList()).stream().findFirst(); + if (CollUtil.isNotEmpty(sqlDataDTOS)) { + first = sqlDataDTOS.stream().filter(x -> x.getDesc().equals(fundCode)).collect(Collectors.toList()).stream().findFirst(); } DevData.SqlDataDTO fund = null; if (first.isPresent()) { diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java index 08c5f5eb..3d61296f 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java @@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; +import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum; import com.njcn.gather.detection.pojo.po.DevData; import com.njcn.gather.detection.pojo.vo.SocketDataMsg; import com.njcn.gather.storage.pojo.po.AdHarmonicResult; @@ -76,75 +77,91 @@ public class MsgUtil { return JSON.toJSONString(socketDataMsg); } - public static List toList(List nonHarm, List harm) { + public static List toList(List nonHarm, List harm, boolean containBaseHarm) { List info = new ArrayList<>(); // if (CollUtil.isNotEmpty(nonHarm)) { - if (CollUtil.isNotEmpty(nonHarm)) { - Map> noHarmMap = nonHarm.stream() - .collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN)) + "_" + x.getSort())); - noHarmMap.forEach((key, value) -> { - String[] split = key.split("_"); - DevData data = new DevData(); - data.setTime(split[2]); - data.setId(split[0]+"_"+split[1]); - List sqlDataDTOS = new ArrayList<>(); - DevData.SqlDataDTO sqlDataDTO; - for (AdNonHarmonicResult result : value) { + if (CollUtil.isNotEmpty(nonHarm)) { + Map> noHarmMap = nonHarm.stream() + .collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN)) + "_" + x.getSort())); + noHarmMap.forEach((key, value) -> { + String[] split = key.split("_"); + DevData data = new DevData(); + data.setTime(split[2]); + data.setId(split[0] + "_" + split[1]); + List sqlDataDTOS = new ArrayList<>(); + DevData.SqlDataDTO sqlDataDTO; + for (AdNonHarmonicResult result : value) { + sqlDataDTO = new DevData.SqlDataDTO(); + sqlDataDTO.setType(result.getDataType()); + sqlDataDTO.setDesc(result.getAdType()); + DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO(); + listDTO.setA(StrUtil.isNotBlank(result.getAValue()) ? Double.valueOf(result.getAValue()) : null); + listDTO.setB(StrUtil.isNotBlank(result.getBValue()) ? Double.valueOf(result.getBValue()) : null); + listDTO.setC(StrUtil.isNotBlank(result.getCValue()) ? Double.valueOf(result.getCValue()) : null); + listDTO.setT(StrUtil.isNotBlank(result.getTValue()) ? Double.valueOf(result.getTValue()) : null); + sqlDataDTO.setList(listDTO); + sqlDataDTOS.add(sqlDataDTO); + } + data.setSqlData(sqlDataDTOS); + info.add(data); + }); + } + if (CollUtil.isNotEmpty(harm)) { + Map> harmMap = harm.stream() + .collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN)))); + harmMap.forEach((key, value) -> { + List collect = info.stream().filter(x -> key.equals(x.getId() + "_" + x.getTime())).collect(Collectors.toList()); + List sqlDataDTOS = new ArrayList<>(); + DevData.SqlDataDTO sqlDataDTO; + List sqlDataHarmDTOS = new ArrayList<>(); + DevData.SqlDataHarmDTO dataHarmDTO; + for (AdHarmonicResult harmonicResult : value) { + if (containBaseHarm) { sqlDataDTO = new DevData.SqlDataDTO(); - sqlDataDTO.setType(result.getDataType()); - sqlDataDTO.setDesc(result.getAdType()); + sqlDataDTO = new DevData.SqlDataDTO(); + sqlDataDTO.setType(harmonicResult.getDataType()); + sqlDataDTO.setDesc(harmonicResult.getAdType()); DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO(); - listDTO.setA(StrUtil.isNotBlank(result.getAValue()) ? Double.valueOf(result.getAValue()) : null); - listDTO.setB(StrUtil.isNotBlank(result.getBValue()) ? Double.valueOf(result.getBValue()) : null); - listDTO.setC(StrUtil.isNotBlank(result.getCValue()) ? Double.valueOf(result.getCValue()) : null); - listDTO.setT(StrUtil.isNotBlank(result.getTValue()) ? Double.valueOf(result.getTValue()) : null); + listDTO.setA(StrUtil.isNotBlank(harmonicResult.getAValue1()) ? Double.valueOf(harmonicResult.getAValue1()) : null); + listDTO.setB(StrUtil.isNotBlank(harmonicResult.getBValue1()) ? Double.valueOf(harmonicResult.getBValue1()) : null); + listDTO.setC(StrUtil.isNotBlank(harmonicResult.getCValue1()) ? Double.valueOf(harmonicResult.getCValue1()) : null); sqlDataDTO.setList(listDTO); sqlDataDTOS.add(sqlDataDTO); } - data.setSqlData(sqlDataDTOS); - info.add(data); - }); - } - if (CollUtil.isNotEmpty(harm)) { - Map> harmMap = harm.stream() - .collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN)))); - harmMap.forEach((key, value) -> { - List collect = info.stream().filter(x -> key.equals(x.getId() + "_" + x.getTime())).collect(Collectors.toList()); - List sqlDataDTOS = new ArrayList<>(); - DevData.SqlDataHarmDTO dataDTO; - for (AdHarmonicResult harmonicResult : value) { - dataDTO = new DevData.SqlDataHarmDTO(); - dataDTO.setType(harmonicResult.getDataType()); - dataDTO.setDesc(harmonicResult.getAdType()); - dataDTO.setNum(50); - DevData.SqlDataHarmDTO.ListDTO listDTO = new DevData.SqlDataHarmDTO.ListDTO(); - listDTO.setA(reflectHarmonicValue("a", harmonicResult)); - listDTO.setB(reflectHarmonicValue("b", harmonicResult)); - listDTO.setC(reflectHarmonicValue("c", harmonicResult)); - dataDTO.setList(listDTO); - sqlDataDTOS.add(dataDTO); - } - if (CollUtil.isNotEmpty(collect)) { - collect.get(0).setSqlDataHarm(sqlDataDTOS); - } else { - String[] split = key.split("_"); - DevData data = new DevData(); - data.setTime(split[2]); - data.setId(split[0]+"_"+split[1]); - data.setSqlDataHarm(sqlDataDTOS); - info.add(data); - } - }); - } + dataHarmDTO = new DevData.SqlDataHarmDTO(); + dataHarmDTO.setType(harmonicResult.getDataType()); + dataHarmDTO.setDesc(harmonicResult.getAdType()); + dataHarmDTO.setNum(containBaseHarm ? 49 : 50); + DevData.SqlDataHarmDTO.ListDTO listHarmDTO = new DevData.SqlDataHarmDTO.ListDTO(); + listHarmDTO.setA(reflectHarmonicValue("a", harmonicResult, containBaseHarm)); + listHarmDTO.setB(reflectHarmonicValue("b", harmonicResult, containBaseHarm)); + listHarmDTO.setC(reflectHarmonicValue("c", harmonicResult, containBaseHarm)); + dataHarmDTO.setList(listHarmDTO); + sqlDataHarmDTOS.add(dataHarmDTO); + } + if (CollUtil.isNotEmpty(collect)) { + collect.get(0).setSqlDataHarm(sqlDataHarmDTOS); + } else { + String[] split = key.split("_"); + DevData data = new DevData(); + data.setTime(split[2]); + data.setId(split[0] + "_" + split[1]); + data.setSqlData(sqlDataDTOS); + data.setSqlDataHarm(sqlDataHarmDTOS); + info.add(data); + } + }); + + } // } return info; } - private static List reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult) { + private static List reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult, boolean notContainBaseHarm) { List info = new ArrayList<>(); - for (int i = 2; i <= 50; i++) { + for (int i = notContainBaseHarm ? 2 : 1; i <= 50; i++) { String fieldName = phase + "Value" + i; try { Field idField = AdHarmonicResult.class.getDeclaredField(fieldName); diff --git a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java index a058de13..5c29b7c7 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java @@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum; import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.po.DevData; @@ -969,23 +970,25 @@ public class ResultServiceImpl implements IResultService { List sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam); sourceIssues.forEach(sourceIssue -> { - List realDataXiList = MsgUtil.toList(nonHarmonicMap.get(sourceIssue.getIndex()), harmonicMap.get(sourceIssue.getIndex())); - for (int i = 0; i < realDataXiList.size(); i++) { - DevData devData = realDataXiList.get(i); - List sqlData = devData.getSqlData(); - if (CollUtil.isNotEmpty(sqlData)) { - for (int j = 0; j < sqlData.size(); j++) { - DevData.SqlDataDTO sqlDataDTO = sqlData.get(j); - String desc = sqlDataDTO.getDesc(); - if (StrUtil.isNotBlank(desc)) { - DictTree dictTree = dictTreeService.getById(desc); - if (ObjectUtil.isNotNull(dictTree)) { - sqlDataDTO.setDesc(dictTree.getCode()); - } - } + List nonHarmonicResults = nonHarmonicMap.get(sourceIssue.getIndex()); + List harmonicResults = harmonicMap.get(sourceIssue.getIndex()); + List realDataXiList = new ArrayList<>(); + if (CollUtil.isNotEmpty(nonHarmonicResults)) { + realDataXiList.addAll(MsgUtil.toList(nonHarmonicResults, null, true)); + } + if (CollUtil.isNotEmpty(harmonicResults)) { + DictTree dictTree = dictTreeService.getById(harmonicResults.get(0).getAdType()); + if (ObjectUtil.isNotNull(dictTree)) { + if (DetectionCodeEnum.V2_50.getCode().equals(dictTree.getCode()) || DetectionCodeEnum.I2_50.getCode().equals(dictTree.getCode()) || DetectionCodeEnum.P2_50.getCode().equals(dictTree.getCode())) { + realDataXiList.addAll(MsgUtil.toList(null, harmonicResults, true)); + } else { + realDataXiList.addAll(MsgUtil.toList(null, harmonicResults, false)); } } + } + for (int i = 0; i < realDataXiList.size(); i++) { + DevData devData = realDataXiList.get(i); List sqlDataHarm = devData.getSqlDataHarm(); if (CollUtil.isNotEmpty(sqlDataHarm)) { for (int j = 0; j < sqlDataHarm.size(); j++) { @@ -999,6 +1002,44 @@ public class ResultServiceImpl implements IResultService { } } } + + List sqlData = devData.getSqlData(); + if (CollUtil.isNotEmpty(sqlData)) { + for (int j = 0; j < sqlData.size(); j++) { + DevData.SqlDataDTO sqlDataDTO = sqlData.get(j); + String desc = sqlDataDTO.getDesc(); + if (StrUtil.isNotBlank(desc)) { + DictTree dictTree = dictTreeService.getById(desc); + if (ObjectUtil.isNotNull(dictTree)) { + if (CollUtil.isNotEmpty(harmonicResults)) { +// if (dictTree.getCode().contains("V")) { +// sqlDataDTO.setDesc(DetectionCodeEnum.U1.getCode()); +// } +// if (dictTree.getCode().contains("I")) { +// sqlDataDTO.setDesc(DetectionCodeEnum.I1.getCode()); +// } + if (DetectionCodeEnum.V2_50.getCode().equals(dictTree.getCode())) { + sqlDataDTO.setDesc(DetectionCodeEnum.U1.getCode()); + } + if (DetectionCodeEnum.I2_50.getCode().equals(dictTree.getCode())) { + sqlDataDTO.setDesc(DetectionCodeEnum.I1.getCode()); + } +// if (DetectionCodeEnum.SV_1_49.getCode().equals(dictTree.getCode())) { +// devData.setSqlData(null); +// } +// if (DetectionCodeEnum.SI_1_49.getCode().equals(dictTree.getCode())) { +// devData.setSqlData(null); +// } +// if (DetectionCodeEnum.P2_50.getCode().equals(dictTree.getCode())) { +// devData.setSqlData(null); +// } + } else { + sqlDataDTO.setDesc(dictTree.getCode()); + } + } + } + } + } } detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule); }); diff --git a/storage/src/main/java/com/njcn/gather/storage/service/impl/TableGenServiceImpl.java b/storage/src/main/java/com/njcn/gather/storage/service/impl/TableGenServiceImpl.java index 8a3b8ddb..e73e4da7 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/impl/TableGenServiceImpl.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/impl/TableGenServiceImpl.java @@ -25,7 +25,7 @@ public class TableGenServiceImpl implements TableGenService { StringBuilder A = new StringBuilder(); StringBuilder B = new StringBuilder(); StringBuilder C = new StringBuilder(); - for (int i = 1; i <= 51; i++) { + for (int i = 1; i <= 50; i++) { if (i == 1) { A.append("A_Value_").append(i).append(" json NULL COMMENT 'A相基波',"); B.append("B_Value_").append(i).append(" json NULL COMMENT 'B相基波',");