云前置改造-暂态数据补召功能

This commit is contained in:
xy
2025-10-15 20:50:04 +08:00
parent 753a22eb4c
commit 9531e18e93
14 changed files with 462 additions and 18 deletions

View File

@@ -37,6 +37,11 @@ public class CsTerminalLogs extends BaseEntity implements Serializable {
*/ */
private String deviceName; private String deviceName;
/**
* 监测点id
*/
private String lineId;
/** /**
* 前置服务器id * 前置服务器id
*/ */

View File

@@ -57,6 +57,11 @@ public class CsTerminalReply extends BaseEntity implements Serializable {
*/ */
private String deviceName; private String deviceName;
/**
* 监测点id
*/
private String lineId;
/** /**
* 是否收到0未收到 1收到 * 是否收到0未收到 1收到
*/ */

View File

@@ -10,10 +10,10 @@ import com.njcn.csdevice.param.IcdParam;
import com.njcn.csdevice.pojo.vo.CldLedgerVo; import com.njcn.csdevice.pojo.vo.CldLedgerVo;
import com.njcn.csdevice.pojo.vo.DeviceInfo; import com.njcn.csdevice.pojo.vo.DeviceInfo;
import com.njcn.csdevice.service.IcdService; import com.njcn.csdevice.service.IcdService;
import com.njcn.mq.message.CldControlMessage;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -68,10 +68,51 @@ public class IcdController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/restartProcess") @PostMapping("/restartProcess")
@ApiOperation("重启前置机进程") @ApiOperation("重启前置机进程")
@ApiImplicitParam(name = "message", value = "message", required = true) @ApiImplicitParams({
public HttpResult<String> restartProcess(@RequestBody CldControlMessage message){ @ApiImplicitParam(name = "nodeId", value = "前置服务器id", required = true),
@ApiImplicitParam(name = "processNo", value = "进程号", required = true)
})
public HttpResult<String> restartProcess(@RequestParam String nodeId,@RequestParam Integer processNo){
String methodDescribe = getMethodDescribe("restartProcess"); String methodDescribe = getMethodDescribe("restartProcess");
icdService.restartProcess(message); icdService.restartProcess(nodeId,processNo);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bzFileByEventId")
@ApiOperation("指定事件补召波形")
@ApiImplicitParam(name = "eventId", value = "事件id", required = true)
public HttpResult<String> bzFileByEventId(@RequestParam String eventId){
String methodDescribe = getMethodDescribe("bzFileByEventId");
icdService.bzFileByEventId(eventId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bzEvent")
@ApiOperation("补召事件")
@ApiImplicitParams({
@ApiImplicitParam(name = "lineList", value = "监测点id集合"),
@ApiImplicitParam(name = "startTime", value = "开始时间"),
@ApiImplicitParam(name = "endTime", value = "结束时间")
})
public HttpResult<String> bzEvent(@RequestParam(required = false) List<String> lineList,@RequestParam String startTime,@RequestParam String endTime){
String methodDescribe = getMethodDescribe("bzEvent");
icdService.bzEvent(lineList,startTime,endTime);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bzFile")
@ApiOperation("补召波形")
@ApiImplicitParams({
@ApiImplicitParam(name = "lineList", value = "监测点id"),
@ApiImplicitParam(name = "startTime", value = "开始时间"),
@ApiImplicitParam(name = "endTime", value = "结束时间")
})
public HttpResult<String> bzFile(@RequestParam(required = false) List<String> lineList,@RequestParam String startTime,@RequestParam String endTime){
String methodDescribe = getMethodDescribe("bzFile");
icdService.bzFile(lineList,startTime,endTime);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }

View File

@@ -130,6 +130,12 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
*/ */
List<CsEquipmentDeliveryPO> getAll(); List<CsEquipmentDeliveryPO> getAll();
/**
* 获取所有装置信息(投运且在线)
* @return
*/
List<CsEquipmentDeliveryPO> getAllOnline();
/** /**
* 判断设备型号 * 判断设备型号
*/ */

View File

@@ -4,7 +4,6 @@ import com.njcn.csdevice.param.IcdLedgerParam;
import com.njcn.csdevice.param.IcdParam; import com.njcn.csdevice.param.IcdParam;
import com.njcn.csdevice.pojo.vo.CldLedgerVo; import com.njcn.csdevice.pojo.vo.CldLedgerVo;
import com.njcn.csdevice.pojo.vo.DeviceInfo; import com.njcn.csdevice.pojo.vo.DeviceInfo;
import com.njcn.mq.message.CldControlMessage;
import java.util.List; import java.util.List;
@@ -16,6 +15,12 @@ public interface IcdService {
CldLedgerVo getLedgerById(String id); CldLedgerVo getLedgerById(String id);
void restartProcess(CldControlMessage message); void restartProcess(String nodeId, Integer processNo);
void bzFileByEventId(String eventId);
void bzEvent(List<String> lineList, String startTime, String endTime);
void bzFile(List<String> lineList,String startTime, String endTime);
} }

View File

@@ -706,6 +706,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return this.lambdaQuery().ne(CsEquipmentDeliveryPO::getRunStatus,0).list(); return this.lambdaQuery().ne(CsEquipmentDeliveryPO::getRunStatus,0).list();
} }
@Override
public List<CsEquipmentDeliveryPO> getAllOnline() {
return this.lambdaQuery()
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
.isNotNull(CsEquipmentDeliveryPO::getNodeId)
.list();
}
@Override @Override
public boolean judgeDevModel(String nDid) { public boolean judgeDevModel(String nDid) {
boolean result = false; boolean result = false;

View File

@@ -146,8 +146,10 @@ public class CsTerminalLogsServiceImpl extends ServiceImpl<CsTerminalLogsMapper,
operateType = 0; operateType = 0;
} else if (Objects.equals(code, "ledger_modify")) { } else if (Objects.equals(code, "ledger_modify")) {
operateType = 1; operateType = 1;
} else{ } else if (Objects.equals(code, "delete_terminal")){
operateType = 2; operateType = 2;
} else {
operateType = 3;
} }
//找出最新的数据,将状态改为未推送,下次可以再次推送 //找出最新的数据,将状态改为未推送,下次可以再次推送
this.lambdaUpdate() this.lambdaUpdate()

View File

@@ -59,12 +59,12 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
} else { } else {
list.forEach(item->{ list.forEach(item->{
String key; String key;
String code; String code = "";
if (Objects.equals(item.getCode(), "add_terminal")) { if (Objects.equals(item.getCode(), "add_terminal")) {
code = "新增"; code = "新增";
} else if (Objects.equals(item.getCode(), "ledger_modify")) { } else if (Objects.equals(item.getCode(), "ledger_modify")) {
code = "修改"; code = "修改";
} else { } else if (Objects.equals(item.getCode(), "delete_terminal")){
code = "删除"; code = "删除";
} }
String nodeName = nodeService.getNodeById(item.getNodeId()).getName(); String nodeName = nodeService.getNodeById(item.getNodeId()).getName();

View File

@@ -1,6 +1,10 @@
package com.njcn.csdevice.service.impl; package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.util.StringUtil;
@@ -16,7 +20,12 @@ import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CldLedgerVo; import com.njcn.csdevice.pojo.vo.CldLedgerVo;
import com.njcn.csdevice.pojo.vo.DeviceInfo; import com.njcn.csdevice.pojo.vo.DeviceInfo;
import com.njcn.csdevice.service.*; import com.njcn.csdevice.service.*;
import com.njcn.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.mq.message.BZEventMessage;
import com.njcn.mq.message.CldControlMessage; import com.njcn.mq.message.CldControlMessage;
import com.njcn.mq.template.BZEventMessageTemplate;
import com.njcn.mq.template.CldControlMessageTemplate;
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.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
@@ -27,6 +36,8 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -44,7 +55,12 @@ class IcdServiceImpl implements IcdService {
private final CsEquipmentDeliveryService csEquipmentDeliveryService; private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final CsLinePOService csLinePOService; private final CsLinePOService csLinePOService;
private final ICsLedgerService csLedgerService; private final ICsLedgerService csLedgerService;
private final CldControlMessageTemplate controlMessageTemplate;
private final BZEventMessageTemplate bzEventMessageTemplate;
private final EventFeignClient eventFeignClient;
private final ICsTerminalLogsService csTerminalLogsService; private final ICsTerminalLogsService csTerminalLogsService;
private final ICsTerminalReplyService csTerminalReplyService;
private final DateTimeFormatter microsecondFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
@Override @Override
public List<DeviceInfo> getLedgerInfo(IcdParam param) { public List<DeviceInfo> getLedgerInfo(IcdParam param) {
@@ -161,8 +177,307 @@ class IcdServiceImpl implements IcdService {
} }
@Override @Override
public void restartProcess(CldControlMessage message) { public void restartProcess(String nodeId, Integer processNo) {
Node node = nodeService.getNodeById(nodeId);
CldControlMessage cldControlMessage = new CldControlMessage();
cldControlMessage.setGuid(IdUtil.simpleUUID());
cldControlMessage.setCode("set_process");
cldControlMessage.setNodeId(nodeId);
cldControlMessage.setProcessNo(processNo);
cldControlMessage.setFun("delete");
cldControlMessage.setProcessNum(node.getMaxProcessNum());
controlMessageTemplate.sendMember(cldControlMessage,nodeId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void bzFileByEventId(String eventId) {
CsEventPO po = eventFeignClient.queryById(eventId).getData();
if (ObjectUtil.isNull(po)) {
throw new BusinessException("事件缺失");
}
//获取设备信息
CsEquipmentDeliveryPO dev = csEquipmentDeliveryService.getDevByLineId(po.getLineId());
BZEventMessage.File file = new BZEventMessage.File();
file.setGuid(po.getId());
file.setTerminalId(po.getDeviceId());
file.setMonitorId(po.getLineId());
file.setTimeList(Collections.singletonList(po.getStartTime().format(microsecondFormatter)));
file.setDataType(2);
//记录发送日志
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
csTerminalLogs.setId(po.getId());
csTerminalLogs.setDeviceId(dev.getId());
csTerminalLogs.setLineId(po.getLineId());
csTerminalLogs.setOperateType(3);
csTerminalLogs.setNodeId(dev.getNodeId());
csTerminalLogs.setNodeProcess(dev.getNodeProcess());
csTerminalLogs.setIsPush(1);
csTerminalLogsService.saveOrUpdate(csTerminalLogs);
//记录响应日志
CsTerminalReply csTerminalReply = new CsTerminalReply();
csTerminalReply.setId(IdUtil.simpleUUID());
csTerminalReply.setReplyId(po.getId());
csTerminalReply.setNodeId(dev.getNodeId());
csTerminalReply.setProcessNo(dev.getNodeProcess());
csTerminalReply.setDeviceId(dev.getId());
csTerminalReply.setLineId(po.getLineId());
csTerminalReply.setIsReceived(0);
csTerminalReply.setCode("oneFile");
csTerminalReplyService.saveOrUpdate(csTerminalReply);
//发送消息
bzEventMessageTemplate.sendMember(file,dev.getNodeId());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void bzEvent(List<String> lineList, String startTime, String endTime) {
// 参数校验
if (StrUtil.isBlank(startTime) || StrUtil.isBlank(endTime)) {
throw new BusinessException("开始时间和结束时间不能为空");
}
LocalDateTime startLocalDate;
LocalDateTime endLocalDate;
try {
startLocalDate = LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATE_PATTERN);
endLocalDate = LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATE_PATTERN);
} catch (Exception e) {
throw new BusinessException("时间格式不正确,请使用 yyyy-MM-dd 格式");
}
String beginDay = LocalDateTimeUtil.format(
LocalDateTimeUtil.beginOfDay(startLocalDate),
DatePattern.NORM_DATETIME_PATTERN
);
String endDay = LocalDateTimeUtil.format(
LocalDateTimeUtil.endOfDay(endLocalDate),
DatePattern.NORM_DATETIME_PATTERN
);
if (CollectionUtil.isNotEmpty(lineList)) {
processWithLineIds(lineList, beginDay, endDay);
} else {
processWithoutLineIds(beginDay, endDay);
}
}
private void processWithLineIds(List<String> lineList, String beginDay, String endDay) {
List<CsLinePO> csLineList = csLinePOService.listByIds(lineList);
List<String> deviceIdList = csLineList.stream()
.map(CsLinePO::getDeviceId)
.distinct()
.collect(Collectors.toList());
List<CsEquipmentDeliveryPO> equipmentList = csEquipmentDeliveryService.listByIds(deviceIdList);
Map<String, List<CsEquipmentDeliveryPO>> devMap = equipmentList.stream()
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
handleEventsAndLogs(devMap, csLineList, beginDay, endDay);
}
private void processWithoutLineIds(String beginDay, String endDay) {
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getAllOnline();
if (CollectionUtil.isEmpty(devList)) return;
List<String> deviceIds = devList.stream()
.map(CsEquipmentDeliveryPO::getId)
.collect(Collectors.toList());
List<CsLinePO> csLineList = csLinePOService.getLinesByDevList(deviceIds);
Map<String, List<CsEquipmentDeliveryPO>> devMap = devList.stream()
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
handleEventsAndLogs(devMap, csLineList, beginDay, endDay);
}
private void handleEventsAndLogs(
Map<String, List<CsEquipmentDeliveryPO>> devMap,
List<CsLinePO> csLineList,
String beginDay,
String endDay
) {
devMap.forEach((nodeId, devices) -> {
List<BZEventMessage.Event> events = new ArrayList<>();
List<CsTerminalLogs> logsToSave = new ArrayList<>();
List<CsTerminalReply> repliesToSave = new ArrayList<>();
for (CsEquipmentDeliveryPO device : devices) {
String uuid = IdUtil.simpleUUID();
BZEventMessage.Event event = buildEvent(uuid, device, csLineList, beginDay, endDay);
events.add(event);
CsTerminalLogs log = buildTerminalLog(uuid, device, csLineList);
logsToSave.add(log);
CsTerminalReply reply = buildTerminalReply(uuid, device, csLineList);
repliesToSave.add(reply);
}
csTerminalLogsService.saveBatch(logsToSave);
csTerminalReplyService.saveBatch(repliesToSave);
bzEventMessageTemplate.sendMember(events, nodeId);
});
}
private BZEventMessage.Event buildEvent(String guid, CsEquipmentDeliveryPO device,
List<CsLinePO> csLineList, String beginDay, String endDay) {
BZEventMessage.Event event = new BZEventMessage.Event();
event.setGuid(guid);
event.setTerminalId(device.getId());
List<String> monitorIds = csLineList.stream()
.filter(line -> Objects.equals(line.getDeviceId(), device.getId()))
.map(CsLinePO::getLineId)
.collect(Collectors.toList());
event.setMonitorIdList(monitorIds);
event.setDataType(1);
event.setTimeInterval(Collections.singletonList(beginDay + "~" + endDay));
return event;
}
private CsTerminalLogs buildTerminalLog(String id, CsEquipmentDeliveryPO device,
List<CsLinePO> csLineList) {
List<String> lineIds = csLineList.stream()
.filter(line -> Objects.equals(line.getDeviceId(), device.getId()))
.map(CsLinePO::getLineId)
.collect(Collectors.toList());
CsTerminalLogs log = new CsTerminalLogs();
log.setId(id);
log.setDeviceId(device.getId());
log.setLineId(String.join(",", lineIds));
log.setOperateType(3);
log.setNodeId(device.getNodeId());
log.setNodeProcess(device.getNodeProcess());
log.setIsPush(1);
return log;
}
private CsTerminalReply buildTerminalReply(String replyId, CsEquipmentDeliveryPO device,
List<CsLinePO> csLineList) {
List<String> lineIds = csLineList.stream()
.filter(line -> Objects.equals(line.getDeviceId(), device.getId()))
.map(CsLinePO::getLineId)
.collect(Collectors.toList());
CsTerminalReply reply = new CsTerminalReply();
reply.setId(IdUtil.simpleUUID());
reply.setReplyId(replyId);
reply.setNodeId(device.getNodeId());
reply.setProcessNo(device.getNodeProcess());
reply.setDeviceId(device.getId());
reply.setLineId(String.join(",", lineIds));
reply.setIsReceived(0);
reply.setCode("allEvent");
return reply;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void bzFile(List<String> lineList, String startTime, String endTime) {
String beginDay = LocalDateTimeUtil.format(
LocalDateTimeUtil.beginOfDay(LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATE_PATTERN)),
DatePattern.NORM_DATETIME_PATTERN
);
String endDay = LocalDateTimeUtil.format(
LocalDateTimeUtil.endOfDay(LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATE_PATTERN)),
DatePattern.NORM_DATETIME_PATTERN
);
// 获取监测点没有波形的事件信息
List<CsEventPO> eventList = eventFeignClient.getEventByTime(lineList, beginDay, endDay).getData();
if (CollUtil.isEmpty(eventList)) {
return;
}
// 获取装置信息,用于区分不同服务器
List<String> deviceIds = eventList.stream()
.map(CsEventPO::getDeviceId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (CollUtil.isEmpty(deviceIds)) {
return;
}
List<CsEquipmentDeliveryPO> equipmentList = csEquipmentDeliveryService.listByIds(deviceIds);
if (CollUtil.isEmpty(equipmentList)) {
return;
}
Map<String, List<CsEquipmentDeliveryPO>> nodeToDeviceMap = equipmentList.stream()
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
// 构建 deviceId -> CsEventPO 映射,避免重复 filter
Map<String, List<CsEventPO>> deviceToEventMap = eventList.stream()
.filter(event -> event.getDeviceId() != null)
.collect(Collectors.groupingBy(CsEventPO::getDeviceId));
nodeToDeviceMap.forEach((nodeId, deviceList) -> {
List<BZEventMessage.File> msgList = new ArrayList<>();
List<CsTerminalLogs> logList = new ArrayList<>();
List<CsTerminalReply> replyList = new ArrayList<>();
for (CsEquipmentDeliveryPO device : deviceList) {
String deviceId = device.getId();
List<CsEventPO> eventsForDevice = deviceToEventMap.getOrDefault(deviceId, Collections.emptyList());
Map<String, List<CsEventPO>> lineToEventMap = eventsForDevice.stream()
.filter(event -> event.getLineId() != null)
.collect(Collectors.groupingBy(CsEventPO::getLineId));
lineToEventMap.forEach((lineId, eventGroup) -> {
BZEventMessage.File event = new BZEventMessage.File();
String guid = IdUtil.simpleUUID();
event.setGuid(guid);
event.setTerminalId(deviceId);
event.setMonitorId(lineId);
event.setDataType(2);
List<String> timeList = eventGroup.stream()
.map(CsEventPO::getStartTime)
.filter(Objects::nonNull)
.map(dt -> dt.format(microsecondFormatter))
.collect(Collectors.toList());
event.setTimeList(timeList);
msgList.add(event);
// 记录发送日志
CsTerminalLogs log = new CsTerminalLogs();
log.setId(guid);
log.setDeviceId(deviceId);
log.setLineId(lineId);
log.setOperateType(3);
log.setNodeId(device.getNodeId());
log.setNodeProcess(device.getNodeProcess());
log.setIsPush(1);
logList.add(log);
// 记录响应日志
CsTerminalReply reply = new CsTerminalReply();
reply.setId(IdUtil.simpleUUID());
reply.setReplyId(guid);
reply.setNodeId(device.getNodeId());
reply.setProcessNo(device.getNodeProcess());
reply.setDeviceId(deviceId);
reply.setLineId(lineId);
reply.setIsReceived(0);
reply.setCode("allFile");
replyList.add(reply);
});
}
if (CollUtil.isNotEmpty(logList)) {
csTerminalLogsService.saveBatch(logList);
}
if (CollUtil.isNotEmpty(replyList)) {
csTerminalReplyService.saveBatch(replyList);
}
if (CollUtil.isNotEmpty(msgList)) {
bzEventMessageTemplate.sendMember(msgList, nodeId);
}
});
} }
/** /**

View File

@@ -1,19 +1,24 @@
package com.njcn.csharmonic.api; package com.njcn.csharmonic.api;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.vo.DataGroupEventVO; import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csharmonic.api.fallback.EventFeignClientFallbackFactory; import com.njcn.csharmonic.api.fallback.EventFeignClientFallbackFactory;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@@ -30,5 +35,9 @@ public interface EventFeignClient {
@PostMapping("/queryByIndex") @PostMapping("/queryByIndex")
HttpResult<CsEventPO> queryByIndex(@RequestBody CsEventPO csEventPO); HttpResult<CsEventPO> queryByIndex(@RequestBody CsEventPO csEventPO);
@PostMapping("/queryById")
HttpResult<CsEventPO> queryById(@RequestParam("eventId") String eventId);
@PostMapping("/getEventByTime")
HttpResult<List<CsEventPO>> getEventByTime(@RequestParam(name = "lineList", required = false) List<String> lineList,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime);
} }

View File

@@ -8,13 +8,10 @@ import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csharmonic.api.EventFeignClient; import com.njcn.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@@ -49,6 +46,18 @@ public class EventFeignClientFallbackFactory implements FallbackFactory<EventFei
log.error("{}异常,降级处理,异常为:{}","根据根据表唯一索引查询(用于校验是否存在该事件)s",cause.toString()); log.error("{}异常,降级处理,异常为:{}","根据根据表唯一索引查询(用于校验是否存在该事件)s",cause.toString());
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<CsEventPO> queryById(String eventId) {
log.error("{}异常,降级处理,异常为:{}","根据事件id查询数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsEventPO>> getEventByTime(List<String> lineList, String startTime, String endTime) {
log.error("{}异常,降级处理,异常为:{}","根据时间获取无波形的暂态事件",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -19,6 +19,7 @@ import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -111,6 +112,16 @@ public class CsEventController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryById")
@ApiOperation("根据事件id查询数据")
public HttpResult<CsEventPO> queryById(String eventId) {
String methodDescribe = getMethodDescribe("queryById");
CsEventPO po = csEventPOService.lambdaQuery().eq(CsEventPO::getId,eventId).one();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryByModelId") @PostMapping("/queryByModelId")
@ApiOperation("获取各模块事件") @ApiOperation("获取各模块事件")
@@ -130,4 +141,18 @@ public class CsEventController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEventByTime")
@ApiOperation("根据时间获取无波形的暂态事件")
@ApiImplicitParams({
@ApiImplicitParam(name = "lineList", value = "监测点id"),
@ApiImplicitParam(name = "startTime", value = "开始时间"),
@ApiImplicitParam(name = "endTime", value = "结束时间")
})
public HttpResult<List<CsEventPO>> getEventByTime(@RequestParam(required = false) List<String> lineList,@RequestParam String startTime,@RequestParam String endTime) {
String methodDescribe = getMethodDescribe("getEventByTime");
List<CsEventPO> list = csEventPOService.getEventByTime(lineList,startTime,endTime);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
} }

View File

@@ -11,6 +11,7 @@ import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO; import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.event.file.pojo.dto.WaveDataDTO; import com.njcn.event.file.pojo.dto.WaveDataDTO;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -59,4 +60,6 @@ public interface CsEventPOService extends IService<CsEventPO>{
void addCldEvent(CldEventParam param); void addCldEvent(CldEventParam param);
List<CsEventPO> getEventByTime(List<String> lineList, String startTime, String endTime);
} }

View File

@@ -42,7 +42,6 @@ import com.njcn.influx.utils.InfluxDbUtils;
import com.njcn.minioss.config.MinIossProperties; import com.njcn.minioss.config.MinIossProperties;
import com.njcn.minioss.util.MinIoUtils; import com.njcn.minioss.util.MinIoUtils;
import com.njcn.oss.constant.GeneralConstant; import com.njcn.oss.constant.GeneralConstant;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil; import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.EleEvtFeignClient; import com.njcn.system.api.EleEvtFeignClient;
import com.njcn.system.api.EpdFeignClient; import com.njcn.system.api.EpdFeignClient;
@@ -62,7 +61,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
@@ -306,6 +304,18 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
} }
} }
@Override
public List<CsEventPO> getEventByTime(List<String> lineList, String startTime, String endTime) {
LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.between(CsEventPO::getStartTime,startTime,endTime)
.eq(CsEventPO::getType,0)
.isNull(CsEventPO::getWavePath);
if (CollUtil.isNotEmpty(lineList)) {
lambdaQueryWrapper.in(CsEventPO::getLineId,lineList);
}
return this.list(lambdaQueryWrapper);
}
public String getTag(Integer type) { public String getTag(Integer type) {
String tag; String tag;
switch (type) { switch (type) {