修改库存

This commit is contained in:
韩鹏辉
2024-06-25 09:58:21 +08:00
parent c1790a3198
commit 86bdcbe3c5
21 changed files with 406 additions and 26 deletions

View File

@@ -0,0 +1,47 @@
package com.chaozhanggui.system.cashierservice.rabbit;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.TbCashierCartMapper;
import com.chaozhanggui.system.cashierservice.dao.TbConsInfoMapper;
import com.chaozhanggui.system.cashierservice.dao.TbProskuConMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.TbConsInfo;
import com.chaozhanggui.system.cashierservice.entity.TbProskuCon;
import com.chaozhanggui.system.cashierservice.entity.po.ConsInfoPO;
import com.chaozhanggui.system.cashierservice.service.ConsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Slf4j
@Component
@RabbitListener(queues = {RabbitConstants.CONS_COLLECT_QUEUE_PUT})
@Service
public class ConsConsumer {
@Autowired
ConsService consService;
@RabbitHandler
public void listener(String message) {
try {
consService.exect(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -53,9 +53,6 @@ public class PrintMechineConsumer {
@RabbitHandler
public void listener(String message) {
String orderId = message;

View File

@@ -89,6 +89,22 @@ public class RabbitConfig {
@Bean
public DirectExchange consExchange_Register() {
return new DirectExchange(RabbitConstants.CONS_COLLECT_PUT);
}
@Bean
public Queue queuecons_Register() {
return new Queue(RabbitConstants.CONS_COLLECT_QUEUE_PUT, true); //队列持久
}
@Bean
public Binding bindingcons_Register() {
return BindingBuilder.bind(queuePrint_Register()).to(printExchange_Register()).with(RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT);
}

View File

@@ -19,4 +19,16 @@ public interface RabbitConstants {
public static final String PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT = "print_mechine_collect_routingkey_put";
public static final String CONS_COLLECT_PUT="cons_collect_put";
public static final String CONS_COLLECT_QUEUE_PUT = "cons_collect_queue_put";
public static final String CONS_COLLECT_ROUTINGKEY_PUT = "cons_collect_routingkey_put";
}

View File

@@ -35,6 +35,15 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
}
public void cons(String content){
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);
}
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
logger.info(" 回调id:" + correlationData);