|
@ -11,7 +11,6 @@ import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
|
|
|
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import com.yihu.wlyy.util.query.BaseJpaService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
@ -97,8 +96,12 @@ public class QuestionnaireManageService extends BaseJpaService {
|
|
|
* @param jsonData
|
|
|
* @param serviceCode
|
|
|
*/
|
|
|
public String saveResultAndAnswer(String patientCode, Integer labelType, String customerCode, Integer source, String jsonData, String serviceCode) {
|
|
|
public String saveResultAndAnswer(String patientCode, Integer labelType, String customerCode, Integer source, String jsonData, String serviceCode) throws Exception {
|
|
|
String url = wlyyUrl + "third/synergy/questionnaire/saveResultAndAnswer";
|
|
|
//查找发放问卷的医生
|
|
|
String sql = "SELECT w.create_user from manage_synergy_workorder_servicer s, manage_synergy_workorder w " +
|
|
|
"where s.workorder_code = w.`code` and s.`code`= '" + serviceCode + "'";
|
|
|
String doctor = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
String response = "";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("labelType", labelType);
|
|
@ -107,17 +110,19 @@ public class QuestionnaireManageService extends BaseJpaService {
|
|
|
params.put("customerCode", customerCode);
|
|
|
params.put("source", source);
|
|
|
params.put("isAgain", 0);
|
|
|
params.put("doctor", doctor);
|
|
|
try {
|
|
|
response = httpClientUtil.post(url, params);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
JSONObject object = JSONObject.parseObject(response);
|
|
|
String questionResultCode = object.getString("data");
|
|
|
if(StringUtils.isNotBlank(questionResultCode)) {
|
|
|
if(object.getInteger("status") == 200) {
|
|
|
String questionResultCode = object.getString("data");
|
|
|
workorderServicerDao.updateRelationCodeByCode(serviceCode, questionResultCode);
|
|
|
return questionResultCode;
|
|
|
}
|
|
|
return questionResultCode;
|
|
|
throw new Exception("保存失败");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -125,14 +130,14 @@ public class QuestionnaireManageService extends BaseJpaService {
|
|
|
* @param surveyCode
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getAnswers(String surveyCode) {
|
|
|
public JSONObject getAnswers(String surveyCode) throws Exception {
|
|
|
String url = wlyyUrl + "third/synergy/questionnaire/getAnswers?id=" + surveyCode;
|
|
|
String response = httpClientUtil.get(url, "UTF-8");
|
|
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
|
|
if(jsonObject.getInteger("status") == 200){
|
|
|
return JSONObject.parseObject(jsonObject.getString("data"));
|
|
|
}
|
|
|
return JSONObject.parseObject(response);
|
|
|
throw new Exception("请求失败");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -145,13 +150,13 @@ public class QuestionnaireManageService extends BaseJpaService {
|
|
|
//查找问卷结果信息
|
|
|
SurveyQuestionResult questionResult = questionResultDao.findByCode(code);
|
|
|
String patient = questionResult.getPatientCode();
|
|
|
String templateCode = questionResult.getTemplateCode();
|
|
|
String surverCode = questionResult.getSurveyCode();
|
|
|
//获取模板问题
|
|
|
List<SurveyQuestionnaire> questionList = surveyQuestionnaireDao.findBySurveyCode(templateCode);
|
|
|
List<SurveyQuestionnaire> questionList = surveyQuestionnaireDao.findBySurveyCode(surverCode);
|
|
|
//查找选项和答案
|
|
|
Map<String, Object> answerMap = new HashMap<>();
|
|
|
String sql = "SELECT soa.*, sqo.content FROM wlyy_survey_option_answers soa LEFT JOIN wlyy_survey_questions_options sqo ON soa.options_code= sqo.code WHERE soa.screen_result_code = ? AND soa.patient=? AND soa.survey_code=?";
|
|
|
List<Map<String, Object>> optionAnswersList = jdbcTemplate.queryForList(sql, new Object[]{code, patient, templateCode});
|
|
|
List<Map<String, Object>> optionAnswersList = jdbcTemplate.queryForList(sql, new Object[]{code, patient, surverCode});
|
|
|
for (SurveyQuestionnaire question : questionList) {
|
|
|
List<Map<String, Object>> optionList = new ArrayList<>();
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
@ -169,13 +174,13 @@ public class QuestionnaireManageService extends BaseJpaService {
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
public JSONObject getQuestionnaireDetail(String surveyCode) {
|
|
|
public JSONObject getQuestionnaireDetail(String surveyCode) throws Exception {
|
|
|
String url = wlyyUrl + "third/synergy/questionnaire/getQuestionnaireDetail?id=" + surveyCode;
|
|
|
String response = httpClientUtil.get(url, "UTF-8");
|
|
|
JSONObject jsonObject = JSONObject.parseObject(response);
|
|
|
if(jsonObject.getInteger("status") == 200){
|
|
|
return JSONObject.parseObject(jsonObject.getString("data"));
|
|
|
}
|
|
|
return JSONObject.parseObject(response);
|
|
|
throw new Exception("请求失败");
|
|
|
}
|
|
|
}
|