Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 826970357e | |||
| 11713e9b68 | |||
| 6d3a1dd735 | |||
| 72150a3acc | |||
| 19999a582e | |||
| 7293d9b84d | |||
| 40a6cd608c | |||
| 1fb08ab66c | |||
| c6e938e7a0 | |||
| 52d2dda01c | |||
| f9926d16f8 | |||
| 87fc735969 | |||
| cc22afd877 | |||
| 2ec0024d0f | |||
| f0a22192fb | |||
| 98b901e6ab | |||
| da3b99f663 | |||
| 04fd2409cf | |||
| b014aa7c8c | |||
| 67be8404d5 | |||
| 19f1c54ade | |||
| f211713f2e | |||
| d9708580db | |||
| af96a91303 | |||
| 4006d26d5f | |||
| 885fc36739 | |||
| eed276c9b3 | |||
| 24cf6e8d56 |
@@ -82,6 +82,10 @@ public class RspDataDto {
|
|||||||
|
|
||||||
@SerializedName("Capacity_A")
|
@SerializedName("Capacity_A")
|
||||||
private Double capacityA;
|
private Double capacityA;
|
||||||
|
|
||||||
|
@SerializedName("StatCycle")
|
||||||
|
@ApiModelProperty("接线方式")
|
||||||
|
private Integer StatCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.access.pojo.dto;
|
package com.njcn.access.pojo.dto;
|
||||||
|
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -17,39 +18,49 @@ import java.util.List;
|
|||||||
public class AutoDataDto {
|
public class AutoDataDto {
|
||||||
|
|
||||||
@SerializedName("Mid")
|
@SerializedName("Mid")
|
||||||
|
@JsonProperty("Mid")
|
||||||
private Integer mid;
|
private Integer mid;
|
||||||
|
|
||||||
@SerializedName("Did")
|
@SerializedName("Did")
|
||||||
|
@JsonProperty("Did")
|
||||||
@ApiModelProperty("逻辑设备 治理逻辑设备为1 电能质量设备为2")
|
@ApiModelProperty("逻辑设备 治理逻辑设备为1 电能质量设备为2")
|
||||||
private Integer did;
|
private Integer did;
|
||||||
|
|
||||||
@SerializedName("Pri")
|
@SerializedName("Pri")
|
||||||
|
@JsonProperty("Pri")
|
||||||
private Integer pri;
|
private Integer pri;
|
||||||
|
|
||||||
@SerializedName("Type")
|
@SerializedName("Type")
|
||||||
|
@JsonProperty("Type")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@SerializedName("Msg")
|
@SerializedName("Msg")
|
||||||
|
@JsonProperty("Msg")
|
||||||
private Msg msg;
|
private Msg msg;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Msg{
|
public static class Msg{
|
||||||
|
|
||||||
@SerializedName("Cldid")
|
@SerializedName("Cldid")
|
||||||
|
@JsonProperty("Cldid")
|
||||||
@ApiModelProperty("逻辑子设备 治理逻辑设备为0 电能质量设备为1、2")
|
@ApiModelProperty("逻辑子设备 治理逻辑设备为0 电能质量设备为1、2")
|
||||||
private Integer clDid;
|
private Integer clDid;
|
||||||
|
|
||||||
@SerializedName("DataType")
|
@SerializedName("DataType")
|
||||||
|
@JsonProperty("DataType")
|
||||||
private Integer dataType;
|
private Integer dataType;
|
||||||
|
|
||||||
@SerializedName("DataAttr")
|
@SerializedName("DataAttr")
|
||||||
|
@JsonProperty("DataAttr")
|
||||||
@ApiModelProperty("数据属性:无-0、实时-1、统计-2")
|
@ApiModelProperty("数据属性:无-0、实时-1、统计-2")
|
||||||
private Integer dataAttr;
|
private Integer dataAttr;
|
||||||
|
|
||||||
@SerializedName("DsNameIdx")
|
@SerializedName("DsNameIdx")
|
||||||
|
@JsonProperty("DsNameIdx")
|
||||||
private Integer dsNameIdx;
|
private Integer dsNameIdx;
|
||||||
|
|
||||||
@SerializedName("DataArray")
|
@SerializedName("DataArray")
|
||||||
|
@JsonProperty("DataArray")
|
||||||
private List<DataArray> dataArray;
|
private List<DataArray> dataArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,95 +68,119 @@ public class AutoDataDto {
|
|||||||
public static class DataArray{
|
public static class DataArray{
|
||||||
|
|
||||||
@SerializedName("DataAttr")
|
@SerializedName("DataAttr")
|
||||||
|
@JsonProperty("DataAttr")
|
||||||
@ApiModelProperty("数据属性 -1-无 0-Rt(实时) 1-Max 2-Min 3-Avg 4-Cp95")
|
@ApiModelProperty("数据属性 -1-无 0-Rt(实时) 1-Max 2-Min 3-Avg 4-Cp95")
|
||||||
private Integer dataAttr;
|
private Integer dataAttr;
|
||||||
|
|
||||||
@SerializedName("DataTimeSec")
|
@SerializedName("DataTimeSec")
|
||||||
|
@JsonProperty("DataTimeSec")
|
||||||
private Long dataTimeSec;
|
private Long dataTimeSec;
|
||||||
|
|
||||||
@SerializedName("DataTimeUSec")
|
@SerializedName("DataTimeUSec")
|
||||||
|
@JsonProperty("DataTimeUSec")
|
||||||
private Integer dataTimeUSec;
|
private Integer dataTimeUSec;
|
||||||
|
|
||||||
@SerializedName("DataTag")
|
@SerializedName("DataTag")
|
||||||
|
@JsonProperty("DataTag")
|
||||||
@ApiModelProperty("数据是否参与合格率统计")
|
@ApiModelProperty("数据是否参与合格率统计")
|
||||||
private Integer dataTag;
|
private Integer dataTag;
|
||||||
|
|
||||||
@SerializedName("Code")
|
@SerializedName("Code")
|
||||||
|
@JsonProperty("Code")
|
||||||
@ApiModelProperty("事件码")
|
@ApiModelProperty("事件码")
|
||||||
private Integer code;
|
private Integer code;
|
||||||
|
|
||||||
@SerializedName("Data")
|
@SerializedName("Data")
|
||||||
|
@JsonProperty("Data")
|
||||||
private String data;
|
private String data;
|
||||||
|
|
||||||
@SerializedName("PrjName")
|
@SerializedName("PrjName")
|
||||||
|
@JsonProperty("PrjName")
|
||||||
@ApiModelProperty("工程名称")
|
@ApiModelProperty("工程名称")
|
||||||
private String prjName;
|
private String prjName;
|
||||||
|
|
||||||
@SerializedName("PrjTimeStart")
|
@SerializedName("PrjTimeStart")
|
||||||
|
@JsonProperty("PrjTimeStart")
|
||||||
@ApiModelProperty("装置启动时间")
|
@ApiModelProperty("装置启动时间")
|
||||||
private Long prjTimeStart;
|
private Long prjTimeStart;
|
||||||
|
|
||||||
@SerializedName("PrjTimeEnd")
|
@SerializedName("PrjTimeEnd")
|
||||||
|
@JsonProperty("PrjTimeEnd")
|
||||||
@ApiModelProperty("装置结束时间")
|
@ApiModelProperty("装置结束时间")
|
||||||
private Long prjTimeEnd;
|
private Long prjTimeEnd;
|
||||||
|
|
||||||
@SerializedName("PrjDataPath")
|
@SerializedName("PrjDataPath")
|
||||||
|
@JsonProperty("PrjDataPath")
|
||||||
@ApiModelProperty("装置数据路径")
|
@ApiModelProperty("装置数据路径")
|
||||||
private String prjDataPath;
|
private String prjDataPath;
|
||||||
|
|
||||||
@SerializedName("DevType")
|
@SerializedName("DevType")
|
||||||
|
@JsonProperty("DevType")
|
||||||
@ApiModelProperty("装置型号")
|
@ApiModelProperty("装置型号")
|
||||||
private String devType;
|
private String devType;
|
||||||
|
|
||||||
@SerializedName("DevMac")
|
@SerializedName("DevMac")
|
||||||
|
@JsonProperty("DevMac")
|
||||||
@ApiModelProperty("装置mac地址")
|
@ApiModelProperty("装置mac地址")
|
||||||
private String devMac;
|
private String devMac;
|
||||||
|
|
||||||
@SerializedName("AppVersion")
|
@SerializedName("AppVersion")
|
||||||
|
@JsonProperty("AppVersion")
|
||||||
@ApiModelProperty("装置程序版本")
|
@ApiModelProperty("装置程序版本")
|
||||||
private String appVersion;
|
private String appVersion;
|
||||||
|
|
||||||
@SerializedName("Cldid")
|
@SerializedName("Cldid")
|
||||||
|
@JsonProperty("Cldid")
|
||||||
@ApiModelProperty("逻辑子设备id")
|
@ApiModelProperty("逻辑子设备id")
|
||||||
private Integer clDid;
|
private Integer clDid;
|
||||||
|
|
||||||
@SerializedName("StatCycle")
|
@SerializedName("StatCycle")
|
||||||
|
@JsonProperty("StatCycle")
|
||||||
@ApiModelProperty("统计间隔")
|
@ApiModelProperty("统计间隔")
|
||||||
private Integer statCycle;
|
private Integer statCycle;
|
||||||
|
|
||||||
@SerializedName("VolGrade")
|
@SerializedName("VolGrade")
|
||||||
|
@JsonProperty("VolGrade")
|
||||||
@ApiModelProperty("电压等级")
|
@ApiModelProperty("电压等级")
|
||||||
private Float volGrade;
|
private Float volGrade;
|
||||||
|
|
||||||
@SerializedName("VolConType")
|
@SerializedName("VolConType")
|
||||||
|
@JsonProperty("VolConType")
|
||||||
@ApiModelProperty("电压接线方式(0-星型, 1-角型, 2-V型)")
|
@ApiModelProperty("电压接线方式(0-星型, 1-角型, 2-V型)")
|
||||||
private Integer volConType;
|
private Integer volConType;
|
||||||
|
|
||||||
@SerializedName("CurConSel")
|
@SerializedName("CurConSel")
|
||||||
|
@JsonProperty("CurConSel")
|
||||||
@ApiModelProperty("电流接线方式(0-正常, 1-合成IB, 2-合成IC)")
|
@ApiModelProperty("电流接线方式(0-正常, 1-合成IB, 2-合成IC)")
|
||||||
private Integer curConSel;
|
private Integer curConSel;
|
||||||
|
|
||||||
@SerializedName("PtRatio")
|
@SerializedName("PtRatio")
|
||||||
|
@JsonProperty("PtRatio")
|
||||||
@ApiModelProperty("PT变比")
|
@ApiModelProperty("PT变比")
|
||||||
private Integer ptRatio;
|
private Integer ptRatio;
|
||||||
|
|
||||||
@SerializedName("CtRatio")
|
@SerializedName("CtRatio")
|
||||||
|
@JsonProperty("CtRatio")
|
||||||
@ApiModelProperty("ct变比")
|
@ApiModelProperty("ct变比")
|
||||||
private Integer ctRatio;
|
private Integer ctRatio;
|
||||||
|
|
||||||
@SerializedName("CapacitySscb")
|
@SerializedName("CapacitySscb")
|
||||||
|
@JsonProperty("CapacitySscb")
|
||||||
@ApiModelProperty("基准短路容量")
|
@ApiModelProperty("基准短路容量")
|
||||||
private Float capacitySscb;
|
private Float capacitySscb;
|
||||||
|
|
||||||
@SerializedName("CapacitySscmin")
|
@SerializedName("CapacitySscmin")
|
||||||
|
@JsonProperty("CapacitySscmin")
|
||||||
@ApiModelProperty("最小短路容量")
|
@ApiModelProperty("最小短路容量")
|
||||||
private Float capacitySscmin;
|
private Float capacitySscmin;
|
||||||
|
|
||||||
@SerializedName("CapacitySt")
|
@SerializedName("CapacitySt")
|
||||||
|
@JsonProperty("CapacitySt")
|
||||||
@ApiModelProperty("供电设备容量")
|
@ApiModelProperty("供电设备容量")
|
||||||
private Float capacitySt;
|
private Float capacitySt;
|
||||||
|
|
||||||
@SerializedName("CapacitySi")
|
@SerializedName("CapacitySi")
|
||||||
|
@JsonProperty("CapacitySi")
|
||||||
@ApiModelProperty("用户协议容量")
|
@ApiModelProperty("用户协议容量")
|
||||||
private Float capacitySi;
|
private Float capacitySi;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,17 +328,18 @@ public class MqttMessageHandler {
|
|||||||
onlineLogsService.updateById(record);
|
onlineLogsService.updateById(record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//接入后系统重置装置心跳
|
|
||||||
redisUtil.saveByKeyWithExpire("MQTT:" + nDid, Instant.now().toEpochMilli(),180L);
|
|
||||||
//修改redis的mid
|
|
||||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
|
||||||
redisUtil.saveByKeyWithExpire("online" + nDid,"online",10L);
|
|
||||||
//询问设备软件信息
|
//询问设备软件信息
|
||||||
askDevData(nDid,version,1,mid);
|
askDevData(nDid,version,1,mid);
|
||||||
//更新治理监测点信息和设备容量
|
//更新治理监测点信息和设备容量
|
||||||
askDevData(nDid,version,2,(res.getMid()+1));
|
askDevData(nDid,version,2,(res.getMid()+1));
|
||||||
//更新电网侧、负载侧监测点信息
|
//更新电网侧、负载侧监测点信息
|
||||||
askDevData(nDid,version,3,(res.getMid()+1));
|
askDevData(nDid,version,3,(res.getMid()+1));
|
||||||
|
//接入后系统重置装置心跳
|
||||||
|
redisUtil.saveByKeyWithExpire("MQTT:" + nDid, Instant.now().toEpochMilli(),180L);
|
||||||
|
//修改redis的mid
|
||||||
|
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
||||||
|
//接入成功标识
|
||||||
|
redisUtil.saveByKeyWithExpire("online" + nDid,"online",10L);
|
||||||
//录波任务倒计时
|
//录波任务倒计时
|
||||||
redisUtil.saveByKeyWithExpire("startFile:" + nDid,null,60L);
|
redisUtil.saveByKeyWithExpire("startFile:" + nDid,null,60L);
|
||||||
} else {
|
} else {
|
||||||
@@ -406,6 +407,7 @@ public class MqttMessageHandler {
|
|||||||
csLineParam.setPtRatio(item.getPtRatio());
|
csLineParam.setPtRatio(item.getPtRatio());
|
||||||
csLineParam.setCtRatio(item.getCtRatio());
|
csLineParam.setCtRatio(item.getCtRatio());
|
||||||
csLineParam.setConType(item.getConType());
|
csLineParam.setConType(item.getConType());
|
||||||
|
csLineParam.setLineInterval(item.getStatCycle());
|
||||||
csLineFeignClient.updateLine(csLineParam);
|
csLineFeignClient.updateLine(csLineParam);
|
||||||
//生成监测点限值
|
//生成监测点限值
|
||||||
Overlimit overlimit = COverlimitUtil.globalAssemble(item.getVolGrade().floatValue(),10f,10f,10f,0,0);
|
Overlimit overlimit = COverlimitUtil.globalAssemble(item.getVolGrade().floatValue(),10f,10f,10f,0,0);
|
||||||
@@ -429,6 +431,7 @@ public class MqttMessageHandler {
|
|||||||
csLineParam.setPtRatio(item.getPtRatio());
|
csLineParam.setPtRatio(item.getPtRatio());
|
||||||
csLineParam.setCtRatio(item.getCtRatio());
|
csLineParam.setCtRatio(item.getCtRatio());
|
||||||
csLineParam.setConType(item.getConType());
|
csLineParam.setConType(item.getConType());
|
||||||
|
csLineParam.setLineInterval(item.getStatCycle());
|
||||||
csLineFeignClient.updateLine(csLineParam);
|
csLineFeignClient.updateLine(csLineParam);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -98,77 +97,92 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
|||||||
String expiredKey = message.toString();
|
String expiredKey = message.toString();
|
||||||
if(expiredKey.startsWith("MQTT:")){
|
if(expiredKey.startsWith("MQTT:")){
|
||||||
String nDid = expiredKey.split(":")[1];
|
String nDid = expiredKey.split(":")[1];
|
||||||
String version = csTopicService.getVersion(nDid);
|
executeMainTask(nDid);
|
||||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
|
||||||
executeMainTask(scheduler,nDid,version);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//主任务
|
//主任务
|
||||||
//1.装置心跳断连
|
//1.装置心跳断连
|
||||||
//2.MQTT客户端不在线
|
//2.MQTT客户端不在线
|
||||||
private void executeMainTask(ScheduledExecutorService scheduler, String nDid, String version) {
|
private void executeMainTask(String nDid) {
|
||||||
log.info("{}->装置离线", nDid);
|
log.info("{}->装置离线", nDid);
|
||||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||||
logDto.setUserName("运维管理员");
|
logDto.setUserName("运维管理员");
|
||||||
logDto.setLoginName("njcnyw");
|
logDto.setLoginName("njcnyw");
|
||||||
//判断mqtt
|
|
||||||
String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
|
|
||||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
|
||||||
//心跳异常,但是客户端在线,则发送接入请求
|
|
||||||
if (mqttClient) {
|
|
||||||
csDeviceService.devAccessAskTemplate(nDid,version,1);
|
|
||||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
|
||||||
try {
|
|
||||||
Thread.sleep(5000);
|
|
||||||
Object object = redisUtil.getObjectByKey("online" + nDid);
|
|
||||||
if (Objects.nonNull(object)) {
|
|
||||||
scheduler.shutdown();
|
|
||||||
logDto.setOperate(nDid + "客户端在线重连成功");
|
|
||||||
} else {
|
|
||||||
//装置下线
|
//装置下线
|
||||||
csEquipmentDeliveryService.updateRunStatusBynDid(nDid, AccessEnum.OFFLINE.getCode());
|
csEquipmentDeliveryService.updateRunStatusBynDid(nDid, AccessEnum.OFFLINE.getCode());
|
||||||
//装置调整为注册状态
|
//装置调整为注册状态
|
||||||
csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.REGISTERED.getCode());
|
csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.REGISTERED.getCode());
|
||||||
//startScheduledTask(scheduler,nDid,version);
|
|
||||||
//logDto.setOperate(nDid +"客户端离线进入定时任务");
|
|
||||||
logDto.setOperate(nDid +"装置离线");
|
logDto.setOperate(nDid +"装置离线");
|
||||||
sendMessage(nDid);
|
sendMessage(nDid);
|
||||||
|
|
||||||
//记录装置掉线时间
|
//记录装置掉线时间
|
||||||
CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
||||||
record.setOfflineTime(LocalDateTime.now());
|
record.setOfflineTime(LocalDateTime.now());
|
||||||
onlineLogsService.updateById(record);
|
onlineLogsService.updateById(record);
|
||||||
|
|
||||||
scheduler.shutdown();
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
scheduler.shutdown();
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
csLogsFeignClient.addUserLog(logDto);
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
}
|
}
|
||||||
//客户端不在线则修改装置状态,进入定时任务
|
|
||||||
else {
|
|
||||||
//装置下线
|
|
||||||
csEquipmentDeliveryService.updateRunStatusBynDid(nDid, AccessEnum.OFFLINE.getCode());
|
|
||||||
//装置调整为注册状态
|
|
||||||
csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.REGISTERED.getCode());
|
|
||||||
logDto.setOperate(nDid +"主任务执行失败,装置下线");
|
|
||||||
//logDto.setOperate(nDid +"主任务执行失败,装置下线,进入定时任务");
|
|
||||||
csLogsFeignClient.addUserLog(logDto);
|
|
||||||
//log.info("客户端离线进入定时任务...");
|
|
||||||
//startScheduledTask(scheduler,nDid,version);
|
|
||||||
sendMessage(nDid);
|
|
||||||
|
|
||||||
//记录装置掉线时间
|
//主任务
|
||||||
CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
//1.装置心跳断连
|
||||||
record.setOfflineTime(LocalDateTime.now());
|
//2.MQTT客户端不在线
|
||||||
onlineLogsService.updateById(record);
|
// private void executeMainTask(String nDid, String version) {
|
||||||
|
// ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||||
scheduler.shutdown();
|
// log.info("{}->装置离线", nDid);
|
||||||
}
|
// DeviceLogDTO logDto = new DeviceLogDTO();
|
||||||
}
|
// logDto.setUserName("运维管理员");
|
||||||
|
// logDto.setLoginName("njcnyw");
|
||||||
|
// //判断mqtt
|
||||||
|
// String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
|
||||||
|
// boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||||
|
// //心跳异常,但是客户端在线,则发送接入请求
|
||||||
|
// if (mqttClient) {
|
||||||
|
// csDeviceService.devAccessAskTemplate(nDid,version,1);
|
||||||
|
// redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
||||||
|
// try {
|
||||||
|
// Thread.sleep(5000);
|
||||||
|
// Object object = redisUtil.getObjectByKey("online" + nDid);
|
||||||
|
// if (Objects.nonNull(object)) {
|
||||||
|
// scheduler.shutdown();
|
||||||
|
// logDto.setOperate(nDid + "客户端在线重连成功");
|
||||||
|
// } else {
|
||||||
|
// //装置下线
|
||||||
|
// csEquipmentDeliveryService.updateRunStatusBynDid(nDid, AccessEnum.OFFLINE.getCode());
|
||||||
|
// //装置调整为注册状态
|
||||||
|
// csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.REGISTERED.getCode());
|
||||||
|
// logDto.setOperate(nDid +"装置离线");
|
||||||
|
// sendMessage(nDid);
|
||||||
|
//
|
||||||
|
// //记录装置掉线时间
|
||||||
|
// CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
||||||
|
// record.setOfflineTime(LocalDateTime.now());
|
||||||
|
// onlineLogsService.updateById(record);
|
||||||
|
//
|
||||||
|
// scheduler.shutdown();
|
||||||
|
// }
|
||||||
|
// } catch (InterruptedException e) {
|
||||||
|
// scheduler.shutdown();
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
|
// csLogsFeignClient.addUserLog(logDto);
|
||||||
|
// }
|
||||||
|
// //客户端不在线则修改装置状态,进入定时任务
|
||||||
|
// else {
|
||||||
|
// //装置下线
|
||||||
|
// csEquipmentDeliveryService.updateRunStatusBynDid(nDid, AccessEnum.OFFLINE.getCode());
|
||||||
|
// //装置调整为注册状态
|
||||||
|
// csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.REGISTERED.getCode());
|
||||||
|
// logDto.setOperate(nDid +"主任务执行失败,装置下线");
|
||||||
|
// csLogsFeignClient.addUserLog(logDto);
|
||||||
|
// sendMessage(nDid);
|
||||||
|
//
|
||||||
|
// //记录装置掉线时间
|
||||||
|
// CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
||||||
|
// record.setOfflineTime(LocalDateTime.now());
|
||||||
|
// onlineLogsService.updateById(record);
|
||||||
|
//
|
||||||
|
// scheduler.shutdown();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
private void startScheduledTask(ScheduledExecutorService scheduler, String nDid, String version) {
|
private void startScheduledTask(ScheduledExecutorService scheduler, String nDid, String version) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
|||||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.system.api.DictTreeFeignClient;
|
import com.njcn.system.api.DictTreeFeignClient;
|
||||||
import com.njcn.system.enums.DicTreeEnum;
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
@@ -45,7 +45,7 @@ public class AccessApplicationRunner implements ApplicationRunner {
|
|||||||
public void run(ApplicationArguments args) {
|
public void run(ApplicationArguments args) {
|
||||||
//项目启动60s后发起自动接入
|
//项目启动60s后发起自动接入
|
||||||
Runnable task = () -> {
|
Runnable task = () -> {
|
||||||
log.info("系统重启,所有符合条件的装置全部接入!");
|
log.info("系统重启,所有符合条件的装置发起接入!");
|
||||||
List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getOnlineDev();
|
List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getOnlineDev();
|
||||||
if (CollUtil.isNotEmpty(list)) {
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(10);
|
ExecutorService executor = Executors.newFixedThreadPool(10);
|
||||||
@@ -87,20 +87,28 @@ public class AccessApplicationRunner implements ApplicationRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void accessDev(List<CsEquipmentDeliveryPO> list) {
|
public void accessDev(List<CsEquipmentDeliveryPO> list) {
|
||||||
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
|
try {
|
||||||
list.forEach(item->{
|
list.forEach(item->{
|
||||||
System.out.println(Thread.currentThread().getName() + ": reboot : nDid : " + item.getNdid());
|
System.out.println(Thread.currentThread().getName() + ": reboot : nDid : " + item.getNdid());
|
||||||
String version = csTopicService.getVersion(item.getNdid());
|
|
||||||
if (!Objects.isNull(version)){
|
|
||||||
//判断设备类型 便携式设备需要特殊处理 未注册的要先注册、再接入;已注册的直接重新接入
|
//判断设备类型 便携式设备需要特殊处理 未注册的要先注册、再接入;已注册的直接重新接入
|
||||||
String code = dictTreeFeignClient.queryById(item.getDevModel()).getData().getCode();
|
String code = dictTreeFeignClient.queryById(item.getDevType()).getData().getCode();
|
||||||
if (Objects.equals(code,DicTreeEnum.PQV_520.getCode()) && Objects.equals(item.getStatus(),1)) {
|
if (Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && Objects.equals(item.getStatus(),1)) {
|
||||||
csDeviceService.wlDevRegister(item.getNdid());
|
//csDeviceService.wlDevRegister(item.getNdid());
|
||||||
|
log.info("请先手动注册、接入");
|
||||||
} else {
|
} else {
|
||||||
csDeviceService.devAccessAskTemplate(item.getNdid(),version,1);
|
String version = csTopicService.getVersion(item.getNdid());
|
||||||
|
if (Objects.isNull(version)) {
|
||||||
|
version = "V1";
|
||||||
|
}
|
||||||
|
csDeviceService.autoAccess(item.getNdid(),version,1);
|
||||||
}
|
}
|
||||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + item.getNdid(),1);
|
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + item.getNdid(),1);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
|||||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.system.api.DictTreeFeignClient;
|
import com.njcn.system.api.DictTreeFeignClient;
|
||||||
import com.njcn.system.enums.DicTreeEnum;
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
@@ -16,6 +16,7 @@ import org.springframework.boot.ApplicationRunner;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
@@ -44,57 +45,72 @@ public class AutoAccessTimer implements ApplicationRunner {
|
|||||||
if (CollUtil.isNotEmpty(list)) {
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(10);
|
ExecutorService executor = Executors.newFixedThreadPool(10);
|
||||||
// 将任务平均分配给10个子列表
|
// 将任务平均分配给10个子列表
|
||||||
List<List<CsEquipmentDeliveryPO>> subLists = new ArrayList<>();
|
List<List<CsEquipmentDeliveryPO>> subLists = CollUtil.split(list, 10);
|
||||||
int partitionSize = list.size() / 10;
|
// List<List<CsEquipmentDeliveryPO>> subLists = new ArrayList<>();
|
||||||
for (int i = 0; i < 10; i++) {
|
// int partitionSize = list.size() / 10;
|
||||||
int start = i * partitionSize;
|
// for (int i = 0; i < 10; i++) {
|
||||||
int end = (i == 9) ? list.size() : start + partitionSize;
|
// int start = i * partitionSize;
|
||||||
subLists.add(list.subList(start, end));
|
// int end = (i == 9) ? list.size() : start + partitionSize;
|
||||||
}
|
// subLists.add(list.subList(start, end));
|
||||||
|
// }
|
||||||
// 创建一个ExecutorService来处理这些任务
|
// 创建一个ExecutorService来处理这些任务
|
||||||
List<Future<Void>> futures = new ArrayList<>();
|
List<Future<Void>> futures = new ArrayList<>();
|
||||||
// 提交任务给线程池执行
|
// 提交任务给线程池执行
|
||||||
for (int i = 0; i < 10; i++) {
|
// for (int i = 0; i < 10; i++) {
|
||||||
int index = i;
|
// int index = i;
|
||||||
futures.add(executor.submit(new Callable<Void>() {
|
// futures.add(executor.submit(() -> {
|
||||||
@Override
|
// accessDev(subLists.get(index));
|
||||||
public Void call() {
|
// return null;
|
||||||
accessDev(subLists.get(index));
|
// }));
|
||||||
|
// }
|
||||||
|
for (List<CsEquipmentDeliveryPO> subList : subLists) {
|
||||||
|
futures.add(executor.submit(() -> {
|
||||||
|
accessDev(subList);
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
// 等待所有任务完成
|
// 等待所有任务完成
|
||||||
for (Future<Void> future : futures) {
|
for (Future<Void> future : futures) {
|
||||||
try {
|
try {
|
||||||
future.get();
|
future.get();
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
Thread.currentThread().interrupt();
|
||||||
|
log.error("任务被中断", e);
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
log.error("任务执行异常", e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭ExecutorService
|
// 关闭ExecutorService
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//第一次执行的时间为120s,然后每隔120s执行一次
|
//第一次执行的时间为120s,然后在前一个任务执行完毕后,等待120s再执行下一个任务
|
||||||
scheduler.scheduleAtFixedRate(task,AUTO_TIME,AUTO_TIME,TimeUnit.SECONDS);
|
scheduler.scheduleWithFixedDelay(task, AUTO_TIME, AUTO_TIME, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void accessDev(List<CsEquipmentDeliveryPO> list) {
|
public void accessDev(List<CsEquipmentDeliveryPO> list) {
|
||||||
list.forEach(item->{
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
System.out.println(Thread.currentThread().getName() + ": reboot : nDid : " + item.getNdid());
|
try {
|
||||||
String version = csTopicService.getVersion(item.getNdid());
|
list.forEach(item -> {
|
||||||
if (!Objects.isNull(version)){
|
System.out.println(Thread.currentThread().getName() + ": auto : nDid : " + item.getNdid());
|
||||||
//判断设备类型 便携式设备需要特殊处理 未注册的要先注册、再接入;已注册的直接重新接入
|
//判断设备类型 便携式设备需要特殊处理 未注册的要先注册、再接入;已注册的直接重新接入
|
||||||
String code = dictTreeFeignClient.queryById(item.getDevModel()).getData().getCode();
|
String code = dictTreeFeignClient.queryById(item.getDevType()).getData().getCode();
|
||||||
if (Objects.equals(code, DicTreeEnum.PQV_520.getCode()) && Objects.equals(item.getStatus(),1)) {
|
if (Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && Objects.equals(item.getStatus(), 1)) {
|
||||||
csDeviceService.wlDevRegister(item.getNdid());
|
//csDeviceService.wlDevRegister(item.getNdid());
|
||||||
|
log.info("请先手动注册、接入");
|
||||||
} else {
|
} else {
|
||||||
csDeviceService.devAccessAskTemplate(item.getNdid(),version,1);
|
String version = csTopicService.getVersion(item.getNdid());
|
||||||
|
if (Objects.isNull(version)) {
|
||||||
|
version = "V1";
|
||||||
}
|
}
|
||||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + item.getNdid(),1);
|
csDeviceService.autoAccess(item.getNdid(), version, 1);
|
||||||
}
|
}
|
||||||
|
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + item.getNdid(), 1);
|
||||||
});
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
|
|||||||
public List<CsDataSet> getDataSetData(String modelId) {
|
public List<CsDataSet> getDataSetData(String modelId) {
|
||||||
return this.lambdaQuery()
|
return this.lambdaQuery()
|
||||||
.eq(CsDataSet::getPid, modelId)
|
.eq(CsDataSet::getPid, modelId)
|
||||||
|
.and(item->item.eq(CsDataSet::getConType,1).or().isNull(CsDataSet::getConType))
|
||||||
.and(item->item.eq(CsDataSet::getDataType,"Stat").or().isNull(CsDataSet::getDataType))
|
.and(item->item.eq(CsDataSet::getDataType,"Stat").or().isNull(CsDataSet::getDataType))
|
||||||
.list();
|
.list();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,12 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
json = JsonUtil.convertStreamToString(file.getInputStream());
|
json = JsonUtil.convertStreamToString(file.getInputStream());
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
TemplateDto templateDto = gson.fromJson(json, TemplateDto.class);
|
TemplateDto templateDto = gson.fromJson(json, TemplateDto.class);
|
||||||
|
//判断设备型号
|
||||||
|
String devType = templateDto.getDevType();
|
||||||
|
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode(devType).getData();
|
||||||
|
if (Objects.isNull(dictTreeVO)){
|
||||||
|
throw new BusinessException(AccessResponseEnum.DEV_TYPE_NOT_FIND);
|
||||||
|
}
|
||||||
logDto.setOperate("新增设备模板,模板名称:" + templateDto.getDevType());
|
logDto.setOperate("新增设备模板,模板名称:" + templateDto.getDevType());
|
||||||
//模板文件存入文件服务器
|
//模板文件存入文件服务器
|
||||||
String filePath = fileStorageUtil.uploadMultipart(file, OssPath.DEV_MODEL + templateDto.getDevType() + "_");
|
String filePath = fileStorageUtil.uploadMultipart(file, OssPath.DEV_MODEL + templateDto.getDevType() + "_");
|
||||||
@@ -838,9 +844,6 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
List<DataSetDto> dataSetList = templateDto.getDataSet();
|
List<DataSetDto> dataSetList = templateDto.getDataSet();
|
||||||
String devType = templateDto.getDevType();
|
String devType = templateDto.getDevType();
|
||||||
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode(devType).getData();
|
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode(devType).getData();
|
||||||
if (Objects.isNull(dictTreeVO)){
|
|
||||||
throw new BusinessException(AccessResponseEnum.DEV_TYPE_NOT_FIND);
|
|
||||||
}
|
|
||||||
String code = dictTreeFeignClient.queryById(dictTreeVO.getPid()).getData().getCode();
|
String code = dictTreeFeignClient.queryById(dictTreeVO.getPid()).getData().getCode();
|
||||||
//逻辑设备录入
|
//逻辑设备录入
|
||||||
if (CollectionUtil.isNotEmpty(dataSetList)){
|
if (CollectionUtil.isNotEmpty(dataSetList)){
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -370,7 +371,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
// @Transactional(rollbackFor = Exception.class)
|
||||||
public String wlDevRegister(String nDid) {
|
public String wlDevRegister(String nDid) {
|
||||||
String result = "fail";
|
String result = "fail";
|
||||||
// 设备状态判断
|
// 设备状态判断
|
||||||
@@ -439,20 +440,12 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
csDevModelRelationAddParm.setDid(modelList.get(0).getDid());
|
csDevModelRelationAddParm.setDid(modelList.get(0).getDid());
|
||||||
csDevModelRelationService.addDevModelRelation(csDevModelRelationAddParm);
|
csDevModelRelationService.addDevModelRelation(csDevModelRelationAddParm);
|
||||||
//5.发起自动接入请求
|
//5.发起自动接入请求
|
||||||
|
Thread.sleep(2000);
|
||||||
devAccessAskTemplate(nDid,version,1);
|
devAccessAskTemplate(nDid,version,1);
|
||||||
//6.修改流程,便携式设备接入成功即为实际环境
|
//6.修改流程,便携式设备接入成功即为实际环境
|
||||||
csEquipmentDeliveryService.updateProcessBynDid(nDid,4);
|
csEquipmentDeliveryService.updateProcessBynDid(nDid,4);
|
||||||
//7.存储日志
|
//7.存储日志
|
||||||
csLogsFeignClient.addUserLog(logDto);
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
//8.存储设备调试日志表
|
|
||||||
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
|
|
||||||
csEquipmentProcess.setDevId(nDid);
|
|
||||||
csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
|
|
||||||
csEquipmentProcess.setStartTime(LocalDateTime.now());
|
|
||||||
csEquipmentProcess.setEndTime(LocalDateTime.now());
|
|
||||||
csEquipmentProcess.setProcess(4);
|
|
||||||
csEquipmentProcess.setStatus(1);
|
|
||||||
processFeignClient.add(csEquipmentProcess);
|
|
||||||
//9.删除redis监测点模板信息
|
//9.删除redis监测点模板信息
|
||||||
redisUtil.delete(AppRedisKey.MODEL + nDid);
|
redisUtil.delete(AppRedisKey.MODEL + nDid);
|
||||||
redisUtil.delete(AppRedisKey.LINE + nDid);
|
redisUtil.delete(AppRedisKey.LINE + nDid);
|
||||||
@@ -604,6 +597,77 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置重新接入系统,需要校验所用的模板
|
||||||
|
* @param nDid
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean autoAccess(String nDid,String version,Integer mid) {
|
||||||
|
String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
|
||||||
|
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||||
|
if (!mqttClient) {
|
||||||
|
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||||
|
logDto.setUserName("运维管理员");
|
||||||
|
logDto.setLoginName("njcnyw");
|
||||||
|
logDto.setResult(1);
|
||||||
|
logDto.setOperate(nDid + "接入失败,装置客户端不在线");
|
||||||
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
|
}
|
||||||
|
boolean result = false;
|
||||||
|
Map<Integer,String> modelMap = new HashMap<>();
|
||||||
|
try {
|
||||||
|
//删除缓存数据
|
||||||
|
redisUtil.delete(AppRedisKey.MODEL + nDid);
|
||||||
|
redisUtil.deleteKeysByString(AppRedisKey.DEV_MODEL);
|
||||||
|
//询问装置当前所用模板
|
||||||
|
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid,new Gson().toJson(getJson(mid,TypeEnum.TYPE_3.getCode())),1,false);
|
||||||
|
//接收到模板,判断模板是否存在,替换模板,发起接入
|
||||||
|
Thread.sleep(2000);
|
||||||
|
List<CsModelDto> modelId = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid),CsModelDto.class);
|
||||||
|
if (CollUtil.isNotEmpty(modelId)) {
|
||||||
|
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||||
|
//重新录入装置和模板关系信息
|
||||||
|
for (CsModelDto item : modelId) {
|
||||||
|
CsDevModelRelationPO po = new CsDevModelRelationPO();
|
||||||
|
po.setDevId(vo.getId());
|
||||||
|
po.setModelId(item.getModelId());
|
||||||
|
po.setDid(item.getDid());
|
||||||
|
po.setUpdateTime(LocalDateTime.now());
|
||||||
|
csDevModelRelationService.addRelation(po);
|
||||||
|
modelMap.put(item.getType(),item.getModelId());
|
||||||
|
}
|
||||||
|
//修改监测点使用的模板和数据集
|
||||||
|
List<CsLinePO> lineList;
|
||||||
|
Object object = redisUtil.getObjectByKey("accessLineInfo:" + nDid);
|
||||||
|
if (Objects.isNull(object)) {
|
||||||
|
lineList = csLineFeignClient.findByNdid(nDid).getData();
|
||||||
|
for (CsLinePO item : lineList) {
|
||||||
|
if (item.getClDid() == 0) {
|
||||||
|
updateLineIds(modelMap.get(0),item.getClDid(),nDid);
|
||||||
|
} else {
|
||||||
|
updateLineIds(modelMap.get(1),item.getClDid(),nDid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//发起接入
|
||||||
|
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(getJson(mid,TypeEnum.TYPE_5.getCode())),1,false);
|
||||||
|
//录波任务倒计时
|
||||||
|
redisUtil.saveByKeyWithExpire("startFile:" + nDid,null,60L);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||||
|
logDto.setUserName("运维管理员");
|
||||||
|
logDto.setLoginName("njcnyw");
|
||||||
|
logDto.setResult(1);
|
||||||
|
logDto.setOperate(nDid + "装置接入失败");
|
||||||
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
|
throw new BusinessException(e.getMessage());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组装报文
|
* 组装报文
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.access.service.impl;
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.access.enums.AccessEnum;
|
import com.njcn.access.enums.AccessEnum;
|
||||||
@@ -97,6 +98,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
.ne(CsEquipmentDeliveryPO::getRunStatus,AccessEnum.DEL.getCode())
|
.ne(CsEquipmentDeliveryPO::getRunStatus,AccessEnum.DEL.getCode())
|
||||||
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
|
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
|
||||||
.list();
|
.list();
|
||||||
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
list.forEach(item->{
|
list.forEach(item->{
|
||||||
String clientName = "NJCN-" + item.getNdid().substring(item.getNdid().length() - 6);
|
String clientName = "NJCN-" + item.getNdid().substring(item.getNdid().length() - 6);
|
||||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||||
@@ -111,6 +113,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
csLogsFeignClient.addUserLog(logDto);
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +123,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
List<CsEquipmentDeliveryPO> list = this.lambdaQuery()
|
List<CsEquipmentDeliveryPO> list = this.lambdaQuery()
|
||||||
.eq(CsEquipmentDeliveryPO::getRunStatus,AccessEnum.OFFLINE.getCode())
|
.eq(CsEquipmentDeliveryPO::getRunStatus,AccessEnum.OFFLINE.getCode())
|
||||||
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
|
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
|
||||||
.eq(CsEquipmentDeliveryPO::getStatus, AccessEnum.REGISTERED.getCode())
|
|
||||||
.list();
|
.list();
|
||||||
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
list.forEach(item->{
|
list.forEach(item->{
|
||||||
String clientName = "NJCN-" + item.getNdid().substring(item.getNdid().length() - 6);
|
String clientName = "NJCN-" + item.getNdid().substring(item.getNdid().length() - 6);
|
||||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||||
@@ -136,6 +139,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
csLogsFeignClient.addUserLog(logDto);
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class RtServiceImpl implements IRtService {
|
|||||||
}
|
}
|
||||||
//fixme 目前实时数据只有基础数据和谐波数据,后期拓展,这边需要再判断
|
//fixme 目前实时数据只有基础数据和谐波数据,后期拓展,这边需要再判断
|
||||||
else {
|
else {
|
||||||
HarmRealDataSet harmRealDataSet = harmData(dataArrayList,item);
|
HarmRealDataSet harmRealDataSet = harmData(dataArrayList,item,dataSet.getDataLevel(),po.getCtRatio());
|
||||||
harmRealDataSet.setUserId(userId);
|
harmRealDataSet.setUserId(userId);
|
||||||
harmRealDataSet.setLineId(lineId);
|
harmRealDataSet.setLineId(lineId);
|
||||||
harmRealDataSet.setPt(po.getPtRatio().floatValue());
|
harmRealDataSet.setPt(po.getPtRatio().floatValue());
|
||||||
@@ -228,7 +228,7 @@ public class RtServiceImpl implements IRtService {
|
|||||||
return baseRealDataSet;
|
return baseRealDataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HarmRealDataSet harmData(List<CsDataArray> dataArrayList, AppAutoDataMessage.DataArray dataArray) {
|
public HarmRealDataSet harmData(List<CsDataArray> dataArrayList, AppAutoDataMessage.DataArray dataArray, String dataLevel, Double ct) {
|
||||||
HarmRealDataSet harmRealDataSet = new HarmRealDataSet();
|
HarmRealDataSet harmRealDataSet = new HarmRealDataSet();
|
||||||
List<HarmData> harmDataList = new ArrayList<>();
|
List<HarmData> harmDataList = new ArrayList<>();
|
||||||
//解码
|
//解码
|
||||||
@@ -259,7 +259,14 @@ public class RtServiceImpl implements IRtService {
|
|||||||
//通过反射将数据赋值
|
//通过反射将数据赋值
|
||||||
Class<?> clazz = HarmRealDataSet.class;
|
Class<?> clazz = HarmRealDataSet.class;
|
||||||
maxDataList.forEach(item->{
|
maxDataList.forEach(item->{
|
||||||
if (Objects.equals(item.getHarmName(),"Pq_RmsFundI") || Objects.equals(item.getHarmName(),"Pq_RmsFundU")) {
|
if (Objects.equals(item.getHarmName(),"Pq_RmsFundI")) {
|
||||||
|
if ("Secondary".equals(dataLevel)) {
|
||||||
|
double data = item.getData() * ct;
|
||||||
|
harmRealDataSet.setData1(FloatUtils.get2Float((float)data));
|
||||||
|
} else {
|
||||||
|
harmRealDataSet.setData1(FloatUtils.get2Float(item.getData()));
|
||||||
|
}
|
||||||
|
} else if (Objects.equals(item.getHarmName(),"Pq_RmsFundU")) {
|
||||||
harmRealDataSet.setData1(FloatUtils.get2Float(item.getData()));
|
harmRealDataSet.setData1(FloatUtils.get2Float(item.getData()));
|
||||||
} else {
|
} else {
|
||||||
String numberStr = item.getHarmName().substring(item.getHarmName().lastIndexOf('_') + 1);
|
String numberStr = item.getHarmName().substring(item.getHarmName().lastIndexOf('_') + 1);
|
||||||
@@ -267,7 +274,16 @@ public class RtServiceImpl implements IRtService {
|
|||||||
try {
|
try {
|
||||||
Field field = clazz.getDeclaredField(fieldName);
|
Field field = clazz.getDeclaredField(fieldName);
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
|
if (item.getHarmName().contains("Pq_HarmI_")) {
|
||||||
|
if ("Secondary".equals(dataLevel)) {
|
||||||
|
double data = item.getData() * ct;
|
||||||
|
field.set(harmRealDataSet,FloatUtils.get2Float((float)data));
|
||||||
|
} else {
|
||||||
field.set(harmRealDataSet,FloatUtils.get2Float(item.getData()));
|
field.set(harmRealDataSet,FloatUtils.get2Float(item.getData()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
field.set(harmRealDataSet,FloatUtils.get2Float(item.getData()));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.influxdb.InfluxDB;
|
import org.influxdb.InfluxDB;
|
||||||
import org.influxdb.dto.BatchPoints;
|
import org.influxdb.dto.BatchPoints;
|
||||||
import org.influxdb.dto.Point;
|
import org.influxdb.dto.Point;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -200,7 +201,7 @@ public class EventServiceImpl implements IEventService {
|
|||||||
if (!Objects.isNull(record)) {
|
if (!Objects.isNull(record)) {
|
||||||
if (!Objects.equals(item.getPrjTimeEnd(),-1L)) {
|
if (!Objects.equals(item.getPrjTimeEnd(),-1L)) {
|
||||||
WlRecordParam.UpdateRecord wlRecord = new WlRecordParam.UpdateRecord();
|
WlRecordParam.UpdateRecord wlRecord = new WlRecordParam.UpdateRecord();
|
||||||
wlRecord.setId(record.getId());
|
BeanUtils.copyProperties(record,wlRecord);
|
||||||
wlRecord.setProEndTime(timestampToDatetime((item.getPrjTimeEnd() - 8*3600)));
|
wlRecord.setProEndTime(timestampToDatetime((item.getPrjTimeEnd() - 8*3600)));
|
||||||
wlRecordFeignClient.updateTestRecord(wlRecord);
|
wlRecordFeignClient.updateTestRecord(wlRecord);
|
||||||
}
|
}
|
||||||
@@ -208,7 +209,7 @@ public class EventServiceImpl implements IEventService {
|
|||||||
//新项目入库
|
//新项目入库
|
||||||
WlRecord wlRecord = new WlRecord();
|
WlRecord wlRecord = new WlRecord();
|
||||||
wlRecord.setId(IdUtil.simpleUUID());
|
wlRecord.setId(IdUtil.simpleUUID());
|
||||||
wlRecord.setItemName("基础数据");
|
wlRecord.setItemName("在线监测");
|
||||||
wlRecord.setGcName(item.getPrjName());
|
wlRecord.setGcName(item.getPrjName());
|
||||||
wlRecord.setDevId(vo.getId());
|
wlRecord.setDevId(vo.getId());
|
||||||
wlRecord.setLineId(appEventMessage.getId() + item.getClDid().toString());
|
wlRecord.setLineId(appEventMessage.getId() + item.getClDid().toString());
|
||||||
@@ -227,6 +228,9 @@ public class EventServiceImpl implements IEventService {
|
|||||||
//fixme 电流接线方式 这边系统没有字典,录入字典通用性不强,采用装置上送值存储
|
//fixme 电流接线方式 这边系统没有字典,录入字典通用性不强,采用装置上送值存储
|
||||||
wlRecord.setCurConSel(item.getCurConSel().toString());
|
wlRecord.setCurConSel(item.getCurConSel().toString());
|
||||||
wlRecord.setStartTime(timestampToDatetime((item.getPrjTimeStart() - 8*3600)));
|
wlRecord.setStartTime(timestampToDatetime((item.getPrjTimeStart() - 8*3600)));
|
||||||
|
if (!Objects.equals(item.getPrjTimeEnd(),-1L)) {
|
||||||
|
wlRecord.setEndTime(timestampToDatetime((item.getPrjTimeEnd() - 8*3600)));
|
||||||
|
}
|
||||||
wlRecord.setType(1);
|
wlRecord.setType(1);
|
||||||
wlRecord.setState(1);
|
wlRecord.setState(1);
|
||||||
wlRecord.setGcDataPath(item.getPrjDataPath());
|
wlRecord.setGcDataPath(item.getPrjDataPath());
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ public class AppAutoDataConsumer extends EnhanceConsumerMessageHandler<AppAutoDa
|
|||||||
private RocketMqLogFeignClient rocketMqLogFeignClient;
|
private RocketMqLogFeignClient rocketMqLogFeignClient;
|
||||||
@Resource
|
@Resource
|
||||||
private RtFeignClient rtFeignClient;
|
private RtFeignClient rtFeignClient;
|
||||||
// @Resource
|
|
||||||
// private WlRecordFeignClient wlRecordFeignClient
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleMessage(AppAutoDataMessage appAutoDataMessage) {
|
protected void handleMessage(AppAutoDataMessage appAutoDataMessage) {
|
||||||
@@ -61,7 +59,7 @@ public class AppAutoDataConsumer extends EnhanceConsumerMessageHandler<AppAutoDa
|
|||||||
rtFeignClient.analysis(appAutoDataMessage);
|
rtFeignClient.analysis(appAutoDataMessage);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
log.info(appAutoDataMessage.getKey() + "分发至统计数据");
|
log.info("{}分发至统计数据", appAutoDataMessage.getKey());
|
||||||
statFeignClient.analysis(appAutoDataMessage);
|
statFeignClient.analysis(appAutoDataMessage);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user