|
@ -1803,16 +1803,70 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
comment = option.get("comment").toString();
|
|
|
haveComment = 1;
|
|
|
}
|
|
|
// 保存到选择题答案表
|
|
|
SurveyOptionAnswers optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
|
|
|
optionAnswer.setScreenResultCode(resultCode);
|
|
|
surveyOptionAnswersDao.save(optionAnswer);
|
|
|
// 选择题修改统计表数量
|
|
|
surveyStatisticsDao.modifyAmount(surveyCode, qstCode, optionCode);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
String content = question.get("content").toString();
|
|
|
if (!StringUtils.isEmpty(content)) {
|
|
|
// 保存到问答题答案表
|
|
|
String code = getCode();
|
|
|
SurveyAnswers surveyAnswer = new SurveyAnswers(code, surveyCode, patient, qstCode, content, createTime);
|
|
|
surveyAnswer.setQuestionResultCode(resultCode);
|
|
|
surveyAnswersDao.save(surveyAnswer);
|
|
|
// 问答题保存到统计表(只负责更改数量不负责创建)
|
|
|
surveyStatisticsDao.modifyAmount(surveyCode, qstCode);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//更改调查对象表答题状态为已答
|
|
|
//surveyUserDao.modifyStatus(surveyCode, patient);
|
|
|
}
|
|
|
|
|
|
public void saveAnswer(String patient,String resultCode, JSONObject jsonData, Boolean save) throws Exception {
|
|
|
System.out.println("********jsonData********* " + jsonData);
|
|
|
//解析json保存各种答案
|
|
|
String surveyCode = jsonData.get("surveyCode").toString();
|
|
|
Date createTime = new Date();
|
|
|
// 获取一维数组
|
|
|
JSONArray questions = jsonData.getJSONArray("questions");
|
|
|
for (int i = 0; i < questions.length(); i++) {
|
|
|
// 获取每一道题的信息
|
|
|
JSONObject question = new JSONObject(questions.get(i).toString());
|
|
|
String qstCode = question.get("qstCode").toString();
|
|
|
//int qstsort = Integer.parseInt(question.get("sort").toString());
|
|
|
int type = Integer.parseInt(question.get("type").toString());
|
|
|
if (type != 2) {
|
|
|
if (question.has("options")) {
|
|
|
// 获取每道题的所有选项
|
|
|
JSONArray options = question.getJSONArray("options");
|
|
|
for (int j = 0; j < options.length(); j++) {
|
|
|
JSONObject option = new JSONObject(options.get(j).toString());
|
|
|
String code = getCode();
|
|
|
String optionCode = option.get("optionCode").toString();
|
|
|
//int optsort = Integer.parseInt(option.get("sort").toString());
|
|
|
String comment = null;
|
|
|
int haveComment = 0;
|
|
|
if (option.has("comment")) {
|
|
|
comment = option.get("comment").toString();
|
|
|
haveComment = 1;
|
|
|
}
|
|
|
// 保存或者更新到选择题答案表
|
|
|
SurveyOptionAnswers optionAnswer = null;
|
|
|
if (StringUtils.isNotBlank(resultCode)){
|
|
|
if (save){
|
|
|
optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
|
|
|
optionAnswer.setScreenResultCode(resultCode);
|
|
|
}else {
|
|
|
optionAnswer = surveyOptionAnswersDao.findOptionAnswer(patient, surveyCode, qstCode, resultCode);
|
|
|
optionAnswer.setOptionsCode(optionCode);
|
|
|
optionAnswer.setOptionComment(comment);
|
|
|
optionAnswer.setCreateTime(new Date());
|
|
|
}else {
|
|
|
optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
|
|
|
optionAnswer.setScreenResultCode(resultCode);
|
|
|
}
|
|
|
surveyOptionAnswersDao.save(optionAnswer);
|
|
|
// 选择题修改统计表数量
|
|
@ -1825,14 +1879,14 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
if (!StringUtils.isEmpty(content)) {
|
|
|
// 保存或者更新问答题答案表
|
|
|
SurveyAnswers surveyAnswer = null;
|
|
|
if (StringUtils.isNotBlank(resultCode)){
|
|
|
surveyAnswer = surveyAnswersDao.findSurveyAnswer(resultCode, surveyCode, qstCode, patient);
|
|
|
surveyAnswer.setContent(content);
|
|
|
surveyAnswer.setCreateTime(new Date());
|
|
|
}else {
|
|
|
if (save){
|
|
|
String code = getCode();
|
|
|
surveyAnswer = new SurveyAnswers(code, surveyCode, patient, qstCode, content, createTime);
|
|
|
surveyAnswer.setQuestionResultCode(resultCode);
|
|
|
}else {
|
|
|
surveyAnswer = surveyAnswersDao.findSurveyAnswer(resultCode, surveyCode, qstCode, patient);
|
|
|
surveyAnswer.setContent(content);
|
|
|
surveyAnswer.setCreateTime(new Date());
|
|
|
}
|
|
|
surveyAnswersDao.save(surveyAnswer);
|
|
|
// 问答题保存到统计表(只负责更改数量不负责创建)
|
|
@ -1960,8 +2014,10 @@ public class ManagerQuestionnaireService extends BaseService {
|
|
|
questionResult.setCreateUserName(user.getName());
|
|
|
questionResult.setCreateTime(new Date());
|
|
|
questionResultDao.save(questionResult);
|
|
|
this.saveAnswer(patientCode, resultCode, jsonData);
|
|
|
}else {
|
|
|
this.saveAnswer(patientCode, resultCode, jsonData, false);
|
|
|
}
|
|
|
this.saveAnswer(patientCode, resultCode, jsonData);
|
|
|
return resultCode;
|
|
|
}
|
|
|
}
|