Parcourir la source

Merge branch 'dev' of wujunjie/patient-co-management into dev

chenweida il y a 8 ans
Parent
commit
15ea9bdc44

+ 1 - 1
patient-co-wlyy/pom.xml

@ -75,7 +75,7 @@
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>jave-ffmpegjave</artifactId>
            <artifactId>java-ffmpegjave</artifactId>
            <version>1.0.4</version>
        </dependency>

+ 8 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyAnswersDao.java

@ -1,6 +1,8 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyAnswers;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -9,7 +11,10 @@ import java.util.List;
/**
 * Created by Reece on 2017/3/9.
 */
public interface SurveyAnswersDao extends PagingAndSortingRepository<SurveyAnswers,Long> {
    @Query("select  t.content from SurveyAnswers t where t.content is not null and t.surveyCode=?1 and t.questionCode=?2 order by t.createTime asc ")
    List<String> findByRelationCode(String id, String questionId);
public interface SurveyAnswersDao extends PagingAndSortingRepository<SurveyAnswers, Long> {
    @Query("select  t.content from SurveyAnswers t where t.content is not null and t.surveyCode=?1 and t.questionCode=?2 ")
    Page<String> findByRelationCode(String id, String questionId, Pageable request);
    @Query("select  count(t.surveyCode) from SurveyAnswers t where t.content is not null and t.surveyCode=?1 and t.questionCode=?2 ")
    int findByRelationCode(String id, String questionId);
}

+ 8 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyOptionAnswersDao.java

@ -1,6 +1,8 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyOptionAnswers;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -9,7 +11,10 @@ import java.util.List;
/**
 * Created by Reece on 2017/3/9.
 */
public interface SurveyOptionAnswersDao extends PagingAndSortingRepository<SurveyOptionAnswers,Long> {
    @Query("select  t.optionComment from SurveyOptionAnswers t where t.optionComment is not null and t.surveyCode =?1 and t.questionCode=?2 and t.optionsCode=?3 order by t.createTime asc ")
    List<Object> findByRelationCode(String id, String questionId, String optionId);
public interface SurveyOptionAnswersDao extends PagingAndSortingRepository<SurveyOptionAnswers, Long> {
    @Query("select  t.optionComment from SurveyOptionAnswers t where t.optionComment is not null and t.surveyCode =?1 and t.questionCode=?2 and t.optionsCode=?3 ")
    Page<String> findByRelationCode(String id, String questionId, String optionId, Pageable request);
    @Query("select  count(t.patient) from SurveyOptionAnswers t where t.optionComment is not null and t.surveyCode =?1 and t.questionCode=?2 and t.optionsCode=?3 ")
    int findByRelationCode(String id, String questionId, String optionId);
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyStatisticsDao.java

@ -18,7 +18,7 @@ public interface SurveyStatisticsDao extends PagingAndSortingRepository<SurveySt
    void modifyAmount(String surveyCode, String qstCode);
    @Query("select t.amount from SurveyStatistics t where t.surveyCode = ?1 and  t.questionCode = ?2 ")
    int findByIdAndQstId(String surveyCode, String qstCode);
    int[] findByIdAndQstId(String surveyCode, String qstCode);
    @Query("select t.amount from SurveyStatistics t where t.surveyCode = ?1 and  t.questionCode = ?2 and t.optionsCode = ?3 ")
    int findByAllId(String surveyCode, String qstCode,String optCode);

+ 6 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyUserDao.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyUser;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -21,4 +22,9 @@ public interface SurveyUserDao extends PagingAndSortingRepository<SurveyUser, Lo
    @Query("select t.patient from SurveyUser t where t.surveyCode=?1 and t.status = 0 and t.isWork = 1  ")
    List<String> findBySurveyCodeAndStatus(String id);
    @Modifying
    @Query("update SurveyUser t set t.status = 1 where t.surveyCode=?1 and t.patient = ?2 ")
    void modifyStatus(String id,String  patient);
}

+ 163 - 150
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -286,155 +286,155 @@ public class ManagerQuestionnaireService extends BaseService {
            int isRequired = Integer.parseInt(tempQestion.get("isRequired").toString());
            int sort = Integer.parseInt(tempQestion.get("sort").toString());
            int del = 1;
                switch (type) {
                    case 0:
            switch (type) {
                case 0:
//                    单选
                        SurveyQuestionnaire surveyQuestionnaire = new SurveyQuestionnaire();
                        surveyQuestionnaire.setCode(questionnaireCode);
                        surveyQuestionnaire.setTitle(title);
                        surveyQuestionnaire.setQuestionComment(comment);
                        surveyQuestionnaire.setQuestionType(type);
                        surveyQuestionnaire.setSurveyCode(surveyCode);
                        surveyQuestionnaire.setIsRequired(isRequired);
                        surveyQuestionnaire.setDel(del);
                        surveyQuestionnaire.setSort(sort);
                        //                   单选没有最大最小选项数及题目逻辑跳转
                        surveyQuestionnaire.setMinNum(null);
                        surveyQuestionnaire.setMinNum(null);
                        surveyQuestionnaire.setQuestionCodeNext(null);
                        surveyQuestionnaireDao.save(surveyQuestionnaire);
                        //                        =======================选项保存=========================
                        //                选择题
                        JSONArray options = new JSONArray(tempQestion.get("options").toString());
                        for (Object option : options) {
                            String optionCode = getCode();
                            JSONObject tempOption = new JSONObject(option.toString());
                            int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                            String optionComment = tempOption.get("content").toString();
                            int required = Integer.parseInt(tempOption.get("isRequired").toString());
                            int optionSort = Integer.parseInt(tempOption.get("sort").toString());
                            int optionDel = 1;
                            String optionNextQuestion = null;
                            if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
                                optionNextQuestion = tempOption.get("nextQuestion").toString();
                            }
//                        自主创建,插入表
                            SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions();
                            surveyQuestionnaireOptions.setCode(optionCode);
                            surveyQuestionnaireOptions.setHaveComment(haveComment);
                            surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                            surveyQuestionnaireOptions.setContent(optionComment);
                            surveyQuestionnaireOptions.setSurveyCode(surveyCode);
                            surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                            surveyQuestionnaireOptions.setIsRequired(required);
                            surveyQuestionnaireOptions.setSort(optionSort);
                            surveyQuestionnaireOptions.setDel(optionDel);
                            surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                            //                单选题保存到统计表
                            String statisticsCode = getCode();
                            String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                            String optcontent = surveyQuestionnaireOptionsDao.findByRelationCode(surveyCode, questionnaireCode, optionCode).getContent();
                            SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, optionCode, 0, optcontent, haveComment, type, sort, optionSort);
                            surveyStatisticsDao.save(statistics);
                    SurveyQuestionnaire surveyQuestionnaire = new SurveyQuestionnaire();
                    surveyQuestionnaire.setCode(questionnaireCode);
                    surveyQuestionnaire.setTitle(title);
                    surveyQuestionnaire.setQuestionComment(comment);
                    surveyQuestionnaire.setQuestionType(type);
                    surveyQuestionnaire.setSurveyCode(surveyCode);
                    surveyQuestionnaire.setIsRequired(isRequired);
                    surveyQuestionnaire.setDel(del);
                    surveyQuestionnaire.setSort(sort);
                    //                   单选没有最大最小选项数及题目逻辑跳转
                    surveyQuestionnaire.setMinNum(null);
                    surveyQuestionnaire.setMaxNum(null);
                    surveyQuestionnaire.setQuestionCodeNext(null);
                    surveyQuestionnaireDao.save(surveyQuestionnaire);
                    //                        =======================选项保存=========================
                    //                选择题
                    JSONArray options = new JSONArray(tempQestion.get("options").toString());
                    for (Object option : options) {
                        String optionCode = getCode();
                        JSONObject tempOption = new JSONObject(option.toString());
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        String optionComment = tempOption.get("content").toString();
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
                        int optionSort = Integer.parseInt(tempOption.get("sort").toString());
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                        }
//                        自主创建,插入表
                        SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions();
                        surveyQuestionnaireOptions.setCode(optionCode);
                        surveyQuestionnaireOptions.setHaveComment(haveComment);
                        surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                        surveyQuestionnaireOptions.setContent(optionComment);
                        surveyQuestionnaireOptions.setSurveyCode(surveyCode);
                        surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                        surveyQuestionnaireOptions.setIsRequired(required);
                        surveyQuestionnaireOptions.setSort(optionSort);
                        surveyQuestionnaireOptions.setDel(optionDel);
                        surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                        //                单选题保存到统计表
                        String statisticsCode = getCode();
                        String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                        String optcontent = surveyQuestionnaireOptionsDao.findByRelationCode(surveyCode, questionnaireCode, optionCode).getContent();
                        SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, optionCode, 0, optcontent, haveComment, type, sort, optionSort);
                        surveyStatisticsDao.save(statistics);
                    }
//                        ===============================================================
                        break;
                    case 1:
                    break;
                case 1:
//            多选特有属性
                        Integer maxOptions = null;
                        Integer minOptions = null;
                        if (!StringUtils.isEmpty(tempQestion.get("minOptions").toString())) {
                            minOptions = Integer.parseInt(tempQestion.get("minOptions").toString());
                        }
                        if (!StringUtils.isEmpty(tempQestion.get("maxOptions").toString())) {
                            maxOptions = Integer.parseInt(tempQestion.get("maxOptions").toString());
                        }
                        SurveyQuestionnaire surveyQuestionnaire1 = new SurveyQuestionnaire();
                        surveyQuestionnaire1.setCode(questionnaireCode);
                        surveyQuestionnaire1.setTitle(title);
                        surveyQuestionnaire1.setQuestionComment(comment);
                        surveyQuestionnaire1.setQuestionType(type);
                        surveyQuestionnaire1.setSurveyCode(surveyCode);
                        surveyQuestionnaire1.setIsRequired(isRequired);
                        surveyQuestionnaire1.setMinNum(minOptions);
                        surveyQuestionnaire1.setMinNum(maxOptions);
                        surveyQuestionnaire1.setSort(sort);
                        surveyQuestionnaire1.setQuestionCodeNext(null);
                        surveyQuestionnaire1.setDel(del);
                        surveyQuestionnaireDao.save(surveyQuestionnaire1);
                    Integer maxOptions = null;
                    Integer minOptions = null;
                    if (!StringUtils.isEmpty(tempQestion.get("minOptions").toString())) {
                        minOptions = Integer.parseInt(tempQestion.get("minOptions").toString());
                    }
                    if (!StringUtils.isEmpty(tempQestion.get("maxOptions").toString())) {
                        maxOptions = Integer.parseInt(tempQestion.get("maxOptions").toString());
                    }
                    SurveyQuestionnaire surveyQuestionnaire1 = new SurveyQuestionnaire();
                    surveyQuestionnaire1.setCode(questionnaireCode);
                    surveyQuestionnaire1.setTitle(title);
                    surveyQuestionnaire1.setQuestionComment(comment);
                    surveyQuestionnaire1.setQuestionType(type);
                    surveyQuestionnaire1.setSurveyCode(surveyCode);
                    surveyQuestionnaire1.setIsRequired(isRequired);
                    surveyQuestionnaire1.setMinNum(minOptions);
                    surveyQuestionnaire1.setMaxNum(maxOptions);
                    surveyQuestionnaire1.setSort(sort);
                    surveyQuestionnaire1.setQuestionCodeNext(null);
                    surveyQuestionnaire1.setDel(del);
                    surveyQuestionnaireDao.save(surveyQuestionnaire1);
//                        =======================选项保存=========================
                        //                选择题
                        JSONArray options1 = new JSONArray(tempQestion.get("options").toString());
                        for (Object option : options1) {
                            String optionCode = getCode();
                            JSONObject tempOption = new JSONObject(option.toString());
                            int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                            String optionComment = tempOption.get("content").toString();
                            int required = Integer.parseInt(tempOption.get("isRequired").toString());
                            int optionSort = Integer.parseInt(tempOption.get("sort").toString());
                            int optionDel = 1;
                            String optionNextQuestion = null;
                            if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
                                optionNextQuestion = tempOption.get("nextQuestion").toString();
                            }
//                        自主创建,插入表
                            SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions();
                            surveyQuestionnaireOptions.setCode(optionCode);
                            surveyQuestionnaireOptions.setHaveComment(haveComment);
                            surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                            surveyQuestionnaireOptions.setContent(optionComment);
                            surveyQuestionnaireOptions.setSurveyCode(surveyCode);
                            surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                            surveyQuestionnaireOptions.setIsRequired(required);
                            surveyQuestionnaireOptions.setSort(optionSort);
                            surveyQuestionnaireOptions.setDel(optionDel);
                            surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                            //                多选题保存到统计表
                            String statisticsCode = getCode();
                            String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                            String optcontent = surveyQuestionnaireOptionsDao.findByRelationCode(surveyCode, questionnaireCode, optionCode).getContent();
                            SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, optionCode, 0, optcontent, haveComment, type, sort, optionSort);
                            surveyStatisticsDao.save(statistics);
                        }
