From d76676d10478f6073c6839e4b23890d5b236d1a8 Mon Sep 17 00:00:00 2001 From: caoyizhong <1270296080@qq.com> Date: Sun, 15 Oct 2023 20:13:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=98=E7=9B=98=E5=8C=85?= =?UTF-8?q?=E4=BB=B6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/logpm/warehouse/vo/TaskTrayVO.java | 11 + .../warehouse/mapper/TaskQuestMapper.xml | 3 +- .../service/impl/TaskQuestServiceImpl.java | 272 +++++++++++++----- 3 files changed, 214 insertions(+), 72 deletions(-) diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TaskTrayVO.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TaskTrayVO.java index 00d7b34ec..7419c33d3 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TaskTrayVO.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TaskTrayVO.java @@ -30,6 +30,17 @@ public class TaskTrayVO { */ @ApiModelProperty(value = "货物类型") private String goodsType; + /** + * 盘点状态;0 待盘点 1. 已盘 2未盘点 3已排除 + */ + @ApiModelProperty(value = "盘点状态;0 待盘点 1. 已盘 2未盘点 3已排除") + private Integer questStatus; + + /** + * 在库数量 + */ + @ApiModelProperty(value = "在库数量") + private Integer stockNum; /** * 盘点件数 diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/TaskQuestMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/TaskQuestMapper.xml index 88951cd86..10cd66296 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/TaskQuestMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/TaskQuestMapper.xml @@ -111,7 +111,8 @@ lqd.tray_id trayId, lqd.tray_code trayCode, lqd.quest_target goodsType, - sum( lqd.stock_num ) unTotal + lqd.quest_status questStatus + lqd.stock_num stockNum FROM logpm_quest_detail lqd diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/TaskQuestServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/TaskQuestServiceImpl.java index 2911d47bc..0e1e45599 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/TaskQuestServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/TaskQuestServiceImpl.java @@ -18,6 +18,7 @@ package com.logpm.warehouse.service.impl; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.logpm.basicdata.entity.*; @@ -251,6 +252,13 @@ public class TaskQuestServiceImpl extends BaseServiceImpl page, TaskSearchDTO taskSearchDTO) { + + //todo 验证盘点信息 + //先判定盘点任务是否已结束 + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + verifyTask(taskSearchDTO.getTaskId(),myCurrentWarehouse.getId()); + //查询托盘编码 BasicdataTrayEntity trayByTrayCode = basicdataTrayClient.getTrayByTrayCode(taskSearchDTO.getTrayCode()); Optional trayByTrayCode1 = Optional.ofNullable(trayByTrayCode); @@ -259,18 +267,35 @@ public class TaskQuestServiceImpl extends BaseServiceImpl collect =this.getmyWarehouseList(); baseMapper.setSqlMode(); - List list = baseMapper.selecttrayList(page,taskSearchDTO,collect);// 查询有没有当次盘点任务的托盘数据 + List list = getTaskTrayInfo(page,taskSearchDTO,collect);// 查询有没有当次盘点任务的托盘数据 if (!list.isEmpty()){ //有盘点数据 - for (TaskTrayVO taskTrayVO : list) { - //查询托盘上面的数量 - Integer i = warehouseTrayGoodsMapper.SumByTrayId(taskTrayVO.getTrayId()); - taskTrayVO.setTotal(i); - } +// for (TaskTrayVO taskTrayVO : list) { +// //查询托盘上面的数量 +// Integer i = warehouseTrayGoodsMapper.SumByTrayId(taskTrayVO.getTrayId()); +// taskTrayVO.setTotal(i); +// } + + list.stream().mapToInt(TaskTrayVO::getStockNum).sum(); + + + }else{ //添加扫描的托盘信息 - //添加托盘上面的数据 + int taskInventory = getTaskInventory(taskSearchDTO.getTaskId(), collect.get(0), trayByTrayCode); + switch (taskInventory){ + case 0: + return Resp.scanFail("没有盘点信息!","没有盘点信息!"); + case 1: + break; + case 2: + return Resp.scanFail("托盘信息未找到!","托盘信息未找到!"); + + case 3: + + return Resp.scanFail("无包件信息!","无包件信息!"); + } } @@ -278,85 +303,190 @@ public class TaskQuestServiceImpl extends BaseServiceImpl getTaskTrayInfo(IPage page, TaskSearchDTO taskSearchDTO,List collect){ + return baseMapper.selecttrayList(page,taskSearchDTO,collect);// 查询有没有当次盘点任务的托盘数据 + } + + + + + /** * 根据托盘ID查询托盘货位并添加 * @param taskId 盘点ID * @param warehouseId 仓库ID - * @param trayId 托盘ID + * @param trayByTrayCode 托盘 * @return */ - private int getTaskInventory(Long taskId,Long warehouseId,Long trayId){ - - List warehouseTrayGoodsEntities = warehouseTrayGoodsMapper.selectList(Wrappers.query().lambda() - .eq(WarehouseTrayGoodsEntity::getTrayId, trayId) - .eq(WarehouseTrayGoodsEntity::getWarehouseId, warehouseId) + private int getTaskInventory(Long taskId,Long warehouseId,BasicdataTrayEntity trayByTrayCode){ + //查询是否在当前任务内 + List list = taskQuestChildService.list(Wrappers.query().lambda() + .eq(TaskQuestChildEntity::getQuestId, taskId) ); - if(!warehouseTrayGoodsEntities.isEmpty()){ - List questDetailList = new ArrayList<>(); - warehouseTrayGoodsEntities.forEach( i -> { - QuestDetailEntity questDetail = new QuestDetailEntity(); - questDetail.setQuestId(taskId); - switch (i.getAssociationType()){ - case "1": //1.订单号 - questDetail.setOrderId(i.getAssociationId()); - questDetail.setQuestTarget(2);//零担 - questDetail.setCategoryName(i.getGoodsName()); - - break; - case "2": //2运单号 - break; - case "3": //3包件码 - //查询订单ID - questDetail.setQuestTarget(1);// - questDetail.setOrdePackageCode(i.getAssociationValue());//包条码 - questDetail.setOrderPackageId(i.getAssociationId());//包件ID - DistributionParcelListEntity parcelList = new DistributionParcelListEntity(); - parcelList.setId(i.getAssociationId()); - parcelList.setOrderPackageCode(i.getAssociationValue()); - List parcelList1 = distributionParcelListClient.getParcelList(parcelList); - if(!parcelList1.isEmpty()){ - questDetail.setOrderId(parcelList1.get(0).getStockArticleId()); - + if(!list.isEmpty()){ + boolean b = list.stream().anyMatch(t -> ObjectUtils.isNotNull(t.getRefId())); + List warehouseTrayGoodsEntities = warehouseTrayGoodsMapper.selectList(Wrappers.query().lambda() + .eq(WarehouseTrayGoodsEntity::getTrayId, trayByTrayCode.getId()) + .eq(WarehouseTrayGoodsEntity::getWarehouseId, warehouseId) + ); + + if(!warehouseTrayGoodsEntities.isEmpty()){ + List questDetailList = new ArrayList<>(); + for (int ii = 0; ii < warehouseTrayGoodsEntities.size(); ii++) { + WarehouseTrayGoodsEntity i = warehouseTrayGoodsEntities.get(ii); + QuestDetailEntity questDetail = new QuestDetailEntity(); + questDetail.setQuestId(taskId); + switch (i.getAssociationType()){ + case "1": //1.订单号 + if(b){ + //部分盘点 + //查询订单信息 + DistributionStockArticleEntity distributionStockArticleEntity = getStockArticleInfo(i.getAssociationId()); + if(!list.stream().anyMatch(d -> d.getRefId().equals(distributionStockArticleEntity.getMallId()))){ + continue; + } + } + questDetail.setOrderId(i.getAssociationId()); + questDetail.setQuestTarget(2);//零担 + questDetail.setCategoryName(i.getGoodsName()); + WarehouseUpdownGoodsEntity updownGoodsEntity = getUpdownGoodsPack(i.getAssociationId(),"1",i.getAssociationValue(),warehouseId); + if(Optional.ofNullable(updownGoodsEntity).isPresent()){ + questDetail.setPositionCode(updownGoodsEntity.getPositionCode());//完整货位 + questDetail.setAllocationId(updownGoodsEntity.getAllocationId()); + } + break; + case "2": //2运单号 + break; + case "3": //3包件码 + //查询订单ID + //查询订单信息 + DistributionStockArticleEntity distributionStockArticleEntity = getStockArticleInfo(i.getAssociationId()); + if(!list.stream().anyMatch(d -> d.getRefId().equals(distributionStockArticleEntity.getMallId()))){ + continue; + } + questDetail.setQuestTarget(1);// + questDetail.setOrdePackageCode(i.getAssociationValue());//包条码 + questDetail.setOrderPackageId(i.getAssociationId());//包件ID + DistributionParcelListEntity parcelList = new DistributionParcelListEntity(); + parcelList.setId(i.getAssociationId()); + parcelList.setOrderPackageCode(i.getAssociationValue()); + List parcelList1 = distributionParcelListClient.getParcelList(parcelList); + WarehouseUpdownGoodsEntity warehouseUpdownGoodsEntity = getUpdownGoodsPack(i.getAssociationId(),"3",i.getAssociationValue(),warehouseId); + + if(Optional.ofNullable(warehouseUpdownGoodsEntity).isPresent()){ + questDetail.setPositionCode(warehouseUpdownGoodsEntity.getPositionCode());//完整货位 + questDetail.setAllocationId(warehouseUpdownGoodsEntity.getAllocationId()); + } + if(!parcelList1.isEmpty()){ + questDetail.setOrderId(parcelList1.get(0).getStockArticleId()); + } + break; + case "4": //4库存品 + + questDetail.setQuestTarget(3);// + DistributionStockListEntity stockListEntity = new DistributionStockListEntity(); + stockListEntity.setIncomingBatch(i.getIncomingBatch()); + stockListEntity.setWarehouseId(warehouseId); + stockListEntity.setMarketId(i.getMarketId()); + stockListEntity.setMaterialId(i.getAssociationId()); + //查询订单信息 + DistributionStockListEntity stockListInfo = getStockListInfo(stockListEntity); + if(!list.stream().anyMatch(d -> d.getRefId().equals(stockListInfo.getMarketId()))){ + continue; + } + DistributionStockListVO queryData = distributionStockListClient.getQueryData(stockListEntity); + WarehouseUpdownGoodsEntity warehouseUpdownGoods = warehouseUpdownGoodsMapper.selectOne(Wrappers.query().lambda() + .eq(WarehouseUpdownGoodsEntity::getAssociationValue, i.getAssociationValue()) + .eq(WarehouseUpdownGoodsEntity::getMarketId, i.getMarketId()) + .eq(WarehouseUpdownGoodsEntity::getIncomingBatch, i.getIncomingBatch()) + .eq(WarehouseUpdownGoodsEntity::getAssociationId, i.getAssociationId()) + .eq(WarehouseUpdownGoodsEntity::getAssociationType, "4") + .eq(WarehouseUpdownGoodsEntity::getWarehouseId, warehouseId) + ); + if(Optional.ofNullable(warehouseUpdownGoods).isPresent()){ + questDetail.setPositionCode(warehouseUpdownGoods.getPositionCode());//完整货位 + questDetail.setAllocationId(warehouseUpdownGoods.getAllocationId()); + } + Optional queryData1 = Optional.ofNullable(queryData); + if(queryData1.isPresent()){ + questDetail.setStockId(queryData.getId()); + } + break; } - break; - case "4": //4库存品 - questDetail.setQuestTarget(3);// - DistributionStockListEntity stockListEntity = new DistributionStockListEntity(); - stockListEntity.setIncomingBatch(i.getIncomingBatch()); - stockListEntity.setWarehouseId(warehouseId); - stockListEntity.setMarketId(i.getMarketId()); - stockListEntity.setMaterialId(i.getAssociationId()); - DistributionStockListVO queryData = distributionStockListClient.getQueryData(stockListEntity); - Optional queryData1 = Optional.ofNullable(queryData); - if(queryData1.isPresent()){ - questDetail.setStockId(queryData.getId()); - } - - - break; + questDetail.setQuestType(4);//托盘 + questDetail.setQuestStatus(0); //包件盘点状态 + questDetail.setStockNum(i.getNum()); //数量 + questDetail.setWarehouseId(warehouseId);//仓库id + questDetail.setTrayCode(trayByTrayCode.getPalletCode()); + questDetail.setTrayId(trayByTrayCode.getId()); + questDetail.setAllocationId(trayByTrayCode.getId()); + questDetail.setIsNew(0);//是否新增 + questDetailList.add(questDetail); } - questDetail.setQuestType(4);//托盘 - - -// questDetail.setOrdePackageCode(4);//托盘 -// questDetail.setQuestType(4);//托盘 -// questDetail.setQuestType(4);//托盘 - - - - questDetailList.add(questDetail); - }); - //添加 - if(!questDetailList.isEmpty()){ - questDetailService.saveBatch(questDetailList); + //添加 + if(!questDetailList.isEmpty()){ + questDetailService.saveBatch(questDetailList); + return 1; + }else{ + log.debug("托盘盘点:没有物料信息"); + return 3; + } + }else{ + log.debug("托盘盘点:托盘没有货物信息"); + return 2; } }else{ - log.debug("托盘没有货位"); + log.debug("托盘盘点:没有当前盘点任务!"); return 0; } + } + + /** + * 包件,订单查询货位信息 + * @return + */ + private WarehouseUpdownGoodsEntity getUpdownGoodsPack(Long associationId,String type,String associationValue,Long warehouseId){ + return warehouseUpdownGoodsMapper.selectOne(Wrappers.query().lambda() + .eq(WarehouseUpdownGoodsEntity::getAssociationValue, associationValue) + .eq(WarehouseUpdownGoodsEntity::getAssociationId, associationId) + .eq(WarehouseUpdownGoodsEntity::getAssociationType, type) + .eq(WarehouseUpdownGoodsEntity::getWarehouseId, warehouseId) + ); + } + + /** + * 库存品查询货位信息 + * @return + */ + private WarehouseUpdownGoodsEntity getUpdownGoodsStpck(Long marketId,String type,String incomingBatch,Long warehouseId,Long associationId ,Long associationValue){ + return warehouseUpdownGoodsMapper.selectOne(Wrappers.query().lambda() + .eq(WarehouseUpdownGoodsEntity::getAssociationValue, associationValue) + .eq(WarehouseUpdownGoodsEntity::getMarketId, marketId) + .eq(WarehouseUpdownGoodsEntity::getIncomingBatch, incomingBatch) + .eq(WarehouseUpdownGoodsEntity::getAssociationId, associationId) + .eq(WarehouseUpdownGoodsEntity::getAssociationType, type) + .eq(WarehouseUpdownGoodsEntity::getWarehouseId, warehouseId) + ); + } + /** + * 订单ID查询订单信息 + * @return + */ + private DistributionStockArticleEntity getStockArticleInfo(Long stockArticleID){ + return distributionStockArticleClient.findEntityByStockArticleId(stockArticleID); + } - return 1; + /** + * 订单ID查询订单信息 + * @return + */ + private DistributionStockListEntity getStockListInfo(DistributionStockListEntity distributionStockListEntity){ + return distributionStockListClient.getQueryData(distributionStockListEntity); }