|
@ -10,6 +10,8 @@ import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
|
|
import com.yihu.jw.restmodel.hospital.survey.*;
|
|
import com.yihu.jw.restmodel.hospital.survey.*;
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
|
import com.yihu.jw.util.common.PercentageUtil;
|
|
import com.yihu.jw.utils.EntityUtils;
|
|
import com.yihu.jw.utils.EntityUtils;
|
|
import com.yihu.jw.utils.StringUtil;
|
|
import com.yihu.jw.utils.StringUtil;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
@ -27,7 +29,7 @@ import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by Trick on 2019/9/6.
|
|
|
|
|
|
* Created by Trick on 2019/9/6
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
@Transactional
|
|
@Transactional
|
|
@ -243,15 +245,15 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
" FROM " +
|
|
" FROM " +
|
|
" wlyy_survey_template t ";
|
|
" wlyy_survey_template t ";
|
|
if(StringUtils.isNotBlank(label)){
|
|
if(StringUtils.isNotBlank(label)){
|
|
totalSql+=" JOIN wlyy_survey_label_info i OM t.id = i.survey_temp_code";
|
|
|
|
|
|
totalSql+=" JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code";
|
|
}
|
|
}
|
|
totalSql += " WHERE " +
|
|
totalSql += " WHERE " +
|
|
" t.del = '1'";
|
|
" t.del = '1'";
|
|
if(StringUtils.isNotBlank(title)){
|
|
if(StringUtils.isNotBlank(title)){
|
|
totalSql += " t.title like '%"+title+"%' ";
|
|
|
|
|
|
totalSql += " AND t.title like '%"+title+"%' ";
|
|
}
|
|
}
|
|
if(StringUtils.isNotBlank(label)){
|
|
if(StringUtils.isNotBlank(label)){
|
|
totalSql += " i.label_code ='"+label+"'";
|
|
|
|
|
|
totalSql += " AND i.label_code ='"+label+"'";
|
|
}
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
@ -273,15 +275,15 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
" FROM " +
|
|
" FROM " +
|
|
" wlyy_survey_template t ";
|
|
" wlyy_survey_template t ";
|
|
if(StringUtils.isNotBlank(label)){
|
|
if(StringUtils.isNotBlank(label)){
|
|
sql += " JOIN wlyy_survey_label_info i OM t.id = i.survey_temp_code";
|
|
|
|
|
|
sql += " JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code";
|
|
}
|
|
}
|
|
sql += " WHERE " +
|
|
sql += " WHERE " +
|
|
" t.del = '1'";
|
|
" t.del = '1'";
|
|
if(StringUtils.isNotBlank(title)){
|
|
if(StringUtils.isNotBlank(title)){
|
|
sql += " t.title like '%"+title+"%' ";
|
|
|
|
|
|
sql += " AND t.title like '%"+title+"%' ";
|
|
}
|
|
}
|
|
if(StringUtils.isNotBlank(label)){
|
|
if(StringUtils.isNotBlank(label)){
|
|
sql += " i.label_code ='"+label+"'";
|
|
|
|
|
|
sql += " AND i.label_code ='"+label+"'";
|
|
}
|
|
}
|
|
sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
@ -317,10 +319,10 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
|
|
|
//设置选项
|
|
//设置选项
|
|
for(WlyySurveyTemplateQuestionVO tq:tqVOs){
|
|
for(WlyySurveyTemplateQuestionVO tq:tqVOs){
|
|
List<WlyySurveyTemplateOptionDO> optionDOs = surveyTemplateOptionDao.findByTemplateQuestionCodeAndDelOrderBySortAsc(tq.getId(),"1");
|
|
|
|
|
|
List<WlyySurveyTemplateOptionDO> optionDOs = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),"1");
|
|
List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
|
|
List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
|
|
convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
|
|
convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
|
|
tq.setTemplateOptionVOs(optionVOs);
|
|
|
|
|
|
tq.setOptionVOs(optionVOs);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return templateVO;
|
|
return templateVO;
|
|
@ -370,8 +372,8 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
|
|
|
//保存新问题选项
|
|
//保存新问题选项
|
|
if(StringUtils.isNotBlank(tempOpJson)){
|
|
if(StringUtils.isNotBlank(tempOpJson)){
|
|
List<WlyySurveyTemplateOptionDO> questions = EntityUtils.jsonToList(tempOpJson, WlyySurveyTemplateOptionDO.class);
|
|
|
|
surveyTemplateOptionDao.save(questions);
|
|
|
|
|
|
List<WlyySurveyTemplateOptionDO> options = EntityUtils.jsonToList(tempOpJson, WlyySurveyTemplateOptionDO.class);
|
|
|
|
surveyTemplateOptionDao.save(options);
|
|
}
|
|
}
|
|
|
|
|
|
//保存标签
|
|
//保存标签
|
|
@ -447,6 +449,30 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 保存部门问卷关系
|
|
|
|
* @param dept
|
|
|
|
* @param sdJsons
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Boolean saveDeptSurvey(String dept,String sdJsons)throws Exception{
|
|
|
|
|
|
|
|
//删除之前关系
|
|
|
|
List<WlyySurveyDeptDO> dels = surveyDeptDao.findByDept(dept);
|
|
|
|
if(dels!=null&&dels.size()>0){
|
|
|
|
surveyDeptDao.delete(dels);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(sdJsons)){
|
|
|
|
List<WlyySurveyDeptDO> list = EntityUtils.jsonToList(sdJsons,WlyySurveyDeptDO.class);
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
surveyDeptDao.save(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询科室下问卷列表
|
|
* 查询科室下问卷列表
|
|
* @param dept
|
|
* @param dept
|
|
@ -473,6 +499,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
*/
|
|
*/
|
|
public List<Map<String,Object>> findDeptBySurvey(String tempId){
|
|
public List<Map<String,Object>> findDeptBySurvey(String tempId){
|
|
String sql ="SELECT " +
|
|
String sql ="SELECT " +
|
|
|
|
" d.survey_temp_code AS surveyTempCode," +
|
|
" d.dept, " +
|
|
" d.dept, " +
|
|
" d.dept_name AS deptName " +
|
|
" d.dept_name AS deptName " +
|
|
" FROM " +
|
|
" FROM " +
|
|
@ -514,4 +541,185 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
List<WlyySurveyUserAnswerDO> list = surveyUserAnswerDao.findBySurveyTempCodeAndPatient(tempId,patient);
|
|
List<WlyySurveyUserAnswerDO> list = surveyUserAnswerDao.findBySurveyTempCodeAndPatient(tempId,patient);
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询问题情况
|
|
|
|
* @param tempId
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public WlyySurveyTemplateVO findSurveyTemplateResult(String tempId) {
|
|
|
|
|
|
|
|
WlyySurveyTemplateDO templateDO = surveyTemplateDao.findOne(tempId);
|
|
|
|
WlyySurveyTemplateVO templateVO = convertToModel(templateDO,WlyySurveyTemplateVO.class);
|
|
|
|
templateVO.setLabels(findSurveyTemplateLabel(tempId));
|
|
|
|
templateVO.setInsplabels(findSurveyInspTemplateLabel(tempId));
|
|
|
|
|
|
|
|
//查询所有答题过的用户,计算答题总数
|
|
|
|
List<WlyySurveyUserDO> surveyUsers = surveyUserDao.findBySurveyTempCodeAndStatus(templateVO.getId(),1);
|
|
|
|
Integer total =0;
|
|
|
|
if(surveyUsers!=null&&surveyUsers.size()>0){
|
|
|
|
total = surveyUsers.size();
|
|
|
|
}
|
|
|
|
templateVO.setAnswerCount(total);
|
|
|
|
|
|
|
|
List<WlyySurveyTemplateQuestionDO> tqDOs = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(tempId,"1");
|
|
|
|
if(tqDOs!=null&&tqDOs.size()>0){
|
|
|
|
//设置问题
|
|
|
|
List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
|
|
|
|
convertToModels(tqDOs,tqVOs,WlyySurveyTemplateQuestionVO.class);
|
|
|
|
templateVO.setTemplateQuestionVOs(tqVOs);
|
|
|
|
|
|
|
|
//设置选项
|
|
|
|
for(WlyySurveyTemplateQuestionVO tq:tqVOs){
|
|
|
|
List<WlyySurveyTemplateOptionDO> optionDOs = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getId(),"1");
|
|
|
|
List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
|
|
|
|
convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 统计每个选项选择的百分比
|
|
|
|
*/
|
|
|
|
if(optionVOs!=null&&optionVOs.size()>0){
|
|
|
|
for(WlyySurveyTemplateOptionVO vo:optionVOs){
|
|
|
|
Integer answerCount =0;
|
|
|
|
List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getId());
|
|
|
|
if(answerDOs!=null&&answerDOs.size()>0){
|
|
|
|
answerCount = answerDOs.size();
|
|
|
|
}
|
|
|
|
vo.setPercentage(PercentageUtil.bs(answerCount,total)+"%");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tq.setOptionVOs(optionVOs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return templateVO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 综合查询问题答案
|
|
|
|
* @param comment
|
|
|
|
* @param content
|
|
|
|
* @param tempQuestionCode
|
|
|
|
* @param tempOptionCode
|
|
|
|
* @param page
|
|
|
|
* @param size
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public MixEnvelop findQuestionInfoList(String comment, String content, String tempQuestionCode,String tempOptionCode,Integer page,Integer size){
|
|
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
|
" COUNT(1) AS total" +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_user_answer t " +
|
|
|
|
" WHERE 1=1";
|
|
|
|
if(StringUtils.isNotBlank(comment)){
|
|
|
|
totalSql += " AND t.comment like '%"+comment+"%' ";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(content)){
|
|
|
|
totalSql += " AND t.content like '%"+content+"%'";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(tempQuestionCode)){
|
|
|
|
totalSql += " AND t.temp_question_code ='"+tempQuestionCode+"'";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(tempOptionCode)){
|
|
|
|
totalSql += " AND t.temp_option_code ='"+tempOptionCode+"'";
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
|
Long count = 0L;
|
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String sql = "SELECT " +
|
|
|
|
" t.id, " +
|
|
|
|
" t.survey_temp_code AS surveyTempCode, " +
|
|
|
|
" t.temp_question_code AS tempQuestionCode, " +
|
|
|
|
" t.question_type AS questionType, " +
|
|
|
|
" t.temp_option_code AS tempOptionCode, " +
|
|
|
|
" t.comment, " +
|
|
|
|
" t.content, " +
|
|
|
|
" t.patient," +
|
|
|
|
" t.patient_name AS patientName," +
|
|
|
|
" t.score," +
|
|
|
|
" t.create_time AS createTime" +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_user_answer t " +
|
|
|
|
" WHERE 1=1";
|
|
|
|
if(StringUtils.isNotBlank(comment)){
|
|
|
|
sql += " AND t.comment like '%"+comment+"%' ";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(content)){
|
|
|
|
sql += " AND t.content like '%"+content+"%'";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(tempQuestionCode)){
|
|
|
|
sql += " AND t.temp_question_code ='"+tempQuestionCode+"'";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(tempOptionCode)){
|
|
|
|
sql += " AND t.temp_option_code ='"+tempOptionCode+"'";
|
|
|
|
}
|
|
|
|
sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
|
|
List<WlyySurveyUserAnswerDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyUserAnswerDO.class));
|
|
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询
|
|
|
|
* @param title
|
|
|
|
* @param page
|
|
|
|
* @param size
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public MixEnvelop findAnswerList(String title,Integer page,Integer size){
|
|
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
|
" COUNT(1) AS total" +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_user t " +
|
|
|
|
" WHERE 1=1 ";
|
|
|
|
if(StringUtils.isNotBlank(title)){
|
|
|
|
totalSql += " AND t.survey_temp_title like '%"+title+"%' ";
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
|
Long count = 0L;
|
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
|
}
|
|
|
|
|
|
|
|
String sql = "SELECT " +
|
|
|
|
" t.id, " +
|
|
|
|
" t.survey_temp_code AS surveyTempCode, " +
|
|
|
|
" t.survey_temp_title AS surveyTempTitle, " +
|
|
|
|
" t.patient," +
|
|
|
|
" t.patient_name AS patientName," +
|
|
|
|
" t.dept," +
|
|
|
|
" t.dept_name AS deptName," +
|
|
|
|
" t.doctor," +
|
|
|
|
" t.doctor_name AS doctorName," +
|
|
|
|
" t.status," +
|
|
|
|
" t.end_time AS endTime," +
|
|
|
|
" t.create_time AS createTime," +
|
|
|
|
" p.idcard" +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_user t " +
|
|
|
|
" JOIN base_patient p ON t.patient = p.id " +
|
|
|
|
" WHERE 1=1 ";
|
|
|
|
if(StringUtils.isNotBlank(title)){
|
|
|
|
sql += " AND t.survey_temp_title like '%"+title+"%' ";
|
|
|
|
}
|
|
|
|
sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
|
|
List<WlyySurveyUserVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyUserVO.class));
|
|
|
|
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
for(WlyySurveyUserVO vo :list){
|
|
|
|
vo.setAge(IdCardUtil.getAgeForIdcard(vo.getIdcard()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
|
|
|
|
}
|
|
}
|
|
}
|