diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/service/WarehouseDomainService.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/service/WarehouseDomainService.java index 5dfc179e0..aa2d571e6 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/service/WarehouseDomainService.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/service/WarehouseDomainService.java @@ -199,6 +199,10 @@ public class WarehouseDomainService { }); } storageSectionLinkagePO.setChildren(storageLocationLinkagePOList); + // 有 storageLocationType 过滤时,库位为空的库区不展示 + if (storageLocationType != null && !storageLocationType.isEmpty() && storageLocationLinkagePOList.isEmpty()) { + return; + } storageSectionLinkagePOList.add(storageSectionLinkagePO); }); warehouseLinkagePO.setChildren(storageSectionLinkagePOList); diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/investigationManage/repository/po/InvestigetionMaterialPO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/investigationManage/repository/po/InvestigetionMaterialPO.java index 3aea9b528..dfb154780 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/investigationManage/repository/po/InvestigetionMaterialPO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/investigationManage/repository/po/InvestigetionMaterialPO.java @@ -57,9 +57,13 @@ public class InvestigetionMaterialPO extends BaseVOEntity { @Excel(name = "盘点数量") private BigDecimal investigationQuantity; - @ApiModelProperty("盈亏数量") - @Excel(name = "盈亏数量") - private BigDecimal profitLossQuantity; + @ApiModelProperty("盘盈数量") + @Excel(name = "盘盈数量") + private BigDecimal investigationProfitQuantity; + + @ApiModelProperty("盘亏数量") + @Excel(name = "盘亏数量") + private BigDecimal investigationLossQuantity; @ApiModelProperty("盘点状态: 1-待盘点 2-盘亏 3-正常 4-盘盈") @Excel(name = "盘点状态: 1-待盘点 2-盘亏 3-正常 4-盘盈") 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 8c3c3273f..bba17eb3d 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 @@ -147,26 +147,59 @@ public class InvestigationManageDomainService { BeanUtils.copyProperties(investigationManageDetailPOListByMaterial.get(0), investigetionStoragePO); BigDecimal inventoryQuantity = BigDecimal.ZERO;//库存数量 BigDecimal investigationQuantity = BigDecimal.ZERO;//盘点数量 - BigDecimal investigationProfitQuantity = BigDecimal.ZERO;//盘盈数量 - BigDecimal investigationLossQuantity = BigDecimal.ZERO;//盘亏数量 + boolean hasInvestigated = false;//是否有已盘点的明细 for (InvestigetionManageDetailPO investigetionManageDetailPO : investigationManageDetailPOListByMaterial) { inventoryQuantity = inventoryQuantity.add(investigetionManageDetailPO.getInventoryQuantity()); investigationQuantity = investigationQuantity.add(investigetionManageDetailPO.getInvestigationQuantity()); - if (1 == investigetionManageDetailPO.getInvestigationResult()) { - //盘盈 - investigationProfitQuantity = investigationProfitQuantity.add(investigetionManageDetailPO.getDifferentQuantity()); - } else if (2 == investigetionManageDetailPO.getInvestigationResult()) { - //盘亏 - investigationLossQuantity = investigationLossQuantity.add(investigetionManageDetailPO.getDifferentQuantity()); + if (investigetionManageDetailPO.getInvestigationResult() != null && investigetionManageDetailPO.getInvestigationResult() > 0) { + hasInvestigated = true; } } investigetionStoragePO.setInventoryQuantity(inventoryQuantity); investigetionStoragePO.setInvestigationQuantity(investigationQuantity); - investigetionStoragePO.setInvestigationProfitQuantity(investigationProfitQuantity); - investigetionStoragePO.setInvestigationLossQuantity(investigationLossQuantity); - //判断盘点数量是否大于0 - Integer investigationStatus = judgeInvestigationQuantityByStorageLocation(investigationQuantity); + //判断盘点数量是否大于0(未盘点时强制返回1) + Integer investigationStatus = hasInvestigated + ? judgeInvestigationQuantityByStorageLocation(investigationQuantity) + : 1; investigetionStoragePO.setInvestigationStatus(investigationStatus); + // 只有已盘点(status=2)才计算盈亏,未盘点(status=1)盈亏为0 + if (investigationStatus == 2) { + if (investigationQuantity.compareTo(inventoryQuantity) > 0) { + investigetionStoragePO.setInvestigationProfitQuantity(investigationQuantity.subtract(inventoryQuantity)); + investigetionStoragePO.setInvestigationLossQuantity(BigDecimal.ZERO); + } else if (investigationQuantity.compareTo(inventoryQuantity) < 0) { + investigetionStoragePO.setInvestigationProfitQuantity(BigDecimal.ZERO); + investigetionStoragePO.setInvestigationLossQuantity(inventoryQuantity.subtract(investigationQuantity)); + } else { + investigetionStoragePO.setInvestigationProfitQuantity(BigDecimal.ZERO); + investigetionStoragePO.setInvestigationLossQuantity(BigDecimal.ZERO); + } + } else { + investigetionStoragePO.setInvestigationProfitQuantity(BigDecimal.ZERO); + investigetionStoragePO.setInvestigationLossQuantity(BigDecimal.ZERO); + } + // 给每条明细填充盘盈/盘亏数量 + // investigationResult=0 表示未盘点,不计算盈亏;否则按数量差值计算 + investigationManageDetailPOListByMaterial.forEach(detail -> { + if (detail.getInvestigationResult() != null && detail.getInvestigationResult() > 0 + && detail.getInventoryQuantity() != null && detail.getInvestigationQuantity() != null) { + BigDecimal dInv = detail.getInventoryQuantity(); + BigDecimal dCount = detail.getInvestigationQuantity(); + if (dCount.compareTo(dInv) > 0) { + detail.setInvestigationProfitQuantity(dCount.subtract(dInv)); + detail.setInvestigationLossQuantity(BigDecimal.ZERO); + } else if (dCount.compareTo(dInv) < 0) { + detail.setInvestigationProfitQuantity(BigDecimal.ZERO); + detail.setInvestigationLossQuantity(dInv.subtract(dCount)); + } else { + detail.setInvestigationProfitQuantity(BigDecimal.ZERO); + detail.setInvestigationLossQuantity(BigDecimal.ZERO); + } + } else { + detail.setInvestigationProfitQuantity(BigDecimal.ZERO); + detail.setInvestigationLossQuantity(BigDecimal.ZERO); + } + }); investigetionStoragePO.setInvestigetionManageDetailList(investigationManageDetailPOListByMaterial); investigetionStorageList.add(investigetionStoragePO); if (investigationStatus > 1) { @@ -203,32 +236,53 @@ public class InvestigationManageDomainService { BeanUtils.copyProperties(investigationManageDetailPOListByMaterial.get(0), investigetionMaterialPO); BigDecimal inventoryQuantity = BigDecimal.ZERO;//库存数量 BigDecimal investigationQuantity = BigDecimal.ZERO;//盘点数量 - BigDecimal investigationProfitQuantity = BigDecimal.ZERO;//盘盈数量 - BigDecimal investigationLossQuantity = BigDecimal.ZERO;//盘亏数量 + boolean hasInvestigated = false;//是否有已盘点的明细 for (InvestigetionManageDetailPO investigetionManageDetailPO : investigationManageDetailPOListByMaterial) { inventoryQuantity = inventoryQuantity.add(investigetionManageDetailPO.getInventoryQuantity()); investigationQuantity = investigationQuantity.add(investigetionManageDetailPO.getInvestigationQuantity()); - if (1 == investigetionManageDetailPO.getInvestigationResult()) { - //盘盈 - investigationProfitQuantity = investigationProfitQuantity.add(investigetionManageDetailPO.getDifferentQuantity()); - } else if (2 == investigetionManageDetailPO.getInvestigationResult()) { - //盘亏 - investigationLossQuantity = investigationLossQuantity.add(investigetionManageDetailPO.getDifferentQuantity()); + if (investigetionManageDetailPO.getInvestigationResult() != null && investigetionManageDetailPO.getInvestigationResult() > 0) { + hasInvestigated = true; } } investigetionMaterialPO.setInventoryQuantity(inventoryQuantity); investigetionMaterialPO.setInvestigationQuantity(investigationQuantity); //判断盘点数量和计划数量的差异 确定盘点状态 1-待盘点 2-盘亏 3-正常 4-盘盈 - int investigationStatus = judgeInvestigationQuantityByMaterial(investigationQuantity, inventoryQuantity); + int investigationStatus = hasInvestigated + ? judgeInvestigationQuantityByMaterial(investigationQuantity, inventoryQuantity) + : 1; investigetionMaterialPO.setInvestigationStatus(investigationStatus); if (investigationStatus == 2) { - investigetionMaterialPO.setProfitLossQuantity(investigationLossQuantity.subtract(investigationProfitQuantity)); + // 盘亏:库存数量 - 盘点数量 + investigetionMaterialPO.setInvestigationProfitQuantity(BigDecimal.ZERO); + investigetionMaterialPO.setInvestigationLossQuantity(inventoryQuantity.subtract(investigationQuantity)); } else if (investigationStatus == 4) { - investigetionMaterialPO.setProfitLossQuantity(investigationProfitQuantity.subtract(investigationProfitQuantity)); + // 盘盈:盘点数量 - 库存数量 + investigetionMaterialPO.setInvestigationProfitQuantity(investigationQuantity.subtract(inventoryQuantity)); + investigetionMaterialPO.setInvestigationLossQuantity(BigDecimal.ZERO); } else { - investigetionMaterialPO.setProfitLossQuantity(BigDecimal.ZERO); + investigetionMaterialPO.setInvestigationProfitQuantity(BigDecimal.ZERO); + investigetionMaterialPO.setInvestigationLossQuantity(BigDecimal.ZERO); } - investigetionMaterialPO.setInvestigetionManageDetailList(investigationManageDetailPOListByMaterial); + investigetionMaterialPO.setInvestigetionManageDetailList(investigationManageDetailPOListByMaterial.stream().peek(detail -> { + if (detail.getInvestigationResult() != null && detail.getInvestigationResult() > 0 + && detail.getInventoryQuantity() != null && detail.getInvestigationQuantity() != null) { + BigDecimal dInv = detail.getInventoryQuantity(); + BigDecimal dCount = detail.getInvestigationQuantity(); + if (dCount.compareTo(dInv) > 0) { + detail.setInvestigationProfitQuantity(dCount.subtract(dInv)); + detail.setInvestigationLossQuantity(BigDecimal.ZERO); + } else if (dCount.compareTo(dInv) < 0) { + detail.setInvestigationProfitQuantity(BigDecimal.ZERO); + detail.setInvestigationLossQuantity(dInv.subtract(dCount)); + } else { + detail.setInvestigationProfitQuantity(BigDecimal.ZERO); + detail.setInvestigationLossQuantity(BigDecimal.ZERO); + } + } else { + detail.setInvestigationProfitQuantity(BigDecimal.ZERO); + detail.setInvestigationLossQuantity(BigDecimal.ZERO); + } + }).collect(java.util.stream.Collectors.toList())); investigetionMaterialList.add(investigetionMaterialPO); if (investigationStatus > 1) { totalInvestigetionMaterialQuantity += 1; @@ -317,11 +371,10 @@ public class InvestigationManageDomainService { * @date 2024/7/20 10:13 */ private Integer judgeInvestigationQuantityByStorageLocation(BigDecimal investigationQuantity) { - if (investigationQuantity.compareTo(BigDecimal.ZERO) == 0) { - //未盘点 + // investigationQuantity 为 null 表示未盘点;0 表示已盘点(全部盘亏) + if (investigationQuantity == null) { return 1; } else { - //已盘点 return 2; } } @@ -336,9 +389,11 @@ public class InvestigationManageDomainService { */ private Integer judgeInvestigationQuantityByMaterial(BigDecimal investigationQuantity, BigDecimal quantity) { //1-待盘点 2-盘亏 3-正常 4-盘盈 - if (investigationQuantity.compareTo(BigDecimal.ZERO) == 0) { + // investigationQuantity 为 null 表示未盘点 + if (investigationQuantity == null) { return 1; } else if (investigationQuantity.compareTo(quantity) < 0) { + // 盘点数量 < 库存数量(含0),盘亏 return 2; } else if (investigationQuantity.compareTo(quantity) == 0) { return 3; diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/investigetionManageDetail/repository/po/InvestigetionManageDetailPO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/investigetionManageDetail/repository/po/InvestigetionManageDetailPO.java index c3252dfac..656f844a1 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/investigetionManageDetail/repository/po/InvestigetionManageDetailPO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/investigetionManageDetail/repository/po/InvestigetionManageDetailPO.java @@ -75,6 +75,14 @@ public class InvestigetionManageDetailPO extends BaseVOEntity { @Excel(name = "差异数量") private BigDecimal differentQuantity; + @ApiModelProperty("盘盈数量") + @Excel(name = "盘盈数量") + private BigDecimal investigationProfitQuantity; + + @ApiModelProperty("盘亏数量") + @Excel(name = "盘亏数量") + private BigDecimal investigationLossQuantity; + @ApiModelProperty("盘点结果:1.盘盈 2.盘亏 3.正常") @Excel(name = "盘点结果:1.盘盈 2.盘亏 3.正常") private Integer investigationResult;