Переглянути джерело

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

trick9191 8 роки тому
батько
коміт
d0e21d06df
18 змінених файлів з 252 додано та 182 видалено
  1. 27 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java
  2. 15 3
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  3. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateOptionsDao.java
  4. 7 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateQuestionsDao.java
  5. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java
  6. 5 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  7. 30 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  8. 93 67
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java
  9. 12 27
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/PatientQuestionnaireService.java
  10. 2 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  11. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java
  12. 4 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java
  13. 7 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendPatientUtil.java
  14. 0 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheduling/DoctorWorkTimeController.java
  15. 34 47
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java
  16. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  17. 9 9
      patient-co-wlyy/src/main/resources/application.properties
  18. 1 1
      patient-co-wlyy/src/main/resources/system.properties

+ 27 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java

@ -337,6 +337,17 @@ public class JobController extends BaseController {
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
        }
    }
    }
    @ApiOperation(value = "立即启动健康信息生成的任务")
    @RequestMapping(value = "startHealthMessageJobNow", method = RequestMethod.GET)
    public String startHealthMessageJobNow() {
        try {
            jobService.startHealthMessageJobNow();
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
    /**
     * 停止判断的任务
     * 停止判断的任务
     *
     *
@ -451,6 +462,22 @@ public class JobController extends BaseController {
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
        }
    }
    }
    /**
     * 启动通知任务
     *
     * @return
     */
    @ApiOperation(value = "立即启动通知任务")
    @RequestMapping(value = "startNoticeJobNow", method = RequestMethod.GET)
    public String startNoticeJobNow() {
        try {
            jobService.startNoticeJobNow();
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
    /**
     * 启动通知任务
     * 启动通知任务
     *
     *

+ 15 - 3
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -462,8 +462,8 @@ public class JobService {
    public void startNoticeJob() throws Exception {
    public void startNoticeJob() throws Exception {
        if (!quartzHelper.isExistJob(NoticeJob.jobKey)) {
        if (!quartzHelper.isExistJob(NoticeJob.jobKey)) {
            quartzHelper.addJob(NoticeJob.class,NoticeJob.jobCron,NoticeJob.jobKey,new HashMap<>());
           // quartzHelper.startNow(NoticeJob.class, UUID.randomUUID().toString().replace("-", ""), new HashMap<>());
            quartzHelper.addJob(NoticeJob.class, NoticeJob.jobCron, NoticeJob.jobKey, new HashMap<>());
            // quartzHelper.startNow(NoticeJob.class, UUID.randomUUID().toString().replace("-", ""), new HashMap<>());
        } else {
        } else {
            throw new Exception("已经启动");
            throw new Exception("已经启动");
@ -478,11 +478,14 @@ public class JobService {
        }
        }
    }
    }
    /******************************* 随访计划任务 *******************************************************/
    /*******************************
     * 随访计划任务
     *******************************************************/
    @Value("${spring.followupMessage.jobId}")
    @Value("${spring.followupMessage.jobId}")
    private String followupJob;
    private String followupJob;
    @Value("${spring.followupMessage.cron}")
    @Value("${spring.followupMessage.cron}")
    private String followupJobCron;
    private String followupJobCron;
    public void startFollowupPlantJob() throws Exception {
    public void startFollowupPlantJob() throws Exception {
        if (!quartzHelper.isExistJob(followupJob)) {
        if (!quartzHelper.isExistJob(followupJob)) {
            quartzHelper.addJob(FollowupPlanJob.class, followupJobCron, followupJob, new HashMap<>());
            quartzHelper.addJob(FollowupPlanJob.class, followupJobCron, followupJob, new HashMap<>());
@ -498,4 +501,13 @@ public class JobService {
            throw new Exception("已经停止");
            throw new Exception("已经停止");
        }
        }
    }
    }
    public void startNoticeJobNow() throws Exception {
        quartzHelper.startNow(NoticeJob.class, UUID.randomUUID().toString(), new HashMap<>());
    }
    public void startHealthMessageJobNow() throws Exception {
        quartzHelper.startNow(HealthMessageJob.class, UUID.randomUUID().toString(), new HashMap<>());
    }
}
}

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

@ -17,5 +17,5 @@ public interface SurveyTemplateOptionsDao extends PagingAndSortingRepository<Sur
    @Modifying
    @Modifying
    @Query("update SurveyTemplateOptions t set t.haveComment=?4,t.content=?5," +
    @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 = ?1 and t.templateCode = ?2 and t.code=?3")
    void modifyOption(String tempCode, String qstcode, String optcode, int haveCommment, String content, String nextCode, int isRequired, int sort);
    void modifyOption(String tempCode, String qstcode, String optcode, Integer haveCommment, String content, String nextCode, Integer isRequired, Integer sort);
}
}

+ 7 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateQuestionsDao.java

@ -16,10 +16,13 @@ public interface SurveyTemplateQuestionsDao extends PagingAndSortingRepository<S
    @Query("select  t from SurveyTemplateQuestions t where t.templateCode = ?1 and t.code = ?2 ")
    @Query("select  t from SurveyTemplateQuestions t where t.templateCode = ?1 and t.code = ?2 ")
    SurveyTemplateQuestions findById(String tempCode, String qstCode);
    SurveyTemplateQuestions findById(String tempCode, String qstCode);
//String code, String title, String questionComment, Integer questionType, String templateCode, Integer isRequired, Integer minNum, Integer maxNum,
// Integer sort, String questionCodeNext, String questionSortNext, Integer del, Date createTime, Date updateTime
    @Query("select  t.code from SurveyTemplateQuestions t where t.templateCode = ?1 and t.sort = ?2 ")
    String findBySort(String tempCode, Object sort);
    @Modifying
    @Modifying
    @Query("update SurveyTemplateQuestions t set t.title=?3,t.questionComment=?4,t.questionType=?5," +
    @Query("update SurveyTemplateQuestions t set t.title=?3,t.questionComment=?4,t.questionType=?5," +
            "t.isRequired=?6,t.minNum=?7,t.maxNum=?8,t.sort=?9,t.questionCodeNext=?10,t.questionSortNext=?11 where t.templateCode = ?1 and t.code = ?2 ")
    void modifyQuestion(String tempCode, String qstCode,String qstTitle, String qstComment, int qstType, int isRequired,int minNum,int  maxNum, int sort,String next);
            "t.isRequired=?6,t.minNum=?7,t.maxNum=?8,t.sort=?9,t.questionCodeNext=?10  where t.templateCode = ?1 and t.code = ?2 ")
    void modifyQuestion(String tempCode, String qstCode, String qstTitle, String qstComment, Integer qstType,
                        Integer isRequired, Integer minNum, Integer maxNum, Integer sort, String next);
}
}

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java

