Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
07f9bc0053
  1. 2
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/vo/FdpAlarmVo.java
  2. 11
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/FdpAlarmServiceImpl.java
  3. 26
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/MessageServiceImpl.java
  4. 12
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/SystemAlarmServiceImpl.java

2
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;
}

11
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<List<StationEntity>> listAll = stationClient.getListAll();
if (!listAll.isSuccess()||CollectionUtil.isEmpty(listAll.getData())){
throw new ServiceException("FdpAlarm send message is null");
}
List<StationEntity> stations = listAll.getData();
// R<List<StationEntity>> listAll = stationClient.getListAll();
// if (!listAll.isSuccess()||CollectionUtil.isEmpty(listAll.getData())){
// throw new ServiceException("FdpAlarm send message is null");
// }
// List<StationEntity> stations = listAll.getData();
// 查询当天已经记录的告警
List<AlarmEntity> historys = alarmService.list(Wrappers.<AlarmEntity>lambdaQuery().
ge(AlarmEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00")

26
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<StationEntity> 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();
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.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
message.setPushType(MessageConstants.IMMEDIATELY);
message.setDeptId(dept);
message.setCreateDept(dept);
R<String> deptName = sysClient.getDeptName(dept);
if (deptName.isSuccess()) {
message.setDeptName(deptName.getData());
}
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);
});
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);
}

12
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<List<StationEntity>> listAll = stationClient.getListAll();
if (!listAll.isSuccess() || CollectionUtil.isEmpty(listAll.getData())) {
throw new ServiceException("systemAlarm send message is null");
}
List<StationEntity> stations = listAll.getData();
//
// R<List<StationEntity>> listAll = stationClient.getListAll();
// if (!listAll.isSuccess() || CollectionUtil.isEmpty(listAll.getData())) {
// throw new ServiceException("systemAlarm send message is null");
// }
// List<StationEntity> stations = listAll.getData();
// 查询当天已经记录的告警
List<AlarmEntity> historys = alarmService.list(Wrappers.<AlarmEntity>lambdaQuery().
ge(AlarmEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00")

Loading…
Cancel
Save