| | |
| | | String API_PREFIX = "/client"; |
| | | String SAVE_SMS_RECORD = API_PREFIX + "/saveSmsRecord"; |
| | | String SEND_SMS_BY_OUT_CALL_NOT_CONNECT = API_PREFIX + "/sendSmsByOutCallNotConnect"; |
| | | String CREATE_OUT_CALL_ERROR_SEND_SMS = API_PREFIX + "/createOutCallErrorSendSms"; |
| | | |
| | | /** |
| | | * 保存短信发送记录 |
| | |
| | | @GetMapping(SEND_SMS_BY_OUT_CALL_NOT_CONNECT) |
| | | String sendSmsByOutCallNotConnect(@RequestParam("taskId")String taskId, |
| | | @RequestParam("time")String time); |
| | | |
| | | /** |
| | | * 外呼任务创建失败发送短信提醒 |
| | | * @param msg 失败原因 |
| | | */ |
| | | @GetMapping(CREATE_OUT_CALL_ERROR_SEND_SMS) |
| | | void createOutCallErrorSendSms(@RequestParam("msg") String msg); |
| | | } |
| | |
| | | public String sendSmsByOutCallNotConnect(String taskId, String time) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void createOutCallErrorSendSms(String msg) { |
| | | |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 短信发送记录 |
| | | * @author zhongrj |
| | |
| | | public String sendSmsByOutCallNotConnect(String taskId,String time) { |
| | | return smsService.sendSmsByOutCallNotConnect(taskId,time); |
| | | } |
| | | |
| | | /** |
| | | * 外呼任务创建失败发送短信提醒 |
| | | * @param msg 失败原因 |
| | | */ |
| | | @Override |
| | | @GetMapping(CREATE_OUT_CALL_ERROR_SEND_SMS) |
| | | public void createOutCallErrorSendSms(String msg) { |
| | | // 创建map 集合 |
| | | Map<String, Object> map = new HashMap<>(3); |
| | | // 查询需要告警的人员手机号 |
| | | List<String> list = new ArrayList<>(); |
| | | list.add("15170720695"); |
| | | list.add("15179776420"); |
| | | //封装数据 |
| | | map.put("templateId","2431012254505"); |
| | | map.put("phones",list); |
| | | map.put("content",msg); |
| | | // 发送短信 |
| | | smsService.batchSendSms(map); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 批量发送动态短信 |
| | | * 批量发送动态短信--该方法只适合除手机号外只有一个动态参数并且是内容一致的情况 |
| | | * @param phoneList |
| | | * @param titleArr 示例: [手机号码,水库名称,水位值] |
| | | * @param param 示例: ***水库,15.12 |
| | |
| | | public Object batchSendSms(Map<String, Object> map) { |
| | | // 获取模板id |
| | | String templateId = map.get("templateId").toString(); |
| | | // 获取集合数据 |
| | | List<Map<String,Object>> list = (List<Map<String,Object>>) map.get("list"); |
| | | List<String> columnList = (List<String>) map.get("columnList"); |
| | | // 遍历 |
| | | for (Map<String, Object> param : list) { |
| | | // 放入集合数据 |
| | | } |
| | | return null; |
| | | // 获取手机号集合 |
| | | List<String> list = (List<String>) map.get("phones"); |
| | | // 获取发送的动态内容(msg) |
| | | String param = (String) map.get("content"); |
| | | // 创建错误手机号集合 |
| | | List<String> errPhones = new ArrayList<>(); |
| | | // 去重 |
| | | Set<String> hashSet = new HashSet<>(list); |
| | | // 查询短信模板 |
| | | SmsTemplate smsTemplate = smsTemplateService.getOne(new QueryWrapper<SmsTemplate>().eq("template_id", templateId)); |
| | | // 拼接短信标题数组 |
| | | String [] titleArr = getSmsTitleArr(smsTemplate); |
| | | // 批量发送短信 |
| | | Map<String, Object> batchSendSmsMap = batchSendSms(hashSet, titleArr, param, smsTemplate,errPhones); |
| | | // 返回 |
| | | return batchSendSmsMap; |
| | | } |
| | | } |
| | |
| | | package cn.gistack.sm.intelligentCall.service.impl; |
| | | |
| | | import cn.gistack.alerts.sms.feign.ISmsRecordClient; |
| | | import cn.gistack.sm.intelligentCall.entity.DailyCallTask; |
| | | import cn.gistack.sm.intelligentCall.service.IDailyCallTaskService; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | |
| | | |
| | | @Autowired |
| | | private IDailyCallTaskService dailyCallTaskService; |
| | | |
| | | @Autowired |
| | | private ISmsRecordClient smsRecordClient; |
| | | |
| | | |
| | | /** |
| | |
| | | // 新增 |
| | | dailyCallTaskService.save(dailyCallTask); |
| | | } |
| | | |
| | | /** |
| | | * 外呼任务创建失败发送短信提醒 |
| | | * @param code 错误码 |
| | | * @param msg 失败原因 |
| | | */ |
| | | @Async |
| | | public void createOutCallErrorSendSms(String code,String msg) { |
| | | String data = msg; |
| | | // 新增 |
| | | smsRecordClient.createOutCallErrorSendSms(data); |
| | | } |
| | | } |
| | |
| | | if (success){ |
| | | //通过任务名称查询taskId |
| | | taskId = callTaskMapper.getTaskIdByTaskName(taskName); |
| | | }else { |
| | | // 任务创建失败,发送短信告知 |
| | | asyncCallService.createOutCallErrorSendSms(jsonObject.getString("code"),jsonObject.getString("message")); |
| | | } |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(response.getBody()); |