| | |
| | | * 任务取消 |
| | | * |
| | | * @param ids |
| | | * @param loginUserId |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R removeTask(Long[] ids) { |
| | | public R removeTask(Long[] ids, Long loginUserId) { |
| | | List<Integer> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); |
| | | List<Integer> list = Arrays.asList(TaskType.TASK_TYPE_IN.type, TaskType.TASK_TYPE_OUT.type, TaskType.TASK_TYPE_EMPITY_IN.type, TaskType.TASK_TYPE_EMPITY_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type); |
| | | List<Task> tasks = this.list(new LambdaQueryWrapper<Task>() |
| | |
| | | throw new CoolException("任务已处执行状态不可取消!!"); |
| | | } |
| | | for (Task task : tasks) { |
| | | //恢复组托状态 |
| | | WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>() |
| | | .eq(WaitPakin::getBarcode, task.getBarcode()) |
| | | ); |
| | | if (null != waitPakin) { |
| | | waitPakin.setIoStatus(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() < TaskStsType.UPDATED_IN.id ? 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 (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.val)) { |
| | | BasStation basStation = null; |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) { |
| | |
| | | } |
| | | } |
| | | |
| | | if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()))) { |
| | | throw new CoolException("任务明细删除失败!!"); |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | if (!taskItems.isEmpty()) { |
| | | for (TaskItem item : taskItems) { |
| | | if (item.getOrderType().equals(OrderType.ORDER_OUT.type)) { |
| | | //出库 |
| | | if (item.getWkType().equals(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type))) { |
| | | //库存出库 |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getId, item.getSourceId())); |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("数据错误:库位信息不存在!!"); |
| | | } |
| | | |
| | | loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type).setBarcode(task.getBarcode()).setUpdateBy(loginUserId).setUpdateTime(new Date()); |
| | | if (!locService.updateById(loc)) { |
| | | throw new CoolException("库位信息修改失败!!"); |
| | | } |
| | | } |
| | | } else { |
| | | //入库 |
| | | //恢复组托状态 |
| | | WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>() |
| | | .eq(WaitPakin::getBarcode, task.getBarcode())); |
| | | if (null != waitPakin) { |
| | | waitPakin.setIoStatus(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() < TaskStsType.UPDATED_IN.id ? 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 (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()))) { |
| | | throw new CoolException("任务明细删除失败!!"); |
| | | } |
| | | } |
| | | } |
| | | if (!this.removeByIds(Arrays.asList(ids))) { |