|
@ -21,6 +21,7 @@ import com.yihu.jw.utils.EntityUtils;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.xpath.operations.Bool;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
@ -29,10 +30,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by Trick on 2019/9/6
|
|
@ -287,7 +285,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
totalSql += " AND i.label_code ='"+label+"'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(creater)){
|
|
|
totalSql +=" AND t.creater = '"+creater+"' ";
|
|
|
totalSql +=" AND t.creater_code = '"+creater+"' ";
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
@ -397,15 +395,19 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
//设置问题
|
|
|
List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
|
|
|
convertToModels(tqDOs,tqVOs,WlyySurveyTemplateQuestionVO.class);
|
|
|
templateVO.setTemplateQuestionVOs(tqVOs);
|
|
|
|
|
|
//设置选项
|
|
|
for(WlyySurveyTemplateQuestionVO tq:tqVOs){
|
|
|
List<WlyySurveyTemplateOptionDO> optionDOs = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),tq.getTemplateCode(),"1");
|
|
|
List<WlyySurveyTemplateOptionDO> optionDOs = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getCode(),tq.getTemplateCode(),"1");
|
|
|
List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
|
|
|
convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
|
|
|
for (WlyySurveyTemplateOptionVO optionVO:optionVOs){
|
|
|
optionVO.setId(optionVO.getCode());
|
|
|
}
|
|
|
tq.setOptionVOs(optionVOs);
|
|
|
tq.setId(tq.getCode());
|
|
|
}
|
|
|
templateVO.setTemplateQuestionVOs(tqVOs);
|
|
|
}
|
|
|
return templateVO;
|
|
|
}
|
|
@ -433,7 +435,13 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
public Boolean saveSurveyTemplate(String tempJson,String tempQJson,String tempOpJson,String labelJson,String labelInspJson)throws Exception{
|
|
|
|
|
|
WlyySurveyTemplateDO temp = objectMapper.readValue(tempJson,WlyySurveyTemplateDO.class);
|
|
|
String doctor = temp.getCreaterCode();
|
|
|
if (StringUtils.isNotEmpty(temp.getId())){
|
|
|
WlyySurveyTemplateDO templateDO = surveyTemplateDao.findOne(temp.getId());
|
|
|
if(null!=templateDO){
|
|
|
temp.setCreater(templateDO.getCreater());
|
|
|
temp.setCreaterCode(templateDO.getCreaterCode());
|
|
|
}
|
|
|
}
|
|
|
temp = surveyTemplateDao.save(temp);
|
|
|
//删除原有问题
|
|
|
List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
|
|
@ -443,6 +451,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
//新增问题
|
|
|
if(StringUtils.isNotBlank(tempQJson)){
|
|
|
List<WlyySurveyTemplateQuestionDO> questions = EntityUtils.jsonToList(tempQJson, WlyySurveyTemplateQuestionDO.class);
|
|
|
for (WlyySurveyTemplateQuestionDO wlyySurveyTemplateQuestionDO:questions){
|
|
|
wlyySurveyTemplateQuestionDO.setTemplateCode(temp.getId());
|
|
|
wlyySurveyTemplateQuestionDO.setCode(wlyySurveyTemplateQuestionDO.getId());
|
|
|
wlyySurveyTemplateQuestionDO.setId(UUID.randomUUID().toString());
|
|
|
}
|
|
|
surveyTemplateQuestionDao.save(questions);
|
|
|
}
|
|
|
|
|
@ -455,6 +468,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
//保存新问题选项
|
|
|
if(StringUtils.isNotBlank(tempOpJson)){
|
|
|
List<WlyySurveyTemplateOptionDO> options = EntityUtils.jsonToList(tempOpJson, WlyySurveyTemplateOptionDO.class);
|
|
|
for (WlyySurveyTemplateOptionDO wlyySurveyTemplateOptionDO:options){
|
|
|
wlyySurveyTemplateOptionDO.setTemplateCode(temp.getId());
|
|
|
wlyySurveyTemplateOptionDO.setCode(wlyySurveyTemplateOptionDO.getId());
|
|
|
wlyySurveyTemplateOptionDO.setId(UUID.randomUUID()+"");
|
|
|
}
|
|
|
surveyTemplateOptionDao.save(options);
|
|
|
}
|
|
|
|
|
@ -580,7 +598,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
if(result!=null&&result.size()>0){
|
|
|
for(Map<String,Object> map:result){
|
|
|
String tempId = (String)map.get("id");
|
|
|
List<WlyySurveyUserDO> list = surveyUserDao.findBySurvey(tempId,patient, DateUtil.strToDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd")));
|
|
|
List<WlyySurveyUserDO> list = surveyUserDao.findBySurvey(tempId,patient);
|
|
|
if(list!=null&&list.size()>0){
|
|
|
map.put("isAnswer",true);
|
|
|
}else{
|
|
@ -635,6 +653,9 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
List<WlyySurveyUserAnswerDO> answerDOs = EntityUtils.jsonToList(suaJsons,WlyySurveyUserAnswerDO.class);
|
|
|
for(WlyySurveyUserAnswerDO answerDO : answerDOs){
|
|
|
answerDO.setSurverUserId(surveyUserDO.getId());
|
|
|
/*WlyySurveyTemplateOptionDO surveyTemplateOptionDO = surveyTemplateOptionDao.findOne(answerDO.getTempOptionCode());
|
|
|
answerDO.setTempQuestionCode(surveyTemplateOptionDO.getQuestionCode());
|
|
|
answerDO.setTempOptionCode(surveyTemplateOptionDO.getCode());*/
|
|
|
}
|
|
|
surveyUserAnswerDao.save(answerDOs);
|
|
|
BasePatientBusinessDO basePatientBusinessDO = basePatientBusinessDao.findByDoctorPatientRelationCode(surveyUserDO.getPatient(),surveyUserDO.getSurveyTempCode(),surveyUserDO.getDoctor());
|
|
@ -654,9 +675,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
if(StringUtils.isNotBlank(surverUserId)){
|
|
|
list = surveyUserAnswerDao.findBySurverUserId(surverUserId);
|
|
|
}else{
|
|
|
List<WlyySurveyUserDO> surveys = surveyUserDao.findBySurvey(tempId,patient, DateUtil.strToDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd")));
|
|
|
List<WlyySurveyUserDO> surveys = surveyUserDao.findBySurvey(tempId,patient);
|
|
|
System.out.println(surveys);
|
|
|
if(surveys!=null&&surveys.size()>0){
|
|
|
WlyySurveyUserDO wlyySurveyUserDO = surveys.get(0);
|
|
|
System.out.println(wlyySurveyUserDO);
|
|
|
list = surveyUserAnswerDao.findBySurverUserId(wlyySurveyUserDO.getId());
|
|
|
}
|
|
|
}
|
|
@ -680,7 +703,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
templateVO.setVisitDeptName(doctor.getVisitDeptName());
|
|
|
}
|
|
|
//查询所有答题过的用户,计算答题总数
|
|
|
List<WlyySurveyUserDO> surveyUsers = surveyUserDao.findBySurveyTempCodeAndStatus(templateVO.getId(),1);
|
|
|
List<WlyySurveyUserDO> surveyUsers = surveyUserDao.findBySurveyTempCodeAndStatus(tempId,1);
|
|
|
Integer total =0;
|
|
|
if(surveyUsers!=null&&surveyUsers.size()>0){
|
|
|
total = surveyUsers.size();
|
|
@ -692,15 +715,14 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
//设置问题
|
|
|
List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
|
|
|
convertToModels(tqDOs,tqVOs,WlyySurveyTemplateQuestionVO.class);
|
|
|
templateVO.setTemplateQuestionVOs(tqVOs);
|
|
|
|
|
|
//设置选项
|
|
|
for(WlyySurveyTemplateQuestionVO tq:tqVOs){
|
|
|
List<WlyySurveyTemplateOptionDO> optionDOs = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),tq.getTemplateCode(),"1");
|
|
|
List<WlyySurveyTemplateOptionDO> optionDOs = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getCode(),tq.getTemplateCode(),"1");
|
|
|
List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
|
|
|
convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
|
|
|
int tpCount = 0;
|
|
|
List<WlyySurveyUserAnswerDO> answerQuestionDOs = surveyUserAnswerDao.findByTempQuestionCodeDistinctPatient(tq.getId(),tempId);
|
|
|
List<WlyySurveyUserAnswerDO> answerQuestionDOs = surveyUserAnswerDao.findByTempQuestionCodeDistinctPatient(tq.getCode(),tempId);
|
|
|
if(answerQuestionDOs!=null&&answerQuestionDOs.size()>0){
|
|
|
tpCount = answerQuestionDOs.size();
|
|
|
}
|
|
@ -711,17 +733,19 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
if(optionVOs!=null&&optionVOs.size()>0){
|
|
|
for(WlyySurveyTemplateOptionVO vo:optionVOs){
|
|
|
Integer answerCount =0;
|
|
|
List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getId(),vo.getTemplateCode());
|
|
|
List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getCode(),vo.getTemplateCode());
|
|
|
if(answerDOs!=null&&answerDOs.size()>0){
|
|
|
answerCount = answerDOs.size();
|
|
|
}
|
|
|
vo.setPercentage(PercentageUtil.bs(answerCount,total)+"%");
|
|
|
vo.setOptCount(answerCount);
|
|
|
vo.setId(vo.getCode());
|
|
|
}
|
|
|
}
|
|
|
tq.setOptionVOs(optionVOs);
|
|
|
|
|
|
tq.setId(tq.getCode());
|
|
|
}
|
|
|
templateVO.setTemplateQuestionVOs(tqVOs);
|
|
|
}
|
|
|
return templateVO;
|
|
|
}
|
|
@ -904,4 +928,5 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
String response = HttpClientUtil.postBody(imAddr, params);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
}
|