he.dujuan 3 gadi atpakaļ
vecāks
revīzija
c265d4598b

+ 72 - 68
eladmin-system/src/main/java/me/zhengjie/config/rabbitmq/test/ListenerTemplate.java

@@ -34,18 +34,20 @@ public class ListenerTemplate {
     DmDayPcService dmDayPcService;
     @Autowired
     DmFoodService dmFoodService;
-    @Autowired
-    DmOrderRecordService dmOrderRecordService;
-    @Autowired
-    DmOrderItemService dmOrderItemService;
-    @Autowired
-    DmOrderPaymentService dmOrderPaymentService;
+//    @Autowired
+//    DmOrderRecordService dmOrderRecordService;
+//    @Autowired
+//    DmOrderItemService dmOrderItemService;
+//    @Autowired
+//    DmOrderPaymentService dmOrderPaymentService;
 
-    @RabbitListener(queues = CuisineProduce.NAME, containerFactory = CuisineProduce.LISTENER)
+//    @RabbitListener(queues = CuisineProduce.NAME, containerFactory = CuisineProduce.LISTENER)
     public void dealDeclareMessage(Message message) throws UnsupportedEncodingException {
         String str = new String(message.getBody(),"utf-8");
         System.out.println("receivePc:"+str);
         JSONObject jsonObject = JSONObject.parseObject(str);
+        Long seq = jsonObject.getLong("seq");
+        System.out.println("pc-seq:"+seq);
         JSONArray array = jsonObject.getJSONArray("list");
         System.out.println("listData"+array);
         try {
@@ -70,6 +72,8 @@ public class ListenerTemplate {
                 dmDayPc.setPstate(attendance.getInteger("pstate"));
                 dmDayPc.setWindowName(attendance.getString("window_name"));
                 dmDayPc.setCateName(attendance.getString("cate_name"));
+                dmDayPc.setShopname("东信餐厅");
+                dmDayPc.setSeq(seq);
                 dmDayPc.setDate(new Timestamp(System.currentTimeMillis()));
 
                 dmDayPcService.create(dmDayPc);
@@ -88,66 +92,66 @@ public class ListenerTemplate {
     }
 
 //    @RabbitListener(queues = OrderProduce.NAME_ORDER, containerFactory = OrderProduce.LISTENER_ORDER)
-    public void dealDeclareOrderMessage(Message message) throws UnsupportedEncodingException {
-        System.out.println("messageOrder"+message);
-        String str = new String(message.getBody(),"utf-8");
-        System.out.println("receiveOrder:"+str);
-        try {
-            JSONObject attendance = JSONObject.parseObject(str);
-            DmOrderRecord dmExpenseCalendar = new DmOrderRecord();
-
-            dmExpenseCalendar.setSeq(attendance.getLong("seq"));
-            dmExpenseCalendar.setCreateDate(attendance.getTimestamp("create_date"));
-            dmExpenseCalendar.setCard(attendance.getString("card"));
-            dmExpenseCalendar.setCardNo(attendance.getString("card_no"));
-            dmExpenseCalendar.setType(attendance.getInteger("type"));
-            dmExpenseCalendar.setPart(attendance.getInteger("part"));
-            dmExpenseCalendar.setTerm(attendance.getInteger("term"));
-            dmExpenseCalendar.setShop(attendance.getInteger("shop"));
-            dmExpenseCalendar.setTermName(attendance.getString("term_name"));
-            dmExpenseCalendar.setShopName(attendance.getString("shop_name"));
-            dmExpenseCalendar.setAmt(attendance.getDouble("amt"));
-            dmExpenseCalendar.setMoney(String.valueOf(attendance.getDouble("amt")));
-            dmExpenseCalendar.setBalance(attendance.getDouble("balance"));
-            dmExpenseCalendar.setAccount(attendance.getInteger("account"));
-            dmExpenseCalendar.setUserName(attendance.getString("name"));
-            dmExpenseCalendar.setMob(attendance.getString("mob"));
-            dmExpenseCalendar.setUserCode(attendance.getString("mob"));
-            dmExpenseCalendar.setTel(attendance.getString("tel"));
-            dmExpenseCalendar.setCardProfile(attendance.getInteger("card_profile"));
-
-            String bh = UUID.randomUUID().toString();
-            dmExpenseCalendar.setBh(bh);//关联编号
-            JSONArray item = attendance.getJSONArray("details");
-            for (int i = 0; i < item.size(); i++) {
-                JSONObject userData = item.getJSONObject(i);
-                DmOrderItem dmOrderItem = new DmOrderItem();
-                DmFood dmFood = new DmFood();
-                dmFood.setId(userData.getLong("pid"));
-                dmOrderItem.setSeq(attendance.getLong("seq"));
-                dmOrderItem.setFood(dmFood);
-                dmOrderItem.setBh(bh);
-                dmOrderItem.setName(userData.getString("name"));
-                dmOrderItem.setPrice(userData.getString("price"));
-                dmOrderItem.setAmt(userData.getDouble("amt"));
-                dmOrderItem.setMoney(String.valueOf(userData.getDouble("amt")));
-                dmOrderItemService.create(dmOrderItem);
-            }
-            JSONArray payment = attendance.getJSONArray("payments");
-            for (int i = 0; i < payment.size(); i++) {
-                JSONObject userData = payment.getJSONObject(i);
-                DmOrderPayment dmOrderPayment = new DmOrderPayment();
-                dmOrderPayment.setBh(bh);
-                dmOrderPayment.setType(userData.getString("type"));
-                dmOrderPayment.setAmt(userData.getDouble("amt"));
-                dmOrderPayment.setBalance(userData.getDouble("balance"));
-                dmOrderPayment.setUid(userData.getString("uid"));
-                dmOrderPaymentService.create(dmOrderPayment);
-            }
-            dmOrderRecordService.create(dmExpenseCalendar);
-        }catch (Exception ex){
-            ex.printStackTrace();
-        }
-    }
+//    public void dealDeclareOrderMessage(Message message) throws UnsupportedEncodingException {
+//        System.out.println("messageOrder"+message);
+//        String str = new String(message.getBody(),"utf-8");
+//        System.out.println("receiveOrder:"+str);
+//        try {
+//            JSONObject attendance = JSONObject.parseObject(str);
+//            DmOrderRecord dmExpenseCalendar = new DmOrderRecord();
+//
+//            dmExpenseCalendar.setSeq(attendance.getLong("seq"));
+//            dmExpenseCalendar.setCreateDate(attendance.getTimestamp("create_date"));
+//            dmExpenseCalendar.setCard(attendance.getString("card"));
+//            dmExpenseCalendar.setCardNo(attendance.getString("card_no"));
+//            dmExpenseCalendar.setType(attendance.getInteger("type"));
+//            dmExpenseCalendar.setPart(attendance.getInteger("part"));
+//            dmExpenseCalendar.setTerm(attendance.getInteger("term"));
+//            dmExpenseCalendar.setShop(attendance.getInteger("shop"));
+//            dmExpenseCalendar.setTermName(attendance.getString("term_name"));
+//            dmExpenseCalendar.setShopName(attendance.getString("shop_name"));
+//            dmExpenseCalendar.setAmt(attendance.getDouble("amt"));
+//            dmExpenseCalendar.setMoney(String.valueOf(attendance.getDouble("amt")));
+//            dmExpenseCalendar.setBalance(attendance.getDouble("balance"));
+//            dmExpenseCalendar.setAccount(attendance.getInteger("account"));
+//            dmExpenseCalendar.setUserName(attendance.getString("name"));
+//            dmExpenseCalendar.setMob(attendance.getString("mob"));
+//            dmExpenseCalendar.setUserCode(attendance.getString("mob"));
+//            dmExpenseCalendar.setTel(attendance.getString("tel"));
+//            dmExpenseCalendar.setCardProfile(attendance.getInteger("card_profile"));
+//
+//            String bh = UUID.randomUUID().toString();
+//            dmExpenseCalendar.setBh(bh);//关联编号
+//            JSONArray item = attendance.getJSONArray("details");
+//            for (int i = 0; i < item.size(); i++) {
+//                JSONObject userData = item.getJSONObject(i);
+//                DmOrderItem dmOrderItem = new DmOrderItem();
+//                DmFood dmFood = new DmFood();
+//                dmFood.setId(userData.getLong("pid"));
+//                dmOrderItem.setSeq(attendance.getLong("seq"));
+//                dmOrderItem.setFood(dmFood);
+//                dmOrderItem.setBh(bh);
+//                dmOrderItem.setName(userData.getString("name"));
+//                dmOrderItem.setPrice(userData.getString("price"));
+//                dmOrderItem.setAmt(userData.getDouble("amt"));
+//                dmOrderItem.setMoney(String.valueOf(userData.getDouble("amt")));
+//                dmOrderItemService.create(dmOrderItem);
+//            }
+//            JSONArray payment = attendance.getJSONArray("payments");
+//            for (int i = 0; i < payment.size(); i++) {
+//                JSONObject userData = payment.getJSONObject(i);
+//                DmOrderPayment dmOrderPayment = new DmOrderPayment();
+//                dmOrderPayment.setBh(bh);
+//                dmOrderPayment.setType(userData.getString("type"));
+//                dmOrderPayment.setAmt(userData.getDouble("amt"));
+//                dmOrderPayment.setBalance(userData.getDouble("balance"));
+//                dmOrderPayment.setUid(userData.getString("uid"));
+//                dmOrderPaymentService.create(dmOrderPayment);
+//            }
+//            dmOrderRecordService.create(dmExpenseCalendar);
+//        }catch (Exception ex){
+//            ex.printStackTrace();
+//        }
+//    }
 
 }

+ 7 - 7
eladmin-system/src/main/java/me/zhengjie/config/rabbitmq/test/SendTemplate.java

@@ -16,9 +16,9 @@ public class SendTemplate {
     @Qualifier(CuisineConsumer.TEMPLATE_CON)
     private RabbitTemplate rabbitTemplate;
 
-    @Autowired
-    @Qualifier(OrderProduce.TEMPLATE_ORDER)
-    private RabbitTemplate rabbitTemplate1;
+//    @Autowired
+//    @Qualifier(OrderProduce.TEMPLATE_ORDER)
+//    private RabbitTemplate rabbitTemplate1;
 
     public void sendMessage(Object message){
         rabbitTemplate.convertAndSend(CuisineConsumer.NAME, CuisineConsumer.NAME, message.toString());
@@ -26,8 +26,8 @@ public class SendTemplate {
         System.out.println(message);
     }
 
-    public void  sendOrederMessage(Object message){
-        rabbitTemplate1.convertAndSend(OrderProduce.NAME_ORDER, OrderProduce.NAME_ORDER, message.toString());
-        System.out.println("雄伟发送消息----消息发送到rabbitmq");
-    }
+//    public void  sendOrederMessage(Object message){
+//        rabbitTemplate1.convertAndSend(OrderProduce.NAME_ORDER, OrderProduce.NAME_ORDER, message.toString());
+//        System.out.println("雄伟发送消息----消息发送到rabbitmq");
+//    }
 }

+ 9 - 10
eladmin-system/src/main/java/me/zhengjie/modules/test/TestController.java

@@ -35,19 +35,18 @@ public class TestController {
         map.put("seq",Long.valueOf(timestamp));
         map.put("date",dateNowStr);
         map.put("shopname","餐厅");
-//        map.put("date", "2021-12-07");
         JSONObject jsonObject = new JSONObject(map);
         sendTemplate.sendMessage(jsonObject);
         System.out.println("消息發送成功success"+jsonObject);
     }
 
-    @GetMapping("/send1")
-    public void testSend1(){
-        Map<String,Object> map = new HashMap<>();
-        map.put("seq",1);
-        map.put("date","2021-12-09 00:00:00");
-        map.put("shopname","111");
-        sendTemplate.sendOrederMessage(map);
-        System.out.println("消息發送成功success"+map);
-    }
+//    @GetMapping("/send1")
+//    public void testSend1(){
+//        Map<String,Object> map = new HashMap<>();
+//        map.put("seq",1);
+//        map.put("date","2021-12-09 00:00:00");
+//        map.put("shopname","111");
+//        sendTemplate.sendOrederMessage(map);
+//        System.out.println("消息發送成功success"+map);
+//    }
 }