|
@@ -1,6 +1,9 @@
|
|
|
package com.fjhx.customer.handle;
|
|
|
|
|
|
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
|
|
|
+import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
|
|
@@ -11,18 +14,25 @@ import com.ruoyi.common.utils.spring.SpringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import com.fjhx.customer.service.xiaoman.XiaomanConfigService;
|
|
|
+import com.ruoyi.common.utils.spring.SpringUtils;
|
|
|
+import okhttp3.HttpUrl;
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.FileReader;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
public class HandleXiaomanData {
|
|
|
+ private static final String ALL_CUSTOMER_API_URL = "https://api-sandbox.xiaoman.cn/v1/company/list";
|
|
|
+ private static XiaomanConfigService xiaomanConfigService = SpringUtils.getBean(XiaomanConfigService.class);
|
|
|
|
|
|
-
|
|
|
+ private static final int PAGE_SIZE = 20;
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
String filePath = "D:\\java_conding\\erhong\\hx-customer\\src\\main\\java\\com\\fjhx\\customer\\handle\\aaa.json";
|
|
@@ -68,4 +78,33 @@ public class HandleXiaomanData {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static void initAllList(){
|
|
|
+ XiaomanConfig config = xiaomanConfigService.getConfig();
|
|
|
+ String token = config.getAccessToken();
|
|
|
+ int pageIndex = 1;
|
|
|
+ int totalPage = 1;
|
|
|
+ do {
|
|
|
+ String str = getData(ALL_CUSTOMER_API_URL, token, pageIndex);
|
|
|
+ CustomerListApiVo customerListApiVo = handleAllCustomer(str);
|
|
|
+ int totalItem = customerListApiVo.getTotalItem();
|
|
|
+ totalPage = (totalItem / PAGE_SIZE) + (totalItem % PAGE_SIZE > 0 ? 1 : 0);
|
|
|
+ pageIndex++;
|
|
|
+ } while (pageIndex <= totalPage);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static String getData(String url, String token, int page) {
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("page", page);
|
|
|
+ params.put("pageSize", PAGE_SIZE);
|
|
|
+ String res = HttpUtil.createGet(url).header("Authorization", "Bearer " + token).form(params).execute().body();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|