Browse Source

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

linzhuo 8 years ago
parent
commit
b64fd5a3f6

+ 12 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateOptionsDao.java

@ -11,11 +11,21 @@ import java.util.List;
 * Created by Reece on 2017/3/10.
 */
public interface SurveyTemplateOptionsDao extends PagingAndSortingRepository<SurveyTemplateOptions, Long> {
    @Query("select t from  SurveyTemplateOptions t where  t.templateQuestionCode = ?1 and t.templateCode = ?2 ")
    @Query("select t from  SurveyTemplateOptions t where  t.templateQuestionCode = ?1 and t.templateCode = ?2 and t.del = 1 ")
    List<SurveyTemplateOptions> findById(String qstcode, String tempCode);
    @Modifying
    @Query("update SurveyTemplateOptions t set t.haveComment=?4,t.content=?5," +
            "t.questionCodeNext=?6,t.isRequired=?7,t.sort=?8 where  t.templateQuestionCode = ?1 and t.templateCode = ?2 and t.code=?3")
            "t.questionCodeNext=?6,t.isRequired=?7,t.sort=?8 where  t.templateQuestionCode = ?2 and t.templateCode = ?1 and t.code=?3")
    int modifyOption(String tempCode, String qstcode, String optcode, Integer haveCommment, String content, String nextCode, Integer isRequired, Integer sort);
    /**
     * 修改选项状态(删除)
     * @param tempCode
     * @param qstcode
     * @param optcode
     */
    @Modifying
    @Query("update SurveyTemplateOptions t set t.del = 0 where  t.templateQuestionCode = ?2 and t.templateCode = ?1 and t.code=?3")
    void modifyOption(String tempCode, String qstcode, String optcode);
}

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

@ -11,7 +11,7 @@ import java.util.List;
 * Created by Reece on 2017/3/10.
 */
public interface SurveyTemplateQuestionsDao extends PagingAndSortingRepository<SurveyTemplateQuestions, Long> {
    @Query("select  t from SurveyTemplateQuestions t where t.templateCode = ?1 ")
    @Query("select  t from SurveyTemplateQuestions t where t.templateCode = ?1 and t.del = 1 ")
    List<SurveyTemplateQuestions> findById(String tempCode);
    @Query("select  t from SurveyTemplateQuestions t where t.templateCode = ?1 and t.code = ?2 ")
@ -25,4 +25,13 @@ public interface SurveyTemplateQuestionsDao extends PagingAndSortingRepository<S
            "t.isRequired=?6,t.minNum=?7,t.maxNum=?8,t.sort=?9,t.questionCodeNext=?10  where t.templateCode = ?1 and t.code = ?2 ")
    int modifyQuestion(String tempCode, String qstCode, String qstTitle, String qstComment, Integer qstType,
                        Integer isRequired, Integer minNum, Integer maxNum, Integer sort, String next);
    /**
     * 修改模板问题状态(删除)
     * @param tempCode
     * @param qstCode
     */
    @Modifying
    @Query("update SurveyTemplateQuestions t set t.del = 0  where t.templateCode = ?1 and t.code = ?2 ")
    void modifyQuestion(String tempCode, String qstCode);
}

+ 38 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -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;
    }

+ 7 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -974,9 +974,16 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                Map map = new HashMap();
                String labelName = label.getLabelName();
                JSONArray jsonArray = list.getJSONArray(label.getLabelName());
                List codes = new ArrayList();
                for (Object patient:jsonArray) {
                    JSONObject jsonObject = new JSONObject(patient.toString());
                    String code = jsonObject.get("code").toString();
                    codes.add(code);
                }
                int length = jsonArray.length();
                map.put("label", labelName);
                map.put("number", length);
                map.put("codes", codes);
                listNum.add(map);
            }
            return write(200, "查询成功!", "data", listNum);