岗位自动任务

This commit is contained in:
“wyx12345678” 2024-05-09 11:40:45 +08:00
parent 6a5b2ac0c0
commit eaf7329bf0
2 changed files with 97 additions and 4 deletions

View File

@ -0,0 +1,49 @@
package shkd.cosmic.cxkg.task.DTO;
/**
* @projectName: shkd-cosmic-root-project
* @package: shkd.cosmic.cxkg.task.DTO
* @className: QueryDTO
* @author: wenyx
* @description: TODO
* @date: 2024/5/7 16:38
* @version: 1.0
*/
public class QueryDTO {
private int pagesize; //每页条数
private int curpage; //第几页
private String created; //创建时间戳使用>=
private String modified; //修改时间戳使用>=
public int getPagesize() {
return pagesize;
}
public void setPagesize(int pagesize) {
this.pagesize = pagesize;
}
public int getCurpage() {
return curpage;
}
public void setCurpage(int curpage) {
this.curpage = curpage;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getModified() {
return modified;
}
public void setModified(String modified) {
this.modified = modified;
}
}

View File

@ -1,8 +1,15 @@
package shkd.cosmic.cxkg.task; package shkd.cosmic.cxkg.task;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import kd.bos.org.model.OrgParam;
import shkd.cosmic.cxkg.task.DTO.QueryDTO; import shkd.cosmic.cxkg.task.DTO.QueryDTO;
import java.math.BigDecimal;
import java.math.RoundingMode;
/** /**
* @projectName: shkd-cosmic-root-project * @projectName: shkd-cosmic-root-project
* @package: shkd.cosmic.cxkg.task * @package: shkd.cosmic.cxkg.task
@ -14,15 +21,52 @@ import shkd.cosmic.cxkg.task.DTO.QueryDTO;
*/ */
public class JobtitleTaskImpl { public class JobtitleTaskImpl {
private static int PAGESIZE = 20;
private int CURPAGE = 1;
public void getJobtitleInfo(){ public void getJobtitleInfo(){
String oaUrl = System.getProperty("OaUrl");
//一次请求20条
QueryDTO queryDTO = new QueryDTO(); QueryDTO queryDTO = new QueryDTO();
queryDTO.setCurpage(1); queryDTO.setCurpage(CURPAGE);
queryDTO.setPagesize(2); queryDTO.setPagesize(PAGESIZE);
String json = HttpRequest.post("10.157.226.9:8088/api/hrm/resful/getHrmUserInfoWithPage") String s = JSON.toJSONString(queryDTO);
.body("") String json = HttpRequest.post("http://"+oaUrl+"/api/hrm/resful/getHrmUserInfoWithPage")
.body(s)
.execute().body(); .execute().body();
} JSONObject jsonObject = JSONObject.parseObject(json);
JSONObject data = jsonObject.getJSONObject("data");
JSONArray dataList = data.getJSONArray("dataList");
BigDecimal totalSize = jsonObject.getBigDecimal("totalSize");
BigDecimal sise = new BigDecimal(PAGESIZE);
//计算分多少页
BigDecimal page = totalSize.divide(sise, 0, RoundingMode.UP); //一共多少页
CURPAGE = page.intValue();
queryDTO.setCurpage(CURPAGE);
queryDTO.setPagesize(PAGESIZE);
String s1 = JSON.toJSONString(queryDTO);
String jsonString = HttpRequest.post("http://"+oaUrl+"/api/hrm/resful/getHrmUserInfoWithPage")
.body(s1)
.execute().body();
JSONObject jsonObject1 = JSONObject.parseObject(jsonString);
JSONObject data1 = jsonObject.getJSONObject("data");
JSONArray dataList1 = data.getJSONArray("dataList");
// 遍历解析结果
for (int i = 0; i < dataList1.size(); i++) {
JSONObject item = dataList.getJSONObject(i);
String jobTitleName = item.getString("jobtitlename"); //岗位名称
String created = item.getString("created"); //创建时间
String modified = item.getString("modified"); //修改时间
String id = item.getString("id"); //岗位ID
}
}
} }