|
|
@ -1,11 +1,13 @@ |
|
|
|
package com.hnac.hzims.alarm.source.service.impl; |
|
|
|
package com.hnac.hzims.alarm.source.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
|
|
|
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.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.SmsPushDto; |
|
|
|
import com.hnac.hzims.message.dto.SmsPushDto; |
|
|
|
import com.hnac.hzims.message.dto.WxMessageDTO; |
|
|
|
import com.hnac.hzims.message.dto.WxMessageDTO; |
|
|
|
import com.hnac.hzims.message.fegin.IMessageClient; |
|
|
|
import com.hnac.hzims.message.fegin.IMessageClient; |
|
|
@ -14,8 +16,10 @@ import com.hnac.hzims.operational.station.feign.IStationClient; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
|
|
|
import org.springblade.core.tool.jackson.JsonUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
@ -61,23 +65,29 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
//通知站点项目经理这个角色
|
|
|
|
//通知站点项目经理这个角色
|
|
|
|
List<User> users = userClient.relationUserListByRoleAlias("200000", station.getData().getRefDept(), PROJECT_MANAGER).getData(); |
|
|
|
List<User> users = userClient.relationUserListByRoleAlias(station.getData().getTenantId(), station.getData().getRefDept(), PROJECT_MANAGER).getData(); |
|
|
|
if(CollectionUtil.isEmpty(users)){ |
|
|
|
if(CollectionUtil.isEmpty(users)){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
List<String> phones = users.stream().map(User::getPhone).filter(phone -> !StringUtil.isEmpty(phone)).collect(Collectors.toList()); |
|
|
|
SmsImmediatelyPushDTO push = SmsImmediatelyPushDTO.builder() |
|
|
|
if(CollectionUtil.isEmpty(phones)){ |
|
|
|
.deptId(entity.getCreateDept()) |
|
|
|
return; |
|
|
|
.taskId(entity.getId()) |
|
|
|
} |
|
|
|
.businessKey(MessageConstants.BusinessClassifyEnum.WARNING.getKey()) |
|
|
|
SmsPushDto sms = new SmsPushDto(); |
|
|
|
.businessClassify(MessageConstants.BusinessClassifyEnum.WARNING.getKey()) |
|
|
|
sms.setPhones(phones); |
|
|
|
.content(entity.getAlarmContext()) |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
.subject("告警短信通知") |
|
|
|
params.put("projectName",entity.getStationName()); |
|
|
|
.tenantId(entity.getTenantId()) |
|
|
|
params.put("deviceName",entity.getDeviceCode()); |
|
|
|
.resourceCode(AlarmConstants.SMS_MESSAGE_TEMPLATE_CODE) |
|
|
|
params.put("ruleDefName",entity.getAlarmContext()); |
|
|
|
.pusher(users.stream().map(o->o.getId().toString()).collect(Collectors.joining(","))) |
|
|
|
params.put("ts", DateUtil.format(entity.getAlarmTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
.createUser(station.getData().getCreateUser()) |
|
|
|
sms.setParams(params); |
|
|
|
.params(new HashMap<String,String>(){{ |
|
|
|
messageClient.sendSmsMessage(sms); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -102,7 +112,7 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
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(Long.valueOf(entity.getAlarmId())); |
|
|
|
message.setTaskId(entity.getId()); |
|
|
|
message.setTenantId("200000"); |
|
|
|
message.setTenantId("200000"); |
|
|
|
message.setContent(entity.getAlarmContext()); |
|
|
|
message.setContent(entity.getAlarmContext()); |
|
|
|
message.setDeptId(dept); |
|
|
|
message.setDeptId(dept); |
|
|
@ -121,12 +131,12 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void weChatMessage(AlarmEntity entity) { |
|
|
|
public void weChatMessage(AlarmEntity entity) { |
|
|
|
R<StationEntity> stationByCode = stationClient.getStationByCode(entity.getStationId()); |
|
|
|
R<StationEntity> station = stationClient.getStationByCode(entity.getStationId()); |
|
|
|
if (!stationByCode.isSuccess() && ObjectUtils.isEmpty(stationByCode.getData())) { |
|
|
|
if (!station.isSuccess() && ObjectUtils.isEmpty(station.getData())) { |
|
|
|
log.error("消息发送失败:站点code获取失败 : {}",entity); |
|
|
|
log.error("消息发送失败:站点code获取失败 : {}",entity); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
Long dept = stationByCode.getData().getCreateDept(); |
|
|
|
Long dept = station.getData().getCreateDept(); |
|
|
|
// 获取站点用户
|
|
|
|
// 获取站点用户
|
|
|
|
R<List<User>> result = userClient.userListByDeptId(dept); |
|
|
|
R<List<User>> result = userClient.userListByDeptId(dept); |
|
|
|
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { |
|
|
|
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { |
|
|
@ -162,9 +172,8 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
message.setUserIds(result.getData().stream().map(o->String.valueOf(o.getId())).distinct().collect(Collectors.joining(","))); |
|
|
|
message.setUserIds(result.getData().stream().map(o->String.valueOf(o.getId())).distinct().collect(Collectors.joining(","))); |
|
|
|
// 创建用户
|
|
|
|
// 创建用户
|
|
|
|
message.setCreateUser(result.getData().get(0).getId()); |
|
|
|
message.setCreateUser(result.getData().get(0).getId()); |
|
|
|
|
|
|
|
|
|
|
|
// 租户Id
|
|
|
|
// 租户Id
|
|
|
|
message.setTenantId("200000"); |
|
|
|
message.setTenantId(station.getData().getTenantId()); |
|
|
|
messageClient.sendWxMessage(message); |
|
|
|
messageClient.sendWxMessage(message); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |