From 4b1c3470712263e8ff9feb7749eebab2c1c6b25a Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期二, 20 五月 2025 19:32:34 +0800 Subject: [PATCH] 添加定时任务--出库任务 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java | 138 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 126 insertions(+), 12 deletions(-) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java index af1b7ed..114e815 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java @@ -1,20 +1,22 @@ package com.vincent.rsf.server.manager.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.vincent.rsf.framework.common.Cools; import com.vincent.rsf.framework.common.R; import com.vincent.rsf.framework.exception.CoolException; +import com.vincent.rsf.server.manager.entity.*; +import com.vincent.rsf.server.manager.enums.*; import com.vincent.rsf.server.common.utils.ExcelUtil; import com.vincent.rsf.server.common.annotation.OperationLog; import com.vincent.rsf.server.common.domain.BaseParam; import com.vincent.rsf.server.common.domain.KeyValVo; import com.vincent.rsf.server.common.domain.PageParam; -import com.vincent.rsf.server.manager.entity.Task; -import com.vincent.rsf.server.manager.entity.TaskItem; -import com.vincent.rsf.server.manager.service.TaskItemService; -import com.vincent.rsf.server.manager.service.TaskService; +import com.vincent.rsf.server.manager.service.*; +import com.vincent.rsf.server.manager.service.impl.BasStationServiceImpl; import com.vincent.rsf.server.system.controller.BaseController; +import com.vincent.rsf.server.system.enums.LocStsType; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -32,6 +34,14 @@ @Autowired private TaskItemService taskItemService; + + @Autowired + private WaitPakinService waitPakinService; + + @Autowired + private LocService locService; + @Autowired + private BasStationService basStationService; @PreAuthorize("hasAuthority('manager:task:list')") @PostMapping("/task/page") @@ -93,12 +103,73 @@ if (Objects.isNull(ids) || ids.length < 1) { return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒"); } - List<TaskItem> list = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, ids)); - if (!list.isEmpty()) { - return R.error("鏈夋槑缁嗗垪琛ㄥ瓨鍦� 锛侊紒"); + List<Short> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); + List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, ids).in(Task::getTaskStatus, longs)); + if (tasks.isEmpty()) { + throw new CoolException("浠诲姟宸插鎵ц鐘舵�佷笉鍙彇娑堬紒锛�"); + } + for (Task task : tasks) { + //鎭㈠缁勬墭鐘舵�� + WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>() + .eq(WaitPakin::getBarcode, task.getBarcode()) + ); + if (null != waitPakin) { + waitPakin.setIoStatus(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)); + if (!waitPakinService.updateById(waitPakin)) { + throw new CoolException("鏇存柊缁勬墭鐘舵�佸け璐ワ紒锛�"); + + } + } + Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getCode, task.getTaskType() < 100 ? task.getTargLoc() : task.getOrgLoc()) + ); + if (null != loc + && (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) + || loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type))) { + + loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type); + if (!locService.updateById(loc)) { + throw new CoolException("鏇存柊搴撲綅鐘舵�佸け璐ワ紒锛�"); + } + } + if (task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.id)){ + BasStation basStation = null; + if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) + || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type) + ){ + basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() + .eq(BasStation::getStationName, task.getOrgSite()) + .eq(BasStation::getUseStatus, StaUseStatusType.TYPE_R.type) + ); + + + } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type) + || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_IN.type) + || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type) + || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) + || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type) + ) { + basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() + .eq(BasStation::getStationName, task.getTargLoc()) + .eq(BasStation::getUseStatus, StaUseStatusType.TYPE_R.type) + ); + } + if (null == basStation) { + throw new CoolException("绔欑偣鐘舵�侀敊璇紒锛�"); + } + basStation.setUseStatus(StaUseStatusType.TYPE_F.type); + if (!basStationService.updateById(basStation)){ + throw new CoolException("鏇存柊绔欑偣鐘舵�佸け璐ワ紒锛�"); + } + } + + } if (!taskService.removeByIds(Arrays.asList(ids))) { return R.error("Delete Fail"); + } + if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, ids))) { + return R.error("Details delete Failed"); } return R.ok("Delete Success").add(ids); } @@ -123,16 +194,59 @@ ExcelUtil.build(ExcelUtil.create(taskService.list(), Task.class), response); } - @PreAuthorize("hasAuthority('manager:task:update')") @ApiOperation("瀹屾垚浠诲姟") - @GetMapping("/task/complete/{id}") - public R completeTask(@PathVariable String id) { + @PostMapping("/task/complete/{id}") + public R completeTask(@PathVariable String id) throws Exception { if (Objects.isNull(id)) { throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒"); } -// return taskService.completeTask(id); - return null; + List<Short> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); + List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getId, id).in(Task::getTaskStatus, longs)); +// if (tasks.isEmpty()) { +// throw new CoolException("浠诲姟宸插鎵ц鐘舵�佷笉鍙竴閿畬鎴愶紒锛�"); +// } +// taskService.completeTask(tasks); + for (Task task : tasks) { + task.setTaskStatus(task.getTaskType() < (short)100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.COMPLETE_OUT.id); + } + if (!taskService.updateBatchById(tasks)){ + return R.error("瀹屾垚浠诲姟澶辫触"); + } + + return R.ok("瀹屾垚浠诲姟鎴愬姛"); + } + + @PreAuthorize("hasAuthority('manager:task:update')") + @ApiOperation("鍙栨秷浠诲姟") + @PostMapping("/task/cancel/{id}") + public R cancelTask(@PathVariable String id) { + if (Objects.isNull(id)) { + throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒"); + } + return R.ok(); + } + + @PreAuthorize("hasAuthority('manager:task:update')") + @ApiOperation("浠诲姟鍑哄簱缃《") + @PostMapping("/task/top/{id}") + public R setTop(@PathVariable String id) { + if (Objects.isNull(id)) { + throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒"); + } + List<Short> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); + List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getId, id).in(Task::getTaskStatus, longs)); + if (tasks.isEmpty()) { + throw new CoolException("浠诲姟宸插鎵ц鐘舵�佷笉鍙竴閿疆椤讹紒锛�"); + } + try { + if (!taskService.update(new LambdaUpdateWrapper<Task>().set(Task::getSort, 100).eq(Task::getId, id))) { + throw new CoolException("缃《澶辫触锛侊紒"); + } + } catch (Exception ex) { + return R.error("浠诲姟寮傚父锛屾棤娉曞畬鎴愶紒锛�"); + } + return R.ok(); } -- Gitblit v1.9.1