Kaynağa Gözat

替换短信平台代码

zhb.dong 1 yıl önce
ebeveyn
işleme
5156640526

+ 22 - 8
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/service/impl/AlarmRecordServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zd.bottle.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -24,7 +25,9 @@ import com.zd.common.core.utils.DateUtils;
 import com.zd.laboratory.api.entity.LabSubjectEntity;
 import com.zd.laboratory.api.feign.RemoteLaboratoryService;
 import com.zd.laboratory.api.feign.RemoteMessageContentService;
+import com.zd.laboratory.api.feign.RemoteSmsService;
 import com.zd.laboratory.api.feign.RemoteSubQueryService;
+import com.zd.laboratory.api.vo.TextMessageVo;
 import com.zd.model.constant.HttpStatus;
 import com.zd.model.domain.AjaxResult;
 import com.zd.model.domain.R;
@@ -37,6 +40,7 @@ import com.zd.system.api.feign.RemoteUserService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.jetbrains.annotations.Nullable;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
@@ -93,6 +97,9 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
     @Resource
     private AlarmProperties alarmProperties;
 
+    @Autowired
+    private RemoteSmsService remoteSmsService;
+
     private static final String MSG_MATCH = "==================>{},{}";
 
     @Override
@@ -276,14 +283,21 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
         }
         String airName = storage.getAirName();
         //电话报警
-        AlarmEntrty alarmEntrty = new AlarmEntrty();
-        alarmEntrty.setRoute(Routes.NoticePush);
-        alarmEntrty.setType(SendTypes.Call + "");
-        alarmEntrty.setTo(phones.toArray(new String[]{}));
-        alarmEntrty.setText(subjectName + airName + "气瓶被违规带离,请尽快确认");
-        AjaxResult result = remoteAlarmService.send(alarmEntrty);
-        if (!result.get(AjaxResult.CODE_TAG).equals(HttpStatus.SUCCESS)) {
-            log.error("电话报警异常:发送实验室【{}】,实验室ID【{}】,接收用户手机号【{}】", subjectName, storage.getSubjectId(), phones);
+//        AlarmEntrty alarmEntrty = new AlarmEntrty();
+//        alarmEntrty.setRoute(Routes.NoticePush);
+//        alarmEntrty.setType(SendTypes.Call + "");
+//        alarmEntrty.setTo(phones.toArray(new String[]{}));
+//        alarmEntrty.setText(subjectName + airName + "气瓶被违规带离,请尽快确认");
+//        AjaxResult result = remoteAlarmService.send(alarmEntrty);
+
+        if(!CollectionUtil.isEmpty(phones)){
+            TextMessageVo textMessageVo=new TextMessageVo();
+            textMessageVo.setPhoneList(phones);
+            textMessageVo.setTempContent(subjectName + airName + "气瓶被违规带离,请尽快确认");
+            remoteSmsService.sendVoiceMessage(textMessageVo);
+            log.info("电话报警成功:发送实验室【{}】,实验室ID【{}】,接收用户手机号【{}】", subjectName, storage.getSubjectId(), phones);
+        }else{
+            log.info("电话报警异常:发送实验室【{}】,实验室ID【{}】,接收用户手机号【{}】", subjectName, storage.getSubjectId(), phones);
         }
     }
 

+ 17 - 3
zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/impl/HxpAlarmRecordServiceImpl.java

