12 changed files with 787 additions and 589 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,109 @@ |
|||||||
|
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; |
||||||
|
import com.logpm.distribution.entity.QualityDeliverEntity; |
||||||
|
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; |
||||||
|
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.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 回库生成明细报表 |
||||||
|
* |
||||||
|
* @author zhaoqiaobo |
||||||
|
* @create 2024-03-18 0:02 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@Component |
||||||
|
@AllArgsConstructor |
||||||
|
public class ReturnWarehouseReportListener { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private IQualityDeliverService qualityDeliverService; |
||||||
|
@Resource |
||||||
|
private IFactoryDataClient factoryDataClient; |
||||||
|
|
||||||
|
@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) |
||||||
|
public void buildReport(String msg) { |
||||||
|
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(); |
||||||
|
List<PackageData> details = vo.getPackageDataList(); |
||||||
|
if (CollUtil.isNotEmpty(details)) { |
||||||
|
for (PackageData detail : details) { |
||||||
|
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder() |
||||||
|
.warehouseName(bean.getWarehouse()) |
||||||
|
.warehouseId(warehouseId) |
||||||
|
.orderPackageCode(detail.getPackageCode()) |
||||||
|
.reviewUserName(bean.getOperator()) |
||||||
|
.reviewTime(bean.getOperatorTime()) |
||||||
|
.bizStatus(100) |
||||||
|
.build(); |
||||||
|
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) { |
||||||
|
qualityDeliverEntity.setConditions(1); |
||||||
|
sendReport(bizOperation, qualityDeliverEntity); |
||||||
|
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) { |
||||||
|
qualityDeliverEntity.setBizCode(vo.getReservationCode()); |
||||||
|
qualityDeliverEntity.setOrderCode(detail.getOrderCode()); |
||||||
|
qualityDeliverEntity.setCategory(detail.getProductName()); |
||||||
|
qualityDeliverEntity.setConditions(2); |
||||||
|
sendReport(bizOperation, 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); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
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()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue