9 files modified
1 files added
| | |
| | | import cn.gistack.sm.sjztmd.feign.IAttResManagePersonClientFallback; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 智能外呼任务 feign |
| | |
| | | String CREATE_OUT_CALL_TASK_JOB_HANDLER_BY_NOT_CALL = API_PREFIX + "/createOutCallTaskJobHandlerByNotCall"; |
| | | String CREATE_OUT_CALL_TASK_BY_NOT_CONNECT_JOB_HANDLER = API_PREFIX + "/createOutCallTaskByNotConnectJobHandler"; |
| | | String GET_CALL_NOT_FILL_RECORD_INFO = API_PREFIX + "/getCallNotFillRecordInfo"; |
| | | String CREATE_OUT_CALL_TASK_BY_ALARM = API_PREFIX + "/createOutCallTaskByAlarm"; |
| | | String CREATE_CALL_SMS_NOTICE_TASK = API_PREFIX + "/createCallSmsNoticeTask"; |
| | | String TEST_OUT_CALL = API_PREFIX + "/testOutCall"; |
| | | |
| | |
| | | */ |
| | | @GetMapping(CREATE_CALL_SMS_NOTICE_TASK) |
| | | Boolean createCallSmsNoticeTask(@RequestParam("taskId") String taskId); |
| | | |
| | | /** |
| | | * 创建告警外呼任务 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | @PostMapping(CREATE_OUT_CALL_TASK_BY_ALARM) |
| | | List<String> createOutCallTaskByAlarm(@RequestBody Map<String, Object> map); |
| | | } |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 智能外呼Feign失败配置 |
| | |
| | | public Boolean createCallSmsNoticeTask(String taskId) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> createOutCallTaskByAlarm(Map<String, Object> map) { |
| | | return null; |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.alerts.notice.constant; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 智能外呼常量 |
| | | * @author zhongrj |
| | | * @since 2023-08-01 |
| | | */ |
| | | public class ZnwhColumnConstant { |
| | | |
| | | |
| | | /** |
| | | * 策略9.1: 水位接近设计洪水位告警-电话 |
| | | */ |
| | | public static Map<String,String> waterComeDesignMap = new HashMap<>() |
| | | {{ |
| | | put("水库编号","res_cd"); |
| | | put("被叫号码","phone"); |
| | | put("日期","tm"); |
| | | put("乡镇名称","town_nm"); |
| | | put("水库名称","res_nm"); |
| | | put("水位值","rz"); |
| | | put("超过汛限水位值及说明","over_z"); |
| | | put("距设计洪水位值","diff_dam"); |
| | | put("水利部人员姓名联系电话","tm"); |
| | | put("告警记录id","alarmRecord"); |
| | | }}; |
| | | |
| | | } |
| | |
| | | import cn.gistack.alerts.notice.enums.DangerEnum; |
| | | import cn.gistack.alerts.sms.service.SmsService; |
| | | import cn.gistack.alerts.sms.vo.SmsRequestTemplate; |
| | | import cn.gistack.sm.intelligentCall.feign.OutCallClient; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | |
| | | Boolean isSendStation, |
| | | String uuid) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | // String uuid = alarmRuleDetail.getTemplateId() + UUID.randomUUID().toString(); |
| | | // 只发短信,将发短信信息组装好 |
| | | SmsRequestTemplate smsRequestTemplate |
| | | = noticeHandle.getSendSmsTemplate(ztData, alarmRule, alarmRuleDetail, columnList, flag, adCode, uuid, isSendStation); |
| | |
| | | list.add(alarmRecord.getId().toString()); |
| | | } |
| | | } |
| | | map = smsService.sendSignMsg(smsRequestTemplate); |
| | | List<String> list = noticeHandle.createOutCallTaskByAlarm(smsRequestTemplate); |
| | | map.put("list",list); |
| | | // 调用短信服务 |
| | | return map; |
| | | } |
| | |
| | | import cn.gistack.alerts.alarmRule.entity.AlarmRule; |
| | | import cn.gistack.alerts.alarmRule.entity.AlarmRuleDetail; |
| | | import cn.gistack.alerts.alarmRule.service.AlarmRecordService; |
| | | import cn.gistack.alerts.notice.constant.ZnwhColumnConstant; |
| | | import cn.gistack.alerts.notice.constant.ZtApiUrlConstant; |
| | | import cn.gistack.alerts.notice.constant.ZtConfigConstant; |
| | | import cn.gistack.alerts.notice.enums.PersonEnum; |
| | |
| | | import cn.gistack.alerts.sms.vo.SmsRequestTemplate; |
| | | import cn.gistack.alerts.sse.server.SSEServer; |
| | | import cn.gistack.common.utils.SpringContextUtil; |
| | | import cn.gistack.sm.intelligentCall.feign.OutCallClient; |
| | | import cn.gistack.sm.message.entity.MessageRecord; |
| | | import cn.gistack.sm.message.feign.IMessageClient; |
| | | import cn.gistack.sm.sjztmd.feign.IAttResManagePersonClient; |
| | |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | |
| | | @Component |
| | |
| | | @Autowired |
| | | private IPushService pushService; |
| | | |
| | | @Autowired |
| | | private OutCallClient outCallClient; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | String adCode, |
| | | String uuid, |
| | | Boolean isSendStation) { |
| | | // 通过模板id 查询模板相关信息 |
| | | // 通过模板id 查询模板相关信息(外呼对应的模板id则为场景id) |
| | | SmsTemplate smsTemplate |
| | | = smsTemplateService.getOne(new QueryWrapper<SmsTemplate>().eq("id",alarmRuleDetail.getTemplateId()).eq("is_deleted",0)); |
| | | if (null != smsTemplate) { |
| | |
| | | // 解析模板并设置 title |
| | | smsRequestTemplate.setTitle(FormatUtil.composeMessage(smsTemplate.getContent())); |
| | | // 列名数据转换 |
| | | getColumnData(jsonArray, columnsList,smsRequestTemplate,alarmRuleDetail.getAlarmPerson(),flag,adCode,uuid); |
| | | getColumnData(jsonArray, columnsList,smsRequestTemplate,alarmRuleDetail,flag,adCode,uuid); |
| | | //返回 |
| | | return smsRequestTemplate; |
| | | } |
| | |
| | | * @param jsonArray 告警动态数据 |
| | | * @param columnsList 告警动态内容 key |
| | | * @param smsRequestTemplate 消息发送对象 |
| | | * @param roleIds 告警人员角色ids |
| | | * @param alarmRuleDetail 告警人员角色ids |
| | | * @param flag 告警内容是否日期 |
| | | * @param adCode 行政区 code ,用于过滤数据 |
| | | * @param uuid 用于过滤数据 |
| | |
| | | private void getColumnData(JSONArray jsonArray, |
| | | List<String> columnsList, |
| | | SmsRequestTemplate smsRequestTemplate, |
| | | String roleIds, |
| | | AlarmRuleDetail alarmRuleDetail, |
| | | Boolean flag, |
| | | String adCode, |
| | | String uuid) { |
| | |
| | | // city_cd,county_cd 过滤数据 |
| | | String county_cd = jsonArray.getJSONObject(i).getString("county_cd"); |
| | | if (null!= county_cd && county_cd.equals(adCode)) { |
| | | jointData(jsonArray, columnsList, roleIds, flag, personLists, lists, i,uuid,set); |
| | | jointData(jsonArray, columnsList, alarmRuleDetail, flag, personLists, lists, i,uuid,set); |
| | | } |
| | | }else { |
| | | jointData(jsonArray, columnsList, roleIds, flag, personLists, lists, i,uuid,set); |
| | | jointData(jsonArray, columnsList, alarmRuleDetail, flag, personLists, lists, i,uuid,set); |
| | | } |
| | | } |
| | | // 设置信息 |
| | |
| | | * 拼接列数据设置告警人员信息 |
| | | * @param jsonArray 告警动态数据 |
| | | * @param columnsList 告警动态内容 key |
| | | * @param roleIds 告警人角色ids |
| | | * @param alarmRuleDetail 告警人角色ids |
| | | * @param flag 告警内容是否日期 |
| | | * @param personLists 告警人 |
| | | * @param lists 告警内容 |
| | |
| | | */ |
| | | private void jointData(JSONArray jsonArray, |
| | | List<String> columnsList, |
| | | String roleIds, |
| | | AlarmRuleDetail alarmRuleDetail, |
| | | Boolean flag, |
| | | List<PersonVO> personLists, |
| | | List<List<String>> lists, |
| | |
| | | flag = false; |
| | | } |
| | | // 获取告警人员信息 |
| | | getAlarmPersonList(jsonArray, columnsList, roleIds, flag, personLists, lists, i, res_cd, day, hour, minute, stcd); |
| | | getAlarmPersonList(jsonArray, columnsList, alarmRuleDetail, flag, personLists, lists, i, res_cd, day, hour, minute, stcd); |
| | | } |
| | | } |
| | | |
| | |
| | | * 获取告警人员信息 |
| | | * @param jsonArray 接口水库相关数据 |
| | | * @param columnsList 模板对应列key |
| | | * @param roleIds 告警人员角色ids |
| | | * @param alarmRuleDetail 告警人员角色ids |
| | | * @param flag 模板中是否填入时间 |
| | | * @param personLists 告警人员集合 |
| | | * @param lists 告警内容集合 |
| | |
| | | */ |
| | | private void getAlarmPersonList(JSONArray jsonArray, |
| | | List<String> columnsList, |
| | | String roleIds, |
| | | AlarmRuleDetail alarmRuleDetail, |
| | | Boolean flag, |
| | | List<PersonVO> personLists, |
| | | List<List<String>> lists, |
| | |
| | | String minute, |
| | | String stcd) { |
| | | // 查询告警人员信息 |
| | | List<PersonVO> personVOList = getPersonListByResGuid(res_cd, roleIds); |
| | | List<PersonVO> personVOList = getPersonListByResGuid(res_cd, alarmRuleDetail.getAlarmPerson()); |
| | | if (personVOList.size() > 0) { |
| | | for (PersonVO personVO : personVOList) { |
| | | List<String> list = new ArrayList<>(); |
| | |
| | | list.add(res_cd); |
| | | list.add(personVO.getPhone()); |
| | | if (flag) { |
| | | list.add(day); |
| | | list.add(hour); |
| | | list.add(minute); |
| | | // 如果是电话告警,需要把日期拼到一起 |
| | | if (alarmRuleDetail.getAlarmMode().equals("电话")){ |
| | | String tem = day + "日" + hour + "时" + minute + "分"; |
| | | list.add(tem); |
| | | }else { |
| | | list.add(day); |
| | | list.add(hour); |
| | | list.add(minute); |
| | | } |
| | | } |
| | | // 变量将值放入集合中 |
| | | for (String column : columnsList) { |
| | |
| | | // 加入集合 |
| | | messageRecordList.add(messageRecord); |
| | | } |
| | | |
| | | /** |
| | | * 创建告警外呼任务 |
| | | * @param smsRequestTemplate |
| | | * @return |
| | | */ |
| | | public List<String> createOutCallTaskByAlarm(SmsRequestTemplate smsRequestTemplate) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, String>> mapList = new ArrayList<>(); |
| | | // 拼装数据 |
| | | List<String> titles = new ArrayList<>(Arrays.asList(smsRequestTemplate.getTitle().split(","))); |
| | | // 修改手机号码为被叫号码 |
| | | titles.set(0, "被叫号码"); |
| | | titles.add("告警记录id"); |
| | | titles.add(0,"水库编号"); |
| | | map.put("titles",titles); |
| | | // 处理人员及预警相关数据并组装 |
| | | for (List<String> list : smsRequestTemplate.getTemplateContent()) { |
| | | Map<String, String> stringMap = new HashMap<>(); |
| | | for (int i = 0; i < titles.size(); i++) { |
| | | stringMap.put(titles.get(i),list.get(i)); |
| | | } |
| | | mapList.add(stringMap); |
| | | } |
| | | map.put("list",mapList); |
| | | map.put("scenesId",smsRequestTemplate.getSmsTemplate().getTemplateId()); |
| | | String taskName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")) + smsRequestTemplate.getAlarmRule().getRuleName() + "智能外呼"; |
| | | map.put("taskName",taskName); |
| | | String taskScheduleTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | map.put("taskScheduleTime",taskScheduleTime); |
| | | // 创建外呼任务 |
| | | return outCallClient.createOutCallTaskByAlarm(map); |
| | | } |
| | | } |
| | |
| | | if (alarmRuleDetailList.size()>0){ |
| | | // 遍历 |
| | | for (AlarmRuleDetail alarmRuleDetail : alarmRuleDetailList) { |
| | | if (alarmRuleDetail.getAlarmMode().equals("短信")) { |
| | | asyncNoticeHandle.waterComeDesignHandleBySms(alarmRule, alarmRuleDetail, ztData,ZtApiDataColumnConstant.waterComeDesignList1,true, adCode, false,uuid); |
| | | } |
| | | // if (alarmRuleDetail.getAlarmMode().equals("电话")) { |
| | | // asyncNoticeHandle.waterComeDesignHandleCall(alarmRule, alarmRuleDetail, ztData,ZtApiDataColumnConstant.waterComeDesignList2,true, adCode, false,uuid); |
| | | // if (alarmRuleDetail.getAlarmMode().equals("短信")) { |
| | | // asyncNoticeHandle.waterComeDesignHandleBySms(alarmRule, alarmRuleDetail, ztData,ZtApiDataColumnConstant.waterComeDesignList1,true, adCode, false,uuid); |
| | | // } |
| | | if (alarmRuleDetail.getAlarmMode().equals("站内信")) { |
| | | asyncNoticeHandle.waterComeDesignHandleStation(alarmRule, alarmRuleDetail, ztData,ZtApiDataColumnConstant.waterComeDesignList3,true, adCode, true,uuid); |
| | | if (alarmRuleDetail.getAlarmMode().equals("电话")) { |
| | | asyncNoticeHandle.waterComeDesignHandleCall(alarmRule, alarmRuleDetail, ztData,ZtApiDataColumnConstant.waterComeDesignList2,true, adCode, false,uuid); |
| | | } |
| | | // if (alarmRuleDetail.getAlarmMode().equals("站内信")) { |
| | | // asyncNoticeHandle.waterComeDesignHandleStation(alarmRule, alarmRuleDetail, ztData,ZtApiDataColumnConstant.waterComeDesignList3,true, adCode, true,uuid); |
| | | // } |
| | | } |
| | | } |
| | | } |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | import java.util.*; |
| | |
| | | //外呼短信通知任务创建并返回 |
| | | return callSmsNoticeTaskService.createCallSmsNoticeTask(taskId); |
| | | } |
| | | |
| | | /** |
| | | * 创建告警外呼任务 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | @Override |
| | | @PostMapping(CREATE_OUT_CALL_TASK_BY_ALARM) |
| | | public List<String> createOutCallTaskByAlarm(@RequestBody Map<String, Object> map) { |
| | | //创建告警外呼任务并返回 |
| | | return callService.createOutCallTaskByAlarm(map); |
| | | } |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | Object getCallResultListTemp(IPage<CallTaskResultVO> page, CallTaskResultVO callTaskResult); |
| | | |
| | | /** |
| | | * 创建告警外呼任务 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | List<String> createOutCallTaskByAlarm(Map<String, Object> map); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | | * @date 2023-06-13 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建告警外呼任务 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<String> createOutCallTaskByAlarm(Map<String, Object> map) { |
| | | List<Map<String, String>> params = (List<Map<String, String>>) map.get("list"); |
| | | JSONArray arr = getCalleeInfoAlarm(params,(List<String>) map.get("titles")); |
| | | String requestUrl = url + CREATE_TASK_URL; |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | String timestamp = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss SSS")); |
| | | String transId = generateTransId(now); |
| | | String taskName = now.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")) + "智能外呼"; |
| | | if(null!= map.get("taskName") && !map.get("taskName").equals("")){ |
| | | taskName = map.get("taskName").toString(); |
| | | } |
| | | String[] numbers = StringUtils.split(callingNumbers,","); |
| | | String taskScheduleTime = LocalDateTime.now().plusHours(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | if (null!=map.get("taskScheduleTime") && !map.get("taskScheduleTime").equals("")){ |
| | | taskScheduleTime = map.get("taskScheduleTime").toString(); |
| | | } |
| | | String scenesIds = scenesId; |
| | | if (null!=map.get("scenesId") && !map.get("scenesId").equals("")){ |
| | | scenesIds = map.get("scenesId").toString(); |
| | | } |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | httpHeaders.add("Content-Type", CONTENT_TYPE); |
| | | httpHeaders.add("Accept", ACCEPT_TYPE); |
| | | httpHeaders.add("Accept-Encoding", ACCEPT_ENCODING); |
| | | JSONObject paramJson = new JSONObject(); |
| | | paramJson.put("taskName", taskName); |
| | | paramJson.put("scenesId", scenesIds); |
| | | paramJson.put("callingNumbers", numbers); |
| | | paramJson.put("taskScheduleTime", taskScheduleTime); |
| | | paramJson.put("calleeData", arr); |
| | | paramJson.put("empId", empId); |
| | | String token = getToken(appId, timestamp, transId, appSecret, paramJson.toJSONString()); |
| | | JSONObject headerJson = new JSONObject(); |
| | | headerJson.put("appId", appId); |
| | | headerJson.put("timestamp", timestamp); |
| | | headerJson.put("transId", transId); |
| | | headerJson.put("token", token); |
| | | JSONObject bodyJson = new JSONObject(); |
| | | bodyJson.put("head", headerJson); |
| | | bodyJson.put("body", paramJson); |
| | | HttpEntity<String> stringHttpEntity = new HttpEntity<>(bodyJson.toJSONString(), httpHeaders); |
| | | log.info("创建超汛限智能外呼任务请求参数:{}", bodyJson.toJSONString()); |
| | | ResponseEntity<String> response = restTemplate.postForEntity(requestUrl, stringHttpEntity, String.class); |
| | | log.info("创建外呼任务请求结果:{}", response.getBody()); |
| | | if (response.getStatusCode() != HttpStatus.OK) { |
| | | log.error("创建智能外呼任务失败:{}", response.getStatusCode()); |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(response.getBody()); |
| | | Boolean success = jsonObject.getBoolean("success"); |
| | | String taskId = ""; |
| | | if (success){ |
| | | //通过任务名称查询taskId |
| | | taskId = callTaskMapper.getTaskIdByTaskName(taskName); |
| | | } |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(response.getBody()); |
| | | list.add(taskId); |
| | | list.add(success.toString()); |
| | | // 返回 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 外呼动态数据封装 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | private JSONArray getCalleeInfoAlarm(List<Map<String, String>> params,List<String> titles) { |
| | | JSONArray arr = new JSONArray(); |
| | | params.forEach(map -> { |
| | | JSONObject json = new JSONObject(); |
| | | for (String title : titles) { |
| | | json.put(title, map.get(title)); |
| | | } |
| | | arr.add(json); |
| | | }); |
| | | return arr; |
| | | } |
| | | |
| | | /** |
| | | * 获取通话详情 |
| | | * @param taskId |
| | | * @param calleeNumber |