|
@@ -14434,6 +14434,54 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg fixQingJianData() {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ int companyId = 1256;
|
|
|
+ List<Participation> toAddList = new ArrayList<>();
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
|
+ List<Integer> projectIds = projectList.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
+ List<ProjectDeptRelate> data = projectDeptRelateMapper.selectList(new QueryWrapper<ProjectDeptRelate>().in("project_id", projectIds));
|
|
|
+ //清理重复数据
|
|
|
+ List<ProjectDeptRelate> pureList = new ArrayList<>();
|
|
|
+ List<Integer> deleteIds = new ArrayList<>();
|
|
|
+ for (ProjectDeptRelate relate : data) {
|
|
|
+ if (pureList.stream().anyMatch(p->p.getProjectId().equals(relate.getProjectId()) && p.getDepartmentId().equals(relate.getDepartmentId()))) {
|
|
|
+ //已存在
|
|
|
+ deleteIds.add(relate.getId());
|
|
|
+ } else {
|
|
|
+ pureList.add(relate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("需要删除的数据size="+deleteIds.size());
|
|
|
+ if (deleteIds.size() > 0) {
|
|
|
+ projectDeptRelateMapper.deleteBatchIds(deleteIds);
|
|
|
+ }
|
|
|
+ List<Participation> allPartiList = participationMapper.selectList(new QueryWrapper<Participation>().in("project_id", projectIds));
|
|
|
+ for (ProjectDeptRelate projectDeptRelate : pureList) {
|
|
|
+ List<Participation> curProjectParticiList = allPartiList.stream().filter(p -> p.getProjectId().equals(projectDeptRelate.getProjectId())).collect(Collectors.toList());
|
|
|
+ List<String> curPartiUserIds = curProjectParticiList.stream().map(Participation::getUserId).collect(Collectors.toList());
|
|
|
+ List<User> deptUserList = userList.stream().filter(u -> u.getDepartmentId().equals(projectDeptRelate.getDepartmentId())).collect(Collectors.toList());
|
|
|
+ for (User user : deptUserList) {
|
|
|
+ if (!curPartiUserIds.contains(user.getId())) {
|
|
|
+ //不在参与人里面
|
|
|
+ Participation participation = new Participation();
|
|
|
+ participation.setUserId(user.getId());
|
|
|
+ participation.setProjectId(projectDeptRelate.getProjectId());
|
|
|
+ toAddList.add(participation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (toAddList.size() > 0) {
|
|
|
+ msg.data = toAddList;
|
|
|
+ participationMapper.insertBatch(toAddList);
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
public void initGroup(Integer companyId, Integer projectId) {
|
|
|
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
|
|
|
.eq(User::getRoleName, "超级管理员")
|