From 9dfb42f9173dfc8cf96beefa4c4c7029b1e2807a Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Wed, 24 Jun 2026 09:15:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=90=E6=B3=A2=E3=80=81=E9=97=B4=E8=B0=90?= =?UTF-8?q?=E6=B3=A2=E5=AF=B9=E7=94=B5=E5=8E=8B=E7=9A=84=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=20=E8=B0=83=E7=94=A8=E6=95=B0=E6=8D=AE=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- detection/pom.xml | 4 - .../handler/SocketDevResponseService.java | 31 +----- .../pojo/vo/FormalTestDevicePayload.java | 17 ---- .../pojo/vo/FormalTestEventPayload.java | 18 ---- .../service/FormalTestEventPublisher.java | 12 --- .../impl/FormalTestEventPublisherImpl.java | 95 ------------------- .../util/socket/FormalTestManager.java | 5 - .../service/impl/ResultServiceImpl.java | 2 +- .../service/impl/PqScriptDtlsServiceImpl.java | 12 ++- entrance/src/main/resources/application.yml | 3 - 10 files changed, 16 insertions(+), 183 deletions(-) delete mode 100644 detection/src/main/java/com/njcn/gather/detection/pojo/vo/FormalTestDevicePayload.java delete mode 100644 detection/src/main/java/com/njcn/gather/detection/pojo/vo/FormalTestEventPayload.java delete mode 100644 detection/src/main/java/com/njcn/gather/detection/service/FormalTestEventPublisher.java delete mode 100644 detection/src/main/java/com/njcn/gather/detection/service/impl/FormalTestEventPublisherImpl.java diff --git a/detection/pom.xml b/detection/pom.xml index 7eae4b66..1a346a4d 100644 --- a/detection/pom.xml +++ b/detection/pom.xml @@ -150,10 +150,6 @@ spring-boot-starter-test test - - org.springframework.boot - spring-boot-starter-data-redis - diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index 1f913ffa..0fbd3e2e 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java @@ -16,7 +16,6 @@ import com.njcn.gather.detection.pojo.po.DevData; import com.njcn.gather.detection.pojo.po.IcdCheckData; import com.njcn.gather.detection.pojo.po.SourceCompareDev; import com.njcn.gather.detection.pojo.vo.*; -import com.njcn.gather.detection.service.FormalTestEventPublisher; import com.njcn.gather.detection.service.impl.DetectionServiceImpl; import com.njcn.gather.detection.util.DetectionUtil; import com.njcn.gather.detection.util.socket.*; @@ -84,7 +83,6 @@ public class SocketDevResponseService { private final IDictDataService dictDataService; private final IPqSourceService pqSourceService; private final IResultService resultService; - private final FormalTestEventPublisher formalTestEventPublisher; @Value("${dataCheck.enable}") private Boolean dataCheck; @@ -1231,7 +1229,6 @@ public class SocketDevResponseService { socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue()); SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg)); - this.publishFormalStartIfNeeded(); webSocketVO.setDesc(null); WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO)); } else { @@ -1530,7 +1527,6 @@ public class SocketDevResponseService { switch (Objects.requireNonNull(operateCodeEnum)) { case QUIT_INIT_01: //关闭所有 - publishFormalEndIfNeeded(); SocketManager.removeUser(s); CnSocketUtil.quitSendSource(param); break; @@ -1553,7 +1549,6 @@ public class SocketDevResponseService { case NO_INIT_DEV: switch (operateCodeEnum) { case QUIT_INIT_01: - publishFormalEndIfNeeded(); SocketManager.removeUser(s); // CnSocketUtil.quitSendSource(param); break; @@ -1576,21 +1571,6 @@ public class SocketDevResponseService { } - private void publishFormalEndIfNeeded() { - if (FormalTestManager.endEventPublished && !Boolean.TRUE.equals(dataCheck)) { - return; - } - formalTestEventPublisher.publishEnd(FormalTestManager.sessionId, FormalTestManager.devList); - FormalTestManager.endEventPublished = true; - } - - private void publishFormalStartIfNeeded() { - if (FormalTestManager.startEventPublished || ObjectUtil.isNull(FormalTestManager.sessionId) && !Boolean.TRUE.equals(dataCheck)) { - return; - } - formalTestEventPublisher.publishStart(FormalTestManager.sessionId, FormalTestManager.devList); - FormalTestManager.startEventPublished = true; - } /** * @param issue @@ -1837,9 +1817,6 @@ public class SocketDevResponseService { FormalTestManager.overload = getOverloadResult(param); FormalTestManager.checkStartTime = LocalDateTime.now(); FormalTestManager.reCheckType = param.getReCheckType(); - FormalTestManager.sessionId = UUID.randomUUID().toString().replace("-", ""); - FormalTestManager.startEventPublished = false; - FormalTestManager.endEventPublished = false; } @@ -1897,16 +1874,16 @@ public class SocketDevResponseService { // 谐波判断 if (channelListDTO.getHarmFlag()) { List harmList = channelListDTO.getHarmList(); - double sum = harmList.stream().map(harmModel -> harmModel.getFAmp() * harmModel.getFAmp() / 10000).mapToDouble(x -> x).sum(); - if (maxVoltage.compareTo(BigDecimal.valueOf(Math.sqrt(1 + sum) * fAmp)) < 0) { + double thd = harmList.stream().map(harmModel -> harmModel.getFAmp() * harmModel.getFAmp() / 10000).mapToDouble(x -> x).sum(); + if (maxVoltage.compareTo(BigDecimal.valueOf(Math.sqrt(1 + thd) * fAmp)) < 0) { return channelType.contains("U") ? 1 : 2; } } // 间谐波判断 if (channelListDTO.getInHarmFlag()) { List inharmList = channelListDTO.getInharmList(); - double sum = inharmList.stream().map(harmModel -> harmModel.getFAmp() * harmModel.getFAmp() / 10000).mapToDouble(x -> x).sum(); - if (maxVoltage.compareTo(BigDecimal.valueOf(Math.sqrt(1 + sum) * fAmp)) < 0) { + double thd = inharmList.stream().map(harmModel -> harmModel.getFAmp() * harmModel.getFAmp() / 10000).mapToDouble(x -> x).sum(); + if (maxVoltage.compareTo(BigDecimal.valueOf(Math.sqrt(1 + thd) * fAmp)) < 0) { return channelType.contains("U") ? 1 : 2; } } diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/FormalTestDevicePayload.java b/detection/src/main/java/com/njcn/gather/detection/pojo/vo/FormalTestDevicePayload.java deleted file mode 100644 index 0b682243..00000000 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/FormalTestDevicePayload.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.njcn.gather.detection.pojo.vo; - -import lombok.Data; - -@Data -public class FormalTestDevicePayload { - - private String deviceId; - - private String monitorId; - - private String deviceIp; - - private String deviceType; - - private String icdMappingName; -} diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/FormalTestEventPayload.java b/detection/src/main/java/com/njcn/gather/detection/pojo/vo/FormalTestEventPayload.java deleted file mode 100644 index a041bbb1..00000000 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/FormalTestEventPayload.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.njcn.gather.detection.pojo.vo; - -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.List; - -@Data -public class FormalTestEventPayload { - - private String eventType; - - private LocalDateTime eventTime; - - private String sessionId; - - private List devices; -} diff --git a/detection/src/main/java/com/njcn/gather/detection/service/FormalTestEventPublisher.java b/detection/src/main/java/com/njcn/gather/detection/service/FormalTestEventPublisher.java deleted file mode 100644 index 19b67f45..00000000 --- a/detection/src/main/java/com/njcn/gather/detection/service/FormalTestEventPublisher.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.njcn.gather.detection.service; - -import com.njcn.gather.device.pojo.vo.PreDetection; - -import java.util.List; - -public interface FormalTestEventPublisher { - - void publishStart(String sessionId, List devices); - - void publishEnd(String sessionId, List devices); -} diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/FormalTestEventPublisherImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/FormalTestEventPublisherImpl.java deleted file mode 100644 index 21e7fcf3..00000000 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/FormalTestEventPublisherImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.njcn.gather.detection.service.impl; - -import com.alibaba.fastjson.JSON; -import com.njcn.gather.detection.pojo.vo.FormalTestDevicePayload; -import com.njcn.gather.detection.pojo.vo.FormalTestEventPayload; -import com.njcn.gather.detection.service.FormalTestEventPublisher; -import com.njcn.gather.device.pojo.vo.PreDetection; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Service; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -@Slf4j -@Service -@RequiredArgsConstructor -public class FormalTestEventPublisherImpl implements FormalTestEventPublisher { - - private final StringRedisTemplate stringRedisTemplate; - - private static String msgChannel = "formal-test-msg-channel"; - - private final Set publishedStartSessions = - Collections.newSetFromMap(new ConcurrentHashMap()); - - private final Set publishedEndSessions = - Collections.newSetFromMap(new ConcurrentHashMap()); - - @Override - public void publishStart(String sessionId, List devices) { - publish("start", sessionId, devices); - } - - @Override - public void publishEnd(String sessionId, List devices) { - publish("end", sessionId, devices); - } - - public FormalTestEventPayload buildPayload(String eventType, String sessionId, List devices) { - FormalTestEventPayload payload = new FormalTestEventPayload(); - payload.setEventType(eventType); - payload.setEventTime(LocalDateTime.now()); - payload.setSessionId(sessionId); - payload.setDevices(buildDevices(devices)); - return payload; - } - - private void publish(String eventType, String sessionId, List devices) { - if (sessionId == null) { - return; - } - Set dedupSet = "start".equals(eventType) ? publishedStartSessions : publishedEndSessions; - if (!dedupSet.add(sessionId)) { - return; - } - try { - FormalTestEventPayload payload = buildPayload(eventType, sessionId, devices); - stringRedisTemplate.convertAndSend(msgChannel, JSON.toJSONString(payload)); - } catch (Exception ex) { - log.error("publish formal test event failed, eventType={}, sessionId={}, deviceCount={}", - eventType, sessionId, devices == null ? 0 : devices.size(), ex); - } - } - - private List buildDevices(List devices) { - List results = new ArrayList<>(); - if (devices == null) { - return results; - } - for (PreDetection device : devices) { - if (device == null || device.getMonitorList() == null) { - continue; - } - for (PreDetection.MonitorListDTO monitor : device.getMonitorList()) { - if (monitor == null || monitor.getLine() == null) { - continue; - } - FormalTestDevicePayload payload = new FormalTestDevicePayload(); - payload.setDeviceId(device.getDevId()); - payload.setMonitorId(device.getDevId() + "_" + monitor.getLine()); - payload.setDeviceIp(device.getDevIP()); - payload.setDeviceType(device.getDevType()); - payload.setIcdMappingName(device.getIcdType()); - results.add(payload); - } - } - return results; - } -} diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java index 82953a5d..1ed07343 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java @@ -220,11 +220,6 @@ public class FormalTestManager { */ public static LocalDateTime checkStartTime; - public static String sessionId; - - public static boolean startEventPublished; - - public static boolean endEventPublished; /** * 数模式 检测类型"1"-"全部检测" , "2"-"不合格项复检" 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 6602ee52..dc5d943e 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 @@ -145,7 +145,7 @@ public class ResultServiceImpl implements IResultService { private final DataCheckAsyncNotifier dataCheckAsyncNotifier; private final RestTemplateUtil restTemplateUtil; - public static final String CHECKSQUARE_CREATE_URL = "http://172.17.100.111:18091/steady/checksquare/create"; + public static final String CHECKSQUARE_CREATE_URL = "http://192.168.2.147:18091/steady/checksquare/create"; private static final DateTimeFormatter CHECKSQUARE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private final Map notifyStates = new ConcurrentHashMap<>(); diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java index 340a291a..d82ca764 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java @@ -849,7 +849,17 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl harmModel.getFAmp() * harmModel.getFAmp() / 10000).mapToDouble(x -> x).sum(); + fAmp = Math.sqrt(1 + thd) * fAmp; + } + if (listDTO.getInHarmFlag()) { + double thd = listDTO.getInharmList().stream().map(harmModel -> harmModel.getFAmp() * harmModel.getFAmp() / 10000).mapToDouble(x -> x).sum(); + fAmp = Math.sqrt(1 + thd) * fAmp; + } + checkData.setValue(fAmp); } } info.add(checkData); diff --git a/entrance/src/main/resources/application.yml b/entrance/src/main/resources/application.yml index 8e7d55d9..f7fa75d4 100644 --- a/entrance/src/main/resources/application.yml +++ b/entrance/src/main/resources/application.yml @@ -3,9 +3,6 @@ server: spring: application: name: entrance - redis: - host: localhost - port: 16379 datasource: druid: driver-class-name: com.mysql.cj.jdbc.Driver