Commit 605a62a011ee216e6cbf58d99f5b379e8219882a
1 parent
d1551e02
Exists in
master
翼学云 通讯录同步
Showing
4 changed files
with
700 additions
and
14 deletions
Show diff stats
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/SyncUserDto.java
@@ -15,6 +15,15 @@ public class SyncUserDto { | @@ -15,6 +15,15 @@ public class SyncUserDto { | ||
15 | private int sex ; | 15 | private int sex ; |
16 | private String mobile ; | 16 | private String mobile ; |
17 | private int updateType ; | 17 | private int updateType ; |
18 | + private String hxyCustomerId ; | ||
19 | + | ||
20 | + public String getHxyCustomerId() { | ||
21 | + return hxyCustomerId; | ||
22 | + } | ||
23 | + | ||
24 | + public void setHxyCustomerId(String hxyCustomerId) { | ||
25 | + this.hxyCustomerId = hxyCustomerId; | ||
26 | + } | ||
18 | 27 | ||
19 | public int getId() { | 28 | public int getId() { |
20 | return id; | 29 | return id; |
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYResultDetail.java
@@ -10,8 +10,46 @@ import java.io.Serializable; | @@ -10,8 +10,46 @@ import java.io.Serializable; | ||
10 | public class YXYResultDetail implements Serializable { | 10 | public class YXYResultDetail implements Serializable { |
11 | 11 | ||
12 | private String id ; | 12 | private String id ; |
13 | + private String schoolid ; | ||
13 | private String name ; | 14 | private String name ; |
14 | private String err ; | 15 | private String err ; |
16 | + private String classname ; | ||
17 | + private String gradeid ; | ||
18 | + private String classid ; | ||
19 | + private String userid ; | ||
20 | + private String stuname ; | ||
21 | + | ||
22 | + public String getSchoolid() { | ||
23 | + return schoolid; | ||
24 | + } | ||
25 | + | ||
26 | + public void setSchoolid(String schoolid) { | ||
27 | + this.schoolid = schoolid; | ||
28 | + } | ||
29 | + | ||
30 | + public String getClassname() { | ||
31 | + return classname; | ||
32 | + } | ||
33 | + | ||
34 | + public void setClassname(String classname) { | ||
35 | + this.classname = classname; | ||
36 | + } | ||
37 | + | ||
38 | + public String getGradeid() { | ||
39 | + return gradeid; | ||
40 | + } | ||
41 | + | ||
42 | + public void setGradeid(String gradeid) { | ||
43 | + this.gradeid = gradeid; | ||
44 | + } | ||
45 | + | ||
46 | + public String getClassid() { | ||
47 | + return classid; | ||
48 | + } | ||
49 | + | ||
50 | + public void setClassid(String classid) { | ||
51 | + this.classid = classid; | ||
52 | + } | ||
15 | 53 | ||
16 | public String getId() { | 54 | public String getId() { |
17 | return id; | 55 | return id; |
@@ -36,4 +74,20 @@ public class YXYResultDetail implements Serializable { | @@ -36,4 +74,20 @@ public class YXYResultDetail implements Serializable { | ||
36 | public void setErr(String err) { | 74 | public void setErr(String err) { |
37 | this.err = err; | 75 | this.err = err; |
38 | } | 76 | } |
77 | + | ||
78 | + public String getUserid() { | ||
79 | + return userid; | ||
80 | + } | ||
81 | + | ||
82 | + public void setUserid(String userid) { | ||
83 | + this.userid = userid; | ||
84 | + } | ||
85 | + | ||
86 | + public String getStuname() { | ||
87 | + return stuname; | ||
88 | + } | ||
89 | + | ||
90 | + public void setStuname(String stuname) { | ||
91 | + this.stuname = stuname; | ||
92 | + } | ||
39 | } | 93 | } |
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYWriteService.java
1 | package com.sincere.quartz.third.yixueyun; | 1 | package com.sincere.quartz.third.yixueyun; |
2 | 2 | ||
3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
4 | +import com.alibaba.fastjson.JSONArray; | ||
4 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
6 | +import com.sincere.common.dto.smartCampus.*; | ||
5 | import com.sincere.common.util.HttpClientUtils; | 7 | import com.sincere.common.util.HttpClientUtils; |
6 | import com.sincere.quartz.feign.ScFeign; | 8 | import com.sincere.quartz.feign.ScFeign; |
9 | +import org.apache.commons.lang3.StringUtils; | ||
7 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
8 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
9 | 12 | ||
13 | +import java.util.ArrayList; | ||
14 | +import java.util.List; | ||
15 | + | ||
10 | /** | 16 | /** |
11 | * @author chen | 17 | * @author chen |
12 | * @version 1.0 | 18 | * @version 1.0 |
@@ -21,6 +27,7 @@ public class YXYWriteService { | @@ -21,6 +27,7 @@ public class YXYWriteService { | ||
21 | private static String prefix_url = "http://115.239.135.60"; | 27 | private static String prefix_url = "http://115.239.135.60"; |
22 | 28 | ||
23 | private static String suffix_org_add = "/szkjapi/toyxybatch/addTeacherOrg" ; //部门添加 | 29 | private static String suffix_org_add = "/szkjapi/toyxybatch/addTeacherOrg" ; //部门添加 |
30 | + private static String suffix_grade_add = "/szkjapi/toyxybatch/addGrade" ; //部门添加 | ||
24 | private static String suffix_class_add = "/szkjapi/toyxybatch/addClass" ; //班级添加 | 31 | private static String suffix_class_add = "/szkjapi/toyxybatch/addClass" ; //班级添加 |
25 | private static String suffix_student_add = "/szkjapi/toyxybatch/addStudent" ; //学生添加 | 32 | private static String suffix_student_add = "/szkjapi/toyxybatch/addStudent" ; //学生添加 |
26 | private static String suffix_teacher_add = "/szkjapi/toyxybatch/addTeacher" ; //老师添加 | 33 | private static String suffix_teacher_add = "/szkjapi/toyxybatch/addTeacher" ; //老师添加 |
@@ -32,37 +39,651 @@ public class YXYWriteService { | @@ -32,37 +39,651 @@ public class YXYWriteService { | ||
32 | private static String suffix_org_delete = "/szkjapi/toyxybatch/deleteOrg" ; //部门 班级 删除 | 39 | private static String suffix_org_delete = "/szkjapi/toyxybatch/deleteOrg" ; //部门 班级 删除 |
33 | private static String suffix_user_delete = "/szkjapi/toyxybatch/deleteUser" ; //老师学生 删除 | 40 | private static String suffix_user_delete = "/szkjapi/toyxybatch/deleteUser" ; //老师学生 删除 |
34 | 41 | ||
42 | + private static String suffix_subject_add = "/szkjapi/toyxybatch/addSubject" ; | ||
43 | + | ||
35 | 44 | ||
36 | @Autowired | 45 | @Autowired |
37 | ScFeign scFeign ; | 46 | ScFeign scFeign ; |
38 | 47 | ||
39 | public void sync(){ | 48 | public void sync(){ |
40 | //查出要同步的学校 | 49 | //查出要同步的学校 |
50 | + List<SyncSchoolDto> schoolList = scFeign.selectSyncSchool(); | ||
51 | + for(SyncSchoolDto school : schoolList){ | ||
52 | + if(school.getPush() == 0){ | ||
53 | + //同步课程 | ||
54 | + syncSubject(school); | ||
55 | + } | ||
56 | + List<SyncDeptDto> deptList = scFeign.selectDept(school.getSchoolId()); | ||
57 | + syncDept(school,deptList); | ||
58 | + List<SyncUserDto> userList = scFeign.selectUser(school.getSchoolId()); | ||
59 | + syncUser(school,userList); | ||
60 | + } | ||
61 | + } | ||
62 | + | ||
63 | + private void syncUser(SyncSchoolDto school , List<SyncUserDto> userList){ | ||
64 | + List<SyncUserDto> addStudentList = new ArrayList<>(); | ||
65 | + List<SyncUserDto> updateStudentList = new ArrayList<>(); | ||
66 | + List<SyncUserDto> deleteStudentList = new ArrayList<>(); | ||
67 | + | ||
68 | + List<SyncUserDto> addTeacherList = new ArrayList<>(); | ||
69 | + List<SyncUserDto> updateTeacherList = new ArrayList<>(); | ||
70 | + List<SyncUserDto> deleteTeacherList = new ArrayList<>(); | ||
71 | + | ||
72 | + for(SyncUserDto user : userList){ | ||
73 | + if(user.getUserType() == 1){ //老师 | ||
74 | + if(user.getUpdateType() == 1){ | ||
75 | + addStudentList.add(user); | ||
76 | + }else if(user.getUpdateType() == 3){ | ||
77 | + updateStudentList.add(user); | ||
78 | + }else if(user.getUpdateType() == 5){ | ||
79 | + deleteStudentList.add(user); | ||
80 | + } | ||
81 | + }else if(user.getUserType() == 2){ //学生 | ||
82 | + if(user.getUpdateType() == 1){ | ||
83 | + addTeacherList.add(user); | ||
84 | + }else if(user.getUpdateType() == 3){ | ||
85 | + updateTeacherList.add(user); | ||
86 | + }else if(user.getUpdateType() == 5){ | ||
87 | + deleteTeacherList.add(user); | ||
88 | + } | ||
89 | + } | ||
90 | + } | ||
91 | + syncStudentHxy(school,addStudentList,updateStudentList,deleteStudentList); | ||
92 | + syncTeacherHxy(school,addTeacherList,updateTeacherList,deleteTeacherList); | ||
93 | + | ||
94 | + } | ||
95 | + | ||
96 | + private void syncSubject(SyncSchoolDto school){ | ||
97 | + List<String> subjectList = scFeign.selectSubject(school.getSchoolId()); | ||
98 | + JSONArray array = new JSONArray(); | ||
99 | + JSONObject object = new JSONObject(); | ||
100 | + object.put("schoolid",school.getYxtId()); | ||
101 | + StringBuffer subjects = new StringBuffer(); | ||
102 | + for(String subject : subjectList){ | ||
103 | + subjects.append(subject).append(","); | ||
104 | + } | ||
105 | + object.put("subjects",subjects.toString().substring(0,subjects.toString().length()-1)); | ||
106 | + array.add(object); | ||
107 | + YXYResult result = getResult(prefix_url+suffix_subject_add,array.toJSONString()) ; | ||
108 | + scFeign.updateSchool(school.getSchoolId()); | ||
109 | + } | ||
110 | + | ||
111 | + private void syncDept(SyncSchoolDto school , List<SyncDeptDto> deptList){ | ||
112 | + List<SyncDeptDto> addDept = new ArrayList<>(); | ||
113 | + List<SyncDeptDto> updateDept = new ArrayList<>(); | ||
114 | + List<SyncDeptDto> deleteDept = new ArrayList<>(); | ||
115 | + | ||
116 | + List<SyncDeptDto> addGrade = new ArrayList<>(); | ||
117 | + List<SyncDeptDto> updateGrade = new ArrayList<>(); | ||
118 | + List<SyncDeptDto> deleteGrade = new ArrayList<>(); | ||
119 | + | ||
120 | + List<SyncDeptDto> addClass = new ArrayList<>(); | ||
121 | + List<SyncDeptDto> updateClass = new ArrayList<>(); | ||
122 | + List<SyncDeptDto> deleteClass = new ArrayList<>(); | ||
123 | + for(SyncDeptDto dept : deptList){ | ||
124 | + if(dept.getUserType() == 1){ //组织架构 | ||
125 | + if(dept.getUpdateType() == 1){ //增 | ||
126 | + addDept.add(dept); | ||
127 | + }else if(dept.getUpdateType() == 2){ //改 | ||
128 | + updateDept.add(dept); | ||
129 | + }else { //删 | ||
130 | + deleteDept.add(dept); | ||
131 | + } | ||
132 | + } | ||
133 | + if(dept.getUserType() == 2){ //年级 | ||
134 | + if(dept.getUpdateType() == 1){ //增 | ||
135 | + addGrade.add(dept); | ||
136 | + }else if(dept.getUpdateType() == 2){ //改 | ||
137 | + updateGrade.add(dept); | ||
138 | + }else { //删 | ||
139 | + deleteGrade.add(dept); | ||
140 | + } | ||
141 | + } | ||
142 | + if(dept.getUserType() == 3){ //班级 | ||
143 | + if(dept.getUpdateType() == 1){ //增 | ||
144 | + addClass.add(dept); | ||
145 | + }else if(dept.getUpdateType() == 2){ //改 | ||
146 | + updateClass.add(dept); | ||
147 | + }else { //删 | ||
148 | + deleteClass.add(dept); | ||
149 | + } | ||
150 | + } | ||
151 | + } | ||
152 | + syncGroupHxy(school,addDept,updateDept,deleteDept); | ||
153 | + syncGradeHxy(school,addGrade,updateGrade,deleteGrade); | ||
154 | + syncClassHxy(school,addClass,updateClass,deleteClass); | ||
155 | + } | ||
156 | + | ||
157 | + private void syncGroupHxy(SyncSchoolDto school , List<SyncDeptDto> addDept , List<SyncDeptDto> updateDept ,List<SyncDeptDto> deleteDept ){ | ||
158 | + if(addDept.size() > 0){ | ||
159 | + JSONArray array = initAddJson(addDept,school.getYxtId()); | ||
160 | + YXYResult result = getResult(prefix_url+suffix_org_add,array.toJSONString()); | ||
161 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
162 | + for(YXYResultDetail detail : result.getData()){ | ||
163 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
164 | + //成功 | ||
165 | + DeptRelationDto deptRelationDto = new DeptRelationDto(); | ||
166 | + SyncDeptDto syncDeptDto = getDept(addDept,detail.getName()) ; | ||
167 | + deptRelationDto.setHxyDeptId(syncDeptDto.getDeptId()); | ||
168 | + deptRelationDto.setYxyDeptId(detail.getId()); | ||
169 | + deptRelationDto.setSqlStatus(1); | ||
170 | + deptRelationDto.setUserType(1); | ||
171 | + deptRelationDto.setState(1); | ||
172 | + scFeign.updateDeptRelation(deptRelationDto); | ||
173 | + scFeign.updateDept(syncDeptDto.getId()); | ||
174 | + }else { | ||
175 | + | ||
176 | + } | ||
177 | + } | ||
178 | + }else { | ||
179 | + System.out.println(result.getMessage()); | ||
180 | + } | ||
181 | + } | ||
182 | + if(updateDept.size() > 0){ | ||
183 | + JSONArray array = initUpdateJson(updateDept); | ||
184 | + YXYResult result = getResult(prefix_url+suffix_org_update,array.toJSONString()); | ||
185 | + List<String> errorList = new ArrayList<>(); | ||
186 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
187 | + for(YXYResultDetail detail : result.getData()){ | ||
188 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
189 | + errorList.add(detail.getName()); | ||
190 | + System.out.println(detail.getName() + "----" + detail.getErr()); | ||
191 | + } | ||
192 | + } | ||
193 | + }else { | ||
194 | + System.out.println(result.getMessage()); | ||
195 | + } | ||
196 | + for(SyncDeptDto deptDto : updateDept){ | ||
197 | + if(!errorList.contains(deptDto.getDeptName())){ | ||
198 | + DeptRelationDto deptRelationDto = new DeptRelationDto(); | ||
199 | + deptRelationDto.setHxyDeptId(deptDto.getDeptId()); | ||
200 | + deptRelationDto.setSqlStatus(2); | ||
201 | + deptRelationDto.setUserType(1); | ||
202 | + deptRelationDto.setState(1); | ||
203 | + scFeign.updateDeptRelation(deptRelationDto); | ||
204 | + scFeign.updateDept(deptDto.getId()); | ||
205 | + } | ||
206 | + } | ||
207 | + } | ||
208 | + if(deleteDept.size() > 0){ | ||
209 | + JSONArray array = initDeleteJson(deleteDept); | ||
210 | + YXYResult result = getResult(prefix_url+suffix_org_delete,array.toJSONString()); | ||
211 | + List<String> errorList = new ArrayList<>(); | ||
212 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
213 | + for(YXYResultDetail detail : result.getData()){ | ||
214 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
215 | + errorList.add(detail.getName()); | ||
216 | + System.out.println(detail.getName() + "----" + detail.getErr()); | ||
217 | + } | ||
218 | + } | ||
219 | + }else { | ||
220 | + System.out.println(result.getMessage()); | ||
221 | + } | ||
222 | + for(SyncDeptDto deptDto : updateDept){ | ||
223 | + if(!errorList.contains(deptDto.getDeptName())){ | ||
224 | + DeptRelationDto deptRelationDto = new DeptRelationDto(); | ||
225 | + deptRelationDto.setHxyDeptId(deptDto.getDeptId()); | ||
226 | + deptRelationDto.setSqlStatus(2); | ||
227 | + deptRelationDto.setUserType(1); | ||
228 | + deptRelationDto.setState(0); | ||
229 | + scFeign.updateDeptRelation(deptRelationDto); | ||
230 | + scFeign.updateDept(deptDto.getId()); | ||
231 | + } | ||
232 | + } | ||
233 | + } | ||
234 | + } | ||
235 | + | ||
236 | + private void syncGradeHxy(SyncSchoolDto school , List<SyncDeptDto> addGrade , List<SyncDeptDto> updateGrade ,List<SyncDeptDto> deleteGrade ){ | ||
237 | + if(addGrade.size() > 0){ | ||
238 | + JSONArray array = initAddJson(addGrade,school.getYxtId()); | ||
239 | + YXYResult result = getResult(prefix_url+suffix_grade_add,array.toJSONString()); | ||
240 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
241 | + for(YXYResultDetail detail : result.getData()){ | ||
242 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
243 | + //成功 | ||
244 | + DeptRelationDto deptRelationDto = new DeptRelationDto(); | ||
245 | + SyncDeptDto syncDeptDto = getDept(addGrade,detail.getName()) ; | ||
246 | + deptRelationDto.setHxyDeptId(syncDeptDto.getDeptId()); | ||
247 | + deptRelationDto.setYxyDeptId(detail.getId()); | ||
248 | + deptRelationDto.setSqlStatus(1); | ||
249 | + deptRelationDto.setUserType(2); | ||
250 | + deptRelationDto.setState(1); | ||
251 | + scFeign.updateDeptRelation(deptRelationDto); | ||
252 | + scFeign.updateDept(syncDeptDto.getId()); | ||
253 | + }else { | ||
254 | + | ||
255 | + } | ||
256 | + } | ||
257 | + }else { | ||
258 | + System.out.println(result.getMessage()); | ||
259 | + } | ||
260 | + } | ||
261 | + if(updateGrade.size() > 0){ | ||
262 | + JSONArray array = initUpdateJson(updateGrade); | ||
263 | + YXYResult result = getResult(prefix_url+suffix_org_update,array.toJSONString()); | ||
264 | + List<String> errorList = new ArrayList<>(); | ||
265 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
266 | + for(YXYResultDetail detail : result.getData()){ | ||
267 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
268 | + errorList.add(detail.getName()); | ||
269 | + System.out.println(detail.getName() + "----" + detail.getErr()); | ||
270 | + } | ||
271 | + } | ||
272 | + }else { | ||
273 | + System.out.println(result.getMessage()); | ||
274 | + } | ||
275 | + for(SyncDeptDto deptDto : updateGrade){ | ||
276 | + if(!errorList.contains(deptDto.getDeptName())){ | ||
277 | + DeptRelationDto deptRelationDto = new DeptRelationDto(); | ||
278 | + deptRelationDto.setHxyDeptId(deptDto.getDeptId()); | ||
279 | + deptRelationDto.setSqlStatus(2); | ||
280 | + deptRelationDto.setUserType(2); | ||
281 | + deptRelationDto.setState(1); | ||
282 | + scFeign.updateDeptRelation(deptRelationDto); | ||
283 | + scFeign.updateDept(deptDto.getId()); | ||
284 | + } | ||
285 | + } | ||
286 | + } | ||
287 | + if(deleteGrade.size() > 0){ | ||
288 | + JSONArray array = initDeleteJson(deleteGrade); | ||
289 | + YXYResult result = getResult(prefix_url+suffix_org_delete,array.toJSONString()); | ||
290 | + List<String> errorList = new ArrayList<>(); | ||
291 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
292 | + for(YXYResultDetail detail : result.getData()){ | ||
293 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
294 | + errorList.add(detail.getName()); | ||
295 | + System.out.println(detail.getName() + "----" + detail.getErr()); | ||
296 | + } | ||
297 | + } | ||
298 | + }else { | ||
299 | + System.out.println(result.getMessage()); | ||
300 | + } | ||
301 | + for(SyncDeptDto deptDto : deleteGrade){ | ||
302 | + if(!errorList.contains(deptDto.getDeptName())){ | ||
303 | + DeptRelationDto deptRelationDto = new DeptRelationDto(); | ||
304 | + deptRelationDto.setHxyDeptId(deptDto.getDeptId()); | ||
305 | + deptRelationDto.setSqlStatus(2); | ||
306 | + deptRelationDto.setUserType(2); | ||
307 | + deptRelationDto.setState(0); | ||
308 | + scFeign.updateDeptRelation(deptRelationDto); | ||
309 | + scFeign.updateDept(deptDto.getId()); | ||
310 | + } | ||
311 | + } | ||
312 | + } | ||
313 | + } | ||
314 | + | ||
315 | + private void syncClassHxy(SyncSchoolDto school , List<SyncDeptDto> addClass , List<SyncDeptDto> updateClass ,List<SyncDeptDto> deleteClass ){ | ||
316 | + if(addClass.size() > 0){ | ||
317 | + JSONArray array = initClassAddJson(addClass); | ||
318 | + YXYResult result = getResult(prefix_url+suffix_class_add,array.toJSONString()); | ||
319 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
320 | + for(YXYResultDetail detail : result.getData()){ | ||
321 | + if(StringUtils.isNotBlank(detail.getClassid())){ | ||
322 | + //成功 | ||
323 | + DeptRelationDto deptRelationDto = new DeptRelationDto(); | ||
324 | + SyncDeptDto syncDeptDto = getDept(addClass,detail.getClassname()) ; | ||
325 | + deptRelationDto.setHxyDeptId(syncDeptDto.getDeptId()); | ||
326 | + deptRelationDto.setYxyDeptId(detail.getClassid()); | ||
327 | + deptRelationDto.setSqlStatus(1); | ||
328 | + deptRelationDto.setUserType(3); | ||
329 | + deptRelationDto.setState(1); | ||
330 | + scFeign.updateDeptRelation(deptRelationDto); | ||
331 | + scFeign.updateDept(syncDeptDto.getId()); | ||
332 | + }else { | ||
333 | + | ||
334 | + } | ||
335 | + } | ||
336 | + }else { | ||
337 | + System.out.println(result.getMessage()); | ||
338 | + } | ||
339 | + } | ||
340 | + if(updateClass.size() > 0){ | ||
341 | + JSONArray array = initUpdateJson(updateClass); | ||
342 | + YXYResult result = getResult(prefix_url+suffix_org_update,array.toJSONString()); | ||
343 | + List<String> errorList = new ArrayList<>(); | ||
344 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
345 | + for(YXYResultDetail detail : result.getData()){ | ||
346 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
347 | + errorList.add(detail.getName()); | ||
348 | + System.out.println(detail.getName() + "----" + detail.getErr()); | ||
349 | + } | ||
350 | + } | ||
351 | + }else { | ||
352 | + System.out.println(result.getMessage()); | ||
353 | + } | ||
354 | + for(SyncDeptDto deptDto : updateClass){ | ||
355 | + if(!errorList.contains(deptDto.getDeptName())){ | ||
356 | + DeptRelationDto deptRelationDto = new DeptRelationDto(); | ||
357 | + deptRelationDto.setHxyDeptId(deptDto.getDeptId()); | ||
358 | + deptRelationDto.setSqlStatus(2); | ||
359 | + deptRelationDto.setUserType(3); | ||
360 | + deptRelationDto.setState(1); | ||
361 | + scFeign.updateDeptRelation(deptRelationDto); | ||
362 | + scFeign.updateDept(deptDto.getId()); | ||
363 | + } | ||
364 | + } | ||
365 | + } | ||
366 | + if(deleteClass.size() > 0){ | ||
367 | + JSONArray array = initDeleteJson(deleteClass); | ||
368 | + YXYResult result = getResult(prefix_url+suffix_org_delete,array.toJSONString()); | ||
369 | + List<String> errorList = new ArrayList<>(); | ||
370 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
371 | + for(YXYResultDetail detail : result.getData()){ | ||
372 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
373 | + errorList.add(detail.getName()); | ||
374 | + System.out.println(detail.getName() + "----" + detail.getErr()); | ||
375 | + } | ||
376 | + } | ||
377 | + }else { | ||
378 | + System.out.println(result.getMessage()); | ||
379 | + } | ||
380 | + for(SyncDeptDto deptDto : deleteClass){ | ||
381 | + if(!errorList.contains(deptDto.getDeptName())){ | ||
382 | + DeptRelationDto deptRelationDto = new DeptRelationDto(); | ||
383 | + deptRelationDto.setHxyDeptId(deptDto.getDeptId()); | ||
384 | + deptRelationDto.setSqlStatus(2); | ||
385 | + deptRelationDto.setUserType(3); | ||
386 | + deptRelationDto.setState(0); | ||
387 | + scFeign.updateDeptRelation(deptRelationDto); | ||
388 | + scFeign.updateDept(deptDto.getId()); | ||
389 | + } | ||
390 | + } | ||
391 | + } | ||
392 | + } | ||
393 | + | ||
41 | 394 | ||
42 | - //同步的部门 ,新增 修改 删除 | ||
43 | - syncDept(); | ||
44 | - //同步的老师 | ||
45 | - syncTeacher(); | ||
46 | - //同步的学生 | ||
47 | - syncStudent(); | ||
48 | - //同步的班级 | ||
49 | - syncClass(); | 395 | + private JSONArray initAddJson(List<SyncUserDto> list){ |
396 | + JSONArray array = new JSONArray(); | ||
397 | + for(SyncUserDto user : list){ | ||
398 | + JSONObject object = new JSONObject(); | ||
399 | + object.put("classid",scFeign.selectYxyIdByHxyId(user.getClassId())); | ||
400 | + object.put("stuname",user.getName()); | ||
401 | + object.put("mobile",user.getMobile()); | ||
402 | + object.put("sex",user.getSex()); | ||
403 | + array.add(object); | ||
404 | + } | ||
405 | + return array ; | ||
50 | } | 406 | } |
51 | 407 | ||
52 | - private void syncDept(){ | 408 | + private JSONArray initTeacherAddJson(SyncSchoolDto school , List<SyncUserDto> list){ |
409 | + JSONArray array = new JSONArray(); | ||
410 | + for(SyncUserDto user : list){ | ||
411 | + JSONObject object = new JSONObject(); | ||
412 | + object.put("schoolid",school.getYxtId()); | ||
413 | + object.put("name",user.getName()); | ||
414 | + object.put("mobile",user.getMobile()); | ||
415 | + object.put("sex",user.getSex()); | ||
416 | + array.add(object); | ||
417 | + } | ||
418 | + return array ; | ||
419 | + } | ||
53 | 420 | ||
421 | + private JSONArray initTeacherUpdateJson(SyncSchoolDto school , List<SyncUserDto> list){ | ||
422 | + JSONArray array = new JSONArray(); | ||
423 | + for(SyncUserDto user : list){ | ||
424 | + JSONObject object = new JSONObject(); | ||
425 | + object.put("schoolid",school.getYxtId()); | ||
426 | + object.put("name",user.getName()); | ||
427 | + object.put("mobile",user.getMobile()); | ||
428 | + object.put("sex",user.getSex()); | ||
429 | + array.add(object); | ||
430 | + } | ||
431 | + return array ; | ||
54 | } | 432 | } |
55 | 433 | ||
56 | - private void syncTeacher(){ | 434 | + private JSONArray initUserUpdateJson(List<SyncUserDto> list){ |
435 | + JSONArray array = new JSONArray(); | ||
436 | + for(SyncUserDto user : list){ | ||
437 | + JSONObject object = new JSONObject(); | ||
438 | + object.put("userid",user.getHxyCustomerId()); | ||
439 | + object.put("classid",scFeign.selectYxyIdByHxyId(user.getClassId())); | ||
440 | + object.put("stuname",user.getName()); | ||
441 | + object.put("mobile",user.getMobile()); | ||
442 | + object.put("sex",user.getSex()); | ||
443 | + array.add(object); | ||
444 | + } | ||
445 | + return array ; | ||
446 | + } | ||
57 | 447 | ||
448 | + private JSONArray initUserDeleteJson(List<SyncUserDto> list){ | ||
449 | + JSONArray array = new JSONArray(); | ||
450 | + for(SyncUserDto user : list){ | ||
451 | + JSONObject object = new JSONObject(); | ||
452 | + object.put("id",user.getHxyCustomerId()); | ||
453 | + array.add(object); | ||
454 | + } | ||
455 | + return array ; | ||
58 | } | 456 | } |
59 | 457 | ||
60 | - private void syncClass(){ | 458 | + private void syncStudentHxy(SyncSchoolDto school , List<SyncUserDto> addStudentList , List<SyncUserDto> updateStudentList ,List<SyncUserDto> deleteStudentList ){ |
459 | + if(addStudentList.size() > 0){ | ||
460 | + JSONArray array = initAddJson(addStudentList); | ||
461 | + YXYResult result = getResult(prefix_url+suffix_student_add,array.toJSONString()); | ||
462 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
463 | + for(YXYResultDetail detail : result.getData()){ | ||
464 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
465 | + //成功 | ||
466 | + UserRelationDto userRelationDto = new UserRelationDto(); | ||
467 | + SyncUserDto syncUserDto = getUser(addStudentList,detail.getName()) ; | ||
468 | + userRelationDto.setHxyCustomerId(syncUserDto.getCustomerId()); | ||
469 | + userRelationDto.setYxyUserId(detail.getUserid()); | ||
470 | + userRelationDto.setSqlstate(1); | ||
471 | + userRelationDto.setUserType(1); | ||
472 | + userRelationDto.setState(1); | ||
473 | + scFeign.updateUserRelation(userRelationDto); | ||
474 | + scFeign.updateUser(syncUserDto.getId()); | ||
475 | + } | ||
476 | + } | ||
477 | + }else { | ||
478 | + System.out.println(result.getMessage()); | ||
479 | + } | ||
480 | + } | ||
481 | + if(updateStudentList.size() > 0){ | ||
482 | + JSONArray array = initUserUpdateJson(updateStudentList); | ||
483 | + YXYResult result = getResult(prefix_url+suffix_student_update,array.toJSONString()); | ||
484 | + List<String> errorList = new ArrayList<>(); | ||
485 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
486 | + for(YXYResultDetail detail : result.getData()){ | ||
487 | + if(StringUtils.isNotBlank(detail.getUserid())){ | ||
488 | + errorList.add(detail.getUserid()); | ||
489 | + System.out.println(detail.getStuname() + "----" + detail.getErr()); | ||
490 | + } | ||
491 | + } | ||
492 | + }else { | ||
493 | + System.out.println(result.getMessage()); | ||
494 | + } | ||
495 | + for(SyncUserDto user : updateStudentList){ | ||
496 | + if(!errorList.contains(user.getHxyCustomerId())){ | ||
497 | + UserRelationDto userRelationDto = new UserRelationDto(); | ||
498 | + userRelationDto.setYxyUserId(user.getCustomerId()); | ||
499 | + userRelationDto.setSqlstate(2); | ||
500 | + userRelationDto.setUserType(1); | ||
501 | + userRelationDto.setState(1); | ||
502 | + scFeign.updateUserRelation(userRelationDto); | ||
503 | + scFeign.updateDept(user.getId()); | ||
504 | + } | ||
505 | + } | ||
506 | + } | ||
507 | + if(deleteStudentList.size() > 0){ | ||
508 | + JSONArray array = initUserDeleteJson(deleteStudentList); | ||
509 | + YXYResult result = getResult(prefix_url+suffix_user_delete,array.toJSONString()); | ||
510 | + List<String> errorList = new ArrayList<>(); | ||
511 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
512 | + for(YXYResultDetail detail : result.getData()){ | ||
513 | + if(StringUtils.isNotBlank(detail.getUserid())){ | ||
514 | + errorList.add(detail.getUserid()); | ||
515 | + System.out.println(detail.getStuname() + "----" + detail.getErr()); | ||
516 | + } | ||
517 | + } | ||
518 | + }else { | ||
519 | + System.out.println(result.getMessage()); | ||
520 | + } | ||
521 | + for(SyncUserDto user : updateStudentList){ | ||
522 | + if(!errorList.contains(user.getHxyCustomerId())){ | ||
523 | + UserRelationDto userRelationDto = new UserRelationDto(); | ||
524 | + userRelationDto.setYxyUserId(user.getCustomerId()); | ||
525 | + userRelationDto.setSqlstate(2); | ||
526 | + userRelationDto.setUserType(1); | ||
527 | + userRelationDto.setState(0); | ||
528 | + scFeign.updateUserRelation(userRelationDto); | ||
529 | + scFeign.updateDept(user.getId()); | ||
530 | + } | ||
531 | + } | ||
532 | + } | ||
533 | + } | ||
61 | 534 | ||
535 | + private void syncTeacherHxy(SyncSchoolDto school , List<SyncUserDto> addTeacherList , List<SyncUserDto> updateTeacherList ,List<SyncUserDto> deleteTeacherList ){ | ||
536 | + if(addTeacherList.size() > 0){ | ||
537 | + JSONArray array = initTeacherAddJson(school,addTeacherList); | ||
538 | + YXYResult result = getResult(prefix_url+suffix_teacher_add,array.toJSONString()); | ||
539 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
540 | + for(YXYResultDetail detail : result.getData()){ | ||
541 | + if(StringUtils.isNotBlank(detail.getId())){ | ||
542 | + //成功 | ||
543 | + UserRelationDto userRelationDto = new UserRelationDto(); | ||
544 | + SyncUserDto syncUserDto = getUser(addTeacherList,detail.getName()) ; | ||
545 | + userRelationDto.setHxyCustomerId(syncUserDto.getCustomerId()); | ||
546 | + userRelationDto.setYxyUserId(detail.getUserid()); | ||
547 | + userRelationDto.setSqlstate(1); | ||
548 | + userRelationDto.setUserType(2); | ||
549 | + userRelationDto.setState(1); | ||
550 | + scFeign.updateUserRelation(userRelationDto); | ||
551 | + scFeign.updateUser(syncUserDto.getId()); | ||
552 | + } | ||
553 | + } | ||
554 | + }else { | ||
555 | + System.out.println(result.getMessage()); | ||
556 | + } | ||
557 | + } | ||
558 | + if(updateTeacherList.size() > 0){ | ||
559 | + JSONArray array = initTeacherUpdateJson(school,updateTeacherList); | ||
560 | + YXYResult result = getResult(prefix_url+suffix_teacher_update,array.toJSONString()); | ||
561 | + List<String> errorList = new ArrayList<>(); | ||
562 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
563 | + for(YXYResultDetail detail : result.getData()){ | ||
564 | + if(StringUtils.isNotBlank(detail.getUserid())){ | ||
565 | + errorList.add(detail.getUserid()); | ||
566 | + System.out.println(detail.getStuname() + "----" + detail.getErr()); | ||
567 | + } | ||
568 | + } | ||
569 | + }else { | ||
570 | + System.out.println(result.getMessage()); | ||
571 | + } | ||
572 | + for(SyncUserDto user : updateTeacherList){ | ||
573 | + if(!errorList.contains(user.getHxyCustomerId())){ | ||
574 | + UserRelationDto userRelationDto = new UserRelationDto(); | ||
575 | + userRelationDto.setYxyUserId(user.getCustomerId()); | ||
576 | + userRelationDto.setSqlstate(2); | ||
577 | + userRelationDto.setUserType(2); | ||
578 | + userRelationDto.setState(1); | ||
579 | + scFeign.updateUserRelation(userRelationDto); | ||
580 | + scFeign.updateDept(user.getId()); | ||
581 | + } | ||
582 | + } | ||
583 | + } | ||
584 | + if(deleteTeacherList.size() > 0){ | ||
585 | + JSONArray array = initUserDeleteJson(deleteTeacherList); | ||
586 | + YXYResult result = getResult(prefix_url+suffix_user_delete,array.toJSONString()); | ||
587 | + List<String> errorList = new ArrayList<>(); | ||
588 | + if(result.getCode() == 0 || result.getCode() == -3){ | ||
589 | + for(YXYResultDetail detail : result.getData()){ | ||
590 | + if(StringUtils.isNotBlank(detail.getUserid())){ | ||
591 | + errorList.add(detail.getUserid()); | ||
592 | + System.out.println(detail.getStuname() + "----" + detail.getErr()); | ||
593 | + } | ||
594 | + } | ||
595 | + }else { | ||
596 | + System.out.println(result.getMessage()); | ||
597 | + } | ||
598 | + for(SyncUserDto user : deleteTeacherList){ | ||
599 | + if(!errorList.contains(user.getHxyCustomerId())){ | ||
600 | + UserRelationDto userRelationDto = new UserRelationDto(); | ||
601 | + userRelationDto.setYxyUserId(user.getCustomerId()); | ||
602 | + userRelationDto.setSqlstate(2); | ||
603 | + userRelationDto.setUserType(2); | ||
604 | + userRelationDto.setState(0); | ||
605 | + scFeign.updateUserRelation(userRelationDto); | ||
606 | + scFeign.updateDept(user.getId()); | ||
607 | + } | ||
608 | + } | ||
609 | + } | ||
62 | } | 610 | } |
63 | 611 | ||
64 | - private void syncStudent(){ | ||
65 | 612 | ||
613 | + //封装组织架构对象 | ||
614 | + private JSONArray initAddJson(List<SyncDeptDto> list , String yxtId){ | ||
615 | + JSONArray array = new JSONArray(); | ||
616 | + for(SyncDeptDto deptDto : list){ | ||
617 | + JSONObject object = new JSONObject(); | ||
618 | + object.put("schoolid",yxtId); | ||
619 | + object.put("name",deptDto.getDeptName()); | ||
620 | + if(deptDto.getGradeId() != 0){ | ||
621 | + object.put("groupname",getDept(list,deptDto.getGradeId()).getDeptName()); | ||
622 | + } | ||
623 | + array.add(object); | ||
624 | + } | ||
625 | + return array ; | ||
626 | + } | ||
627 | + | ||
628 | + private JSONArray initClassAddJson(List<SyncDeptDto> list){ | ||
629 | + JSONArray array = new JSONArray(); | ||
630 | + for(SyncDeptDto deptDto : list){ | ||
631 | + JSONObject object = new JSONObject(); | ||
632 | + object.put("gradeid",scFeign.selectYxyIdByHxyId(deptDto.getGradeId())); | ||
633 | + object.put("classname",deptDto.getDeptName()); | ||
634 | + array.add(object); | ||
635 | + } | ||
636 | + return array ; | ||
637 | + } | ||
638 | + | ||
639 | + private JSONArray initUpdateJson(List<SyncDeptDto> list){ | ||
640 | + JSONArray array = new JSONArray(); | ||
641 | + for(SyncDeptDto deptDto : list){ | ||
642 | + JSONObject object = new JSONObject(); | ||
643 | + object.put("name",deptDto.getDeptName()); | ||
644 | + object.put("id",scFeign.selectYxyIdByHxyId(deptDto.getDeptId())); | ||
645 | + array.add(object); | ||
646 | + } | ||
647 | + return array ; | ||
648 | + } | ||
649 | + | ||
650 | + private JSONArray initDeleteJson(List<SyncDeptDto> list){ | ||
651 | + JSONArray array = new JSONArray(); | ||
652 | + for(SyncDeptDto deptDto : list){ | ||
653 | + JSONObject object = new JSONObject(); | ||
654 | + object.put("id",scFeign.selectYxyIdByHxyId(deptDto.getDeptId())); | ||
655 | + array.add(object); | ||
656 | + } | ||
657 | + return array ; | ||
658 | + } | ||
659 | + | ||
660 | + //返回父部门,或者年级 | ||
661 | + private SyncDeptDto getDept(List<SyncDeptDto> deptList , int pId){ | ||
662 | + for(SyncDeptDto dept : deptList){ | ||
663 | + if(dept.getDeptId() == pId){ | ||
664 | + return dept ; | ||
665 | + } | ||
666 | + } | ||
667 | + return null ; | ||
668 | + } | ||
669 | + | ||
670 | + //返回对应的dept | ||
671 | + private SyncDeptDto getDept(List<SyncDeptDto> deptList , String name){ | ||
672 | + for(SyncDeptDto dept : deptList){ | ||
673 | + if(dept.getDeptName().equals(name)){ | ||
674 | + return dept ; | ||
675 | + } | ||
676 | + } | ||
677 | + return null ; | ||
678 | + } | ||
679 | + | ||
680 | + private SyncUserDto getUser(List<SyncUserDto> deptList , String name){ | ||
681 | + for(SyncUserDto user : deptList){ | ||
682 | + if(user.getName().equals(name)){ | ||
683 | + return user ; | ||
684 | + } | ||
685 | + } | ||
686 | + return null ; | ||
66 | } | 687 | } |
67 | 688 | ||
68 | 689 |
cloud/search_smartCampus/src/main/resources/mapper/SyncMapper.xml
@@ -60,10 +60,12 @@ | @@ -60,10 +60,12 @@ | ||
60 | <result column="Sex" property="sex" /> | 60 | <result column="Sex" property="sex" /> |
61 | <result column="mobile" property="mobile" /> | 61 | <result column="mobile" property="mobile" /> |
62 | <result column="UpdateType" property="updateType" /> | 62 | <result column="UpdateType" property="updateType" /> |
63 | + <result column="hxyCustomerId" property="hxyCustomerId" /> | ||
63 | </resultMap> | 64 | </resultMap> |
64 | <select id="selectUser" parameterType="java.lang.Integer" resultMap="UserDtp"> | 65 | <select id="selectUser" parameterType="java.lang.Integer" resultMap="UserDtp"> |
65 | - select ID , UserType , Name , ClassId , CustomerId , Sex , mobile , UpdateType from HS_StudentUpdateCard | ||
66 | - where SchoolId = #{schoolId} and Yxy_IsNew = 0 | 66 | + select HS_StudentUpdateCard.ID , HS_StudentUpdateCard.UserType , HS_StudentUpdateCard.Name , HS_StudentUpdateCard.ClassId , HS_StudentUpdateCard.CustomerId , HS_StudentUpdateCard.Sex , HS_StudentUpdateCard.mobile , HS_StudentUpdateCard.UpdateType , SZ_UserRelation.yxyUserId from HS_StudentUpdateCard |
67 | + left join SZ_UserRelation on HS_StudentUpdateCard.CustomerId = SZ_UserRelation.hxyCustomerId | ||
68 | + where SchoolId =#{schoolId} and Yxy_IsNew = 0 | ||
67 | </select> | 69 | </select> |
68 | 70 | ||
69 | <insert id="insertDeptRelation" parameterType="com.sincere.common.dto.smartCampus.DeptRelationDto"> | 71 | <insert id="insertDeptRelation" parameterType="com.sincere.common.dto.smartCampus.DeptRelationDto"> |