Browse Source

调整签到、签退信息记录表-新增、事件管理表-新增和APP用户心跳信息-新增三个接口中rabbitMQ推送消息逻辑,调整为点对点,同时增加租户id隔离

james 4 months ago
parent
commit
ff44ace7e5

+ 6 - 2
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/service/listener/RabbitMQListener.java

@@ -7,17 +7,20 @@ import org.springframework.amqp.core.ExchangeTypes;
 import org.springframework.amqp.core.Message;
 import org.springframework.amqp.rabbit.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 @Slf4j
 @Component
 public class RabbitMQListener {
+
     @Autowired
     private patrolAgbox PatrolAgbox;
     @RabbitHandler
     @RabbitListener(bindings = @QueueBinding(
             value = @Queue(),
-            exchange = @Exchange(value = "Patrol_FEvent",type = ExchangeTypes.FANOUT)
+            exchange = @Exchange(value = "Patrol_EEvent"),
+            key = {"${agBox.routeKey}"}
     ))
     public void getData(Message message){
         try {
@@ -52,7 +55,8 @@ public class RabbitMQListener {
     @RabbitHandler
     @RabbitListener(bindings = @QueueBinding(
             value = @Queue(),
-            exchange = @Exchange(value = "Patrol_FInfo",type = ExchangeTypes.FANOUT)
+            exchange = @Exchange(value = "Patrol_EInfo"),
+            key = {"${agBox.routeKey}"}
     ))
     public void getDataInfo(Message message){
         try {

+ 1 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionAttendanceServiceImpl.java

@@ -176,7 +176,7 @@ public class PatrolInspectionAttendanceServiceImpl extends AbstractCrudService<P
         jsonObj.put("name", SecurityUtils.getUsername());
         jsonObj.put("certifiedNo", patrolInspectionAttendance.getIdentificationNumber());
 
-        rabbitTemplate.convertAndSend(rabbitMQConfig.patrolFEventExchange, "", jsonObj.toJSONString());
+        rabbitTemplate.convertAndSend(rabbitMQConfig.patrolEventExchange, SecurityUtils.getTenantId().toString(), jsonObj.toJSONString());
 //        if (pushFlag.equals(1)){
 //            JSONObject a = remotePatrolAgboxService.addEvent(jsonObj.toJSONString());
 //        }

+ 4 - 2
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionEventServiceImpl.java

@@ -125,8 +125,10 @@ public class PatrolInspectionEventServiceImpl extends AbstractCrudService<Patrol
         map.put("remark",patrolInspectionEvent.getRemark());
         map.put("createBy",patrolInspectionEvent.getCreateBy());
         map.put("createTime",patrolInspectionEvent.getCreateTime());
-//        rabbitTemplate.convertAndSend(rabbitMQConfig.patrolEventExchange,rabbitMQConfig.patrolEventRoute,map);
-        rabbitTemplate.convertAndSend(rabbitMQConfig.patrolFEventExchange,"", JSONObject.toJSONString(map));
+
+        rabbitTemplate.convertAndSend(rabbitMQConfig.patrolEventExchange,SecurityUtils.getTenantId().toString(),map);
+//      rabbitTemplate.convertAndSend(rabbitMQConfig.patrolFEventExchange,"", JSONObject.toJSONString(map));
+
         this.save(patrolInspectionEvent);
         String eventTypeName = remoteDictService.selectNameById("patrol_event_type",
                 patrolInspectionEvent.getEventType().toString());

+ 2 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/config/rabbitmq/RabbitMQConfig.java

@@ -6,6 +6,8 @@ import org.springframework.context.annotation.Configuration;
 
 @Configuration
 public class RabbitMQConfig {
+    //点对点
+    public String patrolEInfoExchange = "Patrol_EInfo";
 
     //心跳广播
     public String patrolFInfoExchange = "Patrol_FInfo";

+ 1 - 1
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/BaseAppInfoServiceImpl.java

@@ -102,7 +102,7 @@ public class BaseAppInfoServiceImpl extends AbstractCrudService<BaseAppInfoMappe
         map.put("deviceId",baseAppInfo.getDeviceId());
         map.put("userName",baseAppInfo.getUserName());
         map.put("createTime",baseAppInfo.getCreateTime());
-        rabbitTemplate.convertAndSend(rabbitMQConfig.patrolFInfoExchange,"",JSONObject.toJSONString(map));
+        rabbitTemplate.convertAndSend(rabbitMQConfig.patrolEInfoExchange,SecurityUtils.getTenantId().toString(),JSONObject.toJSONString(map));
 
         this.save(baseAppInfo);
 //        if (pushFlag.equals(1)){