From e81ec538655b1e456675cae92d92464fafa420d4 Mon Sep 17 00:00:00 2001
From: wang0018 <1007152140@qq.com>
Date: Mon, 8 Mar 2021 10:25:17 +0800
Subject: [PATCH 1/2] tijiao
---
.../com/ccsens/tcm/service/PatientService.java | 3 +++
tcm/src/main/resources/mapper_dao/QuestionDao.xml | 15 +++++++++++----
util/src/main/java/com/ccsens/util/CodeEnum.java | 1 +
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java b/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java
index 37500b55..45ce209f 100644
--- a/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java
+++ b/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java
@@ -107,6 +107,9 @@ public class PatientService implements IPatientService {
@Override
public void saveCaseMes(PatientDto.saveCaseMes param, Long userId) {
+ if(param.getList().size()==0){
+ throw new BaseException(CodeEnum.QINGTIJIAOSHITI);
+ }
//拿到这个患者的基本信息
PatientInformation patientInformation = patientInformationMapper.selectByPrimaryKey(param.getPatientId());
//处理过的答案信息集合
diff --git a/tcm/src/main/resources/mapper_dao/QuestionDao.xml b/tcm/src/main/resources/mapper_dao/QuestionDao.xml
index dc968715..3693509f 100644
--- a/tcm/src/main/resources/mapper_dao/QuestionDao.xml
+++ b/tcm/src/main/resources/mapper_dao/QuestionDao.xml
@@ -123,7 +123,8 @@
diff --git a/util/src/main/java/com/ccsens/util/CodeEnum.java b/util/src/main/java/com/ccsens/util/CodeEnum.java
index e5b5c429..915ca37d 100644
--- a/util/src/main/java/com/ccsens/util/CodeEnum.java
+++ b/util/src/main/java/com/ccsens/util/CodeEnum.java
@@ -185,6 +185,7 @@ public enum CodeEnum {
NOT_HOSPITAL(154,"未找到医院信息",true),
ZHUYUANIDCHONGFU(155,"住院号重复",true),
MEIYOUGAIYISHENG(156,"该医生信息查询不正确",true),
+ QINGTIJIAOSHITI(157,"请提交答案",true),
;
From a7433f8dbd4499859ef722176c3b17892e37e8df Mon Sep 17 00:00:00 2001
From: wang0018 <1007152140@qq.com>
Date: Mon, 8 Mar 2021 16:33:52 +0800
Subject: [PATCH 2/2] tijiao
---
.../ccsens/tcm/service/PatientService.java | 47 +++++++++++++++----
.../ccsens/tcm/service/QuestionService.java | 2 +-
.../main/resources/mapper_dao/QuestionDao.xml | 19 +++++---
3 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java b/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java
index 45ce209f..a998098b 100644
--- a/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java
+++ b/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java
@@ -114,26 +114,43 @@ public class PatientService implements IPatientService {
PatientInformation patientInformation = patientInformationMapper.selectByPrimaryKey(param.getPatientId());
//处理过的答案信息集合
List patientRecordList1=new ArrayList();
- //处理过的提交的试题id集合
+ //处理过的提交的答案试题id,答案类型为0,1 集合
Set longSet=new HashSet();
+ //处理过的提交的答案试题id,答案类型为2 集合
+ Set longSet1=new HashSet();
+ //用来装试题答案id和其数量
+ Map shitiwei2de=new HashMap();
//下面是对试题进行处理
if(param.getList().size()>0) {
//在这个地方修改其中得集合
List saveCaseMesSigList= param.getList();
Set stringSet=new HashSet();
+ //类型为2的数组
+ Set stringSet1=new HashSet();
saveCaseMesSigList.forEach(saveCaseMesSig -> {
if(saveCaseMesSig.getContentsType()==(byte)1){
stringSet.add(saveCaseMesSig.getTestQuestionsId()+"-"+saveCaseMesSig.getContents().substring(0,saveCaseMesSig.getContents().indexOf(":")));
}
});
for (int i = param.getList().size() - 1; i >= 0; i--) {
+ //先统计一下数量
+ if(shitiwei2de.containsKey(param.getList().get(i))){
+ shitiwei2de.put( param.getList().get(i).getTestQuestionsId(),shitiwei2de.get(param.getList().get(i).getTestQuestionsId())+1);
+ }else {
+ shitiwei2de.put( param.getList().get(i).getTestQuestionsId(),1);
+ }
if(param.getList().get(i).getContentsType()==(byte) 0){
if(stringSet.contains(param.getList().get(i).getTestQuestionsId()+"-"+param.getList().get(i).getContents())){
param.getList().remove(i);
}
}
}
-
+ for (int i = 0; i < param.getList().size(); i++) {
+ //拿出答案类型为2的并且数量为1的
+ if((param.getList().get(i).getContentsType()==(byte) 2 )&&(shitiwei2de.get(param.getList().get(i).getTestQuestionsId())==1)){
+ longSet1.add(param.getList().get(i).getTestQuestionsId());
+ }
+ }
for (int i = 0; i < param.getList().size(); i++) {
PatientRecord patientRecord=new PatientRecord();
BeanUtils.copyProperties(param.getList().get(i),patientRecord);
@@ -145,17 +162,29 @@ public class PatientService implements IPatientService {
patientRecord.setId(param.getList().get(i).getPatientRecordId());
}
patientRecord.setUserId(userId);
- longSet.add(patientRecord.getTestQuestionsId());
+ if(!longSet1.contains(param.getList().get(i).getTestQuestionsId())){
+ longSet.add(patientRecord.getTestQuestionsId());
+ }
//因为得删除之前得内容,所以把试题集合都抽出来,另外再写循环进行插入
patientRecordList1.add(patientRecord);
}
}
- //对答案进行更新删除
- PatientRecordExample patientRecordExample=new PatientRecordExample();
- patientRecordExample.createCriteria().andTestQuestionsIdIn(new ArrayList(longSet)).andRecStatusEqualTo((byte) 0).andPatientIdEqualTo(param.getPatientId()).andCollectTimeEqualTo(param.getNums());
- PatientRecord patientRecord=new PatientRecord();
- patientRecord.setRecStatus((byte)2);
- patientRecordMapper.updateByExampleSelective(patientRecord,patientRecordExample);
+ if(longSet.size()>0) {
+ //对答案 0 和 1 进行更新删除
+ PatientRecordExample patientRecordExample = new PatientRecordExample();
+ patientRecordExample.createCriteria().andTestQuestionsIdIn(new ArrayList(longSet)).andRecStatusEqualTo((byte) 0).andPatientIdEqualTo(param.getPatientId()).andCollectTimeEqualTo(param.getNums());
+ PatientRecord patientRecord = new PatientRecord();
+ patientRecord.setRecStatus((byte) 2);
+ patientRecordMapper.updateByExampleSelective(patientRecord, patientRecordExample);
+ }
+ //对答案是2的进行删除
+ if(longSet1.size()>0) {
+ PatientRecordExample patientRecordExample1 = new PatientRecordExample();
+ patientRecordExample1.createCriteria().andTestQuestionsIdIn(new ArrayList(longSet1)).andRecStatusEqualTo((byte) 0).andPatientIdEqualTo(param.getPatientId()).andCollectTimeEqualTo(param.getNums()).andContentsTypeEqualTo((byte) 2);
+ PatientRecord patientRecord2 = new PatientRecord();
+ patientRecord2.setRecStatus((byte) 2);
+ patientRecordMapper.updateByExampleSelective(patientRecord2, patientRecordExample1);
+ }
//插入答案
patientRecordList1.forEach(patientRecord1 -> {
patientRecord1.setId(snowflake.nextId());
diff --git a/tcm/src/main/java/com/ccsens/tcm/service/QuestionService.java b/tcm/src/main/java/com/ccsens/tcm/service/QuestionService.java
index f76bbedd..b4c9c858 100644
--- a/tcm/src/main/java/com/ccsens/tcm/service/QuestionService.java
+++ b/tcm/src/main/java/com/ccsens/tcm/service/QuestionService.java
@@ -53,7 +53,7 @@ public class QuestionService implements IQuestionService{
if(CollectionUtil.isNotEmpty(patientCode.getSubReportCodes())){
patientCode.getSubReportCodes().forEach(subReportCode -> {
//查询二级code下的试题和答案
- List subpatientQuestionNumList = questionDao.getQuestionByCodeAndPatientId(patientCode.getCode(),param.getId(),param.getNums());
+ List subpatientQuestionNumList = questionDao.getQuestionByCodeAndPatientId(subReportCode.getCode(),param.getId(),param.getNums());
//查询选项关联的试题及答案
if(CollectionUtil.isNotEmpty(subpatientQuestionNumList)){
subpatientQuestionNumList.forEach(question -> {
diff --git a/tcm/src/main/resources/mapper_dao/QuestionDao.xml b/tcm/src/main/resources/mapper_dao/QuestionDao.xml
index 3693509f..bf0d3736 100644
--- a/tcm/src/main/resources/mapper_dao/QuestionDao.xml
+++ b/tcm/src/main/resources/mapper_dao/QuestionDao.xml
@@ -163,14 +163,19 @@
and q.rec_status = 0
and q.`code` = #{code}
- ) qq,
+ ) qq left join (
+ SELECT
+ test_questions_id,
+ contents
+ FROM
t_patient_record tpr
- where
- tpr.test_questions_id = qq.qid
- AND tpr.contents_type = 2
- AND tpr.patient_id = #{patientId}
- AND tpr.collect_time = #{nums}
- AND tpr.rec_status = 0
+ WHERE
+ tpr.contents_type = 2
+ AND tpr.patient_id = #{patientId}
+ AND tpr.collect_time = #{nums}
+ AND tpr.rec_status = 0
+ ) tpr on tpr.test_questions_id = qq.qid
+
ORDER BY qq.qsort,qq.osort,qq.choose DESC,-qq.otherInformation DESC