1.微调
This commit is contained in:
@@ -1,30 +1,32 @@
|
||||
package com.njcn.gather.detection.handler;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.po.SourceCompareDev;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.web.WebSocketHandler;
|
||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
@@ -35,9 +37,24 @@ public class SocketDevResponseService {
|
||||
private final String handlerStr = "_dev";
|
||||
private final WebSocketHandler webSocketHandler;
|
||||
private final IPqDevService iPqDevService;
|
||||
private final IPqScriptDtlsService scriptDtlsService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 所有装置通道信息
|
||||
*/
|
||||
List<String> moniterIdList = new ArrayList<>();
|
||||
/**
|
||||
* 存储的装置相序数据
|
||||
*/
|
||||
List<DevData> devInfo = new ArrayList<>();
|
||||
/**
|
||||
* 成功结束的装置
|
||||
*/
|
||||
List<String> success = new ArrayList<>();
|
||||
/**
|
||||
* 装置名称
|
||||
*/
|
||||
Map<String,String> devNameMap = new HashMap<>();
|
||||
|
||||
public void deal(PreDetectionParam param,String msg){
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
@@ -104,7 +121,7 @@ public class SocketDevResponseService {
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
|
||||
|
||||
case DEV_ERROR:
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), msg);
|
||||
|
||||
@@ -151,9 +168,345 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
|
||||
public void devXu(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
if (CollUtil.isEmpty(moniterIdList)) {
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
moniterIdList = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||
.map(PreDetection.MonitorListDTO::getLineId)
|
||||
.collect(Collectors.toList());
|
||||
devNameMap = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevName));
|
||||
// moniterIdList.add("192.168.1.186_1");
|
||||
|
||||
}
|
||||
String data = socketDataMsg.getData();
|
||||
DevData devData = JSON.parseObject(data, DevData.class);
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||
devInfo.add(devData);
|
||||
SocketMsg socketMsg = new SocketMsg();
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
success.add(devData.getId());
|
||||
if (success.size() == moniterIdList.size()) {
|
||||
PqScriptIssueParam sourceParam=new PqScriptIssueParam();
|
||||
List<SourceIssue> sourceIssues = scriptDtlsService.listSourceIssue(sourceParam);
|
||||
if(CollUtil.isNotEmpty(sourceIssues)){
|
||||
List<SourceCompareDev> info = new ArrayList<>();
|
||||
for (DevData dev : devInfo) {
|
||||
info.addAll(devIsSource(dev, sourceIssues.get(0)));
|
||||
}
|
||||
}
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues));
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
}
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
|
||||
case NORMAL_RESPONSE:
|
||||
break;
|
||||
case RE_OPERATE:
|
||||
break;
|
||||
default:
|
||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// String a = "{\"requestId\":\"dansldquiwdlandalksn\",\"operateCode\":\"DATA_REQUEST$01\",\"data\":\"{\\\"Time\\\":\\\"2024-12-18T10:26:00\\\",\\\"ID\\\":\\\"192.168.1.186_1\\\",\\\"result\\\":false,\\\"SqlData\\\":[{\\\"type\\\":\\\"平均值\\\",\\\"desc\\\":\\\"电压有效值\\\",\\\"list\\\":{\\\"A\\\":\\\"5.863635\\\",\\\"B\\\":\\\"5.865018\\\",\\\"C\\\":\\\"5.867418\\\",\\\"T\\\":null}},{\\\"type\\\":\\\"平均值\\\",\\\"desc\\\":\\\"电流有效值\\\",\\\"list\\\":{\\\"A\\\":\\\"0.000795\\\",\\\"B\\\":\\\"0.002215\\\",\\\"C\\\":\\\"0.003610\\\",\\\"T\\\":null}}],\\\"SqlDataHarm\\\":[]}\",\"code\":10202}";
|
||||
// SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(a);
|
||||
// String data = socketDataMsg.getData();
|
||||
// DevData devData = JSON.parseObject(data, DevData.class);
|
||||
|
||||
String b = "{\"requestId\":\"dansldquiwdlandalksn\",\"operateCode\":\"DATA_REQUEST$01\",\"data\":\"{\\\"Time\\\":\\\"2024-12-18T10:27:00\\\",\\\"ID\\\":\\\"192.168.1.186_1\\\",\\\"result\\\":false,\\\"SqlData\\\":[{\\\"type\\\":\\\"平均值\\\",\\\"desc\\\":\\\"电压有效值\\\",\\\"list\\\":{\\\"A\\\":\\\"70.0\\\",\\\"B\\\":\\\"50.0\\\",\\\"C\\\":\\\"40.0\\\",\\\"T\\\":null}},{\\\"type\\\":\\\"平均值\\\",\\\"desc\\\":\\\"电流有效值\\\",\\\"list\\\":{\\\"A\\\":\\\"0.000782\\\",\\\"B\\\":\\\"0.002222\\\",\\\"C\\\":\\\"0.003602\\\",\\\"T\\\":null}}],\\\"SqlDataHarm\\\":[]}\",\"code\":10200}";
|
||||
SocketDataMsg socketDataMsgb = MsgUtil.socketDataMsg(b);
|
||||
String datab = socketDataMsgb.getData();
|
||||
DevData devDatab = JSON.parseObject(datab, DevData.class);
|
||||
|
||||
List<SocketDataMsg> list = new LinkedList<>();
|
||||
// list.add(socketDataMsg);
|
||||
list.add(socketDataMsgb);
|
||||
|
||||
String is="\n" +
|
||||
" {\n" +
|
||||
" \"sourceId\": \"1111\",\n" +
|
||||
" \"type\": \"Freq\",\n" +
|
||||
" \"subType\": \"NULL\",\n" +
|
||||
" \"fUn\": 57.74,\n" +
|
||||
" \"fIn\": 5.0,\n" +
|
||||
" \"fFreq\": 50.0,\n" +
|
||||
" \"channelList\": [\n" +
|
||||
" {\n" +
|
||||
" \"channelFlag\": true,\n" +
|
||||
" \"harmFlag\": false,\n" +
|
||||
" \"inHarmFlag\": false,\n" +
|
||||
" \"dipFlag\": false,\n" +
|
||||
" \"flickerFlag\": false,\n" +
|
||||
" \"channelType\": \"Ua\",\n" +
|
||||
" \"fAmp\": 60.0,\n" +
|
||||
" \"fPhase\": 0.0,\n" +
|
||||
" \"harmList\": [],\n" +
|
||||
" \"inharmList\": [],\n" +
|
||||
" \"dipData\": {\n" +
|
||||
" \"fTransValue\": 0.0,\n" +
|
||||
" \"fPreTime\": 2.0,\n" +
|
||||
" \"fRampIn\": 0.001,\n" +
|
||||
" \"fRetainTime\": 0.0,\n" +
|
||||
" \"fRampOut\": 0.001,\n" +
|
||||
" \"fAfterTime\": 3.0\n" +
|
||||
" },\n" +
|
||||
" \"flickerData\": {\n" +
|
||||
" \"waveFluType\": \"SQU\",\n" +
|
||||
" \"waveType\": \"CPM\",\n" +
|
||||
" \"fDutyCycle\": 50.0,\n" +
|
||||
" \"fChagFre\": 0.0,\n" +
|
||||
" \"fChagValue\": 0.0\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"channelFlag\": true,\n" +
|
||||
" \"harmFlag\": false,\n" +
|
||||
" \"inHarmFlag\": false,\n" +
|
||||
" \"dipFlag\": false,\n" +
|
||||
" \"flickerFlag\": false,\n" +
|
||||
" \"channelType\": \"Ub\",\n" +
|
||||
" \"fAmp\": 50.0,\n" +
|
||||
" \"fPhase\": -120.0,\n" +
|
||||
" \"harmList\": [],\n" +
|
||||
" \"inharmList\": [],\n" +
|
||||
" \"dipData\": {\n" +
|
||||
" \"fTransValue\": 0.0,\n" +
|
||||
" \"fPreTime\": 2.0,\n" +
|
||||
" \"fRampIn\": 0.001,\n" +
|
||||
" \"fRetainTime\": 0.0,\n" +
|
||||
" \"fRampOut\": 0.001,\n" +
|
||||
" \"fAfterTime\": 3.0\n" +
|
||||
" },\n" +
|
||||
" \"flickerData\": {\n" +
|
||||
" \"waveFluType\": \"SQU\",\n" +
|
||||
" \"waveType\": \"CPM\",\n" +
|
||||
" \"fDutyCycle\": 50.0,\n" +
|
||||
" \"fChagFre\": 0.0,\n" +
|
||||
" \"fChagValue\": 0.0\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"channelFlag\": true,\n" +
|
||||
" \"harmFlag\": false,\n" +
|
||||
" \"inHarmFlag\": false,\n" +
|
||||
" \"dipFlag\": false,\n" +
|
||||
" \"flickerFlag\": false,\n" +
|
||||
" \"channelType\": \"Uc\",\n" +
|
||||
" \"fAmp\": 40.0,\n" +
|
||||
" \"fPhase\": 120.0,\n" +
|
||||
" \"harmList\": [],\n" +
|
||||
" \"inharmList\": [],\n" +
|
||||
" \"dipData\": {\n" +
|
||||
" \"fTransValue\": 0.0,\n" +
|
||||
" \"fPreTime\": 2.0,\n" +
|
||||
" \"fRampIn\": 0.001,\n" +
|
||||
" \"fRetainTime\": 0.0,\n" +
|
||||
" \"fRampOut\": 0.001,\n" +
|
||||
" \"fAfterTime\": 3.0\n" +
|
||||
" },\n" +
|
||||
" \"flickerData\": {\n" +
|
||||
" \"waveFluType\": \"SQU\",\n" +
|
||||
" \"waveType\": \"CPM\",\n" +
|
||||
" \"fDutyCycle\": 50.0,\n" +
|
||||
" \"fChagFre\": 0.0,\n" +
|
||||
" \"fChagValue\": 0.0\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"channelFlag\": true,\n" +
|
||||
" \"harmFlag\": false,\n" +
|
||||
" \"inHarmFlag\": false,\n" +
|
||||
" \"dipFlag\": false,\n" +
|
||||
" \"flickerFlag\": false,\n" +
|
||||
" \"channelType\": \"Ia\",\n" +
|
||||
" \"fAmp\": 1.0,\n" +
|
||||
" \"fPhase\": 0.0,\n" +
|
||||
" \"harmList\": [],\n" +
|
||||
" \"inharmList\": [],\n" +
|
||||
" \"dipData\": {\n" +
|
||||
" \"fTransValue\": 0.0,\n" +
|
||||
" \"fPreTime\": 2.0,\n" +
|
||||
" \"fRampIn\": 0.001,\n" +
|
||||
" \"fRetainTime\": 0.0,\n" +
|
||||
" \"fRampOut\": 0.001,\n" +
|
||||
" \"fAfterTime\": 3.0\n" +
|
||||
" },\n" +
|
||||
" \"flickerData\": {\n" +
|
||||
" \"waveFluType\": \"SQU\",\n" +
|
||||
" \"waveType\": \"CPM\",\n" +
|
||||
" \"fDutyCycle\": 50.0,\n" +
|
||||
" \"fChagFre\": 0.0,\n" +
|
||||
" \"fChagValue\": 0.0\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"channelFlag\": true,\n" +
|
||||
" \"harmFlag\": false,\n" +
|
||||
" \"inHarmFlag\": false,\n" +
|
||||
" \"dipFlag\": false,\n" +
|
||||
" \"flickerFlag\": false,\n" +
|
||||
" \"channelType\": \"Ib\",\n" +
|
||||
" \"fAmp\": 2.0,\n" +
|
||||
" \"fPhase\": -120.0,\n" +
|
||||
" \"harmList\": [],\n" +
|
||||
" \"inharmList\": [],\n" +
|
||||
" \"dipData\": {\n" +
|
||||
" \"fTransValue\": 0.0,\n" +
|
||||
" \"fPreTime\": 2.0,\n" +
|
||||
" \"fRampIn\": 0.001,\n" +
|
||||
" \"fRetainTime\": 0.0,\n" +
|
||||
" \"fRampOut\": 0.001,\n" +
|
||||
" \"fAfterTime\": 3.0\n" +
|
||||
" },\n" +
|
||||
" \"flickerData\": {\n" +
|
||||
" \"waveFluType\": \"SQU\",\n" +
|
||||
" \"waveType\": \"CPM\",\n" +
|
||||
" \"fDutyCycle\": 50.0,\n" +
|
||||
" \"fChagFre\": 0.0,\n" +
|
||||
" \"fChagValue\": 0.0\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"channelFlag\": true,\n" +
|
||||
" \"harmFlag\": false,\n" +
|
||||
" \"inHarmFlag\": false,\n" +
|
||||
" \"dipFlag\": false,\n" +
|
||||
" \"flickerFlag\": false,\n" +
|
||||
" \"channelType\": \"Ic\",\n" +
|
||||
" \"fAmp\": 3.0,\n" +
|
||||
" \"fPhase\": 120.0,\n" +
|
||||
" \"harmList\": [],\n" +
|
||||
" \"inharmList\": [],\n" +
|
||||
" \"dipData\": {\n" +
|
||||
" \"fTransValue\": 0.0,\n" +
|
||||
" \"fPreTime\": 2.0,\n" +
|
||||
" \"fRampIn\": 0.001,\n" +
|
||||
" \"fRetainTime\": 0.0,\n" +
|
||||
" \"fRampOut\": 0.001,\n" +
|
||||
" \"fAfterTime\": 3.0\n" +
|
||||
" },\n" +
|
||||
" \"flickerData\": {\n" +
|
||||
" \"waveFluType\": \"SQU\",\n" +
|
||||
" \"waveType\": \"CPM\",\n" +
|
||||
" \"fDutyCycle\": 50.0,\n" +
|
||||
" \"fChagFre\": 0.0,\n" +
|
||||
" \"fChagValue\": 0.0\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n";
|
||||
|
||||
SourceIssue issue = JSON.parseObject(is, SourceIssue.class);
|
||||
|
||||
|
||||
/**
|
||||
* 开始收到消息将消息进行存在
|
||||
* 先将成功消息存储在一个set里
|
||||
* 然后在判断所有的装置是否都是存在的
|
||||
*/
|
||||
|
||||
// SocketDevResponseService service = new SocketDevResponseService(null, null);
|
||||
//
|
||||
// for (SocketDataMsg dataMsg : list) {
|
||||
// service.test(null, dataMsg);
|
||||
// }
|
||||
// System.out.println();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<SourceCompareDev> devIsSource(DevData dev, SourceIssue issue) {
|
||||
List<SourceCompareDev> info=new ArrayList<>();
|
||||
String[] split = dev.getId().split("_");
|
||||
List<SourceIssue.ChannelListDTO> channelList = issue.getChannelList();
|
||||
|
||||
List<DevData.SqlDataDTO> sqlData = dev.getSqlData();
|
||||
List<DevData.SqlDataDTO> dataV = sqlData.stream().filter(x -> "电压有效值".equals(x.getDesc())).collect(Collectors.toList());
|
||||
List<DevData.SqlDataDTO> dataI = sqlData.stream().filter(x -> "电流有效值".equals(x.getDesc())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(dataV)) {
|
||||
SourceCompareDev compareDev = getSourceCompareDev(split, dataV,"电压有效值","U", channelList);
|
||||
info.add(compareDev);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(dataI)) {
|
||||
SourceCompareDev compareDev = getSourceCompareDev(split, dataI,"电流有效值","I", channelList);
|
||||
info.add(compareDev);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算是否合格
|
||||
* @param split
|
||||
* @param data
|
||||
* @param name 指标名称
|
||||
* @param type U,I
|
||||
* @param channelList
|
||||
* @return
|
||||
*/
|
||||
private static SourceCompareDev getSourceCompareDev(String[] split,
|
||||
List<DevData.SqlDataDTO> data,
|
||||
String name,
|
||||
String type,
|
||||
List<SourceIssue.ChannelListDTO> channelList
|
||||
) {
|
||||
SourceCompareDev compareDev = new SourceCompareDev();
|
||||
compareDev.setIp(split[0]);
|
||||
compareDev.setLineNum(split[1]);
|
||||
compareDev.setDesc(name);
|
||||
//装置数据
|
||||
DevData.SqlDataDTO.ListDTO devData = data.get(0).getList();
|
||||
List<SourceIssue.ChannelListDTO> sourceList = channelList.stream().filter(x -> (type+"a").equals(x.getChannelType()) ||
|
||||
(type+"b").equals(x.getChannelType()) ||
|
||||
(type+"c").equals(x.getChannelType())
|
||||
).collect(Collectors.toList());
|
||||
Map<String, Float> sourceMap = sourceList.stream()
|
||||
.collect(Collectors.toMap(x -> x.getChannelType().toUpperCase().replace(type, "")
|
||||
, SourceIssue.ChannelListDTO::getFAmp));
|
||||
Map<String,Float> devMap =new HashMap<>(3);
|
||||
devMap.put("A",devData.getA());
|
||||
devMap.put("B",devData.getB());
|
||||
devMap.put("C",devData.getC());
|
||||
Boolean is = true;
|
||||
for (SourceIssue.ChannelListDTO channelListDTO : sourceList) {
|
||||
if (!is) {
|
||||
break;
|
||||
}
|
||||
if (channelListDTO.getChannelType().equals((type+"a"))) {
|
||||
is = NumberUtil.isIn(BigDecimal.valueOf(devData.getA()),
|
||||
BigDecimal.valueOf(channelListDTO.getFAmp() * 0.95),
|
||||
BigDecimal.valueOf(channelListDTO.getFAmp() * 1.05));
|
||||
}
|
||||
if (channelListDTO.getChannelType().equals((type+"b"))) {
|
||||
is = NumberUtil.isIn(BigDecimal.valueOf(devData.getB()),
|
||||
BigDecimal.valueOf(channelListDTO.getFAmp() * 0.95),
|
||||
BigDecimal.valueOf(channelListDTO.getFAmp() * 1.05));
|
||||
}
|
||||
if (channelListDTO.getChannelType().equals((type+"c"))) {
|
||||
is = NumberUtil.isIn(BigDecimal.valueOf(devData.getC()),
|
||||
BigDecimal.valueOf(channelListDTO.getFAmp() * 0.95),
|
||||
BigDecimal.valueOf(channelListDTO.getFAmp() * 1.05));
|
||||
}
|
||||
|
||||
}
|
||||
compareDev.setIsQualified(is);
|
||||
compareDev.setSourceData(sourceMap);
|
||||
compareDev.setDevData(devMap);
|
||||
return compareDev;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -47,38 +48,29 @@ public class SocketSourceResponseService {
|
||||
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(socketDataMsg.getRequestId());
|
||||
switch (enumByCode){
|
||||
case YJC_YTXJY:
|
||||
extracted(param, msg, socketDataMsg);
|
||||
detectionDev(param, socketDataMsg);
|
||||
break;
|
||||
case YJC_XUJY:
|
||||
phaseSequenceDev(param, socketDataMsg);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(SourceOperateCodeEnum.YJC_YTXJY.getValue().equals(socketDataMsg.getRequestId())){
|
||||
|
||||
}
|
||||
//装置通讯成功之后,会跟据获取到的源通道,进行发送源参数发送(处理发送成功后的信息)
|
||||
if(SourceOperateCodeEnum.YJC_XUJY.getValue().equals(socketDataMsg.getRequestId())){
|
||||
extracted1(param, msg, socketDataMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 源装置检测
|
||||
* 装置检测(当源初始化成功后,直接向装置通道向装置服务器发送,装置检测)
|
||||
* @param param
|
||||
* @param msg
|
||||
* @param socketDataMsg
|
||||
*/
|
||||
private void extracted(PreDetectionParam param, String msg, SocketDataMsg socketDataMsg) {
|
||||
private void detectionDev(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
if(ObjectUtil.isNotNull(dictDataEnumByCode)){
|
||||
SocketMsg socketMsg=new SocketMsg();
|
||||
switch (dictDataEnumByCode){
|
||||
case SUCCESS:
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), msg);
|
||||
//todo 前端推送收到的消息暂未处理好
|
||||
// webSocketHandler.sendMsgToUser(param.getUserPageId(), msg);
|
||||
String s = param.getUserPageId() + "_dev";
|
||||
//开始设备通讯检测
|
||||
Channel channel = SocketManager.getChannelByUserId(s);
|
||||
@@ -101,34 +93,43 @@ public class SocketSourceResponseService {
|
||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
// webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void extracted1(PreDetectionParam param, String msg, SocketDataMsg socketDataMsg) {
|
||||
/**
|
||||
* 相序检测向装置发送(当装置初始成功后,会向源发送加量请求。收到加量请求成功后会向装置发送参数下发。)
|
||||
* @param param
|
||||
* @param socketDataMsg
|
||||
*/
|
||||
private void phaseSequenceDev(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
if(ObjectUtil.isNotNull(dictDataEnumByCode)){
|
||||
SocketMsg socketMsg=new SocketMsg();
|
||||
switch (dictDataEnumByCode){
|
||||
case SUCCESS:
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), msg);
|
||||
String s = param.getUserPageId() + "_Dev";
|
||||
//缺少向终端发送相序校验的参数
|
||||
//向前端推送信息
|
||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
String s = param.getUserPageId() + "_Dev";
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
List<String> moniterIdList = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||
.map(PreDetection.MonitorListDTO::getLineId)
|
||||
.collect(Collectors.toList());
|
||||
DevPhaseSequenceParam phaseSequenceParam=new DevPhaseSequenceParam();
|
||||
phaseSequenceParam.setMoniterIdList(moniterIdList);
|
||||
// phaseSequenceParam.setDataType();
|
||||
// phaseSequenceParam.setReadCount();
|
||||
// phaseSequenceParam.setIgnoreCount();
|
||||
//
|
||||
// socketMsg.setData();
|
||||
phaseSequenceParam.setDataType(Arrays.asList("平均值/电压有效值","平均值/电流有效值"));
|
||||
phaseSequenceParam.setReadCount(1);
|
||||
phaseSequenceParam.setIgnoreCount(1);
|
||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||
SocketManager.sendMsg(s,JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.detection.pojo.vo;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -13,15 +14,18 @@ public class SocketMsg {
|
||||
/**
|
||||
* 请求id,确保接收到响应时,知晓是针对的哪次请求的应答
|
||||
*/
|
||||
@JSONField(ordinal = 1)
|
||||
private String requestId;
|
||||
|
||||
/**
|
||||
* 源初始化 INIT_GATHER$01 INIT_GATHER采集初始化,01 统计采集、02 暂态采集、03 实时采集
|
||||
*/
|
||||
@JSONField(ordinal = 2)
|
||||
private String operateCode;
|
||||
|
||||
/**
|
||||
* 数据体,传输前需要将对象、Array等转为String
|
||||
*/
|
||||
@JSONField(ordinal = 3)
|
||||
private String data;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
//开始组装socket报文请求头
|
||||
SocketMsg msg=new SocketMsg();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
msg.setData(JSON.toJSONString(sourceParam));
|
||||
String s = param.getUserPageId() + "_Source";
|
||||
NettyClient.socketClient(ip, port,param.getUserPageId(), new NettySourceClientHandler(param, sourceResponseService));
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
@@ -39,6 +40,8 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -65,6 +68,9 @@ public class PqDevController extends BaseController {
|
||||
public HttpResult<List<PreDetection>> aaa() {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
List<PreDetection> devInfo = pqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
|
||||
Map<String,List<PreDetection> > map=new HashMap();
|
||||
map.put("deviceList",devInfo);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devInfo, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
package com.njcn.gather.device.script.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.device.script.service.IPqScriptService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.sun.xml.internal.bind.v2.runtime.output.SAXOutput;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -132,5 +137,22 @@ public class PqScriptController extends BaseController {
|
||||
List<Map<String, Object>> result = pqScriptService.listAllPqScript(patternId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("dls")
|
||||
@ApiOperation("根据脚本id查询检测脚本详情")
|
||||
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
|
||||
public HttpResult<List<SourceIssue>> dls(@RequestBody PqScriptIssueParam param) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(param);
|
||||
for (SourceIssue sourceIssue : sourceIssues) {
|
||||
String jsonString = JSON.toJSONString(sourceIssue,SerializerFeature.WriteNullStringAsEmpty);
|
||||
System.out.println();
|
||||
}
|
||||
String jsonString = JSON.toJSONString(sourceIssues, SerializerFeature.WriteMapNullValue);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceIssues, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.device.source.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
@@ -9,6 +10,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.source.pojo.param.PqSourceParam;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.device.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.device.source.pojo.po.SourceParam;
|
||||
import com.njcn.gather.device.source.service.IPqSourceService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -125,5 +127,17 @@ public class PqSourceController extends BaseController {
|
||||
List<SourceParam> result = pqSourceService.getSourceParam(sourceId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/aa")
|
||||
@ApiOperation("按照检测源ID获取源参数")
|
||||
@ApiImplicitParam(name = "pqSourceId", value = "检测源ID", required = true)
|
||||
public HttpResult<SourceInitialize> aa(@RequestParam("sourceId") String sourceId) {
|
||||
String methodDescribe = getMethodDescribe("getParam");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceId);
|
||||
SourceInitialize sourceInitializeParam = pqSourceService.getSourceInitializeParam(sourceId);
|
||||
String jsonString = JSON.toJSONString(sourceInitializeParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceInitializeParam, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user