refactor(event): 重构事件统计功能并迁移消息推送服务
- 移除暂态事件统计相关接口和实现方法 - 删除EventStatisticsVo相关代码 - 将设备消息推送功能从CsEventPOServiceImpl迁移到新创建的DeviceMessageService - 新增DeviceMessageFeignClient用于服务间调用 - 实现DeviceMessageController提供统一的消息推送接口
This commit is contained in:
@@ -176,16 +176,6 @@ public class CsEventController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/eventStatistics")
|
||||
@ApiOperation("暂态事件统计")
|
||||
@ApiImplicitParam(name = "param", value = "事件信息", required = true)
|
||||
public HttpResult<List<EventStatisticsVo>> getEventStatistics(@RequestBody CsEventUserQueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("getEventByTime");
|
||||
List<EventStatisticsVo> list = csEventPOService.getEventStatistics(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getDevAlarmList")
|
||||
@ApiOperation("获取设备运行告警事件")
|
||||
|
||||
@@ -70,8 +70,6 @@ public interface CsEventPOService extends IService<CsEventPO>{
|
||||
|
||||
List<CsEventPO> getEventByTime(List<String> lineList, String startTime, String endTime);
|
||||
|
||||
List<EventStatisticsVo> getEventStatistics(CsEventUserQueryParam param);
|
||||
|
||||
List<CsWarnDescVO> getEventDesc(List<String> lineIdList);
|
||||
|
||||
//获取设备告警事件详情
|
||||
|
||||
@@ -16,10 +16,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.pojo.dto.NoticeUserDto;
|
||||
import com.njcn.access.utils.SendMessageUtil;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
|
||||
import com.njcn.csdevice.api.CsLedgerFeignClient;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.DeviceMessageFeignClient;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.param.DeviceMessageParam;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
|
||||
@@ -36,7 +37,6 @@ import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.CsEventVO;
|
||||
import com.njcn.csharmonic.pojo.vo.CsWarnDescVO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventStatisticsVo;
|
||||
import com.njcn.csharmonic.service.CsEventPOService;
|
||||
import com.njcn.csharmonic.service.CsEventUserPOService;
|
||||
import com.njcn.event.common.mapper.WlRmpEventDetailMapper;
|
||||
@@ -62,11 +62,7 @@ import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.po.EleEvtParm;
|
||||
import com.njcn.user.api.AppInfoSetFeignClient;
|
||||
import com.njcn.user.api.AppUserFeignClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.po.app.AppInfoSet;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -124,13 +120,9 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
private final MinIoUtils minIoUtils;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
|
||||
private final AppUserFeignClient appUserFeignClient;
|
||||
private final CsDeviceUserFeignClient csDeviceUserFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final AppInfoSetFeignClient appInfoSetFeignClient;
|
||||
private final CsLedgerFeignClient csLedgerFeignclient;
|
||||
private final SendMessageUtil sendMessageUtil;
|
||||
|
||||
private final DeviceMessageFeignClient deviceMessageClient;
|
||||
|
||||
@Override
|
||||
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
|
||||
@@ -159,12 +151,6 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
} else {
|
||||
eventDataSetDTO.setValue(Optional.ofNullable(evtData.getValue()).orElse("3.1415926"));
|
||||
}
|
||||
//优化,删除监测点位置
|
||||
// if (Objects.equals(temp.getEvtParamPosition(),"-") || Objects.isNull(temp.getEvtParamPosition())) {
|
||||
// if (!Objects.isNull(temp.getLocation())) {
|
||||
// temp.setEvtParamPosition(Objects.equals(temp.getLocation(),"grid")?"电网侧":"负载侧");
|
||||
// }
|
||||
// }
|
||||
eventDataSetDTOS.add(eventDataSetDTO);
|
||||
}
|
||||
temp.setDataSet(eventDataSetDTOS);
|
||||
@@ -426,7 +412,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
NoticeUserDto noticeUserDto = new NoticeUserDto();
|
||||
NoticeUserDto.Payload payload = new NoticeUserDto.Payload();
|
||||
List<CsEventUserPO> result = new ArrayList<>();
|
||||
List<String> eventUser = getEventUser(po.getDeviceId(),true);
|
||||
List<String> eventUser = deviceMessageClient.getEventUserByDeviceId(po.getDeviceId(),true).getData();
|
||||
//针对用户记录未读信息和推送告警
|
||||
eventUser.forEach(item->{
|
||||
CsEventUserPO csEventUser = new CsEventUserPO();
|
||||
@@ -435,7 +421,11 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
csEventUser.setEventId(uuid);
|
||||
result.add(csEventUser);
|
||||
});
|
||||
List<User> users = getSendUser(eventUser,0);
|
||||
//获取打开推送的用户
|
||||
DeviceMessageParam param1 = new DeviceMessageParam();
|
||||
param1.setUserList(eventUser);
|
||||
param1.setEventType(0);
|
||||
List<User> users = deviceMessageClient.getSendUserByType(param1).getData();
|
||||
if (CollectionUtil.isNotEmpty(users)){
|
||||
List<String> devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
||||
noticeUserDto.setPushClientId(devCodeList);
|
||||
@@ -445,7 +435,8 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
//获取台账信息
|
||||
String eventName = epdFeignClient.findByName(getTag(param.getEventType())).getData().getShowName();
|
||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getDeviceId()).getData();
|
||||
String content = devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + time.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生" + eventName;
|
||||
String content = devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName()
|
||||
+ "于" + time.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生暂态事件,事件类型:" + eventName;
|
||||
noticeUserDto.setContent(content);
|
||||
payload.setType(0);
|
||||
payload.setPath("/pages/index/message1?type="+payload.getType());
|
||||
@@ -498,58 +489,6 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> getEventUser(String devId,boolean isAdmin) {
|
||||
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
|
||||
List<String> result = new ArrayList<>(list);
|
||||
if (isAdmin) {
|
||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
||||
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
|
||||
result.addAll(adminList);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result = result.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有打开推送的用户信息
|
||||
*/
|
||||
public List<User> getSendUser(List<String> userList,Integer type) {
|
||||
List<User> users = new ArrayList<>();
|
||||
List<String> result = new ArrayList<>();
|
||||
List<AppInfoSet> appInfoSet = appInfoSetFeignClient.getListById(userList).getData();
|
||||
|
||||
switch (type) {
|
||||
case 0:
|
||||
result = appInfoSet.stream()
|
||||
.filter(person -> person.getEventInfo() == 1)
|
||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
||||
break;
|
||||
case 1:
|
||||
result = appInfoSet.stream()
|
||||
.filter(person -> person.getHarmonicInfo() == 1)
|
||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
||||
break;
|
||||
case 2:
|
||||
result = appInfoSet.stream()
|
||||
.filter(person -> person.getRunInfo() == 1)
|
||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
||||
break;
|
||||
case 3:
|
||||
result = appInfoSet.stream()
|
||||
.filter(person -> person.getAlarmInfo() == 1)
|
||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(result)){
|
||||
users = userFeignClient.appuserByIdList(result).getData();
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
public void insertEvent(String uuid, CldEventParam param, LocalDateTime time) {
|
||||
RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO();
|
||||
rmpEventDetailPO.setEventId(uuid);
|
||||
@@ -571,13 +510,6 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
RmpEventDetailPO po = wlRmpEventDetailMapper.selectOne(wrapper);
|
||||
po.setWavePath(param.getWavePath());
|
||||
po.setFileFlag(1);
|
||||
|
||||
//根据事件获取暂态类型、暂态原因、暂态发生位置
|
||||
//String ip = equipmentFeignClient.getDevByLineId(param.getMonitorId()).getData().getMac();
|
||||
//EntityAdvancedData advancedData = commonEventWaveAnalysisService.analysis(po,ip);
|
||||
//po.setAdvanceReason(advancedData.getSagReason()[0]);
|
||||
//po.setAdvanceType(advancedData.getSagType()[0]);
|
||||
|
||||
wlRmpEventDetailMapper.updateById(po);
|
||||
}
|
||||
|
||||
@@ -594,15 +526,6 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventStatisticsVo> getEventStatistics(CsEventUserQueryParam param) {
|
||||
|
||||
|
||||
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsWarnDescVO> getEventDesc(List<String> lineIdList) {
|
||||
List<CsWarnDescVO> csWarnDescVOList = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user