From d4552ada640ecd1185f70d9f04277fd9be05d79c Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 21 May 2024 09:42:57 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=B9=BF=E6=92=AD=E9=80=9A=E7=9F=A5=E5=BC=80?= =?UTF-8?q?=E5=8D=95=E7=94=9F=E6=88=90=E7=BB=93=E7=AE=97=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/StatisticsOrderInfoEntity.java | 48 ++++ .../entity/StatisticsPackageInfoEntity.java | 168 +++++++++++++ .../vo/TrunklineAdvanceDetailVO.java | 2 + blade-service/logpm-statisticsdata/pom.xml | 6 + .../listener/mq/WaybillFanoutListener.java | 125 +++++++++- .../mapper/StatisticsPackageInfoMapper.java | 9 + .../mapper/StatisticsPackageInfoMapper.xml | 6 + .../IStatisticsPackageInfoService.java | 7 + .../StatisticsPackageInfoServiceImpl.java | 15 ++ .../mapper/TrunklineAdvanceDetailMapper.java | 2 + .../mapper/TrunklineAdvanceDetailMapper.xml | 12 + .../service/IOpenOrderAsyncService.java | 2 +- .../ITrunklineAdvanceDetailService.java | 2 + .../impl/OpenOrderAsyncServiceImpl.java | 234 +++++++++++++++++- .../service/impl/OpenOrderServiceImpl.java | 8 +- .../TrunklineAdvanceDetailServiceImpl.java | 5 + 16 files changed, 634 insertions(+), 17 deletions(-) create mode 100644 blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsOrderInfoEntity.java create mode 100644 blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsPackageInfoEntity.java create mode 100644 blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsPackageInfoMapper.java create mode 100644 blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsPackageInfoMapper.xml create mode 100644 blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsPackageInfoService.java create mode 100644 blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsPackageInfoServiceImpl.java diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsOrderInfoEntity.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsOrderInfoEntity.java new file mode 100644 index 000000000..0569f6671 --- /dev/null +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsOrderInfoEntity.java @@ -0,0 +1,48 @@ +package com.logpm.statistics.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +@Data +@TableName("logpm_statistics_order_info") +@ApiModel(value = "StatisticsOrderInfo对象", description = "结算订单明细表") +@EqualsAndHashCode(callSuper = true) +public class StatisticsOrderInfoEntity extends TenantEntity { + + /** + * 预留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; + + + private String orderCode; + private Long waybillId; + private String waybillNo; + + +} diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsPackageInfoEntity.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsPackageInfoEntity.java new file mode 100644 index 000000000..6a45b3241 --- /dev/null +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/entity/StatisticsPackageInfoEntity.java @@ -0,0 +1,168 @@ +package com.logpm.statistics.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@TableName("logpm_statistics_package_info") +@ApiModel(value = "StatisticsPackageInfo对象", description = "结算包件明细表") +@EqualsAndHashCode(callSuper = true) +public class StatisticsPackageInfoEntity extends TenantEntity { + + /** + * 预留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; + + /** + * 仓库id + */ + @ApiModelProperty(value = "仓库id") + private Long warehouseId; + + /** + * 仓库名称 + */ + @ApiModelProperty(value = "仓库名称") + private String warehouseName; + + /** + * 运单id + */ + @ApiModelProperty(value = "运单id") + private Long waybillId; + + /** + * 运单号 + */ + @ApiModelProperty(value = "运单号") + private String waybillNo; + + /** + * 订单号 + */ + @ApiModelProperty(value = "订单号") + private String orderCode; + + /** + * 包件码 + */ + @ApiModelProperty(value = "包件码") + private String orderPackageCode; + + /** + * 品类名称 + */ + @ApiModelProperty(value = "品类名称") + private String productName; + + /** + * 件数 + */ + @ApiModelProperty(value = "件数") + private Integer totalNum; + + /** + * 重量 + */ + @ApiModelProperty(value = "重量") + private BigDecimal totalWeight; + + @ApiModelProperty(value = "体积") + private BigDecimal totalVolume; + + private BigDecimal openPrice; + private BigDecimal totalPrice; + private BigDecimal pickupFee; + private BigDecimal freightFee; + private Date incomingTime; + private Date outingTime; + private String warehouseFeeInterval; + private BigDecimal warehouseServiceFee; + private BigDecimal warehouseFee; + private BigDecimal warehouseManageFee; + private BigDecimal warehouseSortingFee; + private BigDecimal warehouseOperatingFee; + private BigDecimal deliveryServiceFee; + private BigDecimal deliveryFee; + private BigDecimal deliveryLoadingFee; + private BigDecimal deliverySortingFee; + private BigDecimal deliveryUpfloorFee; + private BigDecimal deliveryMoveFee; + private BigDecimal deliveryDistance; + private BigDecimal deliveryCrossingFee; + private BigDecimal installFee; + private BigDecimal quotationFee; + private BigDecimal claimingValue; + private BigDecimal otherFee; + private BigDecimal returnFee; + private BigDecimal thirdOprationFee; + private BigDecimal xPay; + private BigDecimal dPay; + private BigDecimal hPay; + private BigDecimal yPay; + private Integer isAftersales; + private BigDecimal aftersalesPrice; + private Integer hasStatement; + private Long statementCreateTime; + private String statementCreateUser; + private Integer isZero; + private BigDecimal realPickupFee; + private BigDecimal realFreightFee; + private String realWarehouseFeeInterval; + private BigDecimal realWarehouseServiceFee; + private BigDecimal realWarehouseFee; + private BigDecimal realWarehouseManageFee; + private BigDecimal realWarehouseSortingFee; + private BigDecimal realWarehouseOperatingFee; + private BigDecimal realDeliveryServiceFee; + private BigDecimal realDeliveryFee; + private BigDecimal realDeliveryLoadingFee; + private BigDecimal realDeliverySortingFee; + private BigDecimal realDeliveryUpfloorFee; + private BigDecimal realDeliveryMoveFee; + private BigDecimal realDeliveryDistance; + private BigDecimal realDeliveryCrossingFee; + private BigDecimal realInstallFee; + private BigDecimal realQuotationFee; + private BigDecimal realClaimingValue; + private BigDecimal realOtherFee; + private BigDecimal realReturnFee; + private BigDecimal realThirdOprationFee; + private BigDecimal realXPay; + private BigDecimal realDPay; + private BigDecimal realHPay; + private BigDecimal realYPay; + + private Integer goodsType; //1 订制品 2零担 3库存品 + private String typeService; //1 商配 2市配 3自提 4三方中转 + +} diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/TrunklineAdvanceDetailVO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/TrunklineAdvanceDetailVO.java index 932f3d934..0804e05a1 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/TrunklineAdvanceDetailVO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/TrunklineAdvanceDetailVO.java @@ -11,4 +11,6 @@ public class TrunklineAdvanceDetailVO extends TrunklineAdvanceDetailEntity { private String trayCode; private String trayName; + private String goodsName; + } diff --git a/blade-service/logpm-statisticsdata/pom.xml b/blade-service/logpm-statisticsdata/pom.xml index d4b37f951..ea8762db6 100644 --- a/blade-service/logpm-statisticsdata/pom.xml +++ b/blade-service/logpm-statisticsdata/pom.xml @@ -41,6 +41,12 @@ org.springframework.amqp spring-rabbit + + org.springblade + logpm-statisticsdata-api + 3.2.0.RELEASE + compile + diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/WaybillFanoutListener.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/WaybillFanoutListener.java index d986ba7e9..f942d90b0 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/WaybillFanoutListener.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/WaybillFanoutListener.java @@ -1,10 +1,13 @@ package com.logpm.statistics.listener.mq; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.logpm.statistics.entity.StatisticsPackageInfoEntity; +import com.logpm.statistics.service.IStatisticsPackageInfoService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.broadcast.FanoutConstants; -import org.springblade.core.secure.BladeUser; -import org.springblade.core.secure.utils.AuthUtil; import org.springframework.amqp.core.ExchangeTypes; import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Queue; @@ -13,11 +16,16 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + @Slf4j @Component @AllArgsConstructor public class WaybillFanoutListener { + private final IStatisticsPackageInfoService statisticsPackageInfoService; @RabbitListener(bindings = @QueueBinding( value = @Queue(name = FanoutConstants.trunkline.OPENWAYBILL.QUEUE.STATISTICSDATA_CREATEPACKAGEINFO), @@ -26,13 +34,116 @@ public class WaybillFanoutListener { @Transactional(rollbackFor = Exception.class) public void createPackageInfo(String msg) { - String tenantId = AuthUtil.getTenantId(); - BladeUser user = AuthUtil.getUser(); +// if(StringUtil.isBlank(msg)){ +// log.warn("############createPackageInfo: 接收参数为空 msg={}",msg); +// +// } - log.info("tenantId:{}",tenantId); - log.info("user:{}",user); + JSONObject jsonObject = JSONUtil.parseObj(msg); + Long warehouseId = jsonObject.getLong("warehouseId"); + String warehouseName = jsonObject.getStr("warehouseName"); + Long waybillId = jsonObject.getLong("waybillId"); + String waybillNo = jsonObject.getStr("waybillNo"); - log.info("接收到消息:{}", msg); + List ls = new ArrayList<>(); + JSONArray orderPackageCodes = jsonObject.getJSONArray("orderPackageCodes"); + for (int i = 0; i < orderPackageCodes.size(); i++) { + JSONObject json = orderPackageCodes.getJSONObject(i); + StatisticsPackageInfoEntity statisticsPackageInfoEntity = new StatisticsPackageInfoEntity(); + statisticsPackageInfoEntity.setWarehouseId(warehouseId); + statisticsPackageInfoEntity.setWarehouseName(warehouseName); + statisticsPackageInfoEntity.setTypeService(json.getStr("typeService")); + statisticsPackageInfoEntity.setWaybillId(waybillId); + statisticsPackageInfoEntity.setWaybillNo(waybillNo); + Integer waybillType = json.getInt("waybillType"); + if(waybillType.equals(1)){ + statisticsPackageInfoEntity.setGoodsType(1); + }else if (waybillType.equals(2)){ + statisticsPackageInfoEntity.setGoodsType(2); + }else{ + statisticsPackageInfoEntity.setGoodsType(3); + } + statisticsPackageInfoEntity.setOrderCode(json.getStr("orderCode")); + statisticsPackageInfoEntity.setOrderPackageCode(json.getStr("orderPackageCode")); + statisticsPackageInfoEntity.setProductName(json.getStr("productName")); + statisticsPackageInfoEntity.setTotalNum(json.getInt("totalNum")); + statisticsPackageInfoEntity.setTotalWeight(json.getBigDecimal("totalWeight")); + statisticsPackageInfoEntity.setTotalVolume(json.getBigDecimal("totalVolume")); + statisticsPackageInfoEntity.setOpenPrice(json.getBigDecimal("openPrice")); + statisticsPackageInfoEntity.setTotalPrice(json.getBigDecimal("openPrice")); + statisticsPackageInfoEntity.setPickupFee(json.getBigDecimal("pickupFee")); + statisticsPackageInfoEntity.setRealPickupFee(json.getBigDecimal("pickupFee")); + statisticsPackageInfoEntity.setFreightFee(json.getBigDecimal("freightFee")); + statisticsPackageInfoEntity.setRealFreightFee(json.getBigDecimal("freightFee")); + statisticsPackageInfoEntity.setWarehouseServiceFee(json.getBigDecimal("warehouseServiceFee")); + statisticsPackageInfoEntity.setRealWarehouseServiceFee(json.getBigDecimal("warehouseServiceFee")); + statisticsPackageInfoEntity.setWarehouseFee(json.getBigDecimal("warehouseFee")); + statisticsPackageInfoEntity.setRealWarehouseFee(json.getBigDecimal("warehouseFee")); + statisticsPackageInfoEntity.setWarehouseManageFee(json.getBigDecimal("warehouseManageFee")); + statisticsPackageInfoEntity.setRealWarehouseManageFee(json.getBigDecimal("warehouseManageFee")); + statisticsPackageInfoEntity.setWarehouseSortingFee(json.getBigDecimal("warehouseSortingFee")); + statisticsPackageInfoEntity.setRealWarehouseSortingFee(json.getBigDecimal("warehouseSortingFee")); + statisticsPackageInfoEntity.setWarehouseOperatingFee(json.getBigDecimal("warehouseOperatingFee")); + statisticsPackageInfoEntity.setRealWarehouseOperatingFee(json.getBigDecimal("warehouseOperatingFee")); + statisticsPackageInfoEntity.setDeliveryServiceFee(json.getBigDecimal("deliveryServiceFee")); + statisticsPackageInfoEntity.setRealDeliveryServiceFee(json.getBigDecimal("deliveryServiceFee")); + statisticsPackageInfoEntity.setDeliveryFee(json.getBigDecimal("deliveryFee")); + statisticsPackageInfoEntity.setRealDeliveryFee(json.getBigDecimal("deliveryFee")); + statisticsPackageInfoEntity.setDeliveryLoadingFee(json.getBigDecimal("deliveryLoadingFee")); + statisticsPackageInfoEntity.setRealDeliveryLoadingFee(json.getBigDecimal("deliveryLoadingFee")); + statisticsPackageInfoEntity.setDeliverySortingFee(json.getBigDecimal("deliverySortingFee")); + statisticsPackageInfoEntity.setRealDeliverySortingFee(json.getBigDecimal("deliverySortingFee")); + statisticsPackageInfoEntity.setDeliveryUpfloorFee(json.getBigDecimal("deliveryUpfloorFee")); + statisticsPackageInfoEntity.setRealDeliveryUpfloorFee(json.getBigDecimal("deliveryUpfloorFee")); + statisticsPackageInfoEntity.setDeliveryMoveFee(json.getBigDecimal("deliveryMoveFee")); + statisticsPackageInfoEntity.setRealDeliveryMoveFee(json.getBigDecimal("deliveryMoveFee")); + statisticsPackageInfoEntity.setDeliveryDistance(json.getBigDecimal("deliveryDistance")); + statisticsPackageInfoEntity.setRealDeliveryDistance(json.getBigDecimal("deliveryDistance")); + statisticsPackageInfoEntity.setDeliveryCrossingFee(json.getBigDecimal("deliveryCrossingFee")); + statisticsPackageInfoEntity.setRealDeliveryCrossingFee(json.getBigDecimal("deliveryCrossingFee")); + statisticsPackageInfoEntity.setInstallFee(json.getBigDecimal("installFee")); + statisticsPackageInfoEntity.setRealInstallFee(json.getBigDecimal("installFee")); + statisticsPackageInfoEntity.setQuotationFee(json.getBigDecimal("quotationFee")); + statisticsPackageInfoEntity.setRealQuotationFee(json.getBigDecimal("quotationFee")); + statisticsPackageInfoEntity.setClaimingValue(json.getBigDecimal("claimingValue")); + statisticsPackageInfoEntity.setRealClaimingValue(json.getBigDecimal("claimingValue")); + statisticsPackageInfoEntity.setOtherFee(json.getBigDecimal("otherFee")); + statisticsPackageInfoEntity.setRealOtherFee(json.getBigDecimal("otherFee")); + statisticsPackageInfoEntity.setReturnFee(json.getBigDecimal("returnFee")); + statisticsPackageInfoEntity.setRealReturnFee(json.getBigDecimal("returnFee")); + statisticsPackageInfoEntity.setThirdOprationFee(json.getBigDecimal("thirdOprationFee")); + statisticsPackageInfoEntity.setRealThirdOprationFee(json.getBigDecimal("thirdOprationFee")); + statisticsPackageInfoEntity.setXPay(json.getBigDecimal("xPay")); + statisticsPackageInfoEntity.setRealXPay(json.getBigDecimal("xPay")); + statisticsPackageInfoEntity.setDPay(json.getBigDecimal("dPay")); + statisticsPackageInfoEntity.setRealDPay(json.getBigDecimal("dPay")); + statisticsPackageInfoEntity.setHPay(json.getBigDecimal("hPay")); + statisticsPackageInfoEntity.setRealHPay(json.getBigDecimal("hPay")); + statisticsPackageInfoEntity.setYPay(json.getBigDecimal("yPay")); + statisticsPackageInfoEntity.setRealYPay(json.getBigDecimal("yPay")); + statisticsPackageInfoEntity.setIsAftersales(0); + statisticsPackageInfoEntity.setHasStatement(0); + ls.add(statisticsPackageInfoEntity); + } + statisticsPackageInfoService.saveBatch(ls); + + + //把ls通过typeService=2过滤为一个新的list + List shipeiList = ls.stream().filter(item -> item.getTypeService().equals("2")).collect(Collectors.toList()); + //toC维度 + + + + + List otherList = ls.stream().filter(item -> !item.getTypeService().equals("2")).collect(Collectors.toList()); + //toB维度 + + + + + + + log.info("处理完成:{}", msg); } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsPackageInfoMapper.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsPackageInfoMapper.java new file mode 100644 index 000000000..bebba398d --- /dev/null +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsPackageInfoMapper.java @@ -0,0 +1,9 @@ +package com.logpm.statistics.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.statistics.entity.StatisticsPackageInfoEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface StatisticsPackageInfoMapper extends BaseMapper { +} diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsPackageInfoMapper.xml b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsPackageInfoMapper.xml new file mode 100644 index 000000000..4950ecfc9 --- /dev/null +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsPackageInfoMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsPackageInfoService.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsPackageInfoService.java new file mode 100644 index 000000000..1d612ff60 --- /dev/null +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/IStatisticsPackageInfoService.java @@ -0,0 +1,7 @@ +package com.logpm.statistics.service; + +import com.logpm.statistics.entity.StatisticsPackageInfoEntity; +import org.springblade.core.mp.base.BaseService; + +public interface IStatisticsPackageInfoService extends BaseService { +} diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsPackageInfoServiceImpl.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsPackageInfoServiceImpl.java new file mode 100644 index 000000000..a03fffd56 --- /dev/null +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsPackageInfoServiceImpl.java @@ -0,0 +1,15 @@ +package com.logpm.statistics.service.impl; + +import com.logpm.statistics.entity.StatisticsPackageInfoEntity; +import com.logpm.statistics.mapper.StatisticsPackageInfoMapper; +import com.logpm.statistics.service.IStatisticsPackageInfoService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +@Service +@AllArgsConstructor +@Slf4j +public class StatisticsPackageInfoServiceImpl extends BaseServiceImpl implements IStatisticsPackageInfoService { +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java index 5311d9c8e..81e594af5 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java @@ -62,4 +62,6 @@ public interface TrunklineAdvanceDetailMapper extends BaseMapper advanceIds); List findListByExistsAndOrderPackageCodes(@Param("orderPackageCodeGroup") List orderPackageCodeGroup); + + List findAdvanceDetailVoByAdvanceIds(@Param("advanceIds") List advanceIds); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml index e346aac38..6653c1724 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml @@ -357,5 +357,17 @@ and ltad.is_deleted = 0 + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderAsyncService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderAsyncService.java index b6004aa8b..65ec22511 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderAsyncService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/IOpenOrderAsyncService.java @@ -23,5 +23,5 @@ public interface IOpenOrderAsyncService { void saveUpdateLog(Long waybillId, String waybillNo, String trackType, String refer, String operationRemark, String nickName, Long userId, Long warehouseId, String warehouseName, WarehouseWaybillEntity waybillEntity); - void sendOpenWaybillFanout(WarehouseWaybillEntity waybillEntity, List details); + void sendOpenWaybillFanout(WarehouseWaybillEntity waybillEntity, List details, List advanceIds); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java index 5c4a4983f..9490d3dc3 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java @@ -77,4 +77,6 @@ public interface ITrunklineAdvanceDetailService extends BaseService findListByExistsAndOrderPackageCodes(List orderPackageCodeGroup); + List findAdvanceDetailVoByAdvanceIds(List advanceIds); + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderAsyncServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderAsyncServiceImpl.java index 567b736fd..c75c2cba8 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderAsyncServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderAsyncServiceImpl.java @@ -1,12 +1,17 @@ package com.logpm.trunkline.service.impl; import com.alibaba.fastjson.JSONObject; +import com.logpm.basicdata.entity.BasicdataClientEntity; +import com.logpm.basicdata.entity.BasicdataStoreBusinessEntity; +import com.logpm.basicdata.feign.IBasicdataClientClient; +import com.logpm.basicdata.feign.IBasicdataStoreBusinessClient; import com.logpm.trunkline.dto.InComingDTO; import com.logpm.trunkline.entity.TrunklineCarsLoadEntity; import com.logpm.trunkline.entity.TrunklineCarsLoadLineEntity; import com.logpm.trunkline.entity.TrunklineWaybillTrackEntity; import com.logpm.trunkline.service.*; import com.logpm.trunkline.vo.LoadScanWaybillVO; +import com.logpm.trunkline.vo.TrunklineAdvanceDetailVO; import com.logpm.warehouse.entity.WarehouseWayBillDetail; import com.logpm.warehouse.entity.WarehouseWaybillEntity; import com.logpm.warehouse.feign.IWarehouseWaybillClient; @@ -23,9 +28,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import java.util.Date; -import java.util.List; -import java.util.Objects; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; @Service @Slf4j @@ -47,6 +54,12 @@ public class OpenOrderAsyncServiceImpl implements IOpenOrderAsyncService { private IInComingService inComingService; @Autowired private ISendFanoutService sendFanoutService; + @Autowired + private ITrunklineAdvanceDetailService advanceDetailService; + @Autowired + private IBasicdataClientClient basicdataClientClient; + @Autowired + private IBasicdataStoreBusinessClient basicdataStoreBusinessClient; @LogpmAsync("asyncExecutor") @Override @@ -303,11 +316,220 @@ public class OpenOrderAsyncServiceImpl implements IOpenOrderAsyncService { @LogpmAsync("asyncExecutor") @Override - public void sendOpenWaybillFanout(WarehouseWaybillEntity waybillEntity, List details) { + public void sendOpenWaybillFanout(WarehouseWaybillEntity waybillEntity, List details,List advanceIds) { + + Integer waybillType = waybillEntity.getWaybillType(); + String waybillNo = waybillEntity.getWaybillNo(); JSONObject jsonObject = new JSONObject(); - jsonObject.put("waybillNo",waybillEntity.getWaybillNo()); - jsonObject.put("waybillType",waybillEntity.getWaybillType()); + jsonObject.put("warehouseId",waybillEntity.getDepartureWarehouseId()); + jsonObject.put("warehouseName",waybillEntity.getDepartureWarehouseName()); + jsonObject.put("waybillId",waybillEntity.getId()); + jsonObject.put("waybillNo",waybillNo); + jsonObject.put("waybillType",waybillType); + Long consigneeId = waybillEntity.getConsigneeId(); + BasicdataClientEntity basicdataClientEntity = basicdataClientClient.getMallById(consigneeId); + if(Objects.isNull(basicdataClientEntity)){ + jsonObject.put("typeService","1"); + }else{ + BasicdataStoreBusinessEntity storeBusinessEntity = basicdataStoreBusinessClient.findByClientIdAndTypeService(consigneeId, 3); + if(Objects.isNull(storeBusinessEntity)){ + jsonObject.put("typeService","1"); + }else{ + jsonObject.put("typeService",storeBusinessEntity.getMold()); + } + } + + + Integer totalCount = waybillEntity.getTotalCount(); + BigDecimal pickupFee = waybillEntity.getPickupFee(); + BigDecimal pickupPrice = pickupFee.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal installFee = waybillEntity.getInstallFee(); + BigDecimal installPrice = installFee.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal insuranceFee = waybillEntity.getInsuranceFee(); + BigDecimal insurancePrice = insuranceFee.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal claimingValue = waybillEntity.getClaimingValue(); + BigDecimal claimingPrice = claimingValue.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal otherFee = waybillEntity.getOtherFee(); + BigDecimal otherPrice = otherFee.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal rebate = waybillEntity.getRebate(); + BigDecimal rebatePrice = rebate.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal thirdOperationFee = waybillEntity.getThirdOperationFee(); + BigDecimal thirdOperationPrice = thirdOperationFee.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal xPay = waybillEntity.getXPay(); + BigDecimal xPayPrice = xPay.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal dPay = waybillEntity.getDPay(); + BigDecimal dPayPrice = dPay.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal hPay = waybillEntity.getHPay(); + BigDecimal hPayPrice = hPay.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + BigDecimal yPay = waybillEntity.getYPay(); + BigDecimal yPayPrice = yPay.divide(new BigDecimal(totalCount), 2, RoundingMode.HALF_UP); + + //把details转化成不分组以productName为key的map + Map detailsMap = details.stream() + .collect(Collectors.toMap(WarehouseWayBillDetail::getProductName, detail -> detail, (a, b) -> a)); + + if(waybillType.equals(1)){ + //订制品 + List list = advanceDetailService.findAdvanceDetailVoByAdvanceIds(advanceIds); + //把list按goodsName分组,并统计一个count,转成一个map +// Map countMap = list.stream() +// .collect(Collectors.toMap(TrunklineAdvanceDetailVO::getGoodsName, TrunklineAdvanceDetailVO::getQuantity, Integer::sum)); +// countMap.keySet().forEach(goodsName -> { +// WarehouseWayBillDetail warehouseWayBillDetail = detailsMap.get(goodsName); +// +// +// +// }); + + + + List jsonList = new ArrayList<>(); + list.forEach(advanceDetailVO -> { + JSONObject json = new JSONObject(); + BigDecimal openPrice = BigDecimal.ZERO; + json.put("orderPackageCode",advanceDetailVO.getOrderPackageCode()); + json.put("orderCode",advanceDetailVO.getOrderCode()); + json.put("productName",advanceDetailVO.getFirstPackName()); + json.put("totalNum",advanceDetailVO.getQuantity()); + json.put("totalWeight",advanceDetailVO.getWeight()); + json.put("totalVolume",advanceDetailVO.getVolume()); + String goodsName = advanceDetailVO.getGoodsName(); + WarehouseWayBillDetail warehouseWayBillDetail = detailsMap.get(goodsName); + if(!Objects.isNull(warehouseWayBillDetail)){ + Integer num = warehouseWayBillDetail.getNum(); + if(num > 0){ + json.put("freightFee",warehouseWayBillDetail.getPrice()); + openPrice = openPrice.add(warehouseWayBillDetail.getPrice()); + json.put("deliveryFee",warehouseWayBillDetail.getDeliveryPrice()); + json.put("deliveryServiceFee",warehouseWayBillDetail.getDeliveryPrice()); + openPrice = openPrice.add(warehouseWayBillDetail.getDeliveryPrice()); + warehouseWayBillDetail.setNum(num-1); + detailsMap.put(goodsName,warehouseWayBillDetail); + } + } + json.put("warehouseServiceFee",BigDecimal.ZERO); + json.put("warehouseFee",BigDecimal.ZERO); + json.put("warehouseManageFee",BigDecimal.ZERO); + json.put("warehouseSortingFee",BigDecimal.ZERO); + json.put("warehouseOperatingFee",BigDecimal.ZERO); + json.put("pickupFee",pickupPrice); + openPrice = openPrice.add(pickupPrice); + json.put("deliveryLoadingFee",BigDecimal.ZERO); + json.put("deliverySortingFee",BigDecimal.ZERO); + json.put("deliveryUpfloorFee",BigDecimal.ZERO); + json.put("deliveryMoveFee",BigDecimal.ZERO); + json.put("deliveryDistance",BigDecimal.ZERO); + json.put("deliveryCrossingFee",BigDecimal.ZERO); + json.put("installFee",installPrice); + json.put("quotationFee",insurancePrice); + json.put("claimingValue",claimingPrice); + json.put("otherFee",otherPrice); + json.put("returnFee",rebatePrice); + json.put("thirdOprationFee",thirdOperationPrice); + json.put("xPay",xPayPrice); + json.put("dPay",dPayPrice); + json.put("hPay",hPayPrice); + json.put("yPay",yPayPrice); + openPrice = openPrice.add(installPrice).add(insurancePrice).add(claimingPrice).add(otherPrice).add(rebatePrice).add(thirdOperationPrice).add(xPayPrice).add(dPayPrice).add(hPayPrice).add(yPayPrice); + json.put("openPrice",openPrice); + jsonList.add(json); + }); + + + AtomicInteger atomicOtherNum = new AtomicInteger(); + List otherTotalPriceList = new ArrayList<>(); + List otherTotalDeliveryPriceList = new ArrayList<>(); + detailsMap.values().forEach(warehouseWayBillDetail -> { + if (warehouseWayBillDetail != null && warehouseWayBillDetail.getNum() > 0) { + Integer num = warehouseWayBillDetail.getNum(); + atomicOtherNum.addAndGet(num); + + // 使用 BigDecimal 的 add 方法来正确累加总价,确保精度 + otherTotalPriceList.add(warehouseWayBillDetail.getPrice().multiply(new BigDecimal(num))); + otherTotalDeliveryPriceList.add(warehouseWayBillDetail.getDeliveryPrice().multiply(new BigDecimal(num))); + } + }); + + int otherNum = atomicOtherNum.get(); + //otherTotalPriceList元素求和 + BigDecimal otherTotalPrice = otherTotalPriceList.stream().reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal p = otherTotalPrice.divide(new BigDecimal(otherNum), 2, RoundingMode.HALF_UP); + BigDecimal otherTotalDeliveryPrice = otherTotalDeliveryPriceList.stream().reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal dp = otherTotalDeliveryPrice.divide(new BigDecimal(otherNum), 2, RoundingMode.HALF_UP); + + jsonList.forEach(json -> { + BigDecimal op = json.getBigDecimal("openPrice"); + BigDecimal freightFee = json.getBigDecimal("freightFee"); + if(Objects.isNull(freightFee)){ + json.put("freightFee",p); + op = op.add(p); + } + BigDecimal deliveryFee = json.getBigDecimal("deliveryFee"); + if(Objects.isNull(deliveryFee)){ + json.put("deliveryFee",dp); + json.put("deliveryServiceFee",dp); + op = op.add(dp); + } + json.put("openPrice",op); + }); + jsonObject.put("orderPackageCodes",jsonList); + + }else if(waybillType.equals(2)){ + //零担 + List jsonList = new ArrayList<>(); + details.forEach(detail -> { + Integer num = detail.getNum(); + JSONObject json = new JSONObject(); + BigDecimal openPrice = BigDecimal.ZERO; + json.put("orderPackageCode",detail.getProductName()); + json.put("orderCode",waybillNo); + json.put("productName",detail.getProductName()); + json.put("totalNum",num); + json.put("totalWeight",detail.getWeight()); + json.put("totalVolume",detail.getVolume()); + json.put("freightFee",detail.getSubtotalFreight()); + openPrice = openPrice.add(detail.getSubtotalFreight()); + json.put("deliveryFee",detail.getSubtotalDeliveryFee()); + openPrice = openPrice.add(detail.getSubtotalDeliveryFee()); + json.put("warehouseServiceFee",BigDecimal.ZERO); + json.put("warehouseFee",BigDecimal.ZERO); + json.put("warehouseManageFee",BigDecimal.ZERO); + json.put("warehouseSortingFee",BigDecimal.ZERO); + json.put("warehouseOperatingFee",BigDecimal.ZERO); + json.put("pickupFee",pickupPrice.multiply(new BigDecimal(num))); + openPrice = openPrice.add(pickupPrice.multiply(new BigDecimal(num))); + json.put("deliveryLoadingFee",BigDecimal.ZERO); + json.put("deliverySortingFee",BigDecimal.ZERO); + json.put("deliveryUpfloorFee",BigDecimal.ZERO); + json.put("deliveryMoveFee",BigDecimal.ZERO); + json.put("deliveryDistance",BigDecimal.ZERO); + json.put("deliveryCrossingFee",BigDecimal.ZERO); + json.put("installFee",installPrice); + openPrice = openPrice.add(installPrice.multiply(new BigDecimal(num))); + json.put("quotationFee",insurancePrice); + openPrice = openPrice.add(insurancePrice.multiply(new BigDecimal(num))); + json.put("claimingValue",claimingPrice); + openPrice = openPrice.add(claimingPrice.multiply(new BigDecimal(num))); + json.put("otherFee",otherPrice); + openPrice = openPrice.add(otherPrice.multiply(new BigDecimal(num))); + json.put("returnFee",rebatePrice); + openPrice = openPrice.add(rebatePrice.multiply(new BigDecimal(num))); + json.put("thirdOprationFee",thirdOperationPrice); + openPrice = openPrice.add(thirdOperationPrice.multiply(new BigDecimal(num))); + json.put("xPay",xPayPrice); + openPrice = openPrice.add(xPayPrice.multiply(new BigDecimal(num))); + json.put("dPay",dPayPrice); + openPrice = openPrice.add(dPayPrice.multiply(new BigDecimal(num))); + json.put("hPay",hPayPrice); + openPrice = openPrice.add(hPayPrice.multiply(new BigDecimal(num))); + json.put("yPay",yPayPrice); + openPrice = openPrice.add(yPayPrice.multiply(new BigDecimal(num))); + json.put("openPrice",openPrice); + jsonList.add(json); + }); + jsonObject.put("orderPackageCodes",jsonList); + } FanoutMsg build = FanoutMsg.builder().msg(jsonObject.toJSONString()) .exchange(FanoutConstants.trunkline.OPENWAYBILL.EXCHANGE).build(); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index 14242afa4..1cf152bef 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -470,11 +470,11 @@ public class OpenOrderServiceImpl implements IOpenOrderService { Long waybillId = warehouseWaybillClient.addEnntity(waybillEntity); waybillEntity.setId(waybillId); + List details = new ArrayList<>(); if (!Objects.isNull(waybillId)) { log.info("#################openWaybill: 运单保存成功"); //保存运单货物明细 List waybillDetailList = openOrderDTO.getWaybillDetailList(); - List details = new ArrayList<>(); for (WaybillDetailDTO waybillDetailDTO : waybillDetailList) { WarehouseWayBillDetail warehouseWayBillDetail = new WarehouseWayBillDetail(); warehouseWayBillDetail.setWaybillId(waybillId); @@ -630,9 +630,11 @@ public class OpenOrderServiceImpl implements IOpenOrderService { } //队列处理包件补数据 - carsLoadService.sendRabbitMessageOpenOrder(advanceIds, waybillId); + //发布开单广播 +// openOrderAsyncService.sendOpenWaybillFanout(waybillEntity, details, advanceIds); + Map map = new HashMap<>(); map.put("waybillId",waybillId); return R.data(map); @@ -841,7 +843,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { trunklineWaybillOrderService.save(trunklineWaybillOrderEntity); //发布开单广播 - openOrderAsyncService.sendOpenWaybillFanout(waybillEntity, details); +// openOrderAsyncService.sendOpenWaybillFanout(waybillEntity, details, null); Map map = new HashMap<>(); map.put("waybillId",waybillId); diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java index 3dbeafe4d..1b425ee64 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineAdvanceDetailServiceImpl.java @@ -295,4 +295,9 @@ public class TrunklineAdvanceDetailServiceImpl extends BaseServiceImpl findListByExistsAndOrderPackageCodes(List orderPackageCodeGroup) { return baseMapper.findListByExistsAndOrderPackageCodes(orderPackageCodeGroup); } + + @Override + public List findAdvanceDetailVoByAdvanceIds(List advanceIds) { + return baseMapper.findAdvanceDetailVoByAdvanceIds(advanceIds); + } }