| | |
| | | import org.apache.commons.lang3.RandomUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.*; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.DigestUtils; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Autowired |
| | | private BladeRedis bladeRedis; |
| | | |
| | | // @Value("${dial.task.url}") |
| | | private String url = CallConstant.HOST; |
| | |
| | | */ |
| | | @Override |
| | | public List<String> createCallTaskByParam(Map<String, Object> params) { |
| | | // 常规任务,每天上午11点打150人,下午2点打11点未接人员,下午5点打下午2点未接通人员 |
| | | String redisOneKey = bladeRedis.get(CallConstant.call_task_key); |
| | | if (null==redisOneKey){ |
| | | List<String> stringList = everydayCall(params); |
| | | // 取出数据进行设置 taskId |
| | | bladeRedis.setEx(CallConstant.call_task_key,stringList.get(1)+","+1,6*60*60L); |
| | | // 响应 |
| | | return stringList; |
| | | }else { |
| | | return createEverydayAfter(redisOneKey); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 日常外呼任务未接通的继续拨打 |
| | | * @param redisOneKey 取值为上一次外呼的任务id |
| | | * @return |
| | | */ |
| | | private List<String> createEverydayAfter(String redisOneKey) { |
| | | // redisOneKey = "2216,1"; |
| | | String[] split = redisOneKey.split(","); |
| | | String taskId = split[0]; |
| | | String type = split[1]; |
| | | List<String> stringList = new ArrayList<>(); |
| | | Map<String, Object> params = new HashMap<>(); |
| | | // 通过 taskId 查询未呼叫人员(mysql) |
| | | List<Scene> list = callTaskMapper.getCallNotConnectListByTaskId(taskId); |
| | | if (list.size()>0){ |
| | | Set<Scene> scenes = new HashSet<>(list); |
| | | // 传入调度时间和随机得到的人员信息进行任务的创建并返回 |
| | | params.put("list",setForListMap(scenes)); |
| | | // 调度时间处理 |
| | | params.put("taskScheduleTime",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | // 创建任务 |
| | | stringList = createTask(params); |
| | | |
| | | // 判断是否发送短信 |
| | | if (type.equals("1")){ |
| | | // 取出数据进行设置 taskId |
| | | bladeRedis.setEx(CallConstant.call_task_key,stringList.get(1)+","+2,6*60*60L); |
| | | } |
| | | // 判断是否发送短信 |
| | | if (type.equals("2")){ |
| | | // 新增一个参数代表需要发短信 |
| | | stringList.add("3"); |
| | | } |
| | | } |
| | | // 返回 |
| | | return stringList; |
| | | } |
| | | |
| | | /** |
| | | * 日常外呼任务创建 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | private List<String> everydayCall(Map<String, Object> params) { |
| | | // 自动创建任务的 4个条件 1:呼叫人数 2:调度时间 3:是否超汛限 4:多少天内呼叫过的不呼叫(天数) |
| | | //1. 调用中台接口查询出所有需要发任务的水库巡查责任人相关信息(该处需要将是否超汛限条件传入) |
| | | JSONArray jsonArray = getZtWaterMangerData(params); |