diff --git a/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/task/UserTaskImpl.java b/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/task/UserTaskImpl.java index 9da365c..1d84c99 100644 --- a/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/task/UserTaskImpl.java +++ b/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/task/UserTaskImpl.java @@ -7,6 +7,8 @@ import com.alibaba.fastjson.JSONObject; import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType; +import kd.bos.entity.EntityMetadataCache; import kd.bos.exception.KDException; import kd.bos.org.model.OrgParam; import kd.bos.permission.model.UserParam; @@ -65,7 +67,7 @@ public class UserTaskImpl extends AbstractTask { } JSONObject data = this.getOAUserData(query); - if(data != null){ + if(data != null) { //查询当前星瀚人员id集合 DynamicObjectCollection queryUsers = QueryServiceHelper.query("bos_user", "id,number,shkd_oaid", null);//查询星瀚系统部门集合 @@ -75,13 +77,14 @@ public class UserTaskImpl extends AbstractTask { } List paramList = new ArrayList<>();//创建存放人员类的集合 - JSONArray dataList = data.getJSONArray("dataList");//oa人员数据集合 + JSONArray dataList = data.getJSONArray("dataList");//oa人员数据集合 BigDecimal totalSize = data.getBigDecimal("totalSize");//获取查询到人员总数; BigDecimal size = new BigDecimal(PAGESIZE);//设置页大小为20 - BigDecimal pageNumber = totalSize.divide(size, 0, RoundingMode.UP);//计算需要分页数量 + BigDecimal pageNumber = totalSize.divide(size, 0, RoundingMode.UP);//计算需要分页数量 //查询成功取第一轮数据添加入参数集合 - this.buildUserParam(paramList,dataList,userIds); + this.buildUserParam(paramList, dataList, userIds); + //判断分页数量是否大于1,是则进行遍历后续数据 if (pageNumber.compareTo(new BigDecimal(1)) > 0) {//当页数为1时,不需要再次查询接口直接去同步数据 for (int i = 1; i < pageNumber.intValue(); i++){//查询成功取第一轮数据同步 @@ -105,7 +108,6 @@ public class UserTaskImpl extends AbstractTask { System.out.println(str); } } - if(flag){//重新生成构造集合 paramList.clear(); userIds.clear(); @@ -132,6 +134,7 @@ public class UserTaskImpl extends AbstractTask { } } } + } private JSONObject getOAUserData(Query query){ @@ -152,13 +155,12 @@ public class UserTaskImpl extends AbstractTask { for (int i = 0; i < dataList.size(); i++) { UserParam user = new UserParam(); JSONObject userData = dataList.getJSONObject(i); - Long workid = userIds.get(userData.getString("id")); + Long workid = userIds.get(userData.getString("workcode")); if (workid != null){ user.setId(workid); user.setCustomUserId(workid); } Map dataMap = new HashMap<>(); - dataMap.put("number", userData.getString("workcode")); //工号 dataMap.put("name", userData.getString("lastname")); // 姓名 dataMap.put("username", userData.getString("loginid")); //用户名 dataMap.put("usertype", "1");//类型 @@ -169,7 +171,7 @@ public class UserTaskImpl extends AbstractTask { dataMap.put("gender", "男" .equals(userData.getString("sex")) ? "1" : "2"); //性别 dataMap.put("shkd_oaid",userData.getString("id")); - // 职位分录 + // 职位分 if(workid == null){//若人不存在则更新部门 }