| | |
| | | |
| | | import cn.gistack.sm.intelligentCall.constant.ZtConstant; |
| | | import cn.gistack.sm.intelligentCall.service.CallService; |
| | | import cn.gistack.sm.patrol.entity.PatrolGroupItem; |
| | | import cn.gistack.sm.patrol.entity.PatrolTask; |
| | | import cn.gistack.sm.patrol.service.IPatrolGroupItemService; |
| | | import cn.gistack.sm.patrol.service.IPatrolTaskService; |
| | | import cn.gistack.sm.sjztmd.entity.AttResBase; |
| | | import cn.gistack.sm.sjztmd.entity.PatrolResponsiblePerson; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @ClassName SM服务Feign实现类 |
| | |
| | | private final IPatrolTaskService patrolTaskService; |
| | | private final IAttResManagePersonService attResManagePersonService; |
| | | private final IAttResBaseService attResBaseService; |
| | | private final IPatrolGroupItemService patrolGroupItemService; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | |
| | | List<Integer> taskJob = createTaskJob(processDefinitionId, taskType, title, content, type, patrolResponsiblePersonList); |
| | | return taskJob; |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> createNewTaskJobHandler(String taskType, String title, String content, int type) { |
| | | List<PatrolResponsiblePerson> patrolResponsiblePersonList = attResManagePersonService.getPatrolResponsiblePersonAll(); |
| | | List<Integer> taskJob = createNewTaskJob(taskType, title, content, type, patrolResponsiblePersonList); |
| | | return taskJob; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @GetMapping(CREATE_TASK_JOB_BY_CONDITION_HANDLER) |
| | |
| | | PatrolResponsiblePerson patrolResponsiblePerson = patrolResponsiblePersonByResCdList.get(0); |
| | | //不确定是否有多个,循环下发 |
| | | PatrolTask patrolTask = new PatrolTask(); |
| | | patrolTask.setProcessDefinitionId(processDefinitionId); |
| | | // patrolTask.setProcessDefinitionId(processDefinitionId); |
| | | patrolTask.setToUserId(patrolResponsiblePerson.getUserId()); |
| | | patrolTask.setProjectId(resCd); |
| | | |
| | |
| | | String taskId = patrolTask.getId().toString(); |
| | | return taskId; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | log.info("当前创建任务对象:" + JSON.toJSONString(item)); |
| | | try { |
| | | PatrolTask patrolTask = new PatrolTask(); |
| | | patrolTask.setProcessDefinitionId(processDefinitionId); |
| | | // patrolTask.setProcessDefinitionId(processDefinitionId); |
| | | patrolTask.setToUserId(item.getUserId()); |
| | | patrolTask.setProjectId(item.getResGuid()); |
| | | patrolTask.setReservoirName(item.getName()); |
| | |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | private List<Integer> createNewTaskJob(String taskType, String title, String content, int type, 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()); |
| | | //水库id |
| | | patrolTask.setProjectId(item.getResGuid()); |
| | | |
| | | //水库名称 |
| | | patrolTask.setReservoirName(item.getName()); |
| | | // 开始时间-结束时间 |
| | | if (type == 1) { //周任务 |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate firstDayOfWeek = today.with(ChronoField.DAY_OF_WEEK, 1); |
| | | LocalDate lastDayOfWeek = today.with(ChronoField.DAY_OF_WEEK, 7); |
| | | |
| | | String firstDayOfWeekString = firstDayOfWeek.format(DateTimeFormatter.ofPattern("yyyy-MM-dd 00:00:00")); |
| | | String lastDayOfWeekString = lastDayOfWeek.format(DateTimeFormatter.ofPattern("yyyy-MM-dd 23:59:59")); |
| | | //开始时间,结束时间 |
| | | patrolTask.setStartTime(firstDayOfWeekString); |
| | | patrolTask.setEndTime(lastDayOfWeekString); |
| | | } else { // 默认天任务 |
| | | patrolTask.setStartTime(DateUtil.format(new Date(),"yyyy-MM-dd 00:00:00")); |
| | | patrolTask.setEndTime(DateUtil.format(new Date(),"yyyy-MM-dd 23:59:59")); |
| | | } |
| | | |
| | | // 标题格式 月-日 水库名称 每日巡检任务 |
| | | patrolTask.setTitle(DateUtil.format(new Date(),"MM-dd") + item.getName() + "-" + title); |
| | | |
| | | //内容 |
| | | patrolTask.setContent(DateUtil.format(new Date(),"yyyyMMdd") +content); |
| | | |
| | | //任务类型 |
| | | patrolTask.setTaskType(taskType); |
| | | |
| | | //设置角色为巡查责任人 |
| | | patrolTask.setPatrolRole("5"); |
| | | |
| | | |
| | | //获取巡查项,给任务赋值 |
| | | List<PatrolGroupItem> list = patrolGroupItemService.list(); |
| | | List<String> collect = list.stream().map(groupItem -> groupItem.getId().toString()).collect(Collectors.toList()); |
| | | String itemIds = StringUtil.join(collect, ","); |
| | | patrolTask.setPatrolGroupItemId(itemIds); |
| | | |
| | | // 创建任务 |
| | | patrolTaskService.deliverTask(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; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public List<Integer> createTaskJob(String processDefinitionId, |
| | | String taskType, |
| | | String title, |
| | |
| | | log.info("当前创建任务对象:" + JSON.toJSONString(item)); |
| | | try { |
| | | PatrolTask patrolTask = new PatrolTask(); |
| | | patrolTask.setProcessDefinitionId(processDefinitionId); |
| | | // patrolTask.setProcessDefinitionId(processDefinitionId); |
| | | patrolTask.setToUserId(item.getUserId()); |
| | | patrolTask.setProjectId(item.getResGuid()); |
| | | patrolTask.setReservoirName(item.getName()); |