定时任务同步获取系统参数代码优化

This commit is contained in:
zengweihai 2024-06-03 16:31:30 +08:00
parent db37e17d50
commit 50e677b4d4
3 changed files with 13 additions and 13 deletions

View File

@ -34,6 +34,8 @@ public class CostCenterTaskImpl extends AbstractTask {
@Override
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
String oaUrl = System.getProperty("OaUrl");//:10.157.226.9:8088
//构造请求体
QueryDTO queryDTO = new QueryDTO();
queryDTO.setPagesize(PAGESIZE);
@ -56,7 +58,7 @@ public class CostCenterTaskImpl extends AbstractTask {
//创建人员对应成本中心集合
HashMap<String, String> orgMap = new HashMap<>();
JSONObject data = this.getOAUserData(query);
JSONObject data = this.getOAUserData(query,oaUrl);
this.importOrgMap(orgMap,data);//填充人员数据人员编码成本中心编码
BigDecimal totalSize = data.getBigDecimal("totalSize");//获取查询到人员总数
BigDecimal size = new BigDecimal(PAGESIZE);//设置页大小为20
@ -68,7 +70,7 @@ public class CostCenterTaskImpl extends AbstractTask {
//修改CURPAGE当前页数
CURPAGE = i + 1;
queryDTO.setCurpage(CURPAGE);
JSONObject dataNext = this.getOAUserData(query);//获取查询的数据
JSONObject dataNext = this.getOAUserData(query,oaUrl);//获取查询的数据
this.importOrgMap(orgMap,dataNext);//填充人员数据人员编码成本中心编码
}
}
@ -106,10 +108,10 @@ public class CostCenterTaskImpl extends AbstractTask {
}
private JSONObject getOAUserData(Query query) {
private JSONObject getOAUserData(Query query,String oaUrl) {
String requestBody = JSON.toJSONString(query);
//返回参数
String json = HttpRequest.post("http://" + "10.157.226.9:8088" + "/api/hrm/resful/getHrmUserInfoWithPage").body(requestBody).execute().body();
String json = HttpRequest.post("http://" + oaUrl + "/api/hrm/resful/getHrmUserInfoWithPage").body(requestBody).execute().body();
JSONObject resultJson = JSONObject.parseObject(json);;//查询oa接口返回人员数据
String code = resultJson.getString("code");//第一次执行查询判断接口调用是否成功否则不执行后续逻辑
if (!Objects.equals("1",code)){//当code不为1时调用失败

View File

@ -49,9 +49,7 @@ public class HrmDepartmentTaskImpl extends AbstractTask implements Plugin {
@Override
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
String oaUrl = "10.157.226.9:8088";//暂时指定接口地址
// String oaUrl = System.getProperty("OaUrl");//:10.157.226.9:8088
String oaUrl = System.getProperty("OaUrl");//:10.157.226.9:8088
//初始化入参
Object isFull = map.get("isfull");//判断是否全量
//构造请求体

View File

@ -49,7 +49,7 @@ public class UserTaskImpl extends AbstractTask {
@Override
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
String oaUrl = System.getProperty("OaUrl");//:10.157.226.9:8088
//bos_base_user_syn_weaver2kd
//构造请求体
QueryDTO queryDTO = new QueryDTO();
@ -69,7 +69,7 @@ public class UserTaskImpl extends AbstractTask {
queryDTO.setCreated(time.toString());
}
JSONObject data = this.getOAUserData(query);
JSONObject data = this.getOAUserData(query,oaUrl);
if(data != null) {
//查询当前星瀚人员id集合
DynamicObjectCollection queryUsers = QueryServiceHelper.query("bos_user",
@ -101,7 +101,7 @@ public class UserTaskImpl extends AbstractTask {
//修改CURPAGE当前页数
CURPAGE = i + 1;
queryDTO.setCurpage(CURPAGE);
JSONObject dataNext = this.getOAUserData(query);//获取查询的数据
JSONObject dataNext = this.getOAUserData(query,oaUrl);//获取查询的数据
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds,orgIds);
}
}
@ -130,7 +130,7 @@ public class UserTaskImpl extends AbstractTask {
for (int i = 1; i < pageNumber.intValue(); i++){//查询成功取第一轮数据同步
CURPAGE = i ;
queryDTO.setCurpage(CURPAGE);
JSONObject dataNext = this.getOAUserData(query);//获取查询的数据
JSONObject dataNext = this.getOAUserData(query,oaUrl);//获取查询的数据
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds,orgIds);
}
UserServiceHelper.addOrUpdate(paramList);//新增或更新全量数据
@ -147,10 +147,10 @@ public class UserTaskImpl extends AbstractTask {
}
private JSONObject getOAUserData(Query query){
private JSONObject getOAUserData(Query query,String oaUrl){
String requestBody = JSON.toJSONString(query);
//返回参数
String json = HttpRequest.post("http://" + "10.157.226.9:8088" + "/api/hrm/resful/getHrmUserInfoWithPage").body(requestBody).execute().body();
String json = HttpRequest.post("http://" + oaUrl + "/api/hrm/resful/getHrmUserInfoWithPage").body(requestBody).execute().body();
JSONObject resultJson = JSONObject.parseObject(json);;//查询oa接口返回人员数据
String code = resultJson.getString("code");//第一次执行查询判断接口调用是否成功否则不执行后续逻辑
if (!Objects.equals("1",code)){//当code不为1时调用失败