|
|
@ -1,10 +1,12 @@ |
|
|
|
package com.hnac.hzims.alarm.show.service.impl; |
|
|
|
package com.hnac.hzims.alarm.show.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
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.entity.AlarmEntity; |
|
|
|
import com.hnac.hzims.alarm.show.service.MessageService; |
|
|
|
import com.hnac.hzims.alarm.show.service.MessageService; |
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
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.message.fegin.IMessageClient; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.feign.IStationClient; |
|
|
|
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.springblade.system.user.feign.IUserClient; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 消息推送实现类 |
|
|
|
* 消息推送实现类 |
|
|
@ -32,6 +34,7 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
private final IStationClient stationClient; |
|
|
|
private final IStationClient stationClient; |
|
|
|
private final IUserClient userClient; |
|
|
|
private final IUserClient userClient; |
|
|
|
private final IMessageClient messageClient; |
|
|
|
private final IMessageClient messageClient; |
|
|
|
|
|
|
|
private final AlarmConfigService alarmConfigService; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 短信推送 |
|
|
|
* 短信推送 |
|
|
|
* @param entity : 告警对象 |
|
|
|
* @param entity : 告警对象 |
|
|
@ -47,6 +50,7 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void webAppMessage(AlarmEntity entity) { |
|
|
|
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()); |
|
|
|
R<StationEntity> stationByCode = stationClient.getStationByCode(entity.getStationId()); |
|
|
|
if (!stationByCode.isSuccess() && ObjectUtils.isEmpty(stationByCode.getData())) { |
|
|
|
if (!stationByCode.isSuccess() && ObjectUtils.isEmpty(stationByCode.getData())) { |
|
|
|
log.error("消息发送失败:站点code获取失败",entity); |
|
|
|
log.error("消息发送失败:站点code获取失败",entity); |
|
|
@ -59,29 +63,23 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
log.error("消息发送失败:用户获取失败",entity); |
|
|
|
log.error("消息发送失败:用户获取失败",entity); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
MessagePushRecordDto message = new MessagePushRecordDto(); |
|
|
|
if (support) { |
|
|
|
|
|
|
|
BusinessMessageDTO message = new BusinessMessageDTO(); |
|
|
|
message.setBusinessClassify("warning"); |
|
|
|
message.setBusinessClassify("warning"); |
|
|
|
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); |
|
|
|
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()); |
|
|
|
message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); |
|
|
|
message.setSubject(MessageConstants.BusinessClassifyEnum.WARNING.getDescription()); |
|
|
|
message.setTaskId(entity.getId()); |
|
|
|
message.setTaskId(entity.getId()); |
|
|
|
message.setTenantId("200000"); |
|
|
|
message.setTenantId("200000"); |
|
|
|
message.setContent(entity.getAlarmContext()); |
|
|
|
message.setContent(entity.getAlarmContext()); |
|
|
|
message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); |
|
|
|
|
|
|
|
message.setPushType(MessageConstants.IMMEDIATELY); |
|
|
|
|
|
|
|
message.setDeptId(dept); |
|
|
|
message.setDeptId(dept); |
|
|
|
message.setCreateDept(dept); |
|
|
|
|
|
|
|
R<String> deptName = sysClient.getDeptName(dept); |
|
|
|
R<String> deptName = sysClient.getDeptName(dept); |
|
|
|
if (deptName.isSuccess()) { |
|
|
|
if (deptName.isSuccess()) { |
|
|
|
message.setDeptName(deptName.getData()); |
|
|
|
message.setDeptName(deptName.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
message.setCreateDept(dept); |
|
|
|
message.setUserIds(result.getData().stream().map(o->String.valueOf(o.getId())).distinct().collect(Collectors.joining(","))); |
|
|
|
result.getData().forEach(user -> { |
|
|
|
message.setCreateUser(result.getData().get(0).getId()); |
|
|
|
message.setPusher(String.valueOf(user.getId())); |
|
|
|
messageClient.sendAppAndWsMsgByUsers(message); |
|
|
|
message.setPusherName(user.getName()); |
|
|
|
} |
|
|
|
message.setAccount(String.valueOf(user.getId())); |
|
|
|
|
|
|
|
message.setCreateUser(user.getId()); |
|
|
|
|
|
|
|
messageClient.sendMessage(message); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|