| | |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) { |
| | | //53.拣料再入库 |
| | | pickComplateInStock(task); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | //57.盘点再入库 |
| | | pickComplateInStock(task); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) { |
| | | //全托出库 |
| | | complateOutStock(task); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_IN.type)) { |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) { |
| | | //拣料出库 |
| | | // Task seviceOne = pickTask(task.getId()); |
| | | //移除原始库存 |
| | | complateOutStock(task); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) { |
| | | //盘点出库 |
| | | complateOutStock(task); |
| | | } |
| | | } |
| | |
| | | for (TaskItem taskItem : taskItems) { |
| | | LocItem locItem = new LocItem(); |
| | | LocItemWorking locWorking = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>() |
| | | .eq(LocItemWorking::getTaskId, taskItem.getTaskId())); |
| | | .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 (locWorking.getAnfme().compareTo(taskItem.getAnfme()) >= 0) { |
| | | locWorking.setAnfme(Math.round((locWorking.getAnfme() - taskItem.getAnfme()) * 10000) / 10000.0); |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | locWorking.setWorkQty(0.0); |
| | | locWorking.setAnfme(taskItem.getAnfme()); |
| | | } else { |
| | | continue; |
| | | if (locWorking.getAnfme().compareTo(taskItem.getAnfme()) >= 0) { |
| | | locWorking.setWorkQty(0.0); |
| | | locWorking.setAnfme(Math.round((locWorking.getAnfme() - taskItem.getAnfme()) * 10000) / 10000.0); |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | BeanUtils.copyProperties(locWorking, locItem); |
| | | locItem.setLocCode(loc.getCode()).setLocId(loc.getId()).setId(null); |
| | | items.add(locItem); |
| | | } |
| | | |
| | | TaskItem taskItem = taskItems.stream().findFirst().get(); |
| | | |
| | | saveStockItems(taskItems, null, null, taskItem.getWkType(), taskItem.getOrderType()); |
| | | |
| | | if (!locItemService.saveBatch(items)) { |
| | | throw new CoolException("作业库存回写失败!!"); |
| | | } |
| | | |
| | | TaskItem taskItem = taskItems.stream().findFirst().get(); |
| | | //保存入出库流水 |
| | | saveStockItems(taskItems, null, null, taskItem.getWkType(), taskItem.getOrderType()); |
| | | |
| | | |
| | | if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) { |
| | | throw new CoolException("作业中库存删除失败!!"); |
| | |
| | | .eq(BasStation::getUseStatus, LocStsType.LOC_STS_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_PICK_AGAIN_OUT.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) |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Task pickTask(Long id) throws Exception { |
| | | public Task pickOrCheckTask(Long id, String oType) throws Exception { |
| | | Task task = this.getById(id); |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("当前任务不存在!!"); |
| | | } |
| | | if (!task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_IN.type)) { |
| | | throw new CoolException("非拣料出库 ,不可执行此操作!!"); |
| | | Integer type; |
| | | if (oType.equals("check")) { |
| | | //盘点入库 |
| | | type = TaskType.TASK_TYPE_CHECK_IN.type; |
| | | |
| | | if (!task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) { |
| | | throw new CoolException("非盘点出库 ,不可执行此操作!!"); |
| | | } |
| | | } else { |
| | | //拣料入库 |
| | | type = TaskType.TASK_TYPE_PICK_IN.type; |
| | | |
| | | if (!task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) { |
| | | throw new CoolException("非拣料出库 ,不可执行此操作!!"); |
| | | } |
| | | } |
| | | |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, task); |
| | | //更新任务主单 |
| | | task.setTaskCode(ruleCode) |
| | | .setTaskType(TaskType.TASK_TYPE_PICK_IN.type) |
| | | .setTaskType(type) |
| | | .setBarcode(task.getBarcode()) |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id); |
| | | |
| | | //TODO 根据物料的库位类型生成新的库位 |
| | | TaskInParam param = new TaskInParam(); |
| | | param.setSourceStaNo(Integer.parseInt(task.getTargSite())) |
| | | .setIoType(Integer.parseInt(TaskType.TASK_TYPE_PICK_IN.type + "")) |
| | | .setIoType(type) |
| | | .setLocType1(Integer.parseInt(loc.getType())); |
| | | InTaskMsgDto locInfo = wcsService.getLocNo(param); |
| | | |
| | |
| | | for (LocItem item : locItems) { |
| | | LocItemWorking working = new LocItemWorking(); |
| | | BeanUtils.copyProperties(item, working); |
| | | working.setId(null).setTaskId(task.getId()); |
| | | working.setId(null).setTaskId(task.getId()).setLocItemId(item.getId()); |
| | | workings.add(working); |
| | | } |
| | | |
| | |
| | | //更新库位明细 |
| | | subtractLocItem(loc); |
| | | } catch (Exception e) { |
| | | log.error("<UNK>", e); |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | |
| | |
| | | throw new CoolException("库位状态修改失败!!"); |
| | | } |
| | | |
| | | if (!task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_IN.type)) { |
| | | if (!this.update(new LambdaUpdateWrapper<Task>() |
| | | .eq(Task::getId, task.getId()) |
| | | .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) { |
| | | throw new CoolException("库存状态更新失败!!"); |
| | | } |
| | | } else { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) { |
| | | if (!this.update(new LambdaUpdateWrapper<Task>() |
| | | .eq(Task::getId, task.getId()) |
| | | .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) { |
| | | throw new CoolException("库存状态更新失败!!"); |
| | | } |
| | | } else { |
| | | if (!this.update(new LambdaUpdateWrapper<Task>() |
| | | .eq(Task::getId, task.getId()) |
| | | .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) { |
| | | throw new CoolException("库存状态更新失败!!"); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveStockItems(List<TaskItem> items, Long id, String code, Short wkType, String type) throws Exception { |
| | | public void saveStockItems(List<TaskItem> items, Long id, String code, Short wkType, String type) throws |
| | | Exception { |
| | | Stock stock = new Stock(); |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null); |
| | | if (StringUtils.isBlank(ruleCode)) { |