@ -127,9 +127,9 @@ public class ConsultService extends BaseService {
			type=0;
			type=0;
		}
		}
		if(type!=0){
		if(type!=0){
			new SendPatientUtil(doctor,doctorName,patient, contentType, content,title,type+"").start();
			new SendPatientUtil(doctor,doctorName,patient, contentType, content,title,type+"",sfList.get(0).getTeamCode()).start();
		}else{
		}else{
			new SendPatientUtil(doctor,doctorName,patient, contentType, content,title,"2").start();
			new SendPatientUtil(doctor,doctorName,patient, contentType, content,title,"2",sfList.get(0).getTeamCode()).start();
		}
		}
	}
	}
}
}

+ 5 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -1457,7 +1457,7 @@ public class ConsultTeamService extends ConsultService {
        participants.put(ct.getPatient(), 0);
        participants.put(ct.getPatient(), 0);
        participants.put(ct.getDoctor(), 0);
        participants.put(ct.getDoctor(), 0);
        Doctor doctor = doctorService.findDoctorByCode(uid);
        Doctor doctor = doctorService.findDoctorByCode(uid);
        JSONObject sessionJson = ImUtill.createSession(participants, "2", doctor.getName() + "发起求助!", "");
        JSONObject sessionJson = ImUtill.createSession(participants, ImUtill.SESSION_TYPE_P2P, doctor.getName() + "发起求助!", "");
        if (sessionJson.getInt("status") == -1) {
        if (sessionJson.getInt("status") == -1) {
            throw new RuntimeException(sessionJson.getString("message"));
            throw new RuntimeException(sessionJson.getString("message"));
        }
        }
@ -1546,7 +1546,7 @@ public class ConsultTeamService extends ConsultService {
            jsonObject.put(ct.getPatient(), 0);
            jsonObject.put(ct.getPatient(), 0);
            jsonObject.put(ct.getDoctor(), 0);
            jsonObject.put(ct.getDoctor(), 0);
            //设置消息ID
            //设置消息ID
            JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, "2");
            JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
            if (obj == null || obj.getInt("status") == -1) {
            if (obj == null || obj.getInt("status") == -1) {
                throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
            }
            }
@ -1560,7 +1560,7 @@ public class ConsultTeamService extends ConsultService {
                JSONObject jsonObject = new JSONObject();
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getDoctor(), 0);
                jsonObject.put(ct.getDoctor(), 0);
                JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, "2");
                JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
                if (obj == null || obj.getInt("status") == -1) {
                if (obj == null || obj.getInt("status") == -1) {
                    throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                    throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                }
                }
