Browse Source

feat(all): 仓储配送成本统计

1 修改订单维度的成本统计逻辑
fix-sign
zhaoqiaobo 3 months ago
parent
commit
ff741a6117
  1. 12
      blade-biz-common/src/main/java/org/springblade/common/constant/report/ReportConstants.java
  2. 45
      blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/QualityDeliverEntity.java
  3. 58
      blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseDispatchOrderDetailEntity.java
  4. 34
      blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/ExpenseWarehouseOrderEntity.java
  5. 7
      blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/feign/IExpenseDispatchClient.java
  6. 54
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java
  7. 53
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java
  8. 48
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportListener.java
  9. 5
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IQualityDeliverService.java
  10. 176
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/QualityDeliverServiceImpl.java
  11. 5
      blade-service/logpm-statisticsdata/pom.xml
  12. 32
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/feign/ExpenseDispatchClient.java
  13. 38
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/job/ExpenseJob.java
  14. 18
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseDispatchOrderDetailMapper.xml
  15. 18
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseOrderWarehouseTotalMapper.xml
  16. 48
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseOrderVO.java

12
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;
}

45
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;
}

58
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;
}

34
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;
}

7
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);
}

54
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<String, List<QualityDeliverEntity>> 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<String, List<QualityDeliverEntity>> entry : collect.entrySet()) {
List<QualityDeliverEntity> value = entry.getValue();
// 根据车查询出司机id
List<String> 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<ExpenseDispatchPriceOverZoneEntity> overZoneList = priceVO.getOverZoneList();
Map<String, ExpenseDispatchPriceOverZoneEntity> overZoneEntityMap = new HashMap<>();
if (CollUtil.isNotEmpty(overZoneList)) {
@ -901,11 +901,43 @@ public class DeliverFinishReportListener implements ReportService {
));
sendReport(BizOperationEnums.MODIFY, entityEntry.getValue(), BizOperationEnums.MODIFY);
}
Map<String, TrunklineWaybillOrderEntity> waybillOrderMap = new HashMap<>();
Collection<QualityDeliverEntity> 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<String, TrunklineWaybillOrderEntity> 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<Long, QualityDeliverEntity> valueMap, BigDecimal mul, Integer totalNum) {
@ -925,6 +957,7 @@ public class DeliverFinishReportListener implements ReportService {
idex++;
}
}
private static void buildPointAllowCost(Map<Long, QualityDeliverEntity> 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<Long, QualityDeliverEntity> valueMap, BigDecimal mul, Integer totalNum) {
BigDecimal deliveryFeeSum = BigDecimal.ZERO;
int idex = 0;

53
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());
}
}
}

48
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<? extends ReportService> clazz) {

5
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<QualityDeliverEntity
void delDistributionCarStart(Long id);
void carExpenseDispatchDetailFinal(String trainNumber);
void orderExpenseDispatchDetailFinal(JSONArray objects);
void expenseWarehouseOrder(JSONArray objects);
}

176
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<QualityDeliverMap
}
}
@Override
public void orderExpenseDispatchDetailFinal(JSONArray objects) {
// 生成配送订单总成本
if (CollUtil.isNotEmpty(objects)) {
List<TrunklineWaybillOrderEntity> list = JSONUtil.toList(objects, TrunklineWaybillOrderEntity.class);
TrunklineWaybillOrderEntity entity = list.get(0);
List<QualityDeliverEntity> qualityDeliverEntities = baseMapper.selectList(Wrappers.<QualityDeliverEntity>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<TrunklineWaybillOrderEntity> list = JSONUtil.toList(objects, TrunklineWaybillOrderEntity.class);
TrunklineWaybillOrderEntity entity = list.get(0);
List<QualityDeliverEntity> qualityDeliverEntities = baseMapper.selectList(Wrappers.<QualityDeliverEntity>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);
}
}
}
}
}

5
blade-service/logpm-statisticsdata/pom.xml

@ -78,6 +78,11 @@
<version>3.2.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>logpm-factory-data-api</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
</dependencies>
<build>

32
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.<ExpenseDispatchPriceRuleEntity>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<ExpenseDispatchTrainDetailEntity> list = trainDetailService.list(Wrappers.<ExpenseDispatchTrainDetailEntity>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.<ExpenseDispatchTrainDetailEntity>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);
}
}