//                        ===============================================================
                        break;
                    case 2:
//            问答特有属性
                        String nextQuestion = null;
                        if (tempQestion.has("nextQuestion")) {
                            nextQuestion = tempQestion.get("nextQuestion").toString();
                    //                选择题
                    JSONArray options1 = new JSONArray(tempQestion.get("options").toString());
                    for (Object option : options1) {
                        String optionCode = getCode();
                        JSONObject tempOption = new JSONObject(option.toString());
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        String optionComment = tempOption.get("content").toString();
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
                        int optionSort = Integer.parseInt(tempOption.get("sort").toString());
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                        }
                        SurveyQuestionnaire surveyQuestionnaire2 = new SurveyQuestionnaire();
                        surveyQuestionnaire2.setCode(questionnaireCode);
                        surveyQuestionnaire2.setTitle(title);
                        surveyQuestionnaire2.setQuestionComment(comment);
                        surveyQuestionnaire2.setQuestionType(type);
                        surveyQuestionnaire2.setSurveyCode(surveyCode);
                        surveyQuestionnaire2.setIsRequired(isRequired);
//                   单选没有最大最小选项数
                        surveyQuestionnaire2.setMinNum(null);
                        surveyQuestionnaire2.setMinNum(null);
                        surveyQuestionnaire2.setSort(sort);
                        surveyQuestionnaire2.setQuestionCodeNext(nextQuestion);
                        surveyQuestionnaire2.setDel(del);
                        surveyQuestionnaireDao.save(surveyQuestionnaire2);
                        //                问答题保存到统计表(只负责更改数量不负责创建)
//                        自主创建,插入表
                        SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions();
                        surveyQuestionnaireOptions.setCode(optionCode);
                        surveyQuestionnaireOptions.setHaveComment(haveComment);
                        surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                        surveyQuestionnaireOptions.setContent(optionComment);
                        surveyQuestionnaireOptions.setSurveyCode(surveyCode);
                        surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                        surveyQuestionnaireOptions.setIsRequired(required);
                        surveyQuestionnaireOptions.setSort(optionSort);
                        surveyQuestionnaireOptions.setDel(optionDel);
                        surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                        //                多选题保存到统计表
                        String statisticsCode = getCode();
                        String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                        SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, null, 0, null, null, type, sort, null);
                        String optcontent = surveyQuestionnaireOptionsDao.findByRelationCode(surveyCode, questionnaireCode, optionCode).getContent();
                        SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, optionCode, 0, optcontent, haveComment, type, sort, optionSort);
                        surveyStatisticsDao.save(statistics);
                        break;
                }
                    }
