|
|
@ -5,6 +5,7 @@ import com.hnac.hzims.alarm.config.constants.AlarmConstants; |
|
|
|
import com.hnac.hzims.alarm.config.service.AlarmConfigService; |
|
|
|
import com.hnac.hzims.alarm.config.service.AlarmConfigService; |
|
|
|
import com.hnac.hzims.alarm.config.entity.AlarmEntity; |
|
|
|
import com.hnac.hzims.alarm.config.entity.AlarmEntity; |
|
|
|
import com.hnac.hzims.alarm.source.service.MessageService; |
|
|
|
import com.hnac.hzims.alarm.source.service.MessageService; |
|
|
|
|
|
|
|
import com.hnac.hzims.common.constant.CommonConstant; |
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
import com.hnac.hzims.message.dto.BusinessMessageDTO; |
|
|
|
import com.hnac.hzims.message.dto.BusinessMessageDTO; |
|
|
|
import com.hnac.hzims.message.dto.SmsImmediatelyPushDTO; |
|
|
|
import com.hnac.hzims.message.dto.SmsImmediatelyPushDTO; |
|
|
@ -30,6 +31,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Optional; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import static com.hnac.hzims.operational.main.constant.MainConstants.PROJECT_MANAGER; |
|
|
|
import static com.hnac.hzims.operational.main.constant.MainConstants.PROJECT_MANAGER; |
|
|
@ -54,44 +56,6 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
private final AlarmConfigService alarmConfigService; |
|
|
|
private final AlarmConfigService alarmConfigService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 短信推送 |
|
|
|
|
|
|
|
* @param entity : 告警对象 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void shortMessage(AlarmEntity entity) { |
|
|
|
|
|
|
|
R<StationEntity> station = stationClient.getStationByCode(entity.getStationId()); |
|
|
|
|
|
|
|
if (!station.isSuccess() || ObjectUtils.isEmpty(station.getData())) { |
|
|
|
|
|
|
|
log.error("消息发送失败:站点code获取失败 : {}",entity); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//通知站点项目经理这个角色
|
|
|
|
|
|
|
|
List<User> users = userClient.relationUserListByRoleAlias(station.getData().getTenantId(), station.getData().getRefDept(), PROJECT_MANAGER).getData(); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(users)){ |
|
|
|
|
|
|
|
log.error("消息发送失败:获取站点项目经理用户失败 : {}",entity); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SmsImmediatelyPushDTO push = SmsImmediatelyPushDTO.builder() |
|
|
|
|
|
|
|
.deptId(entity.getCreateDept()) |
|
|
|
|
|
|
|
.taskId(entity.getId()) |
|
|
|
|
|
|
|
.businessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()) |
|
|
|
|
|
|
|
.businessClassify(MessageConstants.BusinessClassifyEnum.WARNING.getKey()) |
|
|
|
|
|
|
|
.content(entity.getAlarmContext()) |
|
|
|
|
|
|
|
.subject("告警短信通知") |
|
|
|
|
|
|
|
.tenantId(entity.getTenantId()) |
|
|
|
|
|
|
|
.resourceCode(AlarmConstants.SMS_MESSAGE_TEMPLATE_CODE) |
|
|
|
|
|
|
|
.pusher(users.stream().map(o->o.getId().toString()).collect(Collectors.joining(","))) |
|
|
|
|
|
|
|
.createUser(station.getData().getCreateUser()) |
|
|
|
|
|
|
|
.params(new HashMap<String,String>(){{ |
|
|
|
|
|
|
|
put("projectName",entity.getStationName()); |
|
|
|
|
|
|
|
put("deviceName",entity.getDeviceName()); |
|
|
|
|
|
|
|
put("ruleDefName",entity.getAlarmContext()); |
|
|
|
|
|
|
|
put("ts", DateUtil.format(entity.getAlarmTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
}}) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
messageClient.sendSmsImmediatelyMsg(push); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* web/app消息推送 |
|
|
|
* web/app消息推送 |
|
|
|
* @param entity : 告警对象 |
|
|
|
* @param entity : 告警对象 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -127,6 +91,45 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 短信推送 |
|
|
|
|
|
|
|
* @param entity : 告警对象 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void shortMessage(AlarmEntity entity) { |
|
|
|
|
|
|
|
R<StationEntity> station = stationClient.getStationByCode(entity.getStationId()); |
|
|
|
|
|
|
|
if (!station.isSuccess() || ObjectUtils.isEmpty(station.getData())) { |
|
|
|
|
|
|
|
log.error("短信发送失败:站点code获取失败 : {}",entity); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.error("短信发送,站点信息: {}",station.getData()); |
|
|
|
|
|
|
|
//通知站点项目经理这个角色
|
|
|
|
|
|
|
|
List<User> users = userClient.relationUserListByRoleAlias(station.getData().getTenantId(), station.getData().getRefDept(), PROJECT_MANAGER).getData(); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(users)){ |
|
|
|
|
|
|
|
log.error("短信发送失败:获取站点项目经理用户失败 : {}",entity); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SmsImmediatelyPushDTO push = SmsImmediatelyPushDTO.builder() |
|
|
|
|
|
|
|
.deptId(entity.getCreateDept()) |
|
|
|
|
|
|
|
.taskId(entity.getId()) |
|
|
|
|
|
|
|
.businessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()) |
|
|
|
|
|
|
|
.businessClassify(MessageConstants.BusinessClassifyEnum.WARNING.getKey()) |
|
|
|
|
|
|
|
.content(entity.getAlarmContext()) |
|
|
|
|
|
|
|
.subject("告警短信通知") |
|
|
|
|
|
|
|
.tenantId(entity.getTenantId()) |
|
|
|
|
|
|
|
.resourceCode(AlarmConstants.SMS_MESSAGE_TEMPLATE_CODE) |
|
|
|
|
|
|
|
.pusher(users.stream().map(o->o.getId().toString()).collect(Collectors.joining(","))) |
|
|
|
|
|
|
|
.createUser(CommonConstant.SYSTEM_USER) |
|
|
|
|
|
|
|
.params(new HashMap<String,String>(){{ |
|
|
|
|
|
|
|
put("projectName",entity.getStationName()); |
|
|
|
|
|
|
|
put("deviceName", Optional.ofNullable(entity.getDeviceName()).orElse("")); |
|
|
|
|
|
|
|
put("ruleDefName",entity.getAlarmContext()); |
|
|
|
|
|
|
|
put("ts", DateUtil.format(entity.getAlarmTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
}}) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
messageClient.sendSmsImmediatelyMsg(push); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 微信公众号消息推送 |
|
|
|
* 微信公众号消息推送 |
|
|
|
* @param entity |
|
|
|
* @param entity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|