|
|
@@ -6,6 +6,7 @@ import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.aliyuncs.unmarshaller.JsonUnmashaller;
|
|
|
import com.nb.web.api.entity.BusDeviceAlarmEntity;
|
|
|
import com.nb.web.service.bus.entity.AlarmMessageEntity;
|
|
|
import com.nb.web.service.bus.entity.BusinessTemplateDTO;
|
|
|
@@ -41,10 +42,10 @@ public class YanShiKeAlarmPushServiceImpl implements IAlarmPushService{
|
|
|
@Async
|
|
|
public void pushAlarmMsg(BusDeviceAlarmEntity entity) {
|
|
|
String msg=errorMsg(entity);
|
|
|
- List<String> staffCodeList = getStaffCodeList();
|
|
|
- if(CollectionUtil.isEmpty(staffCodeList)){
|
|
|
+ List<YanShiKeUserDTO> staffUserList = getStaffCodeList();
|
|
|
+ if(CollectionUtil.isEmpty(staffUserList)){
|
|
|
//没有设置值班人员工号
|
|
|
- log.warn("没有设置值班人员工号");
|
|
|
+ log.warn("没有设置值班人员信息");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -66,17 +67,21 @@ public class YanShiKeAlarmPushServiceImpl implements IAlarmPushService{
|
|
|
Channel channel = null;
|
|
|
try {
|
|
|
channel = connection.createChannel();
|
|
|
- for (String staffCode : staffCodeList) {
|
|
|
+ for (YanShiKeUserDTO staff : staffUserList) {
|
|
|
+ if(ObjectUtil.isNotNull(staff)&&StrUtil.isNotBlank(staff.getMobile())&&ObjectUtil.isNotNull(smsEventcs)){
|
|
|
+ smsEventcs.setMobile(staff.getMobile());
|
|
|
+ smsEventcs.setContent(msg);
|
|
|
+ }
|
|
|
// 构建报警消息
|
|
|
AlarmMessageEntity alarmMessageEntity= new AlarmMessageEntity(msg,
|
|
|
3,
|
|
|
- staffCode,
|
|
|
+ staff.getUserCode(),
|
|
|
smsEventcs,
|
|
|
- new BusinessTemplateDTO(null, DateUtil.formatDateTime(new Date()), "驼人镇痛泵报警", "type",msg)
|
|
|
+ new BusinessTemplateDTO(null, DateUtil.formatDateTime(new Date()), "驼人镇痛泵报警", "镇痛泵报警",msg)
|
|
|
);
|
|
|
// 将报警消息序列化为 JSON 字符串
|
|
|
String message = JSONUtil.toJsonStr(alarmMessageEntity);
|
|
|
-
|
|
|
+ log.warn("SentMQ>>>>>>:{}",message);
|
|
|
HashMap<String, Object> headers = new HashMap<String, Object>();
|
|
|
|
|
|
headers.put("cap-msg-id", UUID.fastUUID().toString());
|
|
|
@@ -86,7 +91,8 @@ public class YanShiKeAlarmPushServiceImpl implements IAlarmPushService{
|
|
|
properties.headers(headers);
|
|
|
// 推送报警消息
|
|
|
channel.basicPublish(mqConfigProperty.getExchangeName(),mqConfigProperty.getRouter(), properties.build(), message.getBytes("UTF-8"));
|
|
|
- log.info("SentMQ>>>>>>:{}",message);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
@@ -114,13 +120,17 @@ public class YanShiKeAlarmPushServiceImpl implements IAlarmPushService{
|
|
|
* 获取值班人员的工号
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<String> getStaffCodeList(){
|
|
|
+ private List<YanShiKeUserDTO> getStaffCodeList(){
|
|
|
String staffCode = configService.getConfigValueByKey("ysg_staff_code");
|
|
|
if(StrUtil.isBlank(staffCode)){
|
|
|
return null;
|
|
|
}
|
|
|
- staffCode =StrUtil.replace(staffCode, ",", ",");
|
|
|
- return StrUtil.split(staffCode,",");
|
|
|
+ try {
|
|
|
+ return JSONUtil.toList(staffCode, YanShiKeUserDTO.class);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("浙江眼视光医院医护人员信息配置错误,",e);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|