| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R gentMoveTask(Map<String, Object> map) { |
| | | if (Objects.isNull(map.get("targetLoc")) && StringUtils.isNotBlank(map.get("targetLoc").toString())) { |
| | | throw new CoolException("目标库位不能为空!1"); |
| | | public R genMoveTask(Map<String, Object> map) { |
| | | if (Objects.isNull(map.get("tarLoc")) || StringUtils.isBlank(map.get("tarLoc").toString())) { |
| | | throw new CoolException("目标库位不能为空!"); |
| | | } |
| | | if (Objects.isNull(map.get("orgLoc")) && StringUtils.isNotBlank(map.get("orgLoc").toString())) { |
| | | if (Objects.isNull(map.get("orgLoc")) || StringUtils.isBlank(map.get("orgLoc").toString())) { |
| | | throw new CoolException("源库位不能为空!"); |
| | | } |
| | | |
| | |
| | | throw new CoolException("源库位不存在!!"); |
| | | } |
| | | |
| | | Loc targetLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, map.get("targetLoc").toString())); |
| | | orgLoc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | |
| | | if (!locService.updateById(orgLoc)) { |
| | | throw new CoolException("目标库位预约失败!!"); |
| | | } |
| | | |
| | | |
| | | Loc targetLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, map.get("tarLoc").toString())); |
| | | if (Objects.isNull(targetLoc)) { |
| | | throw new CoolException("目标库位不存在!!"); |
| | | } |
| | | |
| | | targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type); |
| | | |
| | | if (!locService.updateById(targetLoc)) { |
| | | throw new CoolException("目标库位预约失败!!"); |
| | |
| | | task.setOrgLoc(orgLoc.getCode()) |
| | | .setTaskCode(ruleCode) |
| | | .setTaskType(TaskType.TASK_TYPE_LOC_MOVE.type) |
| | | .setTargLoc(targetLoc.getCode()) |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id) |
| | | .setBarcode(orgLoc.getBarcode()); |
| | | |
| | | if (!taskService.save(task)) { |
| | | throw new CoolException("新建移库任务失败!!"); |
| | | } |
| | | |
| | | return null; |
| | | List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, orgLoc.getId())); |
| | | if (locItems.isEmpty()) { |
| | | throw new CoolException("库位明细不存在!!"); |
| | | } |
| | | |
| | | List<TaskItem> taskItems = new ArrayList<>(); |
| | | for (LocItem item : locItems) { |
| | | TaskItem taskItem = new TaskItem(); |
| | | BeanUtils.copyProperties(item, taskItem); |
| | | taskItem.setTaskId(task.getId()) |
| | | .setAnfme(item.getAnfme()) |
| | | .setBatch(item.getBatch()) |
| | | .setOrderType(OrderType.ORDER_IN.type) |
| | | .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER_IN.type)); |
| | | taskItems.add(taskItem); |
| | | } |
| | | if (!taskItemService.saveBatch(taskItems)) { |
| | | throw new CoolException("任务明细生成失败!!"); |
| | | } |
| | | |
| | | return R.ok(task); |
| | | } |
| | | |
| | | } |