@ -1577,7 +1577,7 @@ public class ConsultTeamService extends ConsultService {
                JSONObject jsonObject = new JSONObject();
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getDoctor(), 0);
                jsonObject.put(ct.getDoctor(), 0);
                JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, "2");
                JSONObject obj = ImUtill.createTopics(null, consult.getCode(), doctorTemp.getName(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
                if (obj == null || obj.getInt("status") == -1) {
                if (obj == null || obj.getInt("status") == -1) {
                    throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                    throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                }
                }
@ -1708,7 +1708,7 @@ public class ConsultTeamService extends ConsultService {
        JSONObject messages = ImUtill.getCreateTopicMessage(senderId, senderName, senderName + "发起咨询", content, ct.getImages());
        JSONObject messages = ImUtill.getCreateTopicMessage(senderId, senderName, senderName + "发起咨询", content, ct.getImages());
        JSONObject obj = ImUtill.createTopics(null, consult.getCode(), consult.getSymptoms(), jsonObject, messages, "2");
        JSONObject obj = ImUtill.createTopics(null, consult.getCode(), consult.getSymptoms(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
        if (obj == null) {
        if (obj == null) {
            throw new RuntimeException("im消息创建异常!");
            throw new RuntimeException("im消息创建异常!");
        }
        }

+ 30 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -996,6 +996,20 @@ public class FamilyContractService extends BaseService {
            // 添加到发送队列
            // 添加到发送队列
            PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
            PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
            new Thread(new SignUploadTask(sf.getCode())).start();
            new Thread(new SignUploadTask(sf.getCode())).start();
            JSONObject participants = new JSONObject();
            participants.put(sf.getPatient(),0);
            if(StringUtils.equals(sf.getDoctor(),sf.getDoctorHealth())){//全科和建管同一个人
                participants.put(sf.getDoctor(),0);
            }else{//全科和建管不同一个人
                participants.put(sf.getDoctorHealth(),0);
                participants.put(sf.getDoctor(),1);
            }
            //创建医生会话讨论组
            JSONObject sessionObj  =  ImUtill.createSession(participants,ImUtill.SESSION_TYPE_MUC,patient.getName(),patient.getCode()+"_"+sf.getTeamCode()+"_"+2);
            if(sessionObj.getInt("status")==-1){
                throw  new RuntimeException(sessionObj.getString("message"));
            }
        }
        }
        BusinessLogs.info(BusinessLogs.BusinessType.sign, signDoctorCode, sf.getPatient(), new JSONObject(sf));
        BusinessLogs.info(BusinessLogs.BusinessType.sign, signDoctorCode, sf.getPatient(), new JSONObject(sf));
        return temp;
        return temp;
@ -1045,6 +1059,7 @@ public class FamilyContractService extends BaseService {
            result.put("status", 0);
            result.put("status", 0);
            return result;
            return result;
        }
        }
        String doctorTeamCode  =null;//服务团队的CODE;
        if (type == 1) {
        if (type == 1) {
            //判断是否有三师签约 并且判断全科医生一致
            //判断是否有三师签约 并且判断全科医生一致
            SignFamily sssignFamily = signFamilyDao.findSSByIdcard(p.getIdcard());
            SignFamily sssignFamily = signFamilyDao.findSSByIdcard(p.getIdcard());
@ -1143,7 +1158,7 @@ public class FamilyContractService extends BaseService {
            //sf.setFamilyCode(createSignCode(sf.getDoctor(), doc.getHospital()));
            //sf.setFamilyCode(createSignCode(sf.getDoctor(), doc.getHospital()));
            //建立团队
            //建立团队
            DoctorTeam doctorTeam = new DoctorTeam();
            DoctorTeam doctorTeam = new DoctorTeam();
            String doctorTeamCode = getCode();
            doctorTeamCode = getCode();
            doctorTeam.setName("三师签约团队患者:" + p.getName());
            doctorTeam.setName("三师签约团队患者:" + p.getName());
            doctorTeam.setCode(doctorTeamCode);
            doctorTeam.setCode(doctorTeamCode);
            doctorTeam.setCzrq(new Date());
            doctorTeam.setCzrq(new Date());
@ -1232,6 +1247,20 @@ public class FamilyContractService extends BaseService {
            // 添加到发送队列
            // 添加到发送队列
            PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
            PushMsgTask.getInstance().putWxMsg(access_token, 1, sf.getOpenid(), sf.getName(), json);
            new Thread(new SignUploadTask(sf.getCode())).start();
            new Thread(new SignUploadTask(sf.getCode())).start();
            JSONObject participants = new JSONObject();
            participants.put(sf.getPatient(),0);
            if(StringUtils.equals(sf.getDoctor(),sf.getDoctorHealth())){//全科和建管同一个人
                participants.put(sf.getDoctor(),0);
            }else{//全科和建管不同一个人
                participants.put(sf.getDoctorHealth(),0);
                participants.put(sf.getDoctor(),1);
            }
            Patient patient = patientDao.findByCode(sf.getPatient());
            //创建医生会话讨论组
            JSONObject sessionObj  =  ImUtill.createSession(participants,ImUtill.SESSION_TYPE_MUC,patient.getName(),patient.getCode()+"_"+sf.getTeamCode()+"_"+2);
            if(sessionObj.getInt("status")==-1){
                throw  new RuntimeException(sessionObj.getString("message"));
            }
        }
        }
        result.put("status", 1);
        result.put("status", 1);
        BusinessLogs.info(BusinessLogs.BusinessType.sign, caller, sf.getPatient(), new JSONObject(sf));
        BusinessLogs.info(BusinessLogs.BusinessType.sign, caller, sf.getPatient(), new JSONObject(sf));

+ 93 - 67
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -88,7 +88,7 @@ public class ManagerQuestionnaireService extends BaseService {
    public String createSurvey(String doctor, JSONObject jsonStr, String accessToken) throws Exception {
    public String createSurvey(String doctor, JSONObject jsonStr, String accessToken) throws Exception {
        System.out.println("=============>"+jsonStr);
        System.out.println("=============>" + jsonStr);
//        问卷信息
//        问卷信息
        String surveyCode = getCode();
        String surveyCode = getCode();
        String surveyName = jsonStr.getString("surveyName");
        String surveyName = jsonStr.getString("surveyName");
@ -275,8 +275,20 @@ public class ManagerQuestionnaireService extends BaseService {
        //            发送居民模板 send=1发送
        //            发送居民模板 send=1发送
//        ====================================================
//        ====================================================
        if ("1".equals(send)) {
        if ("1".equals(send)) {
            SendMessage sendMessage = new SendMessage(surveyCode, codes, accessToken);
            new Thread(sendMessage).start();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String str = "{\"remark\":\"我们将按调查最终结果,优化健康服务。\",\"keyword1\":\"调查问卷\"}";
            JSONObject json = new JSONObject(str);
            codes.stream().forEach(c -> {
                Patient p = patientDao.findByCode(c);
                String name = p.getName();
                String openId = p.getOpenid();
                json.put("keyword2", sdf.format(new Date()));
                json.put("toUser", c);
                json.put("survey_id",surveyCode );
                json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
                PushMsgTask.getInstance().putWxMsg(accessToken, 11, openId, name, json);
            });
        }
        }
//       =====================================================
//       =====================================================
//     获取标签数组
//     获取标签数组
@ -302,6 +314,12 @@ public class ManagerQuestionnaireService extends BaseService {
            int isRequired = Integer.parseInt(tempQestion.get("isRequired").toString());
            int isRequired = Integer.parseInt(tempQestion.get("isRequired").toString());
            int sort = Integer.parseInt(tempQestion.get("sort").toString());
            int sort = Integer.parseInt(tempQestion.get("sort").toString());
            int del = 1;
            int del = 1;
            String qstNextQuestion = null;
            if (!StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                qstNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempQestion.get("nextQuestion"));
                qstNextQuestion = (qstNextQuestion == null ? "0" : qstNextQuestion);
            }
            switch (type) {
            switch (type) {
                case 0:
                case 0:
//                    单选
//                    单选
@ -314,12 +332,15 @@ public class ManagerQuestionnaireService extends BaseService {
                    surveyQuestionnaire.setIsRequired(isRequired);
                    surveyQuestionnaire.setIsRequired(isRequired);
                    surveyQuestionnaire.setDel(del);
                    surveyQuestionnaire.setDel(del);
                    surveyQuestionnaire.setSort(sort);
                    surveyQuestionnaire.setSort(sort);
                    surveyQuestionnaire.setCreateTime(new Date());
                    surveyQuestionnaire.setUpdateTime(new Date());
                    //                   单选没有最大最小选项数及题目逻辑跳转
                    //                   单选没有最大最小选项数及题目逻辑跳转
                    surveyQuestionnaire.setMinNum(null);
                    surveyQuestionnaire.setMinNum(null);
                    surveyQuestionnaire.setMaxNum(null);
                    surveyQuestionnaire.setMaxNum(null);
                    surveyQuestionnaire.setQuestionCodeNext(null);
                    surveyQuestionnaire.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaireDao.save(surveyQuestionnaire);
                    surveyQuestionnaireDao.save(surveyQuestionnaire);
                    System.out.println("=====================================");
                    //                        =======================选项保存=========================
                    //                        =======================选项保存=========================
                    //                选择题
                    //                选择题
                    JSONArray options = new JSONArray(tempQestion.get("options").toString());
                    JSONArray options = new JSONArray(tempQestion.get("options").toString());
@ -333,11 +354,14 @@ public class ManagerQuestionnaireService extends BaseService {
                        int optionDel = 1;
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        String optionNextQuestion = null;
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
                            optionNextQuestion = tempOption.get("nextQuestion").toString();
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                            optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
                            optionNextQuestion = (optionNextQuestion == null ? "0" : optionNextQuestion);
                        }
                        }
//                        自主创建,插入表
//                        自主创建,插入表
                        SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions();
                        surveyQuestionnaireOptions.setCode(optionCode);
                        SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions(optionCode, haveComment, questionnaireCode, optionComment,
                                surveyCode, optionNextQuestion, required, optionSort, optionDel);
                       /* surveyQuestionnaireOptions.setCode(optionCode);
                        surveyQuestionnaireOptions.setHaveComment(haveComment);
                        surveyQuestionnaireOptions.setHaveComment(haveComment);
                        surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                        surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                        surveyQuestionnaireOptions.setContent(optionComment);
                        surveyQuestionnaireOptions.setContent(optionComment);
@ -345,8 +369,7 @@ public class ManagerQuestionnaireService extends BaseService {
                        surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                        surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                        surveyQuestionnaireOptions.setIsRequired(required);
                        surveyQuestionnaireOptions.setIsRequired(required);
                        surveyQuestionnaireOptions.setSort(optionSort);
                        surveyQuestionnaireOptions.setSort(optionSort);
                        surveyQuestionnaireOptions.setDel(optionDel);
                        surveyQuestionnaireOptions.setDel(optionDel);*/
                        surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                        surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                        //                单选题保存到统计表
                        //                单选题保存到统计表
@ -378,8 +401,10 @@ public class ManagerQuestionnaireService extends BaseService {
                    surveyQuestionnaire1.setMinNum(minOptions);
                    surveyQuestionnaire1.setMinNum(minOptions);
                    surveyQuestionnaire1.setMaxNum(maxOptions);
                    surveyQuestionnaire1.setMaxNum(maxOptions);
                    surveyQuestionnaire1.setSort(sort);
                    surveyQuestionnaire1.setSort(sort);
                    surveyQuestionnaire1.setQuestionCodeNext(null);
                    surveyQuestionnaire1.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaire1.setDel(del);
                    surveyQuestionnaire1.setDel(del);
                    surveyQuestionnaire1.setCreateTime(new Date());
                    surveyQuestionnaire1.setUpdateTime(new Date());
                    surveyQuestionnaireDao.save(surveyQuestionnaire1);
                    surveyQuestionnaireDao.save(surveyQuestionnaire1);
@ -396,7 +421,8 @@ public class ManagerQuestionnaireService extends BaseService {
                        int optionDel = 1;
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        String optionNextQuestion = null;
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
                            optionNextQuestion = tempOption.get("nextQuestion").toString();
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                            optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
                        }
                        }
//                        自主创建,插入表
//                        自主创建,插入表
@ -424,10 +450,12 @@ public class ManagerQuestionnaireService extends BaseService {
                    break;
                    break;
                case 2:
                case 2:
//            问答特有属性
//            问答特有属性
                    String nextQuestion = null;
                    if (tempQestion.has("nextQuestion")) {
                    /*String nextQuestion = null;
                    if (StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
                        nextQuestion = tempQestion.get("nextQuestion").toString();
                        nextQuestion = tempQestion.get("nextQuestion").toString();
                    }
                    }else {
                        nextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode,tempQestion.get("nextQuestion"));
                    }*/
                    SurveyQuestionnaire surveyQuestionnaire2 = new SurveyQuestionnaire();
                    SurveyQuestionnaire surveyQuestionnaire2 = new SurveyQuestionnaire();
                    surveyQuestionnaire2.setCode(questionnaireCode);
                    surveyQuestionnaire2.setCode(questionnaireCode);
                    surveyQuestionnaire2.setTitle(title);
                    surveyQuestionnaire2.setTitle(title);
@ -439,8 +467,10 @@ public class ManagerQuestionnaireService extends BaseService {
                    surveyQuestionnaire2.setMinNum(null);
                    surveyQuestionnaire2.setMinNum(null);
                    surveyQuestionnaire2.setMaxNum(null);
                    surveyQuestionnaire2.setMaxNum(null);
                    surveyQuestionnaire2.setSort(sort);
                    surveyQuestionnaire2.setSort(sort);
                    surveyQuestionnaire2.setQuestionCodeNext(nextQuestion);
                    surveyQuestionnaire2.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaire2.setDel(del);
                    surveyQuestionnaire2.setDel(del);
                    surveyQuestionnaire2.setUpdateTime(new Date());
                    surveyQuestionnaire2.setCreateTime(new Date());
                    surveyQuestionnaireDao.save(surveyQuestionnaire2);
                    surveyQuestionnaireDao.save(surveyQuestionnaire2);
@ -462,6 +492,8 @@ public class ManagerQuestionnaireService extends BaseService {
        survey.setTemplateCode(templateCode);
        survey.setTemplateCode(templateCode);
        survey.setStatus(status);
        survey.setStatus(status);
        survey.setAmount(amount);
        survey.setAmount(amount);
        survey.setCreateTime(new Date());
        survey.setUpdateTime(new Date());
        surveyDao.save(survey);
        surveyDao.save(survey);
        return surveyCode;
        return surveyCode;
    }
    }
@ -620,6 +652,14 @@ public class ManagerQuestionnaireService extends BaseService {
            int isRequired = questionnair.getIsRequired();
            int isRequired = questionnair.getIsRequired();
            int sort = questionnair.getSort();
            int sort = questionnair.getSort();
            int type = questionnair.getQuestionType();
            int type = questionnair.getQuestionType();
            if (questionnair.getMaxNum() != null) {
                int maxNum = questionnair.getMaxNum();
                question.put("maxNum", maxNum);
            }
            if (questionnair.getMinNum() != null) {
                int minNum = questionnair.getMinNum();
                question.put("minNum", minNum);
            }
            if (questionnair.getQuestionComment() != null) {
            if (questionnair.getQuestionComment() != null) {
                String comment = questionnair.getQuestionComment();
                String comment = questionnair.getQuestionComment();
                question.put("comment", comment);
                question.put("comment", comment);
@ -627,7 +667,7 @@ public class ManagerQuestionnaireService extends BaseService {
            if (questionnair.getQuestionCodeNext() != null) {
            if (questionnair.getQuestionCodeNext() != null) {
                String next = questionnair.getQuestionCodeNext();
                String next = questionnair.getQuestionCodeNext();
                SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                question.put("nextQuestion", sq.getSort());
                question.put("nextQuestion", sq == null ? 0 : sq.getSort());
            }
            }
//            List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findById(qstcode);
//            List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findById(qstcode);
@ -642,9 +682,11 @@ public class ManagerQuestionnaireService extends BaseService {
                if (option.getQuestionCodeNext() != null) {
                if (option.getQuestionCodeNext() != null) {
                    String next = option.getQuestionCodeNext();
                    String next = option.getQuestionCodeNext();
                    SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                    SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                    System.out.println("=============qstcode============== " + qstcode);
                    System.out.println("=============optCode============== " + option.getCode());
                    System.out.println("=============sq============== " + sq);
                    System.out.println("=============sq============== " + sq);
                    System.out.println("=============next============== " + next);
                    System.out.println("=============next============== " + next);
                    opt.put("nextQuestion", sq.getSort());
                    opt.put("nextQuestion", sq == null ? 0 : sq.getSort());
                }
                }
                opt.put("content", conetent);
                opt.put("content", conetent);
                opt.put("sort", st);
                opt.put("sort", st);
@ -1137,7 +1179,6 @@ public class ManagerQuestionnaireService extends BaseService {
            }
            }
            questions.add(question);
            questions.add(question);
        }
        }
@ -1148,11 +1189,11 @@ public class ManagerQuestionnaireService extends BaseService {
        jsonObject.put("comment", tempComment);
        jsonObject.put("comment", tempComment);
        jsonObject.put("label", labels);
        jsonObject.put("label", labels);
        jsonObject.put("questions", questions);
        jsonObject.put("questions", questions);
        System.out.println("==========jsonObject============" + jsonObject);
        return jsonObject;
        return jsonObject;
    }
    }
    public int savaSurveyAsTemplate(String code) throws Exception {
    public int savaSurveyAsTemplate(String code, String modifyTitle) throws Exception {
        Survey survey = surveyDao.findById(code);
        Survey survey = surveyDao.findById(code);
        String tempCode = getCode();
        String tempCode = getCode();
        String title = survey.getTitle();
        String title = survey.getTitle();
@ -1161,10 +1202,20 @@ public class ManagerQuestionnaireService extends BaseService {
        Date createTime = survey.getCreateTime();
        Date createTime = survey.getCreateTime();
        Date updateTime = survey.getUpdateTime();
        Date updateTime = survey.getUpdateTime();
        //        查询问卷标题重复情况
        //        查询问卷标题重复情况
        int number = surveyTemplatesDao.distinctByTitle(title);
        if (number!=0){
            int likeNum = surveyTemplatesDao.distinctLikeTitle(title+"%");
          return  likeNum;
        int number = 0;
        if (StringUtils.isEmpty(modifyTitle)) {
            number = surveyTemplatesDao.distinctByTitle(title);
        } else {
            number = surveyTemplatesDao.distinctByTitle(modifyTitle);
            title = modifyTitle;
        }
        if (number != 0 && StringUtils.isEmpty(modifyTitle)) {
            int likeNum = surveyTemplatesDao.distinctLikeTitle(title + "%");
            return likeNum;
        }
        if (number != 0 && !StringUtils.isEmpty(modifyTitle)) {
            int likeNum = surveyTemplatesDao.distinctLikeTitle(modifyTitle + "%");
            return likeNum;
        }
        }
        SurveyTemplates surveyTemplates = new SurveyTemplates(tempCode, title, templateComment, creater, 1, createTime, updateTime);
        SurveyTemplates surveyTemplates = new SurveyTemplates(tempCode, title, templateComment, creater, 1, createTime, updateTime);
//        保存模板信息
//        保存模板信息
@ -1208,15 +1259,25 @@ public class ManagerQuestionnaireService extends BaseService {
        return 0;
        return 0;
    }
    }
    public int modifyTemplate(String code, String templateCode) throws Exception {
    public int modifyTemplate(String code, String templateCode, String modifyTitle) throws Exception {
        Survey survey = surveyDao.findById(code);
        Survey survey = surveyDao.findById(code);
        String title = survey.getTitle();
        String title = survey.getTitle();
        String templateComment = survey.getSurveyComment();
        String templateComment = survey.getSurveyComment();
//        查询问卷标题重复情况
//        查询问卷标题重复情况
        int number = surveyTemplatesDao.distinctByTitle(title);
        if (number!=0){
            int likeNum = surveyTemplatesDao.distinctLikeTitle(title+"%");
            return  likeNum;
        int number = 0;
        if (StringUtils.isEmpty(modifyTitle)) {
            number = surveyTemplatesDao.distinctByTitle(title);
        } else {
            number = surveyTemplatesDao.distinctByTitle(modifyTitle);
            title = modifyTitle;
        }
        if (number != 0 && StringUtils.isEmpty(modifyTitle)) {
            int likeNum = surveyTemplatesDao.distinctLikeTitle(title + "%");
            return likeNum;
        }
        if (number != 0 && !StringUtils.isEmpty(modifyTitle)) {
            int likeNum = surveyTemplatesDao.distinctLikeTitle(modifyTitle + "%");
            return likeNum;
        }
        }
//        SurveyTemplates surveyTemplates = new SurveyTemplates(templateCode, title, templateComment, creater, 1, creater, updateTime);
//        SurveyTemplates surveyTemplates = new SurveyTemplates(templateCode, title, templateComment, creater, 1, creater, updateTime);
//        更改模板信息
//        更改模板信息
@ -1381,10 +1442,10 @@ public class ManagerQuestionnaireService extends BaseService {
                case "0":
                case "0":
                    break disea;
                    break disea;
                case "1":
                case "1":
                    dis += " s.label_name LIKE '%糖尿病%' ";
                    dis += " s.label_name LIKE '%高血压%' ";
                    break;
                    break;
                case "2":
                case "2":
                    dis += " s.label_name LIKE '%高血压%' ";
                    dis += " s.label_name LIKE '%糖尿病%' ";
                    break;
                    break;
            }
            }
            dis += " OR ";
            dis += " OR ";
@ -1456,46 +1517,11 @@ public class ManagerQuestionnaireService extends BaseService {
            str += "AND " + diseas;
            str += "AND " + diseas;
        }*/
        }*/
//        Map<String, Object> patients = jdbcTemplate.queryForMap(str);
//        Map<String, Object> patients = jdbcTemplate.queryForMap(str);
        System.out.println("=====query sql =======>>>>" + str);
        List<String> patients = jdbcTemplate.queryForList(str, String.class);
        List<String> patients = jdbcTemplate.queryForList(str, String.class);
        return patients;
        return patients;
    }
    }
    /**
     * 线程发送模板消息
     */
    class SendMessage implements Runnable {
        private String code;
        private List<String> codes;
        private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        private String str = "{\"remark\":\"我们将按调查最终结果,优化健康服务。\",\"keyword1\":\"调查问卷\"}";
        private String accessToken;
        private JSONObject json = new JSONObject(str);
        public SendMessage(String code, List<String> codes, String accessToken) {
            this.code = code;
            this.codes = codes;
            this.accessToken = accessToken;
        }
        @Override
        public void run() {
            synchronized (this) {
                json.put("survey_id", code);
                for (String cod : codes) {
                    Patient p = patientDao.findByCode(cod);
                    String name = p.getName();
                    String openId = p.getOpenid();
                /*String name = "吴俊杰";
                String openId = "o7NFZw1QM4YR1O19mLjwfX1Hh11A";
                cod = "jojojojpkpokpko";*/
                    json.put("keyword2", sdf.format(new Date()));
                    json.put("toUser", cod);
                    json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
                    PushMsgTask.getInstance().sendWeixinMessage(accessToken, 11, openId, name, json);
                }
            }
        }
    }
}
}

+ 12 - 27
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/PatientQuestionnaireService.java

@ -47,28 +47,6 @@ public class PatientQuestionnaireService extends BaseService {
        return jsonObject;
        return jsonObject;
    }
    }
   /* public void getQuestions(String id,Integer sort,Integer pageNo,Integer total,String nextCode){
        JSONObject json = new JSONObject();
        if(StringUtils.isEmpty(nextCode)){
            //不跳题
            if(total==null){
                total = surveyQuestionnaireDao.findTotalById(id);
            }
            sort = pageNo+1;
            json.put("total",total);
            json.put("sort",sort);
        }else{
            //跳题
            SurveyQuestionnaire question = surveyQuestionnaireDao.findByIdAndQstId(id,nextCode);
            total = total - (sort+1);
            json.put("total",total);
            json.put("sort",question.getSort());
        }
    }*/
    /**
    /**
     * @param id   问卷id
     * @param id   问卷id
     * @param sort 当前问题的sort(初始为1)
     * @param sort 当前问题的sort(初始为1)
@ -83,6 +61,13 @@ public class PatientQuestionnaireService extends BaseService {
        String qstCode = question.getCode();
        String qstCode = question.getCode();
        String qstTitle = question.getTitle();
        String qstTitle = question.getTitle();
        int isRequired = question.getIsRequired();
        int isRequired = question.getIsRequired();
        if (question.getQuestionCodeNext() != null) {
            String next = question.getQuestionCodeNext();
            SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
            System.out.println("");
            jsonObject.put("nextQuestion", sq == null ? 0 : sq.getSort());
        }
        if (!StringUtils.isEmpty(question.getQuestionComment())) {
        if (!StringUtils.isEmpty(question.getQuestionComment())) {
            jsonObject.put("comment", question.getQuestionComment());
            jsonObject.put("comment", question.getQuestionComment());
        }
        }
@ -115,7 +100,7 @@ public class PatientQuestionnaireService extends BaseService {
                    if (option.getQuestionCodeNext() != null) {
                    if (option.getQuestionCodeNext() != null) {
                        String next = option.getQuestionCodeNext();
                        String next = option.getQuestionCodeNext();
                        SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                        SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                        map.put("nextQuestion", sq.getSort());
                        map.put("nextQuestion", sq == null ? 0 : sq.getSort());
                    }
                    }
                    list.add(map);
                    list.add(map);
                }
                }
@ -148,7 +133,7 @@ public class PatientQuestionnaireService extends BaseService {
                    if (option.getQuestionCodeNext() != null) {
                    if (option.getQuestionCodeNext() != null) {
                        String next = option.getQuestionCodeNext();
                        String next = option.getQuestionCodeNext();
                        SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                        SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                        map.put("nextQuestion", sq.getSort());
                        map.put("nextQuestion", sq == null ? 0 : sq.getSort());
                    }
                    }
                    lis.add(map);
                    lis.add(map);
                }
                }
@ -157,15 +142,15 @@ public class PatientQuestionnaireService extends BaseService {
                Integer minNum = question.getMinNum();
                Integer minNum = question.getMinNum();
                jsonObject.put("maxNum", maxNum);
                jsonObject.put("maxNum", maxNum);
                jsonObject.put("minNum", minNum);
                jsonObject.put("minNum", minNum);
                jsonObject.put("options", optionss);
//                jsonObject.put("options", optionss);
                break;
                break;
            case 2:
           /* case 2:
                if (question.getQuestionCodeNext() != null) {
                if (question.getQuestionCodeNext() != null) {
                    String next = question.getQuestionCodeNext();
                    String next = question.getQuestionCodeNext();
                    SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                    SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                    jsonObject.put("nextQuestion", sq.getSort());
                    jsonObject.put("nextQuestion", sq.getSort());
                }
                }
                break;
                break;*/
        }
        }
        jsonObject.put("qstCode", qstCode);
        jsonObject.put("qstCode", qstCode);
        jsonObject.put("qstTitle", qstTitle);
        jsonObject.put("qstTitle", qstTitle);

+ 2 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -190,7 +190,7 @@ public class PushMsgTask {
     * @return
     * @return
     */
     */
//    private boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
//    private boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
    public boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
    private boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
        try {
        try {
            if (StringUtils.isEmpty(openid)) {
            if (StringUtils.isEmpty(openid)) {
                logger.error("send wechat message failed:openid is empty");
                logger.error("send wechat message failed:openid is empty");
@ -452,13 +452,12 @@ public class PushMsgTask {
                keyword2.setColor("#000000");
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
                m.put("keyword2", keyword2);
                System.out.println("type=====>openId " + openid);
                logger.info("type=====>openId " + openid);
            }
            }
            temp.setData(m);
            temp.setData(m);
            ObjectMapper mapper = new ObjectMapper();
            ObjectMapper mapper = new ObjectMapper();
            String strJson = mapper.writeValueAsString(temp);
            String strJson = mapper.writeValueAsString(temp);
//            System.out.println("strJson=====>strJson " + strJson);
            return strJson;
            return strJson;
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -128,7 +128,7 @@ public class HttpUtil {
			JSONObject participants = new JSONObject();
			JSONObject participants = new JSONObject();
			participants.put("system",0);
			participants.put("system",0);
			participants.put(receiver,0);
			participants.put(receiver,0);
			JSONObject sessionObj  = ImUtill.createSession(participants,"0","系统消息","");
			JSONObject sessionObj  = ImUtill.createSession(participants,ImUtill.SESSION_TYPE_SYSTEM,"系统消息","");
			if(sessionObj.getInt("status")==-1){
			if(sessionObj.getInt("status")==-1){
				throw  new RuntimeException(sessionObj.getString("message"));
				throw  new RuntimeException(sessionObj.getString("message"));
			}
			}

+ 4 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java

@ -237,4 +237,8 @@ public class ImUtill {
    }
    }
    public  static final String SESSION_TYPE_MUC = "1";
    public  static final String SESSION_TYPE_P2P = "2";
    public  static final String SESSION_TYPE_GROUP = "3";
    public  static final String SESSION_TYPE_SYSTEM = "0";
}
}

+ 7 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendPatientUtil.java

@ -18,8 +18,9 @@ public class SendPatientUtil extends  Thread {
	private String content;
	private String content;
	private String title;
	private String title;
	private String type;
	private String type;
	private String teamCode;
	public SendPatientUtil(String from,String fromName,String to,String contentType,String content,String title,String type){
	public SendPatientUtil(String from,String fromName,String to,String contentType,String content,String title,String type,String teamCode){
		this.from = from;
		this.from = from;
		this.fromName = fromName;
		this.fromName = fromName;
		this.to = to;
		this.to = to;
@ -27,11 +28,12 @@ public class SendPatientUtil extends  Thread {
		this.content = content;
		this.content = content;
		this.title = title;
		this.title = title;
		this.type = type;
		this.type = type;
		this.teamCode =teamCode;
	}
	}
	public String sendToPatient(String from,String fromName,String to,String contentType,String content,String title,String type){
		JSONArray jsonArray = ImUtill.getParticipants(to+"_consult_"+type);
	public String sendToPatient(String from,String fromName,String to,String contentType,String content,String title,String type,String teamCode){
		JSONArray jsonArray = ImUtill.getParticipants(to+"_"+teamCode+"_"+type);
		JSONObject participants = new JSONObject();
		JSONObject participants = new JSONObject();
		for(Object object:jsonArray){
		for(Object object:jsonArray){
			JSONObject jsonObject = (JSONObject)object;
			JSONObject jsonObject = (JSONObject)object;
@ -47,7 +49,7 @@ public class SendPatientUtil extends  Thread {
		if(!"4".equals(contentType)){
		if(!"4".equals(contentType)){
			contentType = "0";
			contentType = "0";
		}
		}
		JSONObject sessionJson  = ImUtill.createSession(participants,"1",title,to+"_consult_"+type);
		JSONObject sessionJson  = ImUtill.createSession(participants,ImUtill.SESSION_TYPE_MUC,title,to+"_"+teamCode+"_"+type);
		if(sessionJson.getInt("status")==-1){
		if(sessionJson.getInt("status")==-1){
			throw  new RuntimeException(sessionJson.getString("message"));
			throw  new RuntimeException(sessionJson.getString("message"));
		}
		}
@ -56,6 +58,6 @@ public class SendPatientUtil extends  Thread {
	}
	}
	public void run(){
	public void run(){
		this.sendToPatient(from,fromName,to,contentType,content,title,type);
		this.sendToPatient(from,fromName,to,contentType,content,title,type,teamCode);
	}
	}
}
}

+ 0 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheduling/DoctorWorkTimeController.java

@ -132,10 +132,6 @@ public class DoctorWorkTimeController extends BaseController {
            if (StringUtils.isEmpty(receiveConsult)) {
            if (StringUtils.isEmpty(receiveConsult)) {
                return error(-1, "是否接受咨询参数不能为空");
                return error(-1, "是否接受咨询参数不能为空");
            }
            }
            Doctor doc = doctorDao.findByCode(getUID());
            if(!(1==doc.getLevel())){
                return error(-1, "非专科医生无法关闭咨询");
            }
            if (doctorWorkTimeService.setDoctorReceiveConsult(getUID(), receiveConsult)) {
            if (doctorWorkTimeService.setDoctorReceiveConsult(getUID(), receiveConsult)) {
                return error(200, "设置成功");
                return error(200, "设置成功");
            } else {
            } else {

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

@ -373,7 +373,8 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    /**
    /**
     * 新建问卷保存为模板
     * 新建问卷保存为模板
     *引用模板新建问卷保存变更到模板
     * 引用模板新建问卷保存变更到模板
     *
     * @param code
     * @param code
     * @return
     * @return
     */
     */
@ -384,18 +385,24 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
            @ApiParam(value = "新建问卷编码")
            @ApiParam(value = "新建问卷编码")
            @RequestParam String code,
            @RequestParam String code,
            @ApiParam(value = "旧模板编码")
            @ApiParam(value = "旧模板编码")
            @RequestParam(required = false) String templateCode) {
            @RequestParam(required = false) String templateCode,
            @ApiParam(value = "修改后的标题")
            @RequestParam(required = false) String title) {
        try {
        try {
            int num=0;
            if (StringUtils.isEmpty(templateCode)){
                num = managerQuestionnaireService.savaSurveyAsTemplate(code);
            }else {
                num = managerQuestionnaireService.modifyTemplate(code,templateCode);
            int num = 0;
            if (StringUtils.isEmpty(templateCode)) {
                num = managerQuestionnaireService.savaSurveyAsTemplate(code, title);
            } else {
                num = managerQuestionnaireService.modifyTemplate(code, templateCode, title);
            }
            }
            if (num==0){
            if (num == 0) {
                return write(200, "保存成功!");
                return write(200, "保存成功!");
            }else {
                return write(-1, "标题重复!","data",num);
            } else {
                Map map = new HashMap();
//              标题重复码
                map.put("errorCode", "001");
                map.put("number", num);
                return write(-1, "标题重复!", "data", map);
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
@ -435,8 +442,23 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
                pushMsgTask.sendWeixinMessage(accessToken, 11, openId, name, json);
                pushMsgTask.sendWeixinMessage(accessToken, 11, openId, name, json);
            }*/
            }*/
            List<String> codes = surveyUserDao.findBySurveyCodeAndStatus(code);
            List<String> codes = surveyUserDao.findBySurveyCodeAndStatus(code);
            SendMessage sendMessage = new SendMessage(code, codes, getAccessToken());
            new Thread(sendMessage).start();
            String accessToken = getAccessToken();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String str = "{\"remark\":\"我们将按调查最终结果,优化健康服务。\",\"keyword1\":\"调查问卷\"}";
            JSONObject json = new JSONObject(str);
            codes.stream().forEach(c -> {
                Patient p = patientDao.findByCode(c);
                String name = p.getName();
                String openId = p.getOpenid();
                json.put("keyword2", sdf.format(new Date()));
                json.put("toUser", c);
                json.put("survey_id", code);
                json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
                PushMsgTask.getInstance().putWxMsg(accessToken, 11, openId, name, json);
            });
            return write(200, "发送成功!");
            return write(200, "发送成功!");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
@ -465,40 +487,5 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
        }
        }
    }
    }
    /**
     * 线程发送模板消息
     */
    class SendMessage implements Runnable {
        private String code;
        private List<String> codes;
        private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        private String str = "{\"remark\":\"我们将按调查最终结果,优化健康服务。\",\"keyword1\":\"调查问卷\"}";
        private String accessToken;
        private JSONObject json = new JSONObject(str);
        public SendMessage(String code, List<String> codes, String accessToken) {
            this.code = code;
            this.codes = codes;
            this.accessToken = accessToken;
            System.out.println("============>" + accessToken);
        }
        @Override
        public void run() {
            synchronized (this) {
                json.put("survey_id", code);
                for (String cod : codes) {
                    Patient p = patientDao.findByCode(cod);
                    String name = p.getName();
                    String openId = p.getOpenid();
                    json.put("keyword2", sdf.format(new Date()));
                    json.put("toUser", cod);
                    json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
                    PushMsgTask.getInstance().sendWeixinMessage(accessToken, 11, openId, name, json);
                }
            }
        }
    }
}
}

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -441,13 +441,13 @@ public class FamilyContractController extends BaseController {
     */
     */
    @RequestMapping(value = "sign")
    @RequestMapping(value = "sign")
    @ResponseBody
    @ResponseBody
    public String sign(String doctor) {
    public String sign(String doctor,String patient) {
        try {
        try {
            if (StringUtils.isEmpty(doctor)) {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
                return error(-1, "签约医生不能为空");
            }
            }
            int result = familyContractService.sign(doctor, getUID());
            int result = familyContractService.sign(doctor,patient);
            if (result == -1) {
            if (result == -1) {
                return error(-1, "用户信息查询失败");
                return error(-1, "用户信息查询失败");

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

@ -54,21 +54,21 @@
##------------------------------------�����������ݿ�����------------------------------------#
##------------------------------------�����������ݿ�����------------------------------------#
#### mysql database setting
#### mysql database setting
jdbc.driver=com.mysql.jdbc.Driver
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
jdbc.url=jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
jdbc.username=linzhou
jdbc.password=linzhou
#### health index
#### health index
health.jdbc.driver=com.mysql.jdbc.Driver
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
health.jdbc.url=jdbc:mysql://172.19.103.85/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
health.jdbc.username=linzhou
health.jdbc.password=linzhou
#### suifang
#### suifang
fv.jdbc.driver=com.mysql.jdbc.Driver
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
fv.jdbc.url=jdbc:mysql://172.19.103.85/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
fv.jdbc.username=linzhou
fv.jdbc.password=linzhou
#### redis
#### redis
redis.host=172.19.103.47
redis.host=172.19.103.47

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

@ -151,7 +151,7 @@ fastdfs_file_url=http://172.19.103.54:80/
##咨询回复
##咨询回复
#template_consult_notice=-dr4QNyFoRvVsf8uWxXMC1dRyjwnbUuJwJ21vBLhf18
#template_consult_notice=-dr4QNyFoRvVsf8uWxXMC1dRyjwnbUuJwJ21vBLhf18
##签约成功
##签约成功
#template_sign_success=bw0_fVIxATsCuOwKYF8gzUyuZQ9IosC4Jf8ZU5IKMS4
#template_sign_success=VYGj8OUKj6FH4i4_nZS2UAHurJxQHx-7_OBPILIdB8s
##签约失败
##签约失败
#template_sign_failed=m221Jrkm0UUY00ExTCpQNTB8t_1U_V4LR9Bg8BgH9-o
#template_sign_failed=m221Jrkm0UUY00ExTCpQNTB8t_1U_V4LR9Bg8BgH9-o
##健康指导提醒
##健康指导提醒