| | |
| | | } |
| | | Task task = new Task(); |
| | | task.setTaskCode(ruleCode) |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id) |
| | | .setTaskStatus(TaskStsType.MISSION_INITIAL.id) |
| | | .setTaskType(TaskType.TASK_TYPE_IN.type) |
| | | .setWarehType(WarehType.WAREHOUSE_TYPE_AGV.val) |
| | | .setTargLoc(targetLoc) |
| | | .setTargSite(targSite) |
| | | //.setTargSite(targSite)//入库没有目标站点 |
| | | .setOrgSite(orgSta) |
| | | .setBarcode(pakin.getBarcode()) |
| | | .setCreateBy(loginUserId) |
| | |
| | | .setUpdateBy(loginUserId) |
| | | .setExtendFields(item.getExtendFields()) |
| | | .setOrderId(item.getAsnId()) |
| | | .setBatch(item.getBatch()) |
| | | .setSplrBatch(item.getBatch()) |
| | | .setPlatWorkCode(item.getPlatWorkCode()) |
| | | .setPlatItemId(item.getPlatItemId()) |
| | | .setOrderId(item.getAsnId()) |
| | | .setSplrBatch(item.getBatch()) |
| | | .setPlatWorkCode(item.getPlatWorkCode()) |
| | | .setPlatItemId(item.getPlatItemId()) |
| | | .setOrderItemId(item.getAsnItemId()); |
| | | taskItems.add(taskItem); |
| | | }); |
| | |
| | | .setUpdateBy(loginUserId) |
| | | .setExtendFields(item.getExtendFields()) |
| | | .setOrderId(item.getAsnId()) |
| | | .setSplrBatch(item.getBatch()) |
| | | .setPlatWorkCode(item.getPlatWorkCode()) |
| | | .setPlatItemId(item.getPlatItemId()) |
| | | .setOrderItemId(item.getAsnItemId()); |
| | | taskItems.add(taskItem); |
| | | }); |
| | |
| | | .setUpdateBy(loginUserId) |
| | | .setExtendFields(item.getExtendFields()) |
| | | .setOrderId(item.getAsnId()) |
| | | .setSplrBatch(item.getBatch()) |
| | | .setPlatWorkCode(item.getPlatWorkCode()) |
| | | .setPlatItemId(item.getPlatItemId()) |
| | | .setOrderItemId(item.getAsnItemId()); |
| | | taskItems.add(taskItem); |
| | | }); |
| | |
| | | for (BasContainer container : containers) { |
| | | String codeType = container.getCodeType(); // 获取正则表达式 |
| | | if (barcode.matches(codeType)) { // 判断条码是否符合这个正则 |
| | | List<Integer> areaList2 = container.getAreas(); |
| | | List<Integer> areaList2 = container.getAreasIds(); |
| | | if (!areaList2.contains(Integer.parseInt(area))) { |
| | | matches2 = false; |
| | | continue; |
| | |
| | | } |
| | | Task task = new Task(); |
| | | task.setTaskCode(ruleCode) |
| | | .setTaskStatus(TaskStsType.WCS_EXECUTE_IN.id) |
| | | .setTaskStatus(TaskStsType.MISSION_INITIAL.id) |
| | | .setTaskType(TaskType.TASK_TYPE_IN.type) |
| | | .setResource(TaskResouceType.TASK_RESOUCE_PAKIN_TYPE.val) |
| | | .setTargLoc(targetLoc) |
| | |
| | | .setUpdateBy(loginUserId) |
| | | .setExtendFields(item.getExtendFields()) |
| | | .setOrderId(item.getAsnId()) |
| | | .setSplrBatch(item.getBatch()) |
| | | .setPlatWorkCode(item.getPlatWorkCode()) |
| | | .setPlatItemId(item.getPlatItemId()) |
| | | .setOrderItemId(item.getAsnItemId()); |
| | | taskItems.add(taskItem); |
| | | }); |
| | |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | //移库 |
| | | moveInStock(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) { |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)) { |
| | | //移库 |
| | | complateInstockE(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)) { |
| | | //越库 |
| | | complateInstockDocking(task, loginUserId); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | private Task modiftyTaskSort(Task task, Long loginUserId) { |
| | | String curLoc; |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)) { |
| | | curLoc = task.getTargLoc(); |
| | | } else { |
| | | curLoc = task.getOrgLoc(); |
| | |
| | | for (Task task : tasks) { |
| | | //出库任务 |
| | | try { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)) { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)) { |
| | | //110.空板出库 |
| | | complateOutStockEmpty(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)) { |
| | | //110.空板出库 |
| | | complateOutStockDocking(task, loginUserId); |
| | | } else { |
| | | complateOutStock(task, loginUserId); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 越库回库 |
| | | * |
| | | * @param task |
| | | * @param loginUserId |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void complateInstockDocking(Task task, Long loginUserId) { |
| | | if (Objects.isNull(task)) { |
| | | return; |
| | | } |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())); |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("库存不存在!!"); |
| | | } |
| | | // if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) { |
| | | // throw new CoolException("当前库位状态不处于S.入库预约,不可执行入库操作!"); |
| | | // } |
| | | loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type) |
| | | .setBarcode(task.getBarcode()) |
| | | .setUpdateBy(loginUserId).setUpdateTime(new Date()); |
| | | |
| | | if (!locService.updateById(loc)) { |
| | | throw new CoolException("库位信息更新失败!!"); |
| | | } |
| | | |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | if (taskItems.isEmpty()) { |
| | | throw new CoolException("任务明细不存在!!"); |
| | | } |
| | | |
| | | TaskItem taskItem = taskItems.stream().findFirst().get(); |
| | | //保存入出库流水 |
| | | saveStockItems(taskItems, task, null, null, taskItem.getWkType(), OrderType.ORDER_IN.type, loginUserId); |
| | | |
| | | locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId())); |
| | | |
| | | task.setTaskStatus(TaskStsType.UPDATED_IN.id).setUpdateTime(new Date()).setUpdateBy(loginUserId); |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 任务取消 |
| | | * |
| | | * @param ids |
| | |
| | | public R removeTask(Long[] ids, Long loginUserId) { |
| | | List<Integer> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); |
| | | List<Integer> list = Arrays.asList(TaskType.TASK_TYPE_IN.type, TaskType.TASK_TYPE_OUT.type, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type, |
| | | TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_EMPITY_IN.type, TaskType.TASK_TYPE_LOC_MOVE.type, |
| | | TaskType.TASK_TYPE_EMPITY_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type); |
| | | TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_EMPTY_IN.type, TaskType.TASK_TYPE_LOC_MOVE.type, |
| | | TaskType.TASK_TYPE_EMPTY_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type); |
| | | List<Task> tasks = this.list(new LambdaQueryWrapper<Task>() |
| | | .in(Task::getTaskType, list) |
| | | .in(Task::getId, ids) |
| | |
| | | |
| | | if (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.val)) { |
| | | BasStation basStation = null; |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)) { |
| | | basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, task.getOrgSite()) |
| | | .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.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)) { |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)) { |
| | | basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, task.getTargLoc()) |
| | | .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type)); |
| | |
| | | */ |
| | | @Synchronized |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void complateOutStockDocking(Task task, Long loginUserId) throws Exception { |
| | | |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc())); |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("库位不存在!!"); |
| | | } |
| | | if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) { |
| | | throw new CoolException("库位状态不处理于R.出库预约!!"); |
| | | } |
| | | |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | if (taskItems.isEmpty()) { |
| | | throw new CoolException("任务明细不存在!!"); |
| | | } |
| | | |
| | | List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId())); |
| | | if (locItems.isEmpty()) { |
| | | throw new CoolException("库位明细不存在!!"); |
| | | } |
| | | |
| | | List<LocItemWorking> workings = new ArrayList<>(); |
| | | for (LocItem item : locItems) { |
| | | LocItemWorking working = new LocItemWorking(); |
| | | BeanUtils.copyProperties(item, working); |
| | | working.setId(null) |
| | | .setTaskId(task.getId()) |
| | | .setLocItemId(item.getId()) |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(new Date()); |
| | | workings.add(working); |
| | | } |
| | | |
| | | |
| | | //添加出入库记录信息 |
| | | Map<Short, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getWkType)); |
| | | /***获取库存出库值,如果为空表示正常单据出库,非空表明是库存出库 |
| | | * 1. 库存出库没有单据信息,单据信息默认为空 |
| | | * 2. 单据库存需通过波次查询原始单据信息,将单据信息填入stock中 |
| | | * */ |
| | | List<TaskItem> list = listMap.get(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)); |
| | | if (Objects.isNull(list) || list.isEmpty()) { |
| | | Map<Long, List<TaskItem>> maps = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource)); |
| | | maps.keySet().forEach(key -> { |
| | | if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_STOCK_UP.val)) { |
| | | WkOrderItem orderItem = asnOrderItemService.getById(key); |
| | | if (Objects.isNull(orderItem)) { |
| | | throw new CoolException("单据明细不存在!!"); |
| | | } |
| | | try { |
| | | saveOutStockItem(maps.get(key), orderItem, loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | try { |
| | | saveOutStockItem(taskItems, null, null, null, loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /**修改为库位状态为O.空库*/ |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>() |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type) |
| | | .set(Loc::getBarcode, loc.getBarcode()) |
| | | .set(Loc::getUpdateBy, loginUserId) |
| | | .set(Loc::getUpdateTime, new Date()) |
| | | .eq(Loc::getId, loc.getId()))) { |
| | | throw new CoolException("库位状态修改失败!!"); |
| | | } |
| | | |
| | | if (!this.update(new LambdaUpdateWrapper<Task>() |
| | | .eq(Task::getId, task.getId()) |
| | | .set(Task::getUpdateBy, loginUserId) |
| | | .set(Task::getUpdateTime, new Date()) |
| | | .set(Task::getTargLoc, task.getOrgLoc()) |
| | | .set(Task::getTaskStatus, TaskStsType.COMPLETE_IN.id))) { |
| | | throw new CoolException("库存状态更新失败!!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/5/20 |
| | | * @description: 完成出库任务,更新出库库存信息 |
| | | * @version 1.0 |
| | | */ |
| | | @Synchronized |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void complateOutStockEmpty(Task task, Long loginUserId) throws Exception { |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | |
| | | itemParam.setOriLoc(task.getOrgLoc()).setDestLoc(task.getTargLoc()); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) { |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)) { |
| | | /**全板入库参数*/ |
| | | itemParam.setDestLoc(task.getTargLoc()) |
| | | .setOriSta(task.getOrgSite()); |
| | |
| | | .setOriSta(task.getTargSite()); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)) { |
| | | /**出库参数*/ |
| | |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | |
| | |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type) |
| | | || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) { |
| | | BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite())); |
| | | if (Objects.isNull(curSta)) { |
| | |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || |
| | | task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type) || |
| | | task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type) || |
| | | task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type) || |
| | | task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type) || |
| | | task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | stock.setLocCode(task.getTargLoc()); |
| | | } else { |