|
@@ -4,6 +4,7 @@ package com.fjhx.customer.handle;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerSelectDto;
|
|
import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerSelectDto;
|
|
import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
|
|
import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
|
|
@@ -99,7 +100,7 @@ public class HandleXiaomanData {
|
|
int pageIndex = 1;
|
|
int pageIndex = 1;
|
|
int totalPage;
|
|
int totalPage;
|
|
do {
|
|
do {
|
|
- String str = getData(XiaomanContant.ALL_CUSTOMER_API_URL, token, pageIndex);
|
|
|
|
|
|
+ String str = getData(XiaomanContant.ALL_CUSTOMER_API_URL, token, initPageParams(pageIndex));
|
|
CustomerListApiVo customerListApiVo = handleAllCustomer(str, collect);
|
|
CustomerListApiVo customerListApiVo = handleAllCustomer(str, collect);
|
|
int totalItem = customerListApiVo.getTotalItem();
|
|
int totalItem = customerListApiVo.getTotalItem();
|
|
totalPage = (totalItem / PAGE_SIZE) + (totalItem % PAGE_SIZE > 0 ? 1 : 0);
|
|
totalPage = (totalItem / PAGE_SIZE) + (totalItem % PAGE_SIZE > 0 ? 1 : 0);
|
|
@@ -115,11 +116,37 @@ public class HandleXiaomanData {
|
|
redisTemplate.opsForValue().set(XiaomanContant.TASK_STATUS_DESC_KEY, "全量更新完成,完成时间:" + DateUtil.now());
|
|
redisTemplate.opsForValue().set(XiaomanContant.TASK_STATUS_DESC_KEY, "全量更新完成,完成时间:" + DateUtil.now());
|
|
}
|
|
}
|
|
|
|
|
|
- public static String getData(String url, String token, int page) {
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取客户详情
|
|
|
|
+ * @author hj
|
|
|
|
+ * @date 2024/4/6 21:38
|
|
|
|
+ * @param companyId
|
|
|
|
+ */
|
|
|
|
+ public static String getCustomerDetail(Long companyId){
|
|
|
|
+ XiaomanConfig config = xiaomanConfigService.getConfig();
|
|
|
|
+ String token = config.getAccessToken();
|
|
Map<String, Object> params = new HashMap<>();
|
|
Map<String, Object> params = new HashMap<>();
|
|
- params.put("start_index", page);
|
|
|
|
- params.put("count", PAGE_SIZE);
|
|
|
|
|
|
+ params.put("companyId", companyId);
|
|
|
|
+ params.put("format", "1");
|
|
|
|
+ return getData(XiaomanContant.CUSTOMER_DETAIL_API_URL, token, params);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private static Map<String, Object> initPageParams(int page) {
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ params.put("page", page);
|
|
|
|
+ params.put("pageSize", PAGE_SIZE);
|
|
|
|
+ return params;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static String getData(String url, String token, Map<String, Object> params) {
|
|
String res = HttpUtil.createGet(url).header("Authorization", "Bearer " + token).form(params).execute().body();
|
|
String res = HttpUtil.createGet(url).header("Authorization", "Bearer " + token).form(params).execute().body();
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
|
+ String error = jsonObject.getString("error");
|
|
|
|
+ if (StrUtil.isNotBlank(error)) {
|
|
|
|
+ throw new RuntimeException("获取小满数据异常:" + error);
|
|
|
|
+ }
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|