| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void completeTask(List<Task> tasks) throws Exception { |
| | | if (tasks.isEmpty()) { |
| | | for (Task task : tasks) { |
| | | if (task.getTaskType() < TaskType.TASK_TYPE_OUT.type) { |
| | | //入库任务 |
| | | complateInstock(task); |
| | | } else { |
| | | //出库任务 |
| | | complateOutStock(task); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/5/20 |
| | | * @description: 完成出库任务,更新出库库存信息 |
| | | * @version 1.0 |
| | | */ |
| | | public void complateOutStock(Task task) { |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/5/20 |
| | | * @description: 完成入库任务 |
| | | * @version 1.0 |
| | | */ |
| | | public void complateInstock(Task task) { |
| | | if (Objects.isNull(task)) { |
| | | return; |
| | | } |
| | | List<Long> list = tasks.stream().map(Task::getId).collect(Collectors.toList()); |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, list)); |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, task.getId())); |
| | | if (taskItems.isEmpty()) { |
| | | throw new CoolException("任务明细不存在!!"); |
| | | } |
| | | List<String> locCodes = tasks.stream().map(Task::getTargLoc).collect(Collectors.toList()); |
| | | Map<Long, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getTaskId)); |
| | | /**对任务明细按任务主单进行分组*/ |
| | | listMap.keySet().forEach(key -> { |
| | |
| | | Map<Long, List<TaskItem>> orderMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource)); |
| | | orderMap.keySet().forEach(key -> { |
| | | WaitPakinItem pakinItem = waitPakinItemService.getById(key); |
| | | // AsnOrder order = asnOrderService.getOne(new LambdaQueryWrapper<AsnOrder>() |
| | | // .eq(AsnOrder::getId, key) |
| | | // .select(AsnOrder::getId, AsnOrder::getPoCode, AsnOrder::getCode)); |
| | | if (null == pakinItem) { |
| | | if (Objects.isNull(pakinItem)) { |
| | | throw new CoolException("数据错误:组拖数据不存在,请联系管理员!!"); |
| | | } |
| | | List<TaskItem> items = orderMap.get(key); |
| | |
| | | } |
| | | }); |
| | | /**修改库位状态为F.在库*/ |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).in(Loc::getCode, locCodes))) { |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) { |
| | | throw new CoolException("库位状态修改失败!!"); |
| | | } |
| | | if (!this.update(new LambdaUpdateWrapper<Task>().in(Task::getId, list).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) { |
| | | if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 生成库存明细 |
| | | * 生成入库库存明细 |
| | | * @param items |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveStockItems(List<TaskItem> items, WaitPakinItem order) throws Exception { |
| | | Stock stock = new Stock(); |
| | | // if (!Objects.isNull(order.getPoCode()) && StringUtils.isNotBlank(order.getPoCode())) { |
| | | // Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>().eq(Purchase::getCode, order.getPoCode())); |
| | | // if (!Objects.isNull(purchase)) { |
| | | // stock.setPlatOrderNo(purchase.getPlatCode()).setPlatToken(purchase.getPlatId()); |
| | | // } |
| | | // } |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null); |
| | | if (StringUtils.isBlank(ruleCode)) { |
| | | throw new CoolException("当前业务:" + SerialRuleCode.SYS_STOCK_CODE + ",编码规则不存在!!"); |
| | |
| | | List<StockItem> stockItems = new ArrayList<>(); |
| | | for (TaskItem item : items) { |
| | | /**通过任务明细中的taskId查询,获取TASK的目标库位信息*/ |
| | | // AsnOrderItem orderItem = asnOrderItemService.getOne(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getId, item.getOrderItemId())); |
| | | // if (Objects.isNull(orderItem)) { |
| | | // throw new CoolException("单据明细不存在!!"); |
| | | // } |
| | | StockItem stockItem = new StockItem(); |
| | | BeanUtils.copyProperties(item, stockItem); |
| | | stockItem.setSourceItemId(item.getOrderItemId()) |