新增事件解析日志记录
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.njcn.zlevent.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件解析日志表
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-09-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("cs_event_logs")
|
||||
public class CsEventLogs {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
*/
|
||||
private String lineId;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 事件发生时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 事件名称
|
||||
*/
|
||||
private String tag;
|
||||
|
||||
/**
|
||||
* 事件解析状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 解析时间
|
||||
*/
|
||||
private LocalDateTime time;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.zlevent.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件解析日志表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-09-18
|
||||
*/
|
||||
public interface CsEventLogsMapper extends BaseMapper<CsEventLogs> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.zlevent.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件解析日志表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-09-18
|
||||
*/
|
||||
public interface ICsEventLogsService extends IService<CsEventLogs> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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-18
|
||||
*/
|
||||
@Service
|
||||
public class CsEventLogsServiceImpl extends ServiceImpl<CsEventLogsMapper, CsEventLogs> implements ICsEventLogsService {
|
||||
|
||||
}
|
||||
@@ -28,6 +28,8 @@ import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.po.app.AppInfoSet;
|
||||
import com.njcn.zlevent.pojo.dto.NoticeUserDto;
|
||||
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
||||
import com.njcn.zlevent.service.ICsEventLogsService;
|
||||
import com.njcn.zlevent.service.ICsEventService;
|
||||
import com.njcn.zlevent.service.ICsEventUserService;
|
||||
import com.njcn.zlevent.service.IEventService;
|
||||
@@ -90,6 +92,8 @@ public class EventServiceImpl implements IEventService {
|
||||
|
||||
private final EventLogsFeignClient eventLogsFeignClient;
|
||||
|
||||
private final ICsEventLogsService csEventLogsService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void analysis(AppEventMessage appEventMessage) {
|
||||
@@ -98,9 +102,8 @@ public class EventServiceImpl implements IEventService {
|
||||
List<String> records = new ArrayList<String>();
|
||||
List<CsEventUserPO> list2 = new ArrayList<>();
|
||||
//获取监测点id
|
||||
String lineId = null;
|
||||
String lineId = null,id = null,tag = null;;
|
||||
LocalDateTime eventTime = null;
|
||||
String id = null;
|
||||
Object object1 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId());
|
||||
//判断字典数据是否存在
|
||||
if (Objects.isNull(redisUtil.getObjectByKey(AppRedisKey.ELE_EPD_PQD))){
|
||||
@@ -116,6 +119,7 @@ public class EventServiceImpl implements IEventService {
|
||||
}
|
||||
//获取装置id
|
||||
String deviceId = equipmentFeignClient.findDevByNDid(appEventMessage.getId()).getData().getId();
|
||||
try {
|
||||
//处理事件数据
|
||||
List<AppEventMessage.DataArray> dataArray = appEventMessage.getMsg().getDataArray();
|
||||
for (AppEventMessage.DataArray item : dataArray) {
|
||||
@@ -126,8 +130,9 @@ public class EventServiceImpl implements IEventService {
|
||||
csEvent.setLineId(lineId);
|
||||
csEvent.setDeviceId(deviceId);
|
||||
eventTime = timeFormat(item.getDataTimeSec(),item.getDataTimeUSec());
|
||||
csEvent.setStartTime(timeFormat(item.getDataTimeSec(),item.getDataTimeUSec()));
|
||||
csEvent.setTag(item.getName());
|
||||
csEvent.setStartTime(eventTime);
|
||||
tag = item.getName();
|
||||
csEvent.setTag(tag);
|
||||
csEvent.setType(0);
|
||||
csEvent.setClDid(appEventMessage.getMsg().getClDid());
|
||||
//todo 默认等级先设为1.后期根据事件再做调整
|
||||
@@ -152,6 +157,15 @@ public class EventServiceImpl implements IEventService {
|
||||
}
|
||||
//事件用户关系入库
|
||||
list2 = deviceUserList(deviceId,id);
|
||||
//事件处理日志库
|
||||
CsEventLogs csEventLogs = new CsEventLogs();
|
||||
csEventLogs.setLineId(lineId);
|
||||
csEventLogs.setDeviceId(deviceId);
|
||||
csEventLogs.setStartTime(timeFormat(item.getDataTimeSec(),item.getDataTimeUSec()));
|
||||
csEventLogs.setTag(item.getName());
|
||||
csEventLogs.setStatus(1);
|
||||
csEventLogs.setTime(LocalDateTime.now());
|
||||
csEventLogsService.save(csEventLogs);
|
||||
}
|
||||
//cs_event入库
|
||||
if (CollectionUtil.isNotEmpty(list1)){
|
||||
@@ -189,6 +203,17 @@ public class EventServiceImpl implements IEventService {
|
||||
}
|
||||
eventLogsFeignClient.addLogs(csEventSendMsgList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CsEventLogs csEventLogs = new CsEventLogs();
|
||||
csEventLogs.setLineId(lineId);
|
||||
csEventLogs.setDeviceId(deviceId);
|
||||
csEventLogs.setStartTime(eventTime);
|
||||
csEventLogs.setTag(tag);
|
||||
csEventLogs.setStatus(0);
|
||||
csEventLogs.setTime(LocalDateTime.now());
|
||||
csEventLogs.setRemark(e.getMessage());
|
||||
csEventLogsService.save(csEventLogs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user