Browse Source

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

wujunjie 7 years ago
parent
commit
6bed27c084
100 changed files with 4271 additions and 0 deletions
  1. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/1.png
  2. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/2.png
  3. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/3.png
  4. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/4.png
  5. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/5.png
  6. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/6.png
  7. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/7.png
  8. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/8.png
  9. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot项目启动的2种方式.docx
  10. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/1.png
  11. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/10.png
  12. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/11.png
  13. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/12.png
  14. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/13.png
  15. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/2.png
  16. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/3.png
  17. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/4.png
  18. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/5.png
  19. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/6.png
  20. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/7.png
  21. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/8.png
  22. BIN
      patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/9.png
  23. 112 0
      patient-co/patient-co-doctor-assistant/doc/技术文档/es/统计新增索引.txt
  24. BIN
      patient-co/patient-co-doctor-assistant/doc/接口文档/厦门i健康API文档.docx
  25. BIN
      patient-co/patient-co-doctor-assistant/doc/接口文档/对外接口文档/集美健康教育/集美健康教育对外接口文档.docx
  26. 10 0
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/ios/00.readme.txt
  27. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/ios/HBuilder使用该证书打包的例子.png
  28. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/ios/aps推送证书.p12
  29. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/ios/xmijkPro.mobileprovision
  30. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/ios/证书.p12
  31. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/医生端通过HBuilder打包说明(草稿,完整版V0.2).docx
  32. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/发布修改参数.docx
  33. 10 0
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/安卓/00.readme.txt
  34. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/安卓/20160721170424_该证书的生成命令.png
  35. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/安卓/HBuilder使用该证书打包的例子.png
  36. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/安卓/ssgg_doctor.keystore
  37. 5 0
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/app/安卓/文档.txt
  38. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/im/im.docx
  39. BIN
      patient-co/patient-co-doctor-assistant/doc/部署文档/正式库/微信端/微信端发布.docx
  40. 500 0
      patient-co/patient-co-doctor-assistant/pom.xml
  41. 29 0
      patient-co/patient-co-doctor-assistant/readme.MD
  42. 20 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/Application.java
  43. 323 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java
  44. 14 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/aop/ObserverRequired.java
  45. 90 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/aop/ObserverRequiredAOP.java
  46. 59 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/ActiveMQConfig.java
  47. 27 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/FastDFSConfig.java
  48. 80 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/MvcConfig.java
  49. 199 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  50. 54 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/async/AsyncConfig.java
  51. 93 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/es/ElasticFactory.java
  52. 49 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java
  53. 61 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/jpa/HealthJpa.java
  54. 27 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/jpa/HibernateProperties.java
  55. 67 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/jpa/WlyyJpa.java
  56. 48 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/security/WebSecurityConfig.java
  57. 20 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/war/ServletInitializer.java
  58. 30 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  59. 101 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java
  60. 58 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/BaseInterceptor.java
  61. 221 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  62. 53 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/EncodingFilter.java
  63. 74 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/GateWayAOP.java
  64. 165 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java
  65. 62 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/MutableHttpServletRequest.java
  66. 85 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/ObserverRequiredInterceptor.java
  67. 157 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  68. 59 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/UserAgentFilter.java
  69. 103 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/logs/BusinessLogs.java
  70. 42 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/logs/InterfaceCallLogs.java
  71. 101 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/redis/RedisMsgPubSubListener.java
  72. 44 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/redis/RedisThread.java
  73. 17 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/VersionsDao.java
  74. 20 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/CityDao.java
  75. 17 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/CountryDao.java
  76. 17 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/ProvinceDao.java
  77. 26 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/StreetDao.java
  78. 25 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/TownDao.java
  79. 21 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/advert/AdvertDao.java
  80. 62 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java
  81. 48 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultCommunicationDao.java
  82. 23 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultCommunicationReplyDao.java
  83. 47 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java
  84. 59 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultMoViDao.java
  85. 17 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultMoViReferralDao.java
  86. 49 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultPublicDao.java
  87. 15 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultPublicReplyDao.java
  88. 296 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java
  89. 38 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDoctorDao.java
  90. 22 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamLogDao.java
  91. 43 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/EvaluateDao.java
  92. 28 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/EvaluateLabelDao.java
  93. 26 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/EvaluateScoreDao.java
  94. 19 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/demographic/ResidenceInfoDao.java
  95. 14 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/demographic/TblBasicDao.java
  96. 11 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/demographic/TblFamilyDao.java
  97. 17 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/demographic/TblsysParamDao.java
  98. 21 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/deviece/DeviceCategoryDao.java
  99. 21 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/deviece/DeviceDao.java
  100. 0 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/deviece/PatientBloodSuggerDao.java

BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/1.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/2.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/3.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/4.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/5.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/6.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/7.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot启动/8.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/boot项目启动的2种方式.docx


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/1.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/10.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/11.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/12.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/13.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/2.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/3.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/4.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/5.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/6.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/7.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/8.png


BIN
patient-co/patient-co-doctor-assistant/doc/技术文档/IDEA操作/tomcat启动/9.png


+ 112 - 0
patient-co/patient-co-doctor-assistant/doc/技术文档/es/统计新增索引.txt

@ -0,0 +1,112 @@
创建索引
POST  http://172.19.103.68:9200/health_edu_article_patient_test
查询索引
GET http://172.19.103.68:9200/health_edu_article_patient_test/
给索引加mapping
POST http://172.19.103.68:9200/health_edu_article_patient_test/health_edu_article_patient_test/_mapping
{
    "health_edu_article_patient_test": {
            "properties": {
                "patient": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "patientName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "sendCode": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "sendName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "sendPic": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "sendSex": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "sendLevel": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "adminTeamCode": {
                    "type": "integer",
                    "index": "not_analyzed"
                },
                "adminTeamName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "hospital": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "hospitalName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "town": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "townName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "batchNo": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "articleId": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "attachedTitle": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "attachedPic": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "attachedContent": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "attachedMessage": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "articleType": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "level1Type": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "level2Type": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "level": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "type": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "createTime": {
                    "type": "date",
                    "index": "not_analyzed"
                }
            }
        }
  }

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


BIN
patient-co/patient-co-doctor-assistant/doc/接口文档/对外接口文档/集美健康教育/集美健康教育对外接口文档.docx


+ 10 - 0
patient-co/patient-co-doctor-assistant/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/patient-co-doctor-assistant/doc/部署文档/正式库/app/ios/HBuilder使用该证书打包的例子.png


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


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


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


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


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


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

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

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


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


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


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

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

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


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


+ 500 - 0
patient-co/patient-co-doctor-assistant/pom.xml

@ -0,0 +1,500 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>patient-co-lib</artifactId>
        <groupId>com.yihu</groupId>
        <version>1.0.0</version>
        <relativePath>../../patient-co-lib/pom.xml</relativePath>
    </parent>
    <artifactId>patient-co-doctor-assistant</artifactId>
    <name>patient-co-doctor-assistant</name>
    <version>1.0.0</version>
    <packaging>war</packaging>
    <!-- 设定插件仓库, 如有Nexus私服, 取消注释并指向正确的服务器地址. -->
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://172.19.103.47:8081/nexus/content/groups/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    <dependencies>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <!--Spring boot family-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator-docs</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <!--<dependency>-->
        <!--<groupId>org.springframework.boot</groupId>-->
        <!--<artifactId>spring-boot-devtools</artifactId>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <!-- end -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>
        <!-- spring start -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-keyvalue</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
        </dependency>
        <!-- spring end -->
        <!--activemq start-->
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-spring</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-broker</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-jaas</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-camel</artifactId>
        </dependency>
        <!--activemq end-->
        <!--Swagger start -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
        </dependency>
        <!--activemq start-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
        </dependency>
        <!--Swagger end -->
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>jave-ffmpegjave</artifactId>
        </dependency>
        <!-- poi start-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
        </dependency>
        <!-- poi end-->
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
        </dependency>
        <dependency>
            <groupId>axis</groupId>
            <artifactId>axis-jaxrpc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>
        <dependency>
            <groupId>sehrCrypto</groupId>
            <artifactId>sehrCrypto</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom</artifactId>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk16</artifactId>
        </dependency>
        <!-- Apache Commons fileupload -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <!-- SPRINGSIDE -->
        <dependency>
            <groupId>org.springside</groupId>
            <artifactId>springside-core</artifactId>
        </dependency>
        <!-- PERSISTENCE begin -->
        <dependency>
            <groupId>com.google.code.kaptcha</groupId>
            <artifactId>kaptcha</artifactId>
        </dependency>
        <!-- spring data access -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
        </dependency>
        <!-- aspectjrt start -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
        </dependency>
        <!-- aspectjrt end -->
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>
        <!-- jdbc driver -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <!-- PERSISTENCE end -->
        <!-- WEB begin -->
        <dependency>
            <groupId>opensymphony</groupId>
            <artifactId>sitemesh</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <!-- WEB end -->
        <!-- JSON begin -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jaxb-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <!-- JSON end -->
        <dependency>
            <groupId>org.htmlparser</groupId>
            <artifactId>htmlparser</artifactId>
        </dependency>
        <dependency>
            <groupId>xom</groupId>
            <artifactId>xom</artifactId>
        </dependency>
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
        </dependency>
        <!-- LOGGING begin -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
        </dependency>
        <!-- 代码直接调用log4j会被桥接到slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
        </dependency>
        <!-- 代码直接调用common-logging会被桥接到slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
        </dependency>
        <!-- 代码直接调用java.util.logging会被桥接到slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
        </dependency>
        <!-- LOGGING end -->
        <!-- GENERAL UTILS begin -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <!-- GENERAL UTILS end -->
        <!-- selenium 2.0 -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-htmlunit-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-android-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-iphone-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-safari-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-remote-driver</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>cglib</groupId>
                    <artifactId>cglib-nodep</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--二维码生成 start-->
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>javase</artifactId>
        </dependency>
        <!--二维码生成 end-->
        <!-- redis start  -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
        <!-- redis end  -->
        <!--fastdfs start-->
        <dependency>
            <groupId>org.csource</groupId>
            <artifactId>fastdfs_lib</artifactId>
        </dependency>
        <!--fastdfs end-->
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <!--易联众支付-->
        <dependency>
            <groupId>com.ylz</groupId>
            <artifactId>onpay-java-sdk-all</artifactId>
        </dependency>
        <dependency>
            <groupId>org.nlpcn</groupId>
            <artifactId>elasticsearch-sql</artifactId>
            <version>2.4.1.0</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>wlyy</finalName>
        <plugins>
            <!--打成war包需要的配置-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <verbose/>
                        <bootclasspath>${java.home}/lib/rt.jar;${java.home}/lib/jce.jar</bootclasspath>
                    </compilerArguments>
                </configuration>
                <version>3.1</version>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <!--打包的时候把webapp下的资源移到根目录下-->
                <directory>${basedir}/src/main/webapp</directory>
                <targetPath>${basedir}/</targetPath>
                <includes>
                    <include>**/**</include>
                </includes>
                <!--防止以下两个文件编译的时候出现在项目根目录中,打包的时候还是会打包进去这2个文件-->
                <excludes>
                    <exclude>downloadPage.html</exclude>
                    <exclude>ssgg_doctor.plist</exclude>
                    <exclude>images/**</exclude>
                </excludes>
            </resource>
            <resource>
                <!--打包的时候把resources下的资源移到classpath下-->
                <directory>${basedir}/src/main/resources</directory>
                <includes>
                    <include>**/**</include>
                </includes>
            </resource>
        </resources>
    </build>
</project>

+ 29 - 0
patient-co/patient-co-doctor-assistant/readme.MD

@ -0,0 +1,29 @@
项目中涉及到的框架
spring,springMVC,springJPA,springSecurity,springBoot
quartz,swagger-ui,hibernate,redis,fastDfs
项目包结构
doc 项目相关文档
src 代码
    main
        java
            com.yihu.wlyy
                aop 切面相关代码
                config 配置相关代码
                entity jpa 实体类相关代码
                event 事件相关代码
                exception 异常相关代码
                health 体征设备相关代码
                interceptors 拦截器相关代码
                job 任务相关代码
                logs 日志相关代码
                repository dao相关代码
                rest 
                service 服务类相关代码
                task 线程相关代码
                util 工具类相关代码
                web controller相关代码
                wechat 微信相关代码
        resource 资源和配置文件
        webapp  web相关代码

+ 20 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/Application.java

@ -0,0 +1,20 @@
package com.yihu.wlyy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
/**
 * Created by chenweida on 2017/7/28.
 */
@SpringBootApplication
public class Application {
    public static ApplicationContext ctx = null;
    public static void main(String[] args) {
        ctx = SpringApplication.run(Application.class, args);
    }
}

+ 323 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java

@ -0,0 +1,323 @@
package com.yihu.wlyy.adapter;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.util.CommonUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
 * Created by Trick on 2017/8/10.
 */
