1
zhang
1 天以前 2ddf6fc24333df35bd1ac15848b917336d533d53
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/ValidService.java
@@ -1,6 +1,7 @@
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;
@@ -9,10 +10,12 @@
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;
@@ -36,6 +39,8 @@
    private MapService mapService;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    @Autowired
    private TaskServiceImpl taskService;
    public List<Task> validTaskDtoList(List<TaskDto> taskDtoList) {
        List<Task> taskList = new ArrayList<>();
@@ -48,6 +53,11 @@
            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())) {
@@ -98,20 +108,24 @@
            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());
                    }
                }
            }
        }
@@ -120,8 +134,10 @@
        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: