| | |
| | | throw new CoolException("任务状态更新失败!!"); |
| | | } |
| | | |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | for (int i = 0; i < taskItems.size(); i++) { |
| | | TaskItem taskItem = taskItems.get(i); |
| | | 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(LocItemWorking::getMatnrId, taskItem.getMatnrId())); |
| | | if (Objects.isNull(locWorking)) { |
| | | throw new CoolException("数据错误,作业中库存数据丢失!!"); |
| | | } |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | locWorking.setWorkQty(0.0); |
| | | locWorking.setAnfme(taskItem.getAnfme()); |
| | | } else { |
| | | if (locWorking.getAnfme().compareTo(taskItem.getAnfme()) >= 0) { |
| | | locWorking.setWorkQty(0.0); |
| | | locWorking.setAnfme(Math.round((locWorking.getAnfme() - taskItem.getAnfme()) * 10000) / 10000.0); |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | if (!locItemWorkingService.updateById(locWorking)) { |
| | | throw new CoolException("临时库存更新失败!!"); |
| | | } |
| | | taskItems.get(i).setAnfme(locWorking.getAnfme()); |
| | | } |
| | | |
| | | if (!taskItemService.updateBatchById(taskItems)) { |
| | | throw new CoolException("任务明细更新失败!!"); |
| | | } |
| | | |
| | | Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())); |
| | | if (Objects.isNull(one)) { |
| | | throw new CoolException("目标库位不存在!!"); |
| | |
| | | throw new CoolException("库存状态更新失败!!"); |
| | | } |
| | | |
| | | //全板出库,删除临时库存 |
| | | if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) { |
| | | throw new CoolException("临时库存清除失败!!"); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |