|
@ -289,22 +289,22 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
String openId = p.getOpenid();
|
|
|
json.put("keyword2", sdf.format(new Date()));
|
|
|
json.put("toUser", c);
|
|
|
json.put("survey_id",surveyCode );
|
|
|
json.put("survey_id", surveyCode);
|
|
|
json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
|
|
|
|
|
|
//判断是否判定openId,有没有发则查找家人发送
|
|
|
if(StringUtils.isNotBlank(p.getOpenid())){
|
|
|
if (StringUtils.isNotBlank(p.getOpenid())) {
|
|
|
// 添加到发送队列
|
|
|
PushMsgTask.getInstance().putWxMsg(accessToken, 11, openId, name, json);
|
|
|
}else{
|
|
|
JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(p.getOpenid());
|
|
|
} else {
|
|
|
JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(p.getOpenid());
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
if(StringUtils.isNotBlank(member.getOpenid())){
|
|
|
if (StringUtils.isNotBlank(member.getOpenid())) {
|
|
|
String first = (String) json.get("first");
|
|
|
json.remove("first");
|
|
|
try{
|
|
|
json.put("first",weiXinOpenIdUtils.getTitleMes(p,j.getInt("relation"),member.getName())+first);
|
|
|
}catch (Exception e){
|
|
|
try {
|
|
|
json.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), member.getName()) + first);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
PushMsgTask.getInstance().putWxMsg(accessToken, 11, member.getOpenid(), member.getName(), json);
|
|
@ -337,6 +337,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
int sort = Integer.parseInt(tempQestion.get("sort").toString());
|
|
|
int del = 1;
|
|
|
String qstNextQuestion = null;
|
|
|
// 前提一定要有nextQuestion字段传入,没有为""
|
|
|
if (!StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
|
|
|
// optionNextQuestion = tempOption.get("nextQuestion").toString();
|
|
|
qstNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempQestion.get("nextQuestion"));
|
|
@ -445,6 +446,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
|
|
|
// optionNextQuestion = tempOption.get("nextQuestion").toString();
|
|
|
optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
|
|
|
optionNextQuestion = (optionNextQuestion == null ? "0" : optionNextQuestion);
|
|
|
}
|
|
|
|
|
|
// 自主创建,插入表
|
|
@ -1187,6 +1189,8 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
}
|
|
|
|
|
|
question.put("title", title);
|
|
|
// 增加返回模板问题编码
|
|
|
question.put("qstCode", qstcode);
|
|
|
question.put("isRequired", isRequired);
|
|
|
question.put("comment", comment);
|
|
|
question.put("type", type);
|
|
@ -1215,9 +1219,17 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存为新模板
|
|
|
*
|
|
|
* @param code 问卷编码
|
|
|
* @param modifyTitle 标题重复后修改后的标题(第一次为null)
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public int savaSurveyAsTemplate(String code, String modifyTitle) throws Exception {
|
|
|
Survey survey = surveyDao.findById(code);
|
|
|
String tempCode = getCode();
|
|
|
Survey survey = surveyDao.findById(code);
|
|
|
String title = survey.getTitle();
|
|
|
String templateComment = survey.getSurveyComment();
|
|
|
String creater = survey.getCreater();
|
|
@ -1281,6 +1293,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
//根据模板创建的问卷再次保存为问卷时是修改模板
|
|
|
public int modifyTemplate(String code, String templateCode, String modifyTitle) throws Exception {
|
|
|
Survey survey = surveyDao.findById(code);
|
|
|
String title = survey.getTitle();
|
|
@ -1312,9 +1325,10 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
// surveyLabelInfoDao.save(surveyLabelInfo1);
|
|
|
surveyLabelInfoDao.modifyLabel(templateCode, surveyLabelInfo.getLabel());
|
|
|
}
|
|
|
List<SurveyQuestionnaire> surveyQuestionnaires = surveyQuestionnaireDao.findById(survey.getCode());
|
|
|
List<SurveyQuestionnaire> surveyQuestionnaires = surveyQuestionnaireDao.findById(code);
|
|
|
for (SurveyQuestionnaire question : surveyQuestionnaires) {
|
|
|
String qstCode = getCode();
|
|
|
// String qstCode = getCode();
|
|
|
String qstCode = question.getCode();
|
|
|
String qstTitle = question.getTitle();
|
|
|
String qstComment = question.getQuestionComment();
|
|
|
Integer qstType = question.getQuestionType();
|
|
@ -1329,6 +1343,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
// SurveyTemplateQuestions surveyTemplateQuestions = new SurveyTemplateQuestions(qstCode, qstTitle, qstComment, qstType, templateCode, isRequired, minNum, maxNum, sort, next, null, de, createTiem, updateTiem);
|
|
|
// 更改问题到模板问题表
|
|
|
// surveyTemplateQuestionsDao.save(surveyTemplateQuestions);
|
|
|
System.out.println(templateCode+","+qstCode+qstTitle+","+qstComment+","+qstType+","+isRequired+","+minNum+","+maxNum+","+sort+","+next);
|
|
|
surveyTemplateQuestionsDao.modifyQuestion(templateCode, qstCode, qstTitle, qstComment, qstType, isRequired, minNum, maxNum, sort, next);
|
|
|
if (qstType != 2) {
|
|
|
List<SurveyQuestionnaireOptions> surveyQuestionnaireOptions = surveyQuestionnaireOptionsDao.findByIdAndQstCode(code, question.getCode());
|
|
@ -1339,6 +1354,7 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
// surveyTemplateOptionsDao.save(surveyTemplateOptions);
|
|
|
surveyTemplateOptionsDao.modifyOption(templateCode, qstCode, option.getCode(),
|
|
|
option.getHaveComment(), option.getContent(), option.getQuestionCodeNext(), option.getIsRequired(), option.getSort());
|
|
|
System.out.println("=============>");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -1395,9 +1411,9 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
// 1.服务 2.健康 3疾病
|
|
|
JSONObject jsonObject = new JSONObject(json);
|
|
|
String sex = jsonObject.get("sex").toString();
|
|
|
String str = "SELECT s.patient FROM ( " +
|
|
|
String str = "SELECT DISTINCT s.patient FROM ( " +
|
|
|
"SELECT t.patient,GROUP_CONCAT(t.label_name) label_name FROM wlyy_sign_patient_label_info t " +
|
|
|
"WHERE t.patient IN (SELECT a.patient FROM wlyy_sign_family a WHERE a.status IN(1,2,3)) AND t.patient IN (SELECT b.`code` FROM wlyy_patient b WHERE b.`openid` IS NOT NULL AND b.`openid`!='' ";
|
|
|
"WHERE t.patient IN (SELECT a.patient FROM wlyy_sign_family a WHERE a.status IN(1,2,3)) and t.status = 1 AND t.patient IN (SELECT b.`code` FROM wlyy_patient b WHERE b.`openid` IS NOT NULL AND b.`openid`!='' ";
|
|
|
if (!"0".equals(sex)) {
|
|
|
str += " AND b.sex= " + sex + " ) GROUP BY t.patient ) s WHERE 1=1 ";
|
|
|
} else {
|
|
@ -1475,75 +1491,10 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
if (!StringUtils.isEmpty(dis)) {
|
|
|
str += " AND ( " + dis.substring(0, dis.lastIndexOf("OR")) + " ) ";
|
|
|
}
|
|
|
/* if (Integer.parseInt(sex) != 0) {
|
|
|
str += "and t.sex = " + sex;
|
|
|
}
|
|
|
JSONArray service = jsonObject.getJSONArray("service");
|
|
|
String ser = "";
|
|
|
String servi = "";
|
|
|
for (Object serv : service) {
|
|
|
if ("0".equals(serv.toString())) {
|
|
|
ser += ",";
|
|
|
break;
|
|
|
} else {
|
|
|
ser += serv.toString() + ",";
|
|
|
}
|
|
|
}
|
|
|
ser = ser.substring(0, ser.length() - 1);
|
|
|
if (ser.length() != 0) {
|
|
|
servi = "(t.`label_type`=1 AND t.`label`IN(" + ser + "))";
|
|
|
}
|
|
|
JSONArray healthCondition = jsonObject.getJSONArray("healthCondition");
|
|
|
String heal = "";
|
|
|
String healt = "";
|
|
|
for (Object health : healthCondition) {
|
|
|
if ("0".equals(health.toString())) {
|
|
|
heal += ",";
|
|
|
break;
|
|
|
} else {
|
|
|
heal += health.toString() + ",";
|
|
|
}
|
|
|
}
|
|
|
heal = heal.substring(0, heal.length() - 1);
|
|
|
if (heal.length() != 0) {
|
|
|
healt = "(t.`label_type`=2 AND t.`label`IN(" + heal + "))";
|
|
|
}
|
|
|
JSONArray disease = jsonObject.getJSONArray("disease");
|
|
|
String dise = "";
|
|
|
String diseas = "";
|
|
|
for (Object disea : disease) {
|
|
|
if ("0".equals(disea.toString())) {
|
|
|
dise += ",";
|
|
|
break;
|
|
|
} else {
|
|
|
dise += disea.toString() + ",";
|
|
|
}
|
|
|
}
|
|
|
dise = dise.substring(0, dise.length() - 1);
|
|
|
if (dise.length() != 0) {
|
|
|
diseas = "(t.`label_type`=3 AND t.`label`IN(" + dise + "))";
|
|
|
}
|
|
|
if (servi.length() != 0 & healt.length() != 0 & diseas.length() != 0) {
|
|
|
str += "AND ( " + servi + "OR" + healt + "OR" + diseas + " )";
|
|
|
} else if (servi.length() != 0 & healt.length() != 0 & diseas.length() == 0) {
|
|
|
str += "AND ( " + servi + "OR" + healt + " )";
|
|
|
} else if (servi.length() != 0 & healt.length() == 0 & diseas.length() != 0) {
|
|
|
str += "AND ( " + servi + "OR" + diseas + " )";
|
|
|
} else if (servi.length() == 0 & healt.length() != 0 & diseas.length() != 0) {
|
|
|
str += "AND ( " + healt + "OR" + diseas + " )";
|
|
|
} else if (servi.length() != 0 & healt.length() == 0 & diseas.length() == 0) {
|
|
|
str += "AND " + servi;
|
|
|
} else if (servi.length() == 0 & healt.length() != 0 & diseas.length() == 0) {
|
|
|
str += "AND " + healt;
|
|
|
} else if (servi.length() == 0 & healt.length() == 0 & diseas.length() != 0) {
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|