|
@ -105,7 +105,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
|
|
|
//计算总数
|
|
|
String totalSql ="SELECT" +
|
|
|
" COUNT(1) AS total" +
|
|
|
" COUNT(1) AS \"total\"" +
|
|
|
" FROM" +
|
|
|
" wlyy_survey_question q " +
|
|
|
" WHERE q.del = '1' ";
|
|
@ -123,21 +123,21 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
Long count = 0L;
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
count = hibenateUtils.objTransformLong(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 " +
|
|
|
" 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 as \"del\", " +
|
|
|
" q.create_time AS \"createTime\", " +
|
|
|
" q.update_time AS \"updateTime\" " +
|
|
|
" FROM " +
|
|
|
" wlyy_survey_question q " +
|
|
|
" WHERE q.del = '1' ";
|
|
@ -152,8 +152,23 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
if (StringUtils.isNoneBlank(creater)){
|
|
|
sql+=" AND q.creater ='"+creater+"' ";
|
|
|
}
|
|
|
sql += " ORDER BY q.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
sql += " ORDER BY q.create_time DESC ";
|
|
|
if ("xm_ykyy_wx".equals(wxId)) {
|
|
|
if (flag){
|
|
|
sql ="SELECT * FROM\n" +
|
|
|
"( SELECT A.*, ROWNUM RN FROM\n" +
|
|
|
" ("+sql+") A \n" +
|
|
|
" WHERE ROWNUM <= "+page*size+" ) \n" +
|
|
|
" WHERE RN >= "+((page-1)*size+1);
|
|
|
|
|
|
}else {
|
|
|
sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
}
|
|
|
List<WlyySurveyQuestionVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyQuestionVO.class));
|
|
|
|
|
|
if(list!=null&&list.size()>0){
|
|
@ -195,6 +210,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
|
|
|
//保存问题
|
|
|
List<WlyySurveyQuestionDO> surveys = EntityUtils.jsonToList(sqjsons, WlyySurveyQuestionDO.class);
|
|
|
for (WlyySurveyQuestionDO wlyySurveyQuestionDO:surveys){
|
|
|
wlyySurveyQuestionDO.setCreateTime(new Date());
|
|
|
wlyySurveyQuestionDO.setUpdateTime(new Date());
|
|
|
}
|
|
|
|
|
|
surveyQuestionDao.save(surveys);
|
|
|
|
|
|
if(surveys!=null&&surveys.size()>0){
|
|
@ -221,6 +241,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
*/
|
|
|
public Boolean updataSurveyQuestion(String sqjson,String sqOptionJson) throws Exception{
|
|
|
WlyySurveyQuestionDO sq = objectMapper.readValue(sqjson,WlyySurveyQuestionDO.class);
|
|
|
sq.setUpdateTime(new Date());
|
|
|
surveyQuestionDao.save(sq);
|
|
|
|
|
|
List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(),"1");
|
|
@ -270,7 +291,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
public MixEnvelop findSurveyTemplate(String title,String creater,String label,Integer page,Integer size){
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
" COUNT(1) AS total" +
|
|
|
" COUNT(1) AS \"total\"" +
|
|
|
" FROM " +
|
|
|
" wlyy_survey_template t ";
|
|
|
if(StringUtils.isNotBlank(label)){
|
|
@ -291,20 +312,20 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
Long count = 0L;
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
count = hibenateUtils.objTransformLong(rstotal.get(0).get("total"));
|
|
|
}
|
|
|
|
|
|
|
|
|
String sql = "SELECT " +
|
|
|
" t.id, " +
|
|
|
" t.title, " +
|
|
|
" t.template_comment AS templateComment, " +
|
|
|
" t.organization, " +
|
|
|
" t.creater, " +
|
|
|
" t.creater_code, " +
|
|
|
" t.create_time AS createTime, " +
|
|
|
" t.del, " +
|
|
|
" t.update_time AS updateTime" +
|
|
|
" t.id as \"id\", " +
|
|
|
" t.title as \"title\", " +
|
|
|
" t.template_comment AS \"templateComment\", " +
|
|
|
" t.organization AS \"organization\", " +
|
|
|
" t.creater AS \"creater\", " +
|
|
|
" t.creater_code AS \"createrCode\", " +
|
|
|
" t.create_time AS \"createTime\", " +
|
|
|
" t.del AS \"del\", " +
|
|
|
" t.update_time AS \"updateTime\"" +
|
|
|
" FROM " +
|
|
|
" wlyy_survey_template t ";
|
|
|
if(StringUtils.isNotBlank(label)){
|
|
@ -321,7 +342,23 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
if (StringUtils.isNoneBlank(creater)){
|
|
|
sql +=" AND t.creater_code = '"+creater+"' ";
|
|
|
}
|
|
|
sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
sql += " ORDER BY t.create_time DESC ";
|
|
|
if ("xm_ykyy_wx".equals(wxId)) {
|
|
|
if (!flag){
|
|
|
sql ="SELECT * FROM\n" +
|
|
|
"( SELECT A.*, ROWNUM RN FROM\n" +
|
|
|
" ("+sql+") A \n" +
|
|
|
" WHERE ROWNUM <= "+page*size+" ) \n" +
|
|
|
" WHERE RN >= "+((page-1)*size+1);
|
|
|
System.out.println(sql);
|
|
|
}else {
|
|
|
sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
}
|
|
|
|
|
|
List<WlyySurveyTemplateVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyTemplateVO.class));
|
|
|
|
|
@ -440,8 +477,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
if(null!=templateDO){
|
|
|
temp.setCreater(templateDO.getCreater());
|
|
|
temp.setCreaterCode(templateDO.getCreaterCode());
|
|
|
temp.setUpdateTime(new Date());
|
|
|
}
|
|
|
}
|
|
|
temp.setCreateTime(new Date());
|
|
|
temp.setUpdateTime(new Date());
|
|
|
temp = surveyTemplateDao.save(temp);
|
|
|
//删除原有问题
|
|
|
List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
|
|
@ -455,6 +495,9 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
wlyySurveyTemplateQuestionDO.setTemplateCode(temp.getId());
|
|
|
wlyySurveyTemplateQuestionDO.setCode(wlyySurveyTemplateQuestionDO.getId());
|
|
|
wlyySurveyTemplateQuestionDO.setId(UUID.randomUUID().toString());
|
|
|
wlyySurveyTemplateQuestionDO.setCreateTime(new Date());
|
|
|
wlyySurveyTemplateQuestionDO.setUpdateTime(new Date());
|
|
|
|
|
|
}
|
|
|
surveyTemplateQuestionDao.save(questions);
|
|
|
}
|
|
@ -472,6 +515,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
wlyySurveyTemplateOptionDO.setTemplateCode(temp.getId());
|
|
|
wlyySurveyTemplateOptionDO.setCode(wlyySurveyTemplateOptionDO.getId());
|
|
|
wlyySurveyTemplateOptionDO.setId(UUID.randomUUID()+"");
|
|
|
|
|
|
}
|
|
|
surveyTemplateOptionDao.save(options);
|
|
|
}
|
|
@ -580,9 +624,9 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
*/
|
|
|
public List<Map<String,Object>> findSurveyByDept(String dept){
|
|
|
String sql = "SELECT " +
|
|
|
" t.id, " +
|
|
|
" t.title, " +
|
|
|
" t.template_comment AS templateComment " +
|
|
|
" t.id as \"id\", " +
|
|
|
" t.title as \"title\", " +
|
|
|
" t.template_comment AS \"templateComment\" " +
|
|
|
" FROM " +
|
|
|
" wlyy_survey_template t " +
|
|
|
" JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
|
|
@ -616,9 +660,9 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
*/
|
|
|
public List<Map<String,Object>> findDeptBySurvey(String tempId){
|
|
|
String sql ="SELECT " +
|
|
|
" d.survey_temp_code AS surveyTempCode," +
|
|
|
" d.dept, " +
|
|
|
" d.dept_name AS deptName " +
|
|
|
" d.survey_temp_code AS \"surveyTempCode\"," +
|
|
|
" d.dept AS \"dept\", " +
|
|
|
" d.dept_name AS \"deptName\" " +
|
|
|
" FROM " +
|
|
|
" wlyy_survey_template t " +
|
|
|
" JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
|
|
@ -653,6 +697,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
List<WlyySurveyUserAnswerDO> answerDOs = EntityUtils.jsonToList(suaJsons,WlyySurveyUserAnswerDO.class);
|
|
|
for(WlyySurveyUserAnswerDO answerDO : answerDOs){
|
|
|
answerDO.setSurverUserId(surveyUserDO.getId());
|
|
|
answerDO.setCreateTime(new Date());
|
|
|
/*WlyySurveyTemplateOptionDO surveyTemplateOptionDO = surveyTemplateOptionDao.findOne(answerDO.getTempOptionCode());
|
|
|
answerDO.setTempQuestionCode(surveyTemplateOptionDO.getQuestionCode());
|
|
|
answerDO.setTempOptionCode(surveyTemplateOptionDO.getCode());*/
|
|
@ -763,7 +808,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
public MixEnvelop findQuestionInfoList(String comment, String tempId,String content, String tempQuestionCode,String tempOptionCode,Integer page,Integer size){
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
" COUNT(1) AS total" +
|
|
|
" COUNT(1) AS \"total\"" +
|
|
|
" FROM " +
|
|
|
" wlyy_survey_user_answer t " +
|
|
|
" WHERE 1=1";
|
|
@ -786,22 +831,22 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
Long count = 0L;
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
count = hibenateUtils.objTransformLong(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" +
|
|
|
" t.id as \"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 AS \"comment\", " +
|
|
|
" t.content AS \"content\", " +
|
|
|
" t.patient AS \"patient\"," +
|
|
|
" t.patient_name AS \"patientName\"," +
|
|
|
" t.score AS \"score\"," +
|
|
|
" t.create_time AS \"createTime\"" +
|
|
|
" FROM " +
|
|
|
" wlyy_survey_user_answer t " +
|
|
|
" WHERE 1=1";
|
|
@ -820,8 +865,23 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
if(StringUtils.isNotBlank(tempId)){
|
|
|
sql += " AND t.survey_temp_code ='"+tempId+"'";
|
|
|
}
|
|
|
sql += " ORDER BY t.create_time DESC LIMIT " + (page - 1) * size + "," + size + " ";
|
|
|
sql += " ORDER BY t.create_time DESC ";
|
|
|
if ("xm_ykyy_wx".equals(wxId)) {
|
|
|
if (flag){
|
|
|
sql ="SELECT * FROM\n" +
|
|
|
"( SELECT A.*, ROWNUM RN FROM\n" +
|
|
|
" ("+sql+") A \n" +
|
|
|
" WHERE ROWNUM <= "+page*size+" ) \n" +
|
|
|
" WHERE RN >= "+((page-1)*size+1);
|
|
|
|
|
|
}else {
|
|
|
sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
sql+="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);
|
|
@ -837,7 +897,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
public MixEnvelop findAnswerList(String tempId,String patient,String patientName,String title,Integer page,Integer size){
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
" COUNT(1) AS total" +
|
|
|
" COUNT(1) AS \"total\"" +
|
|
|
" FROM " +
|
|
|
" wlyy_survey_user t " +
|
|
|
" WHERE 1=1 and t.status = 1 ";
|
|
@ -857,24 +917,24 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
Long count = 0L;
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
count = hibenateUtils.objTransformLong(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," +
|
|
|
" p.sex" +
|
|
|
" t.id as \"id\", " +
|
|
|
" t.survey_temp_code AS \"surveyTempCode\", " +
|
|
|
" t.survey_temp_title AS \"surveyTempTitle\", " +
|
|
|
" t.patient as \"patient\"," +
|
|
|
" t.patient_name AS \"patientName\"," +
|
|
|
" t.dept as \"dept\"," +
|
|
|
" t.dept_name AS \"deptName\"," +
|
|
|
" t.doctor AS \"doctor\"," +
|
|
|
" t.doctor_name AS \"doctorName\"," +
|
|
|
" t.status AS \"status\"," +
|
|
|
" t.end_time AS \"endTime\"," +
|
|
|
" t.create_time AS \"createTime\"," +
|
|
|
" p.idcard as \"idcard\"," +
|
|
|
" p.sex as \"sex\"" +
|
|
|
" FROM " +
|
|
|
" wlyy_survey_user t " +
|
|
|
" JOIN base_patient p ON t.patient = p.id " +
|