Browse Source

20201229查询试题返回是否回显

sd
zy_Java 5 years ago
parent
commit
6e534f49ab
  1. 12
      ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java
  2. 3
      ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java
  3. 36
      ht/src/main/java/com/ccsens/ht/service/QuestionService.java
  4. 4
      ht/src/main/resources/application.yml
  5. 19
      ht/src/main/resources/mapper_dao/HtQuestionDao.xml

12
ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java

@ -141,6 +141,8 @@ public class QuestionVo {
private String path; private String path;
@ApiModelProperty("共享答案的试题Id") @ApiModelProperty("共享答案的试题Id")
private List<Long> shareAnswerIds; private List<Long> shareAnswerIds;
@ApiModelProperty("是否展示关联的试题的答案 0否 1是")
private byte showShareAnswer;
@ApiModelProperty("关联试题") @ApiModelProperty("关联试题")
List<QuestionOption> relationQuestions = new ArrayList<>(); List<QuestionOption> 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 @Data
@ApiModel("QuestionVoOptionOptionJson") @ApiModel("QuestionVoOptionOptionJson")
public static class OptionJson { public static class OptionJson {

3
ht/src/main/java/com/ccsens/ht/persist/dao/HtQuestionDao.java

@ -1,6 +1,7 @@
package com.ccsens.ht.persist.dao; package com.ccsens.ht.persist.dao;
import com.ccsens.ht.bean.po.HtQuestion; import com.ccsens.ht.bean.po.HtQuestion;
import com.ccsens.ht.bean.vo.QuestionVo;
import com.ccsens.ht.persist.mapper.HtQuestionMapper; import com.ccsens.ht.persist.mapper.HtQuestionMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -26,5 +27,5 @@ public interface HtQuestionDao extends HtQuestionMapper {
/** /**
* 查询可以共享答案的试题id * 查询可以共享答案的试题id
*/ */
List<Long> queryShareAnswer(@Param("id") Long id); List<QuestionVo.ShareAnswer> queryShareAnswer(@Param("questionId")Long questionId, @Param("patientReportId") Long patientReportId);
} }

36
ht/src/main/java/com/ccsens/ht/service/QuestionService.java

@ -84,12 +84,38 @@ public class QuestionService implements IQuestionService {
} }
HtQuestion question = questionList.get(0); HtQuestion question = questionList.get(0);
QuestionVo.Question questionVo = QuestionVo.Question.toQuestionVo(question); 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<QuestionVo.Option> optionList = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId());
//查询可以共享答案的试题的id //查询可以共享答案的试题的id
List<Long> shareAnswerIds = htQuestionDao.queryShareAnswer(question.getId()); List<Long> shareAnswerIds = new ArrayList<>();
log.info("答案关联的试题id:{}", questionVo); List<QuestionVo.ShareAnswer> 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); questionVo.setShareAnswerIds(shareAnswerIds);
log.info("试题:{}", questionVo); log.info("试题:{}", questionVo);
//获取评测信息 //获取评测信息
HtReportExample reportExample = new HtReportExample(); HtReportExample reportExample = new HtReportExample();
reportExample.createCriteria().andCodeEqualTo(question.getEvaluationCode()); reportExample.createCriteria().andCodeEqualTo(question.getEvaluationCode());
@ -129,8 +155,8 @@ public class QuestionService implements IQuestionService {
introduceExample.setOrderByClause("sort"); introduceExample.setOrderByClause("sort");
List<HtQuestionIntroducer> introduces = htQuestionIntroducerDao.selectByExample(introduceExample); List<HtQuestionIntroducer> introduces = htQuestionIntroducerDao.selectByExample(introduceExample);
List<QuestionVo.Introduce> introduceVos = QuestionVo.Introduce.toIntroduces(introduces); List<QuestionVo.Introduce> introduceVos = QuestionVo.Introduce.toIntroduces(introduces);
//试题选项 // //试题选项
List<QuestionVo.Option> options = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId()); // List<QuestionVo.Option> options = htQuestionOptionDao.queryOption(question.getId(), query.getPatientReportId());
//答题记录 //答题记录
List<QuestionVo.Record> recordVos; List<QuestionVo.Record> 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); data.setReport(reportVo);
log.info("试题信息:{}", data); log.info("试题信息:{}", data);
return data; return data;

4
ht/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring: spring:
profiles: profiles:
active: prod active: test
include: common, util-prod include: common, util-test

19
ht/src/main/resources/mapper_dao/HtQuestionDao.xml

@ -47,12 +47,17 @@
from t_ht_question from t_ht_question
where evaluation_code = #{code, jdbcType=VARCHAR} where evaluation_code = #{code, jdbcType=VARCHAR}
</select> </select>
<select id="queryShareAnswer" resultType="java.lang.Long"> <select id="queryShareAnswer" resultType="com.ccsens.ht.bean.vo.QuestionVo$ShareAnswer">
SELECT SELECT
relevance_id r.relevance_id as shareAnswerId,
FROM if(count(s.id) = 0, false,true) as showShareAnswer
t_ht_question_relevance FROM
WHERE t_ht_question_relevance r
question_id = #{id} 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
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save