16 changed files with 819 additions and 92 deletions
@ -0,0 +1,18 @@
|
||||
package org.springblade.common.constant.report; |
||||
|
||||
/** |
||||
* excel处理常量类 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-03-18 10:30 |
||||
*/ |
||||
public class ReportConstants { |
||||
|
||||
/** |
||||
* 配送明细报表 |
||||
*/ |
||||
public static final String REPORT_QUALITY_DELIVER_EXCHANGE = "report.quality.deliver.exchange"; |
||||
public static final String REPORT_QUALITY_DELIVER_QUEUE = "report.quality.deliver.queue"; |
||||
public static final String REPORT_QUALITY_DELIVER_ROUTINGKEY = "report.quality.deliver.key"; |
||||
|
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.logpm.distribution.dto; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import org.springblade.common.enums.BizOperationEnums; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
@Data |
||||
@Builder |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class ReportQualityDeliverDTO implements Serializable { |
||||
|
||||
private String data; |
||||
|
||||
private BizOperationEnums operation; |
||||
|
||||
} |
@ -0,0 +1,30 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package com.logpm.distribution.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.logpm.distribution.entity.QualityDeliverEntity; |
||||
|
||||
/** |
||||
* 配送明细 Mapper 接口 |
||||
* |
||||
* @author zqb |
||||
* @since 2024-08-23 |
||||
*/ |
||||
public interface QualityDeliverMapper extends BaseMapper<QualityDeliverEntity> { |
||||
|
||||
} |
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.logpm.distribution.mapper.QualityDeliverMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="qualityDeliverResultMap" type="com.logpm.distribution.entity.QualityDeliverEntity"> |
||||
</resultMap> |
||||
|
||||
|
||||
</mapper> |
@ -0,0 +1,139 @@
|
||||
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.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.DistributionLoadVO; |
||||
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.List; |
||||
|
||||
/** |
||||
* 装车生成明细报表 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-03-18 0:02 |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class LoadingReportListener { |
||||
|
||||
@Resource |
||||
private IQualityDeliverService qualityDeliverService; |
||||
@Resource |
||||
private IFactoryDataClient factoryDataClient; |
||||
|
||||
@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) { |
||||
log.info("备货生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
return; |
||||
} |
||||
NodeFanoutMsg bean = JSONUtil.toBean(msg, NodeFanoutMsg.class); |
||||
Long warehouseId = bean.getWarehouseId(); |
||||
BizOperationEnums bizOperation = bean.getBizOperation(); |
||||
List<PackageData> details = bean.getDetails(); |
||||
Object main = bean.getMain(); |
||||
JSONObject entries = JSONUtil.parseObj(main); |
||||
DistributionLoadVO vo = JSONUtil.toBean(entries, DistributionLoadVO.class); |
||||
if (BizOperationEnums.MODIFY.equals(bizOperation) || BizOperationEnums.DELETE.equals(bizOperation)) { |
||||
// 根据预约单号查询出所有这个预约单下的数据 先置空
|
||||
LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate() |
||||
.set(QualityDeliverEntity::getStockupCode, null) |
||||
.set(QualityDeliverEntity::getStockupUserName, null) |
||||
.set(QualityDeliverEntity::getStockupFinishTime, null) |
||||
.set(QualityDeliverEntity::getStockNum, null) |
||||
.set(QualityDeliverEntity::getStockAllocation, null) |
||||
.set(QualityDeliverEntity::getStockupCreateTime, 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) |
||||
.stockupUserName(bean.getOperator()) |
||||
.stockupCreateTime(bean.getOperatorTime()) |
||||
// 备货区 TODO
|
||||
// .stockAllocation(vo.get)
|
||||
.build(); |
||||
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) { |
||||
qualityDeliverEntity.setConditions(1); |
||||
qualityDeliverEntity.setStockNum(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()); |
||||
} |
||||
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) { |
||||
qualityDeliverEntity.setOrderCode(detail.getOrderCode()); |
||||
qualityDeliverEntity.setCostCategory(detail.getProductName()); |
||||
qualityDeliverEntity.setRevenueCategory(detail.getProductName()); |
||||
qualityDeliverEntity.setConditions(2); |
||||
qualityDeliverEntity.setStockNum(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()); |
||||
} |
||||
} 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); |
||||
qualityDeliverEntity.setStockNum(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()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,101 @@
|
||||
package com.logpm.distribution.receiver.report; |
||||
|
||||
import cn.hutool.core.util.ObjectUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
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.service.IQualityDeliverService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
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.stereotype.Component; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
/** |
||||
* 配送明细基础表处理类 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-03-18 0:02 |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class QualityDeliverListener { |
||||
|
||||
@Resource |
||||
private IQualityDeliverService qualityDeliverService; |
||||
|
||||
@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) { |
||||
log.info("明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
return; |
||||
} |
||||
ReportQualityDeliverDTO bean = JSONUtil.toBean(msg, ReportQualityDeliverDTO.class); |
||||
String data = bean.getData(); |
||||
QualityDeliverEntity qualityDeliverEntity = JSONUtil.toBean(data, QualityDeliverEntity.class); |
||||
switch (bean.getOperation()) { |
||||
case MODIFY: |
||||
Integer conditions = qualityDeliverEntity.getConditions(); |
||||
if (1 == conditions) { |
||||
QualityDeliverEntity entity = qualityDeliverService.getOne(Wrappers.<QualityDeliverEntity>lambdaQuery() |
||||
.eq(QualityDeliverEntity::getOrderPackageCode, qualityDeliverEntity.getOrderPackageCode()) |
||||
.lt(QualityDeliverEntity::getBizStatus, 110)); |
||||
if (ObjectUtil.isNotEmpty(entity)) { |
||||
qualityDeliverService.update(qualityDeliverEntity, Wrappers.<QualityDeliverEntity>lambdaUpdate() |
||||
.eq(QualityDeliverEntity::getOrderPackageCode, qualityDeliverEntity.getOrderPackageCode()) |
||||
.lt(QualityDeliverEntity::getBizStatus, 110)); |
||||
} else { |
||||
// 获取基础数据赋值
|
||||
qualityDeliverService.save(qualityDeliverEntity); |
||||
} |
||||
} else if (2 == conditions) { |
||||
QualityDeliverEntity entity = qualityDeliverService.getOne(Wrappers.<QualityDeliverEntity>lambdaQuery() |
||||
.eq(QualityDeliverEntity::getIncomingBatch, qualityDeliverEntity.getIncomingBatch()) |
||||
.eq(QualityDeliverEntity::getMallName, qualityDeliverEntity.getMallName()) |
||||
.eq(QualityDeliverEntity::getMaterielCode, qualityDeliverEntity.getMaterielCode()) |
||||
.lt(QualityDeliverEntity::getBizStatus, 110)); |
||||
if (ObjectUtil.isNotEmpty(entity)) { |
||||
qualityDeliverService.update(qualityDeliverEntity, Wrappers.<QualityDeliverEntity>lambdaUpdate() |
||||
.eq(QualityDeliverEntity::getIncomingBatch, qualityDeliverEntity.getIncomingBatch()) |
||||
.eq(QualityDeliverEntity::getMallName, qualityDeliverEntity.getMallName()) |
||||
.eq(QualityDeliverEntity::getMaterielCode, qualityDeliverEntity.getMaterielCode()) |
||||
.lt(QualityDeliverEntity::getBizStatus, 110)); |
||||
} else { |
||||
// 获取基础数据赋值
|
||||
qualityDeliverService.save(qualityDeliverEntity); |
||||
} |
||||
} else if (3 == conditions) { |
||||
QualityDeliverEntity entity = qualityDeliverService.getOne(Wrappers.<QualityDeliverEntity>lambdaQuery() |
||||
.eq(QualityDeliverEntity::getOrderCode, qualityDeliverEntity.getOrderCode()) |
||||
.eq(QualityDeliverEntity::getCostCategory, qualityDeliverEntity.getCostCategory()) |
||||
.lt(QualityDeliverEntity::getBizStatus, 110)); |
||||
if (ObjectUtil.isNotEmpty(entity)) { |
||||
qualityDeliverService.update(qualityDeliverEntity, Wrappers.<QualityDeliverEntity>lambdaUpdate() |
||||
.eq(QualityDeliverEntity::getOrderCode, qualityDeliverEntity.getOrderCode()) |
||||
.eq(QualityDeliverEntity::getCostCategory, qualityDeliverEntity.getCostCategory()) |
||||
.lt(QualityDeliverEntity::getBizStatus, 110)); |
||||
} else { |
||||
// 获取基础数据赋值
|
||||
qualityDeliverService.save(qualityDeliverEntity); |
||||
} |
||||
} |
||||
break; |
||||
default: |
||||
return; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,139 @@
|
||||
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.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.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 ReservationPlanReportListener { |
||||
|
||||
@Resource |
||||
private IQualityDeliverService qualityDeliverService; |
||||
@Resource |
||||
private IFactoryDataClient factoryDataClient; |
||||
|
||||
@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) { |
||||
log.info("预约计划生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
return; |
||||
} |
||||
NodeFanoutMsg bean = JSONUtil.toBean(msg, NodeFanoutMsg.class); |
||||
Long warehouseId = bean.getWarehouseId(); |
||||
BizOperationEnums bizOperation = bean.getBizOperation(); |
||||
List<PackageData> details = bean.getDetails(); |
||||
Object main = bean.getMain(); |
||||
JSONObject entries = JSONUtil.parseObj(main); |
||||
ReservationVO vo = JSONUtil.toBean(entries, ReservationVO.class); |
||||
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::getPlanReservationTime, null) |
||||
.set(QualityDeliverEntity::getPlanReservationUser, null) |
||||
.set(QualityDeliverEntity::getPlanNum, null) |
||||
.eq(QualityDeliverEntity::getPlanReservationCode, vo.getReservationCode()) |
||||
.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()) |
||||
.planReservationCreateTime(bean.getOperatorTime()) |
||||
.planReservationCode(vo.getReservationCode()) |
||||
.planReservationTime(vo.getReservationDate()) |
||||
.planReservationUser(bean.getOperator()) |
||||
.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()); |
||||
} |
||||
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) { |
||||
qualityDeliverEntity.setOrderCode(detail.getOrderCode()); |
||||
qualityDeliverEntity.setCostCategory(detail.getProductName()); |
||||
qualityDeliverEntity.setRevenueCategory(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()); |
||||
} |
||||
} 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); |
||||
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()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,141 @@
|
||||
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.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.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.List; |
||||
|
||||
/** |
||||
* 备货生成明细报表 |
||||
* |
||||
* @author zhaoqiaobo |
||||
* @create 2024-03-18 0:02 |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class StockReportListener { |
||||
|
||||
@Resource |
||||
private IQualityDeliverService qualityDeliverService; |
||||
@Resource |
||||
private IFactoryDataClient factoryDataClient; |
||||
|
||||
@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) |
||||
public void buildReport(String msg) { |
||||
log.info("备货生成明细报表: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
return; |
||||
} |
||||
NodeFanoutMsg bean = JSONUtil.toBean(msg, NodeFanoutMsg.class); |
||||
Long warehouseId = bean.getWarehouseId(); |
||||
BizOperationEnums bizOperation = bean.getBizOperation(); |
||||
List<PackageData> details = bean.getDetails(); |
||||
Object main = bean.getMain(); |
||||
JSONObject entries = JSONUtil.parseObj(main); |
||||
StockUpVO vo = JSONUtil.toBean(entries, StockUpVO.class); |
||||
if (BizOperationEnums.MODIFY.equals(bizOperation) || BizOperationEnums.DELETE.equals(bizOperation)) { |
||||
// 根据预约单号查询出所有这个预约单下的数据 先置空
|
||||
LambdaUpdateWrapper<QualityDeliverEntity> wrapper = Wrappers.<QualityDeliverEntity>lambdaUpdate() |
||||
.set(QualityDeliverEntity::getStockupCode, null) |
||||
.set(QualityDeliverEntity::getStockupUserName, null) |
||||
.set(QualityDeliverEntity::getStockupFinishTime, null) |
||||
.set(QualityDeliverEntity::getStockNum, null) |
||||
.set(QualityDeliverEntity::getStockAllocation, null) |
||||
.set(QualityDeliverEntity::getStockupCreateTime, null) |
||||
.eq(QualityDeliverEntity::getStockupCode, vo.getStockupCode()) |
||||
.ne(QualityDeliverEntity::getBizStatus, 110); |
||||
qualityDeliverService.update(wrapper); |
||||
} |
||||
if (CollUtil.isNotEmpty(details)) { |
||||
for (PackageData detail : details) { |
||||
QualityDeliverEntity qualityDeliverEntity = QualityDeliverEntity.builder() |
||||
.warehouseName(bean.getWarehouse()) |
||||
.warehouseId(warehouseId) |
||||
.stockupCode(vo.getStockupCode()) |
||||
.stockupUserName(bean.getOperator()) |
||||
.stockupFinishTime(vo.getStockupDate()) |
||||
.stockupCreateTime(bean.getOperatorTime()) |
||||
// 备货区 TODO
|
||||
// .stockAllocation(vo.get)
|
||||
.build(); |
||||
if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.CMP)) { |
||||
qualityDeliverEntity.setConditions(1); |
||||
qualityDeliverEntity.setStockNum(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()); |
||||
} |
||||
} else if (ObjectUtil.equals(detail.getPackageType(), PackageTypeEnums.LTL)) { |
||||
qualityDeliverEntity.setOrderCode(detail.getOrderCode()); |
||||
qualityDeliverEntity.setCostCategory(detail.getProductName()); |
||||
qualityDeliverEntity.setRevenueCategory(detail.getProductName()); |
||||
qualityDeliverEntity.setConditions(2); |
||||
qualityDeliverEntity.setStockNum(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()); |
||||
} |
||||
} 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); |
||||
qualityDeliverEntity.setStockNum(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()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,30 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package com.logpm.distribution.service; |
||||
|
||||
import com.logpm.distribution.entity.QualityDeliverEntity; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
|
||||
/** |
||||
* 配送明细 服务类 |
||||
* |
||||
* @author zqb |
||||
* @since 2024-08-23 |
||||
*/ |
||||
public interface IQualityDeliverService extends BaseService<QualityDeliverEntity> { |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package com.logpm.distribution.service.impl; |
||||
|
||||
import com.logpm.distribution.entity.QualityDeliverEntity; |
||||
import com.logpm.distribution.mapper.QualityDeliverMapper; |
||||
import com.logpm.distribution.service.IQualityDeliverService; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 配送明细 服务实现类 |
||||
* |
||||
* @author zqb |
||||
* @since 2024-08-23 |
||||
*/ |
||||
@Service |
||||
public class QualityDeliverServiceImpl extends BaseServiceImpl<QualityDeliverMapper, QualityDeliverEntity> implements IQualityDeliverService { |
||||
|
||||
} |
Loading…
Reference in new issue