| | |
| | | case 1://入库 |
| | | executeTask1(task); |
| | | break; |
| | | case 11://库位移转 |
| | | executeTask11(task); |
| | | break; |
| | | case 53://拣料再入库 |
| | | executeTask53(task); |
| | | break; |
| | |
| | | } |
| | | } |
| | | |
| | | //库位移转 |
| | | private void executeTask11(Task task) { |
| | | Long hostId = task.getHostId(); |
| | | |
| | | Loc originLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()).eq(Loc::getHostId, hostId)); |
| | | if (originLoc == null) { |
| | | throw new CoolException("源库位不存在"); |
| | | } |
| | | |
| | | if (originLoc.getLocStsId() != LocStsType.R.val()) { |
| | | throw new CoolException("库位状态不处于R.出库预约"); |
| | | } |
| | | |
| | | Loc targetLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()).eq(Loc::getHostId, hostId)); |
| | | if (targetLoc == null) { |
| | | throw new CoolException("目标库位不存在"); |
| | | } |
| | | |
| | | if (targetLoc.getLocStsId() != LocStsType.S.val()) { |
| | | throw new CoolException("库位状态不处于S.入库预约"); |
| | | } |
| | | |
| | | originLoc.setLocStsId(LocStsType.O.val()); |
| | | originLoc.setUpdateTime(new Date()); |
| | | originLoc.setBarcode(""); |
| | | if (!locService.updateById(originLoc)) { |
| | | throw new CoolException("库位状态更新失败"); |
| | | } |
| | | |
| | | targetLoc.setLocStsId(LocStsType.F.val()); |
| | | targetLoc.setUpdateTime(new Date()); |
| | | targetLoc.setBarcode(task.getBarcode()); |
| | | if (!locService.updateById(targetLoc)) { |
| | | throw new CoolException("库位状态更新失败"); |
| | | } |
| | | |
| | | List<TaskDetl> taskDetls = taskDetlService.getTaskDetlByTaskId(task.getId()); |
| | | if (taskDetls.isEmpty()) { |
| | | throw new CoolException("任务明细不存在"); |
| | | } |
| | | |
| | | //添加库存明细 |
| | | for (TaskDetl taskDetl : taskDetls) { |
| | | LocDetl locDetl = new LocDetl(); |
| | | locDetl.setLocId(targetLoc.getId()); |
| | | locDetl.setLocNo(targetLoc.getLocNo()); |
| | | locDetl.setMatId(taskDetl.getMatId()); |
| | | locDetl.setMatnr(taskDetl.getMat$().getMatnr()); |
| | | locDetl.setOrderNo(taskDetl.getOrderNo()); |
| | | locDetl.setBatch(taskDetl.getBatch()); |
| | | locDetl.setAnfme(taskDetl.getAnfme()); |
| | | locDetl.setHostId(hostId); |
| | | if (!locDetlService.save(locDetl)) { |
| | | throw new CoolException("插入库存明细失败"); |
| | | } |
| | | |
| | | //添加库存明细扩展字段 |
| | | List<TaskDetlField> detlFields = taskDetlFieldService.list(new LambdaQueryWrapper<TaskDetlField>().eq(TaskDetlField::getDetlId, taskDetl.getId()).eq(TaskDetlField::getHostId, hostId)); |
| | | for (TaskDetlField detlField : detlFields) { |
| | | LocDetlField locDetlField = new LocDetlField(); |
| | | locDetlField.setDetlId(locDetl.getId()); |
| | | locDetlField.setFieldId(detlField.getFieldId()); |
| | | locDetlField.setName(detlField.getName()); |
| | | locDetlField.setValue(detlField.getValue()); |
| | | locDetlField.setHostId(hostId); |
| | | if (!locDetlFieldService.save(locDetlField)) { |
| | | throw new CoolException("插入明细扩展字段失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, originLoc.getId())); |
| | | for (LocDetl locDetl : locDetls) { |
| | | boolean remove = locDetlFieldService.remove(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId())); |
| | | boolean result = locDetlService.removeById(locDetl.getId()); |
| | | if (!result) { |
| | | throw new CoolException("清除明细失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | //拣料再入库 |
| | | private void executeTask53(Task task) { |
| | | Long hostId = task.getHostId(); |