短信服务集成
This commit is contained in:
@@ -3,7 +3,9 @@ package com.njcn.access.utils;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.access.pojo.dto.NoticeUserDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -21,12 +23,17 @@ import java.nio.charset.StandardCharsets;
|
||||
@Component
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class SendMessageUtil {
|
||||
|
||||
@Value("${app.sendUrl:https://fc-mp-ff7b310f-94c9-4468-8260-109111c0a6b2.next.bspapp.com/push}")
|
||||
private String appSendUrl;
|
||||
|
||||
//App客户端消息推送
|
||||
public void sendEventToUser(NoticeUserDto noticeUserDto) {
|
||||
try {
|
||||
// 创建一个URL对象,指定目标HTTPS接口地址
|
||||
URL url = new URL("https://fc-mp-ff7b310f-94c9-4468-8260-109111c0a6b2.next.bspapp.com/push");
|
||||
URL url = new URL(appSendUrl);
|
||||
// 打开HTTPS连接
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
// 设置请求方法为POST
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.njcn.csdevice.param.DeviceMessageParam;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.rt.pojo.dto.BaseRealDataSet;
|
||||
import com.njcn.user.api.AppInfoSetFeignClient;
|
||||
@@ -154,6 +155,8 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
dto.setDescription("通讯中断");
|
||||
csCommunicateFeignClient.insertion(dto);
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
//清空缓存
|
||||
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+nDid);
|
||||
}
|
||||
|
||||
//判断设备型号发送数据
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
@@ -190,6 +191,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
//fixme 这边事务不起作用,中途出错会导致数据部分录入,再次接入会报主键冲突,所以暂时加了个重置按钮,清空台账数据的
|
||||
public void devAccess(DevAccessParam devAccessParam) {
|
||||
//日志实体
|
||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||
@@ -286,6 +288,23 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
}
|
||||
csLineService.saveBatch(csLinePoList);
|
||||
redisUtil.saveByKeyWithExpire("accessLineInfo:" + devAccessParam.getNDid(),csLinePoList,30L);
|
||||
//缓存监测点信息
|
||||
Map<Integer,String> map = new HashMap<>();
|
||||
for (CsLinePO item : csLinePoList) {
|
||||
if (Objects.isNull(item.getPosition())){
|
||||
map.put(item.getClDid(),item.getLineId());
|
||||
} else {
|
||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||
map.put(0,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
||||
map.put(1,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
||||
map.put(2,item.getLineId());
|
||||
}
|
||||
}
|
||||
}
|
||||
redisUtil.saveByKey(AppRedisKey.LINE_POSITION+devAccessParam.getNDid(),map);
|
||||
//4.监测点拓扑图表录入关系
|
||||
appLineTopologyDiagramService.saveBatch(appLineTopologyDiagramPoList);
|
||||
//5.绑定装置和人的关系
|
||||
@@ -380,6 +399,8 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
appLineTopologyDiagramPOQueryWrapper.in("line_id",collect);
|
||||
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
|
||||
}
|
||||
//清空缓存
|
||||
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+nDid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -455,6 +476,23 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
});
|
||||
csLineService.saveBatch(csLinePoList);
|
||||
redisUtil.saveByKeyWithExpire("accessLineInfo:" + nDid,csLinePoList,30L);
|
||||
//缓存监测点信息
|
||||
Map<Integer,String> map = new HashMap<>();
|
||||
for (CsLinePO item : csLinePoList) {
|
||||
if (Objects.isNull(item.getPosition())){
|
||||
map.put(item.getClDid(),item.getLineId());
|
||||
} else {
|
||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||
map.put(0,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
||||
map.put(1,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
||||
map.put(2,item.getLineId());
|
||||
}
|
||||
}
|
||||
}
|
||||
redisUtil.saveByKey(AppRedisKey.LINE_POSITION+nDid,map);
|
||||
//4.生成装置和模板的关系表
|
||||
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||
csDevModelRelationAddParm.setDevId(vo.getId());
|
||||
@@ -553,7 +591,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
//1.录入装置台账信息
|
||||
//新增便携式设备
|
||||
//新增监测设备
|
||||
CsLedgerParam csLedgerParam = new CsLedgerParam();
|
||||
csLedgerParam.setId(vo.getId());
|
||||
csLedgerParam.setPid(projectId);
|
||||
@@ -596,6 +634,24 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
});
|
||||
csLineService.saveBatch(csLinePoList);
|
||||
redisUtil.saveByKeyWithExpire("accessLineInfo:" + nDid,csLinePoList,30L);
|
||||
//缓存监测点信息
|
||||
//缓存监测点信息
|
||||
Map<Integer,String> map = new HashMap<>();
|
||||
for (CsLinePO item : csLinePoList) {
|
||||
if (Objects.isNull(item.getPosition())){
|
||||
map.put(item.getClDid(),item.getLineId());
|
||||
} else {
|
||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||
map.put(0,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
||||
map.put(1,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
||||
map.put(2,item.getLineId());
|
||||
}
|
||||
}
|
||||
}
|
||||
redisUtil.saveByKey(AppRedisKey.LINE_POSITION+nDid,map);
|
||||
//4.生成装置和模板的关系表
|
||||
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||
csDevModelRelationAddParm.setDevId(vo.getId());
|
||||
@@ -881,6 +937,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
List<CsLinePO> lineList;
|
||||
Object object = redisUtil.getObjectByKey("accessLineInfo:" + nDid);
|
||||
if (Objects.isNull(object)) {
|
||||
Map<Integer,String> map = new HashMap<>();
|
||||
lineList = csLineFeignClient.findByNdid(nDid).getData();
|
||||
for (CsLinePO item : lineList) {
|
||||
if (item.getClDid() == 0) {
|
||||
@@ -888,10 +945,23 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
} else {
|
||||
updateLineIds(modelMap.get(1), item.getClDid(), nDid);
|
||||
}
|
||||
//缓存监测点信息
|
||||
if (Objects.isNull(item.getPosition())){
|
||||
map.put(item.getClDid(),item.getLineId());
|
||||
} else {
|
||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||
map.put(0,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
||||
map.put(1,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
||||
map.put(2,item.getLineId());
|
||||
}
|
||||
}
|
||||
}
|
||||
redisUtil.saveByKey(AppRedisKey.LINE_POSITION+nDid,map);
|
||||
}
|
||||
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();
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.stream.Collectors;
|
||||
public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> implements ICsLedgerService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public CsLedger addLedgerTree(CsLedgerParam csLedgerParam) {
|
||||
CsLedger fatherCsLedger = this.lambdaQuery().eq(CsLedger::getId,csLedgerParam.getPid()).eq(CsLedger::getState,1).one();
|
||||
CsLedger csLedger = new CsLedger();
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.DataArrayFeignClient;
|
||||
import com.njcn.csdevice.api.DeviceMessageFeignClient;
|
||||
import com.njcn.csdevice.pojo.param.DataArrayParam;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
@@ -53,13 +54,12 @@ import java.util.concurrent.TimeUnit;
|
||||
public class StatServiceImpl implements IStatService {
|
||||
|
||||
private final DataArrayFeignClient dataArrayFeignClient;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
private final RedisUtil redisUtil;
|
||||
private final ChannelObjectUtil channelObjectUtil;
|
||||
private final CsLineLatestDataFeignClient csLineLatestDataFeignClient;
|
||||
private final CsDeviceFeignClient csDeviceFeignClient;
|
||||
private final DeviceMessageFeignClient deviceMessageFeignClient;
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
put("BC", "B");
|
||||
@@ -86,7 +86,7 @@ public class StatServiceImpl implements IStatService {
|
||||
String lineId = null;
|
||||
Object object1 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appAutoDataMessage.getId());
|
||||
if (Objects.isNull(object1)){
|
||||
lineInfo(appAutoDataMessage.getId());
|
||||
deviceMessageFeignClient.getLineInfo(appAutoDataMessage.getId());
|
||||
}
|
||||
//获取当前设备信息判断装置型号,来筛选监测点
|
||||
List<CsEquipmentDeliveryPO> poList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.DEVICE_LIST),CsEquipmentDeliveryPO.class);
|
||||
@@ -171,32 +171,6 @@ public class StatServiceImpl implements IStatService {
|
||||
System.gc();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存监测点相关信息
|
||||
*/
|
||||
public void lineInfo(String id) {
|
||||
Map<Integer,String> map = new HashMap<>();
|
||||
List<CsLinePO> lineList = csLineFeignClient.findByNdid(id).getData();
|
||||
if (CollectionUtil.isEmpty(lineList)){
|
||||
throw new BusinessException(StatResponseEnum.LINE_NULL);
|
||||
}
|
||||
for (CsLinePO item : lineList) {
|
||||
if (Objects.isNull(item.getPosition())){
|
||||
map.put(item.getClDid(),item.getLineId());
|
||||
} else {
|
||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||
map.put(0,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
||||
map.put(1,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
||||
map.put(2,item.getLineId());
|
||||
}
|
||||
}
|
||||
}
|
||||
redisUtil.saveByKeyWithExpire(AppRedisKey.LINE_POSITION+id,map,30L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存设备模板信息
|
||||
*/
|
||||
|
||||
@@ -73,6 +73,11 @@
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>cs-system-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>cs-harmonic-api</artifactId>
|
||||
|
||||
@@ -5,17 +5,12 @@ import com.njcn.access.utils.ChannelObjectUtil;
|
||||
import com.njcn.access.utils.FileCommonUtils;
|
||||
import com.njcn.access.utils.MqttUtil;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.DeviceMessageFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.mq.message.AppEventMessage;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.stat.enums.StatResponseEnum;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.zlevent.pojo.constant.ZlConstant;
|
||||
import com.njcn.zlevent.pojo.dto.WaveTimeDto;
|
||||
import com.njcn.zlevent.service.ICsWaveAnalysisService;
|
||||
@@ -24,7 +19,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -41,11 +39,10 @@ public class CsWaveAnalysisServiceImpl implements ICsWaveAnalysisService {
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
private final RedisUtil redisUtil;
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final ChannelObjectUtil channelObjectUtil;
|
||||
private final MqttUtil mqttUtil;
|
||||
private final FileCommonUtils fileCommonUtils;
|
||||
private final DeviceMessageFeignClient deviceMessageFeignClient;
|
||||
private static Integer mid = 1;
|
||||
|
||||
@Override
|
||||
@@ -54,7 +51,7 @@ public class CsWaveAnalysisServiceImpl implements ICsWaveAnalysisService {
|
||||
List<WaveTimeDto> list = new ArrayList<>();
|
||||
Object object1 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId());
|
||||
if (Objects.isNull(object1)){
|
||||
lineInfo(appEventMessage.getId());
|
||||
deviceMessageFeignClient.getLineInfo(appEventMessage.getId());
|
||||
}
|
||||
//获取装置id
|
||||
String deviceId = equipmentFeignClient.findDevByNDid(appEventMessage.getId()).getData().getId();
|
||||
@@ -156,30 +153,4 @@ public class CsWaveAnalysisServiceImpl implements ICsWaveAnalysisService {
|
||||
waveTimeDto.setLocation(location);
|
||||
return waveTimeDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存监测点相关信息
|
||||
*/
|
||||
public void lineInfo(String id) {
|
||||
Map<Integer,String> map = new HashMap<>();
|
||||
List<CsLinePO> lineList = csLineFeignClient.findByNdid(id).getData();
|
||||
if (CollectionUtil.isEmpty(lineList)){
|
||||
throw new BusinessException(StatResponseEnum.LINE_NULL);
|
||||
}
|
||||
for (CsLinePO item : lineList) {
|
||||
if (Objects.isNull(item.getPosition())){
|
||||
map.put(item.getClDid(),item.getLineId());
|
||||
} else {
|
||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||
map.put(0,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
||||
map.put(1,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
||||
map.put(2,item.getLineId());
|
||||
}
|
||||
}
|
||||
}
|
||||
redisUtil.saveByKeyWithExpire(AppRedisKey.LINE_POSITION+id,map,30L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package com.njcn.zlevent.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.api.*;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
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.cssystem.api.AppMsgSetFeignClient;
|
||||
import com.njcn.event.common.mapper.WlRmpEventDetailMapper;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
@@ -31,17 +33,19 @@ import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.dto.EpdDTO;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.zlevent.pojo.constant.ZlConstant;
|
||||
import com.njcn.zlevent.service.ICsEventLogsService;
|
||||
import com.njcn.zlevent.service.ICsEventService;
|
||||
import com.njcn.zlevent.service.IEventService;
|
||||
import com.njcn.zlevent.utils.SendEventUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -64,7 +68,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class EventServiceImpl implements IEventService {
|
||||
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
@@ -74,11 +78,17 @@ public class EventServiceImpl implements IEventService {
|
||||
private final ICsEventService csEventService;
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
private final ICsEventLogsService csEventLogsService;
|
||||
private final SendEventUtils sendEventUtils;
|
||||
private final WlRecordFeignClient wlRecordFeignClient;
|
||||
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
private final DeviceMessageFeignClient deviceMessageFeignClient;
|
||||
private final AppMsgSetFeignClient appMsgSetFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final SmsSendFeignClient smsSendFeignClient;
|
||||
private final CsLedgerFeignClient csLedgerFeignclient;
|
||||
@Value("${msg.msg_sign:南京灿能电力}")
|
||||
private String msgSign;
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
@@ -94,7 +104,7 @@ public class EventServiceImpl implements IEventService {
|
||||
}
|
||||
//判断监测点是否存在
|
||||
if (Objects.isNull(object1)){
|
||||
lineInfo(appEventMessage.getId());
|
||||
deviceMessageFeignClient.getLineInfo(appEventMessage.getId());
|
||||
}
|
||||
//获取装置id
|
||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(appEventMessage.getId()).getData();
|
||||
@@ -204,6 +214,27 @@ public class EventServiceImpl implements IEventService {
|
||||
//推送事件逻辑处理 && cs_event_user入库
|
||||
for (AppEventMessage.DataArray item : dataArray) {
|
||||
sendEventUtils.sendUser(1,item.getType(),po.getId(),item.getName(),eventTime,id,po.getNdid());
|
||||
//如果是暂降事件,则发送短信
|
||||
if (Objects.equals(item.getName(), "Evt_Sys_DipStr")) {
|
||||
//根据设备获取需要推送的用户列表
|
||||
List<String> userIdList = appMsgSetFeignClient.queryUserIdsByDeviceId(po.getId()).getData();
|
||||
if (CollectionUtil.isNotEmpty(userIdList)) {
|
||||
//获取用户详细信息
|
||||
List<User> userList = userFeignClient.getUserListByIds(userIdList).getData();
|
||||
if (CollectionUtil.isNotEmpty(userList)) {
|
||||
//筛选出有手机号码的;打开短信推送的
|
||||
List<User> userList1 = userList.stream().filter(item2-> StrUtil.isNotBlank(item2.getPhone()) && Objects.equals(item2.getSmsNotice(),1)).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(userList1)) {
|
||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getId()).getData();
|
||||
String msgContent = "【"+msgSign+"】" +devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName()
|
||||
+ "于" + eventTime.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生暂降事件";
|
||||
userList1.forEach(item2->{
|
||||
smsSendFeignClient.sendSmsSimple(item2.getPhone(),msgContent, "verify_code");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//evt_data入库
|
||||
@@ -412,32 +443,6 @@ public class EventServiceImpl implements IEventService {
|
||||
return Objects.isNull(result)?null:result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存监测点相关信息
|
||||
*/
|
||||
public void lineInfo(String id) {
|
||||
Map<Integer,String> map = new HashMap<>();
|
||||
List<CsLinePO> lineList = csLineFeignClient.findByNdid(id).getData();
|
||||
if (CollectionUtil.isEmpty(lineList)){
|
||||
throw new BusinessException(StatResponseEnum.LINE_NULL);
|
||||
}
|
||||
for (CsLinePO item : lineList) {
|
||||
if (Objects.isNull(item.getPosition())){
|
||||
map.put(item.getClDid(),item.getLineId());
|
||||
} else {
|
||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||
map.put(0,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
||||
map.put(1,item.getLineId());
|
||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
||||
map.put(2,item.getLineId());
|
||||
}
|
||||
}
|
||||
}
|
||||
redisUtil.saveByKeyWithExpire(AppRedisKey.LINE_POSITION+id,map,30L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存字典和influxDB表关系
|
||||
*/
|
||||
|
||||
@@ -42,7 +42,7 @@ logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
com.njcn.middle.rocket.handler.EnhanceConsumerMessageHandler: ERROR
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
|
||||
Reference in New Issue
Block a user