Browse Source

删除设备假删除接口

8 years ago
parent
commit
be65d430ac
47 changed files with 658 additions and 249 deletions
  1. BIN
      patient-co-statistics/doc/业务文档/统计指标流程.docx
  2. BIN
      patient-co-statistics/doc/部署文档/正式库/后台/tomcat部署.docx
  3. 27 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java
  4. 6 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/SignDataFilter.java
  5. 4 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/DBStorage.java
  6. 15 3
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  7. 1 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/PushMsgTask.java
  8. BIN
      patient-co-wlyy/doc/接口文档/厦门i健康API文档.docx
  9. 10 0
      patient-co-wlyy/doc/部署文档/正式库/app/ios/00.readme.txt
  10. BIN
      patient-co-wlyy/doc/部署文档/正式库/app/ios/HBuilder使用该证书打包的例子.png
  11. BIN
      patient-co-wlyy/doc/部署文档/正式库/app/ios/aps推送证书.p12
  12. BIN
      patient-co-wlyy/doc/部署文档/正式库/app/ios/xmijkPro.mobileprovision
  13. BIN
      patient-co-wlyy/doc/部署文档/正式库/app/ios/证书.p12
  14. BIN
      patient-co-wlyy/doc/部署文档/正式库/app/医生端通过HBuilder打包说明(草稿,完整版V0.2).docx
  15. BIN
      patient-co-wlyy/doc/部署文档/正式库/app/发布修改参数.docx
  16. 10 0
      patient-co-wlyy/doc/部署文档/正式库/app/安卓/00.readme.txt
  17. BIN
      patient-co-wlyy/doc/部署文档/正式库/app/安卓/20160721170424_该证书的生成命令.png
  18. BIN
      patient-co-wlyy/doc/部署文档/正式库/app/安卓/HBuilder使用该证书打包的例子.png
  19. BIN
      patient-co-wlyy/doc/部署文档/正式库/app/安卓/ssgg_doctor.keystore
  20. 5 0
      patient-co-wlyy/doc/部署文档/正式库/app/安卓/文档.txt
  21. BIN
      patient-co-wlyy/doc/部署文档/正式库/im/im.docx
  22. BIN
      patient-co-wlyy/doc/部署文档/正式库/后台/tomcat部署.docx
  23. BIN
      patient-co-wlyy/doc/部署文档/正式库/微信端/微信端发布.docx
  24. 6 1
      patient-co-wlyy/pom.xml
  25. 12 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateOptions.java
  26. 12 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateQuestions.java
  27. 4 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorWorkTimeDao.java
  28. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyAnswersDao.java
  29. 4 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyLabelInfoDao.java
  30. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyOptionAnswersDao.java
  31. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyQuestionsDao.java
  32. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyStatisticsDao.java
  33. 8 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateOptionsDao.java
  34. 11 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateQuestionsDao.java
  35. 13 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplatesDao.java
  36. 11 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  37. 3 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  38. 24 14
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheduling/DoctorWorkTimeService.java
  39. 310 68
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java
  40. 91 77
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/PatientQuestionnaireService.java
  41. 7 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  42. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheduling/DoctorWorkTimeController.java
  43. 43 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java
  44. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  45. 0 44
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java
  46. 4 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  47. 3 1
      patient-co-wlyy/src/main/resources/system.properties

BIN
patient-co-statistics/doc/业务文档/统计指标流程.docx


BIN
patient-co-statistics/doc/部署文档/正式库/后台/tomcat部署.docx


+ 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());
        }
    }
    @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
     */
    @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());
        }
    }
    /**
     * 启动通知任务
     *

+ 6 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/SignDataFilter.java

@ -81,6 +81,7 @@ public class SignDataFilter {
     *
     * @param signFamilies 签约列表
     * @param level2Key    二级维度的key
     *                       1:性别 2:年龄 3:分组 4:费用 5:健康服务分布 6:年龄 7:年龄疾病
     * @param filterDate   过滤的是哪天的数据 yyyy-MM-dd
     * @return
     */
