|
@@ -539,6 +539,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ boolean inchargerChanged = false;
|
|
|
|
+ String oldInchargerId = null;
|
|
if (id == null) {
|
|
if (id == null) {
|
|
//新增项目
|
|
//新增项目
|
|
if (name == null) {
|
|
if (name == null) {
|
|
@@ -684,6 +686,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
httpRespMsg.setError(MessageUtils.message("project.submitFailByNoRepeat"));
|
|
httpRespMsg.setError(MessageUtils.message("project.submitFailByNoRepeat"));
|
|
} else {
|
|
} else {
|
|
Project project = projectMapper.selectById(id);
|
|
Project project = projectMapper.selectById(id);
|
|
|
|
+ if (inchargerId != null && !inchargerId.equals(project.getInchargerId())) {
|
|
|
|
+ inchargerChanged = true;
|
|
|
|
+ oldInchargerId = project.getInchargerId();
|
|
|
|
+ }
|
|
Project p = new Project();
|
|
Project p = new Project();
|
|
p.setProjectName(name).setId(id).setCompanyId(companyId).setProjectCode(code).setInchargerId(inchargerId)
|
|
p.setProjectName(name).setId(id).setCompanyId(companyId).setProjectCode(code).setInchargerId(inchargerId)
|
|
.setLevel(level)
|
|
.setLevel(level)
|
|
@@ -931,59 +937,73 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- //提取变化的部分
|
|
|
|
- List<ProjectAuditor> oldAuditorList = projectAuditorMapper.selectList(new QueryWrapper<ProjectAuditor>().eq("project_id", id));
|
|
|
|
- List<ProjectAuditor> newList = new ArrayList<>();
|
|
|
|
- String firstAuditorId = null;
|
|
|
|
- if (auditorIds.size() > 0) {
|
|
|
|
- firstAuditorId = auditorIds.get(0);
|
|
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", auditorIds));
|
|
|
|
- System.out.println("有auditor===");
|
|
|
|
- List<User> newUserList = userList.stream()
|
|
|
|
- .filter(u->!oldAuditorList.stream().anyMatch(old->old.getAuditorId().equals(u.getId())))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- if (newUserList.size() > 0) {
|
|
|
|
- for (User u : newUserList) {
|
|
|
|
- ProjectAuditor a = new ProjectAuditor();
|
|
|
|
- a.setProjectId(id);
|
|
|
|
- a.setAuditorId(u.getId());
|
|
|
|
- a.setAuditorName(u.getName());
|
|
|
|
- newList.add(a);
|
|
|
|
- }
|
|
|
|
- projectAuditorService.saveBatch(newList);
|
|
|
|
- }
|
|
|
|
- //检查有没有需要删除的
|
|
|
|
- List<ProjectAuditor> deleteList = oldAuditorList.stream()
|
|
|
|
- .filter(old->!userList.stream().anyMatch(u->u.getId().equals(old.getAuditorId())))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- if (deleteList.size() > 0) {
|
|
|
|
- projectAuditorService.removeByIds(deleteList.stream().map(ProjectAuditor::getId).collect(Collectors.toList()));
|
|
|
|
- }
|
|
|
|
- if (newList.size() == 0 && deleteList.size() == oldAuditorList.size()) {
|
|
|
|
- //全部被删除了的情况,保留项目负责人
|
|
|
|
- if (!StringUtils.isEmpty(inchargerId)) {
|
|
|
|
- ProjectAuditor auditor = new ProjectAuditor();
|
|
|
|
- auditor.setProjectId(id);
|
|
|
|
- auditor.setAuditorId(inchargerId);
|
|
|
|
- auditor.setAuditorName(userMapper.selectById(inchargerId).getName());
|
|
|
|
- projectAuditorMapper.insert(auditor);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //检查日报,如果有删除的审核人的正在审核的日报,要更新审核人为当前的第一个人
|
|
|
|
- Report updateItem = new Report();
|
|
|
|
- if (deleteList.size() > 0 && firstAuditorId != null) {
|
|
|
|
- updateItem.setProjectAuditorId(firstAuditorId);
|
|
|
|
- List<String> collect = deleteList.stream().map(ProjectAuditor::getAuditorId).collect(Collectors.toList());
|
|
|
|
|
|
+ //针对reportAuditType=2(先任务分组负责人审核再项目经理审核的情况),如果项目经理变更,需要把老项目经理负责的日报变成新项目经理负责
|
|
|
|
+ if (timeType.getReportAuditType() == 2) {
|
|
|
|
+ if (inchargerChanged && oldInchargerId != null) {
|
|
|
|
+ Report updateItem = new Report();
|
|
|
|
+ updateItem.setProjectAuditorId(inchargerId);
|
|
reportMapper.update(updateItem, new QueryWrapper<Report>()
|
|
reportMapper.update(updateItem, new QueryWrapper<Report>()
|
|
.eq("company_id", companyId)
|
|
.eq("company_id", companyId)
|
|
- .in("project_auditor_id", collect)
|
|
|
|
|
|
+ .eq("project_auditor_id", oldInchargerId)
|
|
.eq("state", 0)
|
|
.eq("state", 0)
|
|
|
|
+ .eq("group_audit_state", 1)//任务分组已审核,当前是项目经理审核
|
|
.eq("project_id", id));
|
|
.eq("project_id", id));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- //清空
|
|
|
|
- projectAuditorMapper.delete(new QueryWrapper<ProjectAuditor>().eq("project_id", id));
|
|
|
|
|
|
+ //其他审核情况,提取变化的部分
|
|
|
|
+ List<ProjectAuditor> oldAuditorList = projectAuditorMapper.selectList(new QueryWrapper<ProjectAuditor>().eq("project_id", id));
|
|
|
|
+ List<ProjectAuditor> newList = new ArrayList<>();
|
|
|
|
+ String firstAuditorId = null;
|
|
|
|
+ if (auditorIds.size() > 0) {
|
|
|
|
+ firstAuditorId = auditorIds.get(0);
|
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", auditorIds));
|
|
|
|
+ System.out.println("有auditor===");
|
|
|
|
+ List<User> newUserList = userList.stream()
|
|
|
|
+ .filter(u->!oldAuditorList.stream().anyMatch(old->old.getAuditorId().equals(u.getId())))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (newUserList.size() > 0) {
|
|
|
|
+ for (User u : newUserList) {
|
|
|
|
+ ProjectAuditor a = new ProjectAuditor();
|
|
|
|
+ a.setProjectId(id);
|
|
|
|
+ a.setAuditorId(u.getId());
|
|
|
|
+ a.setAuditorName(u.getName());
|
|
|
|
+ newList.add(a);
|
|
|
|
+ }
|
|
|
|
+ projectAuditorService.saveBatch(newList);
|
|
|
|
+ }
|
|
|
|
+ //检查有没有需要删除的
|
|
|
|
+ List<ProjectAuditor> deleteList = oldAuditorList.stream()
|
|
|
|
+ .filter(old->!userList.stream().anyMatch(u->u.getId().equals(old.getAuditorId())))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if (deleteList.size() > 0) {
|
|
|
|
+ projectAuditorService.removeByIds(deleteList.stream().map(ProjectAuditor::getId).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ if (newList.size() == 0 && deleteList.size() == oldAuditorList.size()) {
|
|
|
|
+ //全部被删除了的情况,保留项目负责人
|
|
|
|
+ if (!StringUtils.isEmpty(inchargerId)) {
|
|
|
|
+ ProjectAuditor auditor = new ProjectAuditor();
|
|
|
|
+ auditor.setProjectId(id);
|
|
|
|
+ auditor.setAuditorId(inchargerId);
|
|
|
|
+ auditor.setAuditorName(userMapper.selectById(inchargerId).getName());
|
|
|
|
+ projectAuditorMapper.insert(auditor);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //检查日报,如果有删除的审核人的正在审核的日报,要更新审核人为当前的第一个人
|
|
|
|
+ Report updateItem = new Report();
|
|
|
|
+ if (deleteList.size() > 0 && firstAuditorId != null) {
|
|
|
|
+ updateItem.setProjectAuditorId(firstAuditorId);
|
|
|
|
+ List<String> collect = deleteList.stream().map(ProjectAuditor::getAuditorId).collect(Collectors.toList());
|
|
|
|
+ reportMapper.update(updateItem, new QueryWrapper<Report>()
|
|
|
|
+ .eq("company_id", companyId)
|
|
|
|
+ .in("project_auditor_id", collect)
|
|
|
|
+ .eq("state", 0)
|
|
|
|
+ .eq("project_id", id));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //清空
|
|
|
|
+ projectAuditorMapper.delete(new QueryWrapper<ProjectAuditor>().eq("project_id", id));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -7989,6 +8009,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
public HttpRespMsg batchExchangeIncharger(String projectIds, String inchargerId, HttpServletRequest request) {
|
|
public HttpRespMsg batchExchangeIncharger(String projectIds, String inchargerId, HttpServletRequest request) {
|
|
HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
String[] split = projectIds.split(",");
|
|
String[] split = projectIds.split(",");
|
|
List<String> stringlist = Arrays.asList(split);
|
|
List<String> stringlist = Arrays.asList(split);
|
|
List<Integer> list=new ArrayList<>();
|
|
List<Integer> list=new ArrayList<>();
|
|
@@ -7998,28 +8019,44 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", list));
|
|
List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", list));
|
|
List<Participation> participationList = participationMapper.selectList(new QueryWrapper<Participation>().in("project_id", list));
|
|
List<Participation> participationList = participationMapper.selectList(new QueryWrapper<Participation>().in("project_id", list));
|
|
for (Project project : projectList) {
|
|
for (Project project : projectList) {
|
|
- project.setInchargerId(inchargerId);
|
|
|
|
- if(projectMapper.updateById(project)<=0){
|
|
|
|
- //httpRespMsg.setError("操作失败");
|
|
|
|
- httpRespMsg.setError(MessageUtils.message("other.operationFail"));
|
|
|
|
- return httpRespMsg;
|
|
|
|
- }
|
|
|
|
- boolean b = participationList.stream().anyMatch(pl -> pl.getProjectId().equals(project.getId()) && pl.getUserId().equals(inchargerId));
|
|
|
|
- //项目经理不在参与人当中时 要添加
|
|
|
|
- if(!b){
|
|
|
|
- Participation participation=new Participation();
|
|
|
|
- participation.setProjectId(project.getId());
|
|
|
|
- participation.setUserId(inchargerId);
|
|
|
|
- participationMapper.insert(participation);
|
|
|
|
|
|
+ String oldInchargerId = project.getInchargerId();
|
|
|
|
+ if (!inchargerId.equals(oldInchargerId)) {
|
|
|
|
+ project.setInchargerId(inchargerId);
|
|
|
|
+ if(projectMapper.updateById(project)<=0){
|
|
|
|
+ //httpRespMsg.setError("操作失败");
|
|
|
|
+ httpRespMsg.setError(MessageUtils.message("other.operationFail"));
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+ boolean b = participationList.stream().anyMatch(pl -> pl.getProjectId().equals(project.getId()) && pl.getUserId().equals(inchargerId));
|
|
|
|
+ //项目经理不在参与人当中时 要添加
|
|
|
|
+ if(!b){
|
|
|
|
+ Participation participation=new Participation();
|
|
|
|
+ participation.setProjectId(project.getId());
|
|
|
|
+ participation.setUserId(inchargerId);
|
|
|
|
+ participationMapper.insert(participation);
|
|
|
|
+ }
|
|
|
|
+ OperationRecord operationRecord=new OperationRecord();
|
|
|
|
+ operationRecord.setOperatorName(user.getName());
|
|
|
|
+ operationRecord.setProjectName(project.getProjectName());
|
|
|
|
+ operationRecord.setCompanyId(project.getCompanyId());
|
|
|
|
+ operationRecord.setOperationTime(LocalDateTime.now());
|
|
|
|
+ operationRecord.setContent("批量操作:[设置项目负责人为:"+inchargerId+"]");
|
|
|
|
+ operationRecord.setModuleName("项目管理");
|
|
|
|
+ operationRecordService.save(operationRecord);
|
|
|
|
+ //针对reportAuditType=2(先任务分组负责人审核再项目经理审核的情况),如果项目经理变更,需要把老项目经理负责的日报变成新项目经理负责
|
|
|
|
+ if (timeType.getReportAuditType() == 2) {
|
|
|
|
+ if (oldInchargerId != null) {
|
|
|
|
+ Report updateItem = new Report();
|
|
|
|
+ updateItem.setProjectAuditorId(inchargerId);
|
|
|
|
+ reportMapper.update(updateItem, new QueryWrapper<Report>()
|
|
|
|
+ .eq("company_id", timeType.getCompanyId())
|
|
|
|
+ .eq("project_auditor_id", oldInchargerId)
|
|
|
|
+ .eq("state", 0)
|
|
|
|
+ .eq("group_audit_state", 1)//任务分组已审核,当前是项目经理审核
|
|
|
|
+ .eq("project_id", project.getId()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- OperationRecord operationRecord=new OperationRecord();
|
|
|
|
- operationRecord.setOperatorName(user.getName());
|
|
|
|
- operationRecord.setProjectName(project.getProjectName());
|
|
|
|
- operationRecord.setCompanyId(project.getCompanyId());
|
|
|
|
- operationRecord.setOperationTime(LocalDateTime.now());
|
|
|
|
- operationRecord.setContent("批量操作:[设置项目负责人为:"+inchargerId+"]");
|
|
|
|
- operationRecord.setModuleName("项目管理");
|
|
|
|
- operationRecordService.save(operationRecord);
|
|
|
|
}
|
|
}
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|