38
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<Long, List<QualityDeliverEntity>> customMap = new HashMap<>();
Map<Long, List<QualityDeliverEntity>> tempMap = new HashMap<>();
Map<Long, List<QualityDeliverEntity>> gcpMap = new HashMap<>();
Map<String, TrunklineWaybillOrderEntity> 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<Long, List<QualityDeliverEntity>> map = qualityDeliverEntities.stream().collect(Collectors.groupingBy(QualityDeliverEntity::getWarehouseId));
for (Map.Entry<Long, List<QualityDeliverEntity>> longListEntry : map.entrySet()) {
@ -307,6 +334,17 @@ public class ExpenseJob {
if (CollUtil.isNotEmpty(packageCostMap)) {
qualityDeliverClient.updateWarehouseCost(packageCostMap);
}
// 生成订单 发送延时消息生成报表
if (CollUtil.isNotEmpty(waybillOrderMap)) {
for (Map.Entry<String, TrunklineWaybillOrderEntity> 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;
}

18
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseDispatchOrderDetailMapper.xml

@ -6,8 +6,22 @@
<resultMap id="expenseDispatchOrderDetailResultMap" type="com.logpm.statistics.entity.ExpenseDispatchOrderDetailEntity">
</resultMap>
<select id="selectExpenseDispatchOrderDetailPage" resultMap="expenseDispatchOrderDetailResultMap">
<select id="selectExpenseDispatchOrderDetailPage" resultType="com.logpm.statistics.vo.ExpenseDispatchOrderDetailVO">
select *
from logpm_expense_dispatch_order_detail t
<where>
<if test="expenseDispatchOrderDetail.orderCode != null and expenseDispatchOrderDetail.orderCode != ''">
and t.order_code like concat('%',#{expenseDispatchOrderDetail.orderCode},'%')
</if>
<if test="expenseDispatchOrderDetail.destinationWarehouse != null and expenseDispatchOrderDetail.destinationWarehouse != ''">
and t.destination_warehouse = #{expenseDispatchOrderDetail.destinationWarehouse}
</if>
<if test="expenseDispatchOrderDetail.waybillNumber != null and expenseDispatchOrderDetail.waybillNumber != ''">
and t.waybill_number like concat('%',#{expenseDispatchOrderDetail.waybillNumber},'%')
</if>
</where>
</select>
<select id="selectExpenseDispatchOrderDetailPage" resultType="com.logpm.statistics.vo.ExpenseDispatchOrderDetailVO">
select t.order_code orderCode,
t.waybill_number waybillNumber,
t.brand_name brand,

18
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/ExpenseOrderWarehouseTotalMapper.xml

@ -8,6 +8,24 @@
<select id="selectExpenseOrderWarehouseTotalPage" resultType="com.logpm.statistics.vo.ExpenseWarehouseOrderVO">
select *
from logpm_expense_warehouse_order
<where>
<if test="query.orderCode != null and query.orderCode != ''">
and order_code = #{query.orderCode}
</if>
<if test="query.shipmentNumber != null and query.shipmentNumber != ''">
and shipment_number = #{query.shipmentNumber}
</if>
<if test="query.warehouseName != null and query.warehouseName != ''">
and warehouse_name in
<foreach collection="query.warehouseName.split(',')" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectExpenseOrderWarehouseTotalPage1" resultType="com.logpm.statistics.vo.ExpenseWarehouseOrderVO">
select * from (
select warehouse_name warehouseName,
order_code orderCode,

48
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/vo/ExpenseWarehouseOrderVO.java

@ -71,41 +71,47 @@ public class ExpenseWarehouseOrderVO {
@ExcelProperty("发货单位")
private String shippingUnit;
/**
* 发货单位
* 运单类型
*/
@ApiModelProperty(value = "配送类型")
@ExcelProperty("配送类型")
@ApiModelProperty(value = "运单类型")
@ExcelProperty("运单类型")
private String deliveryType;
/**
* 复核状态
*/
@ApiModelProperty(value = "复核状态 已完成 未完成")
@ExcelProperty("复核状态")
private String reviewStatus;
/**
* 发站仓
*/
@ApiModelProperty(value = "发站仓")
@ExcelProperty("发站仓")
private String originWarehouse;
// /**
// * 复核状态
// */
// @ApiModelProperty(value = "复核状态 已完成 未完成")
// @ExcelProperty("复核状态")
// private String reviewStatus;
/**
* 订单总件数
* 订单运单总件数
*/
@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;
/**
* 复核完成时间
*/
@ApiModelProperty(value = "复核完成时间")
@ExcelProperty("复核完成时间")
private String reviewCompletionTime;
}

Loading…
Cancel
Save