Browse Source

feat(all): 配送明细报表

1 整体优化配送明细报表广播消息
fix-sign
zhaoqiaobo 4 months ago
parent
commit
0d278b4310
  1. 5
      blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/entity/QualityDeliverEntity.java
  2. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/dto/ReportQualityDeliverDTO.java
  3. 32
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.java
  4. 10
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/QualityDeliverMapper.java
  5. 41
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/QualityDeliverMapper.xml
  6. 45
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/BillPlanReportListener.java
  7. 16
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/BillReViewReportListener.java
  8. 8
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/BillSignforReportListener.java
  9. 85
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/CarStartReportListener.java
  10. 101
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ConsigneeArriveReportListener.java
  11. 33
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java
  12. 104
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/LoadingReportListener.java
  13. 166
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/PlanReportListener.java
  14. 133
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java
  15. 87
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReViewReportListener.java
  16. 419
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportListener.java
  17. 11
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportService.java
  18. 201
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReservationPlanReportListener.java
  19. 24
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReturnWarehouseReportListener.java
  20. 87
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/SignforReportListener.java
  21. 105
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/StockReportListener.java
  22. 8
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IQualityDeliverService.java
  23. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionReservationServiceImpl.java
  24. 20
      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

@ -579,6 +579,11 @@ public class QualityDeliverEntity extends TenantEntity {
*/
@ApiModelProperty(value = "复核人")
private String reviewUserName;
/**
* 复核数量
*/
@ApiModelProperty(value = "复核数量")
private Integer reviewNum;
/**
* 复核时间 复核时间=回库时间
*/

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

@ -21,4 +21,6 @@ public class ReportQualityDeliverDTO implements Serializable {
private BizOperationEnums operation;
private String node;
}

32
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionDeliveryListMapper.java

@ -19,17 +19,36 @@ package com.logpm.distribution.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.distribution.dto.DistributionDeliveryListDTO;
import com.logpm.distribution.dto.DistributionLoadingNumDTO;
import com.logpm.distribution.dto.app.DistributionAppDeliveryListDTO;
import com.logpm.distribution.entity.*;
import com.logpm.distribution.entity.DisStockListDetailEntity;
import com.logpm.distribution.entity.DistributionDeliveryListEntity;
import com.logpm.distribution.entity.DistributionLoadscanAbnormalEntity;
import com.logpm.distribution.entity.DistributionLoadscanEntity;
import com.logpm.distribution.entity.DistributionLoadscaninvnEntity;
import com.logpm.distribution.entity.DistributionParcelListEntity;
import com.logpm.distribution.entity.DistributionReservationEntity;
import com.logpm.distribution.entity.DistributionReservationStockarticleEntity;
import com.logpm.distribution.entity.DistributionSignforEntity;
import com.logpm.distribution.entity.DistributionStockArticleEntity;
import com.logpm.distribution.excel.DistributionDeliveryListExcel;
import com.logpm.distribution.vo.*;
import com.logpm.distribution.vo.app.*;
import com.logpm.distribution.vo.DisStockListDetailVO;
import com.logpm.distribution.vo.DistributionDeliveryListPrintReponseVO;
import com.logpm.distribution.vo.DistributionDeliveryListPrintRequestVO;
import com.logpm.distribution.vo.DistributionDeliveryListVO;
import com.logpm.distribution.vo.DistributionDeliveryWordVO;
import com.logpm.distribution.vo.DistributionParcelNumberVO;
import com.logpm.distribution.vo.DistributionReservationStocklistVO;
import com.logpm.distribution.vo.DistributionRetentionScanVo;
import com.logpm.distribution.vo.DistributionStockArticleVO;
import com.logpm.distribution.vo.app.DistributionAppDeliveryListVO;
import com.logpm.distribution.vo.app.DistributionAppDetailVO;
import com.logpm.distribution.vo.app.DistributionAppNewDeliveryListVO;
import com.logpm.distribution.vo.app.DistributionAppParcelListVO;
import com.logpm.distribution.vo.app.DistributionAppStockArticleVO;
import com.logpm.oldproject.dto.SignPushDataDTO;
import org.apache.ibatis.annotations.Param;
import org.springblade.common.model.PackageData;
import java.util.List;
import java.util.Map;
@ -530,11 +549,12 @@ public interface DistributionDeliveryListMapper extends BaseMapper<DistributionD
/**
* 查询配送PDA零担列表
*
* @param id
* @param id1
* @return
*/
List<DistributionParcelNumberVO> selectDeliveryZeroOrderInfoDetail(Long id, Long id1);
List<DistributionParcelNumberVO> selectDeliveryZeroOrderInfoDetail(@Param("stockArticleId") Long id, @Param("deliveryId") Long id1);
/**
* 配送计划内的定制品计划查询

10
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/QualityDeliverMapper.java

@ -18,6 +18,7 @@ package com.logpm.distribution.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.distribution.entity.QualityDeliverEntity;
import org.apache.ibatis.annotations.Param;
/**
* 配送明细 Mapper 接口
@ -27,4 +28,13 @@ import com.logpm.distribution.entity.QualityDeliverEntity;
*/
public interface QualityDeliverMapper extends BaseMapper<QualityDeliverEntity> {
void deleteByPlanReservationCode(@Param("reservationCode") String reservationCode);
void deleteEntityById(@Param("id") Long id);
void delStockingOperation(@Param("id") Long id);
void delPlanDelivery(@Param("id") Long id);
void delDistributionCarStart(@Param("id") Long id);
}

41
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/QualityDeliverMapper.xml

@ -6,5 +6,46 @@
<resultMap id="qualityDeliverResultMap" type="com.logpm.distribution.entity.QualityDeliverEntity">
</resultMap>
<delete id="deleteByPlanReservationCode">
delete from logpm_quality_deliver where plan_reservation_code = #{reservationCode}
</delete>
<delete id="deleteEntityById">
delete from logpm_quality_deliver where id = #{id}
</delete>
<delete id="delStockingOperation">
update logpm_quality_deliver
set stockup_code = null,
stockup_user_name = null,
stockup_finish_time = null,
stockup_create_time = null,
stock_num = null,
stock_allocation = null,
stockup_type = null
where id = #{id}
</delete>
<delete id="delPlanDelivery">
update logpm_quality_deliver
set plan_train_number = null,
delivery_time = null,
delivery_type = null,
delivery_kind = null,
vehicle_name = null,
driver_name = null,
delivery_fee = null,
distribution_company = null,
delivery_plan_time = null,
plan_type = null,
delivery_create_user_name = null,
yn_whole_vehicle = null
where id = #{id}
</delete>
<delete id="delDistributionCarStart">
update logpm_quality_deliver
set start_car_user_name = null,
start_car_time = null
where id = #{id}
</delete>
</mapper>

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

@ -2,20 +2,14 @@ package com.logpm.distribution.receiver.report;
import cn.hutool.core.collection.CollUtil;
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.conditions.update.LambdaUpdateWrapper;
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;
import com.logpm.distribution.service.IQualityDeliverService;
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.report.ReportConstants;
import org.springblade.common.enums.BizOperationEnums;
import org.springblade.common.enums.PackageTypeEnums;
@ -23,11 +17,6 @@ import org.springblade.common.model.NodeFanoutMsg;
import org.springblade.common.model.PackageData;
import org.springblade.common.model.workNode.DeliveryOfPickupPlanVO;
import org.springblade.core.tool.utils.BeanUtil;
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;
@ -43,28 +32,13 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class BillPlanReportListener {
public class BillPlanReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@Resource
private IFactoryDataClient factoryDataClient;
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillPlan.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillPlan.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getBillPlanReport()) {
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);
@ -72,21 +46,6 @@ public class BillPlanReportListener {
Long warehouseId = bean.getWarehouseId();
BizOperationEnums bizOperation = bean.getBizOperation();
List<PackageData> details = vo.getPackageDataList();
if (BizOperationEnums.MODIFY.equals(bizOperation) || BizOperationEnums.DELETE.equals(bizOperation)) {
// 根据预约单号查询出所有这个预约单下的数据 先置空
LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate()
.set(QualityDeliverEntity::getPlanTrainNumber, null)
.set(QualityDeliverEntity::getDeliveryTime, null)
.set(QualityDeliverEntity::getDeliveryType, null)
.set(QualityDeliverEntity::getVehicleName, null)
.set(QualityDeliverEntity::getBizCode, null)
.set(QualityDeliverEntity::getDriverName, null)
.set(QualityDeliverEntity::getDeliveryPlanTime, null)
.set(QualityDeliverEntity::getDeliveryCreateUserName, null)
.eq(QualityDeliverEntity::getBizCode, vo.getPickupBatch())
.ne(QualityDeliverEntity::getBizStatus, 110);
qualityDeliverService.update(wrapper);
}
if (CollUtil.isNotEmpty(details)) {
for (PackageData detail : details) {
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder()

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

@ -2,7 +2,6 @@ package com.logpm.distribution.receiver.report;
import cn.hutool.core.collection.CollUtil;
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.distribution.dto.ReportQualityDeliverDTO;
@ -40,7 +39,7 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class BillReViewReportListener {
public class BillReViewReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -49,19 +48,8 @@ public class BillReViewReportListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillSignReview.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillSignReview.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getBillReviewReport()) {
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);

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

@ -40,7 +40,7 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class BillSignforReportListener {
public class BillSignforReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -49,11 +49,7 @@ public class BillSignforReportListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillSign.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillSign.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getBillSignforReport()) {
return;

85
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/CarStartReportListener.java

@ -1,29 +1,27 @@
package com.logpm.distribution.receiver.report;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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;
import com.logpm.distribution.service.IQualityDeliverService;
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.model.CarStartVO;
import org.springblade.common.model.NodeFanoutMsg;
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.List;
/**
* 发车生成明细报表
@ -34,7 +32,7 @@ import javax.annotation.Resource;
@Slf4j
@Component
@AllArgsConstructor
public class CarStartReportListener {
public class CarStartReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -43,42 +41,53 @@ public class CarStartReportListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndCarStart.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndCarStart.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getCarStartReport()) {
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);
CarStartVO vo = JSONUtil.toBean(entries, CarStartVO.class);
BizOperationEnums bizOperation = bean.getBizOperation();
if (BizOperationEnums.DELETE.equals(bizOperation)) {
LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate()
.set(QualityDeliverEntity::getStartCarUserName, null)
.set(QualityDeliverEntity::getStartCarTime, null)
.eq(QualityDeliverEntity::getLoadTrainNumber, vo.getTrainNumber())
.eq(QualityDeliverEntity::getLoadLicensePlate, vo.getVehicleName())
.ne(QualityDeliverEntity::getBizStatus, 110);
qualityDeliverService.update(wrapper);
}
if (BizOperationEnums.ADD.equals(bizOperation)) {
LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate()
.set(QualityDeliverEntity::getStartCarUserName, vo.getDriverName())
.set(QualityDeliverEntity::getStartCarTime, bean.getOperatorTime())
.eq(QualityDeliverEntity::getLoadTrainNumber, vo.getTrainNumber())
.eq(QualityDeliverEntity::getLoadLicensePlate, vo.getVehicleName())
.ne(QualityDeliverEntity::getBizStatus, 110);
qualityDeliverService.update(wrapper);
// 装车车次号 + 车牌
String trainNumber = vo.getTrainNumber();
String vehicleName = vo.getVehicleName();
List<QualityDeliverEntity> qualityDeliverEntities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery()
.select(QualityDeliverEntity::getId)
.eq(QualityDeliverEntity::getLoadTrainNumber, trainNumber)
.eq(QualityDeliverEntity::getLoadLicensePlate, vehicleName)
);
if (CollUtil.isNotEmpty(qualityDeliverEntities)) {
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder()
.startCarUserName(bean.getOperator())
.startCarTime(bean.getOperatorTime())
.build();
if (BizOperationEnums.DELETE.equals(bizOperation)) {
for (QualityDeliverEntity deliverEntity : qualityDeliverEntities) {
qualityDeliverEntity.setId(deliverEntity.getId());
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE);
}
}
if (BizOperationEnums.ADD.equals(bizOperation)) {
for (QualityDeliverEntity deliverEntity : qualityDeliverEntities) {
qualityDeliverEntity.setId(deliverEntity.getId());
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
}
}
}
private void sendReport(QualityDeliverEntity qualityDeliverEntity, BizOperationEnums operationEnums) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder()
.data(JSONUtil.toJsonStr(qualityDeliverEntity))
.operation(operationEnums)
.node(WorkNodeEnums.DISTRIBUTION_CAR_START.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());
}
}

101
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ConsigneeArriveReportListener.java

@ -1,29 +1,27 @@
package com.logpm.distribution.receiver.report;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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;
import com.logpm.distribution.service.IQualityDeliverService;
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.model.ConsigneeArriveVO;
import org.springblade.common.model.NodeFanoutMsg;
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.List;
/**
* 配送到达生成明细报表
@ -34,65 +32,58 @@ import javax.annotation.Resource;
@Slf4j
@Component
@AllArgsConstructor
public class ConsigneeArriveReportListener {
public class ConsigneeArriveReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@Resource
private IFactoryDataClient factoryDataClient;
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndConsigneeArrive.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndConsigneeArrive.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getConsigneeArriveReport()) {
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);
ConsigneeArriveVO vo = JSONUtil.toBean(entries, ConsigneeArriveVO.class);
BizOperationEnums bizOperation = bean.getBizOperation();
if (BizOperationEnums.DELETE.equals(bizOperation)) {
LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate()
.set(QualityDeliverEntity::getArriveCarUserName, null)
.set(QualityDeliverEntity::getArriveCarTime, null)
.set(QualityDeliverEntity::getArriveProvince, null)
.set(QualityDeliverEntity::getArriveCity, null)
.set(QualityDeliverEntity::getArriveDistrict, null)
.set(QualityDeliverEntity::getArriveTownship, null)
.set(QualityDeliverEntity::getArriveAddress, null)
.set(QualityDeliverEntity::getArrivePositioning, null)
.eq(QualityDeliverEntity::getLoadLicensePlate, vo.getVehicleName())
.eq(QualityDeliverEntity::getLoadTrainNumber, vo.getTrainNumber())
.eq(QualityDeliverEntity::getBizCode, vo.getReservationCode())
.ne(QualityDeliverEntity::getBizStatus, 110);
qualityDeliverService.update(wrapper);
}
if (BizOperationEnums.ADD.equals(bizOperation)) {
LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate()
.set(QualityDeliverEntity::getArriveCarUserName, vo.getDriverName())
.set(QualityDeliverEntity::getArriveCarTime, bean.getOperatorTime())
.set(QualityDeliverEntity::getArriveProvince, vo.getProvince())
.set(QualityDeliverEntity::getArriveCity, vo.getCity())
.set(QualityDeliverEntity::getArriveDistrict, vo.getDistrict())
.set(QualityDeliverEntity::getArriveTownship, vo.getTownship())
.set(QualityDeliverEntity::getArriveAddress, vo.getAddress())
.set(QualityDeliverEntity::getArrivePositioning, vo.getPositioning())
.eq(QualityDeliverEntity::getLoadTrainNumber, vo.getTrainNumber())
.eq(QualityDeliverEntity::getLoadLicensePlate, vo.getVehicleName())
.eq(QualityDeliverEntity::getBizCode, vo.getReservationCode())
.ne(QualityDeliverEntity::getBizStatus, 110);
qualityDeliverService.update(wrapper);
// 装车车次号 + 车牌
String reservationCode = vo.getReservationCode();
List<QualityDeliverEntity> qualityDeliverEntities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery()
.select(QualityDeliverEntity::getId)
.eq(QualityDeliverEntity::getPlanReservationCode, reservationCode)
);
if (CollUtil.isNotEmpty(qualityDeliverEntities)) {
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder()
.arriveCarUserName(vo.getDriverName())
.arriveCarTime(DateUtil.formatDateTime(bean.getOperatorTime()))
.arriveProvince(vo.getProvince())
.arriveCity(vo.getCity())
.arriveDistrict(vo.getDistrict())
.arriveTownship(vo.getTownship())
.arriveAddress(vo.getAddress())
.arrivePositioning(vo.getPositioning())
.build();
if (BizOperationEnums.ADD.equals(bizOperation)) {
for (QualityDeliverEntity deliverEntity : qualityDeliverEntities) {
qualityDeliverEntity.setId(deliverEntity.getId());
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
}
}
}
private void sendReport(QualityDeliverEntity qualityDeliverEntity, BizOperationEnums operationEnums) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder()
.data(JSONUtil.toJsonStr(qualityDeliverEntity))
.operation(operationEnums)
.node(WorkNodeEnums.DISTRIBUTION_CAR_ARRIVED.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());
}
}

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

@ -25,18 +25,12 @@ import com.logpm.statistics.vo.ExpenseDispatchPriceCategoryVO;
import com.logpm.statistics.vo.ExpenseDispatchPriceVO;
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.enums.BizOperationEnums;
import org.springblade.common.enums.BooleanZeroOneEnums;
import org.springblade.common.model.NodeFanoutMsg;
import org.springblade.common.model.workNode.FinishDistributionTrainVO;
import org.springblade.common.utils.GaoDeApiUtil;
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;
@ -60,7 +54,7 @@ import java.util.stream.Collectors;
@Slf4j
@Component
@AllArgsConstructor
public class DeliverFinishReportListener {
public class DeliverFinishReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -75,29 +69,8 @@ public class DeliverFinishReportListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillAndFinish.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillAndFinish.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
public void buildPickUpReport(String msg) {
this.buildReport(msg);
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndFinish.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndFinish.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getDeliverFinishReport()) {
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);
@ -106,7 +79,6 @@ public class DeliverFinishReportListener {
// 根据车次查询出包件明细,然后计算对应的成本
List<QualityDeliverEntity> entities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery()
.eq(QualityDeliverEntity::getSignTrainNumber, trainNumber)
.eq(QualityDeliverEntity::getBizStatus, 100)
);
if (CollUtil.isNotEmpty(entities)) {
// 按签收车分组
@ -888,7 +860,6 @@ public class DeliverFinishReportListener {
}
}
}
}
if (CollUtil.isNotEmpty(valueMap)) {
// 修改配送明细信息

104
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/LoadingReportListener.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,20 @@ 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.DistributionLoadVO;
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 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;
/**
* 装车生成明细报表
@ -40,7 +39,7 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class LoadingReportListener {
public class LoadingReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -49,19 +48,7 @@ public class LoadingReportListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndLoading.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndLoading.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getLoadingReport()) {
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);
@ -69,6 +56,26 @@ public class LoadingReportListener {
Long warehouseId = bean.getWarehouseId();
BizOperationEnums bizOperation = bean.getBizOperation();
List<PackageData> details = vo.getPackageDataList();
// 单号 referenceCode
String referenceCode = vo.getTrainNumber();
Map<String, List<QualityDeliverEntity>> cmpMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> ltlMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> invMap = new HashMap<>();
if (StrUtil.isNotEmpty(referenceCode)) {
List<QualityDeliverEntity> qualityDeliverEntities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery()
.eq(QualityDeliverEntity::getPlanTrainNumber, referenceCode));
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()
@ -83,36 +90,49 @@ public class LoadingReportListener {
.bizCode(vo.getReservationCode())
.build();
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) {
qualityDeliverEntity.setConditions(1);
// qualityDeliverEntity.setConditions(1);
qualityDeliverEntity.setLoadNum(1);
sendReport(bizOperation, qualityDeliverEntity);
// 装车包件是计划内的 更新
if (cmpMap.containsKey(detail.getPackageCode())) {
qualityDeliverEntity.setId(cmpMap.get(detail.getPackageCode()).get(0).getId());
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) {
qualityDeliverEntity.setOrderCode(detail.getOrderCode());
qualityDeliverEntity.setCategory(detail.getProductName());
qualityDeliverEntity.setConditions(2);
sendReport(bizOperation, qualityDeliverEntity);
// qualityDeliverEntity.setOrderCode(detail.getOrderCode());
// qualityDeliverEntity.setCategory(detail.getProductName());
// qualityDeliverEntity.setConditions(2);
if (ltlMap.containsKey(detail.getProductName() + detail.getOrderCode())) {
qualityDeliverEntity.setId(ltlMap.get(detail.getProductName() + detail.getOrderCode()).get(0).getId());
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
} 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);
// qualityDeliverEntity.setIncomingBatch(detail.getPickupBatch());
// qualityDeliverEntity.setMallName(detail.getMallName());
// qualityDeliverEntity.setMaterielCode(detail.getMaterialCode());
// qualityDeliverEntity.setMaterielName(detail.getMaterialName());
// qualityDeliverEntity.setConditions(3);
qualityDeliverEntity.setLoadNum(1);
if (invMap.containsKey(detail.getPackageCode())) {
qualityDeliverEntity.setId(invMap.get(detail.getPackageCode()).get(0).getId());
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
}
}
}
}
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(QualityDeliverEntity qualityDeliverEntity, BizOperationEnums operationEnums) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder()
.data(JSONUtil.toJsonStr(qualityDeliverEntity))
.operation(operationEnums)
.node(WorkNodeEnums.DISTRIBUTION_LOADING.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());
}
}

166
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/PlanReportListener.java

@ -2,11 +2,10 @@ package com.logpm.distribution.receiver.report;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.distribution.dto.ReportQualityDeliverDTO;
import com.logpm.distribution.entity.QualityDeliverEntity;
@ -16,7 +15,7 @@ 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;
@ -25,11 +24,6 @@ import org.springblade.common.model.NodeFanoutMsg;
import org.springblade.common.model.PackageData;
import org.springblade.common.model.PlanDriverbindCarVO;
import org.springblade.common.model.ReservationVO;
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;
@ -37,6 +31,7 @@ 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;
/**
@ -48,7 +43,7 @@ import java.util.stream.Collectors;
@Slf4j
@Component
@AllArgsConstructor
public class PlanReportListener {
public class PlanReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -57,19 +52,8 @@ public class PlanReportListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndPlan.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndPlan.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getLoadingReport()) {
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);
@ -86,28 +70,26 @@ public class PlanReportListener {
vehicleName = planDriverbindCars.stream().map(PlanDriverbindCarVO::getCarPlate).collect(Collectors.joining(","));
driverName = planDriverbindCars.stream().map(PlanDriverbindCarVO::getDriverName).collect(Collectors.joining(","));
}
Map<String, QualityDeliverEntity> invMap = new HashMap<>();
if (BizOperationEnums.MODIFY.equals(bizOperation) || BizOperationEnums.DELETE.equals(bizOperation)) {
// 根据预约单号查询出所有这个预约单下的数据 先置空
LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate()
.set(QualityDeliverEntity::getDeliveryTime, null)
.set(QualityDeliverEntity::getDeliveryType, null)
.set(QualityDeliverEntity::getDeliveryKind, null)
.set(QualityDeliverEntity::getVehicleName, null)
.set(QualityDeliverEntity::getDriverName, null)
.set(QualityDeliverEntity::getDistributionCompany, null)
.set(QualityDeliverEntity::getDeliveryPlanTime, null)
.set(QualityDeliverEntity::getDeliveryCreateUserName, null)
.set(QualityDeliverEntity::getYnWholeVehicle, null)
.set(QualityDeliverEntity::getDeliveryFee, null)
.eq(QualityDeliverEntity::getPlanTrainNumber, vo.getTrainNumber())
.ne(QualityDeliverEntity::getBizStatus, 110);
if (BizOperationEnums.DELETE.equals(bizOperation)) {
wrapper.set(QualityDeliverEntity::getPlanTrainNumber, null);
Set<String> reservationCodeSet = reservationVOList.stream().map(ReservationVO::getReservationCode).collect(Collectors.toSet());
Map<String, List<QualityDeliverEntity>> cmpMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> ltlMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> invMap = new HashMap<>();
if(CollUtil.isNotEmpty(reservationCodeSet)){
List<QualityDeliverEntity> qualityDeliverEntities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery().in(QualityDeliverEntity::getPlanReservationCode, reservationCodeSet));
if (CollUtil.isNotEmpty(qualityDeliverEntities)) {
cmpMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.CMP.getCode()))
.collect(Collectors.groupingBy(item -> item.getPlanReservationCode() + item.getOrderPackageCode()));
ltlMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.LTL.getCode()))
.collect(Collectors.groupingBy(item -> item.getPlanReservationCode() + item.getCategory() + item.getOrderCode()));
invMap = qualityDeliverEntities.stream()
.filter(item -> NumberUtil.equals(item.getConditions(), PackageTypeEnums.INV.getCode()))
.collect(Collectors.groupingBy(item -> item.getPlanReservationCode() + item.getMallName() + item.getMaterielCode()));
}
qualityDeliverService.update(wrapper);
}
for (ReservationVO reservationVO : reservationVOList) {
String reservationCode = reservationVO.getReservationCode();
List<PackageData> details = reservationVO.getPackageDataList();
if (CollUtil.isNotEmpty(details)) {
for (PackageData detail : details) {
@ -130,59 +112,97 @@ public class PlanReportListener {
.build();
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) {
qualityDeliverEntity.setConditions(1);
qualityDeliverEntity.setPlanNum(1);
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());
if (cmpMap.containsKey(reservationCode + detail.getPackageCode())) {
qualityDeliverEntity.setId(cmpMap.get(reservationCode + detail.getPackageCode()).get(0).getId());
if (BizOperationEnums.DELETE.equals(bizOperation)) {
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE);
} else {
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
}
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) {
qualityDeliverEntity.setOrderCode(detail.getOrderCode());
qualityDeliverEntity.setCategory(detail.getProductName());
qualityDeliverEntity.setConditions(2);
qualityDeliverEntity.setPlanNum(detail.getNumber());
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());
if (ltlMap.containsKey(reservationCode + detail.getProductName() + detail.getOrderCode())) {
qualityDeliverEntity.setId(ltlMap.get(reservationCode + detail.getProductName() + detail.getOrderCode()).get(0).getId());
if (BizOperationEnums.DELETE.equals(bizOperation)) {
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE);
} else {
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
}
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.INV)) {
invMap.put(detail.getMallName() + detail.getMaterialCode(), qualityDeliverEntity);
qualityDeliverEntity.setBizCode(reservationVO.getReservationCode());
qualityDeliverEntity.setIncomingBatch(detail.getPickupBatch());
qualityDeliverEntity.setMallName(detail.getMallName());
qualityDeliverEntity.setMaterielCode(detail.getMaterialCode());
qualityDeliverEntity.setMaterielName(detail.getMaterialName());
qualityDeliverEntity.setConditions(3);
qualityDeliverEntity.setPlanNum(1);
if (BizOperationEnums.ADD.equals(bizOperation) || BizOperationEnums.MODIFY.equals(bizOperation)) {
invMap.put(detail.getMallName() + detail.getMaterialCode(), qualityDeliverEntity);
if (invMap.containsKey(reservationCode + detail.getMallName() + detail.getMaterialCode())) {
List<QualityDeliverEntity> qualityDeliverEntities = invMap.get(reservationCode + detail.getMallName() + detail.getMaterialCode());
if (CollUtil.isNotEmpty(qualityDeliverEntities)) {
if (BizOperationEnums.DELETE.equals(bizOperation)) {
for (QualityDeliverEntity deliverEntity : qualityDeliverEntities) {
qualityDeliverEntity.setId(deliverEntity.getId());
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE);
}
} else {
for (QualityDeliverEntity deliverEntity : qualityDeliverEntities) {
qualityDeliverEntity.setId(deliverEntity.getId());
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
}
}
}
}
}
}
}
if (CollUtil.isNotEmpty(invMap)) {
for (Map.Entry<String, QualityDeliverEntity> entry : invMap.entrySet()) {
QualityDeliverEntity qualityDeliverEntity = entry.getValue();
qualityDeliverService.update(qualityDeliverEntity, Wrappers.<QualityDeliverEntity>lambdaUpdate()
.eq(QualityDeliverEntity::getPlanTrainNumber, qualityDeliverEntity.getPlanTrainNumber())
.eq(QualityDeliverEntity::getMallName, qualityDeliverEntity.getMallName())
.eq(QualityDeliverEntity::getMaterielCode, qualityDeliverEntity.getMaterielCode())
.eq(QualityDeliverEntity::getConditions, 3)
.lt(QualityDeliverEntity::getBizStatus, 110)
);
// 系统中有的包件在当前不存在,则删除
Set<String> cmpSet = details.stream()
.filter(item -> ObjectUtil.equals(item.getPackageType(), PackageTypeEnums.CMP))
.map(i-> reservationCode + i.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 -> reservationCode + 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 -> reservationCode + i.getMallName() + i.getMaterialCode()).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(QualityDeliverEntity qualityDeliverEntity, BizOperationEnums operationEnums) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder()
.data(JSONUtil.toJsonStr(qualityDeliverEntity))
.operation(operationEnums)
.node(WorkNodeEnums.PLAN_DELIVERY.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());
}
}

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

@ -15,10 +15,12 @@ import com.logpm.distribution.dto.ReportQualityDeliverDTO;
import com.logpm.distribution.entity.DistributionParcelListEntity;
import com.logpm.distribution.entity.DistributionStockArticleEntity;
import com.logpm.distribution.entity.DistributionStockListEntity;
import com.logpm.distribution.entity.DistributionStockListInfoEntity;
import com.logpm.distribution.entity.QualityDeliverEntity;
import com.logpm.distribution.pros.DistributionProperties;
import com.logpm.distribution.service.IDistributionParcelListService;
import com.logpm.distribution.service.IDistributionStockArticleService;
import com.logpm.distribution.service.IDistributionStockListInfoService;
import com.logpm.distribution.service.IDistributionStockListService;
import com.logpm.distribution.service.IQualityDeliverService;
import com.logpm.trunkline.feign.ITrunklineAdvanceDetailClient;
@ -29,16 +31,12 @@ import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.Nullable;
import org.springblade.common.constant.report.ReportConstants;
import org.springblade.common.constant.WorkNodeEnums;
import org.springblade.common.enums.BizOperationEnums;
import org.springblade.common.enums.PackageTypeEnums;
import org.springblade.core.redis.cache.BladeRedis;
import org.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.Arrays;
@ -53,7 +51,7 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class QualityDeliverListener {
public class QualityDeliverListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -73,6 +71,9 @@ public class QualityDeliverListener {
@Resource
private IDistributionStockListService stockListService;
@Resource
private IDistributionStockListInfoService stockListInfoService;
@Resource
private IBasicdataFactoryCategoryClient factoryCategoryClient;
@ -87,62 +88,65 @@ public class QualityDeliverListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = ReportConstants.REPORT_QUALITY_DELIVER_QUEUE, durable = "true"),
exchange = @Exchange(name = ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE, type = ExchangeTypes.TOPIC),
key = ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY
))
public void data(String msg) throws InterruptedException {
if (!destinationProperties.getReport().getQualityDeliver()) {
return;
}
log.info("配送明细基础表处理: {}", msg);
if (StrUtil.isEmpty(msg)) {
return;
}
@Transactional
public void buildReport(String msg) {
ReportQualityDeliverDTO bean = JSONUtil.toBean(msg, ReportQualityDeliverDTO.class);
String node = bean.getNode();
String data = bean.getData();
QualityDeliverEntity qualityDeliverEntity = JSONUtil.toBean(data, QualityDeliverEntity.class);
Integer conditions = qualityDeliverEntity.getConditions();
if (ObjectUtil.equals(bean.getOperation(), BizOperationEnums.MODIFY)) {
if (ObjectUtil.equals(PackageTypeEnums.CMP.getCode(), conditions)) {
// 定制品
LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery();
if (ObjectUtil.isNotEmpty(qualityDeliverEntity.getId())) {
wrapper.eq(QualityDeliverEntity::getId, qualityDeliverEntity.getId());
} else {
wrapper.eq(QualityDeliverEntity::getOrderPackageCode, qualityDeliverEntity.getOrderPackageCode());
}
wrapper.lt(QualityDeliverEntity::getBizStatus, 110);
saveOrUpdate(wrapper, qualityDeliverEntity);
} else if (ObjectUtil.equals(PackageTypeEnums.INV.getCode(), conditions)) {
// 库存品
LambdaQueryWrapper<QualityDeliverEntity> wrapper = buildInvWrapper(qualityDeliverEntity);
if (wrapper == null) {
return;
}
// 查询不存在时更新,存在时修改
saveOrUpdate(wrapper, qualityDeliverEntity);
} else if (ObjectUtil.equals(PackageTypeEnums.LTL.getCode(), conditions)) {
// 零担
LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery();
if (ObjectUtil.isNotEmpty(qualityDeliverEntity.getId())) {
wrapper.eq(QualityDeliverEntity::getId, qualityDeliverEntity.getId());
} else {
wrapper.eq(QualityDeliverEntity::getOrderCode, qualityDeliverEntity.getOrderCode())
.eq(QualityDeliverEntity::getCategory, qualityDeliverEntity.getCategory());
}
wrapper.lt(QualityDeliverEntity::getBizStatus, 110);
if (StrUtil.isNotEmpty(qualityDeliverEntity.getBizCode())) {
wrapper.eq(QualityDeliverEntity::getBizCode, qualityDeliverEntity.getBizCode());
}
saveOrUpdate(wrapper, qualityDeliverEntity);
}
qualityDeliverService.updateById(qualityDeliverEntity);
// if (ObjectUtil.equals(PackageTypeEnums.CMP.getCode(), conditions)) {
// // 定制品
// LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery();
// if (ObjectUtil.isNotEmpty(qualityDeliverEntity.getId())) {
// wrapper.eq(QualityDeliverEntity::getId, qualityDeliverEntity.getId());
// } else {
// wrapper.eq(QualityDeliverEntity::getOrderPackageCode, qualityDeliverEntity.getOrderPackageCode());
// }
// wrapper.lt(QualityDeliverEntity::getBizStatus, 110);
// saveOrUpdate(wrapper, qualityDeliverEntity);
// } else if (ObjectUtil.equals(PackageTypeEnums.INV.getCode(), conditions)) {
// // 库存品
// LambdaQueryWrapper<QualityDeliverEntity> wrapper = buildInvWrapper(qualityDeliverEntity);
// if (wrapper == null) {
// return;
// }
// // 查询不存在时更新,存在时修改
// saveOrUpdate(wrapper, qualityDeliverEntity);
// } else if (ObjectUtil.equals(PackageTypeEnums.LTL.getCode(), conditions)) {
// // 零担
// LambdaQueryWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaQuery();
// if (ObjectUtil.isNotEmpty(qualityDeliverEntity.getId())) {
// wrapper.eq(QualityDeliverEntity::getId, qualityDeliverEntity.getId());
// } else {
// wrapper.eq(QualityDeliverEntity::getOrderCode, qualityDeliverEntity.getOrderCode())
// .eq(QualityDeliverEntity::getCategory, qualityDeliverEntity.getCategory());
// }
// wrapper.lt(QualityDeliverEntity::getBizStatus, 110);
// if (StrUtil.isNotEmpty(qualityDeliverEntity.getBizCode())) {
// wrapper.eq(QualityDeliverEntity::getBizCode, qualityDeliverEntity.getBizCode());
// }
// saveOrUpdate(wrapper, qualityDeliverEntity);
// }
}
if (ObjectUtil.equals(bean.getOperation(), BizOperationEnums.ADD)) {
if (ObjectUtil.equals(PackageTypeEnums.INV.getCode(), conditions)) {
// 查询不存在时更新,存在时修改
saveOrUpdate(null, qualityDeliverEntity);
// 查询不存在时更新,存在时修改
saveOrUpdate(null, qualityDeliverEntity);
}
if (ObjectUtil.equals(bean.getOperation(), BizOperationEnums.DELETE)) {
if (StrUtil.equals(node, WorkNodeEnums.PLANNED_RESERVATION.getValue())){
qualityDeliverService.deleteEntityById(qualityDeliverEntity.getId());
}
if (StrUtil.equals(node, WorkNodeEnums.STOCKING_OPERATION.getValue())){
qualityDeliverService.delStockingOperation(qualityDeliverEntity.getId());
}
if (StrUtil.equals(node, WorkNodeEnums.PLAN_DELIVERY.getValue())){
qualityDeliverService.delPlanDelivery(qualityDeliverEntity.getId());
}
if (StrUtil.equals(node, WorkNodeEnums.DISTRIBUTION_CAR_START.getValue())){
qualityDeliverService.delDistributionCarStart(qualityDeliverEntity.getId());
}
}
}
@ -265,9 +269,16 @@ public class QualityDeliverListener {
String brandName = stockList.getBrandName();
String sourceType = stockList.getSourceType();
if (StrUtil.equals(sourceType, "1")) {
DistributionParcelListEntity parcelListEntity = getDistributionParcelListEntity(qualityDeliverEntity.getOrderPackageCode(), qualityDeliverEntity.getWarehouseId());
buildCmpBasicInfo(qualityDeliverEntity, parcelListEntity);
// 定制品转的库存品先查出包条码
List<DistributionStockListInfoEntity> list = stockListInfoService.list(Wrappers.<DistributionStockListInfoEntity>lambdaQuery().eq(DistributionStockListInfoEntity::getStockListId, stockList.getId()));
if (CollUtil.isNotEmpty(list)) {
DistributionStockListInfoEntity distributionStockListInfoEntity = list.get(0);
DistributionParcelListEntity parcelListEntity = getDistributionParcelListEntity(distributionStockListInfoEntity.getPackageCode(), qualityDeliverEntity.getWarehouseId());
buildCmpBasicInfo(qualityDeliverEntity, parcelListEntity);
}
} else {
qualityDeliverEntity.setBeginWarehouseName(stockList.getWarehouseName());
qualityDeliverEntity.setBeginWarehouseInTime(stockList.getWarehousingTime());
qualityDeliverEntity.setBrandName(brandName);
qualityDeliverEntity.setMallCode(stockList.getMarketCode());
qualityDeliverEntity.setMallId(stockList.getMarketId());
@ -313,6 +324,10 @@ public class QualityDeliverListener {
// 物料编码
qualityDeliverEntity.setMaterielCode(parcelListEntity.getMaterialCode());
}
// 包条码
if (StrUtil.isNotEmpty(parcelListEntity.getOrderPackageCode())) {
qualityDeliverEntity.setOrderPackageCode(parcelListEntity.getOrderPackageCode());
}
// 订单号
qualityDeliverEntity.setOrderCode(parcelListEntity.getOrderCode());
// 工厂车次号
@ -352,12 +367,14 @@ public class QualityDeliverListener {
private void buildOrderInfo(QualityDeliverEntity qualityDeliverEntity, Long warehouseId, String orderCode) {
DistributionStockArticleEntity stockArticleEntity = getDistributionStockArticleEntity(warehouseId, orderCode);
if (ObjectUtil.isNotEmpty(stockArticleEntity)) {
qualityDeliverEntity.setOrderNumber(stockArticleEntity.getTotalNumber());
// 客户信息
qualityDeliverEntity.setCustomName(stockArticleEntity.getCustomerName());
qualityDeliverEntity.setCustomPhone(stockArticleEntity.getCustomerTelephone());
qualityDeliverEntity.setCustomAddress(stockArticleEntity.getCustomerAddress());
// 商场信息
qualityDeliverEntity.setMallName(stockArticleEntity.getMallName());
qualityDeliverEntity.setMallId(stockArticleEntity.getMallId());
qualityDeliverEntity.setMallCode(stockArticleEntity.getMallCode());
// 服务号
qualityDeliverEntity.setServiceNumber(stockArticleEntity.getServiceNumber());

87
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReViewReportListener.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.DistributionSignforVO;
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 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;
/**
* 文员复核生成明细报表
@ -40,7 +40,7 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class ReViewReportListener {
public class ReViewReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -49,25 +49,34 @@ public class ReViewReportListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndrecheck.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndrecheck.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getReViewReport()) {
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);
DistributionSignforVO vo = JSONUtil.toBean(entries, DistributionSignforVO.class);
Long warehouseId = bean.getWarehouseId();
BizOperationEnums bizOperation = bean.getBizOperation();
String reservationCode = vo.getReservationCode();
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()));
}
}
List<PackageData> details = vo.getPackageDataList();
if (CollUtil.isNotEmpty(details)) {
for (PackageData detail : details) {
@ -77,39 +86,53 @@ public class ReViewReportListener {
.orderPackageCode(detail.getPackageCode())
.reviewUserName(bean.getOperator())
.reviewTime(bean.getOperatorTime())
.reviewNum(detail.getNumber())
.bizCode(vo.getReservationCode())
.bizStatus(100)
.build();
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) {
qualityDeliverEntity.setConditions(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.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.CLERK_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());
}
}

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

@ -0,0 +1,419 @@
package com.logpm.distribution.receiver.report;
import cn.hutool.core.util.StrUtil;
import com.logpm.distribution.pros.DistributionProperties;
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.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.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
/**
* 配送明细报表作业节点监听器
*
* @author zhaoqiaobo
* @create 2024-03-18 0:02
*/
@Slf4j
@Component
@AllArgsConstructor
public class ReportListener {
private final DistributionProperties destinationProperties;
private final List<ReportService> reportServices;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillPlan.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillPlan.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void billPlanReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getBillPlanReport()) {
flag = Boolean.FALSE;
}
log.info("自提任务生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(BillPlanReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("自提任务生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillSignReview.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillSignReview.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void billReViewReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getBillReviewReport()) {
flag = Boolean.FALSE;
}
log.info("自提复核生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(BillReViewReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("自提复核生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.DeliveryOfPickup.BillSign.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.DeliveryOfPickup.BillSign.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void billSignforReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getBillSignforReport()) {
flag = Boolean.FALSE;
}
log.info("自提签收扫描生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(BillSignforReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("自提签收扫描生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndCarStart.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndCarStart.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void carStartReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getCarStartReport()) {
flag = Boolean.FALSE;
}
log.info("发车生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(CarStartReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("发车生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndConsigneeArrive.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndConsigneeArrive.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void consigneeArriveReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getConsigneeArriveReport()) {
flag = Boolean.FALSE;
}
log.info("配送到达生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(ConsigneeArriveReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("配送到达生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndFinish.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndFinish.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void deliverFinishReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getDeliverFinishReport()) {
flag = Boolean.FALSE;
}
log.info("车次完成生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(DeliverFinishReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("车次完成生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndLoading.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndLoading.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void loadingReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getLoadingReport()) {
flag = Boolean.FALSE;
}
log.info("装车生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(LoadingReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("装车生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndPlan.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndPlan.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void planReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getPlanReport()) {
flag = Boolean.FALSE;
}
log.info("配送计划生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(PlanReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("配送计划生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.reservation.OwnReservation.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.reservation.OwnReservation.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void reservationPlanReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getReservationPlanReport()) {
flag = Boolean.FALSE;
}
log.info("预约计划生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(ReservationPlanReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("预约计划生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndReturnWarehouse.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndReturnWarehouse.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void returnWarehouseReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getReturnWarehouseReport()) {
flag = Boolean.FALSE;
}
log.info("回库生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(ReturnWarehouseReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("回库生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndrecheck.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndrecheck.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void reViewReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getReViewReport()) {
flag = Boolean.FALSE;
}
log.info("文员复核生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(ReViewReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("文员复核生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndSignfor.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndSignfor.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void signforReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getSignforReport()) {
flag = Boolean.FALSE;
}
log.info("签收扫描生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(SignforReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("签收扫描生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.stock.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.stock.EXCHANGE, type = ExchangeTypes.FANOUT)
), ackMode = "MANUAL")
public void stockReportListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getStockReport()) {
flag = Boolean.FALSE;
}
log.info("备货生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(StockReportListener.class).buildReport(msg);
} catch (Exception e) {
log.error("备货生成明细报表失败: {}", e.getMessage());
}
}
try {
channel.basicAck(tag, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = ReportConstants.REPORT_QUALITY_DELIVER_QUEUE, durable = "true"),
exchange = @Exchange(name = ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE, type = ExchangeTypes.TOPIC),
key = ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY
), ackMode = "MANUAL")
public void qualityDeliverListener(String msg, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
Boolean flag = Boolean.TRUE;
if (!destinationProperties.getReport().getQualityDeliver()) {
flag = Boolean.FALSE;
}
log.info("配送明细基础表: {}", msg);
if (StrUtil.isEmpty(msg)) {
flag = Boolean.FALSE;
}
if (flag) {
try {
selectReportService(QualityDeliverListener.class).buildReport(msg);
} 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) {
// 根据某些条件选择具体的实现类
for (ReportService reportService : reportServices) {
if (clazz.isInstance(reportService)) {
return reportService;
}
}
// 默认返回第一个实现类
return reportServices.get(0);
}
}

