| | |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wms.asrs.entity.*; |
| | | import com.zy.asrs.wms.asrs.entity.enums.LocStsType; |
| | | import com.zy.asrs.wms.asrs.entity.enums.TaskStsType; |
| | | import com.zy.asrs.wms.asrs.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build()); |
| | | try { |
| | | //获取入库完成任务 |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskSts, 99)); |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskSts, TaskStsType.COMPLETE_IN.id)); |
| | | if (list.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | case 1://入库 |
| | | executeTask1(task); |
| | | break; |
| | | case 11://库位移转 |
| | | executeTask11(task); |
| | | break; |
| | | case 53://拣料再入库 |
| | | executeTask53(task); |
| | | break; |
| | |
| | | throw new CoolException("未知任务类型"); |
| | | } |
| | | |
| | | task.setTaskSts(100L);//100.库存更新完成 |
| | | task.setTaskSts(TaskStsType.UPDATED_IN.id);//100.库存更新完成 |
| | | task.setUpdateTime(new Date()); |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("库存更新失败"); |
| | |
| | | InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build()); |
| | | try { |
| | | //获取出库完成任务 |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskSts, 199)); |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskSts, TaskStsType.COMPLETE_OUT.id)); |
| | | if (list.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | throw new CoolException("未知任务类型"); |
| | | } |
| | | |
| | | task.setTaskSts(200L);//200.库存更新完成 |
| | | task.setTaskSts(TaskStsType.UPDATED_OUT.id);//200.库存更新完成 |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("库存更新失败"); |
| | | } |
| | |
| | | for (WaitPakin waitPakin : waitPakins) { |
| | | WaitPakinLog waitPakinLog = new WaitPakinLog(); |
| | | waitPakinLog.sync(waitPakin); |
| | | waitPakinLog.setId(null); |
| | | if (!waitPakinLogService.save(waitPakinLog)) { |
| | | throw new CoolException("组托通知档转历史档失败"); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | //库位移转 |
| | | 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(); |