From da4074dcf9c0f367bc4ac7c5329afd3e655b37f6 Mon Sep 17 00:00:00 2001 From: liangzhou <594755172@qq.com> Date: Wed, 13 Nov 2024 16:42:05 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E7=9C=8B=E6=9D=BFid?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=AF=BC=E5=85=A5=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=202.=20=E4=BF=AE=E6=94=B9=E5=BC=80=E5=A7=8B=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=BC=BA=E6=96=99=E6=97=B6=E5=B0=BE=E7=AE=B1?= =?UTF-8?q?=E6=8B=89=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/wms/controller/ExcelController.java | 4 +- .../WorkServiceImplements.java | 453 +++--------------- .../excel/listener/UploadKanbanListener.java | 29 +- 3 files changed, 92 insertions(+), 394 deletions(-) diff --git a/src/main/java/com/wms/controller/ExcelController.java b/src/main/java/com/wms/controller/ExcelController.java index 4567974..1e2d1d5 100644 --- a/src/main/java/com/wms/controller/ExcelController.java +++ b/src/main/java/com/wms/controller/ExcelController.java @@ -429,10 +429,8 @@ public class ExcelController { response.setMessage("请先导入物料基本信息。"); return convertJsonString(response); } - // 查询之前的看板 - Map kanbanMap = kanbanService.list().stream().collect(Collectors.toMap(kanban -> kanban.getGoodsId() + kanban.getKanbanId(), kanban -> kanban)); // 导入excel - EasyExcel.read(file.getInputStream(), KanbanGoodsExcelVo.class, new UploadKanbanListener(goodsService, goodsMap, kanbanService, kanbanMap, fileVo.getUserName())).sheet("CLC看板信息").doRead(); + EasyExcel.read(file.getInputStream(), KanbanGoodsExcelVo.class, new UploadKanbanListener(goodsService, goodsMap, kanbanService, fileVo.getUserName())).sheet("CLC看板信息").doRead(); // 添加导入记录 uploadRecordService.save(UploadRecord.ofFileVo(fileVo, "KANBAN")); uploadFileHashStringList.remove(fileVo.getHash()); diff --git a/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java b/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java index 117a74a..102510b 100644 --- a/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java +++ b/src/main/java/com/wms/service/business/serviceImplements/WorkServiceImplements.java @@ -49,12 +49,14 @@ public class WorkServiceImplements implements IWorkService { private final StockService stockService;// 库存服务 private final IWmsTaskService wmsTaskService;// 任务服务 private final PickTaskService pickTaskService;// 拣选任务服务 + private final OutsideVehiclesService outsideVehiclesService;// 外部流转箱服务 private final List workCreatingStations = new ArrayList<>();// 当前正在创建任务的站台 private final List workDoingStations = new ArrayList<>();// 当前正在执行任务的站台 private final List workFinishingStations = new ArrayList<>();// 当前正在完成任务的站台 /** * 新版创建工作 + * * @param workStation 工作站台 * @throws Exception 异常 */ @@ -188,120 +190,9 @@ public class WorkServiceImplements implements IWorkService { } } -// @Override -// @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) -// public void createWork(String workStation) throws Exception { -// if (workCreatingStations.contains(workStation)) { -// // 当前站台正在创建任务 -// return; -// } else { -// // 添加站台 -// workCreatingStations.add(workStation); -// } -// if (StringUtils.isEmpty(workStation)) { -// // 站台号为空 -// return; -// } -// try { -// // 先查看当前站台已经生成的工作流是否为空 -// List currentWorkFlowList = workFlowService.list(new LambdaQueryWrapper() -// .eq(WorkFlow::getWorkStation, workStation) -// .ne(WorkFlow::getWorkStatus, 0)); -// // 当前站台的工作流中还存在其他任务 -// if (currentWorkFlowList != null && !currentWorkFlowList.isEmpty()) { -// return; -// } -// // 查询是否有已经分配好的电子标签库位信息 -// List oldELocationConfigList = eLocationConfigService.list(new LambdaQueryWrapper() -// .eq(ELocationConfig::getWorkStation, workStation)); -// if (oldELocationConfigList != null && !oldELocationConfigList.isEmpty()) { -// return; -// } -// // 查询所有待下发的 -// List currentStationWorkFlows = workFlowService.list(new LambdaQueryWrapper() -// .eq(WorkFlow::getWorkStatus, 0) -// .eq(WorkFlow::getWorkStation, workStation)); -// // 如果当前站台有任务 -// if (!currentStationWorkFlows.isEmpty()) { -// // 获得工单以及小工位列表 -// List boxNoList = new ArrayList<>(); -// // 要料Map -// Map needGoodsMap = new HashMap<>(); -// for (WorkFlow tempWorkflow : currentStationWorkFlows) { -// // 添加盒子配置 -// String boxNo = tempWorkflow.getWorkOrder() + "@" + tempWorkflow.getWorkCenter(); -// if (!boxNoList.contains(boxNo)) { -// boxNoList.add(boxNo); -// } -// // 添加要料信息 -// if (!needGoodsMap.containsKey(tempWorkflow.getGoodsId())) { -// // 添加物料信息 -// needGoodsMap.put(tempWorkflow.getGoodsId(), tempWorkflow.getNeedNum()); -// } else { -// // 增加需求数量 -// needGoodsMap.replace(tempWorkflow.getGoodsId(), needGoodsMap.get(tempWorkflow.getGoodsId()).add(tempWorkflow.getNeedNum())); -// } -// } -// // 站台要料 -// List goodsToStationList = new ArrayList<>(); -// for (String goodsId : needGoodsMap.keySet()) { -// GoodsToStation goodsToStation = new GoodsToStation(); -// goodsToStation.setConfigId(goodsId + "_" + workStation); -// goodsToStation.setGoodsId(goodsId); -// goodsToStation.setWorkStation(workStation); -// goodsToStation.setDistributeStatus(0); -// goodsToStation.setDistributedNum(BigDecimal.ZERO); -// goodsToStation.setTotalNum(needGoodsMap.get(goodsId)); -// goodsToStationList.add(goodsToStation); -// } -// // 将站台要料列表存进数据库 -// goodsToStationService.saveOrUpdateBatch(goodsToStationList); -// // 电子标签库位配置 -// List eLocationConfigList = new ArrayList<>(); -// // 查找到当前站台所有可用的电子标签 -// List eTagLocationList = eTagLocationService.list(new LambdaQueryWrapper() -// .eq(ETagLocation::getWorkStation, workStation) -// .eq(ETagLocation::getELocationStatus, 0) -// .orderByAsc(ETagLocation::getSequenceId)); -// if (eTagLocationList.isEmpty() || eTagLocationList.size() < boxNoList.size()) { -// throw new Exception("站台:" + workStation + "没有足够可用的电子标签位!"); -// } -// for (ETagLocation eTagLocation : eTagLocationList) { -// if (!boxNoList.isEmpty()) { -// String tempBoxNo = boxNoList.get(0); -// ELocationConfig eLocationConfig = new ELocationConfig(); -// eLocationConfig.setWorkOrder(tempBoxNo.split("@")[0]); -// eLocationConfig.setWorkCenter(tempBoxNo.split("@")[1]); -// eLocationConfig.setWorkStation(workStation); -// eLocationConfig.setELocationId(eTagLocation.getELocationId()); -// eLocationConfig.setOrderBoxNo(tempBoxNo); -// // 添加配置 -// eLocationConfigList.add(eLocationConfig); -// // 移除已经分配的盒子 -// boxNoList.remove(tempBoxNo); -// } -// } -// // 将电子标签库位配置存进数据库 -// eLocationConfigService.saveBatch(eLocationConfigList); -// // 更新工作流状态 -// List workFlowIds = currentStationWorkFlows.stream().map(WorkFlow::getWorkFlowId).distinct().toList(); -// workFlowService.update(new LambdaUpdateWrapper() -// .set(WorkFlow::getWorkStatus, 1) -// .in(WorkFlow::getWorkFlowId, workFlowIds) -// .eq(WorkFlow::getWorkStatus, 0)); -// } -// } catch (Exception e) { -// logger.error("创建站台:{}工作发生异常:{}", workStation, convertJsonString(e)); -// // 回滚事务 -// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); -// } finally { -// // 当前站台创建任务完成 -// workCreatingStations.remove(workStation); -// } -// } - /** * 新版开始工作 + * * @param workStation 工作站台 * @throws Exception 异常 */ @@ -329,64 +220,86 @@ public class WorkServiceImplements implements IWorkService { .eq(GoodsToStation::getWorkStation, workStation)); List notFinishedGoodsList = goodsToStationList.stream().filter(goodsToStation -> goodsToStation.getDistributeStatus() < 2).toList(); if (notFinishedGoodsList.isEmpty()) { - // 查询是否还有这个站台的拣选任务 - if (!pickTaskService.exists(new LambdaQueryWrapper() - .eq(PickTask::getStandId, workStation))) { - // 需要重新分配的goodsToStationsList - Map needDistributeGoodsMap = new HashMap<>(); - // 需要完成的工作流 - List needFinishWorkFlowList = new ArrayList<>(); - // 所有缺料的分配 - List lackGoodsIdList = goodsToStationList.stream().filter(goodsToStation -> goodsToStation.getDistributeStatus() == 3).map(GoodsToStation::getGoodsId).distinct().toList(); - // 不缺料的分配 - Map noLackGoodsMap = goodsToStationList.stream().filter(goodsToStation -> goodsToStation.getDistributeStatus() == 2).collect(Collectors.toMap(GoodsToStation::getGoodsId, goodsToStation -> goodsToStation)); - // 查询当前工作流中所有缺料的数据行 - for (WorkFlow notFinishedWorkFlow : currentWorkFlowList) { - if (notFinishedWorkFlow.getPickedNum().compareTo(notFinishedWorkFlow.getNeedNum()) < 0) { - // 缺料时,判断是否当前物料在缺料列表中 - if (lackGoodsIdList.contains(notFinishedWorkFlow.getGoodsId())) { - // 缺料,添加到需要分配的列表中 - notFinishedWorkFlow.setWorkStatus(2); - notFinishedWorkFlow.setFinishTime(LocalDateTime.now()); - notFinishedWorkFlow.setOpUser("系统自动完成"); - needFinishWorkFlowList.add(notFinishedWorkFlow); - } else { - BigDecimal needNum = notFinishedWorkFlow.getNeedNum().subtract(notFinishedWorkFlow.getPickedNum()); - if (needDistributeGoodsMap.containsKey(notFinishedWorkFlow.getGoodsId())) { - // 减少分配数量 - GoodsToStation oldGoodsToStation = needDistributeGoodsMap.get(notFinishedWorkFlow.getGoodsId()); - oldGoodsToStation.setDistributedNum(oldGoodsToStation.getDistributedNum().subtract(needNum)); - oldGoodsToStation.setDistributeStatus(1); - needDistributeGoodsMap.replace(notFinishedWorkFlow.getGoodsId(), oldGoodsToStation); - } else { - if (noLackGoodsMap.containsKey(notFinishedWorkFlow.getGoodsId())) { - GoodsToStation newGoodsToStation = noLackGoodsMap.get(notFinishedWorkFlow.getGoodsId()); - newGoodsToStation.setDistributedNum(newGoodsToStation.getDistributedNum().subtract(needNum)); - newGoodsToStation.setDistributeStatus(1); - needDistributeGoodsMap.put(notFinishedWorkFlow.getGoodsId(), newGoodsToStation); - } else { - GoodsToStation goodsToStation = new GoodsToStation(); - goodsToStation.setConfigId(notFinishedWorkFlow.getGoodsId() + "_" + workStation); - goodsToStation.setGoodsId(notFinishedWorkFlow.getGoodsId()); - goodsToStation.setWorkStation(workStation); - goodsToStation.setDistributeStatus(0); - goodsToStation.setDistributedNum(BigDecimal.ZERO); - goodsToStation.setTotalNum(needNum); - needDistributeGoodsMap.put(notFinishedWorkFlow.getGoodsId(), goodsToStation); - } + // 查询所有的outsideVehicles + List outsideVehiclesList = outsideVehiclesService.list(new LambdaQueryWrapper() + .ne(OutsideVehicles::getOutStatus, 2)); + // 查询所有的当前站台的拣选任务 + List pickTaskList = pickTaskService.list(new LambdaQueryWrapper() + .eq(PickTask::getStandId, workStation)); + // 需要重新分配的goodsToStationsList + Map needDistributeGoodsMap = new HashMap<>(); + // 需要完成的工作流 + List needFinishWorkFlowList = new ArrayList<>(); + // 所有缺料的分配 + List lackGoodsIdList = goodsToStationList.stream().filter(goodsToStation -> goodsToStation.getDistributeStatus() == 3).map(GoodsToStation::getGoodsId).distinct().toList(); + // 不缺料的分配 + Map noLackGoodsMap = goodsToStationList.stream().filter(goodsToStation -> goodsToStation.getDistributeStatus() == 2).collect(Collectors.toMap(GoodsToStation::getGoodsId, goodsToStation -> goodsToStation)); + // 查询当前工作流中所有缺料的数据行 + for (WorkFlow notFinishedWorkFlow : currentWorkFlowList) { + if (notFinishedWorkFlow.getPickedNum().compareTo(notFinishedWorkFlow.getNeedNum()) < 0) { + // 判断这个料有没有在外面 + List currentGoodsOutsideVehiclesList = outsideVehiclesList.stream().filter(outsideVehicles1 -> outsideVehicles1.getGoodsId().equals(notFinishedWorkFlow.getGoodsId())).toList(); + if (!currentGoodsOutsideVehiclesList.isEmpty()) { + // 判断这些箱子有没有当前站台的拣选任务 + boolean havePickTask = false; + for (OutsideVehicles currentGoodsOutsideVehicles : currentGoodsOutsideVehiclesList) { + List currentGoodsPickTaskList = pickTaskList.stream().filter(pickTask -> pickTask.getVehicleId().equals(currentGoodsOutsideVehicles.getVehicleId())).toList(); + if (!currentGoodsPickTaskList.isEmpty()) { + havePickTask = true; + break; } } - } else { - // 不缺料,直接完成 + if (havePickTask) { + continue; + } + } + // 缺料时,判断是否当前物料在缺料列表中 + if (lackGoodsIdList.contains(notFinishedWorkFlow.getGoodsId())) { + // 缺料,添加到需要分配的列表中 notFinishedWorkFlow.setWorkStatus(2); notFinishedWorkFlow.setFinishTime(LocalDateTime.now()); notFinishedWorkFlow.setOpUser("系统自动完成"); needFinishWorkFlowList.add(notFinishedWorkFlow); + } else { + BigDecimal needNum = notFinishedWorkFlow.getNeedNum().subtract(notFinishedWorkFlow.getPickedNum()); + if (needDistributeGoodsMap.containsKey(notFinishedWorkFlow.getGoodsId())) { + // 减少分配数量 + GoodsToStation oldGoodsToStation = needDistributeGoodsMap.get(notFinishedWorkFlow.getGoodsId()); + oldGoodsToStation.setDistributedNum(oldGoodsToStation.getDistributedNum().subtract(needNum)); + oldGoodsToStation.setDistributeStatus(1); + needDistributeGoodsMap.replace(notFinishedWorkFlow.getGoodsId(), oldGoodsToStation); + } else { + if (noLackGoodsMap.containsKey(notFinishedWorkFlow.getGoodsId())) { + GoodsToStation newGoodsToStation = noLackGoodsMap.get(notFinishedWorkFlow.getGoodsId()); + newGoodsToStation.setDistributedNum(newGoodsToStation.getDistributedNum().subtract(needNum)); + newGoodsToStation.setDistributeStatus(1); + needDistributeGoodsMap.put(notFinishedWorkFlow.getGoodsId(), newGoodsToStation); + } else { + GoodsToStation goodsToStation = new GoodsToStation(); + goodsToStation.setConfigId(notFinishedWorkFlow.getGoodsId() + "_" + workStation); + goodsToStation.setGoodsId(notFinishedWorkFlow.getGoodsId()); + goodsToStation.setWorkStation(workStation); + goodsToStation.setDistributeStatus(0); + goodsToStation.setDistributedNum(BigDecimal.ZERO); + goodsToStation.setTotalNum(needNum); + needDistributeGoodsMap.put(notFinishedWorkFlow.getGoodsId(), goodsToStation); + } + } } + } else { + // 不缺料,直接完成 + notFinishedWorkFlow.setWorkStatus(2); + notFinishedWorkFlow.setFinishTime(LocalDateTime.now()); + notFinishedWorkFlow.setOpUser("系统自动完成"); + needFinishWorkFlowList.add(notFinishedWorkFlow); } - // 保存重新分配的goodsToStationList + } + // 保存重新分配的goodsToStationList + if (!needDistributeGoodsMap.values().isEmpty()) { goodsToStationService.saveOrUpdateBatch(needDistributeGoodsMap.values()); - // 保存需要完成的工作流 + } + // 保存需要完成的工作流 + if (!needFinishWorkFlowList.isEmpty()) { workFlowService.updateBatchById(needFinishWorkFlowList); } return; @@ -452,139 +365,9 @@ public class WorkServiceImplements implements IWorkService { } } -// @Override -// @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) -// public void doWork(String workStation) throws Exception { -// if (workDoingStations.contains(workStation)) { -// // 当前站台正在创建任务 -// return; -// } else { -// // 添加站台 -// workDoingStations.add(workStation); -// } -// try { -// // 查找当前站台未开始的工作流 -// List currentWorkFlowList = workFlowService.list(new LambdaQueryWrapper() -// .eq(WorkFlow::getWorkStation, workStation) -// .eq(WorkFlow::getWorkStatus, 1)); -// // 没有可做的任务 -// if (currentWorkFlowList == null || currentWorkFlowList.isEmpty()) { -// return; -// } -// // 查站台要料表---未分配以及分配但未完全分配 -// List goodsToStationList = goodsToStationService.list(new LambdaQueryWrapper() -// .eq(GoodsToStation::getWorkStation, workStation)); -// List notFinishedGoodsList = goodsToStationList.stream().filter(goodsToStation -> goodsToStation.getDistributeStatus() < 2).toList(); -// if (notFinishedGoodsList.isEmpty()) { -// // 查询是否还有这个站台的拣选任务 -// if (!pickTaskService.exists(new LambdaQueryWrapper() -// .eq(PickTask::getStandId, workStation))) { -// // 需要重新分配的goodsToStationsList -// Map needDistributeGoodsMap = new HashMap<>(); -// // 需要完成的工作流 -// List needFinishWorkFlowList = new ArrayList<>(); -// // 所有缺料的分配 -// List lackGoodsIdList = goodsToStationList.stream().filter(goodsToStation -> goodsToStation.getDistributeStatus() == 3).map(GoodsToStation::getGoodsId).distinct().toList(); -// // 不缺料的分配 -// Map noLackGoodsMap = goodsToStationList.stream().filter(goodsToStation -> goodsToStation.getDistributeStatus() == 2).collect(Collectors.toMap(GoodsToStation::getGoodsId, goodsToStation -> goodsToStation)); -// // 查询当前工作流中所有缺料的数据行 -// for (WorkFlow notFinishedWorkFlow : currentWorkFlowList) { -// if (notFinishedWorkFlow.getPickedNum().compareTo(notFinishedWorkFlow.getNeedNum()) < 0) { -// // 缺料时,判断是否当前物料在缺料列表中 -// if (lackGoodsIdList.contains(notFinishedWorkFlow.getGoodsId())) { -// // 缺料,添加到需要分配的列表中 -// notFinishedWorkFlow.setWorkStatus(2); -// notFinishedWorkFlow.setFinishTime(LocalDateTime.now()); -// notFinishedWorkFlow.setOpUser("系统自动完成"); -// needFinishWorkFlowList.add(notFinishedWorkFlow); -// } else { -// BigDecimal needNum = notFinishedWorkFlow.getNeedNum().subtract(notFinishedWorkFlow.getPickedNum()); -// if (needDistributeGoodsMap.containsKey(notFinishedWorkFlow.getGoodsId())) { -// // 减少分配数量 -// GoodsToStation oldGoodsToStation = needDistributeGoodsMap.get(notFinishedWorkFlow.getGoodsId()); -// oldGoodsToStation.setDistributedNum(oldGoodsToStation.getDistributedNum().subtract(needNum)); -// oldGoodsToStation.setDistributeStatus(1); -// needDistributeGoodsMap.replace(notFinishedWorkFlow.getGoodsId(), oldGoodsToStation); -// } else { -// if (noLackGoodsMap.containsKey(notFinishedWorkFlow.getGoodsId())) { -// GoodsToStation newGoodsToStation = noLackGoodsMap.get(notFinishedWorkFlow.getGoodsId()); -// newGoodsToStation.setDistributedNum(newGoodsToStation.getDistributedNum().subtract(needNum)); -// newGoodsToStation.setDistributeStatus(1); -// needDistributeGoodsMap.put(notFinishedWorkFlow.getGoodsId(), newGoodsToStation); -// } else { -// GoodsToStation goodsToStation = new GoodsToStation(); -// goodsToStation.setConfigId(notFinishedWorkFlow.getGoodsId() + "_" + workStation); -// goodsToStation.setGoodsId(notFinishedWorkFlow.getGoodsId()); -// goodsToStation.setWorkStation(workStation); -// goodsToStation.setDistributeStatus(0); -// goodsToStation.setDistributedNum(BigDecimal.ZERO); -// goodsToStation.setTotalNum(needNum); -// needDistributeGoodsMap.put(notFinishedWorkFlow.getGoodsId(), goodsToStation); -// } -// } -// } -// } else { -// // 不缺料,直接完成 -// notFinishedWorkFlow.setWorkStatus(2); -// notFinishedWorkFlow.setFinishTime(LocalDateTime.now()); -// notFinishedWorkFlow.setOpUser("系统自动完成"); -// needFinishWorkFlowList.add(notFinishedWorkFlow); -// } -// } -// // 保存重新分配的goodsToStationList -// goodsToStationService.saveOrUpdateBatch(needDistributeGoodsMap.values()); -// // 保存需要完成的工作流 -// workFlowService.updateBatchById(needFinishWorkFlowList); -// } -// return; -// } -// for (GoodsToStation goodsToStation : notFinishedGoodsList) { -// // 当前物料当前站台需求数量 -// BigDecimal needNum = goodsToStation.getTotalNum().subtract(goodsToStation.getDistributedNum()); -// if (needNum.compareTo(BigDecimal.ZERO) == 0) { -// // 需求数量为0 -// continue; -// } -// // 判断实际库存是否充足 -// List stockList = stockService.list(new LambdaQueryWrapper() -// .apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, goodsToStation.getGoodsId()) -// .apply("goods_related ->> '$.remainNum' > 0")); -// if (stockList == null || stockList.isEmpty()) { -// goodsToStation.setDistributeStatus(3); -// continue; -// } -// // 判断当前物料是否在流转中 -// needNum = wmsTaskService.callGoods(goodsToStation.getGoodsId(), needNum, workStation); -// // 判断此时需求数量是否为0 -// if (needNum.compareTo(BigDecimal.ZERO) <= 0) { -// // 分配完成 -// goodsToStation.setDistributeStatus(2); -// } else { -// needNum = wmsTaskService.callStocks(goodsToStation.getGoodsId(), needNum, workStation); -// if (needNum.compareTo(BigDecimal.ZERO) > 0) { -// // 已分配但未完全分配 -// goodsToStation.setDistributeStatus(1); -// } else { -// // 分配完成 -// goodsToStation.setDistributeStatus(2); -// } -// } -// // 更新已分配数量 -// goodsToStation.setDistributedNum(goodsToStation.getTotalNum().subtract(needNum)); -// } -// goodsToStationService.updateBatchById(notFinishedGoodsList); -// } catch (Exception e) { -// logger.error("执行站台:{}工作发生异常:{}", workStation, convertJsonString(e)); -// // 回滚事务 -// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); -// } finally { -// // 当前站台创建任务完成 -// workDoingStations.remove(workStation); -// } -// } - /** * 新版完成工作 + * * @param workStation 工作站台 * @return 结果 * @throws Exception 异常 @@ -691,90 +474,6 @@ public class WorkServiceImplements implements IWorkService { return ""; } -// @Override -// public String finishWork(String workStation) throws Exception { -// if (workFinishingStations.contains(workStation)) { -// // 当前站台正在完成工作 -// return "当前站台正在完成工作,请勿重复操作"; -// } else { -// // 添加站台 -// workFinishingStations.add(workStation); -// } -// try { -// if (workFlowService.exists(new LambdaQueryWrapper() -// .eq(WorkFlow::getWorkStation, workStation) -// .eq(WorkFlow::getWorkStatus, 1))) { -// // 当前站台工作未全部完成 -// return "工作未全部做完,不允许确认完成。"; -// } -// if (eLocationConfigService.exists(new LambdaQueryWrapper() -// .eq(ELocationConfig::getWorkStation, workStation) -// .eq(ELocationConfig::getPrintStatus, 0))) { -// // 有标签未打印 -// return "有标签未打印"; -// } -// if (!eLocationConfigService.exists(new LambdaQueryWrapper() -// .eq(ELocationConfig::getWorkStation, workStation))) { -// // 没有标签,说明点过确认。 -// return "没有可以确认完成的工作,请勿重复点击。"; -// } -// // 查找当前站台的标签配置 -// List eLocationConfigList = eLocationConfigService.list(new LambdaQueryWrapper() -// .eq(ELocationConfig::getWorkStation, workStation)); -// // 保存一下记录 -// List eLocationConfigLastList = ELocationConfig.toLocationsConfigLastList(eLocationConfigList); -// // 先清空之前的 -// eLocationConfigLastService.remove(new LambdaQueryWrapper() -// .eq(ELocationConfigLast::getWorkStation, workStation)); -// eLocationConfigLastService.saveBatch(eLocationConfigLastList); -// // 删除所有的标签配置 -// eLocationConfigService.remove(new LambdaQueryWrapper() -// .eq(ELocationConfig::getWorkStation, workStation)); -// // 查询当前站台的所有工作流列表 -// List workFlowList = workFlowService.list(new LambdaQueryWrapper() -// .eq(WorkFlow::getWorkStation, workStation) -// .eq(WorkFlow::getWorkStatus, 2)); -// // workSummary列表 -// List workSummaryList = new ArrayList<>(); -// for (WorkFlow workFlow : workFlowList) { -// WorkSummary summary = new WorkSummary(); -// summary.setWorkFlowId(workFlow.getWorkFlowId()); -// summary.setWorkStation(workFlow.getWorkStation()); -// summary.setWorkOrder(workFlow.getWorkOrder()); -// summary.setWorkCenter(workFlow.getWorkCenter()); -// summary.setGoodsId(workFlow.getGoodsId()); -// summary.setPickedNum(workFlow.getPickedNum()); -// summary.setNeedNum(workFlow.getNeedNum()); -// summary.setLackNum(workFlow.getNeedNum().subtract(workFlow.getPickedNum())); -// summary.setWorkDate(workFlow.getCreateTime().toLocalDate().atStartOfDay()); -// summary.setWorkStatus(workFlow.getWorkStatus()); -// summary.setLackStatus(summary.getLackNum().compareTo(BigDecimal.ZERO) > 0 ? 1 : 0); -// summary.setFinishTime(workFlow.getFinishTime()); -// summary.setOpUser(workFlow.getOpUser()); -// // 设置电子标签位置 -// List currentBoxELocationList = eLocationConfigList.stream().filter(e -> -// e.getWorkOrder().equals(workFlow.getWorkOrder()) -// && e.getWorkCenter().equals(workFlow.getWorkCenter())).toList(); -// summary.setELocationId(currentBoxELocationList.size() > 0 ? currentBoxELocationList.get(0).getELocationId() : ""); -// workSummaryList.add(summary); -// } -// workSummaryService.saveBatch(workSummaryList); -// // 移除工作流 -// workFlowService.remove(new LambdaQueryWrapper() -// .eq(WorkFlow::getWorkStation, workStation)); -// // 移库站台要料 -// goodsToStationService.remove(new LambdaQueryWrapper() -// .eq(GoodsToStation::getWorkStation, workStation)); -// } catch (Exception e) { -// logger.error("完成站台:{}工作发生异常:{}", workStation, convertJsonString(e)); -// throw new Exception("完成站台:" + workStation + "工作发生异常!"); -// } finally { -// // 当前站台工作完成 -// workFinishingStations.remove(workStation); -// } -// return ""; -// } - /** * 先找到MWL的小工位的配置 * @@ -862,7 +561,7 @@ public class WorkServiceImplements implements IWorkService { // 通过工单表查询到对应的工单 List kateWorkOrderList = allNewKateWorkOrders.stream().filter(kateWorkOrder -> kateWorkOrder.getWorkOrder().equals(currentWorkCenterAndOrderDto.getWorkOrder()) - && kateWorkOrder.getSupplyArea().equals(currentWorkCenterAndOrderDto.getWorkCenter())).toList(); + && kateWorkOrder.getSupplyArea().equals(currentWorkCenterAndOrderDto.getWorkCenter())).toList(); for (KateOrders tempOrder : kateWorkOrderList) { // 生成workFlow WorkFlow tempWorkFlow = new WorkFlow(); diff --git a/src/main/java/com/wms/utils/excel/listener/UploadKanbanListener.java b/src/main/java/com/wms/utils/excel/listener/UploadKanbanListener.java index 13f8ef8..0267f62 100644 --- a/src/main/java/com/wms/utils/excel/listener/UploadKanbanListener.java +++ b/src/main/java/com/wms/utils/excel/listener/UploadKanbanListener.java @@ -3,6 +3,7 @@ package com.wms.utils.excel.listener; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.util.ListUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.wms.entity.app.dto.extend.KanbanEntity; import com.wms.entity.table.Goods; import com.wms.entity.table.Kanban; @@ -38,12 +39,10 @@ public class UploadKanbanListener implements ReadListener { private final KanbanService kanbanService;// 看板服务 private final String uploadUser;// 用户 private final Map goodsMap;// 物料清单 - private final Map oldKanbanMap;// 看板列表 - public UploadKanbanListener(GoodsService goodsService, Map goodsMap, KanbanService kanbanService, Map oldKanbanMap, String uploadUser) { + public UploadKanbanListener(GoodsService goodsService, Map goodsMap, KanbanService kanbanService, String uploadUser) { this.goodsService = goodsService; this.goodsMap = goodsMap; this.kanbanService = kanbanService; - this.oldKanbanMap = oldKanbanMap; this.uploadUser = uploadUser; } @@ -93,6 +92,7 @@ public class UploadKanbanListener implements ReadListener { */ private void saveData() { // 开始存储数据 + List goodsIds = new ArrayList<>(); List goodsList = new ArrayList<>(); List newKanbanList = new ArrayList<>(); for (KanbanGoodsExcelVo goodsExcelVo : cachedDataList) { @@ -109,24 +109,25 @@ public class UploadKanbanListener implements ReadListener { currentGoods.setLastUpdateTime(LocalDateTime.now()); currentGoods.setLastUpdateUser(uploadUser); goodsList.add(currentGoods); + // 物料id列表 + goodsIds.add(currentGoods.getGoodsId()); // 查询当前料所有的看板 for (KanbanEntity kanbanEntity : kanbanList) { - if (!oldKanbanMap.containsKey(currentGoods.getGoodsId() + kanbanEntity.getKanbanId())) { - // 添加新看板 - Kanban newKanban = new Kanban(); - newKanban.setRecordId(generateId("KANBAN_")); - newKanban.setGoodsId(currentGoods.getGoodsId()); - newKanban.setKanbanId(kanbanEntity.getKanbanId()); - newKanban.setKanbanStatus(1);// 默认置满 - newKanban.setLastPullTime(LocalDateTime.now()); - newKanban.setLastPullUser(uploadUser); - newKanbanList.add(newKanban); - } + // 添加新看板 + Kanban newKanban = new Kanban(); + newKanban.setRecordId(generateId("KANBAN_")); + newKanban.setGoodsId(currentGoods.getGoodsId()); + newKanban.setKanbanId(kanbanEntity.getKanbanId()); + newKanban.setKanbanStatus(1);// 默认置满 + newKanban.setLastPullTime(LocalDateTime.now()); + newKanban.setLastPullUser(uploadUser); + newKanbanList.add(newKanban); } } // 保存物料看板信息 goodsService.saveOrUpdateBatch(goodsList); // 保存看板需求信息 + kanbanService.remove(new LambdaQueryWrapper().in(Kanban::getGoodsId, goodsIds)); kanbanService.saveOrUpdateBatch(newKanbanList); // 打印保存数量 SAVE_COUNT += goodsList.size();