//                        ===============================================================
                    break;
                case 2:
//            问答特有属性
                    String nextQuestion = null;
                    if (tempQestion.has("nextQuestion")) {
                        nextQuestion = tempQestion.get("nextQuestion").toString();
                    }
                    SurveyQuestionnaire surveyQuestionnaire2 = new SurveyQuestionnaire();
                    surveyQuestionnaire2.setCode(questionnaireCode);
                    surveyQuestionnaire2.setTitle(title);
                    surveyQuestionnaire2.setQuestionComment(comment);
                    surveyQuestionnaire2.setQuestionType(type);
                    surveyQuestionnaire2.setSurveyCode(surveyCode);
                    surveyQuestionnaire2.setIsRequired(isRequired);
//                   单选没有最大最小选项数
                    surveyQuestionnaire2.setMinNum(null);
                    surveyQuestionnaire2.setMaxNum(null);
                    surveyQuestionnaire2.setSort(sort);
                    surveyQuestionnaire2.setQuestionCodeNext(nextQuestion);
                    surveyQuestionnaire2.setDel(del);
                    surveyQuestionnaireDao.save(surveyQuestionnaire2);
                    //                问答题保存到统计表(只负责更改数量不负责创建)
                    String statisticsCode = getCode();
                    String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                    SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, null, 0, null, null, type, sort, null);
                    surveyStatisticsDao.save(statistics);
                    break;
            }
        }
