cczhang 2 meses atrás
pai
commit
77f8607882

+ 33
- 0
src/main/java/com/horizon/custom/CreatorPositionDeptIntersectionResolver.java Ver arquivo

@@ -0,0 +1,33 @@
1
+package com.horizon.custom;
2
+
3
+import com.horizon.wf.core.rule.BaseRuleImpl;
4
+import com.horizon.wf.core.rule.IBaseRule;
5
+import com.horizon.wf.definition.pub.IFlowNode;
6
+import com.horizon.wf.global.StaticVarExtend;
7
+
8
+/**
9
+ * 根据组织机构里的群组或者岗位,与流程创建者做交集
10
+ * com.horizon.custom.CreatorPositionDeptIntersectionResolver
11
+ */
12
+public class CreatorPositionDeptIntersectionResolver extends BaseRuleImpl implements IBaseRule {
13
+    @Override
14
+    public boolean executeRule() {
15
+        // 3. 获取办理人的节点定义对象
16
+        IFlowNode flowNode = (IFlowNode) getParameter(StaticVarExtend.Parameter_CustomeUser_IFlowNode);
17
+        // 获取主办中设置的id
18
+        String groups[] = flowNode.getParticipantsUserList().get(1).getGroup().split(";");
19
+        String positions[] = flowNode.getParticipantsUserList().get(1).getPosition().split(";");
20
+        // 5. 获取的办理人返回
21
+        String userId = "";
22
+        // 获取流程创建人id
23
+        String creator = getRunningdata().getWork().getCreator();
24
+        // 获取群组与用户所属部门交集
25
+        userId += GroupOrPositionUtil.getUserBySameDeptAndOrgResolver(groups, creator) + ";";
26
+        // 获取岗位与用户所属部门交集
27
+        userId += GroupOrPositionUtil.getUserBySameDeptAndOrgResolver(positions, creator) + ";";
28
+        setResult(userId);
29
+        return true;
30
+    }
31
+
32
+
33
+}

+ 0
- 41
src/main/java/com/horizon/custom/GroupCreator.java Ver arquivo

@@ -1,41 +0,0 @@
1
-package com.horizon.custom;
2
-
3
-import com.horizon.common.collect.Lists;
4
-import com.horizon.db.Access;
5
-import com.horizon.wf.core.rule.BaseRuleImpl;
6
-import com.horizon.wf.core.rule.IBaseRule;
7
-
8
-import java.util.List;
9
-import java.util.Map;
10
-
11
-/**
12
- * 根据组织机构里的群组或者岗位,与流程创建者做交集
13
- * com.horizon.custom.GroupOrPositionCreator
14
- */
15
-public class GroupCreator extends BaseRuleImpl implements IBaseRule {
16
-    @Override
17
-    public boolean executeRule() {
18
-        String userId = "";
19
-        // 获取流程创建人id
20
-        String creator = getRunningdata().getWork().getCreator();
21
-
22
-        String dbIdentifier = "shindi";
23
-
24
-        // 获取组长ID
25
-        String queryGroupIdSql =
26
-                "SELECT z.EMP_NO AS GROUP_ID " +
27
-                "FROM SHINDI.T_COST_BANK_ACCOUNT z " +
28
-                "WHERE z.SUB_PARK = (SELECT Z.SUB_PARK FROM SHINDI.T_COST_BANK_ACCOUNT Z WHERE Z.EMP_NO = ?)" +
29
-                "AND z.IS_EXAM = '0'";
30
-
31
-        List<String> list = Lists.newArrayList();
32
-        // 参数传递
33
-        list.add(creator);
34
-        Map resmap = Access.getSingleMap(queryGroupIdSql, list, dbIdentifier);
35
-        userId = (String) resmap.get("group_id");
36
-
37
-        setResult(userId);
38
-        return true;
39
-    }
40
-
41
-}

+ 133
- 0
src/main/java/com/horizon/custom/GroupOrPositionByDeptVarsLimit6.java Ver arquivo

