|
@@ -1,7 +1,12 @@
|
|
|
package com.usky.alarm.service.impl;
|
|
|
|
|
|
+import com.aliyuncs.DefaultAcsClient;
|
|
|
+import com.aliyuncs.IAcsClient;
|
|
|
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
|
|
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
|
|
import com.aliyuncs.dyvmsapi.model.v20170525.SingleCallByTtsResponse;
|
|
|
import com.aliyuncs.exceptions.ClientException;
|
|
|
+import com.aliyuncs.profile.DefaultProfile;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -10,6 +15,7 @@ import com.usky.alarm.mapper.BaseAlarmMapper;
|
|
|
import com.usky.alarm.mapper.BaseAlarmNoticeResultMapper;
|
|
|
import com.usky.alarm.mapper.SysUserMapper;
|
|
|
import com.usky.alarm.service.*;
|
|
|
+import com.usky.alarm.service.config.smsmessage.SmsMessage;
|
|
|
import com.usky.alarm.service.config.voice.VoiceNotice;
|
|
|
import com.usky.alarm.service.config.websocket.WebSocket;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
@@ -102,26 +108,45 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
|
|
|
.eq(BaseAlarmNotice::getDeleteFlag,0);
|
|
|
List<BaseAlarmNotice> records3 = baseAlarmNoticeService.list(lambdaQuery3);
|
|
|
if (records3.size()>0){
|
|
|
- if (records3.get(0).getNoticeMethod().contains("电话")){
|
|
|
- String[] array = records3.get(0).getReceiver1().split(",");
|
|
|
- for (String s : array) {
|
|
|
- LambdaQueryWrapper<SysUser> lambdaQuery4 = Wrappers.lambdaQuery();
|
|
|
- lambdaQuery4.eq(SysUser::getUserId,s)
|
|
|
- .eq(SysUser::getDelFlag,0);
|
|
|
- SysUser sysUser = sysUserMapper.selectOne(lambdaQuery4);
|
|
|
-// SingleCallByTtsResponse code = voiceNotice.sendCVoice("15122423833","视频监控","火点侦测","2023-09-12 10:01:54");
|
|
|
+ String[] array = records3.get(0).getReceiver1().split(",");
|
|
|
+ for (String s : array) {
|
|
|
+ LambdaQueryWrapper<SysUser> lambdaQuery4 = Wrappers.lambdaQuery();
|
|
|
+ lambdaQuery4.eq(SysUser::getUserId,s)
|
|
|
+ .eq(SysUser::getDelFlag,0);
|
|
|
+ SysUser sysUser = sysUserMapper.selectOne(lambdaQuery4);
|
|
|
+ BaseAlarmNoticeResult baseAlarmNoticeResult = new BaseAlarmNoticeResult();
|
|
|
+ baseAlarmNoticeResult.setReceiver(sysUser.getPhonenumber());
|
|
|
+ baseAlarmNoticeResult.setAlarmId(alarmId);
|
|
|
+ baseAlarmNoticeResult.setNoticeTime(LocalDateTime.now());
|
|
|
+ baseAlarmNoticeResult.setNoticeContent(records.get(0).getProductName()+","+baseAlarmType.getTypeName()+","+baseAlarm.getAlarmTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd " +
|
|
|
+ "HH:mm:ss")));
|
|
|
+ baseAlarmNoticeResult.setTenantId(records.get(0).getTenantId());
|
|
|
+ if (records3.get(0).getNoticeMethod().contains("电话")){
|
|
|
SingleCallByTtsResponse code = voiceNotice.sendCVoice(sysUser.getPhonenumber(),
|
|
|
records.get(0).getProductName(),baseAlarmType.getTypeName(),
|
|
|
baseAlarm.getAlarmTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd " +
|
|
|
- "HH:mm:ss")));
|
|
|
- BaseAlarmNoticeResult baseAlarmNoticeResult = new BaseAlarmNoticeResult();
|
|
|
- baseAlarmNoticeResult.setReceiver(sysUser.getPhonenumber());
|
|
|
- baseAlarmNoticeResult.setAlarmId(alarmId);
|
|
|
- baseAlarmNoticeResult.setNoticeTime(LocalDateTime.now());
|
|
|
+ "HH:mm:ss")));
|
|
|
baseAlarmNoticeResult.setNoticeType(3);
|
|
|
- baseAlarmNoticeResult.setNoticeContent(records.get(0).getProductName()+","+baseAlarmType.getTypeName()+","+baseAlarm.getAlarmTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd " +
|
|
|
- "HH:mm:ss")));
|
|
|
- baseAlarmNoticeResult.setTenantId(records.get(0).getTenantId());
|
|
|
+ if(code.getCode() != null && code.getCode().equals("OK")) {
|
|
|
+ //请求成功
|
|
|
+ baseAlarmNoticeResult.setNoticeResult(1);
|
|
|
+ }else {
|
|
|
+ baseAlarmNoticeResult.setNoticeResult(2);
|
|
|
+ }
|
|
|
+ Integer saveAlarmResult = baseAlarmNoticeResultMapper.insert(baseAlarmNoticeResult);
|
|
|
+ }
|
|
|
+ if (records3.get(0).getNoticeMethod().contains("短信")){
|
|
|
+ DefaultProfile profile = DefaultProfile.getProfile("cn-beijing", "LTAI5tH3VvRL5BUkovCokHJX", "SaaWUouNqvcA0C746gcNOH9m6SRYN4");
|
|
|
+ IAcsClient client = new DefaultAcsClient(profile);
|
|
|
+ SendSmsRequest request = new SendSmsRequest();
|
|
|
+ request.setPhoneNumbers(sysUser.getPhonenumber());//接收短信的手机号码
|
|
|
+ request.setSignName("上海永天科技股份有限公司");//短信签名名称
|
|
|
+ request.setTemplateCode("SMS_463791105");//短信模板CODE
|
|
|
+ request.setTemplateParam("{\"deviceName\":\""+records2.get(0).getDeviceName()+"\","+"\"time\":\""+baseAlarm.getAlarmTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd " +
|
|
|
+ "HH:mm:ss"))+"\","+
|
|
|
+ "\"alarmType\":\""+baseAlarmType.getTypeName()+"\","+"\"alarmContent\":\""+baseAlarm.getAlarmContent()+"\"}");
|
|
|
+ SendSmsResponse code = client.getAcsResponse(request);
|
|
|
+ baseAlarmNoticeResult.setNoticeType(4);
|
|
|
if(code.getCode() != null && code.getCode().equals("OK")) {
|
|
|
//请求成功
|
|
|
baseAlarmNoticeResult.setNoticeResult(1);
|