Sfoglia il codice sorgente

feat:“添加修改机型接口(删除重新创建MQ队列)”

soobin 1 anno fa
parent
commit
b027a055d5
1 ha cambiato i file con 33 aggiunte e 0 eliminazioni
  1. 33 0
      src/main/java/com/szwl/controller/RabbitMqController.java

+ 33 - 0
src/main/java/com/szwl/controller/RabbitMqController.java

@@ -106,4 +106,37 @@ public class RabbitMqController {
         }
         return "success";
     }
+
+    /**
+     * 修改机型重新创建MQ队列
+     * @param
+     * @return
+     */
+    @GetMapping(value = "/updateEquipmentType")
+    @ResponseBody
+    public String updateEquipmentType(String clientId, String equipmentType){
+        if (StringUtils.isNotEmpty(clientId) && StringUtils.isNotEmpty(equipmentType)) {
+            // 删除MQ队列
+            amqpAdmin.deleteQueue(clientId);
+            // 重新创建队列
+            Map<String,Object> arg = new HashMap<>();
+            arg.put("x-message-ttl",1800000);
+            amqpAdmin.declareQueue(new Queue(clientId, true, false, false, arg));
+            HashMap<String, Object> objectObjectHashMap = new HashMap<>();
+            amqpAdmin.declareBinding(new Binding(clientId,
+                    Binding.DestinationType.QUEUE,
+                    equipmentType, clientId, objectObjectHashMap));
+            LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+            query.eq(TEquipment::getClientId, clientId);
+            TEquipment equipment = tEquipmentService.getOne(query);
+            if(equipment != null){
+                equipment.setEquimentType(equipmentType);
+                tEquipmentService.updateById(equipment);
+                return "success";
+            }
+            return "找不到设备";
+        }
+
+        return "参数为空";
+    }
 }