//        保存到问卷
@ -546,6 +546,7 @@ public class ManagerQuestionnaireService extends BaseService {
            }
        }
//        查询该问卷回答人数
//        int complete = surveyUserDao.findBySurveyCode(id);
        int complete = surveyUserDao.findBySurveyCode(id);
        Map<String, Object> map = new HashMap<>();
//        获取创建者信息
@ -669,6 +670,9 @@ public class ManagerQuestionnaireService extends BaseService {
        JSONObject jsonObject = new JSONObject();
//一个问卷内的所有问题
        List<SurveyQuestionnaire> questions = surveyQuestionnaireDao.findById(id);
        if (questions.size() == 0) {
            return jsonObject;
        }
        List qstList = new ArrayList();
        for (SurveyQuestionnaire question : questions) {
//            新造对象
@ -676,13 +680,18 @@ public class ManagerQuestionnaireService extends BaseService {
            String qstcode = question.getCode();
            String title = question.getTitle();
            int type = question.getQuestionType();
            int amount = surveyStatisticsDao.findByIdAndQstId(id, qstcode);
            int amount = 0;
            int[] sum = surveyStatisticsDao.findByIdAndQstId(id, qstcode);
            for (int count :sum) {
                amount+=count;
            }
            qst.put("amount", amount);
            qst.put("qstcode", qstcode);
            qst.put("title", title);
            qst.put("amount", amount);
            qst.put("type", type);
//            一个问题内的所有选项
            List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findById(qstcode);
//            List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findById(qstcode);
            List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findByIdAndQstCode(id, qstcode);
            List optList = new ArrayList();
            for (SurveyQuestionnaireOptions option : options) {
                Map<String, Object> opt = new HashMap<>();
@ -704,24 +713,28 @@ public class ManagerQuestionnaireService extends BaseService {
        return jsonObject;
    }
    public JSONObject getOptionsComment(String id, String questionId, String optionId) throws Exception {
    public JSONObject getOptionsComment(String id, String questionId, String optionId,int pageNo,int pageSize) throws Exception {
        JSONObject jsonObject = new JSONObject();
        SurveyQuestionnaire question = surveyQuestionnaireDao.findByIdAndQstId(id, questionId);
        Sort sort = new Sort(Sort.Direction.ASC, "createTime");
        PageRequest request = new PageRequest(pageNo - 1, pageSize, sort);
        if (optionId != null && optionId.length() != 0) {
        if (!StringUtils.isEmpty(optionId)) {
//            查看选择题详细答案
            SurveyQuestionnaireOptions opt = surveyQuestionnaireOptionsDao.findByRelationCode(id, questionId, optionId);
            String option = opt.getContent();
            jsonObject.put("option", option);
//        获取同一个选项的所有回答的说明(分页?)
            List<Object> optionComment = surveyOptionAnswersDao.findByRelationCode(id, questionId, optionId);
            jsonObject.put("content", optionComment);
            jsonObject.put("amount", optionComment.size());
            Page<String> optionComment = surveyOptionAnswersDao.findByRelationCode(id, questionId, optionId,request);
            jsonObject.put("content", optionComment.getContent());
            int amount = surveyOptionAnswersDao.findByRelationCode(id, questionId, optionId);
            jsonObject.put("amount", amount);
        } else {
//            查看问答题答案(分页?)
            List<String> answer = surveyAnswersDao.findByRelationCode(id, questionId);
            jsonObject.put("content", answer);
            jsonObject.put("amount", answer.size());
            Page<String> answer = surveyAnswersDao.findByRelationCode(id, questionId,request);
            jsonObject.put("content", answer.getContent());
            int amount = surveyAnswersDao.findByRelationCode(id, questionId);
            jsonObject.put("amount", amount);
        }
        String title = question.getTitle();
@ -861,7 +874,7 @@ public class ManagerQuestionnaireService extends BaseService {
        } else {
            for (Map<String, Object> label : labels) {
//                if ("SURVEY_LABEL".equals(label.get("dict_name").toString())) {
                    surveyTemplates = surveyLabelInfoDao.findByLabel(Integer.parseInt(label.get("code").toString()));
                surveyTemplates = surveyLabelInfoDao.findByLabel(Integer.parseInt(label.get("code").toString()));
//                }
            }

+ 9 - 18
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/PatientQuestionnaireService.java

@ -1,9 +1,5 @@
package com.yihu.wlyy.service.survey;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting;
import com.mchange.v2.util.DoubleWeakHashMap;
import com.yihu.wlyy.entity.doctor.survey.*;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.service.BaseService;
@ -11,14 +7,9 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -45,14 +36,14 @@ public class PatientQuestionnaireService extends BaseService {
    public JSONObject getSurveySummary(String patient, String id) throws Exception {
        JSONObject jsonObject = new JSONObject();
        Survey survey = surveyDao.findById(id);
//        int complete = surveyUserDao.findByPatient(patient, id);
        int complete = surveyUserDao.findByPatient(patient, id);
        String title = survey.getTitle();
        String comment = survey.getSurveyComment();
        int status = survey.getStatus();
        jsonObject.put("title", title);
        jsonObject.put("comment", comment);
        jsonObject.put("status", status);
//        jsonObject.put("complete", complete);
        jsonObject.put("complete", complete == 0 ? 0 : 1);
        return jsonObject;
    }
@ -97,11 +88,9 @@ public class PatientQuestionnaireService extends BaseService {
        int isRequired = question.getIsRequired();
        int type = question.getQuestionType();
//        int sorts = question.getSort();
        switch (type)
        {
        switch (type) {
            case 0:
                List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findById(qstCode);
                List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findByIdAndQstCode(id, qstCode);
                for (SurveyQuestionnaireOptions option : options) {
                    String content = option.getContent();
//                        可构造集合,返回选项特定值
@ -115,7 +104,7 @@ public class PatientQuestionnaireService extends BaseService {
                jsonObject.put("options", options);
                break;
            case 1:
                List<SurveyQuestionnaireOptions> optionss = surveyQuestionnaireOptionsDao.findById(qstCode);
                List<SurveyQuestionnaireOptions> optionss = surveyQuestionnaireOptionsDao.findByIdAndQstCode(id, qstCode);
                for (SurveyQuestionnaireOptions option : optionss) {
                    String content = option.getContent();
                    if (option.getQuestionCodeNext() != null) {
@ -125,8 +114,8 @@ public class PatientQuestionnaireService extends BaseService {
                    }
                }
                int maxNum = question.getMaxNum();
                int minNum = question.getMinNum();
                Integer maxNum = question.getMaxNum();
                Integer minNum = question.getMinNum();
                jsonObject.put("maxNum", maxNum);
                jsonObject.put("minNum", minNum);
                jsonObject.put("options", optionss);
@ -274,6 +263,8 @@ public class PatientQuestionnaireService extends BaseService {
            }
        }
//        更改调查对象表答题状态为已答
        surveyUserDao.modifyStatus(surveyCode,patient);
    }
}

+ 4 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -438,10 +438,11 @@ public class PushMsgTask {
                m.put("keyword3", keyword3);
            } else if (type == 11) {
                temp.setUrl(url + "/survey/html/survey_info.html?openid=" + openid + "&state=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                temp.setUrl(url + "survey/html/survey_info.html?openid=" + openid + "&state=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                temp.setTemplate_id(SystemConf.getInstance().getSystemProperties()
                        .getProperty("template_doctor_survey"));
//                temp.setTemplate_id("fgYiMntj1amEkE8_GLUPmAIyssUAroJrNSHqvydt-PQ");
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
@ -451,21 +452,13 @@ public class PushMsgTask {
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
                /*WechatTemplateData keyword3 = new WechatTemplateData();
                keyword3.setColor("#000000");
                keyword3.setValue(json.getString("keyword3"));
                m.put("keyword3", keyword3);
                WechatTemplateData keyword4 = new WechatTemplateData();
                keyword4.setColor("#000000");
                keyword4.setValue(json.getString("keyword4"));
                m.put("keyword4", keyword4);*/
                System.out.println("type=====>openId " + openid);
            }
            temp.setData(m);
            ObjectMapper mapper = new ObjectMapper();
            String strJson = mapper.writeValueAsString(temp);
            System.out.println("strJson=====>strJson " + strJson);
            return strJson;
        } catch (Exception e) {
            e.printStackTrace();

+ 15 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java

@ -162,7 +162,7 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    }
    /**
     * 详细按钮 查看选项说明
     * 详细按钮 查看选项和问答题说明
     *
     * @param id
     * @return
@ -171,14 +171,16 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    @ApiOperation(value = "调查结果")
    @ResponseBody
    public String getOptionsComment(
            @RequestParam int pageNo,
            @RequestParam int pageSize,
            @ApiParam(value = "问卷id")
            @RequestParam(value = "") String id,
            @RequestParam String id,
            @ApiParam(value = "题目id")
            @RequestParam String questionId,
            @ApiParam(value = "选项id")
            @RequestParam(required = false) String optionId) {
        try {
            JSONObject jsonObject = managerQuestionnaireService.getOptionsComment(id, questionId, optionId);
            JSONObject jsonObject = managerQuestionnaireService.getOptionsComment(id, questionId, optionId,pageNo,pageSize);
            return write(200, "查询成功!", "data", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
@ -415,7 +417,6 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
                Patient p = patientDao.findByCode(cod);
                String name = p.getName();
                String openId = p.getOpenid();
//                String openId = "orrOgwATDaljVunlAq_Tdx3imhYg";
                json.put("keyword2", sdf.format(new Date()));
                json.put("toUser", cod);
                json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
@ -423,6 +424,15 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
            }
           /* String openId = "orrOgwATDaljVunlAq_Tdx3imhYg";
            pushMsgTask.sendWeixinMessage(accessToken, 11, openId, name, json);*/
           /* String cod = "d6b8b1ebe59a4559b587326a97d9b299";
            String name = "曾国桂";
//            String openId = "o7NFZw30tpj626TGdYxzB-0RUpW8";
            String openId = "orrOgwATDaljVunlAq_Tdx3imhYg";
            System.out.println("controller=====>cod " + cod + " name " + name + " openId " + openId);
            json.put("keyword2", sdf.format(new Date()));
            json.put("toUser", cod);
            json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
            pushMsgTask.sendWeixinMessage(accessToken, 11, openId, name, json);*/
            return write(200, "发送成功!");
        } catch (Exception e) {
            e.printStackTrace();
@ -444,7 +454,7 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
            @RequestParam String json) {
        try {
            int amount = managerQuestionnaireService.getAmount(json);
            return write(200, "查询成功!","amount",amount);
            return write(200, "查询成功!", "amount", amount);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");

+ 24 - 24
patient-co-wlyy/src/main/resources/application.properties

@ -51,30 +51,30 @@
#redis.maxWait=1000
#redis.testOnBorrow=true
##------------------------------------开发环境数据库配置------------------------------------#
##------------------------------------锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷匡拷锟斤拷锟斤拷------------------------------------#
#### mysql database setting
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://172.19.103.77/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#jdbc.username=root
#jdbc.password=123456
#
##### health index
#health.jdbc.driver=com.mysql.jdbc.Driver
#health.jdbc.url=jdbc:mysql://172.19.103.77/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#health.jdbc.username=root
#health.jdbc.password=123456
#
##### suifang
#fv.jdbc.driver=com.mysql.jdbc.Driver
#fv.jdbc.url=jdbc:mysql://172.19.103.77/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#fv.jdbc.username=root
#fv.jdbc.password=123456
#
##### redis
#redis.host=172.19.103.47
#redis.port=6379
#redis.password=
#---------------------------------测试环境数据库配置---------------------------------------#
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://172.19.103.77/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
jdbc.username=root
jdbc.password=123456
#### health index
health.jdbc.driver=com.mysql.jdbc.Driver
health.jdbc.url=jdbc:mysql://172.19.103.77/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
health.jdbc.username=root
health.jdbc.password=123456
#### suifang
fv.jdbc.driver=com.mysql.jdbc.Driver
fv.jdbc.url=jdbc:mysql://172.19.103.77/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
fv.jdbc.username=root
fv.jdbc.password=123456
#### redis
redis.host=172.19.103.47
redis.port=6379
redis.password=
#---------------------------------锟斤拷锟皆伙拷锟斤拷锟斤拷锟捷匡拷锟斤拷锟斤拷---------------------------------------#
###### mysql database setting
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
@ -98,7 +98,7 @@
#redis.port=6379
#redis.password=
#-----------------------------------通用配置--------------------------------------------#
#-----------------------------------通锟斤拷锟斤拷锟斤拷--------------------------------------------#
##### redis
redis.maxIdle=300
redis.maxActive=600

+ 5 - 2
patient-co-wlyy/src/main/resources/system.properties

@ -72,9 +72,12 @@ im_list_get=http://192.168.131.102:3008/
im_group_server=http://172.19.103.29:3000/api/v1/chats/gm
msg_push_server=http://172.19.103.29:3000/api/v1/chats/sm
# 微信基本配置 wxb3827510b2e15012 c5bdedd909ded9c2ee08028487e6f50d
# 微信基本配置
appId=wxd03f859efdf0873d
appSecret=2935b54b53a957d9516c920a544f2537
# 个人微信测试平台基本配置
#appId=wxb3827510b2e15012
#appSecret=c5bdedd909ded9c2ee08028487e6f50d
wechat_base_url=http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
wechat_token=27eb3bb24f149a7760cf1bb154b08040
@ -102,7 +105,7 @@ template_healthy_article=LA7erINJ0CSsG2G_ZCrgsDaX3krhsI4qg_NSHEyL_l4
#医生变更
template_doctor_change=TNIDMjduVKgVL4-k71umYLpHROvFB8K6mmm8aZC_EH8
#问卷调查
template_doctor_survey=OqQXrb-e43_TJpq_70_K_y6vYJgY5mpjFYY4c5RWFP4
template_doctor_survey=IjQvzBy0PLeft2kN9mdBhACXPE9I_jyJywJ6B-JRxsY
#健康之路开放平台
yihu_OpenPlatform_url=http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/