diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/report/ReportConstants.java b/blade-biz-common/src/main/java/org/springblade/common/constant/report/ReportConstants.java index 0b7e79f4a..c4e448641 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/constant/report/ReportConstants.java +++ b/blade-biz-common/src/main/java/org/springblade/common/constant/report/ReportConstants.java @@ -29,5 +29,17 @@ public class ReportConstants { public static final String REPORT_QUALITY_CAR_FINAL_EXCHANGE = "report.quality.car.final.exchange" + ModuleNameConstant.DEVAUTH; public static final String REPORT_QUALITY_CAR_FINAL_QUEUE = "report.quality.car.final.queue" + ModuleNameConstant.DEVAUTH; public static final String REPORT_QUALITY_CAR_FINAL_ROUTINGKEY = "report.quality.car.final.key" + ModuleNameConstant.DEVAUTH; + /** + * 配送订单成本报表 + */ + public static final String REPORT_EXPENSE_ORDER_EXCHANGE = "report.expense.order.exchange" + ModuleNameConstant.DEVAUTH; + public static final String REPORT_EXPENSE_ORDER_QUEUE = "report.expense.order.queue" + ModuleNameConstant.DEVAUTH; + public static final String REPORT_EXPENSE_ORDER_ROUTINGKEY = "report.expense.order.key" + ModuleNameConstant.DEVAUTH; + /** + * 仓储订单成本报表 + */ + public static final String REPORT_EXPENSE_WAREHOUSE_ORDER_EXCHANGE = "report.expense.warehouse.order.exchange" + ModuleNameConstant.DEVAUTH; + public static final String REPORT_EXPENSE_WAREHOUSE_ORDER_QUEUE = "report.expense.warehouse.order.queue" + ModuleNameConstant.DEVAUTH; + public static final String REPORT_EXPENSE_WAREHOUSE_ORDER_ROUTINGKEY = "report.expense.warehouse.order.key" + ModuleNameConstant.DEVAUTH; } 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 83a34b82c..4877d777c 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 @@ -118,6 +118,11 @@ public class QualityDeliverEntity extends TenantEntity { */ @ApiModelProperty(value = "运单发货地址") private String shipperAddress; + /** + * 发站 + */ + @ApiModelProperty(value = "发站") + private String shipperStation; /** * 运单收货单位id */ @@ -143,6 +148,11 @@ public class QualityDeliverEntity extends TenantEntity { */ @ApiModelProperty(value = "运单收货地址") private String consigneeAddress; + /** + * 到站 + */ + @ApiModelProperty(value = "到站") + private String consigneeStation; /** * 运单号 */ @@ -719,6 +729,41 @@ public class QualityDeliverEntity extends TenantEntity { */ @ApiModelProperty(value = "异动金额") private Double changeAmount; + /** + * 订单运单总数 + */ + @ApiModelProperty(value = "订单运单总数") + private Integer orderWaybillNumber; + /** + * 预留1 + */ + @ApiModelProperty(value = "预留1") + private String reserve1; + /** + * 预留2 + */ + @ApiModelProperty(value = "预留2") + private String reserve2; + /** + * 预留3 + */ + @ApiModelProperty(value = "预留3") + private String reserve3; + /** + * 预留4 + */ + @ApiModelProperty(value = "预留4") + private String reserve4; + /** + * 预留5 + */ + @ApiModelProperty(value = "预留5") + private String reserve5; + /** + * 客户服务类型 + */ + @ApiModelProperty(value = "客户服务类型") + private String customType; } diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchOrderDetailEntity.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchOrderDetailEntity.java index 54acc275d..dab85bb56 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchOrderDetailEntity.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchOrderDetailEntity.java @@ -75,8 +75,8 @@ public class ExpenseDispatchOrderDetailEntity extends TenantEntity { /** * 配送类型 */ - @ApiModelProperty(value = "配送类型") - @ExcelProperty("配送类型") + @ApiModelProperty(value = "运单类型") + @ExcelProperty("运单类型") private String waybillType; /** * 开单时间 @@ -96,12 +96,12 @@ public class ExpenseDispatchOrderDetailEntity extends TenantEntity { @ApiModelProperty(value = "复核件数") @ExcelProperty("复核件数") private Integer reviewNumber; - /** - * 结算件数 - */ - @ApiModelProperty(value = "结算件数") - @ExcelProperty("结算件数") - private Integer settlementNumber; + // /** + // * 结算件数 + // */ + // @ApiModelProperty(value = "结算件数") + // @ExcelProperty("结算件数") + // private Integer settlementNumber; /** * 总重量 */ @@ -126,12 +126,12 @@ public class ExpenseDispatchOrderDetailEntity extends TenantEntity { @ApiModelProperty(value = "配送成本") @ExcelProperty("配送成本") private Double distributionCost; - /** - * 撕标签成本 - */ - @ApiModelProperty(value = "撕标签成本") - @ExcelProperty("撕标签成本") - private Double inventoryDistributionCost; + // /** + // * 撕标签成本 + // */ + // @ApiModelProperty(value = "撕标签成本") + // @ExcelProperty("撕标签成本") + // private Double inventoryDistributionCost; /** * 上楼费成本 */ @@ -198,18 +198,18 @@ public class ExpenseDispatchOrderDetailEntity extends TenantEntity { @ApiModelProperty(value = "其他成本") @ExcelProperty("其他成本") private Double otherCosts; - /** - * 异动金额 - */ - @ApiModelProperty(value = "异动金额") - @ExcelProperty("异动金额") - private Double changeAmount; - /** - * 配送公里数 - */ - @ApiModelProperty(value = "配送公里数") - @ExcelProperty("配送公里数") - private Double deliveryKilometers; + // /** + // * 异动金额 + // */ + // @ApiModelProperty(value = "异动金额") + // @ExcelProperty("异动金额") + // private Double changeAmount; + // /** + // * 配送公里数 + // */ + // @ApiModelProperty(value = "配送公里数") + // @ExcelProperty("配送公里数") + // private Double deliveryKilometers; /** * 发货人 */ @@ -264,5 +264,11 @@ public class ExpenseDispatchOrderDetailEntity extends TenantEntity { @ApiModelProperty(value = "客户车次") @ExcelProperty("客户车次") private String customerTrip; + /** + * 复核完成时间 + */ + @ApiModelProperty(value = "复核完成时间") + @ExcelProperty("复核完成时间") + private String reviewCompletionTime; } diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseWarehouseOrderEntity.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseWarehouseOrderEntity.java index d85d558de..a82431f88 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseWarehouseOrderEntity.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseWarehouseOrderEntity.java @@ -9,8 +9,6 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; -import java.math.BigDecimal; - /** * 订单仓储成本报表 * @@ -60,30 +58,42 @@ public class ExpenseWarehouseOrderEntity extends TenantEntity { @ExcelProperty("发货单位") private String shippingUnit; /** - * 发站仓 + * 配送类型 */ - @ApiModelProperty(value = "发站仓") - @ExcelProperty("发站仓") - private String originWarehouse; + @ApiModelProperty(value = "运单类型") + @ExcelProperty("运单类型") + private String waybillType; /** - * 订单总件数 + * 订单运单总件数 */ - @ApiModelProperty(value = "订单总件数") - @ExcelProperty("订单总件数") + @ApiModelProperty(value = "订单运单总件数") + @ExcelProperty("订单运单总件数") private Integer totalNumber; /** * 出库件数 */ - @ApiModelProperty(value = "出库件数") - @ExcelProperty("出库件数") + @ApiModelProperty(value = "签收复核件数") + @ExcelProperty("签收复核件数") private Integer outNumber; + /** + * 发站仓 + */ + @ApiModelProperty(value = "发站仓") + @ExcelProperty("发站仓") + private String originWarehouse; /** * 租赁成本 */ @ApiModelProperty(value = "租赁成本") @ExcelProperty("租赁成本") - private BigDecimal warehouseRentalCost; + private Double warehouseRentalCost; + /** + * 复核完成时间 + */ + @ApiModelProperty(value = "复核完成时间") + @ExcelProperty("复核完成时间") + private String reviewCompletionTime; } diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/feign/IExpenseDispatchClient.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/feign/IExpenseDispatchClient.java index 13b876899..d8dd89f30 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/feign/IExpenseDispatchClient.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/feign/IExpenseDispatchClient.java @@ -1,7 +1,9 @@ package com.logpm.statistics.feign; import com.logpm.statistics.dto.ExpenseDispatchClientDTO; +import com.logpm.statistics.entity.ExpenseDispatchOrderDetailEntity; import com.logpm.statistics.entity.ExpenseDispatchTrainDetailEntity; +import com.logpm.statistics.entity.ExpenseWarehouseOrderEntity; import org.springblade.common.constant.ModuleNameConstant; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @@ -22,4 +24,9 @@ public interface IExpenseDispatchClient { @PostMapping(API_PREFIX + "/saveTrainDetailEntity") void saveTrainDetailEntity(@RequestBody ExpenseDispatchTrainDetailEntity entity); + @PostMapping(API_PREFIX + "/saveDispatchOrderDetailEntity") + void saveDispatchOrderDetailEntity(ExpenseDispatchOrderDetailEntity orderDetailEntity); + + @PostMapping(API_PREFIX + "/saveWarehouseOrderEntity") + void saveWarehouseOrderEntity(ExpenseWarehouseOrderEntity orderDetailEntity); } diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesAbnormalRecordServiceImpl.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesAbnormalRecordServiceImpl.java index 5444d7346..73f1391bb 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesAbnormalRecordServiceImpl.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesAbnormalRecordServiceImpl.java @@ -497,9 +497,12 @@ public class AftersalesAbnormalRecordServiceImpl extends BaseServiceImpl exportData = baseMapper.getBasicExportData(workOrderDTO, ids, warehouseIds); return exportData; 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 9ba6abb77..97a45c455 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 @@ -23,6 +23,7 @@ import com.logpm.statistics.entity.ExpenseDispatchPriceOverZoneEntity; import com.logpm.statistics.feign.IExpenseDispatchClient; import com.logpm.statistics.vo.ExpenseDispatchPriceCategoryVO; import com.logpm.statistics.vo.ExpenseDispatchPriceVO; +import com.logpm.trunkline.entity.TrunklineWaybillOrderEntity; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.report.ReportConstants; @@ -37,6 +38,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Collection; import java.util.Comparator; import java.util.Date; import java.util.HashMap; @@ -87,6 +89,7 @@ public class DeliverFinishReportListener implements ReportService { .delay(10000) .build()); + } public void calculateTripCost(String trainNumber, String deliveryKindParam) { @@ -95,35 +98,32 @@ public class DeliverFinishReportListener implements ReportService { .eq(QualityDeliverEntity::getSignTrainNumber, trainNumber) ); if (CollUtil.isNotEmpty(entities)) { + // 按签收车分组 Map> collect = null; - if(StrUtil.isEmpty(deliveryKindParam)){ - return; - } - if(StrUtil.equals(deliveryKindParam, "自主配送")){ + if (StrUtil.equals(deliveryKindParam, "自主配送")) { collect = entities.stream() .filter(entity -> StrUtil.isNotEmpty(entity.getSignCarNumber())) .filter(entity -> ObjectUtil.isNotEmpty(entity.getSignCarId())) .collect(Collectors.groupingBy(i -> Convert.toStr(i.getSignCarId()))); } - if(StrUtil.equals(deliveryKindParam, "三方配送")){ + if (StrUtil.equals(deliveryKindParam, "三方配送")) { collect = entities.stream() .filter(entity -> StrUtil.isNotEmpty(entity.getSignCarNumber())) .collect(Collectors.groupingBy(i -> Convert.toStr(i.getSignTrainNumber()))); } if (CollUtil.isNotEmpty(collect)) { for (Map.Entry> entry : collect.entrySet()) { - List value = entry.getValue(); // 根据车查询出司机id List collect2 = new ArrayList<>(); - if(StrUtil.equals(deliveryKindParam, "自主配送")){ + if (StrUtil.equals(deliveryKindParam, "自主配送")) { collect2 = value.stream() .filter(entity -> ObjectUtil.isNotEmpty(entity.getSignUserId())) .map(entity -> entity.getSignUserId()) .collect(Collectors.toList()); } - if(StrUtil.equals(deliveryKindParam, "三方配送")){ + if (StrUtil.equals(deliveryKindParam, "三方配送")) { collect2.add("0"); } @@ -214,7 +214,7 @@ public class DeliverFinishReportListener implements ReportService { ExpenseDispatchPriceVO priceVO = expenseDispatchClientDTO.getPriceVO(); // 整车计费,则车内的每个包件分摊整车成本费用 if (ynWholeVehicle) { - if(ObjectUtil.isNotEmpty(priceVO)){ + if (ObjectUtil.isNotEmpty(priceVO)) { String wholeVehicleCost = priceVO.getWholeVehicleCost(); if (StrUtil.isNotEmpty(wholeVehicleCost)) { BigDecimal deliveryFeeSum = BigDecimal.ZERO; @@ -237,7 +237,7 @@ public class DeliverFinishReportListener implements ReportService { } } } else { - if(ObjectUtil.isNotEmpty(priceVO)){ + if (ObjectUtil.isNotEmpty(priceVO)) { List overZoneList = priceVO.getOverZoneList(); Map overZoneEntityMap = new HashMap<>(); if (CollUtil.isNotEmpty(overZoneList)) { @@ -901,11 +901,43 @@ public class DeliverFinishReportListener implements ReportService { )); sendReport(BizOperationEnums.MODIFY, entityEntry.getValue(), BizOperationEnums.MODIFY); } + Map waybillOrderMap = new HashMap<>(); + Collection values = valueMap.values(); + for (QualityDeliverEntity entity : values) { + if (StrUtil.isEmpty(entity.getOrderCode()) || StrUtil.isEmpty(entity.getWaybillNumber())) { + log.info("订单或运单为空,不生成订单总成本报表:id = {}", entity.getId()); + continue; + } + String key = entity.getOrderCode() + entity.getWaybillNumber(); + if (waybillOrderMap.containsKey(key)) { + TrunklineWaybillOrderEntity waybillOrderEntity = waybillOrderMap.get(key); + Integer totalNumber = waybillOrderEntity.getTotalNumber(); + waybillOrderEntity.setTotalNumber(totalNumber + entity.getSignNum()); + } else { + TrunklineWaybillOrderEntity waybillOrderEntity = new TrunklineWaybillOrderEntity(); + waybillOrderEntity.setOrderCode(entity.getOrderCode()); + waybillOrderEntity.setWaybillNo(entity.getWaybillNumber()); + waybillOrderEntity.setTotalNumber(entity.getSignNum()); + waybillOrderMap.put(key, waybillOrderEntity); + } + } + // 生成订单 发送延时消息生成报表 + if (CollUtil.isNotEmpty(waybillOrderMap)) { + for (Map.Entry entityEntry : waybillOrderMap.entrySet()) { + factoryDataClient.sendMessage(SendMsg.builder() + .exchange(ReportConstants.REPORT_EXPENSE_ORDER_EXCHANGE) + .routingKey(ReportConstants.REPORT_EXPENSE_ORDER_ROUTINGKEY) + .message(JSONUtil.toJsonStr(entityEntry.getValue())) + .delay(10000) + .build()); + } + } } } } } } + } private static void buildUltrAllpwCost(Map valueMap, BigDecimal mul, Integer totalNum) { @@ -925,6 +957,7 @@ public class DeliverFinishReportListener implements ReportService { idex++; } } + private static void buildPointAllowCost(Map valueMap, BigDecimal mul, Integer totalNum) { BigDecimal deliveryFeeSum = BigDecimal.ZERO; int idex = 0; @@ -942,6 +975,7 @@ public class DeliverFinishReportListener implements ReportService { idex++; } } + private static void buildFuelCost(Map valueMap, BigDecimal mul, Integer totalNum) { BigDecimal deliveryFeeSum = BigDecimal.ZERO; int idex = 0; diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java index bb14b53b0..054e198ae 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java @@ -23,7 +23,9 @@ import com.logpm.distribution.service.IDistributionStockArticleService; import com.logpm.distribution.service.IDistributionStockListInfoService; import com.logpm.distribution.service.IDistributionStockListService; import com.logpm.distribution.service.IQualityDeliverService; +import com.logpm.trunkline.entity.TrunklineWaybillOrderEntity; import com.logpm.trunkline.feign.ITrunklineAdvanceDetailClient; +import com.logpm.trunkline.feign.ITrunklineWaybillOrderClient; import com.logpm.warehouse.entity.WarehouseWayBillDetail; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import com.logpm.warehouse.feign.IWarehouseWaybillClient; @@ -35,6 +37,7 @@ import org.springblade.common.constant.WorkNodeEnums; import org.springblade.common.enums.BizOperationEnums; import org.springblade.common.enums.PackageTypeEnums; import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.secure.utils.AuthUtil; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -87,6 +90,8 @@ public class QualityDeliverListener implements ReportService { private BladeRedis redisCache; @Resource private DistributionProperties destinationProperties; + @Resource + private ITrunklineWaybillOrderClient waybillOrderClient; @Transactional public void buildReport(String msg) { @@ -103,19 +108,19 @@ public class QualityDeliverListener implements ReportService { saveOrUpdate(null, qualityDeliverEntity); } if (ObjectUtil.equals(bean.getOperation(), BizOperationEnums.DELETE)) { - if (StrUtil.equals(node, WorkNodeEnums.PLANNED_RESERVATION.getValue())){ + if (StrUtil.equals(node, WorkNodeEnums.PLANNED_RESERVATION.getValue())) { qualityDeliverService.deleteEntityById(qualityDeliverEntity.getId()); } - if (StrUtil.equals(node, WorkNodeEnums.STOCKING_OPERATION.getValue())){ + if (StrUtil.equals(node, WorkNodeEnums.STOCKING_OPERATION.getValue())) { qualityDeliverService.delStockingOperation(qualityDeliverEntity.getId()); } - if (StrUtil.equals(node, WorkNodeEnums.PLAN_DELIVERY.getValue())){ + if (StrUtil.equals(node, WorkNodeEnums.PLAN_DELIVERY.getValue())) { qualityDeliverService.delPlanDelivery(qualityDeliverEntity.getId()); } - if (StrUtil.equals(node, WorkNodeEnums.DISTRIBUTION_CAR_START.getValue())){ + if (StrUtil.equals(node, WorkNodeEnums.DISTRIBUTION_CAR_START.getValue())) { qualityDeliverService.delDistributionCarStart(qualityDeliverEntity.getId()); } - if (StrUtil.equals(node, WorkNodeEnums.PLAN_BILLOFLADING.getValue())){ + if (StrUtil.equals(node, WorkNodeEnums.PLAN_BILLOFLADING.getValue())) { qualityDeliverService.deleteEntityById(qualityDeliverEntity.getId()); } } @@ -282,6 +287,7 @@ public class QualityDeliverListener implements ReportService { } private void buildCmpBasicInfo(QualityDeliverEntity qualityDeliverEntity, DistributionParcelListEntity parcelListEntity) { + String orderCode = qualityDeliverEntity.getOrderCode(); if (ObjectUtil.isNotEmpty(parcelListEntity)) { // 品牌 qualityDeliverEntity.setBrandName(parcelListEntity.getBrandName()); @@ -321,6 +327,9 @@ public class QualityDeliverListener implements ReportService { qualityDeliverEntity.setEndWarehouseInTime(parcelListEntity.getWarehouseEntryTimeEnd()); // 构建运单相关信息 buildWaybillInfo(qualityDeliverEntity, waybillNumber); + // 设置订单运单总数 + buildOrderWaybillNumber(qualityDeliverEntity, orderCode, waybillNumber); + } // 暂存单查询结算品类 // TrunklineAdvanceDetailEntity advanceDetailEntity = advanceDetailClient.findEntityByOrderPackageCode(qualityDeliverEntity.getOrderPackageCode()); @@ -331,7 +340,23 @@ public class QualityDeliverListener implements ReportService { // qualityDeliverEntity.setRevenueCategory(advanceDetailEntity.getIncomeCategoryName()); // } // 构建订单相关信息 - buildOrderInfo(qualityDeliverEntity, qualityDeliverEntity.getWarehouseId(), qualityDeliverEntity.getOrderCode()); + buildOrderInfo(qualityDeliverEntity, qualityDeliverEntity.getWarehouseId(), orderCode); + } + + private void buildOrderWaybillNumber(QualityDeliverEntity qualityDeliverEntity, String orderCode, String waybillNumber) { + if (StrUtil.isNotEmpty(orderCode) && StrUtil.isNotEmpty(waybillNumber)) { + String key = AuthUtil.getTenantId() + ":" + "logpm-distribution:" + "OrderWaybill:" + orderCode + "_" + waybillNumber; + Integer totalNumber = redisCache.get(key); + if (ObjectUtil.isNotEmpty(totalNumber)) { + qualityDeliverEntity.setOrderWaybillNumber(totalNumber); + } else { + TrunklineWaybillOrderEntity entityByWaybillNoAndOrderCode = waybillOrderClient.findEntityByWaybillNoAndOrderCode(waybillNumber, orderCode); + if (ObjectUtil.isNotEmpty(entityByWaybillNoAndOrderCode)) { + qualityDeliverEntity.setOrderWaybillNumber(entityByWaybillNoAndOrderCode.getTotalNumber()); + } + redisCache.set(key, entityByWaybillNoAndOrderCode.getTotalNumber()); + } + } } private void buildOrderInfo(QualityDeliverEntity qualityDeliverEntity, Long warehouseId, String orderCode) { @@ -356,6 +381,19 @@ public class QualityDeliverListener implements ReportService { qualityDeliverEntity.setStoreName(stockArticleEntity.getStoreName()); // 品牌 qualityDeliverEntity.setBrandName(stockArticleEntity.getBrand()); + // 服务类型 + String typeService = stockArticleEntity.getTypeService(); + if(StrUtil.isNotEmpty(typeService)){ + if("1".equals(typeService)){ + qualityDeliverEntity.setCustomType("商配"); + }else if("2".equals(typeService)){ + qualityDeliverEntity.setCustomType("市配"); + }else if("3".equals(typeService)){ + qualityDeliverEntity.setCustomType("自提"); + }else if("4".equals(typeService)){ + qualityDeliverEntity.setCustomType("三方中转"); + } + } } } @@ -394,6 +432,9 @@ public class QualityDeliverListener implements ReportService { qualityDeliverEntity.setAssignedCustomerId(Convert.toStr(byWaybillNo.getConsigneeId())); qualityDeliverEntity.setAssignedCustomer(byWaybillNo.getConsignee()); + qualityDeliverEntity.setShipperStation(byWaybillNo.getDeparture()); + qualityDeliverEntity.setConsigneeStation(byWaybillNo.getDestination()); + } } } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportListener.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportListener.java index 0fd72a880..7e927d1f3 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportListener.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportListener.java @@ -1,6 +1,8 @@ package com.logpm.distribution.receiver.report; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; import cn.hutool.json.JSONUtil; import com.logpm.distribution.pros.DistributionProperties; import com.logpm.distribution.service.IQualityDeliverService; @@ -513,6 +515,52 @@ public class ReportListener { throw new RuntimeException(e); } } + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = ReportConstants.REPORT_EXPENSE_ORDER_QUEUE, durable = "true"), + exchange = @Exchange(name = ReportConstants.REPORT_EXPENSE_ORDER_EXCHANGE, type = ExchangeTypes.TOPIC, + delayed = FactoryDataConstants.Mq.DELAYED), + key = ReportConstants.REPORT_EXPENSE_ORDER_ROUTINGKEY + ), ackMode = "MANUAL") + public void orderExpenseDispatchDetailFinal(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { + log.info("生成订单总成本报表: {}", msg); + try { + JSONArray objects = JSONUtil.parseArray(msg); + if(CollUtil.isNotEmpty(objects)){ + qualityDeliverService.orderExpenseDispatchDetailFinal(objects); + } + } catch (Exception e) { + e.printStackTrace(); + log.error("生成订单总成本报表失败: {}", e.getMessage()); + } + try { + channel.basicAck(tag, false); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = ReportConstants.REPORT_EXPENSE_WAREHOUSE_ORDER_QUEUE, durable = "true"), + exchange = @Exchange(name = ReportConstants.REPORT_EXPENSE_WAREHOUSE_ORDER_EXCHANGE, type = ExchangeTypes.TOPIC, + delayed = FactoryDataConstants.Mq.DELAYED), + key = ReportConstants.REPORT_EXPENSE_WAREHOUSE_ORDER_ROUTINGKEY + ), ackMode = "MANUAL") + public void expenseWarehouseOrder(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) { + log.info("生成仓储订单总成本报表: {}", msg); + try { + JSONArray objects = JSONUtil.parseArray(msg); + if(CollUtil.isNotEmpty(objects)){ + qualityDeliverService.expenseWarehouseOrder(objects); + } + } catch (Exception e) { + e.printStackTrace(); + log.error("生成仓储订单总成本报表失败: {}", e.getMessage()); + } + try { + channel.basicAck(tag, false); + } catch (IOException e) { + throw new RuntimeException(e); + } + } private ReportService selectReportService(Class clazz) { diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IQualityDeliverService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IQualityDeliverService.java index 7be05663f..047c08358 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IQualityDeliverService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IQualityDeliverService.java @@ -16,6 +16,7 @@ */ package com.logpm.distribution.service; +import cn.hutool.json.JSONArray; import com.logpm.distribution.entity.QualityDeliverEntity; import org.springblade.core.mp.base.BaseService; @@ -42,4 +43,8 @@ public interface IQualityDeliverService extends BaseService kucuns = new ArrayList<>(); List dingzhis= new ArrayList<>(); List lingdans = new ArrayList<>(); + List pushList = new ArrayList<>(); for (DistributionReservationStockarticleEntity reservationStockarticleEntity : reservationStockarticleEntityList) { switch (reservationStockarticleEntity.getIsZero()) { @@ -1600,6 +1601,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl contents = new ArrayList<>(); + PushData pushData = PushData.builder() + .packageCode(parcelListEntity.getOrderPackageCode()) + .orderCode(parcelListEntity.getOrderCode()) + .warehouseName(myCurrentWarehouse.getName()) + .waybillNumber(parcelListEntity.getWaybillNumber()).build(); + contents.add(pushData); + NodePushMsg msg = new NodePushMsg(); + msg.setNode(WorkNodeEnums.DISTRIBUTION_LOADING); + msg.setBrand(BrandEnums.getByValue(parcelListEntity.getBrandName())); + msg.setOperator(AuthUtil.getNickName()); + msg.setOperatorTime(new Date()); + msg.setContent(contents); + log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg)); + factoryDataMessageSender.sendNodeDataByBrand(msg); + } + } return Resp.scanSuccess("操作成功", "装车成功"); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/QualityDeliverServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/QualityDeliverServiceImpl.java index 0f8de634d..100796249 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/QualityDeliverServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/QualityDeliverServiceImpl.java @@ -23,6 +23,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -34,8 +35,11 @@ import com.logpm.basicdata.feign.IWarehouseLeasingClient; import com.logpm.distribution.entity.QualityDeliverEntity; import com.logpm.distribution.mapper.QualityDeliverMapper; import com.logpm.distribution.service.IQualityDeliverService; +import com.logpm.statistics.entity.ExpenseDispatchOrderDetailEntity; import com.logpm.statistics.entity.ExpenseDispatchTrainDetailEntity; +import com.logpm.statistics.entity.ExpenseWarehouseOrderEntity; import com.logpm.statistics.feign.IExpenseDispatchClient; +import com.logpm.trunkline.entity.TrunklineWaybillOrderEntity; import org.springblade.core.mp.base.BaseServiceImpl; import org.springframework.stereotype.Service; @@ -47,6 +51,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -445,4 +450,175 @@ public class QualityDeliverServiceImpl extends BaseServiceImpl list = JSONUtil.toList(objects, TrunklineWaybillOrderEntity.class); + TrunklineWaybillOrderEntity entity = list.get(0); + List qualityDeliverEntities = baseMapper.selectList(Wrappers.lambdaQuery() + .eq(QualityDeliverEntity::getOrderCode, entity.getOrderCode()) + .eq(QualityDeliverEntity::getWaybillNumber, entity.getWaybillNo()) + .orderByDesc(QualityDeliverEntity::getCarComplateTime) + ); + if (CollUtil.isNotEmpty(qualityDeliverEntities)) { + QualityDeliverEntity qualityDeliverEntity = qualityDeliverEntities.get(0); + // 订单运单总数 + Integer totalNumber = qualityDeliverEntity.getOrderWaybillNumber(); + // 计算签收总数 + Integer reduce = qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .map(QualityDeliverEntity::getSignNum) + .filter(Objects::nonNull) + .reduce(0, Integer::sum); + // 全部计算完成之后生成订单总成本 + if (NumberUtil.equals(totalNumber, reduce)) { + ExpenseDispatchOrderDetailEntity orderDetailEntity = new ExpenseDispatchOrderDetailEntity(); + orderDetailEntity.setBrand(qualityDeliverEntity.getBrandName()); + orderDetailEntity.setOrderCode(qualityDeliverEntity.getOrderCode()); + orderDetailEntity.setWaybillNumber(qualityDeliverEntity.getWaybillNumber()); + orderDetailEntity.setDestinationWarehouse(qualityDeliverEntity.getWarehouseName()); + orderDetailEntity.setShippingOrg(qualityDeliverEntity.getShipperUnit()); + orderDetailEntity.setConsigneeOrg(qualityDeliverEntity.getConsigneeUnit()); + orderDetailEntity.setWaybillType(qualityDeliverEntity.getCustomType()); + orderDetailEntity.setDocumentCreationTime(DateUtil.formatDateTime(qualityDeliverEntity.getOpenOrderTime())); + orderDetailEntity.setTotalQuantity(totalNumber); + orderDetailEntity.setReviewNumber(reduce); + orderDetailEntity.setTotalWeight(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getWeight())) + .map(QualityDeliverEntity::getWeight) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setTotalVolume(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getVolume())) + .map(QualityDeliverEntity::getVolume) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setTotalDistributionCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getTotalDistributionCost())) + .map(QualityDeliverEntity::getTotalDistributionCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setDistributionCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getDistributionCost())) + .map(QualityDeliverEntity::getDistributionCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setStairCarryingFee(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getApstairsCost())) + .map(QualityDeliverEntity::getApstairsCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setGoodsAllocationCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getApartCost())) + .map(QualityDeliverEntity::getApartCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setRepositioningCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getMoveCost())) + .map(QualityDeliverEntity::getMoveCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setHandlingCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getStevedoreCost())) + .map(QualityDeliverEntity::getStevedoreCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setMileageCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getKiloAllowCost())) + .map(QualityDeliverEntity::getKiloAllowCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setSubsidizedKilometerCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getAllowKiloAllowCost())) + .map(QualityDeliverEntity::getAllowKiloAllowCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setExcessZoneMileageCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getUltrAllpwCost())) + .map(QualityDeliverEntity::getUltrAllpwCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setLocationSubsidyCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getPointAllowCost())) + .map(QualityDeliverEntity::getPointAllowCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setMinimumGuaranteeCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getGuarCost())) + .map(QualityDeliverEntity::getGuarCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setFuelCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getFuelCost())) + .map(QualityDeliverEntity::getFuelCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setOtherCosts(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getCarComplateTime())) + .filter(item -> Objects.nonNull(item.getOtherCost())) + .map(QualityDeliverEntity::getOtherCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + orderDetailEntity.setShipper(qualityDeliverEntity.getShipperPerson()); + orderDetailEntity.setShippingPhone(qualityDeliverEntity.getShipperMobile()); + orderDetailEntity.setShippingAddress(qualityDeliverEntity.getShipperAddress()); + orderDetailEntity.setArrivalStation(qualityDeliverEntity.getConsigneeStation()); + orderDetailEntity.setDepartureWarehouse(qualityDeliverEntity.getShipperStation()); + orderDetailEntity.setConsignee(qualityDeliverEntity.getConsigneePerson()); + orderDetailEntity.setConsigneePhone(qualityDeliverEntity.getConsigneeMobile()); + orderDetailEntity.setConsigneeAddress(qualityDeliverEntity.getConsigneeAddress()); + orderDetailEntity.setCustomerTrip(qualityDeliverEntity.getTrainNumber()); + orderDetailEntity.setReviewCompletionTime(DateUtil.formatDateTime(qualityDeliverEntity.getReviewTime())); + expenseDispatchClient.saveDispatchOrderDetailEntity(orderDetailEntity); + } + } + } + } + + @Override + public void expenseWarehouseOrder(JSONArray objects) { + // 生成仓储订单总成本 + if (CollUtil.isNotEmpty(objects)) { + List list = JSONUtil.toList(objects, TrunklineWaybillOrderEntity.class); + TrunklineWaybillOrderEntity entity = list.get(0); + List qualityDeliverEntities = baseMapper.selectList(Wrappers.lambdaQuery() + .eq(QualityDeliverEntity::getOrderCode, entity.getOrderCode()) + .eq(QualityDeliverEntity::getWaybillNumber, entity.getWaybillNo()) + .orderByDesc(QualityDeliverEntity::getReviewTime) + ); + if (CollUtil.isNotEmpty(qualityDeliverEntities)) { + QualityDeliverEntity qualityDeliverEntity = qualityDeliverEntities.get(0); + // 订单运单总数 + Integer totalNumber = qualityDeliverEntity.getOrderWaybillNumber(); + // 计算签收总数 + Integer reduce = qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getReviewUserName())) + .map(QualityDeliverEntity::getSignNum) + .filter(Objects::nonNull) + .reduce(0, Integer::sum); + // 全部计算完成之后生成订单总成本 + if (NumberUtil.equals(totalNumber, reduce)) { + ExpenseWarehouseOrderEntity orderDetailEntity = new ExpenseWarehouseOrderEntity(); + orderDetailEntity.setBusinessUnit(qualityDeliverEntity.getBusinessUnit()); + orderDetailEntity.setWarehouseName(qualityDeliverEntity.getWarehouseName()); + orderDetailEntity.setOrderCode(qualityDeliverEntity.getOrderCode()); + orderDetailEntity.setShipmentNumber(qualityDeliverEntity.getWaybillNumber()); + orderDetailEntity.setReceivingUnit(qualityDeliverEntity.getConsigneeUnit()); + orderDetailEntity.setShippingUnit(qualityDeliverEntity.getShipperUnit()); + orderDetailEntity.setWaybillType(qualityDeliverEntity.getCustomType()); + orderDetailEntity.setTotalNumber(totalNumber); + orderDetailEntity.setOutNumber(totalNumber); + orderDetailEntity.setOriginWarehouse(qualityDeliverEntity.getShipperStation()); + orderDetailEntity.setReviewCompletionTime(DateUtil.formatDateTime(qualityDeliverEntity.getReviewTime())); + orderDetailEntity.setWarehouseRentalCost(Convert.toDouble(qualityDeliverEntities.stream() + .filter(item -> ObjectUtil.isNotEmpty(item.getReviewUserName())) + .filter(item -> Objects.nonNull(item.getWarehouseCost())) + .map(QualityDeliverEntity::getWarehouseCost) + .reduce(BigDecimal.ZERO, BigDecimal::add))); + expenseDispatchClient.saveWarehouseOrderEntity(orderDetailEntity); + } + } + } + } + } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/FactoryDataServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/FactoryDataServiceImpl.java index 636a1c4aa..b8bfd17f5 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/FactoryDataServiceImpl.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/FactoryDataServiceImpl.java @@ -133,6 +133,7 @@ public class FactoryDataServiceImpl implements FactoryDataService { entity.setDeliveryNoteId(vo.getId().toString()); entity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); entity.setTenantCode(AuthUtil.getTenantId()); + entity.setOrderType(vo.getOrderType()); packageInfoEntities.add(entity); } packageInfoService.saveBatch(packageInfoEntities); diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/dto/ReportTimeDTO.java b/blade-service/logpm-report/src/main/java/com/logpm/report/dto/ReportTimeDTO.java index 9cc4463e6..3fb02a2b7 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/dto/ReportTimeDTO.java +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/dto/ReportTimeDTO.java @@ -40,4 +40,11 @@ public class ReportTimeDTO implements Serializable { private String trainNumber; private String loadCode; + + private String openTimeStartStr; + private String openTimeEndStr; + + private Date openTimeStart; + private Date openTimeEnd; + } diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.java b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.java index cff60a98c..55703e18d 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.java +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.java @@ -2,7 +2,6 @@ package com.logpm.report.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.report.dto.ReportTimeDTO; -import com.logpm.report.entity.ReportConfigOrderAllEntity; import com.logpm.report.vo.*; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -47,5 +46,5 @@ public interface ReportTimeMapper { IPage orderAllTimePage(IPage page, @Param("param") ReportTimeDTO reportTimeDTO); - List orderAllTimeExport(@Param("param") ReportTimeDTO reportTimeDTO); + List orderAllTimeExport(@Param("param") ReportTimeDTO reportTimeDTO); } diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.xml b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.xml index d4538df4e..fe4101e4f 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.xml +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportTimeMapper.xml @@ -1391,12 +1391,6 @@ where ltad.waybill_id is not null and ltad.create_time > '2024-10-22 00:00:00' and lww.departure_warehouse_id != lww.destination_warehouse_id - - and ltad.create_time >= #{param.startTime} - - - and ltad.create_time <= #{param.endTime} - and lww.brand in @@ -1436,13 +1430,6 @@ and lww.destination_warehouse_name like concat('%',#{param.destinationWarehouseName},'%') - - and GROUP_CONCAT(DISTINCT ltad.train_number) like concat('%',#{param.trainNumber},'%') - GROUP_CONCAT(DISTINCT IFNULL(ltcls.load_code,ltclsm.load_code)) loadCode, - - - and GROUP_CONCAT(DISTINCT IFNULL(ltcls.load_code,ltclsm.load_code)) like concat('%',#{param.loadCode},'%') - group by ltad.order_code, ltad.waybill_no, ltad.brand, @@ -1451,6 +1438,26 @@ lww.departure_warehouse_name, lww.destination_warehouse_name, oat.day_time + + + and GROUP_CONCAT(DISTINCT ltad.train_number) like concat('%',#{param.trainNumber},'%') + + + and GROUP_CONCAT(DISTINCT IFNULL(ltcls.load_code,ltclsm.load_code)) like concat('%',#{param.loadCode},'%') + + + and min(ltad.create_time) >= #{param.startTime} + + + and min(ltad.create_time) <= #{param.endTime} + + + and min(lww.create_time) >= #{param.openTimeStart} + + + and min(lww.create_time) <= #{param.openTimeEnd} + + @@ -1498,12 +1505,6 @@ where ltad.waybill_id is not null and ltad.create_time > '2024-10-22 00:00:00' and lww.departure_warehouse_id != lww.destination_warehouse_id - - and ltad.create_time >= #{param.startTime} - - - and ltad.create_time <= #{param.endTime} - and lww.brand in @@ -1545,7 +1546,6 @@ and GROUP_CONCAT(DISTINCT ltad.train_number) like concat('%',#{param.trainNumber},'%') - GROUP_CONCAT(DISTINCT IFNULL(ltcls.load_code,ltclsm.load_code)) loadCode, and GROUP_CONCAT(DISTINCT IFNULL(ltcls.load_code,ltclsm.load_code)) like concat('%',#{param.loadCode},'%') @@ -1558,6 +1558,27 @@ lww.departure_warehouse_name, lww.destination_warehouse_name, oat.day_time + + + and GROUP_CONCAT(DISTINCT ltad.train_number) like concat('%',#{param.trainNumber},'%') + GROUP_CONCAT(DISTINCT IFNULL(ltcls.load_code,ltclsm.load_code)) loadCode, + + + and GROUP_CONCAT(DISTINCT IFNULL(ltcls.load_code,ltclsm.load_code)) like concat('%',#{param.loadCode},'%') + + + and min(ltad.create_time) >= #{param.startTime} + + + and min(ltad.create_time) <= #{param.endTime} + + + and min(lww.create_time) >= #{param.openTimeStart} + + + and min(lww.create_time) <= #{param.openTimeEnd} + + diff --git a/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportTimeServiceImpl.java b/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportTimeServiceImpl.java index 12f2ff6d0..f71a937ec 100644 --- a/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportTimeServiceImpl.java +++ b/blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportTimeServiceImpl.java @@ -415,6 +415,8 @@ public class ReportTimeServiceImpl implements IReportTimeService { reportTimeDTO.setStartTime(CommonUtil.getStartByDateStr(reportTimeDTO.getStartTimeStr())); reportTimeDTO.setEndTime(CommonUtil.getEndByDateStr(reportTimeDTO.getEndTimeStr())); + reportTimeDTO.setOpenTimeStart(CommonUtil.getStartByDateStr(reportTimeDTO.getOpenTimeStartStr())); + reportTimeDTO.setOpenTimeEnd(CommonUtil.getEndByDateStr(reportTimeDTO.getOpenTimeEndStr())); reportTimeDTO.setDayTime(0); @@ -447,9 +449,9 @@ public class ReportTimeServiceImpl implements IReportTimeService { reportTimeDTO.setDayTime(orderAllEntity.getDayTime()); } - List list = reportTimeMapper.orderAllTimeExport(reportTimeDTO); + List list = reportTimeMapper.orderAllTimeExport(reportTimeDTO); //导出ls - ExcelUtil.export(response, "订单整体时效报表导出", "订单整体时效报表导出", list, ReportConfigOrderAllEntity.class); + ExcelUtil.export(response, "订单整体时效报表导出", "订单整体时效报表导出", list, ReportOrderAllTimeVO.class); } } diff --git a/blade-service/logpm-statisticsdata/pom.xml b/blade-service/logpm-statisticsdata/pom.xml index d0824022a..1af0c5837 100644 --- a/blade-service/logpm-statisticsdata/pom.xml +++ b/blade-service/logpm-statisticsdata/pom.xml @@ -78,6 +78,11 @@ 3.2.0.RELEASE compile + + org.springblade + logpm-factory-data-api + 3.2.0.RELEASE + diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/feign/ExpenseDispatchClient.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/feign/ExpenseDispatchClient.java index b8fd9cb2c..d7296bf25 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/feign/ExpenseDispatchClient.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/feign/ExpenseDispatchClient.java @@ -7,14 +7,18 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.logpm.statistics.dto.ExpenseDispatchClientDTO; import com.logpm.statistics.dto.ExpenseDispatchPriceRuleDTO; +import com.logpm.statistics.entity.ExpenseDispatchOrderDetailEntity; import com.logpm.statistics.entity.ExpenseDispatchPriceEntity; import com.logpm.statistics.entity.ExpenseDispatchPriceRuleEntity; import com.logpm.statistics.entity.ExpenseDispatchPriceServiceEntity; import com.logpm.statistics.entity.ExpenseDispatchTrainDetailEntity; +import com.logpm.statistics.entity.ExpenseWarehouseOrderEntity; +import com.logpm.statistics.service.IExpenseDispatchOrderDetailService; import com.logpm.statistics.service.IExpenseDispatchPriceRuleService; import com.logpm.statistics.service.IExpenseDispatchPriceService; import com.logpm.statistics.service.IExpenseDispatchPriceServiceService; import com.logpm.statistics.service.IExpenseDispatchTrainDetailService; +import com.logpm.statistics.service.IExpenseOrderWarehouseTotalService; import com.logpm.statistics.vo.ExpenseDispatchPriceVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -35,6 +39,8 @@ public class ExpenseDispatchClient implements IExpenseDispatchClient { private final IExpenseDispatchPriceService priceService; private final IExpenseDispatchPriceRuleService ruleService; private final IExpenseDispatchTrainDetailService trainDetailService; + private final IExpenseDispatchOrderDetailService orderDetailService; + private final IExpenseOrderWarehouseTotalService orderWarehouseTotalService; @Override public ExpenseDispatchClientDTO findPriceByDriverId(Long warehouseId, Long driverId, Long carType, String dispatchType) { @@ -42,21 +48,21 @@ public class ExpenseDispatchClient implements IExpenseDispatchClient { .eq(ExpenseDispatchPriceServiceEntity::getWarehouseId, warehouseId) .eq(ExpenseDispatchPriceServiceEntity::getDriverId, driverId) ); - if(CollUtil.isNotEmpty(list)){ + if (CollUtil.isNotEmpty(list)) { ExpenseDispatchClientDTO dto = new ExpenseDispatchClientDTO(); Long templateId = list.get(0).getTemplateId(); ExpenseDispatchPriceRuleEntity rule = ruleService.getOne(Wrappers.lambdaQuery() .eq(ExpenseDispatchPriceRuleEntity::getTemplateId, templateId) - .eq(ExpenseDispatchPriceRuleEntity::getType, StrUtil.equals(dispatchType, "商配") ? 1: 2) + .eq(ExpenseDispatchPriceRuleEntity::getType, StrUtil.equals(dispatchType, "商配") ? 1 : 2) ); - if(ObjectUtil.isNotEmpty(rule)){ + if (ObjectUtil.isNotEmpty(rule)) { ExpenseDispatchPriceRuleDTO expenseDispatchPriceRuleDTO = BeanUtil.copyProperties(rule, ExpenseDispatchPriceRuleDTO.class); dto.setRule(expenseDispatchPriceRuleDTO); } ExpenseDispatchPriceEntity param = new ExpenseDispatchPriceVO(); param.setCarModel(Convert.toStr(carType)); param.setTemplateId(templateId); - param.setType(StrUtil.equals(dispatchType, "商配") ? 1: 2); + param.setType(StrUtil.equals(dispatchType, "商配") ? 1 : 2); ExpenseDispatchPriceVO detail = priceService.detail(param); dto.setPriceVO(detail); return dto; @@ -64,20 +70,30 @@ public class ExpenseDispatchClient implements IExpenseDispatchClient { return null; } - @Override - public void saveTrainDetailEntity(ExpenseDispatchTrainDetailEntity entity) { + @Override + public void saveTrainDetailEntity(ExpenseDispatchTrainDetailEntity entity) { List list = trainDetailService.list(Wrappers.lambdaQuery() .eq(ExpenseDispatchTrainDetailEntity::getTrainNumber, entity.getTrainNumber()) .eq(ExpenseDispatchTrainDetailEntity::getDeliveryVehicle, entity.getDeliveryVehicle()) ); - if(CollUtil.isNotEmpty(list)){ + if (CollUtil.isNotEmpty(list)) { ExpenseDispatchTrainDetailEntity trainDetailEntity = list.get(0); trainDetailService.update(entity, Wrappers.lambdaUpdate() .eq(ExpenseDispatchTrainDetailEntity::getId, trainDetailEntity.getId())); - }else{ + } else { entity.setSettlementStatus("未结算"); trainDetailService.save(entity); } } + + @Override + public void saveDispatchOrderDetailEntity(ExpenseDispatchOrderDetailEntity orderDetailEntity) { + orderDetailService.save(orderDetailEntity); + } + + @Override + public void saveWarehouseOrderEntity(ExpenseWarehouseOrderEntity orderDetailEntity) { + orderWarehouseTotalService.save(orderDetailEntity); + } } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/job/ExpenseJob.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/job/ExpenseJob.java index 333424d30..67a94363e 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/job/ExpenseJob.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/job/ExpenseJob.java @@ -7,22 +7,27 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; import com.logpm.basicdata.entity.BasicdataWarehouseEntity; import com.logpm.basicdata.entity.WarehouseLeasingEntity; import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.basicdata.feign.IWarehouseLeasingClient; import com.logpm.distribution.entity.QualityDeliverEntity; import com.logpm.distribution.feign.IQualityDeliverClient; +import com.logpm.factorydata.feign.IFactoryDataClient; +import com.logpm.factorydata.vo.SendMsg; import com.logpm.statistics.entity.ExpenseWarehouseDayEntity; import com.logpm.statistics.entity.ExpenseWarehouseMonthEntity; import com.logpm.statistics.service.IExpenseDispatchWarehouseMonthService; import com.logpm.statistics.service.IExpenseWarehouseDayService; import com.logpm.statistics.service.IExpenseWarehouseMonthService; +import com.logpm.trunkline.entity.TrunklineWaybillOrderEntity; import com.logpm.trunkline.feign.ITrunklineCarsLoadScanClient; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.report.ReportConstants; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -59,6 +64,8 @@ public class ExpenseJob { private IExpenseDispatchWarehouseMonthService dispatchWarehouseMonthService; @Resource private ITrunklineCarsLoadScanClient carsLoadScanClient; + @Resource + private IFactoryDataClient factoryDataClient; /** * 仓库月度仓储成本统计表 @@ -133,7 +140,27 @@ public class ExpenseJob { Map> customMap = new HashMap<>(); Map> tempMap = new HashMap<>(); Map> gcpMap = new HashMap<>(); + Map waybillOrderMap = new HashMap<>(); if (CollUtil.isNotEmpty(qualityDeliverEntities)) { + for (QualityDeliverEntity entity : qualityDeliverEntities) { + if (StrUtil.isEmpty(entity.getOrderCode()) || StrUtil.isEmpty(entity.getWaybillNumber())) { + log.info("订单或运单为空,不生成订单总成本报表:id = {}", entity.getId()); + continue; + } + String key = entity.getOrderCode() + entity.getWaybillNumber(); + if (waybillOrderMap.containsKey(key)) { + TrunklineWaybillOrderEntity waybillOrderEntity = waybillOrderMap.get(key); + Integer totalNumber = waybillOrderEntity.getTotalNumber(); + waybillOrderEntity.setTotalNumber(totalNumber + entity.getSignNum()); + } else { + TrunklineWaybillOrderEntity waybillOrderEntity = new TrunklineWaybillOrderEntity(); + waybillOrderEntity.setOrderCode(entity.getOrderCode()); + waybillOrderEntity.setWaybillNo(entity.getWaybillNumber()); + waybillOrderEntity.setTotalNumber(entity.getSignNum()); + waybillOrderMap.put(key, waybillOrderEntity); + } + } + // 每个仓有多少数据 Map> map = qualityDeliverEntities.stream().collect(Collectors.groupingBy(QualityDeliverEntity::getWarehouseId)); for (Map.Entry> longListEntry : map.entrySet()) { @@ -307,6 +334,17 @@ public class ExpenseJob { if (CollUtil.isNotEmpty(packageCostMap)) { qualityDeliverClient.updateWarehouseCost(packageCostMap); } + // 生成订单 发送延时消息生成报表 + if (CollUtil.isNotEmpty(waybillOrderMap)) { + for (Map.Entry entityEntry : waybillOrderMap.entrySet()) { + factoryDataClient.sendMessage(SendMsg.builder() + .exchange(ReportConstants.REPORT_EXPENSE_WAREHOUSE_ORDER_EXCHANGE) + .routingKey(ReportConstants.REPORT_EXPENSE_WAREHOUSE_ORDER_ROUTINGKEY) + .message(JSONUtil.toJsonStr(entityEntry.getValue())) + .delay(10000) + .build()); + } + } } return ReturnT.SUCCESS; } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseDispatchOrderDetailMapper.xml b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseDispatchOrderDetailMapper.xml index 89b13f6b9..94678069c 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseDispatchOrderDetailMapper.xml +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseDispatchOrderDetailMapper.xml @@ -6,8 +6,22 @@ - - + select * + from logpm_expense_dispatch_order_detail t + + + and t.order_code like concat('%',#{expenseDispatchOrderDetail.orderCode},'%') + + + and t.destination_warehouse = #{expenseDispatchOrderDetail.destinationWarehouse} + + + and t.waybill_number like concat('%',#{expenseDispatchOrderDetail.waybillNumber},'%') + + + + + select * + from logpm_expense_warehouse_order + + + and order_code = #{query.orderCode} + + + and shipment_number = #{query.shipmentNumber} + + + and warehouse_name in + + #{item} + + + + +