11 changed files with 326 additions and 32 deletions
@ -0,0 +1,19 @@ |
|||||
|
package com.ccsens.tcm.service; |
||||
|
|
||||
|
import com.ccsens.tcm.bean.dto.QuestionDto; |
||||
|
import com.ccsens.tcm.bean.vo.QuestionVo; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author 逗 |
||||
|
*/ |
||||
|
public interface IQuestionService { |
||||
|
/** |
||||
|
* 查询患者的试题和答题记录 |
||||
|
* @param param 类型和采集次数 |
||||
|
* @return |
||||
|
*/ |
||||
|
List<QuestionVo.PatientCode> getQuestionAndAnswer(QuestionDto.QueryQuestionAndAnswer param); |
||||
|
|
||||
|
} |
@ -0,0 +1,71 @@ |
|||||
|
package com.ccsens.tcm.service; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollectionUtil; |
||||
|
import com.ccsens.tcm.bean.dto.QuestionDto; |
||||
|
import com.ccsens.tcm.bean.po.QuestionOption; |
||||
|
import com.ccsens.tcm.bean.vo.QuestionVo; |
||||
|
import com.ccsens.tcm.persist.dao.QuestionDao; |
||||
|
import com.ccsens.tcm.persist.dao.ReportCodeDao; |
||||
|
import com.ccsens.util.RedisUtil; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Propagation; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
||||
|
public class QuestionService implements IQuestionService{ |
||||
|
@Resource |
||||
|
private RedisUtil redisUtil; |
||||
|
@Resource |
||||
|
private ReportCodeDao reportCodeDao; |
||||
|
@Resource |
||||
|
private QuestionDao questionDao; |
||||
|
|
||||
|
@Override |
||||
|
public List<QuestionVo.PatientCode> getQuestionAndAnswer(QuestionDto.QueryQuestionAndAnswer param) { |
||||
|
List<QuestionVo.PatientCode> patientCodeList = reportCodeDao.selectCodeByCode(param.getCode()); |
||||
|
if(CollectionUtil.isNotEmpty(patientCodeList)){ |
||||
|
patientCodeList.forEach(patientCode -> { |
||||
|
//查找此类型下的所有试题及该用户的答题信息
|
||||
|
List<QuestionVo.PatientQuestionNum> patientQuestionNumList = questionDao.getQuestionByCodeAndPatientId(patientCode.getCode(),param.getId(),param.getNums()); |
||||
|
if(CollectionUtil.isNotEmpty(patientQuestionNumList)){ |
||||
|
patientQuestionNumList.forEach(patientQuestionNum -> { |
||||
|
if(CollectionUtil.isNotEmpty(patientQuestionNum.getQuestionList())){ |
||||
|
patientQuestionNum.getQuestionList().forEach(question -> { |
||||
|
if(CollectionUtil.isNotEmpty(question.getOptionVos())){ |
||||
|
question.getOptionVos().forEach(patientOption -> { |
||||
|
patientOption.setQuestionVos(questionDao.getQuestionByOptionId(patientOption.getId(),param.getId(),param.getNums())); |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
patientCode.setQuestionNums(patientQuestionNumList); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
// if(CollectionUtil.isNotEmpty(patientCodes)){
|
||||
|
// patientCodes.forEach(patientCode -> {
|
||||
|
// //查询类型下的题目和患者的答案
|
||||
|
// List<QuestionVo.PatientQuestion> patientQuestionList = getPatientQuestionByCode(patientCode.getCode(),param.getId());
|
||||
|
// reportCodeVo.setQuestionVos(questionVos);
|
||||
|
// //查询子类型下的题目
|
||||
|
// if(CollectionUtil.isNotEmpty(reportCodeVo.getSubReportCodes())){
|
||||
|
// reportCodeVo.getSubReportCodes().forEach(subReportCode -> {
|
||||
|
// List<QuestionVo.CodeQuestionVo> subCodeQuestionVos = getQuestionByCode(subReportCode.getCode());
|
||||
|
// subReportCode.setQuestionVos(subCodeQuestionVos);
|
||||
|
// });
|
||||
|
// }
|
||||
|
// });
|
||||
|
// }
|
||||
|
|
||||
|
return patientCodeList; |
||||
|
} |
||||
|
|
||||
|
} |
@ -1,5 +1,5 @@ |
|||||
spring: |
spring: |
||||
profiles: |
profiles: |
||||
active: test |
active: dev |
||||
include: common, util-test |
include: common, util-dev |
||||
|
|
||||
|
Loading…
Reference in new issue