@@ -18,12 +18,16 @@ import com.zd.common.core.annotation.DataScope;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.utils.SecurityUtils;
+import com.zd.laboratory.api.feign.RemoteSmsService;
+import com.zd.laboratory.api.vo.TextMessageVo;
 import com.zd.model.domain.per.PerPrefix;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -46,6 +50,8 @@ public class HxpAlarmRecordServiceImpl implements IHxpAlarmRecordService {
     private SmsSydUtil smsSydUtil;
     @Autowired
     private RemoteAlarmService remoteAlarmService;
+    @Autowired
+    private RemoteSmsService remoteSmsService;
 
     /**
      * 查询化学品报警记录
@@ -239,9 +245,17 @@ public class HxpAlarmRecordServiceImpl implements IHxpAlarmRecordService {
                         .collect(Collectors.joining(","))
                         .split(",");
                 //打电话
-                AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.Call.name(), hxpAlarmRecord.getAlarmContent());
-                remoteAlarmService.send(alarmEntrty);
-                log.info("阶梯电话通知完成!");
+//                AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.Call.name(), hxpAlarmRecord.getAlarmContent());
+//                remoteAlarmService.send(alarmEntrty);
+               if(strings.length > 0){
+                   TextMessageVo textMessageVo=new TextMessageVo();
+                   textMessageVo.setPhoneList(Arrays.asList(strings));
+                   textMessageVo.setTempContent(hxpAlarmRecord.getAlarmContent());
+                   remoteSmsService.sendVoiceMessage(textMessageVo);
+                   log.info("阶梯电话通知完成!");
+               }else{
+                   log.info("阶梯电话通知失败,接收人为空!");
+               }
             } catch (Exception e) {
                 log.error("阶梯电话通知发送异常:" + e.getMessage());
             }

+ 4 - 2
zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/impl/HxpChemicalServiceImpl.java

@@ -609,7 +609,8 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
                             .split(",");
 
                     String subName = subInfo.get("name") == null ? "" : subInfo.get("name") + "";
-                    String content = subName + "房间内危化品已定为重大危险源,请确认安全存放量!";
+                    String content = "【忠江科技】" + subName + "房间内危化品已定为重大危险源,请确认安全存放量!";
+                    String tempConent = "【忠江科技】{sub_name} 房间内危化品已定为重大危险源,请确认安全存放量!";
                     if (HxpStockServiceImpl.phoneMode == 0) {
                         //AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, content);
                         //remoteAlarmService.send(alarmEntrty);
@@ -618,7 +619,8 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
                         textMessageVo.setPhoneList(Arrays.asList(strings));
                         paramList.add(subName);
                         textMessageVo.setVariableList(paramList);
-                        textMessageVo.setTempContent(content);
+                        textMessageVo.setTempId("142020");
+                        textMessageVo.setTempContent(tempConent);
                         remoteSmsService.sendVoiceMessage(textMessageVo);
                         remoteSmsService.sendTemplateMessage(textMessageVo);
 

+ 114 - 56
zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/impl/HxpStockServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zd.chemical.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.LocalDateTimeUtil;
@@ -441,7 +442,14 @@ public class HxpStockServiceImpl implements IHxpStockService {
             }
             //按照配置预警
             if (illegalRemoval != null) {
-                String text = "【实验室安全系统】" + warningNoticeLogDto.getSubName() + "-实验人员违规携带" + warningNoticeLogDto.getName() + "离开房间,发生时间:" + LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss") + ",请尽快确认。";
+                String date_s = LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss");
+                String templateContent = "【忠江科技】{lab_name}- -实验人员违规携带 {name} 离开房间,发生时间:{date},请尽快确认。";
+                String text = "【忠江科技】" + warningNoticeLogDto.getSubName() + "-实验人员违规携带" + warningNoticeLogDto.getName() + "离开房间,发生时间:" + date_s + ",请尽快确认。";
+
+                List<String> paramList=new ArrayList<>();
+                paramList.add(warningNoticeLogDto.getSubName());
+                paramList.add(warningNoticeLogDto.getName());
+                paramList.add(date_s);
                 //系统通知
                 if (illegalRemoval.contains("1")) {
                     LabMessageContent labMessageContent = new LabMessageContent();
@@ -464,11 +472,23 @@ public class HxpStockServiceImpl implements IHxpStockService {
                             logger.info("获取实验室管理员和安全员信息失败!{}",JSON.toJSONString(listResultData));
                         }
                         List<UserPhoneInfo> userPhoneInfoList = listResultData.getData();
-                        AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.name(), text);
-                        alarmEntrty.setLogId(logId);
-                        alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
-                        remoteAlarmService.send(alarmEntrty);
-                        logger.info("化学品违规带离发送短信打电话消息推送完成!");
+
+                        if(!CollectionUtil.isEmpty(userPhoneInfoList)){
+                            TextMessageVo textMessageVo=new TextMessageVo();
+                            textMessageVo.setPhoneList(userPhoneInfoList.stream().map(UserPhoneInfo::getPhone).collect(Collectors.toList()));
+                            textMessageVo.setTempContent(templateContent);
+                            textMessageVo.setVariableList(paramList);
+                            textMessageVo.setTempId("142047");
+                            remoteSmsService.sendTemplateMessage(textMessageVo);
+                            logger.info("化学品违规带离发送短信打电话消息推送完成!");
+                        }else{
+                            logger.info("短信接收人员为空,请仔细检查");
+                        }
+//                        AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.name(), text);
+//                        alarmEntrty.setLogId(logId);
+//                        alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
+//                        remoteAlarmService.send(alarmEntrty);
+//                        logger.info("化学品违规带离发送短信打电话消息推送完成!");
                     }
                 }
                 //电话通知
@@ -481,11 +501,21 @@ public class HxpStockServiceImpl implements IHxpStockService {
                             logger.info("获取实验室管理员和安全员信息失败!{}",JSON.toJSONString(listResultData));
                         }
                         List<UserPhoneInfo> userPhoneInfoList = listResultData.getData();
-                        AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.Call.name(), text);
-                        alarmEntrty.setLogId(logId);
-                        alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
-                        remoteAlarmService.send(alarmEntrty);
-                        logger.info("化学品违规带离打电话消息推送完成!");
+//                        AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.Call.name(), text);
+//                        alarmEntrty.setLogId(logId);
+//                        alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
+//                        remoteAlarmService.send(alarmEntrty);
+//                        logger.info("化学品违规带离打电话消息推送完成!");
+                        if(!CollectionUtil.isEmpty(userPhoneInfoList)){
+                            TextMessageVo textMessageVo=new TextMessageVo();
+                            textMessageVo.setPhoneList(userPhoneInfoList.stream().map(UserPhoneInfo::getPhone).collect(Collectors.toList()));
+                            textMessageVo.setTempContent(templateContent);
+                            textMessageVo.setVariableList(paramList);
+                            remoteSmsService.sendVoiceMessage(textMessageVo);
+                            logger.info("化学品违规带离打电话消息推送完成!");
+                        }else{
+                            logger.info("语音接收人员为空,请仔细检查");
+                        }
                     }
                 }
                 //声光报警
@@ -612,14 +642,24 @@ public class HxpStockServiceImpl implements IHxpStockService {
 
             // 判断四医大还是其他学校短信方案
             String content;
+            String templateContent = "【忠江科技】 {lab_name} 的化学品:{name}违规带离实验室,请尽快确认!";
             if(phoneMode == 0){
-                content = "电话报警:" + subName + "的化学品" + chemicalName + "违规带离实验室,请尽快确认!";
-                AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, to, content);
-                AjaxResult result = remoteAlarmService.send(alarmEntrty);
+//                content = "电话报警:" + subName + "的化学品" + chemicalName + "违规带离实验室,请尽快确认!";
+//                AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, to, content);
+//                AjaxResult result = remoteAlarmService.send(alarmEntrty);
+                List<String> paramList=new ArrayList<>();
+                TextMessageVo textMessageVo=new TextMessageVo();
+                textMessageVo.setPhoneList(Arrays.asList(to));
+                paramList.add(subName);
+                paramList.add(chemicalName);
+                textMessageVo.setVariableList(paramList);
+                textMessageVo.setTempId("142046");
+                textMessageVo.setTempContent(templateContent);
+                remoteSmsService.sendVoiceMessage(textMessageVo);//发送语音
+                remoteSmsService.sendTemplateMessage(textMessageVo);//发送短信
 
-                logger.error(JSONUtil.toJsonStr(result));
             }else if(phoneMode == 1){
-                content = "【实验室安全系统】" + subName + "-实验人员未领用即携带化学品离开房间,发生时间:"
+                content = "【忠江科技】" + subName + "-实验人员未领用即携带化学品离开房间,发生时间:"
                         + DateUtil.format(DateUtil.date(), DateUtils.YYYY_MM_DD_HH_MM_SS)
                         + ",请尽快确认。";//短信回复“CL”确认已处理。
                 try {
@@ -891,13 +931,13 @@ public class HxpStockServiceImpl implements IHxpStockService {
                 logger.info("即将过期保存日志成功!");
             }
             Long logId = (Long) result.getData();
-            String text = "【实验室安全系统】" + warningNoticeLogDto.getSubName() + "-" + warningNoticeLogDto.getName() + "即将过期,发生时间:" + LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss") + ",请尽快确认。";
+            String text = "【忠江科技】" + warningNoticeLogDto.getSubName() + "-" + warningNoticeLogDto.getName() + "即将过期,发生时间:" + LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss") + ",请尽快确认。";
             List<String> paramList=new ArrayList<>();
             paramList.add(warningNoticeLogDto.getSubName());
             paramList.add(warningNoticeLogDto.getName());
             paramList.add(LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss"));
             //发送通知
-            sendNotice(hxpStock, userIdStr, phones, warningConfigDto.getUnexpired(),text,logId,paramList);
+            sendNotice(hxpStock, userIdStr, phones, warningConfigDto.getUnexpired(),text,logId,paramList,"142030","【忠江科技】{lab_name}-{name} 即将过期,发生时间:{date} ,请尽快确认。");
         });
     }
 
@@ -951,12 +991,12 @@ public class HxpStockServiceImpl implements IHxpStockService {
                 logger.info("已过期保存日志成功!");
             }
             Long logId = (Long)result.getData();
-            String text =  "【实验室安全系统】"+warningNoticeLogDto.getSubName()+"-"+warningNoticeLogDto.getName()+"已过期,请尽快确认。";
+            String text =  "【忠江科技】"+warningNoticeLogDto.getSubName()+"-"+warningNoticeLogDto.getName()+"已过期,请尽快确认。";
             List<String> parmList=new ArrayList<>();
             parmList.add(warningNoticeLogDto.getSubName());
             parmList.add(warningNoticeLogDto.getName());
             //发送通知
-            sendNotice(hxpStock, userIdStr, phones, warningConfigDto.getExpired(), text, logId,parmList);
+            sendNotice(hxpStock, userIdStr, phones, warningConfigDto.getExpired(), text, logId,parmList,"142031","【忠江科技】{lab_name}-{name}已过期,请尽快确认。");
         });
 
         List<Long> stockIds = expiredStock.stream().filter(i -> 1 == i.getStatus()).map(HxpStockVO::getId).collect(Collectors.toList());
@@ -969,7 +1009,19 @@ public class HxpStockServiceImpl implements IHxpStockService {
         }
     }
 
-    private void sendNotice(HxpStockVO hxpStock, StringBuffer userIdStr, StringBuffer phones, String expired,String text,Long logId,List<String> paramList) {
+    /**
+     * 2024/4/16 修改 添加模板id和模板内容字段,替换短信平台
+     * @param hxpStock
+     * @param userIdStr
+     * @param phones
+     * @param expired
+     * @param text
+     * @param logId
+     * @param paramList
+     * @param tempId 模板id
+     * @param tempContent 模板内容
+     */
+    private void sendNotice(HxpStockVO hxpStock, StringBuffer userIdStr, StringBuffer phones, String expired,String text,Long logId,List<String> paramList,String tempId,String tempContent) {
         if (expired.contains("1")) {
             //系统通知
             LabMessageContent labMessageContent = new LabMessageContent();
@@ -996,16 +1048,17 @@ public class HxpStockServiceImpl implements IHxpStockService {
 //                alarmEntrty.setLogId(logId);
 //                alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
 //                remoteAlarmService.send(alarmEntrty);
-                List<String> phoneList=new ArrayList<>();
-                userPhoneInfoList.forEach(a->{
-                    phoneList.add(a.getPhone());
-                });
-                TextMessageVo textMessageVo=new TextMessageVo();
-                textMessageVo.setPhoneList(phoneList);
-                textMessageVo.setTempContent(text);
-                textMessageVo.setVariableList(paramList);
-                remoteSmsService.sendTemplateMessage(textMessageVo);
-                logger.info("化学品已过期发送短信打电话消息推送完成!");
+                if(!CollectionUtil.isEmpty(userPhoneInfoList)){
+                    TextMessageVo textMessageVo=new TextMessageVo();
+                    textMessageVo.setPhoneList(userPhoneInfoList.stream().map(UserPhoneInfo::getPhone).collect(Collectors.toList()));
+                    textMessageVo.setTempContent(tempContent);
+                    textMessageVo.setVariableList(paramList);
+                    textMessageVo.setTempId(tempId);
+                    remoteSmsService.sendTemplateMessage(textMessageVo);
+                    logger.info("发送短信打电话消息推送完成!");
+                }else{
+                    logger.info("短信接收人员为空,请仔细检查");
+                }
             }
         }
     }
@@ -1084,7 +1137,8 @@ public class HxpStockServiceImpl implements IHxpStockService {
                         logger.info("化学品超时未归还保存日志成功!");
                     }
                     Long logId = (Long) result.getData();
-                    String text ="【实验室安全系统】"+warningNoticeLogDto.getSubName()+"-"+warningNoticeLogDto.getApplyUser()+"领用"+warningNoticeLogDto.getName()+"超时未归还,领用时间:"+LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss") +",请尽快确认。";
+                    String text ="【忠江科技】"+warningNoticeLogDto.getSubName()+"-"+warningNoticeLogDto.getApplyUser()+"领用"+warningNoticeLogDto.getName()+"超时未归还,领用时间:"+LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss") +",请尽快确认。";
+                    String templateContent = "【忠江科技】{lab_name} - {apply_user} 领用{name}超时未归还,领用时间:{date},请尽快确认。";
                     if (timeout.contains("1")) {
                         //系统通知
                         LabMessageContent labMessageContent = new LabMessageContent();
@@ -1097,12 +1151,14 @@ public class HxpStockServiceImpl implements IHxpStockService {
                         labMessageContent.setContent(text);
                         remoteMessageContentService.sendMessage(labMessageContent);
                     }
+
+                    List<String> paramList=new ArrayList<>();
+                    paramList.add(warningNoticeLogDto.getSubName());
+                    paramList.add(warningNoticeLogDto.getApplyUser());
+                    paramList.add(warningNoticeLogDto.getName());
+                    paramList.add(LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss"));
+
                     if (timeout.contains("2")) {
-                        List<String> paramList=new ArrayList<>();
-                        paramList.add(warningNoticeLogDto.getSubName());
-                        paramList.add(warningNoticeLogDto.getApplyUser());
-                        paramList.add(warningNoticeLogDto.getName());
-                        paramList.add(LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss"));
                         //短信通知
                         String[] strings = Stream.of(phones.toString().split(",")).filter(a -> StrUtil.isNotBlank(a)).collect(Collectors.joining(",")).split(",");
                         if (strings != null) {
@@ -1117,16 +1173,17 @@ public class HxpStockServiceImpl implements IHxpStockService {
 //                            alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
 //                            remoteAlarmService.send(alarmEntrty);
                             //此处改成发短信模式
-                            List<String> phoneList=new ArrayList<>();
-                            userPhoneInfoList.forEach(a->{
-                                phoneList.add(a.getPhone());
-                            });
-                            TextMessageVo textMessageVo=new TextMessageVo();
-                            textMessageVo.setPhoneList(phoneList);
-                            textMessageVo.setTempContent(text);
-                            textMessageVo.setVariableList(paramList);
-                            remoteSmsService.sendTemplateMessage(textMessageVo);
-                            logger.info("化学品超时未归还发送短信打电话消息推送完成!");
+                            if(!CollectionUtil.isEmpty(userPhoneInfoList)){
+                                TextMessageVo textMessageVo=new TextMessageVo();
+                                textMessageVo.setPhoneList(userPhoneInfoList.stream().map(UserPhoneInfo::getPhone).collect(Collectors.toList()));
+                                textMessageVo.setTempContent(templateContent);
+                                textMessageVo.setTempId("142034");
+                                textMessageVo.setVariableList(paramList);
+                                remoteSmsService.sendTemplateMessage(textMessageVo);
+                                logger.info("化学品超时未归还发送短信打电话消息推送完成!");
+                            }else{
+                                logger.info("短信接收人员未空,请仔细检查");
+                            }
                         }
                     }
                     if (timeout.contains("5")) {
@@ -1143,15 +1200,16 @@ public class HxpStockServiceImpl implements IHxpStockService {
 //                            alarmEntrty.setLogId(logId);
 //                            alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
 //                            remoteAlarmService.send(alarmEntrty);
-                            List<String> phoneList=new ArrayList<>();
-                            userPhoneInfoList.forEach(a->{
-                                phoneList.add(a.getPhone());
-                            });
-                            TextMessageVo textMessageVo=new TextMessageVo();
-                            textMessageVo.setPhoneList(phoneList);
-                            textMessageVo.setTempContent(text);
-                            remoteSmsService.sendVoiceMessage(textMessageVo);
-                            logger.info("化学品超时未归还打电话消息推送完成!");
+                            if(!CollectionUtil.isEmpty(userPhoneInfoList)){
+                                TextMessageVo textMessageVo=new TextMessageVo();
+                                textMessageVo.setPhoneList(userPhoneInfoList.stream().map(UserPhoneInfo::getPhone).collect(Collectors.toList()));
+                                textMessageVo.setTempContent(templateContent);
+                                textMessageVo.setVariableList(paramList);
+                                remoteSmsService.sendVoiceMessage(textMessageVo);
+                                logger.info("化学品超时未归还打电话消息推送完成!");
+                            }else{
+                                logger.info("电信接收人员未空,请仔细检查");
+                            }
                         }
                     }
 

+ 25 - 6
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisExpiredPhotographListener.java

@@ -1,5 +1,6 @@
 package com.zd.laboratory.event;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
@@ -20,6 +21,8 @@ import com.zd.laboratory.api.dto.CheckSubjectDto;
 import com.zd.laboratory.api.dto.WarningNoticeLogDto;
 import com.zd.laboratory.api.entity.LabMessageContent;
 import com.zd.laboratory.api.feign.RemoteLaboratoryService;
+import com.zd.laboratory.api.feign.RemoteSmsService;
+import com.zd.laboratory.api.vo.TextMessageVo;
 import com.zd.laboratory.domain.LabHardware;
 import com.zd.laboratory.domain.WarningConfig;
 import com.zd.laboratory.domain.WarningDetail;
@@ -42,6 +45,7 @@ import org.springframework.stereotype.Component;
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -93,6 +97,9 @@ public class RedisExpiredPhotographListener extends KeyExpirationEventMessageLis
     @Resource
     private RemoteLaboratoryService remoteLaboratoryService;
 
+    @Autowired
+    private RemoteSmsService remoteSmsService;
+
     private final String streamUrlFormat = "rtsp://admin:hk123456@{}:554/h264/ch1/main/av_stream";
 
     public RedisExpiredPhotographListener(RedisMessageListenerContainer listenerContainer) {
@@ -191,7 +198,7 @@ public class RedisExpiredPhotographListener extends KeyExpirationEventMessageLis
 
                             //是否通知
                             StringBuilder warningWay = new StringBuilder();
-                            String text = "【实验室安全系统】"+warningNoticeLog.getSubName()+"-监测到实验人员违规未穿戴实验服,请尽快确认。";
+                            String text = "【忠江科技】"+warningNoticeLog.getSubName()+"-监测到实验人员违规未穿戴实验服,请尽快确认。";
                             WarningNoticeLogDto warningNoticeLogDto2 = new WarningNoticeLogDto();
                             //系统 短信 语音通知
                             long noticeCount = warningNoticeLogService.count(new LambdaQueryWrapper<WarningNoticeLog>().eq(WarningNoticeLog::getSubId, warningNoticeLog.getSubId())
@@ -222,11 +229,23 @@ public class RedisExpiredPhotographListener extends KeyExpirationEventMessageLis
                                         log.info("获取实验室管理员和安全员信息失败!{}",JSON.toJSONString(listResultData));
                                     }
                                     List<UserPhoneInfo> userPhoneInfoList = listResultData.getData();
-                                    AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.toString(), text);
-                                    alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
-                                    alarmEntrty.setLogId(warningNoticeLog.getId());
-                                    remoteAlarmService.send(alarmEntrty);
-                                    log.info("未穿戴实验服发送短信打电话消息推送完成!");
+//                                    AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.toString(), text);
+//                                    alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
+//                                    alarmEntrty.setLogId(warningNoticeLog.getId());
+//                                    remoteAlarmService.send(alarmEntrty);
+                                    if(!CollectionUtil.isEmpty(userPhoneInfoList)){
+                                        List<String> paramList=new ArrayList<>();
+                                        TextMessageVo textMessageVo=new TextMessageVo();
+                                        textMessageVo.setPhoneList(userPhoneInfoList.stream().map(UserPhoneInfo::getPhone).collect(Collectors.toList()));
+                                        paramList.add(warningNoticeLog.getSubName());
+                                        paramList.add("实验服");
+                                        textMessageVo.setVariableList(paramList);
+                                        textMessageVo.setTempId("142019");
+                                        textMessageVo.setTempContent("【忠江科技】{sub_name} -监测到实验人员违规未穿戴{protective_clothing},请尽快确认。");
+                                        remoteSmsService.sendTemplateMessage(textMessageVo);
+                                        log.info("未穿戴实验服发送短信打电话消息推送完成!");
+                                    }
+                                    log.info("接收短信号码为空,请仔细检查!userPhoneInfoList:{}",userPhoneInfoList);
                                 }
                             }
                             long l2 = noticeCount % warningConfig.getVoiceNotcie();

+ 15 - 6
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabMessageContentServiceImpl.java

@@ -116,7 +116,7 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
 
     private final String smsType = "2";
 
-    private final String smsFormatString2 = "【实验室安全系统】{}-{}数值异常,请立即核实处理:";
+    private final String smsFormatString2 = "【忠江科技】{}-{}数值异常,请立即核实处理!";
 
     /**
      * 查询消息发布
@@ -285,15 +285,24 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
                 logger.info("打印发送人电话号码!{}",JSON.toJSONString(strings));
                 AlarmEntrty alarmEntrty = new AlarmEntrty();
                 List<String> alarms = Arrays.asList(labRiskPlanLevel.getAlarmType().split(","));
+                List<String> paramList=new ArrayList<>();
+                TextMessageVo textMessageVo=new TextMessageVo();
+                textMessageVo.setPhoneList(Arrays.asList(strings));
+                paramList.add(labRiskPlanLevel.getTopName());
+                paramList.add(labRiskPlanLevel.getRiskName());
+                textMessageVo.setVariableList(paramList);
+                textMessageVo.setTempId("142024");
+                textMessageVo.setTempContent("【忠江科技】{lab_name}-{risk_name}数值异常,请立即核实处理!");
                 if (alarms.contains(callType) && alarms.contains(smsType)) {
-                    alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, format);
-                    //// TODO: 2024/4/9
-                    TextMessageVo textMessageVo=new TextMessageVo();
+//                    alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, format);
                     remoteSmsService.sendVoiceMessage(textMessageVo);
+                    remoteSmsService.sendTemplateMessage(textMessageVo);
                 }else if(alarms.contains(callType)){
-                    alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.Call.toString(),format);
+//                    alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.Call.toString(),format);
+                    remoteSmsService.sendVoiceMessage(textMessageVo);
                 }else if(alarms.contains(smsType)) {
-                    alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.toString(),format);
+//                    alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.toString(),format);
+                    remoteSmsService.sendTemplateMessage(textMessageVo);
                 }
 //                alarmEntrty.setUserPhoneInfo(userPhoneInfos);
 //                alarmEntrty.setLogId(logId);