@Component
public class PresModeAdapter {
    private static Logger logger = LoggerFactory.getLogger(PresModeAdapter.class);
    @Autowired
    private Icd10DictServcie icd10DictServcie;
    @Autowired
    private ZyDictService zyDictService;
    /**
     * 处方模板适配器
     * @param json
     * @return
     * @throws Exception
     */
    public JSONArray modeTopresInfo(String json){
        try{
            JSONObject oldJson = JSONObject.parseObject(json);
            if(oldJson.getInteger("status")!=200){
                throw new RuntimeException("智业接口失败:"+oldJson.getString("msg"));
            }
            String dataStr = oldJson.getString("data");
            JSONObject data = JSONObject.parseObject(dataStr);
            JSONArray returnData = data.getJSONArray("returnData");
            String code = data.getString("CODE");
            if(StringUtils.isNotBlank(code)&&"1".equals(code)&&returnData.size()>0){
                JSONArray rs = new JSONArray();
                Iterator iterator = returnData.iterator();
                while (iterator.hasNext()){
                    JSONArray modeArray = (JSONArray) iterator.next();
                    for(int i=0;i<modeArray.size();i++){
                        JSONObject mode = (JSONObject) modeArray.get(i);
                        JSONObject m = new JSONObject();
                        m.put("templateNo",mode.getInteger("TEMPLATE_NO"));
                        m.put("templateName",mode.getString("TEMPLATE_NAME"));
                        //m.put("templateExplain",mode.getInt("TEMPLATE_EXPLAIN"));
                        JSONArray infos = mode.getJSONArray("TEMPLATE_DETAIL");
                        Iterator infoIt = infos.iterator();
                        JSONArray is = new JSONArray();
                        while (infoIt.hasNext()){
                            JSONObject info = (JSONObject) infoIt.next();
                            PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                            prescriptionInfo.setRemark(info.getString("REMARK"));
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                            prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                            prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                            prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                            prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                            prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                            prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                            prescriptionInfo.setPrice(info.getInteger("ITEM_PRICE"));//药品单价
                            prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                            prescriptionInfo.setJwSubCode("");//智业子处方号
                            prescriptionInfo.setSubjectClass(info.getString("SUBJECT_CLASS"));//"科目类别编码",
                            prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                            prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
//                            prescriptionInfo.setCost(1);//金额
//                            prescriptionInfo.setCharge(0);//自付
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));//成组标志, 0.非成组,1.成组
                            prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                            prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                            prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                            prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                            prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                            prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                            prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                            prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                            prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                            prescriptionInfo.setPhysicInjectPlace("");//注射地点编码
                            prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称
                            prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                            prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                            is.add(prescriptionInfo);
                        }
                        m.put("prescriptionInfo",is);
                        rs.add(m);
                    }
                }
                return rs;
            }
        }catch (Exception e){
            logger.info("PresModeAdapter:modeTopresInfo:Json:"+json);
            throw e;
        }
        return new JSONArray();
    }
    /**
     * 处方列表解析
     * @param json
     * @return
     * @throws Exception
     */
    public JSONArray modeToPrescription(String json){
        try{
            JSONObject oldJson = JSONObject.parseObject(json);
            if(oldJson.getInteger("status")!=200){
                throw new RuntimeException("智业接口失败:"+oldJson.getString("msg"));
            }
            JSONObject data = oldJson.getJSONObject("data");
            JSONArray returnData = data.getJSONArray("returnData");
            String code = data.getString("CODE");
            if(StringUtils.isNotBlank(code)&&"1".equals(code)&&returnData.size()>0){
                JSONArray rs = new JSONArray();
                Iterator iterator = returnData.iterator();
                while (iterator.hasNext()){
                    JSONArray modeArray = (JSONArray) iterator.next();
                    for(int i=0;i<modeArray.size();i++){
                        JSONObject mode = (JSONObject) modeArray.get(i);
                        JSONObject p  = new JSONObject();
                        p.put("code",mode.getInteger("RECIPE_NO")+"");
                        p.put("createTime",mode.getString("APPLY_TIME"));
                        Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
                        // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                        if(doctor!=null){
                            p.put("doctor",doctor.getCode());
                            p.put("doctorName",doctor.getName());
                            p.put("hospitalName",doctor.getHospitalName());
                            p.put("hospital",doctor.getHospital());
                        }else{
                            p.put("doctor",mode.getString("APPLY_OPERATOR"));
                            p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                            p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                            p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
                        }
                        PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
                        String diagnoseCode = mode.getString("DIAGNOSE_CODE");
                        String diagnoseName = mode.getString("DIAGNOSE_NAME");
//                    String diagnoseCode = "E10.100";
//                    String diagnoseName = "1型糖尿病性酮症";
                        diagnosis.setCode(diagnoseCode);//诊断代码
                        diagnosis.setName(diagnoseName);//诊断名称
                        String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                        if(!StringUtils.isEmpty(icd10)){
                            JSONObject icd = JSONObject.parseObject(icd10);
                            diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
                            diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
                        }else{
                            diagnosis.setHealthProblemName(diagnoseName);//诊断名称
                            diagnosis.setHealthProblem(diagnoseCode);//诊断代码
                        }
                        JSONArray jsonArrayDt = new JSONArray();
                        jsonArrayDt.add(diagnosis);
                        p.put("prescriptionDt",jsonArrayDt);
                        JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
                        Iterator infoIt = infos.iterator();
                        List<PrescriptionInfo> prescriptionInfos = new ArrayList<>();
                        while (infoIt.hasNext()){
                            JSONObject info = (JSONObject) infoIt.next();
                            PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                            prescriptionInfo.setRemark(info.getString("REMARK"));
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                            prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                            prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                            prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                            prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                            prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                            prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                            prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("ITEM_PRICE")));//药品单价
                            prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                            prescriptionInfo.setJwSubCode(info.getString("RECIPE_SUB_NO"));//智业子处方号
                            prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                            prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                            prescriptionInfo.setCost(CommonUtil.doubleToInt(info.getDouble("COST")));//金额
                            prescriptionInfo.setCharge(CommonUtil.doubleToInt(info.getDouble("CHARGE")));//自付
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));//成组标志, 0.非成组,1.成组
                            prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                            prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                            prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                            prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                            prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                            prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                            prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                            prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                            prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                            prescriptionInfo.setPhysicInjectPlace(info.getString("PHYSIC_INJECT_PLACE"));//注射地点编码
                            prescriptionInfo.setPhysicInjectPlaceName(info.getString("PHYSIC_INJECT_PLACE_NAME"));//注射地点名称
                            prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                            prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                            prescriptionInfos.add(prescriptionInfo);
                        }
                        p.put("prescriptionInfo",prescriptionInfos);
                        rs.add(p);
                    }
                }
                return rs;
            }
        }catch (Exception e){
            logger.info("PresModeAdapter:modeToPrescription:Json:"+json);
            throw e;
        }
        return new JSONArray();
    }
    /**
     * 处方详情转换
     * @param json
     * @return
     */
    public JSONObject modelToSinglePrescription(String json){
        try{
            JSONObject oldJson = JSONObject.parseObject(json);
            if(oldJson.getInteger("status")!=200){
                throw new RuntimeException("智业接口失败:"+oldJson.getString("msg"));
            }
            JSONObject data = oldJson.getJSONObject("data");
            JSONArray returnData = data.getJSONArray("returnData");
            String code = data.getString("CODE");
            if(StringUtils.isNotBlank(code)&&"1".equals(code)&&returnData.size()>0){
                JSONArray modeArray = returnData.getJSONArray(0);
                JSONObject mode = (JSONObject) modeArray.get(0);
                JSONObject p  = new JSONObject();
                p.put("code",mode.getInteger("RECIPE_NO")+"");
                p.put("createTime",mode.getString("APPLY_TIME"));
                Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
                // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                if(doctor!=null){
                    p.put("doctor",doctor.getCode());
                    p.put("doctorName",doctor.getName());
                    p.put("hospitalName",doctor.getHospitalName());
                    p.put("hospital",doctor.getHospital());
                }else{
                    p.put("doctor",mode.getString("APPLY_OPERATOR"));
                    p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                    p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                    p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
                }
                JSONObject diagnosis = new JSONObject();
                String diagnoseCode = mode.getString("DIAGNOSE_CODE");
                String diagnoseName = mode.getString("DIAGNOSE_NAME");
//                String diagnoseCode = "E10.100";
//                String diagnoseName = "1型糖尿病性酮症";
                diagnosis.put("code",diagnoseCode);//诊断代码
                diagnosis.put("name",diagnoseName);//诊断名称
                String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                if(!StringUtils.isEmpty(icd10)){
                    JSONObject icd = JSONObject.parseObject(icd10);
                    diagnosis.put("healthProblemName",icd.getString("value"));//诊断名称
                    diagnosis.put("healthProblem",icd.getString("key"));//诊断代码
                }else{
                    diagnosis.put("healthProblemName",diagnoseName);//诊断名称
                    diagnosis.put("healthProblem",diagnoseCode);//诊断代码
                }
                JSONArray jsonArrayDt = new JSONArray();
                jsonArrayDt.add(diagnosis);
                p.put("prescriptionDt",jsonArrayDt);
                JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
                Iterator infoIt = infos.iterator();
                JSONArray prescriptionInfos = new JSONArray();
                while (infoIt.hasNext()){
                    JSONObject info = (JSONObject) infoIt.next();
                    JSONObject prescriptionInfo = new JSONObject();
                    prescriptionInfo.put("Remark",info.getString("REMARK"));
                    prescriptionInfo.put("BindFlag",info.getString("BIND_FLAG"));
                    prescriptionInfo.put("direction",info.getString("USAGE_NAME"));//药品用法
                    prescriptionInfo.put("drugCode",info.getString("ITEM_CODE"));//药品code
                    prescriptionInfo.put("drugName",info.getString("ITEM_NAME"));//药品名称
                    prescriptionInfo.put("drugRate",info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                    prescriptionInfo.put("drugRateName",info.getString("FREQUENCY_NAME"));
                    prescriptionInfo.put("drugFormat",info.getString("ITEM_SPEC"));//药品规格
                    prescriptionInfo.put("price",info.getDouble("ITEM_PRICE"));//药品单价
                    prescriptionInfo.put("num",info.getInteger("ITEM_QUANTITY"));//药品数目
                    prescriptionInfo.put("jwSubCode",info.getString("RECIPE_SUB_NO"));//智业子处方号
                    prescriptionInfo.put("drugNumUnit",info.getString("ITEM_UNIT"));//数量单位编码
                    prescriptionInfo.put("drugNumUnitName",info.getString("ITEM_UNIT_NAME"));//数量单位名称
                    prescriptionInfo.put("cost",info.getDouble("COST"));//金额
                    prescriptionInfo.put("charge",info.getDouble("CHARGE"));//自付
                    prescriptionInfo.put("bindFlag",info.getString("BIND_FLAG"));//成组标志, 0.非成组,1.成组
                    prescriptionInfo.put("dayCount",info.getInteger("DAY_COUNT"));//用药天数
                    prescriptionInfo.put("drugUsage",info.getString("USAGE"));//用药方法编码
                    prescriptionInfo.put("usageName",info.getString("USAGE_NAME"));//用药方法名称
                    prescriptionInfo.put("physicDose",info.getString("PHYSIC_DOSE"));//用药剂量
                    prescriptionInfo.put("physicDoseUnit",info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                    prescriptionInfo.put("physicDoseUnitName",info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                    prescriptionInfo.put("physicAmount",info.getString("PHYSIC_AMOUNT"));//用药总量
                    prescriptionInfo.put("physicAmountUnit",info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                    prescriptionInfo.put("physicAmountUnitName",info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                    prescriptionInfo.put("physicInjectPlace",info.getString("PHYSIC_INJECT_PLACE"));//注射地点编码
                    prescriptionInfo.put("physicInjectPlaceName",info.getString("PHYSIC_INJECT_PLACE_NAME"));//注射地点名称
                    prescriptionInfo.put("physicSkinTest",info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                    prescriptionInfo.put("physicSkinTestName",info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                    prescriptionInfos.add(prescriptionInfo);
                }
                p.put("prescriptionInfo",prescriptionInfos);
                return p;
            }
        }catch (Exception e){
            logger.info("PresModeAdapter:modelToSinglePrescription:Json:"+json);
            throw e;
        }
        return new JSONObject();
    }
}

+ 14 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/aop/ObserverRequired.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.aop;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
 * Created by Trick on 2017/6/24.
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ObserverRequired {
}

+ 90 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/aop/ObserverRequiredAOP.java

@ -0,0 +1,90 @@
package com.yihu.wlyy.aop;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
/**
 * Created by Trick on 2017/6/24.
 */
@Aspect
@Component
public class ObserverRequiredAOP {
    //Controller层切点路径
    @Pointcut("execution(* com.yihu.wlyy.web..*.*(..))")
    public void controllerAspect() {
    }
    public ObserverRequiredAOP() {
        //System.out.println("Observer---------------------------------------");
    }
    @Around("controllerAspect() && @annotation(com.yihu.wlyy.aop.ObserverRequired)")
    public Object checkToken(ProceedingJoinPoint point) throws Throwable {
        Object o = null;
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
        String error = "";
        try {
            response.setCharacterEncoding("UTF-8");
            JSONObject json = getAgent(request);
            String observer = json.has("observer") ? json.getString("observer") : "";
            if(StringUtils.isNotBlank(observer)&&"1".equals(observer)){
                PrintWriter writer=response.getWriter();
                writer.write(error(403, "该操作没有权限"));
                writer.flush();
                return o;
            }
        }catch (Exception e){
            //return o;
        }
         o = point.proceed();
        return o;
    }
    public String write(int code, String msg) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            return json.toString();
        } catch (Exception e) {
            return null;
        }
    }
    public String error(int code, String msg) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            return json.toString();
        } catch (Exception e) {
            return null;
        }
    }
    public JSONObject getAgent(HttpServletRequest request) {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            System.out.println("userAgent:" + userAgent);
            return new JSONObject(userAgent);
        } catch (Exception e) {
            return null;
        }
    }
}

+ 59 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/ActiveMQConfig.java

@ -0,0 +1,59 @@
package com.yihu.wlyy.config;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
/**
 * Created by chenweida on 2017/9/9.
 * 生产者配置
 */
@EnableJms
@Configuration
@Profile({"dev", "devtest", "prod", "test"})
public class ActiveMQConfig {
    @Value("${activemq.username}")
    private String username;
    @Value("${activemq.password}")
    private String password;
    @Value("${activemq.url}")
    private String url;
    @Bean
    public ActiveMQConnectionFactory activeMQConnectionFactory() {
        ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(username, password, url);
        //设置异步发送
        activeMQConnectionFactory.setUseAsyncSend(true);
        return activeMQConnectionFactory;
    }
    /**
     * 缓存session链接
     *
     * @return
     */
    @Bean
    @Primary
    public CachingConnectionFactory CachingConnectionFactory() {
        CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
        //目标ConnectionFactory对应真实的可以产生JMS Connection的ConnectionFactory
        cachingConnectionFactory.setTargetConnectionFactory(activeMQConnectionFactory());
        //Session缓存数量,这里属性也可以直接在这里配置
        cachingConnectionFactory.setSessionCacheSize(100);
        return cachingConnectionFactory;
    }
    @Bean
    public JmsTemplate jmsTemplate() {
        JmsTemplate jmsTemplate = new JmsTemplate();
        jmsTemplate.setConnectionFactory( CachingConnectionFactory());
        return jmsTemplate;
    }
}

+ 27 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/FastDFSConfig.java

@ -0,0 +1,27 @@
package com.yihu.wlyy.config;
import com.yihu.wlyy.util.fastdfs.FastDFSClientPool;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * @author Sand
 * @version 1.0
 * @created 2015.11.27 16:08
 */
@Configuration
public class FastDFSConfig {
    @Bean
    public FastDFSClientPool fastDFSClientPool(){
        FastDFSClientPool clientPool = FastDFSClientPool.getInstance();
        return clientPool;
    }
    @Bean
    public FastDFSUtil fastDFSUtil(){
        FastDFSUtil util = new FastDFSUtil();
        return util;
    }
}

+ 80 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/MvcConfig.java

