@@ -24,6 +24,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; | |||
"com.ningdatech.pmapi.sys.controller", | |||
"com.ningdatech.pmapi.todocenter.controller", | |||
"com.ningdatech.pmapi.user.controller", | |||
"com.ningdatech.pmapi.expert.controller" | |||
}) | |||
public class GlobalResponseHandler implements ResponseBodyAdvice<Object> { | |||
@@ -4,15 +4,16 @@ package com.ningdatech.pmapi.expert.controller; | |||
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 io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiImplicitParam; | |||
import io.swagger.annotations.ApiImplicitParams; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.AllArgsConstructor; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import org.springframework.web.bind.annotation.*; | |||
import javax.validation.Valid; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
@@ -37,4 +38,24 @@ public class ExpertReviewController { | |||
expertReviewManage.expertReview(req); | |||
} | |||
@GetMapping("/detail/{projectId}/{userId}") | |||
@ApiOperation("获取专家评审详情") | |||
@ApiImplicitParams({ | |||
@ApiImplicitParam(name = "userId", value = "专家ID"), | |||
@ApiImplicitParam(name = "projectId", value = "项目ID") | |||
}) | |||
public ExpertReviewDetailVO getExpertReviewDetail(@PathVariable Long userId, @PathVariable Long projectId) { | |||
return expertReviewManage.getExpertReviewDetail(userId, projectId); | |||
} | |||
@GetMapping("/listForGroupLeader/{projectId}/{userId}") | |||
@ApiImplicitParams({ | |||
@ApiImplicitParam(name = "userId", value = "专家ID"), | |||
@ApiImplicitParam(name = "projectId", value = "项目ID") | |||
}) | |||
@ApiOperation("查看组员评审意见") | |||
public List<ExpertReviewDetailVO> listForGroupLeader(@PathVariable Long userId, @PathVariable Long projectId) { | |||
return expertReviewManage.listForGroupLeader(projectId, userId); | |||
} | |||
} |
@@ -1,10 +1,15 @@ | |||
package com.ningdatech.pmapi.expert.manage; | |||
import cn.hutool.json.JSONUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.cache.lock.DistributedLock; | |||
import com.ningdatech.pmapi.expert.model.dto.ReviewTemplateOptionDTO; | |||
import com.ningdatech.pmapi.expert.model.entity.ExpertReview; | |||
import com.ningdatech.pmapi.expert.model.req.ExpertReviewDetailReq; | |||
import com.ningdatech.pmapi.expert.model.vo.ExpertReviewDetailVO; | |||
import com.ningdatech.pmapi.expert.service.IExpertReviewService; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import lombok.RequiredArgsConstructor; | |||
@@ -33,6 +38,20 @@ public class ExpertReviewManage { | |||
return EXPERT_REVIEW_KEY + projectId + ":" + expertId; | |||
} | |||
private ExpertReviewDetailVO buildExpertReviewDetail(ExpertReview review) { | |||
return ExpertReviewDetailVO.builder() | |||
.reviewResult(review.getReviewResult()) | |||
.creator(review.getCreator()) | |||
.projectId(review.getProjectId()) | |||
.templateId(review.getTemplateId()) | |||
.otherAdvice(review.getOtherAdvice()) | |||
.isFinal(review.getIsFinal()) | |||
.createOn(review.getCreateOn()) | |||
.attachFileId(review.getAttachFileId()) | |||
.reviewTemplateOptions(JSONUtil.toList(review.getContent(), ReviewTemplateOptionDTO.class)) | |||
.build(); | |||
} | |||
public void expertReview(ExpertReviewDetailReq req) { | |||
Long userId = LoginUserUtil.getUserId(); | |||
Long projectId = req.getProjectId(); | |||
@@ -60,7 +79,7 @@ public class ExpertReviewManage { | |||
review.setContent(JSONUtil.toJsonStr(req.getReviewTemplateOptions())); | |||
review.setProjectId(req.getProjectId()); | |||
review.setTemplateId(req.getTemplateId()); | |||
review.setAdvice(req.getOtherAdvice()); | |||
review.setOtherAdvice(req.getOtherAdvice()); | |||
review.setAttachFileId(req.getAttachFileId()); | |||
review.setIsFinal(req.getIsFinal()); | |||
review.setCreator(LoginUserUtil.getUsername()); | |||
@@ -70,4 +89,22 @@ public class ExpertReviewManage { | |||
} | |||
} | |||
public ExpertReviewDetailVO getExpertReviewDetail(Long projectId, Long userId) { | |||
List<ExpertReview> reviews = expertReviewService.listByProjectIdAndExpertId(projectId, userId); | |||
reviews.removeIf(ExpertReview::getIsFinal); | |||
if (reviews.isEmpty()) { | |||
throw BizException.wrap("评审记录不存在"); | |||
} | |||
return buildExpertReviewDetail(reviews.get(0)); | |||
} | |||
public List<ExpertReviewDetailVO> listForGroupLeader(Long projectId, Long userId) { | |||
LambdaQueryWrapper<ExpertReview> query = Wrappers.lambdaQuery(ExpertReview.class); | |||
query.eq(ExpertReview::getProjectId, projectId); | |||
query.ne(ExpertReview::getCreateBy, userId); | |||
query.orderByDesc(ExpertReview::getCreateOn); | |||
List<ExpertReview> reviews = expertReviewService.list(query); | |||
return CollUtils.convert(reviews, this::buildExpertReviewDetail); | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
package com.ningdatech.pmapi.expert.model.dto; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.experimental.Tolerate; | |||
import javax.validation.constraints.NotEmpty; | |||
import javax.validation.constraints.NotNull; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* ReviewTemplateOptionVO | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 16:12 2023/2/15 | |||
*/ | |||
@Data | |||
@Builder | |||
public class ReviewTemplateOptionDTO { | |||
@Tolerate | |||
public ReviewTemplateOptionDTO() { | |||
} | |||
@ApiModelProperty("问题序号") | |||
@NotNull(message = "问题序号不能为空") | |||
private Integer questionSerialNo; | |||
@ApiModelProperty("选项序号") | |||
@NotEmpty(message = "选项序号不能为空") | |||
private List<Integer> optionSerialNo; | |||
@ApiModelProperty("其他意见或建议") | |||
private String otherAdvice; | |||
} |
@@ -37,7 +37,7 @@ public class ExpertReview implements Serializable { | |||
private String content; | |||
@ApiModelProperty("意见或建议") | |||
private String advice; | |||
private String otherAdvice; | |||
@ApiModelProperty("附件ID") | |||
private Long attachFileId; | |||
@@ -1,5 +1,6 @@ | |||
package com.ningdatech.pmapi.expert.model.req; | |||
import com.ningdatech.pmapi.expert.model.dto.ReviewTemplateOptionDTO; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
@@ -30,7 +31,7 @@ public class ExpertReviewDetailReq { | |||
@Valid | |||
@ApiModelProperty("配置模版") | |||
@NotEmpty(message = "配置不能为空") | |||
private List<ReviewTemplateOptionVO> reviewTemplateOptions; | |||
private List<ReviewTemplateOptionDTO> reviewTemplateOptions; | |||
@ApiModelProperty("其他意见或建议") | |||
@NotEmpty(message = "其他意见或建议不能为空") | |||
@@ -47,21 +48,4 @@ public class ExpertReviewDetailReq { | |||
@NotNull(message = "是否是最终意见不能为空") | |||
private Boolean isFinal; | |||
@Data | |||
public static class ReviewTemplateOptionVO { | |||
@ApiModelProperty("问题序号") | |||
@NotNull(message = "问题序号不能为空") | |||
private Integer questionSerialNo; | |||
@ApiModelProperty("选项序号") | |||
@NotEmpty(message = "选项序号不能为空") | |||
private List<Integer> optionSerialNo; | |||
@ApiModelProperty("其他意见或建议") | |||
private String otherAdvice; | |||
} | |||
} |
@@ -0,0 +1,55 @@ | |||
package com.ningdatech.pmapi.expert.model.vo; | |||
import com.ningdatech.pmapi.expert.model.dto.ReviewTemplateOptionDTO; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.experimental.Tolerate; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* ExpertReviewDetailVO | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 14:37 2023/2/15 | |||
*/ | |||
@Data | |||
@Builder | |||
public class ExpertReviewDetailVO { | |||
@Tolerate | |||
public ExpertReviewDetailVO() { | |||
} | |||
@ApiModelProperty("模版ID") | |||
private Long templateId; | |||
@ApiModelProperty("项目ID") | |||
private Long projectId; | |||
@ApiModelProperty("配置模版") | |||
private List<ReviewTemplateOptionDTO> reviewTemplateOptions; | |||
@ApiModelProperty("其他意见或建议") | |||
private String otherAdvice; | |||
@ApiModelProperty("附件ID") | |||
private Long attachFileId; | |||
@ApiModelProperty("评审结果:1 通过、2 需复核、3 不通过") | |||
private Integer reviewResult; | |||
@ApiModelProperty("是否是最终意见") | |||
private Boolean isFinal; | |||
@ApiModelProperty("评审时间") | |||
private LocalDateTime createOn; | |||
@ApiModelProperty("专家名称") | |||
private String creator; | |||
} |