From 2f3221b7c90d5663fdb312653a2d188bc4628370 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 09 二月 2026 10:19:21 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
server/services/src/main/java/com/doumee/core/iPass/IPass.java | 91 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/core/iPass/IPass.java b/server/services/src/main/java/com/doumee/core/iPass/IPass.java
new file mode 100644
index 0000000..b23fd5b
--- /dev/null
+++ b/server/services/src/main/java/com/doumee/core/iPass/IPass.java
@@ -0,0 +1,91 @@
+package com.doumee.core.iPass;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.doumee.core.constants.Constants;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.dao.vo.ZhanQuVO;
+import okhttp3.*;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2026/2/3 15:15
+ */
+public class IPass {
+
+ private static String userName = "djpt";
+ private static String password = "CwzOdj3G8Y05NRu9pWjcmmODj56/6iZjSD33couFE3XNrkNjEQUZwnkLEGN6ot1O7b9q/K+PsRNh7iRquL4ZYQdajIM3P+qxn8Q1eW2eICmwMY0L+vWpBK30xU+DX6yzkt5/meitCa5rZERUWUGAfAfimdvhfCazLseXdB3x/ieJ+/C+22LH0gIZoqiC0xqh+xR5NENu0lcC7PLJoCE0rzq+LLY7TNwmv6Ghxjbq5cCuxMd0H6uD3nKM/13+TNLuod5/9RzGBo966CUqLqS2L6XTqZkGCRwJL7pvD0+ZAnM36gXC1aTXT4Z6bYnwsGfpu7MjHODGSrzhrQEXS2Gbfg==";
+ private static String tokenUrl = "https://ipaasuat.zhibang.com:4430/open-api/rest/core/auth/login";
+ private static String zhanquUrl = "https://ipaasuat.zhibang.com:4430/open-api/mdm/cust-territories-trees/query";
+
+ public String getIPassToken(String userName,String password,String tokenUrl) throws IOException {
+ OkHttpClient client = new OkHttpClient().newBuilder()
+ .build();
+ MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
+ Map<String,String> requestBody = new HashMap<>();
+ requestBody.put("userName",userName);
+ requestBody.put("password",password);
+ RequestBody body = RequestBody.create(mediaType, JSONObject.toJSON(requestBody).toString());
+ Request request = new Request.Builder()
+ .url(tokenUrl)
+ .method("POST", body)
+ .addHeader("User-Agent", "Apifox/1.0.0 (https://apifox.com)")
+ .addHeader("Content-Type", "application/json; charset=utf-8")
+ .build();
+ Response response = client.newCall(request).execute();
+ if(Objects.isNull(response)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鑾峰彇IPASS鎺堟潈鏉冮檺澶辫触,璇疯仈绯荤鐞嗗憳");
+ }
+ if(!Constants.equalsInteger(200,response.code())){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鑾峰彇IPASS鎺堟潈鏉冮檺澶辫触:"+response.message());
+ }
+ JSONObject jsonObject = JSONObject.parseObject(response.body().string());
+ String token = jsonObject.getString("identitytoken");
+ return token;
+ }
+
+
+
+ public List<ZhanQuVO> getIPassZhanquList(String userName,String password,String tokenUrl,String zhanquUrl) throws IOException {
+ OkHttpClient client = new OkHttpClient().newBuilder()
+ .build();
+ MediaType mediaType = MediaType.parse("application/json");
+ Map<String,Object> requestBody = new HashMap<>();
+ requestBody.put("nodeLevel","1");
+ requestBody.put("pageNo","1");
+ requestBody.put("pageSize","1000");
+
+ RequestBody body = RequestBody.create(mediaType, JSONObject.toJSON(requestBody).toString());
+ Request request = new Request.Builder()
+ .url(zhanquUrl)
+ .method("POST", body)
+ .addHeader("identitytoken", getIPassToken(userName,password,tokenUrl))
+ .addHeader("User-Agent", "Apifox/1.0.0 (https://apifox.com)")
+ .addHeader("Content-Type", "application/json")
+ .build();
+ Response response = client.newCall(request).execute();
+ if(Objects.isNull(response)){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鑾峰彇IPASS鎴樺尯淇℃伅澶辫触,璇疯仈绯荤鐞嗗憳");
+ }
+ if(!Constants.equalsInteger(200,response.code())){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鑾峰彇IPASS鎴樺尯淇℃伅澶辫触:"+response.message());
+ }
+ JSONObject json = JSONObject.parseObject(response.body().string());
+ JSONArray jsonArray = json.getJSONArray("rows");
+ List<ZhanQuVO> zhanQuVOS = jsonArray.toJavaList(ZhanQuVO.class);
+ return zhanQuVOS;
+ }
+
+
+
+
+}
--
Gitblit v1.9.3