@ -0,0 +1,80 @@
package com.yihu.wlyy.config;
import com.yihu.wlyy.interceptors.DoctorInterceptor;
import com.yihu.wlyy.interceptors.GateWayInterceptor;
import com.yihu.wlyy.interceptors.PatientInterceptor;
import com.yihu.wlyy.interceptors.UserAgentFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@Profile({"test", "prod"})
public class MvcConfig extends WebMvcConfigurerAdapter {
    private Logger logger = LoggerFactory.getLogger(MvcConfig.class);
    @Autowired
    private DoctorInterceptor doctorInterceptor;
    @Autowired
    private PatientInterceptor patientInterceptor;
    @Autowired
    private GateWayInterceptor gateWayInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
        registry.addInterceptor(gateWayInterceptor).addPathPatterns("/wlyygc/**").excludePathPatterns("/wlyygc/doctor/**", "/wlyygc/patient/**");
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**", "wlyygc/doctor/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**", "/wlyygc/patient/**");
        super.addInterceptors(registry);
        logger.info("init doctorInterceptor,patientInterceptor");
    }
    @Bean
    public FilterRegistrationBean testFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new UserAgentFilter());
        registration.addUrlPatterns("/*");
        registration.setName("UserAgentFilter");
        registration.setOrder(1);
        return registration;
    }
//    /**
//     * 编码过滤
//     */
//    @Bean
//    public FilterRegistrationBean testFilterRegistration2() {
//        FilterRegistrationBean registration = new FilterRegistrationBean();
//        registration.setFilter(new UserAgentFilter());
//        registration.addUrlPatterns("/doctor/requestRealNameSoftCertAndSign");
//        registration.setName("EncodingFilter");
//        registration.setOrder(2);
//        return registration;
//    }
//    /**
//     * 为null的数据不返回
//     * @param converters
//     */
//    @Override
//    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
//        MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
//        ObjectMapper objectMapper=new ObjectMapper();
//        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
//        mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper);
//        converters.add(mappingJackson2HttpMessageConverter);
//    }
}

+ 199 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -0,0 +1,199 @@
package com.yihu.wlyy.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@EnableSwagger2
@Configuration
public class SwaggerConfig {
    private static final String Doctor_API = "doctor";
    private static final String Patient_API = "patient";
    private static final String Other_API = "other";
    private static final String GateWay_API = "gateway";
    final String userAgent = "{\"id\":用户id,\"uid\":\"用户code\",\"openid\":\"openid\",\"token\":\"token表\",\"lastUid\":\"\",\"platform\":\"1患者APP,2医生APP,3患者微信公众号\"}";
    final String userAgentJson = "{\"id\":int,\"uid\":string,\"openid\":string,\"token\":string,\"lastUid\":string,\"platform\":int}";
    @Bean
    public Docket gatewayAPI() {
        List<Parameter> pars = addToken();
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(GateWay_API)
                .genericModelSubstitutes(DeferredResult.class)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(true)
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/wlyygc/.*"),
                        regex("/manage_util/.*"),
                        regex("/gc/.*")
                ))
                .build()
                .globalOperationParameters(pars)
                .apiInfo(gatewayApiInfo());
    }
    private ApiInfo gatewayApiInfo() {
        ApiInfo apiInfo = new ApiInfo("三师平台API",
                "对外部应用提供功能与数据接口。",
                "1.0",
                "No terms of service",
                "admin@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return apiInfo;
    }
    private List<Parameter> addToken() {
        ParameterBuilder tokenPar = new ParameterBuilder();
        ParameterBuilder userAgentPar = new ParameterBuilder();
        List<Parameter> pars = new ArrayList<Parameter>();
        userAgentPar.name("userAgent").description(userAgentJson).modelRef(new ModelRef("string")).parameterType("header").required(false).defaultValue("").build();
        tokenPar.name("accesstoken").description("accesstoken").modelRef(new ModelRef("string")).parameterType("header").required(false).defaultValue("").build();
        pars.add(tokenPar.build());
        pars.add(userAgentPar.build());
        return pars;
    }
    @Bean
    public Docket publicAPI() {
        List<Parameter> pars = addUseragent();
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(Doctor_API)
                .genericModelSubstitutes(DeferredResult.class)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(true)
                .pathMapping("/")
                .select()
                .paths(or(regex("/doctor/.*"),
                        regex("/PC/.*")))
                .build()
                .globalOperationParameters(pars)
                .apiInfo(publicApiInfo());
    }
    private List<Parameter> addUseragent() {
        ParameterBuilder tokenPar = new ParameterBuilder();
        List<Parameter> pars = new ArrayList<Parameter>();
        tokenPar.name("userAgent").description(userAgentJson).modelRef(new ModelRef("string")).parameterType("header").required(false).defaultValue("").build();
        pars.add(tokenPar.build());
        return pars;
    }
    private ApiInfo publicApiInfo() {
        ApiInfo apiInfo = new ApiInfo("三师平台API",
                "向PC端,微信、App等应用提供功能与数据接口。",
                "1.0",
                "No terms of service",
                "admin@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return apiInfo;
    }
    @Bean
    public Docket patientAPI() {
        List<Parameter> pars = addUseragent();
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(Patient_API)
                .genericModelSubstitutes(DeferredResult.class)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(true)
                .pathMapping("/")
                .select()
                .paths(PathSelectors.regex("/patient/.*"))
                .build()
                .globalOperationParameters(pars)
                .apiInfo(patientApiInfo());
    }
    private ApiInfo patientApiInfo() {
        ApiInfo apiInfo = new ApiInfo("三师平台API",
                "向PC端,微信、App等应用提供功能与数据接口。",
                "1.0",
                "No terms of service",
                "admin@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return apiInfo;
    }
    @Bean
    public Docket otherAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(Other_API)
                .genericModelSubstitutes(DeferredResult.class)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(true)
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/third/.*"),
                        regex("/statistics/.*"),
                        regex("/statistics/province/.*"),
                        regex("/job/.*"),
                        regex("/family_contract/.*"),
                        regex("/hosptail/.*"),
                        regex("/common/.*"),
                        regex("/hospitals/.*"),
                        regex("/index/.*"),
                        regex("/upload/.*"),
                        regex("/weixin/.*"),
                        regex("/wx/.*"),
                        regex("/area/.*"),
                        regex("/login/.*"),
                        regex("/loginPC/.*"),
                        regex("/qrcode/.*"),
                        regex("/onepay/.*"),
                        regex("/wlyy_service/.*"),
                        regex("/wlyy_service/.*"),
                        regex("/wechat/.*"),
                        regex("/nofilter/.*"),
                        regex("/idc10/.*"),
                        regex("/im_new/.*"),
                        regex("/version/.*"),
                        regex("/express/.*")
                ))
                .build()
                .apiInfo(otherApiInfo());
    }
    private ApiInfo otherApiInfo() {
        ApiInfo apiInfo = new ApiInfo("三师平台API",
                "向PC端,微信、App等应用提供功能与数据接口。",
                "1.0",
                "No terms of service",
                "admin@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return apiInfo;
    }
}

+ 54 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/async/AsyncConfig.java

@ -0,0 +1,54 @@
package com.yihu.wlyy.config.async;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
 * Created by chenweida on 2016.10.18.
 * 启用多綫程
 */
@Configuration
@EnableAsync
public class AsyncConfig {
    /**
     * 如果池中的实际线程数小于corePoolSize,无论是否其中有空闲的线程,都会给新的任务产生新的线程
     */
    private int corePoolSize = 5;
    /**
     * 如果池中的线程数=maximumPoolSize,则有空闲线程使用空闲线程,否则新任务放入queueCapacity.
     * 设定 比 系统native thread个数要大的话,会优先抛出Java.lang.OutOfMemoryError: unable to create new native thread
     */
    private int maxPoolSize = 10;
    /**
     * 缓冲队列大小
     */
    private int queueCapacity = 100;
    /**
     * 线程池维护线程所允许的空闲时间  秒
     */
    private int keepAliveSeconds = 300;
    @Bean
    public Executor wlyyExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        executor.setKeepAliveSeconds(keepAliveSeconds);
        /** Reject策略预定义有四种:
         (1)ThreadPoolExecutor.AbortPolicy策略,是默认的策略,处理程序遭到拒绝将抛出运行时 RejectedExecutionException。
         (2)ThreadPoolExecutor.CallerRunsPolicy策略 ,调用者的线程会执行该任务,如果执行器已关闭,则丢弃.
         (3)ThreadPoolExecutor.DiscardPolicy策略,不能执行的任务将被丢弃.
         (4)ThreadPoolExecutor.DiscardOldestPolicy策略,如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程).
         */
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
}

+ 93 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/es/ElasticFactory.java

@ -0,0 +1,93 @@
package com.yihu.wlyy.config.es;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.config.HttpClientConfig;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.concurrent.TimeUnit;
/**
 * Created by chenweida on 2017/6/5.
 */
@Component
public class ElasticFactory {
    private static JestClientFactory factory = null;
    @Value("${es.host}")
    private String esHost;
    @Value("${es.port}")
    private String port;
    @Value("${es.tPort}")
    private String tPort;
    @Value("${es.clusterName}")
    private String clusterName;
//-----------------------------------jestClient----------------------------------------
    /**
     * @param "http://localhost:9200"
     * @return
     */
    @PostConstruct
    public JestClient getJestClient() {
        synchronized (ElasticFactory.class) {
            if (factory == null) {
                //初始化链接
                init();
            }
        }
        return factory.getObject();
    }
    /**
     * 初始化链接
     */
    public synchronized void init() {
        // Construct a new Jest client according to configuration via factory
        factory = new JestClientFactory();
        factory.setHttpClientConfig(new HttpClientConfig
                .Builder("http://" + esHost + ":" + port)
                .multiThreaded(true)
                .maxTotalConnection(50)// 最大链接
                .maxConnectionIdleTime(120, TimeUnit.SECONDS)//链接等待时间
                .connTimeout(30000)
                .discoveryEnabled(true)
                .readTimeout(30000)//30秒
                .build());//得到链接
    }
    //-----------------------------------TransportClient----------------------------------------
    private Client transportClient;
    public Client getTransportClient() {
        try {
            initTranClient();
            return transportClient;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    private synchronized void initTranClient() throws UnknownHostException {
        if (transportClient == null) {
            Settings settings = Settings.settingsBuilder()
                    .put("client.transport.sniff", true)//开启嗅探功能
                    .put("cluster.name", StringUtils.isEmpty(clusterName) ? "jkzl" : clusterName)//默认集群名字是jkzl
                    .build();
            transportClient = TransportClient.builder().settings(settings).build()
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(esHost), Integer.valueOf(tPort)));
        }
    }
}

+ 49 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java

@ -0,0 +1,49 @@
package com.yihu.wlyy.config.es;
import io.searchbox.client.JestClient;
import io.searchbox.core.Bulk;
import io.searchbox.core.BulkResult;
import io.searchbox.core.Index;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List;
;
/**
 * Created by chenweida on 2017/6/2.
 */
@Component
@Scope("prototype")
public class ElastricSearchSave {
    private Logger logger = LoggerFactory.getLogger(ElastricSearchSave.class);
    @Autowired
    private ElasticFactory elasticFactory;
    public Boolean save(List  sms,String esIndex,String esType) {
        try {
            //得到链接
            JestClient jestClient = elasticFactory.getJestClient();
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (Object obj : sms) {
                Index index = new Index.Builder(obj).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("save data count:" + sms.size());
            logger.info("save flag:" + br.isSucceeded());
            return br.isSucceeded();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(" save error :" + e.getMessage());
        }
        return null;
    }
}

+ 61 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/jpa/HealthJpa.java

@ -0,0 +1,61 @@
package com.yihu.wlyy.config.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "healthEntityManagerFactory",
        transactionManagerRef = "healthTransactionManager",
        basePackages = {"com.yihu.wlyy.health.repository"})  //设置Repository所在位置
public class HealthJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
    @Bean(name = "healthDataSource")
    @ConfigurationProperties(prefix="spring.datasource.health")
    public DataSource healthDataSource() {
        return DataSourceBuilder.create().build();
    }
    @Bean(name = "healthEntityManagerFactory")
    public LocalContainerEntityManagerFactoryBean entityManagerFactorySecondary(
            @Qualifier("healthDataSource") DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.device.entity");
        emfb.setPersistenceUnitName("health");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "healthTransactionManager")
    JpaTransactionManager transactionManagerSecondary(
            @Qualifier("healthEntityManagerFactory")EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
}

+ 27 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/jpa/HibernateProperties.java

@ -0,0 +1,27 @@
package com.yihu.wlyy.config.jpa;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Component
public class HibernateProperties {
    @Value("${hibernate.dialect}")
    private String dialect;
    @Value("${hibernate.show_sql}")
    private String show_sql;
    @Value("${hibernate.ejb.naming_strategy}")
    private String naming_strategy;
    public  Properties hibProperties() {
        Properties properties = new Properties();
        properties.put("hibernate.dialect",dialect);
        properties.put("hibernate.show_sql", show_sql);
        properties.put("hibernate.ejb.naming_strategy", naming_strategy);
        return properties;
    }
}

+ 67 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/jpa/WlyyJpa.java

@ -0,0 +1,67 @@
package com.yihu.wlyy.config.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "wlyyEntityManagerFactory",
        transactionManagerRef = "wlyyTransactionManager",
        basePackages = {"com.yihu.wlyy.repository"})   //设置Repository所在位置
public class WlyyJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
    @Bean(name = "wlyyDataSource")
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource.wlyy")
    public DataSource wlyyDataSource() {
        return DataSourceBuilder.create().build();
    }
    @Bean(name = "wlyyEntityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(
            @Qualifier("wlyyDataSource") DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.wlyy.entity");
        emfb.setPersistenceUnitName("wlyy");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "wlyyTransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(
            @Qualifier("wlyyEntityManagerFactory") EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
}

+ 48 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/security/WebSecurityConfig.java

@ -0,0 +1,48 @@
package com.yihu.wlyy.config.security;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.beans.factory.annotation.Value;
        import org.springframework.context.annotation.Configuration;
        import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
        import org.springframework.security.config.annotation.web.builders.HttpSecurity;
        import org.springframework.security.config.annotation.web.builders.WebSecurity;
        import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
        import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
/**
 * Created by Administrator on 2016.10.17.
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Value("${security.basic.username}")
    String username;
    @Value("${security.basic.password}")
    String password;
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/swagger-ui.html").authenticated()
                .antMatchers("/swagger-ui.html").authenticated()
                .antMatchers("/configuration/security").authenticated()
                .anyRequest().permitAll()
                .and()
                .headers().frameOptions().disable()
                .and()
                .csrf().disable()
                .formLogin().defaultSuccessUrl("/swagger-ui.html").failureUrl("/login") //登录成功之后的跳转
                .permitAll()
                .and()
                .logout().logoutSuccessUrl("/login")
                .permitAll();
    }
    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .withUser(username).password(password).roles("USER");
    }
}

+ 20 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/config/war/ServletInitializer.java

@ -0,0 +1,20 @@
package com.yihu.wlyy.config.war;//package com.yihu.wlyy.config.war;
import com.yihu.wlyy.Application;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
/**
 * Created by Administrator on 2016.10.14.
 */
