From abfce442660a074f69b282ea9cd495a4cfe0f16a Mon Sep 17 00:00:00 2001 From: zengxiangping <318732054@qq.com> Date: Fri, 6 Oct 2023 10:41:44 +0800 Subject: [PATCH] agv任务新增和修改判断容器状态 --- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/controller/AgvTaskController.java | 6 +++--- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java | 4 ++++ huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/controller/AgvTaskController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/controller/AgvTaskController.java index d1de508..e89fced 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/controller/AgvTaskController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/controller/AgvTaskController.java @@ -79,9 +79,9 @@ public class AgvTaskController extends JeecgController<AgvTask, IAgvTaskService> @AutoLog(value = "AGV任务-编辑") @ApiOperation(value = "AGV任务-编辑", notes = "AGV任务-编辑") @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) - public Result<String> edit(@RequestBody AgvTask agvTask) { - agvTaskService.updateById(agvTask); - return Result.OK("编辑成功!"); + public Result<String> edit(@RequestBody AgvTask agvTask, HttpServletRequest req) { + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); + return agvTaskService.editAgvTask(agvTask,warehouseCode); } /** diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java index 006dde2..148c75d 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/IAgvTaskService.java @@ -38,4 +38,8 @@ public interface IAgvTaskService extends IService<AgvTask> { public AgvTask getAgvTaskBuFromPort(String fromPortCode, String warehouseCode); public AgvTask getAgvTaskBuToPort(String toPortCode, String warehouseCode); + + public AgvTask getAgvTaskById(Integer agvTaskId, String warehouseCode); + + public Result editAgvTask(AgvTask agvTask,String warehouseCode); } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java index bcbcffb..6900a18 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/agvTask/service/impl/AgvTaskServiceImpl.java @@ -15,6 +15,7 @@ import org.jeecg.modules.wms.task.agvTask.mapper.AgvTaskMapper; import org.jeecg.modules.wms.task.agvTask.service.IAgvTaskService; import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; +import org.jeecg.utils.StringUtils; import org.jeecg.utils.constant.QuantityConstant; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -45,6 +46,17 @@ public class AgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> impl @Override public Result addAgvTask(AgvTask agvTask, String warehouseCode) { + String containerCode = agvTask.getContainerCode(); + if (StringUtils.isEmpty(containerCode)) { + return Result.error("生成AGV任务,容器号不能为空"); + } + Container containerByCode = containerService.getContainerByCode(containerCode, warehouseCode); + if (containerByCode == null) { + return Result.error("生成AGV任务,容器号:" + containerCode + "未找到"); + } + if (!containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode)) { + throw new JeecgBootException("生成AGV任务,锁定容器失败:" + containerCode); + } agvTask.setWarehouseCode(warehouseCode); agvTask.setTaskType(QuantityConstant.AGV_TYPE_TAKE_AND_RELEASE); agvTask.setStatus(QuantityConstant.AGV_TASK_STATUS_BUILD); @@ -212,4 +224,45 @@ public class AgvTaskServiceImpl extends ServiceImpl<AgvTaskMapper, AgvTask> impl AgvTask agvTask = getOne(agvTaskLambdaQueryWrapper); return agvTask; } + + @Override + public AgvTask getAgvTaskById(Integer agvTaskId, String warehouseCode) { + LambdaQueryWrapper<AgvTask> agvTaskLambdaQueryWrapper = Wrappers.lambdaQuery(); + agvTaskLambdaQueryWrapper.eq(AgvTask::getId, agvTaskId).eq(AgvTask::getWarehouseCode, warehouseCode); + AgvTask agvTask = getOne(agvTaskLambdaQueryWrapper); + return agvTask; + } + + @Override + @Transactional(rollbackFor = JeecgBootException.class) + public Result editAgvTask(AgvTask agvTask, String warehouseCode) { + if (agvTask == null) { + return Result.error("AGV任务信息为空"); + } + if (getById(agvTask) == null) { + return Result.error("根据ID没有找到agv任务"); + } + if (agvTask.getStatus() > QuantityConstant.AGV_TASK_STATUS_BUILD) { + return Result.error("任务已经下发,不可以修改"); + } + String containerCode = agvTask.getContainerCode(); + if (StringUtils.isEmpty(containerCode)) { + return Result.error("修改AGV任务,容器号不能为空"); + } + AgvTask agvTaskByCode = getAgvTaskById(agvTask.getId(), warehouseCode); + Container containerByCode = containerService.getContainerByCode(containerCode, warehouseCode); + if (containerByCode == null) { + return Result.error("修改AGV任务,容器号:" + containerCode + "未找到"); + } + if (!containerService.updateStatus(agvTaskByCode.getContainerCode(), QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode)) { + throw new JeecgBootException("修改AGV任务,解锁原容器失败:" + agvTaskByCode.getContainerCode()); + } + if (!containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode)) { + throw new JeecgBootException("修改AGV任务,锁定容器失败:" + containerCode); + } + if (!updateById(agvTask)) { + throw new JeecgBootException("修改AGV任务失败!"); + } + return Result.OK("修改AGV任务成功"); + } } -- libgit2 0.22.2