@@ -0,0 +1,133 @@
1
+package com.horizon.custom;
2
+
3
+import com.horizon.core.HorizonCore;
4
+import com.horizon.third.adapter.OrganizationAdapter;
5
+import com.horizon.third.build.OrgDataBuilderHolder;
6
+import com.horizon.third.entity.OrgData;
7
+import com.horizon.third.entity.User;
8
+import com.horizon.utils.StringUtil;
9
+import com.horizon.wf.core.rule.BaseRuleImpl;
10
+import com.horizon.wf.core.rule.IBaseRule;
11
+import com.horizon.wf.core.runtime.RunningData;
12
+import com.horizon.wf.definition.pub.IFlowNode;
13
+import com.horizon.wf.global.StaticVarExtend;
14
+
15
+import java.util.*;
16
+
17
+/**
18
+ * 根据组织机构里的群组或者岗位,与流程创建者做交集
19
+ * com.horizon.custom.GroupOrPositionCreator
20
+ */
21
+public class GroupOrPositionByDeptVarsLimit6 extends BaseRuleImpl implements IBaseRule {
22
+    @Override
23
+    public boolean executeRule() {
24
+        RunningData runningdata = getRunningdata();
25
+        Map<String, String> flowVar = runningdata.getFlowVar().getAllFlowVarMap();
26
+
27
+        // 3. 获取办理人的节点定义对象
28
+        IFlowNode flowNode = (IFlowNode) getParameter(StaticVarExtend.Parameter_CustomeUser_IFlowNode);
29
+        // 获取主办中设置的id
30
+        String groups[] = flowNode.getParticipantsUserList().get(1).getGroup().split(";");
31
+        String positions[] = flowNode.getParticipantsUserList().get(1).getPosition().split(";");
32
+//        String depts[] = flowNode.getParticipantsUserList().get(1).getDept().split(";");
33
+//
34
+//        // 获取业务传入的参数变量
35
+//        String customDept = flowVar.get("customDept");
36
+//        if(StringUtil.hasValue(customDept)){
37
+//            depts = customDept.split(";");
38
+//        }
39
+
40
+        String[] originalDepts = flowNode.getParticipantsUserList().get(1).getDept().split(";");
41
+        Set<String> deptSet = new LinkedHashSet<>(Arrays.asList(originalDepts)); // 保持顺序并去重
42
+
43
+        String customDept = flowVar.get("customDept");
44
+        if (StringUtil.hasValue(customDept)) {
45
+            deptSet.addAll(Arrays.asList(customDept.split(";")));
46
+        }
47
+
48
+        String[] depts = deptSet.toArray(new String[0]);
49
+
50
+        // 获取岗位与部门交集+传入部门的交集
51
+
52
+        // 获取岗位与用户所属部门交集
53
+
54
+        String userId = "";
55
+
56
+        if(depts.length > 0){
57
+
58
+            userId += this.getUserBySameDeptAndOrg(positions, depts) + ";";
59
+        }
60
+
61
+        setResult(userId);
62
+        return true;
63
+    }
64
+
65
+    public String getUserBySameDeptAndOrg(String orgIds[], String[] depts) {
66
+        OrganizationAdapter organization = new OrganizationAdapter();
67
+        // 最终办理人用户id
68
+        StringBuilder userIds = new StringBuilder();
69
+        // 获取群组下的所有用户信息
70
+        if (orgIds.length < 1) return "";
71
+        for (String orgId : orgIds) {
72
+            String orgUserIds = "";
73
+            // 获取群组下的所有用户id
74
+            if (orgId.contains("G_")) {
75
+                orgUserIds = organization.getAllUserFromGroup(orgId.replace("G_", ""), HorizonCore.TENANT_IDENTIFIER.value());
76
+            } else if (orgId.contains("P_")) {
77
+                orgUserIds = organization.getAllUserFromPosition(orgId.replace("P_", ""), HorizonCore.TENANT_IDENTIFIER.value());
78
+            }
79
+            if (!StringUtil.hasValue(orgUserIds)) return "";
80
+
81
+            List<User> userList = new ArrayList<>();
82
+            for (String userId : orgUserIds.split(";")) {
83
+                User user = OrgDataBuilderHolder.getBuilder().getUserById(userId);
84
+                userList.add(user);
85
+            }
86
+
87
+            // 根据多个用户id,获取用户信息
88
+//            List<Map<String, String>> userByIDs = organization.getUserByIDs(orgUserIds.split(";"), HorizonCore.TENANT_IDENTIFIER.value());
89
+
90
+            // 对比用户所属部门,如果相同,则添加到userIds中
91
+            for (User user : userList) {
92
+                List<String> deptList = user.getDepartment();
93
+                for (int i = 0; i < deptList.size(); i++) {
94
+                    if (!deptList.get(i).startsWith("D_")) {
95
+                        deptList.set(i, "D_" + deptList.get(i));
96
+                    }
97
+                }
98
+
99
+                boolean hasIntersection = judgeDeptJoinLimit6(deptList, Arrays.asList(depts));
100
+                if (hasIntersection) {
101
+                    userIds.append(user.getId()).append("/").append(orgId).append(";");
102
+                }
103
+            }
104
+        }
105
+        return userIds.toString();
106
+    }
107
+
108
+    public boolean judgeDeptJoinLimit6(List<String> deptIdList1, List<String> deptIdList2) {
109
+        List<String> deptIdListLimit6_1 = new ArrayList<>();
110
+        List<String> deptIdListLimit6_2 = new ArrayList<>();
111
+
112
+        for(String deptId : deptIdList1){
113
+            if(deptId.startsWith("D_")){
114
+                OrgData orgData = OrgDataBuilderHolder.getBuilder().getOrgDataById("D", deptId.substring(2));
115
+                if(orgData != null && orgData.getCode().length() > 6){
116
+                    deptIdListLimit6_1.add(orgData.getCode().substring(0, 7));
117
+                }
118
+            }
119
+        }
120
+
121
+        for(String deptId : deptIdList2){
122
+            if(deptId.startsWith("D_")){
123
+                OrgData orgData = OrgDataBuilderHolder.getBuilder().getOrgDataById("D", deptId.substring(2));
124
+                if(orgData != null && orgData.getCode().length() > 6){
125
+                    deptIdListLimit6_2.add(orgData.getCode().substring(0, 7));
126
+                }
127
+            }
128
+        }
129
+
130
+        return !Collections.disjoint(deptIdListLimit6_1, deptIdListLimit6_2);
131
+    }
132
+
133
+}

