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

This commit is contained in:
zengweihai 2024-06-04 15:28:45 +08:00
parent 29115f3041
commit bff7f48d66
3 changed files with 8 additions and 36 deletions

View File

@ -111,7 +111,7 @@ public class CostCenterTaskImpl extends AbstractTask {
private JSONObject getOAUserData(Query query,String oaUrl) {
String requestBody = JSON.toJSONString(query);
//返回参数
String json = HttpRequest.post("http://" + oaUrl + "/api/hrm/resful/getHrmUserInfoWithPage").body(requestBody).execute().body();
String json = HttpRequest.post( 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时调用失败
@ -127,10 +127,10 @@ public class CostCenterTaskImpl extends AbstractTask {
for (int i = 0; i < dataList.size(); i++) {
JSONObject userData = dataList.getJSONObject(i);
JSONObject base_custom_data = userData.getJSONObject("base_custom_data");
if (base_custom_data != null){
if (base_custom_data != null){
String field0 = base_custom_data.getString("field0");
if (!"".equals(field0)){
orgMap.put(userData.getString("workcode"),field0);
if (!"".equals(field0)){
orgMap.put(userData.getString("workcode"),field0);
}
}
}

View File

@ -137,9 +137,8 @@ public class HrmDepartmentTaskImpl extends AbstractTask implements Plugin {
*/
private JSONObject getOADepartment(Query query,String oaUrl){
String requestBody = JSON.toJSONString(query);
oaUrl = "http://"+oaUrl+"/api/hrm/resful/getHrmdepartmentWithPage";
//返回参数
String json = HttpRequest.post(oaUrl).body(requestBody).execute().body();
String json = HttpRequest.post(oaUrl+"/api/hrm/resful/getHrmdepartmentWithPage").body(requestBody).execute().body();
JSONObject jsonObject = JSONObject.parseObject(json);//查询oa接口返回数据
String code = jsonObject.getString("code");//第一次执行查询判断接口调用是否成功否则不执行后续逻辑
if (!Objects.equals("1",code)){//当code不为1时调用失败
@ -219,31 +218,4 @@ public class HrmDepartmentTaskImpl extends AbstractTask implements Plugin {
}
return orgParam;
}
// //数据服务接口修改数据
// OperateOption option = OperateOption.create();
// JSONObject item = dataList.getJSONObject(i);
// String id = item.getString("id");//oa部门id
// String departmentCode = item.getString("departmentcode");//部门编码
// String departmentName = item.getString("departmentname");// 全称
// String departmentMark = item.getString("departmentmark");// 简称
// String canceled = item.getString("canceled");// 封存标志1 封存其他为未封存 对应星瀚使用状态
// String supDepId = item.getString("supdepid");// 上级部门oaid
// Date created = item.getDate("created");// 创建时间戳
// Date modified = item.getDate("modified");// 修改时间戳
// //String subCompanyId1 = item.getString("subcompanyid1");// 分部id
// //String showOrder = item.getString("showorder");//排序
//
// QFilter qFilter = new QFilter("number", QCP.equals,departmentCode);
// DynamicObject bos_adminorg = BusinessDataServiceHelper.loadSingle("bos_adminorg", qFilter.toArray());
// if (bos_adminorg != null){//查找到晨曦公司修改其数据
// bos_adminorg.set("shkd_oaid",id);
// bos_adminorg.set("number",departmentCode);
// bos_adminorg.set("name",departmentName);
// bos_adminorg.set("simplename",departmentMark);
// bos_adminorg.set("enable",canceled.equals("1") ? "0":"1");
// bos_adminorg.set("createtime",created);
// bos_adminorg.set("modifytime",modified);
// OperationServiceHelper.executeOperate("save", "bos_adminorg", new DynamicObject[]{bos_adminorg}, option);
// }
}

View File

@ -81,9 +81,9 @@ public class UserTaskImpl extends AbstractTask {
DynamicObjectCollection queryOrges = QueryServiceHelper.query("bos_adminorg",
"id,number", null);//查询星瀚部门集合
Map<Object, Long> orgIds = new HashMap<Object, Long>();//存放系统中已经存在的行政组织id集合
Map<Object, Long> orgIds = new HashMap<Object, Long>();//存放系统中已经存在的行政组织id集合
for (DynamicObject queryOrge : queryOrges) {
orgIds.put(queryOrge.getString("number"), queryOrge.getLong("id"));//存放已经存在的部门的id以及number
orgIds.put(queryOrge.getString("number"), queryOrge.getLong("id"));//存放已经存在的部门的id以及number
}
List<UserParam> paramList = new ArrayList<>();//创建存放人员类的集合
@ -150,7 +150,7 @@ public class UserTaskImpl extends AbstractTask {
private JSONObject getOAUserData(Query query,String oaUrl){
String requestBody = JSON.toJSONString(query);
//返回参数
String json = HttpRequest.post("http://" + oaUrl + "/api/hrm/resful/getHrmUserInfoWithPage").body(requestBody).execute().body();
String json = HttpRequest.post( 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时调用失败