文件名称调整
This commit is contained in:
@@ -18,8 +18,8 @@ import lombok.Setter;
|
|||||||
* @since 2023-09-08
|
* @since 2023-09-08
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("cs_event_logs")
|
@TableName("cs_event_file_logs")
|
||||||
public class CsEventLogs {
|
public class CsEventFileLogs {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.njcn.zlevent.mapper;
|
package com.njcn.zlevent.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
import com.njcn.zlevent.pojo.po.CsEventFileLogs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -11,7 +11,6 @@ import com.njcn.zlevent.pojo.po.CsEventLogs;
|
|||||||
* @author xuyang
|
* @author xuyang
|
||||||
* @since 2023-09-08
|
* @since 2023-09-08
|
||||||
*/
|
*/
|
||||||
public interface CsEventLogsMapper extends BaseMapper<CsEventLogs
|
public interface CsEventFileLogsMapper extends BaseMapper<CsEventFileLogs> {
|
||||||
> {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.njcn.zlevent.service;
|
package com.njcn.zlevent.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
import com.njcn.zlevent.pojo.po.CsEventFileLogs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -11,6 +11,6 @@ import com.njcn.zlevent.pojo.po.CsEventLogs;
|
|||||||
* @author xuyang
|
* @author xuyang
|
||||||
* @since 2023-09-08
|
* @since 2023-09-08
|
||||||
*/
|
*/
|
||||||
public interface ICsEventLogsService extends IService<CsEventLogs> {
|
public interface ICsEventFileLogsService extends IService<CsEventFileLogs> {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.njcn.zlevent.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.zlevent.mapper.CsEventFileLogsMapper;
|
||||||
|
import com.njcn.zlevent.pojo.po.CsEventFileLogs;
|
||||||
|
import com.njcn.zlevent.service.ICsEventFileLogsService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 治理暂态文件解析日志 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-09-08
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CsEventFileLogsServiceImpl extends ServiceImpl<CsEventFileLogsMapper, CsEventFileLogs> implements ICsEventFileLogsService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.njcn.zlevent.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.njcn.zlevent.mapper.CsEventLogsMapper;
|
|
||||||
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
|
||||||
import com.njcn.zlevent.service.ICsEventLogsService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 治理暂态文件解析日志 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @since 2023-09-08
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class CsEventLogsServiceImpl extends ServiceImpl<CsEventLogsMapper, CsEventLogs> implements ICsEventLogsService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -7,6 +7,8 @@ import com.njcn.common.pojo.exception.BusinessException;
|
|||||||
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
|
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
|
||||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
|
import com.njcn.csdevice.api.EventLogsFeignClient;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEventSendMsg;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||||
@@ -86,6 +88,8 @@ public class EventServiceImpl implements IEventService {
|
|||||||
|
|
||||||
private final UserFeignClient userFeignClient;
|
private final UserFeignClient userFeignClient;
|
||||||
|
|
||||||
|
private final EventLogsFeignClient eventLogsFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void analysis(AppEventMessage appEventMessage) {
|
public void analysis(AppEventMessage appEventMessage) {
|
||||||
@@ -96,6 +100,7 @@ public class EventServiceImpl implements IEventService {
|
|||||||
//获取监测点id
|
//获取监测点id
|
||||||
String lineId = null;
|
String lineId = null;
|
||||||
LocalDateTime eventTime = null;
|
LocalDateTime eventTime = null;
|
||||||
|
String id = null;
|
||||||
Object object1 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId());
|
Object object1 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId());
|
||||||
//判断字典数据是否存在
|
//判断字典数据是否存在
|
||||||
if (Objects.isNull(redisUtil.getObjectByKey(AppRedisKey.ELE_EPD_PQD))){
|
if (Objects.isNull(redisUtil.getObjectByKey(AppRedisKey.ELE_EPD_PQD))){
|
||||||
@@ -114,7 +119,7 @@ public class EventServiceImpl implements IEventService {
|
|||||||
//处理事件数据
|
//处理事件数据
|
||||||
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
||||||
for (AppEventMessage.DataArray item : dataArray) {
|
for (AppEventMessage.DataArray item : dataArray) {
|
||||||
String id = IdUtil.fastSimpleUUID();
|
id = IdUtil.fastSimpleUUID();
|
||||||
//事件入库
|
//事件入库
|
||||||
CsEventPO csEvent = new CsEventPO();
|
CsEventPO csEvent = new CsEventPO();
|
||||||
csEvent.setId(id);
|
csEvent.setId(id);
|
||||||
@@ -133,7 +138,7 @@ public class EventServiceImpl implements IEventService {
|
|||||||
if (!Objects.isNull(item.getParam())){
|
if (!Objects.isNull(item.getParam())){
|
||||||
String tableName = map.get(item.getName());
|
String tableName = map.get(item.getName());
|
||||||
List<AppEventMessage.Param> params = item.getParam();
|
List<AppEventMessage.Param> params = item.getParam();
|
||||||
params.forEach(param->{
|
for (AppEventMessage.Param param : params) {
|
||||||
Map<String, String> tags = new HashMap<>();
|
Map<String, String> tags = new HashMap<>();
|
||||||
tags.put(InfluxDBTableConstant.UUID,id);
|
tags.put(InfluxDBTableConstant.UUID,id);
|
||||||
Map<String,Object> fields = new HashMap<>();
|
Map<String,Object> fields = new HashMap<>();
|
||||||
@@ -143,7 +148,7 @@ public class EventServiceImpl implements IEventService {
|
|||||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||||
batchPoints.point(point);
|
batchPoints.point(point);
|
||||||
records.add(batchPoints.lineProtocol());
|
records.add(batchPoints.lineProtocol());
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
//事件用户关系入库
|
//事件用户关系入库
|
||||||
list2 = deviceUserList(deviceId,id);
|
list2 = deviceUserList(deviceId,id);
|
||||||
@@ -161,8 +166,29 @@ public class EventServiceImpl implements IEventService {
|
|||||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
|
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
|
||||||
}
|
}
|
||||||
//todo 根据不同事件需要做处理,目前先测试消息通知
|
//todo 根据不同事件需要做处理,目前先测试消息通知
|
||||||
String content = appEventMessage.getId() + "于" +eventTime+ "发生暂态事件";
|
List<User> userList = getEventUser(deviceId);
|
||||||
sendEventToUser(getEventUser(deviceId),"暂态事件",content,1);
|
if (CollectionUtil.isNotEmpty(userList)){
|
||||||
|
List<CsEventSendMsg> csEventSendMsgList = new ArrayList<>();
|
||||||
|
List<String> devCodeList = userList.stream().map(User::getDevCode).collect(Collectors.toList());
|
||||||
|
String content = appEventMessage.getId() + "于" +eventTime+ "发生暂态事件";
|
||||||
|
sendEventToUser(devCodeList,"暂态事件",content,1);
|
||||||
|
//记录推送日志
|
||||||
|
for (User item : userList) {
|
||||||
|
CsEventSendMsg csEventSendMsg = new CsEventSendMsg();
|
||||||
|
csEventSendMsg.setUserId(item.getId());
|
||||||
|
csEventSendMsg.setEventId(id);
|
||||||
|
csEventSendMsg.setSendTime(LocalDateTime.now());
|
||||||
|
if (Objects.isNull(item.getDevCode())){
|
||||||
|
csEventSendMsg.setStatus(0);
|
||||||
|
csEventSendMsg.setRemark("用户设备识别码为空");
|
||||||
|
} else {
|
||||||
|
csEventSendMsg.setDevCode(item.getDevCode());
|
||||||
|
csEventSendMsg.setStatus(1);
|
||||||
|
}
|
||||||
|
csEventSendMsgList.add(csEventSendMsg);
|
||||||
|
}
|
||||||
|
eventLogsFeignClient.addLogs(csEventSendMsgList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,7 +268,8 @@ public class EventServiceImpl implements IEventService {
|
|||||||
/**
|
/**
|
||||||
* 获取需要通知暂态事件的用户
|
* 获取需要通知暂态事件的用户
|
||||||
*/
|
*/
|
||||||
public List<String> getEventUser(String devId) {
|
public List<User> getEventUser(String devId) {
|
||||||
|
List<User> users = new ArrayList<>();
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
List<String> devCode = new ArrayList<>();
|
List<String> devCode = new ArrayList<>();
|
||||||
//获取设备下主用户和子用户集合
|
//获取设备下主用户和子用户集合
|
||||||
@@ -254,12 +281,10 @@ public class EventServiceImpl implements IEventService {
|
|||||||
.filter(person -> person.getEventInfo() == 1)
|
.filter(person -> person.getEventInfo() == 1)
|
||||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
//获取用户的devCode
|
|
||||||
if (CollectionUtil.isNotEmpty(list)){
|
if (CollectionUtil.isNotEmpty(list)){
|
||||||
List<User> users = userFeignClient.getUserByIdList(result).getData();
|
users = userFeignClient.getUserByIdList(result).getData();
|
||||||
devCode = users.stream().map(User::getDevCode).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
return devCode;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,26 +21,24 @@ import com.njcn.zlevent.param.CsEventParam;
|
|||||||
import com.njcn.zlevent.pojo.dto.FileInfoDto;
|
import com.njcn.zlevent.pojo.dto.FileInfoDto;
|
||||||
import com.njcn.zlevent.pojo.dto.FileStreamDto;
|
import com.njcn.zlevent.pojo.dto.FileStreamDto;
|
||||||
import com.njcn.zlevent.pojo.dto.WaveTimeDto;
|
import com.njcn.zlevent.pojo.dto.WaveTimeDto;
|
||||||
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
import com.njcn.zlevent.pojo.po.CsEventFileLogs;
|
||||||
import com.njcn.zlevent.service.ICsEventLogsService;
|
import com.njcn.zlevent.service.ICsEventFileLogsService;
|
||||||
import com.njcn.zlevent.service.ICsEventService;
|
import com.njcn.zlevent.service.ICsEventService;
|
||||||
import com.njcn.zlevent.service.IFileService;
|
import com.njcn.zlevent.service.IFileService;
|
||||||
import com.njcn.zlevent.utils.FileCheckUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.NoSuchFileException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.Base64;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
@@ -64,7 +62,7 @@ public class FileServiceImpl implements IFileService {
|
|||||||
|
|
||||||
private final ICsEventService csEventService;
|
private final ICsEventService csEventService;
|
||||||
|
|
||||||
private final ICsEventLogsService csEventLogsService;
|
private final ICsEventFileLogsService csEventLogsService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analysisFileInfo(AppFileMessage appFileMessage) {
|
public void analysisFileInfo(AppFileMessage appFileMessage) {
|
||||||
@@ -112,7 +110,7 @@ public class FileServiceImpl implements IFileService {
|
|||||||
@Override
|
@Override
|
||||||
public void analysisFileStream(AppFileMessage appFileMessage) {
|
public void analysisFileStream(AppFileMessage appFileMessage) {
|
||||||
//日志记录
|
//日志记录
|
||||||
CsEventLogs csEventLogs = new CsEventLogs();
|
CsEventFileLogs csEventLogs = new CsEventFileLogs();
|
||||||
csEventLogs.setNdid(appFileMessage.getId());
|
csEventLogs.setNdid(appFileMessage.getId());
|
||||||
csEventLogs.setFileName(appFileMessage.getMsg().getName());
|
csEventLogs.setFileName(appFileMessage.getMsg().getName());
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user