11
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReportService.java

@ -0,0 +1,11 @@
package com.logpm.distribution.receiver.report;
/**
* @Author: zqb
* @Date: 2024/12/10
*/
public interface ReportService {
void buildReport(String msg);
}

201
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReservationPlanReportListener.java

@ -1,21 +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.conditions.update.LambdaUpdateWrapper;
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;
import com.logpm.distribution.service.IQualityDeliverService;
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.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;
@ -23,16 +22,14 @@ import org.springblade.common.model.NodeFanoutMsg;
import org.springblade.common.model.PackageData;
import org.springblade.common.model.ReservationVO;
import org.springblade.core.tool.utils.BeanUtil;
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.Set;
import java.util.stream.Collectors;
/**
* 预约计划生成明细报表
@ -43,29 +40,13 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class ReservationPlanReportListener {
public class ReservationPlanReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@Resource
private IFactoryDataClient factoryDataClient;
@Resource
private DistributionProperties destinationProperties;
private final IFactoryDataClient factoryDataClient;
private final QualityDeliverMapper qualityDeliverMapper;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.reservation.OwnReservation.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.reservation.OwnReservation.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) throws InterruptedException {
if (!destinationProperties.getReport().getReservationPlanReport()) {
return;
}
log.info("预约计划生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) {
return;
}
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
NodeFanoutMsg bean = JSONUtil.toBean(msg, NodeFanoutMsg.class);
Object main = bean.getMain();
JSONObject entries = JSONUtil.parseObj(main);
@ -73,21 +54,30 @@ public class ReservationPlanReportListener {
Long warehouseId = bean.getWarehouseId();
BizOperationEnums bizOperation = bean.getBizOperation();
List<PackageData> details = vo.getPackageDataList();
if (BizOperationEnums.MODIFY.equals(bizOperation) || BizOperationEnums.DELETE.equals(bizOperation)) {
// 根据预约单号查询出所有这个预约单下的数据 先置空
LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate()
.set(QualityDeliverEntity::getPlanReservationCreateTime, null)
.set(QualityDeliverEntity::getPlanReservationCode, null)
.set(QualityDeliverEntity::getBizCode, null)
.set(QualityDeliverEntity::getPlanReservationTime, null)
.set(QualityDeliverEntity::getPlanReservationUser, null)
.set(QualityDeliverEntity::getPlanNum, null)
.set(QualityDeliverEntity::getReservationConsignee, null)
.set(QualityDeliverEntity::getReservationConsigneePhone, null)
.set(QualityDeliverEntity::getReservationConsigneeAddr, null)
.eq(QualityDeliverEntity::getPlanReservationCode, vo.getReservationCode())
.ne(QualityDeliverEntity::getBizStatus, 110);
qualityDeliverService.update(wrapper);
String reservationCode = vo.getReservationCode();
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) {
@ -101,7 +91,6 @@ public class ReservationPlanReportListener {
.planReservationTime(vo.getReservationDate())
.planReservationUser(bean.getOperator())
.planNum(detail.getNumber())
// .serviceType(vo.getDeliveryType())
.reservationConsignee(vo.getConsignee())
.reservationConsigneePhone(vo.getDeliveryPhone())
.reservationConsigneeAddr(vo.getDeliveryAddress())
@ -109,13 +98,25 @@ public class ReservationPlanReportListener {
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());
@ -124,28 +125,98 @@ public class ReservationPlanReportListener {
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.PLANNED_RESERVATION.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());
}
}

24
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReturnWarehouseReportListener.java

@ -2,7 +2,6 @@ package com.logpm.distribution.receiver.report;
import cn.hutool.core.collection.CollUtil;
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.distribution.dto.ReportQualityDeliverDTO;
@ -13,18 +12,12 @@ 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.report.ReportConstants;
import org.springblade.common.enums.BizOperationEnums;
import org.springblade.common.enums.PackageTypeEnums;
import org.springblade.common.model.DistributionSignforVO;
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 org.springframework.transaction.annotation.Transactional;
@ -40,7 +33,7 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class ReturnWarehouseReportListener {
public class ReturnWarehouseReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -49,19 +42,8 @@ public class ReturnWarehouseReportListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndReturnWarehouse.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndReturnWarehouse.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getReturnWarehouseReport()) {
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);
@ -78,7 +60,7 @@ public class ReturnWarehouseReportListener {
.reviewUserName(bean.getOperator())
.reviewTime(bean.getOperatorTime())
.bizCode(vo.getReservationCode())
.bizStatus(100)
.bizStatus(-1)
.build();
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) {
qualityDeliverEntity.setConditions(1);

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

@ -2,10 +2,12 @@ package com.logpm.distribution.receiver.report;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
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;
@ -14,23 +16,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.DistributionSignforVO;
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 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;
/**
* 签收扫描生成明细报表
@ -41,7 +41,7 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class SignforReportListener {
public class SignforReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@ -50,19 +50,8 @@ public class SignforReportListener {
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.DeliveryAndSignfor.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.DeliveryAndSignfor.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getSignforReport()) {
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);
@ -70,6 +59,26 @@ public class SignforReportListener {
Long warehouseId = bean.getWarehouseId();
BizOperationEnums bizOperation = bean.getBizOperation();
List<PackageData> details = vo.getPackageDataList();
String reservationCode = vo.getReservationCode();
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()
@ -86,17 +95,26 @@ public class SignforReportListener {
.signType(vo.getOperatMode())
.bizCode(vo.getReservationCode())
.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.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());
@ -104,22 +122,27 @@ public class SignforReportListener {
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.DISTRIBUTION_SIGN_FOR.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());
}
}

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

@ -1,6 +1,7 @@
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;
@ -8,29 +9,26 @@ 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;
import com.logpm.distribution.service.IQualityDeliverService;
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.StockUpVO;
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;
/**
* 备货生成明细报表
@ -41,28 +39,15 @@ import java.util.List;
@Slf4j
@Component
@AllArgsConstructor
public class StockReportListener {
public class StockReportListener implements ReportService {
@Resource
private IQualityDeliverService qualityDeliverService;
@Resource
private IFactoryDataClient factoryDataClient;
@Resource
private DistributionProperties destinationProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FanoutConstants.distribution.stock.QUEUE.REPORT, durable = "true"),
exchange = @Exchange(name = FanoutConstants.distribution.stock.EXCHANGE, type = ExchangeTypes.FANOUT)
))
// @Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) {
if (!destinationProperties.getReport().getStockReport()) {
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);
@ -70,6 +55,25 @@ public class StockReportListener {
Long warehouseId = bean.getWarehouseId();
BizOperationEnums bizOperation = bean.getBizOperation();
List<PackageData> details = vo.getPackageDataList();
// 单号 referenceCode
String referenceCode = vo.getReferenceCode();
Map<String, List<QualityDeliverEntity>> cmpMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> ltlMap = new HashMap<>();
Map<String, List<QualityDeliverEntity>> invMap = new HashMap<>();
if (StrUtil.isNotEmpty(referenceCode)) {
List<QualityDeliverEntity> qualityDeliverEntities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery().eq(QualityDeliverEntity::getPlanReservationCode, referenceCode));
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.getMallName() + item.getMaterielCode()));
}
}
if (CollUtil.isNotEmpty(details)) {
for (PackageData detail : details) {
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder()
@ -86,16 +90,26 @@ public class StockReportListener {
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) {
qualityDeliverEntity.setConditions(1);
qualityDeliverEntity.setStockNum(1);
if (BizOperationEnums.ADD.equals(bizOperation) || BizOperationEnums.MODIFY.equals(bizOperation)) {
sendReport(qualityDeliverEntity);
if (cmpMap.containsKey(detail.getPackageCode())) {
qualityDeliverEntity.setId(cmpMap.get(detail.getPackageCode()).get(0).getId());
if (BizOperationEnums.DELETE.equals(bizOperation)) {
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE);
} else {
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
}
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) {
qualityDeliverEntity.setOrderCode(detail.getOrderCode());
qualityDeliverEntity.setCategory(detail.getProductName());
qualityDeliverEntity.setConditions(2);
qualityDeliverEntity.setStockNum(detail.getNumber());
if (BizOperationEnums.ADD.equals(bizOperation) || BizOperationEnums.MODIFY.equals(bizOperation)) {
sendReport(qualityDeliverEntity);
if (ltlMap.containsKey(detail.getProductName() + detail.getOrderCode())) {
qualityDeliverEntity.setId(ltlMap.get(detail.getProductName() + detail.getOrderCode()).get(0).getId());
if (BizOperationEnums.DELETE.equals(bizOperation)) {
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE);
} else {
sendReport(qualityDeliverEntity, BizOperationEnums.MODIFY);
}
}
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.INV)) {
qualityDeliverEntity.setBizCode(vo.getReferenceCode());
@ -105,19 +119,24 @@ public class StockReportListener {
qualityDeliverEntity.setMaterielName(detail.getMaterialName());
qualityDeliverEntity.setConditions(3);
qualityDeliverEntity.setStockNum(1);
if (BizOperationEnums.ADD.equals(bizOperation) || BizOperationEnums.MODIFY.equals(bizOperation)) {
List<QualityDeliverEntity> list = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery()
.select(QualityDeliverEntity::getId)
.eq(QualityDeliverEntity::getBizCode, qualityDeliverEntity.getBizCode())
.eq(QualityDeliverEntity::getMallName, qualityDeliverEntity.getMallName())
.eq(QualityDeliverEntity::getMaterielCode, qualityDeliverEntity.getMaterielCode())
.isNull(QualityDeliverEntity::getOrderPackageCode)
.lt(QualityDeliverEntity::getBizStatus, 110)
.last(" limit 1")
);
if(CollUtil.isNotEmpty(list)){
qualityDeliverEntity.setId(list.get(0).getId());
sendReport(qualityDeliverEntity);
if (invMap.containsKey(detail.getMallName() + detail.getMaterialCode())) {
List<QualityDeliverEntity> qualityDeliverEntities = invMap.get(detail.getMallName() + detail.getMaterialCode());
if (CollUtil.isNotEmpty(qualityDeliverEntities)) {
if (BizOperationEnums.DELETE.equals(bizOperation)) {
List<QualityDeliverEntity> collect = qualityDeliverEntities.stream()
.filter(i -> StrUtil.equals(i.getOrderPackageCode(), detail.getPackageCode()))
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(collect)) {
qualityDeliverEntity.setId(collect.get(0).getId());
sendReport(qualityDeliverEntity, BizOperationEnums.DELETE);
}
} else {
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);
}
}
}
}
}
@ -125,8 +144,12 @@ public class StockReportListener {
}
}
private void sendReport(QualityDeliverEntity qualityDeliverEntity) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder().data(JSONUtil.toJsonStr(qualityDeliverEntity)).operation(BizOperationEnums.MODIFY).build();
private void sendReport(QualityDeliverEntity qualityDeliverEntity, BizOperationEnums operationEnums) {
ReportQualityDeliverDTO dto = ReportQualityDeliverDTO.builder()
.data(JSONUtil.toJsonStr(qualityDeliverEntity))
.operation(operationEnums)
.node(WorkNodeEnums.STOCKING_OPERATION.getValue())
.build();
factoryDataClient.sendMessage(SendMsg.builder()
.exchange(ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE)
.routingKey(ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY)

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

@ -32,4 +32,12 @@ public interface IQualityDeliverService extends BaseService<QualityDeliverEntity
void calculateStorageCost(String param);
void calculateTransshipmentCost(String param);
void deleteEntityById(Long id);
void delStockingOperation(Long id);
void delPlanDelivery(Long id);
void delDistributionCarStart(Long id);
}

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

@ -1913,6 +1913,8 @@ public class DistributionReservationServiceImpl extends BaseServiceImpl<Distribu
.eq(DistributionParcelNumberEntity::getParcelListId, distributionReservationZeroPackageEntity.getParcelListId()));
parcelNumberEntity.setDeliveryQuantity(parcelNumberEntity.getDeliveryQuantity() - quantity + p.getReservationNum());
distributionParcelNumberService.updateById(parcelNumberEntity);
}else{
allZeroPackageEntityList.add(distributionReservationZeroPackageEntity);
}
zeroPrderNum.getAndAdd(distributionReservationZeroPackageEntity.getQuantity());
} else {

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

@ -405,4 +405,24 @@ public class QualityDeliverServiceImpl extends BaseServiceImpl<QualityDeliverMap
}
@Override
public void deleteEntityById(Long id) {
baseMapper.deleteEntityById(id);
}
@Override
public void delStockingOperation(Long id) {
baseMapper.delStockingOperation(id);
}
@Override
public void delPlanDelivery(Long id) {
baseMapper.delPlanDelivery(id);
}
@Override
public void delDistributionCarStart(Long id) {
baseMapper.delDistributionCarStart(id);
}
}

Loading…
Cancel
Save