Browse Source

feat(all): 增加报表处理逻辑

dist.1.2.0^2
zhaoqiaobo 7 months ago
parent
commit
d84368ae14
  1. 3
      blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java
  2. 492
      blade-service-api/logpm-report-api/src/main/java/com/logpm/report/entity/QualityDeliverEntity.java
  3. 36
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java
  4. 5
      blade-service/logpm-distribution/pom.xml
  5. 125
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/PlanReportListener.java

3
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<JSONObject> findWarehouseList(@RequestParam("warehouseName") String warehouseName);
@GetMapping(API_PREFIX + "/findWarehousesByIds")
List<BasicdataWarehouseEntity> findWarehousesByIds(@RequestParam("ids") List<Long> ids);
}

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

36
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<BasicdataWarehouseEntity> findWarehousesByIds(List<Long> ids) {
if(CollUtil.isNotEmpty(ids)){
List<BasicdataWarehouseEntity> list = warehouseWarehouseService.list(Wrappers.<BasicdataWarehouseEntity>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();
}
}

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

@ -133,6 +133,11 @@
<artifactId>logpm-business-api</artifactId>
<version>${bladex.project.version}</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>logpm-report-api</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
</dependencies>

125
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<PackageData> 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<BasicdataWarehouseEntity> warehouseEntities = warehouseClient.findWarehousesByIds(CollUtil.newArrayList(warehouseId));
// if (CollUtil.isNotEmpty(warehouseEntities)) {
// warehouseEntity = warehouseEntities.get(0);
// }
// }
if (BizOperationEnums.ADD.equals(bizOperation)) {
List<QualityDeliverEntity> entities = new ArrayList<>();
// 新增
// 查询出基础信息插入基础表
// 订制品 库存品 零担
if (CollUtil.isNotEmpty(details)) {
// 按 packageType 分组
Map<PackageTypeEnums, List<PackageData>> detailMap = details.stream().collect(Collectors.groupingBy(PackageData::getPackageType));
if (detailMap.containsKey(PackageTypeEnums.CMP)) {
// 订制品
List<PackageData> packageData = detailMap.get(PackageTypeEnums.CMP);
// List<DistributionParcelListEntity> listByOrderPackageCode = parcelListService.findListByOrderPackageCode(packageData.stream().map(PackageData::getPackageCode).collect(Collectors.toList()), bean.getWarehouseId());
Map<String, DistributionParcelListEntity> 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)) {
// 修改
}
}
}
Loading…
Cancel
Save