|
@ -88,7 +88,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
|
|
|
|
|
|
public String createSurvey(String doctor, JSONObject jsonStr, String accessToken) throws Exception {
|
|
|
System.out.println("=============>"+jsonStr);
|
|
|
System.out.println("=============>" + jsonStr);
|
|
|
// 问卷信息
|
|
|
String surveyCode = getCode();
|
|
|
String surveyName = jsonStr.getString("surveyName");
|
|
@ -302,6 +302,12 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
int isRequired = Integer.parseInt(tempQestion.get("isRequired").toString());
|
|
|
int sort = Integer.parseInt(tempQestion.get("sort").toString());
|
|
|
int del = 1;
|
|
|
String qstNextQuestion = null;
|
|
|
if (!StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
|
|
|
// optionNextQuestion = tempOption.get("nextQuestion").toString();
|
|
|
qstNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempQestion.get("nextQuestion"));
|
|
|
qstNextQuestion =(qstNextQuestion==null ?"0" :qstNextQuestion);
|
|
|
}
|
|
|
switch (type) {
|
|
|
case 0:
|
|
|
// 单选
|
|
@ -317,7 +323,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
// 单选没有最大最小选项数及题目逻辑跳转
|
|
|
surveyQuestionnaire.setMinNum(null);
|
|
|
surveyQuestionnaire.setMaxNum(null);
|
|
|
surveyQuestionnaire.setQuestionCodeNext(null);
|
|
|
surveyQuestionnaire.setQuestionCodeNext(qstNextQuestion);
|
|
|
|
|
|
surveyQuestionnaireDao.save(surveyQuestionnaire);
|
|
|
// =======================选项保存=========================
|
|
@ -334,7 +340,8 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
String optionNextQuestion = null;
|
|
|
if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
|
|
|
// optionNextQuestion = tempOption.get("nextQuestion").toString();
|
|
|
optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode,tempOption.get("nextQuestion"));
|
|
|
optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
|
|
|
optionNextQuestion =(optionNextQuestion==null ?"0" :optionNextQuestion);
|
|
|
}
|
|
|
// 自主创建,插入表
|
|
|
SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions();
|
|
@ -379,7 +386,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
surveyQuestionnaire1.setMinNum(minOptions);
|
|
|
surveyQuestionnaire1.setMaxNum(maxOptions);
|
|
|
surveyQuestionnaire1.setSort(sort);
|
|
|
surveyQuestionnaire1.setQuestionCodeNext(null);
|
|
|
surveyQuestionnaire1.setQuestionCodeNext(qstNextQuestion);
|
|
|
surveyQuestionnaire1.setDel(del);
|
|
|
|
|
|
surveyQuestionnaireDao.save(surveyQuestionnaire1);
|
|
@ -398,7 +405,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
String optionNextQuestion = null;
|
|
|
if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
|
|
|
// optionNextQuestion = tempOption.get("nextQuestion").toString();
|
|
|
optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode,tempOption.get("nextQuestion"));
|
|
|
optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
|
|
|
}
|
|
|
|
|
|
// 自主创建,插入表
|
|
@ -426,11 +433,12 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
break;
|
|
|
case 2:
|
|
|
// 问答特有属性
|
|
|
String nextQuestion = null;
|
|
|
if (tempQestion.has("nextQuestion")) {
|
|
|
// nextQuestion = tempQestion.get("nextQuestion").toString();
|
|
|
/*String nextQuestion = null;
|
|
|
if (StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
|
|
|
nextQuestion = tempQestion.get("nextQuestion").toString();
|
|
|
}else {
|
|
|
nextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode,tempQestion.get("nextQuestion"));
|
|
|
}
|
|
|
}*/
|
|
|
SurveyQuestionnaire surveyQuestionnaire2 = new SurveyQuestionnaire();
|
|
|
surveyQuestionnaire2.setCode(questionnaireCode);
|
|
|
surveyQuestionnaire2.setTitle(title);
|
|
@ -442,7 +450,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
surveyQuestionnaire2.setMinNum(null);
|
|
|
surveyQuestionnaire2.setMaxNum(null);
|
|
|
surveyQuestionnaire2.setSort(sort);
|
|
|
surveyQuestionnaire2.setQuestionCodeNext(nextQuestion);
|
|
|
surveyQuestionnaire2.setQuestionCodeNext(qstNextQuestion);
|
|
|
surveyQuestionnaire2.setDel(del);
|
|
|
|
|
|
surveyQuestionnaireDao.save(surveyQuestionnaire2);
|
|
@ -623,7 +631,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
int isRequired = questionnair.getIsRequired();
|
|
|
int sort = questionnair.getSort();
|
|
|
int type = questionnair.getQuestionType();
|
|
|
if (questionnair.getMaxNum()!= null) {
|
|
|
if (questionnair.getMaxNum() != null) {
|
|
|
int maxNum = questionnair.getMaxNum();
|
|
|
question.put("maxNum", maxNum);
|
|
|
}
|
|
@ -638,7 +646,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
if (questionnair.getQuestionCodeNext() != null) {
|
|
|
String next = questionnair.getQuestionCodeNext();
|
|
|
SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
|
|
|
question.put("nextQuestion", sq.getSort());
|
|
|
question.put("nextQuestion", sq==null?0:sq.getSort());
|
|
|
}
|
|
|
|
|
|
// List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findById(qstcode);
|
|
@ -657,7 +665,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
System.out.println("=============optCode============== " + option.getCode());
|
|
|
System.out.println("=============sq============== " + sq);
|
|
|
System.out.println("=============next============== " + next);
|
|
|
opt.put("nextQuestion", sq.getSort());
|
|
|
opt.put("nextQuestion", sq==null?0:sq.getSort());
|
|
|
}
|
|
|
opt.put("content", conetent);
|
|
|
opt.put("sort", st);
|
|
@ -1150,7 +1158,6 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
questions.add(question);
|
|
|
}
|
|
|
|
|
@ -1161,11 +1168,11 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
jsonObject.put("comment", tempComment);
|
|
|
jsonObject.put("label", labels);
|
|
|
jsonObject.put("questions", questions);
|
|
|
|
|
|
System.out.println("==========jsonObject============" + jsonObject);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
public int savaSurveyAsTemplate(String code) throws Exception {
|
|
|
public int savaSurveyAsTemplate(String code, String modifyTitle) throws Exception {
|
|
|
Survey survey = surveyDao.findById(code);
|
|
|
String tempCode = getCode();
|
|
|
String title = survey.getTitle();
|
|
@ -1174,10 +1181,20 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
Date createTime = survey.getCreateTime();
|
|
|
Date updateTime = survey.getUpdateTime();
|
|
|
// 查询问卷标题重复情况
|
|
|
int number = surveyTemplatesDao.distinctByTitle(title);
|
|
|
if (number!=0){
|
|
|
int likeNum = surveyTemplatesDao.distinctLikeTitle(title+"%");
|
|
|
return likeNum;
|
|
|
int number = 0;
|
|
|
if (StringUtils.isEmpty(modifyTitle)) {
|
|
|
number = surveyTemplatesDao.distinctByTitle(title);
|
|
|
} else {
|
|
|
number = surveyTemplatesDao.distinctByTitle(modifyTitle);
|
|
|
title = modifyTitle;
|
|
|
}
|
|
|
if (number != 0 && StringUtils.isEmpty(modifyTitle)) {
|
|
|
int likeNum = surveyTemplatesDao.distinctLikeTitle(title + "%");
|
|
|
return likeNum;
|
|
|
}
|
|
|
if (number != 0 && !StringUtils.isEmpty(modifyTitle)) {
|
|
|
int likeNum = surveyTemplatesDao.distinctLikeTitle(modifyTitle + "%");
|
|
|
return likeNum;
|
|
|
}
|
|
|
SurveyTemplates surveyTemplates = new SurveyTemplates(tempCode, title, templateComment, creater, 1, createTime, updateTime);
|
|
|
// 保存模板信息
|
|
@ -1221,15 +1238,25 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
public int modifyTemplate(String code, String templateCode) throws Exception {
|
|
|
public int modifyTemplate(String code, String templateCode, String modifyTitle) throws Exception {
|
|
|
Survey survey = surveyDao.findById(code);
|
|
|
String title = survey.getTitle();
|
|
|
String templateComment = survey.getSurveyComment();
|
|
|
// 查询问卷标题重复情况
|
|
|
int number = surveyTemplatesDao.distinctByTitle(title);
|
|
|
if (number!=0){
|
|
|
int likeNum = surveyTemplatesDao.distinctLikeTitle(title+"%");
|
|
|
return likeNum;
|
|
|
int number = 0;
|
|
|
if (StringUtils.isEmpty(modifyTitle)) {
|
|
|
number = surveyTemplatesDao.distinctByTitle(title);
|
|
|
} else {
|
|
|
number = surveyTemplatesDao.distinctByTitle(modifyTitle);
|
|
|
title = modifyTitle;
|
|
|
}
|
|
|
if (number != 0 && StringUtils.isEmpty(modifyTitle)) {
|
|
|
int likeNum = surveyTemplatesDao.distinctLikeTitle(title + "%");
|
|
|
return likeNum;
|
|
|
}
|
|
|
if (number != 0 && !StringUtils.isEmpty(modifyTitle)) {
|
|
|
int likeNum = surveyTemplatesDao.distinctLikeTitle(modifyTitle + "%");
|
|
|
return likeNum;
|
|
|
}
|
|
|
// SurveyTemplates surveyTemplates = new SurveyTemplates(templateCode, title, templateComment, creater, 1, creater, updateTime);
|
|
|
// 更改模板信息
|
|
@ -1394,10 +1421,10 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
case "0":
|
|
|
break disea;
|
|
|
case "1":
|
|
|
dis += " s.label_name LIKE '%糖尿病%' ";
|
|
|
dis += " s.label_name LIKE '%高血压%' ";
|
|
|
break;
|
|
|
case "2":
|
|
|
dis += " s.label_name LIKE '%高血压%' ";
|
|
|
dis += " s.label_name LIKE '%糖尿病%' ";
|
|
|
break;
|
|
|
}
|
|
|
dis += " OR ";
|
|
@ -1469,6 +1496,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
str += "AND " + diseas;
|
|
|
}*/
|
|
|
// Map<String, Object> patients = jdbcTemplate.queryForMap(str);
|
|
|
System.out.println("=====query sql =======>>>>" + str);
|
|
|
List<String> patients = jdbcTemplate.queryForList(str, String.class);
|
|
|
return patients;
|
|
|
}
|
|
@ -1489,14 +1517,16 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
this.code = code;
|
|
|
this.codes = codes;
|
|
|
this.accessToken = accessToken;
|
|
|
System.out.println("survey_id >>>>>>"+code);
|
|
|
System.out.println("survey_id ===================>>>>>>" + code);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
synchronized (this) {
|
|
|
Object obj = new Object();
|
|
|
synchronized (obj) {
|
|
|
json.put("survey_id", code);
|
|
|
for (String cod : codes) {
|
|
|
System.out.println("=========patient code ===========》" + cod);
|
|
|
Patient p = patientDao.findByCode(cod);
|
|
|
String name = p.getName();
|
|
|
String openId = p.getOpenid();
|