diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java index 0ce2cf0..39b6b35 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java @@ -51,7 +51,7 @@ public class FdpAlarmVo { */ private Object[] children; /** - * 报警内容 + * 创建时间 */ private Date createTime; } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java index acba00a..b51eded 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java @@ -76,12 +76,11 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { if(CollectionUtil.isEmpty(alarms)){ return; } - - R> listAll = stationClient.getListAll(); - if (!listAll.isSuccess()||CollectionUtil.isEmpty(listAll.getData())){ - throw new ServiceException("FdpAlarm send message is null"); - } - List stations = listAll.getData(); +// R> listAll = stationClient.getListAll(); +// if (!listAll.isSuccess()||CollectionUtil.isEmpty(listAll.getData())){ +// throw new ServiceException("FdpAlarm send message is null"); +// } +// List stations = listAll.getData(); // 查询当天已经记录的告警 List historys = alarmService.list(Wrappers.lambdaQuery(). ge(AlarmEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00") diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/MessageServiceImpl.java index 1ab0bae..099d953 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/MessageServiceImpl.java @@ -1,10 +1,12 @@ package com.hnac.hzims.alarm.show.service.impl; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.hnac.hzims.alarm.config.service.AlarmConfigService; +import com.hnac.hzims.alarm.constants.AlarmConstants; import com.hnac.hzims.alarm.entity.AlarmEntity; import com.hnac.hzims.alarm.show.service.MessageService; import com.hnac.hzims.message.MessageConstants; -import com.hnac.hzims.message.dto.MessagePushRecordDto; +import com.hnac.hzims.message.dto.BusinessMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; @@ -17,8 +19,8 @@ import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; -import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; /** * 消息推送实现类 @@ -32,6 +34,7 @@ public class MessageServiceImpl implements MessageService { private final IStationClient stationClient; private final IUserClient userClient; private final IMessageClient messageClient; + private final AlarmConfigService alarmConfigService; /** * 短信推送 * @param entity : 告警对象 @@ -47,6 +50,7 @@ public class MessageServiceImpl implements MessageService { */ @Override public void webAppMessage(AlarmEntity entity) { + boolean support = alarmConfigService.isSupport(entity.getStationId(), entity.getAlarmSource(), entity.getAlarmType(), AlarmConstants.IS_PLATFORM_MESSAGE); R stationByCode = stationClient.getStationByCode(entity.getStationId()); if (!stationByCode.isSuccess() && ObjectUtils.isEmpty(stationByCode.getData())) { log.error("消息发送失败:站点code获取失败",entity); @@ -59,29 +63,23 @@ public class MessageServiceImpl implements MessageService { log.error("消息发送失败:用户获取失败",entity); return; } - MessagePushRecordDto message = new MessagePushRecordDto(); - message.setBusinessClassify("warning"); - message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); - message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); - message.setTaskId(entity.getId()); - message.setTenantId("200000"); - message.setContent(entity.getAlarmContext()); - message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); - message.setPushType(MessageConstants.IMMEDIATELY); - message.setDeptId(dept); - message.setCreateDept(dept); - R deptName = sysClient.getDeptName(dept); - if (deptName.isSuccess()) { - message.setDeptName(deptName.getData()); + if (support) { + BusinessMessageDTO message = new BusinessMessageDTO(); + message.setBusinessClassify("warning"); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); + message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); + message.setTaskId(entity.getId()); + message.setTenantId("200000"); + message.setContent(entity.getAlarmContext()); + message.setDeptId(dept); + R deptName = sysClient.getDeptName(dept); + if (deptName.isSuccess()) { + message.setDeptName(deptName.getData()); + } + message.setUserIds(result.getData().stream().map(o->String.valueOf(o.getId())).distinct().collect(Collectors.joining(","))); + message.setCreateUser(result.getData().get(0).getId()); + messageClient.sendAppAndWsMsgByUsers(message); } - message.setCreateDept(dept); - result.getData().forEach(user -> { - message.setPusher(String.valueOf(user.getId())); - message.setPusherName(user.getName()); - message.setAccount(String.valueOf(user.getId())); - message.setCreateUser(user.getId()); - messageClient.sendMessage(message); - }); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/SystemAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/SystemAlarmServiceImpl.java index d03e051..2c553cc 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/SystemAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/SystemAlarmServiceImpl.java @@ -79,12 +79,12 @@ public class SystemAlarmServiceImpl implements SystemAlarmService { if (CollectionUtil.isEmpty(alarms)) { return; } - - R> listAll = stationClient.getListAll(); - if (!listAll.isSuccess() || CollectionUtil.isEmpty(listAll.getData())) { - throw new ServiceException("systemAlarm send message is null"); - } - List stations = listAll.getData(); +// +// R> listAll = stationClient.getListAll(); +// if (!listAll.isSuccess() || CollectionUtil.isEmpty(listAll.getData())) { +// throw new ServiceException("systemAlarm send message is null"); +// } +// List stations = listAll.getData(); // 查询当天已经记录的告警 List historys = alarmService.list(Wrappers.lambdaQuery(). ge(AlarmEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00")