|
@@ -1856,7 +1856,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
httpRespMsg.setError(MessageUtils.message("register.phoneUsed")+":" + userPhoneList.stream().filter(u->!u.getCompanyId().equals(companyId)).map(User::getPhone).collect(Collectors.joining(",")));
|
|
httpRespMsg.setError(MessageUtils.message("register.phoneUsed")+":" + userPhoneList.stream().filter(u->!u.getCompanyId().equals(companyId)).map(User::getPhone).collect(Collectors.joining(",")));
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ List<User> existUsers= new ArrayList<>();
|
|
|
|
+ List<User> unExistUsers = new ArrayList<>();
|
|
for (User oldUser : userPhoneList) {
|
|
for (User oldUser : userPhoneList) {
|
|
for (User newUser : userList) {
|
|
for (User newUser : userList) {
|
|
if (oldUser.getPhone().equals(newUser.getPhone())) {
|
|
if (oldUser.getPhone().equals(newUser.getPhone())) {
|
|
@@ -1868,12 +1869,75 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
.setMonthCost(null)
|
|
.setMonthCost(null)
|
|
.setCost(null)
|
|
.setCost(null)
|
|
.setSalaryType(null);
|
|
.setSalaryType(null);
|
|
|
|
+ existUsers.add(newUser);
|
|
break;
|
|
break;
|
|
|
|
+ }else{
|
|
|
|
+ if(null != newUser.getDepartmentId() && 0 != newUser.getDepartmentId()){
|
|
|
|
+ unExistUsers.add(newUser);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //已存在的用户中查看部门是否有变化,变化则删除原部门关联项目的参与人,新增新部门关联项目
|
|
|
|
+ List<Participation> toAddList = new ArrayList<>();
|
|
|
|
+ if(CollectionUtils.isNotEmpty(existUsers)){
|
|
|
|
+ List<Integer> collect = existUsers.stream().map(User::getDepartmentId).collect(Collectors.toList());
|
|
|
|
+ Map<String, User> existMap = existUsers.stream().collect(Collectors.toMap(User::getId, t -> t));
|
|
|
|
+ List<User> oldDeptCheckUsers = userMapper.selectList(new LambdaQueryWrapper<User>().in(User::getId, collect)
|
|
|
|
+ .ne(User::getDepartmentId,0)
|
|
|
|
+ );
|
|
|
|
+ for (User oldDeptCheckUser : oldDeptCheckUsers) {
|
|
|
|
+ User user = existMap.get(oldDeptCheckUser.getId());
|
|
|
|
+ if(null != user && null != user.getDepartmentId() && 0!= user.getDepartmentId()){
|
|
|
|
+ if(!Objects.equals(oldDeptCheckUser.getDepartmentId(), user.getDepartmentId())){
|
|
|
|
+ List<ProjectDeptRelate> oldProjectDeptRelates = projectDeptRelateMapper.selectList(new LambdaQueryWrapper<ProjectDeptRelate>()
|
|
|
|
+ .eq(ProjectDeptRelate::getDepartmentId, oldDeptCheckUser.getDepartmentId())
|
|
|
|
+ );
|
|
|
|
+ List<ProjectDeptRelate> newProjectDeptRelates = projectDeptRelateMapper.selectList(new LambdaQueryWrapper<ProjectDeptRelate>()
|
|
|
|
+ .eq(ProjectDeptRelate::getDepartmentId, user.getDepartmentId())
|
|
|
|
+ );
|
|
|
|
+ List<Integer> originalProjectIds = oldProjectDeptRelates.stream().map(ProjectDeptRelate::getProjectId).collect(Collectors.toList());
|
|
|
|
+ participationMapper.delete(new LambdaQueryWrapper<Participation>()
|
|
|
|
+ .eq(Participation::getUserId,user.getId())
|
|
|
|
+ .in(Participation::getProjectId,originalProjectIds)
|
|
|
|
+ );
|
|
|
|
+ for (ProjectDeptRelate relate : newProjectDeptRelates) {
|
|
|
|
+ Participation participation = new Participation();
|
|
|
|
+ participation.setProjectId(relate.getProjectId());
|
|
|
|
+ participation.setUserId(user.getId());
|
|
|
|
+ toAddList.add(participation);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //原先不存在用户直接往新部门关联项目中添加
|
|
|
|
+ if(CollectionUtils.isNotEmpty(unExistUsers)){
|
|
|
|
+ for (User unExistUser : unExistUsers) {
|
|
|
|
+ List<ProjectDeptRelate> relates = projectDeptRelateMapper.selectList(new LambdaQueryWrapper<ProjectDeptRelate>()
|
|
|
|
+ .eq(ProjectDeptRelate::getDepartmentId, unExistUser.getDepartmentId())
|
|
|
|
+ );
|
|
|
|
+ for (ProjectDeptRelate relate : relates) {
|
|
|
|
+ Participation participation = new Participation();
|
|
|
|
+ participation.setUserId(unExistUser.getId());
|
|
|
|
+ participation.setProjectId(relate.getProjectId());
|
|
|
|
+ toAddList.add(participation);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(CollectionUtils.isNotEmpty(toAddList)){
|
|
|
|
+ toAddList = toAddList.stream().distinct().collect(Collectors.toList());
|
|
|
|
+ participationMapper.insertBatch(toAddList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
saveOrUpdateBatch(userList);
|
|
saveOrUpdateBatch(userList);
|
|
|
|
+
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|