|
@@ -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();
|