From 2ddf6fc24333df35bd1ac15848b917336d533d53 Mon Sep 17 00:00:00 2001 From: zhang <zc857179121@qq.com> Date: 星期二, 09 九月 2025 09:22:43 +0800 Subject: [PATCH] 1 --- zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/ValidService.java | 69 +++++++++++++++++++++------------- 1 files changed, 43 insertions(+), 26 deletions(-) diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/ValidService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/ValidService.java index 4b44ddf..895d026 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/ValidService.java +++ b/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,8 +39,10 @@ private MapService mapService; @Autowired private SnowflakeIdWorker snowflakeIdWorker; + @Autowired + private TaskServiceImpl taskService; - public List<Task> validBusDto(List<TaskDto> taskDtoList) { + public List<Task> validTaskDtoList(List<TaskDto> taskDtoList) { List<Task> taskList = new ArrayList<>(); for (TaskDto taskDto : taskDtoList) { if (Cools.isEmpty(taskDto.getSeqNum())) { @@ -49,6 +54,11 @@ 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())) { Loc oriLoc = locService.selecatByLocNo(taskDto.getOriLoc()); @@ -59,7 +69,8 @@ // task.setOriCode(oriLoc.getCode()); } if (!Cools.isEmpty(taskDto.getOriSta())) { - Sta oriSta = staService.selectByStaNo(taskDto.getOriSta()); + Sta oriSta = staService.selectByStaNoOrName(taskDto.getOriSta()); + if (null == oriSta) { throw new BusinessException("oriSta: " + taskDto.getOriSta() + " doesn't exist!"); } @@ -76,7 +87,7 @@ task.setDestCode(destLoc.getCode()); } if (!Cools.isEmpty(taskDto.getDestSta())) { - Sta destSta = staService.selectByStaNo(taskDto.getDestSta()); + Sta destSta = staService.selectByStaNoOrName(taskDto.getDestSta()); if (null == destSta) { throw new BusinessException("destSta: " + taskDto.getDestSta() + " doesn't exist!"); } @@ -97,20 +108,24 @@ if (null != task.getDestLoc() && null != task.getDestSta()) { throw new BusinessException("seNum:" + task.getSeqNum() + " is wrong锛宔ither 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()); + } } } } @@ -119,16 +134,18 @@ 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: oriLoc = locService.getById(task.getOriLoc()); destLoc = locService.getById(task.getDestLoc()); - startCode = codeService.getById(oriLoc.getCode()); - endCode = codeService.getById(destLoc.getCode()); + startCode = codeService.getCacheById(oriLoc.getCode()); + endCode = codeService.getCacheById(destLoc.getCode()); if (null == startCode) { throw new BusinessException("oriLoc锛�" + oriLoc.getLocNo() + " hasn't been bound to a QrCode yet"); } @@ -145,8 +162,8 @@ oriLoc = locService.getById(task.getOriLoc()); destSta = staService.getById(task.getDestSta()); - startCode = codeService.getById(oriLoc.getCode()); - endCode = codeService.getById(destSta.getCode()); + startCode = codeService.getCacheById(oriLoc.getCode()); + endCode = codeService.getCacheById(destSta.getCode()); if (null == startCode) { throw new BusinessException("oriLoc锛�" + oriLoc.getLocNo() + " hasn't been bound to QrCode yet"); } @@ -163,8 +180,8 @@ oriSta = staService.getById(task.getOriSta()); destLoc = locService.getById(task.getDestLoc()); - startCode = codeService.getById(oriSta.getCode()); - endCode = codeService.getById(destLoc.getCode()); + startCode = codeService.getCacheById(oriSta.getCode()); + endCode = codeService.getCacheById(destLoc.getCode()); if (null == startCode) { throw new BusinessException("oriSta锛�" + oriSta.getStaNo() + " hasn't bound to QrCode yet"); } @@ -181,8 +198,8 @@ oriSta = staService.getById(task.getOriSta()); destSta = staService.getById(task.getDestSta()); - startCode = codeService.getById(oriSta.getCode()); - endCode = codeService.getById(destSta.getCode()); + startCode = codeService.getCacheById(oriSta.getCode()); + endCode = codeService.getCacheById(destSta.getCode()); if (null == startCode) { throw new BusinessException("oriSta锛�" + oriSta.getStaNo() + " hasn't been bound to a QrCode yet"); } -- Gitblit v1.9.1