| | |
| | | package com.zy.acs.manager.core.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | |
| | | import com.zy.acs.manager.manager.entity.Loc; |
| | | import com.zy.acs.manager.manager.entity.Sta; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.TaskStsType; |
| | | import com.zy.acs.manager.manager.enums.TaskTypeType; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.manager.service.LocService; |
| | | import com.zy.acs.manager.manager.service.StaService; |
| | | import com.zy.acs.manager.manager.service.impl.TaskServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | private MapService mapService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private TaskServiceImpl taskService; |
| | | |
| | | public List<Task> validTaskDtoList(List<TaskDto> taskDtoList) { |
| | | List<Task> taskList = new ArrayList<>(); |
| | |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3)); |
| | | task.setSeqNum(taskDto.getSeqNum()); |
| | | task.setPriority(taskDto.getPriority()); |
| | | |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getSeqNum, taskDto.getSeqNum()).in(Task::getTaskSts, TaskStsType.INIT.val(), TaskStsType.WAITING.val(), TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val())); |
| | | if (!Cools.isEmpty(list)){ |
| | | throw new BusinessException("Task seqNum: " + taskDto.getSeqNum() + " is already exists!"); |
| | | } |
| | | |
| | | // ori -------------------------- |
| | | if (!Cools.isEmpty(taskDto.getOriLoc())) { |
| | |
| | | if (null != task.getDestLoc() && null != task.getDestSta()) { |
| | | throw new BusinessException("seNum:" + task.getSeqNum() + " is wrong,either destLoc and destSta must be present"); |
| | | } |
| | | if (null != task.getOriSta()) { |
| | | if (null != task.getDestLoc()) { |
| | | task.setTaskType(TaskTypeType.STA_TO_LOC.val()); |
| | | if (!Cools.isEmpty(taskDto.getTaskType())) { |
| | | task.setTaskType(TaskTypeType.valueOf(taskDto.getTaskType()).val()); |
| | | } else { |
| | | if (null != task.getOriSta()) { |
| | | if (null != task.getDestLoc()) { |
| | | task.setTaskType(TaskTypeType.STA_TO_LOC.val()); |
| | | } |
| | | if (null != task.getDestSta()) { |
| | | task.setTaskType(TaskTypeType.STA_TO_STA.val()); |
| | | } |
| | | } |
| | | if (null != task.getDestSta()) { |
| | | task.setTaskType(TaskTypeType.STA_TO_STA.val()); |
| | | } |
| | | } |
| | | if (null != task.getOriLoc()) { |
| | | if (null != task.getDestLoc()) { |
| | | task.setTaskType(TaskTypeType.LOC_TO_LOC.val()); |
| | | } |
| | | if (null != task.getDestSta()) { |
| | | task.setTaskType(TaskTypeType.LOC_TO_STA.val()); |
| | | if (null != task.getOriLoc()) { |
| | | if (null != task.getDestLoc()) { |
| | | task.setTaskType(TaskTypeType.LOC_TO_LOC.val()); |
| | | } |
| | | if (null != task.getDestSta()) { |
| | | task.setTaskType(TaskTypeType.LOC_TO_STA.val()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | for (Task task : taskList) { |
| | | Code startCode = null; |
| | | Code endCode = null; |
| | | Loc oriLoc = null; Loc destLoc = null; |
| | | Sta oriSta = null; Sta destSta = null; |
| | | Loc oriLoc = null; |
| | | Loc destLoc = null; |
| | | Sta oriSta = null; |
| | | Sta destSta = null; |
| | | List<String> pathList = null; |
| | | switch (Objects.requireNonNull(TaskTypeType.get(task.getTaskTypeEl()))) { |
| | | case LOC_TO_LOC: |