yq 3 роки тому
батько
коміт
d2480e604d

+ 5 - 0
src/main/java/com/usky/dxtop/model/MsgLog.java

@@ -85,4 +85,9 @@ public class MsgLog implements Serializable {
      * 返回值
      */
     private String consequence;
+
+    /**
+     * 是否成功
+     */
+    private Boolean isSuccess;
 }

+ 1 - 1
src/main/java/com/usky/dxtop/service/MsgLogService.java

@@ -19,7 +19,7 @@ public interface MsgLogService extends IService<MsgLog> {
     Boolean isRepetition(MsgLog msgLog);
 
 
-    void consumerSuccess(Long id,String consequence);
+    void consumerSuccess(String consequence);
 
     /**
      * 判断是否同步成功

+ 11 - 2
src/main/java/com/usky/dxtop/service/impl/MsgLogServiceImpl.java

@@ -1,5 +1,6 @@
 package com.usky.dxtop.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -28,9 +29,16 @@ public class MsgLogServiceImpl extends ServiceImpl<MsgLogMapper, MsgLog> impleme
     }
 
     @Override
-    public void consumerSuccess(Long id,String consequence) {
-        MsgLog msgLog = this.getById(id);
+    public void consumerSuccess(String consequence) {
+        JSONObject jsonObject = JSONObject.parseObject(consequence);
+        Long msgId = Long.parseLong(jsonObject.get("seq").toString());
+        MsgLog msgLog = this.getById(msgId);
         if (this.isRepetition(msgLog)){
+            if ("1".equals(jsonObject.get("code").toString())){
+                msgLog.setIsSuccess(true);
+            }else {
+                msgLog.setIsSuccess(false);
+            }
             msgLog.setConsequence(consequence);
             msgLog.setMsgFlag(MsgLogStatus.CONSUMER_SUCCESS.getCode());
             this.updateById(msgLog);
@@ -41,6 +49,7 @@ public class MsgLogServiceImpl extends ServiceImpl<MsgLogMapper, MsgLog> impleme
     public boolean isSuccess(Long businessId) {
         LambdaQueryWrapper<MsgLog> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(MsgLog::getMsgFlag,MsgLogStatus.CONSUMER_SUCCESS.getCode())
+                .eq(MsgLog::getIsSuccess,true)
                 .eq(MsgLog::getBusinessId,businessId);
         int count = this.count(queryWrapper);
         if (count > 0){

+ 1 - 1
src/main/java/com/usky/dxtop/service/impl/StaffServiceImpl.java

@@ -103,7 +103,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
         map.put("card_type",1);
         map.put("card",staff.getCardId());
         map.put("name",staff.getName());
-        map.put("mob",staff.getId());
+        map.put("mob",staff.getSId());
         map.put("groupid",staff.getDeptId());
         map.put("tel",staff.getContacts());
         map.put("level_name","测试卡");

+ 1 - 11
src/main/java/com/usky/dxtop/service/listener/CartGetMqListener.java

@@ -1,11 +1,8 @@
 package com.usky.dxtop.service.listener;
 
-import com.alibaba.fastjson.JSONObject;
 import com.usky.dxtop.common.exception.CustomException;
-import com.usky.dxtop.model.MsgLog;
 import com.usky.dxtop.service.MsgLogService;
 import com.usky.dxtop.service.config.rabbitmq.cartget.CartGetProduceConfig;
-import com.usky.dxtop.service.emun.MsgLogStatus;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.core.Message;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
@@ -32,14 +29,7 @@ public class CartGetMqListener {
         try {
             //消息类型
             String s = new String(message.getBody(), StandardCharsets.UTF_8);
-            JSONObject jsonObject = JSONObject.parseObject(s);
-            Long msgId = Long.parseLong(jsonObject.get("seq").toString());
-            MsgLog msgLog = msgLogService.getById(msgId);
-            if (msgLogService.isRepetition(msgLog)){
-                msgLog.setConsequence(s);
-                msgLog.setMsgFlag(MsgLogStatus.CONSUMER_SUCCESS.getCode());
-                msgLogService.updateById(msgLog);
-            }
+            msgLogService.consumerSuccess(s);
         } catch (Exception e) {
             log.info("charge_trans_produce"+"异常信息:" + e.getMessage());
             throw new CustomException(e.getMessage());

+ 1 - 8
src/main/java/com/usky/dxtop/service/listener/FaceMqListener.java

@@ -1,6 +1,5 @@
 package com.usky.dxtop.service.listener;
 
-import com.alibaba.fastjson.JSONObject;
 import com.usky.dxtop.service.MsgLogService;
 import com.usky.dxtop.service.config.rabbitmq.face.FaceProduceConfig;
 import lombok.extern.slf4j.Slf4j;
@@ -24,14 +23,8 @@ public class FaceMqListener {
     @RabbitListener(queues = FaceProduceConfig.NAME, containerFactory = FaceProduceConfig.LISTENER)
     public void dealDeclareMessage(Message message) {
         try {
-            //消息类型
-            String routingKey = message.getMessageProperties().getReceivedRoutingKey();
-            log.info(routingKey);
             String s = new String(message.getBody(), StandardCharsets.UTF_8);
-            log.info("charge_trans_produce:接受到的消息"+s);
-            JSONObject jsonObject = JSONObject.parseObject(s);
-            Long msgId = Long.parseLong(jsonObject.get("seq").toString());
-            msgLogService.consumerSuccess(msgId,s);
+            msgLogService.consumerSuccess(s);
         } catch (Exception e) {
             log.info("charge_trans_produce"+"异常信息:" + e.getMessage());
         } finally {

+ 1 - 8
src/main/java/com/usky/dxtop/service/listener/GroupMqListener.java

@@ -1,6 +1,5 @@
 package com.usky.dxtop.service.listener;
 
-import com.alibaba.fastjson.JSONObject;
 import com.usky.dxtop.service.MsgLogService;
 import com.usky.dxtop.service.config.rabbitmq.group.GroupProduceConfig;
 import lombok.extern.slf4j.Slf4j;
@@ -24,14 +23,8 @@ public class GroupMqListener {
     @RabbitListener(queues = GroupProduceConfig.NAME, containerFactory = GroupProduceConfig.LISTENER)
     public void dealDeclareMessage(Message message) {
         try {
-            //消息类型
-            String routingKey = message.getMessageProperties().getReceivedRoutingKey();
-            log.info(routingKey);
             String s = new String(message.getBody(), StandardCharsets.UTF_8);
-            log.info("charge_trans_produce:接受到的消息"+s);
-            JSONObject jsonObject = JSONObject.parseObject(s);
-            Long msgId = Long.parseLong(jsonObject.get("seq").toString());
-            msgLogService.consumerSuccess(msgId,s);
+            msgLogService.consumerSuccess(s);
         } catch (Exception e) {
             log.info("charge_trans_produce"+"异常信息:" + e.getMessage());
         } finally {

+ 1 - 8
src/main/java/com/usky/dxtop/service/listener/PersonMqListener.java

@@ -1,6 +1,5 @@
 package com.usky.dxtop.service.listener;
 
-import com.alibaba.fastjson.JSONObject;
 import com.usky.dxtop.service.MsgLogService;
 import com.usky.dxtop.service.config.rabbitmq.profile.ProfileProduceConfig;
 import lombok.extern.slf4j.Slf4j;
@@ -24,14 +23,8 @@ public class PersonMqListener {
     @RabbitListener(queues = ProfileProduceConfig.NAME, containerFactory = ProfileProduceConfig.LISTENER)
     public void dealDeclareMessage(Message message) {
         try {
-            //消息类型
-            String routingKey = message.getMessageProperties().getReceivedRoutingKey();
-            log.info(routingKey);
             String s = new String(message.getBody(), StandardCharsets.UTF_8);
-            log.info("charge_trans_produce:接受到的消息"+s);
-            JSONObject jsonObject = JSONObject.parseObject(s);
-            Long msgId = Long.parseLong(jsonObject.get("seq").toString());
-            msgLogService.consumerSuccess(msgId,s);
+            msgLogService.consumerSuccess(s);
         } catch (Exception e) {
             log.info("charge_trans_produce"+"异常信息:" + e.getMessage());
         } finally {