|
@@ -1,11 +1,15 @@
|
|
|
package com.usky.dxtop.service.job;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.usky.dxtop.common.utils.http.HttpUtils;
|
|
|
+import com.usky.dxtop.model.Staff;
|
|
|
import com.usky.dxtop.service.api.SmApi;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.TreeMap;
|
|
|
|
|
|
/**
|
|
@@ -23,11 +27,29 @@ public class SmJob {
|
|
|
int page = 1;
|
|
|
int size = 100;
|
|
|
while (isNext){
|
|
|
- String personUrl = String.format("%s?page=%s&size=%s", SmApi.PERSON_URL, page, size);
|
|
|
- TreeMap<String, Object> treeMap = SmApi.generatePersonParam(null, null, null, null);
|
|
|
- String s = HttpUtils.sendPost(personUrl, JSONObject.toJSONString(treeMap), SmApi.sign(treeMap));
|
|
|
- System.out.println(s);
|
|
|
- break;
|
|
|
+ try {
|
|
|
+ String personUrl = String.format("%s?page=%s&size=%s", SmApi.PERSON_URL, page, size);
|
|
|
+ TreeMap<String, Object> treeMap = SmApi.generatePersonParam(null, null, null, null);
|
|
|
+ String result = HttpUtils.sendPost(personUrl, JSONObject.toJSONString(treeMap), SmApi.sign(treeMap));
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ if ("200".equals(jsonObject.get("status").toString())){
|
|
|
+ JSONObject data = jsonObject.getJSONObject("data");
|
|
|
+ JSONArray content = data.getJSONArray("content");
|
|
|
+ if(content != null && content.size() > 0) {
|
|
|
+ List<Staff> staffList = content.toJavaList(Staff.class);
|
|
|
+ if (CollectionUtils.isEmpty(staffList)){
|
|
|
+ isNext = false;
|
|
|
+ }else {
|
|
|
+ page++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("smJob异常"+e);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ log.info("smjob 定时任务完成");
|
|
|
}
|
|
|
+
|
|
|
}
|