谐波、间谐波对电压的影响
调用数据校验接口调整
This commit is contained in:
@@ -150,10 +150,6 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -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<SourceIssue.ChannelListDTO.HarmModel> 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<SourceIssue.ChannelListDTO.InharmModel> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<FormalTestDevicePayload> devices;
|
||||
}
|
||||
@@ -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<PreDetection> devices);
|
||||
|
||||
void publishEnd(String sessionId, List<PreDetection> devices);
|
||||
}
|
||||
@@ -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<String> publishedStartSessions =
|
||||
Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
||||
|
||||
private final Set<String> publishedEndSessions =
|
||||
Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
||||
|
||||
@Override
|
||||
public void publishStart(String sessionId, List<PreDetection> devices) {
|
||||
publish("start", sessionId, devices);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishEnd(String sessionId, List<PreDetection> devices) {
|
||||
publish("end", sessionId, devices);
|
||||
}
|
||||
|
||||
public FormalTestEventPayload buildPayload(String eventType, String sessionId, List<PreDetection> 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<PreDetection> devices) {
|
||||
if (sessionId == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> 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<FormalTestDevicePayload> buildDevices(List<PreDetection> devices) {
|
||||
List<FormalTestDevicePayload> 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;
|
||||
}
|
||||
}
|
||||
@@ -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"-"不合格项复检"
|
||||
|
||||
@@ -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<String, NotifyState> notifyStates = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@@ -849,7 +849,17 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
checkData.setValue(0.0);
|
||||
} else {
|
||||
// 在这里重新根据谐波、间谐波含有率计算新的幅值
|
||||
checkData.setValue(listDTO.getFAmp());
|
||||
Double fAmp = listDTO.getFAmp();
|
||||
if (listDTO.getHarmFlag()) {
|
||||
|
||||
double thd = listDTO.getHarmList().stream().map(harmModel -> 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);
|
||||
|
||||
@@ -3,9 +3,6 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: entrance
|
||||
redis:
|
||||
host: localhost
|
||||
port: 16379
|
||||
datasource:
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
Reference in New Issue
Block a user