public class ServletInitializer extends SpringBootServletInitializer {
    public ServletInitializer() {
        super();
        setRegisterErrorPageFilter(false); //报错不跳到错误页
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}

+ 30 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -0,0 +1,30 @@
package com.yihu.wlyy.event;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;
/**
 * Created by lyr-pc on 2017/3/10.
 */
@Service
public class ApplicationEvent implements ApplicationListener<ContextRefreshedEvent> {
    private Logger logger = LoggerFactory.getLogger(ApplicationEvent.class);
//    @Autowired
//    private RedisThread redisThread;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent ContextRefreshedEvent) {
        try {
            // 启动redis 消息队列线程
            logger.info("redis message start");
//            new Thread(redisThread).start();//移到job 工程
            logger.info("redis message end");
        } catch (Exception e) {
            logger.info("redis message start failed");
        }
    }
}

+ 101 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -0,0 +1,101 @@
package com.yihu.wlyy.health.repository;
import com.yihu.device.entity.DevicePatientHealthIndex;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
public interface DevicePatientHealthIndexDao
        extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
    List<DevicePatientHealthIndex> findByIdcardAndType(String idcard, Integer type);
    /**
     * 按录入时间和患者标识查询健康记录
     *
     * @param patientCode
     * @param date
     * @return
     */
    @Query("select a from DevicePatientHealthIndex a where a.user = ?1 and type = ?2 and a.recordDate = ?3 and a.del = '1'")
    Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date);
    @Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate between ?3 and ?4 and a.del = '1' group by recordDate order by recordDate asc")
    Iterable<DevicePatientHealthIndex> findByPatient(String user, int type, Date begin, Date end);
    @Query("select a.value1 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value1 > 0 and a.del = '1' order by recordDate desc")
    Page<String> findValue1ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value2 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value2 > 0 and a.del = '1' order by recordDate desc")
    Page<String> findValue2ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value3 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value3 > 0 and a.del = '1' order by recordDate desc")
    Page<String> findValue3ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value4 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value4 > 0 and a.del = '1' order by recordDate desc")
    Page<String> findValue4ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value5 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value5 > 0 and a.del = '1' order by recordDate desc")
    Page<String> findValue5ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value6 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value6 > 0 and a.del = '1' order by recordDate desc")
    Page<String> findValue6ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value7 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value7 > 0 and a.del = '1' order by recordDate desc")
    Page<String> findValue7ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate >= ?3 and a.recordDate <= ?4 and a.del = '1'")
	Page<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Date start, Date end, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.value2 =?3 and a.recordDate >= ?4 and a.recordDate <= ?5 and a.del = '1'")
	Page<DevicePatientHealthIndex> findIndexByPatient(String patient, int type,String gi_type, Date start, Date end, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.del = '1'")
	List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Pageable pageRequest);
	@Query("SELECT a FROM DevicePatientHealthIndex a where a.user = ?1 and a.del = '1' order by a.recordDate desc ")
	Iterable<DevicePatientHealthIndex> findRecentByPatient(String patient);
	@Query("select DATE_FORMAT(a.recordDate,'%Y-%m-%d') from DevicePatientHealthIndex a where a.user = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' group by DATE_FORMAT(a.recordDate,'%Y-%m-%d') order by DATE_FORMAT(a.recordDate,'%Y-%m-%d') desc")
	List<String> findDateList(String patient, Date start, Date end, Pageable pageRequest);
	/**
	 * 获取患者一天血糖值
     */
	@Query("select a from DevicePatientHealthIndex a where a.type=1 and a.user = ?1 and DATE_FORMAT(a.recordDate,'%Y-%m-%d') = ?2 and a.del = '1' order by a.recordDate,a.id")
	List<DevicePatientHealthIndex> findByDate(String patient, String date);
	@Query(value = "select a.* from device.wlyy_patient_health_index a where a.user=?1 and a.type=?2 and a.del='1' order by a.record_date desc limit 0,1",nativeQuery = true)
	DevicePatientHealthIndex findLastData(String patient, Integer type);
	/**
	 * 上次血糖值
     */
	@Query(value = "select a.value1 from device.wlyy_patient_health_index a where a.type=1 and a.user = ?1 and a.id<?2 and a.value2 = ?3 and a.del = '1' order by a.sort_date desc ,record_date desc limit 0,1",nativeQuery = true)
	String getPreValue(String user,Long id,String value2);
	@Query(value = "select a.* from device.wlyy_patient_health_index a where a.user = ?1 and a.type = ?2 and a.value2 =?3 and a.record_date >= ?4 and a.record_date <= ?5 and a.del = '1' order by a.sort_date desc ,record_date desc limit ?6 ,?7",nativeQuery = true)
	List<DevicePatientHealthIndex> findIndexByPatientNative(String patient, int type,String gi_type, Date start, Date end,int currentSize,int pageSize);
	/**
	 * 获取患者某一天的血糖  普通sql写法
	 * @param patient
	 * @param date
	 * @return
	 */
	@Query(value = "select a.* from device.wlyy_patient_health_index a where a.type=1 and a.user = ?1 and DATE_FORMAT(a.record_date,'%Y-%m-%d') = ?2 and a.del = '1' order by a.record_date,a.id",nativeQuery = true)
	List<DevicePatientHealthIndex> findByDateNative(String patient, String date );
	@Query(value = "select a.* from device.wlyy_patient_health_index a where a.user = ?1 and a.type = ?2 and a.record_date >= ?3 and a.record_date <= ?4 and a.del = '1' order by a.sort_date desc ,record_date desc limit ?5 ,?6",nativeQuery = true)
	List<DevicePatientHealthIndex> findIndexByPatientNative(String patient, int type, Date start, Date end,int currentSize,int pageSize);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from device.wlyy_patient_health_index a where a.user = ?1 and a.record_date >= ?2 and a.record_date <= ?3 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?4 ,?5",nativeQuery = true)
	List<String> findDateList(String patient,Date start ,Date end,int currentSize,int pageSize);
}

+ 58 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/BaseInterceptor.java

@ -0,0 +1,58 @@
package com.yihu.wlyy.interceptors;
import javax.servlet.http.HttpServletRequest;
import com.yihu.wlyy.repository.url.CudUrlDao;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;
import com.yihu.wlyy.repository.security.TokenDao;
abstract public class BaseInterceptor implements HandlerInterceptor {
	private Logger logger= LoggerFactory.getLogger(BaseInterceptor.class);
	@Autowired
	public TokenDao tokenDao;
	@Autowired
	public CudUrlDao cudUrlDao;
	public JSONObject getAgent(HttpServletRequest request) {
		try {
			String userAgent = request.getHeader("userAgent");
			if (StringUtils.isEmpty(userAgent)) {
				userAgent = request.getHeader("User-Agent");
			}
			logger.info("userAgent:" + userAgent);
			return new JSONObject(userAgent);
		} catch (Exception e) {
			return null;
		}
	}
	public String error(int code, String msg) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			return json.toString();
		} catch (Exception e) {
			return null;
		}
	}
	public String write(int code, String msg) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			return json.toString();
		} catch (Exception e) {
			return null;
		}
	}
}

+ 221 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -0,0 +1,221 @@
package com.yihu.wlyy.interceptors;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.entity.url.CudUrl;
import com.yihu.wlyy.logs.InterfaceCallLogs;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.Map;
/**
 * 医生权限校验
 *
 * @author George
 */
@Component
public class DoctorInterceptor extends BaseInterceptor {
    private Logger logger = LoggerFactory.getLogger(DoctorInterceptor.class);
    public static String status = "1";
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        if(Flag.close.getValue().equals(status)){
            return true;
        }
        try {
            request.setCharacterEncoding("UTF-8");
            response.setHeader("Content-type", "text/html;charset=UTF-8");
            request.setAttribute("log-start", new Date().getTime());
            response.setCharacterEncoding("UTF-8");
            JSONObject json = getAgent(request);
            if (json == null) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                return false;
            }
            if (json.has("uid") && json.has("admin_token") && StringUtils.isNotEmpty(json.getString("admin_token"))) {
                String adminToken = SystemConf.getInstance().getSystemProperties().getProperty("admin_token");
                String adminUid = SystemConf.getInstance().getSystemProperties().getProperty("admin_uid");
                if (json.getString("uid").equals(adminUid) && json.getString("admin_token").equals(adminToken)) {
                    return true;
                }
            }
            String tokenStr = json.has("token") ? json.getString("token") : "";
            String uid = json.has("uid") ? json.getString("uid") : "";
            String imei = json.has("imei") ? json.getString("imei") : "";
            String observer = json.has("observer") ? json.getString("observer") : "";
            Integer platform = json.has("platform") ? json.getInt("platform") : 2;
            logger.debug("tokenStr:" + tokenStr);
            logger.debug("uid:" + uid);
            logger.debug("imei:" + imei);
            logger.debug("observer:" + observer);
            logger.debug("platform:" + platform);
            //如果是观察者直接返回true
            if (!org.springframework.util.StringUtils.isEmpty(observer) && observer.equals("1")) {
                Class cls = ((HandlerMethod) handler).getBeanType();
                RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
                Method method = ((HandlerMethod) handler).getMethod();
                RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
                String url = "";
                String urlCls = "";
                String urlMth = "";
                if (clsRm.value() != null && clsRm.value().length > 0) {
                    urlCls = clsRm.value()[0];
                }
                if (mthRm.value() != null && mthRm.value().length > 0) {
                    urlMth = mthRm.value()[0];
                }
                if (StringUtils.isNotEmpty(urlCls)) {
                    url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
                }
                if (StringUtils.isNotEmpty(urlMth)) {
                    url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
                }
                url = url.replace("\\", "/").replace("//", "/");
                CudUrl cudUrl = cudUrlDao.findByUrl(url);
                if (url.equals("/doctor/consult/readed")) {
                    response.getOutputStream().write(write(200, "操作成功").getBytes());
                    return false;
                }
                if (cudUrl != null) {
                    if (StringUtils.isNotEmpty(cudUrl.getMethod()) &&
                            request.getMethod().toUpperCase().compareTo(cudUrl.getMethod()) != 0) {
                        return true;
                    } else {
                        response.getOutputStream().write(error(403, "该操作没有权限").getBytes("UTF-8"));
                        return false;
                    }
                }
                return true;
            }
            if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                return false;
            }
            Token token = null;
            Map<String, Token> tempMap = null;
            if (platform == 2) {
                tempMap = SystemData.doctorTokens;
            } else if (platform == 4) {
                tempMap = SystemData.doctorPCTokens;
            }else if(platform ==5){
                tempMap = SystemData.doctorWXTokens;
            }
            token = tempMap.get(uid);
            if (token == null) {
                token = tokenDao.findByPatient(uid, platform);
                if (token != null) {
                    // 加入缓存
                    tempMap.put(uid, token);
                }
            }
            //  2、医生端app,3、微信公众号wechat,4、医生端pc,或者 PC端取药系统  或者对外系统
            if (token == null || (token.getPlatform() != 2 && token.getPlatform() != 4&&token.getPlatform()!=5)) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                flag = false;
            } else {
                if (token.getTimeout().getTime() < new Date().getTime()) {
                    // 登录超时
                    response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes("UTF-8"));
                    flag = false;
                } else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
                    // 别处登录
                    response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes("UTF-8"));
                    flag = false;
                } else {
                    // 一天只更新一次
                    if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
                        // 今天未更新,则更新缓存
                        token.setCzrq(new Date());
                        // 更新内存
                        tempMap.put(uid, token);
                        // 更新数据库
                        tokenDao.save(token);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        if (null == request.getAttribute("log-start")) {
            return;
        }
        long start = (long) request.getAttribute("log-start");
        long end = new Date().getTime();
        Class cls = ((HandlerMethod) handler).getBeanType();
        RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
        Method method = ((HandlerMethod) handler).getMethod();
        RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
        String url = "";
        String urlCls = "";
        String urlMth = "";
        if (clsRm.value() != null && clsRm.value().length > 0) {
            urlCls = clsRm.value()[0];
        }
        if (mthRm.value() != null && mthRm.value().length > 0) {
            urlMth = mthRm.value()[0];
        }
        if (StringUtils.isNotEmpty(urlCls)) {
            url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
        }
        if (StringUtils.isNotEmpty(urlMth)) {
            url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
        }
        url = url.replace("\\", "/").replace("//", "/");
        JSONObject json = getAgent(request);
        String uid = json.has("uid") ? json.getString("uid") : "";
        InterfaceCallLogs.info(end - start, url, uid, new JSONObject(request.getParameterMap()).toString());
    }
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
    public String getStatus() {
        return status;
    }
    @Value("${interceptor.doctor.status}")
    public void setStatus(String status) {
        DoctorInterceptor.status = status;
    }
}

+ 53 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/EncodingFilter.java

@ -0,0 +1,53 @@
package com.yihu.wlyy.interceptors;
import com.yihu.wlyy.util.CodeFomat;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Map;
/**
 * Created by chenweida on 2017/8/22.
 */
@Component
public class EncodingFilter implements Filter {
    private Logger logger= LoggerFactory.getLogger(EncodingFilter.class);
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        Map<String, String[]> params = request.getParameterMap();
        MutableHttpServletRequest newRequest = new MutableHttpServletRequest(request);
        newRequest.getParameterNames();
        for (String key : params.keySet()) {
            String[] values = params.get(key);
            for (int i = 0; i < values.length; i++) {
                String value = values[i];
                newRequest.removeAttribute(key);
//                解决%、+后中文以英文编码传入URLDecoder异常
                value = CodeFomat.dateToChinese(value);
                newRequest.addParameter(key, URLDecoder.decode((value),"utf-8"));
            }
        }
        chain.doFilter(newRequest, response);
    }
    @Override
    public void destroy() {
    }
}

+ 74 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/GateWayAOP.java

@ -0,0 +1,74 @@
package com.yihu.wlyy.interceptors;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
/**
 * 由于用了@ResponseBody之后 拦截器返回值ModelAndView 是null 所以用线程变量解决
 */
