6 changed files with 684 additions and 545 deletions
@ -0,0 +1,81 @@
|
||||
package com.logpm.distribution.receiver.log; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import cn.hutool.json.JSONUtil; |
||||
import com.logpm.distribution.entity.DistributionPlanLogEntity; |
||||
import com.logpm.distribution.service.IDistributionPlanLogService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.constant.DistributionTypeConstant; |
||||
import org.springblade.common.constant.broadcast.FanoutConstants; |
||||
import org.springblade.common.enums.BizOperationEnums; |
||||
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 java.util.List; |
||||
|
||||
@Slf4j |
||||
@Component |
||||
@AllArgsConstructor |
||||
public class ReservationLogListener { |
||||
|
||||
private final IDistributionPlanLogService distributionPlanLogService; |
||||
|
||||
@RabbitListener(bindings = @QueueBinding( |
||||
value = @Queue(name = FanoutConstants.reservation.OwnReservation.QUEUE.OWNRESERVATION_LOG, durable = "true"), |
||||
exchange = @Exchange(name = FanoutConstants.reservation.OwnReservation.EXCHANGE, type = ExchangeTypes.FANOUT) |
||||
)) |
||||
public void reservationLog(String msg) { |
||||
log.info("预约日志: {}", msg); |
||||
if (StrUtil.isEmpty(msg)) { |
||||
return; |
||||
} |
||||
NodeFanoutMsg<ReservationVO> bean = JSONUtil.toBean(msg, NodeFanoutMsg.class); |
||||
if (bean == null) { |
||||
return; |
||||
} |
||||
BizOperationEnums bizOperation = bean.getBizOperation(); |
||||
if(bizOperation.equals(BizOperationEnums.ADD)){ |
||||
// addLog(bean);
|
||||
}else if (bizOperation.equals(BizOperationEnums.MODIFY)){ |
||||
|
||||
log.warn("修改预约信息未记录日志"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
private void addLog(NodeFanoutMsg<ReservationVO> bean) { |
||||
ReservationVO main = bean.getMain(); |
||||
if (main == null) { |
||||
return; |
||||
} |
||||
|
||||
String planContent = bean.getOperator() + "在" + bean.getWarehouse() |
||||
+ "创建预约计划;预约计划编号:" + main.getReservationCode() |
||||
+ ";收货单位:" + main.getReceivingUnit() |
||||
+ ",收货人:" + main.getConsignee() |
||||
+ ",联系电话:" + main.getDeliveryPhone() |
||||
+ ",收货地址:" + main.getDeliveryAddress() |
||||
+ ",计划件数:" + (main.getReservationNum() + main.getReservationStockListNum()) |
||||
+ ",配送类型:" + (main.getDeliveryType().equals(DistributionTypeConstant.shangpei.getValue()) ? "商配" : "市配"); |
||||
DistributionPlanLogEntity distributionPlanLogEntity = new DistributionPlanLogEntity(); |
||||
distributionPlanLogEntity.setContent(planContent); |
||||
distributionPlanLogEntity.setRefId(main.getId()); |
||||
distributionPlanLogEntity.setRefCode(main.getReservationCode()); |
||||
distributionPlanLogEntity.setWarehouseId(bean.getWarehouseId()); |
||||
distributionPlanLogEntity.setWarehouseName(bean.getWarehouse()); |
||||
distributionPlanLogEntity.setOperator(bean.getOperator()); |
||||
distributionPlanLogEntity.setType(1); |
||||
distributionPlanLogService.save(distributionPlanLogEntity); |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue