|
|
@ -114,26 +114,43 @@ public class PatientService implements IPatientService { |
|
|
|
PatientInformation patientInformation = patientInformationMapper.selectByPrimaryKey(param.getPatientId()); |
|
|
|
//处理过的答案信息集合
|
|
|
|
List<PatientRecord> patientRecordList1=new ArrayList<PatientRecord>(); |
|
|
|
//处理过的提交的试题id集合
|
|
|
|
//处理过的提交的答案试题id,答案类型为0,1 集合
|
|
|
|
Set<Long> longSet=new HashSet<Long>(); |
|
|
|
//处理过的提交的答案试题id,答案类型为2 集合
|
|
|
|
Set<Long> longSet1=new HashSet<Long>(); |
|
|
|
//用来装试题答案id和其数量
|
|
|
|
Map<Long,Integer> shitiwei2de=new HashMap<Long, Integer>(); |
|
|
|
//下面是对试题进行处理
|
|
|
|
if(param.getList().size()>0) { |
|
|
|
//在这个地方修改其中得集合
|
|
|
|
List<PatientDto.saveCaseMesSig> saveCaseMesSigList= param.getList(); |
|
|
|
Set<String> stringSet=new HashSet<String>(); |
|
|
|
//类型为2的数组
|
|
|
|
Set<String> stringSet1=new HashSet<String>(); |
|
|
|
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<Long>(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<Long>(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<Long>(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()); |
|
|
|