+ 27
- 8
src/main/java/com/horizon/custom/GroupOrPositionByVars.java Ver arquivo

@@ -2,6 +2,8 @@ package com.horizon.custom;
2 2
 
3 3
 import com.horizon.core.HorizonCore;
4 4
 import com.horizon.third.adapter.OrganizationAdapter;
5
+import com.horizon.third.build.OrgDataBuilderHolder;
6
+import com.horizon.third.entity.User;
5 7
 import com.horizon.utils.StringUtil;
6 8
 import com.horizon.wf.core.rule.BaseRuleImpl;
7 9
 import com.horizon.wf.core.rule.IBaseRule;
@@ -50,7 +52,7 @@ public class GroupOrPositionByVars extends BaseRuleImpl implements IBaseRule {
50 52
 
51 53
         String userId = "";
52 54
 
53
-        if(depts.length > 0){
55
+        if (depts.length > 0) {
54 56
             userId += this.getUserBySameDeptAndOrg(positions, depts) + ";";
55 57
         }
56 58
 
@@ -61,7 +63,7 @@ public class GroupOrPositionByVars extends BaseRuleImpl implements IBaseRule {
61 63
     public String getUserBySameDeptAndOrg(String orgIds[], String[] depts) {
62 64
         OrganizationAdapter organization = new OrganizationAdapter();
63 65
         // 最终办理人用户id
64
-        String userIds = "";
66
+        StringBuilder userIds = new StringBuilder();
65 67
         // 获取群组下的所有用户信息
66 68
         if (orgIds.length < 1) return "";
67 69
         for (String orgId : orgIds) {
@@ -73,18 +75,35 @@ public class GroupOrPositionByVars extends BaseRuleImpl implements IBaseRule {
73 75
                 orgUserIds = organization.getAllUserFromPosition(orgId.replace("P_", ""), HorizonCore.TENANT_IDENTIFIER.value());
74 76
             }
75 77
             if (!StringUtil.hasValue(orgUserIds)) return "";
78
+
79
+            List<User> userList = new ArrayList<>();
80
+            for (String userId : orgUserIds.split(";")) {
81
+                User user = OrgDataBuilderHolder.getBuilder().getUserById(userId);
82
+                userList.add(user);
83
+            }
84
+
76 85
             // 根据多个用户id,获取用户信息
77
-            List<Map<String, String>> userByIDs = organization.getUserByIDs(orgUserIds.split(";"), HorizonCore.TENANT_IDENTIFIER.value());
86
+//            List<Map<String, String>> userByIDs = organization.getUserByIDs(orgUserIds.split(";"), HorizonCore.TENANT_IDENTIFIER.value());
78 87
 
79 88
             // 对比用户所属部门,如果相同,则添加到userIds中
80
-            for (Map<String, String> user : userByIDs) {
81
-                String deptId = "D_" + user.get("dept_id");
82
-                if (Arrays.asList(depts).contains(deptId)) {
83
-                    userIds += user.get("id") + "/" + orgId + ";";
89
+            for (User user : userList) {
90
+                List<String> deptList = user.getDepartment();
91
+                if (deptList == null) {
92
+                    continue;
93
+                }
94
+                for (int i = 0; i < deptList.size(); i++) {
95
+                    if (!deptList.get(i).startsWith("D_")) {
96
+                        deptList.set(i, "D_" + deptList.get(i));
97
+                    }
98
+                }
99
+
100
+                boolean hasIntersection = !Collections.disjoint(deptList, Arrays.asList(depts));
101
+                if (hasIntersection) {
102
+                    userIds.append(user.getId()).append("/").append(orgId).append(";");
84 103
                 }
85 104
             }
86 105
         }
87
-        return userIds;
106
+        return userIds.toString();
88 107
     }
89 108
 
90 109
 

+ 173
- 18
src/main/java/com/horizon/custom/GroupOrPositionUtil.java Ver arquivo

@@ -4,10 +4,15 @@ import com.horizon.common.collect.Lists;
4 4
 import com.horizon.core.HorizonCore;
5 5
 import com.horizon.db.Access;
6 6
 import com.horizon.third.adapter.OrganizationAdapter;
7
+import com.horizon.third.build.OrgDataBuilderHolder;
8
+import com.horizon.third.entity.OrgData;
9
+import com.horizon.third.entity.User;
7 10
 import com.horizon.utils.StringUtil;
8 11
 import org.slf4j.Logger;
9 12
 import org.slf4j.LoggerFactory;
10 13
 
14
+import java.util.ArrayList;
15
+import java.util.Collections;
11 16
 import java.util.List;
12 17
 import java.util.Map;
13 18
 
@@ -44,13 +49,15 @@ public class GroupOrPositionUtil {
44 49
             List<Map<String, String>> userByIDs = organization.getUserByIDs(orgUserIds.split(";"), HorizonCore.TENANT_IDENTIFIER.value());
45 50
             // 根据userid获取用户信息
46 51
             Map<String, String> userMap = organization.getUserById(userId, HorizonCore.TENANT_IDENTIFIER.value());
52
+            System.err.println("用户:" + userId);
47 53
             String deptId = userMap.get("dept_id");
48
-            String fDeptId =  GroupOrPositionUtil.queryFDept(deptId);
49
-            LOGGER.info("deptId:{}_fDeptId:{}", deptId, fDeptId);
54
+            System.err.println("用户部门:" + deptId);
55
+
56
+            String fDeptId = GroupOrPositionUtil.queryFDept(deptId);
57
+
50 58
             // 对比用户所属部门,如果相同,则添加到userIds中
51 59
             for (Map<String, String> user : userByIDs) {
52
-                String fDeptIdTmp =  GroupOrPositionUtil.queryFDept(user.get("dept_id"));
53
-                LOGGER.info("deptId:{}_fDeptIdTmp:{}_fDeptIdTmp:{}", user.get("dept_id"), fDeptIdTmp, fDeptId);
60
+                String fDeptIdTmp = GroupOrPositionUtil.queryFDept(user.get("dept_id"));
54 61
                 if (fDeptIdTmp.equals(fDeptId)) {
55 62
                     userIds += user.get("id") + "/" + orgId + ";";
56 63
                     LOGGER.info("获取到{}里同步人员id:{}", orgId, user.get("id"));
@@ -60,8 +67,6 @@ public class GroupOrPositionUtil {
60 67
         return userIds;
61 68
     }
62 69
 
63
-
64
-
65 70
     /**
66 71
      * 获取userid所属部门,与设置的群组/岗位 下的人同部门的用户
67 72
      *
@@ -72,7 +77,7 @@ public class GroupOrPositionUtil {
72 77
     public static String getUserBySameDeptAndOrg(String orgIds[], String userId) {
73 78
         OrganizationAdapter organization = new OrganizationAdapter();
74 79
         // 最终办理人用户id
75
-        String userIds = "";
80
+        StringBuilder userIds = new StringBuilder();
76 81
         // 获取群组下的所有用户信息
77 82
         if (orgIds.length < 1) return "";
78 83
         for (String orgId : orgIds) {
@@ -84,20 +89,52 @@ public class GroupOrPositionUtil {
84 89
                 orgUserIds = organization.getAllUserFromPosition(orgId.replace("P_", ""), HorizonCore.TENANT_IDENTIFIER.value());
85 90
             }
86 91
             if (!StringUtil.hasValue(orgUserIds)) return "";
87
-            // 根据多个用户id,获取用户信息
88
-            List<Map<String, String>> userByIDs = organization.getUserByIDs(orgUserIds.split(";"), HorizonCore.TENANT_IDENTIFIER.value());
89
-            // 根据userid获取用户信息
90
-            Map<String, String> userMap = organization.getUserById(userId, HorizonCore.TENANT_IDENTIFIER.value());
91
-            String deptId = userMap.get("dept_id");
92
-            // 对比用户所属部门,如果相同,则添加到userIds中
93
-            for (Map<String, String> user : userByIDs) {
94
-                if (user.get("dept_id").equals(deptId)) {
95
-                    userIds += user.get("id") + "/" + orgId + ";";
96
-                    LOGGER.info("获取到{}里同步人员id:{}", orgId, user.get("id"));
92
+
93
+            List<User> userList = new ArrayList<>();
94
+            for (String userIdTmp : orgUserIds.split(";")) {
95
+                User user = OrgDataBuilderHolder.getBuilder().getUserById(userIdTmp);
96
+                userList.add(user);
97
+            }
98
+
99
+            User CurrentUser = OrgDataBuilderHolder.getBuilder().getUserById(userId);
100
+            List<String> deptIds = CurrentUser.getDepartment();
101
+
102
+            for (int i = 0; i < deptIds.size(); i++) {
103
+                if (!deptIds.get(i).startsWith("D_")) {
104
+                    deptIds.set(i, "D_" + deptIds.get(i));
97 105
                 }
98 106
             }
107
+
108
+
109
+//            // 根据多个用户id,获取用户信息
110
+//            List<Map<String, String>> userByIDs = organization.getUserByIDs(orgUserIds.split(";"), HorizonCore.TENANT_IDENTIFIER.value());
111
+//            // 根据userid获取用户信息
112
+//            Map<String, String> userMap = organization.getUserById(userId, HorizonCore.TENANT_IDENTIFIER.value());
113
+
114
+
115
+            for (User user : userList) {
116
+                List<String> deptList = user.getDepartment();
117
+
118
+                if (deptList == null) {
119
+                    continue;
120
+                }
121
+                for (int i = 0; i < deptList.size(); i++) {
122
+                    if (!deptList.get(i).startsWith("D_")) {
123
+                        deptList.set(i, "D_" + deptList.get(i));
124
+                    }
125
+                }
126
+
127
+                LOGGER.info("deptList:{},deptIds:{}", deptList.toString(), deptIds.toString());
128
+
129
+                boolean hasIntersection = !Collections.disjoint(deptList, deptIds);
130
+                if (hasIntersection) {
131
+                    userIds.append(user.getId()).append("/").append(orgId).append(";");
132
+                    LOGGER.info("获取到{}里同步人员id:{}", orgId, user.getId());
133
+                }
134
+            }
135
+
99 136
         }
100
-        return userIds;
137
+        return userIds.toString();
101 138
     }
102 139
 
103 140
     public static String queryFDept(String deptId){
@@ -126,4 +163,122 @@ public class GroupOrPositionUtil {
126 163
         }
127 164
         return fDeptId;
128 165
     }
166
+
167
+
168
+    /**
169
+     * 获取userid所属部门,与设置的群组/岗位 下的人同部门的用户
170
+     *
171
+     * @param orgIds
172
+     * @param userId
173
+     * @return
174
+     */
175
+    public static String getUserBySameDeptAndOrgResolver(String orgIds[], String userId) {
176
+        OrganizationAdapter organization = new OrganizationAdapter();
177
+        // 最终办理人用户id
178
+        StringBuilder userIds = new StringBuilder();
179
+        int lenDiff = 0;
180
+        // 获取群组下的所有用户信息
181
+        if (orgIds.length < 1) return "";
182
+//        for (String orgId : orgIds) {
183
+//            String orgUserIds = "";
184
+//            // 获取群组下的所有用户id
185
+//            if (orgId.contains("G_")) {
186
+//                orgUserIds = organization.getAllUserFromGroup(orgId.replace("G_", ""), HorizonCore.TENANT_IDENTIFIER.value());
187
+//            } else if (orgId.contains("P_")) {
188
+//                orgUserIds = organization.getAllUserFromPosition(orgId.replace("P_", ""), HorizonCore.TENANT_IDENTIFIER.value());
189
+//            }
190
+//            if (!StringUtil.hasValue(orgUserIds)) return "";
191
+//
192
+//            List<User> userList = new ArrayList<>();
193
+//            for (String userIdTmp : orgUserIds.split(";")) {
194
+//                User user = OrgDataBuilderHolder.getBuilder().getUserById(userIdTmp);
195
+//                userList.add(user);
196
+//            }
197
+//
198
+//            User CurrentUser = OrgDataBuilderHolder.getBuilder().getUserById(userId);
199
+//            List<String> deptIds = CurrentUser.getDepartment();
200
+//
201
+//            for (int i = 0; i < deptIds.size(); i++) {
202
+//                if (!deptIds.get(i).startsWith("D_")) {
203
+//                    deptIds.set(i, "D_" + deptIds.get(i));
204
+//                }
205
+//            }
206
+//
207
+//            for (User user : userList) {
208
+//                List<String> deptList = user.getDepartment();
209
+//                for (int i = 0; i < deptList.size(); i++) {
210
+//                    if (!deptList.get(i).startsWith("D_")) {
211
+//                        deptList.set(i, "D_" + deptList.get(i));
212
+//                    }
213
+//                }
214
+//
215
+//                boolean hasIntersection = !Collections.disjoint(deptList, deptIds);
216
+//                if (hasIntersection) {
217
+//                    userIds.append(user.getId()).append("/").append(orgId).append(";");
218
+//                    LOGGER.info("获取到{}里同步人员id:{}", orgId, user.getId());
219
+//                }
220
+//            }
221
+//
222
+//        }
223
+
224
+        do {
225
+            for (String orgId : orgIds) {
226
+                String orgUserIds = "";
227
+                // 获取群组下的所有用户id
228
+                if (orgId.contains("G_")) {
229
+                    orgUserIds = organization.getAllUserFromGroup(orgId.replace("G_", ""), HorizonCore.TENANT_IDENTIFIER.value());
230
+                } else if (orgId.contains("P_")) {
231
+                    orgUserIds = organization.getAllUserFromPosition(orgId.replace("P_", ""), HorizonCore.TENANT_IDENTIFIER.value());
232
+                }
233
+                if (!StringUtil.hasValue(orgUserIds)) return "";
234
+
235
+                List<User> userList = new ArrayList<>();
236
+                for (String userIdTmp : orgUserIds.split(";")) {
237
+                    User user = OrgDataBuilderHolder.getBuilder().getUserById(userIdTmp);
238
+                    userList.add(user);
239
+                }
240
+
241
+                User CurrentUser = OrgDataBuilderHolder.getBuilder().getUserById(userId);
242
+                List<String> deptIds = CurrentUser.getDepartment();
243
+
244
+                for (int i = 0; i < deptIds.size(); i++) {
245
+                    OrgData orgData = null;
246
+                    if (deptIds.get(i).startsWith("D_")) {
247
+                        orgData = OrgDataBuilderHolder.getBuilder().getOrgDataById("D", deptIds.get(i).substring(2));
248
+                    } else {
249
+                        orgData = OrgDataBuilderHolder.getBuilder().getOrgDataById("D", deptIds.get(i));
250
+                    }
251
+                    if (orgData != null && orgData.getCode().length() > 4) {
252
+                        deptIds.add(orgData.getCode().substring(0, Math.max(orgData.getCode().length() - lenDiff, 1)));
253
+                    }
254
+                }
255
+
256
+
257
+                for (User user : userList) {
258
+                    List<String> deptList = user.getDepartment();
259
+                    for (int i = 0; i < deptList.size(); i++) {
260
+                        OrgData orgData = null;
261
+                        if (deptList.get(i).startsWith("D_")) {
262
+                            orgData = OrgDataBuilderHolder.getBuilder().getOrgDataById("D", deptList.get(i).substring(2));
263
+                        } else {
264
+                            orgData = OrgDataBuilderHolder.getBuilder().getOrgDataById("D", deptList.get(i));
265
+                        }
266
+                        if (orgData != null && orgData.getCode().length() > 4) {
267
+                            deptList.add(orgData.getCode().substring(0, Math.max(orgData.getCode().length() - lenDiff, 1)));
268
+                        }
269
+                    }
270
+
271
+                    boolean hasIntersection = !Collections.disjoint(deptList, deptIds);
272
+                    if (hasIntersection) {
273
+                        userIds.append(user.getId()).append("/").append(orgId).append(";");
274
+                        LOGGER.info("获取到{}里同步人员id:{}", orgId, user.getId());
275
+                    }
276
+                }
277
+
278
+            }
279
+            lenDiff = lenDiff + 2;
280
+        } while (userIds.length() == 0 && lenDiff < 5);
281
+        return userIds.toString();
282
+    }
283
+
129 284
 }

+ 29
- 15
src/main/java/com/horizon/org/OrgBuilderImpl.java Ver arquivo

@@ -298,6 +298,8 @@ public class OrgBuilderImpl extends OrgBuilder {
298 298
         List<Map<String, Object>> usermap = Access.getMultiMap(sql, null, dbIdentifier);
299 299
         //用户信息保存到datas集合对象中返回
300 300
         List<User> datas = Lists.newArrayList();
301
+        List<String> ids = Lists.newArrayList();
302
+
301 303
         for (Map<String, Object> map : usermap) {
302 304
             String id = map.get("id") == null ? "" : map.get("id").toString();
303 305
             String name = map.get("name") == null ? "" : map.get("name").toString();
@@ -306,23 +308,35 @@ public class OrgBuilderImpl extends OrgBuilder {
306 308
 
307 309
             //处理用户所属部门,可以所属多个部门
308 310
             List<String> listDept = Lists.newArrayList(deptid);
309
-//            listDept.add(deptid);
310
-            //用户信息保存到User类的对象中
311
-            User u = new User();
312
-            u.setId(id);
313
-            u.setUserName(name);
314
-            u.setLoginName(loginName);
315
-            u.setPasswd("1234");//密码,一般设置默认统一的密码
316
-            u.setDepartment(listDept);
317
-            u.setOrderNo(1);//用户排序,可选
318
-
319
-            if(Objects.equals(id, "24F955A08CD8CDECE063040011AC9F7F") && listDept.contains("25855EBF0D906250E063040011ACA98F")){
320
-                u.setOperType("F");//用户类型(F:直接部门领导,C:上级主管领导,I:部门管理员,空:一般用户,可传多值,多值用;隔开)
321
-            }else {
322
-                u.setOperType("");//用户类型(F:直接部门领导,C:上级主管领导,I:部门管理员,空:一般用户,可传多值,多值用;隔开)
311
+
312
+            if(ids.contains(id)){
313
+                for (User user: datas){
314
+                    if(user.getId().equals(id)){
315
+                        listDept = user.getDepartment();
316
+                        listDept.add(deptid);
317
+                        user.setDepartment(listDept);
318
+                    }
319
+                }
320
+            } else {
321
+                ids.add(id);
322
+                //用户信息保存到User类的对象中
323
+                User u = new User();
324
+                u.setId(id);
325
+                u.setUserName(name);
326
+                u.setLoginName(loginName);
327
+                u.setPasswd("1234");//密码,一般设置默认统一的密码
328
+                u.setDepartment(listDept);
329
+                u.setOrderNo(1);//用户排序,可选
330
+
331
+                if(Objects.equals(id, "24F955A08CD8CDECE063040011AC9F7F") && listDept.contains("25855EBF0D906250E063040011ACA98F")){
332
+                    u.setOperType("F");//用户类型(F:直接部门领导,C:上级主管领导,I:部门管理员,空:一般用户,可传多值,多值用;隔开)
333
+                }else {
334
+                    u.setOperType("");//用户类型(F:直接部门领导,C:上级主管领导,I:部门管理员,空:一般用户,可传多值,多值用;隔开)
335
+                }
336
+                datas.add(u);
323 337
             }
324
-            datas.add(u);
325 338
         }
339
+
326 340
         return datas;
327 341
     }
328 342
 }

Carregando…
Cancelar
Salvar