| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object createTask(Map<String,Object> map) { |
| | | public List<String> createTask(Map<String,Object> map) { |
| | | List<Map<String, String>> params = (List<Map<String, String>>) map.get("list"); |
| | | 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")) + "智能外呼";; |
| | | 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(); |
| | | } |
| | |
| | | HttpEntity<String> stringHttpEntity = new HttpEntity<>(bodyJson.toJSONString(), httpHeaders); |
| | | log.info("创建超汛限智能外呼任务请求参数:{}", bodyJson.toJSONString()); |
| | | ResponseEntity<String> response = restTemplate.postForEntity(requestUrl, stringHttpEntity, String.class); |
| | | log.info("创建外呼任务请求结果:{}", response); |
| | | log.info("创建外呼任务请求结果:{}", response.getBody()); |
| | | if (response.getStatusCode() != HttpStatus.OK) { |
| | | log.error("创建智能外呼任务失败:{}", response.getStatusCode()); |
| | | } |
| | | return response; |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean createCallTaskByParam(Map<String, Object> params) { |
| | | public List<String> createCallTaskByParam(Map<String, Object> params) { |
| | | // 自动创建任务的 4个条件 1:呼叫人数 2:调度时间 3:是否超汛限 4:多少天内呼叫过的不呼叫(天数) |
| | | //1. 调用中台接口查询出所有需要发任务的水库巡查责任人相关信息(该处需要将是否超汛限条件传入) |
| | | JSONArray jsonArray = getZtWaterMangerData(params); |
| | |
| | | params.put("list",setForListMap(taskRandomList)); |
| | | // 调度时间处理 |
| | | params.put("taskScheduleTime",new SimpleDateFormat("yyyy-MM-dd").format(new Date())+ " " +params.get("taskScheduleTime") + ":00"); |
| | | // 创建任务 |
| | | createTask(params); |
| | | //5. 返回 |
| | | return true; |
| | | // 创建任务并返回结果 |
| | | return createTask(params); |
| | | } |
| | | |
| | | /** |