|
@ -0,0 +1,517 @@
|
|
|
|
package com.yihu.jw.hospital.survey.service;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
|
|
|
|
import com.yihu.jw.entity.hospital.survey.*;
|
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
|
import com.yihu.jw.hospital.survey.dao.*;
|
|
|
|
import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
|
|
|
|
import com.yihu.jw.restmodel.hospital.survey.*;
|
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
|
|
import com.yihu.jw.utils.EntityUtils;
|
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
import org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtractor;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Trick on 2019/9/6.
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Transactional
|
|
|
|
public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQuestionDao> {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private WlyyHospitalSysDictDao sysDictDao;
|
|
|
|
@Autowired
|
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
@Autowired
|
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
@Autowired
|
|
|
|
private SurveyQuestionDao surveyQuestionDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyQuestionsOptionDao surveyQuestionsOptionDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyTemplateDao surveyTemplateDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyTemplateQuestionDao surveyTemplateQuestionDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyTemplateOptionDao surveyTemplateOptionDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyLabelInfoDao surveyLabelInfoDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyInspLabelInfoDao surveyInspLabelInfoDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyDeptDao surveyDeptDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyUserDao surveyUserDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyUserAnswerDao surveyUserAnswerDao;
|
|
|
|
/**
|
|
|
|
* 查询字典
|
|
|
|
* 1.surveyLabel;2.surveyScreenLabel
|
|
|
|
* @param name
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public List<WlyyHospitalSysDictVO> findSurveyLabel(String name){
|
|
|
|
List<WlyyHospitalSysDictVO> list = new ArrayList<>();
|
|
|
|
return convertToModels(sysDictDao.findByDictName(name),list,WlyyHospitalSysDictVO.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询问题
|
|
|
|
* @param title
|
|
|
|
* @param questionType
|
|
|
|
* @param page
|
|
|
|
* @param size
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public MixEnvelop findSurveyQuestion(String title,Integer questionType,Integer page,Integer size)throws Exception{
|
|
|
|
|
|
|
|
//计算总数
|
|
|
|
String totalSql ="SELECT" +
|
|
|
|
" COUNT(1) AS total" +
|
|
|
|
" FROM" +
|
|
|
|
" wlyy_survey_question q " +
|
|
|
|
" WHERE q.del = '1' ";
|
|
|
|
if(StringUtils.isNotBlank(title)){
|
|
|
|
totalSql+=" AND q.title like '%"+title+"%'";
|
|
|
|
}
|
|
|
|
if(questionType!=null){
|
|
|
|
totalSql+=" AND q.question_type ="+questionType;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 " +
|
|
|
|
" q.id AS id, " +
|
|
|
|
" q.title AS title, " +
|
|
|
|
" q.question_comment AS questionComment, " +
|
|
|
|
" q.question_type AS questionType, " +
|
|
|
|
" q.is_required AS isRequired, " +
|
|
|
|
" q.min_num AS minNum, " +
|
|
|
|
" q.max_num AS maxNum, " +
|
|
|
|
" q.del, " +
|
|
|
|
" q.create_time AS createTime, " +
|
|
|
|
" q.update_time AS updateTime " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_question q " +
|
|
|
|
" WHERE q.del = '1' ";
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(title)){
|
|
|
|
sql+=" AND q.title like '%"+title+"%'";
|
|
|
|
}
|
|
|
|
if(questionType!=null){
|
|
|
|
sql+=" AND q.question_type ="+questionType;
|
|
|
|
}
|
|
|
|
sql += " ORDER BY q.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
|
|
List<WlyySurveyQuestionVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyQuestionVO.class));
|
|
|
|
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
for(WlyySurveyQuestionVO sq:list){
|
|
|
|
List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(),"1");
|
|
|
|
if(optionDOs!=null&&optionDOs.size()>0){
|
|
|
|
List<WlyySurveyQuestionsOptionVO> optionVOs = new ArrayList<>();
|
|
|
|
sq.setOptionVOs(convertToModels(optionDOs,optionVOs,WlyySurveyQuestionsOptionVO.class));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询问题单条
|
|
|
|
* @param surveyId
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public WlyySurveyQuestionVO findBySurveyId(String surveyId){
|
|
|
|
WlyySurveyQuestionDO sq = surveyQuestionDao.findOne(surveyId);
|
|
|
|
WlyySurveyQuestionVO surveyQuestionVO = convertToModel(sq,WlyySurveyQuestionVO.class);
|
|
|
|
List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(),"1");
|
|
|
|
if(optionDOs!=null&&optionDOs.size()>0){
|
|
|
|
List<WlyySurveyQuestionsOptionVO> optionVOs = new ArrayList<>();
|
|
|
|
surveyQuestionVO.setOptionVOs(convertToModels(optionDOs,optionVOs,WlyySurveyQuestionsOptionVO.class));
|
|
|
|
}
|
|
|
|
return surveyQuestionVO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 保存问题
|
|
|
|
* @param sqOptionJson
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Boolean saveSurveyQuestion(String sqjsons,String sqOptionJson)throws Exception{
|
|
|
|
|
|
|
|
//保存问题
|
|
|
|
List<WlyySurveyQuestionDO> surveys = EntityUtils.jsonToList(sqjsons, WlyySurveyQuestionDO.class);
|
|
|
|
surveyQuestionDao.save(surveys);
|
|
|
|
|
|
|
|
if(surveys!=null&&surveys.size()>0){
|
|
|
|
for(WlyySurveyQuestionDO sq:surveys){
|
|
|
|
List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(),"1");
|
|
|
|
if(optionDOs!=null&&optionDOs.size()>0){
|
|
|
|
surveyQuestionsOptionDao.delete(optionDOs);
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(sqOptionJson)){
|
|
|
|
List<WlyySurveyQuestionsOptionDO> options = EntityUtils.jsonToList(sqOptionJson, WlyySurveyQuestionsOptionDO.class);
|
|
|
|
surveyQuestionsOptionDao.save(options);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 单个编辑问题
|
|
|
|
* @param sqjson
|
|
|
|
* @param sqOptionJson
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Boolean updataSurveyQuestion(String sqjson,String sqOptionJson) throws Exception{
|
|
|
|
WlyySurveyQuestionDO sq = objectMapper.readValue(sqjson,WlyySurveyQuestionDO.class);
|
|
|
|
surveyQuestionDao.save(sq);
|
|
|
|
|
|
|
|
List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(),"1");
|
|
|
|
if(optionDOs!=null&&optionDOs.size()>0){
|
|
|
|
surveyQuestionsOptionDao.delete(optionDOs);
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(sqOptionJson)){
|
|
|
|
List<WlyySurveyQuestionsOptionDO> options = EntityUtils.jsonToList(sqOptionJson, WlyySurveyQuestionsOptionDO.class);
|
|
|
|
surveyQuestionsOptionDao.save(options);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除问题
|
|
|
|
* @param ids
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public Boolean delSurveyQuestion(String ids){
|
|
|
|
|
|
|
|
String sids[] =ids.split(",");
|
|
|
|
if(sids!=null&&ids.length()>0){
|
|
|
|
for(String id:sids){
|
|
|
|
WlyySurveyQuestionDO del = surveyQuestionDao.findOne(id);
|
|
|
|
if(del!=null){
|
|
|
|
surveyQuestionDao.delete(del);
|
|
|
|
}
|
|
|
|
List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(id,"1");
|
|
|
|
if(optionDOs!=null&&optionDOs.size()>0){
|
|
|
|
surveyQuestionsOptionDao.delete(optionDOs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=====================问卷模板=====================================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询模板列表
|
|
|
|
* @param title
|
|
|
|
* @param label
|
|
|
|
* @param page
|
|
|
|
* @param size
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public MixEnvelop findSurveyTemplate(String title,String label,Integer page,Integer size){
|
|
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
|
" COUNT(1) AS total" +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_template t ";
|
|
|
|
if(StringUtils.isNotBlank(label)){
|
|
|
|
totalSql+=" JOIN wlyy_survey_label_info i OM t.id = i.survey_temp_code";
|
|
|
|
}
|
|
|
|
totalSql += " WHERE " +
|
|
|
|
" t.del = '1'";
|
|
|
|
if(StringUtils.isNotBlank(title)){
|
|
|
|
totalSql += " t.title like '%"+title+"%' ";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(label)){
|
|
|
|
totalSql += " i.label_code ='"+label+"'";
|
|
|
|
}
|
|
|
|
|
|
|
|
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.title, " +
|
|
|
|
" t.template_comment AS templateComment, " +
|
|
|
|
" t.organization, " +
|
|
|
|
" t.creater, " +
|
|
|
|
" t.create_time AS createTime, " +
|
|
|
|
" t.del, " +
|
|
|
|
" t.update_time AS updateTime" +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_template t ";
|
|
|
|
if(StringUtils.isNotBlank(label)){
|
|
|
|
sql += " JOIN wlyy_survey_label_info i OM t.id = i.survey_temp_code";
|
|
|
|
}
|
|
|
|
sql += " WHERE " +
|
|
|
|
" t.del = '1'";
|
|
|
|
if(StringUtils.isNotBlank(title)){
|
|
|
|
sql += " t.title like '%"+title+"%' ";
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(label)){
|
|
|
|
sql += " i.label_code ='"+label+"'";
|
|
|
|
}
|
|
|
|
sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
|
|
List<WlyySurveyTemplateVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyTemplateVO.class));
|
|
|
|
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
//设置标签
|
|
|
|
for(WlyySurveyTemplateVO templateVO : list){
|
|
|
|
templateVO.setLabels(findSurveyTemplateLabel(templateVO.getId()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取问卷模板详情
|
|
|
|
* @param tempId
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public WlyySurveyTemplateVO findSurveyTemplateById(String tempId){
|
|
|
|
WlyySurveyTemplateDO templateDO = surveyTemplateDao.findOne(tempId);
|
|
|
|
WlyySurveyTemplateVO templateVO = convertToModel(templateDO,WlyySurveyTemplateVO.class);
|
|
|
|
templateVO.setLabels(findSurveyTemplateLabel(tempId));
|
|
|
|
templateVO.setInsplabels(findSurveyInspTemplateLabel(tempId));
|
|
|
|
|
|
|
|
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.findByTemplateQuestionCodeAndDelOrderBySortAsc(tq.getId(),"1");
|
|
|
|
List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
|
|
|
|
convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
|
|
|
|
tq.setTemplateOptionVOs(optionVOs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return templateVO;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<WlyySurveyLabelInfoVO> findSurveyTemplateLabel(String tempId){
|
|
|
|
List<WlyySurveyLabelInfoDO> list = surveyLabelInfoDao.findBySurveyTempCode(tempId);
|
|
|
|
List<WlyySurveyLabelInfoVO> rs = new ArrayList<>();
|
|
|
|
return convertToModels(list,rs,WlyySurveyLabelInfoVO.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<WlyySurveyInspLabelInfoVO> findSurveyInspTemplateLabel(String tempId){
|
|
|
|
List<WlyySurveyInspLabelInfoDO> list = surveyInspLabelInfoDao.findBySurveyTempCode(tempId);
|
|
|
|
List<WlyySurveyInspLabelInfoVO> rs = new ArrayList<>();
|
|
|
|
return convertToModels(list,rs,WlyySurveyInspLabelInfoVO.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 保存,更新模板
|
|
|
|
* @param tempJson
|
|
|
|
* @param tempQJson
|
|
|
|
* @param tempOpJson
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Boolean saveSurveyTemplate(String tempJson,String tempQJson,String tempOpJson,String labelJson,String labelInspJson)throws Exception{
|
|
|
|
|
|
|
|
WlyySurveyTemplateDO temp = objectMapper.readValue(tempJson,WlyySurveyTemplateDO.class);
|
|
|
|
temp = surveyTemplateDao.save(temp);
|
|
|
|
|
|
|
|
//删除原有问题
|
|
|
|
List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
|
|
|
|
if(questionDODels!=null&&questionDODels.size()>0){
|
|
|
|
surveyTemplateQuestionDao.delete(questionDODels);
|
|
|
|
}
|
|
|
|
//新增问题
|
|
|
|
if(StringUtils.isNotBlank(tempQJson)){
|
|
|
|
List<WlyySurveyTemplateQuestionDO> questions = EntityUtils.jsonToList(tempQJson, WlyySurveyTemplateQuestionDO.class);
|
|
|
|
surveyTemplateQuestionDao.save(questions);
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除原有问题选项
|
|
|
|
List<WlyySurveyTemplateOptionDO> optionDODels = surveyTemplateOptionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
|
|
|
|
if(optionDODels!=null&&optionDODels.size()>0){
|
|
|
|
surveyTemplateOptionDao.delete(optionDODels);
|
|
|
|
}
|
|
|
|
|
|
|
|
//保存新问题选项
|
|
|
|
if(StringUtils.isNotBlank(tempOpJson)){
|
|
|
|
List<WlyySurveyTemplateOptionDO> questions = EntityUtils.jsonToList(tempOpJson, WlyySurveyTemplateOptionDO.class);
|
|
|
|
surveyTemplateOptionDao.save(questions);
|
|
|
|
}
|
|
|
|
|
|
|
|
//保存标签
|
|
|
|
List<WlyySurveyLabelInfoDO> labelDels = surveyLabelInfoDao.findBySurveyTempCode(temp.getId());
|
|
|
|
if(labelDels!=null&&labelDels.size()>0){
|
|
|
|
surveyLabelInfoDao.delete(labelDels);
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(labelJson)){
|
|
|
|
List<WlyySurveyLabelInfoDO> labels = EntityUtils.jsonToList(labelJson, WlyySurveyLabelInfoDO.class);
|
|
|
|
surveyLabelInfoDao.save(labels);
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除检查标签
|
|
|
|
List<WlyySurveyInspLabelInfoDO> labelInspDels = surveyInspLabelInfoDao.findBySurveyTempCode(temp.getId());
|
|
|
|
if(labelDels!=null&&labelDels.size()>0){
|
|
|
|
surveyInspLabelInfoDao.delete(labelInspDels);
|
|
|
|
}
|
|
|
|
//保存检查标签
|
|
|
|
if(StringUtils.isNotBlank(labelInspJson)){
|
|
|
|
List<WlyySurveyInspLabelInfoDO> labels = EntityUtils.jsonToList(labelInspJson, WlyySurveyInspLabelInfoDO.class);
|
|
|
|
surveyInspLabelInfoDao.save(labels);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除
|
|
|
|
* @param tempId
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public Boolean delSurveyTemplate(String tempId){
|
|
|
|
WlyySurveyTemplateDO temp = surveyTemplateDao.findOne(tempId);
|
|
|
|
if(temp!=null){
|
|
|
|
//删除原有问题
|
|
|
|
List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
|
|
|
|
if(questionDODels!=null&&questionDODels.size()>0){
|
|
|
|
surveyTemplateQuestionDao.delete(questionDODels);
|
|
|
|
}
|
|
|
|
//删除原有问题选项
|
|
|
|
List<WlyySurveyTemplateOptionDO> optionDODels = surveyTemplateOptionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
|
|
|
|
if(optionDODels!=null&&optionDODels.size()>0){
|
|
|
|
surveyTemplateOptionDao.delete(optionDODels);
|
|
|
|
}
|
|
|
|
surveyTemplateDao.delete(temp);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================调查问卷发送=====================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 保存问卷科室关系
|
|
|
|
* @param tempId
|
|
|
|
* @param sdJsons
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Boolean saveSurveyDept(String tempId,String sdJsons)throws Exception{
|
|
|
|
|
|
|
|
//删除之前关系
|
|
|
|
List<WlyySurveyDeptDO> dels = surveyDeptDao.findBySurveyTempCode(tempId);
|
|
|
|
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
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public List<Map<String,Object>> findSurveyByDept(String dept){
|
|
|
|
String sql = "SELECT " +
|
|
|
|
" t.id, " +
|
|
|
|
" t.title, " +
|
|
|
|
" t.template_comment AS templateComment " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_template t " +
|
|
|
|
" JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
|
|
|
|
" WHERE " +
|
|
|
|
" d.dept = '"+dept+"'";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询问卷下科室
|
|
|
|
* @param tempId
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public List<Map<String,Object>> findDeptBySurvey(String tempId){
|
|
|
|
String sql ="SELECT " +
|
|
|
|
" d.dept, " +
|
|
|
|
" d.dept_name AS deptName " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_template t " +
|
|
|
|
" JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
|
|
|
|
" WHERE " +
|
|
|
|
" t.id = '"+tempId+"'";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param suJson
|
|
|
|
* @param suaJsons
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Boolean saveSurveyAnswer(String suJson,String suaJsons)throws Exception{
|
|
|
|
|
|
|
|
WlyySurveyUserDO surveyUserDO = objectMapper.readValue(suJson,WlyySurveyUserDO.class);
|
|
|
|
surveyUserDao.save(surveyUserDO);
|
|
|
|
|
|
|
|
//删除问题答案
|
|
|
|
List<WlyySurveyUserAnswerDO> dels = surveyUserAnswerDao.findBySurveyTempCodeAndPatient(surveyUserDO.getSurveyTempCode(),surveyUserDO.getPatient());
|
|
|
|
if(dels!=null&&dels.size()>0){
|
|
|
|
surveyUserAnswerDao.delete(dels);
|
|
|
|
}
|
|
|
|
|
|
|
|
//保存答案
|
|
|
|
if(StringUtils.isNotBlank(suaJsons)){
|
|
|
|
List<WlyySurveyUserAnswerDO> answerDOs = EntityUtils.jsonToList(suaJsons,WlyySurveyUserAnswerDO.class);
|
|
|
|
surveyUserAnswerDao.save(answerDOs);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<WlyySurveyUserAnswerDO> findAnswerBySurveyTempCode(String patient,String tempId){
|
|
|
|
List<WlyySurveyUserAnswerDO> list = surveyUserAnswerDao.findBySurveyTempCodeAndPatient(tempId,patient);
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|