Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e7d12ab93 | |||
| 531a787c91 | |||
| 45d31a05ee | |||
| dfd035b908 | |||
| ab59d870d8 | |||
| 5a94b6d8b4 | |||
| cfc2b2b7ba | |||
| eec42f60c0 | |||
| 1d71006d3c | |||
| 1dc16ae071 |
@@ -82,6 +82,79 @@ public class EventDto {
|
||||
|
||||
@SerializedName("Parm")
|
||||
private List<Param> param;
|
||||
|
||||
|
||||
@SerializedName("PrjName")
|
||||
@ApiModelProperty("工程名称")
|
||||
private String prjName;
|
||||
|
||||
@SerializedName("PrjTimeStart")
|
||||
@ApiModelProperty("装置启动时间")
|
||||
private Long prjTimeStart;
|
||||
|
||||
@SerializedName("PrjTimeEnd")
|
||||
@ApiModelProperty("装置结束时间")
|
||||
private Long prjTimeEnd;
|
||||
|
||||
@SerializedName("PrjDataPath")
|
||||
@ApiModelProperty("装置数据路径")
|
||||
private String prjDataPath;
|
||||
|
||||
@SerializedName("DevType")
|
||||
@ApiModelProperty("装置型号")
|
||||
private String devType;
|
||||
|
||||
@SerializedName("DevMac")
|
||||
@ApiModelProperty("装置mac地址")
|
||||
private String devMac;
|
||||
|
||||
@SerializedName("AppVersion")
|
||||
@ApiModelProperty("装置程序版本")
|
||||
private String appVersion;
|
||||
|
||||
@SerializedName("Cldid")
|
||||
@ApiModelProperty("逻辑子设备id")
|
||||
private Integer clDid;
|
||||
|
||||
@SerializedName("StatCycle")
|
||||
@ApiModelProperty("统计间隔")
|
||||
private Integer statCycle;
|
||||
|
||||
@SerializedName("VolGrade")
|
||||
@ApiModelProperty("电压等级")
|
||||
private Float volGrade;
|
||||
|
||||
@SerializedName("VolConType")
|
||||
@ApiModelProperty("电压接线方式(0-星型, 1-角型, 2-V型)")
|
||||
private Integer volConType;
|
||||
|
||||
@SerializedName("CurConSel")
|
||||
@ApiModelProperty("电流接线方式(0-正常, 1-合成IB, 2-合成IC)")
|
||||
private Integer curConSel;
|
||||
|
||||
@SerializedName("PtRatio")
|
||||
@ApiModelProperty("PT变比")
|
||||
private Integer ptRatio;
|
||||
|
||||
@SerializedName("CtRatio")
|
||||
@ApiModelProperty("ct变比")
|
||||
private Integer ctRatio;
|
||||
|
||||
@SerializedName("CapacitySscb")
|
||||
@ApiModelProperty("基准短路容量")
|
||||
private Float capacitySscb;
|
||||
|
||||
@SerializedName("CapacitySscmin")
|
||||
@ApiModelProperty("最小短路容量")
|
||||
private Float capacitySscmin;
|
||||
|
||||
@SerializedName("CapacitySt")
|
||||
@ApiModelProperty("供电设备容量")
|
||||
private Float capacitySt;
|
||||
|
||||
@SerializedName("CapacitySi")
|
||||
@ApiModelProperty("用户协议容量")
|
||||
private Float capacitySi;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -96,7 +96,7 @@ public class CsDeviceController extends BaseController {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/wlRegister")
|
||||
@ApiOperation("便携式设备注册")
|
||||
@ApiOperation("便携式设备接入")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
||||
})
|
||||
@@ -109,7 +109,7 @@ public class CsDeviceController extends BaseController {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/wlAccess")
|
||||
@ApiOperation("便携式设备接入")
|
||||
@ApiOperation("便携式设备手动接入")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
||||
})
|
||||
|
||||
@@ -73,40 +73,22 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||
public class MqttMessageHandler {
|
||||
|
||||
private final DevModelFeignClient devModelFeignClient;
|
||||
|
||||
private final ICsLineModelService csLineModelService;
|
||||
|
||||
private final ICsTopicService csTopicService;
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
|
||||
private final DataSetFeignClient dataSetFeignClient;
|
||||
|
||||
private final AppAutoDataMessageTemplate appAutoDataMessageTemplate;
|
||||
|
||||
private final AppEventMessageTemplate appEventMessageTemplate;
|
||||
|
||||
private final CsLogsFeignClient csLogsFeignClient;
|
||||
|
||||
private final AppFileMessageTemplate appFileMessageTemplate;
|
||||
|
||||
private final AppFileStreamMessageTemplate appFileStreamMessageTemplate;
|
||||
|
||||
private final ICsDeviceOnlineLogsService onlineLogsService;
|
||||
|
||||
@Autowired
|
||||
private final CsSoftInfoFeignClient csSoftInfoFeignClient;
|
||||
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
|
||||
private final DevCapacityFeignClient devCapacityFeignClient;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
@Autowired
|
||||
Validator validator;
|
||||
|
||||
@@ -301,7 +283,6 @@ public class MqttMessageHandler {
|
||||
String key = AppRedisKey.LINE + nDid;
|
||||
redisUtil.saveByKeyWithExpire(key,lineList,600L);
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
System.out.println(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,6 +335,8 @@ public class MqttMessageHandler {
|
||||
onlineLogsService.save(csDeviceOnlineLogs);
|
||||
}
|
||||
}
|
||||
//接入后系统模拟装置心跳
|
||||
redisUtil.saveByKeyWithExpire("MQTT:" + nDid, Instant.now().toEpochMilli(),300L);
|
||||
//修改redis的mid
|
||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
||||
redisUtil.saveByKeyWithExpire("online" + nDid,"online",10L);
|
||||
@@ -412,27 +395,29 @@ public class MqttMessageHandler {
|
||||
List<CsDevCapacityPO> list = new ArrayList<>();
|
||||
devInfo.forEach(item->{
|
||||
//1.更新治理监测点信息
|
||||
CsLineParam csLineParam = new CsLineParam();
|
||||
if (Objects.equals(item.getClDid(),0)){
|
||||
CsLineParam csLineParam = new CsLineParam();
|
||||
csLineParam.setLineId(nDid.concat("0"));
|
||||
csLineParam.setVolGrade(item.getVolGrade());
|
||||
csLineParam.setPtRatio(item.getPtRatio());
|
||||
csLineParam.setCtRatio(item.getCtRatio());
|
||||
csLineParam.setConType(item.getConType());
|
||||
csLineFeignClient.updateLine(csLineParam);
|
||||
//2.录入各个模块设备容量
|
||||
CsDevCapacityPO csDevCapacity = new CsDevCapacityPO();
|
||||
csDevCapacity.setLineId(nDid.concat("0"));
|
||||
csDevCapacity.setCldid(item.getClDid());
|
||||
csDevCapacity.setCapacity(Objects.isNull(item.getCapacityA())?0.0:item.getCapacityA());
|
||||
list.add(csDevCapacity);
|
||||
} else {
|
||||
csLineParam.setLineId(nDid.concat(item.getClDid().toString()));
|
||||
}
|
||||
//2.录入各个模块设备容量
|
||||
CsDevCapacityPO csDevCapacity = new CsDevCapacityPO();
|
||||
csDevCapacity.setLineId(nDid.concat("0"));
|
||||
csDevCapacity.setCldid(item.getClDid());
|
||||
csDevCapacity.setCapacity(Objects.isNull(item.getCapacityA())?0.0:item.getCapacityA());
|
||||
list.add(csDevCapacity);
|
||||
csLineParam.setVolGrade(item.getVolGrade());
|
||||
csLineParam.setPtRatio(item.getPtRatio());
|
||||
csLineParam.setCtRatio(item.getCtRatio());
|
||||
csLineParam.setConType(item.getConType());
|
||||
csLineFeignClient.updateLine(csLineParam);
|
||||
});
|
||||
devCapacityFeignClient.addList(list);
|
||||
//3.更新设备模块个数
|
||||
equipmentFeignClient.updateModuleNumber(nDid,(devInfo.size()-1));
|
||||
//4.询问监测点pt/ct信息
|
||||
//askDevData(nDid,version,3,(res.getMid()+1));
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
devCapacityFeignClient.addList(list);
|
||||
//3.更新设备模块个数
|
||||
equipmentFeignClient.updateModuleNumber(nDid,(devInfo.size()-1));
|
||||
}
|
||||
} else if (Objects.equals(res.getDid(),2)) {
|
||||
logDto.setOperate(nDid + "更新电网侧、负载侧监测点信息");
|
||||
//1.更新电网侧、负载侧监测点相关信息
|
||||
@@ -660,13 +645,13 @@ public class MqttMessageHandler {
|
||||
|
||||
private void saveDirectoryInfo(List<FileDto.DirInfo> dirInfo, String key) {
|
||||
if (!CollectionUtil.isEmpty(dirInfo)) {
|
||||
redisUtil.saveByKeyWithExpire(key, dirInfo, 10L);
|
||||
redisUtil.saveByKeyWithExpire(key, dirInfo, 20L);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFileInfo(FileDto.FileInfo fileInfo, String key) {
|
||||
if (!Objects.isNull(fileInfo)) {
|
||||
redisUtil.saveByKeyWithExpire(key, fileInfo, 10L);
|
||||
redisUtil.saveByKeyWithExpire(key, fileInfo, 20L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,7 +684,7 @@ public class MqttMessageHandler {
|
||||
askDataDto.setEndTime(-1);
|
||||
switch (type) {
|
||||
case 1:
|
||||
reqAndResParam.setDid(2);
|
||||
reqAndResParam.setDid(0);
|
||||
askDataDto.setCldid(0);
|
||||
askDataDto.setDataType(1);
|
||||
break;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.access.listener;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.pojo.po.CsDeviceOnlineLogs;
|
||||
import com.njcn.access.service.ICsDeviceOnlineLogsService;
|
||||
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||
import com.njcn.access.service.ICsTopicService;
|
||||
@@ -14,6 +15,7 @@ import com.njcn.csdevice.api.CsLogsFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.api.AppUserFeignClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
@@ -83,8 +85,6 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
super(listenerContainer);
|
||||
}
|
||||
|
||||
// 当前尝试次数
|
||||
private static int attemptCount = 1;
|
||||
//最大告警次数
|
||||
private static int MAX_WARNING_TIMES = 0;
|
||||
|
||||
@@ -105,6 +105,17 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
executeMainTask(scheduler,nDid,version);
|
||||
}
|
||||
//自动接入
|
||||
else if (expiredKey.startsWith("autoAccess")) {
|
||||
List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getAll();
|
||||
list.forEach(item->{
|
||||
String version = csTopicService.getVersion(item.getNdid());
|
||||
if (!Objects.isNull(version)){
|
||||
csDeviceService.devAccessAskTemplate(item.getNdid(),version,1);
|
||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + item.getNdid(),1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//主任务
|
||||
@@ -118,9 +129,9 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
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(2000);
|
||||
Object object = redisUtil.getObjectByKey("online" + nDid);
|
||||
@@ -132,6 +143,10 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
csEquipmentDeliveryService.updateRunStatusBynDid(nDid, AccessEnum.OFFLINE.getCode());
|
||||
startScheduledTask(scheduler,nDid,version);
|
||||
logDto.setOperate("客户端离线进入定时任务");
|
||||
//记录装置掉线时间
|
||||
CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
||||
record.setOfflineTime(LocalDateTime.now());
|
||||
onlineLogsService.updateById(record);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -159,21 +174,27 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
//判断客户端
|
||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||
if (mqttClient) {
|
||||
csDeviceService.devAccessAskTemplate(nDid,version,attemptCount++);
|
||||
Integer status = csEquipmentDeliveryService.queryEquipmentBynDid(nDid).getRunStatus();
|
||||
if (Objects.equals(status,AccessEnum.ONLINE.getCode())){
|
||||
logDto.setResult(1);
|
||||
scheduler.shutdown();
|
||||
return;
|
||||
} else {
|
||||
logDto.setResult(0);
|
||||
//一个小时未连接上,则推送告警消息
|
||||
MAX_WARNING_TIMES++;
|
||||
if (MAX_WARNING_TIMES == 30) {
|
||||
NoticeUserDto dto2 = sendConnectFail(nDid);
|
||||
sendEventToUser(dto2);
|
||||
addLogs(dto2);
|
||||
csDeviceService.devAccessAskTemplate(nDid,version,1);
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
Integer status = csEquipmentDeliveryService.queryEquipmentBynDid(nDid).getRunStatus();
|
||||
if (Objects.equals(status,AccessEnum.ONLINE.getCode())){
|
||||
logDto.setResult(1);
|
||||
scheduler.shutdown();
|
||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
||||
return;
|
||||
} else {
|
||||
logDto.setResult(0);
|
||||
//一个小时未连接上,则推送告警消息
|
||||
MAX_WARNING_TIMES++;
|
||||
if (MAX_WARNING_TIMES == 30) {
|
||||
NoticeUserDto dto2 = sendConnectFail(nDid);
|
||||
sendEventToUser(dto2);
|
||||
addLogs(dto2);
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
//一个小时未连接上,则推送告警消息
|
||||
@@ -193,7 +214,6 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
//掉线通知
|
||||
private NoticeUserDto sendOffLine(String nDid) {
|
||||
NoticeUserDto dto = new NoticeUserDto();
|
||||
// NoticeUserDto.Payload payload = new NoticeUserDto.Payload();
|
||||
dto.setTitle("设备离线");
|
||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getId()).getData();
|
||||
@@ -203,16 +223,12 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
String content = String.format(devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + dateStr + "离线");
|
||||
dto.setContent(content);
|
||||
dto.setPushClientId(getEventUser(po.getId(),true));
|
||||
// payload.setType(3);
|
||||
// payload.setPath("/pages/message/message?type="+payload.getType());
|
||||
// dto.setPayload(payload);
|
||||
return dto;
|
||||
}
|
||||
|
||||
//重连失败通知
|
||||
private NoticeUserDto sendConnectFail(String nDid) {
|
||||
NoticeUserDto dto = new NoticeUserDto();
|
||||
// NoticeUserDto.Payload payload = new NoticeUserDto.Payload();
|
||||
dto.setTitle("设备接入失败");
|
||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getId()).getData();
|
||||
@@ -222,9 +238,6 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
String content = String.format(devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + dateStr + "多次接入失败");
|
||||
dto.setContent(content);
|
||||
dto.setPushClientId(getEventUser(po.getId(),false));
|
||||
// payload.setType(3);
|
||||
// payload.setPath("/pages/message/message?type="+payload.getType());
|
||||
// dto.setPayload(payload);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -287,6 +300,4 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
package com.njcn.access.runner;
|
||||
|
||||
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||
import com.njcn.access.service.ICsTopicService;
|
||||
import com.njcn.access.service.impl.CsDeviceServiceImpl;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:用来重新发起设备的接入,存在程序意外停止了,缓存失效导致无法更新装置的状态,所以需要在程序启动时发起设备的接入
|
||||
@@ -25,21 +20,11 @@ import java.util.Objects;
|
||||
public class AccessApplicationRunner implements ApplicationRunner {
|
||||
|
||||
@Resource
|
||||
private CsDeviceServiceImpl csDeviceService;
|
||||
@Resource
|
||||
private ICsTopicService csTopicService;
|
||||
@Resource
|
||||
private ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args){
|
||||
List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getAll();
|
||||
list.forEach(item->{
|
||||
String version = csTopicService.getVersion(item.getNdid());
|
||||
if (!Objects.isNull(version)){
|
||||
csDeviceService.devAccessAskTemplate(item.getNdid(),version,1);
|
||||
}
|
||||
});
|
||||
public void run(ApplicationArguments args) {
|
||||
redisUtil.saveByKeyWithExpire("autoAccess",null,60L);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,11 @@ import com.njcn.access.pojo.dto.ControlDto;
|
||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||
import com.njcn.access.pojo.dto.file.FileRedisDto;
|
||||
import com.njcn.access.service.AskDeviceDataService;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.zlevent.pojo.dto.FileStreamDto;
|
||||
import com.njcn.zlevent.pojo.dto.NoticeUserDto;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -25,11 +23,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
@@ -113,7 +106,7 @@ public class AskDeviceDataServiceImpl implements AskDeviceDataService {
|
||||
Object object3 = redisUtil.getObjectByKey(AppRedisKey.FILE_PART.concat(name));
|
||||
if (!Objects.isNull(object3)) {
|
||||
FileStreamDto dto = JSON.parseObject(JSON.toJSONString(object3), FileStreamDto.class);
|
||||
String json = "{allStep:"+dto.getTotal()+",nowStep:"+ (CollectionUtil.isEmpty(dto.getList())?0:dto.getList().size())+"}";
|
||||
String json = "{fileName:"+name+",allStep:"+dto.getTotal()+",nowStep:"+ (CollectionUtil.isEmpty(dto.getList())?0:dto.getList().size())+"}";
|
||||
publisher.send("/Web/Progress/" + nDid, new Gson().toJson(json), 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -64,49 +65,26 @@ import java.util.stream.Collectors;
|
||||
public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
private final DevModelFeignClient devModelFeignClient;
|
||||
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final EleEvtFeignClient eleEvtFeignClient;
|
||||
|
||||
private final ICsDataSetService csDataSetService;
|
||||
|
||||
private final ICsDataArrayService csDataArrayService;
|
||||
|
||||
private final CsDevModelMapper csDevModelMapper;
|
||||
|
||||
private final ICsLineModelService csLineModelService;
|
||||
|
||||
private final ICsGroupService csGroupService;
|
||||
|
||||
private final ICsGroArrService csGroArrService;
|
||||
|
||||
private final CsLogsFeignClient csLogsFeignClient;
|
||||
|
||||
private final EleWaveFeignClient waveFeignClient;
|
||||
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
private final MqttPublisher publisher;
|
||||
|
||||
private final ICsTopicService csTopicService;
|
||||
|
||||
private final ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final MqttMessageHandler mqttMessageHandler;
|
||||
|
||||
@Override
|
||||
public void refreshDevModelCache() {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,7 +169,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
int times = bytes.length / cap + 1;
|
||||
for (int i = 1; i <= times; i++) {
|
||||
//发送数据给前端
|
||||
String json = "{allStep:"+times+",nowStep:"+i+"}";
|
||||
String json = "{fileName:"+file.getOriginalFilename()+",allStep:"+times+",nowStep:"+i+"}";
|
||||
publisher.send("/Web/Progress/" + id, new Gson().toJson(json), 1, false);
|
||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||
byte[] lsBytes;
|
||||
@@ -222,7 +200,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
}
|
||||
} else {
|
||||
String json = "{allStep:\""+1+"\",nowStep:"+1+"}";
|
||||
String json = "{fileName:"+file.getOriginalFilename()+",allStep:\""+1+"\",nowStep:"+1+"}";
|
||||
publisher.send("/Web/Progress", new Gson().toJson(json), 1, false);
|
||||
ReqAndResDto.Req req = getPojo(1,path,file,length,bytes,0,hexString);
|
||||
publisher.send("/Pfm/DevFileCmd/" + version + "/" + id, new Gson().toJson(req), 1, false);
|
||||
@@ -1243,14 +1221,14 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
if (Objects.equals(code, DicDataEnum.CONNECT_DEV.getCode()) || Objects.isNull(code)){
|
||||
showName = "电网侧数据";
|
||||
} else if (Objects.equals(code, DicDataEnum.PORTABLE.getCode())){
|
||||
showName = "监测1路数据";
|
||||
showName = "监测1#数据";
|
||||
}
|
||||
break;
|
||||
case "Ds$Pqd$Stat$02":
|
||||
if (Objects.equals(code, DicDataEnum.CONNECT_DEV.getCode()) || Objects.isNull(code)){
|
||||
showName = "负载侧数据";
|
||||
} else if (Objects.equals(code, DicDataEnum.PORTABLE.getCode())){
|
||||
showName = "监测2路数据";
|
||||
showName = "监测2#数据";
|
||||
}
|
||||
break;
|
||||
//波形参数名称
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.njcn.access.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -11,7 +10,6 @@ import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.param.DevAccessParam;
|
||||
import com.njcn.access.pojo.RspDataDto;
|
||||
import com.njcn.access.pojo.dto.AccessDto;
|
||||
import com.njcn.access.pojo.dto.CsModelDto;
|
||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||
@@ -37,7 +35,6 @@ import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.sf.cglib.core.Local;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -225,16 +222,34 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
po.setClDid(0);
|
||||
if (Objects.equals(DicDataEnum.GRID_SIDE.getCode(),location)){
|
||||
po.setLineId(devAccessParam.getNDid() + "1");
|
||||
String id = Objects.requireNonNull(modelId.stream().filter(it -> Objects.equals(it.getDid(), 2)).findFirst().orElse(null)).getModelId();
|
||||
po.setDataModelId(id);
|
||||
//获取模板下数据集
|
||||
List<CsDataSet> dataSets = csDataSetService.getDataSetData(id);
|
||||
String dataSetId = Objects.requireNonNull(dataSets.stream().filter(it -> Objects.equals(it.getClDev(), 1)&&Objects.equals(it.getType(), 2)).findFirst().orElse(null)).getId();
|
||||
po.setDataSetId(dataSetId);
|
||||
param.setId(devAccessParam.getNDid() + "1");
|
||||
appLineTopologyDiagramPo.setLineId(devAccessParam.getNDid() + "1");
|
||||
po.setClDid(1);
|
||||
} else if (Objects.equals(DicDataEnum.LOAD_SIDE.getCode(),location)){
|
||||
po.setLineId(devAccessParam.getNDid() + "2");
|
||||
String id = Objects.requireNonNull(modelId.stream().filter(it -> Objects.equals(it.getDid(), 2)).findFirst().orElse(null)).getModelId();
|
||||
po.setDataModelId(id);
|
||||
//获取模板下数据集
|
||||
List<CsDataSet> dataSets = csDataSetService.getDataSetData(id);
|
||||
String dataSetId = Objects.requireNonNull(dataSets.stream().filter(it -> Objects.equals(it.getClDev(), 2)&&Objects.equals(it.getType(), 2)).findFirst().orElse(null)).getId();
|
||||
po.setDataSetId(dataSetId);
|
||||
param.setId(devAccessParam.getNDid() + "2");
|
||||
appLineTopologyDiagramPo.setLineId(devAccessParam.getNDid() + "2");
|
||||
po.setClDid(2);
|
||||
} else {
|
||||
po.setLineId(devAccessParam.getNDid() + "0");
|
||||
String id = Objects.requireNonNull(modelId.stream().filter(it -> Objects.equals(it.getDid(), 1)).findFirst().orElse(null)).getModelId();
|
||||
po.setDataModelId(id);
|
||||
//获取模板下数据集
|
||||
List<CsDataSet> dataSets = csDataSetService.getDataSetData(id);
|
||||
String dataSetId = Objects.requireNonNull(dataSets.stream().filter(it -> Objects.equals(it.getClDev(), 0)&&Objects.equals(it.getType(), 0)).findFirst().orElse(null)).getId();
|
||||
po.setDataSetId(dataSetId);
|
||||
param.setId(devAccessParam.getNDid() + "0");
|
||||
appLineTopologyDiagramPo.setLineId(devAccessParam.getNDid() + "0");
|
||||
}
|
||||
@@ -364,7 +379,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||
logDto.setUserName(RequestUtil.getUserNickname());
|
||||
logDto.setLoginName(RequestUtil.getUsername());
|
||||
logDto.setOperate("设备"+nDid+"注册");
|
||||
logDto.setOperate("便携式设备"+nDid+"注册、接入");
|
||||
logDto.setResult(1);
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
@@ -372,7 +387,15 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
String version = csTopicService.getVersion(nDid);
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
//1.根据模板获取监测点个数,插入监测点表
|
||||
//1.录入装置台账信息
|
||||
CsLedgerParam csLedgerParam = new CsLedgerParam();
|
||||
csLedgerParam.setId(vo.getId());
|
||||
csLedgerParam.setPid("0");
|
||||
csLedgerParam.setName(vo.getName());
|
||||
csLedgerParam.setLevel(2);
|
||||
csLedgerParam.setSort(0);
|
||||
csLedgerService.addLedgerTree(csLedgerParam);
|
||||
//2.根据模板获取监测点个数,插入监测点表
|
||||
Thread.sleep(2000);
|
||||
List<CsModelDto> modelList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid),CsModelDto.class);
|
||||
if (CollUtil.isEmpty(modelList)){
|
||||
@@ -386,31 +409,37 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
list.forEach(item->{
|
||||
CsLinePO po = new CsLinePO();
|
||||
po.setLineId(nDid + item.getClDev().toString());
|
||||
po.setName(item.getClDev().toString() + "号监测点");
|
||||
po.setName(item.getClDev().toString() + "#监测点");
|
||||
po.setStatus(1);
|
||||
po.setClDid(item.getClDev());
|
||||
po.setDeviceId(vo.getId());
|
||||
//防止主键重复
|
||||
QueryWrapper<CsLinePO> qw = new QueryWrapper();
|
||||
QueryWrapper<CsLinePO> qw = new QueryWrapper<>();
|
||||
qw.eq("line_id",po.getLineId());
|
||||
if(csLineService.getBaseMapper().selectList(qw).isEmpty()){
|
||||
csLinePoList.add(po);
|
||||
}
|
||||
//3.生成台账树监测点数据
|
||||
CsLedgerParam param = new CsLedgerParam();
|
||||
param.setId(nDid + item.getClDev().toString());
|
||||
param.setPid(vo.getId());
|
||||
param.setName(item.getClDev().toString() + "#监测点");
|
||||
param.setLevel(3);
|
||||
param.setSort(0);
|
||||
csLedgerService.addLedgerTree(param);
|
||||
});
|
||||
csLineService.saveBatch(csLinePoList);
|
||||
//2.生成装置和模板的关系表
|
||||
//4.生成装置和模板的关系表
|
||||
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||
csDevModelRelationAddParm.setDevId(vo.getId());
|
||||
csDevModelRelationAddParm.setModelId(modelList.get(0).getModelId());
|
||||
csDevModelRelationAddParm.setDid(modelList.get(0).getDid());
|
||||
csDevModelRelationService.addDevModelRelation(csDevModelRelationAddParm);
|
||||
//3.修改装置状态为注册状态
|
||||
csEquipmentDeliveryService.updateStatusBynDid(nDid, AccessEnum.REGISTERED.getCode());
|
||||
//4.发起自动接入请求
|
||||
//5.发起自动接入请求
|
||||
devAccessAskTemplate(nDid,version,1);
|
||||
//5.存储日志
|
||||
//6.存储日志
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
//6.存储设备调试日志表
|
||||
//7.存储设备调试日志表
|
||||
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
|
||||
csEquipmentProcess.setDevId(nDid);
|
||||
csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
|
||||
@@ -419,7 +448,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
csEquipmentProcess.setProcess(4);
|
||||
csEquipmentProcess.setStatus(1);
|
||||
processFeignClient.add(csEquipmentProcess);
|
||||
//7.删除redis监测点模板信息
|
||||
//8.删除redis监测点模板信息
|
||||
redisUtil.delete(AppRedisKey.MODEL + nDid);
|
||||
redisUtil.delete(AppRedisKey.LINE + nDid);
|
||||
} catch (Exception e) {
|
||||
@@ -527,6 +556,8 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
po.setUpdateTime(LocalDateTime.now());
|
||||
csDevModelRelationService.addRelation(po);
|
||||
}
|
||||
//fixme 修改监测点使用的模板和数据集
|
||||
|
||||
//发起接入
|
||||
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_5.getCode()));
|
||||
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(reqAndResParam),1,false);
|
||||
|
||||
@@ -33,7 +33,11 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
csLedger.setPid("0");
|
||||
csLedger.setPids("0");
|
||||
} else {
|
||||
csLedger.setPids(fatherCsLedger.getPids() + "," + csLedgerParam.getPid());
|
||||
if (Objects.isNull(fatherCsLedger)) {
|
||||
csLedger.setPids("0");
|
||||
} else {
|
||||
csLedger.setPids(fatherCsLedger.getPids() + "," + csLedgerParam.getPid());
|
||||
}
|
||||
}
|
||||
this.save(csLedger);
|
||||
return csLedger;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
//package com.njcn.stat.api;
|
||||
//
|
||||
//import com.njcn.common.pojo.constant.ServerInfo;
|
||||
//import com.njcn.common.pojo.response.HttpResult;
|
||||
//import com.njcn.mq.message.AppAutoDataMessage;
|
||||
//import com.njcn.stat.api.fallback.WlRecordClientFallbackFactory;
|
||||
//import org.springframework.cloud.openfeign.FeignClient;
|
||||
//import org.springframework.validation.annotation.Validated;
|
||||
//import org.springframework.web.bind.annotation.PostMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestBody;
|
||||
//
|
||||
///**
|
||||
// * @author xy
|
||||
// */
|
||||
//@FeignClient(value = ServerInfo.CS_STAT_BOOT, path = "/record", fallbackFactory = WlRecordClientFallbackFactory.class,contextId = "record")
|
||||
//public interface WlRecordFeignClient {
|
||||
//
|
||||
// @PostMapping("/addOrUpdateBaseData")
|
||||
// HttpResult<String> addOrUpdateBaseData(@RequestBody @Validated AppAutoDataMessage appAutoDataMessage);
|
||||
//
|
||||
//}
|
||||
@@ -1,35 +0,0 @@
|
||||
//package com.njcn.stat.api.fallback;
|
||||
//
|
||||
//import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
//import com.njcn.common.pojo.exception.BusinessException;
|
||||
//import com.njcn.common.pojo.response.HttpResult;
|
||||
//import com.njcn.mq.message.AppAutoDataMessage;
|
||||
//import com.njcn.stat.api.WlRecordFeignClient;
|
||||
//import feign.hystrix.FallbackFactory;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * @author xy
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//public class WlRecordClientFallbackFactory implements FallbackFactory<WlRecordFeignClient> {
|
||||
// @Override
|
||||
// public WlRecordFeignClient create(Throwable cause) {
|
||||
// //判断抛出异常是否为解码器抛出的业务异常
|
||||
// Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
// if (cause.getCause() instanceof BusinessException) {
|
||||
// BusinessException businessException = (BusinessException) cause.getCause();
|
||||
// }
|
||||
// Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
// return new WlRecordFeignClient() {
|
||||
//
|
||||
// @Override
|
||||
// public HttpResult<String> addOrUpdateBaseData(AppAutoDataMessage appAutoDataMessage) {
|
||||
// log.error("{}异常,降级处理,异常为:{}","新增或更新装置基础数据",cause.toString());
|
||||
// throw new BusinessException(finalExceptionEnum);
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
//}
|
||||
@@ -6,6 +6,7 @@ import com.njcn.mq.message.AppEventMessage;
|
||||
import com.njcn.zlevent.api.fallback.EventClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
@@ -16,7 +17,7 @@ public interface EventFeignClient {
|
||||
@PostMapping("/analysis")
|
||||
HttpResult<String> analysis(AppEventMessage appEventMessage);
|
||||
|
||||
@PostMapping("/errorEvent")
|
||||
HttpResult<String> insertErrorEvent(AppEventMessage appEventMessage);
|
||||
@PostMapping("/portableData")
|
||||
HttpResult<String> getPortableData(@RequestBody AppEventMessage appEventMessage);
|
||||
|
||||
}
|
||||
|
||||
@@ -32,10 +32,11 @@ public class EventClientFallbackFactory implements FallbackFactory<EventFeignCli
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> insertErrorEvent(AppEventMessage appEventMessage) {
|
||||
log.error("{}异常,降级处理,异常为:{}","异常事件统计",cause.toString());
|
||||
public HttpResult<String> getPortableData(AppEventMessage appEventMessage) {
|
||||
log.error("{}异常,降级处理,异常为:{}","便携式设备数据记录动作",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/event")
|
||||
@Api(tags = "暂态事件处理")
|
||||
@Api(tags = "事件处理")
|
||||
@AllArgsConstructor
|
||||
public class EventController extends BaseController {
|
||||
|
||||
@@ -44,4 +44,14 @@ public class EventController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/portableData")
|
||||
@ApiOperation("便携式数据事件")
|
||||
@ApiImplicitParam(name = "appEventMessage", value = "数据实体", required = true)
|
||||
public HttpResult<String> getPortableData(@RequestBody AppEventMessage appEventMessage){
|
||||
String methodDescribe = getMethodDescribe("getPortableData");
|
||||
eventService.getPortableData(appEventMessage);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,12 @@ public interface IEventService {
|
||||
*/
|
||||
void analysis(AppEventMessage appEventMessage);
|
||||
|
||||
/**
|
||||
* 便携式设备基础数据
|
||||
* 1.装置发起数据记录开始动作,库中新增数据;
|
||||
* 2.装置发起数据记录结束动作,库中更新数据;
|
||||
* @param appEventMessage
|
||||
*/
|
||||
void getPortableData(AppEventMessage appEventMessage);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,12 @@ import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.api.WlRecordFeignClient;
|
||||
import com.njcn.csdevice.pojo.param.WlRecordParam;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.po.WlRecord;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
@@ -31,11 +35,15 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.InfluxDB;
|
||||
import org.influxdb.dto.BatchPoints;
|
||||
import org.influxdb.dto.Point;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -53,22 +61,15 @@ import java.util.concurrent.TimeUnit;
|
||||
public class EventServiceImpl implements IEventService {
|
||||
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final ICsEventService csEventService;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final ICsEventLogsService csEventLogsService;
|
||||
|
||||
private final SendEventUtils sendEventUtils;
|
||||
private final WlRecordFeignClient wlRecordFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -188,6 +189,93 @@ public class EventServiceImpl implements IEventService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void getPortableData(AppEventMessage appEventMessage) {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(appEventMessage.getId()).getData();
|
||||
//根据报文判断是新增还是更新
|
||||
List<AppEventMessage.DataArray> dataArrays = appEventMessage.getMsg().getDataArray();
|
||||
dataArrays.forEach(item->{
|
||||
WlRecordParam.Record param = new WlRecordParam.Record();
|
||||
param.setDevId(vo.getId());
|
||||
param.setLineId(appEventMessage.getId() + item.getClDid().toString());
|
||||
param.setProName(item.getPrjName());
|
||||
param.setProStartTime(timestampToDatetime((item.getPrjTimeStart() - 8*3600)));
|
||||
WlRecord record = wlRecordFeignClient.findDevBaseData(param).getData();
|
||||
if (!Objects.isNull(record)) {
|
||||
if (!Objects.equals(item.getPrjTimeEnd(),-1L)) {
|
||||
WlRecordParam.UpdateRecord wlRecord = new WlRecordParam.UpdateRecord();
|
||||
wlRecord.setId(record.getId());
|
||||
wlRecord.setProEndTime(timestampToDatetime((item.getPrjTimeEnd() - 8*3600)));
|
||||
wlRecordFeignClient.updateTestRecord(wlRecord);
|
||||
}
|
||||
} else {
|
||||
//新项目入库
|
||||
WlRecord wlRecord = new WlRecord();
|
||||
wlRecord.setId(IdUtil.simpleUUID());
|
||||
wlRecord.setItemName("基础数据");
|
||||
wlRecord.setGcName(item.getPrjName());
|
||||
wlRecord.setDevId(vo.getId());
|
||||
wlRecord.setLineId(appEventMessage.getId() + item.getClDid().toString());
|
||||
wlRecord.setStatisticalInterval(item.getStatCycle());
|
||||
wlRecord.setPt(item.getPtRatio());
|
||||
wlRecord.setCt(item.getCtRatio());
|
||||
//电压等级
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(channelVol(item.getVolGrade()) + "kV","Dev_Voltage_Stand").getData();
|
||||
wlRecord.setVoltageLevel(Objects.isNull(dictData)?null:dictData.getId());
|
||||
wlRecord.setCapacitySscb(item.getCapacitySscb());
|
||||
wlRecord.setCapacitySscmin(item.getCapacitySscmin());
|
||||
wlRecord.setCapacitySt(item.getCapacitySt());
|
||||
wlRecord.setCapacitySi(item.getCapacitySi());
|
||||
//电压接线方式
|
||||
wlRecord.setVolConType(getVolConType(item.getVolConType()));
|
||||
//fixme 电流接线方式 这边系统没有字典,录入字典通用性不强,采用装置上送值存储
|
||||
wlRecord.setCurConSel(item.getCurConSel().toString());
|
||||
wlRecord.setStartTime(timestampToDatetime((item.getPrjTimeStart() - 8*3600)));
|
||||
wlRecord.setType(1);
|
||||
wlRecord.setState(1);
|
||||
wlRecord.setGcDataPath(item.getPrjDataPath());
|
||||
wlRecordFeignClient.addBaseData(wlRecord);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理电压
|
||||
* @param vol
|
||||
* @return
|
||||
*/
|
||||
public String channelVol(Float vol) {
|
||||
BigDecimal value = new BigDecimal(vol);
|
||||
BigDecimal noZeros = value.stripTrailingZeros();
|
||||
return noZeros.toPlainString();
|
||||
}
|
||||
|
||||
// 0-星型, 1-角型, 2-V型
|
||||
// star-星型、Star_Triangle-星三角、Open_Delta-开口三角
|
||||
public String getVolConType(Integer volConType) {
|
||||
String result = null;
|
||||
String dictDataCode = null;
|
||||
switch (volConType) {
|
||||
case 0:
|
||||
dictDataCode = "star";
|
||||
break;
|
||||
case 1:
|
||||
dictDataCode = "Star_Triangle";
|
||||
break;
|
||||
case 2:
|
||||
dictDataCode = "Open_Delta";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!Objects.isNull(dictDataCode)) {
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(dictDataCode,"Dev_Connect").getData();
|
||||
result = dictData.getId();
|
||||
}
|
||||
return Objects.isNull(result)?null:result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存监测点相关信息
|
||||
*/
|
||||
@@ -248,4 +336,9 @@ public class EventServiceImpl implements IEventService {
|
||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
|
||||
return LocalDateTime.parse(time, fmt);
|
||||
}
|
||||
|
||||
public LocalDateTime timestampToDatetime(long timestamp){
|
||||
Instant instant = Instant.ofEpochSecond(timestamp);
|
||||
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public class AppEventConsumer extends EnhanceConsumerMessageHandler<AppEventMess
|
||||
break;
|
||||
case 32:
|
||||
log.info("分发至便携式基础数据处理");
|
||||
eventFeignClient.getPortableData(appEventMessage);
|
||||
break;
|
||||
case 241:
|
||||
log.info("分发装置异常事件统计");
|
||||
|
||||
Reference in New Issue
Block a user