Commit 97eed631 by 李小龙

fix: 语音短信

parent f6d83c32
......@@ -33,5 +33,7 @@ public class MsgSendDTO {
this.param = param;
}
private String alarmType;
}
......@@ -21,7 +21,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
@Component
@Slf4j
......@@ -48,36 +47,63 @@ public class SmsVoiceSender implements IMsgSender{
if(CollectionUtils.isEmpty(msgDTO.getReceiverList())){
log.info("发送语音短信时,没有接收人,短信内容:"+msgDTO.getOriContent());
}
String alarmType = msgDTO.getAlarmType();
Date now = new Date();
//todo 支持同时发送多个老人
String time = String.valueOf(now.getTime());
Collection<String> receiverList = msgDTO.getReceiverList();
String receiverJoin = receiverList.stream().collect(Collectors.joining(","));
receiverList.forEach(
vo->{
try {
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("uid", smsVoiceConfig.getUid());
//md5-32位( md5-16位(登录密码)+ time )
String md16 = CryptoUtil.md5_16(smsVoiceConfig.getPwd());
String md16 = null;
md16 = CryptoUtil.md5_16(smsVoiceConfig.getPwd());
String md32 = CryptoUtil.md5(md16 + time);
paramMap.put("pwd", md32);
paramMap.put("time", time);
paramMap.put("mobile", receiverJoin);
paramMap.put("mobile", vo);
//告警类型 数据字典 1 长者跌倒 2 呼吸异常 3 心率异常 4 行为异常
if (StringUtils.equals(alarmType, "1")) {
paramMap.put("vid", "141");
}
if (StringUtils.equals(alarmType, "2")) {
paramMap.put("vid", "");
}
if (StringUtils.equals(alarmType, "3")) {
paramMap.put("vid", "");
}
if (StringUtils.equals(alarmType, "4")) {
paramMap.put("vid", "");
}
String[] param = msgDTO.getParam();
List<BiConsumer<HashMap<String,String>,String>> consumerList = Arrays.asList(
(t,v)->t.put("one",v),
(t,v)->t.put("two",v)
List<BiConsumer<HashMap<String, String>, String>> consumerList = Arrays.asList(
(t, v) -> t.put("one", v),
(t, v) -> t.put("two", v)
);
for (int i = 0; i < param.length; i++) {
BiConsumer<HashMap<String, String>, String> biConsumer = consumerList.get(i);
biConsumer.accept(paramMap,param[i]);
biConsumer.accept(paramMap, param[i]);
}
String resStr = HttpClient.sendJSONPostRequest(smsVoiceConfig.getUrl(), paramMap, new HttpHeaders(), String.class);
JSONObject jsonObject = JSON.parseObject(resStr);
String status = String.valueOf(jsonObject.get("status"));
if (!StringUtils.equals(status, "0")) {
log.error("发送语音短信失败:"+jsonObject.get("status_code"));
log.error("发送语音短信失败:" + jsonObject.get("status_code"));
throw new BusinessException((String) jsonObject.get("status_code"));
}
log.info("发送语音短信成功");
}catch (Exception e){
log.error("发送语音异常:",vo,msgDTO,e);
}
}
);
}catch (Exception e){
log.error("发送语音异常:",msgDTO,e);
}
}
......
......@@ -323,6 +323,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
msgSendDTO.setOriContent(alarmRecord.getContent());
msgSendDTO.setSubject(alarmRecord.getContent());
msgSendDTO.setParam(alarmRecord.getElderName());
msgSendDTO.setAlarmType(alarmConfig.getAlarmType());
//todo 小程序消息
msgUtil.send(msgSendDTO);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment