| | |
| | | private OutStockService outStockService; |
| | | @Autowired |
| | | private OutStockItemService outStockItemService; |
| | | |
| | | @Autowired |
| | | private CheckOrderItemService checkOrderItemService; |
| | | @Autowired |
| | | private CheckOrderService checkOrderService; |
| | | @Autowired |
| | | private CheckDiffService checkDiffService; |
| | | @Autowired |
| | | private CheckDiffItemService checkDiffItemService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | LocItemWorking locWorking = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>() |
| | | .eq(LocItemWorking::getTaskId, taskItem.getTaskId()) |
| | | .eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch()) |
| | | .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex()) |
| | | // .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex()) |
| | | .eq(LocItemWorking::getMatnrId, taskItem.getMatnrId())); |
| | | if (Objects.isNull(locWorking)) { |
| | | throw new CoolException("数据错误,作业中库存数据丢失!!"); |
| | |
| | | .setSql("work_qty = work_qty - " + taskItem.getAnfme()))) { |
| | | throw new CoolException("盘点单执行数量修改失败!!"); |
| | | } |
| | | |
| | | List<CheckDiffItem> diffItems = checkDiffItemService |
| | | .list(new LambdaQueryWrapper<CheckDiffItem>() |
| | | .eq(CheckDiffItem::getTaskItemId, taskItem.getTaskId())); |
| | | if (!diffItems.isEmpty()) { |
| | | CheckDiffItem item = diffItems.stream().findFirst().get(); |
| | | List<CheckDiffItem> items = checkDiffItemService.list(new LambdaQueryWrapper<CheckDiffItem>() |
| | | .eq(CheckDiffItem::getId, item.getCheckId())); |
| | | if (items.isEmpty()) { |
| | | checkDiffService.removeById(item.getCheckId()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>() |
| | | .eq(Loc::getCode, task.getOrgLoc()) |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type))) { |
| | | throw new CoolException("源库位状态修改失败!!"); |
| | | } |
| | | } |
| | | |
| | |
| | | LocItemWorking locWorking = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>() |
| | | .eq(LocItemWorking::getTaskId, taskItem.getTaskId()) |
| | | .eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch()) |
| | | .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex()) |
| | | // .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex()) |
| | | .eq(LocItemWorking::getMatnrId, taskItem.getMatnrId())); |
| | | if (Objects.isNull(locWorking)) { |
| | | throw new CoolException("数据错误,作业中库存数据丢失!!"); |
| | |
| | | * */ |
| | | List<TaskItem> list = listMap.get(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)); |
| | | if (Objects.isNull(list) || list.isEmpty()) { |
| | | Map<Long, List<TaskItem>> maps = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource)); |
| | | maps.keySet().forEach(key -> { |
| | | if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) { |
| | | WaveItem waveItem = waveItemService.getById(key); |
| | | if (Objects.isNull(waveItem)) { |
| | | throw new CoolException("波次明细不存在!!"); |
| | | } |
| | | try { |
| | | saveOutStockItem(maps.get(key), null, waveItem, loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) { |
| | | WkOrderItem orderItem = asnOrderItemService.getById(key); |
| | | if (Objects.isNull(orderItem)) { |
| | | throw new CoolException("单据明细不存在!!"); |
| | | } |
| | | try { |
| | | saveOutStockItem(maps.get(key), orderItem, null, loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } else { |
| | | Map<Long, List<TaskItem>> maps = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource)); |
| | | maps.keySet().forEach(key -> { |
| | | if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) { |
| | | WaveItem waveItem = waveItemService.getById(key); |
| | | if (Objects.isNull(waveItem)) { |
| | | throw new CoolException("波次明细不存在!!"); |
| | | } |
| | | try { |
| | | saveOutStockItem(maps.get(key), null, waveItem, loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val) || task.getResource().equals(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val)) { |
| | | WkOrderItem orderItem = asnOrderItemService.getById(key); |
| | | if (Objects.isNull(orderItem)) { |
| | | throw new CoolException("单据明细不存在!!"); |
| | | } |
| | | try { |
| | | saveOutStockItem(maps.get(key), orderItem, null, loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } else { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } else { |
| | | try { |
| | | saveOutStockItem(taskItems, null, null, loginUserId); |