From 6e534f49ab889452152afc2a0c51f477a9a80edb Mon Sep 17 00:00:00 2001 From: zy_Java <654600784@qq.com> Date: Tue, 29 Dec 2020 18:40:49 +0800 Subject: [PATCH] =?UTF-8?q?20201229=E6=9F=A5=E8=AF=A2=E8=AF=95=E9=A2=98?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=98=AF=E5=90=A6=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ccsens/ht/bean/vo/QuestionVo.java | 12 +++++++ .../ccsens/ht/persist/dao/HtQuestionDao.java | 3 +- .../ccsens/ht/service/QuestionService.java | 36 ++++++++++++++++--- ht/src/main/resources/application.yml | 4 +-- .../resources/mapper_dao/HtQuestionDao.xml | 19 ++++++---- 5 files changed, 59 insertions(+), 15 deletions(-) diff --git a/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java b/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java index d64d1d65..323af41e 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java +++ b/ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java @@ -141,6 +141,8 @@ public class QuestionVo { private String path; @ApiModelProperty("共享答案的试题Id") private List shareAnswerIds; + @ApiModelProperty("是否展示关联的试题的答案 0否 1是") + private byte showShareAnswer; @ApiModelProperty("关联试题") List relationQuestions = new ArrayList<>(); @@ -174,6 +176,16 @@ public class QuestionVo { } } + + @Data + @ApiModel("(可以共享答案的试题)关联的试题id") + public static class ShareAnswer{ + @ApiModelProperty("关联试题的id") + private Long shareAnswerId; + @ApiModelProperty("是否展示关联试题的答案") + private byte showShareAnswer; + } + @Data @ApiModel("QuestionVoOptionOptionJson") public static class OptionJson { diff --git a/ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java b/ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java index b4289a8a..400b2231 100644 --- a/ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java +++ b/ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java @@ -1,6 +1,7 @@ package com.ccsens.ht.persist.dao; import com.ccsens.ht.bean.po.HtQuestion; +import com.ccsens.ht.bean.vo.QuestionVo; import com.ccsens.ht.persist.mapper.HtQuestionMapper; import org.apache.ibatis.annotations.Param; @@ -26,5 +27,5 @@ public interface HtQuestionDao extends HtQuestionMapper { /** * 查询可以共享答案的试题id */ - List queryShareAnswer(@Param("id") Long id); + List queryShareAnswer(@Param("questionId")Long questionId, @Param("patientReportId") Long patientReportId); } diff --git a/ht/src/main/java/com/ccsens/ht/service/QuestionService.java b/ht/src/main/java/com/ccsens/ht/service/QuestionService.java index 3bfe2796..d4c629b8 100644 --- a/ht/src/main/java/com/ccsens/ht/service/QuestionService.java +++ b/ht/src/main/java/com/ccsens/ht/service/QuestionService.java @@ -84,12 +84,38 @@ public class QuestionService implements IQuestionService { } HtQuestion question = questionList.get(0); QuestionVo.Question questionVo = QuestionVo.Question.toQuestionVo(question); + //检查当前试题是否有答案,共享答案的试题是否有答案 + boolean f = false; + HtPatientScoreExample scoreExample = new HtPatientScoreExample(); + scoreExample.createCriteria().andPatientIdEqualTo(query.getPatientReportId()).andQuestionIdEqualTo(question.getId()); + if(htPatientScoreDao.countByExample(scoreExample) > 0){ + f = true; + questionVo.setShowShareAnswer((byte) 0); + } + //试题选项 + List optionList = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId()); + //查询可以共享答案的试题的id - List shareAnswerIds = htQuestionDao.queryShareAnswer(question.getId()); - log.info("答案关联的试题id:{}", questionVo); + List shareAnswerIds = new ArrayList<>(); + List shareAnswers = htQuestionDao.queryShareAnswer(question.getId(),query.getPatientReportId()); + log.info("答案关联的试题id:{}", shareAnswers); + if(CollectionUtil.isNotEmpty(shareAnswers)){ + for(QuestionVo.ShareAnswer shareAnswer : shareAnswers){ + shareAnswerIds.add(shareAnswer.getShareAnswerId()); + if(!f){ + if(shareAnswer.getShowShareAnswer() == 1){ + questionVo.setShowShareAnswer(shareAnswer.getShowShareAnswer()); + optionList = htQuestionOptionDao.queryOption(shareAnswer.getShareAnswerId(), query.getPatientReportId()); + } + } + } + } + questionVo.setShareAnswerIds(shareAnswerIds); log.info("试题:{}", questionVo); + + //获取评测信息 HtReportExample reportExample = new HtReportExample(); reportExample.createCriteria().andCodeEqualTo(question.getEvaluationCode()); @@ -129,8 +155,8 @@ public class QuestionService implements IQuestionService { introduceExample.setOrderByClause("sort"); List introduces = htQuestionIntroducerDao.selectByExample(introduceExample); List introduceVos = QuestionVo.Introduce.toIntroduces(introduces); - //试题选项 - List options = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId()); +// //试题选项 +// List options = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId()); //答题记录 List recordVos; @@ -145,7 +171,7 @@ public class QuestionService implements IQuestionService { } //封装返回 - QuestionVo.Query data = new QuestionVo.Query(questionVo, options, introduceVos, recordVos,maxSort); + QuestionVo.Query data = new QuestionVo.Query(questionVo, optionList, introduceVos, recordVos,maxSort); data.setReport(reportVo); log.info("试题信息:{}", data); return data; diff --git a/ht/src/main/resources/application.yml b/ht/src/main/resources/application.yml index d082c0ea..5889ff7f 100644 --- a/ht/src/main/resources/application.yml +++ b/ht/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: prod - include: common, util-prod \ No newline at end of file + active: test + include: common, util-test \ No newline at end of file diff --git a/ht/src/main/resources/mapper_dao/HtQuestionDao.xml b/ht/src/main/resources/mapper_dao/HtQuestionDao.xml index 3c17c8a3..52cde333 100644 --- a/ht/src/main/resources/mapper_dao/HtQuestionDao.xml +++ b/ht/src/main/resources/mapper_dao/HtQuestionDao.xml @@ -47,12 +47,17 @@ from t_ht_question where evaluation_code = #{code, jdbcType=VARCHAR} - + SELECT + r.relevance_id as shareAnswerId, + if(count(s.id) = 0, false,true) as showShareAnswer + FROM + t_ht_question_relevance r + LEFT JOIN + (SELECT * FROM t_ht_patient_score WHERE patient_report_id = #{patientReportId} and is_del = 0) s + on r.relevance_id = s.question_id + WHERE + r.question_id = #{questionId} + GROUP BY r.relevance_id \ No newline at end of file