From a0bd7cc32e48b1b0a6401b549d3957a5488fba49 Mon Sep 17 00:00:00 2001 From: zhaoqiaobo <583671871@qq.com> Date: Wed, 9 Oct 2024 16:49:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E4=BF=AE=E6=94=B9=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E6=97=A5=E5=BA=A6=E6=9C=88=E5=BA=A6=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/QualityDeliverEntity.java | 15 + .../entity/ExpenseDispatchPriceEntity.java | 5 + .../ExpenseDispatchTrainDetailEntity.java | 5 + .../report/DeliverFinishReportListener.java | 1181 +++++++++-------- .../report/ReturnWarehouseReportListener.java | 109 ++ .../mapper/ExpenseWarehouseDayMapper.java | 2 +- .../mapper/ExpenseWarehouseDayMapper.xml | 15 +- .../mapper/ExpenseWarehouseMonthMapper.java | 4 +- .../mapper/ExpenseWarehouseMonthMapper.xml | 15 +- .../ExpenseWarehouseMonthServiceImpl.java | 9 +- .../statistics/vo/ExpenseWarehouseDayVO.java | 9 +- .../vo/ExpenseWarehouseMonthVO.java | 7 + 12 files changed, 787 insertions(+), 589 deletions(-) create mode 100644 blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReturnWarehouseReportListener.java diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/QualityDeliverEntity.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/QualityDeliverEntity.java index c01ed6397..f5a667000 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/QualityDeliverEntity.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/QualityDeliverEntity.java @@ -364,6 +364,16 @@ public class QualityDeliverEntity extends TenantEntity { */ @ApiModelProperty(value = "配送公司") private String distributionCompany; + /** + * 配送是否整车计费 + */ + @ApiModelProperty(value = "配送是否整车计费") + private String ynWholeVehicle; + /** + * 配送整车费(外协) + */ + @ApiModelProperty(value = "配送整车费(外协)") + private String deliveryFee; /** * 计划时间 */ @@ -584,6 +594,11 @@ public class QualityDeliverEntity extends TenantEntity { */ @ApiModelProperty(value = "配送成本") private String distributionCost; + /** + * 整车成本 + */ + @ApiModelProperty(value = "整车成本") + private String wholeVehicleCost; /** * 分货费成本 */ diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchPriceEntity.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchPriceEntity.java index ef5bdc00f..07c132c45 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchPriceEntity.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchPriceEntity.java @@ -54,6 +54,11 @@ public class ExpenseDispatchPriceEntity extends TenantEntity { */ @ApiModelProperty(value = "免费上楼层数") private int freeFloorLevels; + /** + * 整车计费单价 + */ + @ApiModelProperty(value = "整车计费单价") + private String wholeVehicleCost; /** * 公里数单价 */ diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchTrainDetailEntity.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchTrainDetailEntity.java index 9b7bb8026..2018d7960 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchTrainDetailEntity.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchTrainDetailEntity.java @@ -124,6 +124,11 @@ public class ExpenseDispatchTrainDetailEntity extends TenantEntity { */ @ApiModelProperty(value = "配送成本") private String distributionCost; + /** + * 整车成本 + */ + @ApiModelProperty(value = "整车成本") + private String wholeVehicleCost; /** * 库存品配送成本 */ diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java index 038fcaefa..dc98545d9 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java @@ -143,7 +143,7 @@ public class DeliverFinishReportListener { param.setMaterielName(qualityDeliverEntity.getMaterielName()); param.setType(2); BasicdataFactoryCategoryEntity factoryCategoryEntity = factoryCategoryClient.findEntityByPaeam(param); - if(ObjectUtil.isNotEmpty(factoryCategoryEntity)){ + if (ObjectUtil.isNotEmpty(factoryCategoryEntity)) { entity.setCostCategory(factoryCategoryEntity.getCategory()); entity.setCostCategoryId(factoryCategoryEntity.getCategoryId()); } @@ -165,521 +165,359 @@ public class DeliverFinishReportListener { Map firstRouteMap = new LinkedHashMap<>(); // 根据对应的司机id查询出价格 if (ObjectUtil.isNotEmpty(qualityDeliverEntity)) { - if (StrUtil.isNotEmpty(qualityDeliverEntity.getDeliveryType()) - && (StrUtil.equals(qualityDeliverEntity.getDeliveryType(), "商配") || StrUtil.equals(qualityDeliverEntity.getDeliveryType(), "市配"))) { - ExpenseDispatchClientDTO expenseDispatchClientDTO = expenseDispatchClient.findPriceByDriverId(qualityDeliverEntity.getWarehouseId(), driverId, qualityDeliverEntity.getSignCarType(), qualityDeliverEntity.getDeliveryType()); - if (ObjectUtil.isNotEmpty(expenseDispatchClientDTO)) { - // 计算总件数 - Integer totalNum = value.stream().mapToInt(QualityDeliverEntity::getSignNum).sum(); - ExpenseDispatchPriceVO priceVO = expenseDispatchClientDTO.getPriceVO(); - if (ObjectUtil.isEmpty(priceVO)) { - return; + // 计算总件数 + Integer totalNum = value.stream().mapToInt(QualityDeliverEntity::getSignNum).sum(); + // 自主配送/外协 + String deliveryKind = qualityDeliverEntity.getDeliveryKind(); + // 是否整车计费 + Boolean ynWholeVehicle = StrUtil.isNotEmpty(qualityDeliverEntity.getYnWholeVehicle()) && StrUtil.equals(qualityDeliverEntity.getYnWholeVehicle(), "是") ? Boolean.TRUE : Boolean.FALSE; + if (StrUtil.isNotEmpty(deliveryKind) && StrUtil.equals(deliveryKind, "三方配送")) { + String deliveryFee = qualityDeliverEntity.getDeliveryFee(); + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + if (StrUtil.isNotEmpty(deliveryFee)) { + BigDecimal div = NumberUtil.div(new BigDecimal(deliveryFee), totalNum); + value2.setWholeVehicleCost(Convert.toStr(div)); } - List overZoneList = priceVO.getOverZoneList(); - Map overZoneEntityMap = new HashMap<>(); - if (CollUtil.isNotEmpty(overZoneList)) { - for (ExpenseDispatchPriceOverZoneEntity expenseDispatchPriceOverZoneEntity : overZoneList) { - overZoneEntityMap.put(expenseDispatchPriceOverZoneEntity.getProvinceName() + expenseDispatchPriceOverZoneEntity.getCityName() + expenseDispatchPriceOverZoneEntity.getDistrictName(), expenseDispatchPriceOverZoneEntity); + } + } + if (StrUtil.isNotEmpty(deliveryKind) && StrUtil.equals(deliveryKind, "自主配送")) { + if (StrUtil.isNotEmpty(qualityDeliverEntity.getDeliveryType()) + && (StrUtil.equals(qualityDeliverEntity.getDeliveryType(), "商配") || StrUtil.equals(qualityDeliverEntity.getDeliveryType(), "市配"))) { + ExpenseDispatchClientDTO expenseDispatchClientDTO = expenseDispatchClient.findPriceByDriverId(qualityDeliverEntity.getWarehouseId(), driverId, qualityDeliverEntity.getSignCarType(), qualityDeliverEntity.getDeliveryType()); + if (ObjectUtil.isNotEmpty(expenseDispatchClientDTO)) { + ExpenseDispatchPriceVO priceVO = expenseDispatchClientDTO.getPriceVO(); + if (ObjectUtil.isEmpty(priceVO)) { + return; } - } - List priceList = priceVO.getPriceList(); - BigDecimal totalFreight = BigDecimal.ZERO; - ExpenseDispatchPriceRuleDTO rule = expenseDispatchClientDTO.getRule(); - if (ObjectUtil.isEmpty(rule)) { - return; - } - if (CollUtil.isNotEmpty(priceList)) { - Map priceMap = priceList.stream().collect(Collectors.toMap(ExpenseDispatchPriceCategoryVO::getCategoryId, v -> v)); - // 车的总运费 用于计算是否触发保底 - for (QualityDeliverEntity entity : value) { - Long id = entity.getId(); - QualityDeliverEntity entity1 = valueMap.get(id); - if (ObjectUtil.isNotEmpty(entity.getCostCategoryId()) && priceMap.containsKey(entity.getCostCategoryId())) { - ExpenseDispatchPriceCategoryVO expenseDispatchPriceCategoryVO = priceMap.get(entity.getCostCategoryId()); - String cost = expenseDispatchPriceCategoryVO.getCost(); - Integer unit = expenseDispatchPriceCategoryVO.getUnit(); - if (StrUtil.isNotEmpty(cost)) { - if (NumberUtil.equals(unit, 1)) { - // 按件 成本就是单价 - BigDecimal mul = NumberUtil.mul(entity.getSignNum(), new BigDecimal(cost)); - entity1.setDistributionCost(Convert.toStr(mul)); - totalFreight = totalFreight.add(mul); - } - if (NumberUtil.equals(unit, 2)) { - // 按方 成本 = 总体积 * 单价 - BigDecimal volume = entity.getVolume(); - if (ObjectUtil.isNotEmpty(volume)) { - BigDecimal mul = NumberUtil.mul(volume, new BigDecimal(cost)); - entity1.setDistributionCost(Convert.toStr(mul)); - totalFreight = totalFreight.add(mul); - } - } - if (NumberUtil.equals(unit, 3)) { - // 按重量 成本 = 总重量 * 单价 - BigDecimal weight = entity.getWeight(); - if (ObjectUtil.isNotEmpty(weight)) { - BigDecimal mul = NumberUtil.mul(weight, new BigDecimal(cost)); - entity1.setDistributionCost(Convert.toStr(mul)); - totalFreight = totalFreight.add(mul); + // 整车计费,则车内的每个包件分摊整车成本费用 + if (ynWholeVehicle) { + String wholeVehicleCost = priceVO.getWholeVehicleCost(); + if(StrUtil.isNotEmpty(wholeVehicleCost)){ + BigDecimal div = NumberUtil.div(new BigDecimal(wholeVehicleCost), totalNum); + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + value2.setWholeVehicleCost(Convert.toStr(div)); + } + } + } else { + List overZoneList = priceVO.getOverZoneList(); + Map overZoneEntityMap = new HashMap<>(); + if (CollUtil.isNotEmpty(overZoneList)) { + for (ExpenseDispatchPriceOverZoneEntity expenseDispatchPriceOverZoneEntity : overZoneList) { + overZoneEntityMap.put(expenseDispatchPriceOverZoneEntity.getProvinceName() + expenseDispatchPriceOverZoneEntity.getCityName() + expenseDispatchPriceOverZoneEntity.getDistrictName(), expenseDispatchPriceOverZoneEntity); + } + } + List priceList = priceVO.getPriceList(); + BigDecimal totalFreight = BigDecimal.ZERO; + ExpenseDispatchPriceRuleDTO rule = expenseDispatchClientDTO.getRule(); + if (ObjectUtil.isEmpty(rule)) { + return; + } + if (CollUtil.isNotEmpty(priceList)) { + Map priceMap = priceList.stream().collect(Collectors.toMap(ExpenseDispatchPriceCategoryVO::getCategoryId, v -> v)); + // 车的总运费 用于计算是否触发保底 + for (QualityDeliverEntity entity : value) { + Long id = entity.getId(); + QualityDeliverEntity entity1 = valueMap.get(id); + if (ObjectUtil.isNotEmpty(entity.getCostCategoryId()) && priceMap.containsKey(entity.getCostCategoryId())) { + ExpenseDispatchPriceCategoryVO expenseDispatchPriceCategoryVO = priceMap.get(entity.getCostCategoryId()); + String cost = expenseDispatchPriceCategoryVO.getCost(); + Integer unit = expenseDispatchPriceCategoryVO.getUnit(); + if (StrUtil.isNotEmpty(cost)) { + if (NumberUtil.equals(unit, 1)) { + // 按件 成本就是单价 + BigDecimal mul = NumberUtil.mul(entity.getSignNum(), new BigDecimal(cost)); + entity1.setDistributionCost(Convert.toStr(mul)); + totalFreight = totalFreight.add(mul); + } + if (NumberUtil.equals(unit, 2)) { + // 按方 成本 = 总体积 * 单价 + BigDecimal volume = entity.getVolume(); + if (ObjectUtil.isNotEmpty(volume)) { + BigDecimal mul = NumberUtil.mul(volume, new BigDecimal(cost)); + entity1.setDistributionCost(Convert.toStr(mul)); + totalFreight = totalFreight.add(mul); + } + } + if (NumberUtil.equals(unit, 3)) { + // 按重量 成本 = 总重量 * 单价 + BigDecimal weight = entity.getWeight(); + if (ObjectUtil.isNotEmpty(weight)) { + BigDecimal mul = NumberUtil.mul(weight, new BigDecimal(cost)); + entity1.setDistributionCost(Convert.toStr(mul)); + totalFreight = totalFreight.add(mul); + } + } } } } - } - } - // 判断是否触发保底 - Integer ynMinimumFee = rule.getYnMinimumFee(); - if (NumberUtil.equals(ynMinimumFee, BooleanZeroOneEnums.YES.getCode())) { - String minimumFee = priceVO.getMinimumFee(); - if (StrUtil.isNotEmpty(minimumFee)) { - // 总运费 < 保底费 触发保底 (保底费/件数 + 单件运费) - if (totalFreight.compareTo(new BigDecimal(minimumFee)) < 0) { - // 保底费/件数 + 单件运费 - BigDecimal divide = NumberUtil.div(new BigDecimal(minimumFee), totalNum); - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - value2.setDistributionCost(Convert.toStr(divide.add(new BigDecimal(value2.getDistributionCost())))); - } - } - } - } - } - // 是否附加费。是 计算附加费 - Integer ynSurcharge = rule.getYnSurcharge(); - if (NumberUtil.equals(ynSurcharge, BooleanZeroOneEnums.YES.getCode())) { - List addPriceList = priceVO.getAddPriceList(); - if (CollUtil.isNotEmpty(addPriceList)) { - Map addPriceMap = addPriceList.stream().collect(Collectors.toMap(ExpenseDispatchPriceCategoryVO::getCategoryId, v -> v)); - Set collect1 = value.stream().map(v -> v.getOrderPackageCode()).collect(Collectors.toSet()); - Map addvaluePackageMap = addvaluePackageService.findMapByPackageCode(collect1); - for (QualityDeliverEntity entity : value) { - if (ObjectUtil.isNotEmpty(entity.getCostCategoryId()) && addPriceMap.containsKey(entity.getCostCategoryId())) { - ExpenseDispatchPriceCategoryVO expenseDispatchPriceCategoryVO = addPriceMap.get(entity.getCostCategoryId()); - if (ObjectUtil.isNotEmpty(expenseDispatchPriceCategoryVO)) { - // 上楼费单价 - String stairsCharge = expenseDispatchPriceCategoryVO.getStairsCharge(); - // 分货费单价 - String cargoSplittingFee = expenseDispatchPriceCategoryVO.getCargoSplittingFee(); - // 平移费单价 - String translationFee = expenseDispatchPriceCategoryVO.getTranslationFee(); - // 装卸费单价 - String loadingUnloadingFee = expenseDispatchPriceCategoryVO.getLoadingUnloadingFee(); - // 上楼层数 - // 查询出上楼层数 - Integer stairsNumber = 0; - if (addvaluePackageMap.containsKey(entity.getOrderPackageCode())) { - stairsNumber = Convert.toInt(addvaluePackageMap.get(entity.getOrderPackageCode())); - } - // 签收数量 - Integer signNum = entity.getSignNum(); - if (ObjectUtil.isNotEmpty(signNum)) { - // 上楼费成本 = 上楼费单价 * 上楼层数 * 签收件数 - QualityDeliverEntity qualityDeliverEntity1 = valueMap.get(entity.getId()); - if (ObjectUtil.isNotEmpty(stairsNumber) && StrUtil.isNotEmpty(stairsCharge)) { - qualityDeliverEntity1.setApstairsCost(Convert.toStr(NumberUtil.mul(stairsNumber, new BigDecimal(stairsCharge)))); - } - // 分货费成本 = 分货费单价 * 签收件数 - if (StrUtil.isNotEmpty(cargoSplittingFee)) { - qualityDeliverEntity1.setApartCost(Convert.toStr(NumberUtil.mul(signNum, new BigDecimal(cargoSplittingFee)))); - } - // 平移费成本 = 平移费单价 * 签收件数 - if (StrUtil.isNotEmpty(translationFee)) { - qualityDeliverEntity1.setMoveCost(Convert.toStr(NumberUtil.mul(signNum, new BigDecimal(translationFee)))); - } - // 装卸费成本 = 装卸费单价 * 签收件数 - if (StrUtil.isNotEmpty(loadingUnloadingFee)) { - qualityDeliverEntity1.setStevedoreCost(Convert.toStr(NumberUtil.mul(signNum, new BigDecimal(loadingUnloadingFee)))); + // 判断是否触发保底 + Integer ynMinimumFee = rule.getYnMinimumFee(); + if (NumberUtil.equals(ynMinimumFee, BooleanZeroOneEnums.YES.getCode())) { + String minimumFee = priceVO.getMinimumFee(); + if (StrUtil.isNotEmpty(minimumFee)) { + // 总运费 < 保底费 触发保底 (保底费/件数) + if (totalFreight.compareTo(new BigDecimal(minimumFee)) < 0) { + // 保底费 = 保底费/件数 + BigDecimal divide = NumberUtil.div(new BigDecimal(minimumFee), totalNum); + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + value2.setGuarCost(Convert.toStr(divide)); } } } } } - } - } - // 是否公里数成本 是 计算成本 - Integer ynSubsidyKilometer = rule.getYnChargedKilometer(); - if (NumberUtil.equals(ynSubsidyKilometer, BooleanZeroOneEnums.YES.getCode())) { - initRule(value, allRouteMap, firstRouteMap); - Integer kilometerCalculationRule = rule.getKilometerCalculationRule(); - // 总公里数计算 - if (NumberUtil.equals(kilometerCalculationRule, 1)) { - BigDecimal total = BigDecimal.ZERO; - String lastCode = null; - if (CollUtil.isNotEmpty(allRouteMap)) { - for (Map.Entry allEntry : allRouteMap.entrySet()) { - String key = allEntry.getKey(); - lastCode = key; - if (StrUtil.isNotEmpty(allEntry.getValue())) { - total = NumberUtil.add(total, new BigDecimal(allEntry.getValue())); - } - } - } - // 是否计算返程 - Integer ynKilometerReturn = rule.getYnKilometerReturn(); - if (NumberUtil.equals(ynKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isNotEmpty(firstRouteMap)) { - String s = firstRouteMap.get(lastCode); - if (StrUtil.isNotEmpty(s)) { - total = total.add(new BigDecimal(s)); - } - } - } - // 总公里数成本 = (总公里数 * 总公里单价)/总件数 - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String kilometerCost = priceVO.getKilometerCost(); - if (StrUtil.isNotEmpty(kilometerCost)) { - value2.setKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(kilometerCost)), totalNum))); - } - } - } - // 点位公里数计算 - if (NumberUtil.equals(kilometerCalculationRule, 2)) { - BigDecimal total = BigDecimal.ZERO; - String lastCode = null; - if (CollUtil.isNotEmpty(firstRouteMap)) { - for (Map.Entry firstEntry : firstRouteMap.entrySet()) { - String value2 = firstEntry.getValue(); - lastCode = firstEntry.getKey(); - if (StrUtil.isNotEmpty(value2)) { - total = NumberUtil.add(total, new BigDecimal(value2)); - } - } - } - // 是否计算返程 - Integer ynKilometerReturn = rule.getYnKilometerReturn(); - if (NumberUtil.equals(ynKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isNotEmpty(firstRouteMap)) { - String s = firstRouteMap.get(lastCode); - if (StrUtil.isNotEmpty(s)) { - total = total.add(new BigDecimal(s)); - } - } - } - // 总公里数成本 = (总公里数 * 总公里单价)/总件数 - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String kilometerCost = priceVO.getKilometerCost(); - if (StrUtil.isNotEmpty(kilometerCost)) { - value2.setKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(kilometerCost)), totalNum))); - } - } - } - // 最大公里数计算 - if (NumberUtil.equals(kilometerCalculationRule, 3)) { - BigDecimal total = null; - String lastCode = null; - if (CollUtil.isNotEmpty(firstRouteMap)) { - for (Map.Entry firstEntry : firstRouteMap.entrySet()) { - String value2 = firstEntry.getValue(); - - if (StrUtil.isNotEmpty(value2)) { - // 比较大小 取最大的距离计算 记录最大距离客户的公里数用于计算返程 - if (ObjectUtil.isNotEmpty(total)) { - if (total.compareTo(new BigDecimal(value2)) < 0) { - total = new BigDecimal(value2); - lastCode = firstEntry.getKey(); + // 是否附加费。是 计算附加费 + Integer ynSurcharge = rule.getYnSurcharge(); + if (NumberUtil.equals(ynSurcharge, BooleanZeroOneEnums.YES.getCode())) { + List addPriceList = priceVO.getAddPriceList(); + if (CollUtil.isNotEmpty(addPriceList)) { + Map addPriceMap = addPriceList.stream().collect(Collectors.toMap(ExpenseDispatchPriceCategoryVO::getCategoryId, v -> v)); + Set collect1 = value.stream().map(v -> v.getOrderPackageCode()).collect(Collectors.toSet()); + Map addvaluePackageMap = addvaluePackageService.findMapByPackageCode(collect1); + for (QualityDeliverEntity entity : value) { + if (ObjectUtil.isNotEmpty(entity.getCostCategoryId()) && addPriceMap.containsKey(entity.getCostCategoryId())) { + ExpenseDispatchPriceCategoryVO expenseDispatchPriceCategoryVO = addPriceMap.get(entity.getCostCategoryId()); + if (ObjectUtil.isNotEmpty(expenseDispatchPriceCategoryVO)) { + // 上楼费单价 + String stairsCharge = expenseDispatchPriceCategoryVO.getStairsCharge(); + // 分货费单价 + String cargoSplittingFee = expenseDispatchPriceCategoryVO.getCargoSplittingFee(); + // 平移费单价 + String translationFee = expenseDispatchPriceCategoryVO.getTranslationFee(); + // 装卸费单价 + String loadingUnloadingFee = expenseDispatchPriceCategoryVO.getLoadingUnloadingFee(); + // 上楼层数 + // 查询出上楼层数 + Integer stairsNumber = 0; + if (addvaluePackageMap.containsKey(entity.getOrderPackageCode())) { + stairsNumber = Convert.toInt(addvaluePackageMap.get(entity.getOrderPackageCode())); + } + // 签收数量 + Integer signNum = entity.getSignNum(); + if (ObjectUtil.isNotEmpty(signNum)) { + // 上楼费成本 = 上楼费单价 * 上楼层数 * 签收件数 + QualityDeliverEntity qualityDeliverEntity1 = valueMap.get(entity.getId()); + if (ObjectUtil.isNotEmpty(stairsNumber) && StrUtil.isNotEmpty(stairsCharge)) { + qualityDeliverEntity1.setApstairsCost(Convert.toStr(NumberUtil.mul(stairsNumber, new BigDecimal(stairsCharge)))); + } + // 分货费成本 = 分货费单价 * 签收件数 + if (StrUtil.isNotEmpty(cargoSplittingFee)) { + qualityDeliverEntity1.setApartCost(Convert.toStr(NumberUtil.mul(signNum, new BigDecimal(cargoSplittingFee)))); + } + // 平移费成本 = 平移费单价 * 签收件数 + if (StrUtil.isNotEmpty(translationFee)) { + qualityDeliverEntity1.setMoveCost(Convert.toStr(NumberUtil.mul(signNum, new BigDecimal(translationFee)))); + } + // 装卸费成本 = 装卸费单价 * 签收件数 + if (StrUtil.isNotEmpty(loadingUnloadingFee)) { + qualityDeliverEntity1.setStevedoreCost(Convert.toStr(NumberUtil.mul(signNum, new BigDecimal(loadingUnloadingFee)))); + } + } } - } else { - total = new BigDecimal(value2); - lastCode = firstEntry.getKey(); } } } } - // 是否计算返程 - Integer ynKilometerReturn = rule.getYnKilometerReturn(); - if (NumberUtil.equals(ynKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isNotEmpty(firstRouteMap)) { - String s = firstRouteMap.get(lastCode); - if (StrUtil.isNotEmpty(s)) { - total = total.add(new BigDecimal(s)); - } - } - } - // 总公里数成本 = (总公里数 * 总公里单价)/总件数 - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String kilometerCost = priceVO.getKilometerCost(); - if (StrUtil.isNotEmpty(kilometerCost)) { - value2.setKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(kilometerCost)), totalNum))); - } - } - } - } - - // 是否补贴起步公里数成本 是 计算成本 - Integer ynSubsidyInitKilometerBill = rule.getYnSubsidyInitKilometerBill(); - if (NumberUtil.equals(ynSubsidyInitKilometerBill, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isEmpty(allRouteMap) || CollUtil.isEmpty(firstRouteMap)) { - initRule(value, allRouteMap, firstRouteMap); - } - Integer subsidyKilometerRule = rule.getSubsidyKilometerRule(); - // 总公里数计算 - if (NumberUtil.equals(subsidyKilometerRule, 1)) { - BigDecimal total = BigDecimal.ZERO; - String lastCode = null; - if (CollUtil.isNotEmpty(allRouteMap)) { - for (Map.Entry allEntry : allRouteMap.entrySet()) { - String key = allEntry.getKey(); - lastCode = key; - if (StrUtil.isNotEmpty(allEntry.getValue())) { - total = NumberUtil.add(total, new BigDecimal(allEntry.getValue())); + // 是否公里数成本 是 计算成本 + Integer ynSubsidyKilometer = rule.getYnChargedKilometer(); + if (NumberUtil.equals(ynSubsidyKilometer, BooleanZeroOneEnums.YES.getCode())) { + initRule(value, allRouteMap, firstRouteMap); + Integer kilometerCalculationRule = rule.getKilometerCalculationRule(); + // 总公里数计算 + if (NumberUtil.equals(kilometerCalculationRule, 1)) { + BigDecimal total = BigDecimal.ZERO; + String lastCode = null; + if (CollUtil.isNotEmpty(allRouteMap)) { + for (Map.Entry allEntry : allRouteMap.entrySet()) { + String key = allEntry.getKey(); + lastCode = key; + if (StrUtil.isNotEmpty(allEntry.getValue())) { + total = NumberUtil.add(total, new BigDecimal(allEntry.getValue())); + } + } } - } - } - // 是否计算返程 - Integer ynSubsidyKilometerReturn = rule.getYnSubsidyKilometerReturn(); - if (NumberUtil.equals(ynSubsidyKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isNotEmpty(firstRouteMap)) { - String s = firstRouteMap.get(lastCode); - if (StrUtil.isNotEmpty(s)) { - total = total.add(new BigDecimal(s)); + // 是否计算返程 + Integer ynKilometerReturn = rule.getYnKilometerReturn(); + if (NumberUtil.equals(ynKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isNotEmpty(firstRouteMap)) { + String s = firstRouteMap.get(lastCode); + if (StrUtil.isNotEmpty(s)) { + total = total.add(new BigDecimal(s)); + } + } } - } - } - // 判断是否达到补贴条件 - String subsidyInitKilometer = priceVO.getSubsidyInitKilometer(); - if (StrUtil.isNotEmpty(subsidyInitKilometer)) { - if (total.compareTo(new BigDecimal(subsidyInitKilometer)) > 0) { - // 总公里数成本 = ((总公里数 - 补贴公里数) * 补贴单价) / 总件数 + // 总公里数成本 = (总公里数 * 总公里单价)/总件数 for (Map.Entry entityEntry : valueMap.entrySet()) { QualityDeliverEntity value2 = entityEntry.getValue(); - String subsidyCost = priceVO.getSubsidyCost(); - if (StrUtil.isNotEmpty(subsidyCost)) { - value2.setAllowKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(subsidyInitKilometer)), new BigDecimal(subsidyCost)), totalNum))); + String kilometerCost = priceVO.getKilometerCost(); + if (StrUtil.isNotEmpty(kilometerCost)) { + value2.setKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(kilometerCost)), totalNum))); } } } - } - } - // 点位公里数计算 - if (NumberUtil.equals(subsidyKilometerRule, 2)) { - BigDecimal total = BigDecimal.ZERO; - String lastCode = null; - if (CollUtil.isNotEmpty(firstRouteMap)) { - for (Map.Entry firstEntry : firstRouteMap.entrySet()) { - String value2 = firstEntry.getValue(); - lastCode = firstEntry.getKey(); - if (StrUtil.isNotEmpty(value2)) { - total = NumberUtil.add(total, new BigDecimal(value2)); + // 点位公里数计算 + if (NumberUtil.equals(kilometerCalculationRule, 2)) { + BigDecimal total = BigDecimal.ZERO; + String lastCode = null; + if (CollUtil.isNotEmpty(firstRouteMap)) { + for (Map.Entry firstEntry : firstRouteMap.entrySet()) { + String value2 = firstEntry.getValue(); + lastCode = firstEntry.getKey(); + if (StrUtil.isNotEmpty(value2)) { + total = NumberUtil.add(total, new BigDecimal(value2)); + } + } } - } - } - // 是否计算返程 - Integer ynSubsidyKilometerReturn = rule.getYnSubsidyKilometerReturn(); - if (NumberUtil.equals(ynSubsidyKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isNotEmpty(firstRouteMap)) { - String s = firstRouteMap.get(lastCode); - if (StrUtil.isNotEmpty(s)) { - total = total.add(new BigDecimal(s)); + // 是否计算返程 + Integer ynKilometerReturn = rule.getYnKilometerReturn(); + if (NumberUtil.equals(ynKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isNotEmpty(firstRouteMap)) { + String s = firstRouteMap.get(lastCode); + if (StrUtil.isNotEmpty(s)) { + total = total.add(new BigDecimal(s)); + } + } } - } - } - // 判断是否达到补贴条件 - String subsidyInitKilometer = priceVO.getSubsidyInitKilometer(); - if (StrUtil.isNotEmpty(subsidyInitKilometer)) { - if (total.compareTo(new BigDecimal(subsidyInitKilometer)) > 0) { - // 总公里数成本 = ((总公里数 - 补贴公里数) * 补贴单价) / 总件数 + // 总公里数成本 = (总公里数 * 总公里单价)/总件数 for (Map.Entry entityEntry : valueMap.entrySet()) { QualityDeliverEntity value2 = entityEntry.getValue(); - String subsidyCost = priceVO.getSubsidyCost(); - if (StrUtil.isNotEmpty(subsidyCost)) { - value2.setAllowKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(subsidyInitKilometer)), new BigDecimal(subsidyCost)), totalNum))); + String kilometerCost = priceVO.getKilometerCost(); + if (StrUtil.isNotEmpty(kilometerCost)) { + value2.setKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(kilometerCost)), totalNum))); } } } - } - } - // 最大公里数计算 - if (NumberUtil.equals(subsidyKilometerRule, 3)) { - BigDecimal total = null; - String lastCode = null; - if (CollUtil.isNotEmpty(firstRouteMap)) { - for (Map.Entry firstEntry : firstRouteMap.entrySet()) { - String value2 = firstEntry.getValue(); + // 最大公里数计算 + if (NumberUtil.equals(kilometerCalculationRule, 3)) { + BigDecimal total = null; + String lastCode = null; + if (CollUtil.isNotEmpty(firstRouteMap)) { + for (Map.Entry firstEntry : firstRouteMap.entrySet()) { + String value2 = firstEntry.getValue(); - if (StrUtil.isNotEmpty(value2)) { - // 比较大小 - if (ObjectUtil.isNotEmpty(total)) { - if (total.compareTo(new BigDecimal(value2)) < 0) { - total = new BigDecimal(value2); - lastCode = firstEntry.getKey(); + if (StrUtil.isNotEmpty(value2)) { + // 比较大小 取最大的距离计算 记录最大距离客户的公里数用于计算返程 + if (ObjectUtil.isNotEmpty(total)) { + if (total.compareTo(new BigDecimal(value2)) < 0) { + total = new BigDecimal(value2); + lastCode = firstEntry.getKey(); + } + } else { + total = new BigDecimal(value2); + lastCode = firstEntry.getKey(); + } } - } else { - total = new BigDecimal(value2); - lastCode = firstEntry.getKey(); } } - } - } - // 是否计算返程 - Integer ynSubsidyKilometerReturn = rule.getYnSubsidyKilometerReturn(); - if (NumberUtil.equals(ynSubsidyKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isNotEmpty(firstRouteMap)) { - String s = firstRouteMap.get(lastCode); - if (StrUtil.isNotEmpty(s)) { - total = total.add(new BigDecimal(s)); + // 是否计算返程 + Integer ynKilometerReturn = rule.getYnKilometerReturn(); + if (NumberUtil.equals(ynKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isNotEmpty(firstRouteMap)) { + String s = firstRouteMap.get(lastCode); + if (StrUtil.isNotEmpty(s)) { + total = total.add(new BigDecimal(s)); + } + } } - } - } - // 判断是否达到补贴条件 - String subsidyInitKilometer = priceVO.getSubsidyInitKilometer(); - if (StrUtil.isNotEmpty(subsidyInitKilometer)) { - if (total.compareTo(new BigDecimal(subsidyInitKilometer)) > 0) { - // 总公里数成本 = ((总公里数 - 补贴公里数) * 补贴单价) / 总件数 + // 总公里数成本 = (总公里数 * 总公里单价)/总件数 for (Map.Entry entityEntry : valueMap.entrySet()) { QualityDeliverEntity value2 = entityEntry.getValue(); - String subsidyCost = priceVO.getSubsidyCost(); - if (StrUtil.isNotEmpty(subsidyCost)) { - value2.setAllowKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(subsidyInitKilometer)), new BigDecimal(subsidyCost)), totalNum))); + String kilometerCost = priceVO.getKilometerCost(); + if (StrUtil.isNotEmpty(kilometerCost)) { + value2.setKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(kilometerCost)), totalNum))); } } } } - } - } - // 是否超区公里数计费 是 计算成本 - Integer ynOverZoneKilometer = rule.getYnOverZoneKilometer(); - if (NumberUtil.equals(ynOverZoneKilometer, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isEmpty(allRouteMap) || CollUtil.isEmpty(firstRouteMap)) { - initRule(value, allRouteMap, firstRouteMap); - } - Integer overZoneKilometerRule = rule.getOverZoneKilometerRule(); - // 总公里数计算 - if (NumberUtil.equals(overZoneKilometerRule, 1)) { - BigDecimal total = BigDecimal.ZERO; - String lastCode = null; - // 超区公里计费模式 统一/区域 - Integer overZoneSiteMode = rule.getOverZoneSiteMode(); - if (NumberUtil.equals(overZoneSiteMode, 1)) { - if (CollUtil.isNotEmpty(allRouteMap)) { - for (Map.Entry allEntry : allRouteMap.entrySet()) { - String key = allEntry.getKey(); - lastCode = key; - if (StrUtil.isNotEmpty(allEntry.getValue())) { - total = NumberUtil.add(total, new BigDecimal(allEntry.getValue())); - } - } - } - // 总公里数成本 = ((总公里数 - 超区公里数)*超区公里单价)/总件数 - String overZoneKilometer = priceVO.getOverZoneKilometer(); - if (StrUtil.isNotEmpty(overZoneKilometer)) { - if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) { - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String overZoneKilometerCost = priceVO.getOverZoneKilometerCost(); - if (StrUtil.isNotEmpty(overZoneKilometer) && StrUtil.isNotEmpty(overZoneKilometerCost)) { - value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneKilometerCost)), totalNum))); + // 是否补贴起步公里数成本 是 计算成本 + Integer ynSubsidyInitKilometerBill = rule.getYnSubsidyInitKilometerBill(); + if (NumberUtil.equals(ynSubsidyInitKilometerBill, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isEmpty(allRouteMap) || CollUtil.isEmpty(firstRouteMap)) { + initRule(value, allRouteMap, firstRouteMap); + } + Integer subsidyKilometerRule = rule.getSubsidyKilometerRule(); + // 总公里数计算 + if (NumberUtil.equals(subsidyKilometerRule, 1)) { + BigDecimal total = BigDecimal.ZERO; + String lastCode = null; + if (CollUtil.isNotEmpty(allRouteMap)) { + for (Map.Entry allEntry : allRouteMap.entrySet()) { + String key = allEntry.getKey(); + lastCode = key; + if (StrUtil.isNotEmpty(allEntry.getValue())) { + total = NumberUtil.add(total, new BigDecimal(allEntry.getValue())); } } } - } - } - } - // 点位公里数计算 - if (NumberUtil.equals(overZoneKilometerRule, 2)) { - // 超区公里计费模式 统一/区域 - Integer overZoneSiteMode = rule.getOverZoneSiteMode(); - // 统一计费 - if (NumberUtil.equals(overZoneSiteMode, 1)) { - BigDecimal total = BigDecimal.ZERO; - String lastCode = null; - if (CollUtil.isNotEmpty(firstRouteMap)) { - for (Map.Entry firstEntry : firstRouteMap.entrySet()) { - String value2 = firstEntry.getValue(); - lastCode = firstEntry.getKey(); - if (StrUtil.isNotEmpty(value2)) { - total = NumberUtil.add(total, new BigDecimal(value2)); + // 是否计算返程 + Integer ynSubsidyKilometerReturn = rule.getYnSubsidyKilometerReturn(); + if (NumberUtil.equals(ynSubsidyKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isNotEmpty(firstRouteMap)) { + String s = firstRouteMap.get(lastCode); + if (StrUtil.isNotEmpty(s)) { + total = total.add(new BigDecimal(s)); + } } } - } - // 总公里数成本 = ((总公里数 - 超区公里数)*超区公里单价)/总件数 - String overZoneKilometer = priceVO.getOverZoneKilometer(); - if (StrUtil.isNotEmpty(overZoneKilometer)) { - if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) { - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String overZoneKilometerCost = priceVO.getOverZoneKilometerCost(); - if (StrUtil.isNotEmpty(overZoneKilometer) && StrUtil.isNotEmpty(overZoneKilometerCost)) { - value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneKilometerCost)), totalNum))); + // 判断是否达到补贴条件 + String subsidyInitKilometer = priceVO.getSubsidyInitKilometer(); + if (StrUtil.isNotEmpty(subsidyInitKilometer)) { + if (total.compareTo(new BigDecimal(subsidyInitKilometer)) > 0) { + // 总公里数成本 = ((总公里数 - 补贴公里数) * 补贴单价) / 总件数 + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String subsidyCost = priceVO.getSubsidyCost(); + if (StrUtil.isNotEmpty(subsidyCost)) { + value2.setAllowKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(subsidyInitKilometer)), new BigDecimal(subsidyCost)), totalNum))); + } } } } } - } - // 按区域计费 - if (NumberUtil.equals(overZoneSiteMode, 2)) { - if (CollUtil.isNotEmpty(overZoneEntityMap)) { - // 超区公里总费用 + // 点位公里数计算 + if (NumberUtil.equals(subsidyKilometerRule, 2)) { BigDecimal total = BigDecimal.ZERO; + String lastCode = null; if (CollUtil.isNotEmpty(firstRouteMap)) { for (Map.Entry firstEntry : firstRouteMap.entrySet()) { - String key = firstEntry.getKey(); - QualityDeliverEntity qualityDeliverEntity1 = pointMap.get(key); - if (ObjectUtil.isNotEmpty(qualityDeliverEntity1)) { - ExpenseDispatchPriceOverZoneEntity expenseDispatchPriceOverZoneEntity = overZoneEntityMap.get(qualityDeliverEntity1.getArriveProvince() + qualityDeliverEntity1.getArriveCity() + qualityDeliverEntity1.getArriveDistrict()); - String overZoneKilometer = expenseDispatchPriceOverZoneEntity.getOverZoneKilometer(); - String overZoneCost = expenseDispatchPriceOverZoneEntity.getOverZoneCost(); - String value2 = firstEntry.getValue(); - if (StrUtil.isNotEmpty(value2)) { - if (new BigDecimal(value2).compareTo(new BigDecimal(overZoneKilometer)) > 0) { - if (StrUtil.isNotEmpty(overZoneCost)) { - total = NumberUtil.mul(NumberUtil.sub(new BigDecimal(value2), new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneCost)); - } - } - } + String value2 = firstEntry.getValue(); + lastCode = firstEntry.getKey(); + if (StrUtil.isNotEmpty(value2)) { + total = NumberUtil.add(total, new BigDecimal(value2)); } - } } - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(total, totalNum))); - } - } - } - } - // 最大公里数计算 - if (NumberUtil.equals(overZoneKilometerRule, 3)) { - Integer overZoneSiteMode = rule.getOverZoneSiteMode(); - if (NumberUtil.equals(overZoneSiteMode, 1)) { - BigDecimal total = null; - String lastCode = null; - if (CollUtil.isNotEmpty(firstRouteMap)) { - for (Map.Entry firstEntry : firstRouteMap.entrySet()) { - String value2 = firstEntry.getValue(); - if (StrUtil.isNotEmpty(value2)) { - // 比较大小 取最大的距离计算 记录最大距离客户的公里数用于计算返程 - if (ObjectUtil.isNotEmpty(total)) { - if (total.compareTo(new BigDecimal(value2)) < 0) { - total = new BigDecimal(value2); - lastCode = firstEntry.getKey(); - } - } else { - total = new BigDecimal(value2); - lastCode = firstEntry.getKey(); + // 是否计算返程 + Integer ynSubsidyKilometerReturn = rule.getYnSubsidyKilometerReturn(); + if (NumberUtil.equals(ynSubsidyKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isNotEmpty(firstRouteMap)) { + String s = firstRouteMap.get(lastCode); + if (StrUtil.isNotEmpty(s)) { + total = total.add(new BigDecimal(s)); } } } - } - // 总公里数成本 = (总公里数 * 总公里单价)/总件数 - String overZoneKilometer = priceVO.getOverZoneKilometer(); - if (StrUtil.isNotEmpty(overZoneKilometer)) { - if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) { - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String overZoneKilometerCost = priceVO.getOverZoneKilometerCost(); - if (StrUtil.isNotEmpty(overZoneKilometer) && StrUtil.isNotEmpty(overZoneKilometerCost)) { - value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneKilometerCost)), totalNum))); + // 判断是否达到补贴条件 + String subsidyInitKilometer = priceVO.getSubsidyInitKilometer(); + if (StrUtil.isNotEmpty(subsidyInitKilometer)) { + if (total.compareTo(new BigDecimal(subsidyInitKilometer)) > 0) { + // 总公里数成本 = ((总公里数 - 补贴公里数) * 补贴单价) / 总件数 + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String subsidyCost = priceVO.getSubsidyCost(); + if (StrUtil.isNotEmpty(subsidyCost)) { + value2.setAllowKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(subsidyInitKilometer)), new BigDecimal(subsidyCost)), totalNum))); + } } } } } - } - // 按区域计费 - if (NumberUtil.equals(overZoneSiteMode, 2)) { - if (CollUtil.isNotEmpty(overZoneEntityMap)) { + // 最大公里数计算 + if (NumberUtil.equals(subsidyKilometerRule, 3)) { BigDecimal total = null; String lastCode = null; if (CollUtil.isNotEmpty(firstRouteMap)) { @@ -700,160 +538,351 @@ public class DeliverFinishReportListener { } } } - // 超区公里总费用 - if (CollUtil.isNotEmpty(firstRouteMap)) { - QualityDeliverEntity qualityDeliverEntity1 = pointMap.get(lastCode); - if (ObjectUtil.isNotEmpty(qualityDeliverEntity1)) { - ExpenseDispatchPriceOverZoneEntity expenseDispatchPriceOverZoneEntity = overZoneEntityMap.get(qualityDeliverEntity1.getArriveProvince() + qualityDeliverEntity1.getArriveCity() + qualityDeliverEntity1.getArriveDistrict()); - String overZoneKilometer = expenseDispatchPriceOverZoneEntity.getOverZoneKilometer(); - String overZoneCost = expenseDispatchPriceOverZoneEntity.getOverZoneCost(); - if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) { - if (StrUtil.isNotEmpty(overZoneCost)) { - total = NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneCost)); - } + // 是否计算返程 + Integer ynSubsidyKilometerReturn = rule.getYnSubsidyKilometerReturn(); + if (NumberUtil.equals(ynSubsidyKilometerReturn, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isNotEmpty(firstRouteMap)) { + String s = firstRouteMap.get(lastCode); + if (StrUtil.isNotEmpty(s)) { + total = total.add(new BigDecimal(s)); } } } - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(total, totalNum))); + // 判断是否达到补贴条件 + String subsidyInitKilometer = priceVO.getSubsidyInitKilometer(); + if (StrUtil.isNotEmpty(subsidyInitKilometer)) { + if (total.compareTo(new BigDecimal(subsidyInitKilometer)) > 0) { + // 总公里数成本 = ((总公里数 - 补贴公里数) * 补贴单价) / 总件数 + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String subsidyCost = priceVO.getSubsidyCost(); + if (StrUtil.isNotEmpty(subsidyCost)) { + value2.setAllowKiloAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(subsidyInitKilometer)), new BigDecimal(subsidyCost)), totalNum))); + } + } + } } } } - } - } - // 是否点位补贴成本 是 计算成本 - Integer ynSiteSubsidy = rule.getYnSiteSubsidy(); - if (NumberUtil.equals(ynSiteSubsidy, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isEmpty(allRouteMap) || CollUtil.isEmpty(firstRouteMap)) { - initRule(value, allRouteMap, firstRouteMap); - } - Set longs = valueMap.keySet(); - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String siteSubsidyCost = priceVO.getSiteSubsidyCost(); - if (StrUtil.isNotEmpty(siteSubsidyCost)) { - value2.setPointAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(longs.size(), new BigDecimal(siteSubsidyCost)), totalNum))); - } - } - } + // 是否超区公里数计费 是 计算成本 + Integer ynOverZoneKilometer = rule.getYnOverZoneKilometer(); + if (NumberUtil.equals(ynOverZoneKilometer, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isEmpty(allRouteMap) || CollUtil.isEmpty(firstRouteMap)) { + initRule(value, allRouteMap, firstRouteMap); + } + Integer overZoneKilometerRule = rule.getOverZoneKilometerRule(); + // 总公里数计算 + if (NumberUtil.equals(overZoneKilometerRule, 1)) { + BigDecimal total = BigDecimal.ZERO; + String lastCode = null; + // 超区公里计费模式 统一/区域 + Integer overZoneSiteMode = rule.getOverZoneSiteMode(); + if (NumberUtil.equals(overZoneSiteMode, 1)) { + if (CollUtil.isNotEmpty(allRouteMap)) { + for (Map.Entry allEntry : allRouteMap.entrySet()) { + String key = allEntry.getKey(); + lastCode = key; + if (StrUtil.isNotEmpty(allEntry.getValue())) { + total = NumberUtil.add(total, new BigDecimal(allEntry.getValue())); + } + } + } + // 总公里数成本 = ((总公里数 - 超区公里数)*超区公里单价)/总件数 + String overZoneKilometer = priceVO.getOverZoneKilometer(); + if (StrUtil.isNotEmpty(overZoneKilometer)) { + if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) { + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String overZoneKilometerCost = priceVO.getOverZoneKilometerCost(); + if (StrUtil.isNotEmpty(overZoneKilometer) && StrUtil.isNotEmpty(overZoneKilometerCost)) { + value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneKilometerCost)), totalNum))); + } + } + } + } + } + } + // 点位公里数计算 + if (NumberUtil.equals(overZoneKilometerRule, 2)) { + // 超区公里计费模式 统一/区域 + Integer overZoneSiteMode = rule.getOverZoneSiteMode(); + // 统一计费 + if (NumberUtil.equals(overZoneSiteMode, 1)) { + BigDecimal total = BigDecimal.ZERO; + String lastCode = null; + if (CollUtil.isNotEmpty(firstRouteMap)) { + for (Map.Entry firstEntry : firstRouteMap.entrySet()) { + String value2 = firstEntry.getValue(); + lastCode = firstEntry.getKey(); + if (StrUtil.isNotEmpty(value2)) { + total = NumberUtil.add(total, new BigDecimal(value2)); + } + } + } + // 总公里数成本 = ((总公里数 - 超区公里数)*超区公里单价)/总件数 + String overZoneKilometer = priceVO.getOverZoneKilometer(); + if (StrUtil.isNotEmpty(overZoneKilometer)) { + if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) { + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String overZoneKilometerCost = priceVO.getOverZoneKilometerCost(); + if (StrUtil.isNotEmpty(overZoneKilometer) && StrUtil.isNotEmpty(overZoneKilometerCost)) { + value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneKilometerCost)), totalNum))); + } + } + } + } + } + // 按区域计费 + if (NumberUtil.equals(overZoneSiteMode, 2)) { + if (CollUtil.isNotEmpty(overZoneEntityMap)) { + // 超区公里总费用 + BigDecimal total = BigDecimal.ZERO; + if (CollUtil.isNotEmpty(firstRouteMap)) { + for (Map.Entry firstEntry : firstRouteMap.entrySet()) { + String key = firstEntry.getKey(); + QualityDeliverEntity qualityDeliverEntity1 = pointMap.get(key); + if (ObjectUtil.isNotEmpty(qualityDeliverEntity1)) { + ExpenseDispatchPriceOverZoneEntity expenseDispatchPriceOverZoneEntity = overZoneEntityMap.get(qualityDeliverEntity1.getArriveProvince() + qualityDeliverEntity1.getArriveCity() + qualityDeliverEntity1.getArriveDistrict()); + String overZoneKilometer = expenseDispatchPriceOverZoneEntity.getOverZoneKilometer(); + String overZoneCost = expenseDispatchPriceOverZoneEntity.getOverZoneCost(); + String value2 = firstEntry.getValue(); + if (StrUtil.isNotEmpty(value2)) { + if (new BigDecimal(value2).compareTo(new BigDecimal(overZoneKilometer)) > 0) { + if (StrUtil.isNotEmpty(overZoneCost)) { + total = NumberUtil.mul(NumberUtil.sub(new BigDecimal(value2), new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneCost)); + } + } + } + } - // 是否补贴油费 是 计算成本 - Integer ynSubsidyFuelCost = rule.getYnSubsidyFuelCost(); - if (NumberUtil.equals(ynSubsidyFuelCost, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isEmpty(allRouteMap) || CollUtil.isEmpty(firstRouteMap)) { - initRule(value, allRouteMap, firstRouteMap); - } - Integer subsidyFuelCostRule = rule.getSubsidyFuelCostRule(); - // 总公里数计算 - if (NumberUtil.equals(subsidyFuelCostRule, 1)) { - BigDecimal total = BigDecimal.ZERO; - String lastCode = null; - if (CollUtil.isNotEmpty(allRouteMap)) { - for (Map.Entry allEntry : allRouteMap.entrySet()) { - String key = allEntry.getKey(); - lastCode = key; - if (StrUtil.isNotEmpty(allEntry.getValue())) { - total = NumberUtil.add(total, new BigDecimal(allEntry.getValue())); + } + } + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(total, totalNum))); + } + } } } - } - // 是否计算返程 - Integer ynSubsidyFuelCostReturn = rule.getYnSubsidyFuelCostReturn(); - if (NumberUtil.equals(ynSubsidyFuelCostReturn, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isNotEmpty(firstRouteMap)) { - String s = firstRouteMap.get(lastCode); - if (StrUtil.isNotEmpty(s)) { - total = total.add(new BigDecimal(s)); + // 最大公里数计算 + if (NumberUtil.equals(overZoneKilometerRule, 3)) { + Integer overZoneSiteMode = rule.getOverZoneSiteMode(); + if (NumberUtil.equals(overZoneSiteMode, 1)) { + BigDecimal total = null; + String lastCode = null; + if (CollUtil.isNotEmpty(firstRouteMap)) { + for (Map.Entry firstEntry : firstRouteMap.entrySet()) { + String value2 = firstEntry.getValue(); + if (StrUtil.isNotEmpty(value2)) { + // 比较大小 取最大的距离计算 记录最大距离客户的公里数用于计算返程 + if (ObjectUtil.isNotEmpty(total)) { + if (total.compareTo(new BigDecimal(value2)) < 0) { + total = new BigDecimal(value2); + lastCode = firstEntry.getKey(); + } + } else { + total = new BigDecimal(value2); + lastCode = firstEntry.getKey(); + } + } + } + } + // 总公里数成本 = (总公里数 * 总公里单价)/总件数 + String overZoneKilometer = priceVO.getOverZoneKilometer(); + if (StrUtil.isNotEmpty(overZoneKilometer)) { + if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) { + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String overZoneKilometerCost = priceVO.getOverZoneKilometerCost(); + if (StrUtil.isNotEmpty(overZoneKilometer) && StrUtil.isNotEmpty(overZoneKilometerCost)) { + value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneKilometerCost)), totalNum))); + } + } + } + } + } + // 按区域计费 + if (NumberUtil.equals(overZoneSiteMode, 2)) { + if (CollUtil.isNotEmpty(overZoneEntityMap)) { + BigDecimal total = null; + String lastCode = null; + if (CollUtil.isNotEmpty(firstRouteMap)) { + for (Map.Entry firstEntry : firstRouteMap.entrySet()) { + String value2 = firstEntry.getValue(); + + if (StrUtil.isNotEmpty(value2)) { + // 比较大小 + if (ObjectUtil.isNotEmpty(total)) { + if (total.compareTo(new BigDecimal(value2)) < 0) { + total = new BigDecimal(value2); + lastCode = firstEntry.getKey(); + } + } else { + total = new BigDecimal(value2); + lastCode = firstEntry.getKey(); + } + } + } + } + // 超区公里总费用 + if (CollUtil.isNotEmpty(firstRouteMap)) { + QualityDeliverEntity qualityDeliverEntity1 = pointMap.get(lastCode); + if (ObjectUtil.isNotEmpty(qualityDeliverEntity1)) { + ExpenseDispatchPriceOverZoneEntity expenseDispatchPriceOverZoneEntity = overZoneEntityMap.get(qualityDeliverEntity1.getArriveProvince() + qualityDeliverEntity1.getArriveCity() + qualityDeliverEntity1.getArriveDistrict()); + String overZoneKilometer = expenseDispatchPriceOverZoneEntity.getOverZoneKilometer(); + String overZoneCost = expenseDispatchPriceOverZoneEntity.getOverZoneCost(); + if (total.compareTo(new BigDecimal(overZoneKilometer)) > 0) { + if (StrUtil.isNotEmpty(overZoneCost)) { + total = NumberUtil.mul(NumberUtil.sub(total, new BigDecimal(overZoneKilometer)), new BigDecimal(overZoneCost)); + } + } + } + } + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + value2.setUltrAllpwCost(Convert.toStr(NumberUtil.div(total, totalNum))); + } + } } } } - // 总公里数成本 = (总公里数 * 油费单价) / 总件数 - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String subsidyCost = priceVO.getSubsidyCost(); - if (StrUtil.isNotEmpty(subsidyCost)) { - value2.setFuelCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(subsidyCost)), totalNum))); + + // 是否点位补贴成本 是 计算成本 + Integer ynSiteSubsidy = rule.getYnSiteSubsidy(); + if (NumberUtil.equals(ynSiteSubsidy, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isEmpty(allRouteMap) || CollUtil.isEmpty(firstRouteMap)) { + initRule(value, allRouteMap, firstRouteMap); } - } - } - // 点位公里数计算 - if (NumberUtil.equals(subsidyFuelCostRule, 2)) { - BigDecimal total = BigDecimal.ZERO; - String lastCode = null; - if (CollUtil.isNotEmpty(firstRouteMap)) { - for (Map.Entry firstEntry : firstRouteMap.entrySet()) { - String value2 = firstEntry.getValue(); - lastCode = firstEntry.getKey(); - if (StrUtil.isNotEmpty(value2)) { - total = NumberUtil.add(total, new BigDecimal(value2)); + Set longs = valueMap.keySet(); + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String siteSubsidyCost = priceVO.getSiteSubsidyCost(); + if (StrUtil.isNotEmpty(siteSubsidyCost)) { + value2.setPointAllowCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(longs.size(), new BigDecimal(siteSubsidyCost)), totalNum))); } } } - // 是否计算返程 - Integer ynSubsidyFuelCostReturn = rule.getYnSubsidyFuelCostReturn(); - if (NumberUtil.equals(ynSubsidyFuelCostReturn, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isNotEmpty(firstRouteMap)) { - String s = firstRouteMap.get(lastCode); - if (StrUtil.isNotEmpty(s)) { - total = total.add(new BigDecimal(s)); + + // 是否补贴油费 是 计算成本 + Integer ynSubsidyFuelCost = rule.getYnSubsidyFuelCost(); + if (NumberUtil.equals(ynSubsidyFuelCost, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isEmpty(allRouteMap) || CollUtil.isEmpty(firstRouteMap)) { + initRule(value, allRouteMap, firstRouteMap); + } + Integer subsidyFuelCostRule = rule.getSubsidyFuelCostRule(); + // 总公里数计算 + if (NumberUtil.equals(subsidyFuelCostRule, 1)) { + BigDecimal total = BigDecimal.ZERO; + String lastCode = null; + if (CollUtil.isNotEmpty(allRouteMap)) { + for (Map.Entry allEntry : allRouteMap.entrySet()) { + String key = allEntry.getKey(); + lastCode = key; + if (StrUtil.isNotEmpty(allEntry.getValue())) { + total = NumberUtil.add(total, new BigDecimal(allEntry.getValue())); + } + } + } + // 是否计算返程 + Integer ynSubsidyFuelCostReturn = rule.getYnSubsidyFuelCostReturn(); + if (NumberUtil.equals(ynSubsidyFuelCostReturn, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isNotEmpty(firstRouteMap)) { + String s = firstRouteMap.get(lastCode); + if (StrUtil.isNotEmpty(s)) { + total = total.add(new BigDecimal(s)); + } + } + } + // 总公里数成本 = (总公里数 * 油费单价) / 总件数 + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String subsidyCost = priceVO.getSubsidyCost(); + if (StrUtil.isNotEmpty(subsidyCost)) { + value2.setFuelCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(subsidyCost)), totalNum))); + } } } - } - // 总公里数成本 = (总公里数 * 油费单价) / 总件数 - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String subsidyCost = priceVO.getSubsidyCost(); - if (StrUtil.isNotEmpty(subsidyCost)) { - value2.setFuelCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(subsidyCost)), totalNum))); + // 点位公里数计算 + if (NumberUtil.equals(subsidyFuelCostRule, 2)) { + BigDecimal total = BigDecimal.ZERO; + String lastCode = null; + if (CollUtil.isNotEmpty(firstRouteMap)) { + for (Map.Entry firstEntry : firstRouteMap.entrySet()) { + String value2 = firstEntry.getValue(); + lastCode = firstEntry.getKey(); + if (StrUtil.isNotEmpty(value2)) { + total = NumberUtil.add(total, new BigDecimal(value2)); + } + } + } + // 是否计算返程 + Integer ynSubsidyFuelCostReturn = rule.getYnSubsidyFuelCostReturn(); + if (NumberUtil.equals(ynSubsidyFuelCostReturn, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isNotEmpty(firstRouteMap)) { + String s = firstRouteMap.get(lastCode); + if (StrUtil.isNotEmpty(s)) { + total = total.add(new BigDecimal(s)); + } + } + } + // 总公里数成本 = (总公里数 * 油费单价) / 总件数 + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String subsidyCost = priceVO.getSubsidyCost(); + if (StrUtil.isNotEmpty(subsidyCost)) { + value2.setFuelCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(subsidyCost)), totalNum))); + } + } } - } - } - // 最大公里数计算 - if (NumberUtil.equals(subsidyFuelCostRule, 3)) { - BigDecimal total = null; - String lastCode = null; - if (CollUtil.isNotEmpty(firstRouteMap)) { - for (Map.Entry firstEntry : firstRouteMap.entrySet()) { - String value2 = firstEntry.getValue(); + // 最大公里数计算 + if (NumberUtil.equals(subsidyFuelCostRule, 3)) { + BigDecimal total = null; + String lastCode = null; + if (CollUtil.isNotEmpty(firstRouteMap)) { + for (Map.Entry firstEntry : firstRouteMap.entrySet()) { + String value2 = firstEntry.getValue(); - if (StrUtil.isNotEmpty(value2)) { - // 比较大小 - if (ObjectUtil.isNotEmpty(total)) { - if (total.compareTo(new BigDecimal(value2)) < 0) { - total = new BigDecimal(value2); - lastCode = firstEntry.getKey(); + if (StrUtil.isNotEmpty(value2)) { + // 比较大小 + if (ObjectUtil.isNotEmpty(total)) { + if (total.compareTo(new BigDecimal(value2)) < 0) { + total = new BigDecimal(value2); + lastCode = firstEntry.getKey(); + } + } else { + total = new BigDecimal(value2); + lastCode = firstEntry.getKey(); + } } - } else { - total = new BigDecimal(value2); - lastCode = firstEntry.getKey(); } } - } - } - // 是否计算返程 - Integer ynSubsidyFuelCostReturn = rule.getYnSubsidyFuelCostReturn(); - if (NumberUtil.equals(ynSubsidyFuelCostReturn, BooleanZeroOneEnums.YES.getCode())) { - if (CollUtil.isNotEmpty(firstRouteMap)) { - String s = firstRouteMap.get(lastCode); - if (StrUtil.isNotEmpty(s)) { - total = total.add(new BigDecimal(s)); + // 是否计算返程 + Integer ynSubsidyFuelCostReturn = rule.getYnSubsidyFuelCostReturn(); + if (NumberUtil.equals(ynSubsidyFuelCostReturn, BooleanZeroOneEnums.YES.getCode())) { + if (CollUtil.isNotEmpty(firstRouteMap)) { + String s = firstRouteMap.get(lastCode); + if (StrUtil.isNotEmpty(s)) { + total = total.add(new BigDecimal(s)); + } + } + } + // 总公里数成本 = (总公里数 * 油费单价) / 总件数 + for (Map.Entry entityEntry : valueMap.entrySet()) { + QualityDeliverEntity value2 = entityEntry.getValue(); + String subsidyCost = priceVO.getSubsidyCost(); + if (StrUtil.isNotEmpty(subsidyCost)) { + value2.setFuelCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(subsidyCost)), totalNum))); + } } - } - } - // 总公里数成本 = (总公里数 * 油费单价) / 总件数 - for (Map.Entry entityEntry : valueMap.entrySet()) { - QualityDeliverEntity value2 = entityEntry.getValue(); - String subsidyCost = priceVO.getSubsidyCost(); - if (StrUtil.isNotEmpty(subsidyCost)) { - value2.setFuelCost(Convert.toStr(NumberUtil.div(NumberUtil.mul(total, new BigDecimal(subsidyCost)), totalNum))); } } } } } } + } if (CollUtil.isNotEmpty(valueMap)) { // 修改配送明细信息 diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReturnWarehouseReportListener.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReturnWarehouseReportListener.java new file mode 100644 index 000000000..dfc5c20b3 --- /dev/null +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReturnWarehouseReportListener.java @@ -0,0 +1,109 @@ +package com.logpm.distribution.receiver.report; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.logpm.distribution.dto.ReportQualityDeliverDTO; +import com.logpm.distribution.entity.QualityDeliverEntity; +import com.logpm.distribution.service.IQualityDeliverService; +import com.logpm.factorydata.feign.IFactoryDataClient; +import com.logpm.factorydata.vo.SendMsg; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.broadcast.FanoutConstants; +import org.springblade.common.constant.report.ReportConstants; +import org.springblade.common.enums.BizOperationEnums; +import org.springblade.common.enums.PackageTypeEnums; +import org.springblade.common.model.DistributionSignforVO; +import org.springblade.common.model.NodeFanoutMsg; +import org.springblade.common.model.PackageData; +import org.springframework.amqp.core.ExchangeTypes; +import org.springframework.amqp.rabbit.annotation.Exchange; +import org.springframework.amqp.rabbit.annotation.Queue; +import org.springframework.amqp.rabbit.annotation.QueueBinding; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 回库生成明细报表 + * + * @author zhaoqiaobo + * @create 2024-03-18 0:02 + */ +@Slf4j +@Component +@AllArgsConstructor +public class ReturnWarehouseReportListener { + + @Resource + private IQualityDeliverService qualityDeliverService; + @Resource + private IFactoryDataClient factoryDataClient; + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FanoutConstants.distribution.DeliveryAndReturnWarehouse.QUEUE.REPORT, durable = "true"), + exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndReturnWarehouse.EXCHANGE, type = ExchangeTypes.FANOUT) + )) + @Transactional(rollbackFor = Exception.class) + public void buildReport(String msg) { + log.info("回库生成明细报表: {}", msg); + if (StrUtil.isEmpty(msg)) { + return; + } + NodeFanoutMsg bean = JSONUtil.toBean(msg, NodeFanoutMsg.class); + Object main = bean.getMain(); + JSONObject entries = JSONUtil.parseObj(main); + DistributionSignforVO vo = JSONUtil.toBean(entries, DistributionSignforVO.class); + Long warehouseId = bean.getWarehouseId(); + BizOperationEnums bizOperation = bean.getBizOperation(); + List details = vo.getPackageDataList(); + if (CollUtil.isNotEmpty(details)) { + for (PackageData detail : details) { + QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder() + .warehouseName(bean.getWarehouse()) + .warehouseId(warehouseId) + .orderPackageCode(detail.getPackageCode()) + .reviewUserName(bean.getOperator()) + .reviewTime(bean.getOperatorTime()) + .bizStatus(100) + .build(); + if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) { + qualityDeliverEntity.setConditions(1); + sendReport(bizOperation, qualityDeliverEntity); + } else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) { + qualityDeliverEntity.setBizCode(vo.getReservationCode()); + qualityDeliverEntity.setOrderCode(detail.getOrderCode()); + qualityDeliverEntity.setCategory(detail.getProductName()); + qualityDeliverEntity.setConditions(2); + sendReport(bizOperation, qualityDeliverEntity); + } else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.INV)) { + qualityDeliverEntity.setIncomingBatch(detail.getPickupBatch()); + qualityDeliverEntity.setMallName(detail.getMallName()); + qualityDeliverEntity.setMaterielCode(detail.getMaterialCode()); + qualityDeliverEntity.setMaterielName(detail.getMaterialName()); + qualityDeliverEntity.setConditions(3); + sendReport(bizOperation, qualityDeliverEntity); + } + } + } + } + + private void sendReport(BizOperationEnums bizOperation, QualityDeliverEntity qualityDeliverEntity) { + if (BizOperationEnums.ADD.equals(bizOperation) || BizOperationEnums.MODIFY.equals(bizOperation)) { + ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder().data(JSONUtil.toJsonStr(qualityDeliverEntity)).operation(BizOperationEnums.MODIFY).build(); + factoryDataClient.sendMessage(SendMsg.builder() + .exchange(ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE) + .routingKey(ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY) + .message(JSONUtil.toJsonStr(dto)) + .delay(3000) + .build()); + } + } + +} diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseDayMapper.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseDayMapper.java index 694388e32..f9d1f9d99 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseDayMapper.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseDayMapper.java @@ -40,7 +40,7 @@ public interface ExpenseWarehouseDayMapper extends BaseMapper selectExpenseWarehouseDayPage(IPage page, ExpenseWarehouseDayVO expenseWarehouseDay); + List selectExpenseWarehouseDayPage(@Param("page") IPage page, @Param("expenseWarehouseDay") ExpenseWarehouseDayVO expenseWarehouseDay); /** diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseDayMapper.xml b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseDayMapper.xml index b56d68a77..f46ef8840 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseDayMapper.xml +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseDayMapper.xml @@ -8,7 +8,20 @@ diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseMonthMapper.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseMonthMapper.java index 7ce26b38a..e93271d28 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseMonthMapper.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseMonthMapper.java @@ -38,10 +38,10 @@ public interface ExpenseWarehouseMonthMapper extends BaseMapper selectExpenseWarehouseMonthPage(IPage page,@Param("ew") Wrapper queryWrapper); + List selectExpenseWarehouseMonthPage(@Param("page") IPage page, @Param("vo") ExpenseWarehouseMonthVO vo); /** diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseMonthMapper.xml b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseMonthMapper.xml index cd0020a1c..d9c1dd544 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseMonthMapper.xml +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseWarehouseMonthMapper.xml @@ -8,7 +8,20 @@ diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseMonthServiceImpl.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseMonthServiceImpl.java index 34cc25d7a..0db13337f 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseMonthServiceImpl.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/ExpenseWarehouseMonthServiceImpl.java @@ -17,16 +17,13 @@ package com.logpm.statistics.service.impl; import com.baomidou.mybatisplus.core.conditions.Wrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.statistics.entity.ExpenseWarehouseMonthEntity; import com.logpm.statistics.excel.ExpenseWarehouseMonthExcel; import com.logpm.statistics.mapper.ExpenseWarehouseMonthMapper; import com.logpm.statistics.service.IExpenseWarehouseMonthService; -import com.logpm.statistics.util.QueryUtil; import com.logpm.statistics.vo.ExpenseWarehouseMonthVO; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.tool.constant.BladeConstant; import org.springframework.stereotype.Service; import java.util.List; @@ -42,9 +39,9 @@ public class ExpenseWarehouseMonthServiceImpl extends BaseServiceImpl selectExpenseWarehouseMonthPage(IPage page, ExpenseWarehouseMonthVO expenseWarehouseMonth) { - QueryWrapper queryWrapper = QueryUtil.buildQueryWrapper(expenseWarehouseMonth, ExpenseWarehouseMonthVO.class); - queryWrapper.lambda().eq(ExpenseWarehouseMonthVO::getIsDeleted, BladeConstant.DB_NOT_DELETED); - return page.setRecords(baseMapper.selectExpenseWarehouseMonthPage(page, queryWrapper)); + // QueryWrapper queryWrapper = QueryUtil.buildQueryWrapper(expenseWarehouseMonth, ExpenseWarehouseMonthVO.class); + // queryWrapper.lambda().eq(ExpenseWarehouseMonthVO::getIsDeleted, BladeConstant.DB_NOT_DELETED); + return page.setRecords(baseMapper.selectExpenseWarehouseMonthPage(page, expenseWarehouseMonth)); } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseDayVO.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseDayVO.java index b7b45dbcf..f0b67708f 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseDayVO.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseDayVO.java @@ -17,7 +17,7 @@ package com.logpm.statistics.vo; import com.logpm.statistics.entity.ExpenseWarehouseDayEntity; -import org.springblade.core.tool.node.INode; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -31,5 +31,10 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) public class ExpenseWarehouseDayVO extends ExpenseWarehouseDayEntity { private static final long serialVersionUID = 1L; - + @ApiModelProperty(value = "开始时间 年-月-日") + private String startDateQuery; + @ApiModelProperty(value = "结束时间 年-月-日") + private String endDateQuery; + @ApiModelProperty(value = "仓库 A,B,C") + private String warehouseNameQuery; } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseMonthVO.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseMonthVO.java index 642226455..1aaa5eb20 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseMonthVO.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseMonthVO.java @@ -40,4 +40,11 @@ public class ExpenseWarehouseMonthVO extends ExpenseWarehouseMonthEntity { @ApiModelProperty(value = "成本结算时间") private String CostSettlementTime; + @ApiModelProperty(value = "开始时间 年-月-日") + private String startDateQuery; + @ApiModelProperty(value = "结束时间 年-月-日") + private String endDateQuery; + @ApiModelProperty(value = "仓库 A,B,C") + private String warehouseNameQuery; + }