Browse Source

first commit

wangweiqun 6 years ago
commit
ab3772fc8b
100 changed files with 12502 additions and 0 deletions
  1. 1159 0
      ehr-cloud/pom.xml
  2. 606 0
      ehr-ms-parent-pom/pom.xml
  3. 127 0
      pom.xml
  4. 33 0
      src/main/java/com/yihu/ehr/ResourceSvrApp.java
  5. 38 0
      src/main/java/com/yihu/ehr/resource/client/QuotaStatisticsClient.java
  6. 36 0
      src/main/java/com/yihu/ehr/resource/client/StdTransformClient.java
  7. 27 0
      src/main/java/com/yihu/ehr/resource/config/TenantConfiguration.java
  8. 175 0
      src/main/java/com/yihu/ehr/resource/controller/HbaseDataEndPoint.java
  9. 378 0
      src/main/java/com/yihu/ehr/resource/controller/ResourceBrowseEndPoint.java
  10. 1087 0
      src/main/java/com/yihu/ehr/resource/controller/ResourceCenterEndPoint.java
  11. 247 0
      src/main/java/com/yihu/ehr/resource/controller/ResourceIntegratedEndPoint.java
  12. 78 0
      src/main/java/com/yihu/ehr/resource/controller/ResourceTransformEndPoint.java
  13. 203 0
      src/main/java/com/yihu/ehr/resource/controller/RsAdapterDictionaryEndPoint.java
  14. 134 0
      src/main/java/com/yihu/ehr/resource/controller/RsAdapterMetaDataEndPoint.java
  15. 117 0
      src/main/java/com/yihu/ehr/resource/controller/RsAdapterSchemeEndPoint.java
  16. 177 0
      src/main/java/com/yihu/ehr/resource/controller/RsDictionaryEndPoint.java
  17. 139 0
      src/main/java/com/yihu/ehr/resource/controller/RsDictionaryEntryEndPoint.java
  18. 110 0
      src/main/java/com/yihu/ehr/resource/controller/RsDimensionCategoryEndPoint.java
  19. 111 0
      src/main/java/com/yihu/ehr/resource/controller/RsDimensionEndPoint.java
  20. 112 0
      src/main/java/com/yihu/ehr/resource/controller/RsInterfaceEndPoint.java
  21. 176 0
      src/main/java/com/yihu/ehr/resource/controller/RsMetadataEndPoint.java
  22. 75 0
      src/main/java/com/yihu/ehr/resource/controller/RsReportCategoryAppEndPoint.java
  23. 178 0
      src/main/java/com/yihu/ehr/resource/controller/RsReportCategoryEndPoint.java
  24. 220 0
      src/main/java/com/yihu/ehr/resource/controller/RsReportEndPoint.java
  25. 68 0
      src/main/java/com/yihu/ehr/resource/controller/RsReportUsersEndPoint.java
  26. 99 0
      src/main/java/com/yihu/ehr/resource/controller/RsReportViewEndPoint.java
  27. 186 0
      src/main/java/com/yihu/ehr/resource/controller/RsResourceCategoryEndPoint.java
  28. 122 0
      src/main/java/com/yihu/ehr/resource/controller/RsResourceDefaultParamsEndPoint.java
  29. 40 0
      src/main/java/com/yihu/ehr/resource/controller/RsResourceDefaultQueryEndPoint.java
  30. 201 0
      src/main/java/com/yihu/ehr/resource/controller/RsResourceEndPoint.java
  31. 1000 0
      src/main/java/com/yihu/ehr/resource/controller/RsResourceGrantEndPoint.java
  32. 153 0
      src/main/java/com/yihu/ehr/resource/controller/RsResourceMetadataEndPoint.java
  33. 129 0
      src/main/java/com/yihu/ehr/resource/controller/RsResourceMonitorTypeEndPoint.java
  34. 191 0
      src/main/java/com/yihu/ehr/resource/controller/RsResourceQuotaEndPoint.java
  35. 112 0
      src/main/java/com/yihu/ehr/resource/controller/RsSystemDictionaryEndPoint.java
  36. 100 0
      src/main/java/com/yihu/ehr/resource/controller/RsSystemDictionaryEntryEndPoint.java
  37. 99 0
      src/main/java/com/yihu/ehr/resource/controller/SolrSchemaEndPoint.java
  38. 19 0
      src/main/java/com/yihu/ehr/resource/dao/PortalMessageRemindDao.java
  39. 17 0
      src/main/java/com/yihu/ehr/resource/dao/PortalMessageTemplateDao.java
  40. 1016 0
      src/main/java/com/yihu/ehr/resource/dao/ResourceBrowseDao.java
  41. 79 0
      src/main/java/com/yihu/ehr/resource/dao/ResourceBrowseMetadataDao.java
  42. 21 0
      src/main/java/com/yihu/ehr/resource/dao/RsAdapterDictionaryDao.java
  43. 27 0
      src/main/java/com/yihu/ehr/resource/dao/RsAdapterMetadataDao.java
  44. 13 0
      src/main/java/com/yihu/ehr/resource/dao/RsAdapterSchemeDao.java
  45. 26 0
      src/main/java/com/yihu/ehr/resource/dao/RsAppResourceDao.java
  46. 18 0
      src/main/java/com/yihu/ehr/resource/dao/RsAppResourceMetadataDao.java
  47. 14 0
      src/main/java/com/yihu/ehr/resource/dao/RsDictionaryDao.java
  48. 20 0
      src/main/java/com/yihu/ehr/resource/dao/RsDictionaryEntryDao.java
  49. 11 0
      src/main/java/com/yihu/ehr/resource/dao/RsDimensionCategoryDao.java
  50. 13 0
      src/main/java/com/yihu/ehr/resource/dao/RsDimensionDao.java
  51. 16 0
      src/main/java/com/yihu/ehr/resource/dao/RsInterfaceDao.java
  52. 18 0
      src/main/java/com/yihu/ehr/resource/dao/RsMetadataDao.java
  53. 12 0
      src/main/java/com/yihu/ehr/resource/dao/RsOrgResourceDao.java
  54. 12 0
      src/main/java/com/yihu/ehr/resource/dao/RsOrgResourceMetadataDao.java
  55. 22 0
      src/main/java/com/yihu/ehr/resource/dao/RsReportCategoryAppDao.java
  56. 41 0
      src/main/java/com/yihu/ehr/resource/dao/RsReportCategoryDao.java
  57. 36 0
      src/main/java/com/yihu/ehr/resource/dao/RsReportDao.java
  58. 25 0
      src/main/java/com/yihu/ehr/resource/dao/RsReportMonitorTypeDao.java
  59. 22 0
      src/main/java/com/yihu/ehr/resource/dao/RsReportUsersDao.java
  60. 29 0
      src/main/java/com/yihu/ehr/resource/dao/RsReportViewDao.java
  61. 19 0
      src/main/java/com/yihu/ehr/resource/dao/RsResourceCategoryDao.java
  62. 48 0
      src/main/java/com/yihu/ehr/resource/dao/RsResourceDao.java
  63. 31 0
      src/main/java/com/yihu/ehr/resource/dao/RsResourceDefaultParamDao.java
  64. 14 0
      src/main/java/com/yihu/ehr/resource/dao/RsResourceDefaultQueryDao.java
  65. 21 0
      src/main/java/com/yihu/ehr/resource/dao/RsResourceMetadataDao.java
  66. 36 0
      src/main/java/com/yihu/ehr/resource/dao/RsResourceQuotaDao.java
  67. 22 0
      src/main/java/com/yihu/ehr/resource/dao/RsRolesResourceDao.java
  68. 14 0
      src/main/java/com/yihu/ehr/resource/dao/RsRolesResourceMetadataDao.java
  69. 11 0
      src/main/java/com/yihu/ehr/resource/dao/RsSystemDictionaryDao.java
  70. 11 0
      src/main/java/com/yihu/ehr/resource/dao/RsSystemDictionaryEntryDao.java
  71. 32 0
      src/main/java/com/yihu/ehr/resource/feign/StandClient.java
  72. 68 0
      src/main/java/com/yihu/ehr/resource/feign/StdRedisClient.java
  73. 139 0
      src/main/java/com/yihu/ehr/resource/job/SurveyTask.java
  74. 36 0
      src/main/java/com/yihu/ehr/resource/model/DtoResourceMetadata.java
  75. 111 0
      src/main/java/com/yihu/ehr/resource/model/PortalMessageTemplate.java
  76. 195 0
      src/main/java/com/yihu/ehr/resource/model/ProtalMessageRemind.java
  77. 300 0
      src/main/java/com/yihu/ehr/resource/model/Registration.java
  78. 34 0
      src/main/java/com/yihu/ehr/resource/model/ResourceQuotaJson.java
  79. 19 0
      src/main/java/com/yihu/ehr/resource/model/ResourcesInterface.java
  80. 19 0
      src/main/java/com/yihu/ehr/resource/model/ResourcesType.java
  81. 79 0
      src/main/java/com/yihu/ehr/resource/model/RsAdapterDictionary.java
  82. 78 0
      src/main/java/com/yihu/ehr/resource/model/RsAdapterMetadata.java
  83. 73 0
      src/main/java/com/yihu/ehr/resource/model/RsAdapterScheme.java
  84. 58 0
      src/main/java/com/yihu/ehr/resource/model/RsDictionary.java
  85. 80 0
      src/main/java/com/yihu/ehr/resource/model/RsDictionaryEntry.java
  86. 82 0
      src/main/java/com/yihu/ehr/resource/model/RsDimension.java
  87. 60 0
      src/main/java/com/yihu/ehr/resource/model/RsDimensionCategory.java
  88. 72 0
      src/main/java/com/yihu/ehr/resource/model/RsInterface.java
  89. 126 0
      src/main/java/com/yihu/ehr/resource/model/RsMetadata.java
  90. 46 0
      src/main/java/com/yihu/ehr/resource/model/RsOrgResource.java
  91. 88 0
      src/main/java/com/yihu/ehr/resource/model/RsOrgResourceMetadata.java
  92. 142 0
      src/main/java/com/yihu/ehr/resource/model/RsReport.java
  93. 102 0
      src/main/java/com/yihu/ehr/resource/model/RsReportCategory.java
  94. 49 0
      src/main/java/com/yihu/ehr/resource/model/RsReportMonitorType.java
  95. 78 0
      src/main/java/com/yihu/ehr/resource/model/RsReportUsers.java
  96. 61 0
      src/main/java/com/yihu/ehr/resource/model/RsReportView.java
  97. 147 0
      src/main/java/com/yihu/ehr/resource/model/RsResource.java
  98. 64 0
      src/main/java/com/yihu/ehr/resource/model/RsResourceCategory.java
  99. 67 0
      src/main/java/com/yihu/ehr/resource/model/RsResourceDefaultParam.java
  100. 0 0
      src/main/java/com/yihu/ehr/resource/model/RsResourceDefaultQuery.java

+ 1159 - 0
ehr-cloud/pom.xml

@ -0,0 +1,1159 @@
<?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>
    <groupId>com.yihu.ehr</groupId>
    <artifactId>ehr-cloud</artifactId>
    <version>1.2.0</version>
    <packaging>pom</packaging>
    <name>ehr-cloud</name>
    <description>EHR parent pom for all</description>
    <url>http://ehr.yihu.com</url>
    <organization>
        <name>JKZL Software, Inc.</name>
        <url>http://www.yihu.com</url>
    </organization>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
    </licenses>
    <developers>
        <developer>
            <id>sand</id>
            <name>Sand Wen</name>
            <email>sand.fj.wen@gmail.com</email>
            <organization>JKZL Software, Inc.</organization>
            <organizationUrl>http://www.yihu.com</organizationUrl>
            <roles>
                <role>Project lead</role>
                <role>Project designer</role>
                <role>Project programmer</role>
            </roles>
        </developer>
        <developer>
            <id>yzh</id>
            <name>叶泽华</name>
            <email>yzh@qq.com</email>
            <organization>JKZL Software, Inc.</organization>
            <organizationUrl>http://www.yihu.com</organizationUrl>
            <roles>
                <role>Project programmer</role>
            </roles>
        </developer>
        <developer>
            <id>cws</id>
            <name>陈维山</name>
            <email>hill9868@qq.com</email>
            <organization>JKZL Software, Inc.</organization>
            <organizationUrl>http://www.yihu.com</organizationUrl>
            <roles>
                <role>Project programmer</role>
            </roles>
        </developer>
        <developer>
            <id>hzy</id>
            <name>黄志勇</name>
            <email>hzy@qq.com</email>
            <organization>JKZL Software, Inc.</organization>
            <organizationUrl>http://www.yihu.com</organizationUrl>
            <roles>
                <role>Project programmer</role>
            </roles>
        </developer>
    </developers>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.spring-framework>4.3.13.RELEASE</version.spring-framework>
        <version.spring-boot>1.5.9.RELEASE</version.spring-boot>
        <version.spring-cloud-starter>1.3.2.RELEASE</version.spring-cloud-starter>
        <version.spring-cloud>1.4.2.RELEASE</version.spring-cloud>
        <version.spring-security>4.2.3.RELEASE</version.spring-security>
        <version.spring-oauth2>2.0.14.RELEASE</version.spring-oauth2>
        <version.spring-session>1.3.1.RELEASE</version.spring-session>
        <version.spring-session-hazelcast>2.0.1.RELEASE</version.spring-session-hazelcast>
        <version.spring-data-commons>1.13.9.RELEASE</version.spring-data-commons>
        <version.spring-data-hadoop>2.2.0.RELEASE</version.spring-data-hadoop>
        <version.spring-data-solr>2.1.3.RELEASE</version.spring-data-solr>
        <version.spring-data-redis>1.7.1.RELEASE</version.spring-data-redis>
        <version.spring-data-jpa>1.11.10.RELEASE</version.spring-data-jpa>
        <version.spring-kafka>1.0.5.RELEASE</version.spring-kafka>
        <version.commons-bean-utils>1.9.2</version.commons-bean-utils>
        <version.commons-codec>1.9</version.commons-codec>
        <version.commons-collections>3.2.1</version.commons-collections>
        <version.commons-compress>1.9</version.commons-compress>
        <version.commons-dbcp2>2.1.1</version.commons-dbcp2>
        <version.commons-dbutils>1.6</version.commons-dbutils>
        <version.commons-io>2.4</version.commons-io>
        <version.commons-lang3>3.2.1</version.commons-lang3>
        <version.commons-pool2>2.4.2</version.commons-pool2>
        <version.zookeeper>3.4.6</version.zookeeper>
        <version.hadoop-client>2.6.5</version.hadoop-client>
        <version.hbase-client>1.1.1</version.hbase-client>
        <version.solr>5.5.4</version.solr>
        <version.hibernate>4.3.11.Final</version.hibernate>
        <version.hibernate-validator>6.0.10.Final</version.hibernate-validator>
        <version.hibernate-jpa-api>1.0.0.Final</version.hibernate-jpa-api>
        <version.http-core>4.4.3</version.http-core>
        <version.http-client>4.5.1</version.http-client>
        <version.http-mime>4.5.1</version.http-mime>
        <version.io-dropwizard-metrics>3.1.2</version.io-dropwizard-metrics>
        <version.java>1.8</version.java>
        <version.jackson>2.6.6</version.jackson>
        <version.jedis>2.9.0</version.jedis>
        <version.jcl-over-slf4j>1.7.19</version.jcl-over-slf4j>
        <version.jul-over-slf4j>1.7.21</version.jul-over-slf4j>
        <version.joda-time>2.8.2</version.joda-time>
        <version.junit>4.12</version.junit>
        <version.logging>1.2</version.logging>
        <version.log4j>1.2.17</version.log4j>
        <version.log4j2>2.4.1</version.log4j2>
        <version.logback>1.1.7</version.logback>
        <version.mysql>5.1.45</version.mysql>
        <version.pinyin4j>2.5.0</version.pinyin4j>
        <version.quartz>2.2.3</version.quartz>
        <version.servlet-api>3.1.0</version.servlet-api>
        <version.slf4j>1.7.21</version.slf4j>
        <version.statsd-client>3.1.0</version.statsd-client>
        <version.swagger>2.7.0</version.swagger>
        <version.swagger-ui>2.7.0</version.swagger-ui>
        <version.thrift>0.9.1</version.thrift>
        <version.tomcat-embed>8.5.27</version.tomcat-embed>
        <version.websocket-api>1.1</version.websocket-api>
        <version.zip4j>1.3.2</version.zip4j>
        <version.poi>3.12</version.poi>
        <version.scala>2.10.6</version.scala>
        <version.elasticsearch>2.1.0</version.elasticsearch>
        <version.elasticsearch-sql>2.4.1.0</version.elasticsearch-sql>
        <version.jest>2.4.0</version.jest>
        <version.alibaba-druid>1.0.15</version.alibaba-druid>
        <version.feign>9.5.0</version.feign>
        <version.hystrix>1.5.10</version.hystrix>
        <version.archaius>0.7.5</version.archaius>
        <version.ehr>1.2.0</version.ehr>
        <version.eip>1.3.1</version.eip>
        <version.json>20160212</version.json>
        <version.json-lib>2.4</version.json-lib>
        <version.fastjson>1.2.17</version.fastjson>
        <version.commons-net>3.3</version.commons-net>
        <version.jxl>2.6</version.jxl>
        <version.fastdfs>1.27</version.fastdfs>
        <version.spring.boot.admin>1.5.7</version.spring.boot.admin>
        <version.jettison>1.3.7</version.jettison>
    </properties>
    <dependencyManagement>
        <dependencies>
            <!--<dependency>-->
                <!--<groupId>org.springframework.boot</groupId>-->
                <!--<artifactId>spring-boot-dependencies</artifactId>-->
                <!--<version>1.5.9.RELEASE</version>-->
                <!--<type>pom</type>-->
                <!--<scope>import</scope>-->
            <!--</dependency>-->
            <!--<dependency>-->
                <!--<groupId>org.springframework.cloud</groupId>-->
                <!--<artifactId>spring-cloud-dependencies</artifactId>-->
                <!--<version>Finchley.M5</version>-->
                <!--<type>pom</type>-->
                <!--<scope>import</scope>-->
            <!--</dependency>-->
            <!-- Base library-->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>${version.servlet-api}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${version.junit}</version>
                <scope>test</scope>
            </dependency>
            <!-- Spring framework family -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-expression</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-messaging</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-oxm</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${version.spring-framework}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.springframework.kafka/spring-kafka -->
            <dependency>
                <groupId>org.springframework.kafka</groupId>
                <artifactId>spring-kafka</artifactId>
                <version>${version.spring-kafka}</version>
            </dependency>
            <!-- Spring boot family -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-actuator</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-autoconfigure</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-aop</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-jpa</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-redis</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-batch</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-security</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
                <optional>true</optional>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <version>${version.spring-boot}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-mongodb</artifactId>
                <version>${version.spring-boot}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Spring cloud family -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter</artifactId>
                <version>${version.spring-cloud-starter}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-config-server</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-archaius</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-config</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka-server</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-netflix-eureka</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-feign</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-ribbon</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-zuul</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-hystrix</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
                <version>${version.spring-cloud}</version>
            </dependency>
            <!-- Feign -->
            <dependency>
                <groupId>io.github.openfeign</groupId>
                <artifactId>feign-core</artifactId>
                <version>${version.feign}</version>
            </dependency>
            <!-- Hystrix -->
            <dependency>
                <groupId>com.netflix.hystrix</groupId>
                <artifactId>hystrix-core</artifactId>
                <version>${version.hystrix}</version>
            </dependency>
            <!-- Archaius -->
            <dependency>
                <groupId>com.netflix.archaius</groupId>
                <artifactId>archaius-core</artifactId>
                <version>${version.archaius}</version>
            </dependency>
            <!-- Spring data family -->
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-commons</artifactId>
                <version>${version.spring-data-commons}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-hadoop-hbase</artifactId>
                <version>${version.spring-data-hadoop}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-solr</artifactId>
                <version>${version.spring-data-solr}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Spring session family-->
            <dependency>
                <groupId>org.springframework.session</groupId>
                <artifactId>spring-session-hazelcast</artifactId>
                <version>${version.spring-session-hazelcast}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.session</groupId>
                <artifactId>spring-session</artifactId>
                <version>${version.spring-session}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.session</groupId>
                <artifactId>spring-session-data-redis</artifactId>
                <version>${version.spring-session}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Spring Security -->
            <!--<dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-config</artifactId>
                <version>${version.spring-security}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-core</artifactId>
                <version>${version.spring-security}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-crypto</artifactId>
                <version>${version.spring-security}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-web</artifactId>
                <version>${version.spring-security}</version>
                <scope>${dependency.scope}</scope>
            </dependency>-->
            <!-- Oauth2 -->
            <dependency>
                <groupId>org.springframework.security.oauth</groupId>
                <artifactId>spring-security-oauth2</artifactId>
                <version>${version.spring-oauth2}</version>
                <scope>${dependency.scope}</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.security</groupId>
                        <artifactId>*</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <!--Jackson library -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${version.jackson}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${version.jackson}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${version.jackson}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Http library -->
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpcore</artifactId>
                <version>${version.http-core}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>${version.http-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpmime</artifactId>
                <version>${version.http-mime}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!--Apache commons library -->
            <dependency>
                <groupId>org.codehaus.woodstox</groupId>
                <artifactId>stax2-api</artifactId>
                <version>3.1.4</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.codehaus.woodstox</groupId>
                <artifactId>woodstox-core-asl</artifactId>
                <version>4.4.1</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.noggit</groupId>
                <artifactId>noggit</artifactId>
                <version>0.6</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${version.commons-lang3}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>${version.poi}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils</artifactId>
                <version>${version.commons-bean-utils}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-pool2</artifactId>
                <version>${version.commons-pool2}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>commons-dbutils</groupId>
                <artifactId>commons-dbutils</artifactId>
                <version>${version.commons-dbutils}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-dbcp2</artifactId>
                <version>${version.commons-dbcp2}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${version.commons-io}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>${version.commons-collections}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>${version.commons-codec}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-compress</artifactId>
                <version>${version.commons-compress}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Mysql library -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>${version.mysql}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Hibernate framework library -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>${version.hibernate}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>${version.hibernate-validator}</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>${version.hibernate}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.1-api</artifactId>
                <version>${version.hibernate-jpa-api}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Zookeeper library -->
            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>${version.zookeeper}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Hadoop library -->
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-annotations</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-auth</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-common</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-distcp</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-hdfs</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-mapreduce-client-common</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-mapreduce-client-core</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-mapreduce-client-jobclient</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-mapreduce-client-shuffle</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-streaming</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-yarn-api</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-yarn-client</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-yarn-common</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-yarn-server-common</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-yarn-server-nodemanager</artifactId>
                <version>${version.hadoop-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hbase</groupId>
                <artifactId>hbase-client</artifactId>
                <version>${version.hbase-client}</version>
                <scope>${dependency.scope}</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.hadoop</groupId>
                        <artifactId>*</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.apache.hbase</groupId>
                <artifactId>hbase-common</artifactId>
                <version>${version.hbase-client}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.apache.hbase</groupId>
                <artifactId>hbase-protocol</artifactId>
                <version>${version.hbase-client}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <!-- export library -->
            <dependency>
                <groupId>net.sourceforge.jexcelapi</groupId>
                <artifactId>jxl</artifactId>
                <version>${version.jxl}</version>
            </dependency>
            <!-- Google library -->
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>18.0</version>
            </dependency>
            <dependency>
                <groupId>com.google.code.findbugs</groupId>
                <artifactId>jsr305</artifactId>
                <version>3.0.1</version>
            </dependency>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.6.2</version>
            </dependency>
            <dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-java</artifactId>
                <version>2.5.0</version>
            </dependency>
            <dependency>
                <groupId>com.google.inject</groupId>
                <artifactId>guice</artifactId>
                <version>4.1.0</version>
            </dependency>
            <!-- Solr library -->
            <dependency>
                <groupId>org.apache.solr</groupId>
                <artifactId>solr-core</artifactId>
                <version>${version.solr}</version>
                <scope>${dependency.scope}</scope>
                <exclusions>
                    <exclusion>
                        <groupId>commons-lang</groupId>
                        <artifactId>commons-lang</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.apache.solr</groupId>
                <artifactId>solr-solrj</artifactId>
                <version>${version.solr}</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-lang</groupId>
                        <artifactId>commons-lang</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <!-- Elasticsearch -->
            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>${version.elasticsearch}</version>
            </dependency>
            <dependency>
                <groupId>org.nlpcn</groupId>
                <artifactId>elasticsearch-sql</artifactId>
                <version>${version.elasticsearch-sql}</version>
            </dependency>
            <!-- Jest -->
            <dependency>
                <groupId>io.searchbox</groupId>
                <artifactId>jest</artifactId>
                <version>${version.jest}</version>
            </dependency>
            <!-- Redis library -->
            <dependency>
                <groupId>redis.clients</groupId>
                <artifactId>jedis</artifactId>
                <version>${version.jedis}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- FastDFS library -->
            <dependency>
                <groupId>org.csource</groupId>
                <artifactId>fastdfs-client-java</artifactId>
                <version>${version.fastdfs}</version>
            </dependency>
            <!-- Quartz library -->
            <dependency>
                <groupId>org.quartz-scheduler</groupId>
                <artifactId>quartz</artifactId>
                <version>${version.quartz}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.quartz-scheduler</groupId>
                <artifactId>quartz-jobs</artifactId>
                <version>${version.quartz}</version>
            </dependency>
            <!-- Zip library -->
            <dependency>
                <groupId>net.lingala.zip4j</groupId>
                <artifactId>zip4j</artifactId>
                <version>${version.zip4j}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Pinyin library -->
            <dependency>
                <groupId>com.belerweb</groupId>
                <artifactId>pinyin4j</artifactId>
                <version>${version.pinyin4j}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Swagger-ui library -->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>${version.swagger}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>${version.swagger-ui}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- date Time util library -->
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>${version.joda-time}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.thrift</groupId>
                <artifactId>libthrift</artifactId>
                <version>${version.thrift}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>com.timgroup</groupId>
                <artifactId>java-statsd-client</artifactId>
                <version>${version.statsd-client}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>io.dropwizard.metrics</groupId>
                <artifactId>metrics-core</artifactId>
                <version>${version.io-dropwizard-metrics}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Log framework library -->
            <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
                <version>${version.logging}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>${version.log4j}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${version.slf4j}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>${version.logback}</version>
                <scope>${dependency.scope}</scope>
            </dependency>
            <!-- Alibaba -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>${version.alibaba-druid}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>${version.fastjson}</version>
            </dependency>
            <!-- Spring Boot Admin -->
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-starter-server</artifactId>
                <version>${version.spring.boot.admin}</version>
            </dependency>
            <dependency>
                <groupId>de.codecentric</groupId>
                <artifactId>spring-boot-admin-server-ui</artifactId>
                <version>${version.spring.boot.admin}</version>
            </dependency>
            <!-- Extend library-->
            <dependency>
                <groupId>org.codehaus.jettison</groupId>
                <artifactId>jettison</artifactId>
                <version>${version.jettison}</version>
            </dependency>
            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>${version.json}</version>
            </dependency>
            <dependency>
                <groupId>net.sf.json-lib</groupId>
                <artifactId>json-lib</artifactId>
                <version>${version.json-lib}</version>
            </dependency>
            <dependency>
                <groupId>commons-net</groupId>
                <artifactId>commons-net</artifactId>
                <version>${version.commons-net}</version>
            </dependency>
            <!-- 个推相关 -->
            <dependency>
                <groupId>com.gexin.platform</groupId>
                <artifactId>gexin-rp-sdk-http</artifactId>
                <version>4.0.1.17</version>
            </dependency>
            <dependency>
                <groupId>com.gexin.platform</groupId>
                <artifactId>gexin-rp-fastjson</artifactId>
                <version>1.0.0.1</version>
            </dependency>
            <dependency>
                <groupId>com.gexin.platform</groupId>
                <artifactId>gexin-rp-sdk-base</artifactId>
                <version>4.0.0.22</version>
            </dependency>
            <dependency>
                <groupId>com.gexin.platform</groupId>
                <artifactId>gexin-rp-sdk-template</artifactId>
                <version>4.0.0.16</version>
            </dependency>
            <dependency>
                <groupId>com.gexin.platform</groupId>
                <artifactId>protobuf-java</artifactId>
                <version>2.5.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <repositories>
        <repository>
            <id>public</id>
            <name>public</name>
            <url>http://172.19.103.43:8081/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>public</id>
            <name>public</name>
            <url>http://172.19.103.43:8081/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ssh</artifactId>
                <version>2.10</version>
            </extension>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-http-lightweight</artifactId>
                <version>2.10</version>
            </extension>
        </extensions>
        <plugins>
            <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>
    </build>
</project>

+ 606 - 0
ehr-ms-parent-pom/pom.xml

@ -0,0 +1,606 @@
<?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>
        <groupId>com.yihu.ehr</groupId>
        <artifactId>ehr-cloud</artifactId>
        <version>1.2.0</version>
        <relativePath>../ehr-cloud/pom.xml</relativePath>
    </parent>
    <artifactId>ehr-ms-parent-pom</artifactId>
    <packaging>pom</packaging>
    <description>EHR micro service parent pom</description>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.jooq</groupId>
                    <artifactId>jooq-codegen-maven</artifactId>
                    <version>${jooq.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.7</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <recompressZippedFiles>false</recompressZippedFiles>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.5</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.10</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-eclipse-plugin</artifactId>
                    <version>2.9</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.18</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-help-plugin</artifactId>
                    <version>2.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.5</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.10.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.7</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>2.3</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.3</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.doxia</groupId>
                            <artifactId>doxia-module-markdown</artifactId>
                            <version>1.5</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.18.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.5</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>1.9.1</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.3.2</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>2.2</version>
                </plugin>
                <plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <version>2.1.11</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${version.spring-boot}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.17</version>
                <executions>
                    <execution>
                        <id>checkstyle-validation</id>
                        <phase>validate</phase>
                        <configuration>
                            <skip>true</skip>
                            <configLocation>src/checkstyle/checkstyle.xml</configLocation>
                            <suppressionsLocation>src/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
                            <headerLocation>src/checkstyle/checkstyle-header.txt</headerLocation>
                            <propertyExpansion>checkstyle.build.directory=${project.build.directory}</propertyExpansion>
                            <encoding>UTF-8</encoding>
                            <consoleOutput>true</consoleOutput>
                            <failsOnError>true</failsOnError>
                            <includeTestSourceDirectory>true</includeTestSourceDirectory>
                        </configuration>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${version.java}</source>
                    <target>${version.java}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <id>enforce-rules</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>[1.8,)</version>
                                </requireJavaVersion>
                                <!--<requireProperty>
                                    <property>main.basedir</property>
                                </requireProperty>-->
                                <!--<requireProperty>
                                    <property>project.organization.name</property>
                                </requireProperty>-->
                                <!--<requireProperty>
                                    <property>project.name</property>
                                </requireProperty>-->
                                <!--<requireProperty>
                                    <property>project.description</property>
                                </requireProperty>-->
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/*Tests.java</include>
                    </includes>
                    <excludes>
                        <exclude>**/Abstract*.java</exclude>
                    </excludes>
                    <!--<systemPropertyVariables>-->
                    <!--<java.security.egd>file:/dev/./urandom</java.security.egd>-->
                    <!--<java.awt.headless>true</java.awt.headless>-->
                    <!--</systemPropertyVariables>-->
                    <argLine>-Xmx1024m</argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>animal-sniffer-maven-plugin</artifactId>
                <configuration>
                    <skip>${disable.checks}</skip>
                    <signature>
                        <groupId>org.codehaus.mojo.signature</groupId>
                        <artifactId>java16</artifactId>
                        <version>1.0</version>
                    </signature>
                    <annotations>
                        <annotation>org.springframework.lang.UsesJava8</annotation>
                        <annotation>org.springframework.lang.UsesJava7</annotation>
                        <annotation>org.springframework.boot.lang.UsesUnsafeJava</annotation>
                    </annotations>
                </configuration>
                <executions>
                    <execution>
                        <id>enforce-java-6</id>
                        <phase>test</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>-->
        </plugins>
    </build>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-admin-gateway-model</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-data-elasticsearch</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-data-fastdfs</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-data-hbase</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-data-mysql</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-data-query</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-data-redis</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-data-solr</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-ehr-constants</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-entity</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <!--<dependency>-->
            <!--<groupId>com.yihu.ehr</groupId>-->
            <!--<artifactId>commons-metrics</artifactId>-->
            <!--<version>${version.ehr}</version>-->
            <!--</dependency>-->
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-profile-core</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-redis-mq</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-rest-model</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.hos</groupId>
                <artifactId>common-rest-model</artifactId>
                <version>${version.eip}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-ui-swagger</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-util</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-web</artifactId>
                <version>${version.ehr}</version>
            </dependency>
            <!--<dependency>
                <groupId>com.yihu.ehr</groupId>
                <artifactId>commons-metrics</artifactId>
                <version>${version.ehr}</version>
            </dependency>-->
        </dependencies>
    </dependencyManagement>
    <!--
    profiles分为三种场景(dev,test,prod),三种部署模式(jar,war,docker).预计是9种模式,
    但目前仅使用到dev,test,prod的jar,test的war.若有需要可以组合配置这些部署模式.
    - dev的可执行jar包,在本机调试,不需要配置wagon参数。
    - test,prod的可执行jar包,需要在编译后传送到服务器上部署,故需配置wagon参数,参数可根据服务需要自行配置。
    - dev,test,prod的war包,编译后使用tomcat api部署,故需配置tomcat参数,参数可根据服务需要自行配置。
    -->
    <profiles>
        <profile>
            <id>dev-jar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <skipTests>true</skipTests>
                <packaging.type>jar</packaging.type>
                <dependency.scope>compile</dependency.scope>
            </properties>
            <dependencies>
                <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>
                <!--<dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-devtools</artifactId>
                    <scope>${dependency.scope}</scope>
                </dependency>-->
            </dependencies>
        </profile>
        <profile>
            <id>test-jar</id>
            <properties>
                <skipTests>true</skipTests>
                <packaging.type>jar</packaging.type>
                <dependency.scope>compile</dependency.scope>
                <wagonServerId/>
                <wagonUrl/>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>wagon-maven-plugin</artifactId>
                        <version>1.0</version>
                        <configuration>
                            <serverId>${wagonServerId}</serverId>
                            <fromFile>${project.build.directory}/${project.build.finalName}.jar</fromFile>
                            <url>${wagonUrl}</url>
                            <commands>
                                <command>pkill -f ${project.build.finalName}.jar</command>
                                <command>nohub java -Djava.security.egd=file:/dev/./urandom -jar
                                    ${project.build.finalName}.jar &amp;
                                </command>
                            </commands>
                            <displayCommandOutputs>true</displayCommandOutputs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-starter-logging</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-devtools</artifactId>
                    <scope>${dependency.scope}</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>test-war</id>
            <activation>
                <property>
                    <name>spring.profiles.active</name>
                    <value>default,test</value>
                </property>
            </activation>
            <properties>
                <skipTests>true</skipTests>
                <packaging.type>war</packaging.type>
                <dependency.scope>provided</dependency.scope>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                    <scope>${dependency.scope}</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-starter-logging</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                    <scope>${dependency.scope}</scope>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-devtools</artifactId>
                    <scope>${dependency.scope}</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.tomcat.maven</groupId>
                        <artifactId>tomcat7-maven-plugin</artifactId>
                        <version>2.2</version>
                        <configuration>
                            <url>http://localhost:8080/manager/text</url>
                            <server>tomcat8</server>
                            <username>deployer</username>
                            <password>jkzldeployer</password>
                            <path>/${project.artifactId}</path>
                            <update>true</update>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>prod-jar</id>
            <activation>
                <property>
                    <name>spring.profiles.active</name>
                    <value>default,prod</value>
                </property>
            </activation>
            <properties>
                <skipTests>true</skipTests>
                <packaging.type>war</packaging.type>
                <dependency.scope>compile</dependency.scope>
                <wagonServerId>11.1.2.21</wagonServerId>
                <wagonUrl>scp://user:password@11.1.2.21/home/root/ehr-release</wagonUrl>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                    <scope>${dependency.scope}</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-starter-logging</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>prod-war</id>
            <properties>
                <skipTests>true</skipTests>
                <packaging.type>war</packaging.type>
                <dependency.scope>provided</dependency.scope>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                    <scope>${dependency.scope}</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-starter-logging</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                    <scope>${dependency.scope}</scope>
                </dependency>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-devtools</artifactId>
                    <scope>${dependency.scope}</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

+ 127 - 0
pom.xml

@ -0,0 +1,127 @@
<?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>
        <groupId>com.yihu.ehr</groupId>
        <artifactId>ehr-ms-parent-pom</artifactId>
        <version>1.2.0</version>
        <relativePath>ehr-ms-parent-pom/pom.xml</relativePath>
    </parent>
    <artifactId>svr-resource</artifactId>
    <!--<packaging>${packaging.type}</packaging>-->
    <packaging>war</packaging>
    <properties>
        <wagonServerId>192.168.1.220</wagonServerId>
        <wagonUrl>scp://sand:timeneverstop@192.168.1.221/home/sand/ehr-release</wagonUrl>
    </properties>
    <dependencies>
        <!-- true -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-feign</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-ehr-constants</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-util</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-data-mysql</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-rest-model</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-data-redis</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-ui-swagger</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-web</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-profile-core</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-data-hbase</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-data-query</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-data-fastdfs</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-data-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <scope>${dependency.scope}</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
    </dependencies>
</project>

+ 33 - 0
src/main/java/com/yihu/ehr/ResourceSvrApp.java

@ -0,0 +1,33 @@
package com.yihu.ehr;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.data.web.config.EnableSpringDataWebSupport;
@Configuration
@EnableAutoConfiguration(exclude = {
        SecurityAutoConfiguration.class})
@ComponentScan
@EnableDiscoveryClient
@EnableFeignClients
@EnableSpringDataWebSupport
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class ResourceSvrApp extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(ResourceSvrApp.class, args);
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(ResourceSvrApp.class);
    }
}

+ 38 - 0
src/main/java/com/yihu/ehr/resource/client/QuotaStatisticsClient.java

@ -0,0 +1,38 @@
package com.yihu.ehr.resource.client;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.MicroServices;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
/**
 * Created by janseny on 2017/12/14.
 */
@FeignClient(name = MicroServices.Quota)
@RequestMapping(value = ApiVersion.Version1_0)
@ApiIgnore
public interface QuotaStatisticsClient {
    @ApiOperation(value = "获取指标统计报表 二维表")
    @RequestMapping(value = ServiceApi.TJ.GetQuotaReportTwoDimensionalTable, method = RequestMethod.GET)
    List<Map<String, Object>> getQuotaReportTwoDimensionalTable(
            @ApiParam(name = "quotaCodeStr", value = "指标Code,多个用,拼接", required = true)
            @RequestParam(value = "quotaCodeStr", required = true) String quotaCodeStr,
            @ApiParam(name = "filter", value = "过滤", defaultValue = "")
            @RequestParam(value = "filter", required = false) String filter,
            @ApiParam(name = "dimension", value = "维度字段", defaultValue = "quotaDate")
            @RequestParam(value = "dimension", required = false) String dimension,
            @ApiParam(name = "top", value = "获取前几条数据")
            @RequestParam(value = "top", required = false) String top);
}

+ 36 - 0
src/main/java/com/yihu/ehr/resource/client/StdTransformClient.java

@ -0,0 +1,36 @@
package com.yihu.ehr.resource.client;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.MicroServices;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
/**
 * Created by progr1mmer on 2018/1/24.
 */
@ApiIgnore
@FeignClient(name = MicroServices.StdRedis)
@RequestMapping(value = ApiVersion.Version1_0)
public interface StdTransformClient {
    @RequestMapping(value = "/redis/stdMetadataCodes", method = RequestMethod.GET)
    String stdMetadataCodes(
            @RequestParam(value = "version") String version,
            @RequestParam(value = "datasetCode") String datasetCode);
    @RequestMapping(value = "/redis/adapterMetadataCode", method = RequestMethod.GET)
    String adapterMetadataCode(
            @RequestParam(value = "version") String version,
            @RequestParam(value = "stdDatasetCode") String datasetCode,
            @RequestParam(value = "stdMetadataCode") String stdMetadataCode);
    @RequestMapping(value = "/redis/stdMetadataName", method = RequestMethod.GET)
    String stdMetadataName(
            @RequestParam(value = "version") String version,
            @RequestParam(value = "datasetCode") String datasetCode,
            @RequestParam(value = "metadataCode") String metadataCode);
}

+ 27 - 0
src/main/java/com/yihu/ehr/resource/config/TenantConfiguration.java

@ -0,0 +1,27 @@
package com.yihu.ehr.resource.config;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 *   ehr使用 feginClient 调用eip(涉及到app应用,标准等) 时,需要此类,增加请求头信息
 */
@Configuration
public class TenantConfiguration {
    @Value("${eip.tenant}")
    private String tenant;
    @Bean
    public RequestInterceptor tenantInterceptor() {
        return new RequestInterceptor() {
            @Override
            public void apply(RequestTemplate requestTemplate) {
                requestTemplate.header("tenant_name", tenant);
            }
        };
    }
}

+ 175 - 0
src/main/java/com/yihu/ehr/resource/controller/HbaseDataEndPoint.java

@ -0,0 +1,175 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.hbase.HBaseAdmin;
import com.yihu.ehr.hbase.HBaseDao;
import com.yihu.ehr.solr.SolrAdmin;
import com.yihu.ehr.solr.SolrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2017/1/11.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "HbaseDataEndPoint", description = "Hbase数据", tags = {"资源服务-Hbase数据"})
public class HbaseDataEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private HBaseAdmin hbaseAdmin;
    @Autowired
    private HBaseDao hbaseDao;
    @Autowired
    private SolrAdmin solrAdmin;
    @Autowired
    private SolrUtil solrUtil;
    @ApiOperation("模糊匹配表")
    @RequestMapping(value = "getTableList", method = RequestMethod.GET)
    public String getTableList(
            @ApiParam(name = "regex", value = "模糊匹配", required = true)
            @RequestParam(value = "regex") String regex) throws Exception {
        String re = "data:[";
        List<String> list = hbaseAdmin.getTableList(regex, true);
        if (list != null && list.size() > 0) {
            for (String item : list) {
                re += item + "; ";
            }
        }
        re += "]";
        return re;
    }
    @ApiOperation("Solr总条数")
    @RequestMapping(value = "countSolr", method = RequestMethod.GET)
    public String countSolr(
            @ApiParam(name = "tableName", value = "表名", defaultValue = "HealthProfile", required = true)
            @RequestParam(value = "tableName") String tableName) throws Exception {
        long count = solrUtil.count(tableName,"*:*");
        //通过org_code分组统计
        /*Map<String,Long> map = solrUtil.groupCount(tableName,null,null,"org_code",0,1000);
        Long orgCount = new Long(0);
        for(String key : map.keySet())
        {
            orgCount += map.get(key);
        }*/
        return "count:"+count;
    }
    @ApiOperation("Hbase总条数")
    @RequestMapping(value = "countHbase", method = RequestMethod.GET)
    public String countHbase(
            @ApiParam(name = "tableName", value="表名",defaultValue = "HealthProfile")
            @RequestParam(value = "tableName") String tableName) throws Exception {
        Integer count = hbaseDao.count(tableName);
        return "count:"+count;
    }
    @ApiOperation("判断表是否存在")
    @RequestMapping(value = "isTableExists", method = RequestMethod.GET)
    public String isTableExists(
            @ApiParam(name = "tableName", value="表名", defaultValue = "HealthProfile")
            @RequestParam(value = "tableName") String tableName) throws Exception {
        if (hbaseAdmin.isTableExists(tableName)) {
            return "true";
        }
        return "false";
    }
    @ApiOperation("创建表")
    @RequestMapping(value = "createTable", method = RequestMethod.POST)
    public String createTable(
            @ApiParam(name = "tableName", value="表名", defaultValue = "HH")
            @RequestParam(value = "tableName") String tableName,
            @ApiParam(name = "columnFamilies", value = "列族,逗号分隔", defaultValue = "HH_F1,HH_F2")
            @RequestParam(value = "columnFamilies") String columnFamilies) throws Exception {
        String[] cols = columnFamilies.split(",");
        hbaseAdmin.createTable(tableName,cols);
        return "Success create table "+tableName+".";
    }
    @ApiOperation("清空表")
    @RequestMapping(value = "truncateTable", method = RequestMethod.POST)
    public String dropTable(
            @ApiParam(name = "tableName", value = "表名", defaultValue = "HealthArchives")
            @RequestParam(value = "tableName") String tableName) throws Exception {
        List<String> list = new ArrayList<>();
        list.add(tableName);
        hbaseAdmin.cleanTable(list);
        //清空索引
        solrAdmin.delete(tableName,"rowkey:*");
        return "Success drop table "+tableName+".";
    }
    @ApiOperation("测试插入数据")
    @RequestMapping(value = "insertRecord", method = RequestMethod.POST)
    public String insertRecord(
            @ApiParam(name = "tableName", value = "表名", defaultValue = "HealthArchives")
            @RequestParam(value = "tableName") String tableName,
            @ApiParam(name = "rowKey", value = "主键", defaultValue = "1")
            @RequestParam(value = "rowKey") String rowKey,
            @ApiParam(name = "family", value = "列族", defaultValue = "basic")
            @RequestParam(value = "family") String family,
            @ApiParam(name = "columns", value = "列", defaultValue = "demographic_id")
            @RequestParam(value = "columns") String columns,
            @ApiParam(name = "values", value = "值", defaultValue = "1234567")
            @RequestParam(value = "values") String values) throws Exception {
        Object[] cols = columns.split(",");
        Object[] vals = values.split(",");
        hbaseDao.add(tableName,rowKey,family,cols, vals);
        return "Success insert record For "+tableName+".";
    }
    @ApiOperation("获取单条数据")
    @RequestMapping(value = "getOneResult", method = RequestMethod.POST)
    public String getOneResult(
            @ApiParam(name = "tableName", value="表名", defaultValue = "HealthProfile")
            @RequestParam(value = "tableName") String tableName,
            @ApiParam(name = "rowKey", value="主键", defaultValue = "1")
            @RequestParam(value = "rowKey") String rowKey) throws Exception {
        Map<String, Object> re = hbaseDao.getResultMap(tableName,rowKey);
        return objectMapper.writeValueAsString(re);
    }
   @ApiOperation("删除单条Hbase")
   @RequestMapping(value = "deleteHbase", method = RequestMethod.POST)
   public String deleteHbase(
           @ApiParam(name = "core", value = "core", defaultValue = "HealthProfile")
           @RequestParam(value = "core") String core,
           @ApiParam(name = "key", value = "key")
           @RequestParam(value = "key") String key) {
       hbaseDao.delete(core,key);
       return "删除单条Hbase成功!";
   }
    @ApiOperation("删除Solr")
    @RequestMapping(value = "deleteSolr", method = RequestMethod.POST)
    @ApiIgnore
    public String deleteSolr(
            @ApiParam(name = "core", value = "core", defaultValue = "HealthProfile")
            @RequestParam(value = "core") String core,
            @ApiParam(name = "key", value = "key")
            @RequestParam(value = "key") String key) throws Exception  {
        solrAdmin.delete(core, key);
        return "删除Solr成功!";
    }
}

+ 378 - 0
src/main/java/com/yihu/ehr/resource/controller/ResourceBrowseEndPoint.java

@ -0,0 +1,378 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.model.packs.EsSimplePackage;
import com.yihu.ehr.model.resource.MRsColumnsModel;
import com.yihu.ehr.profile.queue.RedisCollection;
import com.yihu.ehr.query.services.SolrQuery;
import com.yihu.ehr.resource.service.ResourceBrowseService;
import com.yihu.ehr.resource.service.ResourcesTransformService;
import com.yihu.ehr.util.datetime.DateUtil;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.Serializable;
import java.util.*;
/**
 * Created by hzp on 2016/4/13.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "ResourceBrowseEndPoint", description = "数据浏览查询", tags = {"资源服务-数据浏览查询"})
public class ResourceBrowseEndPoint extends EnvelopRestEndPoint {
    private static final long PAGE_SIZE_SOLR = 50000;
    @Autowired
    private ResourceBrowseService resourceBrowseService;
    @Autowired
    private ResourcesTransformService resourcesTransformService;
    @Autowired
    private SolrQuery solrQuery;
    @Autowired
    private RedisTemplate<String, Serializable> redisTemplate;
    // ---------------------------------------------- 基础信息管理 Start---------------------------------
    @ApiOperation("资源数据源结构")
    @RequestMapping(value = ServiceApi.Resources.ResourceViewMetadata, method = RequestMethod.GET)
    public List<MRsColumnsModel> getResourceMetadata(
            @ApiParam(name = "resourcesCode", value = "资源编码")
            @RequestParam(value = "resourcesCode") String resourcesCode,
            @ApiParam(name = "roleId", value = "角色id")
            @RequestParam(value = "roleId") String roleId) throws Exception {
        return resourceBrowseService.getResourceMetadata(resourcesCode, roleId);
    }
    @ApiOperation("资源浏览")
    @RequestMapping(value = ServiceApi.Resources.ResourceViewData, method = RequestMethod.GET)
    public Envelop getResourceData(
            @ApiParam(name = "resourcesCode", value = "资源编码")
            @RequestParam(value = "resourcesCode", defaultValue = "HDSA00_01") String resourcesCode,
            @ApiParam(name = "roleId", value = "角色id [\"roleId\"]")
            @RequestParam(value = "roleId") String roleId,
            @ApiParam(name = "orgCode", value = "机构编码 [\"49229004X\"]")
            @RequestParam(value = "orgCode") String orgCode,
            @ApiParam(name= "areaCode", value = "地区编码 [\"361121\"]")
            @RequestParam(value = "areaCode") String areaCode,
            @ApiParam(name = "queryCondition", value = "查询条件 [{\"andOr\":\"OR\",\"condition\":\"=\",\"field\":\"event_type\",\"value\":\"0\"}]")
            @RequestParam(value = "queryCondition", required = false) String queryCondition,
            @ApiParam(name = "page", value = "第几页", required = true)
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "每页几条", required = true)
            @RequestParam(value = "size") Integer size) throws Exception{
        return resourceBrowseService.getResourceData(resourcesCode, roleId, orgCode, areaCode, queryCondition, page, size);
    }
    @ApiOperation("档案资源浏览细表数据")
    @RequestMapping(value = ServiceApi.Resources.ResourceViewSubData, method = RequestMethod.GET)
    public Envelop findSubDateByRowKey(
            @ApiParam(name = "rowKey", value = "主表rowKey", required = true)
            @RequestParam(value = "rowKey") String rowKey,
            @ApiParam(name = "version", value = "版本", required = true)
            @RequestParam(value = "version") String version) throws Exception {
        List<Object> resultList = resourceBrowseService.getSubDateByRowkey(rowKey, version);
        return success(resultList);
    }
    // ---------------------------------------------- 基础信息管理 End---------------------------------
    /**
     * 获取资源数据
     */
    @ApiOperation("获取资源数据")
    @RequestMapping(value = ServiceApi.Resources.ResourceQuery, method = RequestMethod.POST)
    public Envelop getResources(
            @ApiParam(name = "resourcesCode", value = "资源编码")
            @RequestParam(value = "resourcesCode", defaultValue = "HDSA00_01") String resourcesCode,
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode") String orgCode,
            @ApiParam(name= "areaCode", value = "地区编码")
            @RequestParam(value = "areaCode") String areaCode,
            @ApiParam(name = "queryParams", value = "json查询条件,{\"q\":\"*:*\"}")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "第几页")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "每页几条")
            @RequestParam(value = "size", required = false) Integer size) throws Exception {
        return resourceBrowseService.getResultData(resourcesCode, "*", orgCode, areaCode, queryParams, page, size);
    }
    /**
     * 获取资源数据(转译)
     */
    @ApiOperation("获取资源数据(转译)")
    @RequestMapping(value = ServiceApi.Resources.ResourceQueryTransform, method = RequestMethod.POST)
    public Envelop getResourcesTransform(
            @ApiParam(name = "resourcesCode", value = "资源代码")
            @RequestParam(value = "resourcesCode") String resourcesCode,
            @ApiParam(name = "roleId", value = "角色ID")
            @RequestParam(value = "roleId") String roleId,
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode") String orgCode,
            @ApiParam(name = "areaCode", value = "地区编码")
            @RequestParam(value = "areaCode") String areaCode,
            @ApiParam(name = "queryParams", value = "json查询条件,{\"q\":\"*:*\"}")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "第几页")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "每页几条")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "version", value = "版本号")
            @RequestParam(value = "version", required = false) String version) throws Exception {
        Envelop result = resourceBrowseService.getResultData(resourcesCode, roleId , orgCode, areaCode, queryParams, page, size);
        if (version != null && version.length() > 0) {
            result.setDetailModelList(resourcesTransformService.displayCodeConvert(result.getDetailModelList(), version, resourcesCode));
        }
        return result;
    }
    @ApiOperation("Hbase主表")
    @RequestMapping(value = ServiceApi.Resources.ResourceMasterData, method = RequestMethod.GET)
    public Envelop getEhrCenter(
            @ApiParam(name = "queryParams", value = "检索条件", defaultValue = "{\"q\":\"*:*\"}")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "分页大小")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "version", value = "版本")
            @RequestParam(value = "version", required = false) String version) throws Exception {
        Envelop result = resourceBrowseService.getEhrCenter(null, "*", "*", queryParams, page, size);
        if (version != null && version.length() > 0) {
            result.setDetailModelList(resourcesTransformService.displayCodeConvert(result.getDetailModelList(), version, null));
        }
        return result;
    }
    @ApiOperation("Hbase从表")
    @RequestMapping(value = ServiceApi.Resources.ResourceSubData, method = RequestMethod.GET)
    public Envelop getEhrCenterSub(
            @ApiParam(name = "queryParams", value = "检索条件", defaultValue = "{\"table\":\"HDSC02_17\"}")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "分页大小")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "version", value = "版本")
            @RequestParam(value = "version", required = false) String version) throws Exception {
        Envelop result = resourceBrowseService.getEhrCenterSub(null, "*", "*", queryParams, page, size);
        if (version != null && version.length() > 0) {
            result.setDetailModelList(resourcesTransformService.displayCodeConvert(result.getDetailModelList(), version, null));
        }
        return result;
    }
    @ApiOperation("Hbase主表统计")
    @RequestMapping(value = ServiceApi.Resources.ResourceMasterStat, method = RequestMethod.GET)
    public Envelop countEhrCenter(
            @ApiParam(name = "queryParams", value = "检索条件", defaultValue = "{\"groupFields\":\"org_code\"}")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "分页大小")
            @RequestParam(value = "size", required = false) Integer size) throws Exception {
        Page<Map<String, Object>> result = resourceBrowseService.countEhrCenter(queryParams, page, size);
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setCurrPage(result.getNumber());
        envelop.setPageSize(result.getSize());
        envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
        envelop.setDetailModelList(result.getContent());
        return envelop;
    }
    @ApiOperation("Hbase从表统计")
    @RequestMapping(value = ServiceApi.Resources.ResourceSubStat, method = RequestMethod.GET)
    public Envelop countEhrCenterSub(
            @ApiParam(name = "queryParams", value = "检索条件")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "分页大小")
            @RequestParam(value = "size", required = false) Integer size) throws Exception {
        Page<Map<String, Object>> result = resourceBrowseService.countEhrCenterSub(queryParams, page, size);
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setCurrPage(result.getNumber());
        envelop.setPageSize(result.getSize());
        envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
        envelop.setDetailModelList(result.getContent());
        return envelop;
    }
    @ApiOperation("获取非结构化数据")
    @RequestMapping(value = ServiceApi.Resources.ResourceHealthFile, method = RequestMethod.GET)
    public Envelop healthFile(
            @ApiParam(name = "filters", value = "检索条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "检索条件")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页数", required = true)
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "分页大小", required = true)
            @RequestParam(value = "size") Integer size) throws Exception {
        Envelop envelop = resourceBrowseService.getEhrFile(filters, sorts, page, size);
        return envelop;
    }
    @ApiOperation("Mysql查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceMysql, method = RequestMethod.GET)
    public Envelop getMysqlData(
            @ApiParam(name = "queryParams", value = "检索条件")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "分页大小")
            @RequestParam(value = "size", required = false) Integer size) throws Exception {
        Page<Map<String, Object>> result = resourceBrowseService.getMysqlData(queryParams, page, size);
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setCurrPage(result.getNumber());
        envelop.setPageSize(result.getSize());
        envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
        envelop.setDetailModelList(result.getContent());
        return envelop;
    }
    @ApiOperation("获取solr索引列表")
    @RequestMapping(value = ServiceApi.Resources.SolrIndexData, method = RequestMethod.GET)
    public Envelop getSolrIndex(
            @ApiParam(name = "queryParams", value = "检索条件", defaultValue = "{\"q\":\"*:*\"}")
            @RequestParam(value = "queryParams", required = false) String queryParams,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "分页大小")
            @RequestParam(value = "size", required = false) Integer size,
            @ApiParam(name = "version", value = "版本")
            @RequestParam(value = "version", required = false) String version) throws Exception {
        Page<String> result = resourceBrowseService.getSolrIndexs(queryParams, page, size);
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setCurrPage(result.getNumber());
        envelop.setPageSize(result.getSize());
        envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
        envelop.setDetailModelList(result.getContent());
        return envelop;
    }
    /**
     * 获取资源数据(转译)
     */
    @ApiOperation("获取资源数据,返回档案包中包含的数据集(转译)")
    @RequestMapping(value = ServiceApi.Resources.ResourceQueryAllTransform, method = RequestMethod.POST)
    public Envelop getAllResourcesTransform(
            @ApiParam(name = "packId", value = "档案包ID")
            @RequestParam(value = "packId") String packId,
            @ApiParam(name = "roleId", value = "角色ID")
            @RequestParam(value = "roleId") String roleId,
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode") String orgCode,
            @ApiParam(name = "areaCode", value = "地区编码")
            @RequestParam(value = "areaCode") String areaCode,
            @ApiParam(name = "rowKey", value = "rowKey")
            @RequestParam(value = "rowKey", required = false) String rowKey,
            @ApiParam(name = "version", value = "版本号")
            @RequestParam(value = "version", required = false) String version) throws Exception {
        //获取档案包中包含的数据集
        List<String> dataSets = resourceBrowseService.dataSetList(packId, version);
        Envelop result = resourceBrowseService.getResultDataList(version, dataSets, roleId , orgCode, areaCode, rowKey );
        if (version != null && version.length() > 0) {
            result.setObj(resourcesTransformService.displayCodeListConvert((Map<String, Object>) result.getObj(), version));
        }
        return result;
    }
    /**
     * 获取资源数据(转译)
     */
    @ApiOperation("获取资源数据,通过数据集列表对应的数据(转译)")
    @RequestMapping(value = ServiceApi.Resources.ResourceQueryByDataSets, method = RequestMethod.POST)
    public Envelop getResourceByDataSets(
            @ApiParam(name = "dataSets", value = "数据集集合")
            @RequestParam(value = "dataSets") List dataSets,
            @ApiParam(name = "roleId", value = "角色ID")
            @RequestParam(value = "roleId") String roleId,
            @ApiParam(name = "orgCode", value = "机构编码")
            @RequestParam(value = "orgCode") String orgCode,
            @ApiParam(name = "areaCode", value = "地区编码")
            @RequestParam(value = "areaCode") String areaCode,
            @ApiParam(name = "rowKey", value = "rowKey")
            @RequestParam(value = "rowKey", required = false) String rowKey,
            @ApiParam(name = "version", value = "版本号")
            @RequestParam(value = "version", required = false) String version) throws Exception {
        //获取档案包中包含的数据集
        Envelop result = resourceBrowseService.getResultByDataSets(version,dataSets, roleId , orgCode, areaCode, rowKey );
        if (version != null && version.length() > 0) {
            result.setObj(resourcesTransformService.displayCodeListConvert((Map<String, Object>) result.getObj(), version));
        }
        return result;
    }
    //TODO  由于vpn问题不好调测,临时放在此处,后面统一放到svr-pack-mgr
    @RequestMapping(value = "/addProvincialQueue", method = RequestMethod.POST)
    @ApiOperation(value = "添加省平台上传队列", notes = "通过条件查询从solr查询数据添加到省平台队列")
    public String addProvincialQueue(
            @ApiParam(value = "core 表名,如 HealthProfile")
            @RequestParam(value = "core", required = true) String core,
            @ApiParam(name = "q", value = "查询条件solr语法,eg:event_date:[\"2017-12-18T09:49:02Z\" TO \"2017-12-18T09:50:30Z\"]")
            @RequestParam(name = "q",required = true) String q,
            @ApiParam(name = "fl", value = "展示字段 多个用  , 拼接 如 org_code,org_name,rowkey,demographic_id,event_type,event_date,patient_name,patient_id,event_no")
            @RequestParam(name = "fl",required = false,defaultValue = "org_code,org_name,rowkey,demographic_id,event_type,event_date,patient_name,patient_id,event_no") String fl){
        long count = 0;
        List<Map<String, Object>> list = new ArrayList<>();
        try {
            if(org.apache.commons.lang.StringUtils.isEmpty(fl)){
                return  "展示字段参数fl 不能为空";
            }
            String [] fields = fl.split(",");
            count = solrQuery.count(core,q,null);
            long page = count / PAGE_SIZE_SOLR +1;
            for (int i = 0; i < page; i++) {
                list = solrQuery.queryReturnFieldList(core, q, null, null, i * PAGE_SIZE_SOLR, PAGE_SIZE_SOLR, fields);
                for (Map<String, Object> item : list) {
                    EsSimplePackage esSimplePackage = new EsSimplePackage();
                    esSimplePackage.setRowkey(String.valueOf(item.get("rowkey")));
                    esSimplePackage.setPatient_id(String.valueOf(item.get("patient_id")));
                    esSimplePackage.setEvent_date(DateUtil.toStringLong((Date)item.get("event_date")));
                    esSimplePackage.setEvent_no(String.valueOf(item.get("event_no")));
                    esSimplePackage.setEvent_type( Integer.valueOf(item.get("event_type").toString()));
                    esSimplePackage.setOrg_code(String.valueOf(item.get("org_code")));
                    esSimplePackage.setIdcard_no(String.valueOf(item.get("demographic_id")));
                    esSimplePackage.setPatient_name(String.valueOf(item.get("patient_name")));
                    esSimplePackage.setOrg_name(String.valueOf(item.get("org_name")));
                    esSimplePackage.setOrg_area(String.valueOf(item.get("org_area")));
                    //存入省平台上传队列
                    redisTemplate.opsForList().leftPush(RedisCollection.PROVINCIAL_PLATFORM_QUEUE_SUPPLEMENT, objectMapper.writeValueAsString(esSimplePackage));
                }
            }
            return "操作成功,数量:"+count;
        } catch (Exception e) {
            e.printStackTrace();
            return "操作成功异常:"+ e.getMessage();
        }
    }
}

+ 1087 - 0
src/main/java/com/yihu/ehr/resource/controller/ResourceCenterEndPoint.java

@ -0,0 +1,1087 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.model.tj.EchartReportModel;
import com.yihu.ehr.model.tj.MapDataModel;
import com.yihu.ehr.resource.service.RedisService;
import com.yihu.ehr.resource.service.ResourceCenterService;
import com.yihu.ehr.solr.SolrUtil;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.solr.client.solrj.response.FacetField;
import org.apache.solr.client.solrj.response.RangeFacet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigInteger;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * EndPoint - 数据资源中心
 * Created by Progr1mmer on 2018/01/05.
 */
@RestController
@RequestMapping(ApiVersion.Version1_0)
@Api(value = "ResourceCenterStatisticsEndPoint", description = "数据资源中心首页", tags = {"资源服务-数据资源中心首页"})
public class ResourceCenterEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private ResourceCenterService resourceCenterService;
    @Autowired
    private SolrUtil solrUtil;
    @Autowired
    private RedisService redisService;
    // ------------------------------- 统计相关 start ------------------------------------
    @RequestMapping(value = ServiceApi.Resources.GetPatientArchiveCount, method = RequestMethod.GET)
    @ApiOperation(value = "顶部栏 - 居民建档数")
    public Envelop getPatientArchiveCount() throws Exception{
        BigInteger totalDemographicsNum = resourceCenterService.getDemographicCount();
        return success(totalDemographicsNum);
    }
    @RequestMapping(value = ServiceApi.Resources.GetMedicalResourcesCount, method = RequestMethod.GET)
    @ApiOperation(value = "顶部栏 - 医疗资源建档数")
    public Envelop getMedicalResourcesCount() {
        BigInteger count = resourceCenterService.getMedicalResourcesCount();
        return success(count);
    }
    @RequestMapping(value = ServiceApi.Resources.GetHealthArchiveCount, method = RequestMethod.GET)
    @ApiOperation(value = "顶部栏 - 健康档案建档数")
    public Envelop getHealthArchiveCount() throws Exception {
        long count = solrUtil.count("HealthProfile", "*:*");
        return success(count);
    }
    @RequestMapping(value = ServiceApi.Resources.GetElectronicCasesCount, method = RequestMethod.GET)
    @ApiOperation(value = "顶部栏 - 电子病例建档数")
    public Envelop getElectronicCasesCount() throws Exception{
        long count = solrUtil.count("HealthProfile", "*:*");
        return success(count);
    }
    @RequestMapping(value = ServiceApi.Resources.GetHealthCardBindingAmount, method = RequestMethod.GET)
    @ApiOperation(value = "全员人口个案库 - 健康卡绑定量")
    public Envelop getHealthCardBindingAmount() {
        //获取居民总数
        Map<String, Object> map = new HashedMap();
        map.put("search", null);
        map.put("province", null);
        map.put("city", null);
        map.put("district", null);
        map.put("gender", null);
        map.put("startDate", null);
        map.put("endDate", null);
        BigInteger totalDemographicsNum = resourceCenterService.getDemographicCount();
        //获取绑卡量 userCardsNum
        BigInteger userCardsNum = resourceCenterService.getUseCardCount();
        //计算未绑卡量 nonBindingCardNum、
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数
        BigInteger nonBindingCardNum = totalDemographicsNum.subtract(userCardsNum);
        EchartReportModel echartReportModel = new EchartReportModel();
        List<MapDataModel> mapData = new ArrayList<>();
        MapDataModel mapDataModel = null;
        mapDataModel = new MapDataModel();
        mapDataModel.setName("已绑定");
        mapDataModel.setValue(String.valueOf(userCardsNum));
        mapData.add(mapDataModel);
        mapDataModel = new MapDataModel();
        mapDataModel.setName("未绑定");
        mapDataModel.setValue(String.valueOf(nonBindingCardNum));
        mapData.add(mapDataModel);
        echartReportModel.setDataModels(mapData);
        List<EchartReportModel> quotaCategories = new ArrayList<>();
        quotaCategories.add(echartReportModel);
        Map<String, String> ma = new HashMap<>();
        ma.put("totalDemographicsNum", String.valueOf(totalDemographicsNum));
        return success(ma, quotaCategories);
    }
    @RequestMapping(value = ServiceApi.Resources.GetInfoDistribution, method = RequestMethod.GET)
    @ApiOperation(value = "全员人口个案库 - 信息分布")
    public Envelop getInfoDistribution() throws Exception {
        List<Map> resultList = new ArrayList(1);
        int currentCityId = resourceCenterService.getCurrentCityId();
        List districtList = resourceCenterService.getDistrict(currentCityId);
        List areaIdGroupList = resourceCenterService.getOrgAreaIdGroup(currentCityId);
        Map<Integer, Double> distinctMap = new HashMap();
        for (int i = 0; i < areaIdGroupList.size(); i ++) {
            Object [] dataArr = (Object[]) areaIdGroupList.get(i);
            Integer areaId = (Integer) dataArr[0];
            double count = (double) dataArr[1];
            if (areaId != null) {
                if (distinctMap.containsKey(areaId)) {
                    distinctMap.put(areaId, count + distinctMap.get(areaId));
                } else {
                    distinctMap.put(areaId, count);
                }
            }
        }
        List<String> xData = new ArrayList<>(districtList.size());
        List<Double> yData = new ArrayList<>(districtList.size());
        for (int i = 0; i < districtList.size(); i ++) {
            Object [] dataArr = (Object[]) districtList.get(i);
            Integer areaId = (Integer) dataArr[0];
            String name = (String) dataArr[1];
            xData.add(name);
            if (distinctMap.containsKey(areaId)) {
                yData.add(distinctMap.get(areaId));
            } else {
                yData.add((double)0);
            }
        }
        /*
        for(Integer areaId : distinctMap.keySet()) {
            String areaName = statisticService.getAreaNameById(areaId);
            xData.add(areaName);
            yData.add(distinctMap.get(areaId));
        }*/
        Map<String, Object> resultMap = new HashMap<>(4);
        resultMap.put("name", "人口个案信息分布");
        resultMap.put("dataModels", null);
        resultMap.put("xData", xData);
        resultMap.put("yData", yData);
        resultList.add(resultMap);
        return success(resultList);
    }
    @RequestMapping(value = ServiceApi.Resources.GetNewSituation, method = RequestMethod.GET)
    @ApiOperation(value = "全员人口个案库 - 新增情况")
    public Envelop getNewSituation() throws Exception {
        List<Map> resultList = new ArrayList(1);
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date now = DateUtils.addDays(calendar.getTime(), 1);
        Date before = DateUtils.addDays(now, -30);
        List<RangeFacet> solrList = solrUtil.getFacetDateRange("HealthProfile", "create_date", DateUtils.addHours(before, 8), DateUtils.addHours(now, 8), "+1DAY",  "*:*");
        RangeFacet rangeFacet = solrList.get(0);
        List<RangeFacet.Count> rangeFacetCounts = rangeFacet.getCounts();
        List<String> xData = new ArrayList<>(30);
        List<Integer> yData = new ArrayList<>(30);
        rangeFacetCounts.forEach(item -> {
            xData.add(item.getValue().substring(0, 10));
            yData.add(item.getCount());
        });
        Map<String, Object> resultMap = new HashMap<>(4);
        resultMap.put("name", "人口个案新增情况");
        resultMap.put("dataModels", null);
        resultMap.put("xData", xData);
        resultMap.put("yData", yData);
        resultList.add(resultMap);
        return success(resultList);
    }
    @RequestMapping(value = ServiceApi.Resources.GetOrgArchives, method = RequestMethod.GET)
    @ApiOperation(value = "医疗资源库 - 医疗机构建档分布")
    public Envelop getOrgArchives() {
        int currentCityId = resourceCenterService.getCurrentCityId();
        List districtList = resourceCenterService.getDistrict(currentCityId);
        List allGroup = resourceCenterService.getOrgAreaNameGroupByClazz(null, currentCityId);
        Map<String, BigInteger> distinctMap = new HashMap();
        for (int i = 0; i < allGroup.size(); i ++) {
            Object [] dataArr = (Object[]) allGroup.get(i);
            String name = (String) dataArr[0];
            BigInteger count = (BigInteger) dataArr[1];
            if (name != null) {
                if (distinctMap.containsKey(name)) {
                    distinctMap.put(name, count.add(distinctMap.get(name)));
                } else {
                    distinctMap.put(name, count);
                }
            }
        }
        List<String> xData = new ArrayList<>(districtList.size());
        List<BigInteger> yData = new ArrayList<>(districtList.size());
        for (int i = 0; i < districtList.size(); i ++) {
            Object [] dataArr = (Object[]) districtList.get(i);
            //Integer areaId = (Integer) dataArr[0];
            String name = (String) dataArr[1];
            xData.add(name);
            if (distinctMap.containsKey(name)) {
                yData.add(distinctMap.get(name));
            } else {
                yData.add(new BigInteger("0"));
            }
        }
        /*for(int i = 0; i < allGroup.size(); i ++) {
            Object [] dataArr = (Object [])allGroup.get(i);
            String name = (String)dataArr[0];
            BigInteger count = (BigInteger) dataArr[1];
            if(!StringUtils.isEmpty(name)) {
                xData.add(name);
                yData.add(count);
            }
        }*/
        List group1 = resourceCenterService.getOrgAreaNameGroupByClazz("1", currentCityId);
        List<String> xData1 = new ArrayList<>(xData.size());
        List<BigInteger> yData1 = new ArrayList<>(xData.size());
        for (int i = 0; i < xData.size(); i ++) {
            boolean isInit = false;
            String xName = xData.get(i);
            for (int j = 0; j < group1.size(); j ++) {
                Object [] dataArr = (Object [])group1.get(j);
                String gName = (String) dataArr[0];
                BigInteger gCount = (BigInteger) dataArr[1];
                if (!StringUtils.isEmpty(gName)) {
                    if (gName.equals(xName)) {
                        xData1.add(gName);
                        yData1.add(gCount);
                        isInit = true;
                    }
                }
            }
            if (!isInit) {
                xData1.add(xName);
                yData1.add(new BigInteger("0"));
            }
        }
        List group2 = resourceCenterService.getOrgAreaNameGroupByClazz("2", currentCityId);
        List<String> xData2 = new ArrayList<>(xData.size());
        List<BigInteger> yData2 = new ArrayList<>(xData.size());
        for (int i = 0; i < xData.size(); i ++) {
            boolean isInit = false;
            String xName = xData.get(i);
            for (int j = 0; j < group2.size(); j ++) {
                Object [] dataArr = (Object [])group2.get(j);
                String gName = (String) dataArr[0];
                BigInteger gCount = (BigInteger) dataArr[1];
                if (!StringUtils.isEmpty(gName)) {
                    if (gName.equals(xName)) {
                        xData2.add(gName);
                        yData2.add(gCount);
                        isInit = true;
                    }
                }
            }
            if (!isInit) {
                xData2.add(xName);
                yData2.add(new BigInteger("0"));
            }
        }
        List group3 = resourceCenterService.getOrgAreaNameGroupByClazz("3", currentCityId);
        List<String> xData3 = new ArrayList<>(xData.size());
        List<BigInteger> yData3 = new ArrayList<>(xData.size());
        for (int i = 0; i < xData.size(); i ++) {
            boolean isInit = false;
            String xName = xData.get(i);
            for (int j = 0; j < group3.size(); j ++) {
                Object [] dataArr = (Object [])group3.get(j);
                String gName = (String) dataArr[0];
                BigInteger gCount = (BigInteger) dataArr[1];
                if (!StringUtils.isEmpty(gName)) {
                    if (gName.equals(xName)) {
                        xData3.add(gName);
                        yData3.add(gCount);
                        isInit = true;
                    }
                }
            }
            if (!isInit) {
                xData3.add(xName);
                yData3.add(new BigInteger("0"));
            }
        }
        List group4 = resourceCenterService.getOrgAreaNameGroupByClazz("4", currentCityId);
        List<String> xData4 = new ArrayList<>(xData.size());
        List<BigInteger> yData4 = new ArrayList<>(xData.size());
        for (int i = 0; i < xData.size(); i ++) {
            boolean isInit = false;
            String xName = xData.get(i);
            for (int j = 0; j < group4.size(); j ++) {
                Object [] dataArr = (Object [])group4.get(j);
                String gName = (String) dataArr[0];
                BigInteger gCount = (BigInteger) dataArr[1];
                if (!StringUtils.isEmpty(gName)) {
                    if (gName.equals(xName)) {
                        xData4.add(gName);
                        yData4.add(gCount);
                        isInit = true;
                    }
                }
            }
            if (!isInit) {
                xData4.add(xName);
                yData4.add(new BigInteger("0"));
            }
        }
        List<Map> eChartReportModels = new ArrayList<>(5);
        Map<String, Object> allMap = new HashMap<>(4);
        allMap.put("name", "医疗机构数量");
        allMap.put("xData", xData);
        allMap.put("yData", yData);
        allMap.put("dataModels", null);
        eChartReportModels.add(allMap);
        Map<String, Object> g1Map = new HashMap<>(4);
        g1Map.put("name", "医院数量");
        g1Map.put("xData", xData1);
        g1Map.put("yData", yData1);
        g1Map.put("dataModels", null);
        eChartReportModels.add(g1Map);
        Map<String, Object> g2Map = new HashMap<>(4);
        g2Map.put("name", "基层医疗机构数量");
        g2Map.put("xData", xData2);
        g2Map.put("yData", yData2);
        g2Map.put("dataModels", null);
        eChartReportModels.add(g2Map);
        Map<String, Object> g3Map = new HashMap<>(4);
        g3Map.put("name", "专业公共卫生机构");
        g3Map.put("xData", xData3);
        g3Map.put("yData", yData3);
        g3Map.put("dataModels", null);
        eChartReportModels.add(g3Map);
        Map<String, Object> g4Map = new HashMap<>(4);
        g4Map.put("name", "其他卫生机构");
        g4Map.put("xData", xData4);
        g4Map.put("yData", yData4);
        g4Map.put("dataModels", null);
        eChartReportModels.add(g4Map);
        return success(eChartReportModels);
    }
    @RequestMapping(value = ServiceApi.Resources.GetMedicalStaffDistribution, method = RequestMethod.GET)
    @ApiOperation(value = "医疗资源库 - 医疗人员分布")
    public Envelop getMedicalStaffDistribution() {
        int currentCityId = resourceCenterService.getCurrentCityId();
        List districtList = resourceCenterService.getDistrict(currentCityId);
        List<Map> eChartReportModels = new ArrayList<>(2);
        Map<Integer, BigInteger> distinctMap = new HashMap();
        //医生信息
        List doctorGroup = resourceCenterService.getMedicalAreaCountGroupByRole("Doctor", currentCityId);
        for (int i = 0; i < doctorGroup.size(); i ++) {
            Object [] dataArr = (Object[]) doctorGroup.get(i);
            if (dataArr[0] != null) {
                Integer areaId = (Integer) dataArr[0];
                BigInteger count = (BigInteger) dataArr[1];
                if (areaId != null) {
                    if (distinctMap.containsKey(areaId)) {
                        distinctMap.put(areaId, count.add(distinctMap.get(areaId)));
                    } else {
                        distinctMap.put(areaId, count);
                    }
                }
            }
        }
        List<String> xData = new ArrayList<>(districtList.size());
        List<BigInteger> yData = new ArrayList<>(districtList.size());
        for (int i = 0; i < districtList.size(); i ++) {
            Object [] dataArr = (Object[]) districtList.get(i);
            Integer areaId = (Integer) dataArr[0];
            String name = (String) dataArr[1];
            xData.add(name);
            if (distinctMap.containsKey(areaId)) {
                yData.add(distinctMap.get(areaId));
            } else {
                yData.add(new BigInteger("0"));
            }
        }
        //护士信息
        distinctMap.clear();
        List nurseGroup = resourceCenterService.getMedicalAreaCountGroupByRole("Nurse", currentCityId);
        for (int i = 0; i < nurseGroup.size(); i ++) {
            Object [] dataArr = (Object[]) nurseGroup.get(i);
            if (dataArr[0] != null) {
                Integer areaId = (Integer) dataArr[0];
                BigInteger count = (BigInteger) dataArr[1];
                if (areaId != null) {
                    if (distinctMap.containsKey(areaId)) {
                        distinctMap.put(areaId, count.add(distinctMap.get(areaId)));
                    } else {
                        distinctMap.put(areaId, count);
                    }
                }
            }
        }
        List<String> xData1 = new ArrayList<>(districtList.size());
        List<BigInteger> yData1 = new ArrayList<>(districtList.size());
        for (int i = 0; i < districtList.size(); i ++) {
            Object [] dataArr = (Object[]) districtList.get(i);
            Integer areaId = (Integer) dataArr[0];
            String name = (String) dataArr[1];
            xData1.add(name);
            if (distinctMap.containsKey(areaId)) {
                yData1.add(distinctMap.get(areaId));
            } else {
                yData1.add(new BigInteger("0"));
            }
        }
        Map<String, Object> doctorMap = new HashMap<>(4);
        doctorMap.put("name", "医生");
        doctorMap.put("xData", xData);
        doctorMap.put("yData", yData);
        doctorMap.put("dataModels", null);
        eChartReportModels.add(doctorMap);
        Map<String, Object> nurseMap = new HashMap<>(4);
        nurseMap.put("name", "护士");
        nurseMap.put("xData", xData1);
        nurseMap.put("yData", yData1);
        nurseMap.put("dataModels", null);
        eChartReportModels.add(nurseMap);
        return success(eChartReportModels);
    }
    @RequestMapping(value = ServiceApi.Resources.GetMedicalStaffRatio, method = RequestMethod.GET)
    @ApiOperation(value = "医疗资源库 - 医护人员比例")
    public Envelop getMedicalStaffRatio() {
        EchartReportModel echartReportModel = new EchartReportModel();
        //根据角色/医院获取Doctor总数
        int currentCityId = resourceCenterService.getCurrentCityId();
        BigInteger doctorCount = resourceCenterService.getMedicalCountByRoleType("Doctor", currentCityId);
        List<MapDataModel> MapDataModelList = new ArrayList<>();
        MapDataModel mapDataModel = new MapDataModel();
        mapDataModel.setName("医生");
        mapDataModel.setValue(String.valueOf(doctorCount));
        MapDataModelList.add(mapDataModel);
        BigInteger nurseCount = resourceCenterService.getMedicalCountByRoleType("Nurse", currentCityId);
        mapDataModel = new MapDataModel();
        mapDataModel.setName("护士");
        mapDataModel.setValue(String.valueOf(nurseCount));
        MapDataModelList.add(mapDataModel);
        echartReportModel.setDataModels(MapDataModelList);
        return success(echartReportModel);
    }
    @RequestMapping(value = ServiceApi.Resources.GetCumulativeIntegration, method = RequestMethod.GET)
    @ApiOperation(value = "健康档案 - 累计整合档案数")
    public Envelop getCumulativeIntegration() throws Exception {
        double count = resourceCenterService.getJsonArchiveCount("3");
        return success(count);
    }
    @RequestMapping(value = ServiceApi.Resources.GteTotallyToBeIntegrated, method = RequestMethod.GET)
    @ApiOperation(value = "健康档案 - 累计待整合档案数")
    public Envelop gteTotallyToBeIntegrated() throws Exception {
        double count = resourceCenterService.getJsonArchiveCount("0");
        return success(count);
    }
    @RequestMapping(value = ServiceApi.Resources.GetArchiveSource, method = RequestMethod.GET)
    @ApiOperation(value = "健康档案 - 档案来源分布情况")
    public Envelop getArchiveSource() throws Exception {
        long clinic = solrUtil.count("HealthProfile", "event_type:0");
        long resident = solrUtil.count("HealthProfile", "event_type:1");
        long medicalExam = solrUtil.count("HealthProfile", "event_type:2");
        List<Map> eChartReportModelList = new ArrayList<>(3);
        Map<String, Object> clinicMap = new HashMap<>(2);
        clinicMap.put("name", "门诊");
        clinicMap.put("value", clinic);
        eChartReportModelList.add(clinicMap);
        Map<String, Object> residentMap = new HashMap<>(2);
        residentMap.put("name", "住院");
        residentMap.put("value", resident);
        eChartReportModelList.add(residentMap);
        Map<String, Object> medicalExamMap = new HashMap<>(2);
        medicalExamMap.put("name", "体检");
        medicalExamMap.put("value", medicalExam);
        eChartReportModelList.add(medicalExamMap);
        List<Map> resultList = new ArrayList<>(1);
        Map<String, Object> dataMap = new HashMap<>(4);
        dataMap.put("name", null);
        dataMap.put("xData", null);
        dataMap.put("yData", null);
        dataMap.put("dataModels", eChartReportModelList);
        resultList.add(dataMap);
        Map<String, Long> resultMap = new HashMap<>(4);
        resultMap.put("clinic", clinic);
        resultMap.put("resident", resident);
        resultMap.put("medicalExam", medicalExam);
        resultMap.put("total", clinic + resident + medicalExam);
        return success(resultMap, resultList);
    }
    @RequestMapping(value = ServiceApi.Resources.GetArchiveDistribution, method = RequestMethod.GET)
    @ApiOperation(value = "健康档案 - 健康档案分布情况")
    public Envelop getArchiveDistribution() {
        //获取年龄字典
        /**
        List<SystemDictEntry> ageDictEntryList = statisticService.getSystemDictEntry((long)89);
        if (ageDictEntryList != null) {
            Map<String, Integer> ageMap = new LinkedHashMap<>();
            for (SystemDictEntry systemDictEntry : ageDictEntryList) {
                ageMap.put(systemDictEntry.getValue(), 0);
            }
            List<Object []> allGroup = statisticService.newStatisticsDemographicsAgeCount();
            Map<String, BigInteger> maleGroup = new HashMap<>(ageMap.size());
            Map<String, BigInteger> femaleGroup = new HashMap<>(ageMap.size());
            for(Object [] dataArr : allGroup) {
                String gender = (String) dataArr[2];
                String age = (String) dataArr[1];
                BigInteger count = (BigInteger) dataArr[0];
                if(gender.equals("1")) {
                    maleGroup.put(age, count);
                }else {
                    femaleGroup.put(age, count);
                }
            }
            List<String> xData = new ArrayList<>(ageMap.size());
            List<BigInteger> yData = new ArrayList<>(ageMap.size());
            List<String> xData1 = new ArrayList<>(ageMap.size());
            List<BigInteger> yData1 = new ArrayList<>(ageMap.size());
            for(String key : ageMap.keySet()) {
                xData.add(key);
                xData1.add(key);
                if(maleGroup.containsKey(key)) {
                    yData.add(maleGroup.get(key));
                }else {
                    yData.add(new BigInteger("0"));
                }
                if(femaleGroup.containsKey(key)) {
                    yData1.add(femaleGroup.get(key));
                }else {
                    yData1.add(new BigInteger("0"));
                }
            }
            List<Map> resultList = new ArrayList<>(2);
            Map<String, Object> resultMap = new HashMap<>(4);
            resultMap.put("name", "男");
            resultMap.put("dataModels", null);
            resultMap.put("xData", xData);
            resultMap.put("yData", yData);
            resultList.add(resultMap);
            Map<String, Object> resultMap1 = new HashMap<>(4);
            resultMap1.put("name", "女");
            resultMap1.put("dataModels", null);
            resultMap1.put("xData", xData1);
            resultMap1.put("yData", yData1);
            resultList.add(resultMap1);
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(resultList);
            return envelop;
        } else { //年龄字典为空的时候
            Map<String, Integer> ageMap = getDefaultAgeMap();
            List<Object []> allGroup = statisticService.newStatisticsDemographicsAgeCount();
            Map<String, BigInteger> maleGroup = new HashMap<>();
            Map<String, BigInteger> femaleGroup = new HashMap<>();
            for(Object [] dataArr : allGroup) {
                String gender = (String) dataArr[2];
                String age = (String) dataArr[1];
                BigInteger count = (BigInteger) dataArr[0];
                if(gender.equals("1")) {
                    maleGroup.put(age, count);
                }else {
                    femaleGroup.put(age, count);
                }
            }
            List<String> xData = new ArrayList<>();
            List<BigInteger> yData = new ArrayList<>();
            List<String> xData1 = new ArrayList<>();
            List<BigInteger> yData1 = new ArrayList<>();
            for(String key : ageMap.keySet()) {
                xData.add(key);
                xData1.add(key);
                if(maleGroup.containsKey(key)) {
                    yData.add(maleGroup.get(key));
                }else {
                    yData.add(new BigInteger("0"));
                }
                if(femaleGroup.containsKey(key)) {
                    yData1.add(femaleGroup.get(key));
                }else {
                    yData1.add(new BigInteger("0"));
                }
            }
            List<Map> resultList = new ArrayList<>(2);
            Map<String, Object> resultMap = new HashMap<>(4);
            resultMap.put("name", "男");
            resultMap.put("dataModels", null);
            resultMap.put("xData", xData);
            resultMap.put("yData", yData);
            resultList.add(resultMap);
            Map<String, Object> resultMap1 = new HashMap<>(4);
            resultMap1.put("name", "女");
            resultMap1.put("dataModels", null);
            resultMap1.put("xData", xData1);
            resultMap1.put("yData", yData1);
            resultList.add(resultMap1);
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(resultList);
            return envelop;
        }*/
        Map<String, Integer> ageMap = getDefaultAgeMap();
        List<Object []> allGroup = resourceCenterService.newStatisticsDemographicsAgeCount();
        Map<String, BigInteger> maleGroup = new HashMap<>();
        Map<String, BigInteger> femaleGroup = new HashMap<>();
        for (Object [] dataArr : allGroup) {
            String gender = (String) dataArr[2];
            String age = (String) dataArr[1];
            BigInteger count = (BigInteger) dataArr[0];
            if (gender.equals("1")) {
                maleGroup.put(age, count);
            } else {
                femaleGroup.put(age, count);
            }
        }
        List<String> xData = new ArrayList<>();
        List<BigInteger> yData = new ArrayList<>();
        List<String> xData1 = new ArrayList<>();
        List<BigInteger> yData1 = new ArrayList<>();
        for (String key : ageMap.keySet()) {
            xData.add(key);
            xData1.add(key);
            if (maleGroup.containsKey(key)) {
                yData.add(maleGroup.get(key));
            } else {
                yData.add(new BigInteger("0"));
            }
            if (femaleGroup.containsKey(key)) {
                yData1.add(femaleGroup.get(key));
            } else {
                yData1.add(new BigInteger("0"));
            }
        }
        List<Map> resultList = new ArrayList<>(2);
        Map<String, Object> resultMap = new HashMap<>(4);
        resultMap.put("name", "男");
        resultMap.put("dataModels", null);
        resultMap.put("xData", xData);
        resultMap.put("yData", yData);
        resultList.add(resultMap);
        Map<String, Object> resultMap1 = new HashMap<>(4);
        resultMap1.put("name", "女");
        resultMap1.put("dataModels", null);
        resultMap1.put("xData", xData1);
        resultMap1.put("yData", yData1);
        resultList.add(resultMap1);
        return success(resultList);
    }
    private  Map<String, Integer> getDefaultAgeMap() {
        Map<String, Integer> map = new LinkedHashMap<>(5);
        map.put("0-6", 0);
        map.put("7-17", 0);
        map.put("18-40", 0);
        map.put("41-65", 0);
        map.put("> 65", 0);
        return map;
    }
    @RequestMapping(value = ServiceApi.Resources.GetStorageAnalysis, method = RequestMethod.GET)
    @ApiOperation(value = "健康档案 - 健康档案入库情况分析")
    public Envelop getStorageAnalysis() throws Exception {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date now = DateUtils.addDays(calendar.getTime(), 1);
        Date before = DateUtils.addDays(now, -29);
        Map<String, Long> receiveGroup = resourceCenterService.getJsonArchiveReceiveDateGroup(before, now);
        Map<String, Long> finishGroup = resourceCenterService.getJsonArchiveFinishDateGroup(before, now);
        List<String> xData = new ArrayList<>(30);
        List<Long> yData = new ArrayList<>(30);
        List<String> xData1 = new ArrayList<>(30);
        List<Long> yData1 = new ArrayList<>(30);
        for (int i = 30; i >= 1; i --) {
            String _day = dateFormat.format(DateUtils.addDays(now, -i));
            //采集量
            xData.add(_day);
            if (receiveGroup.containsKey(_day)) {
                yData.add(receiveGroup.get(_day));
            } else {
                yData.add(0L);
            }
            //入库量
            xData1.add(_day);
            if (finishGroup.containsKey(_day)) {
                yData1.add(finishGroup.get(_day));
            } else {
                yData1.add(0L);
            }
        }
        List<Map> resultList = new ArrayList<>(2);
        Map<String, Object> resultMap = new HashMap<>(4);
        resultMap.put("name", "采集量");
        resultMap.put("dataModels", null);
        resultMap.put("xData", xData);
        resultMap.put("yData", yData);
        resultList.add(resultMap);
        Map<String, Object> resultMap1 = new HashMap<>(4);
        resultMap1.put("name", "入库量");
        resultMap1.put("dataModels", null);
        resultMap1.put("xData", xData1);
        resultMap1.put("yData", yData1);
        resultList.add(resultMap1);
        return success(resultList);
    }
    @RequestMapping(value = ServiceApi.Resources.GetElectronicMedicalSource, method = RequestMethod.GET)
    @ApiOperation(value = "电子病例 - 电子病例来源分布情况")
    public Envelop getElectronicMedicalSource() throws Exception {
        long clinic = solrUtil.count("HealthProfile", "event_type:0");
        Map<String, Object> clinicMap = new HashedMap();
        clinicMap.put("name", "门诊");
        clinicMap.put("value", clinic);
        long resident = solrUtil.count("HealthProfile", "event_type:1");
        Map<String, Object> residentMap = new HashedMap();
        residentMap.put("name", "住院");
        residentMap.put("value", resident);
        long medicalExam = solrUtil.count("HealthProfile", "event_type:2");
        Map<String, Object> medicalExamMap = new HashedMap();
        medicalExamMap.put("name", "体检");
        medicalExamMap.put("value", medicalExam);
        List<Map> dataModels = new ArrayList<>();
        dataModels.add(clinicMap);
        dataModels.add(residentMap);
        dataModels.add(medicalExamMap);
        List<Map> resultList = new ArrayList<>();
        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("name", null);
        dataMap.put("xData", null);
        dataMap.put("yData", null);
        dataMap.put("dataModels", dataModels);
        resultList.add(dataMap);
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("门诊/住院/体检", clinic + resident + medicalExam);
        resultMap.put("门诊", clinic);
        resultMap.put("住院", resident);
        resultMap.put("体检", medicalExam);
        return success(resultMap, resultList);
    }
    @RequestMapping(value = ServiceApi.Resources.GetElectronicMedicalOrgDistributed, method = RequestMethod.GET)
    @ApiOperation(value = "电子病例 - 电子病历采集医院分布")
    public Envelop getElectronicMedicalOrgDistributed() throws Exception {
        int currentCityId = resourceCenterService.getCurrentCityId();
        FacetField facetField = solrUtil.getFacetField("HealthProfile", "org_code", null, 0, 0, 1000000, false);
        List<FacetField.Count> countList = facetField.getValues();
        Map<String, Long> dataMap = new HashMap<>(countList.size());
        for (FacetField.Count count : countList) {
            String orgCode = count.getName();
            Integer areaId = resourceCenterService.getOrgAreaByCode(orgCode, currentCityId);
            if (areaId != null && areaId != 0) {
                String orgName = resourceCenterService.getOrgNameByCode(orgCode);
                if (!StringUtils.isEmpty(orgName)) {
                    long count1 = count.getCount();
                    dataMap.put(orgName, count1);
                }
            }
        }
        return success(dataMap);
    }
    @RequestMapping(value = ServiceApi.Resources.GetElectronicMedicalDeptDistributed, method = RequestMethod.GET)
    @ApiOperation(value = "电子病例 - 电子病历采集科室分布")
    public Envelop getElectronicMedicalDeptDistributed() throws Exception{
        Envelop envelop = new Envelop();
        Envelop orgEnvelop = getElectronicMedicalOrgDistributed();
        if (orgEnvelop.isSuccessFlg() ) {
            Map result1 = (Map)orgEnvelop.getObj();
            if (result1.size() <= 0) {
                envelop.setSuccessFlg(true);
                envelop.setObj(new HashMap<>());
                return envelop;
            }
        } else {
            envelop.setSuccessFlg(false);
            envelop.setErrorCode(orgEnvelop.getErrorCode());
            envelop.setErrorMsg(orgEnvelop.getErrorMsg());
            envelop.setObj(new HashMap<>());
            return envelop;
        }
        FacetField facetField = solrUtil.getFacetField("HealthProfile", "EHR_000081", null, 0, 0, 1000000, false);
        List<FacetField.Count> countList = facetField.getValues();
        Map<String, Long> dataMap = new HashMap<>(countList.size());
        for (FacetField.Count count : countList) {
            String deptCode = count.getName();
            String deptName = redisService.getDictEntryValue("59083976eebd", "253", deptCode);
            if (!StringUtils.isEmpty(deptName)) {
                long count1 = count.getCount();
                dataMap.put(deptName, count1);
            }
        }
        envelop.setSuccessFlg(true);
        envelop.setObj(dataMap);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.Resources.GetElectronicMedicalAcquisitionSituation, method = RequestMethod.GET)
    @ApiOperation(value = "电子病例 - 电子病历采集采集情况")
    public Envelop getElectronicMedicalAcquisitionSituation() throws Exception {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date now = DateUtils.addDays(calendar.getTime(), 1);
        Date before = DateUtils.addDays(now, -30);
        List<RangeFacet> clinicList = solrUtil.getFacetDateRange("HealthProfile", "create_date", DateUtils.addHours(before, 8), DateUtils.addHours(now, 8), "+1DAY", "event_type:0");
        RangeFacet clinicRangeFacet = clinicList.get(0);
        List<RangeFacet.Count> clinicCount = clinicRangeFacet.getCounts();
        Map<String, Integer> dataMap1 = new LinkedHashMap<>(clinicCount.size());
        for (RangeFacet.Count count : clinicCount) {
            dataMap1.put(count.getValue().substring(0, 10), count.getCount());
        }
        List<RangeFacet> residentList = solrUtil.getFacetDateRange("HealthProfile", "create_date", DateUtils.addHours(before, 8), DateUtils.addHours(now, 8), "+1DAY", "event_type:1");
        RangeFacet residentRangeFacet = residentList.get(0);
        List<RangeFacet.Count> residentCount = residentRangeFacet.getCounts();
        Map<String, Integer> dataMap2 = new LinkedHashMap<>(residentCount.size());
        for (RangeFacet.Count count : residentCount) {
            dataMap2.put(count.getValue().substring(0, 10), count.getCount());
        }
        List<Map> resultList = new ArrayList<>(2);
        resultList.add(dataMap1);
        resultList.add(dataMap2);
        return success(resultList);
    }
    // ------------------------------- 统计相关 end ------------------------------------
    // ------------------------------- 大数据展示相关 start ------------------------------------
    @RequestMapping(value = ServiceApi.Resources.Achievements, method = RequestMethod.GET)
    @ApiOperation(value = "成果展示")
    public Envelop achievements() throws Exception {
        List<Map<String, Object>> resultList = new ArrayList<>();
        //数据采集
        List<Object[]> list1 = resourceCenterService.findAppFeatureIdAndNameByAppIdAndCode("EHR_Quality_Trend", "zkGuSIm2Fg");
        if (list1.size() > 0) {
            Map<String, Object> dataMap1 = new LinkedHashMap<>();
            Object [] data = list1.get(0);
            Integer id = (Integer) data[0];
            String name = (String) data[1];
            dataMap1.put("label", "数据采集");
            dataMap1.put("appId", "zkGuSIm2Fg");
            dataMap1.put("name", name);
            dataMap1.put("menuId", id);
            double total = resourceCenterService.getJsonArchiveTotalCount();
            dataMap1.put("total", total);
            Map<String, Object> dataMap2 = new HashMap<>();
            List<Map<String, Object>> pieList1 = new ArrayList<>();
            double count1 = resourceCenterService.getJsonArchiveCount("3");
            Map<String, Object> pieMap1 = new HashMap<>();
            pieMap1.put("成功总量", count1);
            pieList1.add(pieMap1);
            double count2 = resourceCenterService.getJsonArchiveCount("2");
            Map<String, Object> pieMap2 = new HashMap<>();
            pieMap2.put("失败总量", count2);
            pieList1.add(pieMap2);
            dataMap2.put("1", pieList1);
            dataMap1.put("view", dataMap2);
            resultList.add(dataMap1);
        }
        //数据存储
        List<Object[]> list2 = resourceCenterService.findAppFeatureIdAndNameByAppIdAndCode("Ehr_Data_Gateway", "R1yHNdX5Ud");
        if (list2.size() > 0) {
            Map<String, Object> dataMap1 = new LinkedHashMap<>();
            Object [] data = list2.get(0);
            Integer id = (Integer) data[0];
            String name = (String) data[1];
            dataMap1.put("label", "数据存储");
            dataMap1.put("appId", "R1yHNdX5Ud");
            dataMap1.put("name", name);
            dataMap1.put("menuId", id);
            Map<String, Object> dataMap2 = new HashMap<>();
            List<Map<String, Object>> pieList1 = new ArrayList<>();
            long count1 = solrUtil.count("HealthProfile", "*:*");
            Map<String, Object> pieMap1 = new HashMap<>();
            pieMap1.put("patient", count1);
            pieList1.add(pieMap1);
            BigInteger count2 = resourceCenterService.getMedicalResourcesCount();
            Map<String, Object> pieMap2 = new HashMap<>();
            pieMap2.put("medicalResources", count2);
            pieList1.add(pieMap2);
            double count3 = resourceCenterService.getJsonArchiveCount("3");
            Map<String, Object> pieMap3 = new HashMap<>();
            pieMap3.put("healthArchive", count3);
            pieList1.add(pieMap3);
            long count4 = solrUtil.count("HealthProfile", "*:*");
            Map<String, Object> pieMap4 = new HashMap<>();
            pieMap4.put("electronicCases", count4);
            pieList1.add(pieMap4);
            dataMap2.put("1", pieList1);
            dataMap1.put("view", dataMap2);
            resultList.add(dataMap1);
        }
        return success(resultList);
    }
    @RequestMapping(value = ServiceApi.Resources.Visualization, method = RequestMethod.GET)
    @ApiOperation(value = "可视化")
    public Envelop visualization() throws Exception {
        List<Map<String, Object>> resultList = new ArrayList<>();
        //已配置视图
        List<Object[]> list1 = resourceCenterService.findAppFeatureIdAndNameByAppIdAndCode("Resource_ResourceManage_Initial", "zkGuSIm2Fg");
        if (list1.size() > 0) {
            Map<String, Object> dataMap1 = new LinkedHashMap<>();
            Object [] data = list1.get(0);
            Integer id = (Integer) data[0];
            String name = (String) data[1];
            dataMap1.put("label", "已配置视图");
            dataMap1.put("appId", "zkGuSIm2Fg");
            dataMap1.put("name", name);
            dataMap1.put("menuId", id);
            BigInteger total = resourceCenterService.getTotalViewCount(null);
            dataMap1.put("total", total);
            //大分类
            Map<String, Object> dataMap2 = new HashMap<>();
            List<Map<String, Object>> pieList1 = new ArrayList<>();
            BigInteger dataSource1 = resourceCenterService.getTotalViewCount(1);
            Map<String, Object> pieMap1 = new LinkedHashMap<>();
            pieMap1.put("档案数据", dataSource1);
            pieList1.add(pieMap1);
            BigInteger dataSource2 = resourceCenterService.getTotalViewCount(2);
            Map<String, Object> pieMap2 = new LinkedHashMap<>();
            pieMap2.put("指标统计", dataSource2);
            pieList1.add(pieMap2);
            dataMap2.put("1", pieList1);
            //小分类
            List<Map<String, Object>> pieList2 = new ArrayList<>();
            List<Object[]> cateList = resourceCenterService.getResourceCategoryIdAndNameList();
            for (Object [] temp : cateList) {
                Map<String, Object> pieMap3 = new HashMap<>();
                String cateId = (String) temp[0];
                String cateName = (String) temp[1];
                BigInteger count1 = resourceCenterService.countResourceByResourceCateIdAndDataSource(cateId, 1);
                if (count1.compareTo(new BigInteger("0")) > 0) {
                    pieMap3.put(cateName, count1);
                    pieList2.add(pieMap3);
                }
            }
            for (Object [] temp : cateList) {
                Map<String, Object> pieMap3 = new HashMap<>();
                String cateId = (String) temp[0];
                String cateName = (String) temp[1];
                BigInteger count1 = resourceCenterService.countResourceByResourceCateIdAndDataSource(cateId, 2);
                if (count1.compareTo(new BigInteger("0")) > 0) {
                    pieMap3.put(cateName, count1);
                    pieList2.add(pieMap3);
                }
            }
            dataMap2.put("2", pieList2);
            dataMap1.put("view", dataMap2);
            resultList.add(dataMap1);
        }
        //已配置资源报表
        List<Object[]> list2 = resourceCenterService.findAppFeatureIdAndNameByAppIdAndCode("Ehr_Resource_Report_Index", "zkGuSIm2Fg");
        if (list2.size() > 0) {
            Map<String, Object> dataMap1 = new LinkedHashMap<>();
            Object [] data = list2.get(0);
            Integer id = (Integer) data[0];
            String name = (String) data[1];
            dataMap1.put("label", "已配置资源报表");
            dataMap1.put("appId", "zkGuSIm2Fg");
            dataMap1.put("name", name);
            dataMap1.put("menuId", id);
            BigInteger total = resourceCenterService.getTotalReportCount();
            dataMap1.put("total", total);
            Map<String, Object> dataMap2 = new HashMap<>();
            List<Map<String, Object>> pieList1 = new ArrayList<>();
            List<Object[]> cateList = resourceCenterService.getReportCategoryIdAndNameList();
            for (Object [] temp : cateList) {
                Map<String, Object> pieMap3 = new HashMap<>();
                Integer cateId = (Integer) temp[0];
                String cateName = (String) temp[1];
                BigInteger count1 = resourceCenterService.countReportByReportCateId(cateId);
                if (count1.compareTo(new BigInteger("0")) > 0) {
                    pieMap3.put(cateName, count1);
                    pieList1.add(pieMap3);
                }
            }
            dataMap2.put("1", pieList1);
            dataMap1.put("view", dataMap2);
            resultList.add(dataMap1);
        }
        return success(resultList);
    }
    @RequestMapping(value = ServiceApi.Resources.DataAnalysis, method = RequestMethod.GET)
    @ApiOperation(value = "数据分析")
    public Envelop dataAnalysis() throws Exception {
        List<Map<String, Object>> resultList = new ArrayList<>();
        //已注册指标
        List<Object[]> list1 = resourceCenterService.findAppFeatureIdAndNameByAppIdAndCode("Ehr_Zhibiao_Initial", "zkGuSIm2Fg");
        if (list1.size() > 0) {
            Map<String, Object> dataMap1 = new LinkedHashMap<>();
            Object [] data = list1.get(0);
            Integer id = (Integer) data[0];
            String name = (String) data[1];
            dataMap1.put("label", "已注册指标");
            dataMap1.put("appId", "zkGuSIm2Fg");
            dataMap1.put("name", name);
            dataMap1.put("menuId", id);
            BigInteger total = resourceCenterService.getTotalQuotaCount();
            dataMap1.put("total", total);
            Map<String, Object> dataMap2 = new HashMap<>();
            List<Map<String, Object>> pieList1 = new ArrayList<>();
            List<Object[]> cateList = resourceCenterService.getQuotaCategoryIdAndNameList();
            for (Object [] temp : cateList) {
                Map<String, Object> pieMap3 = new HashMap<>();
                Integer cateId = (Integer) temp[0];
                String cateName = (String) temp[1];
                BigInteger count1 = resourceCenterService.countQuotaByQuotaCateId(cateId);
                if (count1.compareTo(new BigInteger("0")) > 0) {
                    pieMap3.put(cateName, count1);
                    pieList1.add(pieMap3);
                }
            }
            dataMap2.put("1", pieList1);
            dataMap1.put("view", dataMap2);
            resultList.add(dataMap1);
        }
        return success(resultList);
    }
    @RequestMapping(value = ServiceApi.Resources.HierarchicalManagement, method = RequestMethod.GET)
    @ApiOperation(value = "分级管理")
    public Envelop hierarchicalManagement() throws Exception {
        List<Map<String, Object>> resultList = new ArrayList<>();
        //机构数据授权
        List<Object[]> list1 = resourceCenterService.findAppFeatureIdAndNameByAppIdAndCode("Ehr_Security_Org_Auth", "zkGuSIm2Fg");
        if (list1.size() > 0) {
            Map<String, Object> dataMap = new LinkedHashMap<>();
            Object [] data = list1.get(0);
            Integer id = (Integer) data[0];
            String name = (String) data[1];
            dataMap.put("label", "机构数据授权");
            dataMap.put("appId", "zkGuSIm2Fg");
            dataMap.put("name", name);
            dataMap.put("menuId", id);
            resultList.add(dataMap);
        }
        //应用授权
        List<Object[]> list2 = resourceCenterService.findAppFeatureIdAndNameByAppIdAndCode("Ehr_Public_Thirdparty_App", "zkGuSIm2Fg");
        if (list2.size() > 0) {
            Map<String, Object> dataMap = new LinkedHashMap<>();
            Object [] data = list2.get(0);
            Integer id = (Integer) data[0];
            String name = (String) data[1];
            dataMap.put("label", "应用授权");
            dataMap.put("appId", "zkGuSIm2Fg");
            dataMap.put("name", name);
            dataMap.put("menuId", id);
            resultList.add(dataMap);
        }
        //角色授权
        List<Object[]> list3 = resourceCenterService.findAppFeatureIdAndNameByAppIdAndCode("UserRoles_Initial", "zkGuSIm2Fg");
        if (list3.size() > 0) {
            Map<String, Object> dataMap = new LinkedHashMap<>();
            Object [] data = list3.get(0);
            Integer id = (Integer) data[0];
            String name = (String) data[1];
            dataMap.put("label", "角色授权");
            dataMap.put("appId", "zkGuSIm2Fg");
            dataMap.put("name", name);
            dataMap.put("menuId", id);
            resultList.add(dataMap);
        }
        return success(resultList);
    }
    // ------------------------------- 大数据展示相关 end ------------------------------------
}

+ 247 - 0
src/main/java/com/yihu/ehr/resource/controller/ResourceIntegratedEndPoint.java

@ -0,0 +1,247 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.query.common.model.QueryCondition;
import com.yihu.ehr.resource.model.RsResource;
import com.yihu.ehr.resource.model.RsResourceDefaultParam;
import com.yihu.ehr.resource.model.RsResourceQuota;
import com.yihu.ehr.resource.model.RsResourceMetadata;
import com.yihu.ehr.resource.service.*;
import com.yihu.ehr.util.id.BizObject;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
 * Created by Progr1mmer on 2017/08.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsResourceIntegratedEndPoint", description = "资源综合查询", tags = {"资源服务-资源综合查询"})
public class ResourceIntegratedEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private ResourceIntegratedService resourcesIntegratedService;
    @Autowired
    private RsResourceService rsService;
    @Autowired
    private ResourceBrowseService resourceBrowseService;
    @Autowired
    private RsResourceDefaultParamService resourceDefaultParamService;
    @Deprecated
    @ApiOperation("综合查询档案数据列表树")
    @RequestMapping(value = ServiceApi.Resources.IntMetadataList, method = RequestMethod.GET)
    public Envelop getMetadataList(
            @ApiParam(name = "userResource", value = "授权资源", required = true)
            @RequestParam(value = "userResource") String userResource,
            @ApiParam(name = "roleId", value = "角色id", required = true)
            @RequestParam(value = "roleId") String roleId,
            @ApiParam(name = "categoryCode", value = "视图分类", required = true)
            @RequestParam(value = "categoryCode") String categoryCode,
            @ApiParam(name = "filters", value = "过滤条件(name)")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List list = resourcesIntegratedService.getMetadataList(userResource, roleId, categoryCode, filters);
        return success(list);
    }
    @ApiOperation("综合查询档案数据分类列表")
    @RequestMapping(value = ServiceApi.Resources.IntCategory, method = RequestMethod.GET)
    public Envelop intCategory(
            @ApiParam(name = "categoryCode", value = "视图分类", required = true)
            @RequestParam(value = "categoryCode") String categoryCode
    ) throws Exception {
        Map<String, Object> baseMap = new HashMap<>();
        baseMap.put("baseInfo", new ArrayList<>());
        List<Map<String, Object>> list = resourcesIntegratedService.intCategory(categoryCode);
        return success(baseMap, list);
    }
    @ApiOperation("综合查询档案数据资源列表")
    @RequestMapping(value = ServiceApi.Resources.IntMetadata, method = RequestMethod.GET)
    public Envelop intMetadata(
            @ApiParam(name = "categoryId", value = "分类ID", required = true)
            @RequestParam(value = "categoryId") String categoryId,
            @ApiParam(name = "userResource", value = "授权资源", required = true)
            @RequestParam(value = "userResource") String userResource,
            @ApiParam(name = "roleId", value = "角色id", required = true)
            @RequestParam(value = "roleId") String roleId,
            @ApiParam(name = "categoryCode", value = "视图分类")
            @RequestParam(value = "categoryCode") String categoryCode,
            @ApiParam(name = "filters", value = "过滤条件(name)")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<Map<String, Object>> list = resourcesIntegratedService.intMetadata(categoryId, userResource, roleId, categoryCode, filters);
        return success(list);
    }
    @ApiOperation("综合查询档案数据检索")
    @RequestMapping(value = ServiceApi.Resources.IntMetadataData, method = RequestMethod.GET)
    public Envelop searchMetadataData(
            @ApiParam(name = "resourcesCode", value = "资源编码([\"code\"])")
            @RequestParam(value = "resourcesCode") String resourcesCode,
            @ApiParam(name = "metaData", value = "数据元([\"metadataId\"])")
            @RequestParam(value = "metaData", required = false) String metaData,
            @ApiParam(name = "orgCode", value = "机构编码(orgCode)")
            @RequestParam(value = "orgCode") String orgCode,
            @ApiParam(name = "areaCode", value = "地区编码(areaCode)")
            @RequestParam(value = "areaCode") String areaCode,
            @ApiParam(name = "queryCondition", value = "查询条件[{\"andOr\":\"(AND)(OR)\",\"condition\":\"(<)(=)(>)\",\"field\":\"fieldName\",\"value\":\"value\"}]")
            @RequestParam(value = "queryCondition", required = false) String queryCondition,
            @ApiParam(name = "page", value = "第几页(>0)")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "size", value = "每页几行(>0)")
            @RequestParam(value = "size", required = false) Integer size) throws Exception {
        return resourceBrowseService.getCustomizeData(resourcesCode, metaData, orgCode, areaCode, queryCondition, page, size);
    }
    @ApiOperation("综合查询指标统计列表树")
    @RequestMapping(value = ServiceApi.Resources.IntQuotaList, method = RequestMethod.GET)
    public Envelop getQuotaList(
            @ApiParam(name = "filters", value = "过滤条件(name)", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<Map<String, Object>> list = resourcesIntegratedService.getQuotaList(filters);
        return success(list);
    }
    @ApiOperation("综合查询视图保存")
    @RequestMapping(value = ServiceApi.Resources.IntResourceUpdate, method = RequestMethod.POST)
    public Envelop updateResource(
            @ApiParam(name = "dataJson", value = "JSON对象参数({\"resource\":\"objStr\",\"(metadatas)(quotas)\":\"[objStr]\",\"queryCondition\":\"([])({})\"})", required = true)
            @RequestParam(value = "dataJson") String dataJson) throws Exception {
        RsResource newResources;
        Map<String, Object> paraMap = objectMapper.readValue(dataJson, Map.class);
        if (!paraMap.containsKey("resource")) {
            return failed("resource不能为空");
        }
        //处理资源视图
        String resource = objectMapper.writeValueAsString(paraMap.get("resource"));
        RsResource rsResources = toEntity(resource, RsResource.class);
        if (rsService.findByField("name", rsResources.getName()).size() > 0) {
            return failed("资源名称重复");
        }
        if (rsService.getResourceByCode(rsResources.getCode()) != null) {
            return failed("资源编码重复");
        }
        /**
         * 资源ID
         */
        String reId = getObjectId(BizObject.Resources);
        rsResources.setId(reId);
        /**
         * 根据资源数据类型保存相关数据元和搜索条件
         */
        if (rsResources.getDataSource() == 1) { //档案数据
            //处理关联档案数据元
            if (!paraMap.containsKey("metadatas")) {
                return failed("档案数据元不能为空");
            }
            String rsMetadatasStr = objectMapper.writeValueAsString(paraMap.get("metadatas"));
            RsResourceMetadata[] rsMetadatas = toEntity(rsMetadatasStr, RsResourceMetadata[].class);
            if (rsMetadatas == null || rsMetadatas.length <= 0) {
                //档案数据元为空,删除资源
                return failed("档案数据元不能为空");
            }
            for (RsResourceMetadata rsMetadata : rsMetadatas) {
                rsMetadata.setResourcesId(reId);
                rsMetadata.setId(getObjectId(BizObject.ResourceMetadata));
            }
            //处理默认搜索条件
            RsResourceDefaultParam rsResourceDefaultParam = null;
            if (paraMap.get("queryCondition") != null) {
                List<Map<String, String>> queryList = (List<Map<String, String>>) paraMap.get("queryCondition");
                if (!queryList.isEmpty()) {
                    String queryCondition = objectMapper.writeValueAsString(queryList);
                    rsResourceDefaultParam = new RsResourceDefaultParam();
                    rsResourceDefaultParam.setResourcesId(reId);
                    rsResourceDefaultParam.setResourcesCode(rsResources.getCode());
                    rsResourceDefaultParam.setParamKey("q");
                    rsResourceDefaultParam.setParamValue(queryCondition);
                }
            }
            newResources = resourcesIntegratedService.profileCompleteSave(rsResources, Arrays.asList(rsMetadatas), rsResourceDefaultParam);
            return success(newResources.getId());
        } else if (rsResources.getDataSource() == 2) { //统计指标
            //处理关联指标数据元
            if (!paraMap.containsKey("quotas")) {
                return failed("指标数据元不能为空");
            }
            String rsQuotasStr = objectMapper.writeValueAsString(paraMap.get("quotas"));
            RsResourceQuota[] rsQuotas = toEntity(rsQuotasStr, RsResourceQuota[].class);
            if (rsQuotas == null || rsQuotas.length <= 0) {
                return failed("指标数据元不能为空");
            }
            for (RsResourceQuota resourceQuota : rsQuotas) {
                resourceQuota.setResourceId(reId);
            }
            //处理默认搜索条件
            RsResourceDefaultParam rsResourceDefaultParam = null;
            if (paraMap.get("queryCondition") != null) {
                Map<String, Object> queryMap = (Map<String, Object>) paraMap.get("queryCondition");
                if (!queryMap.isEmpty()) {
                    String queryCondition = objectMapper.writeValueAsString(queryMap);
                    rsResourceDefaultParam = new RsResourceDefaultParam();
                    rsResourceDefaultParam.setResourcesId(reId);
                    rsResourceDefaultParam.setResourcesCode(rsResources.getCode());
                    rsResourceDefaultParam.setParamKey("q");
                    rsResourceDefaultParam.setParamValue(queryCondition);
                }
            }
            newResources = resourcesIntegratedService.quotaCompleteSave(rsResources, Arrays.asList(rsQuotas), rsResourceDefaultParam);
            return success(newResources.getId());
        } else {
            return failed("资源类型有误");
        }
    }
    @ApiOperation("综合查询搜索条件更新")
    @RequestMapping(value = ServiceApi.Resources.IntResourceQueryUpdate, method = RequestMethod.PUT)
    public Envelop customizeUpdate(
            @ApiParam(name = "dataJson", value = "JSON对象参数({\"resourceId\":\"resourceId\",\"queryCondition\":\"([])({})\"})", required = true)
            @RequestParam(value = "dataJson") String dataJson) throws Exception {
        Map<String, Object> paraMap = objectMapper.readValue(dataJson, Map.class);
        if (!paraMap.containsKey("resourceId") || !paraMap.containsKey("queryCondition")) {
            return failed("参数不完整,缺少resourceId或者queryCondition");
        }
        String resourceId = (String) paraMap.get("resourceId");
        RsResource rsResources = rsService.getResourceById(resourceId);
        if (rsResources != null) {
            RsResourceDefaultParam rsResourceDefaultParam = null;
            String queryCondition = (String) paraMap.get("queryCondition");
            if (rsResources.getDataSource() == 1) {
                if (!queryCondition.equals("[]")) {
                    rsResourceDefaultParam = new RsResourceDefaultParam();
                    rsResourceDefaultParam.setResourcesId(rsResources.getId());
                    rsResourceDefaultParam.setResourcesCode(rsResources.getCode());
                    rsResourceDefaultParam.setParamKey("q");
                    rsResourceDefaultParam.setParamValue(queryCondition);
                }
            } else {
                if (!queryCondition.equals("{}")) {
                    rsResourceDefaultParam = new RsResourceDefaultParam();
                    rsResourceDefaultParam.setResourcesId(rsResources.getId());
                    rsResourceDefaultParam.setResourcesCode(rsResources.getCode());
                    rsResourceDefaultParam.setParamKey("q");
                    rsResourceDefaultParam.setParamValue(queryCondition);
                }
            }
            if (rsResourceDefaultParam != null) {
                RsResourceDefaultParam resourceDefaultParam = resourceDefaultParamService.saveWithDel(rsResourceDefaultParam);
                return success(resourceDefaultParam);
            }
            return failed("条件不能为空");
        } else {
            return failed("资源不存在");
        }
    }
}

+ 78 - 0
src/main/java/com/yihu/ehr/resource/controller/ResourceTransformEndPoint.java

@ -0,0 +1,78 @@
package com.yihu.ehr.resource.controller;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MStdTransformDto;
import com.yihu.ehr.resource.service.ResourcesTransformService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
 * Created by hzp on 2016/4/13.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0 )
@Api(value = "ResourceTransformEndPoint", description = "格式转换", tags = {"资源服务-格式转换"})
public class ResourceTransformEndPoint {
    @Autowired
    private ResourcesTransformService resourcesTransformService;
    @Autowired
    private ObjectMapper objectMapper;
    @ApiOperation("EHR内部标准转国家标准")
    @RequestMapping(value="/rs/transform/stdTransformList",method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public List<Map<String,Object>> stdTransformList(
            @ApiParam(name="stdTransformDtoJson",value="资源数据模型",required = true)
            @RequestBody String stdTransformDtoJson) throws Exception {
        MStdTransformDto stdTransformDto = objectMapper.readValue(stdTransformDtoJson,MStdTransformDto.class);
        String resource =  stdTransformDto.getSource();
        String version = stdTransformDto.getVersion();
        String dataset = stdTransformDto.getDataset();
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, Object>> list = objectMapper.readValue(resource, javaType);
        return resourcesTransformService.displayCodeConvert(list, version,dataset);
    }
    @ApiOperation("EHR内部标准转国家标准(单条记录)")
    @RequestMapping(value="/rs/transform/stdTransform",method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String,Object> stdTransform(
            @ApiParam(name="stdTransformDtoJson",value="资源数据模型",required = true)
            @RequestBody String stdTransformDtoJson) throws Exception {
        MStdTransformDto stdTransformDto = objectMapper.readValue(stdTransformDtoJson,MStdTransformDto.class);
        String resource =  stdTransformDto.getSource();
        String version = stdTransformDto.getVersion();
        String dataset = stdTransformDto.getDataset();
        Map<String, Object> map = objectMapper.readValue(resource, Map.class);
        return resourcesTransformService.displayCodeConvert(map,version,dataset);
    }
    @ApiOperation("EHR主表数据分解")
    @RequestMapping(value = "/rs/transform/stdMasterTransform", method = RequestMethod.POST)
    public Map<String,Object> stdMasterTransform(
            @ApiParam(name="stdTransformDtoJson",value="资源数据模型",required = true)
            @RequestBody String stdTransformDtoJson) throws Exception {
        MStdTransformDto stdTransformDto = objectMapper.readValue(stdTransformDtoJson,MStdTransformDto.class);
        String resource =  stdTransformDto.getSource();
        String version = stdTransformDto.getVersion();
        String dataset = stdTransformDto.getDataset();
        Map<String, Object> map = objectMapper.readValue(resource, Map.class);
        return resourcesTransformService.stdMasterTransform(map, dataset, version);
    }
}

+ 203 - 0
src/main/java/com/yihu/ehr/resource/controller/RsAdapterDictionaryEndPoint.java

@ -0,0 +1,203 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsAdapterDictionary;
import com.yihu.ehr.resource.model.RsAdapterDictionary;
import com.yihu.ehr.resource.service.RsAdapterDictionaryService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0 )
@Api(value = "RsAdapterDictionaryEndPoint", description = "适配字典", tags = {"资源服务-适配字典"})
public class RsAdapterDictionaryEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsAdapterDictionaryService adapterDictionaryService;
    @RequestMapping(value = ServiceApi.Resources.AdapterDicts, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取适配字典列表")
    public List<MRsAdapterDictionary> searchRsAdapterDictionaries(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsAdapterDictionary> adapterDictionaries = adapterDictionaryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, adapterDictionaryService.getCount(filters), page, size);
        return (List<MRsAdapterDictionary>) convertToModels(adapterDictionaries, new ArrayList<MRsAdapterDictionary>(adapterDictionaries.size()), MRsAdapterDictionary.class, fields);
    }
    /**
     * 貌似重复的方法
     * @param fields
     * @param filters
     * @param sorts
     * @param page
     * @param size
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionaries, method = RequestMethod.GET)
    @ApiOperation("查询适配字典")
    public List<MRsAdapterDictionary> getDictionaries(
            @ApiParam(name="fields",value="返回字段",defaultValue = "")
            @RequestParam(value="fields",required = false)String fields,
            @ApiParam(name="filters",value="过滤",defaultValue = "")
            @RequestParam(value="filters",required = false)String filters,
            @ApiParam(name="sorts",value="排序",defaultValue = "")
            @RequestParam(value="sorts",required = false)String sorts,
            @ApiParam(name="page",value="页码",defaultValue = "1")
            @RequestParam(value="page",required = false)int page,
            @ApiParam(name="size",value="分页大小",defaultValue = "15")
            @RequestParam(value="size",required = false)int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsAdapterDictionary> adapterDictionaries = adapterDictionaryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, adapterDictionaryService.getCount(filters), page, size);
        return (List<MRsAdapterDictionary>) convertToModels(adapterDictionaries, new ArrayList<MRsAdapterDictionary>(adapterDictionaries.size()), MRsAdapterDictionary.class, fields);
    }
    @RequestMapping(value = ServiceApi.Resources.AdapterDicts, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建适配字典")
    public MRsAdapterDictionary createRsAdapterDictionary(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsAdapterDictionary adapterDictionary = toEntity(jsonData, RsAdapterDictionary.class);
        adapterDictionary.setId(getObjectId(BizObject.RsAdapterDictionary));
        adapterDictionaryService.save(adapterDictionary);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
    }
    /**
     * 貌似重复的方法
     * @param jsonData
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionaries, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("创建适配字典")
    public MRsAdapterDictionary createDictionaries(
            @ApiParam(name = "json_data", value = "适配字典JSON", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsAdapterDictionary adapterDictionary = toEntity(jsonData, RsAdapterDictionary.class);
        adapterDictionary.setId(getObjectId(BizObject.RsAdapterDictionary));
        adapterDictionary = adapterDictionaryService.save(adapterDictionary);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class);
    }
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionaries, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新适配字典")
    public MRsAdapterDictionary updateDictionary(
            @ApiParam(name = "json_data", value = "适配字典JSON", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsAdapterDictionary adapterDictionary = toEntity(jsonData, RsAdapterDictionary.class);
        adapterDictionary = adapterDictionaryService.save(adapterDictionary);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class);
    }
    /**
     * 貌似重复的方法
     * @param jsonData
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.Resources.AdapterDicts, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改适配字典")
    public MRsAdapterDictionary updateRsAdapterDictionary(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
        RsAdapterDictionary adapterDictionary = toEntity(jsonData, RsAdapterDictionary.class);
        adapterDictionaryService.save(adapterDictionary);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.AdapterDict, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除适配字典")
    public boolean deleteRsAdapterDictionary(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        adapterDictionaryService.delete(id);
        return true;
    }
    /**
     * 貌似重复的方法
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionary, method = RequestMethod.DELETE)
    @ApiOperation("删除适配字典")
    public boolean deleteDictionary(
            @ApiParam(name = "id", value = "适配字典ID", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        adapterDictionaryService.delete(id);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.AdapterDict, method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取获取适配字典")
    public MRsAdapterDictionary getRsAdapterDictionaryById(
            @ApiParam(name = "id", value = "", defaultValue = "")
            @RequestParam(value = "id") String id) {
        RsAdapterDictionary adapterDictionary = adapterDictionaryService.findById(id);
        return convertToModel(adapterDictionary, MRsAdapterDictionary.class);
    }
    /**
     * 貌似重复的方法
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = ServiceApi.Adaptions.RsAdapterDictionary, method = RequestMethod.GET)
    @ApiOperation("根据ID获取适配字典")
    public MRsAdapterDictionary getDictionaryById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(adapterDictionaryService.findById(id), MRsAdapterDictionary.class);
    }
    @RequestMapping(value = ServiceApi.Resources.AdapterDictsBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量创建适配字典")
    public boolean createRsAdapterDictionaries(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        List<RsAdapterDictionary> dictionaries = toEntity(jsonData,List.class);
        adapterDictionaryService.batchInsert(dictionaries);
        return true;
    }
}

+ 134 - 0
src/main/java/com/yihu/ehr/resource/controller/RsAdapterMetaDataEndPoint.java

@ -0,0 +1,134 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsAdapterMetadata;
import com.yihu.ehr.resource.model.RsAdapterMetadata;
import com.yihu.ehr.resource.service.RsAdapterMetadataService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * 适配数据元服务
 *
 * Created by lyr on 2016/5/17.
 */
@RestController
@RequestMapping(value= ApiVersion.Version1_0)
@Api(value = "RsAdapterMetaDataEndPoint", description = "适配数据元", tags = {"资源服务-适配数据元"})
public class RsAdapterMetaDataEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsAdapterMetadataService metadataService;
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataList,method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("创建适配数据元")
    public MRsAdapterMetadata createMetadata(
            @ApiParam(name="adapterMetadata",value="数据元JSON",defaultValue = "")
            @RequestBody String adapterMetadata) throws Exception
    {
        RsAdapterMetadata metadata = toEntity(adapterMetadata,RsAdapterMetadata.class);
        metadata.setId(getObjectId(BizObject.RsAdapterMetadata));
        metadata = metadataService.saveAdapterMetadata(metadata);
        return convertToModel(metadata,MRsAdapterMetadata.class);
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataList,method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新适配数据元")
    public MRsAdapterMetadata updateMetadata(
            @ApiParam(name="adapterMetadata",value="数据元JSON",defaultValue = "")
            @RequestBody String adapterMetadata) throws Exception
    {
        RsAdapterMetadata metadata = toEntity(adapterMetadata,RsAdapterMetadata.class);
        metadata = metadataService.saveAdapterMetadata(metadata);
        return convertToModel(metadata,MRsAdapterMetadata.class);
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadata,method = RequestMethod.DELETE)
    @ApiOperation("删除适配数据元")
    public boolean deleteMetadata(
            @ApiParam(name="id",value="数据元ID",defaultValue = "")
            @PathVariable(value="id")String id) throws Exception
    {
        metadataService.deleteAdapterMetadata(id);
        return true;
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataList,method = RequestMethod.DELETE)
    @ApiOperation("批量删除适配数据元")
    public boolean deleteMetadataBatch(
            @ApiParam(name="ids",value="数据元ID",defaultValue = "")
            @RequestParam(value="ids") String ids) throws Exception
    {
        metadataService.deleteAdapterMetadata(ids);
        return true;
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadata,method = RequestMethod.GET)
    @ApiOperation("根据ID获取适配数据元")
    public MRsAdapterMetadata getMetadataById(
            @ApiParam(name="id",value="id",defaultValue = "")
            @PathVariable(value="id") String id) throws Exception
    {
         return convertToModel(metadataService.getAdapterMetadataById(id),MRsAdapterMetadata.class);
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataList,method = RequestMethod.GET)
    @ApiOperation("查询适配数据元")
    public List<MRsAdapterMetadata> getMetadata(
            @ApiParam(name="fields",value="返回字段",defaultValue = "")
            @RequestParam(value="fields",required = false)String fields,
            @ApiParam(name="filters",value="过滤",defaultValue = "")
            @RequestParam(value="filters",required = false)String filters,
            @ApiParam(name="sorts",value="排序",defaultValue = "")
            @RequestParam(value="sorts",required = false)String sorts,
            @ApiParam(name="page",value="页码",defaultValue = "1")
            @RequestParam(value="page",required = false)int page,
            @ApiParam(name="size",value="分页大小",defaultValue = "15")
            @RequestParam(value="size",required = false)int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsAdapterMetadata> metaList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
            Page<RsAdapterMetadata> metadataPage = metadataService.getAdapterMetadata(sorts, reducePage(page), size);
            total = metadataPage.getTotalElements();
            metaList = convertToModels(metadataPage.getContent(), new ArrayList<>(metadataPage.getNumber()), MRsAdapterMetadata.class, fields);
        } else {
            List<RsAdapterMetadata> metadata = metadataService.search(fields, filters, sorts, page, size);
            total = metadataService.getCount(filters);
            metaList = convertToModels(metadata, new ArrayList<>(metadata.size()), MRsAdapterMetadata.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsAdapterMetadata>)metaList;
    }
    @RequestMapping(value = ServiceApi.Adaptions.SchemaMetadataBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量创建适配数据元", notes = "批量创建适配数据元")
    public boolean createRsMetaDataBatch(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        List<RsAdapterMetadata> adapterMetadata = toEntity(jsonData,List.class);
        metadataService.batchInsert(adapterMetadata);
        return true;
    }
}

+ 117 - 0
src/main/java/com/yihu/ehr/resource/controller/RsAdapterSchemeEndPoint.java

@ -0,0 +1,117 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsAdapterSchema;
import com.yihu.ehr.resource.model.RsAdapterScheme;
import com.yihu.ehr.resource.service.RsAdapterSchemeService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * 适配方案服务
 * <p/>
 * Created by lyr on 2016/5/17.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsAdapterSchemeEndPoint", description = "适配方案", tags = {"资源服务-适配方案"})
public class RsAdapterSchemeEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsAdapterSchemeService schemaService;
    @RequestMapping(value = ServiceApi.Adaptions.Schemes, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("创建适配方案")
    public MRsAdapterSchema createSchema(
            @ApiParam(name = "adapterSchema", value = "数据元JSON", defaultValue = "")
            @RequestBody String adapterSchema) throws Exception {
        RsAdapterScheme schema = toEntity(adapterSchema, RsAdapterScheme.class);
        schema.setId(getObjectId(BizObject.RsAdapterSchema));
        schema = schemaService.saveAdapterScheme(schema);
        return convertToModel(schema, MRsAdapterSchema.class);
    }
    @RequestMapping(value = ServiceApi.Adaptions.Schemes, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新适配方案")
    public MRsAdapterSchema updateSchema(
            @ApiParam(name = "adapterScheme", value = "数据元JSON", defaultValue = "")
            @RequestBody String adapterSchema) throws Exception {
        RsAdapterScheme schema = toEntity(adapterSchema, RsAdapterScheme.class);
        schema = schemaService.save(schema);
        return convertToModel(schema, MRsAdapterSchema.class);
    }
    @RequestMapping(value = ServiceApi.Adaptions.Scheme, method = RequestMethod.DELETE)
    @ApiOperation("删除适配方案")
    public boolean deleteSchema(
            @ApiParam(name = "id", value = "方案id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        schemaService.deleteById(id);
        return true;
    }
    @RequestMapping(value = ServiceApi.Adaptions.Schemes, method = RequestMethod.DELETE)
    @ApiOperation("批量删除适配方案")
    public boolean deleteSchemaBatch(
            @ApiParam(name = "ids", value = "ids", defaultValue = "")
            @RequestParam(value = "ids") String ids) throws Exception {
        schemaService.deleteAdapterScheme(ids);
        return true;
    }
    @RequestMapping(value = ServiceApi.Adaptions.Scheme, method = RequestMethod.GET)
    @ApiOperation("根据ID获取适配方案")
    public MRsAdapterSchema getAdapterSchemaById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(schemaService.getAdapterSchemeById(id), MRsAdapterSchema.class);
    }
    @RequestMapping(value = ServiceApi.Adaptions.Schemes, method = RequestMethod.GET)
    @ApiOperation("查询适配方案")
    public List<MRsAdapterSchema> getSchema(
            @ApiParam(name = "fields", value = "返回字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsAdapterSchema> metaList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
            Page<RsAdapterScheme> metadataPage = schemaService.getAdapterScheme(sorts, reducePage(page), size);
            total = metadataPage.getTotalElements();
            metaList = convertToModels(metadataPage.getContent(), new ArrayList<>(metadataPage.getNumber()), MRsAdapterSchema.class, fields);
        } else {
            List<RsAdapterScheme> metadata = schemaService.search(fields, filters, sorts, page, size);
            total = schemaService.getCount(filters);
            metaList = convertToModels(metadata, new ArrayList<>(metadata.size()), MRsAdapterSchema.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsAdapterSchema>) metaList;
    }
}

+ 177 - 0
src/main/java/com/yihu/ehr/resource/controller/RsDictionaryEndPoint.java

@ -0,0 +1,177 @@
package com.yihu.ehr.resource.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.model.resource.MRsDictionary;
import com.yihu.ehr.resource.model.RsDictionary;
import com.yihu.ehr.resource.service.RsDictionaryEntryService;
import com.yihu.ehr.resource.service.RsDictionaryService;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0 + "/dictionaries")
@Api(value = "RsDictionaryEndPoint", description = "标准字典", tags = {"资源服务-标准字典"})
public class RsDictionaryEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsDictionaryService dictionaryService;
    @Autowired
    private RsDictionaryEntryService dictionaryEntryService;
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取标准字典列表", notes = "根据查询条件获取标准字典列表")
    public List<MRsDictionary> searchRsDictionaries(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsDictionary> dictionaries = dictionaryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, dictionaryService.getCount(filters), page, size);
        return (List<MRsDictionary>) convertToModels(dictionaries, new ArrayList<MRsDictionary>(dictionaries.size()), MRsDictionary.class, fields);
    }
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建标准字典", notes = "创建标准字典")
    public MRsDictionary createRsDictionary(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsDictionary rsDictionary = toEntity(jsonData, RsDictionary.class);
        String code = rsDictionary.getCode();
        if (isExistence(code)) {
            throw new Exception("字典代码不能重复");
        }
        dictionaryService.insert(rsDictionary);
        return convertToModel(rsDictionary, MRsDictionary.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.DictList, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改标准字典", notes = "修改标准字典")
    public MRsDictionary updateRsDictionary(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
        RsDictionary dictionary = toEntity(jsonData, RsDictionary.class);
        dictionaryService.save(dictionary);
        return convertToModel(dictionary, MRsDictionary.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.Dict, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除标准字典", notes = "删除标准字典")
    public Envelop deleteRsDictionary(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") int id) throws Exception {
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(false);
        try {
            RsDictionary dictionary = dictionaryService.findById(id);
            int count = dictionaryEntryService.countByDictId(dictionary.getId());
            if (count != 0) {
                envelop.setErrorMsg("该字典存在字典项,不可删除。");
            } else {
                dictionaryService.delete(id);
                envelop.setSuccessFlg(true);
                envelop.setErrorMsg("删除成功。");
            }
        } catch (Exception e) {
            e.printStackTrace();
            envelop.setErrorMsg("删除发生异常。");
        }
        return envelop;
    }
    @RequestMapping(value = ServiceApi.Resources.Dict, method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取获取标准字典")
    public MRsDictionary getRsDictionaryById(
            @ApiParam(name = "id", value = "", defaultValue = "")
            @PathVariable(value = "id") int id) throws UnsupportedEncodingException {
        RsDictionary dictionary = dictionaryService.findById(id);
        return convertToModel(dictionary, MRsDictionary.class);
    }
    @RequestMapping(value = ServiceApi.Resources.DictBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量创建标准字典", notes = "批量创建标准字典")
    public boolean createRsDictionaries(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        List<RsDictionary> dictionaries = toEntity(jsonData, List.class);
        dictionaryService.batchInsert(dictionaries);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.DictExistence, method = RequestMethod.GET)
    @ApiOperation("根据过滤条件判断是否存在")
    public boolean isExistenceFilters(
            @ApiParam(name = "filters", value = "filters", defaultValue = "")
            @RequestParam(value = "filters") String filters) throws Exception {
        List ls = dictionaryService.search("", filters, "", 1, 1);
        return ls != null && ls.size() > 0;
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntryBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "批量创建标准字典以及字典项", notes = "批量创建标准字典以及字典项")
    public boolean createDictAndEntries(
            @RequestBody String jsonData) throws Exception {
        List models = objectMapper.readValue(jsonData, new TypeReference<List>() {
        });
        dictionaryService.batchInsertDictsAndEntry(models);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.DictCodesExistence, method = RequestMethod.POST)
    @ApiOperation("获取已存在字典编码")
    public List codeExistence(
            @RequestBody String codes) throws Exception {
        List existCodes = dictionaryService.codeExist(toEntity(codes, String[].class));
        return existCodes;
    }
    @RequestMapping(value = ServiceApi.Resources.DictCode, method = RequestMethod.GET)
    @ApiOperation(value = "根据code获取获取标准字典")
    public MRsDictionary getRsDictionaryByCode(
            @ApiParam(name = "code", value = "", defaultValue = "")
            @RequestParam(value = "code") String code) throws Exception {
        List<RsDictionary> ls = dictionaryService.findByField("code", code);
        return ls.size() > 0 ? convertToModel(ls.get(0), MRsDictionary.class) : null;
    }
    private boolean isExistence(String code) {
        return dictionaryService.findByField("code", code).size() != 0;
    }
}

+ 139 - 0
src/main/java/com/yihu/ehr/resource/controller/RsDictionaryEntryEndPoint.java

@ -0,0 +1,139 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.model.resource.MRsDictionaryEntry;
import com.yihu.ehr.resource.model.RsDictionaryEntry;
import com.yihu.ehr.resource.service.RsDictionaryEntryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsDictionaryEntry", description = "标准字典项", tags = {"资源服务-标准字典项"})
public class RsDictionaryEntryEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsDictionaryEntryService rsDictionaryEntryService;
    @RequestMapping(value = ServiceApi.Resources.DictEntries, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取标准字典项列表", notes = "根据查询条件获取标准字典项列表")
    public List<MRsDictionaryEntry> searchRsDictionaryEntries(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsDictionaryEntry> dictionaryEntries = rsDictionaryEntryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, rsDictionaryEntryService.getCount(filters), page, size);
        return (List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<MRsDictionaryEntry>(dictionaryEntries.size()), MRsDictionaryEntry.class, fields);
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntries, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建标准字典项", notes = "创建标准字典项")
    public MRsDictionaryEntry createRsDictionaryEntry(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsDictionaryEntry dictionaryEntry = toEntity(jsonData, RsDictionaryEntry.class);
        String code = dictionaryEntry.getCode();
        String dictCode = dictionaryEntry.getDictCode();
        if(isExistence(dictCode,code)){
            throw new Exception("字典项代码不能重复");
        }
        rsDictionaryEntryService.insert(dictionaryEntry);
        return convertToModel(dictionaryEntry, MRsDictionaryEntry.class, null);
    }
    @RequestMapping(value =ServiceApi.Resources.DictEntries, method = RequestMethod.PUT)
    @ApiOperation(value = "修改标准字典项", notes = "修改标准字典项")
    public MRsDictionaryEntry updateRsDictionaryEntry(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
        RsDictionaryEntry dictionaryEntry = toEntity(jsonData, RsDictionaryEntry.class);
        RsDictionaryEntry d = rsDictionaryEntryService.findById(dictionaryEntry.getId());
        String code = dictionaryEntry.getCode();
        String dictCode = dictionaryEntry.getDictCode();
        if(!d.getCode().equals(code) && isExistence(dictCode,code)){
            throw new Exception("字典代码不可修改");
        }
        rsDictionaryEntryService.save(dictionaryEntry);
        return convertToModel(dictionaryEntry, MRsDictionaryEntry.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntry, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除标准字典项", notes = "删除标准字典项")
    public boolean deleteRsDictionaryEntry(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") int id) throws Exception {
        rsDictionaryEntryService.delete(id);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntry, method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取获取标准字典")
    public MRsDictionaryEntry getRsDictionaryEntryById(
            @ApiParam(name = "id", value = "", defaultValue = "")
            @PathVariable(value = "id") int id) {
        RsDictionaryEntry dictionaryEntry = rsDictionaryEntryService.findById(id);
        return convertToModel(dictionaryEntry, MRsDictionaryEntry.class);
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntriesByDictCode, method = RequestMethod.GET)
    @ApiOperation(value = "根据dict_code获取获取标准字典")
    public List<MRsDictionaryEntry>  getRsDictionaryEntryByDictCode(
            @ApiParam(name = "dict_code", value = "", defaultValue = "")
            @RequestParam(value = "dict_code") String dict_code)
    {
        List<RsDictionaryEntry> dictionaryEntries = rsDictionaryEntryService.findByDictCode(dict_code);
        return (List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<>(dictionaryEntries.size()), MRsDictionaryEntry.class,null);
    }
    @RequestMapping(value = ServiceApi.Resources.DictEntriesExistence,method = RequestMethod.GET)
    @ApiOperation("根据过滤条件判断是否存在")
    public boolean isExistence(
            @ApiParam(name="filters",value="filters",defaultValue = "")
            @RequestParam(value="filters") String filters) throws Exception {
        List ls = rsDictionaryEntryService.search("",filters,"", 1, 1);
        return ls!=null && ls.size()>0;
    }
    public boolean isExistence(String dictCode,String code) {
        return rsDictionaryEntryService.findByFields(new String[]{"dictCode","code"},new String[]{dictCode,code}).size() != 0;
    }
    @RequestMapping(value = ServiceApi.Resources.NoPageDictEntries, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取标准字典项列表_不分页", notes = "根据查询条件获取标准字典项列表_不分页")
    public List<MRsDictionaryEntry> searchNoPageRsDictEntries(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<RsDictionaryEntry> dictionaryEntries = rsDictionaryEntryService.search(filters);
        return (List<MRsDictionaryEntry>) convertToModels(dictionaryEntries, new ArrayList<>(dictionaryEntries.size()), MRsDictionaryEntry.class, "");
    }
}

+ 110 - 0
src/main/java/com/yihu/ehr/resource/controller/RsDimensionCategoryEndPoint.java

@ -0,0 +1,110 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsDimensionCategory;
import com.yihu.ehr.resource.model.RsDimensionCategory;
import com.yihu.ehr.resource.service.RsDimensionCategoryService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by lyr on 2016/4/25.
 */
@RestController
@Api(value="RsDimensionCategoryEndPoint", description = "维度分类", tags = {"资源服务-维度分类"})
@RequestMapping(value= ApiVersion.Version1_0)
public class RsDimensionCategoryEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsDimensionCategoryService dmcService;
    @ApiOperation("创建维度类别")
    @RequestMapping(value = "/dimensionCategories", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public MRsDimensionCategory createDimensionCategory(
            @ApiParam(name="dimensionCategory",value="维度类别",defaultValue = "")
            @RequestBody String dimensionCategory) throws Exception
    {
        RsDimensionCategory dmc = toEntity(dimensionCategory,RsDimensionCategory.class);
        dmc.setId(getObjectId(BizObject.DimensionsCategories));
        dmcService.saveDimensionCategory(dmc);
        return convertToModel(dmc,MRsDimensionCategory.class);
    }
    @ApiOperation("更新维度类别")
    @RequestMapping(value = "/dimensionCategories", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public MRsDimensionCategory updateDimensionCategory(
            @ApiParam(name="dimensionCategory",value="维度类别",defaultValue="")
            @RequestBody String dimensionCategory) throws Exception
    {
        RsDimensionCategory  dmc= toEntity(dimensionCategory,RsDimensionCategory.class);
        dmcService.saveDimensionCategory(dmc);
        return convertToModel(dmc,MRsDimensionCategory.class);
    }
    @ApiOperation("维度类别删除")
    @RequestMapping(value="/dimensionCategorie/{id}",method = RequestMethod.DELETE)
    public boolean deleteDimensionCategory(
            @ApiParam(name="id",value="维度类别ID",defaultValue = "")
            @PathVariable(value="id") String id) throws Exception
    {
        dmcService.deleteDimensionCategory(id);
        return true;
    }
    @ApiOperation("维度类别查询")
    @RequestMapping(value="/dimensionCategories", method = RequestMethod.GET)
    public Page<MRsDimensionCategory> queryCategories(
            @ApiParam(name="fields",value="返回字段",defaultValue = "")
            @RequestParam(value="fields",required = false)String fields,
            @ApiParam(name="filters",value="过滤",defaultValue = "")
            @RequestParam(value="filters",required = false)String filters,
            @ApiParam(name="sorts",value="排序",defaultValue = "")
            @RequestParam(value="sorts",required = false)String sorts,
            @ApiParam(name="page",value="页码",defaultValue = "1")
            @RequestParam(value="page",required = false)int page,
            @ApiParam(name="size",value="分页大小",defaultValue = "15")
            @RequestParam(value="size",required = false)int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception
    {
        Pageable pageable = new PageRequest(reducePage(page),size);
        long total = 0;
        Collection<MRsDimensionCategory> rsDimCateGoryList;
        //过滤条件为空
        if(StringUtils.isEmpty(filters))
        {
            Page<RsDimensionCategory> dmcs = dmcService.getDimensionCategories(sorts,reducePage(page),size);
            total = dmcs.getTotalElements();
            rsDimCateGoryList = convertToModels(dmcs.getContent(),new ArrayList<>(dmcs.getNumber()),MRsDimensionCategory.class,fields);
        }
        else
        {
            List<RsDimensionCategory> dmcs = dmcService.search(fields,filters,sorts,page,size);
            total = dmcService.getCount(filters);
            rsDimCateGoryList =  convertToModels(dmcs,new ArrayList<>(dmcs.size()),MRsDimensionCategory.class,fields);
        }
        pagedResponse(request,response,total,page,size);
        Page<MRsDimensionCategory> rsPage = new PageImpl<MRsDimensionCategory>((List<MRsDimensionCategory>)rsDimCateGoryList,pageable,total);
        return rsPage;
    }
}

+ 111 - 0
src/main/java/com/yihu/ehr/resource/controller/RsDimensionEndPoint.java

@ -0,0 +1,111 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsDimension;
import com.yihu.ehr.resource.model.RsDimension;
import com.yihu.ehr.resource.service.RsDimensionService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by hzp on 2016/4/13.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsDimensionEndPoint", description = "维度", tags = {"资源服务-维度"})
public class RsDimensionEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsDimensionService dimensionService;
    @ApiOperation("创建维度")
    @RequestMapping(value = "/dimensions", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public MRsDimension createDimension(
            @ApiParam(name="dimension",value="维度",defaultValue = "")
            @RequestBody String dimension) throws Exception
    {
        RsDimension dimens = toEntity(dimension,RsDimension.class);
        dimens.setId(getObjectId(BizObject.Dimensions));
        dimensionService.saveDimension(dimens);
        return convertToModel(dimens,MRsDimension.class);
    }
    @ApiOperation("更新维度")
    @RequestMapping(value = "/dimensions", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public MRsDimension updateDimension(
            @ApiParam(name="dimension",value="维度",defaultValue="")
            @RequestBody String dimension) throws Exception
    {
        RsDimension  dimens= toEntity(dimension,RsDimension.class);
        dimensionService.saveDimension(dimens);
        return convertToModel(dimens,MRsDimension.class);
    }
    @ApiOperation("维度删除")
    @RequestMapping(value="/dimensions/{id}",method = RequestMethod.DELETE)
    public boolean deleteDimension(
            @ApiParam(name="id",value="维度ID",defaultValue = "")
            @PathVariable(value="id") String id) throws Exception
    {
        dimensionService.deleteDimension(id);
        return true;
    }
    @ApiOperation("维度查询")
    @RequestMapping(value = "/dimensions", method = RequestMethod.GET)
    public Page<MRsDimension> queryDimensions(
            @ApiParam(name="fields",value="返回字段",defaultValue = "")
            @RequestParam(value="fields",required = false)String fields,
            @ApiParam(name="filters",value="过滤",defaultValue = "")
            @RequestParam(value="filters",required = false)String filters,
            @ApiParam(name="sorts",value="排序",defaultValue = "")
            @RequestParam(value="sorts",required = false)String sorts,
            @ApiParam(name="page",value="页码",defaultValue = "1")
            @RequestParam(value="page",required = false)int page,
            @ApiParam(name="size",value="分页大小",defaultValue = "15")
            @RequestParam(value="size",required = false)int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception
    {
        Pageable pageable = new PageRequest(reducePage(page),size);
        long total = 0;
        Collection<MRsDimension> rsDimensionList;
        //过滤条件为空
        if(StringUtils.isEmpty(filters))
        {
            Page<RsDimension> dimensions = dimensionService.getDimensions(sorts,reducePage(page),size);
            total = dimensions.getTotalElements();
            rsDimensionList =  convertToModels(dimensions.getContent(),new ArrayList<>(dimensions.getNumber()),MRsDimension.class,fields);
        }
        else
        {
            List<RsDimension> dimensions = dimensionService.search(fields,filters,sorts,page,size);
            total =  dimensionService.getCount(filters);
            rsDimensionList =  convertToModels(dimensions,new ArrayList<>(dimensions.size()),MRsDimension.class,fields);
        }
        pagedResponse(request,response,total,page,size);
        Page<MRsDimension> rsPage = new PageImpl<MRsDimension>((List<MRsDimension>)rsDimensionList,pageable,total);
        return rsPage;
    }
}

+ 112 - 0
src/main/java/com/yihu/ehr/resource/controller/RsInterfaceEndPoint.java

@ -0,0 +1,112 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsInterface;
import com.yihu.ehr.resource.model.RsInterface;
import com.yihu.ehr.resource.service.RsInterfaceService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsInterfaceEndPoint", description = "资源接口", tags = {"资源服务-资源接口"})
public class RsInterfaceEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsInterfaceService interfaceService;
    @RequestMapping(value = ServiceApi.Resources.Interfaces, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取资源列表", notes = "根据查询条件获取资源列表")
    public List<MRsInterface> searchRsInterfaces(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsInterface> interfaces = interfaceService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, interfaceService.getCount(filters), page, size);
        return (List<MRsInterface>) convertToModels(interfaces, new ArrayList<MRsInterface>(interfaces.size()), MRsInterface.class, fields);
    }
    @RequestMapping(value = ServiceApi.Resources.Interfaces, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建资源", notes = "创建资源")
    public MRsInterface createRsInterface(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsInterface rsInterface = toEntity(jsonData, RsInterface.class);
        rsInterface.setId(getObjectId(BizObject.RsInterface));
        interfaceService.save(rsInterface);
        return convertToModel(rsInterface, MRsInterface.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.Interfaces, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改资源", notes = "修改资源")
    public MRsInterface updateRsInterface(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
        RsInterface rsInterface = toEntity(jsonData, RsInterface.class);
        interfaceService.save(rsInterface);
        return convertToModel(rsInterface, MRsInterface.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.InterfaceById, method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取获取标准字典")
    public MRsInterface getRsInterfaceById(
            @ApiParam(name = "id", value = "", defaultValue = "")
            @PathVariable(value = "id") String id) {
        RsInterface rsInterface = interfaceService.retrieve(id);
        return convertToModel(rsInterface, MRsInterface.class);
    }
    @RequestMapping(value = ServiceApi.Resources.InterfaceNameExistence, method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取获取标准字典")
    public boolean isExistenceName(
            @ApiParam(name = "name", value = "", defaultValue = "")
            @RequestParam(value = "name") String name) {
        return interfaceService.isNameExist(name);
    }
    @RequestMapping(value = ServiceApi.Resources.Interface, method = RequestMethod.GET)
    @ApiOperation(value = "根据资源接口编码resourceInterface获取资源接口")
    public MRsInterface findByResourceInterface(
            @ApiParam(name = "resource_interface", value = "", defaultValue = "")
            @RequestParam(value = "resource_interface") String resourceInterface) {
        RsInterface  rsInterface =  interfaceService.findByResourceInterface(resourceInterface);
        return convertToModel(rsInterface, MRsInterface.class);
    }
    @RequestMapping(value = ServiceApi.Resources.InterfaceById, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源", notes = "删除资源")
    public boolean deleteRsInterface(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        interfaceService.delete(id);
        return true;
    }
}

+ 176 - 0
src/main/java/com/yihu/ehr/resource/controller/RsMetadataEndPoint.java

@ -0,0 +1,176 @@
package com.yihu.ehr.resource.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsMetadata;
import com.yihu.ehr.resource.model.RsMetadata;
import com.yihu.ehr.resource.service.RsMetadataService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * 数据元服务接口
 *
 * Created by lyr on 2016/5/16.
 */
@RestController
@RequestMapping(value= ApiVersion.Version1_0)
@Api(value = "RsMetadataEndPoint", description = "数据元", tags = {"资源服务-数据元"})
public class RsMetadataEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsMetadataService metadataService;
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("创建数据元")
    public MRsMetadata createMetadata(
        @ApiParam(name="metadata",value="数据元JSON",defaultValue = "")
        @RequestBody String metadata) throws Exception
    {
        RsMetadata rsMetadata = toEntity(metadata,RsMetadata.class);
        rsMetadata.setId(getObjectId(BizObject.RsMetadata));
        rsMetadata = metadataService.save(rsMetadata);
        return convertToModel(rsMetadata,MRsMetadata.class);
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataBatch,method = RequestMethod.POST)
    @ApiOperation("批量创建数据元")
    public boolean createMetadataPatch(
            @ApiParam(name="metadatas",value="数据元JSON",defaultValue = "")
            @RequestBody String metadatas) throws Exception
    {
        List models = objectMapper.readValue(metadatas, new TypeReference<List>() {});
        metadataService.addMetaBatch(models);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新数据元")
    public MRsMetadata updateMetadata(
            @ApiParam(name="metadata",value="数据元JSON",defaultValue = "")
            @RequestBody String metadata) throws Exception
    {
        RsMetadata rsMetadata = toEntity(metadata,RsMetadata.class);
        rsMetadata = metadataService.save(rsMetadata);
        return convertToModel(rsMetadata,MRsMetadata.class);
    }
    @RequestMapping(value = ServiceApi.Resources.Metadata,method = RequestMethod.DELETE)
    @ApiOperation("删除数据元")
    public boolean deleteMetadata(
            @ApiParam(name="id",value="数据元ID",defaultValue = "")
            @PathVariable(value="id")String id) throws Exception
    {
        metadataService.deleteMetadata(id);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.DELETE)
    @ApiOperation("批量删除数据元")
    public boolean deleteMetadataBatch(
            @ApiParam(name="ids",value="数据元ID",defaultValue = "")
            @RequestParam(name="ids") String ids) throws Exception
    {
        metadataService.deleteMetadata(ids);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.Metadata,method = RequestMethod.GET)
    @ApiOperation("根据ID获取数据元")
    public MRsMetadata getMetadataById(
            @ApiParam(name="id",value="id",defaultValue = "")
            @PathVariable(value="id") String id) throws Exception
    {
        return convertToModel(metadataService.getMetadataById(id),MRsMetadata.class);
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataExistence,method = RequestMethod.GET)
    @ApiOperation("根据过滤条件判断是否存在")
    public boolean isExistence(
            @ApiParam(name="filters",value="filters",defaultValue = "")
            @RequestParam(value="filters") String filters) throws Exception {
        List<RsMetadata> metadata = metadataService.search("",filters,"", 1, 1);
        return metadata!=null && metadata.size()>0;
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataStdCodeExistence,method = RequestMethod.GET)
    @ApiOperation("获取已存在内部编码")
    public List stdCodeExistence(
            @ApiParam(name="std_codes",value="std_codes",defaultValue = "")
            @RequestParam(value="std_codes") String stdCodes) throws Exception {
        List existCodes = metadataService.stdCodeExist(stdCodes);
        return existCodes;
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataIdExistence,method = RequestMethod.POST)
    @ApiOperation("获取已存在资源标准编码")
    public List idExistence(
            @ApiParam(name="ids",value="ids",defaultValue = "")
            @RequestBody String ids) throws Exception {
        List existIds = metadataService.idExist(toEntity(ids, String[].class));
        return existIds;
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataList,method = RequestMethod.GET)
    @ApiOperation("查询数据元")
    public List<MRsMetadata> getMetadata(
            @ApiParam(name="fields",value="返回字段",defaultValue = "")
            @RequestParam(name="fields",required = false)String fields,
            @ApiParam(name="filters",value="过滤",defaultValue = "")
            @RequestParam(name="filters",required = false)String filters,
            @ApiParam(name="sorts",value="排序",defaultValue = "")
            @RequestParam(name="sorts",required = false)String sorts,
            @ApiParam(name="page",value="页码",defaultValue = "1")
            @RequestParam(name="page",required = false)int page,
            @ApiParam(name="size",value="分页大小",defaultValue = "15")
            @RequestParam(name="size",required = false)int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception
    {
        long total = 0;
        Collection<MRsMetadata> metaList;
        //过滤条件为空
        if(StringUtils.isEmpty(filters))
        {
            Page<RsMetadata> metadataPage = metadataService.getMetadata(sorts,reducePage(page),size);
            total = metadataPage.getTotalElements();
            metaList = convertToModels(metadataPage.getContent(),new ArrayList<>(metadataPage.getNumber()),MRsMetadata.class,fields);
        }
        else
        {
            List<RsMetadata> metadata = metadataService.search(fields,filters,sorts,page,size);
            total = metadataService.getCount(filters);
            metaList = convertToModels(metadata,new ArrayList<>(metadata.size()),MRsMetadata.class,fields);
        }
        pagedResponse(request,response,total,page,size);
        return (List<MRsMetadata>)metaList;
    }
    @RequestMapping(value = ServiceApi.Resources.MetadataMaxId,method = RequestMethod.GET)
    @ApiOperation("获取资源标准编码的最大编号")
    public int getMaxIdNumber( ){
        return  metadataService.getMaxIdNumber();
    }
}

+ 75 - 0
src/main/java/com/yihu/ehr/resource/controller/RsReportCategoryAppEndPoint.java

@ -0,0 +1,75 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.entity.report.ReportCategoryAppRelation;
import com.yihu.ehr.resource.service.RsReportCategoryAppService;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by wxw on 2017/11/24.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsReportCategoryAppEndPoint", description = "资源报表分类与应用", tags = {"资源服务-资源报表分类与应用"})
public class RsReportCategoryAppEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsReportCategoryAppService rsReportCategoryAppService;
    @ApiOperation("根据报表分类编码和应用编码删除信息")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryAppDelete, method = RequestMethod.DELETE)
    public Envelop deleteByCategoryIdAndAppId(
            @ApiParam(name = "reportCategoryId", value = "报表分类编码")
            @RequestParam(value = "reportCategoryId")String reportCategoryId,
            @ApiParam(name = "appId", value = "应用编码")
            @RequestParam(value = "appId")String appId) {
        Envelop envelop = new Envelop();
        try {
            rsReportCategoryAppService.deleteByCategoryIdAndAppId(reportCategoryId, appId);
            envelop.setSuccessFlg(true);
        } catch (Exception e) {
            e.printStackTrace();
            envelop.setErrorMsg(e.getMessage());
        }
        return envelop;
    }
    @ApiOperation("根据报表分类编码和应用编码新增")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryAppSave, method = RequestMethod.POST)
    public Envelop saveCategoryIdAndAppId(
            @ApiParam(name = "reportCategoryId", value = "报表分类编码")
            @RequestParam(value = "reportCategoryId")String reportCategoryId,
            @ApiParam(name = "appId", value = "应用编码")
            @RequestParam(value = "appId")String appId) {
        Envelop envelop = new Envelop();
        try {
            ReportCategoryAppRelation reportCategoryAppRelation = rsReportCategoryAppService.saveInfo(reportCategoryId, appId);
            if (null != reportCategoryAppRelation) {
                envelop.setSuccessFlg(true);
            }
        } catch (Exception e) {
            e.printStackTrace();
            envelop.setErrorMsg(e.getMessage());
        }
        return envelop;
    }
    @ApiOperation("根据报表分类编码获取应用编码")
    @RequestMapping(value = ServiceApi.Resources.GetRsReportCategoryApps, method = RequestMethod.GET)
    public String getAppIdByCategory(
            @ApiParam(name = "reportCategoryId", value = "报表分类编码")
            @RequestParam(value = "reportCategoryId")String reportCategoryId) {
        String appIds = rsReportCategoryAppService.getAppIdByCategory(reportCategoryId);
        return appIds;
    }
}

+ 178 - 0
src/main/java/com/yihu/ehr/resource/controller/RsReportCategoryEndPoint.java

@ -0,0 +1,178 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.model.resource.MRsReportCategory;
import com.yihu.ehr.resource.model.RsReportCategory;
import com.yihu.ehr.resource.service.RsReportCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
 * 资源报表分类 服务接口
 *
 * @author 张进军
 * @created 2017.8.8 20:32
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsReportCategoryEndPoint", description = "资源报表分类", tags = {"资源服务-资源报表分类"})
public class RsReportCategoryEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsReportCategoryService rsReportCategoryService;
    @ApiOperation("根据ID获取资源报表分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategory, method = RequestMethod.GET)
    public MRsReportCategory getById(
            @ApiParam(name = "id", value = "id", required = true)
            @PathVariable(value = "id") Integer id) throws Exception {
        return convertToModel(rsReportCategoryService.getById(id), MRsReportCategory.class);
    }
    @ApiOperation(value = "根据条件获取资源报表分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategories, method = RequestMethod.GET)
    List<MRsReportCategory> search(
            @ApiParam(name = "codeName", value = "资源分类编码或名称")
            @RequestParam(value = "codeName", required = false) String codeName) throws ParseException {
        List<MRsReportCategory> resultList = new ArrayList<>();
        // 获取最顶层的资源报表分类集合
        List<RsReportCategory> topNodeList = rsReportCategoryService.getChildrenByPid(0);
        if (topNodeList.size() == 0) {
            return resultList;
        }
        // 暂存最顶层资源报表分类中,满足条件的集合
        List<RsReportCategory> topNodeListIn = new ArrayList<>();
        // 暂存最顶层资源报表分类中,不满足条件的集合
        List<RsReportCategory> topNodeListOut = new ArrayList<>();
        if (StringUtils.isEmpty(codeName)) {
            List<RsReportCategory> treeList = rsReportCategoryService.getTreeByParents(topNodeList);
            return (List<MRsReportCategory>) convertToModels(treeList, resultList, MRsReportCategory.class, "");
        }
        for (RsReportCategory reportCategory : topNodeList) {
            if (reportCategory.getCode().contains(codeName) || reportCategory.getName().contains(codeName)) {
                topNodeListIn.add(reportCategory);
                continue;
            }
            topNodeListOut.add(reportCategory);
        }
        if (topNodeListIn.size() != 0) {
            List<RsReportCategory> inList = rsReportCategoryService.getTreeByParents(topNodeListIn);
            resultList.addAll(convertToModels(inList, new ArrayList<MRsReportCategory>(), MRsReportCategory.class, ""));
        }
        List<RsReportCategory> outList = rsReportCategoryService.getTreeByParentsAndCodeName(topNodeListOut, codeName);
        resultList.addAll(convertToModels(outList, new ArrayList<MRsReportCategory>(), MRsReportCategory.class, ""));
        return resultList;
    }
    @ApiOperation(value = "获取资源报表分类的树形下拉框数据")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryComboTree, method = RequestMethod.GET)
    public List<MRsReportCategory> getComboTreeData() throws Exception {
        List<RsReportCategory> list = rsReportCategoryService.getAllTreeData();
        return (List<MRsReportCategory>) convertToModels(list, new ArrayList<MRsReportCategory>(list.size()), MRsReportCategory.class, "");
    }
    @ApiOperation("新增资源报表分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategorySave, method = RequestMethod.POST)
    public MRsReportCategory add(
            @ApiParam(name = "rsReportCategory", value = "资源报表分类JSON", required = true)
            @RequestBody String rsReportCategory) throws Exception {
        RsReportCategory newRsReportCategory = toEntity(rsReportCategory, RsReportCategory.class);
        if (null == newRsReportCategory.getPid()) {
            newRsReportCategory.setPid(0);
        }
        if (null == newRsReportCategory.getSortNo()) {
            newRsReportCategory.setSortNo(99);
        }
        newRsReportCategory = rsReportCategoryService.save(newRsReportCategory);
        return convertToModel(newRsReportCategory, MRsReportCategory.class);
    }
    @ApiOperation("更新资源报表分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategorySave, method = RequestMethod.PUT)
    public MRsReportCategory update(
            @ApiParam(name = "rsReportCategory", value = "资源报表分类JSON", required = true)
            @RequestBody String rsReportCategory) throws Exception {
        RsReportCategory newRsReportCategory = toEntity(rsReportCategory, RsReportCategory.class);
        newRsReportCategory = rsReportCategoryService.save(newRsReportCategory);
        return convertToModel(newRsReportCategory, MRsReportCategory.class);
    }
    @ApiOperation("删除资源报表分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryDelete, method = RequestMethod.DELETE)
    public void delete(
            @ApiParam(name = "id", value = "资源报表分类ID", required = true)
            @RequestParam(value = "id") Integer id) throws Exception {
        rsReportCategoryService.delete(id);
    }
    @ApiOperation("验证资源报表分类编码是否唯一")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryIsUniqueCode, method = RequestMethod.GET)
    public boolean isUniqueCode(
            @ApiParam(name = "id", value = "资源报表分类ID", required = true)
            @RequestParam(value = "id") Integer id,
            @ApiParam(name = "code", value = "资源报表分类编码", required = true)
            @RequestParam(value = "code") String code) throws Exception {
        return rsReportCategoryService.isUniqueCode(id, code);
    }
    @ApiOperation("验证资源报表分类名称是否唯一")
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryIsUniqueName, method = RequestMethod.GET)
    public boolean isUniqueName(
            @ApiParam(name = "id", value = "资源报表分类ID", required = true)
            @RequestParam(value = "id") Integer id,
            @ApiParam(name = "name", value = "资源报表分类名称", required = true)
            @RequestParam(value = "name") String name) throws Exception {
        return rsReportCategoryService.isUniqueName(id, name);
    }
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryNoPageCategories, method = RequestMethod.GET)
    @ApiOperation("获取资源报表类别")
    public List<MRsReportCategory> getAllCategories(
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<RsReportCategory> list = rsReportCategoryService.search(filters);
        return (List<MRsReportCategory>) convertToModels(list, new ArrayList<>(list.size()), MRsReportCategory.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryByApp, method = RequestMethod.GET)
    @ApiOperation("获取平台应用对应的报表分类")
    public List<RsReportCategory> getCategoryByApp(
            @ApiParam(name = "appId", value = "应用Id")
            @RequestParam(value = "appId") String appId) {
        List<RsReportCategory> reportCategoryList = rsReportCategoryService.getCategoryByApp(appId);
        return reportCategoryList;
    }
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryByIds, method = RequestMethod.GET)
    @ApiOperation("根据Id获取平台应用对应的报表分类")
    public List<RsReportCategory> getCategoryByIds(
            @ApiParam(name = "ids", value = "id")
            @RequestParam(value = "ids") List<Integer> ids) {
        List<RsReportCategory> categoryList = rsReportCategoryService.getCategoryByIds(ids);
        return categoryList;
    }
    @RequestMapping(value = ServiceApi.Resources.RsReportCategoryIdsByCode, method = RequestMethod.GET)
    @ApiOperation("根据code获取平台应用对应的报表分类子类")
    public List<Integer> getCategoryIdsByCode(
            @ApiParam(name = "code", value = "分类编码")
            @RequestParam(value = "code") String code) {
        List<Integer> categoryIds = rsReportCategoryService.getCategoryIds(code);
        return categoryIds;
    }
}

+ 220 - 0
src/main/java/com/yihu/ehr/resource/controller/RsReportEndPoint.java

@ -0,0 +1,220 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ErrorCode;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.exception.ApiException;
import com.yihu.ehr.fastdfs.FastDFSUtil;
import com.yihu.ehr.model.resource.MRsReport;
import com.yihu.ehr.resource.model.RsReport;
import com.yihu.ehr.resource.service.RsReportCategoryService;
import com.yihu.ehr.resource.service.RsReportService;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 资源报表 服务接口
 *
 * @author 张进军
 * @created 2017.8.15 19:18
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsReportEndPoint", description = "资源报表", tags = {"资源服务-资源报表"})
public class RsReportEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsReportService rsReportService;
    @Autowired
    private FastDFSUtil fastDFSUtil;
    @Autowired
    private RsReportCategoryService rsReportCategoryService;
    @ApiOperation("根据ID获取资源报表")
    @RequestMapping(value = ServiceApi.Resources.RsReport, method = RequestMethod.GET)
    public MRsReport getById(
            @ApiParam(name = "id", value = "主键", required = true)
            @PathVariable(value = "id") Integer id) throws Exception {
        return convertToModel(rsReportService.getById(id), MRsReport.class);
    }
    @ApiOperation("根据编码获取资源报表")
    @RequestMapping(value = ServiceApi.Resources.RsReportFindByCode, method = RequestMethod.GET)
    public MRsReport findByCode(
            @ApiParam(name = "code", value = "编码", required = true)
            @RequestParam(value = "code") String code) throws Exception {
        return convertToModel(rsReportService.getByCode(code), MRsReport.class);
    }
    @ApiOperation(value = "根据条件获取资源报表")
    @RequestMapping(value = ServiceApi.Resources.RsReports, method = RequestMethod.GET)
    List<MRsReport> search(
            @ApiParam(name = "fields", value = "返回的字段,为空则返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "筛选条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsReport> rsReports = rsReportService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, rsReportService.getCount(filters), page, size);
        return (List<MRsReport>) convertToModels(rsReports, new ArrayList<MRsReport>(), MRsReport.class, fields);
    }
    @ApiOperation("新增资源报表")
    @RequestMapping(value = ServiceApi.Resources.RsReportSave, method = RequestMethod.POST,produces = "application/json")
    public MRsReport add(
            @ApiParam(name = "rsReport", value = "资源报表JSON", required = true)
            @RequestBody String rsReport) throws Exception {
        RsReport newRsReport = toEntity(rsReport, RsReport.class);
        newRsReport = rsReportService.save(newRsReport);
        return convertToModel(newRsReport, MRsReport.class);
    }
    @ApiOperation("更新资源报表")
    @RequestMapping(value = ServiceApi.Resources.RsReportSave, method = RequestMethod.PUT, produces = "application/json" )
    public MRsReport update(
            @ApiParam(name = "rsReport", value = "资源报表JSON", required = true)
            @RequestBody String rsReport) throws Exception {
        RsReport newRsReport = toEntity(rsReport, RsReport.class);
        newRsReport = rsReportService.save(newRsReport);
        return convertToModel(newRsReport, MRsReport.class);
    }
    @ApiOperation("删除资源报表")
    @RequestMapping(value = ServiceApi.Resources.RsReportDelete, method = RequestMethod.DELETE)
    public void delete(
            @ApiParam(name = "id", value = "资源报表ID", required = true)
            @RequestParam(value = "id") Integer id) throws Exception {
        rsReportService.delete(id);
    }
    @ApiOperation("验证资源报表编码是否唯一")
    @RequestMapping(value = ServiceApi.Resources.RsReportIsUniqueCode, method = RequestMethod.GET)
    public boolean isUniqueCode(
            @ApiParam(name = "id", value = "资源报表ID", required = true)
            @RequestParam(value = "id") Integer id,
            @ApiParam(name = "code", value = "资源报表编码", required = true)
            @RequestParam(value = "code") String code) throws Exception {
        return rsReportService.isUniqueCode(id, code);
    }
    @ApiOperation("验证资源报表名称是否唯一")
    @RequestMapping(value = ServiceApi.Resources.RsReportIsUniqueName, method = RequestMethod.GET)
    public boolean isUniqueName(
            @ApiParam(name = "id", value = "资源报表ID", required = true)
            @RequestParam(value = "id") Integer id,
            @ApiParam(name = "name", value = "资源报表名称", required = true)
            @RequestParam(value = "name") String name) throws Exception {
        return rsReportService.isUniqueName(id, name);
    }
    @ApiOperation("查询报表信息(不分页)")
    @RequestMapping(value = ServiceApi.Resources.RsReportNoPage, method = RequestMethod.GET)
    public List<MRsReport> queryNoPageResources(
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<RsReport> list = rsReportService.search(filters);
        return (List<MRsReport>) convertToModels(list, new ArrayList<>(list.size()), MRsReport.class, null);
    }
    @ApiOperation("获取报表模版内容")
    @RequestMapping(value = ServiceApi.Resources.RsReportTemplateContent, method = RequestMethod.GET)
    public String getTemplateContent(
            @ApiParam(name = "reportCode", value = "资源报表Code", required = true)
            @RequestParam(value = "reportCode") String reportCode,
            HttpServletResponse response) throws Exception {
        RsReport rsReport = rsReportService.getByCode(reportCode);
        if (rsReport == null || StringUtils.isEmpty(rsReport.getTemplatePath())) {
            throw new ApiException(ErrorCode.NOT_FOUND, "模版未找到");
        }
        String[] paths = rsReport.getTemplatePath().split(":");
        byte[] bytes = fastDFSUtil.download(paths[0], paths[1]);
        String templateContent = new String(bytes, "UTF-8");
        return templateContent;
    }
    @ApiOperation("判断资源报表分类是否被使用")
    @RequestMapping(value = ServiceApi.Resources.RsReportIsCategoryApplied, method = RequestMethod.GET)
    public boolean isCategoryApplied(
            @ApiParam(name = "reportCategoryId", value = "资源报表分类ID", required = true)
            @RequestParam(value = "reportCategoryId") Integer reportCategoryId) throws Exception {
        List<RsReport> list = rsReportService.getByReportCategoryId(reportCategoryId);
        return list.size() == 0 ? false : true;
    }
    @ApiOperation("根据资源分类编码获取资源报表分")
    @RequestMapping(value = ServiceApi.Resources.RsReportByCategoryId, method = RequestMethod.GET)
    public List<RsReport> getByCategoryId(
            @ApiParam(name = "reportCategoryId", value = "资源报表分类ID", required = true)
            @RequestParam(value = "reportCategoryId") Integer reportCategoryId) throws Exception {
        List<RsReport> list = rsReportService.getByReportCategoryIdAndStatus(reportCategoryId);
        return list;
    }
    @ApiOperation("根据报表编码获取视图位置")
    @RequestMapping(value = ServiceApi.Resources.GetPositionMapByCode, method = RequestMethod.GET)
    public Envelop getPositionByCode(
            @ApiParam(name = "code", value = "报表编码", required = true)
            @RequestParam(value = "code") String code) throws Exception {
        Envelop envelop = new Envelop();
        String positionMap = rsReportService.getPositionByCode(code);
        envelop.setSuccessFlg(true);
        envelop.setObj(positionMap);
        return envelop;
    }
    @ApiOperation(value = "根据报表名称模糊查询")
    @RequestMapping(value = ServiceApi.Resources.GetRsReportByParam, method = RequestMethod.GET)
    public Envelop searchReportByName(
            @ApiParam(name = "filters", value = "筛选条件")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        Envelop envelop = new Envelop();
        String filter = "";
        List<Map<String, Object>> listMap = new ArrayList<>();
        List governmentCategoryId = rsReportCategoryService.getGovernmentCategoryId();
        if (null != governmentCategoryId && governmentCategoryId.size() > 0) {
            for (int i = 0; i < governmentCategoryId.size(); i++) {
                if (StringUtils.isNotEmpty(filters)) {
                    filter = filters + ";status=1;reportCategoryId=" + governmentCategoryId.get(i);
                } else {
                    filter = "status=1;reportCategoryId=" + governmentCategoryId.get(i);
                }
                List<RsReport> rsReports = rsReportService.search(filter, "+showType");
                if (null != rsReports && rsReports.size() > 0) {
                    Map<String, Object> map = new HashMap<>();
                    for (RsReport report : rsReports) {
                        String categoryCode = rsReportCategoryService.getCategoryCodeById(report.getReportCategoryId());
                        report.setReportCategoryTopCode(categoryCode);
                    }
                    map.put("name", rsReports.get(0).getReportCategory());
                    map.put("arr", rsReports);
                    listMap.add(map);
                }
            }
        }
        envelop.setDetailModelList(listMap);
        envelop.setSuccessFlg(true);
        return envelop;
    }
}

+ 68 - 0
src/main/java/com/yihu/ehr/resource/controller/RsReportUsersEndPoint.java

@ -0,0 +1,68 @@
package com.yihu.ehr.resource.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.resource.model.RsReport;
import com.yihu.ehr.resource.model.RsReportUsers;
import com.yihu.ehr.resource.service.RsReportUsersService;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.net.URLDecoder;
import java.util.List;
/**
 * Created by wxw on 2018/7/31.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsReportUsersEndPoint", description = "资源报表用户关系", tags = {"资源服务-资源报表用户关系"})
public class RsReportUsersEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsReportUsersService rsReportUsersService;
    @ApiOperation("根据用户ID获取资源报表列表")
    @RequestMapping(value = ServiceApi.Resources.QueryByUserId, method = RequestMethod.GET)
    public Envelop queryByUserId(
            @ApiParam(name = "userId", value = "用户编码", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        Envelop envelop = new Envelop();
        List<RsReportUsers> rsReportUsersList = rsReportUsersService.getRsReportUsersList(userId);
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(rsReportUsersList);
        return envelop;
    }
    @ApiOperation("根据用户ID获取其他资源报表列表")
    @RequestMapping(value = ServiceApi.Resources.QueryOtherReportByUserId, method = RequestMethod.GET)
    public Envelop queryOtherReportByUserId(
            @ApiParam(name = "userId", value = "用户编码", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        Envelop envelop = new Envelop();
        List<RsReport> rsReportList = rsReportUsersService.getOtherReportListByUserId(userId);
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(rsReportList);
        return envelop;
    }
    @ApiOperation("保存用户报表关系")
    @RequestMapping(value = ServiceApi.Resources.SaveByUserId, method = RequestMethod.POST)
    public Envelop saveByUserId(
            @ApiParam(name = "userId", value = "用户编码", required = true)
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "model", value = "json数据模型", defaultValue = "")
            @RequestParam String model) throws Exception {
        Envelop envelop = new Envelop();
        List<RsReportUsers> rsReportUsersList = objectMapper.readValue(URLDecoder.decode(model, "UTF-8"), new TypeReference<List<RsReportUsers>>() {});
        rsReportUsersService.saveRsReportUser(userId, rsReportUsersList);
        envelop.setSuccessFlg(true);
        return envelop;
    }
}

+ 99 - 0
src/main/java/com/yihu/ehr/resource/controller/RsReportViewEndPoint.java

@ -0,0 +1,99 @@
package com.yihu.ehr.resource.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.model.resource.MRsReportView;
import com.yihu.ehr.resource.model.RsReportView;
import com.yihu.ehr.resource.service.RsReportViewService;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
 * 资源报表视图配置 服务接口
 *
 * @author 张进军
 * @created 2017.8.22 14:05
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsReportViewEndPoint", description = "资源报表视图配置", tags = {"资源服务-资源报表视图配置"})
public class RsReportViewEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsReportViewService rsReportViewService;
    @ApiOperation(value = "根据资源报表ID,获取资源报表视图配置")
    @RequestMapping(value = ServiceApi.Resources.RsReportViews, method = RequestMethod.GET)
    List<MRsReportView> findByReportId(
            @ApiParam(name = "reportId", value = "资源报表ID")
            @RequestParam(value = "reportId") Integer reportId) throws Exception {
        List<RsReportView> rsReportViews = rsReportViewService.findByReportId(reportId);
        return (List<MRsReportView>) convertToModels(rsReportViews, new ArrayList<MRsReportView>(), MRsReportView.class, "");
    }
    @ApiOperation("保存资源报表视图配置")
    @RequestMapping(value = ServiceApi.Resources.RsReportViewSave, method = RequestMethod.POST)
    public void save(
            @ApiParam(name = "reportId", value = "资源报表ID", required = true)
            @RequestParam(value = "reportId") Integer reportId,
            @ApiParam(name = "modelListJson", value = "资源报表视图配置集合JSON字符串", required = true)
            @RequestParam(value = "modelListJson") String modelListJson) throws Exception {
        List<RsReportView> rsReportViewList = objectMapper.readValue(modelListJson, new TypeReference<List<RsReportView>>(){});
        rsReportViewService.save(reportId, rsReportViewList);
    }
    @ApiOperation("判断资源报表视图配置是否存在")
    @RequestMapping(value = ServiceApi.Resources.RsReportViewExist, method = RequestMethod.GET)
    public boolean exist(
            @ApiParam(name = "reportId", value = "资源报表ID", required = true)
            @RequestParam(value = "reportId") Integer reportId,
            @ApiParam(name = "resourceId", value = "视图ID", required = true)
            @RequestParam(value = "resourceId") String resourceId) throws Exception {
        RsReportView rsReportView = rsReportViewService.findByReportIdAndResourceId(reportId, resourceId);
        if (rsReportView != null) {
            return true;
        }
        return false;
    }
    @ApiOperation("判断资源报表是否关联相关资源")
    @RequestMapping(value = ServiceApi.Resources.RsReportViewExistByResourceId, method = RequestMethod.GET)
    public Envelop existByResourceId(
            @ApiParam(name = "resourceId", value = "视图ID", required = true)
            @RequestParam(value = "resourceId") String resourceId){
        Envelop envelop = new Envelop();
        List<RsReportView> rsReportViewList = rsReportViewService.findByResourceId(resourceId);
        envelop.setSuccessFlg(true);
        if (rsReportViewList == null || rsReportViewList.size() <= 0) {
            envelop.setObj(false);
        }else {
            envelop.setObj(true);
        }
        return envelop;
    }
    @ApiOperation("判断资源视图是否存在于报表中")
    @RequestMapping(value = ServiceApi.Resources.RsReportViewExistReport, method = RequestMethod.GET)
    public boolean existReport(
            @ApiParam(name = "resourceId", value = "视图ID", required = true)
            @RequestParam(value = "resourceId") String resourceId) throws Exception {
        List<RsReportView> list = rsReportViewService.findByResourceId(resourceId);
        if (list != null && list.size() > 0) {
            return true;
        }
        return false;
    }
}

+ 186 - 0
src/main/java/com/yihu/ehr/resource/controller/RsResourceCategoryEndPoint.java

@ -0,0 +1,186 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.model.resource.MRsCategory;
import com.yihu.ehr.resource.model.RsResourceCategory;
import com.yihu.ehr.resource.service.RsResourceCategoryService;
import com.yihu.ehr.util.id.BizObject;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by lyr on 2016/5/4.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsResourceCategoryEndPoint", description = "资源分类", tags = {"资源服务-资源分类"})
public class RsResourceCategoryEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsResourceCategoryService rsCategoryService;
    @RequestMapping(value = ServiceApi.Resources.CategoryUpdate, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("资源类别创建")
    public MRsCategory createRsCategory(
            @ApiParam(name = "resourceCategory", value = "资源分类", defaultValue = "{\"name\":\"string\",\"pid\":\"string\",\"description\":\"string\"}")
            @RequestBody String resourceCategory) throws Exception {
        RsResourceCategory rsCategory = toEntity(resourceCategory, RsResourceCategory.class);
        rsCategory.setId(getObjectId(BizObject.ResourceCategory));
        rsCategoryService.createOrUpdRsCategory(rsCategory);
        return convertToModel(rsCategory, MRsCategory.class);
    }
    @RequestMapping(value = ServiceApi.Resources.Category, method = RequestMethod.DELETE)
    @ApiOperation("删除资源类别")
    public Envelop deleteResourceCategory(
            @ApiParam(name = "id", value = "资源类别ID", defaultValue = "string")
            @PathVariable(value = "id") String id) throws Exception {
        Envelop json = new Envelop();
        try{
            rsCategoryService.deleteRsCategory(id);
            json.setSuccessFlg(true);
        }catch (Exception e){
            json.setSuccessFlg(false);
            json.setErrorMsg(e.getMessage());
        }
        return json;
    }
    @RequestMapping(value = ServiceApi.Resources.CategoryUpdate, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("资源类别更新")
    public MRsCategory updateRsCategory(
            @ApiParam(name = "resourceCategory", value = "资源分类", defaultValue = "{\"id\":\"string\",\"name\":\"string\",\"pid\":\"string\",\"description\":\"string\"}")
            @RequestBody String resourceCategory) throws Exception {
        RsResourceCategory rsCategory = toEntity(resourceCategory, RsResourceCategory.class);
        rsCategoryService.createOrUpdRsCategory(rsCategory);
        return convertToModel(rsCategory, MRsCategory.class);
    }
    @RequestMapping(value = ServiceApi.Resources.Category, method = RequestMethod.GET)
    @ApiOperation("根据ID获取资源类别")
    public MRsCategory getRsCategoryById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(rsCategoryService.getRsCategoryById(id), MRsCategory.class);
    }
    @RequestMapping(value = ServiceApi.Resources.CategoriesByPid, method = RequestMethod.GET)
    @ApiOperation("根据pid获取资源类别列表")
    public List<MRsCategory> getRsCategoryByPid(
            @ApiParam(name="pid",value="pid",defaultValue = "")
            @RequestParam(value="pid",required = false) String pid) throws Exception {
        List<RsResourceCategory> categoryList = rsCategoryService.getRsCategoryByPid(pid);
        return (List<MRsCategory>) convertToModels(categoryList, new ArrayList<MRsCategory>(categoryList.size()), MRsCategory.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.CategoriesByCodeAndPid, method = RequestMethod.GET)
    @ApiOperation("根据pid和code获取资源类别列表")
    public List<MRsCategory> getRsCategoryByPidAndCode(
            @ApiParam(name = "code", value="编码类型", defaultValue = "")
            @RequestParam(value= "code") String code,
            @ApiParam(name = "pid", value = "上级id", defaultValue = "")
            @RequestParam(value="pid",required = false) String pid) throws Exception {
        List<RsResourceCategory> categoryList = rsCategoryService.findByCodeAndPid(code, pid);
        return (List<MRsCategory>) convertToModels(categoryList, new ArrayList<MRsCategory>(categoryList.size()), MRsCategory.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.CategoryExitSelfAndParent, method = RequestMethod.GET)
    @ApiOperation(value = "根据当前类别获取自己的父级以及同级以及同级所在父级类别列表")
    public List<MRsCategory> getCateTypeExcludeSelfAndChildren(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id") String id) throws Exception {
        List<RsResourceCategory> parentTypes = rsCategoryService.getRsCategoryByPid(id);
        String childrenIds = getChildIncludeSelfByParentsAndChildrenIds(parentTypes,id+",");   //递归获取
        List<RsResourceCategory> cdaTypes = rsCategoryService.getCateTypeExcludeSelfAndChildren(childrenIds);
        return  (List<MRsCategory>)convertToModels(cdaTypes,new ArrayList<MRsCategory>(cdaTypes.size()),MRsCategory.class,"");
    }
    @RequestMapping(value = ServiceApi.Resources.CategoriesAll, method = RequestMethod.GET)
    @ApiOperation("获取资源类别")
    public List<MRsCategory> getAllCategories(
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<RsResourceCategory> resources = rsCategoryService.search(filters);
        return (List<MRsCategory>) convertToModels(resources, new ArrayList<MRsCategory>(resources.size()), MRsCategory.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.CategoriesSearch, method = RequestMethod.GET)
    @ApiOperation("获取资源类别")
    public List<MRsCategory> getRsCategories(
            @ApiParam(name = "roleId", value = "角色编码")
            @RequestParam(value = "roleId") String roleId,
            @ApiParam(name = "fields", value = "返回字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsCategory> rsList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
            if(roleId.equals("*")) {
                Page<RsResourceCategory> rsCatePage = null;
                rsCatePage = rsCategoryService.getRsCategories(sorts, reducePage(page), size);
                total = rsCatePage.getTotalElements();
                rsList = convertToModels(rsCatePage.getContent(), new ArrayList<>(rsCatePage.getNumber()), MRsCategory.class, fields);
            }else {
                List<RsResourceCategory> rsCateList = null;
                rsCateList = rsCategoryService.findByCode("derived");
                total = rsCateList.size();
                rsList = convertToModels(rsCateList, new ArrayList<>(rsCateList.size()), MRsCategory.class, fields);
            }
        } else {
            List<RsResourceCategory> rsCateList = null;
            if(roleId.equals("*")) {
                rsCateList = rsCategoryService.search(fields, filters, sorts, page, size);
            }else {
                filters += "code=derived;";
                rsCateList = rsCategoryService.search(fields, filters, sorts, page, size);
            }
            total = rsCateList.size();
            rsList = convertToModels(rsCateList, new ArrayList<>(rsCateList.size()), MRsCategory.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsCategory>) rsList;
    }
    public String getChildIncludeSelfByParentsAndChildrenIds(List<RsResourceCategory> parentTypes,String childrenIds) {
        for (int i = 0; i < parentTypes.size(); i++) {
            RsResourceCategory typeInfo = parentTypes.get(i);
            childrenIds+=typeInfo.getId()+",";
            List<RsResourceCategory> listChild = rsCategoryService.getRsCategoryByPid(typeInfo.getId());
            if(listChild.size()>0){
                childrenIds = getChildIncludeSelfByParentsAndChildrenIds(listChild,childrenIds);
            }
        }
        return childrenIds;
    }
}

+ 122 - 0
src/main/java/com/yihu/ehr/resource/controller/RsResourceDefaultParamsEndPoint.java

@ -0,0 +1,122 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.model.resource.MResourceDefaultParam;
import com.yihu.ehr.resource.model.RsResourceDefaultParam;
import com.yihu.ehr.resource.service.RsResourceDefaultParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by shine on 2016/6/27.
 */
@RestController
@RequestMapping(value= ApiVersion.Version1_0)
@Api(value = "RsResourceDefaultParamsEndPoint", description = "资源默认参数", tags = {"资源服务-资源默认参数"})
public class RsResourceDefaultParamsEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsResourceDefaultParamService resourceDefaultParamService;
    @RequestMapping(value = ServiceApi.Resources.ParamById,method = RequestMethod.GET)
    @ApiOperation("根据id获取参数信息")
    public MResourceDefaultParam getResourceDefaultParamById(
            @ApiParam(name = "id", value = "资源默认参数信息id")
            @PathVariable(value = "id") String id){
        RsResourceDefaultParam resourceDefaultParam = resourceDefaultParamService.findById(id);
        if(resourceDefaultParam == null){
            return null;
        }
        return convertToModel(resourceDefaultParam, MResourceDefaultParam.class);
    }
    @RequestMapping(value = ServiceApi.Resources.Param,method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("增加资源默认参数")
    public MResourceDefaultParam addResourceDefaultParams(
            @ApiParam(name = "json_data", value = "资源默认参数json串")
            @RequestBody String jsonData) throws IOException {
        RsResourceDefaultParam resourceDefaultParam = toEntity(jsonData, RsResourceDefaultParam.class);
        RsResourceDefaultParam resourceDefaultParamNew = resourceDefaultParamService.save(resourceDefaultParam);
        return convertToModel(resourceDefaultParamNew, MResourceDefaultParam.class);
    }
    @RequestMapping(value = ServiceApi.Resources.Param,method = RequestMethod.PUT,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation("更新资源默认参数")
    public MResourceDefaultParam updateResourceDefaultParams(
            @ApiParam(name = "json_data", value = "资源默认参数json串")
            @RequestBody String jsonData) throws IOException {
        RsResourceDefaultParam resourceDefaultParam = toEntity(jsonData, RsResourceDefaultParam.class);
        RsResourceDefaultParam resourceDefaultParamNew = resourceDefaultParamService.save(resourceDefaultParam);
        return convertToModel(resourceDefaultParamNew, MResourceDefaultParam.class);
    }
    @RequestMapping(value = ServiceApi.Resources.ParamById,method = RequestMethod.DELETE)
    @ApiOperation("根据id删除资源默认参数")
    public boolean deleteResourceDefaultParams(
            @ApiParam(name="id",value="资源默认参数id")
            @PathVariable(value="id") String id){
        resourceDefaultParamService.delete(id);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.Params, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取资源默认参数列表,分页")
    public List<MResourceDefaultParam> searchRsDefaultParams(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,resourcesId,resourcesCode,paramKey,paramValue")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+id")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsResourceDefaultParam>  rsDefaultParams = resourceDefaultParamService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, resourceDefaultParamService.getCount(filters), page, size);
        return (List<MResourceDefaultParam>) convertToModels(rsDefaultParams, new ArrayList<MResourceDefaultParam>(rsDefaultParams.size()), MResourceDefaultParam.class, fields);
    }
    @RequestMapping(value = ServiceApi.Resources.ParamsNoPage, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取资源默认参数列表,不分页")
    public Collection<MResourceDefaultParam> searchRsDefaultParamsNoPage(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<RsResourceDefaultParam> rsDefaultParams = resourceDefaultParamService.search(filters);
        return convertToModels(rsDefaultParams, new ArrayList<MResourceDefaultParam>(rsDefaultParams.size()), MResourceDefaultParam.class,null);
    }
    @RequestMapping(value = ServiceApi.Resources.ParamKeyValueExistence, method = RequestMethod.GET)
    @ApiOperation(value = "同个资源下同个参数名所对应的参数值不重复验证")
    public boolean isExistenceRsParamKeyValue(
            @ApiParam(name = "resources_id", value = "过资源id")
            @RequestParam(value = "resources_id") String resourcesId,
            @ApiParam(name = "param_key", value = "默认参数名")
            @RequestParam(value = "param_key") String paramKey,
            @ApiParam(name = "param_value", value = "默认参数值")
            @RequestParam(value = "param_value") String paramValue){
        String[] fields = {"resourcesId","paramKey","paramValue"};
        String[] values = {resourcesId,paramKey,paramValue};
        List<RsResourceDefaultParam> list = resourceDefaultParamService.findByFields(fields, values);
        if(list != null && list.size()>0){
            return true;
        }
        return false;
    }
}

+ 40 - 0
src/main/java/com/yihu/ehr/resource/controller/RsResourceDefaultQueryEndPoint.java

@ -0,0 +1,40 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.resource.model.RsResourceDefaultQuery;
import com.yihu.ehr.resource.service.RsResourceDefaultQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Sxy on 2017/08.
 */
@RestController
@RequestMapping(value= ApiVersion.Version1_0)
@Api(value = "RsResourceDefaultQueryEndPoint", description = "资源默认查询条件", tags = {"资源服务-资源默认查询条件"})
public class RsResourceDefaultQueryEndPoint {
    @Autowired
    private RsResourceDefaultQueryService resourcesDefaultQueryService;
    @RequestMapping(value = ServiceApi.Resources.QueryByResourceId, method = RequestMethod.GET)
    @ApiOperation("根据资源id获取默认查询条件值")
    public String getByResourceId(
            @ApiParam(name = "resourceId", value = "资源id")
            @RequestParam(value = "resourceId") String resourceId){
        RsResourceDefaultQuery resourcesQuery = resourcesDefaultQueryService.findByResourcesId(resourceId);
        if(resourcesQuery == null){
            return "{}";
        }
        return resourcesQuery.getQuery();
    }
}

+ 201 - 0
src/main/java/com/yihu/ehr/resource/controller/RsResourceEndPoint.java

@ -0,0 +1,201 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ErrorCode;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsResources;
import com.yihu.ehr.resource.model.RsResource;
import com.yihu.ehr.resource.service.RsAppResourceService;
import com.yihu.ehr.resource.service.RsResourceService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
/**
 * Created by lyr on 2016/4/25.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsResourceEndPoint", description = "资源", tags = {"资源服务-资源"})
public class RsResourceEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsResourceService rsResourceService;
    @Autowired
    private RsAppResourceService rsAppResourceService;
    @ApiOperation("创建资源")
    @RequestMapping(value = ServiceApi.Resources.Resources, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Envelop createResource(
            @ApiParam(name="resource",value="资源",defaultValue = "")
            @RequestBody String resource) throws Exception {
        Envelop envelop = new Envelop();
        RsResource rs = toEntity(resource, RsResource.class);
        rs.setId(getObjectId(BizObject.Resources));
        RsResource newRsResource =  rsResourceService.saveResource(rs);
        envelop.setSuccessFlg(true);
        envelop.setObj(newRsResource);
        return envelop;
    }
    @ApiOperation("更新资源")
    @RequestMapping(value = ServiceApi.Resources.Resources, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Envelop updateResources(
            @ApiParam(name="resource",value="资源")
            @RequestBody String resource) throws IOException {
        Envelop envelop = new Envelop();
        RsResource rs = toEntity(resource,RsResource.class);
        RsResource newRsResource =  rsResourceService.saveResource(rs);
        envelop.setSuccessFlg(true);
        envelop.setObj(newRsResource);
        return envelop;
    }
    @ApiOperation("资源删除")
    @RequestMapping(value=ServiceApi.Resources.Resource, method = RequestMethod.DELETE)
    public boolean deleteResources(
            @ApiParam(name="id", value = "资源ID")
            @PathVariable(value = "id") String id) throws Exception {
        rsResourceService.deleteResource(id);
        return true;
    }
    @ApiOperation("批量资源删除")
    @RequestMapping(value = ServiceApi.Resources.Resources, method = RequestMethod.DELETE)
    public boolean deleteResourcesBatch(
            @ApiParam(name="ids",value="资源ID",defaultValue = "")
            @RequestParam(value="ids") String ids) throws Exception {
        rsResourceService.deleteResource(ids);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.Resource, method = RequestMethod.GET)
    @ApiOperation("根据ID获取资源")
    public Envelop getResourceById(
            @ApiParam(name = "id",value = "id")
            @PathVariable(value = "id") String id) {
        Envelop envelop = new Envelop();
        RsResource rsResource = rsResourceService.getResourceById(id);
        if (rsResource != null) {
            return success(rsResource);
        } else {
            return failed("无相关资源id:" + id, ErrorCode.OBJECT_NOT_FOUND.value());
        }
    }
    @RequestMapping(value = ServiceApi.Resources.ResourceByCode, method = RequestMethod.GET)
    @ApiOperation("根据code获取资源")
    public Envelop getResourceByCode(
            @ApiParam(name = "code", value = "编码" )
            @RequestParam(value = "code" ) String code) {
        RsResource rsResource = rsResourceService.getResourceByCode(code);
        if (rsResource != null) {
            return success(rsResource);
        } else {
            return failed("无相关资源code:" + code, ErrorCode.OBJECT_NOT_FOUND.value());
        }
    }
    @RequestMapping(value = ServiceApi.Resources.ResourceTree, method = RequestMethod.GET)
    @ApiOperation("获取资源列表树")
    public Envelop getResourceTree(
            @ApiParam(name = "dataSource", value = "资源类型")
            @RequestParam(value = "dataSource") Integer dataSource,
            @ApiParam(name = "userResource", value = "授权资源")
            @RequestParam(value = "userResource") String userResource,
            @ApiParam(name = "filters", value = "过滤条件(name)")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<Map<String, Object>> resultList = rsResourceService.getResourceTree(dataSource, userResource, filters);
        return success(resultList);
    }
    @RequestMapping(value = ServiceApi.Resources.ResourcePage, method = RequestMethod.POST)
    @ApiOperation("获取资源列表分页(政府服务平台)")
    public Envelop getResourcePage(
            @ApiParam(name = "userResource", value = "授权资源")
            @RequestParam(value = "userResource") String userResource,
            @ApiParam(name = "userId", value = "用户ID")
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<RsResource> resultList = rsResourceService.getResourcePage(userResource, userId, page, size);
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setCurrPage(page);
        envelop.setPageSize(size);
        envelop.setTotalCount(rsResourceService.getResourceCount(userResource, userId));
        envelop.setDetailModelList(resultList);
        return envelop;
    }
    @ApiOperation("资源查询")
    @RequestMapping(value = ServiceApi.Resources.Resources, method = RequestMethod.GET)
    public List<MRsResources> queryResources(
            @ApiParam(name="fields",value="返回字段",defaultValue = "")
            @RequestParam(value="fields",required = false)String fields,
            @ApiParam(name="filters",value="过滤",defaultValue = "")
            @RequestParam(value="filters",required = false)String filters,
            @ApiParam(name="sorts",value="排序",defaultValue = "")
            @RequestParam(value="sorts",required = false)String sorts,
            @ApiParam(name="page",value="页码",defaultValue = "1")
            @RequestParam(value="page",required = false)int page,
            @ApiParam(name="size",value="分页大小",defaultValue = "15")
            @RequestParam(value="size",required = false)int size,
            @ApiParam(name = "rolesId", value = "角色组Id", defaultValue = "")
            @RequestParam(value = "rolesId", required = false) String rolesId,
            @ApiParam(name = "appId", value = "应用Id", defaultValue = "")
            @RequestParam(value = "appId", required = false) String appId,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsResources> rsList;
        //过滤条件为空
        if(StringUtils.isEmpty(filters)) {
            Page<RsResource> resources = rsResourceService.getResources(sorts,reducePage(page),size);
            total = resources.getTotalElements();
            rsList = convertToModels(resources.getContent(),new ArrayList<>(resources.getNumber()),MRsResources.class,fields);
        } else {
            if (!StringUtils.isEmpty(rolesId) && !StringUtils.isEmpty(appId)) {
                String resourceIds = rsAppResourceService.getResourceIdByAppId(appId);
                if (!StringUtils.isEmpty(resourceIds)) {
                    filters += ";id=" + resourceIds + ";" ;
                } else {
                    filters += ";id=0000;" ;
                }
            }
            List<RsResource> resources = rsResourceService.search(fields,filters,sorts,page,size);
            total = rsResourceService.getCount(filters);
            rsList = convertToModels(resources,new ArrayList<>(resources.size()),MRsResources.class,fields);
        }
        pagedResponse(request,response,total,page,size);
        return (List<MRsResources>)rsList;
    }
    @ApiOperation("资源查询_不分页")
    @RequestMapping(value = ServiceApi.Resources.NoPageResources, method = RequestMethod.GET)
    public List<MRsResources> queryNoPageResources(
            @ApiParam(name="filters",value="过滤",defaultValue = "")
            @RequestParam(value="filters",required = false)String filters) throws Exception {
        Collection<MRsResources> mrsList;
        Collection<MRsResources> rsList = rsResourceService.search(filters);
        mrsList = convertToModels(rsList,new ArrayList<>(rsList.size()),MRsResources.class,"");
        return (List<MRsResources>)mrsList;
    }
}

+ 1000 - 0
src/main/java/com/yihu/ehr/resource/controller/RsResourceGrantEndPoint.java

@ -0,0 +1,1000 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.entity.resource.RsAppResource;
import com.yihu.ehr.entity.resource.RsAppResourceMetadata;
import com.yihu.ehr.model.org.MRsOrgResource;
import com.yihu.ehr.model.org.MRsOrgResourceMetadata;
import com.yihu.ehr.model.resource.MRsAppResource;
import com.yihu.ehr.model.resource.MRsAppResourceMetadata;
import com.yihu.ehr.model.resource.MRsRolesResource;
import com.yihu.ehr.model.resource.MRsRolesResourceMetadata;
import com.yihu.ehr.resource.model.*;
import com.yihu.ehr.resource.service.*;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
/**
 * Created by lyr on 2016/4/26.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsResourceGrantEndPoint", description = "资源授权", tags = {"资源服务-资源授权"})
public class RsResourceGrantEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsResourceService rsResourceService;
    @Autowired
    private RsResourceGrantService rsGrantService;
    @Autowired
    private RsAppResourceMetadataGrantService rsMetadataGrantService;
    @Autowired
    private RsRolesResourceMetadataGrantService rolesResourceMetadataGrantService;
    @Autowired
    private RsRolesResourceGrantService rolesResourceGrantService;
    @Autowired
    private RsOrgResourceGrantService orgResourceGrantService;
    @Autowired
    private RsOrgResourceMetadataGrantService orgResourceMetadataGrantService;
    @Autowired
    private RsResourceMetadataService rsResourceMetadataService;
    @ApiOperation("单个应用授权多个资源")
    @RequestMapping(value = ServiceApi.Resources.AppsGrantResources, method = RequestMethod.POST)
    public Collection<MRsAppResource> grantAppResource(
            @ApiParam(name = "appId", value = "资源ID", defaultValue = "")
            @PathVariable(value = "appId") String appId,
            @ApiParam(name = "resourceIds", value = "资源ID", defaultValue = "")
            @RequestParam(value = "resourceIds") String resourceIds) throws Exception {
        String[] resourceIdArray = resourceIds.split(",");
        List<RsAppResource> appRsList = new ArrayList<RsAppResource>();
        for (String resoruceId : resourceIdArray) {
            RsAppResource appRs = new RsAppResource();
            appRs.setId(getObjectId(BizObject.AppResource));
            appRs.setAppId(appId);
            appRs.setResourceId(resoruceId);
            appRsList.add(appRs);
        }
        return convertToModels(rsGrantService.grantResourceBatch(appRsList), new ArrayList<>(appRsList.size()), MRsAppResource.class, "");
    }
    @ApiOperation("资源授权多个应用")
    @RequestMapping(value = ServiceApi.Resources.ResourceGrantApps, method = RequestMethod.POST)
    public Collection<MRsAppResource> grantResourceApp(
            @ApiParam(name = "resourceId", value = "资源ID", defaultValue = "")
            @PathVariable(value = "resourceId") String resourceId,
            @ApiParam(name = "appIds", value = "资源ID", defaultValue = "")
            @RequestParam(value = "appIds") String appIds) throws Exception {
        String[] appIdArray = appIds.split(",");
        List<RsAppResource> appRsList = new ArrayList<RsAppResource>();
        List<RsAppResource> rsGrant = rsGrantService.search("", "resourceId=" + resourceId + ";appId=" + appIds, "", 1, 999);
        String existGrant = "";
        for (RsAppResource rsAppResource : rsGrant) {
            existGrant += "," + rsAppResource.getAppId();
        }
        for (String _appId : appIdArray) {
            if (existGrant.contains(_appId)) {
                continue;
            }
            RsAppResource appRs = new RsAppResource();
            appRs.setId(getObjectId(BizObject.AppResource));
            appRs.setAppId(_appId);
            appRs.setResourceId(resourceId);
            appRsList.add(appRs);
        }
        return convertToModels(rsGrantService.addList(appRsList, resourceId), new ArrayList<>(appRsList.size()), MRsAppResource.class, "");
    }
    @ApiOperation("资源授权删除")
    @RequestMapping(value = ServiceApi.Resources.ResourceGrant, method = RequestMethod.DELETE)
    public boolean deleteGrant(
            @ApiParam(name = "id", value = "授权ID", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        rsGrantService.deleteResourceGrant(id);
        return true;
    }
    @ApiOperation("资源授权批量删除")
    @RequestMapping(value = ServiceApi.Resources.ResourceGrants, method = RequestMethod.DELETE)
    public boolean deleteGrantBatch(
            @ApiParam(name = "ids", value = "授权ID", defaultValue = "")
            @RequestParam(value = "ids") String ids) throws Exception {
        rsGrantService.deleteGrantByIds(ids.split(","));
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.ResourceGrant, method = RequestMethod.GET)
    @ApiOperation("根据ID获取资源授权")
    public MRsAppResource getRsAppGrantById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(rsGrantService.getRsAppGrantById(id), MRsAppResource.class);
    }
    @ApiOperation("资源授权查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceGrants, method = RequestMethod.GET)
    public List<MRsAppResource> queryAppResourceGrant(
            @ApiParam(name = "fields", value = "返回字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsAppResource> rsAppList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
            Page<RsAppResource> rsGrant = rsGrantService.getAppResourceGrant(sorts, reducePage(page), size);
            total = rsGrant.getTotalElements();
            rsAppList = convertToModels(rsGrant.getContent(), new ArrayList<>(rsGrant.getNumber()), MRsAppResource.class, fields);
        } else {
            List<RsAppResource> rsGrant = rsGrantService.search(fields, filters, sorts, page, size);
            total = rsGrantService.getCount(filters);
            rsAppList = convertToModels(rsGrant, new ArrayList<>(rsGrant.size()), MRsAppResource.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsAppResource>) rsAppList;
    }
    @ApiOperation("资源授权查询-不分页")
    @RequestMapping(value = ServiceApi.Resources.ResourceGrantsNoPage, method = RequestMethod.GET)
    public List<MRsAppResource> queryAppResourceGrantNoPage(
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        Collection<MRsAppResource> rsAppList;
        List<RsAppResource> rsGrant = rsGrantService.search(filters);
        rsAppList = convertToModels(rsGrant, new ArrayList<>(rsGrant.size()), MRsAppResource.class, null);
        return (List<MRsAppResource>) rsAppList;
    }
    @ApiOperation("资源数据元授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataGrantApp, method = RequestMethod.POST)
    public MRsAppResourceMetadata grantRsMetaData(
            @ApiParam(name = "metadataId", value = "资源ID", defaultValue = "")
            @PathVariable(value = "metadataId") String metadataId,
            @ApiParam(name = "appResourceId", value = "资源数据元ID", defaultValue = "")
            @PathVariable(value = "appResourceId") String appResourceId) throws Exception {
        RsAppResourceMetadata appRsMetadata = new RsAppResourceMetadata();
        appRsMetadata.setId(getObjectId(BizObject.AppResourceMetadata));
        appRsMetadata.setAppResourceId(appResourceId);
        appRsMetadata.setResourceMetadataId(metadataId);
        rsMetadataGrantService.grantRsMetadata(appRsMetadata);
        return convertToModel(appRsMetadata, MRsAppResourceMetadata.class);
    }
    @ApiOperation("资源数据元批量授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataListGrantApp, method = RequestMethod.POST)
    public Collection<MRsAppResourceMetadata> grantRsMetaDataBatch(
            @ApiParam(name = "appResourceId", value = "资源ID", defaultValue = "")
            @PathVariable(value = "appResourceId") String appResourceId,
            @ApiParam(name = "metadataIds", value = "资源数据元ID", defaultValue = "")
            @RequestParam(value = "metadataIds") String metadataIds) throws Exception {
        String[] metadataIdArray = metadataIds.split(",");
        List<RsAppResourceMetadata> appRsMetadataList = new ArrayList<RsAppResourceMetadata>();
        for (String _metadataId : metadataIdArray) {
            RsAppResourceMetadata appRsMetadata = new RsAppResourceMetadata();
            appRsMetadata.setId(getObjectId(BizObject.AppResourceMetadata));
            appRsMetadata.setAppResourceId(appResourceId);
            appRsMetadata.setResourceMetadataId(_metadataId);
            appRsMetadataList.add(appRsMetadata);
        }
        rsMetadataGrantService.grantRsMetadataBatch(appRsMetadataList);
        return convertToModels(appRsMetadataList, new ArrayList<>(appRsMetadataList.size()), MRsAppResourceMetadata.class, "");
    }
    @ApiOperation("资源数据元授权删除")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataGrant, method = RequestMethod.DELETE)
    public boolean deleteMetadataGrant(
            @ApiParam(name = "id", value = "授权ID", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        rsMetadataGrantService.deleteRsMetadataGrant(id);
        return true;
    }
    @ApiOperation("资源数据元授权批量删除")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataGrants, method = RequestMethod.DELETE)
    public boolean deleteMetadataGrantBatch(
            @ApiParam(name = "ids", value = "授权ID", defaultValue = "")
            @RequestParam(value = "ids") String ids) throws Exception {
        rsMetadataGrantService.deleteRsMetadataGrant(ids);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataGrant, method = RequestMethod.GET)
    @ApiOperation("根据ID获取资源数据元授权")
    public MRsAppResourceMetadata getRsMetadataGrantById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(rsMetadataGrantService.getRsMetadataGrantById(id), MRsAppResourceMetadata.class);
    }
    @ApiOperation("资源数据元授权查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataGrants, method = RequestMethod.GET)
    public List<MRsAppResourceMetadata> queryAppRsMetadataGrant(
            @ApiParam(name = "fields", value = "返回字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsAppResourceMetadata> rsAppMetaList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
            Page<RsAppResourceMetadata> rsMetadataGrant = rsMetadataGrantService.getAppRsMetadataGrant(sorts, reducePage(page), size);
            total = rsMetadataGrant.getTotalElements();
            rsAppMetaList = convertToModels(rsMetadataGrant.getContent(), new ArrayList<>(rsMetadataGrant.getNumber()), MRsAppResourceMetadata.class, fields);
        } else {
            List<RsAppResourceMetadata> rsMetadataGrant = rsMetadataGrantService.search(fields, filters, sorts, page, size);
            total = rsMetadataGrantService.getCount(filters);
            rsAppMetaList = convertToModels(rsMetadataGrant, new ArrayList<>(rsMetadataGrant.size()), MRsAppResourceMetadata.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsAppResourceMetadata>) rsAppMetaList;
    }
    @ApiOperation("资源数据元授权查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceAppMetadataGrants, method = RequestMethod.GET)
    public Collection<MRsAppResourceMetadata> getAppRsMetadatas(
            @ApiParam(name = "app_res_id", value = "授权应用编号", defaultValue = "1")
            @PathVariable(value = "app_res_id") String appResId) throws Exception {
        RsAppResource appResource = rsGrantService.retrieve(appResId);
        List<RsAppResourceMetadata> rsMetadataGrant = new ArrayList<>();
        if (appResource != null) {
            rsMetadataGrant = rsMetadataGrantService.getAppRsMetadatas(appResource.getId(), appResource.getAppId(), appResource.getResourceId());
        }
        return convertToModels(rsMetadataGrant, new ArrayList<>(rsMetadataGrant.size()), MRsAppResourceMetadata.class, "");
    }
    @ApiOperation("资源数据元生失效操作")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadatasValid, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public boolean valid(
            @ApiParam(name = "data", value = "授权数据元", defaultValue = "")
            @RequestBody List<RsAppResourceMetadata> data,
            @ApiParam(name = "valid", value = "授权数据元ID", defaultValue = "")
            @RequestParam(value = "valid") int valid) throws Exception {
        String ids = "";
        if (valid == 0) {
            for (RsAppResourceMetadata metadata : data) {
                ids += "," + metadata.getId();
            }
        } else {
            List addLs = new ArrayList<>();
            for (RsAppResourceMetadata metadata : data) {
                if (!StringUtils.isEmpty(metadata.getId())) {
                    ids += "," + metadata.getId();
                } else {
                    metadata.setId(getObjectId(BizObject.AppResourceMetadata));
                    addLs.add(metadata);
                }
            }
            rsMetadataGrantService.grantRsMetadataBatch(addLs);
        }
        if (ids.length() > 0) {
            rsMetadataGrantService.valid(ids.substring(1), valid);
        }
        return true;
    }
    @ApiOperation("资源数据元维度授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataGrant, method = RequestMethod.POST)
    public MRsAppResourceMetadata metadataGrant(
            @ApiParam(name = "id", value = "授权ID", defaultValue = "")
            @PathVariable(value = "id") String id,
            @ApiParam(name = "dimension", value = "授权ID", defaultValue = "")
            @RequestParam(value = "dimension") String dimension) throws Exception {
        RsAppResourceMetadata rsAppResourceMetadata = rsMetadataGrantService.retrieve(id);
        rsAppResourceMetadata.setDimensionValue(dimension);
        rsMetadataGrantService.save(rsAppResourceMetadata);
        return convertToModel(rsAppResourceMetadata, MRsAppResourceMetadata.class);
    }
    @ApiOperation("资源数据元维度授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataGrants, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    MRsAppResourceMetadata metadataGrant(
            @RequestBody RsAppResourceMetadata model) throws Exception {
        if (StringUtils.isEmpty(model.getId())) {
            model.setId(getObjectId(BizObject.AppResourceMetadata));
        }
        return convertToModel(rsMetadataGrantService.save(model), MRsAppResourceMetadata.class);
    }
    @ApiOperation("查询资源应用下存在多少授权数据元")
    @RequestMapping(value = ServiceApi.Resources.ResourceAppMetadataGrantExistence, method = RequestMethod.GET)
    List<Map> appMetaExistence(
            @ApiParam(name = "dimension", value = "授权ID", defaultValue = "")
            @RequestParam("res_app_ids") String resAppIds) throws Exception {
        List<Map> ls = rsMetadataGrantService.appMetaExistence(resAppIds.split(","));
        return ls;
    }
    @ApiOperation("角色组资源授权查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceRolesGrants, method = RequestMethod.GET)
    public List<MRsRolesResource> queryRolesResourceGrant(
            @ApiParam(name = "fields", value = "返回字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "999")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsRolesResource> rsRolesList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
            Page<RsRolesResource> rsGrant = rolesResourceGrantService.getRolesResourceGrant(sorts, reducePage(page), size);
            total = rsGrant.getTotalElements();
            rsRolesList = convertToModels(rsGrant.getContent(), new ArrayList<>(rsGrant.getNumber()), MRsRolesResource.class, fields);
        } else {
            List<RsRolesResource> rsGrant = rolesResourceGrantService.search(fields, filters, sorts, page, size);
            total = rolesResourceGrantService.getCount(filters);
            rsRolesList = convertToModels(rsGrant, new ArrayList<>(rsGrant.size()), MRsRolesResource.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsRolesResource>) rsRolesList;
    }
    @ApiOperation("角色组资源数据元生失效操作")
    @RequestMapping(value = ServiceApi.Resources.ResourceRolesMetadatasValid, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public boolean rolesValid(
            @ApiParam(name = "data", value = "授权数据元", defaultValue = "")
            @RequestBody List<RsRolesResourceMetadata> data,
            @ApiParam(name = "valid", value = "授权数据元ID", defaultValue = "")
            @RequestParam(value = "valid") int valid) throws Exception {
        String ids = "";
        if (valid == 0) {
            for (RsRolesResourceMetadata metadata : data) {
                ids += "," + metadata.getId();
            }
        } else {
            List addLs = new ArrayList<>();
            for (RsRolesResourceMetadata metadata : data) {
                if (!StringUtils.isEmpty(metadata.getId())) {
                    ids += "," + metadata.getId();
                } else {
                    metadata.setId(getObjectId(BizObject.RolesResourceMetadata));
                    addLs.add(metadata);
                }
            }
            rolesResourceMetadataGrantService.grantRsRolesMetadataBatch(addLs);
        }
        if (ids.length() > 0) {
            rolesResourceMetadataGrantService.rolesValid(ids.substring(1), valid);
        }
        return true;
    }
    @ApiOperation("角色组资源数据元维度授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceRolesGrant, method = RequestMethod.POST)
    public MRsRolesResourceMetadata metadataRolesGrant(
            @ApiParam(name = "id", value = "授权ID", defaultValue = "")
            @PathVariable(value = "id") String id,
            @ApiParam(name = "dimension", value = "授权ID", defaultValue = "")
            @RequestParam(value = "dimension") String dimension) throws Exception {
        RsRolesResourceMetadata rsRolesResourceMetadata = rolesResourceMetadataGrantService.retrieve(id);
        rsRolesResourceMetadata.setDimensionValue(dimension);
        rolesResourceMetadataGrantService.save(rsRolesResourceMetadata);
        return convertToModel(rsRolesResourceMetadata, MRsRolesResourceMetadata.class);
    }
    @ApiOperation("角色组资源数据元维度授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceRolesMetadataGrants, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    MRsRolesResourceMetadata rolesMetadataGrant(
            @RequestBody RsRolesResourceMetadata model) throws Exception {
        if (StringUtils.isEmpty(model.getId())) {
            model.setId(getObjectId(BizObject.RolesResourceMetadata));
        }
        return convertToModel(rolesResourceMetadataGrantService.save(model), MRsRolesResourceMetadata.class);
    }
    @ApiOperation("单个角色组授权多个资源")
    @RequestMapping(value = ServiceApi.Resources.RolesGrantResources, method = RequestMethod.POST)
    public Collection<MRsRolesResource> grantRolesResource(
            @ApiParam(name = "rolesId", value = "角色组ID", defaultValue = "")
            @PathVariable(value = "rolesId") String rolesId,
            @ApiParam(name = "resourceIds", value = "资源ID", defaultValue = "")
            @RequestParam(value = "resourceIds") String resourceIds) throws Exception {
        String[] resourceIdArray = resourceIds.split(",");
        List<RsRolesResource> rolesRsList = new ArrayList<RsRolesResource>();
        for (String resoruceId : resourceIdArray) {
            RsRolesResource rolesRs = new RsRolesResource();
            rolesRs.setId(getObjectId(BizObject.RolesResource));
            rolesRs.setRolesId(rolesId);
            rolesRs.setResourceId(resoruceId);
            rolesRsList.add(rolesRs);
        }
        return convertToModels(rolesResourceGrantService.grantResourceBatch(rolesRsList), new ArrayList<>(rolesRsList.size()), MRsRolesResource.class, "");
    }
    @ApiOperation("角色组授权资源查询")
    @RequestMapping(value = ServiceApi.Resources.GetRolesGrantResources, method = RequestMethod.GET)
    public Envelop getRolesGrantResources(
            @ApiParam(name = "rolesId", value = "角色组ID")
            @RequestParam(value = "rolesId") String rolesId,
            @ApiParam(name = "userId", value = "用户ID")
            @RequestParam(value = "userId") String userId) throws Exception {
        Envelop envelop = new Envelop();
        Set<String> idSet = new HashSet<String>();
        List<RsRolesResource> rolesRsList = rolesResourceGrantService.search("rolesId=" + rolesId);
        for (RsRolesResource rsRolesResource : rolesRsList) {
            idSet.add(rsRolesResource.getResourceId());
        }
        List<RsResource> rsResourceList = rsResourceService.search("creator=" + userId);
        for (RsResource rsResource : rsResourceList) {
            idSet.add(rsResource.getId());
        }
        List<String> idList = new ArrayList<String>();
        idList.addAll(idSet);
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(idList);
        return envelop;
    }
    @ApiOperation("角色组资源数据元授权查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceRolesResMetadataGrants, method = RequestMethod.GET)
    public Collection<MRsRolesResourceMetadata> getRolesRsMetadatas(
            @ApiParam(name = "roles_res_id", value = "授权应用编号", defaultValue = "1")
            @PathVariable(value = "roles_res_id") String rolesResId,
            @ApiParam(name = "appId", value = "应用编号", defaultValue = "")
            @RequestParam(value = "appId", required = false) String appId) throws Exception {
        RsRolesResource rolesResource = rolesResourceGrantService.retrieve(rolesResId);
        List<RsRolesResourceMetadata> rsMetadataGrant = new ArrayList<>();
        List<RsRolesResourceMetadata> rsMetadataGrantApp = new ArrayList<>();
        if (rolesResource != null) {
            rsMetadataGrant = rolesResourceMetadataGrantService.getRolesRsMetadatas(rolesResource.getId(), rolesResource.getRolesId(), rolesResource.getResourceId());
        }
        if (!StringUtils.isEmpty(appId)) {
            List<String> list = rsMetadataGrantService.getMetadataIdByAppId(appId);
            for (RsRolesResourceMetadata resourceMetadata : rsMetadataGrant) {
                if (list.contains(resourceMetadata.getResourceMetadataId())) {
                    rsMetadataGrantApp.add(resourceMetadata);
                }
            }
            return convertToModels(rsMetadataGrantApp, new ArrayList<>(rsMetadataGrantApp.size()), MRsRolesResourceMetadata.class, "");
        }
        return convertToModels(rsMetadataGrant, new ArrayList<>(rsMetadataGrant.size()), MRsRolesResourceMetadata.class, "");
    }
    @ApiOperation("角色组取消资源授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceRolesGrantsNoPage, method = RequestMethod.GET)
    public List<MRsRolesResource> queryRolesResourceGrantNoPage(
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        Collection<MRsRolesResource> rsRolesList;
        List<RsRolesResource> rsGrant = rolesResourceGrantService.search(filters);
        rsRolesList = convertToModels(rsGrant, new ArrayList<>(rsGrant.size()), MRsRolesResource.class, null);
        return (List<MRsRolesResource>) rsRolesList;
    }
    @ApiOperation("角色组资源授权批量删除")
    @RequestMapping(value = ServiceApi.Resources.ResourceRolesGrants, method = RequestMethod.DELETE)
    public boolean deleteRolesGrantBatch(
            @ApiParam(name = "ids", value = "授权ID", defaultValue = "")
            @RequestParam(value = "ids") String ids) throws Exception {
        rolesResourceGrantService.deleteGrantByIds(ids.split(","));
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.ResourceRolesMetadataGrant, method = RequestMethod.GET)
    @ApiOperation("角色组-资源授权-维度授权-根据ID获取资源数据元授权")
    public MRsRolesResourceMetadata getRolesRsMetadataGrantById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(rolesResourceMetadataGrantService.getRsRolesMetadataGrantById(id), MRsRolesResourceMetadata.class);
    }
    //机构授权
    @ApiOperation("机构资源授权查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceOrgGrants, method = RequestMethod.GET)
    public List<MRsOrgResource> queryOrgResourceGrant(
            @ApiParam(name = "fields", value = "返回字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "999")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsOrgResource> rsOrgList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
            Page<RsOrgResource> rsGrant = orgResourceGrantService.getOrgResourceGrant(sorts, reducePage(page), size);
            total = rsGrant.getTotalElements();
            rsOrgList = convertToModels(rsGrant.getContent(), new ArrayList<>(rsGrant.getNumber()), MRsOrgResource.class, fields);
        } else {
            List<RsOrgResource> rsGrant = orgResourceGrantService.search(fields, filters, sorts, page, size);
            total = orgResourceGrantService.getCount(filters);
            rsOrgList = convertToModels(rsGrant, new ArrayList<>(rsGrant.size()), MRsOrgResource.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsOrgResource>) rsOrgList;
    }
    @ApiOperation("机构资源数据元生失效操作")
    @RequestMapping(value = ServiceApi.Resources.ResourceOrgMetadatasValid, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public boolean orgValid(
            @ApiParam(name = "data", value = "授权数据元", defaultValue = "")
            @RequestBody List<RsOrgResourceMetadata> data,
            @ApiParam(name = "valid", value = "授权数据元ID", defaultValue = "")
            @RequestParam(value = "valid") int valid) throws Exception {
        String ids = "";
        if (valid == 0) {
            for (RsOrgResourceMetadata metadata : data) {
                ids += "," + metadata.getId();
            }
        } else {
            List addLs = new ArrayList<>();
            for (RsOrgResourceMetadata metadata : data) {
                if (!StringUtils.isEmpty(metadata.getId()))
                    ids += "," + metadata.getId();
                else {
                    metadata.setId(getObjectId(BizObject.OrgResourceMetadata));
                    addLs.add(metadata);
                }
            }
            orgResourceMetadataGrantService.grantRsOrgMetadataBatch(addLs);
        }
        if (ids.length() > 0) {
            orgResourceMetadataGrantService.orgValid(ids.substring(1), valid);
        }
        return true;
    }
    @ApiOperation("机构资源数据元维度授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceOrgGrant, method = RequestMethod.POST)
    public MRsOrgResourceMetadata metadataOrgGrant(
            @ApiParam(name = "id", value = "授权ID", defaultValue = "")
            @PathVariable(value = "id") String id,
            @ApiParam(name = "dimension", value = "授权ID", defaultValue = "")
            @RequestParam(value = "dimension") String dimension) throws Exception {
        RsOrgResourceMetadata rsOrgResourceMetadata = orgResourceMetadataGrantService.retrieve(id);
        rsOrgResourceMetadata.setDimensionValue(dimension);
        orgResourceMetadataGrantService.save(rsOrgResourceMetadata);
        return convertToModel(rsOrgResourceMetadata, MRsOrgResourceMetadata.class);
    }
    @ApiOperation("机构资源数据元维度授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceOrgMetadataGrants, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    MRsOrgResourceMetadata orgMetadataGrant(
            @RequestBody RsOrgResourceMetadata model) throws Exception {
        if (StringUtils.isEmpty(model.getId())) {
            model.setId(getObjectId(BizObject.OrgResourceMetadata));
        }
        return convertToModel(orgResourceMetadataGrantService.save(model), MRsOrgResourceMetadata.class);
    }
    @ApiOperation("单个机构授权多个资源")
    @RequestMapping(value = ServiceApi.Resources.OrgGrantResources, method = RequestMethod.POST)
    public Collection<MRsOrgResource> grantOrgResource(
            @ApiParam(name = "orgCode", value = "机构ID", defaultValue = "")
            @PathVariable(value = "orgCode") String orgCode,
            @ApiParam(name = "resourceIds", value = "资源ID", defaultValue = "")
            @RequestParam(value = "resourceIds") String resourceIds) throws Exception {
        String[] resourceIdArray = resourceIds.split(",");
        List<RsOrgResource> orgRsList = new ArrayList<RsOrgResource>();
        for (String resoruceId : resourceIdArray) {
            RsOrgResource orgRs = new RsOrgResource();
            orgRs.setId(getObjectId(BizObject.RolesResource));
            orgRs.setOrganizationId(orgCode);
            orgRs.setResourceId(resoruceId);
            orgRsList.add(orgRs);
        }
        return convertToModels(orgResourceGrantService.grantResourceBatch(orgRsList), new ArrayList<>(orgRsList.size()), MRsOrgResource.class, "");
    }
    @ApiOperation("机构资源数据元授权查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceOrgResMetadataGrants, method = RequestMethod.GET)
    public Collection<MRsOrgResourceMetadata> getOrgRsMetadatas(
            @ApiParam(name = "Org_res_id", value = "授权应用编号", defaultValue = "1")
            @PathVariable(value = "Org_res_id") String orgResId) throws Exception {
        RsOrgResource orgResource = orgResourceGrantService.retrieve(orgResId);
        List<RsOrgResourceMetadata> rsMetadataGrant = new ArrayList<>();
        if (orgResource != null) {
            rsMetadataGrant = orgResourceMetadataGrantService.getOrgRsMetadatas(orgResource.getId(), orgResource.getOrganizationId(), orgResource.getResourceId());
        }
        return convertToModels(rsMetadataGrant, new ArrayList<>(rsMetadataGrant.size()), MRsOrgResourceMetadata.class, "");
    }
    @ApiOperation(" 机构取消资源授权")
    @RequestMapping(value = ServiceApi.Resources.ResourceOrgGrantsNoPage, method = RequestMethod.GET)
    public List<MRsOrgResource> queryOrgResourceGrantNoPage(
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        Collection<MRsOrgResource> rsOrgList;
        List<RsOrgResource> rsGrant = orgResourceGrantService.search(filters);
        rsOrgList = convertToModels(rsGrant, new ArrayList<>(rsGrant.size()), MRsOrgResource.class, null);
        return (List<MRsOrgResource>) rsOrgList;
    }
    @ApiOperation("机构资源授权批量删除")
    @RequestMapping(value = ServiceApi.Resources.ResourceOrgGrants, method = RequestMethod.DELETE)
    public boolean deleteOrgGrantBatch(
            @ApiParam(name = "ids", value = "授权ID", defaultValue = "")
            @RequestParam(value = "ids") String ids) throws Exception {
        orgResourceGrantService.deleteGrantByIds(ids.split(","));
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.ResourceOrgMetadataGrant, method = RequestMethod.GET)
    @ApiOperation("机构-资源授权-维度授权-根据ID获取资源数据元授权")
    public MRsOrgResourceMetadata getOrgRsMetadataGrantById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(orgResourceMetadataGrantService.getRsOrgMetadataGrantById(id), MRsOrgResourceMetadata.class);
    }
    //-----------------------------------------------------------应用数据元一键(取消)授权  start----------------------------------------------------------------------------
    @ApiOperation("单个应用一键授权多个资源(数据元)")
    @RequestMapping(value = ServiceApi.Resources.AppsGrantResourcesByCategoryId, method = RequestMethod.POST)
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public Envelop AppsGrantResourcesByCategoryId(
            @ApiParam(name = "appId", value = "应用ID", defaultValue = "zkGuSIm2Fg")
            @RequestParam(value = "appId") String appId,
            @ApiParam(name = "categoryIds", value = "视图分类ID", defaultValue = "0dae002159535497b3865e129433e933")
            @RequestParam(value = "categoryIds", required = false) String categoryIds,
            @ApiParam(name = "resourceIds", value = "资源ID", defaultValue = "d3beebf86ed611e89f87fa163e20f96e")
            @RequestParam(value = "resourceIds", required = false) String resourceIds) throws Exception {
        List<RsAppResource> appRsList = new ArrayList<RsAppResource>();
        Envelop envelop = new Envelop();
        if (StringUtils.isEmpty(resourceIds)) {
            if (StringUtils.isEmpty(categoryIds)) {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("视图分类id与资源id不能同时为空!");
                return envelop;
            } else {
                //根据视图分类id获取视图list
                String[] categoryIdArray = categoryIds.split(",");
                for (String categoryId : categoryIdArray) {
                    //根据视图分类id获取 档案数据资源list
                    List<RsResource> resourceList = rsResourceService.findByCategoryIdAndDataSource(categoryId, 1);
                    for (RsResource rsResource : resourceList) {
                        RsAppResource appRs = new RsAppResource();
                        appRs.setId(getObjectId(BizObject.AppResource));
                        appRs.setAppId(appId);
                        appRs.setResourceId(rsResource.getId());
                        appRsList.add(appRs);
                    }
                }
            }
        } else {
            String[] resourceIdArray = resourceIds.split(",");
            for (String resoruceId : resourceIdArray) {
                RsAppResource appRs = new RsAppResource();
                appRs.setId(getObjectId(BizObject.AppResource));
                appRs.setAppId(appId);
                appRs.setResourceId(resoruceId);
                appRsList.add(appRs);
            }
        }
        //查找视图是否已经授权,删除已授权数据
        for (RsAppResource rsAppResource : appRsList) {
            List<String> rsAppResourcesear = rsGrantService.findByrsResourceIdAndAppId(rsAppResource.getResourceId(), appId);
            if (null != rsAppResourcesear && rsAppResourcesear.size() > 0) {
                rsGrantService.deleteGrantByIds(rsAppResourcesear.toArray(new String[rsAppResourcesear.size()]));
            }
        }
        //授权视图
        rsGrantService.grantResourceBatch(appRsList);
        //授权视图数据元
        updateRsAppResourceMetadataByRsAppResource(appId, appRsList);
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(appRsList);
        envelop.setTotalCount(appRsList.size());
        return envelop;
    }
    /**
     * 一键授权-授权数据元
     *
     * @param list
     * @return
     * @throws Exception
     */
    public void updateRsAppResourceMetadataByRsAppResource(String appId, List<RsAppResource> list) throws Exception {
        List<RsAppResourceMetadata> appRsMetadataList = new ArrayList<RsAppResourceMetadata>();
        if (null != list && list.size() > 0) {
            for (RsAppResource rsAppResource : list) {
                //根据rs_resoruceId获取rs_resource_metadata中的数据元,授权
                List<RsResourceMetadata> rsResourceMetadataList = rsResourceMetadataService.getRsMetadataByResourcesId(rsAppResource.getResourceId());
                for (RsResourceMetadata rsResourceMetadata : rsResourceMetadataList) {
                    RsAppResourceMetadata appRsMetadata = new RsAppResourceMetadata();
                    appRsMetadata.setId(getObjectId(BizObject.AppResourceMetadata));
                    appRsMetadata.setAppResourceId(rsAppResource.getId());
                    appRsMetadata.setResourceMetadataId(rsResourceMetadata.getMetadataId());
                    appRsMetadata.setAppId(appId);
                    appRsMetadata.setResourceMetadataName((null != rsResourceMetadata.getDescription() ? rsResourceMetadata.getDescription().substring(rsResourceMetadata.getDescription().indexOf("--") + 2) : ""));
                    appRsMetadataList.add(appRsMetadata);
                }
                rsMetadataGrantService.grantRsMetadataBatch(appRsMetadataList);
            }
        }
    }
    @ApiOperation("单个应用--------一键取消授权多个资源(数据元)")
    @RequestMapping(value = ServiceApi.Resources.DeleteAppsGrantResourcesByCategoryId, method = RequestMethod.POST)
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public Envelop DeleteAppsGrantResourcesByCategoryId(
            @ApiParam(name = "appId", value = "应用ID", defaultValue = "zkGuSIm2Fg")
            @RequestParam(value = "appId") String appId,
            @ApiParam(name = "categoryIds", value = "视图分类ID", defaultValue = "")
            @RequestParam(value = "categoryIds", required = false) String categoryIds,
            @ApiParam(name = "resourceIds", value = "资源ID", defaultValue = "d3beebf86ed611e89f87fa163e20f96e")
            @RequestParam(value = "resourceIds", required = false) String resourceIds) throws Exception {
        List<RsAppResource> appRsList = new ArrayList<RsAppResource>();
        Envelop envelop = new Envelop();
        if (StringUtils.isEmpty(resourceIds)) {
            if (StringUtils.isEmpty(categoryIds)) {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("视图分类id与资源id不能同时为空!");
                return envelop;
            } else {
                //根据视图分类id获取视图list
                String[] categoryIdArray = categoryIds.split(",");
                for (String categoryId : categoryIdArray) {
                    //根据视图分类id获取 档案数据资源list
                    List<RsResource> resourceList = rsResourceService.findByCategoryIdAndDataSource(categoryId, 1);
                    for (RsResource rsResource : resourceList) {
                        RsAppResource appRs = new RsAppResource();
                        appRs.setId(getObjectId(BizObject.AppResource));
                        appRs.setAppId(appId);
                        appRs.setResourceId(rsResource.getId());
                        appRsList.add(appRs);
                    }
                }
            }
        } else {
            String[] resourceIdArray = resourceIds.split(",");
            for (String resoruceId : resourceIdArray) {
                RsAppResource appRs = new RsAppResource();
                appRs.setId(getObjectId(BizObject.AppResource));
                appRs.setAppId(appId);
                appRs.setResourceId(resoruceId);
                appRsList.add(appRs);
            }
        }
        //查找视图是否已经授权,删除已授权数据
        for (RsAppResource rsAppResource : appRsList) {
            List<String> rsAppResourcesear = rsGrantService.findByrsResourceIdAndAppId(rsAppResource.getResourceId(), appId);
            if (null != rsAppResourcesear && rsAppResourcesear.size() > 0) {
                rsGrantService.deleteGrantByIds(rsAppResourcesear.toArray(new String[rsAppResourcesear.size()]));
            }
        }
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(appRsList);
        envelop.setTotalCount(appRsList.size());
        return envelop;
    }
    //-----------------------------------------------------------应用数据元一键(取消)授权 end----------------------------------------------------------------------------
    //-----------------------------------------------------------角色组数据元一键(取消)授权 start-------------------------------------------------------------------------
    @ApiOperation("单个角色组----一键授权多个资源")
    @RequestMapping(value = ServiceApi.Resources.RolesGrantResourcesByCategoryId, method = RequestMethod.POST)
    public Envelop rolesGrantResourcesByCategoryId(
            @ApiParam(name = "rolesId", value = "角色组ID", defaultValue = "")
            @RequestParam(value = "rolesId") String rolesId,
            @ApiParam(name = "appId", value = "应用ID", defaultValue = "zkGuSIm2Fg")
            @RequestParam(value = "appId") String appId,
            @ApiParam(name = "categoryIds", value = "视图分类ID", defaultValue = "0dae002159535497b3865e129433e933")
            @RequestParam(value = "categoryIds", required = false) String categoryIds,
            @ApiParam(name = "resourceIds", value = "资源ID", defaultValue = "d3beebf86ed611e89f87fa163e20f96e")
            @RequestParam(value = "resourceIds", required = false) String resourceIds) throws Exception {
        List<RsRolesResource> rolesRsList = new ArrayList<RsRolesResource>();
        Envelop envelop = new Envelop();
        if (StringUtils.isEmpty(resourceIds)) {
            if (StringUtils.isEmpty(categoryIds)) {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("视图分类id与资源id不能同时为空!");
                return envelop;
            } else {
                //根据视图分类id获取视图list
                String[] categoryIdArray = categoryIds.split(",");
                for (String categoryId : categoryIdArray) {
                    //根据视图分类id获取 档案数据资源list
                    List<String> rsResourceIdList = rsResourceService.findIdByCategoryIdAndDataSource(categoryId, 1);
                    if(null!= rsResourceIdList && rsResourceIdList.size()>0){
                        List<RsAppResource> rsResourceList = rsGrantService.findByrsResourceIds(rsResourceIdList.toArray(new String[rsResourceIdList.size()]),appId);
                        for (RsAppResource rsResource : rsResourceList) {
                            RsRolesResource rolesRs = new RsRolesResource();
                            rolesRs.setId(getObjectId(BizObject.RolesResource));
                            rolesRs.setRolesId(rolesId);
                            rolesRs.setResourceId(rsResource.getResourceId());
                            rolesRsList.add(rolesRs);
                        }
                    }
                }
            }
        } else {
            String[] resourceIdArray = resourceIds.split(",");
            for (String resoruceId : resourceIdArray) {
                RsRolesResource rolesRs = new RsRolesResource();
                rolesRs.setId(getObjectId(BizObject.RolesResource));
                rolesRs.setRolesId(rolesId);
                rolesRs.setResourceId(resoruceId);
                rolesRsList.add(rolesRs);
            }
        }
        //查找视图是否已经授权,删除已授权数据
        for (RsRolesResource rsAppResource : rolesRsList) {
            List<String> rsAppResourcesear = rolesResourceGrantService.findIdByResourceIdAndRolesId(rsAppResource.getResourceId(), rolesId);
            if (null != rsAppResourcesear && rsAppResourcesear.size() > 0) {
                rolesResourceGrantService.deleteGrantByIds(rsAppResourcesear.toArray(new String[rsAppResourcesear.size()]));
            }
        }
        //授权视图
        rolesResourceGrantService.grantResourceBatch(rolesRsList);
        //授权视图数据元
        updateRsRolrResourceMetadataByRsAppResource(rolesId, rolesRsList);
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(rolesRsList);
        envelop.setTotalCount(rolesRsList.size());
        return envelop;
    }
    /**
     * 一键授权-授权数据元
     *
     * @param list
     * @return
     * @throws Exception
     */
    public void updateRsRolrResourceMetadataByRsAppResource(String rolesId, List<RsRolesResource> list) throws Exception {
        List<RsRolesResourceMetadata> appRsMetadataList = new ArrayList<RsRolesResourceMetadata>();
        if (null != list && list.size() > 0) {
            for (RsRolesResource rsAppResource : list) {
                //根据rs_resoruceId获取rs_resource_metadata中的数据元,授权
                List<RsResourceMetadata> rsResourceMetadataList = rsResourceMetadataService.getRsMetadataByResourcesId(rsAppResource.getResourceId());
                for (RsResourceMetadata rsResourceMetadata : rsResourceMetadataList) {
                    RsRolesResourceMetadata rsRolesResourceMetadata = new RsRolesResourceMetadata();
                    rsRolesResourceMetadata.setId(getObjectId(BizObject.AppResourceMetadata));
                    rsRolesResourceMetadata.setRolesResourceId(rsAppResource.getId());
                    rsRolesResourceMetadata.setResourceMetadataId(rsResourceMetadata.getMetadataId());
                    rsRolesResourceMetadata.setRolesId(rolesId);
                    rsRolesResourceMetadata.setResourceMetadataName((null != rsResourceMetadata.getDescription() ? rsResourceMetadata.getDescription().substring(rsResourceMetadata.getDescription().indexOf("--") + 2) : ""));
                    appRsMetadataList.add(rsRolesResourceMetadata);
                }
                rolesResourceMetadataGrantService.grantRsRolesMetadataBatch(appRsMetadataList);
            }
        }
    }
    @ApiOperation("单个角色组----一键取消授权多个资源")
    @RequestMapping(value = ServiceApi.Resources.DeleteRolesGrantResourcesByCategoryId, method = RequestMethod.POST)
    public Envelop deleteRolesGrantResourcesByCategoryId(
            @ApiParam(name = "rolesId", value = "角色组ID", defaultValue = "")
            @RequestParam(value = "rolesId") String rolesId,
            @ApiParam(name = "appId", value = "应用ID", defaultValue = "zkGuSIm2Fg")
            @RequestParam(value = "appId") String appId,
            @ApiParam(name = "categoryIds", value = "视图分类ID", defaultValue = "0dae002159535497b3865e129433e933")
            @RequestParam(value = "categoryIds", required = false) String categoryIds,
            @ApiParam(name = "resourceIds", value = "资源ID", defaultValue = "d3beebf86ed611e89f87fa163e20f96e")
            @RequestParam(value = "resourceIds", required = false) String resourceIds) throws Exception {
        List<RsRolesResource> rolesRsList = new ArrayList<RsRolesResource>();
        Envelop envelop = new Envelop();
        if (StringUtils.isEmpty(resourceIds)) {
            if (StringUtils.isEmpty(categoryIds)) {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("视图分类id与资源id不能同时为空!");
                return envelop;
            } else {
                //根据视图分类id获取视图list
                String[] categoryIdArray = categoryIds.split(",");
                for (String categoryId : categoryIdArray) {
                    //根据视图分类id获取 档案数据资源list
                    List<String> rsResourceIdList = rsResourceService.findIdByCategoryIdAndDataSource(categoryId, 1);
                    if(null!= rsResourceIdList && rsResourceIdList.size()>0) {
                        List<RsAppResource> rsResourceList = rsGrantService.findByrsResourceIds(rsResourceIdList.toArray(new String[rsResourceIdList.size()]), appId);
                        for (RsAppResource rsResource : rsResourceList) {
                            RsRolesResource rolesRs = new RsRolesResource();
                            rolesRs.setId(getObjectId(BizObject.RolesResource));
                            rolesRs.setRolesId(rolesId);
                            rolesRs.setResourceId(rsResource.getResourceId());
                            rolesRsList.add(rolesRs);
                        }
                    }
                }
            }
        } else {
            String[] resourceIdArray = resourceIds.split(",");
            for (String resoruceId : resourceIdArray) {
                RsRolesResource rolesRs = new RsRolesResource();
                rolesRs.setId(getObjectId(BizObject.RolesResource));
                rolesRs.setRolesId(rolesId);
                rolesRs.setResourceId(resoruceId);
                rolesRsList.add(rolesRs);
            }
        }
        //查找视图是否已经授权,删除已授权数据
        for (RsRolesResource rsAppResource : rolesRsList) {
            List<String> rsAppResourcesear = rolesResourceGrantService.findIdByResourceIdAndRolesId(rsAppResource.getResourceId(), rolesId);
            if (null != rsAppResourcesear && rsAppResourcesear.size() > 0) {
                rolesResourceGrantService.deleteGrantByIds(rsAppResourcesear.toArray(new String[rsAppResourcesear.size()]));
            }
        }
        envelop.setSuccessFlg(true);
        envelop.setDetailModelList(rolesRsList);
        envelop.setTotalCount(rolesRsList.size());
        return envelop;
    }
//-----------------------------------------------------------角色组数据元一键(取消)授权 end----------------------------------------------------------------------------
}

+ 153 - 0
src/main/java/com/yihu/ehr/resource/controller/RsResourceMetadataEndPoint.java

@ -0,0 +1,153 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsResourceMetadata;
import com.yihu.ehr.resource.model.RsResourceMetadata;
import com.yihu.ehr.resource.service.RsResourceMetadataService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
 * Created by lyr on 2016/4/25.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsResourceMetadataEndPoint", description = "资源数据元", tags = {"资源服务-资源数据元"})
public class RsResourceMetadataEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsResourceMetadataService rsMetadataService;
    @ApiOperation("创建资源数据元")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataList, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public MRsResourceMetadata createResourceMetadata(
            @ApiParam(name = "metadata", value = "资源数据元", defaultValue = "")
            @RequestBody String metadata) throws Exception {
        RsResourceMetadata rsMetadata = toEntity(metadata, RsResourceMetadata.class);
        rsMetadata.setId(getObjectId(BizObject.ResourceMetadata));
        rsMetadataService.saveResourceMetadata(rsMetadata);
        return convertToModel(rsMetadata, MRsResourceMetadata.class);
    }
    @ApiOperation("批量创建资源数据元")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataBatch, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Collection<MRsResourceMetadata> createResourceMetadataBatch(
            @ApiParam(name = "metadatas", value = "资源数据元", defaultValue = "")
            @RequestParam(value = "metadatas") String metadatas) throws Exception {
        RsResourceMetadata[] rsMetadata = toEntity(metadatas, RsResourceMetadata[].class);
        for (RsResourceMetadata metadata : rsMetadata) {
            metadata.setId(getObjectId(BizObject.ResourceMetadata));
        }
        List<RsResourceMetadata> metadataList = rsMetadataService.saveMetadataBatch(rsMetadata);
        return convertToModels(metadataList, new ArrayList<MRsResourceMetadata>(), MRsResourceMetadata.class, "");
    }
    @ApiOperation("更新资源数据元")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataList, method = RequestMethod.PUT)
    public MRsResourceMetadata updateResourceMetadata(
            @ApiParam(name = "dimension", value = "资源数据元", defaultValue = "")
            @RequestParam(value = "dimension") String metadata) throws Exception {
        RsResourceMetadata rsMetadata = toEntity(metadata, RsResourceMetadata.class);
        rsMetadataService.saveResourceMetadata(rsMetadata);
        return convertToModel(rsMetadata, MRsResourceMetadata.class);
    }
    @ApiOperation("资源数据元删除")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadata, method = RequestMethod.DELETE)
    public boolean deleteResourceMetadata(
            @ApiParam(name = "id", value = "资源数据元ID", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        rsMetadataService.deleteResourceMetadata(id);
        return true;
    }
    @ApiOperation("根据ids批量资源数据元删除")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataBatch, method = RequestMethod.DELETE)
    public boolean deleteResourceMetadataBatchById(
            @ApiParam(name = "ids", value = "ids", defaultValue = "")
            @RequestParam(value = "ids") String[] ids) throws Exception {
        rsMetadataService.delete(ids);
        return true;
    }
    @ApiOperation("根据resourceId删除资源数据元")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataList, method = RequestMethod.DELETE)
    public boolean deleteResourceMetadataBatchByResourceId(
            @ApiParam(name = "resourceId", value = "资源ID", defaultValue = "")
            @RequestParam(value = "resourceId") String resourceId) throws Exception {
        rsMetadataService.deleteRsMetadataByResourceId(resourceId);
        return true;
    }
    @ApiOperation("根据ResourceIds列表批量资源数据元删除")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataBatchByResourceId, method = RequestMethod.DELETE)
    public boolean deleteResourceMetadataBatchByResourceId(
            @ApiParam(name = "resource_ids", value = "resource_ids", defaultValue = "")
            @RequestParam(value = "resource_ids") String[] resourceIds) throws Exception {
        rsMetadataService.deleteByResourcesIds(resourceIds);
        return true;
    }
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadata, method = RequestMethod.GET)
    @ApiOperation("根据ID获取资源数据元")
    public MRsResourceMetadata getRsMetadataById(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        return convertToModel(rsMetadataService.getRsMetadataById(id), MRsResourceMetadata.class);
    }
    @RequestMapping(value = "/resources/{resources_id}/metadata_list", method = RequestMethod.GET)
    @ApiOperation("根据资源id(resourcesId)获取资源数据元列表")
    public List<MRsResourceMetadata> getRsMetadataByResourcesId(
            @ApiParam(name = "resources_id", value = "resources_id", defaultValue = "")
            @PathVariable(value = "resources_id") String resourcesId) throws Exception {
        List<RsResourceMetadata> metadataList = rsMetadataService.getRsMetadataByResourcesId(resourcesId);
        return (List<MRsResourceMetadata>) convertToModels(metadataList, new ArrayList<MRsResourceMetadata>(metadataList.size()), MRsResourceMetadata.class, "");
    }
    @ApiOperation("资源数据元查询")
    @RequestMapping(value = ServiceApi.Resources.ResourceMetadataList, method = RequestMethod.GET)
    public List<MRsResourceMetadata> queryDimensions(
            @ApiParam(name = "fields", value = "返回字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        long total = 0;
        Collection<MRsResourceMetadata> rsAppMetaList;
        //过滤条件为空
        if (StringUtils.isEmpty(filters)) {
            Page<RsResourceMetadata> dimensions = rsMetadataService.getResourceMetadata(sorts, reducePage(page), size);
            total = dimensions.getTotalElements();
            rsAppMetaList = convertToModels(dimensions.getContent(), new ArrayList<>(dimensions.getNumber()), MRsResourceMetadata.class, fields);
        } else {
            List<RsResourceMetadata> dimensions = rsMetadataService.search(fields, filters, sorts, page, size);
            total = rsMetadataService.getCount(filters);
            rsAppMetaList = convertToModels(dimensions, new ArrayList<>(dimensions.size()), MRsResourceMetadata.class, fields);
        }
        pagedResponse(request, response, total, page, size);
        return (List<MRsResourceMetadata>) rsAppMetaList;
    }
}

+ 129 - 0
src/main/java/com/yihu/ehr/resource/controller/RsResourceMonitorTypeEndPoint.java

@ -0,0 +1,129 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.model.common.ListResult;
import com.yihu.ehr.model.resource.MRsReportMonitorType;
import com.yihu.ehr.resource.model.RsReport;
import com.yihu.ehr.resource.model.RsReportMonitorType;
import com.yihu.ehr.resource.service.RsReportMonitorTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by jansny 2017年11月7日15:17:24
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsResourceMonitorTypeEndPoint", description = "资源报表监测分类", tags = {"资源服务-资源报表监测分类"})
public class RsResourceMonitorTypeEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsReportMonitorTypeService rsReportMonitorTypeService;
    @ApiOperation("根据ID获取资源报表监测分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportMonitorType, method = RequestMethod.GET)
    public MRsReportMonitorType getById(
            @ApiParam(name = "id", value = "id", required = true)
            @PathVariable(value = "id") Integer id) throws Exception {
        return convertToModel(rsReportMonitorTypeService.getById(id), MRsReportMonitorType.class);
    }
    @ApiOperation("新增资源报表监测分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportMonitorTypeSave, method = RequestMethod.POST)
    public MRsReportMonitorType add(
            @ApiParam(name = "rsReportMonitorType", value = "资源报表监测分类JSON", required = true)
            @RequestBody String rsReportMonitorType) throws Exception {
        RsReportMonitorType newRsReportMonitorType = toEntity(rsReportMonitorType, RsReportMonitorType.class);
        newRsReportMonitorType = rsReportMonitorTypeService.save(newRsReportMonitorType);
        return convertToModel(newRsReportMonitorType, MRsReportMonitorType.class);
    }
    @ApiOperation("更新资源报表监测分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportMonitorTypeSave, method = RequestMethod.PUT)
    public MRsReportMonitorType update(
            @ApiParam(name = "rsReportMonitorType", value = "资源报表监测分类JSON", required = true)
            @RequestBody String rsReportMonitorType) throws Exception {
        RsReportMonitorType newRsReportMonitorType = toEntity(rsReportMonitorType, RsReportMonitorType.class);
        newRsReportMonitorType = rsReportMonitorTypeService.save(newRsReportMonitorType);
        return convertToModel(newRsReportMonitorType, MRsReportMonitorType.class);
    }
    @ApiOperation("删除资源报表监测分类")
    @RequestMapping(value = ServiceApi.Resources.RsReportMonitorTypeDelete, method = RequestMethod.DELETE)
    public void delete(
            @ApiParam(name = "id", value = "资源报表监测分类ID", required = true)
            @RequestParam(value = "id") Integer id) throws Exception {
        rsReportMonitorTypeService.delete(id);
    }
    @ApiOperation("验证资源报表监测分类名称是否唯一")
    @RequestMapping(value = ServiceApi.Resources.RsReportMonitorTypeIsUniqueName, method = RequestMethod.GET)
    public boolean isUniqueName(
            @ApiParam(name = "id", value = "资源报表监测分类ID", required = true)
            @RequestParam(value = "id") Integer id,
            @ApiParam(name = "name", value = "资源报表监测分类名称", required = true)
            @RequestParam(value = "name") String name) throws Exception {
        return rsReportMonitorTypeService.isUniqueName(id, name);
    }
    @RequestMapping(value = ServiceApi.Resources.RsReportMonitorTypes, method = RequestMethod.GET)
    @ApiOperation(value = "资源报表监测分类列表")
    public ListResult getQcQuotaDictList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        ListResult listResult = new ListResult();
        List<RsReportMonitorType> rsReportMonitorTypeList = rsReportMonitorTypeService.search(fields, filters, null, page, size);
        if(rsReportMonitorTypeList != null){
            listResult.setDetailModelList(rsReportMonitorTypeList);
            listResult.setTotalCount((int)rsReportMonitorTypeService.getCount(filters));
            listResult.setCode(200);
            listResult.setCurrPage(page);
            listResult.setPageSize(size);
        }else{
            listResult.setCode(200);
            listResult.setMessage("查询无数据");
            listResult.setTotalCount(0);
        }
        return listResult;
    }
    @RequestMapping(value = ServiceApi.Resources.RsReportMonitorTypesNoPage, method = RequestMethod.GET)
    @ApiOperation("获取资源报表监测分类")
    public List<MRsReportMonitorType> getAll(
            @ApiParam(name = "filters", value = "过滤", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<RsReportMonitorType> list = rsReportMonitorTypeService.search(filters);
        return (List<MRsReportMonitorType>) convertToModels(list, new ArrayList<>(list.size()), MRsReportMonitorType.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.RsReportMonitorTypesById, method = RequestMethod.GET)
    @ApiOperation("获取报表监测分类")
    public List<MRsReportMonitorType> getInfoById (
            @ApiParam(name = "monitorTypeIds", value = "类型id", defaultValue = "")
            @RequestParam(value = "monitorTypeIds", required = false) List<Integer> monitorTypeIds) {
        List<RsReportMonitorType> monitorTypes = rsReportMonitorTypeService.getInfoById(monitorTypeIds);
        return (List<MRsReportMonitorType>) convertToModels(monitorTypes, new ArrayList<>(monitorTypes.size()), MRsReportMonitorType.class, null);
    }
}

+ 191 - 0
src/main/java/com/yihu/ehr/resource/controller/RsResourceQuotaEndPoint.java

@ -0,0 +1,191 @@
package com.yihu.ehr.resource.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.entity.quota.TjQuota;
import com.yihu.ehr.model.common.ListResult;
import com.yihu.ehr.model.common.ObjectResult;
import com.yihu.ehr.model.common.Result;
import com.yihu.ehr.model.resource.MResourceQuota;
import com.yihu.ehr.resource.model.ResourceQuotaJson;
import com.yihu.ehr.resource.model.RsResourceQuota;
import com.yihu.ehr.resource.service.RsResourceQuotaService;
import com.yihu.ehr.util.rest.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by Administrator on 2017/8/10.
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0 + "/resourcesQuota")
@Api(value = "RsResourceQuotaEndPoint", description = "资源视图指标", tags = {"资源服务-资源视图指标"})
public class RsResourceQuotaEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsResourceQuotaService resourceQuotaService;
    @RequestMapping(value = ServiceApi.Resources.SearchInfo, method = RequestMethod.GET)
    @ApiOperation(value = "资源视图指标")
    public ListResult search(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception {
        ListResult listResult = new ListResult();
        List<RsResourceQuota> list = resourceQuotaService.search(fields, filters, sorts, page, size);
        if(list != null){
            listResult.setDetailModelList(list);
            listResult.setTotalCount((int)resourceQuotaService.getCount(filters));
            listResult.setCode(200);
            listResult.setCurrPage(page);
            listResult.setPageSize(size);
        }else{
            listResult.setCode(200);
            listResult.setMessage("查询无数据");
            listResult.setTotalCount(0);
        }
        return listResult;
    }
    @RequestMapping(value = ServiceApi.Resources.GetRQNameByResourceId, method = RequestMethod.GET)
    @ApiOperation(value = "资源视图指标-根据resourceId查询")
    public List<Integer> getRQNameByResourceId(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters) throws Exception {
        List<RsResourceQuota> list = resourceQuotaService.search(filters);
        List<Integer> quotaIds = new ArrayList<>();
        for (RsResourceQuota rq : list) {
            quotaIds.add(rq.getQuotaId());
        }
        return quotaIds;
    }
    @RequestMapping(value = ServiceApi.Resources.BatchAddResourceQuota, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "新增&修改资源视图-关联指标表")
    public ObjectResult batchAddResourceQuota(
            @ApiParam(name = "model", value = "json数据模型", defaultValue = "")
            @RequestBody String model) throws Exception{
        List<RsResourceQuota> list = objectMapper.readValue(model, new TypeReference<List<RsResourceQuota>>(){});
        //先删除表中resourceId=XX的数据
        if (list != null && list.size() > 0) {
            resourceQuotaService.deleteByResourceId(list.get(0).getResourceId());
        }
        for (int i=0; i<list.size(); i++) {
            resourceQuotaService.save(list.get(i));
        }
        return Result.success("资源视图-关联指标表更新成功!", list);
    }
    @RequestMapping(value = ServiceApi.Resources.GetQuotaChartByQuotaId, method = RequestMethod.GET)
    @ApiOperation(value = "资源视图指标-获取已选图表值")
    public String getQuotaChartByQuotaId(
            @ApiParam(name = "quotaId", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "quotaId", required = false) Integer quotaId,
            @ApiParam(name = "resourceId", value = "资源Id")
            @RequestParam(value = "resourceId") String resourceId) {
        return resourceQuotaService.getQuotaChartByQuotaId(quotaId, resourceId);
    }
    @RequestMapping(value = ServiceApi.Resources.GetByResourceId, method = RequestMethod.GET)
    @ApiOperation(value = "根据资源Id获取资源视图 关联指标列表")
    public List<RsResourceQuota> getByResourceId(
            @ApiParam(name = "resourceId", value = "资源ID", defaultValue = "")
            @RequestParam(value = "resourceId") String resourceId) throws Exception{
        List<RsResourceQuota> list = resourceQuotaService.search("resourceId=" + resourceId);
        return list;
    }
    @RequestMapping(value = ServiceApi.Resources.SearchByQuotaId, method = RequestMethod.GET)
    @ApiOperation(value = "资源视图指标-根据quotaId查询,此指标有被多少个视图选中")
    public List<MResourceQuota> searchByQuotaId (
            @ApiParam(name= "quotaId", value = "过滤器", defaultValue = "0")
            @RequestParam(value = "quotaId") Integer quotaId) throws Exception{
        List<RsResourceQuota> list = resourceQuotaService.search("quotaId=" + quotaId);
        List<MResourceQuota> models = new ArrayList<>();
        if( list != null && list.size() > 0){
            for(RsResourceQuota resourceQuota: list){
                MResourceQuota mResourceQuota = objectMapper.convertValue(resourceQuota,MResourceQuota.class);
                models.add(mResourceQuota);
            }
            return models;
        }else {
            return null;
        }
    }
    @RequestMapping(value = ServiceApi.Resources.DelRQNameByResourceId, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除资源视图-关联指标表")
    public Result deleteByResourceId(
            @ApiParam(name = "resourceId", value = "资源Id", defaultValue = "")
            @RequestParam(value = "resourceId") String resourceId) {
        resourceQuotaService.deleteByResourceId(resourceId);
        return Result.success("资源视图-关联指标表删除成功!");
    }
    @RequestMapping(value = ServiceApi.Resources.SearchQuotaByResourceId, method = RequestMethod.GET)
    @ApiOperation(value = "根据resourceId获取该资源下的指标列表")
    public List<TjQuota> getQuotaByResourceId(
            @ApiParam(name = "resourceId", value = "资源ID", defaultValue = "")
            @RequestParam(value = "resourceId") String resourceId) {
        List<TjQuota> quotaList = resourceQuotaService.getQuotaByResourceId(resourceId);
        return quotaList;
    }
    @RequestMapping(value = ServiceApi.Resources.SearchTreeByResourceId, method = RequestMethod.GET)
    @ApiOperation(value = "根据resourceId获取该资源下的指标列表树")
    public Envelop searchTreeByResourceId(
            @ApiParam(name = "resourceId", value = "资源ID", defaultValue = "")
            @RequestParam(value = "resourceId") String resourceId) throws ParseException {
        Envelop envelop = new Envelop();
        List<RsResourceQuota> resultList = new ArrayList<>();
        // 获取最顶层的资源报表分类集合
        List<RsResourceQuota> topNodeList = resourceQuotaService.getChildrenByPid(-1, resourceId);
        if (topNodeList.size() == 0) {
            envelop.setDetailModelList(resultList);
            return envelop;
        }
        resultList = resourceQuotaService.getTreeByParents(topNodeList, resourceId);
        List<TjQuota> quotaTreeByParents = resourceQuotaService.getQuotaTreeByParents(resultList);
        envelop.setDetailModelList(quotaTreeByParents);
        return envelop;
    }
    @RequestMapping(value = ServiceApi.Resources.UpdateResourceQuota, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据resourceId修改该资源下的指标关系")
    public Envelop updateResourceQuota(
            @ApiParam(name = "model", value = "json数据模型", defaultValue = "")
            @RequestBody String jsonRelation) {
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(false);
        try {
            List<ResourceQuotaJson> list = objectMapper.readValue(jsonRelation, new TypeReference<List<ResourceQuotaJson>>() {
            });
            resourceQuotaService.updateResourceQuota(list);
            envelop.setSuccessFlg(true);
        } catch (IOException e) {
            e.printStackTrace();
            envelop.setErrorMsg(e.getMessage());
        }
        return envelop;
    }
}

+ 112 - 0
src/main/java/com/yihu/ehr/resource/controller/RsSystemDictionaryEndPoint.java

@ -0,0 +1,112 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsSystemDictionary;
import com.yihu.ehr.resource.model.RsSystemDictionary;
import com.yihu.ehr.resource.model.RsSystemDictionaryEntry;
import com.yihu.ehr.resource.service.RsSystemDictionaryEntryService;
import com.yihu.ehr.resource.service.RsSystemDictionaryService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsSystemDictionaryEndPoint", description = "资源系统字典", tags = {"资源服务-资源系统字典"})
public class RsSystemDictionaryEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsSystemDictionaryService rsSystemDictionaryService;
    @Autowired
    private RsSystemDictionaryEntryService rsSystemDictionaryEntryService;
    @RequestMapping(value = ServiceApi.Resources.SystemDictList, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取系统字典列表", notes = "根据查询条件获取系统字典列表")
    public List<MRsSystemDictionary> searchRsSystemDictionaries(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsSystemDictionary> systemDictionaries = rsSystemDictionaryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, rsSystemDictionaryService.getCount(filters), page, size);
        return (List<MRsSystemDictionary>) convertToModels(systemDictionaries, new ArrayList<MRsSystemDictionary>(systemDictionaries.size()), MRsSystemDictionary.class, fields);
    }
    @RequestMapping(value = ServiceApi.Resources.SystemDictList, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建系统字典", notes = "创建系统字典")
    public MRsSystemDictionary createRsSystemDictionary(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsSystemDictionary systemDictionary = toEntity(jsonData, RsSystemDictionary.class);
        String code = systemDictionary.getCode();
        if(isExistence(code)){
            throw new Exception("字典代码不能重复");
        }
        systemDictionary.setId(getObjectId(BizObject.RsSystemDictionary));
        rsSystemDictionaryService.save(systemDictionary);
        return convertToModel(systemDictionary, MRsSystemDictionary.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.SystemDictList, method = RequestMethod.PUT)
    @ApiOperation(value = "修改系统字典", notes = "修改系统字典")
    public MRsSystemDictionary updateRsSystemDictionary(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
        RsSystemDictionary rsSystemDictionary = toEntity(jsonData, RsSystemDictionary.class);
        String id = rsSystemDictionary.getId();
        RsSystemDictionary d = rsSystemDictionaryService.findById(id);
        String code = rsSystemDictionary.getCode();
        if(code!=d.getCode()){
            throw new Exception("字典代码不可修改");
        }
        rsSystemDictionaryService.save(rsSystemDictionary);
        return convertToModel(rsSystemDictionary, MRsSystemDictionary.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.SystemDict, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除系统字典", notes = "删除系统字典")
    public boolean deleteRsSystemDictionary(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        RsSystemDictionary systemDictionary = rsSystemDictionaryService.findById(id);
        String code = systemDictionary.getCode();
        List<RsSystemDictionaryEntry> systemDictionaryEntries = rsSystemDictionaryEntryService.findByField("dictCode",code);
        if(systemDictionaryEntries!=null && systemDictionaryEntries.size()!=0){
            throw new Exception("该字典包含字典项,不可删除");
        }
        rsSystemDictionaryService.delete(id);
        return true;
    }
    public boolean isExistence(String code) {
        return rsSystemDictionaryService.findByField("code",code) != null;
    }
}

+ 100 - 0
src/main/java/com/yihu/ehr/resource/controller/RsSystemDictionaryEntryEndPoint.java

@ -0,0 +1,100 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.model.resource.MRsSystemDictionaryEntry;
import com.yihu.ehr.resource.model.RsSystemDictionaryEntry;
import com.yihu.ehr.resource.service.RsSystemDictionaryEntryService;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.util.id.BizObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "RsSystemDictionaryEntryEndPoint", description = "资源系统字典项", tags = {"资源服务-资源系统字典项"})
public class RsSystemDictionaryEntryEndPoint extends EnvelopRestEndPoint {
    @Autowired
    private RsSystemDictionaryEntryService systemDictionaryEntryService;
    @RequestMapping(value = ServiceApi.Resources.SystemDictEntries, method = RequestMethod.GET)
    @ApiOperation(value = "根据查询条件获取系统字典项列表", notes = "根据查询条件获取系统字典项列表")
    public List<MRsSystemDictionaryEntry> searchRsSystemDictionaryEntries(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,secret,url,createTime")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        List<RsSystemDictionaryEntry> systemDictionaryEntries = systemDictionaryEntryService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, systemDictionaryEntryService.getCount(filters), page, size);
        return (List<MRsSystemDictionaryEntry>) convertToModels(systemDictionaryEntries, new ArrayList<MRsSystemDictionaryEntry>(systemDictionaryEntries.size()), MRsSystemDictionaryEntry.class, fields);
    }
    @RequestMapping(value = ServiceApi.Resources.SystemDictEntries, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建系统字典项", notes = "创建系统字典项")
    public MRsSystemDictionaryEntry createRsSystemDictionaryEntry(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) throws Exception {
        RsSystemDictionaryEntry systemDictionaryEntry = toEntity(jsonData, RsSystemDictionaryEntry.class);
        String code = systemDictionaryEntry.getCode();
        String dictCode = systemDictionaryEntry.getDictCode();
        if(isExistence(dictCode,code)){
            throw new Exception("字典项代码不能重复");
        }
        systemDictionaryEntry.setId(getObjectId(BizObject.RsSystemDictionaryEntry));
        systemDictionaryEntryService.save(systemDictionaryEntry);
        return convertToModel(systemDictionaryEntry, MRsSystemDictionaryEntry.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.SystemDictEntries, method = RequestMethod.PUT)
    @ApiOperation(value = "修改系统字典项", notes = "修改系统字典项")
    public MRsSystemDictionaryEntry updateRsSystemDictionaryEntry(
            @ApiParam(name = "json_data", value = "")
            @RequestBody String jsonData) throws Exception {
        RsSystemDictionaryEntry systemDictionaryEntry = toEntity(jsonData, RsSystemDictionaryEntry.class);
        String id = systemDictionaryEntry.getId();
        RsSystemDictionaryEntry d = systemDictionaryEntryService.findById(id);
        String code = systemDictionaryEntry.getCode();
        String dictCode = systemDictionaryEntry.getDictCode();
        if(code!=d.getCode() && isExistence(dictCode,code)){
            throw new Exception("字典代码不可修改");
        }
        systemDictionaryEntryService.save(systemDictionaryEntry);
        return convertToModel(systemDictionaryEntry, MRsSystemDictionaryEntry.class, null);
    }
    @RequestMapping(value = ServiceApi.Resources.SystemDictEntry, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除系统字典项", notes = "删除系统字典项")
    public boolean deleteRsSystemDictionaryEntry(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") String id) throws Exception {
        systemDictionaryEntryService.delete(id);
        return true;
    }
    public boolean isExistence(String dictCode,String code) {
        return systemDictionaryEntryService.findByFields(new String[]{"dictCode","code"},new String[]{dictCode,code}) != null;
    }
}

+ 99 - 0
src/main/java/com/yihu/ehr/resource/controller/SolrSchemaEndPoint.java

@ -0,0 +1,99 @@
package com.yihu.ehr.resource.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.resource.model.RsMetadata;
import com.yihu.ehr.resource.service.RsMetadataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.schema.SchemaRequest;
import org.apache.solr.client.solrj.response.schema.SchemaResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author Sand
 * @created 2016.05.20 14:03
 */
@RestController
@RequestMapping(value = ApiVersion.Version1_0)
@Api(value = "SolrSchemaEndPoint", description = "资源数据元与SolrSchema同步", tags = {"资源服务-资源数据元与SolrSchema同步"})
public class SolrSchemaEndPoint {
    @Autowired
    RsMetadataService metaDataService;
    @Autowired
    SolrClient solrClient;
    @RequestMapping(value = "/rs/solr_schema", method = RequestMethod.GET)
    @ApiOperation(value = "导出档案的SolrSchema字段")
    public List<Map<String, Object>> exportProfileSolrSchema(
            @ApiParam(value = "core", defaultValue = "HealthProfile")
            @RequestParam String core) throws IOException, SolrServerException {
        SchemaRequest.Fields fieldsRequest = new SchemaRequest.Fields(null);
        SchemaResponse.FieldsResponse fieldsResponse = fieldsRequest.process(solrClient, core);
        List<Map<String, Object>> fields = fieldsResponse.getFields();
        return fields;
    }
    @RequestMapping(value = "/rs/solr_schema", method = RequestMethod.POST)
    @ApiOperation(value = "更新SolrSchema字段", notes = "对比现有的资源数据元与Solr中的Schema字段列表,若不存在则添加")
    public void updateSolrSchema(
            @ApiParam(value = "core", defaultValue = "HealthProfile")
            @RequestParam String core,
            @ApiParam(value = "stored", defaultValue = "false")
            @RequestParam boolean stored,
            @ApiParam(value = "indexed", defaultValue = "true")
            @RequestParam boolean indexed) throws IOException, SolrServerException {
        Page<RsMetadata> metaDatas = metaDataService.getMetadata("+id", 0, 100000);
        for (RsMetadata metaData : metaDatas.getContent()) {
            checkFieldExistence(metaData, core, stored, indexed);
        }
    }
    private void checkFieldExistence(RsMetadata metaData, String core, boolean stored, boolean indexed) throws IOException, SolrServerException {
        SchemaRequest.Field fieldRequest = new SchemaRequest.Field(metaData.getId());
        SchemaResponse.FieldResponse fieldResponse = fieldRequest.process(solrClient, core);
        Map<String, Object> fieldAttributes = fieldResponse.getField();
        if (fieldAttributes == null) {
            fieldAttributes = new HashMap<>();
            fieldAttributes.put("name", metaData.getId());
            fieldAttributes.put("type", getMetaDataSolrType(metaData.getColumnType()));
            fieldAttributes.put("stored", stored);
            fieldAttributes.put("indexed", indexed);
            SchemaRequest.AddField addFieldRequest = new SchemaRequest.AddField(fieldAttributes);
            addFieldRequest.process(solrClient, core);
        }
    }
    private String getMetaDataSolrType(String metaDataType) {
        if (metaDataType.startsWith("S")) {
            return "text_ansj";
        } else if (metaDataType.startsWith("D")) {
            return "date";
        } else if (metaDataType.startsWith("L")) {
            return "string";
        } else if (metaDataType.startsWith("N")) {
            return "double";
        }
        return "string";
    }
}

+ 19 - 0
src/main/java/com/yihu/ehr/resource/dao/PortalMessageRemindDao.java

@ -0,0 +1,19 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.ProtalMessageRemind;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author ZDM
 * @vsrsion 1.0
 * Created at 2018/4/20.
 */
public interface PortalMessageRemindDao extends PagingAndSortingRepository<ProtalMessageRemind,Long> {
    @Query(value = "select p.* from portal_message_remind p order by p.create_date desc limit 10 ",nativeQuery = true)
    List<ProtalMessageRemind> getMessageRemindTop10();
}

+ 17 - 0
src/main/java/com/yihu/ehr/resource/dao/PortalMessageTemplateDao.java

@ -0,0 +1,17 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.PortalMessageTemplate;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2018.03.21
 */
public interface PortalMessageTemplateDao extends PagingAndSortingRepository<PortalMessageTemplate, Long> {
    @Query("select portalMessageTemplate from PortalMessageTemplate portalMessageTemplate where portalMessageTemplate.classification = :classification and  portalMessageTemplate.type = :type and  portalMessageTemplate.state = :state")
    List<PortalMessageTemplate> searchPortalMessageTemplate(@Param("classification") String classification, @Param("type") String type, @Param("state") String state);
}

+ 1016 - 0
src/main/java/com/yihu/ehr/resource/dao/ResourceBrowseDao.java

@ -0,0 +1,1016 @@
package com.yihu.ehr.resource.dao;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.elasticsearch.ElasticSearchUtil;
import com.yihu.ehr.exception.ApiException;
import com.yihu.ehr.hbase.HBaseDao;
import com.yihu.ehr.profile.ProfileType;
import com.yihu.ehr.profile.core.ResourceCore;
import com.yihu.ehr.profile.family.ResourceCells;
import com.yihu.ehr.query.common.model.QueryCondition;
import com.yihu.ehr.query.common.model.SolrGroupEntity;
import com.yihu.ehr.query.common.sqlparser.ParserFactory;
import com.yihu.ehr.query.common.sqlparser.ParserSql;
import com.yihu.ehr.query.services.HbaseQuery;
import com.yihu.ehr.query.services.SolrQuery;
import com.yihu.ehr.resource.client.QuotaStatisticsClient;
import com.yihu.ehr.resource.client.StdTransformClient;
import com.yihu.ehr.resource.model.*;
import com.yihu.ehr.resource.service.RedisService;
import com.yihu.ehr.resource.service.RsResourceService;
import com.yihu.ehr.util.rest.Envelop;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.hbase.client.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created by hzp on 2016/4/22.
 * 资源查询底层接口
 */
@Repository
public class ResourceBrowseDao {
    private Integer defaultPage = 1;
    private Integer defaultSize = 1000;
    private String mainJoinCore = ResourceCore.MasterTable + "_shard1_replica1";
    private String subJoinCore = ResourceCore.SubTable + "_shard1_replica1";
    private static final String INDEX = "archive_relation";
    private static final String TYPE = "info";
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HbaseQuery hbaseQuery;
    @Autowired
    private SolrQuery solr;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private RsResourceDao rsResourceDao;
    @Autowired
    private ResourceBrowseMetadataDao resourceBrowseMetadataDao;
    @Autowired
    private RsResourceDefaultParamDao resourceDefaultParamDao;
    @Autowired
    private RedisService redisService;
    @Autowired
    private RsRolesResourceMetadataDao rsRolesResourceMetadataDao;
    @Autowired
    private StdTransformClient stdTransformClient;
    @Autowired
    private RsRolesResourceDao rsRolesResourceDao;
    @Autowired
    private RsResourceQuotaDao rsResourceQuotaDao;
    @Autowired
    private QuotaStatisticsClient quotaStatisticsClient;
    @Autowired
    private HBaseDao hbaseDao;
    @Autowired
    private ElasticSearchUtil elasticSearchUtil;
    @Autowired
    private SolrQuery solrQuery;
    @Autowired
    private RsResourceService rsResourceService;
    /**
     * 获取资源授权数据元列表
     *
     * @param rsResource 资源
     * @param roleId 角色ID列表
     * @return
     * @throws Exception
     */
    public List<DtoResourceMetadata> getAccessMetadata(RsResource rsResource, String roleId, Map<String, String> correspondMap) throws Exception {
        Set<String> rsMetadataIdSet = new HashSet<>();
        String grantType = rsResource.getGrantType();
        boolean isOtherVersion = false;
        if (rsResource.getCode().split("\\$").length > 1) {
            isOtherVersion = true;
        }
        if (isOtherVersion) {
            String version = rsResource.getCode().split("\\$")[1];
            String code = rsResource.getCode().split("\\$")[0];
            String otherStdMetadataStr = stdTransformClient.stdMetadataCodes(version, code); //省平台临时数据处理
            if (null == otherStdMetadataStr) {
                throw new ApiException("省平台数据缓存为空");
            }
            String[] otherStdMetadataArr = otherStdMetadataStr.split(",");
            List<String> transformEhrMetadataList = new ArrayList<>(); // 此list存储其他标准数据集底下的数据元转换成的平台的数据元的id (EHR_XXXXX)
            for (String otherStdMetadata : otherStdMetadataArr) {
                String dataSetAndMetadata = stdTransformClient.adapterMetadataCode("5a6951bff0bb", code, otherStdMetadata); //适配版本号
                if (!StringUtils.isEmpty(dataSetAndMetadata) && dataSetAndMetadata.split("\\.").length > 1) {
                    String[] dataSetAndMetadataArr = dataSetAndMetadata.split("\\.");
                    String ehrMetadata = redisService.getRsAdapterMetaData("59083976eebd", dataSetAndMetadataArr[0], dataSetAndMetadataArr[1]);
                    if (!StringUtils.isEmpty(ehrMetadata)) {
                        transformEhrMetadataList.add(ehrMetadata);
                        correspondMap.put(ehrMetadata, otherStdMetadata);
                    }
                }
            }
            if (grantType.equals("1") && !roleId.equals("*")) {
                List<String> roleIdList = objectMapper.readValue(roleId, List.class);
                for (String id : roleIdList) {
                    RsRolesResource rsRolesResource = rsRolesResourceDao.findByResourceIdAndRolesId(rsResource.getId(), id);
                    if (rsRolesResource != null) {
                        List<RsRolesResourceMetadata> rsRolesResourceMetadataList = rsRolesResourceMetadataDao.findByRolesResourceIdAndValid(rsRolesResource.getId(), "1");
                        if (rsRolesResourceMetadataList != null) {
                            for (RsRolesResourceMetadata rsRolesResourceMetadata : rsRolesResourceMetadataList) {
                                if (transformEhrMetadataList.contains(rsRolesResourceMetadata.getResourceMetadataId())) { // 如果其他标准数据集包含该数据元
                                    rsMetadataIdSet.add(rsRolesResourceMetadata.getResourceMetadataId());
                                }
                            }
                        }
                    }
                }
                if (rsMetadataIdSet.size() > 0) {
                    StringBuilder rsMetadataIds = new StringBuilder();
                    for (String id : rsMetadataIdSet) {
                        rsMetadataIds.append("'");
                        rsMetadataIds.append(id);
                        rsMetadataIds.append("',");
                    }
                    if (rsMetadataIds.length() <= 0) {
                        return null;
                    }
                    return resourceBrowseMetadataDao.getAuthResourceMetadata(rsMetadataIds.substring(0, rsMetadataIds.length() - 1));
                } else {
                    return null;
                }
            } else {
                StringBuilder rsMetadataIds = new StringBuilder();
                for (String id : transformEhrMetadataList) {
                    rsMetadataIds.append("'");
                    rsMetadataIds.append(id);
                    rsMetadataIds.append("',");
                }
                if (rsMetadataIds.length() <= 0) {
                    return null;
                }
                return resourceBrowseMetadataDao.getRsMetadataByIds(rsMetadataIds.substring(0, rsMetadataIds.length() - 1));
            }
        } else { //EHR所用标准
            if (grantType.equals("1") && !roleId.equals("*")) {
                List<String> roleIdList = objectMapper.readValue(roleId, List.class);
                for (String id : roleIdList) {
                    RsRolesResource rsRolesResource = rsRolesResourceDao.findByResourceIdAndRolesId(rsResource.getId(), id);
                    if (rsRolesResource != null) {
                        List<RsRolesResourceMetadata> rsRolesResourceMetadataList = rsRolesResourceMetadataDao.findByRolesResourceIdAndValid(rsRolesResource.getId(), "1");
                        if (rsRolesResourceMetadataList != null) {
                            for (RsRolesResourceMetadata rsRolesResourceMetadata : rsRolesResourceMetadataList) {
                                rsMetadataIdSet.add(rsRolesResourceMetadata.getResourceMetadataId());
                            }
                        }
                    }
                }
                if (rsMetadataIdSet.size() > 0) {
                    StringBuilder rsMetadataIds = new StringBuilder();
                    for (String id : rsMetadataIdSet) {
                        rsMetadataIds.append("'");
                        rsMetadataIds.append(id);
                        rsMetadataIds.append("',");
                    }
                    return resourceBrowseMetadataDao.getAuthResourceMetadata(rsMetadataIds.substring(0, rsMetadataIds.length() - 1));
                } else {
                    return null;
                }
            } else {
                //返回所有数据元
                return resourceBrowseMetadataDao.getAllResourceMetadata(rsResource.getCode());
            }
        }
    }
    /**
     * @param resourcesCode 资源编码
     * @param roleId        角色ID列表
     * @param saas          权限
     * @param queryParams   查询条件 {"q":"*:*","fq":"*:*","basicFl":"","dFl":"","sort":"{\"field1\":\"asc\",\"field2\":\"desc\"}"}
     * @param page          页码
     * @param size          页数
     * @return
     * @throws Exception
     */
    public Envelop getEhrCenter (String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws Exception {
        //获取Saas权限
        StringBuilder q = new StringBuilder();
        if (saas != null && !"*".equals(saas)) {
            q.append(saas);
        }
        String fq = "";
        final Map<String, String> sort = new HashMap<>();
        Map<String, String> query = new HashMap<>();
        if (queryParams != null) {
            query = objectMapper.readValue(queryParams, Map.class);
            if (query.containsKey("q") && !query.get("q").trim().equals("*:*")) {
                if (q.length() > 0) {
                    q.append(" AND (");
                    q.append(query.get("q"));
                    q.append(")");
                } else {
                    q.append(query.get("q"));
                }
            }
            if (query.containsKey("fq")) {
                fq = query.get("fq");
            }
            if (query.containsKey("sort")) {
                Map<String, String> temp = objectMapper.readValue((String) query.get("sort"), Map.class);
                temp.forEach((key, value) -> {
                    sort.put(key, value);
                });
            }
        }
        //通过资源代码获取默认参数
        List<RsResourceDefaultParam> paramsList = resourceDefaultParamDao.findByResourcesCode(resourcesCode);
        for (RsResourceDefaultParam param : paramsList) {
            if (param.getParamKey().equals("sort")) {
                Map<String, String> temp = objectMapper.readValue(param.getParamValue(), Map.class);
                temp.forEach((key, value) -> {
                    sort.put(key, value);
                });
            }
            if (param.getParamKey().equals("q")) {
                List<QueryCondition> ql = parseCondition(param.getParamValue());
                if (q.length() > 0) {
                    q.append(" AND ");
                    q.append(solrQuery.conditionToString(ql));
                } else {
                    q.append(solrQuery.conditionToString(ql));
                }
            }
        }
        if (resourcesCode != null) {
            RsResource rsResources = rsResourceService.getResourceByCategory(resourcesCode,"standard");
            //获取资源结构权限,该部分新增其他标准数据集的判断
            List<DtoResourceMetadata> metadataList = getAccessMetadata(rsResources, roleId, new HashMap<>());
            if (metadataList != null && metadataList.size() > 0) {
                //数据元信息字段
                List<String> metadataIdList = new ArrayList<>();
                for (DtoResourceMetadata metadata : metadataList) {
                    String id = metadata.getId();
                    metadataIdList.add(id);
                    String dictCode = metadata.getDictCode();
                    if (!StringUtils.isEmpty(dictCode)) {
                        metadataIdList.add(id + "_VALUE");
                    }
                }
                Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.MasterTable, q.toString(), objectMapper.writeValueAsString(sort), fq, StringUtils.join(ResourceCells.getMasterBasicCell(ProfileType.Standard), ","), StringUtils.join(metadataIdList, ","), page, size);
                Envelop envelop = new Envelop();
                envelop.setSuccessFlg(true);
                envelop.setCurrPage(result.getNumber());
                envelop.setPageSize(result.getSize());
                envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
                envelop.setDetailModelList(result.getContent());
                return envelop;
            }
        } else {
            String basicFl = "";
            String dFl = "";
            if (query.containsKey("basicFl")) {
                basicFl = query.get("basicFl");
            }
            if (query.containsKey("dFl")) {
                dFl = query.get("dFl");
            }
            Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.MasterTable, q.toString(), objectMapper.writeValueAsString(sort), fq, basicFl, dFl, page, size);
            Envelop envelop = new Envelop();
            envelop.setSuccessFlg(true);
            envelop.setCurrPage(result.getNumber());
            envelop.setPageSize(result.getSize());
            envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
            envelop.setDetailModelList(result.getContent());
            return envelop;
        }
        throw new ApiException("资源无相关数据元");
    }
    /**
     * @param resourcesCode 资源编码
     * @param roleId        角色ID列表
     * @param saas          权限
     * @param queryParams   查询条件 {"q":"*:*","fq":"*:*","basicFl":"","dFl":"","sort":"{\"field1\":\"asc\",\"field2\":\"desc\"}"}
     * @param page          页码
     * @param size          页数
     * @return
     * @throws Exception
     */
    public Envelop getEhrCenterSub (String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws Exception {
        //获取Saas权限
        StringBuilder q = new StringBuilder();
        if (saas != null && !"*".equals(saas)) {
            q.append(saas);
        }
        String fq = "";
        final Map<String, String> sort = new HashMap<>();
        Map<String, String> query = new HashMap<>();
        if (queryParams != null) {
            query = objectMapper.readValue(queryParams, Map.class);
            if (query.containsKey("q") && !query.get("q").trim().equals("*:*")) {
                if (q.length() > 0) {
                    q.append(" AND (");
                    q.append(query.get("q"));
                    q.append(")");
                } else {
                    q.append(query.get("q"));
                }
            }
            if (query.containsKey("fq")) {
                fq = query.get("fq");
            }
            if (query.containsKey("sort")) {
                Map<String, String> temp = objectMapper.readValue((String) query.get("sort"), Map.class);
                temp.forEach((key, value) -> {
                    sort.put(key, value);
                });
            }
        }
        //通过资源代码获取默认参数
        List<RsResourceDefaultParam> paramsList = resourceDefaultParamDao.findByResourcesCode(resourcesCode);
        for (RsResourceDefaultParam param : paramsList) {
            if (param.getParamKey().equals("sort")) {
                Map<String, String> temp = objectMapper.readValue(param.getParamValue(), Map.class);
                temp.forEach((key, value) -> {
                    sort.put(key, value);
                });
            }
            if (param.getParamKey().equals("table")) {
                if (q.length() > 0) {
                    q.append(" AND (rowkey:*$" + param.getParamValue() + "$*)");
                } else {
                    q.append("rowkey:*$" + param.getParamValue() + "$*");
                }
            }
            if (param.getParamKey().equals("q")) {
                List<QueryCondition> ql = parseCondition(param.getParamValue());
                if (q.length() > 0) {
                    q.append(" AND ");
                    q.append(solrQuery.conditionToString(ql));
                } else {
                    q.append(solrQuery.conditionToString(ql));
                }
            }
        }
        if (resourcesCode != null) {
            RsResource rsResources = rsResourceService.getResourceByCategory(resourcesCode,"standard");
            //获取资源结构权限,该部分新增其他标准数据集的判断
            List<DtoResourceMetadata> metadataList = getAccessMetadata(rsResources, roleId, new HashMap<>());
            if (metadataList != null && metadataList.size() > 0) {
                //数据元信息字段
                List<String> metadataIdList = new ArrayList<>();
                for (DtoResourceMetadata metadata : metadataList) {
                    String id = metadata.getId();
                    metadataIdList.add(id);
                    String dictCode = metadata.getDictCode();
                    if (!StringUtils.isEmpty(dictCode)) {
                        metadataIdList.add(id + "_VALUE");
                    }
                }
                Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.SubTable, q.toString(), objectMapper.writeValueAsString(sort), fq, StringUtils.join(ResourceCells.getSubBasicCell(ProfileType.Standard), ","), StringUtils.join(metadataIdList, ","), page, size);
                Envelop envelop = new Envelop();
                envelop.setSuccessFlg(true);
                envelop.setCurrPage(result.getNumber());
                envelop.setPageSize(result.getSize());
                envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
                envelop.setDetailModelList(result.getContent());
                return envelop;
            }
        } else {
            String basicFl = "";
            String dFl = "";
            if (query.containsKey("basicFl")) {
                basicFl = query.get("basicFl");
            }
            if (query.containsKey("dFl")) {
                dFl = query.get("dFl");
            }
            Page<Map<String, Object>> result = hbaseQuery.queryBySolr(ResourceCore.SubTable, q.toString(), objectMapper.writeValueAsString(sort), fq, basicFl, dFl, page, size);
            Envelop envelop = new Envelop();
            envelop.setSuccessFlg(true);
            envelop.setCurrPage(result.getNumber());
            envelop.setPageSize(result.getSize());
            envelop.setTotalCount(new Long(result.getTotalElements()).intValue());
            envelop.setDetailModelList(result.getContent());
            return envelop;
        }
        throw new ApiException("资源无相关数据元");
    }
    /**
     * habse主表的solr分组统计
     * {"q":"*:*","groupFields":"key1,key2","statsFields":"key3,key4","customGroup":[{"groupField":"lastUpdateTime","groupCondition":{"3Month":"last_update_time:[2016-02-16 TO *]","6Month":"last_update_time:[2015-11-10 TO *]"}}]}
     *
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> countEhrCenter(String queryParams, Integer page, Integer size) throws Exception {
        String core = ResourceCore.MasterTable;
        ObjectMapper objectMapper = new ObjectMapper();
        Map<String, Object> params = objectMapper.readValue(queryParams, Map.class);
        String q = "";
        String fq = "";
        String groupFields = "";
        String statsFields = "";
        List<SolrGroupEntity> customGroup = new ArrayList<>();
        if (params.containsKey("q")) {
            fq = params.get("q").toString();
            if (params.containsKey("saas") && !params.get("saas").equals("*")) {
                fq += " AND (" + params.get("saas") + ")";
            }
        } else {
            if (params.containsKey("saas") && !params.get("saas").equals("*")) {
                fq = params.get("saas").toString();
            }
        }
        if (params.containsKey("groupFields")) {
            groupFields = params.get("groupFields").toString();
        }
        if (params.containsKey("statsFields")) {
            statsFields = params.get("statsFields").toString();
        }
        if (params.containsKey("customGroup")) {
            ArrayList listGroup = ((ArrayList) params.get("customGroup"));
            if (listGroup != null && listGroup.size() > 0) {
                for (int i = 0; i < listGroup.size(); i++) {
                    String groupField = ((LinkedHashMap) listGroup.get(i)).get("groupField").toString();
                    Map<String, String> groupCondition = (Map) ((LinkedHashMap) listGroup.get(i)).get("groupCondition");
                    customGroup.add(new SolrGroupEntity(groupField, groupCondition));
                }
            }
        }
        //join操作
        if (params.containsKey("join")) {
            String join = params.get("join").toString();
            q = "{!join fromIndex=" + subJoinCore + " from=profile_id to=rowkey}" + join;
        }
        if (groupFields.length() == 0 && customGroup.size() == 0) {
            throw new Exception("缺少分组条件!");
        }
        //数值统计
        if (statsFields != null && statsFields.length() > 0) {
            return solr.getStats(core, groupFields, statsFields, q, fq, customGroup);
        }
        //总数统计
        else {
            if (customGroup.size() == 0) {
                //默认第一页
                if (page == null) {
                    page = defaultPage;
                }
                //默认行数
                if (size == null) {
                    size = defaultSize;
                }
                //多分组
                if (groupFields.contains(",")) {
                    return solr.getGroupMult(core, groupFields, q, fq, page, size);
                } else {
                    return solr.getGroupCount(core, groupFields, q, fq, page, size);
                }
            } else {
                return solr.getGroupMult(core, groupFields, customGroup, q, fq);
            }
        }
    }
    /**
     * habse细表的solr分组统计
     *
     * @param queryParams {"table":"HDSD00_08","q":"*:*","groupFields":"key1,key2","statsFields":"key3,key4",customGroup:""}
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> countEhrCenterSub (String queryParams, Integer page, Integer size) throws Exception {
        String core = ResourceCore.SubTable;
        ObjectMapper objectMapper = new ObjectMapper();
        Map<String, String> params = objectMapper.readValue(queryParams, Map.class);
        String q = "";
        String fq = "";
        String groupFields = "";
        String statsFields = "";
        if (params.containsKey("q")) {
            fq = params.get("q");
        }
        if (params.containsKey("groupFields")) {
            groupFields = params.get("groupFields");
        } else {
            throw new Exception("缺少分组条件!");
        }
        if (params.containsKey("statsFields")) {
            statsFields = params.get("statsFields");
        }
        if (params.containsKey("table")) {
            if (fq.length() > 0) {
                fq += " AND rowkey:*" + params.get("table") + "*";
            } else {
                fq = "rowkey:*" + params.get("table") + "*";
            }
        }
        if (params.containsKey("saas")) {
            if (fq.length() > 0) {
                fq = "(" + fq + ") AND (" + params.get("saas") + ")";
            } else {
                fq = params.get("saas");
            }
        }
        //join操作
        if (params.containsKey("join")) {
            String join = params.get("join").toString();
            q = "{!join  fromIndex=" + mainJoinCore + " from=rowkey to=profile_id}" + join;
        }
        //数值统计
        if (statsFields != null && statsFields.length() > 0) {
            return solr.getStats(core, groupFields, statsFields, q, fq);
        }
        //总数统计
        else {
            if (groupFields.contains(",")) {//多分组
                return solr.getGroupMult(core, groupFields, null, q, fq); //自定义分组未完善
            } else { //单分组
                //默认第一页
                if (page == null) {
                    page = defaultPage;
                }
                //默认行数
                if (size == null) {
                    size = defaultSize;
                }
                return solr.getGroupCount(core, groupFields, q, fq, page, size);
            }
        }
    }
    /**
     * 获取指标数据
     * @param resourcesCode
     * @param roleId
     * @param saas
     * @param queryParams
     * @param page
     * @param size
     * @return
     */
    public Envelop getQuotaData(String resourcesCode, String roleId, String saas, String queryParams, Integer page, Integer size) throws IOException {
        RsResource rsResource = rsResourceService.getResourceByCategory(resourcesCode,"standard");
        if (rsResource.getDimension() != null && "orgHealthCategoryCode".equals(rsResource.getDimension())) {
            List<RsResourceQuota> list = rsResourceQuotaDao.findByResourceId(rsResource.getId());
            final StringBuilder quotaCodeStr = new StringBuilder();
            list.forEach(item -> {
                quotaCodeStr.append(item.getQuotaCode()).append(",");
            });
            List<Map<String, Object>> resultList = quotaStatisticsClient.getQuotaReportTwoDimensionalTable(quotaCodeStr.toString(), null, rsResource.getDimension(), null);
            Envelop envelop = new Envelop();
            envelop.setSuccessFlg(true);
            envelop.setDetailModelList(resultList);
            return envelop;
        }
        return null;
    }
    /**
     * 获取非结构化资源
     *
     * @param filters key1=val1;key2>val2;key3<>val3
     * @param sorts
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Envelop getEhrFile(String filters, String sorts, Integer page, Integer size) throws Exception {
        Page<Map<String, Object>> esList = elasticSearchUtil.page(INDEX, TYPE, filters, sorts, page, size);
        List<String> rowkeys = new ArrayList<>();
        esList.forEach(item -> rowkeys.add((String) item.get("_id")));
        List<Map<String, Object>> hbaseList = new ArrayList<>();
        Result[] results = hbaseDao.getResultList("HealthFile", rowkeys, "", ""); //hbase结果集
        if (results != null && results.length > 0) {
            for (Result result : results) {
                Map<String, Object> obj = hbaseQuery.resultToMap(result);
                if (obj != null) {
                    if (obj.get("file_list") != null) {
                        String file_list = (String) obj.get("file_list");
                        List<Map<String, String>> list = objectMapper.readValue(file_list, List.class);
                        obj.put("file_list", list);
                    }
                    if (obj.get("sub_rowkeys") != null) {
                        String sub_rowkeys = (String) obj.get("sub_rowkeys");
                        List<String> list = objectMapper.readValue(sub_rowkeys, List.class);
                        obj.put("sub_rowkeys", list);
                    }
                    hbaseList.add(obj);
                } else {
                    hbaseList.add(new HashMap<>());
                }
            }
        }
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        envelop.setCurrPage(page);
        envelop.setPageSize(size);
        envelop.setTotalCount((int)esList.getTotalElements());
        envelop.setDetailModelList(hbaseList);
        return envelop;
    }
    /**
     * 获取Mysql配置库数据
     *
     * @param queryParams
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public Page<Map<String, Object>> getMysqlData(String queryParams, Integer page, Integer size) throws Exception {
        String sql = queryParams;
        //判定是否完整sql语句
        if (sql.toLowerCase().indexOf(" from ") <= 0) {
            sql = "select * from " + queryParams;
        }
        //查询总条数
        ParserSql parser = ParserFactory.getParserSql();
        String sqlCount = parser.getCountSql(sql);
        long count = jdbcTemplate.queryForObject(sqlCount, Long.class);
        //默认第一页
        if (page == null) {
            page = defaultPage;
        }
        //默认行数
        if (size == null) {
            size = defaultSize;
        }
        //分页查询
        List<Map<String, Object>> list;
        if (count > size) {
            String sqlList = parser.getPageSql(sql, page, size);
            list = jdbcTemplate.queryForList(sqlList);
        } else {
            list = jdbcTemplate.queryForList(sql);
        }
        return new PageImpl<>(list, new PageRequest(page - 1, size), count);
    }
    /**
     * 获取solr索引列表
     * queryParams可为solr表达式,也可为json例:{"q":"*:*","saas":"*","join":"*:*","fl":"","sort":"{\"field1\":\"asc\",\"field2\":\"desc\"}""}
     * 有join参数做join操作
     */
    public Page<String> getSolrIndexs(String queryParams, Integer page, Integer size) throws Exception {
        String core = ResourceCore.MasterTable;
        String q = "";
        String fq = "";
        String basicFl = "";
        String dFl = "";
        String sort = "";
        if (queryParams != null && queryParams.length() > 0) {
            if (queryParams.startsWith("{") && queryParams.endsWith("}")) {
                ObjectMapper objectMapper = new ObjectMapper();
                Map<String, String> obj = objectMapper.readValue(queryParams, Map.class);
                if (obj.containsKey("q")) {
                    q = obj.get("q");
                    if (obj.containsKey("saas") && !obj.get("saas").equals("*")) {
                        q += " AND (" + obj.get("saas") + ")";
                    }
                } else {
                    if (obj.containsKey("saas") && !obj.get("saas").equals("*")) {
                        q = obj.get("saas");
                    }
                }
                if (obj.containsKey("basicFl")) {
                    basicFl = obj.get("basicFl");
                }
                if (obj.containsKey("dFl")) {
                    dFl = obj.get("dFl");
                }
                if (obj.containsKey("sort")) {
                    sort = obj.get("sort");
                }
                //join操作
                if (obj.containsKey("join")) {
                    String join = obj.get("join");
                    fq = q;
                    q = "{!join fromIndex=" + subJoinCore + " from=profile_id to=rowkey}" + join;
                }
            } else {
                q = queryParams;
            }
        }
        //默认第一页
        if (page == null) {
            page = defaultPage;
        }
        //默认行数
        if (size == null) {
            size = defaultSize;
        }
        return hbaseQuery.queryIndexBySolr(core, q, sort, fq, basicFl, dFl, page, size);
    }
    /**
     * @param resourcesCode 资源编码
     * @param roleId        角色ID列表
     * @param saas          权限
     * @param rowKey        主键
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> getEhrCenterByScan (String resourcesCode, String roleId, String saas, String rowKey) throws Exception {
        Map<String, Object> query = new HashMap<>();
        if (resourcesCode != null) {
            RsResource rsResources = rsResourceService.getResourceByCategory(resourcesCode,"standard");
            //获取资源结构权限,该部分新增其他标准数据集的判断
            List<DtoResourceMetadata> metadataList = getAccessMetadata(rsResources, roleId, new HashMap<>());
            if (metadataList != null && metadataList.size() > 0) {
                //数据元信息字段
                List<String> metadataIdList = new ArrayList<>();
                for (DtoResourceMetadata metadata : metadataList) {
                    String id = metadata.getId();
                    metadataIdList.add(id);
                    String dictCode = metadata.getDictCode();
                    if (!StringUtils.isEmpty(dictCode)) {
                        metadataIdList.add(id + "_VALUE");
                    }
                }
                List<Map<String, Object>> data = new ArrayList<>();
                //Scan查询
                String legacyRowKeys[] = hbaseDao.findRowKeys(ResourceCore.MasterTable, rowKey, rowKey.substring(0, rowKey.length() - 1) + "1", "^" + rowKey);
                List list = Arrays.asList(legacyRowKeys);
                Result[] resultList = hbaseDao.getResultList(ResourceCore.MasterTable, list, "", ""); //hbase结果集
                if (resultList != null && resultList.length > 0) {
                    for (Result result : resultList) {
                        Map<String, Object> obj = hbaseQuery.resultToMap(result);
                        if (obj != null) {
                            data.add(obj);
                        }
                    }
                }
                return data;
            }
        } else {
            String basicFl = "";
            String dFl = "";
            if (query.containsKey("basicFl")) {
                basicFl = (String) query.get("basicFl");
            }
            if (query.containsKey("dFl")) {
                dFl = (String) query.get("dFl");
            }
            List<Map<String, Object>> data = new ArrayList<>();
            //Scan查询
            String legacyRowKeys[] = hbaseDao.findRowKeys(ResourceCore.MasterTable, rowKey, rowKey.substring(0, rowKey.length() - 1) + "1", "^" + rowKey);
            List list = Arrays.asList(legacyRowKeys);
            Result[] resultList = hbaseDao.getResultList(ResourceCore.MasterTable, list, basicFl, dFl); //hbase结果集
            if (resultList != null && resultList.length > 0) {
                for (Result result : resultList) {
                    Map<String, Object> obj = hbaseQuery.resultToMap(result);
                    if (obj != null) {
                        data.add(obj);
                    }
                }
            }
            return data;
        }
        throw new ApiException("资源无相关数据元");
    }
    /**
     * @param dataSetCode 数据集编码
     * @param roleId      角色ID列表
     * @param saas        权限
     * @param rowKey
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> getEhrCenterSubByScan (String dataSetCode, String roleId, String saas, String rowKey) throws Exception {
        Map<String, Object> query = new HashMap<>();
        if (dataSetCode != null) {
            RsResource rsResources = rsResourceService.getResourceByCategory(dataSetCode,"standard");
            //获取资源结构权限,该部分新增其他标准数据集的判断
            List<DtoResourceMetadata> metadataList = getAccessMetadata(rsResources, roleId, new HashMap<>());
            if (metadataList != null && metadataList.size() > 0) {
                //数据元信息字段
                List<String> metadataIdList = new ArrayList<>();
                for (DtoResourceMetadata metadata : metadataList) {
                    String id = metadata.getId();
                    metadataIdList.add(id);
                    String dictCode = metadata.getDictCode();
                    if (!StringUtils.isEmpty(dictCode)) {
                        metadataIdList.add(id + "_VALUE");
                    }
                }
                List<Map<String, Object>> data = new ArrayList<>();
                String subrowKey = rowKey + "$" + dataSetCode + "$";
                //Scan查询
                String legacyRowKeys[] = hbaseDao.findRowKeys(ResourceCore.SubTable, subrowKey + "0", subrowKey + "z", "^" + rowKey);
//                String legacyRowKeys[] = hbaseDao.findRowKeys(ResourceCore.SubTable, rowKey, rowKey.substring(0, rowKey.length() - 1) + "1", "^" + rowKey);
                List list = Arrays.asList(legacyRowKeys);
                //获取各个数据集相关的rowkey
                Result[] resultList = hbaseDao.getResultList(ResourceCore.SubTable, list, StringUtils.join(ResourceCells.getSubBasicCell(ProfileType.Standard), ","), StringUtils.join(metadataIdList, ",")); //hbase结果集
                if (resultList != null && resultList.length > 0) {
                    for (Result result : resultList) {
                        Map<String, Object> obj = hbaseQuery.resultToMap(result);
                        if (obj != null) {
                            data.add(obj);
                        }
                    }
                }
                return data;
            }
        } else {
            String basicFl = "";
            String dFl = "";
            if (query.containsKey("basicFl")) {
                basicFl = (String) query.get("basicFl");
            }
            if (query.containsKey("dFl")) {
                dFl = (String) query.get("dFl");
            }
            List<Map<String, Object>> data = new ArrayList<>();
            //Scan查询
            String legacyRowKeys[] = hbaseDao.findRowKeys(ResourceCore.SubTable, rowKey, rowKey.substring(0, rowKey.length() - 1) + "1", "^" + rowKey);
            List list = Arrays.asList(legacyRowKeys);
            Result[] resultList = hbaseDao.getResultList(ResourceCore.SubTable, list, basicFl, dFl); //hbase结果集
            if (resultList != null && resultList.length > 0) {
                for (Result result : resultList) {
                    Map<String, Object> obj = hbaseQuery.resultToMap(result);
                    if (obj != null) {
                        data.add(obj);
                    }
                }
            }
            return data;
        }
        throw new ApiException("资源无相关数据元");
    }
    /**
     * 通过数据集编码集合,获取对应rowkey 下的资源数据
     *
     * @param dataSetCodes 数据集编码集合
     * @param roleId       角色ID列表
     * @param saas         权限
     * @param rowKey
     * @return
     * @throws Exception
     */
    public Map<String, Object> getEhrCenterSubMapByScan (List<String> dataSetCodes, String roleId, String saas, String rowKey) throws Exception {
        Map<String, Object> resultMap = new HashMap<>();
        Map<String, List<String>> rowKeyMap = new HashMap<>();
        //获取Saas权限
        StringBuilder q = new StringBuilder();
        if (saas != null && !"*".equals(saas)) {
            q.append(saas);
        }
        String fq = "";
        final Map<String, String> sort = new HashMap<>();
        Map<String, Object> query = new HashMap<>();
        if (query.containsKey("q")) {
            if (q.length() > 0) {
                q.append(" AND (");
                q.append("rowKey:" + rowKey);
                q.append(")");
            } else {
                q.append("(" + query.get("q") + ")");
            }
        }
        if (query.containsKey("sort")) {
            Map<String, String> temp = objectMapper.readValue((String) query.get("sort"), Map.class);
            temp.forEach((key, value) -> {
                sort.put(key, value);
            });
        }
        if (CollectionUtils.isNotEmpty(dataSetCodes)) {
            String legacyRowKeys[] = hbaseDao.findRowKeys(ResourceCore.SubTable, rowKey, rowKey.substring(0, rowKey.length() - 1) + "1", "^" + rowKey);
            List<String> list = Arrays.asList(legacyRowKeys);
            if (CollectionUtils.isNotEmpty(list)) {
                for (String dataSet : dataSetCodes) {
                    String subrowKey = rowKey + "$" + dataSet + "$";
                    List<String> keys = list.stream().filter(row -> row.contains(subrowKey)).collect(Collectors.toList());
                    if (CollectionUtils.isNotEmpty(keys)) {
                        rowKeyMap.put(dataSet, keys);
                    }
                }
            }
        }
        Iterator<String> iterator = rowKeyMap.keySet().iterator();
        while (iterator.hasNext()) {
            String dataSetCode = iterator.next();
            //获取rowkey
            List<String> list = rowKeyMap.get(dataSetCode);
            if (dataSetCode != null) {
                RsResource rsResources = rsResourceService.getResourceByCategory(dataSetCode,"standard");
                //获取资源结构权限,该部分新增其他标准数据集的判断
                List<DtoResourceMetadata> metadataList = getAccessMetadata(rsResources, roleId, new HashMap<>());
                if (metadataList != null && metadataList.size() > 0) {
                    //数据元信息字段
                    List<String> metadataIdList = new ArrayList<>();
                    for (DtoResourceMetadata metadata : metadataList) {
                        String id = metadata.getId();
                        metadataIdList.add(id);
                        String dictCode = metadata.getDictCode();
                        if (!StringUtils.isEmpty(dictCode)) {
                            metadataIdList.add(id + "_VALUE");
                        }
                    }
                    List<Map<String, Object>> data = new ArrayList<>();
                    Result[] resultList = hbaseDao.getResultList(ResourceCore.SubTable, list, StringUtils.join(ResourceCells.getSubBasicCell(ProfileType.Standard), ","), StringUtils.join(metadataIdList, ",")); //hbase结果集
                    if (resultList != null && resultList.length > 0) {
                        for (Result result : resultList) {
                            Map<String, Object> obj = hbaseQuery.resultToMap(result);
                            if (obj != null) {
                                data.add(obj);
                            }
                        }
                    }
                    resultMap.put(dataSetCode, data);
                }
            } else {
                String basicFl = "";
                String dFl = "";
                if (query.containsKey("basicFl")) {
                    basicFl = (String) query.get("basicFl");
                }
                if (query.containsKey("dFl")) {
                    dFl = (String) query.get("dFl");
                }
                List<Map<String, Object>> data = new ArrayList<>();
                //Scan查询
                Result[] resultList = hbaseDao.getResultList(ResourceCore.SubTable, list, basicFl, dFl); //hbase结果集
                if (resultList != null && resultList.length > 0) {
                    for (Result result : resultList) {
                        Map<String, Object> obj = hbaseQuery.resultToMap(result);
                        if (obj != null) {
                            data.add(obj);
                        }
                    }
                }
                resultMap.put(dataSetCode, data);
            }
        }
        return resultMap;
    }
    /**
     * 查询条件转换
     *
     * @param queryCondition
     * @return
     * @throws Exception
     */
    private List<QueryCondition> parseCondition(String queryCondition) throws Exception {
        List<QueryCondition> ql = new ArrayList<QueryCondition>();
        List<Map<String, Object>> list = objectMapper.readValue(queryCondition, List.class);
        if (list != null && list.size() > 0) {
            for (Map<String, Object> item : list) {
                String andOr = String.valueOf(item.get("andOr")).trim();
                String field = String.valueOf(item.get("field")).trim();
                String cond = String.valueOf(item.get("condition")).trim();
                String value = String.valueOf(item.get("value"));
                if (value.indexOf(",") > 0) {
                    ql.add(new QueryCondition(andOr, cond, field, value.split(",")));
                } else {
                    ql.add(new QueryCondition(andOr, cond, field, value));
                }
            }
        }
        return ql;
    }
}

+ 79 - 0
src/main/java/com/yihu/ehr/resource/dao/ResourceBrowseMetadataDao.java

@ -0,0 +1,79 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.DtoResourceMetadata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/5/14.
 */
@Repository
public class ResourceBrowseMetadataDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 获取某资源所有数据元
     */
    public List<DtoResourceMetadata> getAllResourceMetadata(String resourcesCode) throws Exception {
        String sql = "SELECT m.id, m.domain, m.name, m.std_code, m.display_code, m.column_type, m.null_able, m.dict_code, m.description, m.valid, a.group_type, a.group_data " +
                "FROM rs_resource_metadata a, rs_resource b, rs_metadata m " +
                "WHERE a.resources_id = b.id " +
                "AND a.metadata_id = m.id " +
                "AND b.code = '" + resourcesCode + "'";
        RowMapper rowMapper = BeanPropertyRowMapper.newInstance(DtoResourceMetadata.class);
        return jdbcTemplate.query(sql, rowMapper);
    }
    /**
     * 获取某资源数据元(根据资源数据元id过滤)
     */
    public List<DtoResourceMetadata> getAuthResourceMetadata(String rsMetadataIds) throws Exception {
        String sql = "SELECT m.id, m.domain, m.name, m.std_code, m.display_code, m.column_type, m.null_able, m.dict_code, m.description, m.valid, a.group_type, a.group_data " +
                "FROM rs_resource_metadata a, rs_metadata m " +
                "WHERE a.id IN (" + rsMetadataIds + ") " +
                "AND a.metadata_id = m.id ";
        RowMapper rowMapper = BeanPropertyRowMapper.newInstance(DtoResourceMetadata.class);
        return jdbcTemplate.query(sql, rowMapper);
    }
    /**
     * 为其他平台标准数据元转换新增的方法
     * @param rsMetadataIds
     * @return
     * @throws Exception
     */
    public List<DtoResourceMetadata> getRsMetadataByIds(String rsMetadataIds) throws Exception {
        String sql = "SELECT m.id, m.std_code, m.column_type, m.dict_code " +
                "FROM rs_metadata m " +
                "WHERE m.id IN (" + rsMetadataIds + ")";
        RowMapper rowMapper = BeanPropertyRowMapper.newInstance(DtoResourceMetadata.class);
        return jdbcTemplate.query(sql, rowMapper);
    }
    public List<Map<String, Object>> getMetaData(List<String> idsList){
        StringBuilder builder = new StringBuilder();
        for (String id : idsList){
            builder.append("'");
            builder.append(id);
            builder.append("',");
        }
        String ids = "";
        if (builder.length() > 1){
            ids = builder.substring(0, builder.length() - 1);
        }
        String sql ="SELECT id, name FROM rs_metadata WHERE id in(" + ids + ")";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}

+ 21 - 0
src/main/java/com/yihu/ehr/resource/dao/RsAdapterDictionaryDao.java

@ -0,0 +1,21 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsAdapterDictionary;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
public interface RsAdapterDictionaryDao extends PagingAndSortingRepository<RsAdapterDictionary, String> {
    @Modifying
    @Query("delete from RsAdapterDictionary where schemeId = ?1")
    void deleteBySchemeId(String schemeId);
    List<RsAdapterDictionary> findBySchemeId(String schemeId);
}

+ 27 - 0
src/main/java/com/yihu/ehr/resource/dao/RsAdapterMetadataDao.java

@ -0,0 +1,27 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsAdapterMetadata;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr on 2016/5/17.
 */
public interface RsAdapterMetadataDao extends PagingAndSortingRepository<RsAdapterMetadata, String> {
    Iterable<RsAdapterMetadata> findBySchemeId(String scheme_id);
    @Query("from RsAdapterMetadata where schemeId = ?1")
    List<RsAdapterMetadata> findByScheme(String schemeId);
    @Query("from RsAdapterMetadata where schemeId = ?1 and srcDatasetCode = ?2")
    List<RsAdapterMetadata> findByDataset(String schemeId, String dataset);
    @Modifying
    @Query("delete from RsAdapterMetadata where schemeId = ?1")
    void deleteBySchemeId(String schemeId);
    List<RsAdapterMetadata> findBySchemeIdAndSrcDatasetCode(String schemeId, String srcDatasetCode);
}

+ 13 - 0
src/main/java/com/yihu/ehr/resource/dao/RsAdapterSchemeDao.java

@ -0,0 +1,13 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsAdapterScheme;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr on 2016/5/17.
 */
public interface RsAdapterSchemeDao extends PagingAndSortingRepository<RsAdapterScheme, String> {
    List<RsAdapterScheme> findByAdapterVersion(String version);
}

+ 26 - 0
src/main/java/com/yihu/ehr/resource/dao/RsAppResourceDao.java

@ -0,0 +1,26 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.entity.resource.RsAppResource;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by lyr on 2016/4/26.
 */
public interface RsAppResourceDao extends PagingAndSortingRepository<RsAppResource, String> {
    RsAppResource findByAppId(String appId);
    @Query("select ar.resourceId from RsAppResource ar where ar.appId = :appId")
    List<String> findResourceIdListByAppId(@Param("appId") String appId);
    @Query("select ar.id FROM RsAppResource ar WHERE ar.resourceId=:rsResourceId AND ar.appId=:appId ")
    List<String> findByrsResourceIdAndAppId(@Param("rsResourceId")String rsResourceId, @Param("appId")String appId);
    @Query("select ar FROM RsAppResource ar WHERE ar.resourceId IN (:rsResourceIds) AND ar.appId=:appId ")
    List<RsAppResource> findByrsResourceIds(@Param("rsResourceIds") String [] rsResourceIds,@Param("appId")String appId);
}

+ 18 - 0
src/main/java/com/yihu/ehr/resource/dao/RsAppResourceMetadataDao.java

@ -0,0 +1,18 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.entity.resource.RsAppResourceMetadata;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by lyr on 2016/4/26.
 */
public interface RsAppResourceMetadataDao extends PagingAndSortingRepository<RsAppResourceMetadata, String> {
     void deleteByAppResourceId(String appResourceId);
     @Query("select arm.resourceMetadataId from RsAppResourceMetadata arm where arm.appId = :appId and arm.valid = 1")
     List<String> findMetadataIdByAppId(@Param("appId") String appId);
}

+ 14 - 0
src/main/java/com/yihu/ehr/resource/dao/RsDictionaryDao.java

@ -0,0 +1,14 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsDictionary;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
public interface RsDictionaryDao extends PagingAndSortingRepository<RsDictionary,Integer> {
    RsDictionary findByCode(String code);
}

+ 20 - 0
src/main/java/com/yihu/ehr/resource/dao/RsDictionaryEntryDao.java

@ -0,0 +1,20 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsDictionaryEntry;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
public interface RsDictionaryEntryDao extends PagingAndSortingRepository<RsDictionaryEntry,Integer> {
    List<RsDictionaryEntry> findByDictCode(String code);
    @Query("SELECT count(e) FROM RsDictionaryEntry e WHERE e.dictId=?1")
    int countByDictId(int dictId);
}

+ 11 - 0
src/main/java/com/yihu/ehr/resource/dao/RsDimensionCategoryDao.java

@ -0,0 +1,11 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsDimensionCategory;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by lyr on 2016/4/25.
 */
public interface RsDimensionCategoryDao extends PagingAndSortingRepository<RsDimensionCategory,String> {
     int countByPid(String pid);
}

+ 13 - 0
src/main/java/com/yihu/ehr/resource/dao/RsDimensionDao.java

@ -0,0 +1,13 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsDimension;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by lyr on 2016/4/25.
 */
public interface RsDimensionDao extends PagingAndSortingRepository<RsDimension, String> {
     long countByCategoryId(String categoryId);
}

+ 16 - 0
src/main/java/com/yihu/ehr/resource/dao/RsInterfaceDao.java

@ -0,0 +1,16 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsInterface;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
public interface RsInterfaceDao extends PagingAndSortingRepository<RsInterface,String> {
    List<RsInterface> findByName(String name);
    List<RsInterface> findByResourceInterface(String resourceInterface);
}

+ 18 - 0
src/main/java/com/yihu/ehr/resource/dao/RsMetadataDao.java

@ -0,0 +1,18 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsMetadata;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 数据元DAO
 *
 * Created by lyr on 2016/5/16.
 */
public interface RsMetadataDao extends PagingAndSortingRepository<RsMetadata, String> {
    @Query("select a from RsMetadata a where a.dictCode <> null and a.dictCode <> '' ")
    List<RsMetadata> findMetadataExistDictCode();
}

+ 12 - 0
src/main/java/com/yihu/ehr/resource/dao/RsOrgResourceDao.java

@ -0,0 +1,12 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsOrgResource;
import com.yihu.ehr.resource.model.RsRolesResource;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by zdm on 2017/7/4
 */
public interface RsOrgResourceDao extends PagingAndSortingRepository<RsOrgResource, String> {
    RsOrgResource findByOrganizationId(String organizationId);
}

+ 12 - 0
src/main/java/com/yihu/ehr/resource/dao/RsOrgResourceMetadataDao.java

@ -0,0 +1,12 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsOrgResourceMetadata;
import com.yihu.ehr.resource.model.RsRolesResourceMetadata;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by zdm on 2017/7/4
 */
public interface RsOrgResourceMetadataDao extends PagingAndSortingRepository<RsOrgResourceMetadata, String> {
     void deleteByOrganizationResourceId(String organizationResourceId);
}

+ 22 - 0
src/main/java/com/yihu/ehr/resource/dao/RsReportCategoryAppDao.java

@ -0,0 +1,22 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.entity.report.ReportCategoryAppRelation;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by wxw on 2017/11/24.
 */
public interface RsReportCategoryAppDao extends CrudRepository<ReportCategoryAppRelation, Integer> {
    @Query
    @Modifying
    void deleteByReportCategoryIdAndAppId(@Param("reportCategoryId") Integer reportCategoryId, @Param("appId") String appId);
    @Query("select relation.appId from ReportCategoryAppRelation relation where relation.reportCategoryId = :reportCategoryId")
    List<String> findAppIdByCategory(@Param("reportCategoryId") Integer reportCategoryId);
}

+ 41 - 0
src/main/java/com/yihu/ehr/resource/dao/RsReportCategoryDao.java

@ -0,0 +1,41 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsReportCategory;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * 资源报表分类 DAO
 *
 * @author 张进军
 * @created 2017.8.8 20:32
 */
public interface RsReportCategoryDao extends CrudRepository<RsReportCategory, Integer> {
    @Query(" FROM RsReportCategory rc WHERE rc.pid = :pid ")
    List<RsReportCategory> getChildrenByPid(@Param("pid") Integer pid);
    @Query(" FROM RsReportCategory rc WHERE rc.pid = 0 ")
    List<RsReportCategory> getTopParents();
    @Query(" FROM RsReportCategory rc WHERE rc.id <> :id AND rc.code = :code ")
    RsReportCategory isUniqueCode(@Param("id") Integer id, @Param("code") String code);
    @Query(" FROM RsReportCategory rc WHERE rc.pid = :id AND rc.name = :name ")
    RsReportCategory isUniqueName(@Param("id") Integer id, @Param("name") String name);
    @Query("from RsReportCategory rc where rc.id in(:ids)  ORDER BY rc.sortNo asc")
    List<RsReportCategory> findCategoryByIds(@Param("ids") List<Integer> ids);
    @Query("select rc.id from RsReportCategory rc where rc.pid =(select r.id from RsReportCategory r where r.code = :code) ORDER BY rc.sortNo asc")
    List<Integer> findCategoryIds(@Param("code") String code);
    @Query("select rc.code from RsReportCategory rc where rc.id = :id")
    String findCategoryCodeById(@Param("id") Integer id);
    @Query("select rc.id from RsReportCategory rc where rc.pid in (select r.id from RsReportCategory r where r.code in('businessMonitoringSystem','healthMonitorSystem')) ORDER BY rc.sortNo asc")
    List<Integer> findCategoryIdsByCodeList();
}

+ 36 - 0
src/main/java/com/yihu/ehr/resource/dao/RsReportDao.java

@ -0,0 +1,36 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsReport;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * 资源报表 DAO
 *
 * @author 张进军
 * @created 2017.8.15 19:18
 */
public interface RsReportDao extends PagingAndSortingRepository<RsReport, Integer> {
    @Query(" FROM RsReport rc WHERE rc.id <> :id AND rc.code = :code ")
    RsReport isUniqueCode(@Param("id") Integer id, @Param("code") String code);
    @Query(" FROM RsReport rc WHERE rc.id <> :id AND rc.name = :name ")
    RsReport isUniqueName(@Param("id") Integer id, @Param("name") String name);
    RsReport findByCode(@Param("code") String code);
    List<RsReport> findByReportCategoryId(@Param("reportCategoryId") Integer reportCategoryId);
    @Query("FROM RsReport rc WHERE rc.status = 1 and rc.reportCategoryId =:reportCategoryId order by rc.showType asc")
    List<RsReport> findByReportCategoryIdAndStatus(@Param("reportCategoryId") Integer reportCategoryId);
    @Query("FROM RsReport rc WHERE rc.status = 1 and rc.id in (:ids)")
    List<RsReport> findByIds(@Param("ids") List<Integer> ids);
    @Query("select rc.position FROM RsReport rc WHERE rc.code = :code ")
    String findPositionByCode(@Param("code") String code);
}

+ 25 - 0
src/main/java/com/yihu/ehr/resource/dao/RsReportMonitorTypeDao.java

@ -0,0 +1,25 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsReportMonitorType;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * 资源报表监测分类 DAO
 *
 * @author janseny
 * @created 2017年11月7日15:27:28
 */
public interface RsReportMonitorTypeDao extends PagingAndSortingRepository<RsReportMonitorType, Integer> {
    @Query(" FROM RsReportMonitorType rc WHERE rc.id <> :id AND rc.name = :name ")
    RsReportMonitorType isUniqueName(@Param("id") Integer id, @Param("name") String name);
    @Query("from RsReportMonitorType rc WHERE rc.id in (:monitorTypeIds)")
    List<RsReportMonitorType> findById(@Param("monitorTypeIds") List<Integer> monitorTypeIds);
}

+ 22 - 0
src/main/java/com/yihu/ehr/resource/dao/RsReportUsersDao.java

@ -0,0 +1,22 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsReportUsers;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by wxw on 2018/7/31.
 */
public interface RsReportUsersDao extends PagingAndSortingRepository<RsReportUsers, Integer> {
    @Query("from RsReportUsers ru where ru.userId = :userId order by ru.sortNo asc")
    List<RsReportUsers> findByUserId(@Param("userId") String userId);
    @Modifying
    @Query("delete from RsReportUsers ru where ru.userId = :userId")
    int deleteByUserId(@Param("userId") String userId);
}

+ 29 - 0
src/main/java/com/yihu/ehr/resource/dao/RsReportViewDao.java

@ -0,0 +1,29 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsReportView;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * 资源报表视图配置 DAO
 *
 * @author 张进军
 * @created 2017.8.22 14:05
 */
public interface RsReportViewDao extends PagingAndSortingRepository<RsReportView, Integer> {
    List<RsReportView> findByReportId(Integer reportId);
    List<RsReportView> findByResourceId(String resourceId);
    RsReportView findByReportIdAndResourceId(Integer reportId, String resourceId);
    @Modifying
    @Query(" DELETE FROM RsReportView rv WHERE rv.reportId = :reportId")
    void deleteByReportId(@Param("reportId") Integer reportId);
}

+ 19 - 0
src/main/java/com/yihu/ehr/resource/dao/RsResourceCategoryDao.java

@ -0,0 +1,19 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsResourceCategory;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by lyr on 2016/5/4.
 */
public interface RsResourceCategoryDao extends PagingAndSortingRepository<RsResourceCategory, String> {
      long countByPid(String pid);
      List<RsResourceCategory> findByPid(String pid);
      List<RsResourceCategory> findByCode(String code);
      @Query("SELECT rsResourceCategory FROM RsResourceCategory rsResourceCategory WHERE rsResourceCategory.code = :code AND rsResourceCategory.pid = :pid" )
      List<RsResourceCategory> findByCodeAndPid(@Param("code") String code, @Param("pid") String pid);
}

+ 48 - 0
src/main/java/com/yihu/ehr/resource/dao/RsResourceDao.java

@ -0,0 +1,48 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsResource;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by lyr on 2016/4/25.
 */
public interface RsResourceDao extends PagingAndSortingRepository<RsResource, String> {
    RsResource findByCode(String code);
    RsResource findById(String id);
    long countByCategoryId(String categoryId);
    List<RsResource> findByCategoryId(String categoryId);
    //不受权限控制(JKZL超级管理员)
    List<RsResource> findByCategoryIdAndDataSource(String categoryId, Integer dataSource);
    @Query("SELECT rsResource FROM RsResource rsResource WHERE rsResource.categoryId = :categoryId AND rsResource.dataSource = :dataSource AND rsResource.name LIKE %:name%")
    List<RsResource> findByCategoryIdAndDataSourceAndName(
            @Param("categoryId") String categoryId,
            @Param("dataSource") Integer dataSource,
            @Param("name") String name);
    //受权限控制
    @Query("SELECT rsResource FROM RsResource rsResource WHERE (rsResource.categoryId = :categoryId AND rsResource.dataSource = :dataSource AND rsResource.id IN (:ids)) OR (rsResource.categoryId = :categoryId AND rsResource.dataSource = :dataSource AND rsResource.grantType = :grantType)")
    List<RsResource> findByCategoryIdAndDataSourceAndIdsOrGrantType(
            @Param("categoryId") String categoryId,
            @Param("dataSource") Integer dataSource,
            @Param("ids") String [] ids,
            @Param("grantType") String grantType);
    @Query("SELECT rsResource FROM RsResource rsResource WHERE ((rsResource.categoryId = :categoryId AND rsResource.dataSource = :dataSource AND rsResource.id IN (:ids)) OR (rsResource.categoryId = :categoryId AND rsResource.dataSource = :dataSource AND rsResource.grantType = :grantType)) AND rsResource.name LIKE %:name%")
    List<RsResource> findByCategoryIdAndDataSourceAndIdsOrGrantTypeAndName(
            @Param("categoryId") String categoryId,
            @Param("dataSource") Integer dataSource,
            @Param("ids") String [] ids,
            @Param("grantType") String grantType,
            @Param("name") String name);
    @Query("SELECT rsResource.id FROM RsResource rsResource WHERE rsResource.categoryId = :categoryId AND rsResource.dataSource = :dataSource ")
    List<String> findIdByCategoryIdAndDataSourceAndName(
            @Param("categoryId") String categoryId,
            @Param("dataSource") Integer dataSource);
}

+ 31 - 0
src/main/java/com/yihu/ehr/resource/dao/RsResourceDefaultParamDao.java

@ -0,0 +1,31 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsResourceDefaultParam;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
public interface RsResourceDefaultParamDao extends PagingAndSortingRepository<RsResourceDefaultParam, Long> {
    List<RsResourceDefaultParam> findByResourcesCode(String resourcesCode);
    void deleteByResourcesId(String resourcesId);
    void deleteByResourcesIdAndParamKey(String resourcesId, String paramKey);
    @Query("from RsResourceDefaultParam where resourcesId = ?1 or resourcesCode = ?2 ")
    List<RsResourceDefaultParam> findByResourcesIdOrResourcesCode(String resourcesId, String resourceCode);
    @Query("from RsResourceDefaultParam where ( resourcesId = ?1 or resourcesCode = ?2 ) and paramKey = ?3 ")
    List<RsResourceDefaultParam> findByResourcesIdOrResourcesCodeWithParamKey(String resourceId, String resourceCode , String ParamKey);
    @Query("select rdf from RsResourceDefaultParam rdf where rdf.id = :id")
    RsResourceDefaultParam findById(@Param("id") String id);
}

+ 14 - 0
src/main/java/com/yihu/ehr/resource/dao/RsResourceDefaultQueryDao.java

@ -0,0 +1,14 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsResourceDefaultQuery;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Sxy on 2017/08/04.
 */
public interface RsResourceDefaultQueryDao extends PagingAndSortingRepository<RsResourceDefaultQuery, String> {
    RsResourceDefaultQuery findById(String id);
    RsResourceDefaultQuery findByResourcesId(String resourcesId);
    void deleteByResourcesId(String resourcesId);
}

+ 21 - 0
src/main/java/com/yihu/ehr/resource/dao/RsResourceMetadataDao.java

@ -0,0 +1,21 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsResourceMetadata;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by lyr on 2016/4/25.
 */
public interface RsResourceMetadataDao extends PagingAndSortingRepository<RsResourceMetadata, String>{
    void deleteByResourcesId(String resourcesId);
    List<RsResourceMetadata> findByResourcesId(String resourcesId);
    @Query(value="delete from RsResourceMetadata rm where rm.resourcesId in (:resourcesIds)",nativeQuery=true)
    void deleteByResourcesIds(@Param("resourcesIds") String[] resourcesIds);
}

+ 36 - 0
src/main/java/com/yihu/ehr/resource/dao/RsResourceQuotaDao.java

@ -0,0 +1,36 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsResourceQuota;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by Administrator on 2017/8/10.
 */
public interface RsResourceQuotaDao extends PagingAndSortingRepository<RsResourceQuota,Integer> {
    @Query("delete from RsResourceQuota rq where rq.resourceId = :resourceId")
    @Modifying
    int deleteByResourceId(@Param("resourceId") String resourceId);
    @Query("select rq.quotaChart from RsResourceQuota rq where rq.quotaId = :quotaId and rq.resourceId = :resourceId")
    List<Integer> findQuotaChartByQuotaId(@Param("quotaId")Integer quotaId, @Param("resourceId") String resourceId);
    @Query("select rq.quotaId from RsResourceQuota rq where rq.resourceId = :resourceId")
    List<Integer> findQuotaIdByResourceId(@Param("resourceId") String resourceId);
    @Query("select rq from RsResourceQuota rq where rq.resourceId = :resourceId and rq.pid = :pid")
    List<RsResourceQuota> findChildByPidAndResourceId(@Param("resourceId") String resourceId, @Param("pid") Integer pid);
    @Query(" FROM RsResourceQuota rq WHERE rq.resourceId = :resourceId and rq.pid = null ")
    List<RsResourceQuota> getTopParents(@Param("resourceId") String resourceId);
    @Query("select  rq FROM RsResourceQuota rq WHERE rq.resourceId = :resourceId and rq.quotaId = :quotaId")
    RsResourceQuota findByResourceIdAndQuotaId(@Param("resourceId")String resourceId, @Param("quotaId")Integer quotaId);
    List<RsResourceQuota> findByResourceId(String resourceId);
}

+ 22 - 0
src/main/java/com/yihu/ehr/resource/dao/RsRolesResourceDao.java

@ -0,0 +1,22 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsRolesResource;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * Created by zdm on 2017/6/15
 */
public interface RsRolesResourceDao extends PagingAndSortingRepository<RsRolesResource, String> {
    RsRolesResource findByResourceIdAndRolesId(String resourceId, String roleId);
    @Query("select ar.id FROM RsRolesResource ar WHERE ar.resourceId=:resourceId AND ar.rolesId=:rolesId ")
    List<String> findIdByResourceIdAndRolesId(@Param("resourceId")String resourceId, @Param("rolesId")String rolesId);
    List<RsRolesResource> findByResourceId(String resourceId);
    void deleteByResourceId(String resourceId);
}

+ 14 - 0
src/main/java/com/yihu/ehr/resource/dao/RsRolesResourceMetadataDao.java

@ -0,0 +1,14 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsRolesResourceMetadata;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by zdm on 2017/6/16
 */
public interface RsRolesResourceMetadataDao extends PagingAndSortingRepository<RsRolesResourceMetadata, String> {
     void deleteByRolesResourceId(String rolesResourceId);
     List<RsRolesResourceMetadata> findByRolesResourceIdAndValid(String rolesResourceId, String valid);
}

+ 11 - 0
src/main/java/com/yihu/ehr/resource/dao/RsSystemDictionaryDao.java

@ -0,0 +1,11 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsSystemDictionary;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
public interface RsSystemDictionaryDao extends PagingAndSortingRepository<RsSystemDictionary,String> {
}

+ 11 - 0
src/main/java/com/yihu/ehr/resource/dao/RsSystemDictionaryEntryDao.java

@ -0,0 +1,11 @@
package com.yihu.ehr.resource.dao;
import com.yihu.ehr.resource.model.RsSystemDictionaryEntry;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author linaz
 * @created 2016.05.17 16:33
 */
public interface RsSystemDictionaryEntryDao extends PagingAndSortingRepository<RsSystemDictionaryEntry,String> {
}

+ 32 - 0
src/main/java/com/yihu/ehr/resource/feign/StandClient.java

@ -0,0 +1,32 @@
package com.yihu.ehr.resource.feign;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.MicroServices;
import com.yihu.ehr.constants.ServiceApi;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
/**
 * @author hzp
 * @created 2017.05.16
 */
@ApiIgnore
@FeignClient(name = MicroServices.Standard)
@RequestMapping(ApiVersion.Version1_0)
public interface StandClient {
    @RequestMapping(value = ServiceApi.Standards.AdaptMeta, method = RequestMethod.GET)
    @ApiOperation(value = "获取ehr适配的数据元", notes = "获取ehr适配的数据元")
    public List<Map<String, Object>> getEhrAdapterMetadata(@RequestParam(value = "version") String version);
    @RequestMapping(value = ServiceApi.Standards.AdaptDict, method = RequestMethod.GET)
    @ApiOperation(value = "获取ehr适配的字典", notes = "获取ehr适配的字典")
    public List<Map<String, Object>> getEhrAdapterDict(@RequestParam(value = "version") String version);
}

+ 68 - 0
src/main/java/com/yihu/ehr/resource/feign/StdRedisClient.java

@ -0,0 +1,68 @@
package com.yihu.ehr.resource.feign;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.MicroServices;
import com.yihu.ehr.constants.ServiceApi;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
/**
 * @author hzp
 * @created 2017.04.28
 */
@ApiIgnore
@FeignClient(name = MicroServices.StdRedis)
@RequestMapping(ApiVersion.Version1_0)
public interface StdRedisClient {
    //("获取标准版本 redis")
    @RequestMapping(value = ServiceApi.Redis.StdVersion, method = RequestMethod.GET)
    public String getStdVersion(@RequestParam("key") String key);
    //("获取标准数据集代码 redis")
    @RequestMapping(value = ServiceApi.Redis.StdDataSetCode, method = RequestMethod.GET)
    public String getDataSetCode(@RequestParam("version") String version,
                                 @RequestParam("id") String id);
    //("获取标准数据集名称通过ID redis")
    @RequestMapping(value = ServiceApi.Redis.StdDataSetName, method = RequestMethod.GET)
    public String getDataSetName(@RequestParam("version") String version,
                                 @RequestParam("id") String id);
    //("获取标准数据集名称通过Code redis")
    @RequestMapping(value = ServiceApi.Redis.StdDataSetNameByCode, method = RequestMethod.GET)
    public String getDataSetNameByCode(@RequestParam("version") String version,
                                       @RequestParam("code") String code);
    //("获取标准数据集--主从表 redis")
    @RequestMapping(value = ServiceApi.Redis.StdDataSetMultiRecord, method = RequestMethod.GET)
    public String getDataSetMultiRecord(@RequestParam("version") String version,
                                        @RequestParam("code") String code);
    //("获取标准数据元对应类型 redis")
    @RequestMapping(value = ServiceApi.Redis.StdMetadataType, method = RequestMethod.GET)
    public String getMetaDataType(@RequestParam("version") String version,
                                  @RequestParam("dataSetCode") String dataSetCode,
                                  @RequestParam("innerCode") String innerCode);
    //("获取标准数据元对应字典 redis")
    @RequestMapping(value = ServiceApi.Redis.StdMetadataDict, method = RequestMethod.GET)
    public String getMetaDataDict(@RequestParam("version") String version,
                                  @RequestParam("dataSetCode") String dataSetCode,
                                  @RequestParam("innerCode") String innerCode);
    //("获取标准数据字典对应值 redis")
    @RequestMapping(value = ServiceApi.Redis.StdDictEntryValue, method = RequestMethod.GET)
    public String getDictEntryValue(@RequestParam("version") String version,
                                    @RequestParam("dictId") String dictId,
                                    @RequestParam("entryCode") String entryCode);
}

+ 139 - 0
src/main/java/com/yihu/ehr/resource/job/SurveyTask.java

@ -0,0 +1,139 @@
package com.yihu.ehr.resource.job;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.model.portal.MTemplateContent;
import com.yihu.ehr.resource.model.PortalMessageTemplate;
import com.yihu.ehr.resource.model.ProtalMessageRemind;
import com.yihu.ehr.resource.model.Registration;
import com.yihu.ehr.resource.service.PortalMessageRemindService;
import com.yihu.ehr.resource.service.PortalMessageTemplateService;
import com.yihu.ehr.resource.service.ResourceBrowseService;
import com.yihu.ehr.solr.SolrUtil;
import com.yihu.ehr.util.datetime.DateUtil;
import com.yihu.ehr.util.reflection.MethodUtil;
import com.yihu.ehr.util.rest.Envelop;
import org.apache.poi.util.StringUtil;
import org.apache.solr.common.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.*;
/**
 * 健康上饶app、公众健康服务平台-满意度调查
 * Created by zdm  on 2018/4/20.
 */
@Component
public class SurveyTask {
    @Autowired
    private ResourceBrowseService resourceBrowseService;
    @Autowired
    private SolrUtil solrUtil;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private PortalMessageRemindService messageRemindService;
    @Autowired
    private PortalMessageTemplateService messageTemplateService;
    /**
     * 应用ID
     */
    @Value("${h5.clientId}")
    public String clientId;
    @Scheduled(cron = "0 0 7 * * ?")
    private void startTask() throws  Exception{
        //检索条件
        String date = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
        String queryParams = "create_date:["+date+"T00:00:00Z  TO "+date+ "T23:59:59Z"+"] AND event_type: \"0\"";
        int count = (int)(solrUtil.count("HealthProfile", queryParams));
        int size = 1000;
        int totalPages = count%size == 0 ? count/size : (count/size)+1;
        ProtalMessageRemind messageRemind = null;
        for(int i=0; i<totalPages ;i++){
            //查找档案
            queryParams = "{\"q\":\"create_date:["+date+"T00:00:00Z TO "+date+ "T23:59:59Z] AND event_type:0\"}";
            Envelop envelop = resourceBrowseService.getEhrCenter(null, "*", "*", queryParams, i + 1, size);
            List list = envelop.getDetailModelList();
            List<Map<String, String>> contentList = new ArrayList<>();
            Registration newEntity = null;
            if(null != list && list.size()>0){
                //获取消息模板
                List<PortalMessageTemplate> messageTemplateList = messageTemplateService.getMessageTemplate("0","100","0");
                List<MTemplateContent> mTemplateContents = null;
                if(null != messageTemplateList && messageTemplateList.size()>0) {
                    PortalMessageTemplate template = messageTemplateList.get(0);
                    mTemplateContents = JSON.parseArray(template.getContent(), MTemplateContent.class);
                    for (Object obj : list) {
                        Map<String, Object> map = (Map) obj;
                        newEntity = new Registration();
                        //身份证号码 没有用户id 表示该用户未注册
                        String userId = "";
                        if (null != map.get("EHR_000017") && !StringUtils.isEmpty(map.get("EHR_000017").toString())) {
                            newEntity.setCardNo(map.get("EHR_000017").toString());
                            userId = messageTemplateService.getUserIdByIdCardNo(newEntity.getCardNo());
                        }
                        if (!StringUtils.isEmpty(userId)) {
                            if (null != map.get("org_name")) {
                                newEntity.setHospitalName(map.get("org_name").toString());
                            }
                            if (null != map.get("EHR_000082")) {
                                newEntity.setDeptName(map.get("EHR_000082").toString());
                            }
                            if (null != map.get("EHR_000079")) {
                                newEntity.setDoctorName(map.get("EHR_000079").toString());
                            }
                            if (null != map.get("EHR_000065")) {
                                newEntity.setRegisterDate(map.get("EHR_000065").toString());
                            }
                            if (null != map.get("EHR_000004")) {
                                newEntity.setPatientName(map.get("EHR_000004").toString());
                            }
                        for (MTemplateContent content : mTemplateContents) {
                            String value = "";
                            if (null != newEntity) {
                                value = String.valueOf(MethodUtil.invokeGet(newEntity, content.getCode())) == null ? "" : String.valueOf(MethodUtil.invokeGet(newEntity, content.getCode()));
                            }
                            if (value.equals("null")) {
                                value = "";
                            }
                            Map<String, String> maps = new LinkedHashMap<>();
                            maps.put("code", content.getCode());
                            maps.put("name", content.getName());
                            maps.put("value", value);
                            contentList.add(maps);
                        }
                        String contentJson = JSON.toJSONString(contentList);
                        messageRemind = new ProtalMessageRemind();
                        messageRemind.setAppId(clientId);
                        messageRemind.setAppName("健康上饶App");
                        messageRemind.setFromUserId("system");
                        messageRemind.setCreateDate(new Date());
                        messageRemind.setNotifieFlag("0");//未评价
                        messageRemind.setPortalMessagerTemplateType("100");
                        messageRemind.setTypeId("7");//健康上饶App消息固定值
                        messageRemind.setWorkUri("");
                        messageRemind.setMessageTemplateId(template.getId());
                        messageRemind.setReaded(0);//未读
                        messageRemind.setToUserId(userId);
                        messageRemind.setContent(contentJson);
                        messageRemind.setAppraiseFlag("0");
                        messageRemindService.save(messageRemind);
                    }
                }
                }else{
                    throw  new Exception("消息模板不存在!");
                }
            }
        }
    }
}

+ 36 - 0
src/main/java/com/yihu/ehr/resource/model/DtoResourceMetadata.java

@ -0,0 +1,36 @@
package com.yihu.ehr.resource.model;
/**
 * Created by hzp on 2016/5/14.
 */
public class DtoResourceMetadata extends RsMetadata {
    private String groupType; //分组类型
    private String groupData; //分组数据
    private String dimensionValue; //维度范围
    public String getGroupType() {
        return groupType;
    }
    public void setGroupType(String groupType) {
        this.groupType = groupType;
    }
    public String getGroupData() {
        return groupData;
    }
    public void setGroupData(String groupData) {
        this.groupData = groupData;
    }
    public String getDimensionValue() {
        return dimensionValue;
    }
    public void setDimensionValue(String dimensionValue) {
        this.dimensionValue = dimensionValue;
    }
}

+ 111 - 0
src/main/java/com/yihu/ehr/resource/model/PortalMessageTemplate.java

@ -0,0 +1,111 @@
package com.yihu.ehr.resource.model;
import javax.persistence.*;
/**
 * @author zdm
 * @since 2018.04.21
 */
@Entity
@Table(name = "portal_message_template", schema = "", catalog = "healtharchive")
public class PortalMessageTemplate {
    private Long id;
    /**
     * 消息分类
     */
    private String classification;
    /**
     * 消息标题
     */
    private String title;
    /**
     * 主体之前内容
     */
    private String beforeContent;
    /**
     * 主体内容
     */
    private String content;
    /**
     * 主体之后内容
     */
    private String afterContent;
    /**
     * 部推送类型 ,101:挂号结果推送,102:退号结果推送,-101:订单操作推送
     */
    private String type;
    /**
     * 模板状态:0生效,1失效
     */
    private String state;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getClassification() {
        return classification;
    }
    public void setClassification(String classification) {
        this.classification = classification;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getBeforeContent() {
        return beforeContent;
    }
    public void setBeforeContent(String beforeContent) {
        this.beforeContent = beforeContent;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getAfterContent() {
        return afterContent;
    }
    public void setAfterContent(String afterContent) {
        this.afterContent = afterContent;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
}

+ 195 - 0
src/main/java/com/yihu/ehr/resource/model/ProtalMessageRemind.java

@ -0,0 +1,195 @@
package com.yihu.ehr.resource.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.*;
import java.util.Date;
/**
 * 健康上饶app、公众健康服务平台-满意度调查
 *
 * @author zdm
 * @vsrsion 1.0
 * Created at 2018/4/20.
 */
@Entity
@Table(name = "portal_message_remind", schema = "", catalog = "healtharchive")
public class ProtalMessageRemind {
    private Long id;
    private String appId;
    private String appName;
    private String fromUserId;
    private String typeId;
    private String content;
    private String workUri;
    private Integer readed;
    private Date createDate;
    private String toUserId;
    private Long messageTemplateId;
    /**
     * 推送过来的消息
     */
    private String receivedMessages;
    /**
     * 就诊时间
     */
    private String visitTime;
    /**
     * 健康之路-预约挂号订单号
     */
    private String orderId;
    /**
     * 我的就诊-是否通知:0为通知,1为不通知。我的档案:0未评价、1为已评价
     */
    private String notifieFlag;
    /**
     * 总部推送消息类型 ,101:挂号结果推送,102:退号结果推送,-101:订单操作推送,100:满意度调查
     */
    private String portalMessagerTemplateType;
    /**
     * 满意度调查-是否评价 0为未评、1为已评
     */
    private String appraiseFlag;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Column(name = "app_id", nullable = true, insertable = true, updatable = true)
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    @Column(name = "app_name", nullable = true, insertable = true, updatable = true)
    public String getAppName() {
        return appName;
    }
    public void setAppName(String appName) {
        this.appName = appName;
    }
    @Column(name = "from_user_id", nullable = true, insertable = true, updatable = true)
    public String getFromUserId() {
        return fromUserId;
    }
    public void setFromUserId(String fromUserId) {
        this.fromUserId = fromUserId;
    }
    @Column(name = "type_id", nullable = true, insertable = true, updatable = true)
    public String getTypeId() {
        return typeId;
    }
    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }
    @Column(name = "content", nullable = true, insertable = true, updatable = true)
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "work_uri", nullable = true, insertable = true, updatable = true)
    public String getWorkUri() {
        return workUri;
    }
    public void setWorkUri(String workUri) {
        this.workUri = workUri;
    }
    @Column(name = "readed", nullable = true, insertable = true, updatable = true)
    public Integer getReaded() {
        return readed;
    }
    public void setReaded(Integer readed) {
        this.readed = readed;
    }
    @Column(name = "create_date", nullable = true, insertable = true, updatable = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getCreateDate() {
        return createDate;
    }
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
    @Column(name = "to_user_id", nullable = true, insertable = true, updatable = true)
    public String getToUserId() {
        return toUserId;
    }
    public void setToUserId(String toUserId) {
        this.toUserId = toUserId;
    }
    @Column(name = "message_template_id", nullable = true, insertable = true, updatable = true)
    public Long getMessageTemplateId() {
        return messageTemplateId;
    }
    public void setMessageTemplateId(Long messageTemplateId) {
        this.messageTemplateId = messageTemplateId;
    }
    @Column(name = "received_messages", nullable = true, insertable = true, updatable = true)
    public String getReceivedMessages() {
        return receivedMessages;
    }
    public void setReceivedMessages(String receivedMessages) {
        this.receivedMessages = receivedMessages;
    }
    @Column(name = "visit_time", nullable = true, insertable = true, updatable = true)
    public String getVisitTime() {
        return visitTime;
    }
    public void setVisitTime(String visitTime) {
        this.visitTime = visitTime;
    }
    @Column(name = "order_id", nullable = true, insertable = true, updatable = true)
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    @Column(name = "notifie_flag", nullable = true, insertable = true, updatable = true)
    public String getNotifieFlag() {
        return notifieFlag;
    }
    public void setNotifieFlag(String notifieFlag) {
        this.notifieFlag = notifieFlag;
    }
    @Column(name = "portal_messager_template_type", nullable = true, insertable = true, updatable = true)
    public String getPortalMessagerTemplateType() {
        return portalMessagerTemplateType;
    }
    public void setPortalMessagerTemplateType(String portalMessagerTemplateType) {
        this.portalMessagerTemplateType = portalMessagerTemplateType;
    }
    @Column(name = "appraise_flag", nullable = true, insertable = true, updatable = true)
    public String getAppraiseFlag() {
        return appraiseFlag;
    }
    public void setAppraiseFlag(String appraiseFlag) {
        this.appraiseFlag = appraiseFlag;
    }
}

+ 300 - 0
src/main/java/com/yihu/ehr/resource/model/Registration.java

@ -0,0 +1,300 @@
package com.yihu.ehr.resource.model;
import com.yihu.ehr.entity.BaseAssignedEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 挂号单
 *
 * @author 张进军
 * @date 2018/4/16 19:18
 */
@Entity
@Table(name = "registration")
public class Registration extends BaseAssignedEntity {
    public String orderId; // 订单号
    public String orderCreateTime; // 下单时间
    public String userId; // 患者ID
    public String patientName; // 患者姓名
    public Integer cardType; // 患者证件类型,默认身份证,1:中国大陆身份证
    public String cardNo; // 患者证件号
    public String phoneNo; // 患者手机号
    public String hospitalId; // 医院ID
    public String hospitalName; // 医院名称
    public String deptId; // 科室ID
    public String deptName; // 科室名称
    public String doctorId; // 医生ID
    public String doctorName; // 医生姓名
    public String lczcName; // 临床职称名称
    public String photoUri; // 医生头像URL
    public Integer state; // 订单状态。1:待付款  2:待就诊 11:预约中 22:退款中 99:已退号 -1:系统取消 3:已就诊
    public String stateDesc; // 订单状态描述
    public Integer visitClinicResult; // 到诊情况。0:确认中,1:已到诊,-1:爽约。(医院如果未提供到诊信息,该返回值将永远处于确认中)
    public String visitClinicResultDesc; // 到诊情况描述
    public String registerDate; // 就诊时间
    public Integer timeId; // 就诊午别。1:上午,2:下午,3:晚上
    public String timeIdDesc; // 就诊午别描述
    public String commendTime; // 就诊时间段
    public Integer serialNo; // 就诊号数
    public String invalidDate; // 退号截止时间(与预约截止时间相同)
    public Integer originType; // 来源类型,1:PC,2:APP
    public Integer registerType; // 挂号方式,1:预约挂号,2:现场挂号
    public String registerTypeDesc; // 挂号方式描述
    @Column(name = "order_id")
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    @Column(name = "order_create_time")
    public String getOrderCreateTime() {
        return orderCreateTime;
    }
    public void setOrderCreateTime(String orderCreateTime) {
        this.orderCreateTime = orderCreateTime;
    }
    @Column(name = "user_id")
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "card_type")
    public Integer getCardType() {
        return cardType;
    }
    public void setCardType(Integer cardType) {
        this.cardType = cardType;
    }
    @Column(name = "card_no")
    public String getCardNo() {
        return cardNo;
    }
    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }
    @Column(name = "phone_no")
    public String getPhoneNo() {
        return phoneNo;
    }
    public void setPhoneNo(String phoneNo) {
        this.phoneNo = phoneNo;
    }
    @Column(name = "hospital_id")
    public String getHospitalId() {
        return hospitalId;
    }
    public void setHospitalId(String hospitalId) {
        this.hospitalId = hospitalId;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "dept_id")
    public String getDeptId() {
        return deptId;
    }
    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Column(name = "doctor_id")
    public String getDoctorId() {
        return doctorId;
    }
    public void setDoctorId(String doctorId) {
        this.doctorId = doctorId;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "lczc_name")
    public String getLczcName() {
        return lczcName;
    }
    public void setLczcName(String lczcName) {
        this.lczcName = lczcName;
    }
    @Column(name = "photo_uri")
    public String getPhotoUri() {
        return photoUri;
    }
    public void setPhotoUri(String photoUri) {
        this.photoUri = photoUri;
    }
    @Column(name = "state")
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    @Column(name = "state_desc")
    public String getStateDesc() {
        return stateDesc;
    }
    public void setStateDesc(String stateDesc) {
        this.stateDesc = stateDesc;
    }
    @Column(name = "visit_clinic_result")
    public Integer getVisitClinicResult() {
        return visitClinicResult;
    }
    public void setVisitClinicResult(Integer visitClinicResult) {
        this.visitClinicResult = visitClinicResult;
    }
    @Column(name = "visit_clinic_result_desc")
    public String getVisitClinicResultDesc() {
        return visitClinicResultDesc;
    }
    public void setVisitClinicResultDesc(String visitClinicResultDesc) {
        this.visitClinicResultDesc = visitClinicResultDesc;
    }
    @Column(name = "register_date")
    public String getRegisterDate() {
        return registerDate;
    }
    public void setRegisterDate(String registerDate) {
        this.registerDate = registerDate;
    }
    @Column(name = "time_id")
    public Integer getTimeId() {
        return timeId;
    }
    public void setTimeId(Integer timeId) {
        this.timeId = timeId;
    }
    @Column(name = "time_id_desc")
    public String getTimeIdDesc() {
        return timeIdDesc;
    }
    public void setTimeIdDesc(String timeIdDesc) {
        this.timeIdDesc = timeIdDesc;
    }
    @Column(name = "commend_time")
    public String getCommendTime() {
        return commendTime;
    }
    public void setCommendTime(String commendTime) {
        this.commendTime = commendTime;
    }
    @Column(name = "serial_no")
    public Integer getSerialNo() {
        return serialNo;
    }
    public void setSerialNo(Integer serialNo) {
        this.serialNo = serialNo;
    }
    @Column(name = "invalid_date")
    public String getInvalidDate() {
        return invalidDate;
    }
    public void setInvalidDate(String invalidDate) {
        this.invalidDate = invalidDate;
    }
    @Column(name = "origin_type")
    public Integer getOriginType() {
        return originType;
    }
    public void setOriginType(Integer originType) {
        this.originType = originType;
    }
    @Column(name = "register_type")
    public Integer getRegisterType() {
        return registerType;
    }
    public void setRegisterType(Integer registerType) {
        this.registerType = registerType;
    }
    @Column(name = "register_type_desc")
    public String getRegisterTypeDesc() {
        return registerTypeDesc;
    }
    public void setRegisterTypeDesc(String registerTypeDesc) {
        this.registerTypeDesc = registerTypeDesc;
    }
}

+ 34 - 0
src/main/java/com/yihu/ehr/resource/model/ResourceQuotaJson.java

@ -0,0 +1,34 @@
package com.yihu.ehr.resource.model;
/**
 * Created by Administrator on 2017/12/19.
 */
public class ResourceQuotaJson {
    private String resourceId;
    private Integer quotaId;
    private Integer pid;
    public String getResourceId() {
        return resourceId;
    }
    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }
    public Integer getQuotaId() {
        return quotaId;
    }
    public void setQuotaId(Integer quotaId) {
        this.quotaId = quotaId;
    }
    public Integer getPid() {
        return pid;
    }
    public void setPid(Integer pid) {
        this.pid = pid;
    }
}

+ 19 - 0
src/main/java/com/yihu/ehr/resource/model/ResourcesInterface.java

@ -0,0 +1,19 @@
package com.yihu.ehr.resource.model;
/**
 * Created by hzp on 2016/04/22.
 */
public class ResourcesInterface {
    public static final String EHR_CENTER = "getEhrCenter";
    public static final String EHR_CENTER_SUB = "getEhrCenterSub";
    public static final String Mysql = "getMysqlData";
    public static final String RS_ETL = "4";
    public static final String RS_CONFIG = "5";
    public static final String RS_DICT = "6";
}

+ 19 - 0
src/main/java/com/yihu/ehr/resource/model/ResourcesType.java

@ -0,0 +1,19 @@
package com.yihu.ehr.resource.model;
/**
 * Created by hzp on 2016/04/22.
 */
public class ResourcesType {
    public static final String HBASE_SINGLE_CORE = "1";
    public static final String HBASE_MULTI_CORE = "2";
    public static final String HBASE_SOLR = "3";
    public static final String RS_ETL = "4";
    public static final String RS_CONFIG = "5";
    public static final String RS_DICT = "6";
}

+ 79 - 0
src/main/java/com/yihu/ehr/resource/model/RsAdapterDictionary.java

@ -0,0 +1,79 @@
package com.yihu.ehr.resource.model;
import javax.persistence.*;
/**
 * @author linaz
 * @created 2016.05.30 13:48
 */
@Entity
@Table(name="rs_adapter_dictionary")
@Access(value = AccessType.PROPERTY)
public class RsAdapterDictionary {
    private String id;
    private String schemeId;
    private String dictCode;
    private String dictEntryCode;
    private String srcDictCode;
    private String srcDictEntryCode;
    private String srcDictEntryName;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="id",nullable = false,unique = true)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    @Column(name="scheme_id",nullable = false)
    public String getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(String schemeId) {
        this.schemeId = schemeId;
    }
    @Column(name="dict_code",nullable = true)
    public String getDictCode() {
        return dictCode;
    }
    public void setDictCode(String dictCode) {
        this.dictCode = dictCode;
    }
    @Column(name="dict_entry_code",nullable = true)
    public String getDictEntryCode() {
        return dictEntryCode;
    }
    public void setDictEntryCode(String dictEntryCode) {
        this.dictEntryCode = dictEntryCode;
    }
    @Column(name="src_dict_code",nullable = false)
    public String getSrcDictCode() {
        return srcDictCode;
    }
    public void setSrcDictCode(String srcDictCode) {
        this.srcDictCode = srcDictCode;
    }
    @Column(name="src_dict_entry_code",nullable = false)
    public String getSrcDictEntryCode() {
        return srcDictEntryCode;
    }
    public void setSrcDictEntryCode(String srcDictEntryCode) {
        this.srcDictEntryCode = srcDictEntryCode;
    }
    @Column(name="src_dict_entry_name",nullable = true)
    public String getSrcDictEntryName() {
        return srcDictEntryName;
    }
    public void setSrcDictEntryName(String srcDictEntryName) {
        this.srcDictEntryName = srcDictEntryName;
    }
}

+ 78 - 0
src/main/java/com/yihu/ehr/resource/model/RsAdapterMetadata.java

@ -0,0 +1,78 @@
package com.yihu.ehr.resource.model;
import javax.persistence.*;
/**
 * 适配数据元
 *
 * Created by lyr on 2016/5/17.
 */
@Entity
@Table(name="rs_adapter_metadata")
public class RsAdapterMetadata {
    private String id;
    private String schemeId;
    private String metadataId;
    private String srcDatasetCode;
    private String srcMetadataCode;
    private String srcMetadataName;
    private String metadataDomain;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="id",nullable = false,unique = true)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    @Column(name="scheme_id",nullable = false)
    public String getSchemeId() {
        return schemeId;
    }
    public void setSchemeId(String schemeId) {
        this.schemeId = schemeId;
    }
    @Column(name="metadata_id")
    public String getMetadataId() {
        return metadataId;
    }
    public void setMetadataId(String metadataId) {
        this.metadataId = metadataId;
    }
    @Column(name="src_dataset_code",nullable = false)
    public String getSrcDatasetCode() {
        return srcDatasetCode;
    }
    public void setSrcDatasetCode(String srcDatasetCode) {
        this.srcDatasetCode = srcDatasetCode;
    }
    @Column(name="src_metadata_code")
    public String getSrcMetadataCode() {
        return srcMetadataCode;
    }
    public void setSrcMetadataCode(String srcMetadataCode) {
        this.srcMetadataCode = srcMetadataCode;
    }
    @Column(name="src_metadata_name")
    public String getSrcMetadataName() {
        return srcMetadataName;
    }
    public void setSrcMetadataName(String srcMetadataName) {
        this.srcMetadataName = srcMetadataName;
    }
    @Column(name="metadata_domain")
    public String getMetadataDomain() {
        return metadataDomain;
    }
    public void setMetadataDomain(String metadataDomain) {
        this.metadataDomain = metadataDomain;
    }
}

+ 73 - 0
src/main/java/com/yihu/ehr/resource/model/RsAdapterScheme.java

@ -0,0 +1,73 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * 资源适配方案实体
 *
 * Created by lyr on 2016/5/17.
 */
@Entity
@Table(name="rs_adapter_scheme")
public class RsAdapterScheme {
    private String id;
    private String type;
    private String name;
    private String code;
    private String adapterVersion;
    private String description;
    @Id
    @GeneratedValue(generator="Generator")
    @GenericGenerator(name="Generator",strategy = "assigned")
    @Column(name="id",nullable = false,unique = true)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    @Column(name="type",nullable = false)
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name="name",nullable = false)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name="code",nullable = false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name="adapter_version")
    public String getAdapterVersion() {
        return adapterVersion;
    }
    public void setAdapterVersion(String adapterVersion) {
        this.adapterVersion = adapterVersion;
    }
    @Column(name="description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 58 - 0
src/main/java/com/yihu/ehr/resource/model/RsDictionary.java

@ -0,0 +1,58 @@
package com.yihu.ehr.resource.model;
import javax.persistence.*;
/**
 * 资源字典
 *
 * Created by lyr on 2016/5/13.
 */
@Entity
@Table(name="rs_dictionary")
public class RsDictionary {
    private int id;
    private String code;
    private String name;
    private String description;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    @Column(name = "code",nullable = false)
    public String getCode()
    {
        return code;
    }
    public void setCode(String code)
    {
        this.code = code;
    }
    @Column(name="name",nullable = false)
    public String getName()
    {
        return name;
    }
    public void setName(String name)
    {
        this.name = name;
    }
    @Column(name="description")
    public String getDescription()
    {
        return description;
    }
    public void setDescription(String description)
    {
        this.description = description;
    }
}

+ 80 - 0
src/main/java/com/yihu/ehr/resource/model/RsDictionaryEntry.java

@ -0,0 +1,80 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * 资源字典项
 *
 * Created by lyr on 2016/5/13.
 */
@Entity
@Table(name = "rs_dictionary_entry")
public class RsDictionaryEntry {
    private int id;
    private int dictId;
    private String dictCode;
    private String code;
    private String name;
    private String description;
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name = "Generator", strategy = "increment")
    @Column(name = "id", unique = true, nullable = false)
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    @Column(name = "dict_id",nullable = false)
    public Integer getDictId() {
        return dictId;
    }
    public void setDictId(int dictId) {
        this.dictId = dictId;
    }
    @Column(name = "dict_code",nullable = false)
    public String getDictCode()
    {
        return dictCode;
    }
    public void setDictCode(String dictCode)
    {
        this.dictCode = dictCode;
    }
    @Column(name = "code",nullable = false)
    public String getCode()
    {
        return code;
    }
    public void setCode(String code)
    {
        this.code = code;
    }
    @Column(name="name",nullable = false)
    public String getName()
    {
        return name;
    }
    public void setName(String name)
    {
        this.name = name;
    }
    @Column(name="description")
    public String getDescription()
    {
        return description;
    }
    public void setDescription(String description)
    {
        this.description = description;
    }
}

+ 82 - 0
src/main/java/com/yihu/ehr/resource/model/RsDimension.java

@ -0,0 +1,82 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * Created by lyr on 2016/4/25.
 */
@Entity
@Table(name="rs_dimension")
public class RsDimension {
    private String id;
    private String code;
    private String name;
    private String categoryId;
    private String type;
    private String dictCode;
    private String description;
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name="Generator",strategy = "assigned")
    @Column(name="id",unique = true,nullable = false)
    public String getId(){
        return id;
    }
    public void setId(String id){
        this.id = id;
    }
    @Column(name="code",nullable = false)
    public String getCode(){
        return code;
    }
    public void setCode(String code)
    {
        this.code = code;
    }
    @Column(name="name",nullable = false)
    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name = name;
    }
    @Column(name="category_id",nullable = false)
    public String getCategoryId()
    {
        return categoryId;
    }
    public void setCategoryId(String categoryId)
    {
        this.categoryId = categoryId;
    }
    @Column(name="type",nullable = false)
    public String getType(){
        return type;
    }
    public void setType(String type){
        this.type = type;
    }
    @Column(name="dict_code")
    public String getDictCode()
    {
        return dictCode;
    }
    public void setDictCode(String dictCode){
        this.dictCode = dictCode;
    }
    @Column(name="description")
    public String getDescription(){
        return description;
    }
    public void setDescription(String description){
        this.description =  description;
    }
}

+ 60 - 0
src/main/java/com/yihu/ehr/resource/model/RsDimensionCategory.java

@ -0,0 +1,60 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * Created by lyr on 2016/4/25.
 */
@Entity
@Table(name="rs_dimension_category")
public class RsDimensionCategory {
    private String id;
    private String name;
    private String pid;
    private String description;
    @Id
    @GeneratedValue(generator="Generator")
    @GenericGenerator(name="Generator",strategy = "assigned")
    @Column(name="id",unique = true,nullable = false)
    public String getId()
    {
        return id;
    }
    public void setId(String id)
    {
        this.id = id;
    }
    @Column(name="name",nullable = false)
    public String getName()
    {
        return name;
    }
    public void setName(String name){
        this.name = name;
    }
    @Column(name="pid")
    public String getPid()
    {
        return pid;
    }
    public void setPid(String pid)
    {
        this.pid = pid;
    }
    @Column(name="description")
    public String getDescription()
    {
        return description;
    }
    public void setDescription(String description)
    {
        this.description = description;
    }
}

+ 72 - 0
src/main/java/com/yihu/ehr/resource/model/RsInterface.java

@ -0,0 +1,72 @@
package com.yihu.ehr.resource.model;
        import org.hibernate.annotations.GenericGenerator;
        import javax.persistence.*;
/**
 * 资源接口
 *
 * Created by lyr on 2016/5/13.
 */
@Entity
@Table(name="rs_interface")
public class RsInterface {
    private String id;
    private String name;
    private String resourceInterface;
    private String paramDescription;
    private String resultDescription;
    private String description;
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name = "Generator", strategy = "assigned")
    @Column(name = "id", unique = true, nullable = false)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    @Column(name="name",nullable = false)
    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name = name;
    }
    @Column(name="resource_interface",nullable = false)
    public String getResourceInterface(){
        return resourceInterface;
    }
    public void setResourceInterface(String resourceInterface){
        this.resourceInterface = resourceInterface;
    }
    @Column(name="param_description")
    public String getParamDescription(){
        return paramDescription;
    }
    public void setParamDescription(String paramDescription) {
        this.paramDescription = paramDescription;
    }
    @Column(name="result_description")
    public String getResultDescription() {
        return resultDescription;
    }
    public void setResultDescription(String resultDescription) {
        this.resultDescription = resultDescription;
    }
    @Column(name="description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 126 - 0
src/main/java/com/yihu/ehr/resource/model/RsMetadata.java

@ -0,0 +1,126 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * Created by lyr on 2016/5/16.
 */
@Entity
@Table(name="rs_metadata")
public class RsMetadata {
    private String id;
    private String domain;
    private String name;
    private String stdCode;
    private String displayCode;
    private String columnType;
    private String nullAble;
    private String dictCode;
    private String description;
    private String valid;
    private int dictId;
    private Integer dataSource;
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name = "Generator", strategy = "assigned")
    @Column(name = "id", unique = true, nullable = false)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    @Column(name = "dict_id")
    public int getDictId() {
        return dictId;
    }
    public void setDictId(int dictId) {
        this.dictId = dictId;
    }
    @Column(name="domain",nullable = false)
    public String getDomain() {
        return domain;
    }
    public void setDomain(String domain) {
        this.domain = domain;
    }
    @Column(name="name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name="std_code")
    public String getStdCode() {
        return stdCode;
    }
    public void setStdCode(String stdCode) {
        this.stdCode = stdCode;
    }
    @Column(name="display_code")
    public String getDisplayCode() {
        return displayCode;
    }
    public void setDisplayCode(String displayCode) {
        this.displayCode = displayCode;
    }
    @Column(name="dict_code")
    public String getDictCode() {
        return dictCode;
    }
    public void setDictCode(String dictCode) {
        this.dictCode = dictCode;
    }
    @Column(name="column_type")
    public String getColumnType() {
        return columnType;
    }
    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }
    @Column(name="null_able")
    public String getNullAble() {
        return nullAble;
    }
    public void setNullAble(String nullAble) {
        this.nullAble = nullAble;
    }
    @Column(name="description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    @Column(name="valid")
    public String getValid() {
        return valid;
    }
    public void setValid(String valid) {
        this.valid = valid;
    }
    @Column(name="data_source")
    public Integer getDataSource() {
        return dataSource;
    }
    public void setDataSource(Integer dataSource) {
        this.dataSource = dataSource;
    }
}

+ 46 - 0
src/main/java/com/yihu/ehr/resource/model/RsOrgResource.java

@ -0,0 +1,46 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * Created by zdm on 2017/6/15
 */
@Entity
@Table(name="rs_organization_resource")
public class RsOrgResource {
    private String id;
    private String organizationId;
    private String resourceId;
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name="Generator",strategy="assigned")
    @Column(name="id",unique = true,nullable = false)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    @Column(name="organization_id",nullable = false)
    public String getOrganizationId() {
        return organizationId;
    }
    public void setOrganizationId(String organizationId) {
        this.organizationId = organizationId;
    }
    @Column(name="resource_id",nullable = false)
    public String getResourceId() {
        return resourceId;
    }
    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }
}

+ 88 - 0
src/main/java/com/yihu/ehr/resource/model/RsOrgResourceMetadata.java

@ -0,0 +1,88 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * Created by zdm on 2017/6/15
 */
@Entity
@Table(name="rs_organization_resource_metadata")
public class RsOrgResourceMetadata {
    private String id;
    private String organizationId;
    private String organizationResourceId;
    private String resourceMetadataId;
    private String resourceMetadataName;
    private String dimensionId;
    private String dimensionValue;
    private String valid = "1";
    @Id
    @GeneratedValue(generator = "Generator")
    @GenericGenerator(name = "Generator", strategy = "assigned")
    @Column(name = "id", unique = true, nullable = false)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    @Column(name="organization_id",nullable = false)
    public String getOrganizationId() {
        return organizationId;
    }
    public void setOrganizationId(String organizationId) {
        this.organizationId = organizationId;
    }
    @Column(name="organization_resource_id",nullable = false)
    public String getOrganizationResourceId() {
        return organizationResourceId;
    }
    public void setOrganizationResourceId(String organizationResourceId) {
        this.organizationResourceId = organizationResourceId;
    }
    @Column(name="resource_metadata_id",nullable = false)
    public String getResourceMetadataId() {
        return resourceMetadataId;
    }
    public void setResourceMetadataId(String resourceMetadataId) {
        this.resourceMetadataId = resourceMetadataId;
    }
    @Column(name="dimension_id")
    public String getDimensionId() {
        return dimensionId;
    }
    public void setDimensionId(String dimensionId) {
        this.dimensionId = dimensionId;
    }
    @Column(name="dimension_value")
    public String getDimensionValue() {
        return dimensionValue;
    }
    public void setDimensionValue(String dimensionValue) {
        this.dimensionValue = dimensionValue;
    }
    @Column(name="resource_metadata_name",nullable = false)
    public String getResourceMetadataName() {
        return resourceMetadataName;
    }
    public void setResourceMetadataName(String resourceMetadataName) {
        this.resourceMetadataName = resourceMetadataName;
    }
    @Column(name="valid",nullable = false)
    public String getValid() {
        return valid;
    }
    public void setValid(String valid) {
        this.valid = valid;
    }
}

+ 142 - 0
src/main/java/com/yihu/ehr/resource/model/RsReport.java

@ -0,0 +1,142 @@
package com.yihu.ehr.resource.model;
import com.yihu.ehr.constants.SystemDictId;
import org.hibernate.annotations.Formula;
import javax.persistence.*;
/**
 * 资源报表 entity
 *
 * @author 张进军
 * @created 2017.8.15 19:18
 */
@Entity
@Table(name = "rs_report")
public class RsReport {
    private Integer id; // 主键
    private String code; // 报表编码
    private String name; // 报表名称
    private Integer reportCategoryId; // 资源报表分类ID
    private String reportCategoryTopCode; // 资源报表分类祖先编码
    private String status; // 报表状态
    private String remark; // 备注
    private String templatePath; // 报表模版路径
    private String showType;    // 报表展示类型  1、图表  2、二维表
    private String position;    // 报表中视图和位置的关系 json串
    // 临时字段
    private String reportCategory; // 报表分类名称
    private String statusName; // 报表状态名称
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "REPORT_CATEGORY_ID")
    public Integer getReportCategoryId() {
        return reportCategoryId;
    }
    public void setReportCategoryId(Integer reportCategoryId) {
        this.reportCategoryId = reportCategoryId;
    }
    @Transient
    public String getReportCategoryTopCode() {
        return reportCategoryTopCode;
    }
    public void setReportCategoryTopCode(String reportCategoryTopCode) {
        this.reportCategoryTopCode = reportCategoryTopCode;
    }
    @Column(name = "STATUS")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "TEMPLATE_PATH")
    public String getTemplatePath() {
        return templatePath;
    }
    public void setTemplatePath(String templatePath) {
        this.templatePath = templatePath;
    }
    @Formula("(SELECT rs.name FROM rs_report r LEFT JOIN rs_report_category rs ON rs.id = r.report_category_id WHERE r.id = id )")
    public String getReportCategory() {
        return reportCategory;
    }
    public void setReportCategory(String reportCategory) {
        this.reportCategory = reportCategory;
    }
    @Formula("(SELECT de.value FROM rs_report r LEFT JOIN system_dict_entries de ON de.dict_id = " + SystemDictId.RsReportStatus + " AND de.code = r.status WHERE r.id = id )")
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
    @Column(name = "show_type")
    public String getShowType() {
        return showType;
    }
    public void setShowType(String showType) {
        this.showType = showType;
    }
    @Column(name = "position")
    public String getPosition() {
        return position;
    }
    public void setPosition(String position) {
        this.position = position;
    }
}

+ 102 - 0
src/main/java/com/yihu/ehr/resource/model/RsReportCategory.java

@ -0,0 +1,102 @@
package com.yihu.ehr.resource.model;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
 * 资源报表分类 entity
 *
 * @author 张进军
 * @created 2017.8.8 20:32
 */
@Entity
@Table(name = "rs_report_category")
public class RsReportCategory {
    private Integer id; // 主键
    private Integer pid; // 父级ID
    private String code; // 编码
    private String name; // 名称
    private String remark; // 备注
    private Integer sortNo; // 排序
    // 临时字段
    private String text; // 名称,树形下拉框使用
    private List<RsReportCategory> children = new ArrayList<>(); // 子节点
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    @Column(name = "pid")
    public Integer getPid() {
        return pid;
    }
    public void setPid(Integer pid) {
        this.pid = pid;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "sort_no")
    public Integer getSortNo() {
        return sortNo;
    }
    public void setSortNo(Integer sortNo) {
        this.sortNo = sortNo;
    }
    @Transient
    public String getText() {
        return this.name;
    }
    public void setText(String text) {
        this.text = text;
    }
    @Transient
    public List<RsReportCategory> getChildren() {
        return children;
    }
    public void setChildren(List<RsReportCategory> children) {
        this.children = children;
    }
}

+ 49 - 0
src/main/java/com/yihu/ehr/resource/model/RsReportMonitorType.java

@ -0,0 +1,49 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.Formula;
import javax.persistence.*;
/**
 * 资源报表监测类型 entity
 *
 * @author janseny
 * @created 2017年11月7日14:27:18
 */
@Entity
@Table(name = "rs_report_monitor_type")
public class RsReportMonitorType {
    private Integer id; // 主键
    private String name; // 名称
    private String note; // 类型
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "note")
    public String getNote() {
        return note;
    }
    public void setNote(String note) {
        this.note = note;
    }
}

+ 78 - 0
src/main/java/com/yihu/ehr/resource/model/RsReportUsers.java

@ -0,0 +1,78 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.Formula;
import javax.persistence.*;
/**
 * Created by wxw on 2018/7/31.
 */
@Entity
@Table(name = "rs_report_users")
public class RsReportUsers {
    private Integer id; // 主键
    private String reportCode;  // 报表编码
    private String userId;  // 用户id
    private String sortNo;  // 排序
    // 临时字段
    private String reportName;
    private String showType;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    @Column(name = "report_code")
    public String getReportCode() {
        return reportCode;
    }
    public void setReportCode(String reportCode) {
        this.reportCode = reportCode;
    }
    @Column(name = "user_id")
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
    @Column(name = "sort_no")
    public String getSortNo() {
        return sortNo;
    }
    public void setSortNo(String sortNo) {
        this.sortNo = sortNo;
    }
    @Formula("(SELECT r.NAME from rs_report r RIGHT JOIN rs_report_users ru on r.CODE = ru.report_code WHERE ru.id = id )")
    public String getReportName() {
        return reportName;
    }
    public void setReportName(String reportName) {
        this.reportName = reportName;
    }
    @Formula("(SELECT r.show_type from rs_report r RIGHT JOIN rs_report_users ru on r.CODE = ru.report_code WHERE ru.id = id )")
    public String getShowType() {
        return showType;
    }
    public void setShowType(String showType) {
        this.showType = showType;
    }
}

+ 61 - 0
src/main/java/com/yihu/ehr/resource/model/RsReportView.java

@ -0,0 +1,61 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.Formula;
import javax.persistence.*;
/**
 * 资源报表视图配置 entity
 *
 * @author 张进军
 * @created 2017.8.22 14:05
 */
@Entity
@Table(name = "rs_report_view")
public class RsReportView {
    private Integer id; // 主键
    private Integer reportId; // 资源报表ID
    private String resourceId; // 视图ID
    // 临时字段
    private String resourceName; // 视图名称
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    @Column(name = "REPORT_ID")
    public Integer getReportId() {
        return reportId;
    }
    public void setReportId(Integer reportId) {
        this.reportId = reportId;
    }
    @Column(name = "RESOURCE_ID")
    public String getResourceId() {
        return resourceId;
    }
    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }
    @Formula("(SELECT rs.name FROM rs_report_view rv LEFT JOIN rs_resource rs ON rs.id = rv.RESOURCE_ID WHERE rv.ID = id )")
    public String getResourceName() {
        return resourceName;
    }
    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }
}

+ 147 - 0
src/main/java/com/yihu/ehr/resource/model/RsResource.java

@ -0,0 +1,147 @@
package com.yihu.ehr.resource.model;
import com.yihu.ehr.entity.BaseAssignedEntity;
import javax.persistence.*;
/**
 * Entity - 资源
 * Created by hzp on 2016/4/21.
 * Modify by Progr1mmer 2017/11/20
 */
@Entity
@Table(name = "rs_resource")
@Access(value = AccessType.PROPERTY)
public class RsResource extends BaseAssignedEntity {
    // 编码
    private String code;
    // 名称
    private String name;
    // 分类ID
    private String categoryId;
    // 数据接口
    private String rsInterface;
    // 授权类型 (0 开放 1 授权)
    private String grantType;
    // 描述
    private String description;
    // 资源类型
    private Integer dataSource;
    //指标视图展示类型
    private String echartType;
    //视图展示维度
    private String dimension;
    // 计量数值
    private String dataMeasurement;
    // 单位
    private String dataUnit;
    // 单位放置位置
    private String dataPosition;
    @Column(name="code",nullable = false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name="name",nullable = false)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name="category_id",nullable=false)
    public String getCategoryId() {
        return categoryId;
    }
    public void setCategoryId(String categoryId) {
        this.categoryId = categoryId;
    }
    @Column(name="rs_interface")
    public String getRsInterface()
    {
        return rsInterface;
    }
    public void setRsInterface(String rsInterface)
    {
        this.rsInterface = rsInterface;
    }
    @Column(name="grant_type")
    public String getGrantType()
    {
        return grantType;
    }
    public void setGrantType(String grantType)
    {
        this.grantType = grantType;
    }
    @Column(name="description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    @Column(name="data_source")
    public Integer getDataSource() {
        return dataSource;
    }
    public void setDataSource(Integer dataSource) {
        this.dataSource = dataSource;
    }
    @Column(name="echart_type")
    public String getEchartType() {
        return echartType;
    }
    public void setEchartType(String echartType) {
        this.echartType = echartType;
    }
    @Column(name="dimension")
    public String getDimension() {
        return dimension;
    }
    public void setDimension(String dimension) {
        this.dimension = dimension;
    }
    @Column(name="data_measurement")
    public String getDataMeasurement() {
        return dataMeasurement;
    }
    public void setDataMeasurement(String dataMeasurement) {
        this.dataMeasurement = dataMeasurement;
    }
    @Column(name="data_unit")
    public String getDataUnit() {
        return dataUnit;
    }
    public void setDataUnit(String dataUnit) {
        this.dataUnit = dataUnit;
    }
    @Column(name="data_position")
    public String getDataPosition() {
        return dataPosition;
    }
    public void setDataPosition(String dataPosition) {
        this.dataPosition = dataPosition;
    }
}

+ 64 - 0
src/main/java/com/yihu/ehr/resource/model/RsResourceCategory.java

@ -0,0 +1,64 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * Created by lyr on 2016/5/4.
 * 资源类别
 */
@Entity
@Table(name="rs_resource_category")
public class RsResourceCategory {
    private String id;
    private String name;
    private String pid;
    private String code;
    private String description;
    @Id
    @GeneratedValue(generator="Generator")
    @GenericGenerator(name="Generator",strategy = "assigned")
    @Column(name="id",nullable = false,unique = true)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    @Column(name="name",nullable = false)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name="pid")
    public String getPid() {
        return pid;
    }
    public void setPid(String pid) {
        this.pid = pid;
    }
    @Column(name="code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name="description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

+ 67 - 0
src/main/java/com/yihu/ehr/resource/model/RsResourceDefaultParam.java

@ -0,0 +1,67 @@
package com.yihu.ehr.resource.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * 资源字典
 *
 * Created by lyr on 2016/5/13.
 */
@Entity
@Table(name="rs_resource_default_params")
public class RsResourceDefaultParam {
    private String id;
    private String resourcesId;
    private String resourcesCode;
    private String paramKey;
    private String paramValue;
    @Id
   // @GeneratedValue(strategy = GenerationType.AUTO)
    @GenericGenerator(name="systemUUID", strategy="uuid")
    @GeneratedValue(generator="systemUUID")
    @Column(name = "id", unique = true, nullable = false, length = 32)
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    @Column(name = "resources_id",nullable = false)
    public String getResourcesId() {
        return resourcesId;
    }
    public void setResourcesId(String resourcesId) {
        this.resourcesId = resourcesId;
    }
    @Column(name = "resources_code", nullable = false)
    public String getResourcesCode() {
        return resourcesCode;
    }
    public void setResourcesCode(String resourcesCode) {
        this.resourcesCode = resourcesCode;
    }
    @Column(name = "param_key", nullable = false)
    public String getParamKey() {
        return paramKey;
    }
    public void setParamKey(String paramKey) {
        this.paramKey = paramKey;
    }
    @Column(name = "param_value",nullable = false)
    public String getParamValue() {
        return paramValue;
    }
    public void setParamValue(String paramValue) {
        this.paramValue = paramValue;
    }
}

+ 0 - 0
src/main/java/com/yihu/ehr/resource/model/RsResourceDefaultQuery.java


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