8 changed files with 336 additions and 89 deletions
@ -0,0 +1,120 @@
|
||||
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.CarStartVO; |
||||
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.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 发车生成明细报表 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-03-18 0:02 |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class CarStartReportListener { |
||||
|
||||
@Resource |
||||
private IQualityDeliverService qualityDeliverService; |
||||
@Resource |
||||
private IFactoryDataClient factoryDataClient; |
||||
|
||||
@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) |
||||
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); |
||||
CarStartVO vo = JSONUtil.toBean(entries, CarStartVO.class); |
||||
Long warehouseId = bean.getWarehouseId(); |
||||
BizOperationEnums bizOperation = bean.getBizOperation(); |
||||
// if (BizOperationEnums.MODIFY.equals(bizOperation) || BizOperationEnums.DELETE.equals(bizOperation)) {
|
||||
// // 根据预约单号查询出所有这个预约单下的数据 先置空
|
||||
// LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate()
|
||||
// .set(QualityDeliverEntity::getLoadUserName, null)
|
||||
// .set(QualityDeliverEntity::getLoadTime, null)
|
||||
// .set(QualityDeliverEntity::getLoadLicensePlate, null)
|
||||
// .set(QualityDeliverEntity::getLoadNum, null)
|
||||
// .ne(QualityDeliverEntity::getBizStatus, 110);
|
||||
// qualityDeliverService.update(wrapper);
|
||||
// }
|
||||
List<PackageData> details = new ArrayList<>(); |
||||
if (CollUtil.isNotEmpty(details)) { |
||||
for (PackageData detail : details) { |
||||
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder() |
||||
.warehouseName(bean.getWarehouse()) |
||||
.warehouseId(warehouseId) |
||||
.orderPackageCode(detail.getPackageCode()) |
||||
.startCarUserName(bean.getOperator()) |
||||
.startCarTime(bean.getOperatorTime()) |
||||
.build(); |
||||
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) { |
||||
qualityDeliverEntity.setConditions(1); |
||||
qualityDeliverEntity.setLoadNum(1); |
||||
sendReport(bizOperation, qualityDeliverEntity); |
||||
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) { |
||||
qualityDeliverEntity.setOrderCode(detail.getOrderCode()); |
||||
qualityDeliverEntity.setCostCategory(detail.getProductName()); |
||||
qualityDeliverEntity.setRevenueCategory(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()); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,121 @@
|
||||
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.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; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 签收扫描生成明细报表 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-03-18 0:02 |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class SignforReportListener { |
||||
|
||||
@Resource |
||||
private IQualityDeliverService qualityDeliverService; |
||||
@Resource |
||||
private IFactoryDataClient factoryDataClient; |
||||
|
||||
@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) |
||||
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 (BizOperationEnums.MODIFY.equals(bizOperation) || BizOperationEnums.DELETE.equals(bizOperation)) {
|
||||
// // 根据预约单号查询出所有这个预约单下的数据 先置空
|
||||
// LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate()
|
||||
// .set(QualityDeliverEntity::getLoadUserName, null)
|
||||
// .set(QualityDeliverEntity::getLoadTime, null)
|
||||
// .set(QualityDeliverEntity::getLoadLicensePlate, null)
|
||||
// .set(QualityDeliverEntity::getLoadNum, null)
|
||||
// .ne(QualityDeliverEntity::getBizStatus, 110);
|
||||
// qualityDeliverService.update(wrapper);
|
||||
// }
|
||||
if (CollUtil.isNotEmpty(details)) { |
||||
for (PackageData detail : details) { |
||||
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder() |
||||
.warehouseName(bean.getWarehouse()) |
||||
.warehouseId(warehouseId) |
||||
.orderPackageCode(detail.getPackageCode()) |
||||
.signUserName(bean.getOperator()) |
||||
.signTime(bean.getOperatorTime()) |
||||
.signCarNumber(vo.getVehicleName()) |
||||
.build(); |
||||
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) { |
||||
qualityDeliverEntity.setConditions(1); |
||||
qualityDeliverEntity.setLoadNum(1); |
||||
sendReport(bizOperation, qualityDeliverEntity); |
||||
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) { |
||||
qualityDeliverEntity.setOrderCode(detail.getOrderCode()); |
||||
qualityDeliverEntity.setCostCategory(detail.getProductName()); |
||||
qualityDeliverEntity.setRevenueCategory(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