@Aspect
@Component
public class GateWayAOP {
    private Logger logger = LoggerFactory.getLogger(GateWayAOP.class);
    //Controller层切点路径
    @Pointcut("execution(* com.yihu.wlyy.web..*.*(..))")
    public void controllerAspect() {
    }
    public GateWayAOP() {
        //System.out.println("Observer---------------------------------------");
    }
    @Around("controllerAspect()")
    public Object checkToken(ProceedingJoinPoint point) throws Throwable {
        Object obj = null;
        HttpServletRequest request = null;
        try {
            request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            obj = point.proceed();
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        if (request != null) {
            request.setAttribute("returnObj", obj);
        }
        return obj;
    }
}
enum Flag {
    close("0"),
    open("1");
    Flag(String value) {
        this.value = value;
    }
    private String value;
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
}

+ 165 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java

@ -0,0 +1,165 @@
package com.yihu.wlyy.interceptors;
/**
 * Created by chenweida on 2017/8/17.
 */
import com.yihu.wlyy.entity.gateway.GcHttpLog;
import com.yihu.wlyy.entity.gateway.GcToken;
import com.yihu.wlyy.repository.gateway.GcHttpLogDao;
import com.yihu.wlyy.repository.gateway.GcTokenDao;
import com.yihu.wlyy.util.NetworkUtil;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
/**
 * 对外的请求拦截
 */
@Component
public class GateWayInterceptor implements HandlerInterceptor {
    private Logger logger = LoggerFactory.getLogger(GateWayInterceptor.class);
    @Autowired
    private GcHttpLogDao httpLogDao;
    @Autowired
    private GcTokenDao gcTokenDaoDao;
    public static String status = "1";
    /**
     * preHandle:预处理回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(Flag.close.getValue().equals(status)){
            return true;
        }
        boolean flag = true;
        String accesstoken = request.getHeader("accesstoken");
        String ip = NetworkUtil.getIpAddress(request);
        //********************************判断accesstoken********************************
        try {
            if (org.springframework.util.StringUtils.isEmpty(accesstoken)) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_null.getMessage());
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_null.getCode(), BaseResultModel.statusEm.token_null.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
            }
            GcToken gcToken = gcTokenDaoDao.findByToken(accesstoken);
            if (gcToken == null) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_no_power.getMessage());
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_no_power.getCode(), BaseResultModel.statusEm.token_no_power.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
            }
            if (gcToken.getDel() == null || gcToken.getDel() == 0) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_out_effect.getMessage());
                //token无效
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_out_effect.getCode(), BaseResultModel.statusEm.token_out_effect.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
            }
            if (System.currentTimeMillis() > gcToken.getOutTime().getTime()) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.statusEm.token_out_time.getMessage());
                //token过期
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.statusEm.token_out_time.getCode(), BaseResultModel.statusEm.token_out_time.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
            }
        } catch (Exception e) {
            saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), e.getMessage());
            return false;
        }
        //********************************判断accesstoken********************************
        return flag;
    }
    /**
     * 后处理回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @param modelAndView
     * @throws Exception
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        String output = "";
        if (modelAndView != null) {
            output = JSONObject.fromObject(modelAndView.getModelMap()).toString();
        } else {
            Object returnObj = request.getAttribute("returnObj");
            if (returnObj != null) {
                output = JSONObject.fromObject(returnObj).toString();
            }
        }
        HandlerMethod handlerMethod = (HandlerMethod) handler;
//        response.getOutputStream()
        String token = request.getHeader("accesstoken");
        String ip = NetworkUtil.getIpAddress(request);
        saveHttpLog(ip,
                JSONObject.fromObject(request.getParameterMap()).toString(),
                output,
                token,
                request.getRequestURI(),
                GcHttpLog.flagEm.success.getCode(),
                null);
    }
    /**
     * 整个请求处理完毕回调方法
     *
     * @param request
     * @param response
     * @param handler
     * @param ex
     * @throws Exception
     */
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
    public void saveHttpLog(String ip, String input, String output, String token, String method, Integer flag, String message) {
        GcHttpLog gcHttpLog = new GcHttpLog();
        gcHttpLog.setCreateTime(new Date());
        gcHttpLog.setIp(ip);
        gcHttpLog.setInput(input);
        gcHttpLog.setOutput(output);
        gcHttpLog.setToken(token);
        gcHttpLog.setMethod(method);
        gcHttpLog.setFlag(flag);
        gcHttpLog.setMessage(message);
        httpLogDao.save(gcHttpLog);
    }
    public String getStatus() {
        return status;
    }
    @Value("${interceptor.accesstoken.status}")
    public void setStatus(String status) {
        DoctorInterceptor.status = status;
    }
}

+ 62 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/MutableHttpServletRequest.java

@ -0,0 +1,62 @@
package com.yihu.wlyy.interceptors;
/**
 * Created by chenweida on 2017/8/22.
 */
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
final class MutableHttpServletRequest extends HttpServletRequestWrapper {
    // holds custom header and value mapping
    private final Map<String, String> customHeaders;
    public MutableHttpServletRequest(HttpServletRequest request){
        super(request);
        this.customHeaders = new HashMap<String, String>();
    }
    public void putHeader(String name, String value){
        this.customHeaders.put(name, value);
    }
    public String getHeader(String name) {
        // check the custom headers first
        String headerValue = customHeaders.get(name);
        if (headerValue != null){
            return headerValue;
        }
        // else return from into the original wrapped object
        return ((HttpServletRequest) getRequest()).getHeader(name);
    }
    public Enumeration<String> getHeaderNames() {
        // create a set of the custom header names
        Set<String> set = new HashSet<String>(customHeaders.keySet());
        // now add the headers from the wrapped request object
        @SuppressWarnings("unchecked")
        Enumeration<String> e = ((HttpServletRequest) getRequest()).getHeaderNames();
        while (e.hasMoreElements()) {
            // add the names of the request headers into the list
            String n = e.nextElement();
            set.add(n);
        }
        // create an enumeration from the set and return
        return Collections.enumeration(set);
    }
    public void addParameter(String name , Object value) {//增加参数
        if(value != null) {
            customHeaders.put(name , String.valueOf(value));
        }
    }
}

+ 85 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/ObserverRequiredInterceptor.java

@ -0,0 +1,85 @@
package com.yihu.wlyy.interceptors;
import com.yihu.wlyy.aop.ObserverRequired;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
/**
 * Created by Trick on 2017/6/24.
 */
public class ObserverRequiredInterceptor  implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation mi) throws Throwable {
        Object[] ars = mi.getArguments();
        HttpServletRequest request =null;
        HttpServletResponse response = null;
        for(Object o :ars){
            if(o instanceof HttpServletRequest){
                request = (HttpServletRequest) o;
            }
            if(o instanceof HttpServletResponse){
                response = (HttpServletResponse) o;
            }
        }
        if(request!=null&&response!=null){
            JSONObject json = getAgent(request);
            String tokenStr = json.has("token") ? json.getString("token") : "";
            String uid = json.has("uid") ? json.getString("uid") : "";
            String imei = json.has("imei") ? json.getString("imei") : "";
            String observer = json.has("observer") ? json.getString("observer") : "";
            //if(StringUtils.isNotBlank(observer)&&"1".equals(observer)){
                if(mi.getMethod().isAnnotationPresent(ObserverRequired.class)){
                    System.out.println("----------this method is added @ObserverRequired-------------------------");
                    response.getOutputStream().write(error(403, "该操作没有权限").getBytes());
                    return null;
                }
            //}
        }
        //执行被拦截的方法,切记,如果此方法不调用,则被拦截的方法不会被执行。
        return mi.proceed();
    }
    public JSONObject getAgent(HttpServletRequest request) {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            System.out.println("userAgent:" + userAgent);
            return new JSONObject(userAgent);
        } catch (Exception e) {
            return null;
        }
    }
    public String write(int code, String msg) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            return json.toString();
        } catch (Exception e) {
            return null;
        }
    }
    public String error(int code, String msg) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            return json.toString();
        } catch (Exception e) {
            return null;
        }
    }
}

+ 157 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java

@ -0,0 +1,157 @@
package com.yihu.wlyy.interceptors;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.logs.InterfaceCallLogs;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Date;
/**
 * 患者权限校验
 *
 * @author George
 */
@Component
public class PatientInterceptor extends BaseInterceptor {
    private Logger logger = LoggerFactory.getLogger(PatientInterceptor.class);
    public static String status = "1";
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        if(Flag.close.getValue().equals(status)){
            return true;
        }
        try {
            request.setCharacterEncoding("UTF-8");
            response.setHeader("Content-type", "text/html;charset=UTF-8");
            request.setAttribute("log-start", new Date().getTime());
            if (request.getRequestURI().contains("/patient/hosptail/getHositalByTownCode") || request.getRequestURI().contains("/patient/feedback/saveAppeal")) {
                return true;
            }
            response.setCharacterEncoding("UTF-8");
            JSONObject json = getAgent(request);
            logger.debug("userAgent:" + json);
            if (json == null) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                return false;
            }
            String tokenStr = json.has("token") ? json.getString("token") : "";
            String user = json.has("uid") ? json.getString("uid") : "";
            String imei = json.has("imei") ? json.getString("imei") : "";
            String openid = json.has("openid") ? json.getString("openid") : "";
            int platform = json.has("platform") ? json.getInt("platform") : 1;
            logger.debug("tokenStr:" + tokenStr);
            logger.debug("uid:" + user);
            logger.debug("imei:" + imei);
            logger.debug("openid:" + openid);
            logger.debug("platform:" + platform);
            if (StringUtils.isEmpty(imei)) {
                imei = openid;
            }
            Token token = null;
            if (platform == 3) {
                token = SystemData.patientTokens.get(user);
            }
            if (token == null) {
                token = tokenDao.findByPatient(user, platform);
                // 加入缓存
                if (platform == 3) {
                    SystemData.patientTokens.put(user, token);
                }
            }
            if (token == null || StringUtils.isEmpty(tokenStr) || (token.getPlatform() != 1 && token.getPlatform() != 3)) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                flag = false;
            } else {
                if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(user, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
                    // 别处登录
                    response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes("UTF-8"));
                    flag = false;
                } else {
                    // 一天只更新一次
                    if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
                        // 今天未更新,则更新缓存
                        token.setCzrq(new Date());
                        // 更新内存
                        if (platform == 3) {
                            SystemData.patientTokens.put(user, token);
                        }
                        // 更新数据库
                        tokenDao.save(token);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        if (null == request.getAttribute("log-start")) {
            return;
        }
        long start = (long) request.getAttribute("log-start");
        long end = new Date().getTime();
        Class cls = ((HandlerMethod) handler).getBeanType();
        RequestMapping clsRm = (RequestMapping) cls.getAnnotation(RequestMapping.class);
        Method method = ((HandlerMethod) handler).getMethod();
        RequestMapping mthRm = method.getAnnotation(RequestMapping.class);
        String url = "";
        String urlCls = "";
        String urlMth = "";
        if (clsRm.value() != null && clsRm.value().length > 0) {
            urlCls = clsRm.value()[0];
        }
        if (mthRm.value() != null && mthRm.value().length > 0) {
            urlMth = mthRm.value()[0];
        }
        if (StringUtils.isNotEmpty(urlCls)) {
            url += urlCls.startsWith("/") ? urlCls : ("/" + urlCls);
        }
        if (StringUtils.isNotEmpty(urlMth)) {
            url += urlMth.startsWith("/") ? urlMth : ("/" + urlMth);
        }
        url = url.replace("\\", "/").replace("//", "/");
        JSONObject json = getAgent(request);
        String uid = json.has("uid") ? json.getString("uid") : "";
        InterfaceCallLogs.info(end - start, url, uid, new JSONObject(request.getParameterMap()).toString());
    }
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
    public  String getStatus() {
        return status;
    }
    @Value("${interceptor.patient.status}")
    public  void setStatus(String status) {
        DoctorInterceptor.status = status;
    }
}

+ 59 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/interceptors/UserAgentFilter.java

@ -0,0 +1,59 @@
package com.yihu.wlyy.interceptors;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
 * Created by chenweida on 2017/8/22.
 */
@Component
public class UserAgentFilter implements javax.servlet.Filter {
    private Logger logger= LoggerFactory.getLogger(UserAgentFilter.class);
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        MutableHttpServletRequest mutableRequest = new MutableHttpServletRequest(request);
        String is_switch = request.getParameter("userAgent_is_switch");
        if ("1".equals(is_switch)) {
            String token = request.getParameter("userAgent_token");
            String uid = request.getParameter("userAgent_uid");
            String imei = request.getParameter("userAgent_imei");
            String openid = request.getParameter("userAgent_openid");
            String platform = request.getParameter("userAgent_platform");
            String lastUid = request.getParameter("userAgent_lastUid");
            String represented = request.getParameter("userAgent_represented");
            JSONObject jo = new JSONObject();
            jo.put("token", token);
            jo.put("imei", imei);
            jo.put("openid", openid);
            jo.put("uid", uid);
            jo.put("platform", platform);
            jo.put("lastUid", lastUid);
            jo.put("represented", represented);
            mutableRequest.putHeader("userAgent", jo.toString());
            logger.info("------filter:"+jo.toString());
            chain.doFilter(mutableRequest, response);
        }else{
           // logger.info("------filter:noswitch");
            chain.doFilter(servletRequest, response);
        }
    }
    @Override
    public void destroy() {
    }
}

+ 103 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/logs/BusinessLogs.java

@ -0,0 +1,103 @@
package com.yihu.wlyy.logs;
import com.yihu.wlyy.util.DateUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 业务日志输出
 * <p>
 * Created by lyr-pc on 2017/1/19.
 */
