|
@@ -21,6 +21,7 @@ import me.chanjar.weixin.mp.api.WxMpService;
|
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
@@ -218,6 +219,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
@Resource
|
|
@Resource
|
|
private UserReportDeptService userReportDeptService;
|
|
private UserReportDeptService userReportDeptService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private ProjectDeptRelateMapper projectDeptRelateMapper;
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private LdapTemplate ldapTemplate;
|
|
private LdapTemplate ldapTemplate;
|
|
@Resource
|
|
@Resource
|
|
@@ -1434,6 +1438,22 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
});
|
|
});
|
|
userReportDeptService.saveBatch(userReportDeptList);
|
|
userReportDeptService.saveBatch(userReportDeptList);
|
|
}
|
|
}
|
|
|
|
+ //新增用户,查看项目部门关联表,若存在有直属部门,直接加入
|
|
|
|
+ if(null != departmentId && 0 != departmentId){
|
|
|
|
+ List<ProjectDeptRelate> projectDeptRelates = projectDeptRelateMapper.selectList(new LambdaQueryWrapper<ProjectDeptRelate>()
|
|
|
|
+ .eq(ProjectDeptRelate::getDepartmentId, departmentId)
|
|
|
|
+ );
|
|
|
|
+ if(CollectionUtils.isNotEmpty(projectDeptRelates)){
|
|
|
|
+ List<Participation> toAddList = new ArrayList<>(projectDeptRelates.size());
|
|
|
|
+ for (ProjectDeptRelate relate : projectDeptRelates) {
|
|
|
|
+ Participation participation = new Participation();
|
|
|
|
+ participation.setProjectId(relate.getProjectId());
|
|
|
|
+ participation.setUserId(String.valueOf(id));
|
|
|
|
+ toAddList.add(participation);
|
|
|
|
+ }
|
|
|
|
+ participationMapper.insertBatch(toAddList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -1473,6 +1493,29 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
superiorChange = true;
|
|
superiorChange = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //更新操作,判断前后部门是否变化,有变化则删除原部门关联项目下的该用户,新增到新部门关联的项目下
|
|
|
|
+ if(oldUser.getDepartmentId() != (departmentId == null ? 0 : departmentId)){
|
|
|
|
+ List<ProjectDeptRelate> oldProjectDeptRelates = projectDeptRelateMapper.selectList(new LambdaQueryWrapper<ProjectDeptRelate>()
|
|
|
|
+ .eq(ProjectDeptRelate::getDepartmentId, oldUser.getDepartmentId())
|
|
|
|
+ );
|
|
|
|
+ List<ProjectDeptRelate> newProjectDeptRelates = projectDeptRelateMapper.selectList(new LambdaQueryWrapper<ProjectDeptRelate>()
|
|
|
|
+ .eq(ProjectDeptRelate::getDepartmentId, departmentId)
|
|
|
|
+ );
|
|
|
|
+ List<Integer> originalProjectIds = oldProjectDeptRelates.stream().map(ProjectDeptRelate::getProjectId).collect(Collectors.toList());
|
|
|
|
+ participationMapper.delete(new LambdaQueryWrapper<Participation>()
|
|
|
|
+ .eq(Participation::getUserId,targetId)
|
|
|
|
+ .in(Participation::getProjectId,originalProjectIds)
|
|
|
|
+ );
|
|
|
|
+ List<Participation> toAddList = new ArrayList<>(newProjectDeptRelates.size());
|
|
|
|
+ for (ProjectDeptRelate relate : newProjectDeptRelates) {
|
|
|
|
+ Participation participation = new Participation();
|
|
|
|
+ participation.setProjectId(relate.getProjectId());
|
|
|
|
+ participation.setUserId(targetId);
|
|
|
|
+ toAddList.add(participation);
|
|
|
|
+ }
|
|
|
|
+ participationMapper.insertBatch(toAddList);
|
|
|
|
+ }
|
|
|
|
+
|
|
userMapper.updateById(oldUser
|
|
userMapper.updateById(oldUser
|
|
.setName(name)
|
|
.setName(name)
|
|
.setPhone(phone)
|
|
.setPhone(phone)
|