@ -93,7 +94,9 @@ public class SignDataFilter {
     *
     * @param signFamilies 签约列表
     * @param level2Key    二级维度的key
     *                       1:性别 2:年龄 3:分组 4:费用 5:健康服务分布 6:年龄 7:年龄疾病
     * @param level3Key    三级维度的key
     *                      1.疾病
     * @param filterDate   过滤的是哪天的数据 yyyy-MM-dd
     * @return
     */
@ -106,7 +109,9 @@ public class SignDataFilter {
     *
     * @param signFamilies 签约列表
     * @param level2Key    二级维度的key
     *                       1:性别 2:年龄 3:分组 4:费用 5:健康服务分布 6:年龄 7:年龄疾病
     * @param level3Key    三级维度的key
     *                      1.疾病
     * @param filterDate   过滤的是哪天的数据 yyyy-MM-dd
     * @return
     */
@ -295,7 +300,7 @@ public class SignDataFilter {
    /**
     * 得到二级维度的key
     *
     *1:性别 2:年龄 3:分组 4:费用 5:健康服务分布 6:年龄 7:年龄疾病
     * @param level2Key
     * @return
     */

+ 4 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/DBStorage.java

@ -200,7 +200,10 @@ public class DBStorage   {
     * @param type 1 性别 2 年龄 3 用户分组 4.签约费用 5 健康分布
     * @param start 起始位置 默认是1
     */
    public void saveByLevel2(List<Map<String, Map<String, List<ETLModel>>>> data, String day, WlyyQuotaVO wlyyQuota,Integer foreachNum,Integer type,Integer start)throws Exception {
    public void saveByLevel2(List<Map<String, Map<String, List<ETLModel>>>> data, String day, WlyyQuotaVO wlyyQuota,
                             Integer foreachNum,
                             Integer type,
                             Integer start)throws Exception {
        this.wlyyQuota=wlyyQuota;
        level2Public(data, day, foreachNum, type, start);
    }

+ 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 {
        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 {
            throw new Exception("已经启动");
@ -478,11 +478,14 @@ public class JobService {
        }
    }
    /******************************* 随访计划任务 *******************************************************/
    /*******************************
     * 随访计划任务
     *******************************************************/
    @Value("${spring.followupMessage.jobId}")
    private String followupJob;
    @Value("${spring.followupMessage.cron}")
    private String followupJobCron;
    public void startFollowupPlantJob() throws Exception {
        if (!quartzHelper.isExistJob(followupJob)) {
            quartzHelper.addJob(FollowupPlanJob.class, followupJobCron, followupJob, new HashMap<>());
@ -498,4 +501,13 @@ public class JobService {
            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-statistics/src/main/java/com/yihu/wlyy/statistics/task/PushMsgTask.java

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

BIN
patient-co-wlyy/doc/接口文档/厦门i健康API文档.docx


+ 10 - 0
patient-co-wlyy/doc/部署文档/正式库/app/ios/00.readme.txt

@ -0,0 +1,10 @@
----------------------------------
包名:
com.yihu.xmijk
证书密码:
111111
----------------------------------
develope.apple.com 账号:
chunyudang.yihu@gmail.com 
Jkzldangchunyu060201

BIN
patient-co-wlyy/doc/部署文档/正式库/app/ios/HBuilder使用该证书打包的例子.png


BIN
patient-co-wlyy/doc/部署文档/正式库/app/ios/aps推送证书.p12


BIN
patient-co-wlyy/doc/部署文档/正式库/app/ios/xmijkPro.mobileprovision


BIN
patient-co-wlyy/doc/部署文档/正式库/app/ios/证书.p12


BIN
patient-co-wlyy/doc/部署文档/正式库/app/医生端通过HBuilder打包说明(草稿,完整版V0.2).docx


BIN
patient-co-wlyy/doc/部署文档/正式库/app/发布修改参数.docx


+ 10 - 0
patient-co-wlyy/doc/部署文档/正式库/app/安卓/00.readme.txt

@ -0,0 +1,10 @@
----------------------------------
包名:
com.wjw.ssgg.doctor
证书别名:
ssgg_doctor.keystore
证书密码:
ssgg_doctor
----------------------------------

BIN
patient-co-wlyy/doc/部署文档/正式库/app/安卓/20160721170424_该证书的生成命令.png


BIN
patient-co-wlyy/doc/部署文档/正式库/app/安卓/HBuilder使用该证书打包的例子.png


BIN
patient-co-wlyy/doc/部署文档/正式库/app/安卓/ssgg_doctor.keystore


+ 5 - 0
patient-co-wlyy/doc/部署文档/正式库/app/安卓/文档.txt

@ -0,0 +1,5 @@
upload_preview.js
common_http.js
im_new.js

BIN
patient-co-wlyy/doc/部署文档/正式库/im/im.docx


BIN
patient-co-wlyy/doc/部署文档/正式库/后台/tomcat部署.docx


BIN
patient-co-wlyy/doc/部署文档/正式库/微信端/微信端发布.docx


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

@ -75,7 +75,7 @@
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>java-ffmpegjave</artifactId>
            <artifactId>jave-ffmpegjave</artifactId>
            <version>1.0.4</version>
        </dependency>
@ -489,6 +489,11 @@
            <artifactId>fastdfs_lib</artifactId>
            <version>1.25</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>RELEASE</version>
        </dependency>
    </dependencies>
    <dependencyManagement>

+ 12 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateOptions.java

@ -25,6 +25,8 @@ public class SurveyTemplateOptions extends IdEntity implements Serializable {
    private String templateCode;
    //    下一题问题编码(逻辑跳转)
    private String questionCodeNext;
    //    下一题问题编码(逻辑跳转)
    private String questionSortNext;
    //    选项说明是否必填(0否 1是)
    private Integer isRequired;
    //    单题内排序
@ -35,18 +37,27 @@ public class SurveyTemplateOptions extends IdEntity implements Serializable {
    public SurveyTemplateOptions() {
    }
    public SurveyTemplateOptions(String code, Integer haveComment, String templateQuestionCode, String content, String templateCode, String questionCodeNext, Integer isRequired, Integer sort, Integer del) {
    public SurveyTemplateOptions(String code, Integer haveComment, String templateQuestionCode, String content, String templateCode, String questionCodeNext, String questionSortNext, Integer isRequired, Integer sort, Integer del) {
        this.code = code;
        this.haveComment = haveComment;
        this.templateQuestionCode = templateQuestionCode;
        this.content = content;
        this.templateCode = templateCode;
        this.questionCodeNext = questionCodeNext;
        this.questionSortNext = questionSortNext;
        this.isRequired = isRequired;
        this.sort = sort;
        this.del = del;
    }
    public String getQuestionSortNext() {
        return questionSortNext;
    }
    public void setQuestionSortNext(String questionSortNext) {
        this.questionSortNext = questionSortNext;
    }
    public String getCode() {
        return code;
    }

+ 12 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyTemplateQuestions.java

@ -33,6 +33,8 @@ public class SurveyTemplateQuestions extends IdEntity implements Serializable{
    private Integer sort;
    //    下一题问题编码(问答题逻辑跳转)
    private String questionCodeNext;
    //    下一题问题编码(问答题逻辑跳转)
    private String questionSortNext;
    //    删除标志(1正常,0删除)
    private Integer del;
//创建时间
@ -43,7 +45,7 @@ public class SurveyTemplateQuestions extends IdEntity implements Serializable{
    public SurveyTemplateQuestions() {
    }
    public SurveyTemplateQuestions(String code, String title, String questionComment, Integer questionType, String templateCode, Integer isRequired, Integer minNum, Integer maxNum, Integer sort, String questionCodeNext, Integer del, Date createTime, Date updateTime) {
    public SurveyTemplateQuestions(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) {
        this.code = code;
        this.title = title;
        this.questionComment = questionComment;
@ -54,11 +56,20 @@ public class SurveyTemplateQuestions extends IdEntity implements Serializable{
        this.maxNum = maxNum;
        this.sort = sort;
        this.questionCodeNext = questionCodeNext;
        this.questionSortNext = questionSortNext;
        this.del = del;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }
    public String getQuestionSortNext() {
        return questionSortNext;
    }
    public void setQuestionSortNext(String questionSortNext) {
        this.questionSortNext = questionSortNext;
    }
    public String getCode() {
        return code;
    }

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

@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr on 2016/08/19.
 */
@ -19,5 +21,6 @@ public interface DoctorWorkTimeDao extends PagingAndSortingRepository<WlyyDoctor
    @Query("select a from WlyyDoctorWorkTime a where a.doctor = ?1")
    WlyyDoctorWorkTime findDoctorWorkTime(String doctor);
    @Query("select a from WlyyDoctorWorkTime a where a.doctor = ?1")
    List<WlyyDoctorWorkTime> findDoctorWorkTimes(String doctor);
}

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

@ -17,4 +17,7 @@ public interface SurveyAnswersDao extends PagingAndSortingRepository<SurveyAnswe
    @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);
    @Query("select  count(distinct t.patient) from SurveyAnswers t where t.content is not null and t.surveyCode=?1 and t.questionCode=?2 ")
    int countByRelationCode(String surveyCode, String questionId);
}

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

@ -23,8 +23,11 @@ public interface SurveyLabelInfoDao extends PagingAndSortingRepository<SurveyLab
    @Query("select distinct t.label from SurveyLabelInfo t where  t.useType=?1 ")
    List<Object> findByUseType(int useType);
    @Query("select t from SurveyLabelInfo s,SurveyTemplates t where s.relationCode = t.code and s.useType=0 and s.label = ?1 ")
    @Query("select t from SurveyLabelInfo s,SurveyTemplates t where t.del = 1 and s.relationCode = t.code and s.useType=0 and s.label = ?1 ")
    List<SurveyTemplates> findByLabel(int label);
    @Modifying
    @Query("update SurveyLabelInfo s set s.label=?2 where s.relationCode = ?1 ")
    void modifyLabel(String code,int label);
}

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

@ -17,4 +17,7 @@ public interface SurveyOptionAnswersDao extends PagingAndSortingRepository<Surve
    @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);
    @Query("select  count(distinct  t.patient) from SurveyOptionAnswers t where t.surveyCode =?1 and t.questionCode=?2 ")
    int countByRelationCode(String id, String questionId);
}

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

@ -11,9 +11,9 @@ import java.util.List;
 * Created by Reece on 2017/3/9.
 */
public interface SurveyQuestionsDao extends PagingAndSortingRepository<SurveyQuestions, Long> {
    @Query("select  t from SurveyQuestions t where t.title like ?1 ")
    @Query("select  t from SurveyQuestions t where t.title like ?1 and t.del= 1 ")
    List<SurveyQuestions> findByTitle(String title, Pageable request);
    @Query("select  t from SurveyQuestions t ")
    @Query("select  t from SurveyQuestions t where t.del = 1 ")
    List<SurveyQuestions> findByTitle(Pageable request);
}

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

@ -17,7 +17,7 @@ public interface SurveyStatisticsDao extends PagingAndSortingRepository<SurveySt
    @Query("update SurveyStatistics t set t.amount = amount+1 where t.surveyCode = ?1 and  t.questionCode = ?2 ")
    void modifyAmount(String surveyCode, String qstCode);
    @Query("select t.amount from SurveyStatistics t where t.surveyCode = ?1 and  t.questionCode = ?2 ")
    @Query("select distinct t.amount from SurveyStatistics t where t.surveyCode = ?1 and  t.questionCode = ?2 ")
    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 ")

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

@ -1,6 +1,7 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyTemplateOptions;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -9,7 +10,12 @@ import java.util.List;
/**
 * Created by Reece on 2017/3/10.
 */
public interface SurveyTemplateOptionsDao extends PagingAndSortingRepository<SurveyTemplateOptions,Long>{
public interface SurveyTemplateOptionsDao extends PagingAndSortingRepository<SurveyTemplateOptions, Long> {
    @Query("select t from  SurveyTemplateOptions t where  t.templateQuestionCode = ?1 and t.templateCode = ?2 ")
    List<SurveyTemplateOptions> findById(String qstcode,String tempCode);
    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")
    void modifyOption(String tempCode, String qstcode, String optcode, Integer haveCommment, String content, String nextCode, Integer isRequired, Integer sort);
}

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

@ -1,6 +1,7 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyTemplateQuestions;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -14,5 +15,14 @@ public interface SurveyTemplateQuestionsDao extends PagingAndSortingRepository<S
    List<SurveyTemplateQuestions> findById(String tempCode);
    @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);
    @Query("select  t.code from SurveyTemplateQuestions t where t.templateCode = ?1 and t.sort = ?2 ")
    String findBySort(String tempCode, Object sort);
    @Modifying
    @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  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);
}

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

@ -2,22 +2,34 @@ package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyTemplates;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
 * Created by Reece on 2017/3/9.
 */
public interface SurveyTemplatesDao extends PagingAndSortingRepository<SurveyTemplates, Long> {
    @Query("select  t from SurveyTemplates t")
    @Query("select  t from SurveyTemplates t where t.del = 1 ")
    List<SurveyTemplates> findAlls(Pageable request);
    @Query("select  distinct t from SurveyTemplates t where t.title like?1 ")
    List<SurveyTemplates> findByTitle(String title, Pageable request);
    @Query("select count(t.id)  from SurveyTemplates t where t.title = ?1 ")
    int distinctByTitle(String title);
    @Query("select count(t.id)  from SurveyTemplates t where t.title like ?1 ")
    int distinctLikeTitle(String title);
    @Query("select  t from SurveyTemplates t where t.code = ?1 ")
    SurveyTemplates findById(String code);
    @Modifying
    @Query("update SurveyTemplates t set t.title=?2 ,t.templateComment=?3 where t.code=?1 ")
    void modifyTemplate(String templateCode, String title, String templateComment);
}

+ 11 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -105,6 +105,8 @@ public class DoctorInfoService extends BaseService {
    WeiXinAccessTokenUtils accessTokenUtils;
    @Autowired
    protected OperatorLogDao operatorLogDao;
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    /**
     * 获取医生的签约病人
@ -629,10 +631,14 @@ public class DoctorInfoService extends BaseService {
    public void setFamous(String doctorCode, Integer status) {
        Doctor doctor = doctorDao.findByCode(doctorCode);
        //如果是空或者大于1 默认是关闭名医
        if (status == null || status > 1) {
        if (status == null || status > 1 || status == 0) {
            status = 0;
            doctor.setIsFamous(status);
            //更新医生改成可以接受咨询
            doctorWorkTimeService.updateDoctorWorkTime(doctorCode);
        } else {
            doctor.setIsFamous(status);
        }
        doctor.setIsFamous(status);
    }
    @Transactional
@ -881,7 +887,7 @@ public class DoctorInfoService extends BaseService {
        for (int i = 0; i < patiensString.length; i++) {
            try {
                updateTeamHealthDoctor(newDoctorCode, oldDoctorCode, patiensString[i]);
                ImUtill.deleteMucUser(newDoctorCode,oldDoctorCode,patiensString[i]+"_consult_2");
                ImUtill.deleteMucUser(newDoctorCode, oldDoctorCode, patiensString[i] + "_consult_2");
                successs++;
            } catch (Exception e) {
                error++;
@ -913,7 +919,7 @@ public class DoctorInfoService extends BaseService {
                    if (updateTeamHealthDoctorAll(newDoctorCode, patient) == -1) {
                        hasNoTeam = true;
                    }
                    ImUtill.deleteMucUser(newDoctorCode,doctor,patient+"_consult_2");
                    ImUtill.deleteMucUser(newDoctorCode, doctor, patient + "_consult_2");
                } catch (Exception e) {
                    e.printStackTrace();
                }
@ -1086,7 +1092,7 @@ public class DoctorInfoService extends BaseService {
        for (int i = 0; i < patiensString.length; i++) {
            try {
                ImUtill.deleteMucUser(newDoctorCode,oldDoctorCode,patiensString[i]+"_consult_2");
                ImUtill.deleteMucUser(newDoctorCode, oldDoctorCode, patiensString[i] + "_consult_2");
                updateTeamDoctor(newDoctorCode, oldDoctorCode, patiensString[i]);
                successs++;
            } catch (Exception e) {

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

@ -743,8 +743,8 @@ public class ConsultTeamService extends ConsultService {
        String content = addLogs(ct);
        //推送给IM去创建议题,取得成员消息
        JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), "咨询问题:"+consult.getSymptoms(), consult.getImages());
        users.put(patient, 0);
        JSONObject obj = ImUtill.createTopics(patient + "_consult_" + ct.getType(), consult.getCode(), tempPatient.getName() + " " + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard()), users, messages, ImUtill.SESSION_TYPE_MUC);
        users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
        JSONObject obj = ImUtill.createTopics(patient + "_consult_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, "1");
        if (obj == null) {
            throw new RuntimeException("IM消息发送异常!");
        }
@ -1565,6 +1565,7 @@ public class ConsultTeamService extends ConsultService {
                    throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
                }
                ct.setStartMsgId(obj.get("start_msg_id").toString());
                Thread.sleep(100);//消息发送顺序问题处理
                ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "6", content);
                if (StringUtils.isNotBlank(consult.getImages())) {
                    String imgs[] = consult.getImages().split(",");

+ 24 - 14
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheduling/DoctorWorkTimeService.java

@ -40,6 +40,16 @@ public class DoctorWorkTimeService extends BaseService {
    @Autowired
    private FamousDoctorTimesRemainDao timesRemainDao;
    @Transactional
    public void updateDoctorWorkTime(String doctorCode) {
        List<WlyyDoctorWorkTime> wlyyDoctorWorkTimess = doctorWorkTimeDao.findDoctorWorkTimes(doctorCode);
        if (wlyyDoctorWorkTimess != null && wlyyDoctorWorkTimess.size() > 0) {
            wlyyDoctorWorkTimess.stream().forEach( wt->{
                wt.setReceiveConsult("1");
            });
        }
    }
    /**
     * 查询医生工作时间列表
     *
@ -58,10 +68,10 @@ public class DoctorWorkTimeService extends BaseService {
        result.put("workTime", workTime != null ? new JSONObject(workTime) : "");
        result.put("workWeeks", workWeekList != null ? new JSONArray(workWeekList) : "");
        JSONObject docJson = new JSONObject(doc);
        if(docJson.has("password")) {
        if (docJson.has("password")) {
            docJson.remove("password");
        }
        if(docJson.has("salt")) {
        if (docJson.has("salt")) {
            docJson.remove("salt");
        }
        result.put("doctor", doc != null ? docJson : "");
@ -182,10 +192,10 @@ public class DoctorWorkTimeService extends BaseService {
            doctorWorkWeekDao.save(weeks);
        }
        if(doc.getIsFamous() != null && doc.getIsFamous() == 1){
            JSONObject json =  isDoctorWorkingToday(doctor);
        if (doc.getIsFamous() != null && doc.getIsFamous() == 1) {
            JSONObject json = isDoctorWorkingToday(doctor);
            if(json.getString("status").equals("1")){
            if (json.getString("status").equals("1")) {
                DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor,
                        new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
@ -375,7 +385,7 @@ public class DoctorWorkTimeService extends BaseService {
     * @return
     * @throws Exception
     */
    public JSONObject isFamousDoctorWorking(String doctor) throws Exception{
    public JSONObject isFamousDoctorWorking(String doctor) throws Exception {
        JSONObject json = new JSONObject();
        Calendar calendar = Calendar.getInstance();
        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
@ -414,7 +424,7 @@ public class DoctorWorkTimeService extends BaseService {
                        int hour = calendar.get(Calendar.HOUR_OF_DAY);
                        int minute = calendar.get(Calendar.MINUTE);
                        String start = "";
                        String end ="";
                        String end = "";
                        String current = (hour < 10 ? ("0" + hour) : hour) + ":" + (hour < 10 ? ("0" + minute) : minute);
                        // 早上
@ -441,7 +451,7 @@ public class DoctorWorkTimeService extends BaseService {
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if(StringUtils.isEmpty(start)) {
                            if (StringUtils.isEmpty(start)) {
                                start = currentStart;
                            }
                            end = currentEnd;
@ -456,13 +466,13 @@ public class DoctorWorkTimeService extends BaseService {
                            if (currentEnd.length() == 4) {
                                currentEnd = "0" + currentEnd;
                            }
                            if(StringUtils.isEmpty(start)) {
                            if (StringUtils.isEmpty(start)) {
                                start = currentStart;
                            }
                            end = currentEnd;
                        }
                        if(current.compareTo(start) >= 0 && current.compareTo(end) < 0){
                        if (current.compareTo(start) >= 0 && current.compareTo(end) < 0) {
                            flag = 1;
                        }
@ -604,9 +614,9 @@ public class DoctorWorkTimeService extends BaseService {
                        if (plus >= 0) {
                            timesRemain.setTimesRemain(timesRemain.getTimesRemain() + plus);
                        } else {
                            if(workTime.getFamousConsultTimes() >= Math.abs(plus)){
                                timesRemain.setTimesRemain(timesRemain.getTimesRemain()  - Math.abs(plus));
                            }else{
                            if (workTime.getFamousConsultTimes() >= Math.abs(plus)) {
                                timesRemain.setTimesRemain(timesRemain.getTimesRemain() - Math.abs(plus));
                            } else {
                                timesRemain.setTimesRemain(0);
                            }
                        }
@ -706,7 +716,7 @@ public class DoctorWorkTimeService extends BaseService {
                    DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doc.getCode(), date);
                    if (timesRemain == null) {
                        timesRemain = new DoctorFamousConsultTimesRemain();
                    }else{
                    } else {
                        continue;
                    }
                    timesRemain.setDoctor(doc.getCode());

+ 310 - 68
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -9,11 +9,13 @@ import com.yihu.wlyy.entity.wechat.WechatTemplate;
import com.yihu.wlyy.entity.wechat.WechatTemplateData;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.doctor.survey.ManagerQuestionnaireController;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
@ -81,9 +83,12 @@ public class ManagerQuestionnaireService extends BaseService {
    private SurveyDimensionDetailDao surveyDimensionDetailDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PatientDao patientDao;
    public String createSurvey(String doctor, String accessToken, JSONObject jsonStr) throws Exception {
    public String createSurvey(String doctor, JSONObject jsonStr, String accessToken) throws Exception {
        System.out.println("=============>" + jsonStr);
//        问卷信息
        String surveyCode = getCode();
        String surveyName = jsonStr.getString("surveyName");
@ -105,13 +110,12 @@ public class ManagerQuestionnaireService extends BaseService {
        JSONArray disease = surveyTarget.getJSONArray("disease");
        JSONArray service = surveyTarget.getJSONArray("service");
        JSONArray healthCondition = surveyTarget.getJSONArray("healthCondition");
        String str = "SELECT DISTINCT t.patient AS patient,p.name,p.openid " +
                " FROM `wlyy_sign_patient_label_info` t,wlyy_patient p " +
                " WHERE t.`patient` =  p.`code` " +
                " AND p.`openid` IS NOT NULL  AND p.`openid`!=''  ";
        /*String str = "SELECT DISTINCT t.patient  " +
                "FROM `wlyy_sign_patient_label_info` t,wlyy_patient p,`wlyy_sign_family` f  " +
                "WHERE t.`patient` =  p.`code`  AND f.`patient`=t.`patient` AND f.`status` IN (1,2,3) AND p.`openid` IS NOT NULL AND p.`openid`!='' ";*/
        //      保存到维度详情表(不限不保存)  维度表(1性别 2疾病类型 3服务类型 4健康状况)
        if (sex != 0) {
            str += "AND(p.sex=" + sex + ")";
//            str += "AND(p.sex=" + sex + ")";
            String dimensionCode = surveyDimensionDao.findByName("性别");
            String dimensionDetailCode = getCode();
            SurveyDimensionDetail surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, sex == 1 ? "男" : "女", sex, "性别", 1, surveyCode);
@ -120,14 +124,14 @@ public class ManagerQuestionnaireService extends BaseService {
            SurveyFilter surveyFilter = new SurveyFilter(getCode(), surveyCode, dimensionDetailCode);
            surveyFilterDao.save(surveyFilter);
        }
        String ser = "";
        String servi = "";
//        String ser = "";
//        String servi = "";
        for (Object serv : service) {
            if ("0".equals(serv.toString())) {
                ser += ",";
//                ser += ",";
                break;
            } else {
                ser += serv.toString() + ",";
//                ser += serv.toString() + ",";
                //                ===================================
                String dimensionCode = surveyDimensionDao.findByName("服务类型");
                String dimensionDetailCode = getCode();
@ -151,18 +155,18 @@ public class ManagerQuestionnaireService extends BaseService {
                surveyFilterDao.save(surveyFilter);
            }
        }
        ser = ser.substring(0, ser.length() - 1);
        /*ser = ser.substring(0, ser.length() - 1);
        if (ser.length() != 0) {
            servi = "(t.`label_type`=1 AND t.`label`IN(" + ser + "))";
        }
        String heal = "";
        String healt = "";
        }*/
//        String heal = "";
//        String healt = "";
        for (Object health : healthCondition) {
            if ("0".equals(health.toString())) {
                heal += ",";
//                heal += ",";
                break;
            } else {
                heal += health.toString() + ",";
//                heal += health.toString() + ",";
                String dimensionCode = surveyDimensionDao.findByName("健康状况");
                String dimensionDetailCode = getCode();
                String surveyFilterCode = getCode();
@ -189,18 +193,18 @@ public class ManagerQuestionnaireService extends BaseService {
            }
        }
        heal = heal.substring(0, heal.length() - 1);
       /* heal = heal.substring(0, heal.length() - 1);
        if (heal.length() != 0) {
            healt = "(t.`label_type`=2 AND t.`label`IN(" + heal + "))";
        }
        String dise = "";
        String diseas = "";
        }*/
//        String dise = "";
//        String diseas = "";
        for (Object disea : disease) {
            if ("0".equals(disea.toString())) {
                dise += ",";
//                dise += ",";
                break;
            } else {
                dise += disea.toString() + ",";
//                dise += disea.toString() + ",";
//                ================================================================
                String dimensionCode = surveyDimensionDao.findByName("疾病类型");
                String dimensionDetailCode = getCode();
@ -220,7 +224,7 @@ public class ManagerQuestionnaireService extends BaseService {
                surveyFilterDao.save(surveyFilter);
            }
        }
        dise = dise.substring(0, dise.length() - 1);
        /*dise = dise.substring(0, dise.length() - 1);
        if (dise.length() != 0) {
            diseas = "(t.`label_type`=3 AND t.`label`IN(" + dise + "))";
        }
@ -238,30 +242,55 @@ public class ManagerQuestionnaireService extends BaseService {
            str += " AND " + healt;
        } else if (servi.length() == 0 & healt.length() == 0 & diseas.length() != 0) {
            str += " AND " + diseas;
        }
        }*/
       /* System.out.println("*****************str***********************" + str);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        sdf.format(new Date());
        String jsonData = "{\"remark\":\"我们将按调查最终结果,优化健康服务。\",\"keyword1\":\"调查问卷\"}";
        JSONObject json = new JSONObject(jsonData);
        List<Map<String, Object>> patients = jdbcTemplate.queryForList(str);
        int amount = patients.size();
        for (Map<String, Object> patient : patients) {
            String code = patient.get("patient").toString();
        json.put("survey_id", surveyCode);*/
//        List<Map<String, Object>> patients = jdbcTemplate.queryForList(str);
//        Map<String, Object> map = jdbcTemplate.queryForMap(str);
//        List<String> codes = jdbcTemplate.queryForList(str, String.class);
        List<String> codes = getCount(surveyTarget.toString());
        int amount = codes.size();
        for (String code : codes) {
//            String code = patient.get("patient").toString();
            SurveyUser user = new SurveyUser(surveyCode, code, 0, 1, new Date(), new Date());
            surveyUserDao.save(user);
//            发送居民模板 send=1发送
            if ("1".equals(send)) {
           /* if ("1".equals(send)) {
                String name = patient.get("name").toString();
                String openId = patient.get("openid").toString();
//                String openId = "orrOgwATDaljVunlAq_Tdx3imhYg";
//            String openId = "o7NFZw1QM4YR1O19mLjwfX1Hh11A";
                json.put("keyword2", sdf.format(new Date()));
                json.put("toUser", code);
                json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
                System.out.println("*************************" + json + "******************");
                System.out.println("********name*********************" + name + "openId" + openId);
                PushMsgTask.getInstance().sendWeixinMessage(accessToken, 11, openId, name, json);
            }
            }*/
        }
        //            发送居民模板 send=1发送
//        ====================================================
        if ("1".equals(send)) {
            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);
            });
        }
//       =====================================================
//     获取标签数组
        JSONArray lables = jsonStr.getJSONArray("label");
//        标签保存到wlyy_survey_label_info
@ -285,6 +314,12 @@ public class ManagerQuestionnaireService extends BaseService {
            int isRequired = Integer.parseInt(tempQestion.get("isRequired").toString());
            int sort = Integer.parseInt(tempQestion.get("sort").toString());
            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) {
                case 0:
//                    单选
@ -297,12 +332,15 @@ public class ManagerQuestionnaireService extends BaseService {
                    surveyQuestionnaire.setIsRequired(isRequired);
                    surveyQuestionnaire.setDel(del);
                    surveyQuestionnaire.setSort(sort);
                    surveyQuestionnaire.setCreateTime(new Date());
                    surveyQuestionnaire.setUpdateTime(new Date());
                    //                   单选没有最大最小选项数及题目逻辑跳转
                    surveyQuestionnaire.setMinNum(null);
                    surveyQuestionnaire.setMaxNum(null);
                    surveyQuestionnaire.setQuestionCodeNext(null);
                    surveyQuestionnaire.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaireDao.save(surveyQuestionnaire);
                    System.out.println("=====================================");
                    //                        =======================选项保存=========================
                    //                选择题
                    JSONArray options = new JSONArray(tempQestion.get("options").toString());
@ -316,11 +354,14 @@ public class ManagerQuestionnaireService extends BaseService {
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        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.setQuestionnaireCode(questionnaireCode);
                        surveyQuestionnaireOptions.setContent(optionComment);
@ -328,8 +369,7 @@ public class ManagerQuestionnaireService extends BaseService {
                        surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                        surveyQuestionnaireOptions.setIsRequired(required);
                        surveyQuestionnaireOptions.setSort(optionSort);
                        surveyQuestionnaireOptions.setDel(optionDel);
                        surveyQuestionnaireOptions.setDel(optionDel);*/
                        surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                        //                单选题保存到统计表
@ -361,8 +401,10 @@ public class ManagerQuestionnaireService extends BaseService {
                    surveyQuestionnaire1.setMinNum(minOptions);
                    surveyQuestionnaire1.setMaxNum(maxOptions);
                    surveyQuestionnaire1.setSort(sort);
                    surveyQuestionnaire1.setQuestionCodeNext(null);
                    surveyQuestionnaire1.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaire1.setDel(del);
                    surveyQuestionnaire1.setCreateTime(new Date());
                    surveyQuestionnaire1.setUpdateTime(new Date());
                    surveyQuestionnaireDao.save(surveyQuestionnaire1);
@ -379,7 +421,8 @@ public class ManagerQuestionnaireService extends BaseService {
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
                            optionNextQuestion = tempOption.get("nextQuestion").toString();
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                            optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
                        }
//                        自主创建,插入表
@ -407,10 +450,12 @@ public class ManagerQuestionnaireService extends BaseService {
                    break;
                case 2:
//            问答特有属性
                    String nextQuestion = null;
                    if (tempQestion.has("nextQuestion")) {
                    /*String nextQuestion = null;
                    if (StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
                        nextQuestion = tempQestion.get("nextQuestion").toString();
                    }
                    }else {
                        nextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode,tempQestion.get("nextQuestion"));
                    }*/
                    SurveyQuestionnaire surveyQuestionnaire2 = new SurveyQuestionnaire();
                    surveyQuestionnaire2.setCode(questionnaireCode);
                    surveyQuestionnaire2.setTitle(title);
@ -422,8 +467,10 @@ public class ManagerQuestionnaireService extends BaseService {
                    surveyQuestionnaire2.setMinNum(null);
                    surveyQuestionnaire2.setMaxNum(null);
                    surveyQuestionnaire2.setSort(sort);
                    surveyQuestionnaire2.setQuestionCodeNext(nextQuestion);
                    surveyQuestionnaire2.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaire2.setDel(del);
                    surveyQuestionnaire2.setUpdateTime(new Date());
                    surveyQuestionnaire2.setCreateTime(new Date());
                    surveyQuestionnaireDao.save(surveyQuestionnaire2);
@ -445,6 +492,8 @@ public class ManagerQuestionnaireService extends BaseService {
        survey.setTemplateCode(templateCode);
        survey.setStatus(status);
        survey.setAmount(amount);
        survey.setCreateTime(new Date());
        survey.setUpdateTime(new Date());
        surveyDao.save(survey);
        return surveyCode;
    }
@ -603,6 +652,14 @@ public class ManagerQuestionnaireService extends BaseService {
            int isRequired = questionnair.getIsRequired();
            int sort = questionnair.getSort();
            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) {
                String comment = questionnair.getQuestionComment();
                question.put("comment", comment);
@ -610,7 +667,7 @@ public class ManagerQuestionnaireService extends BaseService {
            if (questionnair.getQuestionCodeNext() != null) {
                String next = questionnair.getQuestionCodeNext();
                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);
@ -625,7 +682,11 @@ public class ManagerQuestionnaireService extends BaseService {
                if (option.getQuestionCodeNext() != null) {
                    String next = option.getQuestionCodeNext();
                    SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                    opt.put("nextQuestion", sq.getSort());
                    System.out.println("=============qstcode============== " + qstcode);
                    System.out.println("=============optCode============== " + option.getCode());
                    System.out.println("=============sq============== " + sq);
                    System.out.println("=============next============== " + next);
                    opt.put("nextQuestion", sq == null ? 0 : sq.getSort());
                }
                opt.put("content", conetent);
                opt.put("sort", st);
@ -679,11 +740,21 @@ public class ManagerQuestionnaireService extends BaseService {
            String qstcode = question.getCode();
            String title = question.getTitle();
            int type = question.getQuestionType();
            int amount = 0;
//            有效答了该题的人数
            /*int amount = 0;
            int[] sum = surveyStatisticsDao.findByIdAndQstId(id, qstcode);
            for (int count : sum) {
                amount += count;
            }*/
            int amount = 0;
            if (type == 2) {
//          问卷答案表有效(去重)答题人数
                amount = surveyAnswersDao.countByRelationCode(id, qstcode);
            } else {
//          问卷选项答案表有效(去重)答题人数
                amount = surveyOptionAnswersDao.countByRelationCode(id, qstcode);
            }
            qst.put("amount", amount);
            qst.put("qstcode", qstcode);
            qst.put("title", title);
@ -817,7 +888,6 @@ public class ManagerQuestionnaireService extends BaseService {
                String comment = question.getQuestionComment();
                map.put("comment", comment);
            }
            int isRequired = question.getIsRequired();
            int questionType = question.getQuestionType();
            if (questionType != 2) {
@ -837,7 +907,6 @@ public class ManagerQuestionnaireService extends BaseService {
            }
            map.put("code", code);
            map.put("title", qstTitle);
            map.put("isRequired", isRequired);
            map.put("questionType", questionType);
            list.add(map);
@ -857,7 +926,7 @@ public class ManagerQuestionnaireService extends BaseService {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (labels.size() == 0) {
//            模板标题
            String cql = "select  distinct t.* from wlyy_survey_templates t where t.title like '%" + name + "%'";
            String cql = "select  distinct t.* from wlyy_survey_templates t where t.del = 1 and t.title like '%" + name + "%' ";
            List<Map<String, Object>> surveyTemp = jdbcTemplate.queryForList(cql);
            for (Map<String, Object> temp : surveyTemp) {
                String create = temp.get("create_time").toString();
@ -962,6 +1031,7 @@ public class ManagerQuestionnaireService extends BaseService {
                    " FROM wlyy_survey_templates t,wlyy_survey_label_info s  " +
                    " WHERE t.code = s.relation_code  " +
                    " AND s.use_type= 0 " +
                    " AND t.del = 1 " +
                    " AND s.label IN (" + labels +
                    ")  " +
                    " ORDER by t.create_time DESC " +
@ -996,7 +1066,7 @@ public class ManagerQuestionnaireService extends BaseService {
                    }
                }
                map.put("title", title);
                map.put("templateID", code);
                map.put("templateId", code);
                map.put("comment", comment);
                map.put("label", tags);
                list.add(map);
@ -1071,6 +1141,7 @@ public class ManagerQuestionnaireService extends BaseService {
            int sort = questionnair.getSort();
            String comment = questionnair.getQuestionComment();
            int type = questionnair.getQuestionType();
            List<SurveyTemplateOptions> options = surveyTemplateOptionsDao.findById(qstcode, id);
            List optList = new ArrayList();
            for (SurveyTemplateOptions option : options) {
@ -1078,14 +1149,17 @@ public class ManagerQuestionnaireService extends BaseService {
                String conetent = option.getContent();
                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.getSort());
//                    跳题结束怎么办?
                    opt.put("nextQuestion", tempQst == null ? 0 : tempQst.getSort());
                }
                opt.put("isRequired", required);
                opt.put("content", conetent);
                opt.put("sort", optsort);
                opt.put("haveComment", haveComment);
                optList.add(opt);
            }
@ -1096,11 +1170,15 @@ public class ManagerQuestionnaireService extends BaseService {
            question.put("type", type);
            question.put("options", optList);
            question.put("sort", sort);
            question.put("maxNum", questionnair.getMaxNum());
            question.put("minNum", questionnair.getMinNum());
            if (!StringUtils.isEmpty(questionnair.getQuestionCodeNext())) {
                String next = questionnair.getQuestionCodeNext();
                SurveyTemplateQuestions tempQst = surveyTemplateQuestionsDao.findById(id, next);
//                question.put("nextQuestion", tempQst.getSort());
                question.put("nextQuestion", tempQst == null ? 0 : tempQst.getSort());
            }
            questions.add(question);
        }
@ -1111,10 +1189,11 @@ public class ManagerQuestionnaireService extends BaseService {
        jsonObject.put("comment", tempComment);
        jsonObject.put("label", labels);
        jsonObject.put("questions", questions);
        System.out.println("==========jsonObject============" + jsonObject);
        return jsonObject;
    }
    public void savaSurveyAsTemplate(String code) throws Exception {
    public int savaSurveyAsTemplate(String code, String modifyTitle) throws Exception {
        Survey survey = surveyDao.findById(code);
        String tempCode = getCode();
        String title = survey.getTitle();
@ -1122,6 +1201,22 @@ public class ManagerQuestionnaireService extends BaseService {
        String creater = survey.getCreater();
        Date createTime = survey.getCreateTime();
        Date updateTime = survey.getUpdateTime();
        //        查询问卷标题重复情况
        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);
//        保存模板信息
        surveyTemplatesDao.save(surveyTemplates);
@ -1145,14 +1240,14 @@ public class ManagerQuestionnaireService extends BaseService {
            Integer sort = question.getSort();
            Integer de = question.getDel();
            String next = question.getQuestionCodeNext();
            SurveyTemplateQuestions surveyTemplateQuestions = new SurveyTemplateQuestions(qstCode, qstTitle, qstComment, qstType, tempCode, isRequired, minNum, maxNum, sort, next, de, createTiem, updateTiem);
            SurveyTemplateQuestions surveyTemplateQuestions = new SurveyTemplateQuestions(qstCode, qstTitle, qstComment, qstType, tempCode, isRequired, minNum, maxNum, sort, next, null, de, createTiem, updateTiem);
            //            保存问题到模板问题表
            surveyTemplateQuestionsDao.save(surveyTemplateQuestions);
            if (qstType != 2) {
                List<SurveyQuestionnaireOptions> surveyQuestionnaireOptions = surveyQuestionnaireOptionsDao.findByIdAndQstCode(code, question.getCode());
                for (SurveyQuestionnaireOptions option : surveyQuestionnaireOptions) {
                    SurveyTemplateOptions surveyTemplateOptions = new SurveyTemplateOptions(getCode(), option.getHaveComment(), qstCode, question.getTitle(),
                            tempCode, question.getQuestionCodeNext(), question.getIsRequired(), question.getSort(), option.getDel());
                    SurveyTemplateOptions surveyTemplateOptions = new SurveyTemplateOptions(getCode(), option.getHaveComment(), qstCode, option.getContent(),
                            tempCode, option.getQuestionCodeNext(), null, option.getIsRequired(), option.getSort(), option.getDel());
                    //         保存到模板选项表   survey_template_options
                    surveyTemplateOptionsDao.save(surveyTemplateOptions);
                }
@ -1161,6 +1256,71 @@ public class ManagerQuestionnaireService extends BaseService {
        }
        return 0;
    }
    public int modifyTemplate(String code, String templateCode, String modifyTitle) throws Exception {
        Survey survey = surveyDao.findById(code);
        String title = survey.getTitle();
        String templateComment = survey.getSurveyComment();
//        查询问卷标题重复情况
        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);
//        更改模板信息
//        surveyTemplatesDao.save(surveyTemplates);
        surveyTemplatesDao.modifyTemplate(templateCode, title, templateComment);
        List<SurveyLabelInfo> surveyLabelInfos = surveyLabelInfoDao.findByCode(code);
        for (SurveyLabelInfo surveyLabelInfo : surveyLabelInfos) {
//        更改模板标签信息
//            SurveyLabelInfo surveyLabelInfo1 = new SurveyLabelInfo(getCode(), templateCode, 0, surveyLabelInfo.getLabel());
//            surveyLabelInfoDao.save(surveyLabelInfo1);
            surveyLabelInfoDao.modifyLabel(templateCode, surveyLabelInfo.getLabel());
        }
        List<SurveyQuestionnaire> surveyQuestionnaires = surveyQuestionnaireDao.findById(survey.getCode());
        for (SurveyQuestionnaire question : surveyQuestionnaires) {
            String qstCode = getCode();
            String qstTitle = question.getTitle();
            String qstComment = question.getQuestionComment();
            Integer qstType = question.getQuestionType();
            Integer isRequired = question.getIsRequired();
            Integer minNum = question.getMinNum();
            Integer maxNum = question.getMaxNum();
//            Date createTiem = question.getCreateTime();
//            Date updateTiem = question.getUpdateTime();
            Integer sort = question.getSort();
//            Integer de = question.getDel();
            String next = question.getQuestionCodeNext();
//            SurveyTemplateQuestions surveyTemplateQuestions = new SurveyTemplateQuestions(qstCode, qstTitle, qstComment, qstType, templateCode, isRequired, minNum, maxNum, sort, next, null, de, createTiem, updateTiem);
            //            更改问题到模板问题表
//            surveyTemplateQuestionsDao.save(surveyTemplateQuestions);
            surveyTemplateQuestionsDao.modifyQuestion(templateCode, qstCode, qstTitle, qstComment, qstType, isRequired, minNum, maxNum, sort, next);
            if (qstType != 2) {
                List<SurveyQuestionnaireOptions> surveyQuestionnaireOptions = surveyQuestionnaireOptionsDao.findByIdAndQstCode(code, question.getCode());
                for (SurveyQuestionnaireOptions option : surveyQuestionnaireOptions) {
                    SurveyTemplateOptions surveyTemplateOptions = new SurveyTemplateOptions(getCode(), option.getHaveComment(), qstCode, option.getContent(),
                            templateCode, option.getQuestionCodeNext(), null, option.getIsRequired(), option.getSort(), option.getDel());
                    //         更改到模板选项表   survey_template_options
//                    surveyTemplateOptionsDao.save(surveyTemplateOptions);
                    surveyTemplateOptionsDao.modifyOption(templateCode, qstCode, option.getCode(),
                            option.getHaveComment(), option.getContent(), option.getQuestionCodeNext(), option.getIsRequired(), option.getSort());
                }
            }
        }
        return 0;
    }
    public Map getFilter() {
@ -1206,16 +1366,95 @@ public class ManagerQuestionnaireService extends BaseService {
    }
    public int getAmount(String json) {
        return getCount(json).size();
    }
    public List<String> getCount(String json) {
//        1.服务 2.健康 3疾病
        JSONObject jsonObject = new JSONObject(json);
        String str = "SELECT COUNT(DISTINCT t.patient) AS amount" +
                " FROM `wlyy_sign_patient_label_info` t,wlyy_patient p " +
                " WHERE t.`patient` =  p.`code` " +
                " AND p.`openid` IS NOT NULL ";
        String sex = jsonObject.get("sex").toString();
        String str = "SELECT s.patient  FROM ( " +
                "SELECT t.patient,GROUP_CONCAT(t.label_name) label_name FROM wlyy_sign_patient_label_info t  " +
                "WHERE t.patient IN (SELECT a.patient FROM wlyy_sign_family a WHERE a.status IN(1,2,3)) AND t.patient IN (SELECT b.`code` FROM wlyy_patient b WHERE b.`openid` IS NOT NULL AND b.`openid`!='' ";
        if (!"0".equals(sex)) {
            str += "AND(p.sex=" + sex + ")";
            str += " AND b.sex= " + sex + " ) GROUP BY t.patient ) s WHERE 1=1 ";
        } else {
            str += " ) GROUP BY t.patient ) s WHERE 1=1 ";
        }
        JSONArray service = jsonObject.getJSONArray("service");
        String ser = "";
        service:
        for (Object serv : service) {
            String type = serv.toString();
            switch (type) {
//                AND (s.label_name LIKE '%普通人群%'OR s.label_name LIKE '%慢病人群%'OR s.label_name LIKE '%65岁以上人群%')
                case "0":
                    break service;
                case "1":
                    ser += " s.label_name LIKE '%普通人群%' ";
                    break;
                case "2":
                    ser += " s.label_name LIKE '%慢病人群%' ";
                    break;
                case "3":
                    ser += " s.label_name LIKE '%65岁以上人群%' ";
                    break;
            }
            ser += " OR ";
        }
        if (!StringUtils.isEmpty(ser)) {
            str += " AND ( " + ser.substring(0, ser.lastIndexOf("OR")) + " ) ";
        }
        JSONArray healthCondition = jsonObject.getJSONArray("healthCondition");
        String heal = "";
        health:
        for (Object health : healthCondition) {
            String type = health.toString();
            switch (type) {
//                AND (s.label_name LIKE '%普通人群%'OR s.label_name LIKE '%慢病人群%'OR s.label_name LIKE '%65岁以上人群%')
                case "0":
                    break health;
                case "1":
                    heal += " s.label_name LIKE '%健康人群%' ";
                    break;
                case "2":
                    heal += " s.label_name LIKE '%患病人群%' ";
                    break;
                case "3":
                    heal += " s.label_name LIKE '%高危人群%' ";
                    break;
                case "4":
                    heal += " s.label_name LIKE '%恢复期人群%' ";
                    break;
            }
            heal += " OR ";
        }
        if (!StringUtils.isEmpty(heal)) {
            str += " AND ( " + heal.substring(0, heal.lastIndexOf("OR")) + " ) ";
        }
        JSONArray disease = jsonObject.getJSONArray("disease");
        String dis = "";
        disea:
        for (Object disea : disease) {
            String type = disea.toString();
            switch (type) {
//                AND (s.label_name LIKE '%普通人群%'OR s.label_name LIKE '%慢病人群%'OR s.label_name LIKE '%65岁以上人群%')
                case "0":
                    break disea;
                case "1":
                    dis += " s.label_name LIKE '%高血压%' ";
                    break;
                case "2":
                    dis += " s.label_name LIKE '%糖尿病%' ";
                    break;
            }
            dis += " OR ";
        }
        if (!StringUtils.isEmpty(dis)) {
            str += " AND ( " + dis.substring(0, dis.lastIndexOf("OR")) + " ) ";
        }
      /*  if (Integer.parseInt(sex) != 0) {
            str += "and t.sex = " + sex;
        }
        JSONArray service = jsonObject.getJSONArray("service");
        String ser = "";
@ -1276,10 +1515,13 @@ public class ManagerQuestionnaireService extends BaseService {
            str += "AND " + healt;
        } else if (servi.length() == 0 & healt.length() == 0 & diseas.length() != 0) {
            str += "AND " + diseas;
        }
        Map<String, Object> patients = jdbcTemplate.queryForMap(str);
        int amount = Integer.parseInt(patients.get("amount").toString());
        return amount;
        }*/
//        Map<String, Object> patients = jdbcTemplate.queryForMap(str);
        System.out.println("=====query sql =======>>>>" + str);
        List<String> patients = jdbcTemplate.queryForList(str, String.class);
        return patients;
    }
}

+ 91 - 77
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/PatientQuestionnaireService.java

@ -47,28 +47,6 @@ public class PatientQuestionnaireService extends BaseService {
        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 sort 当前问题的sort(初始为1)
@ -78,55 +56,101 @@ public class PatientQuestionnaireService extends BaseService {
        SurveyQuestionnaire question = null;
        //      该套问卷总题目数
        int total = surveyQuestionnaireDao.findTotalById(id);
        question = surveyQuestionnaireDao.findTotalByIdAndSort(id, sort);
        int sorts = question.getSort();
        String qstCode = question.getCode();
        String qstTitle = question.getTitle();
        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())) {
            jsonObject.put("comment", question.getQuestionComment());
        }
        int type = question.getQuestionType();
//        int sorts = question.getSort();
        switch (type) {
            case 0:
                List<SurveyQuestionnaireOptions> options = surveyQuestionnaireOptionsDao.findByIdAndQstCode(id, qstCode);
                List list = new ArrayList();
                for (SurveyQuestionnaireOptions option : options) {
                    String content = option.getContent();
//                        可构造集合,返回选项特定值
                    Map<String, Object> map = new HashMap<>();
                    String content = option.getContent();
                    int optSort = option.getSort();
                    int required = option.getIsRequired();
                    String surCod = option.getSurveyCode();
                    int del = option.getDel();
                    int havaComment = option.getHaveComment();
                    String code = option.getCode();
                    String questionCode = option.getQuestionnaireCode();
                    long optid = option.getId();
                    map.put("content", content);
                    map.put("isRequired", required);
                    map.put("code", code);
                    map.put("del", del);
                    map.put("sort", optSort);
                    map.put("surveyCode", surCod);
                    map.put("havaComment", havaComment);
                    map.put("questionnaireCode", questionCode);
                    map.put("id", optid);
                    if (option.getQuestionCodeNext() != null) {
                        String next = option.getQuestionCodeNext();
                        SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                        jsonObject.put("questionCodeNext", sq.getSort());
                        map.put("nextQuestion", sq == null ? 0 : sq.getSort());
                    }
                    list.add(map);
                }
                jsonObject.put("options", options);
                jsonObject.put("options", list);
                break;
            case 1:
                List<SurveyQuestionnaireOptions> optionss = surveyQuestionnaireOptionsDao.findByIdAndQstCode(id, qstCode);
                List lis = new ArrayList();
                for (SurveyQuestionnaireOptions option : optionss) {
//                        可构造集合,返回选项特定值
                    Map<String, Object> map = new HashMap<>();
                    String content = option.getContent();
                    int optSort = option.getSort();
                    int required = option.getIsRequired();
                    String surCod = option.getSurveyCode();
                    int del = option.getDel();
                    int havaComment = option.getHaveComment();
                    String code = option.getCode();
                    String questionCode = option.getQuestionnaireCode();
                    long optid = option.getId();
                    map.put("content", content);
                    map.put("isRequired", required);
                    map.put("code", code);
                    map.put("del", del);
                    map.put("sort", optSort);
                    map.put("surveyCode", surCod);
                    map.put("havaComment", havaComment);
                    map.put("questionnaireCode", questionCode);
                    map.put("id", optid);
                    if (option.getQuestionCodeNext() != null) {
                        String next = option.getQuestionCodeNext();
                        SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                        jsonObject.put("questionCodeNext", sq.getSort());
                        map.put("nextQuestion", sq == null ? 0 : sq.getSort());
                    }
                    lis.add(map);
                }
                jsonObject.put("options", lis);
                Integer maxNum = question.getMaxNum();
                Integer minNum = question.getMinNum();
                jsonObject.put("maxNum", maxNum);
                jsonObject.put("minNum", minNum);
                jsonObject.put("options", optionss);
//                jsonObject.put("options", optionss);
                break;
            case 2:
           /* case 2:
                if (question.getQuestionCodeNext() != null) {
                    String next = question.getQuestionCodeNext();
                    SurveyQuestionnaire sq = surveyQuestionnaireDao.findByIdAndQstId(id, next);
                    jsonObject.put("questionCodeNext", sq.getSort());
                    jsonObject.put("nextQuestion", sq.getSort());
                }
                break;
                break;*/
        }
        jsonObject.put("qstCode", qstCode);
        jsonObject.put("qstTitle", qstTitle);
@ -203,6 +227,7 @@ public class PatientQuestionnaireService extends BaseService {
//    ======================================================================================
    public void saveAnswer(String patient, JSONObject jsonData) throws Exception {
        System.out.println("********jsonData********* " + jsonData);
        //解析json保存各种答案
        String surveyCode = jsonData.get("surveyCode").toString();
        Date createTime = new Date();
@ -215,56 +240,45 @@ public class PatientQuestionnaireService extends BaseService {
            String qstCode = question.get("qstCode").toString();
            int qstsort = Integer.parseInt(question.get("sort").toString());
            int type = Integer.parseInt(question.get("type").toString());
            String content = null;
            if (question.has("content")) {
                content = question.get("content").toString();
            }
            if (question.has("options")) {
            if (type != 2) {
                if (question.has("options")) {
//               获取每道题的所有选项
                JSONArray options = question.getJSONArray("options");
                for (int j = 0; j < options.length(); j++) {
                    JSONObject option = new JSONObject(options.get(j).toString());
                    String code = getCode();
                    String optionCode = option.get("optionCode").toString();
                    int optsort = Integer.parseInt(option.get("sort").toString());
                    String comment = null;
                    int haveComment = 0;
                    if (option.has("comment")) {
                        comment = option.get("comment").toString();
                        haveComment = 1;
                    }
                    JSONArray options = question.getJSONArray("options");
                    for (int j = 0; j < options.length(); j++) {
                        JSONObject option = new JSONObject(options.get(j).toString());
                        String code = getCode();
                        String optionCode = option.get("optionCode").toString();
                        int optsort = Integer.parseInt(option.get("sort").toString());
                        String comment = null;
                        int haveComment = 0;
                        if (option.has("comment")) {
                            comment = option.get("comment").toString();
                            haveComment = 1;
                        }
//                 保存到选择题答案表
                    SurveyOptionAnswers optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
                    surveyOptionAnswersDao.save(optionAnswer);
/*//                选择题修改统计表数量
                    String statisticsCode = getCode();
                    String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode,qstCode).getTitle();
                    String optcontent = surveyQuestionnaireOptionsDao.findByRelationCode(surveyCode,qstCode,optionCode).getContent();
                    int amount =0;
                    ++amount;
                    SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, qstCode, questionTitle, optionCode, amount, optcontent, haveComment, type, qstsort, optsort);
                    surveyStatisticsDao.save(statistics);*/
                    surveyStatisticsDao.modifyAmount(surveyCode, qstCode, optionCode);
                        SurveyOptionAnswers optionAnswer = new SurveyOptionAnswers(code, patient, surveyCode, qstCode, optionCode, comment, type, createTime);
                        surveyOptionAnswersDao.save(optionAnswer);
//                选择题修改统计表数量
                        surveyStatisticsDao.modifyAmount(surveyCode, qstCode, optionCode);
                    }
                }
            } else {
//               保存到问答题答案表
                String code = getCode();
                SurveyAnswers surveyAnswer = new SurveyAnswers(code, surveyCode, patient, qstCode, content, createTime);
                surveyAnswersDao.save(surveyAnswer);
                String content = question.get("content").toString();
                if (!StringUtils.isEmpty(content)) {
//                    保存到问答题答案表
                    String code = getCode();
                    SurveyAnswers surveyAnswer = new SurveyAnswers(code, surveyCode, patient, qstCode, content, createTime);
                    surveyAnswersDao.save(surveyAnswer);
//                问答题保存到统计表(只负责更改数量不负责创建)
                /*String statisticsCode = getCode();
                String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode,qstCode).getTitle();
                int amount = 0;
                ++amount;
                SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, qstCode, questionTitle, null, amount, null, null, type, qstsort, null);
                surveyStatisticsDao.save(statistics);*/
                surveyStatisticsDao.modifyAmount(surveyCode, qstCode);
                    surveyStatisticsDao.modifyAmount(surveyCode, qstCode);
                }
            }
        }
//        更改调查对象表答题状态为已答
        surveyUserDao.modifyStatus(surveyCode,patient);
        surveyUserDao.modifyStatus(surveyCode, patient);
    }
}

+ 7 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -190,7 +190,7 @@ public class PushMsgTask {
     * @return
     */
//    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 {
            if (StringUtils.isEmpty(openid)) {
                logger.error("send wechat message failed:openid is empty");
@ -200,13 +200,13 @@ public class PushMsgTask {
                String token_url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + access_token;
                String params = typeMsg(type, openid, name, json);
                if (params == "") {
                    logger.error("参数错误!");
                    logger.error("参数错误!error");
                    return false;
                }
                String result = HttpUtil.sendPost(token_url, params);
                JSONObject jsonResult = new JSONObject(result);
                if (Integer.parseInt(jsonResult.get("errcode").toString()) == 0) {
                    logger.info("微信信息推送成功!");
                    logger.info("微信信息推送成功!success");
                    return true;
                } else {
                    logger.error("错误编码:" + jsonResult.get("errcode").toString() + "  错误提示:" + jsonResult.get("errmsg").toString());
@ -335,7 +335,7 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("date"));
                m.put("keyword4", keyword4);
            } else if (type == 6) {
                temp.setUrl(url + "wdyy/html/detail-appointment.html?openid=" + openid+ "&orgCode=" + json.get("orgCode")  + "&id=" + json.getString("id") + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                temp.setUrl(url + "wdyy/html/detail-appointment.html?openid=" + openid + "&orgCode=" + json.get("orgCode") + "&id=" + json.getString("id") + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                temp_id = SystemConf.getInstance().getSystemProperties().getProperty("template_appoint_success");
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -438,12 +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 + "&survey_id=" + json.getString("survey_id")+"&toUser=" + json.getString("toUser") + "&toName=" + name );
                temp.setUrl(url + "survey/html/survey_info.html?openid=" + openid + "&state=" + openid + "&survey_id=" + json.getString("survey_id") + "&toUser=" + json.getString("toUser") + "&toName=" + name);
//                temp.setTemplate_id("fgYiMntj1amEkE8_GLUPmAIyssUAroJrNSHqvydt-PQ");
                temp.setTemplate_id(SystemConf.getInstance().getSystemProperties()
                        .getProperty("template_doctor_survey"));
                System.out.println("templateID=====>"+SystemConf.getInstance().getSystemProperties()
                        .getProperty("template_doctor_survey"));
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
@ -453,13 +452,12 @@ public class PushMsgTask {
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
                System.out.println("type=====>openId " + openid);
                logger.info("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();

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

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.doctor.scheduling;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.web.BaseController;
@ -27,6 +28,8 @@ public class DoctorWorkTimeController extends BaseController {
    private DoctorInfoService doctorInfoService;
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    @Autowired
    private DoctorDao doctorDao;
    /**
     * 查询医生工作时间设置

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

@ -47,8 +47,6 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    private PatientDao patientDao;
    @Autowired
    private SurveyUserDao surveyUserDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    /**
     * 获取问卷列表
@ -207,7 +205,7 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
//            获取医生信息(仅限市级管理员)
            String doctor = getUID();
            String accessToken = getAccessToken();
            String surveyCode = managerQuestionnaireService.createSurvey(doctor, accessToken, jsonStr);
            String surveyCode = managerQuestionnaireService.createSurvey(doctor, jsonStr, accessToken);
            return write(200, "创建成功!", "surveyCode", surveyCode);
        } catch (Exception e) {
            e.printStackTrace();
@ -375,6 +373,7 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    /**
     * 新建问卷保存为模板
     * 引用模板新建问卷保存变更到模板
     *
     * @param code
     * @return
@ -384,10 +383,27 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    @ResponseBody
    public String savaSurveyAsTemplate(
            @ApiParam(value = "新建问卷编码")
            @RequestParam String code) {
            @RequestParam String code,
            @ApiParam(value = "旧模板编码")
            @RequestParam(required = false) String templateCode,
            @ApiParam(value = "修改后的标题")
            @RequestParam(required = false) String title) {
        try {
            managerQuestionnaireService.savaSurveyAsTemplate(code);
            return write(200, "保存成功!");
            int num = 0;
            if (StringUtils.isEmpty(templateCode)) {
                num = managerQuestionnaireService.savaSurveyAsTemplate(code, title);
            } else {
                num = managerQuestionnaireService.modifyTemplate(code, templateCode, title);
            }
            if (num == 0) {
                return write(200, "保存成功!");
            } else {
                Map map = new HashMap();
//              标题重复码
                map.put("errorCode", "001");
                map.put("number", num);
                return write(-1, "标题重复!", "data", map);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
@ -407,8 +423,8 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
            @ApiParam(value = "问卷编码")
            @RequestParam String code) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            sdf.format(new Date());
            /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            sdf.format(new Date());
            String str = "{\"remark\":\"我们将按调查最终结果,优化健康服务。\",\"keyword1\":\"调查问卷\"}";
            String accessToken = getAccessToken();
            System.out.println("accessToken=====>" + accessToken);
@ -424,7 +440,25 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
                json.put("toUser", cod);
                json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
                pushMsgTask.sendWeixinMessage(accessToken, 11, openId, name, json);
            }
            }*/
            List<String> codes = surveyUserDao.findBySurveyCodeAndStatus(code);
            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, "发送成功!");
        } catch (Exception e) {
            e.printStackTrace();

+ 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")
    @ResponseBody
    public String sign(String doctor) {
    public String sign(String doctor,String patient) {
        try {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
            }
            int result = familyContractService.sign(doctor, getUID());
            int result = familyContractService.sign(doctor,patient);
            if (result == -1) {
                return error(-1, "用户信息查询失败");

+ 0 - 44
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java

@ -63,50 +63,6 @@ public class PatientQuestionnaireController extends BaseController {
    @ApiOperation(value = "保存用户答案")
    @ResponseBody
    public String saveAnswer(
            @ApiParam(allowMultiple = true, defaultValue = "{\n" +
                    "    \"surveyCode\": \"问卷id\",\n" +
                    "    \"questions\": [\n" +
                    "        {\n" +
                    "            \"qstCode\": \"问题id\",\n" +
                    "            \"sort\": \"1\",\n" +
                    "            \"type\": \"0\",\n" +
                    "            \"options\": [\n" +
                    "                {\n" +
                    "                    \"optionCode\": \"选项id\",\n" +
                    "                    \"sort\": \"2\"\n" +
                    "                }\n" +
                    "            ]\n" +
                    "        },\n" +
                    "        {\n" +
                    "            \"qstCode\": \"问题id\",\n" +
                    "            \"type\": \"1\",\n" +
                    "            \"sort\": \"2\",\n" +
                    "            \"options\": [\n" +
                    "                {\n" +
                    "                    \"optionCode\": \"选项id\",\n" +
                    "                    \"sort\": \"1\",\n" +
                    "                    \"comment\": \"选项说明可为null\"\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    \"optionCode\": \"选项id\",\n" +
                    "                    \"sort\": \"3\",\n" +
                    "                    \"comment\": \"选项说明可为null\"\n" +
                    "                },\n" +
                    "                {\n" +
                    "                    \"optionCode\": \"选项id\",\n" +
                    "                    \"sort\": \"5\",\n" +
                    "                    \"comment\": \"选项说明可为null\"\n" +
                    "                }\n" +
                    "            ]\n" +
                    "        },\n" +
                    "        {\n" +
                    "            \"qstCode\": \"问答题题目ID\",\n" +
                    "            \"content\": \"问答题答案\",\n" +
                    "            \"sort\": \"3\",\n" +
                    "            \"type\": \"2\"\n" +
                    "        }\n" +
                    "    ]\n" +
                    "}")
            @RequestParam String jsonData) {
        try {
            String patient = getUID();

+ 4 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -109,6 +109,10 @@ public class WeiXinEventProcess {
        // URL设置服务器URL、AppId
        urlBooking = urlBooking.replace("{server}", systemConf.getProperty("wechat_base_url"))
                .replace("{appId}", systemConf.getProperty("appId"));
        System.out.println("picUrlBooking ===>"+picUrlBooking);
        System.out.println("server_url ===>"+systemConf.getProperty("server_url"));
        //图片地址
        picUrlBooking = picUrlBooking.replace("{server}", systemConf.getProperty("server_url"));

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

@ -78,6 +78,7 @@ appSecret=2935b54b53a957d9516c920a544f2537
# 个人微信测试平台基本配置
#appId=wxb3827510b2e15012
#appSecret=c5bdedd909ded9c2ee08028487e6f50d
wechat_base_url=http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
wechat_token=27eb3bb24f149a7760cf1bb154b08040
@ -106,6 +107,7 @@ template_healthy_article=LA7erINJ0CSsG2G_ZCrgsDaX3krhsI4qg_NSHEyL_l4
template_doctor_change=TNIDMjduVKgVL4-k71umYLpHROvFB8K6mmm8aZC_EH8
#问卷调查
template_doctor_survey=IjQvzBy0PLeft2kN9mdBhACXPE9I_jyJywJ6B-JRxsY
#template_doctor_survey=fgYiMntj1amEkE8_GLUPmAIyssUAroJrNSHqvydt-PQ
#健康之路开放平台
yihu_OpenPlatform_url=http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/
@ -149,7 +151,7 @@ fastdfs_file_url=http://172.19.103.54:80/
##咨询回复
#template_consult_notice=-dr4QNyFoRvVsf8uWxXMC1dRyjwnbUuJwJ21vBLhf18
##签约成功
#template_sign_success=bw0_fVIxATsCuOwKYF8gzUyuZQ9IosC4Jf8ZU5IKMS4
#template_sign_success=VYGj8OUKj6FH4i4_nZS2UAHurJxQHx-7_OBPILIdB8s
##签约失败
#template_sign_failed=m221Jrkm0UUY00ExTCpQNTB8t_1U_V4LR9Bg8BgH9-o
##健康指导提醒