| | |
| | | @GetMapping(CREATE_TASK_JOB_HANDLER) |
| | | List<Integer> createTaskJobHandler(@RequestParam("processDefinitionId") String processDefinitionId, |
| | | @RequestParam("taskType") String taskType, |
| | | @RequestParam("title") String title, |
| | | @RequestParam("title") String title, @RequestParam("startTime")String startTime, |
| | | @RequestParam("endTime") String endTime, |
| | | @RequestParam("content") String content); |
| | | |
| | | /** |
| | |
| | | @Component |
| | | public class PatrolTaskClientFallback implements PatrolTaskClient { |
| | | |
| | | |
| | | @Override |
| | | public List<Integer> createTaskJobHandler(String processDefinitionId, String taskType, String title, String content) { |
| | | public List<Integer> createTaskJobHandler(String processDefinitionId, String taskType, String title, String startTime, String endTime, String content) { |
| | | return null; |
| | | } |
| | | |
| | |
| | | public List<Integer> createTaskJobHandler(String processDefinitionId, |
| | | String taskType, |
| | | String title, |
| | | String startTime, |
| | | String endTime, |
| | | String content) { |
| | | List<PatrolResponsiblePerson> patrolResponsiblePersonList = attResManagePersonService.getPatrolResponsiblePersonAll(); |
| | | List<Integer> taskJob = createTaskJob(processDefinitionId, taskType, title, content, patrolResponsiblePersonList); |
| | | List<Integer> taskJob = createTaskJob(processDefinitionId, taskType, title, content, startTime, endTime, patrolResponsiblePersonList); |
| | | return taskJob; |
| | | } |
| | | |
| | |
| | | public List<Integer> createTaskJob(String processDefinitionId, |
| | | String taskType, |
| | | String title, |
| | | String content,List<PatrolResponsiblePerson> patrolResponsiblePersonList){ |
| | | String content, |
| | | List<PatrolResponsiblePerson> patrolResponsiblePersonList){ |
| | | AtomicInteger failureCount = new AtomicInteger(); |
| | | patrolResponsiblePersonList.forEach(item -> { |
| | | log.info("当前创建任务对象:" + JSON.toJSONString(item)); |
| | |
| | | return list; |
| | | } |
| | | |
| | | public List<Integer> createTaskJob(String processDefinitionId, |
| | | String taskType, |
| | | String title, |
| | | String content, |
| | | String startTime, |
| | | String endTime, |
| | | List<PatrolResponsiblePerson> patrolResponsiblePersonList){ |
| | | AtomicInteger failureCount = new AtomicInteger(); |
| | | patrolResponsiblePersonList.forEach(item -> { |
| | | log.info("当前创建任务对象:" + JSON.toJSONString(item)); |
| | | try { |
| | | PatrolTask patrolTask = new PatrolTask(); |
| | | patrolTask.setProcessDefinitionId(processDefinitionId); |
| | | patrolTask.setToUserId(item.getUserId()); |
| | | patrolTask.setProjectId(item.getResGuid()); |
| | | patrolTask.setReservoirName(item.getName()); |
| | | // 开始时间-结束时间 |
| | | patrolTask.setStartTime(startTime); |
| | | patrolTask.setEndTime(endTime); |
| | | // 标题格式 月-日 水库名称 每日巡检任务 |
| | | patrolTask.setTitle(DateUtil.format(new Date(),"MM-dd") + item.getName() + "-" + title); |
| | | patrolTask.setContent(DateUtil.format(new Date(),"yyyyMMdd") +content); |
| | | patrolTask.setTaskType(taskType); |
| | | // 创建任务 |
| | | patrolTaskService.startProcess(patrolTask); |
| | | } catch (Exception e) { |
| | | log.error("创建任务失败:" + e.getMessage()); |
| | | log.error("创建任务失败对象:" + JSON.toJSONString(item)); |
| | | failureCount.getAndIncrement(); |
| | | } |
| | | |
| | | }); |
| | | List<Integer> list = new ArrayList<>(); |
| | | list.add(patrolResponsiblePersonList.size()); |
| | | list.add(failureCount.get()); |
| | | // 返回 |
| | | return list; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | String taskType = jsonParam.getString("taskType"); |
| | | String title = jsonParam.getString("title"); |
| | | String content = jsonParam.getString("content"); |
| | | String startTime = jsonParam.getString("startTime"); |
| | | String endTime = jsonParam.getString("endTime"); |
| | | // 远程调用 |
| | | List<Integer> taskJobHandler = patrolTasClient.createTaskJobHandler(processDefinitionId, taskType, title, content); |
| | | List<Integer> taskJobHandler = patrolTasClient.createTaskJobHandler(processDefinitionId, taskType, title, content, startTime, endTime); |
| | | // 打印响应数据 |
| | | XxlJobLogger.log("结束自动创建任务..."); |
| | | XxlJobLogger.log("总数量:<span style='color:red'>" + taskJobHandler.get(0) + "</span> ... 失败数量:<span style='color:red'>" + taskJobHandler.get(1) + "</span> "); |