Browse Source

feat(all): 配送明细报表

1 整体优化配送明细报表广播消息
fix-sign
zhaoqiaobo 4 months ago
parent
commit
b526311e54
  1. 5
      blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/QualityDeliverEntity.java
  2. 25
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/job/ExpenseJob.java
  3. 162
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/BillPlanReportListener.java
  4. 75
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/BillReViewReportListener.java
  5. 84
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/BillSignforReportListener.java
  6. 19
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java
  7. 4
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java
  8. 26
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportListener.java
  9. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/SignforReportListener.java
  10. 4
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/StockReportListener.java
  11. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IQualityDeliverService.java
  12. 14
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/QualityDeliverServiceImpl.java

5
blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/QualityDeliverEntity.java

@ -569,6 +569,11 @@ public class QualityDeliverEntity extends TenantEntity {
*/
@ApiModelProperty(value = "车辆类型")
private String signCarType;
/**
* 车辆类型id
*/
@ApiModelProperty(value = "车辆类型id")
private Long signCarTypeId;
/**
* 上楼层数
*/

25
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/job/ExpenseJob.java

@ -1,5 +1,6 @@
package com.logpm.distribution.job;
import com.logpm.distribution.receiver.report.DeliverFinishReportListener;
import com.logpm.distribution.service.IQualityDeliverService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
@ -20,6 +21,8 @@ public class ExpenseJob {
@Resource
private IQualityDeliverService qualityDeliverService;
@Resource
private DeliverFinishReportListener deliverFinishReportListener;
/**
* 车辆成本明细表 job
@ -33,6 +36,28 @@ public class ExpenseJob {
qualityDeliverService.carExpenseDispatchDetailJob(param);
return ReturnT.SUCCESS;
}
/**
* 车辆成本明细表 车次号
* 每天晚上凌晨0点执行
* @param param 指定时间 yyyy-MM-dd
* @return
* @throws Exception
*/
@XxlJob("carExpenseDispatchDetailTrainJob")
public ReturnT<String> carExpenseDispatchDetailTrainJob(String param) throws Exception {
qualityDeliverService.carExpenseDispatchDetailFinal(param);
return ReturnT.SUCCESS;
}
/**
* 计算车次成本 车次号
* @return
* @throws Exception
*/
@XxlJob("calculateTripCostJob")
public ReturnT<String> calculateTripCostJob(String param) throws Exception {
deliverFinishReportListener.calculateTripCost(param);
return ReturnT.SUCCESS;
}
/**
* 每天凌晨00:30:00计算仓储成本

162
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/BillPlanReportListener.java

@ -1,15 +1,20 @@
package com.logpm.distribution.receiver.report;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.distribution.dto.ReportQualityDeliverDTO;
import com.logpm.distribution.entity.QualityDeliverEntity;
import com.logpm.distribution.mapper.QualityDeliverMapper;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.vo.SendMsg;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.WorkNodeEnums;
import org.springblade.common.constant.report.ReportConstants;
import org.springblade.common.enums.BizOperationEnums;
import org.springblade.common.enums.PackageTypeEnums;
@ -21,7 +26,11 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 自提任务生成明细报表
@ -36,6 +45,7 @@ public class BillPlanReportListener implements ReportService {
@Resource
private IFactoryDataClient factoryDataClient;
private final QualityDeliverMapper qualityDeliverMapper;
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
@ -46,31 +56,75 @@ public class BillPlanReportListener implements ReportService {
Long warehouseId = bean.getWarehouseId();
BizOperationEnums bizOperation = bean.getBizOperation();
List<PackageData> details = vo.getPackageDataList();
String reservationCode = vo.getPickupBatch();
Map<String, List<QualityDeliverEntity>> cmpMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> ltlMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> invMap = new HashMap<>();
if (StrUtil.isNotEmpty(reservationCode)) {
List<QualityDeliverEntity> qualityDeliverEntities = qualityDeliverMapper.selectList(Wrappers.<QualityDeliverEntity>lambdaQuery().eq(QualityDeliverEntity::getPlanReservationCode, reservationCode));
if (CollUtil.isNotEmpty(qualityDeliverEntities)) {
// 取消预约 将表中数据全删
if (BizOperationEnums.DELETE.equals(bizOperation)) {
for (QualityDeliverEntity qualityDeliverEntity : qualityDeliverEntities) {
sendReport(qualityDeliverEntity, bizOperation);
}
return;
}
cmpMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.CMP.getCode()))
.collect(Collectors.groupingBy(item -> item.getOrderPackageCode()));
ltlMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.LTL.getCode()))
.collect(Collectors.groupingBy(item -> item.getCategory() + item.getOrderCode()));
invMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.INV.getCode()))
.collect(Collectors.groupingBy(item -> item.getMallName() + item.getMaterielCode() + item.getIncomingBatch()));
}
}
if (CollUtil.isNotEmpty(details)) {
for (PackageData detail : details) {
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder()
.warehouseName(bean.getWarehouse())
.warehouseId(warehouseId)
.orderPackageCode(detail.getPackageCode())
.planReservationCode(vo.getPickupBatch())
.reservationConsignee(vo.getConsignee())
.reservationConsigneePhone(vo.getConsigneePhone())
.planReservationUser(bean.getOperator())
.planReservationTime(bean.getOperatorTime())
.planNum(detail.getNumber())
.planTrainNumber(vo.getPickupBatch())
.deliveryTime(vo.getPickUpTime())
.deliveryType("自提")
.deliveryKind("自主配送")
.vehicleName(vo.getPickUpPlate())
.bizCode(vo.getPickupBatch())
.driverName(vo.getConsignee())
.bizCode(vo.getPickupBatch())
.deliveryPlanTime(bean.getOperatorTime())
.deliveryCreateUserName(bean.getOperator())
.build();
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) {
qualityDeliverEntity.setConditions(1);
qualityDeliverEntity.setPlanNum(1);
sendReport(bizOperation, qualityDeliverEntity, BizOperationEnums.MODIFY);
// 存在订制品则修改 不存在则新增
if (cmpMap.containsKey(detail.getPackageCode())) {
qualityDeliverEntity.setId(cmpMap.get(detail.getPackageCode()).get(0).getId());
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
} else {
sendReport(qualityDeliverEntity, BizOperationEnums.ADD);
}
}
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) {
qualityDeliverEntity.setOrderCode(detail.getOrderCode());
qualityDeliverEntity.setCategory(detail.getProductName());
qualityDeliverEntity.setConditions(2);
sendReport(bizOperation, qualityDeliverEntity, BizOperationEnums.MODIFY);
// 存在零担则修改 不存在则新增
if (ltlMap.containsKey(detail.getProductName() + detail.getOrderCode())) {
qualityDeliverEntity.setId(ltlMap.get(detail.getProductName() + detail.getOrderCode()).get(0).getId());
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
} else {
sendReport(qualityDeliverEntity, BizOperationEnums.ADD);
}
}
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.INV)) {
qualityDeliverEntity.setIncomingBatch(detail.getPickupBatch());
@ -79,28 +133,98 @@ public class BillPlanReportListener implements ReportService {
qualityDeliverEntity.setMaterielName(detail.getMaterialName());
qualityDeliverEntity.setConditions(3);
Integer number = detail.getNumber();
for (int i = 0; i < number; i++) {
QualityDeliverEntity entity = new QualityDeliverEntity();
BeanUtil.copyProperties(qualityDeliverEntity, entity);
entity.setPlanNum(1);
sendReport(bizOperation, entity, BizOperationEnums.ADD);
// 存在库存品则修改 不存在则新增
// 当前库存品数据大于已有数量 则新增增量部分,如果当前库存品数量小于已有数量 需要删除数据 1 删除操作只针对未备货的数据 2 全删或者只删除部分
if (invMap.containsKey(detail.getMallName() + detail.getMaterialCode() + detail.getPickupBatch())) {
List<QualityDeliverEntity> qualityDeliverEntities = invMap.get(detail.getMallName() + detail.getMaterialCode() + detail.getPickupBatch());
int size = qualityDeliverEntities.size();
if (number > size) {
for (int i = 0; i < number - size; i++) {
QualityDeliverEntity entity = new QualityDeliverEntity();
BeanUtil.copyProperties(qualityDeliverEntity, entity);
entity.setPlanNum(1);
sendReport(entity, BizOperationEnums.ADD);
}
for (QualityDeliverEntity deliverEntity : qualityDeliverEntities) {
qualityDeliverEntity.setId(deliverEntity.getId());
qualityDeliverEntity.setPlanNum(1);
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE);
}
} else if (number == size) {
for (QualityDeliverEntity deliverEntity : qualityDeliverEntities) {
qualityDeliverEntity.setId(deliverEntity.getId());
qualityDeliverEntity.setPlanNum(1);
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
} else {
List<QualityDeliverEntity> collect = qualityDeliverEntities.stream()
.filter(item -> StrUtil.isEmpty(item.getOrderPackageCode()))
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(collect)) {
int i = size - number;
if (i >= collect.size()) {
for (QualityDeliverEntity entity : collect) {
sendReport(entity, BizOperationEnums.DELETE);
}
} else {
for (int j = 0; j < i; j++) {
sendReport(collect.get(j), BizOperationEnums.DELETE);
}
}
}
}
} else {
for (int i = 0; i < number; i++) {
QualityDeliverEntity entity = new QualityDeliverEntity();
BeanUtil.copyProperties(qualityDeliverEntity, entity);
entity.setPlanNum(1);
sendReport(entity, BizOperationEnums.ADD);
}
}
}
}
}
// 系统中有的包件在当前不存在,则删除
Set<String> cmpSet = details.stream().filter(item -> ObjectUtil.equals(item.getPackageType(), PackageTypeEnums.CMP)).map(PackageData::getPackageCode).collect(Collectors.toSet());
for (Map.Entry<String, List<QualityDeliverEntity>> entry : cmpMap.entrySet()) {
String key = entry.getKey();
if (!cmpSet.contains(key)) {
sendReport(entry.getValue().get(0), BizOperationEnums.DELETE);
}
}
Set<String> ltlSet = details.stream().filter(item -> ObjectUtil.equals(item.getPackageType(), PackageTypeEnums.LTL))
.map(i -> i.getProductName() + i.getOrderCode()).collect(Collectors.toSet());
for (Map.Entry<String, List<QualityDeliverEntity>> entry : ltlMap.entrySet()) {
String key = entry.getKey();
if (!ltlSet.contains(key)) {
sendReport(entry.getValue().get(0), BizOperationEnums.DELETE);
}
}
Set<String> invSet = details.stream().filter(item -> ObjectUtil.equals(item.getPackageType(), PackageTypeEnums.INV))
.map(i -> i.getMallName() + i.getMaterialCode() + i.getPickupBatch()).collect(Collectors.toSet());
for (Map.Entry<String, List<QualityDeliverEntity>> entry : invMap.entrySet()) {
String key = entry.getKey();
if (!invSet.contains(key)) {
List<QualityDeliverEntity> value = entry.getValue();
for (QualityDeliverEntity entity : value) {
sendReport(entity, BizOperationEnums.DELETE);
}
}
}
}
private void sendReport(BizOperationEnums bizOperation, QualityDeliverEntity qualityDeliverEntity, BizOperationEnums bizOperationEnums) {
if (BizOperationEnums.ADD.equals(bizOperation) || BizOperationEnums.MODIFY.equals(bizOperation)) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder().data(JSONUtil.toJsonStr(qualityDeliverEntity)).operation(bizOperationEnums).build();
factoryDataClient.sendMessage(SendMsg.builder()
.exchange(ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE)
.routingKey(ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY)
.message(JSONUtil.toJsonStr(dto))
.delay(3000)
.build());
}
private void sendReport(QualityDeliverEntity qualityDeliverEntity, BizOperationEnums operationEnums) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder()
.data(JSONUtil.toJsonStr(qualityDeliverEntity))
.operation(operationEnums)
.node(WorkNodeEnums.PLAN_BILLOFLADING.getValue())
.build();
factoryDataClient.sendMessage(SendMsg.builder()
.exchange(ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE)
.routingKey(ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY)
.message(JSONUtil.toJsonStr(dto))
.delay(3000)
.build());
}
}

75
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/BillReViewReportListener.java

@ -1,9 +1,12 @@
package com.logpm.distribution.receiver.report;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.distribution.dto.ReportQualityDeliverDTO;
import com.logpm.distribution.entity.QualityDeliverEntity;
import com.logpm.distribution.pros.DistributionProperties;
@ -12,23 +15,21 @@ import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.vo.SendMsg;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.broadcast.FanoutConstants;
import org.springblade.common.constant.WorkNodeEnums;
import org.springblade.common.constant.report.ReportConstants;
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.springblade.common.model.workNode.PickUpByReCheckVO;
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 org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 自提复核生成明细报表
@ -57,12 +58,33 @@ public class BillReViewReportListener implements ReportService {
Long warehouseId = bean.getWarehouseId();
BizOperationEnums bizOperation = bean.getBizOperation();
List<PackageData> details = vo.getPackageDataList();
String reservationCode = vo.getPickupBatch();
Map<String, List<QualityDeliverEntity>> cmpMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> ltlMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> invMap = new HashMap<>();
if (StrUtil.isNotEmpty(reservationCode)) {
List<QualityDeliverEntity> qualityDeliverEntities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery()
.eq(QualityDeliverEntity::getPlanReservationCode, reservationCode)
);
if (CollUtil.isNotEmpty(qualityDeliverEntities)) {
cmpMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.CMP.getCode()))
.collect(Collectors.groupingBy(item -> item.getOrderPackageCode()));
ltlMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.LTL.getCode()))
.collect(Collectors.groupingBy(item -> item.getCategory() + item.getOrderCode()));
invMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.INV.getCode()))
.collect(Collectors.groupingBy(item -> item.getOrderPackageCode()));
}
}
if (CollUtil.isNotEmpty(details)) {
for (PackageData detail : details) {
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder()
.warehouseName(bean.getWarehouse())
.warehouseId(warehouseId)
.orderPackageCode(detail.getPackageCode())
.reviewNum(detail.getNumber())
.reviewUserName(bean.getOperator())
.reviewTime(bean.getOperatorTime())
.bizCode(vo.getPickupBatch())
@ -70,36 +92,49 @@ public class BillReViewReportListener implements ReportService {
.build();
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) {
qualityDeliverEntity.setConditions(1);
qualityDeliverEntity.setLoadNum(1);
sendReport(bizOperation, qualityDeliverEntity);
qualityDeliverEntity.setReviewNum(1);
if (cmpMap.containsKey(detail.getPackageCode())) {
qualityDeliverEntity.setId(cmpMap.get(detail.getPackageCode()).get(0).getId());
sendReport(BizOperationEnums.MODIFY, qualityDeliverEntity);
} else {
// 不在计划内被扫描到了 特殊处理
}
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) {
qualityDeliverEntity.setBizCode(vo.getPickupBatch());
qualityDeliverEntity.setOrderCode(detail.getOrderCode());
qualityDeliverEntity.setCategory(detail.getProductName());
qualityDeliverEntity.setConditions(2);
sendReport(bizOperation, qualityDeliverEntity);
if (ltlMap.containsKey(detail.getProductName() + detail.getOrderCode())) {
qualityDeliverEntity.setId(ltlMap.get(detail.getProductName() + detail.getOrderCode()).get(0).getId());
sendReport(BizOperationEnums.MODIFY, qualityDeliverEntity);
}
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.INV)) {
qualityDeliverEntity.setIncomingBatch(detail.getPickupBatch());
qualityDeliverEntity.setMallName(detail.getMallName());
qualityDeliverEntity.setMaterielCode(detail.getMaterialCode());
qualityDeliverEntity.setMaterielName(detail.getMaterialName());
qualityDeliverEntity.setConditions(3);
sendReport(bizOperation, qualityDeliverEntity);
if (invMap.containsKey(detail.getPackageCode())) {
qualityDeliverEntity.setId(invMap.get(detail.getPackageCode()).get(0).getId());
sendReport(BizOperationEnums.MODIFY, qualityDeliverEntity);
}
}
}
}
}
private void sendReport(BizOperationEnums bizOperation, QualityDeliverEntity qualityDeliverEntity) {
if (BizOperationEnums.ADD.equals(bizOperation) || BizOperationEnums.MODIFY.equals(bizOperation)) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder().data(JSONUtil.toJsonStr(qualityDeliverEntity)).operation(BizOperationEnums.MODIFY).build();
factoryDataClient.sendMessage(SendMsg.builder()
.exchange(ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE)
.routingKey(ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY)
.message(JSONUtil.toJsonStr(dto))
.delay(3000)
.build());
}
private void sendReport(BizOperationEnums operationEnums, QualityDeliverEntity qualityDeliverEntity) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder()
.data(JSONUtil.toJsonStr(qualityDeliverEntity))
.operation(operationEnums)
.node(WorkNodeEnums.SIGN_BILLOFLADING_REVIEW.getValue())
.build();
factoryDataClient.sendMessage(SendMsg.builder()
.exchange(ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE)
.routingKey(ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY)
.message(JSONUtil.toJsonStr(dto))
.delay(3000)
.build());
}
}

84
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/BillSignforReportListener.java

@ -1,10 +1,12 @@
package com.logpm.distribution.receiver.report;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.distribution.dto.ReportQualityDeliverDTO;
import com.logpm.distribution.entity.QualityDeliverEntity;
import com.logpm.distribution.pros.DistributionProperties;
@ -13,23 +15,21 @@ import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.vo.SendMsg;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.broadcast.FanoutConstants;
import org.springblade.common.constant.WorkNodeEnums;
import org.springblade.common.constant.report.ReportConstants;
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.springblade.common.model.workNode.PickUpByScanVO;
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 org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 自提签收扫描生成明细报表
@ -51,13 +51,6 @@ public class BillSignforReportListener implements ReportService {
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getBillSignforReport()) {
return;
}
log.info("自提签收扫描生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
return;
}
NodeFanoutMsg bean = JSONUtil.toBean(msg, NodeFanoutMsg.class);
Object main = bean.getMain();
JSONObject entries = JSONUtil.parseObj(main);
@ -65,29 +58,61 @@ public class BillSignforReportListener implements ReportService {
Long warehouseId = bean.getWarehouseId();
BizOperationEnums bizOperation = bean.getBizOperation();
List<PackageData> details = vo.getPackageDataList();
String reservationCode = vo.getPickupBatch();
Map<String, List<QualityDeliverEntity>> cmpMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> ltlMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> invMap = new HashMap<>();
if (StrUtil.isNotEmpty(reservationCode)) {
List<QualityDeliverEntity> qualityDeliverEntities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery()
.eq(QualityDeliverEntity::getPlanReservationCode, reservationCode)
);
if (CollUtil.isNotEmpty(qualityDeliverEntities)) {
cmpMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.CMP.getCode()))
.collect(Collectors.groupingBy(item -> item.getOrderPackageCode()));
ltlMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.LTL.getCode()))
.collect(Collectors.groupingBy(item -> item.getCategory() + item.getOrderCode()));
invMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.INV.getCode()))
.collect(Collectors.groupingBy(item -> item.getOrderPackageCode()));
}
}
if (CollUtil.isNotEmpty(details)) {
for (PackageData detail : details) {
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder()
.warehouseName(bean.getWarehouse())
.warehouseId(warehouseId)
.orderPackageCode(detail.getPackageCode())
.signCarNumber(vo.getCarNumber())
.signReservationCode(vo.getPickupBatch())
.signTrainNumber(vo.getPickupBatch())
.signUserName(bean.getOperator())
.signTime(bean.getOperatorTime())
.signReservationCode(vo.getPickupBatch())
.signType(vo.getSignType())
.bizCode(vo.getPickupBatch())
.bizStatus(90)
.signStatus("已签收")
.build();
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) {
qualityDeliverEntity.setConditions(1);
qualityDeliverEntity.setSignNum(1);
sendReport(bizOperation, qualityDeliverEntity);
if (cmpMap.containsKey(detail.getPackageCode())) {
qualityDeliverEntity.setId(cmpMap.get(detail.getPackageCode()).get(0).getId());
sendReport(BizOperationEnums.MODIFY, qualityDeliverEntity);
} else {
// 不在计划内被扫描到了 特殊处理
}
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) {
qualityDeliverEntity.setBizCode(vo.getPickupBatch());
qualityDeliverEntity.setOrderCode(detail.getOrderCode());
qualityDeliverEntity.setCategory(detail.getProductName());
qualityDeliverEntity.setSignNum(detail.getNumber());
qualityDeliverEntity.setConditions(2);
sendReport(bizOperation, qualityDeliverEntity);
if (ltlMap.containsKey(detail.getProductName() + detail.getOrderCode())) {
qualityDeliverEntity.setId(ltlMap.get(detail.getProductName() + detail.getOrderCode()).get(0).getId());
sendReport(BizOperationEnums.MODIFY, qualityDeliverEntity);
}
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.INV)) {
qualityDeliverEntity.setIncomingBatch(detail.getPickupBatch());
qualityDeliverEntity.setMallName(detail.getMallName());
@ -95,22 +120,27 @@ public class BillSignforReportListener implements ReportService {
qualityDeliverEntity.setMaterielName(detail.getMaterialName());
qualityDeliverEntity.setSignNum(1);
qualityDeliverEntity.setConditions(3);
sendReport(bizOperation, qualityDeliverEntity);
if (invMap.containsKey(detail.getPackageCode())) {
qualityDeliverEntity.setId(invMap.get(detail.getPackageCode()).get(0).getId());
sendReport(BizOperationEnums.MODIFY, qualityDeliverEntity);
}
}
}
}
}
private void sendReport(BizOperationEnums bizOperation, QualityDeliverEntity qualityDeliverEntity) {
if (BizOperationEnums.ADD.equals(bizOperation) || BizOperationEnums.MODIFY.equals(bizOperation)) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder().data(JSONUtil.toJsonStr(qualityDeliverEntity)).operation(BizOperationEnums.MODIFY).build();
factoryDataClient.sendMessage(SendMsg.builder()
.exchange(ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE)
.routingKey(ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY)
.message(JSONUtil.toJsonStr(dto))
.delay(3000)
.build());
}
private void sendReport(BizOperationEnums operationEnums, QualityDeliverEntity qualityDeliverEntity) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder()
.data(JSONUtil.toJsonStr(qualityDeliverEntity))
.operation(operationEnums)
.node(WorkNodeEnums.SIGN_BILLOFLADING.getValue())
.build();
factoryDataClient.sendMessage(SendMsg.builder()
.exchange(ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE)
.routingKey(ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY)
.message(JSONUtil.toJsonStr(dto))
.delay(3000)
.build());
}
}

19
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java

@ -76,6 +76,18 @@ public class DeliverFinishReportListener implements ReportService {
JSONObject entries = JSONUtil.parseObj(main);
FinishDistributionTrainVO vo = JSONUtil.toBean(entries, FinishDistributionTrainVO.class);
String trainNumber = vo.getTrainNumber();
calculateTripCost(trainNumber);
// 生成车辆车次成本 发送延时消息生成报表
factoryDataClient.sendMessage(SendMsg.builder()
.exchange(ReportConstants.REPORT_QUALITY_CAR_FINAL_EXCHANGE)
.routingKey(ReportConstants.REPORT_QUALITY_CAR_FINAL_ROUTINGKEY)
.message(JSONUtil.toJsonStr(vo))
.delay(10000)
.build());
}
public void calculateTripCost(String trainNumber) {
// 根据车次查询出包件明细,然后计算对应的成本
List<QualityDeliverEntity> entities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery()
.eq(QualityDeliverEntity::getSignTrainNumber, trainNumber)
@ -162,11 +174,14 @@ public class DeliverFinishReportListener implements ReportService {
if (StrUtil.isNotEmpty(deliveryKind) && StrUtil.equals(deliveryKind, "自主配送")) {
if (StrUtil.isNotEmpty(qualityDeliverEntity.getDeliveryType())
&& (StrUtil.equals(qualityDeliverEntity.getDeliveryType(), "商配") || StrUtil.equals(qualityDeliverEntity.getDeliveryType(), "市配"))) {
if(StrUtil.isEmpty(qualityDeliverEntity.getSignCarType())){
continue;
}
ExpenseDispatchClientDTO expenseDispatchClientDTO = expenseDispatchClient.findPriceByDriverId(qualityDeliverEntity.getWarehouseId(), driverId, qualityDeliverEntity.getSignCarType(), qualityDeliverEntity.getDeliveryType());
if (ObjectUtil.isNotEmpty(expenseDispatchClientDTO)) {
ExpenseDispatchPriceVO priceVO = expenseDispatchClientDTO.getPriceVO();
if (ObjectUtil.isEmpty(priceVO)) {
return;
continue;
}
// 整车计费,则车内的每个包件分摊整车成本费用
if (ynWholeVehicle) {
@ -190,7 +205,7 @@ public class DeliverFinishReportListener implements ReportService {
BigDecimal totalFreight = BigDecimal.ZERO;
ExpenseDispatchPriceRuleDTO rule = expenseDispatchClientDTO.getRule();
if (ObjectUtil.isEmpty(rule)) {
return;
continue;
}
if (CollUtil.isNotEmpty(priceList)) {
Map<Long, ExpenseDispatchPriceCategoryVO> priceMap = priceList.stream().collect(Collectors.toMap(ExpenseDispatchPriceCategoryVO::getCategoryId, v -> v));

4
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java

@ -148,6 +148,9 @@ public class QualityDeliverListener implements ReportService {
if (StrUtil.equals(node, WorkNodeEnums.DISTRIBUTION_CAR_START.getValue())){
qualityDeliverService.delDistributionCarStart(qualityDeliverEntity.getId());
}
if (StrUtil.equals(node, WorkNodeEnums.PLAN_BILLOFLADING.getValue())){
qualityDeliverService.deleteEntityById(qualityDeliverEntity.getId());
}
}
}
@ -407,6 +410,7 @@ public class QualityDeliverListener implements ReportService {
if (StrUtil.isNotEmpty(waybillNumber)) {
WarehouseWaybillEntity byWaybillNo = getWarehouseWaybillEntity(waybillNumber);
if (ObjectUtil.isNotEmpty(byWaybillNo)) {
qualityDeliverEntity.setOpenOrderTime(byWaybillNo.getDocumentMakingTime());
// 运单发货信息
qualityDeliverEntity.setShipperUnitId(byWaybillNo.getShipperId());
qualityDeliverEntity.setShipperUnit(byWaybillNo.getShipper());

26
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportListener.java

@ -1,12 +1,15 @@
package com.logpm.distribution.receiver.report;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.logpm.distribution.pros.DistributionProperties;
import com.logpm.distribution.service.IQualityDeliverService;
import com.rabbitmq.client.Channel;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.broadcast.FanoutConstants;
import org.springblade.common.constant.report.ReportConstants;
import org.springblade.common.model.workNode.FinishDistributionTrainVO;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
@ -32,6 +35,7 @@ public class ReportListener {
private final DistributionProperties destinationProperties;
private final List<ReportService> reportServices;
private final IQualityDeliverService qualityDeliverService;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillPlan.QUEUE.REPORT, durable = "true"),
@ -404,6 +408,28 @@ public class ReportListener {
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = ReportConstants.REPORT_QUALITY_CAR_FINAL_QUEUE, durable = "true"),
exchange = @Exchange(name = ReportConstants.REPORT_QUALITY_CAR_FINAL_EXCHANGE, type = ExchangeTypes.TOPIC),
key = ReportConstants.REPORT_QUALITY_CAR_FINAL_ROUTINGKEY
), ackMode = "MANUAL")
public void carExpenseDispatchDetailFinal(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
log.info("生成车辆车次成本报表: {}", msg);
try {
FinishDistributionTrainVO vo = JSONUtil.toBean(msg, FinishDistributionTrainVO.class);
String trainNumber = vo.getTrainNumber();
qualityDeliverService.carExpenseDispatchDetailFinal(trainNumber);
} catch (Exception e) {
log.error("生成车辆车次成本报表失败: {}", e.getMessage());
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private ReportService selectReportService(Class<? extends ReportService> clazz) {
// 根据某些条件选择具体的实现类

2
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/SignforReportListener.java

@ -93,6 +93,8 @@ public class SignforReportListener implements ReportService {
.signTrainNumber(vo.getTrainNumber())
.signReservationCode(vo.getReservationCode())
.signType(vo.getOperatMode())
.signCarTypeId(vo.getCarTypeId())
.signCarType(vo.getCarType())
.bizCode(vo.getReservationCode())
.bizStatus(90)
.signStatus("已签收")

4
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/StockReportListener.java

@ -131,7 +131,9 @@ public class StockReportListener implements ReportService {
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE);
}
} else {
List<QualityDeliverEntity> collect = qualityDeliverEntities.stream().filter( i -> StrUtil.isEmpty(i.getStockupCode())).collect(Collectors.toList());
List<QualityDeliverEntity> collect = qualityDeliverEntities.stream()
.filter( i -> StrUtil.isEmpty(i.getStockupCode()))
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(collect)) {
qualityDeliverEntity.setId(collect.get(0).getId());
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);

2
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IQualityDeliverService.java

@ -40,4 +40,6 @@ public interface IQualityDeliverService extends BaseService<QualityDeliverEntity
void delPlanDelivery(Long id);
void delDistributionCarStart(Long id);
void carExpenseDispatchDetailFinal(String trainNumber);
}

14
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/QualityDeliverServiceImpl.java

@ -80,6 +80,10 @@ public class QualityDeliverServiceImpl extends BaseServiceImpl<QualityDeliverMap
wrapper.ge(QualityDeliverEntity::getCarComplateTime, dayStart);
wrapper.le(QualityDeliverEntity::getCarComplateTime, dayEnd);
List<QualityDeliverEntity> entities = this.list(wrapper);
buildCarExpenseReport(entities);
}
private void buildCarExpenseReport(List<QualityDeliverEntity> entities) {
if (CollUtil.isNotEmpty(entities)) {
// 按签收车次+签收车次分组封装为map
Map<String, List<QualityDeliverEntity>> collect = new HashMap<>();
@ -425,4 +429,14 @@ public class QualityDeliverServiceImpl extends BaseServiceImpl<QualityDeliverMap
baseMapper.delDistributionCarStart(id);
}
@Override
public void carExpenseDispatchDetailFinal(String trainNumber) {
if(StrUtil.isNotEmpty(trainNumber)){
List<QualityDeliverEntity> entities = this.list(Wrappers.<QualityDeliverEntity>lambdaQuery().eq(QualityDeliverEntity::getSignTrainNumber, trainNumber));
if(CollUtil.isNotEmpty(entities)){
buildCarExpenseReport(entities);
}
}
}
}

Loading…
Cancel
Save