岗位自动任务

This commit is contained in:
“wyx12345678” 2024-05-11 14:46:15 +08:00
parent 373519684d
commit b9ce6f6dfd
1 changed files with 13 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption; import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.exception.KDException; import kd.bos.exception.KDException;
import kd.bos.org.model.OrgParam; import kd.bos.org.model.OrgParam;
import kd.bos.orm.ORM; import kd.bos.orm.ORM;
@ -51,7 +52,7 @@ public class JobtitleTaskImpl extends AbstractTask {
Query query = new Query(); Query query = new Query();
query.setQueryDTO(queryDTO); query.setQueryDTO(queryDTO);
String requestBody = JSON.toJSONString(query); String requestBody = JSON.toJSONString(query);
String jsonResponse = HttpRequest.post("http://" + "10.157.226.9:8088" + "/api/hrm/resful/getHrmUserInfoWithPage") String jsonResponse = HttpRequest.post("http://" + "10.157.226.9:8088" + "/api/hrm/resful/getJobtitleInfoWithPage")
.body(requestBody) .body(requestBody)
.execute().body(); .execute().body();
@ -78,6 +79,8 @@ public class JobtitleTaskImpl extends AbstractTask {
// 遍历解析结果 // 遍历解析结果
for (int i = 0; i < dataList.size(); i++) { for (int i = 0; i < dataList.size(); i++) {
//根据ID看是否查询到已有的数据对已有数据进行ID,
OperateOption option = OperateOption.create(); OperateOption option = OperateOption.create();
JSONObject item = dataList.getJSONObject(i); JSONObject item = dataList.getJSONObject(i);
String jobTitleName = item.getString("jobtitlename"); String jobTitleName = item.getString("jobtitlename");
@ -85,17 +88,22 @@ public class JobtitleTaskImpl extends AbstractTask {
String modified = item.getString("modified"); String modified = item.getString("modified");
String id = item.getString("id"); String id = item.getString("id");
String jobTitleMark = item.getString("jobtitlemark"); String jobTitleMark = item.getString("jobtitlemark");
String number = "0" + id; QFilter filter = new QFilter("shkd_oaid", "=", "aurogp");
DynamicObject bos_position = BusinessDataServiceHelper.loadSingle("bos_position", new QFilter[]{filter});
ORM orm = ORM.create(); ORM orm = ORM.create();
DynamicObject job = orm.newDynamicObject("bos_position"); DynamicObject job = orm.newDynamicObject("bos_position");
if(bos_position!=null){
job =bos_position;
}
job.set("name", jobTitleName); job.set("name", jobTitleName);
job.set("dpt", bosAdminorg); job.set("dpt", bosAdminorg);
job.set("remarks", jobTitleMark); job.set("remarks", jobTitleMark);
job.set("enable", 1); job.set("enable", 1);
job.set("shkd_oaid",id);
OperationServiceHelper.executeOperate("save", "bos_position", new DynamicObject[]{job}, option); // job.set("");
OperationResult operationResult = OperationServiceHelper.executeOperate("save", "bos_position", new DynamicObject[]{job}, option);
System.out.println();
} }
} catch (Exception e) { } catch (Exception e) {
// 处理异常 // 处理异常