public class BusinessLogs {
    // 日志输出
    private static Logger logger = LoggerFactory.getLogger(BusinessLogs.class);
    /**
     * 业务类型
     */
    public enum BusinessType {
        // 咨询
        consult
        // 指导
        , guidance
        // 健康教育
        , article
        // 随访
        , followup
        // 预约
        , appointment
        // 标签
        , label
        // 注册
        , register
        // 健康档案
        , archive
        // 签约
        , sign
        // 指标
        , index
    }
    /**
     * 业务日志输出
     *
     * @param type 业务类别
     * @param info 日志信息
     */
    public static void info(BusinessType type, String caller,String user, JSONObject info) {
        try {
            JSONObject log = new JSONObject();
            log.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date()));
            log.put("logType", 2);
            log.put("caller", caller);
            JSONObject data = new JSONObject();
            data.put("businessType", type.ordinal());
            data.put("patient", user);
            data.put("data", info);
            log.put("data", data);
            logger.info(log.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 业务日志输出
     *
     * @param type 业务类别
     * @param info 日志信息
     */
    public static void info(BusinessType type,String caller, String user, JSONArray info) {
        try {
            JSONObject log = new JSONObject();
            log.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date()));
            log.put("logType", 2);
            log.put("caller", caller);
            JSONObject data = new JSONObject();
            data.put("businessType", type.ordinal());
            data.put("patient", user);
            data.put("data", info);
            log.put("data", data);
            logger.info(log.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 42 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/logs/InterfaceCallLogs.java

@ -0,0 +1,42 @@
package com.yihu.wlyy.logs;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * Created by lyr-pc on 2017/1/22.
 */
public class InterfaceCallLogs {
    // 日志输出
    private static Logger logger = LoggerFactory.getLogger(InterfaceCallLogs.class);
    /**
     * 接口调用日志输出
     *
     * @param info 日志信息
     */
    public static void info(long time, String url, String user, String info) {
        try {
            JSONObject log = new JSONObject();
            log.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date()));
            log.put("logType", 1);
            log.put("caller", user);
            JSONObject data = new JSONObject();
            data.put("responseTime", time);
            data.put("url", url);
            data.put("params", info);
            log.put("data", data);
            logger.info(log.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 101 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/redis/RedisMsgPubSubListener.java

@ -0,0 +1,101 @@
//package com.yihu.wlyy.redis;
//
//import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
//import com.yihu.wlyy.service.app.prescription.PrescriptionService;
//import com.yihu.wlyy.util.HttpUtil;
//import org.json.JSONObject;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import redis.clients.jedis.JedisPubSub;
//
///**
// * Created by Trick on 2017/8/7.
// */
//@Component
//public class RedisMsgPubSubListener extends JedisPubSub {
//
//    @Autowired
//    private PrescriptionInfoService prescriptionInfoService;
//    @Autowired
//    private PrescriptionService prescriptionService;
//
//    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
//
//    @Override
//    public void unsubscribe() {
//        super.unsubscribe();
//    }
//
//    @Override
//    public void unsubscribe(String... channels) {
//        super.unsubscribe(channels);
//    }
//
//    @Override
//    public void subscribe(String... channels) {
//        super.subscribe(channels);
//    }
//
//    @Override
//    public void psubscribe(String... patterns) {
//        super.psubscribe(patterns);
//    }
//
//    @Override
//    public void punsubscribe() {
//        super.punsubscribe();
//    }
//
//    @Override
//    public void punsubscribe(String... patterns) {
//        super.punsubscribe(patterns);
//    }
//
//    @Override
//    public void onMessage(String channel, String message) {
//        logger.info("redis_onMessage...:"+message);
//        //this.unsubscribe();
//        try{
//            JSONObject json = new JSONObject(message);
//            String title =  json.getString("title");
//            if("redisAddPrescription".equals(title)){
//                logger.info(json.toString());
//                //审核消息发送
//                prescriptionInfoService.onMesSquareState(message);
//            }else if("dispensingComplete".equals(title)){//配药完成
//                //药品配送完成,提醒取药
//                String prescriptionCode = json.getString("prescription");
//                prescriptionService.dispensingComplete(prescriptionCode);
//            }
//        }catch (Exception e){
//            logger.error("redis_error...",e);
//        }
//    }
//
//    @Override
//    public void onPMessage(String pattern, String channel, String message) {
//
//    }
//
//    @Override
//    public void onSubscribe(String channel, int subscribedChannels) {
//        //System.out.println("channel:" + channel + "is been subscribed:" + subscribedChannels);
//    }
//
//    @Override
//    public void onPUnsubscribe(String pattern, int subscribedChannels) {
//
//    }
//
//    @Override
//    public void onPSubscribe(String pattern, int subscribedChannels) {
//
//    }
//
//    @Override
//    public void onUnsubscribe(String channel, int subscribedChannels) {
//        System.out.println("channel:" + channel + "is been unsubscribed:" + subscribedChannels);
//    }
//}

+ 44 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -0,0 +1,44 @@
//package com.yihu.wlyy.redis;
//
//import com.yihu.wlyy.service.app.prescription.PrescriptionService;
//import com.yihu.wlyy.util.SystemConf;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.stereotype.Component;
//
///**
// * Created by Trick on 2017/8/7.
// */
//@Component
//public class RedisThread implements Runnable {
//
//    @Value("${spring.redis.host}")
//    private String url;
//    @Autowired
//    private RedisMsgPubSubListener redisMsgPubSubListener;
//    @Autowired
//    private StringRedisTemplate redisTemplate;
//    @Autowired
//    private PrescriptionService prescriptionService;
//
//    @Override
//    public void run() {
//        String key = SystemConf.getInstance().getSystemProperties().getProperty("redis_prescription_title");
//        while (true){
//            redisTemplate.watch(key);
//            String message = redisTemplate.opsForList().rightPop(key);
//            redisTemplate.unwatch();
//            if(StringUtils.isEmpty(message)){
//                try{
//                    Thread.sleep(1000L);//如果没有读取到记录,等待1秒
//                }catch (Exception e){
//                    e.printStackTrace();
//                }
//            }else {
//                prescriptionService.redisMessage(message);
//            }
//        }
//    }
//}

+ 17 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/VersionsDao.java

@ -0,0 +1,17 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.Versions;
public interface VersionsDao extends PagingAndSortingRepository<Versions, Long>, JpaSpecificationExecutor<Versions> {
	Versions findByCode(String code);
}

+ 20 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/CityDao.java

@ -0,0 +1,20 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.address;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.address.City;
public interface CityDao extends PagingAndSortingRepository<City, Long> {
	// 根據CODE查詢城市名稱
	@Query("select p from City p where p.code = ?1")
	City findByCode(String code);
	
	@Query("select a from City a where a.province = ?1 order by id")
	Iterable<City> findByProvince(String province);
}

+ 17 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/CountryDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.address;
import com.yihu.wlyy.entity.address.Country;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2017/7/20.
 */
public interface CountryDao extends PagingAndSortingRepository<Country, Long> {
    @Query("from Country c where c.street=?1 AND (c.jwCode IS NOT NULL OR c.jwCode <> '')")
    List<Country> findByStreet(String street);
    Country findByCode(String code);
}

+ 17 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/ProvinceDao.java

@ -0,0 +1,17 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.address;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.address.Province;
public interface ProvinceDao extends PagingAndSortingRepository<Province, Long> {
	// 根據CODE查詢省名稱
	@Query("select p from Province p where p.code = ?1")
	Province findByCode(String code);
}

+ 26 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/StreetDao.java

@ -0,0 +1,26 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.address;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.address.Street;
import java.util.List;
public interface StreetDao extends PagingAndSortingRepository<Street, Long> {
	
	// 根據CODE查詢街道名稱
	@Query("select p from Street p where p.code = ?1")
	Street findByCode(String code);
	
	@Query("select a from Street a where a.town = ?1 order by id")
	Iterable<Street> findByTown(String town);
	@Query("select a from Street a where a.town = ?1 order by id")
	List<Street> findListByTown(String town);
}

+ 25 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/address/TownDao.java

@ -0,0 +1,25 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.address;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.address.Town;
import java.util.List;
public interface TownDao extends PagingAndSortingRepository<Town, Long> {
	// 根據CODE查詢區縣名稱
	@Query("select p from Town p where p.code = ?1")
	Town findByCode(String code);
	@Query("select a from Town a where a.city = ?1 order by id")
	Iterable<Town> findByCity(String province);
	@Query("select a from Town a where a.city = ?1 order by id")
	List<Town> findByCityCode(String province);
}

+ 21 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/advert/AdvertDao.java

@ -0,0 +1,21 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.advert;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.advert.Advert;
public interface AdvertDao extends PagingAndSortingRepository<Advert, Long>, JpaSpecificationExecutor<Advert> {
	
	@Query("select a from Advert a where a.type = ?1 and del = '1'")
	Page<Advert> findByType(int type, Pageable pageRequest);
	
}

+ 62 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java

@ -0,0 +1,62 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.charge;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
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;
public interface ChargeDao extends PagingAndSortingRepository<WlyyCharge, Long>, JpaSpecificationExecutor<WlyyCharge> {
    List<WlyyCharge> findByChargeTypeAndChargeRelation(String chargeType, String chargeRelation);
    /**
     * 根据签约code查询缴费成功的流水号
     *
     * @param chargeRelation
     * @return
     */
    @Query("select a from WlyyCharge a where a.chargeRelation = ?1 and a.tradeStatus = '0'")
    WlyyCharge findByChargeRelation(String chargeRelation);
    /**
     * 根据code查询支付情况
     *
     * @param chargeCode
     * @return
     */
    @Query("select a from WlyyCharge a where a.code = ?1 ")
    WlyyCharge findByCode(String chargeCode);
    /**
     * 根据code查询上传状态 为0不需要更改数据
     *
     * @param code
     * @return
     */
    @Query("select a from WlyyCharge a where a.code = ?1 ")
    WlyyCharge getUploadStatus(String code);
    /**
     * 根据code更新wlyy_charge数据
     *
     * @param chargeCode
     * @return
     */
    @Modifying
    @Query("update WlyyCharge a set a.tradeStatus = ?9,a.chargeTime = ?2, a.updateTime = ?3, a.totalAmount = ?4, " +
            " a.insuranceAmount = ?5, a.selfpayAmount =?6 ,a.billNo = ?7, a.miRegisterNo = ?8 where a.code = ?1 ")
    int updateByChargeCode(String chargeCode, String chargeTime, Date updateTime, Integer totalAmount, Integer insuranceAmount, Integer selfPayAmount, String billNo, String miRegisterNo,String tradeStatus);
    List<WlyyCharge> findByPatient(String patient, Pageable pageRequest);
}

+ 48 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultCommunicationDao.java

@ -0,0 +1,48 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.consult;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.ConsultCommunication;
public interface ConsultCommunicationDao extends PagingAndSortingRepository<ConsultCommunication, Long>, JpaSpecificationExecutor<ConsultCommunication> {
	ConsultCommunication findByConsult(String consult);
	// 回复数量+1
	@Modifying
	@Query("update ConsultCommunication a set a.amount = a.amount + 1 where a.consult = ?1")
	int increaseAmount(String consult);
	// 未读数量+1
	@Modifying
	@Query("update ConsultCommunication a set a.unread = a.unread + 1 where a.consult = ?1")
	int increaseUnread(String consult);
	// 清空未读数量
	@Modifying
	@Query("update ConsultCommunication a set a.unread = 0 where a.consult = ?1")
	int clearUnRead(String consult);
	// 患者回答过的病友咨询记录
	@Query("SELECT a FROM ConsultCommunication a, ConsultCommunicationReply b WHERE a.patient <> ?1 and a.del = '1' and a.consult = b.consult and b.patient = ?2 GROUP BY a.consult ORDER BY a.czrq DESC")
	Page<ConsultCommunication> findPatienReplied(String patient, String patient2, Pageable pageRequest);
	@Query("SELECT a FROM ConsultCommunication a, ConsultCommunicationReply b WHERE a.patient <> ?1 and a.del = '1' and a.consult = b.consult and b.patient = ?2 and a.id < ?3 GROUP BY a.consult ORDER BY a.czrq DESC")
	Page<ConsultCommunication> findPatienReplied(String patient, String patient2, long id, Pageable pageRequest);
	
	@Query("SELECT a FROM ConsultCommunication a, ConsultCommunicationReply b WHERE a.patient <> ?1 and a.del = '1' and a.consult = b.consult and b.patient = ?2 and a.disease = ?3 GROUP BY a.consult ORDER BY a.czrq DESC")
	Page<ConsultCommunication> findPatienReplied(String patient, String patient2, String disease, Pageable pageRequest);
	@Query("SELECT a FROM ConsultCommunication a, ConsultCommunicationReply b WHERE a.patient <> ?1 and a.del = '1' and a.consult = b.consult and b.patient = ?2 and a.disease = ?3 and a.id < ?3 GROUP BY a.consult ORDER BY a.czrq DESC")
	Page<ConsultCommunication> findPatienReplied(String patient, String patient2, String disease, long id, Pageable pageRequest);
}

+ 23 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultCommunicationReplyDao.java

@ -0,0 +1,23 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.consult;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.ConsultCommunicationReply;
public interface ConsultCommunicationReplyDao extends PagingAndSortingRepository<ConsultCommunicationReply, Long>, JpaSpecificationExecutor<ConsultCommunicationReply> {
	
	@Query("select a from ConsultCommunicationReply a where a.consult = ?1 and a.del = '1'")
	Page<ConsultCommunicationReply> findReplyListByConsult(String consult, Pageable pageRequest);
	
	@Query("select a from ConsultCommunicationReply a where a.consult = ?1 and a.id < ?2 and a.del = '1'")
	Page<ConsultCommunicationReply> findReplyListByConsult(String consult, long id, Pageable pageRequest);
}

+ 47 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java

@ -0,0 +1,47 @@
package com.yihu.wlyy.repository.consult;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.Consult;
public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, JpaSpecificationExecutor<Consult> {
    Consult findByCode(String code);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type<>8 and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1' and a.type<>8 and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, long id, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type<>8 order by a.czrq desc")
    Page<Object> findByPatient(String patient, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1' and a.type<>8 order by a.czrq desc")
    Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
    @Query("select count(a) from Consult a,ConsultTeamDoctor b  where a.code = b.consult and a.patient=?1 and b.to=?2 and b.from is null")
    Integer findByPatient(String patientCode, String doctorCode);
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.adminTeamId,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and b.adminTeamId = ?2 and a.del = '1' order by a.czrq desc")
    Page<Object> findByPatientAndTeam(String patient, Long team, Pageable pageRequest);
    //获取咨询的状态
    @Query("select a from Consult a,ConsultTeam b where a.code = b.consult and a.code = ?1 ")
    Consult findTypeByCode(String code);
    // 按类型查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.evaluate,a.relationCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type=?2 order by a.czrq desc")
    Page<Object> findByPatientAndType(String patient,Integer type, Pageable pageRequest);
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.evaluate,a.relationCode from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type=?3 and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatientAndType(String patient, String title,Integer type, Pageable pageRequest);
}

+ 59 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultMoViDao.java

@ -0,0 +1,59 @@
package com.yihu.wlyy.repository.consult;
import java.util.Date;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.ConsultMoVi;
import com.yihu.wlyy.entity.doctor.profile.DoctorComment;
public interface ConsultMoViDao extends PagingAndSortingRepository<ConsultMoVi, Long>, JpaSpecificationExecutor<ConsultMoVi> {
	// 根據consult查詢咨询记录
	ConsultMoVi findByConsult(String consult);
	// 查询医生预约列表
	@Query("select a from ConsultMoVi a, ConsultMoViReferral b where a.consult = b.consult and b.to = ?1 and a.type = ?2 and b.talkTime = 0 and a.del = '1'")
	Page<ConsultMoVi> findByDoctor(String doctor, int type, Pageable pageRequest);
	
	@Query("select a from ConsultMoVi a, ConsultMoViReferral b where a.consult = b.consult and b.to = ?1 and a.type = ?2 and a.appoDate < ?3 and b.talkTime = 0 and a.del = '1'")
	Page<ConsultMoVi> findByDoctor(String doctor, int type, Date appoDate, Pageable pageRequest);
	// 查询医生处理过记录列表
	@Query("select a from ConsultMoVi a, ConsultMoViReferral b where a.consult = b.consult and b.to = ?1 and a.type = ?2 and b.talkTime > 0 and a.del = '1'")
	Page<ConsultMoVi> findDoneByDoctor(String doctor, int type, Pageable pageRequest);
	
	@Query("select a from ConsultMoVi a, ConsultMoViReferral b where a.consult = b.consult and b.to = ?1 and a.type = ?2 and a.appoDate < ?3 and b.talkTime > 0 and a.del = '1'")
	Page<ConsultMoVi> findDoneByDoctor(String doctor, int type, Date appoDate, Pageable pageRequest);
	// 查询患者预约列表
	@Query("select a from ConsultMoVi a where a.patient = ?1 and a.type = ?2 and a.status = 0 and del = '1'")
	Page<ConsultMoVi> findByPatient(String patient, int type, Pageable pageRequest);
	// 查询患者已完成记录列表
	@Query("select a from ConsultMoVi a where a.patient = ?1 and a.type = ?2 and a.status <> 0 and del = '1'")
	Page<ConsultMoVi> findDoneByPatient(String patient, int type, Pageable pageRequest);
	// 按患者查询列表
	@Query("select a from ConsultMoVi a where a.patient = ?1 and del = '1'")
	Page<ConsultMoVi> findByPatient(String patient, Pageable pageRequest);
	// 按患者查询列表
	@Query("select a from ConsultMoVi a where a.patient = ?1 and a.appoDate < ?2 and del = '1'")
	Page<ConsultMoVi> findByPatient(String patient, Date appoDate, Pageable pageRequest);
	// 更新患者评价
	@Modifying
	@Query("update ConsultMoVi a set a.comment = ?1 where a.consult = ?2")
	int updateComment(DoctorComment comment, String consult);
	// 更新咨询状态
	@Modifying
	@Query("update ConsultMoVi a set a.status = ?1 where a.consult = ?2")
	int updateStatus(int status, String consult);
}

+ 17 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultMoViReferralDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.consult;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.ConsultMoViReferral;
public interface ConsultMoViReferralDao extends PagingAndSortingRepository<ConsultMoViReferral, Long>, JpaSpecificationExecutor<ConsultMoViReferral> {
	
	@Query("select a from ConsultMoViReferral a where a.to = ?1 and a.consult = ?2")
	ConsultMoViReferral findDoctorReferral(String doctor, String consult);
	
	//查询最后处理的医生标识
	@Query("select a.to from ConsultMoViReferral a where a.consult = ?1 and a.flag = 0")
	String findToDoctor(String consult);
}

+ 49 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultPublicDao.java

@ -0,0 +1,49 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.consult;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.ConsultPublic;
public interface ConsultPublicDao extends PagingAndSortingRepository<ConsultPublic, Long>, JpaSpecificationExecutor<ConsultPublic> {
	ConsultPublic findByConsult(String consult);
	// 回复数量+1
	@Modifying
	@Query("update ConsultPublic a set a.amount = a.amount + 1 where a.consult = ?1")
	int increaseAmount(String consult);
	// 患者未读数量+1
	@Modifying
	@Query("update ConsultPublic a set a.unread = a.unread + 1 where a.consult = ?1")
	int increaseUnread(String consult);
	// 清空未读数量
	@Modifying
	@Query("update ConsultPublic a set a.unread = 0 where a.consult = ?1")
	int clearUnread(String consult);
	// 查询医生回答过的公共咨询记录
	@Query("SELECT a FROM ConsultPublic a, ConsultPublicReply b WHERE a.del = '1' and a.consult = b.consult and b.doctor = ?1 GROUP BY a.consult ORDER BY a.czrq DESC")
	Page<ConsultPublic> findRepliedPublicQuestionByDoctor(String doctor, Pageable pageRequest);
	@Query("SELECT a FROM ConsultPublic a, ConsultPublicReply b WHERE a.del = '1' and a.consult = b.consult and b.doctor = ?1 and a.id < ?2 GROUP BY a.consult ORDER BY a.czrq DESC")
	Page<ConsultPublic> findRepliedPublicQuestionByDoctor(String doctor, long id, Pageable pageRequest);
	
	@Query("SELECT a FROM ConsultPublic a, ConsultPublicReply b WHERE a.del = '1' and a.consult = b.consult and b.doctor = ?1 and a.disease = ?2 GROUP BY a.consult ORDER BY a.czrq DESC")
	Page<ConsultPublic> findRepliedPublicQuestionByDoctor(String doctor, String disease, Pageable pageRequest);
	@Query("SELECT a FROM ConsultPublic a, ConsultPublicReply b WHERE a.del = '1' and a.consult = b.consult and b.doctor = ?1 and a.disease = ?2 and a.id < ?3 GROUP BY a.consult ORDER BY a.czrq DESC")
	Page<ConsultPublic> findRepliedPublicQuestionByDoctor(String doctor, String disease, long id, Pageable pageRequest);
}

+ 15 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultPublicReplyDao.java

@ -0,0 +1,15 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.consult;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.ConsultPublicReply;
public interface ConsultPublicReplyDao extends PagingAndSortingRepository<ConsultPublicReply, Long>, JpaSpecificationExecutor<ConsultPublicReply> {
	
}

+ 296 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java

@ -0,0 +1,296 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.consult;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.jaxb.PageAdapter;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import java.util.List;
public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam, Long>, JpaSpecificationExecutor<ConsultTeam> {
	// 根據consult查詢咨询记录
	ConsultTeam findByConsult(String consult);
	@Query("select a from ConsultTeam a where a.patient = ?1 and a.del = '1' and a.status = 0")
	List<ConsultTeam> findUnfinishedConsult(String patient);
	@Query("select a from ConsultTeam a,ConsultTeamDoctor b where a.consult = b.consult and a.patient = ?1 and b.to = ?2 and a.del = '1' and a.type<>8 and a.status = 0")
	List<ConsultTeam> findUnfinishedConsultType(String patient,String doctor);
	// 统计未完成的数量
	@Query("select count(1) from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.patient = ?1 and a.status = 0 and a.del = '1'and b.to=?2")
	int countByPatient(String patient,String doctor);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and b.from is null")
	Page<ConsultTeam> findDoctorList(String doctor, Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.id < ?2 and b.from is null")
	Page<ConsultTeam> findDoctorList(String doctor, long id, Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.patient = ?2 and b.to = ?1 and b.from is null")
	Page<ConsultTeam> findDoctorPatientList(String doctor,String patient,  Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.patient = ?2 and b.to = ?1 and a.id < ?3  and b.from is null")
	Page<ConsultTeam> findDoctorPatientList(String doctor,String patient, long id, Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.status = 0 and a.del = '1' and b.del = '1' and a.type<3 and b.from is null")
	Page<ConsultTeam> findDoctorPointList(String doctor, Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.id < ?2 and a.status = 0 and a.del = '1' and b.del = '1' and a.type<3 and b.from is null")
	Page<ConsultTeam> findDoctorPointList(String doctor, long id, Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.id < ?2 and a.status = 0 and a.del = '1' and b.del = '1' and (a.type = 1 or a.type = 2 or a.type = 6) ")
	Page<ConsultTeam> findDoctorAllList(String doctor, long id, Pageable pageRequest);
	// 被指定且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.status = 0 and a.del = '1' and b.del = '1' and (a.type = 1 or a.type = 2 or a.type = 6) ")
	Page<ConsultTeam> findDoctorAllList(String doctor, Pageable pageRequest);
	// 医生参与且未结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.status = 0 and b.reply = 1 and a.del = '1' and b.del = '1' and a.type<3 and b.from is null")
	Page<ConsultTeam> findDoctorJoinList(String doctor, Pageable pageRequest);
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.id < ?2 and a.status = 0 and b.reply = 1 and a.del = '1' and b.del = '1' and a.type<3 and b.from is null")
	Page<ConsultTeam> findDoctorJoinList(String doctor, long id, Pageable pageRequest);
	// 医生参与并已结束列表
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.status = 1 and a.del = '1' and b.del = '1' and a.type<3 and b.from is null")
	Page<ConsultTeam> findDoctorFinishList(String doctor, Pageable pageRequest);
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and b.to = ?1 and a.id < ?2 and a.status = 1 and a.del = '1' and b.del = '1' and a.type<3  and b.from is null")
	Page<ConsultTeam> findDoctorFinishList(String doctor, long id, Pageable pageRequest);
	// 医生关闭三师咨询
	@Modifying
	@Query("update ConsultTeam a set a.status = 1 where a.consult = ?1")
	int updateStatusByConsult(String consult);
	/**
	 * 解约时结束家庭咨询
	 * @param patient
	 * @return
	 */
	@Modifying
	@Query("update ConsultTeam a set a.status = 1 where a.patient =?1 and a.type = 2")
	int updateStatusByPatient(String patient);
	// 取消三师咨询
	@Modifying
	@Query("update ConsultTeam a set a.status = -1 where a.consult = ?1 and a.status <> 1")
	int cancel(String consult);
	// 患者咨询列表(未结束)
	@Query("select a from ConsultTeam a where a.patient = ?1 and a.status=0 and del = '1'")
	Page<ConsultTeam> findNotFinishedBypatient(String patient, Pageable pageRequest);
	@Query("select a from ConsultTeam a where a.patient = ?1 and a.id < ?2 and a.status=0 and del = '1' and a.type<>8")
	Page<ConsultTeam> findNotFinishedBypatient(String patient, long id, Pageable pageRequest);
	// 患者咨询列表(已结束)
	@Query("select a from ConsultTeam a where a.patient=?1 and a.status=1 and del = '1' and a.type<>8")
	Page<ConsultTeam> findFinishedBypatient(String patient, Pageable pageRequest);
	@Query("select a from ConsultTeam a where a.patient=?1 and a.id < ?2 and a.status=1 and del = '1' and a.type<>8")
	Page<ConsultTeam> findFinishedBypatient(String patient, long id, Pageable pageRequest);
	// 患者咨询列表(已取消)
	@Query("select a from ConsultTeam a where a.patient=?1 and a.status=-1 and del = '1' and a.type<>8")
	Page<ConsultTeam> findCancelBypatient(String patient, Pageable pageRequest);
	@Query("select a from ConsultTeam a where a.patient=?1 and a.id < ?2 and a.status=-1 and del = '1' and a.type<>8")
	Page<ConsultTeam> findCancelBypatient(String patient, long id, Pageable pageRequest);
	// 医生未读数量+1
	@Modifying
	@Query("update ConsultTeam a set a.doctorRead = a.doctorRead + 1 where a.consult = ?1")
	int increaseDoctorRead(String consult);
	// 患者未读数量+1
	@Modifying
	@Query("update ConsultTeam a set a.patientRead = a.patientRead + 1 where a.consult = ?1")
	int increasePatientRead(String consult);
	// 清空医生未读数量
	@Modifying
	@Query("update ConsultTeam a set a.doctorRead = 0 where a.consult = ?1")
	int clearDoctorRead(String consult);
	// 清空患者未读数量
	@Modifying
	@Query("update ConsultTeam a set a.patientRead = 0 where a.consult = ?1")
	int clearPatientRead(String consult);
	// 更新患者评价标识
	@Modifying
	@Query("update ConsultTeam a set a.commentContent = ?2, a.commentStar = ?3 where a.consult = ?4")
	int updateComment(String commentContent, double commentStar, String consult);
	// 查询医生所有未读的消息总数
	@Query("SELECT SUM(a.doctorRead) FROM ConsultTeam a, ConsultTeamDoctor b WHERE a.consult = b.consult AND b.to = ?1 AND a.del = '1' AND a.status = 0 AND a.type <> 6")
	int amountAllDoctorUnread(String doctor);
	// 查询医生所有未读的消息总数
	@Query("SELECT SUM(a.doctorRead) FROM ConsultTeam a, ConsultTeamDoctor b WHERE a.consult = b.consult AND b.to = ?1 AND a.del = '1' AND a.status = 0 AND a.type = 6")
	int amountAlFamouslDoctorUnread(String doctor);
	// 查询医生所有未读的消息总数
	@Query("SELECT a.name,b.czrq FROM ConsultTeam a, ConsultTeamDoctor b WHERE a.consult = b.consult AND b.to = ?1 AND a.del = '1' AND a.status = 0 AND a.type <> 6 order by b.czrq desc")
	Page<Object> AllDoctorUnreadLast(String doctor,Pageable pageRequest);
	// 查询医生所有未读的消息总数
	@Query("SELECT a.name,b.czrq FROM ConsultTeam a, ConsultTeamDoctor b WHERE a.consult = b.consult AND b.to = ?1 AND a.del = '1' AND a.status = 0 AND a.type = 6 order by b.czrq desc")
	Page<Object> AllDoctorFamousUnreadLast(String doctor,Pageable pageRequest);
	// 查询带未读数量的所有健康咨询列表
	@Query("SELECT a FROM ConsultTeam a, ConsultTeamDoctor b WHERE a.consult = b.consult AND b.to = ?1 AND a.status = 0 and a.type< 3")
	Page<ConsultTeam> findListByUnreadDoctor(String doctor, Pageable pageRequest);
	// 查询带未读数量的所有健康咨询列表
	@Query("SELECT a FROM ConsultTeam a, ConsultTeamDoctor b WHERE a.consult = b.consult AND b.to = ?1 and a.id < ?2 AND a.status = 0 and a.type<3")
	Page<ConsultTeam> findListByUnreadDoctor(String doctor, long id, Pageable pageRequest);
	//找出当日的咨询量
	@Query("SELECT a FROM ConsultTeam a WHERE a.type=2 and unix_timestamp(a.czrq)>=unix_timestamp(?1) and unix_timestamp(a.czrq)<unix_timestamp(?2) ")
	List<ConsultTeam> findByCzrqyYesterday(String yesterday,String now);
	//查找
	@Query("SELECT a FROM ConsultTeam a WHERE a.patient=?1 and a.doctor = ?2 and a.status=0 and a.del=1 and a.type=6")
	ConsultTeam findFamousConsultByPatient(String uid,String doctor);
	//名医咨询 -全部
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and b.to = ?1 and a.id < ?2 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorAllList(String uid, long id, Pageable pageRequest);
	//名医咨询 -全部
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and b.to = ?1  and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorAllList(String uid, Pageable pageRequest);
	//名医咨询 -全部 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and b.to = ?1 and a.id < ?2 and a.symptoms like ?3 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorAllList(String uid, long id,String title, Pageable pageRequest);
	//名医咨询 -全部 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and b.to = ?1 and a.symptoms like ?2  and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorAllList(String uid,String title, Pageable pageRequest);
	//名医咨询 -根据status
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and b.to = ?1 and a.id < ?2 and a.status = ?3 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid, long id,Integer type, Pageable pageRequest);
	//名医咨询 -根据status
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 )and b.to = ?1 and a.status = ?2  and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid,Integer type, Pageable pageRequest);
	//名医咨询 -根据status 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and b.to = ?1 and a.id < ?2 and a.symptoms like ?3 and a.status = ?4 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid, long id,String title,Integer type, Pageable pageRequest);
	//名医咨询 -根据status 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 )and b.to = ?1 and a.symptoms like ?2 and a.status = ?3 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid,String title,Integer type, Pageable pageRequest);
	@Query("select a from ConsultTeam a where  a.type=?3  and a.del = '1' and a.patient=?1 and a.doctor=?2 and  a.status=0 ")
	ConsultTeam findByParientCodeAndSignTypeAndDoctor(String patientCode, String doctor, int s);
	//名医咨询 -全部 带symptoms 未处理、未回复
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.id < ?2 and a.symptoms like ?3 and a.status = 0 and (a.doctorRead > 0 or b.reply <> 1) and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorUnReplyReadList(String uid, long id,String title, Pageable pageRequest);
	//名医咨询 -全部 带symptoms 处理、未回复
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.symptoms like ?2 and a.status = 0 and (a.doctorRead > 0 or b.reply <> 1) and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorUnReplyReadList(String uid,String title, Pageable pageRequest);
	//名医咨询 -全部 处理、未回复
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.id < ?2 and a.status = 0 and (a.doctorRead > 0 or b.reply <> 1) and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorUnReplyReadNoTitleList(String uid, long id, Pageable pageRequest);
	//三师家庭咨询 -全部
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type= 1 or a.type = 2) and b.to = ?1 and a.status = 0 and (a.doctorRead > 0 or b.reply <> 1) and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findDoctorUnReplyReadNoTitleList(String uid, Pageable pageRequest);
	//三师家庭咨询 -全部 处理、未回复
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type= 1 or a.type = 2) and b.to = ?1 and a.id < ?2 and a.status = 0 and (a.doctorRead > 0 or b.reply <> 1) and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findDoctorUnReplyReadNoTitleList(String uid, long id, Pageable pageRequest);
	//名医咨询 -全部
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.status = 0 and (a.doctorRead > 0 or b.reply <> 1) and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findFamousDoctorUnReplyReadNoTitleList(String uid, Pageable pageRequest);
	//名医咨询 -全部 带symptoms 进行中
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.id < ?2 and a.symptoms like ?3 and a.status = 0 and b.reply = 1 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorIngList(String uid, long id,String title, Pageable pageRequest);
	//名医咨询 -全部 带symptoms 进行中
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.symptoms like ?2 and a.status = 0 and  b.reply = 1 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorIngList(String uid,String title, Pageable pageRequest);
	//名医咨询 -全部 进行中
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.id < ?2 and a.status = 0 and  b.reply = 1 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorIngNoTitleList(String uid, long id, Pageable pageRequest);
	//名医咨询 -全部 进行中
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.status = 0 and b.reply = 1 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorIngNoTitleList(String uid, Pageable pageRequest);
	//三师家庭咨询 -全部 进行中
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type= 1 or a.type = 2) and b.to = ?1 and a.id < ?2 and a.status = 0 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findDoctorIngNoTitleList(String uid, long id, Pageable pageRequest);
	//三师家庭咨询 -全部 进行中
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type= 1 or a.type = 2) and b.to = ?1 and a.status = 0 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findDoctorIngNoTitleList(String uid, Pageable pageRequest);
    // 更新超过24小时未回复的项目,多加一分钟,防止过于频繁更新
    @Modifying
    @Query("UPDATE ConsultTeam a set a.status = -2 where TIMESTAMPDIFF(SECOND, a.czrq, CURRENT_TIME) > 87840 and status = 0")
    void updateUnresponsedConsultOver24Hours();
    // 最近24小时内未回复的项目
    @Query("FROM ConsultTeam a where TIMESTAMPDIFF(SECOND, a.czrq, CURRENT_TIME) < 86400 and a.status = 0 order by a.czrq desc")
    Page<ConsultTeam> getUnresponsedConsultIn24Hours(Pageable pageable);
	@Query("FROM ConsultTeam a where a.type=?1 and a.adminTeamId is null")
	List<ConsultTeam> findByTypeAndAdminTeamIdIsNull(Integer s);
	//名医咨询 -我咨询的全部 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and a.patient = ?1 and a.id < ?2 and a.symptoms like ?3 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findMyFamousDoctorAllList(String uid, long id, String title, Pageable pageRequest);
	//名医咨询 -我咨询的全部 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and a.patient = ?1 and a.symptoms like ?2 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findMyFamousDoctorAllList(String uid, String title, Pageable pageRequest);
	//名医咨询 -我咨询的全部 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and a.patient = ?1 and a.id < ?2 and  a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findMyFamousDoctorAllList(String uid, Long id, Pageable pageRequest);
	//名医咨询 -我咨询的全部 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and a.patient = ?1  and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findMyFamousDoctorAllList(String uid, Pageable pageRequest);
	//名医咨询 -我咨询的 带symptoms 根据status
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and a.patient = ?1 and a.status=?2 and a.id < ?3 and a.symptoms like ?4 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findMyFamousDoctorListByStatus(String uid, int status, long id, String title, Pageable pageRequest);
	//名医咨询 -我咨询的 带symptoms 根据status
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and a.patient = ?1 and a.status=?2  and a.symptoms like ?3 and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findMyFamousDoctorListByStatus(String uid, int status, String title, Pageable pageRequest);
	//名医咨询 -我咨询的 带symptoms根据status
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and a.patient = ?1 and a.status=?2  and a.id < ?3 and  a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findMyFamousDoctorListByStatus(String uid, int status, long id, Pageable pageRequest);
	//名医咨询 -我咨询的 带symptoms根据status
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and (a.type=6 or a.type=7 ) and a.patient = ?1 and a.status=?2  and a.del = '1' and b.del = '1' and b.from is null")
	Page<ConsultTeam> findMyFamousDoctorListByStatus(String uid, int status, Pageable pageRequest);
	@Query("select a from ConsultTeam a where ((a.patient = ?1 and a.doctor = ?2) or (a.patient = ?2 and a.doctor = ?1))  and a.del = '1' and a.status = 0 order by id desc ")
	List<ConsultTeam> findUnfinishedConsult(String patient,String doctor);
	@Query("select a.doctor from ConsultTeam a where team = ?1  and del = '1' and type=?2 ")
	List<Object> findByTeamAndType(String fromConsult, int type);
}

+ 38 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDoctorDao.java

@ -0,0 +1,38 @@
package com.yihu.wlyy.repository.consult;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.ConsultTeamDoctor;
public interface ConsultTeamDoctorDao extends PagingAndSortingRepository<ConsultTeamDoctor, Long>, JpaSpecificationExecutor<ConsultTeamDoctor> {
	@Query("select count(1) from ConsultTeamDoctor a where a.consult = ?1 and a.to = ?2")
	int isExist(String consult, String doctor);
	@Query("select count(1) from ConsultTeamDoctor a,ConsultTeam t where t.consult = a.consult and t.type = ?1 and a.to = ?2")
	int countByDoctorAndType(int type,String doctor);
	// 更新为有回复
	@Modifying
	@Query("update ConsultTeamDoctor a set a.reply = 1 where a.consult = ?1 and a.to = ?2")
	int updateReply(String consult, String doctor);
	@Query("select a from ConsultTeamDoctor a where a.consult = ?1 and a.del = '1'")
	Iterable<ConsultTeamDoctor> findByConsult(String consult);
	// 查询有回复过的医生
	@Query("select a.to from ConsultTeamDoctor a where a.consult = ?1 and a.reply = 1 and a.del = '1'")
	String[] findReplyDoctor(String consult);
	@Query("select count(a) from ConsultTeamDoctor a where a.to = ?1 and a.del = '1'")
	long getAllCountByDoctorCode(String doctorCode);
	
	@Query("select count(a) from ConsultTeamDoctor a where a.to = ?1 and a.del = '1' and date(a.czrq) = curdate() ")
	long getTodayCountByDoctorCode(String doctorCode);
	@Query(" from ConsultTeamDoctor a where a.consult=?1 and a.to = ?2 and a.del = '1' ")
	ConsultTeamDoctor getByConsultCodeAndDoctorCode(String consultCode, String code);
}

+ 22 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamLogDao.java

@ -0,0 +1,22 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.consult;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.consult.ConsultTeamLog;
import java.util.List;
public interface ConsultTeamLogDao extends PagingAndSortingRepository<ConsultTeamLog, Long>, JpaSpecificationExecutor<ConsultTeamLog> {
    int countByConsult(String consult);
    @Query(" from ConsultTeamLog a where a.consult = ?1 ")
    List<ConsultTeamLog> getConsultLogByConsultLog(String consultCode);
}

+ 43 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/EvaluateDao.java

@ -0,0 +1,43 @@
package com.yihu.wlyy.repository.consult;
import com.yihu.wlyy.entity.consult.Evaluate;
import org.springframework.beans.factory.annotation.Autowired;
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 卓 on 2017/5/10.
 */
public interface EvaluateDao extends PagingAndSortingRepository<Evaluate, Long>, JpaSpecificationExecutor<Evaluate> {
    /**
     * 获取某个咨询的评分
     * @param consult
     * @return
     */
    List<Evaluate> findByConsult(String consult);
    /**
     * 根据咨询获取实名或者匿名评分
     * @param consult
     * @return
     */
    List<Evaluate> findByConsultAndType(String consult,int type);
    /**
     * 根据医生获取实名或者匿名评分
     * @param doctor
     * @return
     */
    List<Evaluate> findByDoctorAndType(String doctor,int type);
    /**
     * 查找所有分数为零的接口
     */
    @Query("select a from Evaluate a where a.score =0")
    List<Evaluate> findByScoreZero();
}

+ 28 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/EvaluateLabelDao.java

@ -0,0 +1,28 @@
package com.yihu.wlyy.repository.consult;
import com.yihu.wlyy.entity.consult.EvaluateLabel;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by 卓 on 2017/5/10.
 */
public interface EvaluateLabelDao extends PagingAndSortingRepository<EvaluateLabel, Long>, JpaSpecificationExecutor<EvaluateLabel> {
    /**
     * 获取某个咨询的标签
     * @param consult
     * @return
     */
    List<EvaluateLabel> findByConsult(String consult);
    /**
     * 获取某个医生的标签
     * @param doctor
     * @return
     */
    List<EvaluateLabel> findByDoctor(String doctor);
}

+ 26 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/consult/EvaluateScoreDao.java

@ -0,0 +1,26 @@
package com.yihu.wlyy.repository.consult;
import com.yihu.wlyy.entity.consult.Evaluate;
import com.yihu.wlyy.entity.consult.EvaluateScore;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by 卓 on 2017/5/10.
 */
public interface EvaluateScoreDao extends PagingAndSortingRepository<EvaluateScore, Long>, JpaSpecificationExecutor<EvaluateScore> {
    int countEvaluateScoreByDoctor(String doctor);
    /**
     * 获取某个咨询的评分
     * @param consult
     * @return
     */
    List<EvaluateScore> findByConsult(String consult);
    List<EvaluateScore> findByConsultAndDoctor(String consult,String doctor);
}

+ 19 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/demographic/ResidenceInfoDao.java

@ -0,0 +1,19 @@
package com.yihu.wlyy.repository.demographic;
import com.yihu.wlyy.entity.demographic.ResidenceInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 户口信息DAO。
 */
public interface ResidenceInfoDao extends PagingAndSortingRepository<ResidenceInfo, Long>, JpaSpecificationExecutor<ResidenceInfo> {
    @Query(" FROM ResidenceInfo a WHERE a.personid=?1 ")
    List<ResidenceInfo> findByPersonId(Integer personid);
    @Query(" FROM ResidenceInfo a WHERE a.familystateid=?1 ")
    List<ResidenceInfo> findByFamilyId(Integer familyinfoid);
}

+ 14 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/demographic/TblBasicDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.demographic;
import com.yihu.wlyy.entity.demographic.DemographicInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2016.08.20.
 */
public interface TblBasicDao extends PagingAndSortingRepository<DemographicInfo, Integer>, JpaSpecificationExecutor<DemographicInfo> {
    @Query(" from DemographicInfo a  where a.cardid = ?1 and a.state='1'")
    DemographicInfo findByIdCard(String idcard);
}

+ 11 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/demographic/TblFamilyDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.repository.demographic;
import com.yihu.wlyy.entity.demographic.FamilyInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2016.08.20.
 */
public interface TblFamilyDao extends PagingAndSortingRepository<FamilyInfo, Long>, JpaSpecificationExecutor<FamilyInfo> {
}

+ 17 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/demographic/TblsysParamDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.demographic;
import com.yihu.wlyy.entity.dict.FoundationMedicalSystemParam;
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 Administrator on 2016.08.20.
 */
public interface TblsysParamDao extends PagingAndSortingRepository<FoundationMedicalSystemParam, Long>, JpaSpecificationExecutor<FoundationMedicalSystemParam> {
    @Query(" FROM FoundationMedicalSystemParam a WHERE a.paramname=?1 ")
    List<FoundationMedicalSystemParam> findByParamname(String relaholder);
}

+ 21 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/deviece/DeviceCategoryDao.java

@ -0,0 +1,21 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.deviece;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.device.DeviceCategory;
import java.util.List;
public interface DeviceCategoryDao extends PagingAndSortingRepository<DeviceCategory, Long> {
	@Query("select a from DeviceCategory a where a.del = '1'")
	List<DeviceCategory> findAll();
	@Query("select a from DeviceCategory a where a.code = ?1 and  a.del = '1'")
	DeviceCategory findByCode(String code);
}

+ 21 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/deviece/DeviceDao.java

@ -0,0 +1,21 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.deviece;
import com.yihu.wlyy.entity.device.Device;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface DeviceDao extends PagingAndSortingRepository<Device, Long> {
	@Query("select a from Device a where a.categoryCode = ?1 and a.del = '1'")
	List<Device> findByCategoryCode(String categoryCode);
	@Query("select a from Device a where a.del = '1'")
	List<Device> findAll();
}

+ 0 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/repository/deviece/PatientBloodSuggerDao.java


Some files were not shown because too many files changed in this diff