Pu Zhibing
2025-05-26 3aa9f732b013c778a666b00e4936462372878a5c
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/util/haikang/Artemis.java
@@ -1,7 +1,6 @@
package com.ruoyi.dataInterchange.util.haikang;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
@@ -11,12 +10,8 @@
import com.ruoyi.dataInterchange.util.haikang.model.GetTopicInfoRequest;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@@ -53,36 +48,6 @@
      return result;
   }
   //按事件类型获取事件订阅信息
   public static String getTopicInfo(GetTopicInfoRequest getTopicInfoRequest)throws Exception {
      String getTopicInfoDataApi = ARTEMIS_PATH +"/api/common/v1/event/getTopicInfo";
      Map<String,String> path = new HashMap<String,String>(2){
         {
            put("https://",getTopicInfoDataApi);
         }
      };
      String body=JSON.toJSONString(getTopicInfoRequest);
      String result =ArtemisHttpUtil.doPostStringArtemis(artemisConfig,path,body,null,null,"application/json");
      return result;
   }
   public static void run() {
      try {
         //先查询是否订阅事件
         GetTopicInfoRequest getTopicInfoRequest = new GetTopicInfoRequest();
         getTopicInfoRequest.setEventTypes(new ArrayList<Long>(){{
            add(5201154049L);
            add(5201301505L);
         }});
         String eventSubscriptionView = Artemis.getTopicInfo(getTopicInfoRequest);
         JSONObject jsonObject = JSON.parseObject(eventSubscriptionView);
      }catch (Exception e){
         e.printStackTrace();
      }
   }
   //查询事件订阅信息
   public static String eventSubscriptionView(EventSubscriptionViewRequest eventSubscriptionViewRequest) throws Exception {
      String eventSubscriptionViewDataApi = ARTEMIS_PATH +"/api/eventService/v1/eventSubscriptionView";
@@ -109,8 +74,35 @@
      return result;
   }
   public static void main(String[] args) {
      Artemis.run();
   }
   public static void run() {
      try {
         //先查询是否订阅事件
         GetTopicInfoRequest getTopicInfoRequest = new GetTopicInfoRequest();
         getTopicInfoRequest.setEventTypes(new ArrayList<Long>(){{
            add(5201154049L);
            add(5201301505L);
         }});
         String eventSubscriptionView = Artemis.getTopicInfo(getTopicInfoRequest);
         JSONObject jsonObject = JSON.parseObject(eventSubscriptionView);
      }catch (Exception e){
         e.printStackTrace();
      }
   }
   //按事件类型获取事件订阅信息
   public static String getTopicInfo(GetTopicInfoRequest getTopicInfoRequest)throws Exception {
      String getTopicInfoDataApi = ARTEMIS_PATH +"/api/common/v1/event/getTopicInfo";
      Map<String,String> path = new HashMap<String,String>(2){
         {
            put("https://",getTopicInfoDataApi);
         }
      };
      String body=JSON.toJSONString(getTopicInfoRequest);
      String result =ArtemisHttpUtil.doPostStringArtemis(artemisConfig,path,body,null,null,"application/json");
      return result;
   }
}