From 7899379c228dd6dbbf49326386209cc540e9455a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Tue, 17 Mar 2026 13:17:47 +0800 Subject: [PATCH] =?UTF-8?q?PDA=E7=9B=98=E7=82=B9=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E7=8A=B6=E6=80=81=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...InvestigationManageApplicationService.java | 18 ++++++++---- .../InvestigationManageDomainService.java | 29 ++++++++++++------- .../InvestigationManageMapper.xml | 6 ++-- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/investigationManage/InvestigationManageApplicationService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/investigationManage/InvestigationManageApplicationService.java index f61669d1a..ac1d7a603 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/application/service/investigationManage/InvestigationManageApplicationService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/investigationManage/InvestigationManageApplicationService.java @@ -559,20 +559,28 @@ public class InvestigationManageApplicationService { po.setInvestigationProgress(BigDecimal.ZERO); return; } + int totalCount = detailList.size(); + int investigatedCount = 0; BigDecimal totalQuantity = BigDecimal.ZERO; BigDecimal investigatedQuantity = BigDecimal.ZERO; for (InvestigetionManageDetailPO detail : detailList) { if (detail.getInventoryQuantity() != null) { totalQuantity = totalQuantity.add(detail.getInventoryQuantity()); - if (Integer.valueOf(4).equals(detail.getInvestigationStatus())) { + } + Integer status = detail.getInvestigationStatus(); + // 状态>=3表示已盘完(3=盘亏/盘盈,4=正常),盘点数量可以为0 + if (status != null && status >= 3) { + investigatedCount++; + if (detail.getInventoryQuantity() != null) { investigatedQuantity = investigatedQuantity.add(detail.getInventoryQuantity()); } } } po.setTotalInventoryQuantity(totalQuantity); po.setInvestigatedInventoryQuantity(investigatedQuantity); - if (totalQuantity.compareTo(BigDecimal.ZERO) > 0) { - po.setInvestigationProgress(investigatedQuantity.divide(totalQuantity, 4, RoundingMode.HALF_UP)); + // 进度按条数计算,避免盘点数量为0时进度不准 + if (totalCount > 0) { + po.setInvestigationProgress(new BigDecimal(investigatedCount).divide(new BigDecimal(totalCount), 4, RoundingMode.HALF_UP)); } else { po.setInvestigationProgress(BigDecimal.ZERO); } @@ -623,8 +631,8 @@ public class InvestigationManageApplicationService { if (investigetionManageDetailPO == null){ throw new ServiceException("物料明细不存在"); } - if (ObjectUtil.isNull(investigetionManageDetailDO.getInvestigationQuantity()) || investigetionManageDetailDO.getInvestigationQuantity().compareTo(BigDecimal.ZERO) == 0){ - //未进盘点直接跳过 + if (ObjectUtil.isNull(investigetionManageDetailDO.getInvestigationQuantity())){ + //盘点数量为null时跳过 continue; } InvestigetionManageDetailDO returnInvestigetionManageDetailDO = new InvestigetionManageDetailDO(); diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/investigationManage/service/InvestigationManageDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/investigationManage/service/InvestigationManageDomainService.java index dab64fe25..8c3c3273f 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/investigationManage/service/InvestigationManageDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/investigationManage/service/InvestigationManageDomainService.java @@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -175,19 +176,23 @@ public class InvestigationManageDomainService { investigationManagePO.setInvestigationMaterialQuantity(totalInvestigetionMaterialQuantity); investigationManagePO.setMaterialQuantity(investigetionStorageList.size()); investigationManagePO.setInvestigetionStorageList(investigetionStorageList); + // 计算盘点进度 = 已盘组数 / 总组数 + if (investigetionStorageList.size() > 0) { + investigationManagePO.setInvestigationProgress( + new BigDecimal(totalInvestigetionMaterialQuantity).divide(new BigDecimal(investigetionStorageList.size()), 4, RoundingMode.HALF_UP) + ); + } else { + investigationManagePO.setInvestigationProgress(BigDecimal.ZERO); + } return investigationManagePO; } - - /** - * 按物料盘点 获取盘点单详细信息 - */ public InvestigationManagePO getInfoByMaterial(Long investigationManageId) { InvestigationManagePO investigationManagePO = investigationManageService.getInfoByInvestigationManageId(investigationManageId); InvestigetionManageDetailDO investigetionManageDetailDO = new InvestigetionManageDetailDO(); investigetionManageDetailDO.setInvestigationNumber(investigationManagePO.getInvestigationNumber()); List investigetionManageDetailPOList = iInvestigetionManageDetailService.queryList(investigetionManageDetailDO); - Map> investigetionManageDetailPOMap = investigetionManageDetailPOList.stream().collect(Collectors.groupingBy(InvestigetionManageDetailPO::getStorageLocationId)); - int totalInvestigetionMaterialQuantity = 0;//盘点单按物料分组 统计已拣货进度 + Map> investigetionManageDetailPOMap = investigetionManageDetailPOList.stream().collect(Collectors.groupingBy(InvestigetionManageDetailPO::getMaterialBaseInfoId)); + int totalInvestigetionMaterialQuantity = 0;//盘点单按物料分组 统计已盘点进度 List investigetionMaterialList = new ArrayList<>(); for (Map.Entry> map : investigetionManageDetailPOMap.entrySet()) { List investigationManageDetailPOListByMaterial = map.getValue(); @@ -232,6 +237,14 @@ public class InvestigationManageDomainService { investigationManagePO.setInvestigationMaterialQuantity(totalInvestigetionMaterialQuantity); investigationManagePO.setMaterialQuantity(investigetionMaterialList.size()); investigationManagePO.setInvestigetionMaterialList(investigetionMaterialList); + // 计算盘点进度 = 已盘组数 / 总组数 + if (investigetionMaterialList.size() > 0) { + investigationManagePO.setInvestigationProgress( + new BigDecimal(totalInvestigetionMaterialQuantity).divide(new BigDecimal(investigetionMaterialList.size()), 4, RoundingMode.HALF_UP) + ); + } else { + investigationManagePO.setInvestigationProgress(BigDecimal.ZERO); + } return investigationManagePO; } @@ -324,16 +337,12 @@ public class InvestigationManageDomainService { private Integer judgeInvestigationQuantityByMaterial(BigDecimal investigationQuantity, BigDecimal quantity) { //1-待盘点 2-盘亏 3-正常 4-盘盈 if (investigationQuantity.compareTo(BigDecimal.ZERO) == 0) { - //待盘点 return 1; } else if (investigationQuantity.compareTo(quantity) < 0) { - //盘亏 return 2; } else if (investigationQuantity.compareTo(quantity) == 0) { - //正常 return 3; } else { - //盘盈 return 4; } } diff --git a/mhd_wms/src/main/resources/mapper/investigationManage/InvestigationManageMapper.xml b/mhd_wms/src/main/resources/mapper/investigationManage/InvestigationManageMapper.xml index b8b8cd8ee..23bb5d042 100644 --- a/mhd_wms/src/main/resources/mapper/investigationManage/InvestigationManageMapper.xml +++ b/mhd_wms/src/main/resources/mapper/investigationManage/InvestigationManageMapper.xml @@ -29,6 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -44,9 +46,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select m.investigation_manage_id, m.organization_id, m.organization_name, m.top_organization_id, m.investigation_number, m.old_investigation_number, m.investigation_status, m.investigation_range, m.investigation_type, m.investigation_method, m.investigation_frequency, m.different_number, m.warehouse_id, m.warehouse_code, m.warehouse_name, m.audit_status, m.audit_remark, m.audit_by, m.audit_by_name, m.audit_time, m.task_distribution, m.task_distribution_time, m.operators_by, m.operators_name, m.nullify, m.remark, m.create_time, m.create_by, m.create_by_name, m.update_time, m.update_by, m.update_by_name, m.del_flag, + select m.investigation_manage_id, m.organization_id, m.organization_name, m.top_organization_id, m.investigation_number, m.old_investigation_number, m.investigation_status, m.investigation_range, m.investigation_type, m.investigation_method, m.investigation_frequency, m.different_number, m.warehouse_id, m.warehouse_code, m.warehouse_name, m.audit_status, m.audit_remark, m.audit_by, m.audit_by_name, m.audit_time, m.task_distribution, m.task_distribution_time, m.operators_by, m.operators_name, m.investigation_man_by, m.investigation_man_name, m.nullify, m.remark, m.create_time, m.create_by, m.create_by_name, m.update_time, m.update_by, m.update_by_name, m.del_flag, (SELECT IFNULL(SUM(d.inventory_quantity), 0) FROM investigetion_manage_detail d WHERE d.investigation_number = m.investigation_number AND d.del_flag = 1) as total_inventory_quantity, - (SELECT IFNULL(SUM(d.inventory_quantity), 0) FROM investigetion_manage_detail d WHERE d.investigation_number = m.investigation_number AND d.del_flag = 1 AND d.investigation_status = 4) as investigated_inventory_quantity + (SELECT IFNULL(SUM(d.inventory_quantity), 0) FROM investigetion_manage_detail d WHERE d.investigation_number = m.investigation_number AND d.del_flag = 1 AND d.investigation_status IN (3, 4)) as investigated_inventory_quantity from investigation_manage m