kookmin-sw / 2018-cap1-4

Oriental medical and Expert system convergence
5 stars 4 forks source link

설문지 연동 관련 (generalSurvey) #75

Closed WonYong-Jang closed 6 years ago

WonYong-Jang commented 6 years ago

@junyeongRue / 현재 GeneralSurvey에서 22문항을 작성하고 나면 ajax를 통해 SurveyController 로 받아오게 됩니다. 아래는 소스코드 일부이며, 처음 for문에서 배열에 받아온 값을 모두 더해줍니다(인덱스 0번부터 시작) 그 후 sum값에 따라 페이지 전환하는 소스가 추가되었으며 확인후 수정할 부분을 해주시면 됩니다. 마찬가지로 B ,C 도 Controller에서 받아올수 있으며 디비테이블 생성 후 최종 결과페이지에 보여줄 데이터를 넣어서 보내주시면 연동하겠습니다.

         /** 
     * GeneralSurvey 설문 작성 완료 한 후 save 버튼 클릭시
     */
    @RequestMapping(value ="/saveGeneralSurvey", method = RequestMethod.POST)
    public @ResponseBody String G_SurveySaveButton(@RequestBody SurveyVO surveyResult) throws Exception
    {
        logger.info("saveGeneralSurvey");
        int sum =0;
        for(Integer val : surveyResult.generalSurvey) 
        {
            // receive the value from 0 index sequentially in the array (0 ~ 21)
            System.out.print(val+" "); // confirm message
            if(val != null)
            {
                sum += val;
            }
        }
        System.out.println("\ntotalSum : "+sum);
        if(sum <= 10)return "/home/generalSurvey_B"; 
        else if(sum >= 12) return "/home/generalSurvey_C";
        else { // 판단 Rule
            int a = surveyResult.generalSurvey.get(3); // 4번 문제  
            int b = surveyResult.generalSurvey.get(13);
            int c = surveyResult.generalSurvey.get(19);
            System.out.println(a+" "+b+" "+c);
            return "/home/generalSurvey";
        }
    }
junyeongRue commented 6 years ago

확인했습니다.