1.源装置,入参和发送指令业务编写
This commit is contained in:
@@ -12,10 +12,8 @@ import io.swagger.annotations.ApiImplicitParam;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.Get;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Api(tags = "预检测")
|
@Api(tags = "预检测")
|
||||||
@@ -41,4 +39,18 @@ public class PreDetectionController extends BaseController {
|
|||||||
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始检测
|
||||||
|
*/
|
||||||
|
@PostMapping("/startTest2")
|
||||||
|
@OperateInfo
|
||||||
|
@ApiOperation("开始检测")
|
||||||
|
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||||
|
public HttpResult<String> startTest2(@RequestBody PreDetectionParam param){
|
||||||
|
String methodDescribe = getMethodDescribe("startTest");
|
||||||
|
preDetectionService.sourceCommunicationCheck(param);
|
||||||
|
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,18 @@
|
|||||||
package com.njcn.gather.detection.handler;
|
package com.njcn.gather.detection.handler;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||||
|
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
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.web.WebSocketHandler;
|
import com.njcn.gather.detection.util.socket.web.WebSocketHandler;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -14,12 +24,39 @@ public class SocketSourceResponseService {
|
|||||||
*/
|
*/
|
||||||
private final WebSocketHandler webSocketHandler;
|
private final WebSocketHandler webSocketHandler;
|
||||||
|
|
||||||
|
private final SocketResponseService sourceResponseService;
|
||||||
|
|
||||||
|
@Value("${socket.device.ip}")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
@Value("${socket.device.port}")
|
||||||
|
private Integer port;
|
||||||
public void deal(String userId,String msg){
|
public void deal(String userId,String msg){
|
||||||
|
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||||
|
if(SourceOperateCodeEnum.YJC_YTXJY.getValue().equals(socketDataMsg.getRequestId())){
|
||||||
|
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||||
|
if(ObjectUtil.isNotNull(dictDataEnumByCode)){
|
||||||
|
switch (dictDataEnumByCode){
|
||||||
|
case SUCCESS:
|
||||||
|
webSocketHandler.sendMsgToUser(userId,msg);
|
||||||
|
String s = userId + "_Dev";
|
||||||
|
//todo 创建终端socket连接
|
||||||
|
NettyClient.socketClient(ip, port, s, new NettyDevClientHandler(s, sourceResponseService));
|
||||||
|
SocketManager.sendMsg(s,"向127服务器发送");
|
||||||
|
break;
|
||||||
|
case UNPROCESSED_BUSINESS:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SocketMsg socketMsg=new SocketMsg();
|
||||||
|
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||||
|
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||||
|
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||||
|
webSocketHandler.sendMsgToUser(userId, JSON.toJSONString(socketMsg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("进入deal+++++++++++++++++++");
|
}
|
||||||
webSocketHandler.sendMsgToUser(userId,msg);
|
|
||||||
|
|
||||||
SocketManager.getChannelByUserId(userId).close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.njcn.gather.detection.pojo.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description:
|
||||||
|
* @Author: wr
|
||||||
|
* @Date: 2024/12/17 15:37
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum SourceOperateCodeEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 源状态
|
||||||
|
*/
|
||||||
|
INIT_GATHER("INIT_GATHER", "源初始化"),
|
||||||
|
OPER_GATHER("OPER_GATHER", "源输出"),
|
||||||
|
CLOSE_GATHER("CLOSE_GATHER", "源停止"),
|
||||||
|
|
||||||
|
YJC_YTXJY("yjc_ytxjy", "预检测_源通讯检测");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
SourceOperateCodeEnum(String value, String msg) {
|
||||||
|
this.value = value;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.njcn.gather.detection.pojo.enums;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: wr
|
||||||
|
* @Date: 2024/12/17 15:37
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum SourceResponseCodeEnum {
|
||||||
|
|
||||||
|
SUCCESS(10200, "请求成功"),
|
||||||
|
UNPROCESSED_BUSINESS(10201, "立即响应,业务还未处理,类似肯定应答"),
|
||||||
|
NORMAL_RESPONSE(10202, "正常响应中间状态码"),
|
||||||
|
MESSAGE_PARSING_ERROR(10520, "报文解析有误"),
|
||||||
|
CONTROLLED_SOURCE_ERROR(10521, "程控源参数有误"),
|
||||||
|
TEST_ITEM_PARSING_ERROR(10522, "测试项解析有误"),
|
||||||
|
SOURCE_CONNECTION_ERROR(10523, "源连接失败"),
|
||||||
|
SOURCE_CONTROL_ERROR(10524, "获取源控制权失败"),
|
||||||
|
RESET_ERROR(10525, "重置源失败"),
|
||||||
|
STOP_ERROR(10526, "停止源失败"),
|
||||||
|
NOT_INITIALIZED(10527, "源未进行初始化"),
|
||||||
|
TARGET_SOURCE_ERROR(10528, "目标源有误(该用户已控制其他源,在关闭前无法操作新的源)"),
|
||||||
|
UNABLE_TO_RESPOND(10529, "源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)");
|
||||||
|
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
SourceResponseCodeEnum(Integer code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMsgByValue(Integer code) {
|
||||||
|
for (SourceResponseCodeEnum state : SourceResponseCodeEnum.values()) {
|
||||||
|
if (state.getCode().equals(code)) {
|
||||||
|
return state.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SourceResponseCodeEnum getDictDataEnumByCode(Integer code) {
|
||||||
|
for (SourceResponseCodeEnum sourceResponseCodeEnum : SourceResponseCodeEnum.values()) {
|
||||||
|
if (ObjectUtil.equals(code, sourceResponseCodeEnum.getCode())) {
|
||||||
|
return sourceResponseCodeEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ public class PreDetectionParam {
|
|||||||
/**
|
/**
|
||||||
* 检测计划id
|
* 检测计划id
|
||||||
*/
|
*/
|
||||||
private String plan;
|
private String planId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户功能组成唯一标识 zhangsan_test
|
* 用户功能组成唯一标识 zhangsan_test
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.gather.detection.pojo.vo;
|
package com.njcn.gather.detection.pojo.vo;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,21 +14,25 @@ public class SocketDataMsg {
|
|||||||
/**
|
/**
|
||||||
* 请求id,确保接收到响应时,知晓是针对的哪次请求的应答
|
* 请求id,确保接收到响应时,知晓是针对的哪次请求的应答
|
||||||
*/
|
*/
|
||||||
|
@JSONField(ordinal = 1)
|
||||||
private String requestId;
|
private String requestId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 源初始化 INIT_GATHER$01 INIT_GATHER采集初始化,01 统计采集、02 暂态采集、03 实时采集
|
* 源初始化 INIT_GATHER$01 INIT_GATHER采集初始化,01 统计采集、02 暂态采集、03 实时采集
|
||||||
*/
|
*/
|
||||||
|
@JSONField(ordinal = 2)
|
||||||
private String operateCode;
|
private String operateCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据体,传输前需要将对象、Array等转为String
|
* 数据体,传输前需要将对象、Array等转为String
|
||||||
*/
|
*/
|
||||||
|
@JSONField(ordinal = 4)
|
||||||
private String data;
|
private String data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* code码
|
* code码
|
||||||
*/
|
*/
|
||||||
private String code;
|
@JSONField(ordinal = 3)
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package com.njcn.gather.detection.service;
|
|||||||
|
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wr
|
* @author wr
|
||||||
@@ -21,21 +19,6 @@ public interface PreDetectionService {
|
|||||||
*/
|
*/
|
||||||
void sourceCommunicationCheck(PreDetectionParam param);
|
void sourceCommunicationCheck(PreDetectionParam param);
|
||||||
|
|
||||||
/**
|
|
||||||
* 装置通讯校验
|
|
||||||
*/
|
|
||||||
void deviceCommunicationCheck();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 协议校验
|
|
||||||
*/
|
|
||||||
void agreementCheck();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 相序校验
|
|
||||||
*/
|
|
||||||
void phaseSequenceCheck();
|
|
||||||
|
|
||||||
|
|
||||||
boolean startTest(PreDetectionParam param);
|
boolean startTest(PreDetectionParam param);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package com.njcn.gather.detection.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||||
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||||
import com.njcn.gather.detection.service.PreDetectionService;
|
import com.njcn.gather.detection.service.PreDetectionService;
|
||||||
@@ -24,8 +26,6 @@ import com.njcn.gather.plan.service.IAdPlanService;
|
|||||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -53,25 +53,24 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final String userId = "aaa";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sourceCommunicationCheck(PreDetectionParam param) {
|
public void sourceCommunicationCheck(PreDetectionParam param) {
|
||||||
/*
|
/*
|
||||||
先组装源通讯协议
|
先组装源通讯协议
|
||||||
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
|
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
|
||||||
*/
|
*/
|
||||||
AdPlan plan = iAdPlanService.getById(param.getPlan());
|
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
||||||
if (ObjectUtil.isNotNull(plan)) {
|
if (ObjectUtil.isNotNull(plan)) {
|
||||||
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
||||||
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
||||||
switch (dictDataEnumByCode) {
|
switch (dictDataEnumByCode) {
|
||||||
case DIGITAL:
|
case DIGITAL:
|
||||||
case SIMULATE:
|
case SIMULATE:
|
||||||
sendYtxSocket(plan.getId());
|
sendYtxSocket(plan.getId(),param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
case CONTRAST:
|
case CONTRAST:
|
||||||
//todo 对比式可以是多个源
|
//todo 对比式可以是多个源
|
||||||
|
sendYtxSocket(plan.getId(),param.getUserPageId());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//todo 没有找到对应的模式
|
//todo 没有找到对应的模式
|
||||||
@@ -84,27 +83,23 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private void sendYtxSocket(String planId,String userPageId){
|
||||||
/**
|
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
|
||||||
* 源参数下发
|
.eq(AdPlanSource::getPlanId,planId)
|
||||||
* @param scriptId
|
);
|
||||||
*/
|
|
||||||
private void sendSourceIssue(String scriptId){
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
private void sendYtxSocket(String planId){
|
|
||||||
AdPlanSource planSource = adPlanSourceService.getById(planId);
|
|
||||||
if(ObjectUtil.isNotNull(planSource)){
|
if(ObjectUtil.isNotNull(planSource)){
|
||||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||||
if(ObjectUtil.isNotNull(sourceParam)){
|
if(ObjectUtil.isNotNull(sourceParam)){
|
||||||
//开始组装socket报文请求头
|
//开始组装socket报文请求头
|
||||||
SocketMsg msg=new SocketMsg();
|
SocketMsg msg=new SocketMsg();
|
||||||
msg.setRequestId("yjc_ytxjy");
|
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||||
msg.setOperateCode("");
|
msg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
msg.setData(JSON.toJSONString(sourceParam));
|
msg.setData(JSON.toJSONString(sourceParam));
|
||||||
NettyClient.socketClient(ip, port, JSON.toJSONString(msg), new NettySourceClientHandler(ip, sourceResponseService));
|
String s = userPageId + "_Source";
|
||||||
|
NettyClient.socketClient(ip, port, s, new NettySourceClientHandler(s, sourceResponseService));
|
||||||
|
SocketManager.sendMsg(s,JSON.toJSONString(msg));
|
||||||
|
|
||||||
|
|
||||||
PqScriptIssueParam param=new PqScriptIssueParam();
|
PqScriptIssueParam param=new PqScriptIssueParam();
|
||||||
param.setScriptId(planSource.getSourceId());
|
param.setScriptId(planSource.getSourceId());
|
||||||
param.setPlanId(planId);
|
param.setPlanId(planId);
|
||||||
@@ -122,63 +117,51 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deviceCommunicationCheck() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void agreementCheck() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void phaseSequenceCheck() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startTest(PreDetectionParam param) {
|
public boolean startTest(PreDetectionParam param) {
|
||||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
|
List<PreDetection> pqDevList = iPqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
|
||||||
System.out.println(pqDevList);
|
System.out.println(pqDevList);
|
||||||
//校验
|
//校验
|
||||||
|
// List<PreDetection> pqDevList = iPqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
|
||||||
//组装请求数据
|
// System.out.println(pqDevList);
|
||||||
SocketMsg socketMsg = new SocketMsg();
|
// //校验
|
||||||
Map<String, List<PreDetection>> map = new HashMap();
|
//
|
||||||
map.put("deviceList", pqDevList);
|
// //组装请求数据
|
||||||
String jsonString = JSON.toJSONString(map);
|
// SocketMsg socketMsg = new SocketMsg();
|
||||||
socketMsg.setRequestId("adawdawd");
|
// Map<String, List<PreDetection>> map = new HashMap();
|
||||||
socketMsg.setOperateCode("INIT_GATHER$03");
|
// map.put("deviceList", pqDevList);
|
||||||
socketMsg.setData(jsonString);
|
// String jsonString = JSON.toJSONString(map);
|
||||||
String json = JSON.toJSONString(socketMsg);
|
// socketMsg.setRequestId("adawdawd");
|
||||||
|
// socketMsg.setOperateCode("INIT_GATHER$03");
|
||||||
String tem = "{\"data\":\"{\\\"deviceList\\\":[{\\\"devIP\\\":\\\"192.168.1.186\\\",\\\"port\\\":102,\\\"devType\\\":\\\"PQS882B\\\",\\\"icdType\\\":\\\"PQS882_VX_ZJ_1(V102)\\\",\\\"devCode\\\":\\\"Pqs\\u0026cn870299\\\",\\\"devKey\\\":\\\"!qaz@wsx3edc4rfv\\\",\\\"monitorList\\\":[{\\\"lineId\\\":\\\"1_192.168.1.186_102_1\\\",\\\"line\\\":1}]}]}\",\"operateCode\":\"INIT_GATHER$03\",\"requestId\":\"dansldquiwdlandalksn\"}";
|
// socketMsg.setData(jsonString);
|
||||||
|
// String json = JSON.toJSONString(socketMsg);
|
||||||
|
//
|
||||||
|
// NettyClient.socketClient(ip, port, "{\"data\":\"{\\\"deviceList\\\":[{\\\"devIP\\\":\\\"192.168.1.186\\\",\\\"port\\\":102,\\\"devType\\\":\\\"PQS882B\\\",\\\"icdType\\\":\\\"PQS882_VX_ZJ_1(V102)\\\",\\\"devCode\\\":\\\"Pqs\\u0026cn870299\\\",\\\"devKey\\\":\\\"!qaz@wsx3edc4rfv\\\",\\\"monitorList\\\":[{\\\"lineId\\\":\\\"1_192.168.1.186_102_1\\\",\\\"line\\\":1}]}]}\",\"operateCode\":\"INIT_GATHER$03\",\"requestId\":\"dansldquiwdlandalksn\"}", new NettySourceClientHandler(param.getUserPageId(), sourceResponseService));
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
// NettyClient.socketClient(ip, port, "源客户端初始化发送", new NettySourceClientHandler(ip + "_" + port, sourceResponseService));
|
||||||
Channel channel = null;
|
|
||||||
if(SocketManager.getChannelByUserId(param.getUserPageId()) == null || !SocketManager.getChannelByUserId(param.getUserPageId()).isActive()){
|
|
||||||
channel = NettyClient.socketClient(ip, port,param.getUserPageId(),new NettySourceClientHandler(param.getUserPageId(), sourceResponseService));
|
|
||||||
}
|
}
|
||||||
if(Objects.nonNull(channel)){
|
};
|
||||||
try {
|
runnable.run();
|
||||||
channel.writeAndFlush(tem).sync();
|
System.out.println("111111111111111111111+++++++++++++++");
|
||||||
} catch (InterruptedException e) {
|
// Runnable runnable2 = new Runnable() {
|
||||||
System.out.println("发送异常=====");
|
// @Override
|
||||||
e.printStackTrace();
|
// public void run() {
|
||||||
throw new RuntimeException(e);
|
// NettyClient.socketClient(ip, 61001, "装置客户端初始化发送", new NettySourceClientHandler(ip + "_" + 61001, sourceResponseService2));
|
||||||
}
|
// }
|
||||||
}
|
// };
|
||||||
}
|
// runnable2.run();
|
||||||
};
|
|
||||||
runnable.run();
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
String tem = "{\"data\":\"{\\\"deviceList\\\":[{\\\"devIP\\\":\\\"192.168.1.186\\\",\\\"port\\\":102,\\\"devType\\\":\\\"PQS882B\\\",\\\"icdType\\\":\\\"PQS882_VX_ZJ_1(V102)\\\",\\\"devCode\\\":\\\"Pqs\\u0026cn870299\\\",\\\"devKey\\\":\\\"!qaz@wsx3edc4rfv\\\",\\\"monitorList\\\":[{\\\"lineId\\\":\\\"1_192.168.1.186_102_1\\\",\\\"line\\\":1}]}]}\",\"operateCode\":\"INIT_GATHER$03\",\"requestId\":\"dansldquiwdlandalksn\"}";
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static void main(String[] args) {
|
||||||
|
// NettyClient.socketClient("192.168.1.121", 61000, "源客户端初始化发送", new NettySourceClientHandler( "192.168.1.121_61000"));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
|||||||
public class MsgUtil {
|
public class MsgUtil {
|
||||||
|
|
||||||
|
|
||||||
public SocketDataMsg socketDataMsg(String textMsg){
|
public static SocketDataMsg socketDataMsg(String textMsg){
|
||||||
return JSON.parseObject(textMsg,SocketDataMsg.class);
|
return JSON.parseObject(textMsg,SocketDataMsg.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
* @Date: 2024/12/11 13:04
|
* @Date: 2024/12/11 13:04
|
||||||
*/
|
*/
|
||||||
public class SocketManager {
|
public class SocketManager {
|
||||||
|
|
||||||
private static final Map<String, Channel> userSessions = new ConcurrentHashMap<>();
|
private static final Map<String, Channel> userSessions = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static void addUser(String userId, Channel channel) {
|
public static void addUser(String userId, Channel channel) {
|
||||||
@@ -28,8 +29,7 @@ public class SocketManager {
|
|||||||
|
|
||||||
public static void sendMsg(String userId,String msg) {
|
public static void sendMsg(String userId,String msg) {
|
||||||
Channel channel = userSessions.get(userId);
|
Channel channel = userSessions.get(userId);
|
||||||
TextWebSocketFrame wd1 = new TextWebSocketFrame(msg);
|
channel.writeAndFlush(msg);
|
||||||
channel.writeAndFlush(wd1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9,7 +9,6 @@ import io.netty.channel.*;
|
|||||||
import io.netty.channel.nio.NioEventLoopGroup;
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
import io.netty.handler.codec.LineBasedFrameDecoder;
|
import io.netty.handler.codec.LineBasedFrameDecoder;
|
||||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
|
||||||
import io.netty.handler.codec.string.StringDecoder;
|
import io.netty.handler.codec.string.StringDecoder;
|
||||||
import io.netty.handler.codec.string.StringEncoder;
|
import io.netty.handler.codec.string.StringEncoder;
|
||||||
import io.netty.handler.timeout.TimeoutException;
|
import io.netty.handler.timeout.TimeoutException;
|
||||||
@@ -18,7 +17,6 @@ import io.netty.util.CharsetUtil;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.ProtocolException;
|
import java.net.ProtocolException;
|
||||||
import java.net.SocketTimeoutException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,11 +27,9 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class NettyClient {
|
public class NettyClient {
|
||||||
|
|
||||||
|
|
||||||
public static Channel socketClient(String ip, Integer port,String userId, ChannelHandler handler) {
|
public static void socketClient(String ip, Integer port,String userId, ChannelHandler handler) {
|
||||||
NioEventLoopGroup group = new NioEventLoopGroup();
|
NioEventLoopGroup group = new NioEventLoopGroup();
|
||||||
Bootstrap bootstrap = new Bootstrap();
|
Bootstrap bootstrap = new Bootstrap();
|
||||||
Channel channel = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bootstrap.group(group)
|
bootstrap.group(group)
|
||||||
.channel(NioSocketChannel.class)
|
.channel(NioSocketChannel.class)
|
||||||
@@ -81,14 +77,10 @@ public class NettyClient {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
ChannelFuture channelFuture = bootstrap.connect(ip, port).sync();
|
ChannelFuture channelFuture = bootstrap.connect(ip, port).sync();
|
||||||
channel = channelFuture.channel();
|
SocketManager.addUser(userId,channelFuture.channel());
|
||||||
SocketManager.addUser(userId,channel);
|
|
||||||
return channel;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("进入异常............");
|
System.out.println("进入异常............");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
|
||||||
|
|
||||||
}finally {
|
}finally {
|
||||||
System.out.println("进入clientSocket最后步骤---------------------");
|
System.out.println("进入clientSocket最后步骤---------------------");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,10 @@ package com.njcn.gather.detection.util.socket.cilent;
|
|||||||
|
|
||||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
import io.netty.channel.ChannelFuture;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,13 +21,6 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<Strin
|
|||||||
|
|
||||||
private final SocketSourceResponseService sourceResponseService;
|
private final SocketSourceResponseService sourceResponseService;
|
||||||
|
|
||||||
@Value("${socket.device.ip}")
|
|
||||||
private String devIp;
|
|
||||||
|
|
||||||
@Value("${socket.device.port}")
|
|
||||||
private Integer devPort;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当通道进行连接时推送消息
|
* 当通道进行连接时推送消息
|
||||||
* @param ctx
|
* @param ctx
|
||||||
@@ -41,7 +31,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<Strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理服务端消息消息信息
|
* 处理服务端消息信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws InterruptedException {
|
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws InterruptedException {
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
package com.njcn.gather.detection.util.socket.web;
|
package com.njcn.gather.detection.util.socket.web;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
|
||||||
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.njcn.gather.plan.pojo.po;
|
package com.njcn.gather.plan.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@@ -13,16 +15,19 @@ import java.io.Serializable;
|
|||||||
@Data
|
@Data
|
||||||
@TableName("ad_plan_source")
|
@TableName("ad_plan_source")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
public class AdPlanSource implements Serializable {
|
public class AdPlanSource implements Serializable {
|
||||||
private static final long serialVersionUID = -76292730578149530L;
|
private static final long serialVersionUID = -76292730578149530L;
|
||||||
/**
|
/**
|
||||||
* 检测计划表Id
|
* 检测计划表Id
|
||||||
*/
|
*/
|
||||||
|
@TableField("Plan_Id")
|
||||||
private String planId;
|
private String planId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测源表Id
|
* 检测源表Id
|
||||||
*/
|
*/
|
||||||
|
@TableField("Source_Id")
|
||||||
private String sourceId;
|
private String sourceId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.njcn.gather.device.script.pojo.param;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,6 +20,12 @@ public class PqScriptIssueParam {
|
|||||||
@ApiModelProperty("检测计划id")
|
@ApiModelProperty("检测计划id")
|
||||||
private String planId;
|
private String planId;
|
||||||
|
|
||||||
|
@ApiModelProperty("终端id集合")
|
||||||
|
private List<String> devIds;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否是相序校验")
|
||||||
|
private Boolean isPhaseSequence;
|
||||||
|
|
||||||
@ApiModelProperty("源id")
|
@ApiModelProperty("源id")
|
||||||
private String sourceId ="111";
|
private String sourceId ="111";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class PqScriptDtls implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 总检测脚本中的测试项序号
|
* 总检测脚本中的测试项序号
|
||||||
*/
|
*/
|
||||||
|
@TableField("Index")
|
||||||
private Integer index;
|
private Integer index;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,6 +89,7 @@ public class PqScriptDtls implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 状态:0-不启用 1-启用
|
* 状态:0-不启用 1-启用
|
||||||
*/
|
*/
|
||||||
|
@TableField("Enable")
|
||||||
private Integer enable;
|
private Integer enable;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.gather.device.script.service.impl;
|
package com.njcn.gather.device.script.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
@@ -16,6 +17,7 @@ import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
|||||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -40,6 +42,20 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
private final static String INHARM_I = "InHarm_I";
|
private final static String INHARM_I = "InHarm_I";
|
||||||
private final static String DIP = "Dip";
|
private final static String DIP = "Dip";
|
||||||
private final static String FLICKER = "Flicker";
|
private final static String FLICKER = "Flicker";
|
||||||
|
@Value("${Dip.fPreTime}")
|
||||||
|
private Float fPreTime;
|
||||||
|
@Value("${Dip.fRampIn}")
|
||||||
|
private Float fRampIn;
|
||||||
|
@Value("${Dip.fRampOut}")
|
||||||
|
private Float fRampOut;
|
||||||
|
@Value("${Dip.fAfterTime}")
|
||||||
|
private Float fAfterTime;
|
||||||
|
@Value("${Flicker.waveFluType}")
|
||||||
|
private String waveFluType;
|
||||||
|
@Value("${Flicker.waveType}")
|
||||||
|
private String waveType;
|
||||||
|
@Value("${Flicker.fDutyCycle}")
|
||||||
|
private Float fDutyCycle;
|
||||||
|
|
||||||
|
|
||||||
private final IPqDevService pqDevService;
|
private final IPqDevService pqDevService;
|
||||||
@@ -89,6 +105,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
//校验终端额定电压电流是否相同
|
//校验终端额定电压电流是否相同
|
||||||
List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>()
|
List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>()
|
||||||
.eq(PqDev::getPlanId, param.getPlanId())
|
.eq(PqDev::getPlanId, param.getPlanId())
|
||||||
|
.in(PqDev::getId, param.getDevIds())
|
||||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||||
);
|
);
|
||||||
//额定电压信息
|
//额定电压信息
|
||||||
@@ -98,7 +115,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (voltSet.size() == 1 && currSet.size() == 1) {
|
if (voltSet.size() == 1 && currSet.size() == 1) {
|
||||||
Float volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
Float volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
||||||
Float curr = currSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
Float curr = currSet.stream().collect(Collectors.toList()).stream().findFirst().get();
|
||||||
List<PqScriptDtls> pqScriptDtls = this.pqScriptDtls(param.getScriptId(), volt, curr);
|
List<PqScriptDtls> pqScriptDtls = this.pqScriptDtls(param.getScriptId(),param.getIsPhaseSequence(), volt, curr);
|
||||||
if (CollUtil.isNotEmpty(pqScriptDtls)) {
|
if (CollUtil.isNotEmpty(pqScriptDtls)) {
|
||||||
/**
|
/**
|
||||||
* 1.获取全部检测点脚本
|
* 1.获取全部检测点脚本
|
||||||
@@ -134,10 +151,15 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
|
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
//谐波电压,间谐波
|
//谐波电压,间谐波
|
||||||
List<PqScriptDtls> dtlsVList = value.stream().filter(x -> HARM_V.equals(x.getValueType()) || INHARM_V.equals(x.getValueType()))
|
List<PqScriptDtls> dtlsVList = value.stream().filter(x -> HARM_V.equals(x.getValueType()) ||
|
||||||
|
INHARM_V.equals(x.getValueType()) ||
|
||||||
|
DIP.equals(x.getValueType()) ||
|
||||||
|
FLICKER.equals(x.getValueType())
|
||||||
|
|
||||||
|
)
|
||||||
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
|
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
issueAdd(volList, dtlsVList, HARM_V, INHARM_V, "U", channelListDTOS);
|
issueAdd(volList, dtlsVList, HARM_V, INHARM_V, freqDtls.getValue(), "U", channelListDTOS);
|
||||||
|
|
||||||
//2.通道电流(ABC)
|
//2.通道电流(ABC)
|
||||||
List<PqScriptDtls> curList = value.stream().filter(x -> CUR.equals(x.getValueType()))
|
List<PqScriptDtls> curList = value.stream().filter(x -> CUR.equals(x.getValueType()))
|
||||||
@@ -147,9 +169,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
List<PqScriptDtls> dtlsIList = value.stream().filter(x -> HARM_I.equals(x.getValueType()) || HARM_I.equals(x.getValueType()))
|
List<PqScriptDtls> dtlsIList = value.stream().filter(x -> HARM_I.equals(x.getValueType()) || HARM_I.equals(x.getValueType()))
|
||||||
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
|
.sorted(Comparator.comparing(PqScriptDtls::getPhase))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, "I", channelListDTOS);
|
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, freqDtls.getValue(), "I", channelListDTOS);
|
||||||
|
|
||||||
//todo 暂降和闪变没写
|
|
||||||
issue.setChannelList(channelListDTOS);
|
issue.setChannelList(channelListDTOS);
|
||||||
sourceIssues.add(issue);
|
sourceIssues.add(issue);
|
||||||
}
|
}
|
||||||
@@ -161,20 +182,29 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
return sourceIssues;
|
return sourceIssues;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PqScriptDtls> pqScriptDtls(String scriptId, Float volt, Float curr) {
|
private List<PqScriptDtls> pqScriptDtls(String scriptId,Boolean isPhaseSequence,Float volt, Float curr) {
|
||||||
//先获取检测脚本类型是否相对值 true相对值 false绝对值(相对值要乘额定值,绝对值不需要处理)
|
List<PqScriptDtls> pqScriptDtls;
|
||||||
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(scriptId);
|
if(isPhaseSequence){
|
||||||
List<PqScriptDtls> pqScriptDtls = this.listPqScriptDtlByScriptId(scriptId);
|
pqScriptDtls = this.list(new MPJLambdaWrapper<PqScriptDtls>()
|
||||||
if (isValueType) {
|
.eq(PqScriptDtls::getIndex, -1)
|
||||||
for (PqScriptDtls pqScriptDtl : pqScriptDtls) {
|
.eq(PqScriptDtls::getEnable, 1)
|
||||||
if (VOL.equals(pqScriptDtl.getValueType())) {
|
);
|
||||||
pqScriptDtl.setValue(pqScriptDtl.getChagValue() * volt);
|
}else{
|
||||||
}
|
//先获取检测脚本类型是否相对值 true相对值 false绝对值(相对值要乘额定值,绝对值不需要处理)
|
||||||
if (CUR.equals(pqScriptDtl.getValueType())) {
|
Boolean isValueType = pqScriptMapper.selectScriptIsValueType(scriptId);
|
||||||
pqScriptDtl.setValue(pqScriptDtl.getChagValue() * curr);
|
pqScriptDtls = this.listPqScriptDtlByScriptId(scriptId);
|
||||||
|
if (isValueType) {
|
||||||
|
for (PqScriptDtls pqScriptDtl : pqScriptDtls) {
|
||||||
|
if (VOL.equals(pqScriptDtl.getValueType())) {
|
||||||
|
pqScriptDtl.setValue(pqScriptDtl.getChagValue() * volt);
|
||||||
|
}
|
||||||
|
if (CUR.equals(pqScriptDtl.getValueType())) {
|
||||||
|
pqScriptDtl.setValue(pqScriptDtl.getChagValue() * curr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pqScriptDtls;
|
return pqScriptDtls;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +214,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
* @param dtlsList 其他类型检测集合(谐波,间谐波等)
|
* @param dtlsList 其他类型检测集合(谐波,间谐波等)
|
||||||
* @param harm 谐波
|
* @param harm 谐波
|
||||||
* @param harm 间谐波
|
* @param harm 间谐波
|
||||||
|
* @param fFreq 频率
|
||||||
* @param code U,I
|
* @param code U,I
|
||||||
* @param channelListDTOS 通道信息
|
* @param channelListDTOS 通道信息
|
||||||
* @param channelListDTOS 通道信息
|
* @param channelListDTOS 通道信息
|
||||||
@@ -191,12 +222,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
* @Author: wr
|
* @Author: wr
|
||||||
* @Date: 2024/12/16 15:51
|
* @Date: 2024/12/16 15:51
|
||||||
*/
|
*/
|
||||||
private static void issueAdd(List<PqScriptDtls> dtlsList,
|
private void issueAdd(List<PqScriptDtls> dtlsList,
|
||||||
List<PqScriptDtls> dtlsOtherList,
|
List<PqScriptDtls> dtlsOtherList,
|
||||||
String harm,
|
String harm,
|
||||||
String inHarm,
|
String inHarm,
|
||||||
String code,
|
Float fFreq,
|
||||||
List<SourceIssue.ChannelListDTO> channelListDTOS) {
|
String code,
|
||||||
|
List<SourceIssue.ChannelListDTO> channelListDTOS) {
|
||||||
for (PqScriptDtls dtls : dtlsList) {
|
for (PqScriptDtls dtls : dtlsList) {
|
||||||
SourceIssue.ChannelListDTO channelListDTO = new SourceIssue.ChannelListDTO();
|
SourceIssue.ChannelListDTO channelListDTO = new SourceIssue.ChannelListDTO();
|
||||||
channelListDTO.setChannelFlag(true);
|
channelListDTO.setChannelFlag(true);
|
||||||
@@ -212,20 +244,26 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
//暂态数据
|
//暂态数据
|
||||||
SourceIssue.ChannelListDTO.DipDataDTO dipDataDTO = new SourceIssue.ChannelListDTO.DipDataDTO();
|
SourceIssue.ChannelListDTO.DipDataDTO dipDataDTO = new SourceIssue.ChannelListDTO.DipDataDTO();
|
||||||
dipDataDTO.setFTransValue(0.0f);
|
dipDataDTO.setFTransValue(0.0f);
|
||||||
dipDataDTO.setFPreTime(0.0f);
|
|
||||||
dipDataDTO.setFRampIn(0.001f);
|
|
||||||
dipDataDTO.setFRetainTime(0.0f);
|
dipDataDTO.setFRetainTime(0.0f);
|
||||||
dipDataDTO.setFRampOut(0.001f);
|
|
||||||
dipDataDTO.setFAfterTime(0.0f);
|
dipDataDTO.setFPreTime(fPreTime);
|
||||||
|
dipDataDTO.setFRampIn(fRampIn);
|
||||||
|
dipDataDTO.setFRampOut(fRampOut);
|
||||||
|
dipDataDTO.setFAfterTime(fAfterTime);
|
||||||
|
|
||||||
|
|
||||||
channelListDTO.setDipData(dipDataDTO);
|
channelListDTO.setDipData(dipDataDTO);
|
||||||
//闪变数据
|
//闪变数据
|
||||||
SourceIssue.ChannelListDTO.FlickerDataDTO flickerDataDTO = new SourceIssue.ChannelListDTO.FlickerDataDTO();
|
SourceIssue.ChannelListDTO.FlickerDataDTO flickerDataDTO = new SourceIssue.ChannelListDTO.FlickerDataDTO();
|
||||||
flickerDataDTO.setWaveFluType(null);
|
flickerDataDTO.setWaveFluType(waveFluType);
|
||||||
flickerDataDTO.setWaveType(null);
|
flickerDataDTO.setWaveType(waveType);
|
||||||
flickerDataDTO.setFDutyCycle(0.0f);
|
flickerDataDTO.setFDutyCycle(fDutyCycle);
|
||||||
|
|
||||||
flickerDataDTO.setFChagFre(0.0f);
|
flickerDataDTO.setFChagFre(0.0f);
|
||||||
flickerDataDTO.setFChagValue(0.0f);
|
flickerDataDTO.setFChagValue(0.0f);
|
||||||
channelListDTO.setFlickerData(flickerDataDTO);
|
channelListDTO.setFlickerData(flickerDataDTO);
|
||||||
|
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(dtlsOtherList)) {
|
if (CollUtil.isNotEmpty(dtlsOtherList)) {
|
||||||
List<PqScriptDtls> phaseList = dtlsOtherList.stream().filter(x -> dtls.getPhase().equals(x.getPhase()))
|
List<PqScriptDtls> phaseList = dtlsOtherList.stream().filter(x -> dtls.getPhase().equals(x.getPhase()))
|
||||||
.sorted(Comparator.comparing(PqScriptDtls::getHarmNum))
|
.sorted(Comparator.comparing(PqScriptDtls::getHarmNum))
|
||||||
@@ -238,7 +276,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
channelListDTO.setHarmList(getHarmModels(harmList));
|
channelListDTO.setHarmList(getHarmModels(harmList));
|
||||||
channelListDTO.setHarmFlag(true);
|
channelListDTO.setHarmFlag(true);
|
||||||
}
|
}
|
||||||
//处理间谐波电压
|
//处理间谐波类型
|
||||||
List<PqScriptDtls> inHarmList = phaseList.stream().filter(x -> inHarm.equals(x.getValueType()))
|
List<PqScriptDtls> inHarmList = phaseList.stream().filter(x -> inHarm.equals(x.getValueType()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(inHarmList)) {
|
if (CollUtil.isNotEmpty(inHarmList)) {
|
||||||
@@ -251,11 +289,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (CollUtil.isNotEmpty(dipList)) {
|
if (CollUtil.isNotEmpty(dipList)) {
|
||||||
PqScriptDtls dip = dipList.get(0);
|
PqScriptDtls dip = dipList.get(0);
|
||||||
dipDataDTO.setFTransValue(dip.getTransValue());
|
dipDataDTO.setFTransValue(dip.getTransValue());
|
||||||
dipDataDTO.setFPreTime(0.0f);
|
// 1.0/频率*持续时间(周波)= 暂态持续时间(s)
|
||||||
dipDataDTO.setFRampIn(0.001f);
|
dipDataDTO.setFRetainTime(NumberUtil.round(1.0 / fFreq * dip.getRetainTime(), 3).floatValue());
|
||||||
dipDataDTO.setFRetainTime(0.0f);
|
|
||||||
dipDataDTO.setFRampOut(0.001f);
|
|
||||||
dipDataDTO.setFAfterTime(0.0f);
|
|
||||||
channelListDTO.setDipFlag(true);
|
channelListDTO.setDipFlag(true);
|
||||||
channelListDTO.setDipData(dipDataDTO);
|
channelListDTO.setDipData(dipDataDTO);
|
||||||
}
|
}
|
||||||
@@ -263,12 +298,11 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
List<PqScriptDtls> flickeRList = phaseList.stream().filter(x -> FLICKER.equals(x.getValueType()))
|
List<PqScriptDtls> flickeRList = phaseList.stream().filter(x -> FLICKER.equals(x.getValueType()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(flickeRList)) {
|
if (CollUtil.isNotEmpty(flickeRList)) {
|
||||||
PqScriptDtls flicke = flickeRList.get(0);
|
PqScriptDtls flicker = flickeRList.get(0);
|
||||||
flickerDataDTO.setWaveFluType(null);
|
|
||||||
flickerDataDTO.setWaveType(null);
|
flickerDataDTO.setFChagFre(flicker.getChagFre());
|
||||||
flickerDataDTO.setFDutyCycle(0.0f);
|
flickerDataDTO.setFChagValue(flicker.getChagValue());
|
||||||
flickerDataDTO.setFChagFre(0.0f);
|
|
||||||
flickerDataDTO.setFChagValue(0.0f);
|
|
||||||
channelListDTO.setFlickerFlag(true);
|
channelListDTO.setFlickerFlag(true);
|
||||||
channelListDTO.setFlickerData(flickerDataDTO);
|
channelListDTO.setFlickerData(flickerDataDTO);
|
||||||
}
|
}
|
||||||
@@ -285,7 +319,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
* @param phaseHarmVList
|
* @param phaseHarmVList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static List<SourceIssue.ChannelListDTO.HarmModel> getHarmModels(List<PqScriptDtls> phaseHarmVList) {
|
private List<SourceIssue.ChannelListDTO.HarmModel> getHarmModels(List<PqScriptDtls> phaseHarmVList) {
|
||||||
List<SourceIssue.ChannelListDTO.HarmModel> info = new ArrayList<>();
|
List<SourceIssue.ChannelListDTO.HarmModel> info = new ArrayList<>();
|
||||||
SourceIssue.ChannelListDTO.HarmModel harmModel;
|
SourceIssue.ChannelListDTO.HarmModel harmModel;
|
||||||
for (PqScriptDtls pqScriptDtls : phaseHarmVList) {
|
for (PqScriptDtls pqScriptDtls : phaseHarmVList) {
|
||||||
@@ -304,7 +338,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
* @param phaseHarmVList
|
* @param phaseHarmVList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static List<SourceIssue.ChannelListDTO.InharmModel> getInHarmModels(List<PqScriptDtls> phaseHarmVList) {
|
private List<SourceIssue.ChannelListDTO.InharmModel> getInHarmModels(List<PqScriptDtls> phaseHarmVList) {
|
||||||
List<SourceIssue.ChannelListDTO.InharmModel> info = new ArrayList<>();
|
List<SourceIssue.ChannelListDTO.InharmModel> info = new ArrayList<>();
|
||||||
SourceIssue.ChannelListDTO.InharmModel inHarmModel;
|
SourceIssue.ChannelListDTO.InharmModel inHarmModel;
|
||||||
for (PqScriptDtls pqScriptDtls : phaseHarmVList) {
|
for (PqScriptDtls pqScriptDtls : phaseHarmVList) {
|
||||||
|
|||||||
@@ -45,15 +45,31 @@ mybatis-plus:
|
|||||||
|
|
||||||
socket:
|
socket:
|
||||||
source:
|
source:
|
||||||
ip: 192.168.1.138
|
ip: 192.168.1.121
|
||||||
port: 61000
|
port: 61000
|
||||||
device:
|
device:
|
||||||
ip: 192.168.1.127
|
ip: 192.168.1.127
|
||||||
port: 7777
|
port: 8574
|
||||||
|
|
||||||
webSocket:
|
webSocket:
|
||||||
port: 7777
|
port: 7777
|
||||||
|
|
||||||
|
#源参数下发,暂态数据默认值
|
||||||
|
Dip:
|
||||||
|
#暂态前时间(s)
|
||||||
|
fPreTime: 2f
|
||||||
|
#写入时间(s)
|
||||||
|
fRampIn: 0.001f
|
||||||
|
#写出时间(s)
|
||||||
|
fRampOut: 0.001f
|
||||||
|
#暂态后时间(s)
|
||||||
|
fAfterTime: 3f
|
||||||
|
|
||||||
|
|
||||||
|
Flicker:
|
||||||
|
waveFluType: SQU
|
||||||
|
waveType: CPM
|
||||||
|
fDutyCycle: 50f
|
||||||
|
|
||||||
log:
|
log:
|
||||||
homeDir: D:\logs
|
homeDir: D:\logs
|
||||||
|
|||||||
Reference in New Issue
Block a user