人员同步接口新增同步劳动主体
This commit is contained in:
parent
b1a5103114
commit
b37cbebe5d
|
@ -40,6 +40,8 @@ public class UserTaskImpl extends AbstractTask {
|
|||
private static Logger logger = LoggerFactory.getLogger(HrmDepartmentTaskImpl.class);
|
||||
private static final int PAGESIZE = 20;
|
||||
private int CURPAGE = 1;
|
||||
|
||||
private String base_custom_data = "field0,field1";
|
||||
private DynamicObjectCollection queryOrges;
|
||||
|
||||
static boolean flag = false; //判断当前用户集合是否存在需要设置的用户还没存入系统的情况
|
||||
|
@ -53,6 +55,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
QueryDTO queryDTO = new QueryDTO();
|
||||
queryDTO.setPagesize(PAGESIZE);
|
||||
queryDTO.setCurpage(CURPAGE);
|
||||
queryDTO.setBase_custom_data(base_custom_data);
|
||||
Query query = new Query();
|
||||
query.setQueryDTO(queryDTO);
|
||||
|
||||
|
@ -70,10 +73,17 @@ public class UserTaskImpl extends AbstractTask {
|
|||
if(data != null) {
|
||||
//查询当前星瀚人员id集合
|
||||
DynamicObjectCollection queryUsers = QueryServiceHelper.query("bos_user",
|
||||
"id,number,shkd_oaid", null);//查询星瀚系统部门集合
|
||||
"id,number,shkd_oaid", null);//查询星瀚系统人员集合
|
||||
Map<Object, Long> userIds = new HashMap<Object, Long>();//存放系统中已经存在的用户id集合
|
||||
for (DynamicObject queryUser : queryUsers) {
|
||||
userIds.put(queryUser.getString("number"), queryUser.getLong("id"));//存放已经存在的人员的id以及number
|
||||
userIds.put(queryUser.getString("shkd_oaid"), queryUser.getLong("id"));//存放已经存在的人员的id以及number
|
||||
}
|
||||
|
||||
DynamicObjectCollection queryOrges = QueryServiceHelper.query("bos_adminorg",
|
||||
"id,number", null);//查询星瀚部门集合
|
||||
Map<Object, Long> orgIds = new HashMap<Object, Long>();//存放系统中已经存在的行政组织id集合
|
||||
for (DynamicObject queryOrge : queryOrges) {
|
||||
orgIds.put(queryOrge.getString("number"), queryOrge.getLong("id"));//存放已经存在的部门的id以及number
|
||||
}
|
||||
|
||||
List<UserParam> paramList = new ArrayList<>();//创建存放人员类的集合
|
||||
|
@ -83,7 +93,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
BigDecimal size = new BigDecimal(PAGESIZE);//设置页大小为20
|
||||
BigDecimal pageNumber = totalSize.divide(size, 0, RoundingMode.UP);//计算需要分页数量
|
||||
//查询成功取第一轮数据添加入参数集合
|
||||
this.buildUserParam(paramList, dataList, userIds);
|
||||
this.buildUserParam(paramList, dataList, userIds,orgIds);
|
||||
|
||||
//判断分页数量是否大于1,是则进行遍历后续数据
|
||||
if (pageNumber.compareTo(new BigDecimal(1)) > 0) {//当页数为1时,不需要再次查询接口直接去同步数据
|
||||
|
@ -92,7 +102,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
CURPAGE = i + 1;
|
||||
queryDTO.setCurpage(CURPAGE);
|
||||
JSONObject dataNext = this.getOAUserData(query);//获取查询的数据
|
||||
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds);
|
||||
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds,orgIds);
|
||||
}
|
||||
}
|
||||
UserServiceHelper.addOrUpdate(paramList);
|
||||
|
@ -112,7 +122,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
paramList.clear();
|
||||
userIds.clear();
|
||||
queryUsers = QueryServiceHelper.query("bos_user",
|
||||
"id,number,shkd_oaid", null);//查询星瀚系统部门集合
|
||||
"id,number,shkd_oaid", null);//查询星瀚系统人员集合
|
||||
userIds = new HashMap<Object, Long>();//存放系统中已经存在的用户id集合
|
||||
for (DynamicObject queryUser : queryUsers) {
|
||||
userIds.put(queryUser.getString("shkd_oaid"), queryUser.getLong("id"));//存放已经存在的人员的id以及number
|
||||
|
@ -121,7 +131,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
CURPAGE = i ;
|
||||
queryDTO.setCurpage(CURPAGE);
|
||||
JSONObject dataNext = this.getOAUserData(query);//获取查询的数据
|
||||
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds);
|
||||
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds,orgIds);
|
||||
}
|
||||
UserServiceHelper.addOrUpdate(paramList);//新增或更新全量数据
|
||||
for (UserParam userParam : paramList) {
|
||||
|
@ -151,11 +161,11 @@ public class UserTaskImpl extends AbstractTask {
|
|||
return data ;
|
||||
}
|
||||
|
||||
private void buildUserParam(List<UserParam> paramList,JSONArray dataList,Map<Object,Long> userIds) {
|
||||
private void buildUserParam(List<UserParam> paramList,JSONArray dataList,Map<Object,Long> userIds,Map<Object, Long> orgIds) {
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
UserParam user = new UserParam();
|
||||
JSONObject userData = dataList.getJSONObject(i);
|
||||
Long workid = userIds.get(userData.getString("workcode"));
|
||||
Long workid = userIds.get(userData.getString("id"));
|
||||
if (workid != null){
|
||||
user.setId(workid);
|
||||
user.setCustomUserId(workid);
|
||||
|
@ -170,6 +180,12 @@ public class UserTaskImpl extends AbstractTask {
|
|||
dataMap.put("birthday", userData.getDate("birthday"));//生日
|
||||
dataMap.put("gender", "男" .equals(userData.getString("sex")) ? "1" : "2"); //性别
|
||||
dataMap.put("shkd_oaid",userData.getString("id"));
|
||||
JSONObject base_custom_data = userData.getJSONObject("base_custom_data");
|
||||
String field1= base_custom_data.getString("field1");
|
||||
if (!"".equals(field1)){
|
||||
dataMap.put("shkd_labororg",orgIds.get(field1));
|
||||
}
|
||||
|
||||
|
||||
// 职位分
|
||||
if(workid == null){//若人不存在则更新部门
|
||||
|
@ -184,7 +200,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
entryentity.put("position", userData.getString("jobactivityname")); // 职位
|
||||
entryentity.put("isincharge", false); //负责人
|
||||
entryentity.put("ispartjob", false); //兼职
|
||||
String managerId_oa = userData.getString("managerid");//获取上级人员id(oa)
|
||||
String managerId_oa = userData.getString("managerid");//获取上级人员id(oa)
|
||||
Long managerId = userIds.get(managerId_oa);//直接上级id
|
||||
if (managerId != null){
|
||||
entryentity.put("superior", managerId); // 赋值直接上级
|
||||
|
|
Loading…
Reference in New Issue