Browse Source

报错调整

dzx 3 months ago
parent
commit
4360f30074

+ 36 - 8
src/main/java/com/xjrsoft/module/teacher/service/impl/TeacherbaseManagerServiceImpl.java

@@ -17,6 +17,7 @@ import com.xjrsoft.common.enums.RoleEnum;
 import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.config.CommonPropertiesConfig;
+import com.xjrsoft.module.courseTable.entity.ClassTime;
 import com.xjrsoft.module.organization.entity.Department;
 import com.xjrsoft.module.organization.entity.Post;
 import com.xjrsoft.module.organization.entity.User;
@@ -498,6 +499,26 @@ public class TeacherbaseManagerServiceImpl extends MPJBaseServiceImpl<XjrUserMap
         );
         Map<String, Long> postMap = postList.stream().collect(Collectors.toMap(Post::getName, Post::getId));
 
+        List<UserPostRelation> postRelations = userPostRelationService.list(
+                new MPJLambdaWrapper<UserPostRelation>()
+                        .select(UserPostRelation::getId)
+                        .select(UserPostRelation.class, x -> VoToColumnUtil.fieldsToColumns(UserPostRelation.class).contains(x.getProperty()))
+                        .innerJoin(User.class, User::getId, UserPostRelation::getUserId)
+                        .innerJoin(BaseTeacher.class, BaseTeacher::getUserId, User::getId)
+        );
+        Map<Long, List<Long>> userPostMap = postRelations.stream()
+                .collect(Collectors.groupingBy(UserPostRelation::getUserId, Collectors.mapping(UserPostRelation::getPostId, Collectors.toList())));
+
+        List<UserDeptRelation> deptRelations = userDeptRelationMapper.selectList(
+                new MPJLambdaWrapper<UserDeptRelation>()
+                        .select(UserDeptRelation::getId)
+                        .select(UserDeptRelation.class, x -> VoToColumnUtil.fieldsToColumns(UserDeptRelation.class).contains(x.getProperty()))
+                        .innerJoin(User.class, User::getId, UserDeptRelation::getUserId)
+                        .innerJoin(BaseTeacher.class, BaseTeacher::getUserId, User::getId)
+        );
+        Map<Long, List<Long>> userDeptMap = postRelations.stream()
+                .collect(Collectors.groupingBy(UserPostRelation::getUserId, Collectors.mapping(UserPostRelation::getPostId, Collectors.toList())));
+
         List<User> updateUserList = new ArrayList<>();
         List<BaseTeacher> updateTeacherList = new ArrayList<>();
         List<UserDeptRelation> updateDeptList = new ArrayList<>();
@@ -518,15 +539,22 @@ public class TeacherbaseManagerServiceImpl extends MPJBaseServiceImpl<XjrUserMap
                 teacher.setEmployType(dictionaryMap.get(rowData.get(6).toString()));
                 updateTeacherList.add(teacher);
 
-                UserDeptRelation userDeptRelation = new UserDeptRelation();
-                userDeptRelation.setDeptId(departmentMap.get(rowData.get(7).toString()));
-                userDeptRelation.setUserId(user.getId());
-                updateDeptList.add(userDeptRelation);
+                List<Long> deptIds = userDeptMap.get(user.getId());
+                if(deptIds == null || !deptIds.contains(departmentMap.get(rowData.get(7).toString()))){
+                    UserDeptRelation userDeptRelation = new UserDeptRelation();
+                    userDeptRelation.setDeptId(departmentMap.get(rowData.get(7).toString()));
+                    userDeptRelation.setUserId(user.getId());
+                    updateDeptList.add(userDeptRelation);
+                }
+
+                List<Long> postIds = userPostMap.get(user.getId());
+                if(postIds == null || !postIds.contains(postMap.get(rowData.get(8).toString()))){
+                    UserPostRelation postRelation = new UserPostRelation();
+                    postRelation.setPostId(postMap.get(rowData.get(8).toString()));
+                    postRelation.setUserId(user.getId());
+                    updatePostList.add(postRelation);
+                }
 
-                UserPostRelation postRelation = new UserPostRelation();
-                postRelation.setPostId(postMap.get(rowData.get(8).toString()));
-                postRelation.setUserId(user.getId());
-                updatePostList.add(postRelation);
                 continue;
             }
             User user = new User();

+ 1 - 1
src/main/resources/mapper/student/BaseStudentPunishmentInfoMapper.xml

@@ -15,7 +15,7 @@
         t.push_message_object,
         t.reason
         FROM base_student_punishment_info t
-        INNER JOIN base_punishment_type t2 ON (AND t2.id = t.punishment_type_id)
+        INNER JOIN base_punishment_type t2 ON (t2.id = t.punishment_type_id)
         LEFT JOIN base_semester t1 ON (t1.id = t.base_semester_id)
         LEFT JOIN base_class t3 ON (t3.id = t.class_id)
         where t.delete_mark = 0