|
|
@@ -31,7 +31,10 @@ import com.hz.pm.api.meeting.builder.MeetingReviewProjectBuilder; |
|
|
|
import com.hz.pm.api.meeting.builder.ProjectReviewResultBuilder; |
|
|
|
import com.hz.pm.api.meeting.entity.domain.*; |
|
|
|
import com.hz.pm.api.meeting.entity.dto.*; |
|
|
|
import com.hz.pm.api.meeting.entity.enumeration.*; |
|
|
|
import com.hz.pm.api.meeting.entity.enumeration.ExpertAttendStatusEnum; |
|
|
|
import com.hz.pm.api.meeting.entity.enumeration.ExpertInviteTypeEnum; |
|
|
|
import com.hz.pm.api.meeting.entity.enumeration.MeetingReviewTypeEnum; |
|
|
|
import com.hz.pm.api.meeting.entity.enumeration.MeetingStatusEnum; |
|
|
|
import com.hz.pm.api.meeting.entity.req.*; |
|
|
|
import com.hz.pm.api.meeting.entity.vo.*; |
|
|
|
import com.hz.pm.api.meeting.helper.ExpertInviteHelper; |
|
|
@@ -1013,71 +1016,66 @@ public class MeetingManage { |
|
|
|
Meeting meeting = meetingService.getById(req.getMeetingId()); |
|
|
|
Assert.notNull(meeting, "会议不存在"); |
|
|
|
Assert.isTrue(MeetingStatusEnum.NORMAL.eq(meeting.getStatus()), "当前会议无法添加项目"); |
|
|
|
List<String> projectCodes = CollUtils.convert(req.getProjectIds(), ProjectIdCodeCacheUtil::get); |
|
|
|
List<String> projectCodes; |
|
|
|
if (CollUtil.isNotEmpty(req.getProjectIds())) { |
|
|
|
projectCodes = CollUtils.convert(req.getProjectIds(), ProjectIdCodeCacheUtil::get); |
|
|
|
} else { |
|
|
|
projectCodes = Collections.emptyList(); |
|
|
|
} |
|
|
|
Wrapper<MeetingInnerProject> query = Wrappers.lambdaQuery(MeetingInnerProject.class) |
|
|
|
.select(MeetingInnerProject::getMeetingId, MeetingInnerProject::getProjectCode, |
|
|
|
MeetingInnerProject::getId, MeetingInnerProject::getReviewResult) |
|
|
|
.in(MeetingInnerProject::getProjectCode, projectCodes); |
|
|
|
Collection<MeetingInnerProject> linkedProjList = BizUtils.groupFirst(meetingInnerProjectService.list(query), |
|
|
|
MeetingInnerProject::getProjectCode, Comparator.comparing(MeetingInnerProject::getId).reversed()); |
|
|
|
// 移除已关联当前会议的项目 |
|
|
|
projectCodes.removeIf(w -> CollUtil.anyMatch(linkedProjList, |
|
|
|
x -> x.getProjectCode().equals(w) && x.getMeetingId().equals(meeting.getId()))); |
|
|
|
if (projectCodes.isEmpty()) { |
|
|
|
.eq(MeetingInnerProject::getMeetingId, meeting.getId()); |
|
|
|
List<MeetingInnerProject> linkedProjList = meetingInnerProjectService.list(query); |
|
|
|
if (linkedProjList.isEmpty() && projectCodes.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
linkedProjList.removeIf(w -> w.getMeetingId().equals(meeting.getId())); |
|
|
|
if (CollUtil.isNotEmpty(linkedProjList)) { |
|
|
|
Set<Long> linkedMeetingIds = CollUtils.fieldSet(linkedProjList, MeetingInnerProject::getMeetingId); |
|
|
|
if (!linkedMeetingIds.isEmpty()) { |
|
|
|
List<Meeting> meetings = meetingService.listByIds(linkedMeetingIds); |
|
|
|
Map<Long, Meeting> meetingMap = CollUtils.listToMap(meetings, Meeting::getId); |
|
|
|
if (CollUtil.anyMatch(linkedProjList, w -> { |
|
|
|
Meeting linkedMeeting = meetingMap.get(w.getMeetingId()); |
|
|
|
return MeetingStatusEnum.NORMAL.eq(linkedMeeting.getStatus()) |
|
|
|
&& ExpertReviewResultEnum.PASS.eq(w.getReviewResult()); |
|
|
|
})) { |
|
|
|
throw ReturnException.wrap("所选项目包含已评审通过的项目"); |
|
|
|
List<String> deletedProjectCodes = linkedProjList.stream().filter(w -> { |
|
|
|
boolean deleted = !projectCodes.remove(w.getProjectCode()); |
|
|
|
if (deleted && w.getReviewResult() != null) { |
|
|
|
throw ReturnException.wrap("已上传评审结果的项目不可移除"); |
|
|
|
} |
|
|
|
return deleted; |
|
|
|
}).map(MeetingInnerProject::getProjectCode).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<String> changeProjectCodes = new ArrayList<>(); |
|
|
|
changeProjectCodes.addAll(projectCodes); |
|
|
|
changeProjectCodes.addAll(deletedProjectCodes); |
|
|
|
List<Project> projects = projectService.listNewestByProjectCodes(changeProjectCodes); |
|
|
|
// 校验项目状态 |
|
|
|
for (Project project : projects) { |
|
|
|
if (deletedProjectCodes.contains(project.getProjectCode())) { |
|
|
|
if (!ProjectStatus.ON_EXPERT_REVIEW.eq(project.getStatus())) { |
|
|
|
throw ReturnException.wrap("仅专家评审中的项目可以移除"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (!ProjectStatus.WITHOUT_EXPERT_REVIEW.eq(project.getStatus())) { |
|
|
|
throw ReturnException.wrap("仅待专家评审的项目可以关联"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
List<Project> projects = projectService.listNewestByProjectCodes(projectCodes); |
|
|
|
if (CollUtil.anyMatch(projects, w -> !ProjectStatus.WITHOUT_EXPERT_REVIEW.eq(w.getStatus()))) { |
|
|
|
throw ReturnException.wrap("所选项目必须为待专家评审状态"); |
|
|
|
} |
|
|
|
List<MeetingInnerProject> mips = CollUtils.convert(projects, w -> { |
|
|
|
projectStateMachineUtil.pass(w); |
|
|
|
MeetingInnerProject mip = new MeetingInnerProject(); |
|
|
|
mip.setProjectId(w.getId()); |
|
|
|
mip.setMeetingId(req.getMeetingId()); |
|
|
|
mip.setProjectCode(w.getProjectCode()); |
|
|
|
return mip; |
|
|
|
}); |
|
|
|
projectService.updateBatchById(projects); |
|
|
|
meetingInnerProjectService.saveBatch(mips); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public synchronized void removeProject(MeetingAppendProjectReq req) { |
|
|
|
Meeting meeting = meetingService.getById(req.getMeetingId()); |
|
|
|
Assert.notNull(meeting, "会议不存在"); |
|
|
|
Assert.isTrue(MeetingStatusEnum.NORMAL.eq(meeting.getStatus()), "当前会议无法移除项目"); |
|
|
|
List<String> projectCodes = CollUtils.convert(req.getProjectIds(), ProjectIdCodeCacheUtil::get); |
|
|
|
Wrapper<MeetingInnerProject> query = Wrappers.lambdaQuery(MeetingInnerProject.class) |
|
|
|
.select(MeetingInnerProject::getId, MeetingInnerProject::getProjectCode, MeetingInnerProject::getReviewResult) |
|
|
|
.in(MeetingInnerProject::getProjectCode, projectCodes) |
|
|
|
.eq(MeetingInnerProject::getMeetingId, meeting.getId()); |
|
|
|
List<MeetingInnerProject> linkedProjList = meetingInnerProjectService.list(query); |
|
|
|
if (projectCodes.size() != linkedProjList.size()) { |
|
|
|
throw ReturnException.wrap("所选项目与当前会议未关联"); |
|
|
|
Map<Boolean, List<Project>> changeProjectMap = CollUtils.group(projects, |
|
|
|
w -> projectCodes.contains(w.getProjectCode())); |
|
|
|
List<Project> newLinkedProjList = changeProjectMap.get(Boolean.TRUE); |
|
|
|
if (CollUtil.isNotEmpty(newLinkedProjList)) { |
|
|
|
List<MeetingInnerProject> mips = CollUtils.convert(projects, w -> { |
|
|
|
projectStateMachineUtil.pass(w); |
|
|
|
MeetingInnerProject mip = new MeetingInnerProject(); |
|
|
|
mip.setProjectId(w.getId()); |
|
|
|
mip.setMeetingId(req.getMeetingId()); |
|
|
|
mip.setProjectCode(w.getProjectCode()); |
|
|
|
return mip; |
|
|
|
}); |
|
|
|
meetingInnerProjectService.saveBatch(mips); |
|
|
|
} |
|
|
|
if (CollUtil.anyMatch(linkedProjList, w -> w.getReviewResult() != null)) { |
|
|
|
throw ReturnException.wrap("已上传评审结果的项目不能移除"); |
|
|
|
// |
|
|
|
List<Project> delLinkedProjList = changeProjectMap.get(Boolean.FALSE); |
|
|
|
if (CollUtil.isNotEmpty(delLinkedProjList)) { |
|
|
|
meetingInnerProjectService.remove(Wrappers.lambdaQuery(MeetingInnerProject.class) |
|
|
|
.in(MeetingInnerProject::getProjectCode, deletedProjectCodes) |
|
|
|
.eq(MeetingInnerProject::getMeetingId, meeting.getId())); |
|
|
|
delLinkedProjList.forEach(projectStateMachineUtil::withDraw); |
|
|
|
} |
|
|
|
Set<Long> mipIds = CollUtils.fieldSet(linkedProjList, MeetingInnerProject::getId); |
|
|
|
meetingInnerProjectService.removeByIds(mipIds); |
|
|
|
List<Project> projects = projectService.listNewestByProjectCodes(projectCodes); |
|
|
|
projects.forEach(projectStateMachineUtil::withDraw); |
|
|
|
projectService.updateBatchById(projects); |
|
|
|
} |
|
|
|
|
|
|
|