From 0f250512f4b52aee30473fdcfe28d6feb1b650ba Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 19 Apr 2023 20:40:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9F=A5=E7=9C=8B=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=89=80=E6=9C=89=E8=AF=84=E5=AE=A1=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../expert/controller/ExpertReviewController.java | 10 ++++ .../pmapi/expert/manage/ExpertReviewManage.java | 64 ++++++++++++++++++++-- .../manage/ReviewTemplateSettingsManage.java | 4 +- .../expert/model/vo/ProjectReviewDetailVO.java | 40 ++++++++++++++ .../service/IMeetingInnerProjectService.java | 9 +++ .../impl/MeetingInnerProjectServiceImpl.java | 10 ++++ 6 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/expert/model/vo/ProjectReviewDetailVO.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertReviewController.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertReviewController.java index ac8ce50..b4718f4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertReviewController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertReviewController.java @@ -5,6 +5,7 @@ import com.ningdatech.log.annotation.WebLog; import com.ningdatech.pmapi.expert.manage.ExpertReviewManage; import com.ningdatech.pmapi.expert.model.req.ExpertReviewDetailReq; import com.ningdatech.pmapi.expert.model.vo.ExpertReviewDetailVO; +import com.ningdatech.pmapi.expert.model.vo.ProjectReviewDetailVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -72,4 +73,13 @@ public class ExpertReviewController { return expertReviewManage.listReviews(projectId, meetingId, false); } + @GetMapping("/detail/{projectId}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "projectId", value = "项目ID"), + }) + @ApiOperation("查看项目的所有评审意见") + public ProjectReviewDetailVO projectExpertReviewDetail(@PathVariable Long projectId) { + return expertReviewManage.projectExpertReviewDetail(projectId); + } + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertReviewManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertReviewManage.java index c92e278..f05220b 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertReviewManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertReviewManage.java @@ -10,19 +10,25 @@ import com.ningdatech.file.entity.vo.result.AttachFileVo; import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.expert.model.dto.ReviewTemplateOptionDTO; import com.ningdatech.pmapi.expert.model.entity.ExpertReview; +import com.ningdatech.pmapi.expert.model.entity.ReviewTemplateSettings; import com.ningdatech.pmapi.expert.model.req.ExpertReviewDetailReq; import com.ningdatech.pmapi.expert.model.vo.ExpertReviewDetailVO; +import com.ningdatech.pmapi.expert.model.vo.ProjectReviewDetailVO; +import com.ningdatech.pmapi.expert.model.vo.ReviewTemplateVO; import com.ningdatech.pmapi.expert.service.IExpertReviewService; +import com.ningdatech.pmapi.expert.service.IReviewTemplateSettingsService; +import com.ningdatech.pmapi.meeting.entity.domain.Meeting; import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; +import com.ningdatech.pmapi.meeting.service.IMeetingInnerProjectService; +import com.ningdatech.pmapi.meeting.service.IMeetingService; import com.ningdatech.pmapi.user.util.LoginUserUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; +import static com.ningdatech.pmapi.expert.model.vo.ProjectReviewDetailVO.ReviewDetailByTypeVO; import static com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum.AGREED; /** @@ -41,6 +47,9 @@ public class ExpertReviewManage { private final DistributedLock distributedLock; private final IMeetingExpertService meetingExpertService; private final FileService fileService; + private final IMeetingInnerProjectService meetingInnerProjectService; + private final IMeetingService meetingService; + private final IReviewTemplateSettingsService templateSettingsService; private static final String EXPERT_REVIEW_KEY = "expert_review:"; @@ -142,4 +151,51 @@ public class ExpertReviewManage { }); } + public ProjectReviewDetailVO projectExpertReviewDetail(Long projectId) { + ProjectReviewDetailVO detail = new ProjectReviewDetailVO(); + List meetingIds = meetingInnerProjectService.listMeetingIdByProjectId(projectId); + if (meetingIds.isEmpty()) { + return detail; + } + List meetings = meetingService.listByIds(meetingIds); + Collection tmpMeetingIds = meetings.stream() + .collect(Collectors.groupingBy(Meeting::getType, + Collectors.collectingAndThen(Collectors.toList(), w -> { + w.sort(Comparator.comparing(Meeting::getCreateOn)); + return w.get(w.size() - 1).getId(); + }))).values(); + LambdaQueryWrapper erQuery = Wrappers.lambdaQuery(ExpertReview.class) + .in(ExpertReview::getMeetingId, tmpMeetingIds) + .eq(ExpertReview::getProjectId, projectId) + .orderByDesc(ExpertReview::getCreateOn); + List expertReviews = expertReviewService.list(erQuery); + if (expertReviews.isEmpty()) { + return detail; + } + List templateIds = CollUtils.fieldList(expertReviews, ExpertReview::getTemplateId); + List templates = templateSettingsService.listByIds(templateIds); + Map templateMap = CollUtils.listToMap(templates, + ReviewTemplateSettings::getId, + ReviewTemplateSettingsManage::buildTemplateDetail); + detail.setTemplates(templateMap.values()); + Map map = new HashMap<>(8); + expertReviews.forEach(review -> { + ReviewTemplateVO template = templateMap.get(review.getTemplateId()); + ReviewDetailByTypeVO reviewDetailByType = map.computeIfAbsent(template.getTemplateType(), k -> { + ReviewDetailByTypeVO tmpReviewDetail = new ReviewDetailByTypeVO(); + tmpReviewDetail.setReviewType(k); + tmpReviewDetail.setTeamMemberReviews(new ArrayList<>()); + return tmpReviewDetail; + }); + ExpertReviewDetailVO tmpReview = buildExpertReviewDetail(review); + if (review.getIsFinal()) { + reviewDetailByType.setFinalReview(tmpReview); + } else { + reviewDetailByType.getTeamMemberReviews().add(tmpReview); + } + }); + detail.setReviews(map.values()); + return detail; + } + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ReviewTemplateSettingsManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ReviewTemplateSettingsManage.java index c81ca99..8341463 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ReviewTemplateSettingsManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ReviewTemplateSettingsManage.java @@ -67,10 +67,10 @@ public class ReviewTemplateSettingsManage { public List listReviewTemplateSettings(List templateIds) { List settings = reviewTemplateSettingsService.listByIds(templateIds); - return CollUtils.convert(settings, this::buildTemplateDetail); + return CollUtils.convert(settings, ReviewTemplateSettingsManage::buildTemplateDetail); } - private ReviewTemplateVO buildTemplateDetail(ReviewTemplateSettings settings) { + protected static ReviewTemplateVO buildTemplateDetail(ReviewTemplateSettings settings) { if (settings == null) { throw BizException.wrap("模版不存在"); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/vo/ProjectReviewDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/vo/ProjectReviewDetailVO.java new file mode 100644 index 0000000..8bb3919 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/vo/ProjectReviewDetailVO.java @@ -0,0 +1,40 @@ +package com.ningdatech.pmapi.expert.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Collection; +import java.util.List; + +/** + *

+ * ProjectExpertReviewDetailVO + *

+ * + * @author WendyYang + * @since 2023/4/19 + **/ +@Data +public class ProjectReviewDetailVO { + + @ApiModelProperty("评审模版详情") + private Collection templates; + + private Collection reviews; + + @Data + public static class ReviewDetailByTypeVO { + + @ApiModelProperty("评审类型") + private Integer reviewType; + + @ApiModelProperty("最终评审意见") + private ExpertReviewDetailVO finalReview; + + @ApiModelProperty("组员评审意见") + private List teamMemberReviews; + + } + + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IMeetingInnerProjectService.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IMeetingInnerProjectService.java index 668f765..1b565af 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IMeetingInnerProjectService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IMeetingInnerProjectService.java @@ -24,4 +24,13 @@ public interface IMeetingInnerProjectService extends IService listByMeetingId(Long meetingId); + /** + * 查询项目关联的所有会议 + * + * @param projectId 会议ID + * @return 项目关联的会议ID + * @author WendyYang + **/ + List listMeetingIdByProjectId(Long projectId); + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingInnerProjectServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingInnerProjectServiceImpl.java index d3e1053..60bae26 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingInnerProjectServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingInnerProjectServiceImpl.java @@ -1,7 +1,9 @@ package com.ningdatech.pmapi.meeting.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.basic.util.CollUtils; import com.ningdatech.pmapi.meeting.entity.domain.MeetingInnerProject; import com.ningdatech.pmapi.meeting.mapper.MeetingInnerProjectMapper; import com.ningdatech.pmapi.meeting.service.IMeetingInnerProjectService; @@ -26,4 +28,12 @@ public class MeetingInnerProjectServiceImpl extends ServiceImpl listMeetingIdByProjectId(Long projectId) { + LambdaQueryWrapper query = Wrappers + .lambdaQuery(MeetingInnerProject.class) + .eq(MeetingInnerProject::getProjectId, projectId); + return CollUtils.fieldList(list(query), MeetingInnerProject::getMeetingId); + } + }