| 
					
				 | 
			
			
				@ -94,7 +94,6 @@ public class ManagerQuestionnaireService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String createSurvey(String doctor, JSONObject jsonStr, String accessToken) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        System.out.println("createSurvey ======》" + jsonStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        问卷信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String surveyCode = getCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String surveyName = jsonStr.getString("surveyName"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -345,8 +344,9 @@ public class ManagerQuestionnaireService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //                选择题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray options = new JSONArray(tempQestion.get("options").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (Object option : options) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String optionCode = getCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        String optionCode = getCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONObject tempOption = new JSONObject(option.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String optionCode = tempOption.get("optCode").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String optionComment = tempOption.get("content").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        int required = Integer.parseInt(tempOption.get("isRequired").toString()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -411,8 +411,9 @@ public class ManagerQuestionnaireService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //                选择题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray options1 = new JSONArray(tempQestion.get("options").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (Object option : options1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String optionCode = getCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        String optionCode = getCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        JSONObject tempOption = new JSONObject(option.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String optionCode = tempOption.get("optCode").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String optionComment = tempOption.get("content").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        int required = Integer.parseInt(tempOption.get("isRequired").toString()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1147,16 +1148,18 @@ public class ManagerQuestionnaireService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (SurveyTemplateOptions option : options) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String, Object> opt = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String conetent = option.getContent(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String optCode = option.getCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                int haveComment = option.getHaveComment(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                int required = option.getIsRequired(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                int optsort = option.getSort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!StringUtils.isEmpty(option.getQuestionCodeNext())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String next = option.getQuestionCodeNext(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    SurveyTemplateQuestions tempQst = surveyTemplateQuestionsDao.findById(id, next); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    跳题结束怎么办? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    跳题结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    opt.put("nextQuestion", tempQst == null ? 0 : tempQst.getSort()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                opt.put("optCode", optCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                opt.put("isRequired", required); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                opt.put("content", conetent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                opt.put("sort", optsort); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1297,6 +1300,11 @@ public class ManagerQuestionnaireService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        更改模板标签信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            surveyLabelInfoDao.modifyLabel(templateCode, surveyLabelInfo.getLabel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SurveyTemplateQuestions> ques = surveyTemplateQuestionsDao.findById(templateCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List questions = new ArrayList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (SurveyTemplateQuestions que : ques) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            questions.add(que.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<SurveyQuestionnaire> surveyQuestionnaires = surveyQuestionnaireDao.findById(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (SurveyQuestionnaire question : surveyQuestionnaires) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String qstCode = question.getCode(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1308,8 +1316,13 @@ public class ManagerQuestionnaireService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer maxNum = question.getMaxNum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Integer sort = question.getSort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String next = question.getQuestionCodeNext(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //            更改问题到模板问题表(修改模板新增的问题怎么办?) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            System.out.println(templateCode + "," + qstCode + qstTitle + "," + qstComment + "," + qstType + "," + isRequired + "," + minNum + "," + maxNum + "," + sort + "," + next); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //            删除问题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Boolean exist = questions.contains(qstCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (exist) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                除掉重复问题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                questions.remove(qstCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //            更改问题到模板问题表(修改模板新增的问题) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int rows = surveyTemplateQuestionsDao.modifyQuestion(templateCode, qstCode, qstTitle, qstComment, qstType, isRequired, minNum, maxNum, sort, next); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            新增问题直接保存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (rows == 0) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1321,7 +1334,11 @@ public class ManagerQuestionnaireService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (qstType != 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<SurveyQuestionnaireOptions> surveyQuestionnaireOptions = surveyQuestionnaireOptionsDao.findByIdAndQstCode(code, question.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                问卷的选项编码都是新增的,不是从模板里复用的 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<SurveyTemplateOptions> templateOption = surveyTemplateOptionsDao.findById(qstCode,templateCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List options = new ArrayList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (SurveyTemplateOptions opt : templateOption) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    options.add(opt.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (SurveyQuestionnaireOptions option : surveyQuestionnaireOptions) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //         更改到模板选项表   survey_template_options 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String optCode = option.getCode(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1330,6 +1347,12 @@ public class ManagerQuestionnaireService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String nextCode = option.getQuestionCodeNext(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer required = option.getIsRequired(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer optsort = option.getSort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //                    删除选项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Boolean exists = options.contains(optCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (exists) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                除掉重复问题 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        options.remove(optCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    int row = surveyTemplateOptionsDao.modifyOption(templateCode, qstCode, optCode, have, content, nextCode, required, optsort); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            新增问题的选项直接保存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (row == 0) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1339,8 +1362,16 @@ public class ManagerQuestionnaireService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        surveyTemplateOptionsDao.save(surveyTemplateOptions); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//               删除选项更改选项状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Object opt:options) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    surveyTemplateOptionsDao.modifyOption(templateCode, qstCode, opt.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            删除问题更改问题状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Object qst:questions) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            surveyTemplateQuestionsDao.modifyQuestion(templateCode,qst.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |