From d84368ae14d2481ad5b1015e975eab46d9be3c5e Mon Sep 17 00:00:00 2001 From: zhaoqiaobo <583671871@qq.com> Date: Mon, 2 Sep 2024 17:28:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E5=A2=9E=E5=8A=A0=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/IBasicdataWarehouseClient.java | 3 + .../report/entity/QualityDeliverEntity.java | 492 ++++++++++++++++++ .../feign/BasicdataWarehouseClient.java | 36 ++ blade-service/logpm-distribution/pom.xml | 5 + .../receiver/report/PlanReportListener.java | 125 +++++ 5 files changed, 661 insertions(+) create mode 100644 blade-service-api/logpm-report-api/src/main/java/com/logpm/report/entity/QualityDeliverEntity.java create mode 100644 blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/PlanReportListener.java diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java index 50f2500ad..d71f7d28b 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java @@ -127,5 +127,8 @@ public interface IBasicdataWarehouseClient { @GetMapping(API_PREFIX + "/findWarehouseList") List findWarehouseList(@RequestParam("warehouseName") String warehouseName); + + @GetMapping(API_PREFIX + "/findWarehousesByIds") + List findWarehousesByIds(@RequestParam("ids") List ids); } diff --git a/blade-service-api/logpm-report-api/src/main/java/com/logpm/report/entity/QualityDeliverEntity.java b/blade-service-api/logpm-report-api/src/main/java/com/logpm/report/entity/QualityDeliverEntity.java new file mode 100644 index 000000000..204494d4a --- /dev/null +++ b/blade-service-api/logpm-report-api/src/main/java/com/logpm/report/entity/QualityDeliverEntity.java @@ -0,0 +1,492 @@ +package com.logpm.report.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 配送明细 + * + * @author zqb + * @create 2024-08-23 + */ +@Data +@TableName("logpm_quality_deliver") +@ApiModel(value = "QualityDeliver对象", description = "配送明细") +@EqualsAndHashCode(callSuper = true) +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class QualityDeliverEntity extends TenantEntity { + private static final long serialVersionUID = 1L; + /** + * 事业线 + */ + @ApiModelProperty(value = "事业线") + private String businessUnit; + /** + * 作业仓库 + */ + @ApiModelProperty(value = "作业仓库") + private String warehouseName; + /** + * 作业仓库ID + */ + @ApiModelProperty(value = "作业仓库ID") + private Long warehouseId; + /** + * 品牌 + */ + @ApiModelProperty(value = "品牌") + private String brandName; + /** + * 客户名称 + */ + @ApiModelProperty(value = "客户名称") + private String customName; + /** + * 客户电话 + */ + @ApiModelProperty(value = "客户电话") + private String customPhone; + /** + * 客户地址 + */ + @ApiModelProperty(value = "客户地址") + private String customAddress; + /** + * 运单发货单位 + */ + @ApiModelProperty(value = "运单发货单位") + private String shipperUnit; + /** + * 运单发货人 + */ + @ApiModelProperty(value = "运单发货人") + private String shipperPerson; + /** + * 运单发货电话 + */ + @ApiModelProperty(value = "运单发货电话") + private String shipperMobile; + /** + * 运单发货地址 + */ + @ApiModelProperty(value = "运单发货地址") + private String shipperAddress; + /** + * 运单收货单位 + */ + @ApiModelProperty(value = "运单收货单位") + private String consigneeUnit; + /** + * 运单收货人 + */ + @ApiModelProperty(value = "运单收货人") + private String consigneePerson; + /** + * 运单收货电话 + */ + @ApiModelProperty(value = "运单收货电话") + private String consigneeMobile; + /** + * 运单收货地址 + */ + @ApiModelProperty(value = "运单收货地址") + private String consigneeAddress; + /** + * 运单号 + */ + @ApiModelProperty(value = "运单号") + private String waybillNumber; + /** + * 商场名称 + */ + @ApiModelProperty(value = "商场名称") + private String mallName; + /** + * 商场ID + */ + @ApiModelProperty(value = "商场ID") + private Long mallId; + /** + * 入库批次号 + */ + @ApiModelProperty(value = "入库批次号") + private String incomingBatch; + /** + * 订单号 + */ + @ApiModelProperty(value = "订单号") + private String orderCode; + /** + * 包条码 + */ + @ApiModelProperty(value = "包条码") + private String orderPackageCode; + /** + * 客户车次号 + */ + @ApiModelProperty(value = "客户车次号") + private String trainNumber; + /** + * 数据类型 1 定制品 2 库存品 3零担 + */ + @ApiModelProperty(value = "数据类型 1 定制品 2 库存品 3零担") + private Integer conditions; + /** + * 一级品 + */ + @ApiModelProperty(value = "一级品") + private String firstsProduct; + /** + * 二级品 + */ + @ApiModelProperty(value = "二级品") + private String secondProduct; + /** + * 三级品 + */ + @ApiModelProperty(value = "三级品") + private String thirdProduct; + /** + * 体积 + */ + @ApiModelProperty(value = "体积") + private BigDecimal volume; + /** + * 重量 + */ + @ApiModelProperty(value = "重量") + private BigDecimal weight; + /** + * 成本结算品类 + */ + @ApiModelProperty(value = "成本结算品类") + private String costCategory; + /** + * 收入结算品类 + */ + @ApiModelProperty(value = "收入结算品类") + private String revenueCategory; + /** + * 物料信息 + */ + @ApiModelProperty(value = "物料信息") + private String materielName; + /** + * 物料编码 + */ + @ApiModelProperty(value = "物料编码") + private String materielCode; + /** + * 始发仓 + */ + @ApiModelProperty(value = "始发仓") + private String beginWarehouseName; + /** + * 始发仓入库时间 + */ + @ApiModelProperty(value = "始发仓入库时间") + private Date beginWarehouseInTime; + /** + * 始发仓发货时间 + */ + @ApiModelProperty(value = "始发仓发货时间") + private Date beginWarehouseOutTime; + /** + * 末端仓入库时间 + */ + @ApiModelProperty(value = "末端仓入库时间") + private String endWarehouseInTime; + /** + * 计划配送单号 包含配送车次和自提车次 直发商家 对应干线车次 三方中转 三方中转车次号 + */ + @ApiModelProperty(value = "计划配送单号 包含配送车次和自提车次 直发商家 对应干线车次 三方中转 三方中转车次号") + private String planTrainNumber; + /** + * 计划预约单号 只有商市配,自提采用自提车次号 三方中转采用三方中转车次号 + */ + @ApiModelProperty(value = "计划预约单号 只有商市配,自提采用自提车次号 三方中转采用三方中转车次号") + private String planReservationCode; + /** + * 配送日期 + */ + @ApiModelProperty(value = "配送日期") + private Date deliveryTime; + /** + * 配送类型2市配 1商配 3自提 4三方中转(5直发商家 【签收节点进行驱动】) 没有这个字段 + */ + @ApiModelProperty(value = "配送类型2市配 1商配 3自提 4三方中转(5直发商家 【签收节点进行驱动】) 没有这个字段") + private String deliveryType; + /** + * 配送种类 + */ + @ApiModelProperty(value = "配送种类") + private String deliveryKind; + /** + * 配送车辆 存在多个逗号拼接 + */ + @ApiModelProperty(value = "配送车辆 存在多个逗号拼接") + private String vehicleName; + /** + * 配送司机 存在多个逗号拼接 + */ + @ApiModelProperty(value = "配送司机 存在多个逗号拼接") + private String driverName; + /** + * 配送公司 + */ + @ApiModelProperty(value = "配送公司") + private String distributionCompany; + /** + * 计划时间 + */ + @ApiModelProperty(value = "计划时间") + private Date deliveryPlanTime; + /** + * 计划数量 + */ + @ApiModelProperty(value = "计划数量") + private Integer planNum; + /** + * 计划类型(新增 补录) + */ + @ApiModelProperty(value = "计划类型(新增 补录)") + private String planType; + /** + * 计划人 + */ + @ApiModelProperty(value = "计划人") + private String deliveryCreateUserName; + /** + * 备货单号 + */ + @ApiModelProperty(value = "备货单号") + private String stockupCode; + /** + * 备货人 + */ + @ApiModelProperty(value = "备货人") + private String stockupUserName; + /** + * 备货时间 + */ + @ApiModelProperty(value = "备货时间") + private Date stockupFinishTime; + /** + * 备货数量 + */ + @ApiModelProperty(value = "备货数量") + private Integer stockNum; + /** + * 备货区 + */ + @ApiModelProperty(value = "备货区") + private String stockAllocation; + /** + * 备货类型(新增 补录) + */ + @ApiModelProperty(value = "备货类型(新增 补录)") + private String stockupType; + /** + * 装车人 + */ + @ApiModelProperty(value = "装车人") + private String loadUserName; + /** + * 装车时间 + */ + @ApiModelProperty(value = "装车时间") + private Date loadTime; + /** + * 装车配送单号 包含配送车次和自提车次 直发商家 对应干线车次 三方中转 三方中转车次号 + */ + @ApiModelProperty(value = "装车配送单号 包含配送车次和自提车次 直发商家 对应干线车次 三方中转 三方中转车次号") + private String loadTrainNumber; + /** + * 装车数量 + */ + @ApiModelProperty(value = "装车数量") + private Integer loadNum; + /** + * 装车类型(按件装车 一键装车 补录) + */ + @ApiModelProperty(value = "装车类型(按件装车 一键装车 补录)") + private String loadType; + /** + * 发车人 + */ + @ApiModelProperty(value = "发车人") + private String startCarUserName; + /** + * 发车时间 + */ + @ApiModelProperty(value = "发车时间") + private String startCarTime; + /** + * 到达人 + */ + @ApiModelProperty(value = "到达人") + private String arriveCarUserName; + /** + * 到达时间 + */ + @ApiModelProperty(value = "到达时间") + private String arriveCarTime; + /** + * 到达省 + */ + @ApiModelProperty(value = "到达省") + private String arriveProvince; + /** + * 到达市 + */ + @ApiModelProperty(value = "到达市") + private String arriveCity; + /** + * 到达区/县 + */ + @ApiModelProperty(value = "到达区/县") + private String arriveDistrict; + /** + * 到达地址 + */ + @ApiModelProperty(value = "到达地址") + private String arriveAddress; + /** + * 签收人 + */ + @ApiModelProperty(value = "签收人") + private String signUserName; + /** + * 签收时间 + */ + @ApiModelProperty(value = "签收时间") + private String signTime; + /** + * 签收状态 1.已签收 0 未签收 -1 已回库 -2 滞留 + */ + @ApiModelProperty(value = "签收状态 1.已签收 0 未签收 -1 已回库 -2 滞留") + private String signStatus; + /** + * 签收数量 + */ + @ApiModelProperty(value = "签收数量") + private String signNum; + /** + * 签收配送单号 包含配送车次和自提车次 直发商家 对应干线车次 三方中转 三方中转车次号 + */ + @ApiModelProperty(value = "签收配送单号 包含配送车次和自提车次 直发商家 对应干线车次 三方中转 三方中转车次号") + private String signTrainNumber; + /** + * 签收预约单号 只有商市配,自提没有该字段 + */ + @ApiModelProperty(value = "签收预约单号 只有商市配,自提没有该字段") + private String signReservationCode; + /** + * 签收车牌 + */ + @ApiModelProperty(value = "签收车牌") + private String signCarNumber; + /** + * 签收类型(按件签收 批量签收 补录) + */ + @ApiModelProperty(value = "签收类型(按件签收 批量签收 补录)") + private String signType; + /** + * 车辆类型 + */ + @ApiModelProperty(value = "车辆类型") + private String signCarType; + /** + * 复核人 + */ + @ApiModelProperty(value = "复核人") + private String reviewUserName; + /** + * 复核时间 复核时间=回库时间 + */ + @ApiModelProperty(value = "复核时间 复核时间=回库时间") + private String reviewTime; + /** + * 滞留人 + */ + @ApiModelProperty(value = "滞留人") + private String retentionUserName; + /** + * 滞留时间 + */ + @ApiModelProperty(value = "滞留时间") + private String retentionTime; + /** + * 配送成本 + */ + @ApiModelProperty(value = "配送成本") + private String distributionCost; + /** + * 分货费成本 + */ + @ApiModelProperty(value = "分货费成本") + private String apartCost; + /** + * 上楼费成本 + */ + @ApiModelProperty(value = "上楼费成本") + private String apstairsCost; + /** + * 平移费成本 + */ + @ApiModelProperty(value = "平移费成本") + private String moveCost; + /** + * 装卸费成本 + */ + @ApiModelProperty(value = "装卸费成本") + private String stevedoreCost; + /** + * 公里数成本 + */ + @ApiModelProperty(value = "公里数成本") + private String kiloAllowCost; + /** + * 补贴公里数成本 + */ + @ApiModelProperty(value = "补贴公里数成本") + private String allowKiloAllowCost; + /** + * 超区公里数成本 + */ + @ApiModelProperty(value = "超区公里数成本") + private String ultrAllpwCost; + /** + * 点位补贴成本 + */ + @ApiModelProperty(value = "点位补贴成本") + private String pointAllowCost; + /** + * 保底费成本 + */ + @ApiModelProperty(value = "保底费成本") + private String guarCost; + /** + * 油费成本 + */ + @ApiModelProperty(value = "油费成本") + private String fuelCost; + /** + * 其它成本 + */ + @ApiModelProperty(value = "其它成本") + private String otherCost; + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java index 94b62c882..35ed03499 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java @@ -16,6 +16,9 @@ */ package com.logpm.basicdata.feign; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -32,14 +35,18 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.redis.cache.BladeRedis; import org.springblade.core.tool.api.R; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.IDeptClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * 仓库 Feign实现类 @@ -55,6 +62,8 @@ public class BasicdataWarehouseClient implements IBasicdataWarehouseClient { private final IBasicdataWarehouseService warehouseWarehouseService; + private final IDeptClient deptClient; + private final BladeRedis bladeRedis; @Override @@ -225,5 +234,32 @@ public class BasicdataWarehouseClient implements IBasicdataWarehouseClient { return list; } + @Override + public List findWarehousesByIds(List ids) { + if(CollUtil.isNotEmpty(ids)){ + List list = warehouseWarehouseService.list(Wrappers.lambdaQuery().in(BasicdataWarehouseEntity::getId, ids.stream().collect(Collectors.toSet()))); + if(CollUtil.isNotEmpty(list)){ + for (BasicdataWarehouseEntity warehouseEntity : list) { + Long department = warehouseEntity.getDepartment(); + if(ObjectUtil.isNotNull(department)){ + Dept dept = deptClient.findEntityById(department); + if(ObjectUtil.isNotEmpty(dept)){ + Integer deptCategory = dept.getDeptCategory(); + if(NumberUtil.equals(deptCategory,2)){ + warehouseEntity.setBusinessLine(dept.getDeptName()); + } else { + Long parentId = dept.getParentId(); + Dept parentDept = deptClient.findEntityById(parentId); + warehouseEntity.setBusinessLine(parentDept.getDeptName()); + } + } + } + } + return list; + } + } + return Collections.emptyList(); + } + } diff --git a/blade-service/logpm-distribution/pom.xml b/blade-service/logpm-distribution/pom.xml index 56afb2ebc..50c5e6106 100644 --- a/blade-service/logpm-distribution/pom.xml +++ b/blade-service/logpm-distribution/pom.xml @@ -133,6 +133,11 @@ logpm-business-api ${bladex.project.version} + + org.springblade + logpm-report-api + 3.2.0.RELEASE + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/PlanReportListener.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/PlanReportListener.java new file mode 100644 index 000000000..0801bb6c5 --- /dev/null +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/PlanReportListener.java @@ -0,0 +1,125 @@ +package com.logpm.distribution.receiver.report; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.distribution.entity.DistributionParcelListEntity; +import com.logpm.distribution.service.IDistributionDeliveryListService; +import com.logpm.distribution.service.IDistributionParcelListService; +import com.logpm.report.entity.QualityDeliverEntity; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.constant.broadcast.FanoutConstants; +import org.springblade.common.enums.BizOperationEnums; +import org.springblade.common.enums.PackageTypeEnums; +import org.springblade.common.model.NodeFanoutMsg; +import org.springblade.common.model.PackageData; +import org.springframework.amqp.core.ExchangeTypes; +import org.springframework.amqp.rabbit.annotation.Exchange; +import org.springframework.amqp.rabbit.annotation.Queue; +import org.springframework.amqp.rabbit.annotation.QueueBinding; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 配送计划生成明细报表 + * + * @author zhaoqiaobo + * @create 2024-03-18 0:02 + */ +@Slf4j +@Component +@AllArgsConstructor +public class PlanReportListener { + + @Resource + private IDistributionParcelListService parcelListService; + + @Resource + private IDistributionDeliveryListService deliveryListService; + + @Resource + private IBasicdataWarehouseClient warehouseClient; + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(name = FanoutConstants.distribution.plan.QUEUE.REPORT, durable = "true"), + exchange = @Exchange(name = FanoutConstants.distribution.plan.EXCHANGE, type = ExchangeTypes.FANOUT) + )) + public void nodeDataPushDelayed(String msg) { + log.info("配送计划生成明细报表: {}", msg); + if (StrUtil.isEmpty(msg)) { + return; + } + NodeFanoutMsg bean = JSONUtil.toBean(msg, NodeFanoutMsg.class); + // Long warehouseId = bean.getWarehouseId(); + BizOperationEnums bizOperation = bean.getBizOperation(); + List details = bean.getDetails(); + Object main = bean.getMain(); + // main: {"distributionCompany":"承运商", "driverName":"司机姓名", "id":"任务ID", "kind":"任务类型 1-自主 2-外协", "taskTime":"任务时间", "trainNumber":"车次号","type":"配送类型 1商配 2市配", "vehicleName":"车牌号"} + JSONObject entries = JSONUtil.parseObj(main); + BasicdataWarehouseEntity warehouseEntity = null; + // if (ObjectUtil.isNotEmpty(warehouseId)) { + // List warehouseEntities = warehouseClient.findWarehousesByIds(CollUtil.newArrayList(warehouseId)); + // if (CollUtil.isNotEmpty(warehouseEntities)) { + // warehouseEntity = warehouseEntities.get(0); + // } + // } + if (BizOperationEnums.ADD.equals(bizOperation)) { + List entities = new ArrayList<>(); + // 新增 + // 查询出基础信息插入基础表 + // 订制品 库存品 零担 + if (CollUtil.isNotEmpty(details)) { + // 按 packageType 分组 + Map> detailMap = details.stream().collect(Collectors.groupingBy(PackageData::getPackageType)); + if (detailMap.containsKey(PackageTypeEnums.CMP)) { + // 订制品 + List packageData = detailMap.get(PackageTypeEnums.CMP); + // List listByOrderPackageCode = parcelListService.findListByOrderPackageCode(packageData.stream().map(PackageData::getPackageCode).collect(Collectors.toList()), bean.getWarehouseId()); + Map parcelListMap = null; + // if (CollUtil.isNotEmpty(listByOrderPackageCode)) { + // 转map + // parcelListMap = listByOrderPackageCode.stream().collect(Collectors.toMap(DistributionParcelListEntity::getOrderPackageCode, e -> e)); + // } + for (PackageData packageDatum : packageData) { + QualityDeliverEntity entity = QualityDeliverEntity.builder() + .orderCode(packageDatum.getOrderCode()) + .businessUnit(ObjectUtil.isNotEmpty(warehouseEntity) ? warehouseEntity.getBusinessLine() : "") + .warehouseName(bean.getWarehouse()) + // .warehouseId(bean.getWarehouseId()) + .build(); + if (MapUtil.isNotEmpty(parcelListMap) && parcelListMap.containsKey(packageDatum.getPackageCode())) { + DistributionParcelListEntity parcelListEntity = parcelListMap.get(packageDatum.getPackageCode()); + if (ObjectUtil.isNotEmpty(parcelListEntity)) { + entity.setBrandName(parcelListEntity.getBrandName()); + } + } + } + } else if (detailMap.containsKey(PackageTypeEnums.INV)) { + // 库存品 + + } else if (detailMap.containsKey(PackageTypeEnums.LTL)) { + // 零担 + + } + + } + } else if (BizOperationEnums.DELETE.equals(bizOperation)) { + // 删除 + } else if (BizOperationEnums.MODIFY.equals(bizOperation)) { + // 修改 + } + } + +}