1.微调实体信息

This commit is contained in:
wr
2024-12-20 08:55:46 +08:00
parent b0f54b0cde
commit 5dafcad3fa
8 changed files with 63 additions and 95 deletions

View File

@@ -41,10 +41,6 @@ public class SocketDevResponseService {
private final IPqScriptDtlsService scriptDtlsService;
private final IPqScriptDtlsService pqScriptDtlsService;
/**
* 所有装置通道信息
*/
List<String> moniterIdList = new ArrayList<>();
/**
* 存储的装置相序数据
*/
@@ -53,24 +49,20 @@ public class SocketDevResponseService {
* 成功结束的装置
*/
List<String> success = new ArrayList<>();
/**
* 装置名称
*/
Map<String, String> devNameMap = new HashMap<>();
/**
* 所有装置通道信息
*/
List<String> moniterIdListComm = new ArrayList<>();
/**
* 成功结束的装置
*/
List<String> successComm = new ArrayList<>();
List<String> monitorIdListComm = new ArrayList<>();
/**
* 装置名称
*/
Map<String, String> devNameMapComm = new HashMap<>();
/**
* 成功结束的装置
*/
List<String> successComm = new ArrayList<>();
/**
@@ -78,10 +70,7 @@ public class SocketDevResponseService {
*/
List<String> successXieyi = new ArrayList<>();
List<String> successXieyi3 = new ArrayList<>();
/**
* 装置名称
*/
Map<String, String> devNameMapXieyi = new HashMap<>();
public void deal(PreDetectionParam param, String msg) {
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
@@ -153,8 +142,8 @@ public class SocketDevResponseService {
String mId = JSON.parseObject(msg).get("data").toString();
successComm.add(mId);
System.out.println(successComm.size() + "=====" + moniterIdListComm.size());
if (successComm.size() == moniterIdListComm.size()) {
System.out.println(successComm.size() + "=====" + monitorIdListComm.size());
if (successComm.size() == monitorIdListComm.size()) {
//开始进行协议校验
List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
Map<String, List<PreDetection>> map = new HashMap(1);
@@ -211,7 +200,7 @@ public class SocketDevResponseService {
String type = jsonObject.get("operateCode").toString();
if (type.equals(SourceOperateCodeEnum.DEV_INIT_GATHER_02.getValue())) {
successXieyi.add(mId);
if (successXieyi.size() == moniterIdListComm.size()) {
if (successXieyi.size() == monitorIdListComm.size()) {
//协议3校验
successXieyi = new ArrayList<>();
@@ -230,8 +219,8 @@ public class SocketDevResponseService {
}
} else if (type.equals(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue())) {
successXieyi3.add(mId);
System.out.println(successXieyi3.size() + "=====" + moniterIdListComm.size());
if (successXieyi3.size() == moniterIdListComm.size()) {
System.out.println(successXieyi3.size() + "=====" + monitorIdListComm.size());
if (successXieyi3.size() == monitorIdListComm.size()) {
System.out.println("开始相序校验++++++++++");
PqScriptIssueParam issueParam = new PqScriptIssueParam();
issueParam.setPlanId(param.getPlanId());
@@ -277,15 +266,6 @@ 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());
@@ -295,7 +275,7 @@ public class SocketDevResponseService {
case SUCCESS:
devInfo.add(devData);
success.add(devData.getId());
if (success.size() == moniterIdList.size()) {
if (success.size() == monitorIdListComm.size()) {
PqScriptIssueParam sourceParam = new PqScriptIssueParam();
sourceParam.setPlanId(param.getPlanId());
sourceParam.setDevIds(param.getDevIds());
@@ -308,7 +288,6 @@ public class SocketDevResponseService {
info.addAll(devIsSource(dev, sourceIssues.get(0)));
}
}
xuClear();
String s = param.getUserPageId() + "_Source";
SocketMsg msg = new SocketMsg();
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
@@ -317,7 +296,7 @@ public class SocketDevResponseService {
map.put("sourceId", sourceIssues.get(0).getSourceId());
msg.setData(JSON.toJSONString(map));
SocketManager.sendMsg(s, JSON.toJSONString(msg));
//向前端推送消息
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
socketMsg.setData(JSON.toJSONString(info));
@@ -425,28 +404,24 @@ public class SocketDevResponseService {
return compareDev;
}
public void xuClear() {
this.moniterIdList.clear();
this.devInfo.clear();
this.success.clear();
}
/**
* 初始化集合
*/
public void initList(PreDetectionParam param) {
this.moniterIdListComm = new ArrayList<>();
this.monitorIdListComm = new ArrayList<>();
this.successComm = new ArrayList<>();
this.devNameMapComm = new HashMap<>();
this.successXieyi = new ArrayList<>();
this.successXieyi3 = new ArrayList<>();
this.devNameMapXieyi = new HashMap<>();
this.devInfo = new ArrayList<>();
this.success = new ArrayList<>();
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
this.moniterIdListComm = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
this.monitorIdListComm = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
.map(PreDetection.MonitorListDTO::getLineId)
.collect(Collectors.toList());
this.devNameMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevName));
}

View File

@@ -33,7 +33,7 @@ public class PreDetectionParam {
private String scriptId;
/**
* 检测脚本Id
* 源id
*/
private String sourceId;
}

View File

@@ -87,6 +87,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
}
private void sendYtxSocket(PreDetectionParam param) {
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
.eq(AdPlanSource::getPlanId, param.getPlanId())
@@ -95,20 +96,13 @@ public class PreDetectionServiceImpl implements PreDetectionService {
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
if (ObjectUtil.isNotNull(sourceParam)) {
//开始组装socket报文请求头
SocketMsg msg ;
String s = param.getUserPageId() + "_Source";
//PQC600A_192.168.1.133_6806
Channel channel = SocketManager.getChannelByUserId(s);
socketDevResponseService.xuClear();
socketDevResponseService.initList(param);
msg= new SocketMsg();
SocketMsg msg = new SocketMsg();
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
msg.setData(JSON.toJSONString(sourceParam));
param.setSourceId(sourceParam.getSourceId());
NettyClient.socketClient(ip, port, param.getUserPageId(), JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
} else {
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
}

View File

@@ -92,7 +92,6 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
socketResponseService.xuClear();
// 处理异常,例如记录日志、关闭连接等
cause.printStackTrace();
// 根据异常类型进行不同的处理

View File

@@ -53,12 +53,12 @@ public class PqDev extends BaseEntity implements Serializable {
/**
* 额定电压V
*/
private Float devVolt;
private Double devVolt;
/**
* 额定电流A
*/
private Float devCurr;
private Double devCurr;
/**
* 设备厂家,字典表

View File

@@ -151,7 +151,7 @@ public class PqScriptController extends BaseController {
String jsonString = JSON.toJSONString(sourceIssue,SerializerFeature.WriteNullStringAsEmpty);
System.out.println();
}
String jsonString = JSON.toJSONString(sourceIssues, SerializerFeature.WriteMapNullValue);
String jsonString =sourceIssues.get(0).toString();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sourceIssues, methodDescribe);
}
}

View File

@@ -49,12 +49,12 @@ public class PqScriptDtls implements Serializable {
/**
* 值
*/
private Float value;
private Double value;
/**
* 相角
*/
private Float angle;
private Double angle;
/**
* (间)谐波次数
@@ -66,25 +66,25 @@ public class PqScriptDtls implements Serializable {
* 暂态幅度(%
*/
@TableField("TransValue")
private Float transValue;
private Double transValue;
/**
* 持续时间(周波)
*/
@TableField("RetainTime")
private Float retainTime;
private Double retainTime;
/**
* 变动频度(次/min
*/
@TableField("ChagFre")
private Float chagFre;
private Double chagFre;
/**
* 变动量(%
*/
@TableField("ChagValue")
private Float chagValue;
private Double chagValue;
/**
* 状态0-不启用 1-启用

View File

@@ -43,19 +43,19 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
private final static String DIP = "Dip";
private final static String FLICKER = "Flicker";
@Value("${Dip.fPreTime}")
private Float fPreTime;
private Double fPreTime;
@Value("${Dip.fRampIn}")
private Float fRampIn;
private Double fRampIn;
@Value("${Dip.fRampOut}")
private Float fRampOut;
private Double fRampOut;
@Value("${Dip.fAfterTime}")
private Float fAfterTime;
private Double fAfterTime;
@Value("${Flicker.waveFluType}")
private String waveFluType;
@Value("${Flicker.waveType}")
private String waveType;
@Value("${Flicker.fDutyCycle}")
private Float fDutyCycle;
private Double fDutyCycle;
private final IPqDevService pqDevService;
@@ -109,12 +109,12 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
);
//额定电压信息
Set<Float> voltSet = list.stream().map(PqDev::getDevVolt).collect(Collectors.toSet());
Set<Double> voltSet = list.stream().map(PqDev::getDevVolt).collect(Collectors.toSet());
//额定电流信息
Set<Float> currSet = list.stream().map(PqDev::getDevCurr).collect(Collectors.toSet());
Set<Double> currSet = list.stream().map(PqDev::getDevCurr).collect(Collectors.toSet());
if (voltSet.size() == 1 && currSet.size() == 1) {
Float volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
Float curr = currSet.stream().collect(Collectors.toList()).stream().findFirst().get();
Double volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
Double curr = currSet.stream().collect(Collectors.toList()).stream().findFirst().get();
List<PqScriptDtls> pqScriptDtls = this.pqScriptDtls(param.getScriptId(),param.getIsPhaseSequence(), volt, curr);
if (CollUtil.isNotEmpty(pqScriptDtls)) {
/**
@@ -182,7 +182,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
return sourceIssues;
}
private List<PqScriptDtls> pqScriptDtls(String scriptId,Boolean isPhaseSequence,Float volt, Float curr) {
private List<PqScriptDtls> pqScriptDtls(String scriptId,Boolean isPhaseSequence,Double volt, Double curr) {
List<PqScriptDtls> pqScriptDtls;
if(isPhaseSequence){
pqScriptDtls = this.list(new MPJLambdaWrapper<PqScriptDtls>()
@@ -226,7 +226,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
List<PqScriptDtls> dtlsOtherList,
String harm,
String inHarm,
Float fFreq,
Double fFreq,
String code,
List<SourceIssue.ChannelListDTO> channelListDTOS) {
for (PqScriptDtls dtls : dtlsList) {
@@ -243,8 +243,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
channelListDTO.setInharmList(new ArrayList<>());
//暂态数据
SourceIssue.ChannelListDTO.DipDataDTO dipDataDTO = new SourceIssue.ChannelListDTO.DipDataDTO();
dipDataDTO.setFTransValue(0.0f);
dipDataDTO.setFRetainTime(0.0f);
dipDataDTO.setFTransValue(0.0);
dipDataDTO.setFRetainTime(0.0);
dipDataDTO.setFPreTime(fPreTime);
dipDataDTO.setFRampIn(fRampIn);
@@ -259,8 +259,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
flickerDataDTO.setWaveType(waveType);
flickerDataDTO.setFDutyCycle(fDutyCycle);
flickerDataDTO.setFChagFre(0.0f);
flickerDataDTO.setFChagValue(0.0f);
flickerDataDTO.setFChagFre(0.0);
flickerDataDTO.setFChagValue(0.0);
channelListDTO.setFlickerData(flickerDataDTO);
@@ -290,7 +290,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
PqScriptDtls dip = dipList.get(0);
dipDataDTO.setFTransValue(dip.getTransValue());
// 1.0/频率*持续时间(周波)= 暂态持续时间s
dipDataDTO.setFRetainTime(NumberUtil.round(1.0 / fFreq * dip.getRetainTime(), 3).floatValue());
dipDataDTO.setFRetainTime(NumberUtil.round(1.0 / fFreq * dip.getRetainTime(), 3).doubleValue());
channelListDTO.setDipFlag(true);
channelListDTO.setDipData(dipDataDTO);
}