|
@ -8,6 +8,7 @@ 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.utils.StringUtil;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -43,13 +44,17 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
private SurveyTemplateQuestionDao surveyTemplateQuestionDao;
|
|
private SurveyTemplateQuestionDao surveyTemplateQuestionDao;
|
|
@Autowired
|
|
@Autowired
|
|
private SurveyTemplateOptionDao surveyTemplateOptionDao;
|
|
private SurveyTemplateOptionDao surveyTemplateOptionDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyLabelInfoDao surveyLabelInfoDao;
|
|
|
|
@Autowired
|
|
|
|
private SurveyInspLabelInfoDao surveyInspLabelInfoDao;
|
|
/**
|
|
/**
|
|
* 查询字典
|
|
* 查询字典
|
|
* 1.surveyLabel;2.surveyScreenLabel
|
|
* 1.surveyLabel;2.surveyScreenLabel
|
|
* @param name
|
|
* @param name
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public List<WlyyHospitalSysDictVO> getSurveyLabel(String name){
|
|
|
|
|
|
public List<WlyyHospitalSysDictVO> findSurveyLabel(String name){
|
|
List<WlyyHospitalSysDictVO> list = new ArrayList<>();
|
|
List<WlyyHospitalSysDictVO> list = new ArrayList<>();
|
|
return convertToModels(sysDictDao.findByDictName(name),list,WlyyHospitalSysDictVO.class);
|
|
return convertToModels(sysDictDao.findByDictName(name),list,WlyyHospitalSysDictVO.class);
|
|
}
|
|
}
|
|
@ -105,7 +110,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
if(questionType!=null){
|
|
if(questionType!=null){
|
|
sql+=" AND q.question_type ="+questionType;
|
|
sql+=" AND q.question_type ="+questionType;
|
|
}
|
|
}
|
|
sql += " ORDER BY o.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
sql += " ORDER BY q.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
List<WlyySurveyQuestionVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyQuestionVO.class));
|
|
List<WlyySurveyQuestionVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyQuestionVO.class));
|
|
|
|
|
|
@ -267,7 +272,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
if(StringUtils.isNotBlank(label)){
|
|
if(StringUtils.isNotBlank(label)){
|
|
sql += " i.label_code ='"+label+"'";
|
|
sql += " i.label_code ='"+label+"'";
|
|
}
|
|
}
|
|
sql += " ORDER BY o.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
List<WlyySurveyTemplateVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyTemplateVO.class));
|
|
List<WlyySurveyTemplateVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyTemplateVO.class));
|
|
|
|
|
|
@ -290,6 +295,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
WlyySurveyTemplateDO templateDO = surveyTemplateDao.findOne(tempId);
|
|
WlyySurveyTemplateDO templateDO = surveyTemplateDao.findOne(tempId);
|
|
WlyySurveyTemplateVO templateVO = convertToModel(templateDO,WlyySurveyTemplateVO.class);
|
|
WlyySurveyTemplateVO templateVO = convertToModel(templateDO,WlyySurveyTemplateVO.class);
|
|
templateVO.setLabels(findSurveyTemplateLabel(tempId));
|
|
templateVO.setLabels(findSurveyTemplateLabel(tempId));
|
|
|
|
templateVO.setInsplabels(findSurveyInspTemplateLabel(tempId));
|
|
|
|
|
|
List<WlyySurveyTemplateQuestionDO> tqDOs = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(tempId,"1");
|
|
List<WlyySurveyTemplateQuestionDO> tqDOs = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(tempId,"1");
|
|
if(tqDOs!=null&&tqDOs.size()>0){
|
|
if(tqDOs!=null&&tqDOs.size()>0){
|
|
@ -309,19 +315,98 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
return templateVO;
|
|
return templateVO;
|
|
}
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> findSurveyTemplateLabel(String tempId){
|
|
|
|
String sql ="SELECT " +
|
|
|
|
" i.label_code AS labelCode, " +
|
|
|
|
" i.label_name AS labelName " +
|
|
|
|
" FROM " +
|
|
|
|
" wlyy_survey_label_info i " +
|
|
|
|
" WHERE " +
|
|
|
|
" i.survey_temp_code = '"+tempId+"'";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
return list;
|
|
|
|
|
|
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 = (List<WlyySurveyTemplateQuestionDO>) com.alibaba.fastjson.JSONArray.parseArray(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 = (List<WlyySurveyTemplateOptionDO>) com.alibaba.fastjson.JSONArray.parseArray(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 = (List<WlyySurveyLabelInfoDO>) com.alibaba.fastjson.JSONArray.parseArray(labelJson, WlyySurveyLabelInfoDO.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除检查标签
|
|
|
|
List<WlyySurveyInspLabelInfoDO> labelInspDels = surveyInspLabelInfoDao.findBySurveyTempCode(temp.getId());
|
|
|
|
if(labelDels!=null&&labelDels.size()>0){
|
|
|
|
surveyInspLabelInfoDao.delete(labelInspDels);
|
|
|
|
}
|
|
|
|
//保存检查标签
|
|
|
|
if(StringUtils.isNotBlank(labelInspJson)){
|
|
|
|
List<WlyySurveyInspLabelInfoDO> labels = (List<WlyySurveyInspLabelInfoDO>) com.alibaba.fastjson.JSONArray.parseArray(labelInspJson, WlyySurveyInspLabelInfoDO.class);
|
|
|
|
surveyInspLabelInfoDao.save(labels);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
// public Boolean saveSurveyTemplate(){
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
|
* 删除
|
|
|
|
* @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;
|
|
|
|
}
|
|
}
|
|
}
|