瀏覽代碼

Merge branch 'master' of luofaqiang/esb into master

luofaqiang 9 年之前
父節點
當前提交
337e640594
共有 100 個文件被更改,包括 134 次插入13348 次删除
  1. 65 51
      Hos-Framework-dependencies/Hos-Framework-dependencies.iml
  2. 14 35
      Hos-Framework-dependencies/pom.xml
  3. 55 61
      Hos-Framework/Hos-Framework.iml
  4. 0 294
      Hos-Resource-Mini-Update/pom.xml
  5. 0 128
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/ApplicationStart.java
  6. 0 70
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/Constants.java
  7. 0 9
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/DictDataType.java
  8. 0 12
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/LogicValues.java
  9. 0 45
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/MetaDataType.java
  10. 0 21
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/TransformType.java
  11. 0 65
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/config/ThreadConfig.java
  12. 0 34
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/thread/ThreadManage.java
  13. 0 393
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/thread/UpdateThread.java
  14. 0 57
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/PathUtil.java
  15. 0 141
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/ZipUtil.java
  16. 0 129
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/encode/Base64.java
  17. 0 106
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/encode/UnicodeReader.java
  18. 0 35
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/encrypt/DES.java
  19. 0 75
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/encrypt/MD5.java
  20. 0 218
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/file/FileUtil.java
  21. 0 22
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/http/HopHostnameVerifier.java
  22. 0 449
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/http/HttpClientUtil.java
  23. 0 513
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/http/HttpsClientUtil.java
  24. 0 40
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/log/LogUtil.java
  25. 0 47
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/BeanUtil.java
  26. 0 38
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/ConfigureUtil.java
  27. 0 1492
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/DateUtil.java
  28. 0 89
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/ListSortUtil.java
  29. 0 636
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/NumberUtil.java
  30. 0 29
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/Select2.java
  31. 0 353
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/SqlCreate.java
  32. 0 1428
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/StringUtil.java
  33. 0 53
      Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/TreeNode.java
  34. 0 2
      Hos-Resource-Mini-Update/src/main/resources/config/dbhelper.properties
  35. 0 9
      Hos-Resource-Mini-Update/src/main/resources/config/serviceAlive.bat
  36. 0 2
      Hos-Resource-Mini-Update/src/main/resources/config/start.bat
  37. 0 2
      Hos-Resource-Mini-Update/src/main/resources/config/stop.bat
  38. 0 29
      Hos-Resource-Mini-Update/src/main/resources/config/threadConfig.properties
  39. 二進制
      Hos-Resource-Mini-Update/src/main/resources/config/tomcat.keystore
  40. 0 39
      Hos-Resource-Mini-Update/src/main/resources/log4j2.xml
  41. 0 13
      Hos-Resource-Mini-Update/src/main/webapp/WEB-INF/web.xml
  42. 0 5
      Hos-Resource-Mini-Update/src/main/webapp/index.jsp
  43. 0 2
      Hos-Resource-Mini-Update/target/classes/config/dbhelper.properties
  44. 0 29
      Hos-Resource-Mini-Update/target/classes/config/threadConfig.properties
  45. 二進制
      Hos-Resource-Mini-Update/target/classes/config/tomcat.keystore
  46. 0 39
      Hos-Resource-Mini-Update/target/classes/log4j2.xml
  47. 0 294
      Hos-Resource-Mini-helper/pom.xml
  48. 0 159
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/ApplicationStart.java
  49. 0 70
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/Constants.java
  50. 0 9
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/DictDataType.java
  51. 0 12
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/LogicValues.java
  52. 0 45
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/MetaDataType.java
  53. 0 21
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/TransformType.java
  54. 0 347
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/config/SysConfig.java
  55. 0 72
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/config/ThreadConfig.java
  56. 0 35
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/model/DataSource.java
  57. 0 59
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/model/PatientIdentity.java
  58. 0 35
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/model/SystemParams.java
  59. 0 159
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/LogThread.java
  60. 0 349
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/SQLThread.java
  61. 0 34
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/ThreadManage.java
  62. 0 235
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/UpdateThread.java
  63. 0 432
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/HttpClientUtil.java
  64. 0 497
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/HttpsClientUtil.java
  65. 0 57
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/PathUtil.java
  66. 0 140
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/ZipUtil.java
  67. 0 129
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encode/Base64.java
  68. 0 29
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encode/HexEncode.java
  69. 0 106
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encode/UnicodeReader.java
  70. 0 75
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encrypt/MD5.java
  71. 0 110
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encrypt/RSA.java
  72. 0 218
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/file/FileUtil.java
  73. 0 43
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HAHttpClient.java
  74. 0 196
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HAHttpClientImpl.java
  75. 0 56
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HAHttpsClient.java
  76. 0 240
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HOPClient.java
  77. 0 59
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HttpsInitialise.java
  78. 0 21
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/IHAHttpClient.java
  79. 0 40
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/log/LogUtil.java
  80. 0 47
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/BeanUtil.java
  81. 0 18
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/CollectionUtil.java
  82. 0 38
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/ConfigureUtil.java
  83. 0 89
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/ListSortUtil.java
  84. 0 636
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/NumberUtil.java
  85. 0 29
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/Select2.java
  86. 0 353
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/SqlCreate.java
  87. 0 88
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/TokenUtil.java
  88. 0 53
      Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/TreeNode.java
  89. 0 2
      Hos-Resource-Mini-helper/src/main/resources/config/dbhelper.properties
  90. 0 45
      Hos-Resource-Mini-helper/src/main/resources/config/threadConfig.properties
  91. 二進制
      Hos-Resource-Mini-helper/src/main/resources/config/tomcat.keystore
  92. 0 39
      Hos-Resource-Mini-helper/src/main/resources/log4j2.xml
  93. 0 44
      Hos-Resource-Mini-helper/src/main/webapp/WEB-INF/dispatcher-servlet.xml
  94. 0 54
      Hos-Resource-Mini-helper/src/main/webapp/WEB-INF/web.xml
  95. 0 5
      Hos-Resource-Mini-helper/src/main/webapp/index.jsp
  96. 0 2
      Hos-Resource-Mini-helper/target/classes/config/dbhelper.properties
  97. 0 45
      Hos-Resource-Mini-helper/target/classes/config/threadConfig.properties
  98. 二進制
      Hos-Resource-Mini-helper/target/classes/config/tomcat.keystore
  99. 0 39
      Hos-Resource-Mini-helper/target/classes/log4j2.xml
  100. 0 0
      Hos-Resource-Mini/Hos-Resource-Mini.iml

+ 65 - 51
Hos-Framework-dependencies/Hos-Framework-dependencies.iml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
    <output url="file://$MODULE_DIR$/target/classes" />
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
    <content url="file://$MODULE_DIR$">
@ -12,43 +12,6 @@
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc-portlet:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-websocket:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis:axis:1.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2-adb:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.0.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2-kernel:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-api:1.2.14" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.7.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:1.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.james:apache-mime4j-core:0.7.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-compat:1.2.14" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.ws.commons.axiom:axiom-impl:1.2.14" level="project" />
    <orderEntry type="library" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.1.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:1.1.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1" level="project" />
    <orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.3" level="project" />
    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.neethi:neethi:3.0.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-api:1.0M9" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-impl-dom:1.0M9" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-impl-commons:1.0M9" level="project" />
    <orderEntry type="library" name="Maven: javax.ws.rs:jsr311-api:1.1.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:org.apache.axis2.osgi:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2-transport-http:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2-transport-local:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
    <orderEntry type="library" name="Maven: org.csource:fastdfs-client-java:1.0" level="project" />
    <orderEntry type="library" name="Maven: redis.clients:jedis:2.8.0" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.3" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate:hibernate-core:4.3.11.Final" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.3.GA" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.5.Final" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" />
    <orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aspects:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.1.8.RELEASE" level="project" />
@ -64,6 +27,59 @@
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc-portlet:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-websocket:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.6.1" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.7" level="project" />
    <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.7" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.21" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.21" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.17" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.4" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.2.4.Final" level="project" />
    <orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.5.0" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.3.0" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.3" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate:hibernate-core:4.3.11.Final" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.0.Final" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.5.Final" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" />
    <orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aspects:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-core:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-orm:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-tx:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-web:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc-portlet:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-websocket:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-acl:4.0.2.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-aspects:4.0.2.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-cas:4.0.2.RELEASE" level="project" />
@ -71,8 +87,7 @@
    <orderEntry type="library" name="Maven: org.opensaml:opensaml:2.5.1-1" level="project" />
    <orderEntry type="library" name="Maven: org.opensaml:openws:1.4.2-1" level="project" />
    <orderEntry type="library" name="Maven: org.opensaml:xmltooling:1.3.2-1" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.6.1" level="project" />
    <orderEntry type="library" name="Maven: joda-time:joda-time:1.6.2" level="project" />
    <orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
    <orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15:1.45" level="project" />
    <orderEntry type="library" name="Maven: org.apache.santuario:xmlsec:1.4.4" level="project" />
    <orderEntry type="library" name="Maven: ca.juliusdavies:not-yet-commons-ssl:0.3.9" level="project" />
@ -89,8 +104,8 @@
    <orderEntry type="library" name="Maven: com.google.inject:guice:2.0" level="project" />
    <orderEntry type="library" name="Maven: org.openid4java:openid4java-nodeps:0.9.6" level="project" />
    <orderEntry type="library" name="Maven: net.jcip:jcip-annotations:1.0" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: net.sourceforge.nekohtml:nekohtml:1.9.20" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: xerces:xercesImpl:2.10.0" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: net.sourceforge.nekohtml:nekohtml:1.9.22" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: xerces:xercesImpl:2.11.0" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-remoting:4.0.2.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-taglibs:4.0.2.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:4.0.2.RELEASE" level="project" />
@ -103,11 +118,10 @@
    <orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.1.2" level="project" />
    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.1.2" level="project" />
    <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.1.2" level="project" />
    <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.2.0" level="project" />
    <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.1" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.hateoas:spring-hateoas:0.17.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.objenesis:objenesis:2.1" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.hateoas:spring-hateoas:0.20.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.1.2" level="project" />
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.4.6" level="project" />
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.4.6" level="project" />
@ -135,7 +149,7 @@
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1" level="project" />
    <orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.3" level="project" />
    <orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.2" level="project" />
    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.neethi:neethi:3.0.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-api:1.0M9" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-impl-dom:1.0M9" level="project" />
@ -161,8 +175,8 @@
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-extras:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-core:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-api:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: commons-digester:commons-digester:2.0" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.6" level="project" />
    <orderEntry type="library" name="Maven: commons-digester:commons-digester:2.1" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.21" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-servlet-wildcard:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-servlet:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-mustache:1.0.6" level="project" />
@ -175,11 +189,11 @@
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-jsp:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-freemarker:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-freemarker:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.15" level="project" />
    <orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.25-incubating" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-velocity:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.velocity:velocity-tools:2.0" level="project" />
    <orderEntry type="library" name="Maven: oro:oro:2.0.8" level="project" />
    <orderEntry type="library" name="Maven: org.apache.velocity:velocity:1.6.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.velocity:velocity:1.7" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-velocity:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-el:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-mvel:3.0.5" level="project" />
@ -189,7 +203,7 @@
    <orderEntry type="library" name="Maven: jboss:javassist:3.7.ga" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-compat:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: net.sf.json-lib:json-lib:2.4" level="project" />
    <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
    <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
    <orderEntry type="library" name="Maven: commons-discovery:commons-discovery:0.2" level="project" />
    <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.0" level="project" />

+ 14 - 35
Hos-Framework-dependencies/pom.xml

@ -8,26 +8,16 @@
    <artifactId>Hos-Framework-dependencies</artifactId>
    <version>1.0.1</version>
    <packaging>pom</packaging>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <properties>
@ -74,11 +64,6 @@
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
@ -91,28 +76,22 @@
        <!--<dependency>-->
            <!--<groupId>io.springfox</groupId>-->
            <!--<artifactId>springfox-swagger2</artifactId>-->
            <!--<version>2.4.0</version>-->
            <!--<exclusions>-->
                <!--<exclusion>-->
                    <!--<artifactId>classmate</artifactId>-->
                    <!--<groupId>com.fasterxml</groupId>-->
                <!--</exclusion>-->
            <!--</exclusions>-->
        <!--<groupId>io.springfox</groupId>-->
        <!--<artifactId>springfox-swagger2</artifactId>-->
        <!--<version>2.4.0</version>-->
        <!--<exclusions>-->
        <!--<exclusion>-->
        <!--<artifactId>classmate</artifactId>-->
        <!--<groupId>com.fasterxml</groupId>-->
        <!--</exclusion>-->
        <!--</exclusions>-->
        <!--</dependency>-->
        <!--<dependency>-->
            <!--<groupId>io.springfox</groupId>-->
            <!--<artifactId>springfox-swagger-ui</artifactId>-->
            <!--<version>2.4.0</version>-->
        <!--<groupId>io.springfox</groupId>-->
        <!--<artifactId>springfox-swagger-ui</artifactId>-->
        <!--<version>2.4.0</version>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--=============httpclient start=============-->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>

+ 55 - 61
Hos-Framework/Hos-Framework.iml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
    <output url="file://$MODULE_DIR$/target/classes" />
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
    <content url="file://$MODULE_DIR$">
@ -9,62 +9,58 @@
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc-portlet:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-websocket:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis:axis:1.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2-adb:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.0.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2-kernel:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-api:1.2.14" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.7.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:1.0.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.james:apache-mime4j-core:0.7.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.ws.commons.axiom:axiom-compat:1.2.14" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.ws.commons.axiom:axiom-impl:1.2.14" level="project" />
    <orderEntry type="library" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.1.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-ws-metadata_2.0_spec:1.1.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1" level="project" />
    <orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.3" level="project" />
    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.neethi:neethi:3.0.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-api:1.0M9" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-impl-dom:1.0M9" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-impl-commons:1.0M9" level="project" />
    <orderEntry type="library" name="Maven: javax.ws.rs:jsr311-api:1.1.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:org.apache.axis2.osgi:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2-transport-http:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.axis2:axis2-transport-local:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
    <orderEntry type="library" name="Maven: org.csource:fastdfs-client-java:1.0" level="project" />
    <orderEntry type="library" name="Maven: redis.clients:jedis:2.8.0" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.7" level="project" />
    <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.7" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.21" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.21" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.17" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.4" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.4" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.2.4.Final" level="project" />
    <orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.4.0.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.5.0" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.3.0" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.1" level="project" />
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.3" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate:hibernate-core:4.3.11.Final" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.3.GA" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.0.Final" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1" level="project" />
    <orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.5.Final" level="project" />
    <orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" />
    <orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aspects:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-core:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-orm:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-tx:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-web:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc-portlet:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-websocket:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.1.8.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aspects:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context-support:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-core:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-orm:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-tx:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-web:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc-portlet:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-websocket:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.2.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-acl:4.0.2.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-aspects:4.0.2.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-cas:4.0.2.RELEASE" level="project" />
@ -72,8 +68,7 @@
    <orderEntry type="library" name="Maven: org.opensaml:opensaml:2.5.1-1" level="project" />
    <orderEntry type="library" name="Maven: org.opensaml:openws:1.4.2-1" level="project" />
    <orderEntry type="library" name="Maven: org.opensaml:xmltooling:1.3.2-1" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.6.1" level="project" />
    <orderEntry type="library" name="Maven: joda-time:joda-time:1.6.2" level="project" />
    <orderEntry type="library" name="Maven: joda-time:joda-time:2.9.4" level="project" />
    <orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15:1.45" level="project" />
    <orderEntry type="library" name="Maven: org.apache.santuario:xmlsec:1.4.4" level="project" />
    <orderEntry type="library" name="Maven: ca.juliusdavies:not-yet-commons-ssl:0.3.9" level="project" />
@ -90,8 +85,8 @@
    <orderEntry type="library" name="Maven: com.google.inject:guice:2.0" level="project" />
    <orderEntry type="library" name="Maven: org.openid4java:openid4java-nodeps:0.9.6" level="project" />
    <orderEntry type="library" name="Maven: net.jcip:jcip-annotations:1.0" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: net.sourceforge.nekohtml:nekohtml:1.9.20" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: xerces:xercesImpl:2.10.0" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: net.sourceforge.nekohtml:nekohtml:1.9.22" level="project" />
    <orderEntry type="library" scope="RUNTIME" name="Maven: xerces:xercesImpl:2.11.0" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-remoting:4.0.2.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-taglibs:4.0.2.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:4.0.2.RELEASE" level="project" />
@ -104,11 +99,10 @@
    <orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.1.2" level="project" />
    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.1.2" level="project" />
    <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.1.2" level="project" />
    <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.2.0" level="project" />
    <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.1" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.hateoas:spring-hateoas:0.17.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.objenesis:objenesis:2.1" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.hateoas:spring-hateoas:0.20.0.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.1.2" level="project" />
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.4.6" level="project" />
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.4.6" level="project" />
@ -136,7 +130,7 @@
    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1" level="project" />
    <orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.3" level="project" />
    <orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.2" level="project" />
    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.neethi:neethi:3.0.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-api:1.0M9" level="project" />
    <orderEntry type="library" name="Maven: org.apache.woden:woden-impl-dom:1.0M9" level="project" />
@ -162,8 +156,8 @@
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-extras:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-core:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-api:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: commons-digester:commons-digester:2.0" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.6" level="project" />
    <orderEntry type="library" name="Maven: commons-digester:commons-digester:2.1" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.21" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-servlet-wildcard:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-servlet:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-mustache:1.0.6" level="project" />
@ -176,11 +170,11 @@
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-jsp:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-freemarker:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-freemarker:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.15" level="project" />
    <orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.25-incubating" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-velocity:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.velocity:velocity-tools:2.0" level="project" />
    <orderEntry type="library" name="Maven: oro:oro:2.0.8" level="project" />
    <orderEntry type="library" name="Maven: org.apache.velocity:velocity:1.6.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.velocity:velocity:1.7" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-request-velocity:1.0.6" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-el:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-mvel:3.0.5" level="project" />
@ -190,7 +184,7 @@
    <orderEntry type="library" name="Maven: jboss:javassist:3.7.ga" level="project" />
    <orderEntry type="library" name="Maven: org.apache.tiles:tiles-compat:3.0.5" level="project" />
    <orderEntry type="library" name="Maven: net.sf.json-lib:json-lib:2.4" level="project" />
    <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
    <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
    <orderEntry type="library" name="Maven: commons-discovery:commons-discovery:0.2" level="project" />
    <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.0" level="project" />

+ 0 - 294
Hos-Resource-Mini-Update/pom.xml

@ -1,294 +0,0 @@
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ehr</groupId>
    <artifactId>Hos-Resource-Mini-Update</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Hos-Resource-Mini-Update Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <properties>
        <aspectj.version>1.8.7</aspectj.version>
        <jackson.version>2.4.6</jackson.version>
        <spring.version>4.1.8.RELEASE</spring.version>
    </properties>
    <distributionManagement>
        <repository>
            <id>Releases</id>
            <name>Releases</name>
            <url>http://172.19.103.47:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Snapshots</name>
            <url>http://172.19.103.47:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    <dependencies>
        <!--=============数据库驱动 start =============-->
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>ehr-dbhelper</artifactId>
            <version>1.1.5</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.37</version>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.8.11.2</version>
        </dependency>
        <!--=============数据库驱动 end =============-->
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20151123</version>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.2</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.10</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.10</version>
        </dependency>
        <dependency>
            <groupId>commons-dbutils</groupId>
            <artifactId>commons-dbutils</artifactId>
            <version>1.6</version>
        </dependency>
        <!--=============spring start =============-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-websocket</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>
        <!--=============spring end =============-->
        <!--=============log4j start =============-->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-nop</artifactId>
            <version>1.7.13</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.12</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <!--=============log4j end =============-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <!--=============tilesJSP布局框架 start =============-->
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-extras</artifactId>
            <version>3.0.5</version>
        </dependency>
        <!--=============tiles end =============-->
        <!--=============httpclient start=============-->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.3</version>
        </dependency>
        <dependency>
            <groupId>ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.7.0</version>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>net.lingala.zip4j</groupId>
            <artifactId>zip4j</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!--=============httpclient end=============-->
    </dependencies>
    <build>
        <finalName>Hos-Resource-Mini-Update</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

+ 0 - 128
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/ApplicationStart.java

@ -1,128 +0,0 @@
package com.yihu.ehr.common;
import com.yihu.ehr.config.ThreadConfig;
import com.yihu.ehr.thread.ThreadManage;
import com.yihu.ehr.thread.UpdateThread;
import com.yihu.ehr.util.log.LogUtil;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
/**
 * 项目启动执行
 * add by hzp at 2016-01-25
 */
public class ApplicationStart implements ServletContextListener {
    private static Properties prop = new Properties();
    private static int rebootCount = 0;
    private String log4jDirKey = "log4j";
    @Override
    public void contextInitialized(ServletContextEvent context) {
        String home = System.getProperty("catalina.home").replace('\\', '/');
        //设置日志文件路径
        System.setProperty(log4jDirKey, home + File.separator + "log4j" + File.separator);
        // String homeUrl = home.substring(0, home.lastIndexOf('/') + 1);
        //启动sqllite
        initSqlLite();
        //使用自定义转化器转化时间格式
        //ConvertUtils.register(new DateConvert(), Date.class);
        //初始化日志,sql和更新文件的线程需要的参数
        initParams();
        //启动各个线程
        startThread();
    }
    private void initSqlLite() {
        try {
            InputStream in = this.getClass().getResourceAsStream("/config/dbhelper.properties");
            prop.load(in);
            String configPath = this.getClass().getClassLoader().getResource("/").getPath() + "config/dbhelper.properties";
            OutputStream fos = new FileOutputStream(configPath);
            String home = System.getProperty("catalina.home").replace('\\', '/');
            String url = home.substring(0, home.lastIndexOf('/') + 1) + "db/localDB.db";
            prop.setProperty("defaultUri", "jdbc:sqlite://" + url);
            prop.store(fos, "last update");
            in.close();
            fos.close();
            LogUtil.info("加载sqllite文件成功,路径更新为:jdbc:sqlite://" + url);
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.error("加载sqllite文件失败");
        }
    }
    @Override
    public void contextDestroyed(ServletContextEvent context) {
    }
    private void initParams() {
        //读取配置文件
        readProperties();
        //设置参数
        setParams();
    }
    private void setParams() {
        try {
            ThreadConfig.SERVICE_USERNAME = prop.getProperty("service.username");
            ThreadConfig.SERVICE_PASSWORD = prop.getProperty("service.password");
            ThreadConfig.SERVICE_URL = prop.getProperty("service.url");
            ThreadConfig.SERVICE_CLIENTID = prop.getProperty("service.clientId");
            ThreadConfig.SERVICE_CLIENTKEY = prop.getProperty("service.clientKey");
            //更新代码线程模快的参数初始化
            ThreadConfig.UPDATE_THREAD_SLEEP_TIME = Integer.valueOf(prop.getProperty("updateThread.sleepTime"));
            ThreadConfig.UPDATE_THREAD_DOWNUPDATEWAR = prop.getProperty("updateThread.downUpdateWar");
            ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG = prop.getProperty("updateThread.isUpdate");
            ThreadConfig.UPDATE_THREAD_UPLOADRESULT = prop.getProperty("updateThread.uploadResult");
            ThreadConfig.TOMCAT_SERVICENAME = prop.getProperty("tomcat.servicename");
            //ThreadConfig.SOFT_VERSIONCODE = prop.getProperty("soft.versionCode");
            ThreadConfig.SYSTEM_CODE = prop.getProperty("system.code");
            ThreadConfig.TOKEN_INFO = prop.getProperty("token.info");
            ThreadConfig.TOKEN_USER_NAME = prop.getProperty("token.user_name");
            ThreadConfig.TOKEN_METHOD = prop.getProperty("token.getToken");
            ThreadConfig.SYSTEM_DOWNLOADPATH = prop.getProperty("system.downloadPath");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void readProperties() {
        InputStream in;
        try {
            in = ApplicationStart.class.getResourceAsStream("/config/threadConfig.properties");
            prop.load(in);
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void startThread() {
        Thread updateThread = new Thread(new UpdateThread());
        //启动线程
        updateThread.start();
        //把线程放进线程管理器
        ThreadManage.add(ThreadManage.UPDATE_THREAD, updateThread);
    }
    public static void main(String[] args) {
        System.out.println(ApplicationStart.class.getResource("/").getPath());
    }
}

+ 0 - 70
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/Constants.java

@ -1,70 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * Created by lingfeng on 2015/6/23.
 */
public class Constants {
    public static final String CREATE_TABLE = " CREATE TABLE ";
    public static final String INSERT_INTO = " INSERT INTO ";
    public static final String ALTER_TABLE = " ALTER TABLE ";
    public static final String SELECT = " SELECT ";
    public static final String UPDATE = "UPDATE ";
    public static final String DELETE = "DELETE ";
    public static final String FROM = " FROM ";
    public static final String WHERE = " WHERE ";
    public static final String BETWEEN = " BETWEEN ";
    public static final String EQUAL_MARK = " = ";
    public static final String GREATER_EQUAL_MARK = " >= ";
    public static final String LESS_EQUAL_MARK = " <= ";
    public static final String GREATER_MARK = " > ";
    public static final String LESS_MARK = " < ";
    public static final String SET = " SET ";
    public static final String AND = " AND ";
    public static final String QUESTION_MARK = " ? ";
    public static final String ADD = " ADD ";
    public static final String NOT_NULL = " NOT NULL ";
    public static final String SINGLE_QUOTE_MARK = "'";
    public static final String BLANK = " ";
    public static final String PRIMARY_KEY = "PRIMARY_KEY ";
    public static final String LEFT_BRACKET = "(";
    public static final String RIGHT_BRACKET = ")";
    public static final String COMMA = ",";
    public static final String SEMICOLON = ";";
    public static final String OCTOTHORPE = "#";
    public static final String VALUES = " VALUES ";
    public static final String LIKE = " LIKE ";
    public static final String PERCENT = "%";
    public static final String ROW_FORMAT_DYNAMIC = "row_format=dynamic";
    public static final String USERNAME_KEY = "u2akgXkkRRkiiCVR";
    public static final String ACCESS_TOKEN = "accessToken";
    public static final String REFRESH_TOKEN = "refreshToken";
    public static final String TOKEN_FAILD = "tokenFaild";
    public static final String TOKEN_EXPIRED = "tokenExpired";
    public static final String EMPTY = "";
    public static final String CDA_FILE = "CDA_File";
    public static final String STANDARD_ZIP = "standard.zip";
    public static final String DOT = ".";
    public static final String PATIENT_QUEUE = "patient_queue";
    public static final String UPDATE_TYPE = "update";
    public static final String DELETE_TYPE = "delete";
    public static final String ADD_TYPE = "add";
    public static final String TABLE_KEY = "id";
    public static final String FAILURE_FLG = "valid";
    public static final String UNDERLINE = "_";
    public static final String STD_PREFIX = "std_";
    public static final String ADAPTER_PREFIX = "adapter_";
    public static final String ORIGIN_PREFIX = "origin_";
    public static final String CODE_STR = "code";
    public static final String VALUE_STR = "value";
    public static final String OK = "ok";
    public static final String NO = "no";
    public static final Integer NUMBER_ZREO = 0;
    public static final Integer NUMBER_ONE = 1;
    public static final String MYSQL_DRIVER = "com.mysql.jdbc.Driver";
    public static final String ORACLE_DRIVER = "oracle.jdbc.driver.OracleDriver";
    public static final String SQLSERVER_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    public static final String MYSQL = "mysql";
    public static final String ORACLE = "oracle";
    public static final String SQLSERVER = "sqlserver";
}

+ 0 - 9
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/DictDataType.java

@ -1,9 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * Created by Administrator on 2015/9/16.
 */
public enum DictDataType {
    VALUE, //值
    CODE //编码
}

+ 0 - 12
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/LogicValues.java

@ -1,12 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * Created by HZY on 2016/1/29.
 */
public class LogicValues {
    public static final String LOGIC_OK = "ok";
    public static final String LOGIC_NO = "no";
    public static final String LOGIC_TRUE = "true";
    public static final String LOGIC_FALSE = "false";
}

+ 0 - 45
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/MetaDataType.java

@ -1,45 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * 数据元类型
 *
 * @created Created by Air on 2015/6/9.
 */
public enum MetaDataType {
    /**
     * 字符,不可枚举
     */
    S1,
    /**
     * 字符,枚举<=3个
     */
    S2,
    /**
     * 字符,代码表
     */
    S3,
    /**
     * 布尔,0(False),1(True)
     */
    L,
    /**
     * 数值,
     */
    N,
    /**
     * 日期
     */
    D,
    /**
     * 时间日期
     */
    DT,
    /**
     * 时间
     */
    T,
    /**
     * 二进制
     */
    BY
}

+ 0 - 21
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/common/constants/TransformType.java

@ -1,21 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * @created  Air on 2015/6/8.
 */
public enum TransformType {
    /**
     * 数据集
     */
    DATA_SET_JSON,
    DATA_SET_XML,
    /**
     * CDA
     */
    CDA_JSON,
    CDA_XML,
    /**
     * 非结构化
     */
    DOCUMENT,
}

+ 0 - 65
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/config/ThreadConfig.java

@ -1,65 +0,0 @@
package com.yihu.ehr.config;
import com.yihu.ehr.util.log.LogUtil;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
/**
 * Created by chenweida on 2016/2/27.
 */
public class ThreadConfig {
    public static String SERVICE_USERNAME = "admin";
    public static String SERVICE_PASSWORD = "123456";
     public static String SERVICE_URL = "https://172.19.103.73:443/api/v1.0/";
    // public static String SERVICE_URL = "https://192.168.131.15:4432/api/v1.0/";
    //public static String SERVICE_URL = "https://192.168.131.6:4432/api/v1.0/";//"";
    //public static String SERVICE_URL = "https://ehr.yihu.com/api/v1.0/";//"";
    public static String SERVICE_CLIENTID = "kHAbVppx44";
    public static String SERVICE_CLIENTKEY = "Bd2h8rdYhep6NKOO";
    public static int UPDATE_THREAD_SLEEP_TIME = 30;
    public static int SQL_THREAD_SLEEP_TIME = 30;
    public static String UPDATE_THREAD_GETUPDATEFLAG;
    public static String UPDATE_THREAD_DOWNUPDATEWAR;
    public static String UPDATE_THREAD_UPLOADRESULT;
    public static String TOKEN_USER_NAME = "kHAbVppx44";
    public static String TOKEN_INFO = "{\"fingerprint\": \"abc\"}";
    public static String TOKEN_METHOD = "authorizations/clients/";
    public static String TOMCAT_SERVICENAME = "tomcat8-esb-ds";
    public static String SOFT_VERSIONCODE = "1";
    public static String SYSTEM_CODE = "";
    public static String SYSTEM_DOWNLOADPATH="";
    private static Properties prop = new Properties();
    public static void updatVersion(String version) {
        try {
            InputStream in;
            OutputStream fos;
            try {
                in = ThreadConfig.class.getResourceAsStream("/config/threadConfig.properties");
                fos = new FileOutputStream("/config/threadConfig.properties");
                prop.load(in);
                prop.setProperty("soft.versionCode", version);
                prop.store(fos, "last update");
                in.close();
                fos.close();
                ThreadConfig.SOFT_VERSIONCODE = version;
            } catch (Exception e) {
                e.printStackTrace();
            }
            LogUtil.info("更新配置文件中版本成功号");
        } catch (Exception e) {
            LogUtil.info("更新配置文件中版本失败" + e.getMessage());
        }
    }
}

+ 0 - 34
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/thread/ThreadManage.java

@ -1,34 +0,0 @@
package com.yihu.ehr.thread;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by chenweida on 2016/3/2.
 */
public class ThreadManage {
    public static String LOG_THREAD = "logThread";
    public static String SQL_THREAD = "sqlThread";
    public static String UPDATE_THREAD = "UpdateThread";
    public static boolean logIsRunning = true;
    public static boolean sqlIsRunning = true;
    public static boolean updateIsRunning = true;
    private static Map<String, Thread> threadPool = new HashMap<String, Thread>();
    public static void add(String threadId, Thread thread) {
        threadPool.put(threadId, thread);
    }
    public static Thread get(String threadId) {
        return threadPool.get(threadId);
    }
    //把所有的线程的有效标示设置成false
    public static void stopAllThread() {
        logIsRunning = false;
        sqlIsRunning = false;
        updateIsRunning = false;
    }
}

+ 0 - 393
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/thread/UpdateThread.java

@ -1,393 +0,0 @@
package com.yihu.ehr.thread;
import com.yihu.ehr.config.ThreadConfig;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.util.Zipper;
import com.yihu.ehr.util.http.HttpClientUtil;
import com.yihu.ehr.util.http.HttpsClientUtil;
import com.yihu.ehr.util.log.LogUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.springframework.util.StringUtils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by chenweida on 2016/2/27.
 */
public class UpdateThread implements Runnable {
    private String orgCode;
    private String systemCode;
    private int sleepTime = 60 * 1000;
    private DBHelper db = new DBHelper();
    private String resultString = "";
    private String versionName = "";
    private String versionCode = "";
    private String downloadPath = "";
    private String token;
    private boolean isStart = false;
    @Override
    public void run() {
        while (ThreadManage.updateIsRunning) {
            try {
                token = HttpsClientUtil.getToken();
                if (!StringUtils.isEmpty(token)) {
                    //初始化参数
                    initParam();
                    LogUtil.info("-----------更新线程开始启动------------token:" + token);
                    //判断是否需要更新
                    if (isUpdate()) {
                        LogUtil.info("有需要更新的任务");
                        //得到更新的文件包
                        String filePath = downLoadFile();
                        LogUtil.info("更新包的路径是:" + filePath);
                        //解压并且覆盖文件
                        if (!StringUtils.isEmpty(filePath)) {
                            //关闭服務
                            closeService();
                            //解压
                            if (zipFile(filePath)) {
                                //启动服务
                                startService();
                                //更新本地版本号
                                updateVersion();
                                //判断服务是否启动
                                String message = "启动服務失败";
                                if (isStart) {
                                    message = "启动服務成功";
                                }
                                //上传结果
                                upLoagResult(message);
                            }
                        }
                    } else {
                        LogUtil.info("没有需要更新的任务");
                    }
                }
            } catch (Exception e) {
                LogUtil.error("-----------更新线程执行失败------------失败原因:" + e.getMessage());
            } finally {
                //睡眠
                try {
                    sleep();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    private void updateVersion() {
        if (StringUtils.isEmpty(versionCode)) {
            versionCode = "1";
        }
        String sql = "update system_param set param_value='" + versionCode + "' where param_key='VERSION'";//UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
        db.execute(sql);
    }
    private void upLoagResult(String isStart) {
        try {
            net.sf.json.JSONObject jo = net.sf.json.JSONObject.fromObject(resultString);
//            Map<String, Object> params = new HashMap<String, Object>();
//            params.put("systemCode", systemCode);
//            params.put("orgCode", orgCode);
//            params.put("versionName", versionName);
//            params.put("versionCode", versionCode);
//            params.put("updateDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
//            HttpClientUtil.doPost(ThreadConfig.SERVICE_URL + ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG, params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            List<NameValuePair> formParams = new ArrayList<NameValuePair>();
            formParams.add(new BasicNameValuePair("systemCode", systemCode));
            formParams.add(new BasicNameValuePair("versionName", versionName));
            formParams.add(new BasicNameValuePair("versionCode", versionCode));
            formParams.add(new BasicNameValuePair("access_token", token));
            formParams.add(new BasicNameValuePair("message", isStart));
            formParams.add(new BasicNameValuePair("updateDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
            formParams.add(new BasicNameValuePair("orgCode", orgCode));
            resultString = HttpsClientUtil.post(ThreadConfig.SERVICE_URL + ThreadConfig.UPDATE_THREAD_UPLOADRESULT, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("上传结果成功");
        } catch (Exception e) {
            LogUtil.error("上传结果失败:" + e.getMessage());
        }
    }
    private void initParam() {
        if (StringUtils.isEmpty(orgCode) || StringUtils.isEmpty(systemCode)) {
            try {
                List<JSONObject> listORG = db.query("select * from system_param where param_key='ORG_CODE'");
                List<JSONObject> listSYSTEM = db.query("select * from system_param where param_key='SYSTEM_CODE'");
                if (listORG != null && listORG.size() > 0) {
                    orgCode = listORG.get(0).getString("param_value");
                }
                if (listSYSTEM != null && listSYSTEM.size() > 0) {
                    systemCode = listSYSTEM.get(0).getString("param_value");
                } else {
                    String sql = "insert into system_param (id,param_key,param_value) values " +
                            "('" + UUID.randomUUID() + "'," +
                            " 'SYSTEM_CODE' ," +
                            " '" + ThreadConfig.SYSTEM_CODE + "'" +
                            ")";
                    db.execute(sql);
                }
            } catch (Exception e) {
                LogUtil.error("初始化参数失败:" + e.getMessage());
            }
        }
        LogUtil.info("初始化参数成功orgCode:" + orgCode + "---systemCode:" + systemCode);
    }
    private void closeService() throws Exception {
        //C:\Windows\System32\UserAccountControlSettings.exe
        LogUtil.info("开始关闭服务");
        try {
            String system = System.getProperty("os.name").toLowerCase();
            if (system.contains("windows")) {
                LogUtil.info("关闭windows服务");
                //windows
                String batPathStop = UpdateThread.class.getResource("/").getPath() + "config/stop.bat";
                Process psStop = Runtime.getRuntime().exec(batPathStop);
                ByteArrayOutputStream baosStop = new ByteArrayOutputStream();
                InputStream osStop = psStop.getInputStream();
                byte bStop[] = new byte[256];
                while (osStop.read(bStop) > 0) {
                    baosStop.write(bStop);
                }
                String sStop = baosStop.toString();
                osStop.close();
                baosStop.close();
                //判断是否服务是否关闭
                while (true) {
                    String batPath = UpdateThread.class.getResource("/").getPath() + "config/serviceAlive.bat";
                    Process ps = Runtime.getRuntime().exec(batPath);
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    InputStream os = ps.getInputStream();
                    byte b[] = new byte[256];
                    while (os.read(b) > 0) {
                        baos.write(b);
                    }
                    String s = baos.toString();
                    os.close();
                    baos.close();
                    if (!Boolean.valueOf(s.trim())) {
                        break;
                    }
                    LogUtil.info("服务正在关闭");
                }
                Thread.sleep(1000L);
            } else {
                LogUtil.info("重启linux服务");
                Runtime.getRuntime().exec("service " + ThreadConfig.TOMCAT_SERVICENAME + " stop");
                Thread.sleep(6000L);
            }
            LogUtil.info("关闭成功");
        } catch (Exception e) {
            LogUtil.error("关闭失败:" + e.getMessage());
        }
    }
    private void startService() throws Exception {
        LogUtil.info("开始启动服务");
        try {
            String system = System.getProperty("os.name").toLowerCase();
            if (system.contains("windows")) {
                String batPathStart = UpdateThread.class.getResource("/").getPath() + "config/start.bat";
                LogUtil.info("启动windows服务:" + batPathStart);
                //windows
                Process psStart = Runtime.getRuntime().exec(batPathStart);
                ByteArrayOutputStream baosStart = new ByteArrayOutputStream();
                InputStream osStart = psStart.getInputStream();
                byte bStart[] = new byte[256];
                while (osStart.read(bStart) > 0) {
                    baosStart.write(bStart);
                }
                osStart.close();
                baosStart.close();
                int i = 0;
                LogUtil.info("开始判断服务是否启动");
                while (true) {
                    String batPath = UpdateThread.class.getResource("/").getPath() + "config/serviceAlive.bat";
                    Process ps = Runtime.getRuntime().exec(batPath);
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    InputStream os = ps.getInputStream();
                    byte b[] = new byte[256];
                    while (os.read(b) > 0)
                        baos.write(b);
                    String s = baos.toString();
                    os.close();
                    baos.close();
                    LogUtil.info("服务正在启动:" + Boolean.valueOf(s.trim()));
                    if (Boolean.valueOf(s.trim())) {
                        i++;
                        if (i > 3) {
                            isStart = true;
                            LogUtil.info("服务启动成功");
                            break;
                        }
                    }
                }
            } else {
                LogUtil.info("启动linux服务");
                Runtime.getRuntime().exec("service " + ThreadConfig.TOMCAT_SERVICENAME + " start");
            }
            LogUtil.info("启动成功");
        } catch (Exception e) {
            LogUtil.error("启动失败:" + e.getMessage());
        }
    }
    private boolean zipFile(String filePath) {
        try {
            String home = System.getProperty("catalina.home").replace('\\', '/');
            String url = home.substring(0, home.lastIndexOf('/') + 1) + "tomcat8-esb-ds/webapps";
            Zipper.unzipFile(new File(filePath.trim()), url);
            LogUtil.info("解压成功解压路径:" + url);
            return true;
        } catch (Exception e) {
            LogUtil.error("解压失败:" + e.getMessage());
            return false;
        }
    }
    private String downLoadFile() throws Exception {
        String path = null;
        try {
            //Map<String, Object> params = new HashMap<String, Object>();
            //    params.put("systemCode", systemCode);
            // params.put("orgCode", orgCode);
            path = getFilePath();
            //  HttpClientUtil.downFile(path, params, ThreadConfig.getURL(ThreadConfig.UPDATE_THREAD_DOWNUPDATEWAR), "", "");
            // Map<String, Object> params = new HashMap<String, Object>();
            // params.put("systemCode", systemCode);
            //  params.put("orgCode", orgCode);
            // params.put("access_token", token);
            LogUtil.info("开始下载文件,文件下載地址在:" + ThreadConfig.SYSTEM_DOWNLOADPATH + downloadPath);
            // HttpClientUtil.downFile(path, new HashMap<String, Object>(), , "", "");
            HttpClientUtil.getFile(ThreadConfig.SYSTEM_DOWNLOADPATH + downloadPath, path);
            LogUtil.info("下载文件成功,文件保存目录:" + path);
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.error("下载文件失败:" + path + e.getMessage());
            return "";
        }
        return path;
    }
    private Boolean isUpdate() throws Exception {
        // Map<String, Object> params = new HashMap<String, Object>();
        // params.put("systemCode", systemCode);
        //params.put("versionCode", ThreadConfig.SOFT_VERSIONCODE);
        // params.put("orgCode", orgCode);
        // String returnString = "true";
        try {
            List<JSONObject> listSYSTEM = db.query("select * from system_param where param_key='VERSION'");
            if (listSYSTEM != null && listSYSTEM.size() > 0) {
                ThreadConfig.SOFT_VERSIONCODE = listSYSTEM.get(0).getString("param_value");
            } else {
                String sql = "insert into system_param (id,param_key,param_value) values " +
                        "('" + UUID.randomUUID() + "'," +
                        " 'VERSION' ," +
                        " '1'" +
                        ")";
                db.execute(sql);
                ThreadConfig.SOFT_VERSIONCODE = "1";
            }
            // resultString = HttpClientUtil.doPost(ThreadConfig.SERVICE_URL + ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG, params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("systemCode", systemCode);
            params.put("orgCode", orgCode);
            params.put("versionCode", ThreadConfig.SOFT_VERSIONCODE);
            params.put("access_token", token);
            String path = ThreadConfig.SERVICE_URL + ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG;//192.168.1.1:7070/getisupodate
            resultString = HttpsClientUtil.get(path, params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            //不需要更新返回空 需要更新返回版本号版本名称
            if (!StringUtils.isEmpty(resultString)) {
                net.sf.json.JSONObject jo = net.sf.json.JSONObject.fromObject(resultString);
                LogUtil.info("判断是否有需要更新的任务返回結果:" + resultString);
                versionName = String.valueOf(jo.get("versionName"));
                versionCode = String.valueOf(jo.get("versionCode"));
                downloadPath = String.valueOf(jo.get("file"));
                if (StringUtils.isEmpty(versionName)) {
                    return false;
                }
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            LogUtil.error("判断是否有需要更新的任务失败:" + e.getMessage());
            return false;
        }
    }
    private void sleep() throws Exception {
        LogUtil.info("更新线程开始睡眠,睡眠时间(分钟):" + ThreadConfig.UPDATE_THREAD_SLEEP_TIME);
        Thread.sleep(sleepTime * ThreadConfig.UPDATE_THREAD_SLEEP_TIME);
    }
    private String getFilePath() {
        SimpleDateFormat s = new SimpleDateFormat("yyyyMMddHHmmss");
        String home = System.getProperty("catalina.home").replace('\\', '/');
        //F:/{tomcat_home}/updateWar
        String fileName = s.format(new Date()).toString();
        // String fileName = "aaa";
        String folderPath = home + File.separator + "updateWar/";
        File file = new File(folderPath);
        //判断文件夹是否存在,如果不存在则创建文件夹
        if (!file.exists()) {
            file.mkdir();
        }
        return folderPath + fileName + ".war";
    }
    public static boolean getProcess() {
        boolean flag = false;
        try {
            Process p = Runtime.getRuntime().exec("cmd /c tasklist ");
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            InputStream os = p.getInputStream();
            byte b[] = new byte[256];
            while (os.read(b) > 0)
                baos.write(b);
            String s = baos.toString();
            if (s.indexOf("smss.exe") >= 0) {
                flag = true;
            } else {
                flag = false;
            }
        } catch (java.io.IOException ioe) {
        }
        return flag;
    }
    public static void main(String[] args) throws Exception {
        while (true) {
            String batPath = UpdateThread.class.getResource("/").getPath() + "config/serviceAlive.bat";
            System.out.println(batPath);
            Process ps = Runtime.getRuntime().exec(batPath);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            InputStream os = ps.getInputStream();
            byte b[] = new byte[256];
            while (os.read(b) > 0)
                baos.write(b);
            String s = baos.toString();
            System.out.println(s);
            os.close();
            baos.close();
            if (Boolean.valueOf(s.trim())) {
                break;
            }
        }
    }
}

+ 0 - 57
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/PathUtil.java

@ -1,57 +0,0 @@
package com.yihu.ehr.util;
import java.io.File;
/**
 * Created by chenweida on 2016/3/3.
 */
public class PathUtil {
    /**
     * 得到tomcat的根目录
     * F:\server\apache-tomcat-8.0.26
     *
     * @return
     */
    public static String getTomcatProjectRealPath() {
        String classesPath = PathUtil.class.getResource("/").getPath();
        String newPath = "";
        System.out.println(classesPath);
        String[] cpSize = null;
        if (classesPath.contains("/")) {
            cpSize = classesPath.split("/");
        } else {
            cpSize = classesPath.split(File.pathSeparator);
        }
        for (int i = 0; i < cpSize.length; i++) {
            if (i - 2 == 0) {
                break;
            } else {
                newPath += cpSize[i] + "/";
            }
        }
        System.out.println(newPath);
        return newPath;
    }
    public static void main(String[] args) {
        //F:/git/hos/Hos-Resource-Mini-helper/target/classes/
        String classesPath = PathUtil.class.getResource("/").getPath();
        String newPath = "";
        System.out.println(classesPath);
        String[] cpSize = null;
        if (classesPath.contains("/")) {
            cpSize = classesPath.split("/");
        } else {
            cpSize = classesPath.split(File.pathSeparator);
        }
        for (int i = 0; i < cpSize.length; i++) {
            if (i - 2 == 0) {
                break;
            } else {
                newPath += cpSize[i] + "/";
            }
        }
        System.out.println(newPath);
    }
}

+ 0 - 141
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/ZipUtil.java

@ -1,141 +0,0 @@
package com.yihu.ehr.util;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Zip;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Enumeration;
/**
 * Created by chenweida on 2016/2/27. 用的是ant解压缩
 */
public class ZipUtil {
    private static final int buffer = 1024;
    private static void createDirectory(String directory, String subDirectory) {
        String dir[];
        File fl = new File(directory);
        try {
            if (subDirectory == "" && fl.exists() != true) {
                fl.mkdir();
            } else if (subDirectory != "") {
                dir = subDirectory.replace('\\', '/').split("/");
                for (int i = 0; i < dir.length; i++) {
                    File subFile = new File(directory + File.separator + dir[i]);
                    if (subFile.exists() == false) {
                        subFile.mkdir();
                    }
                    directory += File.separator + dir[i];
                }
            }
        } catch (Exception ex) {
            return;
        }
    }
    /**
     * @param zipFilePath     解压的文件
     * @param outputDirectory 解压的文件路径
     * @return
     */
    @SuppressWarnings("unchecked")
    public static boolean unZip(String zipFilePath, String outputDirectory) {
        boolean flag = false;
        try {
            ZipFile zipFile = new ZipFile(zipFilePath);
            Enumeration e = zipFile.getEntries();
            ZipEntry zipEntry = null;
            createDirectory(outputDirectory, "");
            while (e.hasMoreElements()) {
                zipEntry = (ZipEntry) e.nextElement();
                if (zipEntry.isDirectory()) {
                    String name = zipEntry.getName().trim();
                    name = name.substring(0, name.length() - 1);
                    File f = new File(outputDirectory + File.separator + name);
                    if (!f.exists()) {
                        f.mkdir();
                    }
                } else {
                    String fileName = zipEntry.getName();
                    fileName = fileName.replace('\\', '/');
                    if (fileName.indexOf("/") != -1) {
                        createDirectory(outputDirectory, fileName.substring(0,
                                fileName.lastIndexOf("/")));
                        fileName = fileName
                                .substring(fileName.lastIndexOf("/") + 1);
                    }
                    File f = new File(outputDirectory + File.separator
                            + zipEntry.getName());
                    f.createNewFile();
                    InputStream in = zipFile.getInputStream(zipEntry);
                    FileOutputStream out = new FileOutputStream(f);
                    byte[] by = new byte[buffer];
                    int c;
                    while ((c = in.read(by)) != -1) {
                        out.write(by, 0, c);
                    }
                    in.close();
                    out.close();
                }
            }
            flag = true;
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
        return flag;
    }
    /**
     * 压缩
     *
     * @param srcDirName  要压缩的路径
     * @param zipFilePath 压缩的文件名字
     * @return
     */
    public static boolean zip(String srcDirName, String zipFilePath) {
        boolean flag = false;
        try {
            File srcdir = new File(srcDirName);
            if (!srcdir.exists())
                throw new RuntimeException(srcDirName + " is not exist!");
            Project prj = new Project();
            Zip zip_ = new Zip();
            zip_.setProject(prj);
            zip_.setDestFile(new File(zipFilePath));
            FileSet fileSet = new FileSet();
            fileSet.setProject(prj);
            fileSet.setDir(srcdir);
            zip_.addFileset(fileSet);
            zip_.execute();
            flag = true;
        } catch (Exception ex) {
            return false;
        }
        return flag;
    }
    public static void main(String[] args) {
        try {
            //ZipUtil.zip("F:/简历",
            //       "F:/sss.war");
            ZipUtil.unZip("E:/Hos-Resource-Mini-Update.war",
                    "E:/");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

+ 0 - 129
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/encode/Base64.java

@ -1,129 +0,0 @@
package com.yihu.ehr.util.encode;
/**
 * 标准Base64编解码,具体规范请参见相关文档。
 */
public class Base64 {
  /** Base64编码表。*/
  private static char Base64Code[] = {
    'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
    'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
    'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
    'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/',
  };
  /** Base64解码表。*/
  private static byte Base64Decode[] = {
    -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
    -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  //注意两个63,为兼容SMP,
    -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,63,-1,63,  //“/”和“-”都翻译成63。
    52,53,54,55,56,57,58,59,60,61,-1,-1,-1, 0,-1,-1,
    -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,  //注意两个0:
    15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,  //“A”和“=”都翻译成0。
    -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
    41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
  };
  /**
   * 构造方法私有化,防止实例化。
   */
  private Base64() {}
  /**
   * Base64编码。将字节数组中字节3个一组编码成4个可见字符。
   * @param b 需要被编码的字节数据。
   * @return 编码后的Base64字符串。
   */
  public static String encode(byte[] b) {
    int code = 0;
    //按实际编码后长度开辟内存,加快速度
    StringBuffer sb =new StringBuffer(((b.length-1)/3)<<2+4);
    //进行编码
    for (int i=0;i<b.length;i++) {
      code|=(b[i]<<(16-i%3*8)) & (0xff<<(16-i%3*8));
      if (i%3==2 || i==b.length-1) {
        sb.append(Base64Code[(code & 0xfc0000) >>> 18 ]);
        sb.append(Base64Code[(code & 0x3f000)  >>> 12 ]);
        sb.append(Base64Code[(code & 0xfc0)    >>> 6  ]);
        sb.append(Base64Code[ code & 0x3f             ]);
        code=0;
      }
    }
    //对于长度非3的整数倍的字节数组,编码前先补0,编码后结尾处编码用=代替,
    //=的个数和短缺的长度一致,以此来标识出数据实际长度
    if (b.length%3>0) {
      sb.setCharAt(sb.length()-1,'=');
    }
    if (b.length%3==1) {
      sb.setCharAt(sb.length()-2,'=');
    }
    return sb.toString();
  }
  /**
   * Base64解码。
   * @param code 用Base64编码的ASCII字符串
   * @return 解码后的字节数据
   */
  public static byte[] decode(String code) {
    //检查参数合法性
    if (code==null) {
      return null;
    }
    int len = code.length();
    if (len%4!=0) {
      throw new IllegalArgumentException("Base64 string length must be 4*n");
    }
    if (code.length()==0){
      return new byte[0];
    }
    //统计填充的等号个数
    int pad = 0;
    if (code.charAt(len-1)=='=') {
      pad++;
    }
    if (code.charAt(len-2)=='=') {
      pad++;
    }
    //根据填充等号的个数来计算实际数据长度
    int retLen = len/4*3 - pad;
    //分配字节数组空间
    byte[] ret = new byte [retLen];
    //查表解码
    char ch1,ch2,ch3,ch4;
    int i;
    for (i=0;i<len;i+=4) {
      int j=i/4*3;
      ch1 = code.charAt(i);
      ch2 = code.charAt(i+1);
      ch3 = code.charAt(i+2);
      ch4 = code.charAt(i+3);
      int tmp = (Base64Decode[ch1]<<18)|(Base64Decode[ch2]<<12)
                |(Base64Decode[ch3]<<6)|(Base64Decode[ch4]);
      ret[j] = (byte) ((tmp&0xff0000) >> 16);
        if (i<len-4) {
          ret[j+1] = (byte) ((tmp&0x00ff00) >> 8);
          ret[j+2] =(byte) ((tmp&0x0000ff));
        }
        else {
          if(j+1<retLen) {
            ret[j+1] = (byte) ((tmp&0x00ff00) >> 8);
          }
          if(j+2<retLen) {
            ret[j+2] = (byte) ((tmp&0x0000ff));
          }
        }
      }
      return ret;
    }
}

+ 0 - 106
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/encode/UnicodeReader.java

@ -1,106 +0,0 @@
package com.yihu.ehr.util.encode;
/**
 * UTF-8 编码工具类,解决bom问题
 * Created by HZY on 2015/8/12.
 */
import java.io.*;
/**
 * Generic unicode textreader, which will use BOM mark to identify the encoding
 * to be used. If BOM is not found then use a given default or system encoding.
 */
public class UnicodeReader extends Reader {
	PushbackInputStream internalIn;
	InputStreamReader internalIn2 = null;
	String defaultEnc;
	private static final int BOM_SIZE = 4;
	/**
	 * 
	 * @param in
	 *            inputstream to be read
	 * @param defaultEnc
	 *            default encoding if stream does not have BOM marker. Give NULL
	 *            to use system-level default.
	 */
	public UnicodeReader(InputStream in, String defaultEnc) {
		internalIn = new PushbackInputStream(in, BOM_SIZE);
		this.defaultEnc = defaultEnc;
	}
	public String getDefaultEncoding() {
		return defaultEnc;
	}
	/**
	 * Get stream encoding or NULL if stream is uninitialized. Call init() or
	 * read() method to initialize it.
	 */
	public String getEncoding() {
		if (internalIn2 == null)
			return null;
		return internalIn2.getEncoding();
	}
	/**
	 * Read-ahead four bytes and check for BOM marks. Extra bytes are unread
	 * back to the stream, only BOM bytes are skipped.
	 */
	protected void init() throws IOException {
		if (internalIn2 != null)
			return;
		String encoding;
		byte bom[] = new byte[BOM_SIZE];
		int n, unread;
		n = internalIn.read(bom, 0, bom.length);
		if ((bom[0] == (byte) 0x00) && (bom[1] == (byte) 0x00)
				&& (bom[2] == (byte) 0xFE) && (bom[3] == (byte) 0xFF)) {
			encoding = "UTF-32BE";
			unread = n - 4;
		} else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)
				&& (bom[2] == (byte) 0x00) && (bom[3] == (byte) 0x00)) {
			encoding = "UTF-32LE";
			unread = n - 4;
		} else if ((bom[0] == (byte) 0xEF) && (bom[1] == (byte) 0xBB)
				&& (bom[2] == (byte) 0xBF)) {
			encoding = "UTF-8";
			unread = n - 3;
		} else if ((bom[0] == (byte) 0xFE) && (bom[1] == (byte) 0xFF)) {
			encoding = "UTF-16BE";
			unread = n - 2;
		} else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)) {
			encoding = "UTF-16LE";
			unread = n - 2;
		} else {
			// Unicode BOM mark not found, unread all bytes
			encoding = defaultEnc;
			unread = n;
		}
		// System.out.println("read=" + n + ", unread=" + unread);
		if (unread > 0)
			internalIn.unread(bom, (n - unread), unread);
		// Use given encoding
		if (encoding == null) {
			internalIn2 = new InputStreamReader(internalIn);
		} else {
			internalIn2 = new InputStreamReader(internalIn, encoding);
		}
	}
	public void close() throws IOException {
		init();
		internalIn2.close();
	}
	public int read(char[] cbuf, int off, int len) throws IOException {
		init();
		return internalIn2.read(cbuf, off, len);
	}
}

+ 0 - 35
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/encrypt/DES.java

@ -1,35 +0,0 @@
package com.yihu.ehr.util.encrypt;
import com.yihu.ehr.util.encode.HexEncode;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
/**
 * @created Air 2015/6/2.
 */
public class DES {
    public static String encrypt(String data, String passWord) throws Exception {
        DESKeySpec desKey = new DESKeySpec(passWord.getBytes());
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
        SecretKey secretKey = keyFactory.generateSecret(desKey);
        Cipher cipher = Cipher.getInstance("DES");
        cipher.init(Cipher.ENCRYPT_MODE, secretKey);
        return HexEncode.toHexString(cipher.doFinal(data.getBytes()));
    }
    public static String decrypt(String data, String passWord) throws Exception {
        DESKeySpec desKey = new DESKeySpec(passWord.getBytes());
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
        SecretKey secretKey = keyFactory.generateSecret(desKey);
        Cipher cipher = Cipher.getInstance("DES");
        cipher.init(Cipher.DECRYPT_MODE, secretKey);
        return new String(cipher.doFinal(HexEncode.toBytes(data)));
    }
}

+ 0 - 75
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/encrypt/MD5.java

@ -1,75 +0,0 @@
package com.yihu.ehr.util.encrypt;
import com.yihu.ehr.util.encode.HexEncode;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.security.AccessController;
import java.security.MessageDigest;
import java.security.PrivilegedAction;
/**
 * @created  Air 2015/6/2.
 */
public class MD5 {
    static public String hash(String str) throws Exception {
        MessageDigest messageDigest = null;
        messageDigest = MessageDigest.getInstance("MD5");
        messageDigest.reset();
        messageDigest.update(str.getBytes());
        return HexEncode.toHexString(messageDigest.digest());
    }
    public static String getMd5ByFile(File file) throws FileNotFoundException {
        String value = null;
        FileInputStream in = new FileInputStream(file);
        MappedByteBuffer byteBuffer =null;
        try {
            byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(byteBuffer);
//            BigInteger bi = new BigInteger(1, md5.digest());
//            value = bi.toString(16);
            value= HexEncode.toHexString(md5.digest());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if(null != in) {
                try {
                    in.close();
                    clean(byteBuffer);
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return value;
    }
    public static void clean(final Object buffer) throws Exception {
        AccessController.doPrivileged(new PrivilegedAction() {
            public Object run() {
                try {
                    Method getCleanerMethod = buffer.getClass().getMethod("cleaner", new Class[0]);
                    getCleanerMethod.setAccessible(true);
                   // sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(buffer, new Object[0]);
                   // cleaner.clean();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return null;
            }
        });
    }
}

+ 0 - 218
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/file/FileUtil.java

@ -1,218 +0,0 @@
package com.yihu.ehr.util.file;
import java.io.*;
/**
 * @author Air
 * @version 1.0
 * @created 2015.06.25 14:14
 */
public class FileUtil {
    public static boolean writeFile(String filePath, String data, String encoding) throws IOException {
        File file = new File(filePath);
        if (!file.getParentFile().exists()) {
            if (!file.getParentFile().mkdirs()) {
                return false;
            }
        }
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, encoding);
        outputStreamWriter.write(data);
        outputStreamWriter.flush();
        outputStreamWriter.close();
        return true;
    }
    public static boolean writeFile(String filePath, byte[] bytes, String encoding) throws IOException {
        File file = new File(filePath);
        if (!file.getParentFile().exists()) {
            if (!file.getParentFile().mkdirs()) {
                return false;
            }
        }
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        byte[] bbuf = new byte[1024];
        InputStream fis = new ByteArrayInputStream(bytes);
        int hasRead = 0;
        //循环从输入流中取出数据
        while ((hasRead = fis.read(bbuf)) > 0) {
            fileOutputStream.write(bbuf, 0, hasRead);
        }
        fileOutputStream.close();
        return true;
    }
    public static boolean writeFile(String filePath,InputStream fis, String encoding) throws IOException {
        File file = new File(filePath);
        if (!file.getParentFile().exists()) {
            if (!file.getParentFile().mkdirs()) {
                return false;
            }
        }
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        byte[] bbuf = new byte[1024];
        int hasRead = 0;
        //循环从输入流中取出数据
        while ((hasRead = fis.read(bbuf)) > 0) {
            fileOutputStream.write(bbuf, 0, hasRead);
        }
        fileOutputStream.close();
        return true;
    }
    /**
     * 删除整个目录
     *
     * @param dir 目录
     * @return boolean
     * @created Airhead
     */
    public static boolean deleteDirectory(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            //递归删除目录中的子目录下
            for (int i = 0; i < children.length; i++) {
                boolean success = deleteDirectory(new File(dir, children[i]));
                if (!success) {
                    return false;
                }
            }
        }
        // 目录此时为空,可以删除
        return dir.delete();
    }
    /**
     * file转string
     * @param file 文件
     * @return string类型流
     */
    public static String convertFileToString(File file) {
        StringBuilder sb = new StringBuilder();
        if(file.isFile()&&file.exists()) {
            InputStreamReader read = null;
            try {
                read = new InputStreamReader(new FileInputStream(file), "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            BufferedReader reader = new BufferedReader(read);
            String line = null;
            try {
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return sb.toString();
    }
    /**
     * 清空文件内容
     * @param filePath 文件路径
     * @param content 写入内容
     */
    public static void clearInfoForFile(String filePath,String content) {
        File file =new File(filePath);
        try {
            if(!file.exists()) {
                file.createNewFile();
            }
            FileWriter fileWriter =new FileWriter(file);
            fileWriter.write(content);
            fileWriter.flush();
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /**
     * 记录文件最后读取的位置
     * @param readPath  被读取文件路径
     * @param savePath  保存被读取文件的最后位置 的文件路径
     */
    public static Integer  saveFilePos(String  readPath,  String  savePath)  {
        boolean result=false;
        File readFile=new File(readPath);
        Integer lenth=null;
        try  {
            if(readFile.exists()){
                InputStream inputStream = new FileInputStream(readPath);
                lenth = inputStream.available();
                clearInfoForFile(savePath,"");//清空内容
                writeFile(savePath,lenth.toString(),"UTF-8");//重新写入标识
            }
        }
        catch  (Exception  e)  {
            e.printStackTrace();
        }
        return lenth;
    }
    public static Integer getFileSize(String path) {
        Integer size=0;
        InputStream inputStream=null;
        File file=new File(path);
        if (file.exists()){
            try {
                inputStream = new FileInputStream(path);
                size = inputStream.available();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
       return size;
    }
    /**
     * 读取文本文件内容
     * @param file  文件路径
     * @return
     */
    public static String readFileText(File file) {
        StringBuilder stringBuilder = new StringBuilder();
        InputStream in = null;
        BufferedReader br = null;
        try {
            in = new FileInputStream(file);
            br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
            String line = null;
            while ((line = br.readLine()) != null) {
                stringBuilder.append(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e1) {
                }
            }
        }
        return stringBuilder.toString();
    }
}

+ 0 - 22
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/http/HopHostnameVerifier.java

@ -1,22 +0,0 @@
package com.yihu.ehr.util.http;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
/**
 * @author Air
 * @version 1.0
 * @created 2015.07.02 15:48
 */
public class HopHostnameVerifier implements HostnameVerifier {
    @Override
    public boolean verify(String hostname, SSLSession session) {
//        if("localhost".equals(hostname)){
//            return true;
//        } else {
//            return false;
//        }
        return true;
    }
}

+ 0 - 449
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/http/HttpClientUtil.java

@ -1,449 +0,0 @@
package com.yihu.ehr.util.http;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.util.StringUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * HTTP 请求工具类
 *
 * @author : cwd
 * @version : 1.0.0
 * @date : 2016/1/14
 * @see : TODO
 */
public class HttpClientUtil {
    /**
     * 发送 GET 请求(HTTP),不带输入数据 不加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url) throws Exception {
        return doGet(url, new HashMap<String, Object>(), "", "");
    }
    /**
     * 发送 GET 请求(HTTP),不带输入数据 不加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url, Map<String, Object> params) throws Exception {
        return doGet(url, params, "", "");
    }
    /**
     * 发送 GET 请求(HTTP),不带输入数据 加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url, String username, String password) throws Exception {
        return doGet(url, new HashMap<String, Object>(), username, password);
    }
    /**
     * httpClient的get请求方式
     *
     * @return
     * @throws Exception
     */
    public static String doGet(String url, Map<String, Object> params, String username, String password)
            throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        //设置请求信息
        try {
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpGet httpget = new HttpGet(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpget, context);
            } else {
                response1 = httpclient.execute(httpget);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            return "";
        } finally {
            response1.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * httpClient的post请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doPost(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            //流转字符串
            responString = EntityUtils.toString(httpEntity);
        } catch (Exception e) {
            return "";
        } finally {
            response.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * httpClient的put请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doPut(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpPut httpPut = new HttpPut(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpPut.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpPut, context);
            } else {
                response1 = httpclient.execute(httpPut);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            return "";
        } finally {
            response1.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * httpClient的delete请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doDelete(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpDelete httpget = new HttpDelete(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpget, context);
            } else {
                response1 = httpclient.execute(httpget);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            return "";
        } finally {
            response1.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * 文件上传
     *
     * @param file
     * @param url
     * @param username
     * @param password
     * @return
     * @throws IOException
     */
    public static String sendFile(File file, String url, String username, String password, Map<String, String> params) throws IOException {
        String responString = "";
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            httpPost.setConfig(requestConfig);
            FileBody bin = new FileBody(file);
            MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
            reqEntity.addPart("file", bin);
            httpPost.setEntity(reqEntity.build());
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            //流转字符串
            responString = EntityUtils.toString(httpEntity);
        } catch (Exception e) {
            return "";
        } finally {
            response.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * 文件下载
     *
     * @param filePath
     * @param url
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static File downFile(String filePath, Map<String, Object> params, String url, String username, String password) throws Exception {
        File file = null;
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            InputStream is = httpEntity.getContent();
            file = new File(filePath);
            file.getParentFile().mkdirs();
            FileOutputStream fileout = new FileOutputStream(file);
            /**
             * 根据实际运行效果 设置缓冲区大小
             */
            byte[] buffer = new byte[1024];
            int ch = 0;
            while ((ch = is.read(buffer)) != -1) {
                fileout.write(buffer, 0, ch);
            }
            is.close();
            fileout.flush();
            fileout.close();
        } catch (Exception e) {
            return null;
        } finally {
            response.close();
            httpclient.close();
        }
        return file;
    }
    public static void getFile(String url, String destFileName)
            throws Exception {
        // 生成一个httpclient对象
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpGet httpget = new HttpGet(url);
        HttpResponse response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();
        InputStream in = entity.getContent();
        File file = new File(destFileName);
        FileOutputStream fout = null;
        try {
            fout = new FileOutputStream(file);
            int l = -1;
            byte[] tmp = new byte[1024];
            while ((l = in.read(tmp)) != -1) {
                fout.write(tmp, 0, l);
                // 注意这里如果用OutputStream.write(buff)的话,图片会失真,大家可以试试
            }
            fout.flush();
        } finally {
            // 关闭低层流。
            if (in != null) {
                in.close();
            }
            if (fout != null) {
                fout.close();
            }
            httpclient.close();
        }
    }
    public static void main(String[] args) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("standard", "{\n" +
//                "    \"id\": 4,\n" +
//                "    \"name\": \"电子健康档案标准bbb\",\n" +
//                "    \"code\": \"YY20160114\",\n" +
//                "    \"publisher\": \"健康之路2\",\n" +
//                "    \"publisherOrgCode\": \"jkzl\",\n" +
//                "    \"summary\": \"string\",\n" +
//                "    \"refStandard\": \"WS2012\",\n" +
//                "    \"refStandardVersion\": \"V1.0\",\n" +
//                "    \"versionStatus\": 0\n" +
//                "}");
        // params.put("versionId", "5694696eb80d");
        //  params.put("publisher", "lfq");
        //   System.out.println(HttpClientUtil.doPost("http://192.168.131.17:6020/api/v1.0/standard_center/version/publish", params, "user", "standard"));
        //文件上传
        //File file = new File("F:/111.txt");
        // HttpClientUtil.sendFile(file, "http://192.168.131.6:8890/api/v1.0/resource/upload", "user", "standard");
        //文件下载
        //params.put("field", "[{\"key\":\"name\",\"value\":\"资源名称\"},{\"key\":\"code\",\"value\":\"资源代码\"},{\"key\":\"type\",\"value\":\"资源类型\"},{\"key\":\"category\",\"value\":\"资源类别\"}]");
        //params.put("name", "授权资源清单");
        //params.put("id", "aaaaaaaa1");
        // params.put("queryParams", "[]");
        params.put("systemCode", "test1");
        //  HttpClientUtil.downFile("E:/AADq8amUQ2161111.war", params, , "", "");
        HttpClientUtil.getFile("http://172.19.103.54/group1/M00/00/06/rBFuWVX6rQGADZfKAABQtFXK5o8933.war", "E:/AADq8amUQ2161231111.war");
    }
}

+ 0 - 513
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/http/HttpsClientUtil.java

@ -1,513 +0,0 @@
package com.yihu.ehr.util.http;
import com.yihu.ehr.config.ThreadConfig;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.util.encode.Base64;
import com.yihu.ehr.util.log.LogUtil;
import net.sf.json.JSONObject;
import org.apache.http.*;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2016/3/9.
 */
public class HttpsClientUtil {
    private static String sslPath = "/ssl/tomcat.keystore";
    private static String password = "123456";
    private static PoolingHttpClientConnectionManager connMgr = null;
    private static HttpClientBuilder httpClientBuilder = null;
    private static RestTemplate rt = null;//springRest模板
    private static DBHelper db = new DBHelper();
    private static String finger = "";
    public static String getToken() {
        try {
            if (StringUtils.isEmpty(finger)) {
                List<org.json.JSONObject> listSYSTEM = db.query("select * from system_param where param_key='FINGER_PRINT'");
                if (listSYSTEM != null && listSYSTEM.size() > 0) {
                    finger = listSYSTEM.get(0).getString("param_value");
                }
            }
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("info", "{\"fingerprint\": \"+finger+\"}");
            //得到加密的字符串
            String encodeString = Base64.encode((ThreadConfig.SERVICE_CLIENTID + ":" + ThreadConfig.SERVICE_CLIENTKEY).getBytes());
            String responString = HttpsClientUtil.doPut(ThreadConfig.SERVICE_URL + ThreadConfig.TOKEN_METHOD + ThreadConfig.TOKEN_USER_NAME, params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD,
                    new BasicHeader("Authorization", encodeString));
            System.out.println(responString);
            return String.valueOf(JSONObject.fromObject(responString).get("token"));
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.error("获取token失败");
            return "";
        }
    }
    static {
        //初始化证书
        try {
            String path = HttpsClientUtil.class.getResource("/").getPath() + "config/tomcat.keystore";
            System.out.println(path);
            acceptsUntrustedCertsHttpClient();
            //创建spring的RestTemplate并且初始化
            HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build());
            rt = new RestTemplate(clientHttpRequestFactory);
        } catch (Exception e) {
            LogUtil.error("初始化证书失败");
        }
    }
    public static RestTemplate getRestTemplate() {
        return rt;
    }
    public static CloseableHttpClient getCloseableHttpClient() {
        CloseableHttpClient c = httpClientBuilder.build();
        return c;
    }
    /**
     * 初始化连接池并且生成可以用的接口
     *
     * @return
     * @throws Exception
     */
    public static void acceptsUntrustedCertsHttpClient() throws Exception {
        httpClientBuilder = HttpClientBuilder.create();
        // String home = System.getProperty("catalina.home").replace('\\', '/');
        //String path=HttpsClientUtil.class.getResource(home + sslPath).getPath();
        String path = HttpsClientUtil.class.getResource("/").getPath() + "config/tomcat.keystore";
        // LogUtil.info("证书路径:" + home + sslPath);
        // 设置证书
        SSLContext sslContext = SSLContexts.custom()
                .loadTrustMaterial(new File(path), password.toCharArray(),
                        (TrustStrategy) new TrustSelfSignedStrategy())
                .build();
        httpClientBuilder.setSSLContext(sslContext);
        SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
                sslContext,
                new String[]{"TLSv1"},
                null,
                new HopHostnameVerifier());
        Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
                .register("https", sslSocketFactory)
                .build();
        connMgr = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
        httpClientBuilder.setConnectionManager(connMgr);
    }
    /**
     * 发送文件
     *
     * @param url        路径
     * @param filePath   文件路径
     * @param formParams 参数
     * @return
     */
    public static String postFile(String url, String filePath, List<NameValuePair> formParams, String username, String password) {
        CloseableHttpClient httpClient = getCloseableHttpClient();
        File file = new File(filePath);
        //设置请求信息
        RequestConfig requestConfig = RequestConfig.custom().
                setAuthenticationEnabled(true).build();
        //创建httppost请求
        HttpPost httpPost = new HttpPost(url);
        ArrayList<Header> headers = new ArrayList<Header>();
        httpPost.addHeader(new BasicHeader(HttpHeaders.AUTHORIZATION, "Basic a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P"));
        httpPost.setConfig(requestConfig);
        //新建文件对象并且设置文件
        FileBody bin = new FileBody(file);
        MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
        reqEntity.addPart("file", bin);
        //设置参数
        if (formParams != null && formParams.size() > 0) {
            for (NameValuePair nv : formParams) {
                reqEntity.addTextBody(nv.getName(), nv.getValue(), ContentType.create("text/plain", Charset.forName(HTTP.UTF_8)));
            }
        }
        httpPost.setEntity(reqEntity.build());
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            //设置验证
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpClient.execute(httpPost, context);
            } else {
                response = httpClient.execute(httpPost);
            }
            entity = response.getEntity();
            return EntityUtils.toString(entity, "UTF-8");
        } catch (IOException e) {
            return e.getMessage();
        } finally {
            close(httpClient, response);
        }
    }
    /**
     * post请求
     *
     * @param url        请求路径
     * @param formParams 请求参数
     * @param username
     * @param password
     * @return
     */
    public static String post(String url, List<NameValuePair> formParams, String username, String password) {
        CloseableHttpClient httpClient = getCloseableHttpClient();
        UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
        HttpPost httpPost = new HttpPost(url);
        httpPost.setEntity(postEntity);
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpClient.execute(httpPost, context);
            } else {
                response = httpClient.execute(httpPost);
            }
            entity = response.getEntity();
            return EntityUtils.toString(entity, "UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
            return e.getMessage();
        } finally {
            close(httpClient, response);
        }
    }
    /**
     * get请求
     *
     * @param url      路径
     * @param params   参数
     * @param username
     * @param password
     * @return
     */
    public static String get(String url, Map<String, Object> params, String username, String password) {
        String responString = "";
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = getCloseableHttpClient();
        //设置请求信息
        try {
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpGet httpget = new HttpGet(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpget, context);
            } else {
                response = httpclient.execute(httpget);
            }
            HttpEntity entity1 = response.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        } finally {
            close(httpclient, response);
        }
        return responString;
    }
    /**
     * 发送File
     *
     * @param filePath 文件路径
     * @param params   参数
     * @param url      http路径
     * @param username
     * @param password
     * @return
     */
    public static boolean downLoadFileByBase64(String filePath, Map<String, Object> params, String url, String username, String password) {
        File file = null;
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = getCloseableHttpClient();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).setConnectTimeout(8 * 1000 * 60).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            String responString = EntityUtils.toString(httpEntity);
            file = new File(filePath);
            file.getParentFile().mkdirs();
            System.out.println(responString.length());
            InputStream i = new ByteArrayInputStream(Base64.decode(responString));
            FileOutputStream fileout = new FileOutputStream(file);
            /**
             * 根据实际运行效果 设置缓冲区大小
             */
            byte[] buffer = new byte[1024];
            int ch = 0;
            while ((ch = i.read(buffer)) != -1) {
                fileout.write(buffer, 0, ch);
            }
            i.close();
            fileout.flush();
            fileout.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        } finally {
            close(httpclient, response);
        }
    }
    public static boolean downLoadFile(String filePath, Map<String, Object> params, String url, String username, String password) {
        File file = null;
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = getCloseableHttpClient();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).setConnectTimeout(8 * 1000 * 60).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            String responString = EntityUtils.toString(httpEntity);
            file = new File(filePath);
            file.getParentFile().mkdirs();
            System.out.println(responString.length());
            InputStream i = new ByteArrayInputStream(responString.getBytes("UTF-8"));
            FileOutputStream fileout = new FileOutputStream(file);
            /**
             * 根据实际运行效果 设置缓冲区大小
             */
            byte[] buffer = new byte[1024];
            int ch = 0;
            while ((ch = i.read(buffer)) != -1) {
                fileout.write(buffer, 0, ch);
            }
            i.close();
            fileout.flush();
            fileout.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        } finally {
            close(httpclient, response);
        }
    }
    /**
     * httpClient的put请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doPut(String url, Map<String, Object> params, String username, String password, Header header) {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = getCloseableHttpClient();
        try {
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpPut httpPut = new HttpPut(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            //kHAbVppx44:Bd2h8rdYhep6NKOO
            //a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P
            if (header != null) {
                httpPut.addHeader(header);
            }
            httpPut.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpPut, context);
            } else {
                response1 = httpclient.execute(httpPut);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.error("put请求失败" + e.getMessage());
        } finally {
            close(httpclient, response1);
        }
        return responString;
    }
    private static void close(CloseableHttpClient httpClient, CloseableHttpResponse response) {
        /*
        try {
            if (httpClient != null) {
                httpClient.close();
            }
        } catch (Exception e) {
            LogUtil.error("关闭httpClient失败");
        }
        try {
            if (response != null) {
                response.close();
            }
        } catch (Exception e) {
            LogUtil.error("关闭httpClient失败");
        }*/
    }
    public static void main(String[] args) {
        // List<NameValuePair> formParams = new ArrayList<NameValuePair>();
        //formParams.add(new BasicNameValuePair("systemCode", "MINIESB"));
        // formParams.add(new BasicNameValuePair("orgCode", "123"));
        // formParams.add(new BasicNameValuePair("access_token", "3801916fbd19d6fdc2adf2752b491a5d"));
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("access_token", "4cqetfocxyorlb5ug9umgatlpkjjn18n");
        params.put("systemCode", "MINIESB");
        params.put("orgCode", "FJWYSYY");
        //params.put("info", "{\"fingerprint\": \"abc\"}");
        //params.put("user_name", "admin");
        //POST /api/v1.0/simplified-esb/fillMiningPUT /api/v1.0/authorizations/users/{user_name}
        System.out.println(getToken());
        // System.out.println(HttpsClientUtil.post("https://192.168.5.109:4431/api/v1.0/simplified-esb/fillMining", formParams, "admin", "123456"));
        //params.put("access_token", "7txx6wx8cmak3zpnpralh3d9626z9vfu");
        //   params.put("systemCode", "MINIESB");
        //  params.put("orgCode", "test1");
        // params.put("info", "{\"fingerprint\": \"abc\"}");
        // HttpsClientUtil.downLoadFileByBase64("E:/a.war", params, "https://172.19.103.45:8443/api/v1.0/simplified-esb/downUpdateWar", "", "");
        //  HttpsClientUtil.downLoadFile("E:/b.zip", params, "https://192.168.131.6:4432/api/v1.0/simplified-esb/downUpdateWar", "", "");
    }
}

+ 0 - 40
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/log/LogUtil.java

@ -1,40 +0,0 @@
package com.yihu.ehr.util.log;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class LogUtil {
    static Logger logger = LogManager.getLogger(LogUtil.class.getName());
    public static void entry() {
        logger.entry();
    }
    public static void trace(String msg) {
        logger.trace(msg);
    }
    public static void info(String msg) {
        logger.info(msg);
    }
    public static void debug(String msg) {
        logger.debug(msg);
    }
    public static void error(String msg) {
        logger.error(msg);
    }
    public static void warn(String msg) {
        logger.warn(msg);
    }
    public static void fatal(String msg) {
        logger.fatal(msg);
    }
    public static void exit() {
        logger.exit();
    }
}

+ 0 - 47
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/BeanUtil.java

@ -1,47 +0,0 @@
package com.yihu.ehr.util.operator;
import org.apache.commons.beanutils.PropertyUtils;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
 * Created by lingfeng on 2015/12/29.
 */
public class BeanUtil {
    public static List objectArray2Bean(List list, Class beanClass){
        Constructor beanConstructor;
        try        {
            beanConstructor =  beanClass.getConstructor(new Class[] {Object[].class});
        }
        catch (Exception e)        {
            return null;
        }
        Iterator it = list.iterator();
        List result = new ArrayList();
        result.clear();
        while (it.hasNext())        {
            Object bean;
            try            {
                bean = beanConstructor.newInstance(new Object[] {it.next()});
            }
            catch (Exception e)            {
                return null;
            }
            result.add(beanClass.cast(bean));
        }
        return result;
    }
    public static Object getPropertyValue(Object o, String name) {
        try {
            return PropertyUtils.getProperty(o, name);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

+ 0 - 38
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/ConfigureUtil.java

@ -1,38 +0,0 @@
package com.yihu.ehr.util.operator;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import java.io.IOException;
import java.util.Properties;
/**
 *  获取配置文件内容滚工具类
 * Created by HZY on 2015/10/29.
 */
public class ConfigureUtil {
    /**
     * 获取.propertiest文件属性值
     * @param filePath  文件路径
     * @param key        属性名:key
     * @return value     属性值:value
     */
    public static String CRAWLER_PROPERTIES = "config/crawler.properties";
    public static String getProValue(String filePath, String key) {
        Resource resource = null;
        Properties props = null;
        String value = null;
        try {
            resource = new ClassPathResource(filePath);
            EncodedResource encRes = new EncodedResource(resource,"UTF-8");
            props = PropertiesLoaderUtils.loadProperties(encRes);
            value= (String) props.get(key);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return value;
    }
}

+ 0 - 1492
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/DateUtil.java

@ -1,1492 +0,0 @@
/****************************************************************************
 * Copyright(c) Yamaha Motor Solutions CO.,Ltd. 2010 All Rights Reserved
 * <p>
 * System Name:(smart)Human Resource Management System
 * SubSystem Name:-
 * service for all substystems
 * <p>
 * File Name: DateUtil
 * <p>
 * HISTORY RECORD
 * Ver.   Date           Create User/Update     Comment
 * -------------------------------------------------------------------------
 * 1.0    2010/07/12    tuchengye              New Making
 ***************************************************************************/
package com.yihu.ehr.util.operator;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.*;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
public class DateUtil {
    public static final String DEFAULT_DATE_YEAR_FORMAT = "yyyy";
    public static final String DEFAULT_DATE_MONTH_FORMAT = "MM";
    public static final String PRINT_DATE_YM_FORMAT = "MMM., yyyy";
    public static final String PRINT_DATE_YMD_FORMAT = "MMM. d, yyyy";
    public static final Locale PRINT_LOCALE = Locale.ENGLISH;
    public static final String DEFAULT_YEARS = "0.0";
    public static final String DEFAULT_DATE_YMD_FORMAT = "yyyy-MM-dd";
    public static final String DEFAULT_DATE_YM_FORMAT = "yyyyMM";
    public static final String DEFAULT_DATE_MD_FORMAT = "MMdd";
    public static final String DEFAULT_CHAR_DATE_YMD_FORMAT = "yyyyMMdd";
    public static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
    public final static String DEFAULT_SIMPLEDATE_FORMAT = "yyyy-MM-dd HH:mm:ss SSS";
    public final static String DEFAULT_YMDHMSDATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
    public static final String DEFAULT_NOW_STRING_FORMAT = "yyyyMMddHHmmssSSS";
    public static final String DATE_MDY_FORMAT = "MMddyyyy";
    public static final String DATE_MY_FORMAT = "MMyyyy";
    public static String changeFormat(String changeDate, String beforeFormat, String afterFormat) {
        if (StringUtil.isBlank(changeDate)) {
            return changeDate;
        }
        return formatDate(parseDate(changeDate, beforeFormat), afterFormat);
    }
    public static String changeToYMDFormatForPrint(String changeDate) {
        if (StringUtil.isBlank(changeDate)) {
            return "";
        }
        DateFormat df = new SimpleDateFormat(PRINT_DATE_YMD_FORMAT, Locale.ENGLISH);
        return df.format(parseDate(changeDate, DEFAULT_CHAR_DATE_YMD_FORMAT));
    }
    public static String changeToYMFormatForPrint(String changeDate) {
        if (StringUtil.isBlank(changeDate)) {
            return "";
        }
        DateFormat df = new SimpleDateFormat(PRINT_DATE_YM_FORMAT, Locale.ENGLISH);
        return df.format(parseDate(changeDate, DEFAULT_DATE_YM_FORMAT));
    }
    public static String getFirstDate(String yearMonthStr, String yearMonthFormat, String dateFormat) throws Exception {
        DateFormat dfYearMonth = new SimpleDateFormat(yearMonthFormat);
        DateFormat dfDate = new SimpleDateFormat(dateFormat);
        java.util.Date date;
        if (yearMonthStr == null || yearMonthStr.equals("")) {
            throw new Exception(yearMonthStr + " is invalid.");
        }
        try {
            date = dfYearMonth.parse(yearMonthStr);
        } catch (ParseException e) {
            throw new Exception(yearMonthStr + " is invalid.");
        }
        return dfDate.format(date);
    }
    public static String getLastDate(String dateSource, String dateSourceFormat, String dateFormat) throws Exception {
        DateFormat dsf = new SimpleDateFormat(dateSourceFormat);
        DateFormat df = new SimpleDateFormat(dateFormat);
        java.util.Date date;
        String resultDateString;
        if (dateSource == null || dateSource.equals("")) {
            throw new Exception(dateSource + " is invalid.");
        }
        try {
            date = dsf.parse(dateSource);
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
            resultDateString = df.format(cal.getTime());
        } catch (ParseException e) {
            throw new Exception(dateSource + " is invalid.");
        }
        return resultDateString;
    }
    public static String getYearFromDBDate(String dateStr) {
        if (dateStr == null || dateStr.length() != DEFAULT_CHAR_DATE_YMD_FORMAT.length()) {
            return null;
        }
        return changeFormat(dateStr, DEFAULT_CHAR_DATE_YMD_FORMAT, DEFAULT_DATE_YEAR_FORMAT);
    }
    public static String getMonthFromDBDate(String dateStr) {
        if (dateStr == null || dateStr.length() != DEFAULT_CHAR_DATE_YMD_FORMAT.length()) {
            return null;
        }
        return changeFormat(dateStr, DEFAULT_CHAR_DATE_YMD_FORMAT, DEFAULT_DATE_MONTH_FORMAT);
    }
    public static String getYMFromDBDate(String dateStr) {
        if (dateStr == null || dateStr.length() != DEFAULT_CHAR_DATE_YMD_FORMAT.length()) {
            return null;
        }
        return changeFormat(dateStr, DEFAULT_CHAR_DATE_YMD_FORMAT, DEFAULT_DATE_YM_FORMAT);
    }
    public static int getDifferenceOfDays(java.util.Date dateFrom, java.util.Date dateTo) {
        return new Long((dateTo.getTime() - dateFrom.getTime()) / 1000 / 60 / 60 / 24).intValue();
    }
    public static int getDifferenceOfDays(String dateFromStr, String dateToStr, String dateFormat) {
        java.util.Date dateFrom = parseDate(dateFromStr, dateFormat);
        java.util.Date dateTo = parseDate(dateToStr, dateFormat);
        return getDifferenceOfDays(dateFrom, dateTo);
    }
    public static int getDifferenceOfDays(String dateFromStr, String dateToStr) {
        return getDifferenceOfDays(dateFromStr, dateToStr, DEFAULT_CHAR_DATE_YMD_FORMAT);
    }
    public static String formatTime(String timeStr) {
        if (timeStr == null || timeStr.length() != 6) {
            return null;
        }
        return StringUtil.substring(timeStr, 0, 2)
                + ":" + StringUtil.substring(timeStr, 2, 4)
                + ":" + StringUtil.substring(timeStr, 4);
    }
    public static String toString(Date date) {
        return toString((java.util.Date) date);
    }
    public static String toString(java.util.Date date) {
        return toString(date, DEFAULT_DATE_YMD_FORMAT);
    }
    public static String toString(Date date, String format) {
        return toString((java.util.Date) date, format);
    }
    public static String toString(java.util.Date date, String format) {
        if (date == null) {
            return null;
        }
        if (format == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
    public static String formatTimestamp(Timestamp time) {
        return formatTimestamp(time, DEFAULT_TIMESTAMP_FORMAT);
    }
    public static String formatTimestamp(Timestamp time, String format) {
        if (time == null) {
            return null;
        }
        if (format == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(time);
    }
    public static String toString(Time time, String format) {
        if (time == null) {
            return null;
        }
        if (format == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(time);
    }
    public static Date formatCharDateYMD(String str) {
        return formatCharDateYMD(str, DEFAULT_DATE_YMD_FORMAT);
    }
    public static Date formatCharDateYMD(String str, String format) {
        if (str == null || str.trim().length() == 0) {
            return null;
        }
        if (format == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        ParsePosition pos = new ParsePosition(0);
        java.util.Date date = sdf.parse(str, pos);
        if (date == null) {
            return null;
        }
        return new Date(date.getTime());
    }
    public static Date formatCharDateYMD(String yy, String mm, String dd) {
        if (yy == null || mm == null || dd == null || yy.trim().length() == 0 ||
                mm.trim().length() == 0 || dd.trim().length() == 0) {
            return null;
        }
        return formatCharDateYMD(yy + "-" + (mm != null && mm.length() == 1 ? "0" + mm : mm) + "-" +
                (dd != null && dd.length() == 1 ? "0" + dd : dd));
    }
    public static Timestamp toTimestamp(String str) {
        if (str == null) {
            return null;
        }
        try {
            return Timestamp.valueOf(str.trim());
        } catch (IllegalArgumentException iae) {
            return null;
        }
    }
    public static Timestamp toTimestamp(String str, String format) {
        if (str == null) {
            return null;
        }
        try {
            return new Timestamp(parseDate(str, format).getTime());
        } catch (Exception e) {
            return null;
        }
    }
    public static Time toTime(String str) {
        if (str == null) {
            return null;
        }
        try {
            return (str.length() == 5 ? Time.valueOf(str + ":00") : Time.valueOf(str));
        } catch (Exception e) {
            return null;
        }
    }
    public static String toString(Time time) {
        return toString(time, DEFAULT_TIME_FORMAT);
    }
    public static String toYM(String yy, String mm) {
        if (yy == null || mm == null) {
            return null;
        }
        if (yy.trim().length() == 0 && mm.trim().length() != 0 ||
                yy.trim().length() != 0 && mm.trim().length() == 0) {
            return null;
        }
        return yy + (mm != null && mm.length() == 1 ? "0" + mm : mm);
    }
    public static String getNowDate() {
        return getNowDate(DEFAULT_NOW_STRING_FORMAT);
    }
    public static String getNowDate(String format) {
        if (format == null) {
            return null;
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.JAPAN);
        java.util.Date date = Calendar.getInstance().getTime();
        if (date == null) {
            return null;
        }
        return sdf.format(date);
    }
    public static Date getSysDate() {
        return new Date(Calendar.getInstance().getTime().getTime());
    }
    public static java.util.Date getSysDateYMDHMS() {
        Date dSysDateYMD = DateUtil.getSysDate();
        Timestamp ts = formatYMDToYMDHMS(StringUtil.toString(dSysDateYMD));
        return ts;
    }
    public static Timestamp getSysDateTime() {
        return new Timestamp(Calendar.getInstance().getTime().getTime());
    }
    public static Time getSysTime() {
        return new Time(Calendar.getInstance().getTime().getTime());
    }
    public static String toAge(String birthDay) {
        if (birthDay == null || birthDay.length() != 8) {
            return null;
        }
        int birthYear = Integer.parseInt(birthDay.substring(0, 4));
        int birthMonth = Integer.parseInt(birthDay.substring(4, 6));
        int birthDayOfMonth = Integer.parseInt(birthDay.substring(6, 8));
        return toAge(birthYear, birthMonth, birthDayOfMonth);
    }
    public static String toAge(int birthYear, int birthMonth, int birthDayOfMonth) {
        Calendar cl = Calendar.getInstance();
        int year = cl.get(Calendar.YEAR);
        int month = cl.get(Calendar.MONTH) + 1;
        int day = cl.get(Calendar.DAY_OF_MONTH);
        int sa = 0;
        if (month > birthMonth) {
            sa = 0;
        } else if (month == birthMonth && day >= birthDayOfMonth) {
            sa = 0;
        } else {
            sa = 1;
        }
        int age = year - birthYear - sa;
        return Integer.toString(age);
    }
    public static Date addDate(int add, java.util.Date d) {
        return addDate(add, new Date(d.getTime()));
    }
    public static java.util.Date addDateTime(int add, java.util.Date d) {
        return addDateTime(add, new Date(d.getTime()));
    }
    public static Date addDate(int add, Date d) {
        if (d == null) {
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime((java.util.Date) d);
        cal.setTimeZone(TimeZone.getDefault());
        cal.add(Calendar.DAY_OF_MONTH, add);
        return new Date(cal.getTime().getTime());
    }
    public static java.util.Date addDateTime(int add, Date d) {
        if (d == null) {
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime((java.util.Date) d);
        cal.setTimeZone(TimeZone.getDefault());
        cal.add(Calendar.DAY_OF_MONTH, add);
        return cal.getTime();
    }
    public static String addDate(int add, String sDate) {
        if (sDate.length() < 8) {
            return null;
        }
        return formatDate(addDate(add, formatCharDateYMD(sDate, DEFAULT_CHAR_DATE_YMD_FORMAT)), DEFAULT_CHAR_DATE_YMD_FORMAT);
    }
    public static Date addMonth(int add, java.util.Date d) {
        return addMonth(add, new Date(d.getTime()));
    }
    public static Date addMonth(int add, Date d) {
        if (d == null) {
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime((java.util.Date) d);
        cal.setTimeZone(TimeZone.getDefault());
        cal.add(Calendar.MONTH, add);
        return new Date(cal.getTime().getTime());
    }
    public static String addMonth(int add, String sDate) {
        if (sDate.length() < 8) {
            return null;
        }
        return formatDate(addMonth(add, formatCharDateYMD(sDate, DEFAULT_CHAR_DATE_YMD_FORMAT)), DEFAULT_CHAR_DATE_YMD_FORMAT);
    }
    public static Date addYear(int add, java.util.Date d) {
        return addYear(add, new Date(d.getTime()));
    }
    public static Date addYear(int add, Date d) {
        if (d == null) {
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime((java.util.Date) d);
        cal.setTimeZone(TimeZone.getDefault());
        cal.add(Calendar.YEAR, add);
        return new Date(cal.getTime().getTime());
    }
    public static String addYear(int add, String sDate) {
        if (sDate.length() < 8) {
            return null;
        }
        return formatDate(addYear(add, formatCharDateYMD(sDate, DEFAULT_CHAR_DATE_YMD_FORMAT)), DEFAULT_CHAR_DATE_YMD_FORMAT);
    }
    public static String getNowDateTime() {
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss", Locale.JAPAN);
        df.setTimeZone(TimeZone.getDefault());
        return df.format(new java.util.Date());
    }
    public static String getCurrentString() {
        return getCurrentString(DEFAULT_SIMPLEDATE_FORMAT);
    }
    public static String getCurrentString(String pattern) {
        SimpleDateFormat f = new SimpleDateFormat(pattern);
        return f.format(Calendar.getInstance(TimeZone.getDefault()).getTime());
    }
    public static long compareDate(String pattern, String s1, String s2) {
        SimpleDateFormat f = new SimpleDateFormat(pattern);
        try {
            return f.parse(s1).getTime() - f.parse(s2).getTime();
        } catch (Exception e) {
            return -1;
        }
    }
    public static long compareDate(java.util.Date s1, java.util.Date s2) {
        try {
            return compareDate(DEFAULT_DATE_YMD_FORMAT, toString(s1), toString(s2));
        } catch (Exception e) {
            return -1;
        }
    }
    public static long compareDateTime(java.util.Date s1, java.util.Date s2) {
        return s1.getTime() - s2.getTime();
    }
    public static java.util.Date parseDate(String value, String pattern) {
        try {
            TimeZone tz = TimeZone.getDefault();
            String dateFormat = pattern;
            SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
            sdf.setTimeZone(tz);
            // Parse date
            java.util.Date parsed = null;
            parsed = sdf.parse(value);
            return parsed;
        } catch (ParseException e) {
            return null;
        }
    }
    public static String formatDate(java.util.Date value, String pattern) {
        TimeZone tz = TimeZone.getDefault();
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        sdf.setTimeZone(tz);
        return sdf.format(value);
    }
    public static int getLastDay(Date dt) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(dt);
        int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        return lastDay;
    }
    public static String getYMDFormat(String datePtn) {
        final String[][] DATE_FORMAT_YMD_LIST = {{"1", "yyyy/MM/dd"},
                {"2", "yyyy.MM.dd"},
                {"3", "yyyy-MM-dd"},
                {"4", "MM/dd/yyyy"},
                {"5", "MM.dd.yyyy"},
                {"6", "MM-dd-yyyy"},
                {"7", "dd/MM/yyyy"},
                {"8", "dd.MM.yyyy"},
                {"9", "dd-MM-yyyy"},
                {"A", "dd/MM yyyy"}
        };
        String format = null;
        for (int i = 0; i < DATE_FORMAT_YMD_LIST.length; i++) {
            if (DATE_FORMAT_YMD_LIST[i][0].equals(datePtn)) {
                format = DATE_FORMAT_YMD_LIST[i][1];
                break;
            }
        }
        if (format == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return format;
    }
    public static String getYMFormat(String datePtn) {
        final String[][] DATE_FORMAT_YM_LIST = {{"1", "yyyy/MM"},
                {"2", "yyyy.MM"},
                {"3", "yyyy-MM"},
                {"4", "MM/yyyy"},
                {"5", "MM.yyyy"},
                {"6", "MM-yyyy"},
                {"7", "MM/yyyy"},
                {"8", "MM.yyyy"},
                {"9", "MM-yyyy"},
                {"A", "MM yyyy"},
                {"B", "yyyyMM"}
        };
        String format = null;
        for (int i = 0; i < DATE_FORMAT_YM_LIST.length; i++) {
            if (DATE_FORMAT_YM_LIST[i][0].equals(datePtn)) {
                format = DATE_FORMAT_YM_LIST[i][1];
                break;
            }
        }
        if (format == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return format;
    }
    public static String toYMD(Date date, String datePtn) {
        if (date == null) {
            return null;
        }
        return toString(date, getYMDFormat(datePtn));
    }
    public static String formatDateYMD(String str, String datePtn) {
        if (str == null || str.trim().length() == 0) {
            return null;
        }
        return toYMD(formatCharDateYMD(str), datePtn);
    }
    public static String formatDateYMD(String yy, String mm, String dd, String datePtn) {
        if (yy == null || mm == null || dd == null || yy.trim().length() == 0
                || mm.trim().length() == 0 || dd.trim().length() == 0) {
            return null;
        }
        return formatDateYMD(yy + "-" + (mm != null && mm.length() == 1 ? "0" + mm : mm)
                + "-" + (dd != null && dd.length() == 1 ? "0" + dd : dd), datePtn);
    }
    public static String formatDateYM(Date date, String datePtn) {
        if (date == null) {
            return null;
        }
        return toString(date, getYMFormat(datePtn));
    }
    public static String formatDateYM(String str, String datePtn) {
        if (str == null || str.trim().length() == 0) {
            return null;
        }
        return formatDateYM(formatCharDateYMD(str, DEFAULT_DATE_YM_FORMAT), datePtn);
    }
    public static String formatDateYM(String yy, String mm, String datePtn) {
        if (yy == null || mm == null || yy.trim().length() == 0 || mm.trim().length() == 0) {
            return null;
        }
        return formatDateYM(yy + (mm != null && mm.length() == 1 ? "0" + mm : mm), datePtn);
    }
    public static String getTimestampFormat(String dateStyleId) {
        return getYMDFormat(dateStyleId) + " HH:mm:ss";
    }
    public static Date toDateFromTime(String time) {
        try {
            return toDateFromTime(Long.parseLong(time));
        } catch (Exception iae) {
            return null;
        }
    }
    public static Date toDateFromTime(long time) {
        return new Date(time);
    }
    public static Timestamp toTimestampFromTime(String time) {
        try {
            return toTimestampFromTime(Long.parseLong(time));
        } catch (Exception iae) {
            return null;
        }
    }
    public static Timestamp toTimestampFromTime(long time) {
        return new Timestamp(time);
    }
    public static Timestamp toTimestampFromGMT(int yy, int mm, int dd, int hh, int mi, int ss) {
        return toTimestampFromGMT(
                String.valueOf(yy),
                String.valueOf(mm),
                String.valueOf(dd),
                String.valueOf(hh),
                String.valueOf(mi),
                String.valueOf(ss));
    }
    public static Timestamp toTimestampFromGMT(String yy, String mm, String dd,
                                               String hh, String mi, String ss) {
        mm = mm != null && mm.length() == 1 ? "0" + mm : mm;
        dd = dd != null && dd.length() == 1 ? "0" + dd : dd;
        hh = hh != null && hh.length() == 1 ? "0" + hh : hh;
        mi = mi != null && mi.length() == 1 ? "0" + mi : mi;
        ss = ss != null && ss.length() == 1 ? "0" + ss : ss;
        return toTimestampFromGMT(yy + "-" + mm + "-" + dd + " " + hh + ":" + mi + ":" + ss);
    }
    public static Timestamp toTimestampFromGMT(String str) {
        if (str == null) {
            return null;
        }
        SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_TIMESTAMP_FORMAT);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        ParsePosition pos = new ParsePosition(0);
        java.util.Date date = sdf.parse(str, pos);
        if (date == null) {
            return null;
        }
        return new Timestamp(date.getTime());
    }
    public static Timestamp toTimestampFromGMT(Timestamp time) {
        return toTimestampFromGMT(StringUtil.toString(time));
    }
    public static Timestamp toTimestampFromLocal(String yy, String mm, String dd, String hh,
                                                 String mi, String ss, String differTimeSign,
                                                 String differenceTime, String summerTimeFrom,
                                                 String summerTimeTo, String summerTime) {
        mm = mm != null && mm.length() == 1 ? "0" + mm : mm;
        dd = dd != null && dd.length() == 1 ? "0" + dd : dd;
        hh = hh != null && hh.length() == 1 ? "0" + hh : hh;
        mi = mi != null && mi.length() == 1 ? "0" + mi : mi;
        ss = ss != null && ss.length() == 1 ? "0" + ss : ss;
        return toTimestampFromLocal(
                yy + "-" + mm + "-" + dd + " " + hh + ":" + mi + ":" + ss,
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime);
    }
    public static Timestamp toTimestampFromLocal(String str, String differTimeSign,
                                                 String differenceTime, String summerTimeFrom,
                                                 String summerTimeTo, String summerTime) {
        if (str == null) {
            return null;
        }
        Timestamp time = toTimestamp(str);
        if (time == null) {
            return null;
        }
        long localTime = toGMTTimeFromLocalTime(
                time.getTime(),
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime);
        return toTimestampFromGMT(new Timestamp(localTime));
    }
    public static Timestamp toTimestampFromLocal(Timestamp time, String differTimeSign,
                                                 String differenceTime, String summerTimeFrom,
                                                 String summerTimeTo, String summerTime) {
        return toTimestampFromLocal(
                StringUtil.toString(time),
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime);
    }
    public static long toGMTTime(long local) {
        SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_TIMESTAMP_FORMAT);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        ParsePosition pos = new ParsePosition(0);
        java.util.Date date = sdf.parse(StringUtil.toString(new Timestamp(local)), pos);
        if (date == null) {
            return -1;
        }
        return date.getTime();
    }
    public static long toGMTTime(Timestamp local) {
        if (local == null) {
            return -1;
        }
        return toGMTTime(local.getTime());
    }
    public static Timestamp toGMTTimestamp(long local) {
        long time = toGMTTime(local);
        if (time == -1) {
            return null;
        }
        return new Timestamp(time);
    }
    public static Timestamp toGMTTimestamp(Timestamp local) {
        if (local == null) {
            return null;
        }
        return toGMTTimestamp(local.getTime());
    }
    public static String toYMD(String yy, String mm, String dd) {
        if (yy == null || mm == null || dd == null) {
            return null;
        }
        if (yy.trim().length() == 0 || mm.trim().length() == 0) {
            return "";
        }
        mm = mm != null && mm.length() == 1 ? "0" + mm : mm;
        if (dd != null && dd.length() == 0) {
            dd = "  ";
        }
        if (dd != null && dd.length() == 1) {
            dd = "0" + dd;
        }
        return yy + mm + dd;
    }
    public static String getYearFromYM(String ym) {
        if (ym == null || ym.length() != DEFAULT_DATE_YM_FORMAT.length()) {
            return null;
        }
        return ym.substring(0, 4);
    }
    public static String getMonthFromYM(String ym) {
        if (ym == null || ym.length() != DEFAULT_DATE_YM_FORMAT.length()) {
            return null;
        }
        return ym.substring(4, 6);
    }
    public static String getYearFromYMD(Date ymd) {
        return getYearFromYMD(toString(ymd));
    }
    public static String getMonthFromYMD(Date ymd) {
        return getMonthFromYMD(toString(ymd));
    }
    public static String getDateFromYMD(Date ymd) {
        return getDateFromYMD(toString(ymd));
    }
    public static String getYearFromYMD(String ymd) {
        if (ymd == null || ymd.length() != DEFAULT_DATE_YMD_FORMAT.length()) {
            return null;
        }
        return ymd.substring(0, 4);
    }
    public static String getMonthFromYMD(String ymd) {
        if (ymd == null || ymd.length() != DEFAULT_DATE_YMD_FORMAT.length()) {
            return null;
        }
        return ymd.substring(5, 7);
    }
    public static String getDateFromYMD(String ymd) {
        if (ymd == null || ymd.length() != DEFAULT_DATE_YMD_FORMAT.length()) {
            return null;
        }
        return ymd.substring(8, 10);
    }
    public static String getHourFromHMS(String hms) {
        if (hms == null || hms.length() != DEFAULT_TIME_FORMAT.length()) {
            return null;
        }
        return hms.substring(0, 2);
    }
    public static String getMinuteFromHMS(String hms) {
        if (hms == null || hms.length() != DEFAULT_TIME_FORMAT.length()) {
            return null;
        }
        return hms.substring(3, 5);
    }
    public static String getSecondFromHMS(String hms) {
        if (hms == null || hms.length() != DEFAULT_TIME_FORMAT.length()) {
            return null;
        }
        return hms.substring(6, 8);
    }
    public static String formatDateYMD(Date date, String dateStyleId) {
        if (date == null) {
            return null;
        }
        return toString(date, getYMDFormat(dateStyleId));
    }
    public static long getSystemTime() {
        return Calendar.getInstance().getTime().getTime();
    }
    public static Timestamp getSystemTimestamp() {
        return new Timestamp(getSystemTime());
    }
    public static long getSystemTimeGMTToday() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        Timestamp today = toTimestamp(sdf.format(Calendar.getInstance().getTime()) + " 00:00:00");
        return toGMTTime(today);
    }
    public static Timestamp getSystemTimestampGMTToday() {
        long time = getSystemTimeGMTToday();
        if (time == -1) {
            return null;
        }
        return new Timestamp(time);
    }
    public static Date getSysDateGMTToday() {
        long time = getSystemTimeGMTToday();
        if (time == -1) {
            return null;
        }
        return new Date(getSystemTimeGMTToday());
    }
    public static String formatTimestamp(Timestamp time, String differTimeSign,
                                         String differenceTime, String summerTimeFrom,
                                         String summerTimeTo, String summerTime) {
        if (time == null) {
            return null;
        }
        return toStringFormatLocalTime(
                time.getTime(),
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime,
                DEFAULT_TIMESTAMP_FORMAT);
    }
    public static String formatTimestamp(Timestamp time, String differTimeSign,
                                         String differenceTime, String summerTimeFrom,
                                         String summerTimeTo, String summerTime, String dateStyleId) {
        if (time == null) {
            return null;
        }
        return toStringFormatLocalTime(
                time.getTime(),
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime,
                getTimestampFormat(dateStyleId));
    }
    public static String formatTimestamp(long time, String differTimeSign, String differenceTime,
                                         String summerTimeFrom, String summerTimeTo, String summerTime) {
        return toStringFormatLocalTime(
                time,
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime,
                DEFAULT_TIMESTAMP_FORMAT);
    }
    public static String formatTimestamp(long time, String differTimeSign, String differenceTime,
                                         String summerTimeFrom, String summerTimeTo,
                                         String summerTime, String dateStyleId) {
        return toStringFormatLocalTime(
                time,
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime,
                getTimestampFormat(dateStyleId));
    }
    public static String formatTimestampToDate(Timestamp time, String differTimeSign,
                                               String differenceTime, String summerTimeFrom,
                                               String summerTimeTo, String summerTime) {
        if (time == null) {
            return null;
        }
        return toStringFormatLocalTime(
                time.getTime(),
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime,
                DEFAULT_DATE_YMD_FORMAT);
    }
    public static String formatTimestampToDate(Timestamp time, String differTimeSign,
                                               String differenceTime, String summerTimeFrom,
                                               String summerTimeTo, String summerTime, String dateStyleId) {
        if (time == null) {
            return null;
        }
        return toStringFormatLocalTime(
                time.getTime(),
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime,
                getYMDFormat(dateStyleId));
    }
    public static String formatTimestampToDate(long time, String differTimeSign,
                                               String differenceTime, String summerTimeFrom,
                                               String summerTimeTo, String summerTime) {
        return toStringFormatLocalTime(
                time,
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime,
                DEFAULT_DATE_YMD_FORMAT);
    }
    public static String formatTimestampToDate(long time, String differTimeSign,
                                               String differenceTime, String summerTimeFrom,
                                               String summerTimeTo, String summerTime, String dateStyleId) {
        return toStringFormatLocalTime(
                time,
                differTimeSign,
                differenceTime,
                summerTimeFrom,
                summerTimeTo,
                summerTime,
                getYMDFormat(dateStyleId));
    }
    public static String toStringFormatLocalTime(long time, String differTimeSign,
                                                 String differenceTime, String summerTimeFrom,
                                                 String summerTimeTo, String summerTime, String format) {
        long localTime = time;
        long differenceTimeLong = toDifferenceTimeLong(differenceTime);
        long summerTimeLong = toSummerTimeLong(summerTime);
        if (differTimeSign != null && differTimeSign.equals("+")) {
            localTime += differenceTimeLong;
        } else {
            localTime -= differenceTimeLong;
        }
        if (isSummerTime(time, summerTimeFrom, summerTimeTo)) {
            localTime -= summerTimeLong;
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        return sdf.format(new java.util.Date(localTime));
    }
    public static long toGMTTimeFromLocalTime(long localTime, String differTimeSign,
                                              String differenceTime, String summerTimeFrom,
                                              String summerTimeTo, String summerTime) {
        long time = localTime;
        long differenceTimeLong = toDifferenceTimeLong(differenceTime);
        long summerTimeLong = toSummerTimeLong(summerTime);
        if (differTimeSign != null && differTimeSign.equals("+")) {
            time -= differenceTimeLong;
        } else {
            time += differenceTimeLong;
        }
        if (isSummerTime(localTime, summerTimeFrom, summerTimeTo)) {
            time += summerTimeLong;
        }
        return time;
    }
    public static long toDifferenceTimeLong(String differenceTime) {
        long differenceTimeLong;
        try {
            long differenceTimeM = Long.parseLong(differenceTime.substring(0, 2));
            long differenceTimeS = Long.parseLong(differenceTime.substring(2, 4));
            differenceTimeLong = (differenceTimeM * 60 * 60 * 1000) + (differenceTimeS * 60 * 1000);
        } catch (Exception e) {
            differenceTimeLong = 0;
        }
        return differenceTimeLong;
    }
    public static long toSummerTimeLong(String summerTime) {
        long summerTimeLong;
        try {
            long summerTimeM = Long.parseLong(summerTime.substring(0, 2));
            long summerTimeS = Long.parseLong(summerTime.substring(2, 4));
            summerTimeLong = (summerTimeM * 60 * 60 * 1000) + (summerTimeS * 60 * 1000);
        } catch (Exception e) {
            summerTimeLong = 0;
        }
        return summerTimeLong;
    }
    public static boolean isSummerTime(long time, String summerTimeFrom, String summerTimeTo) {
        if (summerTimeFrom == null || summerTimeFrom.trim().length() != 4 ||
                summerTimeTo == null || summerTimeTo.trim().length() != 4) {
            return false;
        }
        SimpleDateFormat sdf = new SimpleDateFormat(DEFAULT_DATE_MD_FORMAT);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        String md = sdf.format(new java.util.Date(time));
        if (md.compareTo(summerTimeFrom) >= 0 && md.compareTo(summerTimeTo) <= 0) {
            // サマータイム
            return true;
        } else {
            return false;
        }
    }
    public static String formatGMTTimestamp(Timestamp time) {
        return toStringFormatGMTTime(time, DEFAULT_TIMESTAMP_FORMAT);
    }
    public static String formatGMTTimestamp(Timestamp time, String dateStyleId) {
        return toStringFormatGMTTime(time, getTimestampFormat(dateStyleId));
    }
    public static String formatGMTTimestamp(long time) {
        return toStringFormatGMTTime(time, DEFAULT_TIMESTAMP_FORMAT);
    }
    public static String formatGMTTimestamp(long time, String dateStyleId) {
        return toStringFormatGMTTime(time, getTimestampFormat(dateStyleId));
    }
    public static String formatGMTTimestampToDate(Timestamp time) {
        return toStringFormatGMTTime(time, DEFAULT_DATE_YMD_FORMAT);
    }
    public static String formatGMTTimestampToDate(Timestamp time, String dateStyleId) {
        return toStringFormatGMTTime(time, getYMDFormat(dateStyleId));
    }
    public static String formatGMTTimestampToDate(long time) {
        return toStringFormatGMTTime(time, DEFAULT_DATE_YMD_FORMAT);
    }
    public static String formatGMTTimestampToDate(long time, String dateStyleId) {
        return toStringFormatGMTTime(time, getYMDFormat(dateStyleId));
    }
    public static String toStringFormatGMTTime(Timestamp time, String format) {
        if (time == null) {
            return null;
        }
        return toStringFormatGMTTime(time.getTime(), format);
    }
    public static String toStringFormatGMTTime(long time, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        return sdf.format(new java.util.Date(time));
    }
    public static String toStringFormatTime(long time, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(new java.util.Date(time));
    }
    public static int getLastDay(int yy, int mm) {
        GregorianCalendar gc = new GregorianCalendar(yy, mm - 1, 1);
        return gc.getActualMaximum(GregorianCalendar.DATE);
    }
    public static String getLocalPattern(Locale locale) {
        SimpleDateFormat f = new SimpleDateFormat();
        f.setCalendar(Calendar.getInstance(locale));
        return f.toLocalizedPattern();
    }
    public static int getYears(java.util.Date date0, java.util.Date date1) {
        Calendar calendar0 = Calendar.getInstance();
        calendar0.setTime(date0);
        Calendar calendar1 = Calendar.getInstance();
        calendar1.setTime(date1);
        int year0 = calendar0.get(Calendar.YEAR);
        int year1 = calendar1.get(Calendar.YEAR);
        int years = year1 - year0;
        return years;
    }
    public static String getDifferenceOfYears(java.util.Date dateFrom, java.util.Date dateTo) {
        String years = DEFAULT_YEARS;
        if (dateFrom == null || dateTo == null) {
            years = DEFAULT_YEARS;
        } else {
            int days = getDifferenceOfDays(dateFrom, dateTo);
            DecimalFormat df = new DecimalFormat("#.0");
            years = df.format(days / 365.0);
        }
        return years;
    }
    public static Date formatCharDateYMDHMS(String str) {
        String format = DEFAULT_YMDHMSDATE_FORMAT;
        if (str == null || str.trim().length() == 0) {
            return null;
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        ParsePosition pos = new ParsePosition(0);
        java.util.Date date = sdf.parse(str, pos);
        if (date == null) {
            return null;
        }
        return new Date(date.getTime());
    }
    public static Timestamp formatYMDToYMDHMS(String str) {
        String format = DEFAULT_YMDHMSDATE_FORMAT;
        if (str == null || str.trim().length() == 0) {
            return null;
        }
        str += " 00:00:00";
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        ParsePosition pos = new ParsePosition(0);
        java.util.Date date = sdf.parse(str, pos);
        if (date == null) {
            return null;
        }
        Timestamp ts = DateUtil.fromatDateToTimestamp(new Date(date.getTime()));
        return ts;
    }
    public static Timestamp fromatDateToTimestamp(java.util.Date date) {
        Timestamp ts = new Timestamp(System.currentTimeMillis());
        try {
            SimpleDateFormat df = new SimpleDateFormat(DEFAULT_YMDHMSDATE_FORMAT);
            String time = df.format(date);
            ts = Timestamp.valueOf(time);
        } catch (Exception e) {
            return null;
        }
        return ts;
    }
    /**
     * 获取标准时区偏移
     * @return
     */
    public static int geTimeZoneOffset(){
        int offset=0;
        Calendar cal = Calendar.getInstance();
        TimeZone timeZone = cal.getTimeZone();
        offset=timeZone.getRawOffset()/(1000*60*60);
        return offset;
    }
    /**
     *  凌晨0点的时间
     * @param date  时间
     * @param days  正数为 days天后 ,负数为 days天前
     * @return
     */
    public static java.util.Date getTimesmorning(java.util.Date date,int days){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.DATE, cal.get(Calendar.DATE) +(days));
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return  cal.getTime();
    }
    /**
     *  晚上24点的时间
     * @param date  时间
     * @param days  正数为 days天后 ,负数为 days天前
     * @return
     */
    public static java.util.Date getTimesnight(java.util.Date date,int days){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.DATE, cal.get(Calendar.DATE) +(days));
        cal.set(Calendar.HOUR_OF_DAY, 24);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return  cal.getTime();
    }
    /**
     *  日期加减天数 (可优化)
     * @param date 时间
     * @param days 天数差
     * @return
     */
    public static java.util.Date setDateTime(java.util.Date date,int days){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.DATE, cal.get(Calendar.DATE) +(days));
        return  cal.getTime();
    }
    public static Boolean isExpire(java.util.Date fromDate, java.util.Date endDate, Integer expiresIn){
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long diff = (endDate.getTime() - fromDate.getTime())/1000;
        if(diff > expiresIn){
            return true;
        }
        else{
            return false;
        }
    }
}

+ 0 - 89
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/ListSortUtil.java

@ -1,89 +0,0 @@
/******************************************************************************/
/* SYSTEM     : Commons                                                       */
/*                                                                            */
/* SUBSYSTEM  : Util                                                          */
/******************************************************************************/
package com.yihu.ehr.util.operator;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparableComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.collections.comparators.NullComparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ListSortUtil {
    public static ArrayList sort(ArrayList list, String[] fields) throws IllegalArgumentException {
        if (fields == null) {
            throw new IllegalArgumentException("fields is null.");
        }
        return sort(list, fields, new boolean[fields.length]);
    }
    public static List sort(List list, String[] fields) throws IllegalArgumentException {
        if (fields == null) {
            throw new IllegalArgumentException("fields is null.");
        }
        return sort(list, fields, new boolean[fields.length]);
    }
    public static ArrayList sort(ArrayList list, String[] fields, boolean[] reverses) throws IllegalArgumentException {
        return (ArrayList) sort((List) list, fields, reverses);
    }
    public static List sort(List list, String[] fields, boolean[] reverses) throws IllegalArgumentException {
        if (list == null || list.size() == 0) {
            return list;
        }
        if (fields == null) {
            throw new IllegalArgumentException("fields is null.");
        }
        if (reverses == null) {
            throw new IllegalArgumentException("reverses is null.");
        }
        if (fields.length != reverses.length) {
            throw new IllegalArgumentException("The size of fields and reverses is not in agreement.");
        }
        if (fields.length == 0) {
            return list;
        }
        // マルチカラムソート用のコンパレータ
        ComparatorChain cc = new ComparatorChain();
        for (int i = 0; fields != null && i < fields.length; i++) {
            String field = fields[i];
            boolean reverse = reverses[i];
            if (field.trim().length() == 0) {
                continue;
            }
            cc.addComparator(
                    new BeanComparator(
                            field,
                            new NullComparator(ComparableComparator.getInstance())),
                    reverse);
        }
        if (cc.size() != 0) {
            // ソート
            Collections.sort(list, cc);
        }
        return list;
    }
}

+ 0 - 636
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/NumberUtil.java

@ -1,636 +0,0 @@
package com.yihu.ehr.util.operator;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class NumberUtil {
    public static final BigDecimal DEFAULT_NUMBER = BigDecimal.ZERO;
    public static final String DECIMAL_FORMAT = "#,##0.00";
    public static final String INTEGER_FORMAT = "#,##0";
    public static final String DEFAULT_NUM_GROUP_STYLE_ID = "1";
    public static final String DEFAULT_DECIMAL_STYLE_ID = "2";
    public static final String[][] DECIMAL_STYLE_LIST = {
            {"1", ",", "Comma"},
            {"2", ".", "Period"}
    };
    public static final String[][] NUM_GROUP_STYLE_LIST = {
            {"1", ",", "Comma"},
            {"2", ".", "Period"},
            {"3", " ", "Space"}
    };
    protected NumberUtil() {
    }
    public static boolean isDivisible(BigDecimal dividend, BigDecimal divisor) {
        if (dividend == null || divisor == null) {
            return false;
        }
        if (compare(dividend.remainder(divisor), DEFAULT_NUMBER) == 0) {
            return true;
        }
        return false;
    }
    public static String changeToDecimalFormat(Number num) {
        return formatNumber(num, DECIMAL_FORMAT);
    }
    public static String changeToIntegerFormat(Number num) {
        return formatNumber(num, INTEGER_FORMAT);
    }
    public static String formatNumber(Number num, String format) {
        DecimalFormat noFormat = new DecimalFormat(format);
        return noFormat.format(num);
    }
    public static int compare(BigDecimal num1, BigDecimal num2) {
        if (num1 == null) {
            num1 = DEFAULT_NUMBER;
        }
        if (num2 == null) {
            num2 = DEFAULT_NUMBER;
        }
        return num1.compareTo(num2);
    }
    public static boolean gt(BigDecimal num1, BigDecimal num2) {
        if (compare(num1, num2) > 0) {
            return true;
        }
        return false;
    }
    public static boolean ge(BigDecimal num1, BigDecimal num2) {
        return !lt(num1, num2);
    }
    public static boolean lt(BigDecimal num1, BigDecimal num2) {
        if (compare(num1, num2) < 0) {
            return true;
        }
        return false;
    }
    public static boolean le(BigDecimal num1, BigDecimal num2) {
        return !gt(num1, num2);
    }
    public static boolean equals(BigDecimal num1, BigDecimal num2) {
        if (compare(num1, num2) == 0) {
            return true;
        }
        return false;
    }
    public static boolean equals(int num1, int num2) {
        if (compare(new BigDecimal(String.valueOf(num1)), new BigDecimal(String.valueOf(num2))) == 0) {
            return true;
        }
        return false;
    }
    public static boolean isPositive(BigDecimal num) {
        if (num == null) {
            return false;
        }
        if (gt(num, BigDecimal.ZERO)) {
            return true;
        }
        return false;
    }
    public static boolean isZero(BigDecimal num) {
        if (num == null) {
            return false;
        }
        if (equals(num, BigDecimal.ZERO)) {
            return true;
        }
        return false;
    }
    public static BigDecimal subtractBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).subtract(dec2 != null ? dec2 : DEFAULT_NUMBER);
    }
    public static BigDecimal multiplyBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).multiply(dec2 != null ? dec2 : DEFAULT_NUMBER);
    }
    public static BigDecimal divideBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        if (dec2 == null || dec2.equals(DEFAULT_NUMBER)) {
            return DEFAULT_NUMBER;
        }
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(dec2, 2, BigDecimal.ROUND_HALF_UP);
    }
    public static BigDecimal divideBigDecimal(BigDecimal dec1, BigDecimal dec2, int scale) {
        if (dec2 == null || dec2.equals(DEFAULT_NUMBER)) {
            return DEFAULT_NUMBER;
        }
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(dec2, scale, BigDecimal.ROUND_HALF_UP);
    }
    public static BigDecimal floorDivideBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        if (dec2 == null || dec2.equals(DEFAULT_NUMBER)) {
            return DEFAULT_NUMBER;
        }
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(dec2, 0, BigDecimal.ROUND_FLOOR);
    }
    public static BigDecimal ceilingDivideBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        if (dec2 == null || dec2.equals(DEFAULT_NUMBER)) {
            return DEFAULT_NUMBER;
        }
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(dec2, 0, BigDecimal.ROUND_CEILING);
    }
    public static BigDecimal toBigDecimal(int num) {
        return toBigDecimal(StringUtil.toString(num));
    }
    public static Integer toInteger(long num) {
        return toInteger(StringUtil.toString(num));
    }
    public static BigDecimal roundBigDecimal(BigDecimal dec1, int scale) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(new BigDecimal("1"), scale, BigDecimal.ROUND_HALF_UP);
    }
    public static BigDecimal floorBigDecimal(BigDecimal dec1, int scale) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(new BigDecimal("1"), scale, BigDecimal.ROUND_FLOOR);
    }
    public static BigDecimal ceilingBigDecimal(BigDecimal dec1, int scale) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(new BigDecimal("1"), scale, BigDecimal.ROUND_CEILING);
    }
    public static Boolean toBoolean(String str) {
        try {
            return new Boolean(str);
        } catch (Exception e) {
            return null;
        }
    }
    public static int toInt(String str) {
        Integer integer = toInteger(str);
        return (integer == null ? 0 : integer.intValue());
    }
    public static int toInt(Integer integer) {
        return (integer == null ? 0 : integer.intValue());
    }
    public static Integer toInteger(String str) {
        if (str == null) {
            return null;
        }
        if (StringUtil.isBlank(str)) {
            return 0;
        }
        try {
            return new Integer(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static Integer toInteger(int i) {
        try {
            return new Integer(i);
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static BigInteger toBigInteger(String str) {
        if (str == null) {
            return null;
        }
        try {
            return new BigInteger(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static BigDecimal toBigDecimal(String str) {
        if (str == null) {
            return null;
        }
        if (StringUtil.isBlank(str)) {
            return BigDecimal.ZERO;
        }
        try {
            return new BigDecimal(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static BigDecimal toBigDecimal(String str, String decPoPtn) {
        return toBigDecimal(formatDecDefault(str, decPoPtn));
    }
    public static Float toFloat(String str) {
        if (str == null) {
            return null;
        }
        try {
            return new Float(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static float totoPrimitiveFloat(String str) {
        return (str == null ? 0 : Float.parseFloat(str));
    }
    public static Long toLong(String str) {
        if (str == null) {
            return null;
        }
        try {
            return new Long(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static long totoPrimitiveLong(String str) {
        return (str == null ? 0 : Long.parseLong(str));
    }
    public static Double toDouble(String str) {
        if (str == null) {
            return null;
        }
        try {
            return new Double(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static double totoPrimitiveDouble(String str) {
        return (str == null ? 0 : Double.parseDouble(str));
    }
    public static String getDecimalStyleName(String decimalStyleId) {
        String value = null;
        for (int i = 0; i < DECIMAL_STYLE_LIST.length; i++) {
            if (DECIMAL_STYLE_LIST[i][0].equals(decimalStyleId)) {
                value = DECIMAL_STYLE_LIST[i][2];
                break;
            }
        }
        if (value == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return value;
    }
    public static String getDecPo(String decPoPtn) {
        return String.valueOf(getDecimalStyleValue(decPoPtn));
    }
    public static String getDecimalStyleValue(String decimalStyleId) {
        String value = null;
        for (int i = 0; i < DECIMAL_STYLE_LIST.length; i++) {
            if (DECIMAL_STYLE_LIST[i][0].equals(decimalStyleId)) {
                value = DECIMAL_STYLE_LIST[i][1];
                break;
            }
        }
        if (value == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return value;
    }
    public static char getDecimalStyleValueChar(String decimalStyleId) {
        return getDecimalStyleValue(decimalStyleId).charAt(0);
    }
    public static String formatIntValue(int n) {
        return formatIntValue(new Integer(n));
    }
    public static String formatIntView(int n, String numSepPtn) {
        return formatIntView(new Integer(n), numSepPtn);
    }
    public static String formatIntValue(Integer num) {
        if (num == null) {
            return null;
        }
        String format = "#####0";
        return formatNum(num, format, null, null);
    }
    public static String formatIntView(Integer num, String numGroupStyleId) {
        if (num == null) {
            return null;
        }
        String format = "###,##0";
        return formatNum(num, format, null, numGroupStyleId);
    }
    public static String formatDecValue(BigDecimal dec, String decimalStyleId) {
        return formatDecValue(dec, -1, decimalStyleId);
    }
    public static String formatDecValue(BigDecimal dec, Integer decLength, String decimalStyleId) {
        return formatDecValue(dec, decLength != null ? decLength.intValue() : -1, decimalStyleId);
    }
    public static String formatDecValue(BigDecimal dec, int decLength, String decimalStyleId) {
        if (dec == null) {
            return null;
        }
        String format = "#####0";
        if (decLength > 0) {
            // 小数桁数指定あり
            for (int i = 0; i < decLength; i++) {
                if (i == 0) {
                    format += ".";
                }
                format += "0";
            }
        } else {
            // 小数桁数指定なし
            format += ".##########";
        }
        return formatNum(dec, format, decimalStyleId, null);
    }
    public static String formatDecView(BigDecimal dec, String decimalStyleId, String numGroupStyleId) {
        return formatDecView(dec, -1, decimalStyleId, numGroupStyleId);
    }
    public static String formatDecView(BigDecimal dec, Integer decLength,
                                       String decimalStyleId, String numGroupStyleId) {
        return formatDecView(dec,
                decLength != null ? decLength.intValue() : -1,
                decimalStyleId,
                numGroupStyleId);
    }
    public static String formatDecView(BigDecimal dec, int decLength,
                                       String decimalStyleId, String numGroupStyleId) {
        if (dec == null) {
            return null;
        }
        String format = "###,##0";
        if (decLength > 0) {
            // 小数桁数指定あり
            for (int i = 0; i < decLength; i++) {
                if (i == 0) {
                    format += ".";
                }
                format += "0";
            }
        } else {
            // 小数桁数指定なし
            format += ".##########";
        }
        return formatNum(dec, format, decimalStyleId, numGroupStyleId);
    }
    protected static String formatNum(Object obj, String format, String decimalStyleId, String numGroupStyleId) {
        char decPo = decimalStyleId != null ? getDecimalStyleValueChar(decimalStyleId) : ' ';
        char numSep = numGroupStyleId != null ? getNumGroupStyleValueChar(numGroupStyleId) : ' ';
        DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();
        df.applyPattern(format);
        String str = df.format(obj);
        if (str == null) {
            return null;
        }
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (c == ',') {
                sb.append(numSep);
                continue;
            }
            if (c == '.') {
                sb.append(decPo);
                if (i != str.length()) {
                    sb.append(str.substring(i + 1, str.length()));
                }
                break;
            }
            sb.append(c);
        }
        return sb.toString();
    }
    public static String formatDecDefault(String str, String decPoPtn) {
        if (str == null) {
            return null;
        }
        char decPo = getDecimalStyleValueChar(decPoPtn);
        StringBuffer sb = new StringBuffer(str);
        int idx = sb.toString().indexOf(String.valueOf(decPo));
        if (idx != -1) {
            sb.replace(idx, idx + String.valueOf(decPo).length(), String.valueOf('.'));
        }
        return sb.toString();
    }
    public static String getNumGroupStyleValue(String numGroupStyleId) {
        String value = null;
        for (int i = 0; i < NUM_GROUP_STYLE_LIST.length; i++) {
            if (NUM_GROUP_STYLE_LIST[i][0].equals(numGroupStyleId)) {
                value = NUM_GROUP_STYLE_LIST[i][1];
                break;
            }
        }
        if (value == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return value;
    }
    public static char getNumGroupStyleValueChar(String numGroupStyleId) {
        return getNumGroupStyleValue(numGroupStyleId).charAt(0);
    }
    public static String getNumGroupStyleName(String numGroupStyleId) {
        String value = null;
        for (int i = 0; i < NUM_GROUP_STYLE_LIST.length; i++) {
            if (NUM_GROUP_STYLE_LIST[i][0].equals(numGroupStyleId)) {
                value = NUM_GROUP_STYLE_LIST[i][2];
                break;
            }
        }
        if (value == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return value;
    }
    public static String roundString(String str) {
        BigDecimal dec = toBigDecimal(str);
        return (dec == null ? str : StringUtil.toString(roundBigDecimal(dec)));
    }
    public static BigDecimal roundBigDecimal(BigDecimal dec) {
        return (dec == null ? dec : dec.divide(new BigDecimal("1"), 0, BigDecimal.ROUND_HALF_UP));
    }
    public static int roundBigDecimal(int num) {
        return toInt(roundString(StringUtil.toString(num)));
    }
    public static String fomatNumber(double amount, String pattern) {
        NumberFormat nf = NumberFormat.getCurrencyInstance();
        DecimalFormat df = (DecimalFormat) nf;
        df.setMinimumFractionDigits(2);
        df.setMaximumFractionDigits(2);
        df.setDecimalSeparatorAlwaysShown(true);
        df.applyPattern(pattern);
        return df.format(amount);
    }
    public static String fomatNumber(long amount, String pattern) {
        NumberFormat nf = NumberFormat.getCurrencyInstance();
        DecimalFormat df = (DecimalFormat) nf;
        df.setMinimumFractionDigits(2);
        df.setMaximumFractionDigits(2);
        df.setDecimalSeparatorAlwaysShown(true);
        df.applyPattern(pattern);
        return df.format(amount);
    }
    public static BigDecimal addBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        return (dec1 != null ? dec1 : new BigDecimal(0)).add(dec2 != null ? dec2 : new BigDecimal(0));
    }
    public static boolean isInteger(String target) {
        if (target == null) {
            return false;
        }
        char[] digit = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
        for (int i = 0; i < target.length(); i++) {
            for (int j = 0; j < digit.length; j++) {
                if (target.charAt(i) == digit[j]) {
                    break;
                }
                if (i == 0 && target.charAt(i) == '-') {
                    break;
                }
                if (i == 0 && target.charAt(i) == '+') {
                    break;
                }
                if (j == digit.length - 1) {
                    return false;
                }
            }
        }
        return true;
    }
}

+ 0 - 29
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/Select2.java

@ -1,29 +0,0 @@
package com.yihu.ehr.util.operator;
/**
 * select2类
 *
 * @author llh
 */
public class Select2 {
    private String id;
    private String text;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getText() {
        return text;
    }
    public void setText(String text) {
        this.text = text;
    }
}

+ 0 - 353
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/SqlCreate.java

@ -1,353 +0,0 @@
package com.yihu.ehr.util.operator;
import com.yihu.ehr.common.constants.Constants;
import java.util.List;
import java.util.Map;
/**
 * Created by lingfeng on 2015/6/23.
 */
public class SqlCreate {
    private String primaryKey;
    private String tableName;
    private String tableItem;
    private String tableKey;
    private List<String> itemList;
    private List<String> itemValueList;
    private List<String> conditionList;
    private Map<String, String> keyValueMap;
    private static String[] stdTable = {"std_dataset", "std_metadata", "std_dict", "std_dict_item"};
    private static String[] stdDatasetTable = {"std_dataset", "std_metadata"};
    public SqlCreate() {
    }
    public String createTable() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.CREATE_TABLE + tableName + Constants.LEFT_BRACKET);
        for (String item : itemList) {
            sqlBuffer.append(item + Constants.COMMA);
        }
        if (!primaryKey.equals("")) {
            sqlBuffer.append(Constants.PRIMARY_KEY + Constants.LEFT_BRACKET + primaryKey);
            sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
            sqlBuffer.append(Constants.RIGHT_BRACKET);
        } else {
            sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        }
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.ROW_FORMAT_DYNAMIC + Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String insertData() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.INSERT_INTO + tableName + Constants.LEFT_BRACKET);
        for (String item : itemList) {
            sqlBuffer.append(item + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.VALUES + Constants.LEFT_BRACKET);
        for (String item : itemValueList) {
            sqlBuffer.append(item + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String insertDataByKeyValue() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.INSERT_INTO + this.tableName + Constants.LEFT_BRACKET);
        for (String key : keyValueMap.keySet()) {
            sqlBuffer.append(key + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.VALUES + Constants.LEFT_BRACKET);
        for (String key : keyValueMap.keySet()) {
            sqlBuffer.append(keyValueMap.get(key) + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String updateDataByTableKey() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.UPDATE + tableName + Constants.SET);
        for (String key : keyValueMap.keySet()) {
            sqlBuffer.append(key + Constants.EQUAL_MARK + keyValueMap.get(key) + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.WHERE + Constants.TABLE_KEY + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String getMaxId() {
        String sql = "select max(id) from " + tableName;
        return sql;
    }
    public Boolean isToAdapter() {
        Boolean flg = false;
        for (String str : stdTable) {
            if (tableName.equals(str)) {
                flg = true;
            }
        }
        return flg;
    }
    public Boolean isToAdapterDataset() {
        Boolean flg = false;
        for (String str : stdDatasetTable) {
            if (tableName.equals(str)) {
                flg = true;
            }
        }
        return flg;
    }
    public Boolean isCodeOrValue() {
        Boolean flg = false;
        for (String key : keyValueMap.keySet()) {
            if (key.equals(Constants.CODE_STR) || key.equals(Constants.VALUE_STR)) {
                flg = true;
            }
        }
        return flg;
    }
    public String updateAdapterData() {
        StringBuilder sqlBuffer = new StringBuilder();
        String adapterTableName = tableName.replace(Constants.STD_PREFIX, Constants.ADAPTER_PREFIX);
        sqlBuffer.append(Constants.UPDATE + adapterTableName + Constants.SET);
        for (String key : keyValueMap.keySet()) {
            if (key.equals(Constants.CODE_STR) || key.equals(Constants.VALUE_STR)) {
                sqlBuffer.append(tableName + Constants.UNDERLINE + key + Constants.EQUAL_MARK
                        + keyValueMap.get(key) + Constants.COMMA);
            }
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.WHERE + tableName + Constants.UNDERLINE + Constants.TABLE_KEY
                + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String failureDataByTableKey() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.UPDATE + tableName + Constants.SET);
        sqlBuffer.append(Constants.FAILURE_FLG + Constants.EQUAL_MARK + Constants.NUMBER_ZREO);
        sqlBuffer.append(Constants.WHERE + Constants.TABLE_KEY + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String deleteDataByTableKey() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.DELETE);
        sqlBuffer.append(Constants.FROM + tableName);
        sqlBuffer.append(Constants.WHERE + Constants.TABLE_KEY + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String deleteAdapterData() {
        StringBuilder sqlBuffer = new StringBuilder();
        String adapterTableName = tableName.replace(Constants.STD_PREFIX, Constants.ADAPTER_PREFIX);
        sqlBuffer.append(Constants.DELETE);
        sqlBuffer.append(Constants.FROM + adapterTableName);
        sqlBuffer.append(Constants.WHERE + tableName + Constants.UNDERLINE + Constants.TABLE_KEY
                + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String deleteAdapterOriginData() {
        StringBuilder sqlBuffer = new StringBuilder();
        String adapterOriginTableName = tableName.replace(Constants.STD_PREFIX, Constants.ADAPTER_PREFIX + Constants.ORIGIN_PREFIX);
        String tableKeyStr = tableName.replace(Constants.STD_PREFIX, "") + Constants.UNDERLINE + Constants.TABLE_KEY;
                sqlBuffer.append(Constants.DELETE);
        sqlBuffer.append(Constants.FROM + adapterOriginTableName);
        sqlBuffer.append(Constants.WHERE + tableKeyStr + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String addTableItem() {
        StringBuffer sqlBuffer = new StringBuffer();
        sqlBuffer.append(Constants.ALTER_TABLE + tableName + Constants.ADD + tableItem + Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String deleteData() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.DELETE);
        sqlBuffer.append(Constants.FROM + tableName);
        if (!CollectionUtil.isEmpty(conditionList)) {
            sqlBuffer.append(Constants.WHERE);
            sqlBuffer.append("1=1" + Constants.AND);
            for (String condition : conditionList) {
                sqlBuffer.append(condition + Constants.AND);
            }
            sqlBuffer.delete(sqlBuffer.length() - 4, sqlBuffer.length() - 1);
        }
//        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String selectData() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.SELECT);
        for (String item : itemList) {
            sqlBuffer.append(item + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.FROM + tableName);
        if (!CollectionUtil.isEmpty(conditionList)) {
            sqlBuffer.append(Constants.WHERE);
            sqlBuffer.append("1=1" + Constants.AND);
            for (String condition : conditionList) {
                sqlBuffer.append(condition + Constants.AND);
            }
            sqlBuffer.delete(sqlBuffer.length() - 4, sqlBuffer.length() - 1);
        }
//        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String betweenCondition(String item) {
        String condition = item + Constants.BETWEEN + Constants.QUESTION_MARK + Constants.AND + Constants.QUESTION_MARK;
        return condition;
    }
    public String greaterAndEqualCondition(String item) {
        String condition = item + Constants.GREATER_EQUAL_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String greaterCondition(String item) {
        String condition = item + Constants.GREATER_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String lessAndEqualCondition(String item) {
        String condition = item + Constants.LESS_EQUAL_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String lessCondition(String item) {
        String condition = item + Constants.LESS_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String betweenCondition(String item, String value1, String value2) {
        String condition = item + Constants.BETWEEN + value1 + Constants.AND + value2;
        return condition;
    }
    public String equalCondition(String item) {
        String condition = item + Constants.EQUAL_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String equalCondition(String item, String value) {
        String condition = item + Constants.EQUAL_MARK + value;
        return condition;
    }
    public String likeCondition(String item) {
        String condition = item + Constants.LIKE + Constants.QUESTION_MARK;
        return condition;
    }
    public String getTableName() {
        return tableName;
    }
    public void setTableName(String tableName) {
        this.tableName = tableName;
    }
    public String getPrimaryKey() {
        return primaryKey;
    }
    public void setPrimaryKey(String primaryKey) {
        this.primaryKey = primaryKey;
    }
    public List<String> getItemList() {
        return itemList;
    }
    public void setItemList(List<String> itemList) {
        this.itemList = itemList;
    }
    public List<String> getItemValueList() {
        return itemValueList;
    }
    public void setItemValueList(List<String> itemValueList) {
        this.itemValueList = itemValueList;
    }
    public String getTableItem() {
        return tableItem;
    }
    public void setTableItem(String tableItem) {
        this.tableItem = tableItem;
    }
    public List<String> getConditionList() {
        return conditionList;
    }
    public void setConditionList(List<String> conditionList) {
        this.conditionList = conditionList;
    }
    public String getTableKey() {
        return tableKey;
    }
    public void setTableKey(String tableKey) {
        this.tableKey = tableKey;
    }
    public Map<String, String> getKeyValueMap() {
        return keyValueMap;
    }
    public void setKeyValueMap(Map<String, String> keyValueMap) {
        this.keyValueMap = keyValueMap;
    }
}

+ 0 - 1428
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/StringUtil.java

@ -1,1428 +0,0 @@
package com.yihu.ehr.util.operator;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.sql.Clob;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
public class StringUtil {
    public static String substring(String str, int start) {
        return StringUtils.substring(str, start);
    }
    public static String substring(String str, int start, int end) {
        return StringUtils.substring(str, start, end);
    }
    public static boolean isBlank(String str) {
        return StringUtils.isBlank(str);
    }
    public static String toString(Object obj) {
        if (obj == null) {
            return null;
        }
        return obj.toString();
    }
    public static String trimLeft(String value) {
        if (value == null)
            return "";
        String result = value;
        char ch[] = result.toCharArray();
        int index = -1;
        for (int i = 0; i < ch.length; i++) {
            if (Character.isWhitespace(ch[i])) {
                index = i;
            } else {
                break;
            }
        }
        if (index != -1) {
            result = result.substring(index + 1);
        }
        return result;
    }
    /**
     * �ù���ѹ���ַ������ұ߿ո�
     *
     * @param value ��Դ��
     * @return String src����ַ���
     */
    public static String trimRight(String value) {
        if (value == null)
            return "";
        String result = value;
        char ch[] = result.toCharArray();
        int endIndex = -1;
        for (int i = ch.length - 1; i > -1; i--) {
            if (Character.isWhitespace(ch[i])) {
                endIndex = i;
            } else {
                break;
            }
        }
        if (endIndex != -1) {
            result = result.substring(0, endIndex);
        }
        return result;
    }
    /**
     * ***************************************************** ��
     * �ܣ����ַ���ǰ����Ӷ��"0",���ع̶����� ��ڲ�����param str:��������ַ��� param len�����ع̶����� �� �أ�Stirng
     * <p/> ��д���ڣ� �޸ı�ע�� ******************************************************
     */
    public static String fillHeadCharsLen(String strOri, int len) {
        return fillHeadCharsLen(strOri, "0", len);
    }
    /**
     * ***************************************************** ��
     * �ܣ����ַ���������Ӷ��"0",���ع̶����� ��ڲ�����param str:��������ַ��� param len�����ع̶����� �� �أ�Stirng
     * <p/> ��д���ڣ� �޸ı�ע�� ******************************************************
     */
    public static String fillBackCharsLen(String strOri, int len) {
        return fillBackCharsLen(strOri, "0", len);
    }
    /**
     * ***************************************************** ��
     * �ܣ����ַ���ǰ����Ӷ���ظ��ַ���,���ع̶����� ��ڲ�����param str:��������ַ��� param subStr:�ظ������ַ���
     * param len�����ع̶����� �� �أ�Stirng <p/> ��д���ڣ� �޸ı�ע��
     * ******************************************************
     */
    public static String fillHeadCharsLen(String strOri, String subStr, int len) {
        if (strOri == null || strOri.trim().length() == 0) {
            strOri = "";
        }
        if (subStr == null) {
            subStr = " ";
        }
        String fillStr = "";
        for (int i = 0; i < len; i++) {
            fillStr = fillStr + subStr;
        }
        subStr = fillStr + strOri;
        return (subStr.substring(subStr.length() - len, subStr.length()));
    }
    /**
     * ***************************************************** ��
     * �ܣ����ַ���������Ӷ���ظ��ַ���,���ع̶����� ��ڲ�����param str:��������ַ��� param subStr:�ظ������ַ���
     * param len�����ع̶����� �� �أ�Stirng <p/> ��д���ڣ� �޸ı�ע��
     * ******************************************************
     */
    public static String fillBackCharsLen(String strOri, String subStr, int len) {
        if (strOri == null || strOri.trim().length() == 0) {
            strOri = "";
        }
        if (subStr == null) {
            subStr = " ";
        }
        String fillStr = "";
        for (int i = 0; i < len; i++) {
            fillStr = fillStr + subStr;
        }
        subStr = strOri + fillStr;
        return (subStr.substring(0, len));
    }
    /**
     * ***************************************************** �� �ܣ����ַ���ǰ����Ӷ��"0"
     * ��ڲ�����param str:��������ַ��� param counter���ظ������� �� �أ�Stirng <p/> ��д���ڣ� �޸ı�ע��
     * ******************************************************
     */
    public static String fillHeadChars(String strOri, int counter) {
        return fillHeadChars(strOri, "0", counter);
    }
    /**
     * ***************************************************** �� �ܣ����ַ���������Ӷ��"0"
     * ��ڲ�����param str:��������ַ��� param counter���ظ������� �� �أ�Stirng <p/> ��д���ڣ� �޸ı�ע��
     * ******************************************************
     */
    public static String fillBackChars(String strOri, int counter) {
        return fillBackChars(strOri, "0", counter);
    }
    /**
     * ***************************************************** �� �ܣ����ַ���ǰ����Ӷ���ظ��ַ���
     * ��ڲ�����param str:��������ַ��� param subStr:�ظ������ַ��� param counter���ظ������� ��
     * �أ�Stirng <p/> ��д���ڣ� �޸ı�ע��
     * ******************************************************
     */
    public static String fillHeadChars(String strOri, String subStr, int counter) {
        if (strOri == null || strOri.trim().length() == 0) {
            strOri = "";
        }
        if (counter <= 0 || subStr == null) {
            return strOri;
        }
        String fillStr = "";
        for (int i = 0; i < counter; i++) {
            fillStr = fillStr + subStr;
        }
        return (fillStr + strOri);
    }
    /**
     * ***************************************************** �� �ܣ����ַ���������Ӷ���ظ��ַ���
     * ��ڲ�����param str:��������ַ��� param subStr:�ظ������ַ��� param counter���ظ������� ��
     * �أ�Stirng <p/> ��д���ڣ� �޸ı�ע��
     * ******************************************************
     */
    public static String fillBackChars(String strOri, String subStr, int counter) {
        if (strOri == null || strOri.trim().length() == 0) {
            strOri = "";
        }
        if (counter <= 0 || subStr == null) {
            return strOri;
        }
        String fillStr = "";
        for (int i = 0; i < counter; i++) {
            fillStr = fillStr + subStr;
        }
        return (strOri + fillStr);
    }
    /**
     * ***************************************************** ��
     * �ܣ��ж��ַ����Ƿ�Ϊ�ջ���null(ѹ���ո��) ��ڲ�����param str:��������ַ��� ���ڲ����� �� �أ��գ�null��true;
     * ���գ�false <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean isEmpty(Object strObj) {
        if (strObj == null || strObj.toString().trim().length() < 1) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * ***************************************************** ��
     * �ܣ��ж�һ���ַ����Ƿ�Ϊ��ֵ��null����(ѹ���ո��)�� ��ڲ�����param str:���жϵ��ַ��� ���ڲ����� ��
     * �أ�true���գ�false���ǿ� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean isStrEmpty(String str) {
        if ((str == null) || (str.trim().length() < 1) || "null".endsWith(str.toLowerCase())) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * ***************************************************** ��
     * �ܣ�����һ���ַ���ȥ���ұ߿ո���ֵ�����Ϊnull�򷵻ؿմ� ��ڲ�����param str:��������ַ��� ���ڲ����� ��
     * �أ�ȥ���ұ߿ո����ַ������߿մ� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String getValue(String str) {
        if (str == null) {
            return "";
        }
        if (str.trim().length() <= 0)
            return "";
        str = "H" + str;
        str = str.trim();
        str = str.substring(1);
        return str;
    }
    /**
     * ***************************************************** �� �ܣ��ж�һ���ַ����Ƿ񳬳���������
     * ��ڲ�����param text:���жϵ��ַ�����param len:�����ij��� ���ڲ����� �� �أ�return
     * true��δ������false��Ϊ�ջ��߳��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean chkTextLen(String text, int len) {
        if (text == null || text.length() > len) {
            return false;
        } else {
            return true;
        }
    }
    /**
     * ***************************************************** ��
     * �ܣ��ж�һ���ַ���ȥ���ո��Ƿ񳬳��������� ��ڲ�����param text:���жϵ��ַ�����param len:�����ij��� ���ڲ����� ��
     * �أ�return true��δ������false��Ϊ�ջ��߳��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean chkTextTrimLen(String text, int len) {
        if (text == null || text.trim().length() > len) {
            return false;
        } else {
            return true;
        }
    }
    /**
     * ***************************************************** ��
     * �ܣ��ж�һ���ַ����Ƿ�ֻ��english ��ڲ�����param text:���жϵ��ַ����� ���ڲ����� �� �أ�return
     * true���Ϸ���false:�������Ļ��������Ƿ��ַ� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean isStrEn(String text) {
        for (int i = 0; i < text.length(); i++) {
            if (text.charAt(i) > 127) {
                return false;
            }
        }
        return true;
    }
    /**
     * ***************************************************** �� �ܣ��ж�һ���ַ����Ƿ�����
     * ��ڲ�����param ch:���жϵ��ַ� ���ڲ����� �� �أ�return true�����֣�false:������ <p/>
     * ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean isCharNum(char ch) {
        if (ch > 47 && ch < 58) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * ***************************************************** ��
     * �ܣ��ж�һ���ַ����Ƿ��з����ֵ��ַ� ��ڲ�����param str:���жϵ��ַ��� ���ڲ����� �� �أ�return
     * true��Null���߲�ȫ�����֣�false:ȫ������ <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean isStrNum(String str) {
        if (isStrEmpty(str)) {
            return true;
        }
        boolean notNum = false;
        for (int i = 0; i < str.length(); i++) {
            if (!isCharNum(str.charAt(i))) {
                notNum = true;
            }
        }
        return !notNum;
    }
    /**
     * ***************************************************** ��
     * �ܣ��ж�һ���ַ����Ƿ��з����ֵ��ַ� ��ڲ�����param strSrc:���жϵ��ַ��� ���ڲ����� �� �أ�return
     * true��ȫ�����֣�false:��ȫ������ <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean isNum(String strSrc) throws Exception {
        for (int i = 0; i < strSrc.length(); i++) {
            if (!isCharNum(strSrc.charAt(i)))
                return false;
        }
        return true;
    }
    /**
     * ***************************************************** �� �ܣ��ж�һ���ַ��Ƿ���Ӣ����ĸ
     * ��ڲ�����param ch:���жϵ��ַ� ���ڲ����� �� �أ�return true����Ӣ����ĸ��false:����Ӣ����ĸ <p/>
     * ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean isCharLetter(char ch) {
        if ((ch >= 65 && ch <= 90) && (ch >= 97 && ch <= 122)) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * ***************************************************** �� �ܣ��ж�һ���ַ����Ƿ�ȫ��Ӣ����ĸ
     * ��ڲ�����param str:���жϵ��ַ��� ���ڲ����� �� �أ�return true��NULL���з�Ӣ����ĸ��false:ȫ��Ӣ����ĸ
     * <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean isStrLetter(String str) {
        if (isStrEmpty(str))
            return true;
        boolean notLetter = false;
        for (int i = 0; i < str.length(); i++) {
            if (!isCharLetter(str.charAt(i))) {
                notLetter = true;
            }
        }
        return !notLetter;
    }
    /**
     * ***************************************************** ��
     * �ܣ���������ַ���ȡ����һ���ַ����� ��ڲ�����param src:������ַ��� ���ڲ����� �� �أ�return
     * ��������ַ���ȡ����һ���ַ����� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static char strToChar(String src) {
        src = src.trim();
        char result = src.charAt(0);
        return result;
    }
    /**
     * ***************************************************** ��
     * �ܣ���������ַ���ת�ɶ�Ӧ��ASCII�봮 ��ڲ�����param sql:�������sql������ ���ڲ����� �� �أ��������ַ��� <p/>
     * ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String encodeSQL(String sql) {
        StringBuffer tempBuff = new StringBuffer();
        for (int i = 0; i < sql.length(); i++) {
            tempBuff.append(Integer.toHexString(sql.charAt(i)));
        }
        return tempBuff.toString();
    }
    /**
     * ***************************************************** ��
     * �ܣ��������ASCII�봮����Ϊ��Ӧ���ַ��� ��ڲ�����param encoded:��������ַ��� ���ڲ����� �� �أ��������ַ��� <p/>
     * ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String decodeSQL(String encoded) {
        StringBuffer tempBuff = new StringBuffer();
        for (int i = 0; i < encoded.length(); i += 2) {
            tempBuff.append((char) Integer.parseInt(
                    encoded.substring(i, i + 2), 16));
        }
        return tempBuff.toString();
    }
    /**
     * ***************************************************** �� �ܣ���ȡ���·��
     * ��ڲ�����param path1:����·����param context1:������ ���ڲ����� �� �أ�return ���·�� <p/>
     * ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String getAbsolutePath(String path1, String context1) {
        int i1 = path1.indexOf(context1);
        if (i1 < 0) {
            return path1;
        } else {
            return path1.substring(path1.indexOf(context1) + context1.length());
        }
    }
    /**
     * ***************************************************** �� �ܣ���ȡ�Ӵ� ��ڲ�����param
     * str1:��ȡ�Ӵ����ַ�����param sindex:��ʼλ�ã�param eindex:����λ�� ���ڲ����� ��
     * �أ����ش���ʼλ�ÿ�ʼ����λ�ý������Ӵ����������λ��С��0���򷵻ش���ʼλ�ÿ�ʼ���Ӵ� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String getSubString(String str1, int sindex, int eindex) {
        if (str1 == null) {
            return "";
        }
        if (str1.trim().length() <= 0)
            return "";
        if (str1.length() > sindex) {
            if (eindex >= 0)
                return str1.substring(sindex, eindex);
            else if (eindex < 0)
                return str1.substring(sindex);
        }
        return "";
    }
    /**
     * ***************************************************** ��
     * �ܣ����ַ����������䵽ָ���Ĵ�С��������ÿմ����� ��ڲ�����param strs:��������ַ������飬param size1:���������鳤��
     * ���ڲ����� �� �أ�return �������ַ������� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String[] getValues(String[] strs, int size1) {
        String[] strs1 = new String[size1];
        for (int i = 0; i < size1; i++) {
            strs1[i] = "";
        }
        if (strs == null) {
            return strs1;
        } else {
            if (strs.length < size1) {
                for (int i = 0; i < strs.length; i++) {
                    strs1[i] = strs[i];
                }
                return strs1;
            } else {
                return strs;
            }
        }
    }
    /**
     * ***************************************************** �� �ܣ��ַ���ȫ���滻����
     * ��ڲ�����param strSource ���滻���ַ�����param strFrom Դ�ַ�����param strTo Ŀ���ַ��� ���ڲ����� ��
     * �أ��滻����ַ��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String replaceStrAll(String strSource, String strFrom,
                                       String strTo) {
        String strDest = "";
        int intFromLen = strFrom.length();
        int intPos;
        while ((intPos = strSource.indexOf(strFrom)) != -1) {
            strDest = strDest + strSource.substring(0, intPos);
            strDest = strDest + strTo;
            strSource = strSource.substring(intPos + intFromLen);
        }
        strDest = strDest + strSource;
        return strDest;
    }
    public static String replaceStr(String strTarget, String strNew) {
        int iIndex = -1;
        while (true) {
            iIndex = strTarget.indexOf('\n');
            if (iIndex < 0) {
                break;
            }
            String strTemp = null;
            strTemp = strTarget.substring(0, iIndex);
            strTarget = strTemp + strNew + strTarget.substring(iIndex + 1);
        }
        return strTarget;
    }
    /**
     * ***************************************************** ��
     * �ܣ��ж��ַ����������Ƿ��и��ַ��� ��ڲ�����param str1 ��Ѱ�ҵ��ַ�����param strarray ��Ѱ�ҵ��ַ������飬
     * ���ڲ����� �� �أ�return true������;false��δ���� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static boolean includestr(String str1, String[] strarray) {
        if (strarray == null || strarray.length <= 0)
            return false;
        for (int i = 0; i < strarray.length; i++) {
            if (strarray[i] == null) {
                if (str1 == null)
                    return true;
                else
                    continue;
            }
            if (strarray[i].trim().equals(str1)) {
                return true;
            }
        }
        return false;
    }
    /**
     * ***************************************************** ��
     * �ܣ���\n��Ϊ�ָ��������ַ����ָ������飬��ȥ��\r ��ڲ�����param fvalue ��ת�����ַ��� ���ڲ����� �� �أ�return
     * ת��������� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String[] getAreaValues(String fvalue) {
        String tmpstr = fvalue;
        int i = 0;
        if (tmpstr == null)
            return null;
        if (tmpstr.trim().equals(""))
            return null;
        while (tmpstr.indexOf("\n") >= 0) {
            i++;
            tmpstr = tmpstr.substring(tmpstr.indexOf("\n") + 1);
        }
        if (tmpstr.trim().equals("")) {
            i--;
        }
        String[] fvalues = new String[i + 1];
        tmpstr = fvalue;
        i = 0;
        while (tmpstr.indexOf("\n") >= 0) {
            fvalues[i] = tmpstr.substring(0, tmpstr.indexOf("\n"));
            if (fvalues[i].indexOf("\r") >= 0)
                fvalues[i] = fvalues[i].substring(0, fvalues[i].indexOf("\r"));
            i++;
            tmpstr = tmpstr.substring(tmpstr.indexOf("\n") + 1);
        }
        if (!tmpstr.trim().equals(""))
            fvalues[i] = tmpstr;
        return fvalues;
    }
    /**
     * ***************************************************** �� �ܣ����ַ����е�|ת�ɴ�\n
     * ��ڲ�����param fvalue ��ת�����ַ��� ���ڲ����� �� �أ�ת������ַ��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String getrealAreaValues(String fvalue) {
        String tmpstr = fvalue;
        String returnstr = "";
        if (tmpstr == null)
            return null;
        if (tmpstr.trim().equals(""))
            return "";
        while (tmpstr.indexOf("|") > 0) {
            returnstr += tmpstr.substring(0, tmpstr.indexOf("|")) + "\n";
            tmpstr = tmpstr.substring(tmpstr.indexOf("|") + 1);
        }
        return returnstr;
    }
    /**
     * ***************************************************** ��
     * �ܣ������ַ����к��е�ָ���ַ��ĸ��� ��ڲ�����param strInput ��������ַ�����param chr ��Ѱ�ҵ��ַ� ���ڲ����� ��
     * �أ�return ������ַ����� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static int countChar(String strInput, char chr) {
        int iCount = 0;
        char chrTmp = ' ';
        if (strInput.trim().length() == 0)
            return 0;
        // ����ָ�����ٸ��ַ���
        for (int i = 0; i < strInput.length(); i++) {
            chrTmp = strInput.charAt(i);
            if (chrTmp == chr) {
                iCount++;
            }
        }
        return iCount;
    }
    /**
     * ***************************************************** �� �ܣ�����ά����ת��һ���ַ����ͳ�
     * ��ڲ�����param strs ��ת�����ַ������� ���ڲ����� �� �أ��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String strArrayToStr(String[] strs) {
        return strArrayToStr(strs, null);
    }
    /**
     * ***************************************************** �� �ܣ����еĴ�ӡ���ַ������������
     * ��ڲ�����param strs ����ӡ���ַ������� ���ڲ����� �� �أ��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static void printStrs(String[] strs) {
        for (int i = 0; i < strs.length; i++) {
            System.out.println(strs[i]);
        }
    }
    /**
     * ***************************************************** ��
     * �ܣ���ά�����У�һά���еĴ�ӡ���ַ������������ ��ڲ�����param strs ����ӡ�Ķ�ά�ַ������� ���ڲ����� �� �أ��� <p/>
     * ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static void printDualStr(String[][] dualStr) {
        for (int i = 0; i < dualStr.length; i++) {
            for (int j = 0; j < dualStr[i].length; j++) {
                System.out.print(dualStr[i][j] + " ");
            }
            System.out.println();
        }
    }
    /**
     * ***************************************************** ��
     * �ܣ�����ά��������ߵ������б�Ϊ�У����б�Ϊ�� ��ڲ�����param dualStr ����Ķ�ά���� ���ڲ����� �� �أ�return
     * �ߵ���Ķ�ά���� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String[][] rowToColumn(String[][] dualStr) {
        String[][] returnDualStr = null;
        if (dualStr != null) {
            returnDualStr = new String[dualStr[0].length][dualStr.length];
            for (int i = 0; i < dualStr.length; i++)
                for (int j = 0; j < dualStr[0].length; j++)
                    returnDualStr[j][i] = dualStr[i][j];
        }
        return returnDualStr;
    }
    /**
     * ***************************************************** ��
     * �ܣ���Ҫ��ֵ��ҳ����ʾ���String�����е������ַ�����ת��� ��ڲ�����param inStr ������ַ��� ���ڲ����� �� �أ�return
     * ���ת�������ַ��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String latinString(String inStr) {
        String res = inStr;
        if (null == res)
            return null;
        res = replaceStrAll(res, "\"", "\\\"");
        res = replaceStrAll(res, "'", "\\'");
        return res;
    }
    /**
     * ***************************************************** �� �ܣ����ַ������пո��滻��ָ����
     * ��ڲ�����param String strTarget, String strNew ���ڲ����� �� �أ�return String
     * �����ѱ��滻���ִ� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String replaceWhiteSpace(String strTarget, String strNew) {
        int iIndex = -1;
        while (true) {
            char cRep = 32;
            iIndex = strTarget.indexOf(cRep);
            if (iIndex < 0) {
                break;
            }
            String strTemp = null;
            strTemp = strTarget.substring(0, iIndex);
            strTarget = strTemp + strNew + strTarget.substring(iIndex + 1);
        }
        return strTarget;
    }
    /**
     * ***************************************************** ��
     * �ܣ�������д�ɷ���Ҫ���С����λ����ֻȥ�������С����λ��������չλ���� ��ڲ�����param amount ����Ľ��, param
     * length ָ����С��λ���� ���ڲ����� �� �أ�return ���ת�������ַ��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String double2str(double amount, int length) {
        String strAmt = Double.toString(amount);
        int pos = strAmt.indexOf('.');
        if (pos != -1 && strAmt.length() > length + pos + 1)
            strAmt = strAmt.substring(0, pos + length + 1);
        return strAmt;
    }
    /**
     * ***************************************************** ��
     * �ܣ�����chr�ָ��ַ�������ΪString���Դ���split��֧����"|"Ϊ�ָ���� ��ڲ�����param str ��Ҫ���ָ�Ĵ�,param
     * chr �ָ���� ���ڲ����� �� �أ�return String[] �ָ����ַ�������,���������һ��|������ַ��� <p/>
     * ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String[] doSplit(String str, char chr) {
        int iCount = 0;
        char chrTmp = ' ';
        // ����ָ�����ٸ��ַ���
        for (int i = 0; i < str.length(); i++) {
            chrTmp = str.charAt(i);
            if (chrTmp == chr) {
                iCount++;
            }
        }
        String[] strArray = new String[iCount];
        for (int i = 0; i < iCount; i++) {
            int iPos = str.indexOf(chr);
            if (iPos == 0) {
                strArray[i] = "";
            } else {
                strArray[i] = str.substring(0, iPos);
            }
            str = str.substring(iPos + 1); // ��iPos+1������,str��������С
        }
        return strArray;
    }
    /**
     * ***************************************************** ��
     * �ܣ�����s�ָ��ַ�������ΪString���Դ���split��֧����"|"Ϊ�ָ���� ��ڲ�����param str ��Ҫ���ָ�Ĵ�,param s
     * �ָ��ַ��� ���ڲ����� �� �أ�return String[] �ָ����ַ�������,�������һ��|������ַ��� <p/>
     * ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String[] strSplit(String src, String splitchar) {
        int resultSize = 0;
        int len = src.length();
        int idx = 0;
        String strTemp = "";
        for (int i = 0; i < len; i++) {
            if (src.substring(i, i + 1).equals(splitchar)) {
                resultSize++;
            }
        }
        if ((len > 1) & (!src.substring(len - 1, len).equals(splitchar))) {
            resultSize++;
        }
        String result[] = new String[resultSize];
        for (int i = 0; i < len; i++) {
            if (src.substring(i, i + 1).equals(splitchar)) {
                result[idx] = strTemp;
                idx++;
                strTemp = "";
            } else {
                strTemp = String.valueOf(strTemp)
                        + String.valueOf(src.charAt(i));
            }
        }
        if (!strTemp.equals("")) {
            result[idx] = strTemp;
        }
        return result;
    }
    /**
     * ***************************************************** ��
     * �ܣ�����strSeparator�ָ��ַ�����ֻ�ָ���ָ����С���ַ��� ��ڲ�����param strToSplit ��Ҫ���ָ�Ĵ�,param
     * strSeparator �ָ��ַ���,param iLimit ָ����С ���ڲ����� �� �أ�return String[] �ָ����ַ�������
     * <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String[] split(String strToSplit, String strSeparator,
                                 int iLimit) {
        ArrayList tmpList = new ArrayList();
        int iFromIndex = 0;
        int iCurIndex = strToSplit.length();
        String strUnitInfo = "";
        int iCurCounts = 0;
        while ((iCurIndex != -1) && (iFromIndex < strToSplit.length())
                && (iCurCounts < iLimit)) {
            iCurIndex = strToSplit.indexOf(strSeparator, iFromIndex);
            if (iCurIndex == -1) {
                strUnitInfo = strToSplit.substring(iFromIndex, strToSplit
                        .length());
            } else {
                strUnitInfo = strToSplit.substring(iFromIndex, iCurIndex);
                iFromIndex = iCurIndex + 1;
            }
            tmpList.add(strUnitInfo);
            iCurCounts++;
        }
        int iCounts = tmpList.size();
        String tmpArray[] = new String[iCounts];
        for (int i = 0; i < iCounts; i++) {
            tmpArray[i] = (String) tmpList.get(i);
        }
        return tmpArray;
    }
    /**
     * ***************************************************** ��
     * �ܣ����ַ�����С��ָ�����ȣ�����IJ�����...���� ��ڲ�����param src ��Ҫ������Ĵ�,param len ָ����С ���ڲ����� ��
     * �أ�return String ��С��ָ�����ȣ�����IJ�����...�������ַ��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String strIntercept(String src, int len) {
        if (src == null) {
            return "";
        }
        if (src.length() > len) {
            src = String.valueOf(String.valueOf(src.substring(0, len))).concat(
                    "...");
        }
        return src;
    }
    /**
     * ***************************************************** ��
     * �ܣ����ַ���ת��ISO8859_1���� ��ڲ�����param str_in Ҫ��������ַ����� ���ڲ����� �� �أ�return String
     * ת������ַ����� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public static String strtochn(String str_in) {
        try {
            String temp_p = str_in;
            if (temp_p == null) {
                temp_p = "";
            }
            String temp = "";
            if (!temp_p.equals("")) {
                byte[] byte1 = temp_p.getBytes("ISO8859_1");
                temp = new String(byte1);
            }
            return temp;
        } catch (Exception e) {
        }
        return "null";
    }
    /**
     * ***************************************************** ��
     * �ܣ���ISO8859_1�ַ���ת��GBK���� ��ڲ�����param strvalue Ҫ��������ַ����� ���ڲ����� �� �أ�return
     * String ת������ַ����� �޸ı�ע��
     * ******************************************************
     */
    public static String ISO2GBK(String strvalue) {
        try {
            if (strvalue == null)
                return null;
            else {
                strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK");
                return strvalue;
            }
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * ***************************************************** ��
     * �ܣ���ҳ��Ҫ��ʾ���Ķ�����б���ת�� ��ڲ�����param str Ҫ��������ַ����� ���ڲ����� �� �أ�return String
     * ת������ַ����� �޸ı�ע�� ******************************************************
     */
    public static String cnCodeTrans(String str) {
        String s = "";
        try {
            s = new String(str.getBytes("GB2312"), "8859_1");
        } catch (UnsupportedEncodingException a) {
            System.out.print("chinese thansform exception");
        }
        return s;
    }
    /**
     * ***************************************************** ��
     * �ܣ��ж�Դ���Ƿ���Ϲ�������STaaaa����ST****** ��ڲ�����param strSourceҪ��������ַ�����param
     * strRule���� ���ڲ����� �� �أ�return false:Դ����ƥ�����true:Դ��ƥ����� �޸ı�ע��
     * ******************************************************
     */
    public static boolean judgeMatch(String strSource, String strRule) {
        int i = 0;
        // Դ�������ж�
        if ((null == strSource) || (strSource.length() == 0))
            return false;
        // ���򴮳����ж�
        if ((null == strRule) || (strRule.length() == 0))
            return false;
        // ���Ȳ��ɳ���
        if (strSource.length() > strRule.length())
            return false;
        // ÿһλ���ж�
        for (i = 0; i < strRule.length(); i++) {
            // Դ���ȹ��򴮶�
            if (strSource.length() < i + 1) {
                break;
            }
            if ((strRule.charAt(i) != '*')
                    && (strSource.charAt(i) != strRule.charAt(i))) {
                return false;
            }
        }
        // ����Դ���ȹ��򴮶̵�����������򴮺��Ǿ�Ϊ'*'����ƥ�䲻��
        for (; i < strRule.length(); i++) {
            if (strRule.charAt(i) != '*')
                return false;
        }
        return true;
    }
    public static String column2Property(String column) {
        column = column.toLowerCase();
        int i = column.indexOf("_");
        while (i != -1) {
            if (i != column.length() - 1) {
                char temp = column.charAt(i + 1);
                String strTemp = String.valueOf(temp);
                column = column.replaceFirst("_" + strTemp, strTemp
                        .toUpperCase());
                i = column.indexOf("_");
            } else {
                break;
            }
        }
        return column;
    }
    public static String strArrayToStr(String[] strs, String separator) {
        StringBuffer returnstr = new StringBuffer("");
        if (strs == null)
            return "";
        if (separator == null)
            separator = "";
        for (int i = 0; i < strs.length; i++) {
            returnstr.append(strs[i]);
            if (i < strs.length - 1)
                returnstr.append(separator);
        }
        return returnstr.toString();
    }
    public static String objectArrayToStr(Object[] objects, String separator) {
        StringBuffer returnstr = new StringBuffer("");
        if (objects == null)
            return "";
        if (separator == null)
            separator = "";
        for (int i = 0; i < objects.length; i++) {
            returnstr.append(String.valueOf(objects[i]));
            if (i < objects.length - 1)
                returnstr.append(separator);
        }
        return returnstr.toString();
    }
    public static String listToStr(List element, String separator) {
        StringBuffer returnstr = new StringBuffer("");
        if (element == null)
            return "";
        if (separator == null)
            separator = "";
        Iterator it = element.iterator();
        while (it.hasNext()) {
            returnstr.append(String.valueOf(it.next()));
            if (it.hasNext())
                returnstr.append(separator);
        }
        return returnstr.toString();
    }
    public static String[] listToStrArray(List element) {
        if (element == null || element.size() == 0)
            return null;
        Iterator it = element.iterator();
        String[] strArray = new String[element.size()];
        int i = 0;
        while (it.hasNext()) {
            strArray[i] = String.valueOf(it.next());
            i++;
        }
        return strArray;
    }
    public static List strToList(String str, String separator) {
        if (str == null || str.equals(""))
            return null;
        if (separator == null)
            separator = "";
        String[] strArr = str.split(separator);
        int size = strArr.length;
        List list = new ArrayList();
        for (int i = 0; i < size; i++) {
            list.add(strArr[i]);
        }
        return list;
    }
    public static StringBuffer populate(StringBuffer bf, String value,
                                        boolean isNotLast) {
        if (value == null) {
            return bf;
        }
        // ���ַ�����ÿ���������滻�����������ţ�ע�⣺����˫���ţ�����SQL����ѯ������
        System.out.println(value.replaceAll("'", "''"));
        bf.append("'").append(value.replaceAll("'", "''")).append("'");
        if (isNotLast)
            bf.append(",");
        return bf;
    }
    public static boolean isExist(String str, String substr, String sepatator) {
        if (str == null || str.trim().equals(""))
            return false;
        if (substr == null || substr.trim().equals(""))
            return false;
        String[] strArr = str.split(sepatator);
        int size = strArr.length;
        for (int i = 0; i < size; i++) {
            if (strArr[i].equals(substr))
                return true;
        }
        return false;
    }
    public static boolean isExist(String str, String substr) {
        return isExist(str, substr, ",");
    }
    public static String leftInclude(String str) {
        if (str == null || str.equals(""))
            return str;
        return str + "%";
    }
    public static String rightInclude(String str) {
        if (str == null || str.equals(""))
            return str;
        return "%" + str;
    }
    public static String include(String str) {
        if (str == null || str.equals(""))
            return str;
        return "%" + str + "%";
    }
    /**
     * ���һ���ַ���Ϊ�գ���ת��Ϊָ�����ַ���
     *
     * @param source String ԭ����
     * @param target String ת�������
     * @return String ���
     */
    public static String nvl(Object source, Object target) {
        return source != null ? String.valueOf(source)
                : (target != null ? String.valueOf(target) : null);
    }
    /**
     * ��clob�ֶ�ֵ����Ϊ�ַ���
     *
     * @param clobValue
     * @return
     * @throws SQLException
     */
    public static String clob2Str(Object clobValue) throws SQLException {
        return ((Clob) clobValue).getSubString(1, (int) ((Clob) clobValue)
                .length());
    }
    /**
     * ��ȡweb�ͻ�����ʵIp
     *
     * @param request
     * @return
     */
    public static String getRemoteAddr(HttpServletRequest request) {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
        return ip;
    }
    public static String hideFlowStr(String str, int maxLen) {
        if (str == null || maxLen == 0) {
            return "";
        }
        if (str.length() > maxLen) {
            str = str.substring(0, maxLen) + "...";
        }
        return str;
    }
    /**
     * ���������Ƿ�����
     *
     * @param str
     * @return
     */
    public static String escapeLuceneSpecialCharacters(String str) {
        if (str == null) {
            return null;
        }
        try {
            StringWriter writer = new StringWriter(str.length() * 2);
            escapeLuceneSpecialCharacterString(writer, str);
            return writer.toString();
        } catch (IOException ioe) {
            // this should never ever happen while writing to a StringWriter
            ioe.printStackTrace();
            return null;
        }
    }
    private static void escapeLuceneSpecialCharacterString(Writer out,
                                                           String str) throws IOException {
        if (str == null) {
            return;
        }
        int sz = str.length();
        for (int i = 0; i < sz; i++) {
            char ch = str.charAt(i);
            /*
             * Reference link:
			 * http://lucene.apache.org/java/docs/queryparsersyntax.html Lucene
			 * supports escaping special characters that are part of the query
			 * syntax. The current list special characters are: + - && || ! ( ) { } [ ] ^ " ~ * ? : \
			 * To escape these character use the \ before the character.
			 */
            switch (ch) {
                case '+':
                case '-':
                case '!':
                case '(':
                case ')':
                case '{':
                case '}':
                case '[':
                case ']':
                case '^':
                case '\"':
                case '~':
                case '*':
                case '?':
                case ':':
                case '\\':
                    out.write('\\');
                    out.write(ch);
                    break;
                case '&':
                case '|':
                    // check if it is '&&' or '||' ~ check if the next char is '&'
                    // or '|'
                    if ((i + 1) < sz && str.charAt(i + 1) == ch) {
                        out.write('\\');
                        out.write(ch);
                        i++;
                    }
                    out.write(ch);
                    break;
                default:
                    out.write(ch);
                    break;
            }
        }
    }
    /**
     * ȡ�ø������ֵ�����ĸ������ĸ
     */
    public static String getFirstLetter(String chinese) {
        /**
         * ��ĸ
         */
        final int[] li_SecPosValue = {1601, 1637, 1833, 2078, 2274, 2302,
                2433, 2594, 2787, 3106, 3212, 3472, 3635, 3722, 3730, 3858,
                4027, 4086, 4390, 4558, 4684, 4925, 5249, 5590};
        final String[] lc_FirstLetter = {"A", "B", "C", "D", "E", "F", "G",
                "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
                "W", "X", "Y", "Z"};
        if (chinese == null || chinese.trim().length() == 0) {
            return "";
        }
        chinese = conversionStr(chinese, "GB2312", "ISO8859-1");
        if (chinese.length() > 1) { // �ж��Dz��Ǻ���
            int li_SectorCode = (int) chinese.charAt(0); // ��������
            int li_PositionCode = (int) chinese.charAt(1); // �����
            li_SectorCode = li_SectorCode - 160;
            li_PositionCode = li_PositionCode - 160;
            int li_SecPosCode = li_SectorCode * 100 + li_PositionCode;// �������
            if (li_SecPosCode > 1600 && li_SecPosCode < 5590) {
                for (int i = 0; i < 23; i++) {
                    if (li_SecPosCode >= li_SecPosValue[i]
                            && li_SecPosCode < li_SecPosValue[i + 1]) {
                        chinese = lc_FirstLetter[i];
                        break;
                    }
                }
            } else {
                chinese = conversionStr(chinese, "ISO8859-1", "GB2312");
                chinese = chinese.substring(0, 1);
            }
        }
        return chinese;
    }
    private static String conversionStr(String str, String charsetName,
                                        String toCharsetName) {
        try {
            str = new String(str.getBytes(charsetName), toCharsetName);
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        }
        return str;
    }
    /**
     * �ı��༭���˷���
     *
     * @param html
     * @return
     */
    public static String checkStr(String html) {
        try {
            html = html.replaceAll("\r", "");
            html = html.replaceAll("\n", "");
            html = html.replaceAll("\"", "'");
            html = html.replaceAll("\t", " ");
            Pattern p_script;
            java.util.regex.Matcher m_script;
            Pattern p_href;
            java.util.regex.Matcher m_href;
            Pattern p_a;
            java.util.regex.Matcher m_a;
            Pattern p_on;
            java.util.regex.Matcher m_on;
            Pattern p_iframe;
            java.util.regex.Matcher m_iframe;
            Pattern p_frameset;
            java.util.regex.Matcher m_frameset;
            Pattern p_img;
            java.util.regex.Matcher m_img;
            Pattern p_p1;
            java.util.regex.Matcher m_p1;
            Pattern p_p2;
            java.util.regex.Matcher m_p2;
            String stript_str = "<script[\\s\\S]+</script *>";
            String href_str = " href *= *[\\s\\S]*script *:";
            String on_str = " on[\\s\\S]*=";
            String iframe_str = "<iframe[\\s\\S]+</iframe *>";
            String frameset_str = "<frameset[\\s\\S]+</frameset *>";
            String a_str = "<a ([^>])*>.*?</a([^>])*>";
            //String img_str = "\\<img[^\\>]+\\>";
            String p_str1 = "</p>";
            String p_str2 = "<p>";
            p_script = Pattern.compile(stript_str, Pattern.CASE_INSENSITIVE);
            m_script = p_script.matcher(html);
            html = m_script.replaceAll(""); // ����script��ǩ
            p_href = Pattern.compile(href_str, Pattern.CASE_INSENSITIVE);
            m_href = p_href.matcher(html);
            html = m_href.replaceAll(""); // ����script��ǩ
            p_a = Pattern.compile(a_str, Pattern.CASE_INSENSITIVE);
            m_a = p_a.matcher(html);
            html = m_a.replaceAll(""); // ����script��ǩ
            p_on = Pattern.compile(on_str, Pattern.CASE_INSENSITIVE);
            m_on = p_on.matcher(html);
            html = m_on.replaceAll(""); // ����script��ǩ
            p_iframe = Pattern.compile(iframe_str, Pattern.CASE_INSENSITIVE);
            m_iframe = p_iframe.matcher(html);
            html = m_iframe.replaceAll(""); // ����script��ǩ
            p_frameset = Pattern
                    .compile(frameset_str, Pattern.CASE_INSENSITIVE);
            m_frameset = p_frameset.matcher(html);
            html = m_frameset.replaceAll(""); // ����script��ǩ
            // p_img = Pattern.compile(img_str, Pattern.CASE_INSENSITIVE);
            // m_img = p_img.matcher(html);
            // html = m_img.replaceAll(""); // ����script��ǩ
            p_p1 = Pattern.compile(p_str1, Pattern.CASE_INSENSITIVE);
            m_p1 = p_p1.matcher(html);
            html = m_p1.replaceAll(""); // ����script��ǩ
            p_p2 = Pattern.compile(p_str2, Pattern.CASE_INSENSITIVE);
            m_p2 = p_p2.matcher(html);
            html = m_p2.replaceAll(""); // ����script��ǩ
        } catch (Exception e) {
            System.err.println("Html2Text: " + e.getMessage());
        }
        return html;
    }
    public static String substr(String value, int maxlength, String postfix) {
        int k = 0;
        int l = 0;
        for (int i = 0; i < value.length() && maxlength > l * 2 + k; i++) {
            if (value.charAt(i) > '\200') {
                l++;
            } else {
                k++;
            }
        }
        // value����������Ϊ�����ַ���
        if (l + k >= value.length()) {
            return value;
        } else if (maxlength >= l * 2 + k && l + k > 0) {
            value = value.substring(0, l + k);
        } else if (l + k > 0) {
            value = value.substring(0, (l + k) - 1);
        } else {
            return value;
        }
        // ��ָ���޶���ʾ����ʱ����ȡָ�����ȵ��ַ�����Ϊ���
        if (!StringUtils.isEmpty(postfix)) {
            value += postfix;
        }
        return value;
    }
    public static void main(String[] args) {
        String str = "���!";
    }
    /**
     * ***************************************************** ��
     * �ܣ����紫����ַ�����null��ת�ɿմ������򷵻�ԭ�ַ��� ��ڲ�����param Content:��ת�����ַ��� ���ڲ����� ��
     * �أ�����ַ�����null��ת�ɿմ������򷵻�ԭ�ַ��� <p/> ��д���ڣ�20051220 �޸ı�ע��
     * ******************************************************
     */
    public String nullToSpace(String Content) {
        if (Content == null) {
            Content = "";
        }
        return Content;
    }
    /**
     * ***************************************************** ��
     * �ܣ���GBK�ַ���ת��ISO8859_1���� ��ڲ�����param strvalue Ҫ��������ַ����� ���ڲ����� �� �أ�return
     * String ת������ַ����� �޸ı�ע��
     * ******************************************************
     */
    public String GBK2ISO(String strvalue) throws Exception {
        try {
            if (strvalue == null)
                return null;
            else {
                strvalue = new String(strvalue.getBytes("GBK"), "ISO8859_1");
                return strvalue;
            }
        } catch (Exception e) {
            return null;
        }
    }
}

+ 0 - 53
Hos-Resource-Mini-Update/src/main/java/com/yihu/ehr/util/operator/TreeNode.java

@ -1,53 +0,0 @@
package com.yihu.ehr.util.operator;
/**
 * 树类
 *
 * @author llh
 */
public class TreeNode {
    private String id;
    private String pid;
    private String text;
    private Boolean ischecked;
    public TreeNode(String id, String pid, String text) {
        this.id = id;
        this.pid = pid;
        this.text = text;
        this.ischecked = false;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getText() {
        return text;
    }
    public void setText(String text) {
        this.text = text;
    }
    public String getPid() {
        return pid;
    }
    public void setPid(String pid) {
        this.pid = pid;
    }
    public Boolean getIschecked() {
        return ischecked;
    }
    public void setIschecked(Boolean ischecked) {
        this.ischecked = ischecked;
    }
}

+ 0 - 2
Hos-Resource-Mini-Update/src/main/resources/config/dbhelper.properties

@ -1,2 +0,0 @@
defaultName = localDB
defaultUri = jdbc:sqlite://F:/test/db/localDB.db

+ 0 - 9
Hos-Resource-Mini-Update/src/main/resources/config/serviceAlive.bat

@ -1,9 +0,0 @@
@echo off
for /f "skip=3 tokens=4" %%i in ('sc query tomcat8-esb-ds ') do set "zt=%%i" &goto :next
:next
if /i "%zt%"=="RUNNING" (
    echo true
) else (
    echo false
)
exit

+ 0 - 2
Hos-Resource-Mini-Update/src/main/resources/config/start.bat

@ -1,2 +0,0 @@
net start tomcat8-esb-ds
exit

+ 0 - 2
Hos-Resource-Mini-Update/src/main/resources/config/stop.bat

@ -1,2 +0,0 @@
net stop tomcat8-esb-ds
exit

+ 0 - 29
Hos-Resource-Mini-Update/src/main/resources/config/threadConfig.properties

@ -1,29 +0,0 @@
soft.versionCode=1
## service address
service.url=https://172.19.103.73:443/api/v1.0/
service.clientId = kHAbVppx44
service.clientKey = Bd2h8rdYhep6NKOO
service.username=user
service.password=123456
##˯Ãßʱ¼ä ·ÖÖÓ
updateThread.sleepTime=30
## updateThread sleep time  min
updateThread.isUpdate=simplified-esb/getUpdateFlag
updateThread.downUpdateWar=simplified-esb/downUpdateWar
updateThread.uploadResult=simplified-esb/uploadResult
##service name
tomcat.servicename=tomcat8-esb-ds
##token
token.info={"fingerprint": "abc"}
token.basic=Basic a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P
token.getToken=authorizations/clients/
token.user_name=kHAbVppx44
system.code=MINIESB
system.downloadPath=http://172.19.103.54/

二進制
Hos-Resource-Mini-Update/src/main/resources/config/tomcat.keystore


+ 0 - 39
Hos-Resource-Mini-Update/src/main/resources/log4j2.xml

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ========================== 自定义输出格式说明================================ -->
<!-- %p 输出优先级,即DEBUG,INFO,WARN,ERROR,FATAL -->
<!-- %r 输出自应用启动到输出该log信息耗费的毫秒数  -->
<!-- %c 输出所属的类目,通常就是所在类的全名 -->
<!-- %t 输出产生该日志事件的线程名 -->
<!-- %m 输出代码中指定的消息, 产生的日志具体信息-->
<!-- %n 输出一个回车换行符,Windows平台为“\r\n”,Unix平台为“\n” -->
<!-- %d 输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比如:%d{yyy MMM dd HH:mm:ss,SSS},输出类似:2002年10月18日 22:10:28,921  -->
<!-- %l 输出日志事件的发生位置,包括类目名、发生的线程,以及在代码中的行数。举例:Testlog4.main(TestLog4.java:10)  -->
<!-- ========================================================================== -->
<Configuration status="WARN"  monitorInterval="1800" >
    <!--<properties> -->
    <!--  <property name="LOG_HOME">logs</property> -->
    <!--<property name="FILE_NAME">hos</property>-->
    <!--</properties>-->
    <Appenders>
        <!-- 日志文件保存-->
        <RollingFile name="RollingFile" fileName="${sys:log4j}/esb_mini.log"
                     filePattern="${sys:log4j}esb_mini-%d{MM-dd-yyyy}-%i.log">
            <PatternLayout charset="UTF-8"
                           pattern='%d{yyyy-MM-dd HH:mm:ss}-- %p %t %c - %m%n'/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="10 MB"/>
            </Policies>
            <DefaultRolloverStrategy fileIndex="max" max="10"/>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="trace">
            <AppenderRef ref="RollingFile"/>
        </Root>
    </Loggers>
</Configuration>

+ 0 - 13
Hos-Resource-Mini-Update/src/main/webapp/WEB-INF/web.xml

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
		  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    <listener>
        <listener-class>
            com.yihu.ehr.common.ApplicationStart
        </listener-class>
    </listener>
</web-app>

+ 0 - 5
Hos-Resource-Mini-Update/src/main/webapp/index.jsp

@ -1,5 +0,0 @@
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>

+ 0 - 2
Hos-Resource-Mini-Update/target/classes/config/dbhelper.properties

@ -1,2 +0,0 @@
defaultName = localDB
defaultUri = jdbc:sqlite://F:/test/db/localDB.db

+ 0 - 29
Hos-Resource-Mini-Update/target/classes/config/threadConfig.properties

@ -1,29 +0,0 @@
soft.versionCode=1
## service address
service.url=https://172.19.103.73:443/api/v1.0/
service.clientId = kHAbVppx44
service.clientKey = Bd2h8rdYhep6NKOO
service.username=user
service.password=123456
##˯Ãßʱ¼ä ·ÖÖÓ
updateThread.sleepTime=30
## updateThread sleep time  min
updateThread.isUpdate=simplified-esb/getUpdateFlag
updateThread.downUpdateWar=simplified-esb/downUpdateWar
updateThread.uploadResult=simplified-esb/uploadResult
##service name
tomcat.servicename=tomcat8-esb-ds
##token
token.info={"fingerprint": "abc"}
token.basic=Basic a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P
token.getToken=authorizations/clients/
token.user_name=kHAbVppx44
system.code=MINIESB
system.downloadPath=http://172.19.103.54/

二進制
Hos-Resource-Mini-Update/target/classes/config/tomcat.keystore


+ 0 - 39
Hos-Resource-Mini-Update/target/classes/log4j2.xml

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ========================== 自定义输出格式说明================================ -->
<!-- %p 输出优先级,即DEBUG,INFO,WARN,ERROR,FATAL -->
<!-- %r 输出自应用启动到输出该log信息耗费的毫秒数  -->
<!-- %c 输出所属的类目,通常就是所在类的全名 -->
<!-- %t 输出产生该日志事件的线程名 -->
<!-- %m 输出代码中指定的消息, 产生的日志具体信息-->
<!-- %n 输出一个回车换行符,Windows平台为“\r\n”,Unix平台为“\n” -->
<!-- %d 输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比如:%d{yyy MMM dd HH:mm:ss,SSS},输出类似:2002年10月18日 22:10:28,921  -->
<!-- %l 输出日志事件的发生位置,包括类目名、发生的线程,以及在代码中的行数。举例:Testlog4.main(TestLog4.java:10)  -->
<!-- ========================================================================== -->
<Configuration status="WARN"  monitorInterval="1800" >
    <!--<properties> -->
    <!--  <property name="LOG_HOME">logs</property> -->
    <!--<property name="FILE_NAME">hos</property>-->
    <!--</properties>-->
    <Appenders>
        <!-- 日志文件保存-->
        <RollingFile name="RollingFile" fileName="${sys:log4j}/esb_mini.log"
                     filePattern="${sys:log4j}esb_mini-%d{MM-dd-yyyy}-%i.log">
            <PatternLayout charset="UTF-8"
                           pattern='%d{yyyy-MM-dd HH:mm:ss}-- %p %t %c - %m%n'/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="10 MB"/>
            </Policies>
            <DefaultRolloverStrategy fileIndex="max" max="10"/>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="trace">
            <AppenderRef ref="RollingFile"/>
        </Root>
    </Loggers>
</Configuration>

+ 0 - 294
Hos-Resource-Mini-helper/pom.xml

@ -1,294 +0,0 @@
<?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>ehr</groupId>
    <artifactId>Hos-Resource-Mini-Helper</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <properties>
        <aspectj.version>1.8.7</aspectj.version>
        <jackson.version>2.4.6</jackson.version>
        <spring.version>4.1.8.RELEASE</spring.version>
    </properties>
    <!--用于发布到服务器 对应setting的对应server表情里面的id -->
    <distributionManagement>
        <repository>
            <id>Releases</id>
            <name>Releases</name>
            <url>http://172.19.103.47:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Snapshots</name>
            <url>http://172.19.103.47:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    <dependencies>
        <!--=============数据库驱动 start =============-->
        <dependency>
            <groupId>com.yihu.core</groupId>
            <artifactId>ehr-dbhelper</artifactId>
            <version>1.1.5</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.37</version>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.8.11.2</version>
        </dependency>
        <!--=============数据库驱动 end =============-->
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20151123</version>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.2</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.10</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.10</version>
        </dependency>
        <dependency>
            <groupId>commons-dbutils</groupId>
            <artifactId>commons-dbutils</artifactId>
            <version>1.6</version>
        </dependency>
        <!--=============spring start =============-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-websocket</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>
        <!--=============spring end =============-->
        <!--=============log4j start =============-->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-nop</artifactId>
            <version>1.7.13</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.12</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.4.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <!--=============log4j end =============-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <!--=============tilesJSP布局框架 start =============-->
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-extras</artifactId>
            <version>3.0.5</version>
        </dependency>
        <!--=============tiles end =============-->
        <!--=============httpclient start=============-->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.3</version>
        </dependency>
        <dependency>
            <groupId>ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.7.0</version>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>net.lingala.zip4j</groupId>
            <artifactId>zip4j</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!--=============httpclient end=============-->
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

+ 0 - 159
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/ApplicationStart.java

@ -1,159 +0,0 @@
package com.yihu.ehr.common;
import com.yihu.ehr.config.SysConfig;
import com.yihu.ehr.config.ThreadConfig;
import com.yihu.ehr.thread.LogThread;
import com.yihu.ehr.thread.SQLThread;
import com.yihu.ehr.thread.ThreadManage;
import com.yihu.ehr.util.log.LogUtil;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
/**
 * 项目启动执行
 * add by hzp at 2016-01-25
 */
public class ApplicationStart implements ServletContextListener {
    private static Properties prop = new Properties();
    private static int rebootCount = 0;
    private String log4jDirKey = "log4j";
    @Override
    public void contextInitialized(ServletContextEvent context) {
        String home = System.getProperty("catalina.home").replace('\\', '/');
        //设置日志文件路径
        System.setProperty(log4jDirKey, home + File.separator + "log4j" + File.separator);
        // String homeUrl = home.substring(0, home.lastIndexOf('/') + 1);
        //启动sqllite
        initSqlLite();
        //使用自定义转化器转化时间格式
        //ConvertUtils.register(new DateConvert(), Date.class);
        //初始化日志,sql和更新文件的线程需要的参数
        initParams();
        //启动各个线程
        startThread();
        //加载证书
        //crawlerConfig(homeUrl)
    }
    private void crawlerConfig(String homeUrl) {
        try {
            System.setProperty(log4jDirKey, homeUrl + "log4j");
            SysConfig.getInstance().setTempFile(homeUrl + "standard");
            SysConfig.getInstance().setTrustStorePath(homeUrl + "ssl/tomcat.keystore");
            LogUtil.error("加载证书文件");
        } catch (Exception e) {
            LogUtil.error("加载证书文件失败");
        }
    }
    private void initSqlLite() {
        try {
            InputStream in = this.getClass().getResourceAsStream("/config/dbhelper.properties");
            prop.load(in);
            String configPath = this.getClass().getClassLoader().getResource("/").getPath() + "config/dbhelper.properties";
            OutputStream fos = new FileOutputStream(configPath);
            String home = System.getProperty("catalina.home").replace('\\', '/');
            String url = home.substring(0, home.lastIndexOf('/') + 1) + "db/localDB.db";
            prop.setProperty("defaultUri", "jdbc:sqlite://" + url);
            prop.store(fos, "last update");
            in.close();
            fos.close();
            LogUtil.info("加载sqllite文件成功,路径更新为:jdbc:sqlite://" + url);
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.error("加载sqllite文件失败");
        }
    }
    @Override
    public void contextDestroyed(ServletContextEvent context) {
    }
    private void initParams() {
        //读取配置文件
        readProperties();
        //设置参数
        setParams();
    }
    private void setParams() {
        try {
            ThreadConfig.SERVICE_USERNAME = prop.getProperty("service.username");
            ThreadConfig.SERVICE_PASSWORD = prop.getProperty("service.password");
            ThreadConfig.SERVICE_URL = prop.getProperty("service.url");
            ThreadConfig.SERVICE_CLIENTID = prop.getProperty("service.clientId");
            ThreadConfig.SERVICE_CLIENTKEY = prop.getProperty("service.clientKey");
            //日志线程模块的参数初始化
            ThreadConfig.LOG_THREAD_SLEEP_TIME = Integer.valueOf(prop.getProperty("logThread.sleepTime"));
            ThreadConfig.LOG_THREAD_UPLOAD = prop.getProperty("logThread.uploadLog");
            ThreadConfig.LOG_THREAD_GETUPLOADFLAG = prop.getProperty("logThread.getUploadFlag");
            //SQL线程模块的参数初始化
            ThreadConfig.SQL_THREAD_SLEEP_TIME = Integer.valueOf(prop.getProperty("sqlThread.sleepTime"));
            ThreadConfig.SQL_THREAD_FILLMINING = prop.getProperty("sqlThread.fillMining");
            ThreadConfig.SQL_THREAD_CHANGEFILLMININGSTATUS = prop.getProperty("sqlThread.changeFillMiningStatus");
            ThreadConfig.SQL_THREAD_HISPENETRATION = prop.getProperty("sqlThread.hisPenetration");
            ThreadConfig.SQL_THREAD_CHANGEHISPENETRATIONSTATUS = prop.getProperty("sqlThread.changeHisPenetrationStatus");
            //更新代码线程模快的参数初始化
            //ThreadConfig.UPDATE_THREAD_SLEEP_TIME = Integer.valueOf(prop.getProperty("updateThread.sleepTime"));
            // ThreadConfig.UPDATE_THREAD_DOWNUPDATEWAR = prop.getProperty("updateThread.downUpdateWar");
            //ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG = prop.getProperty("updateThread.isUpdate");
            // ThreadConfig.UPDATE_THREAD_UPLOADRESULT = prop.getProperty("updateThread.uploadResult");
            ThreadConfig.TOMCAT_SERVICENAME = prop.getProperty("tomcat.servicename");
            ThreadConfig.SOFT_VERSIONCODE = prop.getProperty("soft.versionCode");
            ThreadConfig.SYSTEM_CODE = prop.getProperty("system.code");
            ThreadConfig.TOKEN_INFO = prop.getProperty("token.info");
            ThreadConfig.TOKEN_USER_NAME = prop.getProperty("token.user_name");
            ThreadConfig.TOKEN_METHOD = prop.getProperty("token.getToken");
            ThreadConfig.TOKEN_BASIC = prop.getProperty("token.basic");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void readProperties() {
        InputStream in;
        try {
            in = ApplicationStart.class.getResourceAsStream("/config/threadConfig.properties");
            prop.load(in);
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void startThread() {
        Thread logThread = new Thread(new LogThread());
        Thread sqlThread = new Thread(new SQLThread());
        //   Thread updateThread = new Thread(new UpdateThread());
        //启动线程
        logThread.start();
        sqlThread.start();
        // updateThread.start();
        //把线程放进线程管理器
        ThreadManage.add(ThreadManage.LOG_THREAD, logThread);
        ThreadManage.add(ThreadManage.SQL_THREAD, sqlThread);
        // ThreadManage.add(ThreadManage.UPDATE_THREAD, updateThread);
    }
    public static void main(String[] args) {
        System.out.println(ApplicationStart.class.getResource("/").getPath());
    }
}

+ 0 - 70
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/Constants.java

@ -1,70 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * Created by lingfeng on 2015/6/23.
 */
public class Constants {
    public static final String CREATE_TABLE = " CREATE TABLE ";
    public static final String INSERT_INTO = " INSERT INTO ";
    public static final String ALTER_TABLE = " ALTER TABLE ";
    public static final String SELECT = " SELECT ";
    public static final String UPDATE = "UPDATE ";
    public static final String DELETE = "DELETE ";
    public static final String FROM = " FROM ";
    public static final String WHERE = " WHERE ";
    public static final String BETWEEN = " BETWEEN ";
    public static final String EQUAL_MARK = " = ";
    public static final String GREATER_EQUAL_MARK = " >= ";
    public static final String LESS_EQUAL_MARK = " <= ";
    public static final String GREATER_MARK = " > ";
    public static final String LESS_MARK = " < ";
    public static final String SET = " SET ";
    public static final String AND = " AND ";
    public static final String QUESTION_MARK = " ? ";
    public static final String ADD = " ADD ";
    public static final String NOT_NULL = " NOT NULL ";
    public static final String SINGLE_QUOTE_MARK = "'";
    public static final String BLANK = " ";
    public static final String PRIMARY_KEY = "PRIMARY_KEY ";
    public static final String LEFT_BRACKET = "(";
    public static final String RIGHT_BRACKET = ")";
    public static final String COMMA = ",";
    public static final String SEMICOLON = ";";
    public static final String OCTOTHORPE = "#";
    public static final String VALUES = " VALUES ";
    public static final String LIKE = " LIKE ";
    public static final String PERCENT = "%";
    public static final String ROW_FORMAT_DYNAMIC = "row_format=dynamic";
    public static final String USERNAME_KEY = "u2akgXkkRRkiiCVR";
    public static final String ACCESS_TOKEN = "accessToken";
    public static final String REFRESH_TOKEN = "refreshToken";
    public static final String TOKEN_FAILD = "tokenFaild";
    public static final String TOKEN_EXPIRED = "tokenExpired";
    public static final String EMPTY = "";
    public static final String CDA_FILE = "CDA_File";
    public static final String STANDARD_ZIP = "standard.zip";
    public static final String DOT = ".";
    public static final String PATIENT_QUEUE = "patient_queue";
    public static final String UPDATE_TYPE = "update";
    public static final String DELETE_TYPE = "delete";
    public static final String ADD_TYPE = "add";
    public static final String TABLE_KEY = "id";
    public static final String FAILURE_FLG = "valid";
    public static final String UNDERLINE = "_";
    public static final String STD_PREFIX = "std_";
    public static final String ADAPTER_PREFIX = "adapter_";
    public static final String ORIGIN_PREFIX = "origin_";
    public static final String CODE_STR = "code";
    public static final String VALUE_STR = "value";
    public static final String OK = "ok";
    public static final String NO = "no";
    public static final Integer NUMBER_ZREO = 0;
    public static final Integer NUMBER_ONE = 1;
    public static final String MYSQL_DRIVER = "com.mysql.jdbc.Driver";
    public static final String ORACLE_DRIVER = "oracle.jdbc.driver.OracleDriver";
    public static final String SQLSERVER_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    public static final String MYSQL = "mysql";
    public static final String ORACLE = "oracle";
    public static final String SQLSERVER = "sqlserver";
}

+ 0 - 9
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/DictDataType.java

@ -1,9 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * Created by Administrator on 2015/9/16.
 */
public enum DictDataType {
    VALUE, //值
    CODE //编码
}

+ 0 - 12
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/LogicValues.java

@ -1,12 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * Created by HZY on 2016/1/29.
 */
public class LogicValues {
    public static final String LOGIC_OK = "ok";
    public static final String LOGIC_NO = "no";
    public static final String LOGIC_TRUE = "true";
    public static final String LOGIC_FALSE = "false";
}

+ 0 - 45
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/MetaDataType.java

@ -1,45 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * 数据元类型
 *
 * @created Created by Air on 2015/6/9.
 */
public enum MetaDataType {
    /**
     * 字符,不可枚举
     */
    S1,
    /**
     * 字符,枚举<=3个
     */
    S2,
    /**
     * 字符,代码表
     */
    S3,
    /**
     * 布尔,0(False),1(True)
     */
    L,
    /**
     * 数值,
     */
    N,
    /**
     * 日期
     */
    D,
    /**
     * 时间日期
     */
    DT,
    /**
     * 时间
     */
    T,
    /**
     * 二进制
     */
    BY
}

+ 0 - 21
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/common/constants/TransformType.java

@ -1,21 +0,0 @@
package com.yihu.ehr.common.constants;
/**
 * @created  Air on 2015/6/8.
 */
public enum TransformType {
    /**
     * 数据集
     */
    DATA_SET_JSON,
    DATA_SET_XML,
    /**
     * CDA
     */
    CDA_JSON,
    CDA_XML,
    /**
     * 非结构化
     */
    DOCUMENT,
}

+ 0 - 347
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/config/SysConfig.java

@ -1,347 +0,0 @@
package com.yihu.ehr.config;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.ehr.model.PatientIdentity;
import com.yihu.ehr.util.encrypt.RSA;
import com.yihu.ehr.util.http.HOPClient;
import com.yihu.ehr.util.http.Response;
import com.yihu.ehr.util.log.LogUtil;
import com.yihu.ehr.util.operator.ConfigureUtil;
import com.yihu.ehr.util.operator.StringUtil;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
public class SysConfig {
    public static final String HOS_RESOURCES_CONFIG = "/config/sys.config.xml";
    public static String publicKeyMethod;
    public static String tokenMethod;
    private static volatile SysConfig instance = null;
    private String platformUrl;
    private boolean debugMode;
    private String tempFile;
    private String publicKey;
    private HashMap<String, PatientIdentity> patientIdentityHashMap;
    private String trustStorePath;
    private String trustStorePwd;
    private String registerDataSet;
    private String registerIdCardNo;
    private String platformUserName;
    private String platformUserPass;
    private String platformAppId;
    private String platformAppSecret;
    private String accessToken;
    private String refreshToken;
    private String platformUser;
    private SysConfig() {
        patientIdentityHashMap = new HashMap<>();
        init();
    }
    public static SysConfig getInstance() {
        if (instance == null) {
            synchronized (SysConfig.class) {
                if (instance == null) {
                    try {
                        instance = new SysConfig();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return instance;
    }
    public void finalize() throws Throwable {
    }
    public Boolean isDebugMode() {
        return debugMode;
    }
    public String getTempFile() {
        return this.tempFile;
    }
    public void setTempFile(String tempFile) {
        this.tempFile = tempFile;
    }
    public void setTrustStorePath(String trustStorePath) {
        this.trustStorePath = trustStorePath;
        HOPCLientInit();
    }
    public String getPlatformUrl() {
        return platformUrl;
    }
    /**
     * @return String
     * @throws Exception
     * @modify 2015.09.15 airhead 修订日志信息不对问题
     */
    public String getPublicKey() throws Exception {
        if (publicKey != null) {
            return publicKey;
        }
        if (publicKeyMethod == null) {
            publicKeyMethod = ConfigureUtil.getProValue(ConfigureUtil.CRAWLER_PROPERTIES, "ha.url.security.publicKey.get");
        }
        HOPClient hopClient = new HOPClient(HOPClient.HTTPS);
        hopClient.setAppId(SysConfig.getInstance().getPlatformAppId());
        hopClient.setUrl(SysConfig.getInstance().getPlatformUrl());
        hopClient.setMethod(publicKeyMethod + platformUserName);
        Response response = hopClient.get();
        if (response == null) {
            LogUtil.fatal("获取公钥失败.");
            return null;
        }
        if (response.statusCode != 200) {
            LogUtil.fatal("获取公钥失败,错误代码:" + response.statusCode);
            return null;
        }
        ObjectMapper mapper = new ObjectMapper();
        JsonNode rootNode = mapper.readValue(response.body, JsonNode.class);
        String code = rootNode.path("code").asText();
        if ("ehr.invalid.user".equals(code)) {
            LogUtil.fatal("获取公钥失败:无效用户,请检查 Sys.config.xml文件中 <user>节点值是否正确");
            return null;
        }
        JsonNode publicNode = rootNode.path("result").path("public_key");
        if (publicNode.isMissingNode()) {
            LogUtil.fatal("获取公钥失败,返回数据格式不正确.");
            return null;
        }
        publicKey = publicNode.asText();
        return publicKey;
    }
    public PatientIdentity getPatientIdentity(String dataSetCode) {
        return patientIdentityHashMap.get(dataSetCode);
    }
    public HashMap<String, PatientIdentity> getPatientIdentityHashMap() {
        return patientIdentityHashMap;
    }
    public String getRegisterDataSet() {
        return registerDataSet;
    }
    public String getRegisterIdCardNo() {
        return registerIdCardNo;
    }
    /**
     * @return String
     * @modify 2015.09.15 airhead 修订日志信息不对问题
     */
    public String getAccessToken() {
        try {
            if (tokenMethod == null) {
                tokenMethod = ConfigureUtil.getProValue(ConfigureUtil.CRAWLER_PROPERTIES, "ha.url.security.token.get");
            }
            HOPClient hopClient = new HOPClient(HOPClient.HTTPS);
            hopClient.setAppId(SysConfig.getInstance().getPlatformAppId());
            hopClient.setUrl(SysConfig.getInstance().getPlatformUrl());
            hopClient.setMethod(tokenMethod);
//            hopClient.setParam("grant_type", "password");
            hopClient.setParam("user_name", getPlatformUserName());
            hopClient.setParam("app_secret", SysConfig.getInstance().getPlatformAppSecret());
            String publicKey = getPublicKey();
            String encryptPwd = RSA.encrypt(platformUserPass, RSA.genPublicKey(publicKey));
            hopClient.setParam("rsa_pw", encryptPwd);
            Response response = hopClient.get();
            if (response == null) {
                LogUtil.fatal("获取令牌失败.");
                return null;
            }
            if (response.statusCode != 200) {
                LogUtil.fatal("获取令牌失败,错误代码:" + response.statusCode);
                return null;
            }
            ObjectMapper mapper = new ObjectMapper();
            JsonNode rootNode = mapper.readValue(response.body, JsonNode.class);
            String code = rootNode.path("code").asText();
            if (code.equals("ehr.invalid.username.or.pwd")) {
                LogUtil.fatal("无效用户名或密码,请检查Sys.config.xml文件中 <user>节点值是否正确");
                return null;
            }
            if (code.equals("ehr.app.register.invalid")) {
                LogUtil.fatal("该app应用在系统中不存在,请检查Sys.config.xml文件中 <app>节点值是否正确");
                return null;
            }
            if (code.equals("ehr.security.token.expired") && !StringUtil.isEmpty(refreshToken)) {
                hopClient.reset();
                hopClient.setMethod(tokenMethod);
                hopClient.setAppId(SysConfig.getInstance().getPlatformAppId());
                hopClient.setParam("grant_type", "password");
                hopClient.setParam("refresh_token", refreshToken);
                hopClient.setParam("user_id", getPlatformUserName());
                response = hopClient.get();
                if (response == null) {
                    LogUtil.fatal("刷新令牌失败.");
                    return null;
                }
                if (response.statusCode != 200) {
                    LogUtil.fatal("刷新令牌失败,错误代码:" + response.statusCode);
                    return null;
                }
                rootNode = mapper.readValue(response.body, JsonNode.class);
                code = rootNode.path("code").asText();
                if (StringUtil.isEmpty(code) || !code.equals("0")) {
                    LogUtil.fatal("刷新令牌失败,错误代码:" + code);
                    return null;
                }
            }
            accessToken = rootNode.path("result").get("access_token").asText();
            refreshToken = rootNode.path("result").path("refresh_token").asText();
            return accessToken;
        } catch (Exception e) {
            LogUtil.fatal(e.getMessage());
        }
        return null;
    }
    public String getPlatformUser() {
        return platformUser;
    }
    public String getPlatformUserName() {
        return platformUserName;
    }
    public String getPlatformAppId() {
        return platformAppId;
    }
    private String getPlatformAppSecret() {
        return platformAppSecret;
    }
    private Document getDocument() throws DocumentException {
        SAXReader reader = new SAXReader();
        Document document = null;
        try {
            InputStream inputStream = SysConfig.class.getResourceAsStream(HOS_RESOURCES_CONFIG);
            document = reader.read(inputStream);
            return document;
        } catch (DocumentException de) {
            LogUtil.fatal("读取classpath下的xml文档路径发生异常");
            return null;
        }
    }
    private void init() {
        try {
            Document document = this.getDocument();
            Element rootElement = null;
            if (document != null) {
                rootElement = document.getRootElement();
            }
            if (rootElement == null) {
                return;
            }
            this.initPlatForm(rootElement);
            this.initCrawler(rootElement);
            this.initEventNo(rootElement);
            String debug = rootElement.elementTextTrim("debug");
            if (StringUtil.isEmpty(debug) || debug.equals("false")) {
                debugMode = false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.fatal(e.getMessage());
        }
    }
    private void initPlatForm(Element rootElement) throws Exception {
        Element platform = rootElement.element("platform");
        String platformUrl = platform.elementTextTrim("url");
        if (!StringUtil.isEmpty(platformUrl)) {
            this.platformUrl = platformUrl;
        }
        Element trustStore = platform.element("trust_store");
        trustStorePwd = trustStore.attributeValue("pwd");
        Element platformUserElem = platform.element("user");
        platformUserName = platformUserElem.getTextTrim();
        platformUserPass = platformUserElem.attributeValue("pwd");
        Element platformAppElem = platform.element("app");
        platformAppId = platformAppElem.getTextTrim();
        platformAppSecret = platformAppElem.attributeValue("secret");
    }
    private void initCrawler(Element rootElement) {
        List queueDataSets = rootElement.element("patient_queue").elements("dataset");
        for (Object obj : queueDataSets) {
            if (obj instanceof Element) {
                Element element = (Element) obj;
                String dataSetCode = element.attributeValue("code");
                String eventNo = element.elementTextTrim("event_no");
                String refTime = element.elementTextTrim("ref_time");
                PatientIdentity patientIdentity = new PatientIdentity(eventNo, refTime);
                patientIdentityHashMap.put(dataSetCode, patientIdentity);
            }
        }
        Element registerDataSet = rootElement.element("register").element("dataset");
        this.registerDataSet = registerDataSet.attributeValue("code");
        this.registerIdCardNo = registerDataSet.elementTextTrim("id_card");
    }
    private void initEventNo(Element rootElement) {
        List eventItems = rootElement.element("event_no").elements("item");
        for (Object obj : eventItems) {
            if (obj instanceof Element) {
                Element element = (Element) obj;
                String eventNoCode = element.getTextTrim();
                PatientIdentity.addEventNoCode(eventNoCode);
            }
        }
    }
    private void HOPCLientInit () {
        try {
            HOPClient.initHttps(trustStorePath, trustStorePwd);
        } catch (Exception e) {
            LogUtil.error(e.getMessage());
        }
    }
}//end SysConfig

+ 0 - 72
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/config/ThreadConfig.java

@ -1,72 +0,0 @@
package com.yihu.ehr.config;
import com.yihu.ehr.util.log.LogUtil;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
/**
 * Created by chenweida on 2016/2/27.
 */
public class ThreadConfig {
    public static String SERVICE_USERNAME = "admin";
    public static String SERVICE_PASSWORD = "123456";
    public static String SERVICE_URL="https://172.19.103.73:443/api/v1.0/";
    public static String SERVICE_CLIENTID = "kHAbVppx44";
    public static String SERVICE_CLIENTKEY= "Bd2h8rdYhep6NKOO";
    public static int LOG_THREAD_SLEEP_TIME = 30;
    public static String LOG_THREAD_UPLOAD = "simplified-esb/uploadLog";
    public static String LOG_THREAD_GETUPLOADFLAG;
    public static int SQL_THREAD_SLEEP_TIME = 30;
    public static String SQL_THREAD_FILLMINING = "";
    public static String SQL_THREAD_CHANGEFILLMININGSTATUS = "";
    public static String SQL_THREAD_HISPENETRATION = "";
    public static String SQL_THREAD_CHANGEHISPENETRATIONSTATUS = "";
    public static int UPDATE_THREAD_SLEEP_TIME = 30;
    public static String UPDATE_THREAD_GETUPDATEFLAG;
    public static String UPDATE_THREAD_DOWNUPDATEWAR;
    public static String UPDATE_THREAD_UPLOADRESULT;
    public static String TOKEN_USER_NAME = "kHAbVppx44";
    public static String TOKEN_INFO = "{\"fingerprint\": \"abc\"}";
    public static String TOKEN_METHOD = "authorizations/clients/";
    public static String TOKEN_BASIC = "Basic a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P";
    public static String TOMCAT_SERVICENAME = "tomcat8-esb-service";
    public static String SOFT_VERSIONCODE = "1";
    public static String SYSTEM_CODE = "";
    private static Properties prop = new Properties();
    public static void updatVersion(String version) {
        try {
            InputStream in;
            OutputStream fos;
            try {
                in = ThreadConfig.class.getResourceAsStream("/config/threadConfig.properties");
                fos = new FileOutputStream("/config/threadConfig.properties");
                prop.load(in);
                prop.setProperty("soft.versionCode", version);
                prop.store(fos, "last update");
                in.close();
                fos.close();
                ThreadConfig.SOFT_VERSIONCODE = version;
            } catch (Exception e) {
                e.printStackTrace();
            }
            LogUtil.info("更新配置文件中版本成功号");
        } catch (Exception e) {
            LogUtil.info("更新配置文件中版本失败" + e.getMessage());
        }
    }
}

+ 0 - 35
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/model/DataSource.java

@ -1,35 +0,0 @@
package com.yihu.ehr.model;
/**
 * Created by hzp on 2016/2/26.
 */
public class DataSource {
    private String id;
    private String name;
    private String config;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getConfig() {
        return config;
    }
    public void setConfig(String config) {
        this.config = config;
    }
}

+ 0 - 59
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/model/PatientIdentity.java

@ -1,59 +0,0 @@
package com.yihu.ehr.model;
import java.util.HashSet;
import java.util.Set;
/**
 * 病人身份标识
 * 病人ID, 事件号(门诊号,住院号等),卡号,身份证号
 * 目前使用的是病人ID和事件号
 *
 * @author Air
 * @version 1.0
 * @created 2015.06.16 16:29
 */
public class PatientIdentity {
    public static final String PATIENT_ID = "PATIENT_ID";
    public static final String LOCAL_CARD_NO = "CARD_NO";
    public static final String ID_CARD = "DE02_01_030_00";
    public static Set<String> EVENT_NO_SET = new HashSet<>();
    private String eventNoCode;
    private String refTimeCode;
    public PatientIdentity(String eventNoCode, String refTimeCode) {
        this.eventNoCode = eventNoCode;
        this.refTimeCode = refTimeCode;
        EVENT_NO_SET.add(eventNoCode);
    }
    public static String getPatientIDCode() {
        return PATIENT_ID;
    }
    public static String getLocalCardNoCode() {
        return LOCAL_CARD_NO;
    }
    public static String getIdCardCode() {
        return ID_CARD;
    }
    public static Set<String> getEventNoSet() {
        return EVENT_NO_SET;
    }
    public static void addEventNoCode(String eventNoCode) {
        EVENT_NO_SET.add(eventNoCode);
    }
    public String getEventNoCode() {
        return eventNoCode;
    }
    public String getRefTimeCode() {
        return refTimeCode;
    }
}

+ 0 - 35
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/model/SystemParams.java

@ -1,35 +0,0 @@
package com.yihu.ehr.model;
/**
 * Created by hzp on 2016/2/26.
 */
public class SystemParams {
    private String orgCode;
    private String orgName;
    private String interval;
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getInterval() {
        return interval;
    }
    public void setInterval(String interval) {
        this.interval = interval;
    }
}

+ 0 - 159
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/LogThread.java

@ -1,159 +0,0 @@
package com.yihu.ehr.thread;
import com.yihu.ehr.config.ThreadConfig;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.util.HttpsClientUtil;
import com.yihu.ehr.util.ZipUtil;
import com.yihu.ehr.util.log.LogUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import java.io.File;
import java.util.*;
/**
 * Created by chenweida on 2016/2/27.
 * 日志线程,定时把生成的日志发送出去
 */
public class LogThread implements Runnable {
    private String orgCode = "";
    private String systemCode = "";
    private int sleepTime = 60 * 1000;
    private DBHelper db = new DBHelper();
    private String logFileName = "esb_mini.zip";
    private String token;
    @Override
    public void run() {
        while (ThreadManage.logIsRunning) {
            try {
                token = HttpsClientUtil.getToken();
                if (!StringUtils.isEmpty(token)) {
                    initParam();
                    //判断该机构是否需要上传日志
                    if (isUpload()) {
                        //初始化参数
                        LogUtil.info("-----------日志开始上传------------token:" + token);
                        //得到日志文件
                        String file = getLogFile();
                        if (!StringUtils.isEmpty(file)) {
                            //发送日志文件
                            sendLogFile(file);
                            //删除日志文件
                            deleteLogFile(file);
                        }
                    }
                }
            } catch (Exception e) {
                LogUtil.error("-----------日志采集失败------------:" + e.getMessage());
            } finally {
                //睡眠
                try {
                    sleep();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    private void initParam() {
        if (StringUtils.isEmpty(orgCode)) {
            try {
                List<org.json.JSONObject> listORG = db.query("select * from system_param where param_key='ORG_CODE'");
                List<org.json.JSONObject> listSYSTEM = db.query("select * from system_param where param_key='SYSTEM_CODE'");
                if (listORG != null && listORG.size() > 0) {
                    orgCode = listORG.get(0).getString("param_value");
                }
                if (listSYSTEM != null && listSYSTEM.size() > 0) {
                    systemCode = listSYSTEM.get(0).getString("param_value");
                } else {
                    String sql = "insert into system_param (id,param_key,param_value) values " +
                            "('" + UUID.randomUUID() + "'," +
                            " 'SYSTEM_CODE' ," +
                            " '" + ThreadConfig.SYSTEM_CODE + "'" +
                            ")";
                    db.execute(sql);
                }
            } catch (Exception e) {
                LogUtil.error("初始化参数失败:" + e.getMessage());
            }
        }
        LogUtil.info("初始化参数成功orgCode:" + orgCode + "---systemCode:" + systemCode);
    }
    private boolean sendLogFile(String file) {
        try {
            //String booleanString =HttpClientUtil.sendFile(file, ThreadConfig.getURL(ThreadConfig.LOG_THREAD_UPLOAD), ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            String token = HttpsClientUtil.getToken();
            List<NameValuePair> formParams = new ArrayList<NameValuePair>();
            formParams.add(new BasicNameValuePair("ip", ""));
            formParams.add(new BasicNameValuePair("access_token", token));
            formParams.add(new BasicNameValuePair("orgCode", orgCode));
            String booleanString = HttpsClientUtil.postFile(ThreadConfig.SERVICE_URL + ThreadConfig.LOG_THREAD_UPLOAD, file, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("日志上传结果:" + booleanString);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.error("日志发送失败:");
            return false;
        }
    }
    private void deleteLogFile(String filePathTemp) {
        File file=new File(filePathTemp);
        String filePath = file.getAbsolutePath();
        if (file.delete()) {
            LogUtil.info("日志删除成功");
        } else {
            LogUtil.error("日志删除失败,日志路径:" + file.getAbsolutePath());
        }
    }
    public String getLogFile() {
        String home = System.getProperty("catalina.home").replace('\\', '/');
        String srcPath = home.substring(0, home.lastIndexOf('/') + 1) + "log4j";
        LogUtil.info("压缩日志,日志目录:" + srcPath);
        String filePath = srcPath + File.separator + logFileName;
        ZipUtil.zip(srcPath, filePath);
        LogUtil.info("上传的日志文件路径:" + filePath);
        File file = new File(filePath);
        if (file.exists()) {
            LogUtil.info("-----------得到日志成功------------");
            return filePath;
        } else {
            LogUtil.error("-----------得到日志失败------------");
            return "";
        }
    }
    private void sleep() throws Exception {
        LogUtil.info("日志线程开始睡眠,睡眠时间(分钟):" + ThreadConfig.LOG_THREAD_SLEEP_TIME);
        Thread.sleep(sleepTime * ThreadConfig.LOG_THREAD_SLEEP_TIME);
    }
    public static void main(String[] args) {
        RestTemplate r = new RestTemplate();
    }
    public boolean isUpload() {
        try {
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("orgCode", orgCode);
            params.put("systemCode", systemCode);
            params.put("access_token", token);
            String booleanString = HttpsClientUtil.get(ThreadConfig.SERVICE_URL + ThreadConfig.LOG_THREAD_GETUPLOADFLAG, params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("判断日志是否需要上传:" + booleanString);
            return Boolean.valueOf(booleanString);
        } catch (Exception e) {
            LogUtil.error("判断日志是否需要上传失败" + e.getMessage());
            return false;
        }
    }
}

+ 0 - 349
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/SQLThread.java

@ -1,349 +0,0 @@
package com.yihu.ehr.thread;
import com.yihu.ehr.config.SysConfig;
import com.yihu.ehr.config.ThreadConfig;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.util.HttpsClientUtil;
import com.yihu.ehr.util.log.LogUtil;
import net.sf.json.JSONObject;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
 * Created by chenweida on 2016/2/27.
 */
public class SQLThread implements Runnable {
    private String orgCode = "";
    private String systemCode = "";
    private int sleepTime = 60 * 1000;//睡眠时间
    private String fillMiningResponString;//补采的返回数据
    private String hisResponString;//his的返回数据
    private DBHelper db = new DBHelper();
    private DBHelper localdb = null;
    private String token;
    private boolean flag = true;
    @Override
    public void run() {
        while (ThreadManage.sqlIsRunning) {
            try {
                token = HttpsClientUtil.getToken();
                LogUtil.info("-----------sql线程开始启动------------token:" + token);
                if (!StringUtils.isEmpty(token)) {
                    //初始化参数
                    initParam();
                    //执行补采操作
                    LogUtil.info("-----------开始执行补采任务判断------------");
                    fillMining();
                    LogUtil.info("-----------结束执行补采任务判断------------");
                    //执行his穿透
                    LogUtil.info("-----------开始执行his穿透任务判断------------");
                    hisPenetration();
                    LogUtil.info("-----------结束执行his穿透任务判断------------");
                    //休眠
                }
            } catch (Exception e) {
                LogUtil.info("-----------sql线程执行失败-----------:" + e.getMessage());
            } finally {
                try {
                    sleep();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    private void initParam() {
        if (StringUtils.isEmpty(orgCode) || StringUtils.isEmpty(systemCode)) {
            try {
                List<org.json.JSONObject> listORG = db.query("select * from system_param where param_key='ORG_CODE'");
                List<org.json.JSONObject> listSYSTEM = db.query("select * from system_param where param_key='SYSTEM_CODE'");
                if (listORG != null && listORG.size() > 0) {
                    orgCode = listORG.get(0).getString("param_value");
                }
                if (listSYSTEM != null && listSYSTEM.size() > 0) {
                    systemCode = listSYSTEM.get(0).getString("param_value");
                } else {
                    String sql = "insert into system_param (id,param_key,param_value) values " +
                            "('" + UUID.randomUUID() + "'," +
                            " 'SYSTEM_CODE' ," +
                            " '" + ThreadConfig.SYSTEM_CODE + "'" +
                            ")";
                    db.execute(sql);
                }
            } catch (Exception e) {
                LogUtil.error("初始化参数失败:" + e.getMessage());
            }
        }
        LogUtil.info("初始化参数成功orgCode:" + orgCode + "---systemCode:" + systemCode);
    }
    /**
     * his穿透
     */
    private void hisPenetration() {
        //判断是否有his穿透的SQL
        if (hasHisPenetration()) {
            //判断jsonObject是不是有效的
            if (!StringUtils.isEmpty(hisResponString)) {
                JSONObject jo = JSONObject.fromObject(hisResponString);
                try {
                    //得到id
                    String id = (String) jo.get("id");
                    //得到sql
                    String sql = (String) jo.get("sql");
                    //执行sql返回结果
                    String resultObj = excuteSQL(sql.replace("[", "").replace("]", ""));
                    //保存结果的到总支撑
                    save(id, resultObj);
                } catch (Exception e) {
                    LogUtil.error("hql穿透返回结果解析失败:" + jo.toString());
                }
            }
        }
    }
    /**
     * 保存结果的到总支撑
     *
     * @param id
     * @param resultObj
     */
    private void save(String id, String resultObj) {
        try {
            // Map<String, Object> params = new HashMap<String, Object>();
            // params.put("id", id);
            //params.put("result", resultObj);
            //params.put("status", 1);
            // HttpClientUtil.doPost(ThreadConfig.getURL(ThreadConfig.SQL_THREAD_CHANGEHISPENETRATIONSTATUS), params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            List<NameValuePair> formParams = new ArrayList<NameValuePair>();
            formParams.add(new BasicNameValuePair("id", id));
            if (flag) {
                formParams.add(new BasicNameValuePair("message", "执行失败"));
            } else {
                formParams.add(new BasicNameValuePair("message", "执行成功"));
            }
            formParams.add(new BasicNameValuePair("result", resultObj));
            formParams.add(new BasicNameValuePair("access_token", token));
            formParams.add(new BasicNameValuePair("status", "1"));
            hisResponString = HttpsClientUtil.post(ThreadConfig.SERVICE_URL + ThreadConfig.SQL_THREAD_CHANGEHISPENETRATIONSTATUS, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("保存结果成功 " + hisResponString + ":ID=" + id);
        } catch (Exception e) {
            LogUtil.error("保存结果失败:ID=" + id + e.getMessage());
        }
    }
    /**
     * 执行sql返回结果
     *
     * @param sql
     * @return
     */
    private String excuteSQL(String sql) {
        if (localdb == null) {
            synchronized (SQLThread.class) {
                //初始化数据库连接池
                LogUtil.info("初始化数据库连接池:");
                List<org.json.JSONObject> list = db.query(" select * from system_datasource ");
                if (list != null && list.size() > 0) {
                    org.json.JSONObject jo = list.get(0);
                    LogUtil.info("得到数据源:" + (String) jo.get("config"));
                    localdb = new DBHelper((String) jo.get("id"), (String) jo.get("config"));
                    LogUtil.info("初始化数据源成功:" + localdb);
                }
            }
        }
        try {
            List<org.json.JSONObject> locallist = localdb.query(sql);
            LogUtil.info("执行语句得到数据数目:" + locallist.size());
            flag = true;
            return locallist.toString();
        } catch (Exception e) {
            flag = false;
            LogUtil.error("执行语句失败:" + e.getMessage());
            return "";
        }
    }
    /**
     * 判断是否有his穿透的语句
     *
     * @return
     */
    private boolean hasHisPenetration() {
        try {
            // Map<String, Object> params = new HashMap<String, Object>();
            //  params.put("systemCode", systemCode);
            //params.put("orgCode", orgCode);
            //得到执行的hisSql语句  {id:xxx,sql:xxx}
            //hisResponString = HttpClientUtil.doPost(ThreadConfig.getURL(ThreadConfig.SQL_THREAD_HISPENETRATION), params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            //hisResponString = "{\"id\":\"aaaa\",\"sql\":\"select * from HDSA00_01 t where t.patient_id = '10126751'\"}";
            List<NameValuePair> formParams = new ArrayList<NameValuePair>();
            formParams.add(new BasicNameValuePair("systemCode", systemCode));
            formParams.add(new BasicNameValuePair("orgCode", orgCode));
            formParams.add(new BasicNameValuePair("access_token", token));
            String path = ThreadConfig.SERVICE_URL + ThreadConfig.SQL_THREAD_HISPENETRATION;
            hisResponString = HttpsClientUtil.post(path, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("得到要执行的his穿透任务:" + hisResponString);
            if (!StringUtils.isEmpty(hisResponString)) {
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.error("没有要执行的his穿透任务:" + e.getMessage());
            return false;
        }
    }
    /**
     * 补采
     */
    private void fillMining() {
        //判断是否补采
        if (hasFillning()) {
            //把数据插入到补采的表
            if (!StringUtils.isEmpty(fillMiningResponString)) {
                try {
                    // {"startTime":"yyyyMMdd HH:mm:ss","endTime":"yyyyMMdd HH:mm:ss"}
                    JSONObject jo = JSONObject.fromObject(fillMiningResponString);
                    String id = (String) jo.get("id");
                    String startTime = (String) jo.get("startTime");
                    if (StringUtils.isEmpty(startTime) || startTime.equals("null")) {
                        LogUtil.info("-----------开始时间格式有错");
                        return;
                    }
                    String endtime = (String) jo.get("endTime");
                    if (StringUtils.isEmpty(endtime) || endtime.equals("null")) {
                        LogUtil.info("-----------结束时间格式有错");
                        return;
                    }
                    if (StringUtils.isEmpty(id) || id.equals("null")) {
                        LogUtil.info("-----------id格式有错");
                        return;
                    }
                    String sql = "insert into crawler_supply (id,start_time,end_time,status,remote_id) values " +
                            "('" + UUID.randomUUID() + "'," +
                            "'" + startTime + "' ," +
                            "'" + endtime + "'," +
                            "'0','" + id + "'" +
                            ")";
                    db.execute(sql);
                    LogUtil.info("-----------补采数据插入数据库sql:" + sql);
                    LogUtil.info("-----------修改总平台的补采数据状态:");
                    changeFillmining();
                } catch (Exception e) {
                    e.printStackTrace();
                    LogUtil.info("-----------补采数据插入数据库失败");
                }
            }
        }
    }
    /**
     * 判断是否补采
     *
     * @return
     */
    private boolean hasFillning() {
        try {
            // Map<String, Object> params = new HashMap<String, Object>();
            //params.put("systemCode", systemCode);
            //params.put("orgCode", orgCode);
            // fillMiningResponString = HttpClientUtil.doPost(ThreadConfig.getURL(ThreadConfig.SQL_THREAD_FILLMINING).trim(), params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            //fillMiningResponString = "{\"id\":\"111\",\"startTime\":\"2014-01-01 12:12:12\",\"endTime\":\"2014-01-01 12:12:12\"}";
            List<NameValuePair> formParams = new ArrayList<NameValuePair>();
            formParams.add(new BasicNameValuePair("systemCode", systemCode));
            formParams.add(new BasicNameValuePair("access_token", token));
            formParams.add(new BasicNameValuePair("orgCode", orgCode));
            fillMiningResponString = HttpsClientUtil.post(ThreadConfig.SERVICE_URL + ThreadConfig.SQL_THREAD_FILLMINING, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("-----------返回的執行的補採任務:responString:" + fillMiningResponString);
            if (!StringUtils.isEmpty(fillMiningResponString)) {
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            LogUtil.error("-----------沒有要執行的補採任務------------:" + e.getMessage());
            return false;
        }
    }
    /**
     * 休眠
     *
     * @throws Exception
     */
    private void sleep() throws Exception {
        LogUtil.info("SQL线程开始睡眠,睡眠时间(分钟):" + ThreadConfig.SQL_THREAD_SLEEP_TIME);
        Thread.sleep(sleepTime * ThreadConfig.SQL_THREAD_SLEEP_TIME);
    }
    /**
     * 得到补采的参数
     *
     * @return
     */
    public String changeFillmining() {
        String result = "";
        JSONObject jo = JSONObject.fromObject(fillMiningResponString);
        String id = (String) jo.get("id");
        try {
//            Map<String, Object> params = new HashMap<String, Object>();
//            params.put("systemCode", systemCode);
//            params.put("orgCode", orgCode);
//            params.put("id", id);
//            params.put("status", 2);
//            result = HttpClientUtil.doPost(ThreadConfig.getURL(ThreadConfig.SQL_THREAD_CHANGEFILLMININGSTATUS), params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            List<NameValuePair> formParams = new ArrayList<NameValuePair>();
            formParams.add(new BasicNameValuePair("message", "修改成功"));
            formParams.add(new BasicNameValuePair("id", id));
            formParams.add(new BasicNameValuePair("access_token", token));
            formParams.add(new BasicNameValuePair("status", "2"));
            fillMiningResponString = HttpsClientUtil.post(ThreadConfig.SERVICE_URL + ThreadConfig.SQL_THREAD_CHANGEFILLMININGSTATUS, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("修改总平台补采数据状态为2成功:" + fillMiningResponString);
        } catch (Exception e) {
            LogUtil.error("得到补采的参数失败:" + e.getMessage());
            return "";
        }
        return result;
    }
    /**
     * 得到his穿透的语句
     *
     * @return
     */
    public String getHisSql() {
        String result = "";
        try {
            List<NameValuePair> formParams = new ArrayList<NameValuePair>();
            formParams.add(new BasicNameValuePair("systemCode", systemCode));
            formParams.add(new BasicNameValuePair("orgCode", orgCode));
            formParams.add(new BasicNameValuePair("access_token", token));
            result = HttpsClientUtil.post(SysConfig.getInstance().getPlatformUrl() + ThreadConfig.SQL_THREAD_FILLMINING, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("得到需要执行的his穿透任务的语句成功:" + result);
        } catch (Exception e) {
            LogUtil.error("得到需要执行的his穿透任务的语句失败");
        }
        return result;
    }
}

+ 0 - 34
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/ThreadManage.java

@ -1,34 +0,0 @@
package com.yihu.ehr.thread;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by chenweida on 2016/3/2.
 */
public class ThreadManage {
    public static String LOG_THREAD = "logThread";
    public static String SQL_THREAD = "sqlThread";
    public static String UPDATE_THREAD = "UpdateThread";
    public static boolean logIsRunning = true;
    public static boolean sqlIsRunning = true;
    public static boolean updateIsRunning = true;
    private static Map<String, Thread> threadPool = new HashMap<String, Thread>();
    public static void add(String threadId, Thread thread) {
        threadPool.put(threadId, thread);
    }
    public static Thread get(String threadId) {
        return threadPool.get(threadId);
    }
    //把所有的线程的有效标示设置成false
    public static void stopAllThread() {
        logIsRunning = false;
        sqlIsRunning = false;
        updateIsRunning = false;
    }
}

+ 0 - 235
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/UpdateThread.java

@ -1,235 +0,0 @@
package com.yihu.ehr.thread;
import com.yihu.ehr.config.SysConfig;
import com.yihu.ehr.config.ThreadConfig;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.util.HttpsClientUtil;
import com.yihu.ehr.util.ZipUtil;
import com.yihu.ehr.util.log.LogUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.springframework.util.StringUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by chenweida on 2016/2/27.
 */
public class UpdateThread implements Runnable {
    private String orgCode;
    private String systemCode;
    private int sleepTime = 60 * 1000;
    private DBHelper db = new DBHelper();
    private String resultString = "";
    private String versionName = "";
    private String versionCode = "";
    private String token;
    @Override
    public void run() {
        while (ThreadManage.updateIsRunning) {
            token = HttpsClientUtil.getToken();
            if (!StringUtils.isEmpty(token)) {
                try {
                    //初始化参数
                    initParam();
                    LogUtil.info("-----------更新线程开始启动------------token:" + token);
                    //判断是否需要更新
                    if (isUpdate()) {
                        LogUtil.info("有需要更新的任务");
                        //得到更新的文件包
                        String filePath = downLoadFile();
                        LogUtil.info("更新包的路径是:" + filePath);
                        //解压并且覆盖文件
                        if (!StringUtils.isEmpty(filePath)) {
                            if (zipFile(filePath)) {
                                //重启服务
                                reload();
                            }
                        }
                        //上传结果
                        upLoagResult();
                    } else {
                        LogUtil.info("没有需要更新的任务");
                    }
                } catch (Exception e) {
                    LogUtil.error("-----------更新线程执行失败------------失败原因:" + e.getMessage());
                } finally {
                    //睡眠
                    try {
                        sleep();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    private void upLoagResult() {
        try {
            net.sf.json.JSONObject jo = net.sf.json.JSONObject.fromObject(resultString);
//            Map<String, Object> params = new HashMap<String, Object>();
//            params.put("systemCode", systemCode);
//            params.put("orgCode", orgCode);
//            params.put("versionName", versionName);
//            params.put("versionCode", versionCode);
//            params.put("updateDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
//            HttpClientUtil.doPost(ThreadConfig.SERVICE_URL + ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG, params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            List<NameValuePair> formParams = new ArrayList<NameValuePair>();
            formParams.add(new BasicNameValuePair("systemCode", systemCode));
            formParams.add(new BasicNameValuePair("versionName", versionName));
            formParams.add(new BasicNameValuePair("versionCode", versionCode));
            formParams.add(new BasicNameValuePair("updateDate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
            formParams.add(new BasicNameValuePair("orgCode", orgCode));
            resultString = HttpsClientUtil.post(ThreadConfig.SERVICE_URL + ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("上传结果成功");
        } catch (Exception e) {
            LogUtil.error("上传结果失败:" + e.getMessage());
        }
    }
    private void initParam() {
        if (StringUtils.isEmpty(orgCode) || StringUtils.isEmpty(systemCode)) {
            try {
                List<JSONObject> listORG = db.query("select * from system_param where param_key='ORG_CODE'");
                List<JSONObject> listSYSTEM = db.query("select * from system_param where param_key='SYSTEM_CODE'");
                if (listORG != null && listORG.size() > 0) {
                    orgCode = listORG.get(0).getString("param_value");
                }
                if (listSYSTEM != null && listSYSTEM.size() > 0) {
                    systemCode = listSYSTEM.get(0).getString("param_value");
                }
                LogUtil.info("初始化参数成功orgCode:" + orgCode + "---systemCode:" + systemCode);
            } catch (Exception e) {
                LogUtil.error("初始化参数失败:" + e.getMessage());
            }
        }
    }
    private void reload() throws Exception {
        LogUtil.info("开始重启服务");
        try {
            String system = System.getProperty("os.name").toLowerCase();
            if (system.contains("windows")) {
                LogUtil.info("重启windows服务");
                //windows
                String root = System.getProperty("catalina.home").replace('\\', '/');
                String[] commandStop = {root + "\\bin\\shutdown.bat"};
                String[] commandStart = {root + "\\bin\\startup.bat"};
                String[] envp = {"JAVA_HOME=" + root + "\\jdk1.8.0_45", "CATALINA_HOME=" + root + "\\tomcat8-esb-ds"};
                File workdir = new File(root + "\\tomcat8-esb-ds\\bin");
                LogUtil.info("关闭服务目录:" + commandStop);
                LogUtil.info("启动服务目录:" + commandStop);
                Runtime.getRuntime().exec(commandStop, envp, workdir);
                Process process = Runtime.getRuntime().exec(commandStart, envp, workdir);
                //取得命令结果的输出流
                InputStream fis = process.getInputStream();
                //用一个读输出流类去读
                BufferedReader br = new BufferedReader(new InputStreamReader(fis));
                String line = null;
                //逐行读取输出到控制台
                while ((line = br.readLine()) != null) {
                }
                fis.close();
                br.close();
            } else {
                LogUtil.info("重启linux服务");
                Runtime.getRuntime().exec("service " + ThreadConfig.TOMCAT_SERVICENAME + " restart");
            }
            LogUtil.info("重启成功");
        } catch (Exception e) {
            LogUtil.error("重启失败:" + e.getMessage());
        }
    }
    private boolean zipFile(String filePath) {
        try {
            String home = System.getProperty("catalina.home").replace('\\', '/');
            String url = home.substring(0, home.lastIndexOf('/') + 1) + "tomcat8-esb-ds/webapps/hos-esb-mini";
            boolean zipResult = ZipUtil.unZip(filePath, url);
            LogUtil.info("解压" + zipResult + ",解压路径:" + url);
            return true;
        } catch (Exception e) {
            LogUtil.error("解压失败:" + e.getMessage());
            return false;
        }
    }
    private String downLoadFile() throws Exception {
        String path = null;
        try {
            //Map<String, Object> params = new HashMap<String, Object>();
            //    params.put("systemCode", systemCode);
            // params.put("orgCode", orgCode);
            // path = getFilePath();
            //  HttpClientUtil.downFile(path, params, ThreadConfig.getURL(ThreadConfig.UPDATE_THREAD_DOWNUPDATEWAR), "", "");
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("systemCode", systemCode);
            params.put("orgCode", orgCode);
            HttpsClientUtil.downLoadFileByBase64(path, params,ThreadConfig.SERVICE_URL + ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("下载文件成功,文件保存目录:" + path);
        } catch (Exception e) {
            LogUtil.error("下载文件失败:" + path + e.getMessage());
            return "";
        }
        return path;
    }
    private Boolean isUpdate() throws Exception {
        // Map<String, Object> params = new HashMap<String, Object>();
        // params.put("systemCode", systemCode);
        //params.put("versionCode", ThreadConfig.SOFT_VERSIONCODE);
        // params.put("orgCode", orgCode);
        // String returnString = "true";
        try {
            // resultString = HttpClientUtil.doPost(ThreadConfig.SERVICE_URL + ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG, params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("systemCode", systemCode);
            params.put("orgCode", orgCode);
            params.put("versionCode", ThreadConfig.SOFT_VERSIONCODE);
            resultString = HttpsClientUtil.get(ThreadConfig.SERVICE_URL + ThreadConfig.UPDATE_THREAD_GETUPDATEFLAG, params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            if (!StringUtils.isEmpty(resultString)) {
                net.sf.json.JSONObject jo = net.sf.json.JSONObject.fromObject(resultString);
                versionName = String.valueOf(jo.get("versionName"));
                versionCode = String.valueOf(jo.get("versionCode"));
                return true;
            } else {
                return false;
            }
        } catch (Exception e) {
            LogUtil.error("判断是否有需要更新的任务失败:" + e.getMessage());
            return false;
        }
    }
    private void sleep() throws Exception {
        LogUtil.info("日志线程开始睡眠,睡眠时间(分钟):" + ThreadConfig.UPDATE_THREAD_SLEEP_TIME);
        Thread.sleep(sleepTime * ThreadConfig.SQL_THREAD_SLEEP_TIME);
    }
    private String getFilePath() {
        SimpleDateFormat s = new SimpleDateFormat("yyyyMMddHHmmss");
        String home = System.getProperty("catalina.home").replace('\\', '/');
        //F:/{tomcat_home}/updateWar
        String fileName = s.format(new Date()).toString();
        // String fileName = "aaa";
        return home + File.separator + "updateWar" + File.separator + fileName + ".war";
    }
}

+ 0 - 432
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/HttpClientUtil.java

@ -1,432 +0,0 @@
package com.yihu.ehr.util;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.util.StringUtils;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * HTTP 请求工具类
 *
 * @author : cwd
 * @version : 1.0.0
 * @date : 2016/1/14
 * @see : TODO
 */
public class HttpClientUtil {
    /**
     * 发送 GET 请求(HTTP),不带输入数据 不加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url) throws Exception {
        return doGet(url, new HashMap<String, Object>(), "", "");
    }
    /**
     * 发送 GET 请求(HTTP),不带输入数据 不加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url, Map<String, Object> params) throws Exception {
        return doGet(url, params, "", "");
    }
    /**
     * 发送 GET 请求(HTTP),不带输入数据 加密
     *
     * @param url
     * @return
     */
    public static String doGet(String url, String username, String password) throws Exception {
        return doGet(url, new HashMap<String, Object>(), username, password);
    }
    /**
     * httpClient的get请求方式
     *
     * @return
     * @throws Exception
     */
    public static String doGet(String url, Map<String, Object> params, String username, String password)
            throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        //设置请求信息
        try {
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpGet httpget = new HttpGet(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpget, context);
            } else {
                response1 = httpclient.execute(httpget);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            return "";
        } finally {
            response1.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * httpClient的post请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doPost(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            //流转字符串
            responString = EntityUtils.toString(httpEntity);
        } catch (Exception e) {
            return "";
        } finally {
            response.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * httpClient的put请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doPut(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpPut httpPut = new HttpPut(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpPut.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpPut, context);
            } else {
                response1 = httpclient.execute(httpPut);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            return "";
        } finally {
            response1.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * httpClient的delete请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doDelete(String url, Map<String, Object> params, String username, String password) throws Exception {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpDelete httpget = new HttpDelete(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpget, context);
            } else {
                response1 = httpclient.execute(httpget);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            return "";
        } finally {
            response1.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * 文件上传
     *
     * @param file
     * @param url
     * @param username
     * @param password
     * @return
     * @throws IOException
     */
    public static String sendFile(File file, String url, String username, String password, Map<String, String> params) throws IOException {
        String responString = "";
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            httpPost.setConfig(requestConfig);
            FileBody bin = new FileBody(file);
            MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
            reqEntity.addPart("file", bin);
            httpPost.setEntity(reqEntity.build());
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            //流转字符串
            responString = EntityUtils.toString(httpEntity);
        } catch (Exception e) {
            return "";
        } finally {
            response.close();
            httpclient.close();
        }
        return responString;
    }
    /**
     * 文件下载
     *
     * @param filePath
     * @param url
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static File downFile(String filePath, Map<String, Object> params, String url, String username, String password) throws Exception {
        File file = null;
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            InputStream is = httpEntity.getContent();
            file = new File(filePath);
            file.getParentFile().mkdirs();
            FileOutputStream fileout = new FileOutputStream(file);
            /**
             * 根据实际运行效果 设置缓冲区大小
             */
            byte[] buffer = new byte[1024];
            int ch = 0;
            while ((ch = is.read(buffer)) != -1) {
                fileout.write(buffer, 0, ch);
            }
            is.close();
            fileout.flush();
            fileout.close();
        } catch (Exception e) {
            return null;
        } finally {
            response.close();
            httpclient.close();
        }
        return file;
    }
    public static void main(String[] args) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("standard", "{\n" +
//                "    \"id\": 4,\n" +
//                "    \"name\": \"电子健康档案标准bbb\",\n" +
//                "    \"code\": \"YY20160114\",\n" +
//                "    \"publisher\": \"健康之路2\",\n" +
//                "    \"publisherOrgCode\": \"jkzl\",\n" +
//                "    \"summary\": \"string\",\n" +
//                "    \"refStandard\": \"WS2012\",\n" +
//                "    \"refStandardVersion\": \"V1.0\",\n" +
//                "    \"versionStatus\": 0\n" +
//                "}");
        // params.put("versionId", "5694696eb80d");
        //  params.put("publisher", "lfq");
        //   System.out.println(HttpClientUtil.doPost("http://192.168.131.17:6020/api/v1.0/standard_center/version/publish", params, "user", "standard"));
        //文件上传
        //File file = new File("F:/111.txt");
        // HttpClientUtil.sendFile(file, "http://192.168.131.6:8890/api/v1.0/resource/upload", "user", "standard");
        //文件下载
        //params.put("field", "[{\"key\":\"name\",\"value\":\"资源名称\"},{\"key\":\"code\",\"value\":\"资源代码\"},{\"key\":\"type\",\"value\":\"资源类型\"},{\"key\":\"category\",\"value\":\"资源类别\"}]");
        //params.put("name", "授权资源清单");
        //params.put("id", "aaaaaaaa1");
        // params.put("queryParams", "[]");
        params.put("systemCode", "test1");
        HttpClientUtil.downFile("E:/bbb.war", params, "http://localhost:10060/api/v1.0/esb/downUpdateWar", "", "");
    }
}

+ 0 - 497
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/HttpsClientUtil.java

@ -1,497 +0,0 @@
package com.yihu.ehr.util;
import com.yihu.ehr.config.ThreadConfig;
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
import com.yihu.ehr.util.encode.Base64;
import com.yihu.ehr.util.http.HopHostnameVerifier;
import com.yihu.ehr.util.log.LogUtil;
import net.sf.json.JSONObject;
import org.apache.http.*;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2016/3/9.
 */
public class HttpsClientUtil {
    private static String sslPath = "/ssl/tomcat.keystore";
    private static String password = "123456";
    private static PoolingHttpClientConnectionManager connMgr = null;
    private static HttpClientBuilder httpClientBuilder = null;
    private static RestTemplate rt = null;//springRest模板
    private static DBHelper db = new DBHelper();
    private static String finger = "";
    public static String getToken() {
        try {
            if (StringUtils.isEmpty(finger)) {
                List<org.json.JSONObject> listSYSTEM = db.query("select * from system_param where param_key='FINGER_PRINT'");
                if (listSYSTEM != null && listSYSTEM.size() > 0) {
                    finger = listSYSTEM.get(0).getString("param_value");
                }
            }
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("info", "{\"fingerprint\": \"+finger+\"}");
            String encodeString = Base64.encode((ThreadConfig.SERVICE_CLIENTID + ":" + ThreadConfig.SERVICE_CLIENTKEY).getBytes());
            String responString = HttpsClientUtil.doPut(ThreadConfig.SERVICE_URL + ThreadConfig.TOKEN_METHOD + ThreadConfig.TOKEN_USER_NAME, params, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD,
                    new BasicHeader("Authorization", encodeString));
            return String.valueOf(JSONObject.fromObject(responString).get("token"));
        } catch (Exception e) {
            LogUtil.error("获取token失败");
            return "";
        }
    }
    static {
        //初始化证书
        try {
            String path = HttpsClientUtil.class.getResource("/").getPath() + "config/tomcat.keystore";
            acceptsUntrustedCertsHttpClient();
            //创建spring的RestTemplate并且初始化
            HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build());
            rt = new RestTemplate(clientHttpRequestFactory);
        } catch (Exception e) {
            LogUtil.error("初始化证书失败");
        }
    }
    public static RestTemplate getRestTemplate() {
        return rt;
    }
    public static CloseableHttpClient getCloseableHttpClient() {
        CloseableHttpClient c = httpClientBuilder.build();
        return c;
    }
    /**
     * 初始化连接池并且生成可以用的接口
     *
     * @return
     * @throws Exception
     */
    public static void acceptsUntrustedCertsHttpClient() throws Exception {
        httpClientBuilder = HttpClientBuilder.create();
        // String home = System.getProperty("catalina.home").replace('\\', '/');
        //String path=HttpsClientUtil.class.getResource(home + sslPath).getPath();
        String path = HttpsClientUtil.class.getResource("/").getPath() + "config/tomcat.keystore";
        // LogUtil.info("证书路径:" + home + sslPath);
        // 设置证书
        SSLContext sslContext = SSLContexts.custom()
                .loadTrustMaterial(new File(path), password.toCharArray(),
                        (TrustStrategy) new TrustSelfSignedStrategy())
                .build();
        httpClientBuilder.setSSLContext(sslContext);
        SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
                sslContext,
                new String[]{"TLSv1"},
                null,
                new HopHostnameVerifier());
        Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
                .register("https", sslSocketFactory)
                .build();
        connMgr = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
        httpClientBuilder.setConnectionManager(connMgr);
    }
    /**
     * 发送文件
     *
     * @param url        路径
     * @param filePath   文件路径
     * @param formParams 参数
     * @return
     */
    public static String postFile(String url, String filePath, List<NameValuePair> formParams, String username, String password) {
        CloseableHttpClient httpClient = getCloseableHttpClient();
        File file = new File(filePath);
        //设置请求信息
        RequestConfig requestConfig = RequestConfig.custom().
                setAuthenticationEnabled(true).build();
        //创建httppost请求
        HttpPost httpPost = new HttpPost(url);
        ArrayList<Header> headers = new ArrayList<Header>();
        httpPost.addHeader(new BasicHeader(HttpHeaders.AUTHORIZATION, "Basic a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P"));
        httpPost.setConfig(requestConfig);
        //新建文件对象并且设置文件
        FileBody bin = new FileBody(file);
        MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
        reqEntity.addPart("file", bin);
        //设置参数
        if (formParams != null && formParams.size() > 0) {
            for (NameValuePair nv : formParams) {
                reqEntity.addTextBody(nv.getName(), nv.getValue(), ContentType.create("text/plain", Charset.forName(HTTP.UTF_8)));
            }
        }
        httpPost.setEntity(reqEntity.build());
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            //设置验证
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpClient.execute(httpPost, context);
            } else {
                response = httpClient.execute(httpPost);
            }
            entity = response.getEntity();
            return EntityUtils.toString(entity, "UTF-8");
        } catch (IOException e) {
            return e.getMessage();
        } finally {
            close(httpClient, response);
        }
    }
    /**
     * post请求
     *
     * @param url        请求路径
     * @param formParams 请求参数
     * @param username
     * @param password
     * @return
     */
    public static String post(String url, List<NameValuePair> formParams, String username, String password) {
        CloseableHttpClient httpClient = getCloseableHttpClient();
        UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
        HttpPost httpPost = new HttpPost(url);
        httpPost.setEntity(postEntity);
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpClient.execute(httpPost, context);
            } else {
                response = httpClient.execute(httpPost);
            }
            entity = response.getEntity();
            return EntityUtils.toString(entity, "UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
            return e.getMessage();
        } finally {
            close(httpClient, response);
        }
    }
    /**
     * get请求
     *
     * @param url      路径
     * @param params   参数
     * @param username
     * @param password
     * @return
     */
    public static String get(String url, Map<String, Object> params, String username, String password) {
        String responString = "";
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = getCloseableHttpClient();
        //设置请求信息
        try {
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpGet httpget = new HttpGet(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            httpget.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpget, context);
            } else {
                response = httpclient.execute(httpget);
            }
            HttpEntity entity1 = response.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            return "";
        } finally {
            close(httpclient, response);
        }
        return responString;
    }
    /**
     * 发送File
     *
     * @param filePath 文件路径
     * @param params   参数
     * @param url      http路径
     * @param username
     * @param password
     * @return
     */
    public static File downLoadFileByBase64(String filePath, Map<String, Object> params, String url, String username, String password) {
        File file = null;
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = getCloseableHttpClient();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            String responString = EntityUtils.toString(httpEntity, "UTF-8");
            file = new File(filePath);
            file.getParentFile().mkdirs();
            InputStream i = new ByteArrayInputStream(Base64.decode(responString));
            FileOutputStream fileout = new FileOutputStream(file);
            /**
             * 根据实际运行效果 设置缓冲区大小
             */
            byte[] buffer = new byte[1024];
            int ch = 0;
            while ((ch = i.read(buffer)) != -1) {
                fileout.write(buffer, 0, ch);
            }
            i.close();
            fileout.flush();
            fileout.close();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            close(httpclient, response);
        }
        return file;
    }
    public static File downLoadFile(String filePath, Map<String, Object> params, String url, String username, String password) {
        File file = null;
        CloseableHttpResponse response = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = getCloseableHttpClient();
        try {
            HttpPost httpPost = new HttpPost(url);
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //设置参数
            List<NameValuePair> formparams = new ArrayList<NameValuePair>();
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                formparams.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, Consts.UTF_8);
            httpPost.setEntity(entity);
            httpPost.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response = httpclient.execute(httpPost, context);
            } else {
                response = httpclient.execute(httpPost);
            }
            HttpEntity httpEntity = response.getEntity();
            InputStream is = httpEntity.getContent();
            file = new File(filePath);
            file.getParentFile().mkdirs();
            FileOutputStream fileout = new FileOutputStream(file);
            /**
             * 根据实际运行效果 设置缓冲区大小
             */
            byte[] buffer = new byte[1024];
            int ch = 0;
            while ((ch = is.read(buffer)) != -1) {
                fileout.write(buffer, 0, ch);
            }
            is.close();
            fileout.flush();
            fileout.close();
        } catch (Exception e) {
            return null;
        } finally {
            close(httpclient, response);
        }
        return file;
    }
    /**
     * httpClient的put请求方式
     *
     * @param url
     * @param params
     * @param username
     * @param password
     * @return
     * @throws Exception
     */
    public static String doPut(String url, Map<String, Object> params, String username, String password, Header header) {
        String responString = "";
        CloseableHttpResponse response1 = null;
        List<BasicNameValuePair> jsonParams = new ArrayList<>();
        CloseableHttpClient httpclient = getCloseableHttpClient();
        try {
            //设置请求信息
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //配置参数
            for (String key : params.keySet()) {
                jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
            }
            HttpPut httpPut = new HttpPut(url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8));
            //kHAbVppx44:Bd2h8rdYhep6NKOO
            //a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P
            if (header != null) {
                httpPut.addHeader(header);
            }
            httpPut.setConfig(requestConfig);
            if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
                //需要验证
                HttpClientContext context = HttpClientContext.create();
                //通过http的上下文设置账号密码
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                        new org.apache.http.auth.UsernamePasswordCredentials(username, password));
                context.setCredentialsProvider(credsProvider);
                response1 = httpclient.execute(httpPut, context);
            } else {
                response1 = httpclient.execute(httpPut);
            }
            HttpEntity entity1 = response1.getEntity();
            responString = EntityUtils.toString(entity1, "UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
            LogUtil.error("put请求失败" + e.getMessage());
        } finally {
            close(httpclient, response1);
        }
        return responString;
    }
    private static void close(CloseableHttpClient httpClient, CloseableHttpResponse response) {
        /*
        try {
            if (httpClient != null) {
                httpClient.close();
            }
        } catch (Exception e) {
            LogUtil.error("关闭httpClient失败");
        }
        try {
            if (response != null) {
                response.close();
            }
        } catch (Exception e) {
            LogUtil.error("关闭httpClient失败");
        }*/
    }
    public static void main(String[] args) {
        // List<NameValuePair> formParams = new ArrayList<NameValuePair>();
        //formParams.add(new BasicNameValuePair("systemCode", "MINIESB"));
        // formParams.add(new BasicNameValuePair("orgCode", "123"));
        // formParams.add(new BasicNameValuePair("access_token", "3801916fbd19d6fdc2adf2752b491a5d"));
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("info", "{\"fingerprint\": \"abc\"}");
        //params.put("user_name", "admin");
        //POST /api/v1.0/simplified-esb/fillMiningPUT /api/v1.0/authorizations/users/{user_name}
        System.out.println(getToken());
        // System.out.println(HttpsClientUtil.post("https://192.168.5.109:4431/api/v1.0/simplified-esb/fillMining", formParams, "admin", "123456"));
    }
}

+ 0 - 57
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/PathUtil.java

@ -1,57 +0,0 @@
package com.yihu.ehr.util;
import java.io.File;
/**
 * Created by chenweida on 2016/3/3.
 */
public class PathUtil {
    /**
     * 得到tomcat的根目录
     * F:\server\apache-tomcat-8.0.26
     *
     * @return
     */
    public static String getTomcatProjectRealPath() {
        String classesPath = PathUtil.class.getResource("/").getPath();
        String newPath = "";
        System.out.println(classesPath);
        String[] cpSize = null;
        if (classesPath.contains("/")) {
            cpSize = classesPath.split("/");
        } else {
            cpSize = classesPath.split(File.pathSeparator);
        }
        for (int i = 0; i < cpSize.length; i++) {
            if (i - 2 == 0) {
                break;
            } else {
                newPath += cpSize[i] + "/";
            }
        }
        System.out.println(newPath);
        return newPath;
    }
    public static void main(String[] args) {
        //F:/git/hos/Hos-Resource-Mini-helper/target/classes/
        String classesPath = PathUtil.class.getResource("/").getPath();
        String newPath = "";
        System.out.println(classesPath);
        String[] cpSize = null;
        if (classesPath.contains("/")) {
            cpSize = classesPath.split("/");
        } else {
            cpSize = classesPath.split(File.pathSeparator);
        }
        for (int i = 0; i < cpSize.length; i++) {
            if (i - 2 == 0) {
                break;
            } else {
                newPath += cpSize[i] + "/";
            }
        }
        System.out.println(newPath);
    }
}

+ 0 - 140
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/ZipUtil.java

@ -1,140 +0,0 @@
package com.yihu.ehr.util;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Zip;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Enumeration;
/**
 * Created by chenweida on 2016/2/27. 用的是ant解压缩
 */
public class ZipUtil {
    private static final int buffer = 1024;
    private static void createDirectory(String directory, String subDirectory) {
        String dir[];
        File fl = new File(directory);
        try {
            if (subDirectory == "" && fl.exists() != true) {
                fl.mkdir();
            } else if (subDirectory != "") {
                dir = subDirectory.replace('\\', '/').split("/");
                for (int i = 0; i < dir.length; i++) {
                    File subFile = new File(directory + File.separator + dir[i]);
                    if (subFile.exists() == false) {
                        subFile.mkdir();
                    }
                    directory += File.separator + dir[i];
                }
            }
        } catch (Exception ex) {
            return;
        }
    }
    /**
     * @param zipFilePath     解压的文件
     * @param outputDirectory 解压的文件路径
     * @return
     */
    @SuppressWarnings("unchecked")
    public static boolean unZip(String zipFilePath, String outputDirectory) {
        boolean flag = false;
        try {
            ZipFile zipFile = new ZipFile(zipFilePath);
            Enumeration e = zipFile.getEntries();
            ZipEntry zipEntry = null;
            createDirectory(outputDirectory, "");
            while (e.hasMoreElements()) {
                zipEntry = (ZipEntry) e.nextElement();
                if (zipEntry.isDirectory()) {
                    String name = zipEntry.getName().trim();
                    name = name.substring(0, name.length() - 1);
                    File f = new File(outputDirectory + File.separator + name);
                    if (!f.exists()) {
                        f.mkdir();
                    }
                } else {
                    String fileName = zipEntry.getName();
                    fileName = fileName.replace('\\', '/');
                    if (fileName.indexOf("/") != -1) {
                        createDirectory(outputDirectory, fileName.substring(0,
                                fileName.lastIndexOf("/")));
                        fileName = fileName
                                .substring(fileName.lastIndexOf("/") + 1);
                    }
                    File f = new File(outputDirectory + File.separator
                            + zipEntry.getName());
                    f.createNewFile();
                    InputStream in = zipFile.getInputStream(zipEntry);
                    FileOutputStream out = new FileOutputStream(f);
                    byte[] by = new byte[buffer];
                    int c;
                    while ((c = in.read(by)) != -1) {
                        out.write(by, 0, c);
                    }
                    in.close();
                    out.close();
                }
            }
            flag = true;
        } catch (Exception ex) {
            return false;
        }
        return flag;
    }
    /**
     * 压缩
     *
     * @param srcDirName  要压缩的路径
     * @param zipFilePath 压缩的文件名字
     * @return
     */
    public static boolean zip(String srcDirName, String zipFilePath) {
        boolean flag = false;
        try {
            File srcdir = new File(srcDirName);
            if (!srcdir.exists())
                throw new RuntimeException(srcDirName + " is not exist!");
            Project prj = new Project();
            Zip zip_ = new Zip();
            zip_.setProject(prj);
            zip_.setDestFile(new File(zipFilePath));
            FileSet fileSet = new FileSet();
            fileSet.setProject(prj);
            fileSet.setDir(srcdir);
            zip_.addFileset(fileSet);
            zip_.execute();
            flag = true;
        } catch (Exception ex) {
            return false;
        }
        return flag;
    }
    public static void main(String[] args) {
        try {
            ZipUtil.zip("F:/简历",
                    "F:/sss.war");
            //  ZipUtil.unZip("F:/sss.war",
            //          "E:/");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

+ 0 - 129
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encode/Base64.java

@ -1,129 +0,0 @@
package com.yihu.ehr.util.encode;
/**
 * 标准Base64编解码,具体规范请参见相关文档。
 */
public class Base64 {
  /** Base64编码表。*/
  private static char Base64Code[] = {
    'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
    'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
    'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
    'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/',
  };
  /** Base64解码表。*/
  private static byte Base64Decode[] = {
    -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
    -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,  //注意两个63,为兼容SMP,
    -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,63,-1,63,  //“/”和“-”都翻译成63。
    52,53,54,55,56,57,58,59,60,61,-1,-1,-1, 0,-1,-1,
    -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,  //注意两个0:
    15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,  //“A”和“=”都翻译成0。
    -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
    41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
  };
  /**
   * 构造方法私有化,防止实例化。
   */
  private Base64() {}
  /**
   * Base64编码。将字节数组中字节3个一组编码成4个可见字符。
   * @param b 需要被编码的字节数据。
   * @return 编码后的Base64字符串。
   */
  public static String encode(byte[] b) {
    int code = 0;
    //按实际编码后长度开辟内存,加快速度
    StringBuffer sb =new StringBuffer(((b.length-1)/3)<<2+4);
    //进行编码
    for (int i=0;i<b.length;i++) {
      code|=(b[i]<<(16-i%3*8)) & (0xff<<(16-i%3*8));
      if (i%3==2 || i==b.length-1) {
        sb.append(Base64Code[(code & 0xfc0000) >>> 18 ]);
        sb.append(Base64Code[(code & 0x3f000)  >>> 12 ]);
        sb.append(Base64Code[(code & 0xfc0)    >>> 6  ]);
        sb.append(Base64Code[ code & 0x3f             ]);
        code=0;
      }
    }
    //对于长度非3的整数倍的字节数组,编码前先补0,编码后结尾处编码用=代替,
    //=的个数和短缺的长度一致,以此来标识出数据实际长度
    if (b.length%3>0) {
      sb.setCharAt(sb.length()-1,'=');
    }
    if (b.length%3==1) {
      sb.setCharAt(sb.length()-2,'=');
    }
    return sb.toString();
  }
  /**
   * Base64解码。
   * @param code 用Base64编码的ASCII字符串
   * @return 解码后的字节数据
   */
  public static byte[] decode(String code) {
    //检查参数合法性
    if (code==null) {
      return null;
    }
    int len = code.length();
    if (len%4!=0) {
      throw new IllegalArgumentException("Base64 string length must be 4*n");
    }
    if (code.length()==0){
      return new byte[0];
    }
    //统计填充的等号个数
    int pad = 0;
    if (code.charAt(len-1)=='=') {
      pad++;
    }
    if (code.charAt(len-2)=='=') {
      pad++;
    }
    //根据填充等号的个数来计算实际数据长度
    int retLen = len/4*3 - pad;
    //分配字节数组空间
    byte[] ret = new byte [retLen];
    //查表解码
    char ch1,ch2,ch3,ch4;
    int i;
    for (i=0;i<len;i+=4) {
      int j=i/4*3;
      ch1 = code.charAt(i);
      ch2 = code.charAt(i+1);
      ch3 = code.charAt(i+2);
      ch4 = code.charAt(i+3);
      int tmp = (Base64Decode[ch1]<<18)|(Base64Decode[ch2]<<12)
                |(Base64Decode[ch3]<<6)|(Base64Decode[ch4]);
      ret[j] = (byte) ((tmp&0xff0000) >> 16);
        if (i<len-4) {
          ret[j+1] = (byte) ((tmp&0x00ff00) >> 8);
          ret[j+2] =(byte) ((tmp&0x0000ff));
        }
        else {
          if(j+1<retLen) {
            ret[j+1] = (byte) ((tmp&0x00ff00) >> 8);
          }
          if(j+2<retLen) {
            ret[j+2] = (byte) ((tmp&0x0000ff));
          }
        }
      }
      return ret;
    }
}

+ 0 - 29
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encode/HexEncode.java

@ -1,29 +0,0 @@
package com.yihu.ehr.util.encode;
/**
 * @created Created by Air on 2015/6/2.
 */
public class HexEncode {
    static public String toHexString(byte[] bytes) {
        StringBuilder stringBuffer = new StringBuilder();
        for (byte aByte : bytes) {
            if (Integer.toHexString(0xFF & aByte).length() == 1) {
                stringBuffer.append("0").append(Integer.toHexString(0xFF & aByte));
            } else {
                stringBuffer.append(Integer.toHexString(0xFF & aByte));
            }
        }
        return stringBuffer.toString();
    }
    static public byte[] toBytes(String hexString) {
        byte[] bytes;
        bytes = new byte[hexString.length() / 2];
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = (byte) Integer.parseInt(hexString.substring(2 * i, 2 * i + 2), 16);
        }
        return bytes;
    }
}

+ 0 - 106
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encode/UnicodeReader.java

@ -1,106 +0,0 @@
package com.yihu.ehr.util.encode;
/**
 * UTF-8 编码工具类,解决bom问题
 * Created by HZY on 2015/8/12.
 */
import java.io.*;
/**
 * Generic unicode textreader, which will use BOM mark to identify the encoding
 * to be used. If BOM is not found then use a given default or system encoding.
 */
public class UnicodeReader extends Reader {
	PushbackInputStream internalIn;
	InputStreamReader internalIn2 = null;
	String defaultEnc;
	private static final int BOM_SIZE = 4;
	/**
	 * 
	 * @param in
	 *            inputstream to be read
	 * @param defaultEnc
	 *            default encoding if stream does not have BOM marker. Give NULL
	 *            to use system-level default.
	 */
	public UnicodeReader(InputStream in, String defaultEnc) {
		internalIn = new PushbackInputStream(in, BOM_SIZE);
		this.defaultEnc = defaultEnc;
	}
	public String getDefaultEncoding() {
		return defaultEnc;
	}
	/**
	 * Get stream encoding or NULL if stream is uninitialized. Call init() or
	 * read() method to initialize it.
	 */
	public String getEncoding() {
		if (internalIn2 == null)
			return null;
		return internalIn2.getEncoding();
	}
	/**
	 * Read-ahead four bytes and check for BOM marks. Extra bytes are unread
	 * back to the stream, only BOM bytes are skipped.
	 */
	protected void init() throws IOException {
		if (internalIn2 != null)
			return;
		String encoding;
		byte bom[] = new byte[BOM_SIZE];
		int n, unread;
		n = internalIn.read(bom, 0, bom.length);
		if ((bom[0] == (byte) 0x00) && (bom[1] == (byte) 0x00)
				&& (bom[2] == (byte) 0xFE) && (bom[3] == (byte) 0xFF)) {
			encoding = "UTF-32BE";
			unread = n - 4;
		} else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)
				&& (bom[2] == (byte) 0x00) && (bom[3] == (byte) 0x00)) {
			encoding = "UTF-32LE";
			unread = n - 4;
		} else if ((bom[0] == (byte) 0xEF) && (bom[1] == (byte) 0xBB)
				&& (bom[2] == (byte) 0xBF)) {
			encoding = "UTF-8";
			unread = n - 3;
		} else if ((bom[0] == (byte) 0xFE) && (bom[1] == (byte) 0xFF)) {
			encoding = "UTF-16BE";
			unread = n - 2;
		} else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)) {
			encoding = "UTF-16LE";
			unread = n - 2;
		} else {
			// Unicode BOM mark not found, unread all bytes
			encoding = defaultEnc;
			unread = n;
		}
		// System.out.println("read=" + n + ", unread=" + unread);
		if (unread > 0)
			internalIn.unread(bom, (n - unread), unread);
		// Use given encoding
		if (encoding == null) {
			internalIn2 = new InputStreamReader(internalIn);
		} else {
			internalIn2 = new InputStreamReader(internalIn, encoding);
		}
	}
	public void close() throws IOException {
		init();
		internalIn2.close();
	}
	public int read(char[] cbuf, int off, int len) throws IOException {
		init();
		return internalIn2.read(cbuf, off, len);
	}
}

+ 0 - 75
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encrypt/MD5.java

@ -1,75 +0,0 @@
package com.yihu.ehr.util.encrypt;
import com.yihu.ehr.util.encode.HexEncode;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.security.AccessController;
import java.security.MessageDigest;
import java.security.PrivilegedAction;
/**
 * @created  Air 2015/6/2.
 */
public class MD5 {
    static public String hash(String str) throws Exception {
        MessageDigest messageDigest = null;
        messageDigest = MessageDigest.getInstance("MD5");
        messageDigest.reset();
        messageDigest.update(str.getBytes());
        return HexEncode.toHexString(messageDigest.digest());
    }
    public static String getMd5ByFile(File file) throws FileNotFoundException {
        String value = null;
        FileInputStream in = new FileInputStream(file);
        MappedByteBuffer byteBuffer =null;
        try {
            byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(byteBuffer);
//            BigInteger bi = new BigInteger(1, md5.digest());
//            value = bi.toString(16);
            value= HexEncode.toHexString(md5.digest());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if(null != in) {
                try {
                    in.close();
                    clean(byteBuffer);
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return value;
    }
    public static void clean(final Object buffer) throws Exception {
        AccessController.doPrivileged(new PrivilegedAction() {
            public Object run() {
                try {
                    Method getCleanerMethod = buffer.getClass().getMethod("cleaner", new Class[0]);
                    getCleanerMethod.setAccessible(true);
                   // sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(buffer, new Object[0]);
                   // cleaner.clean();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return null;
            }
        });
    }
}

+ 0 - 110
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/encrypt/RSA.java

@ -1,110 +0,0 @@
package com.yihu.ehr.util.encrypt;
import com.yihu.ehr.util.encode.Base64;
import javax.crypto.Cipher;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
/**
 * RSA加密辅助类,采用Base64编码
 *
 * @created Air  2015/6/02.
 */
public class RSA {
    public static final String PUBLIC_KEY = "public";
    public static final String PRIVATE_KEY = "private";
    public static final String KEY_ALGORITHM = "RSA";
    /**
     * 生成公钥和私钥
     *
     * @throws NoSuchAlgorithmException
     */
    public static HashMap<String, Key> generateKeys() throws NoSuchAlgorithmException {
        KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
        keyPairGen.initialize(1024);
        KeyPair keyPair = keyPairGen.generateKeyPair();
        RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
        RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
        HashMap<String, Key> map = new HashMap<>();
        map.put(PUBLIC_KEY, publicKey);
        map.put(PRIVATE_KEY, privateKey);
        return map;
    }
    public static String encodeKey(Key key) {
//        return HexEncode.toHexString(key.getEncoded());
        return Base64.encode(key.getEncoded());
    }
    public static Key genPrivateKey(String key) {
//        byte[] bytes = HexEncode.toBytes(key);
        byte[] bytes = Base64.decode(key);
        PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(bytes);
        try {
            KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
            return keyFactory.generatePrivate(pkcs8KeySpec);
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static Key genPublicKey(String key) {
        if (key == null){
            return null;
        }
        byte[] bytes = Base64.decode(key);
        X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(bytes);
        try {
            KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
            return keyFactory.generatePublic(x509KeySpec);
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * @param data 明文
     * @param key  密钥
     * @return HexString密文
     * @throws Exception
     */
    public static String encrypt(String data, Key key) throws Exception {
        Cipher cipher = Cipher.getInstance(KEY_ALGORITHM);
        cipher.init(Cipher.ENCRYPT_MODE, key);
//        return HexEncode.toHexString(cipher.doFinal(data.getBytes()));
        return Base64.encode(cipher.doFinal(data.getBytes()));
    }
    /**
     * @param data HexString密文
     * @param key  密钥
     * @return 明文
     * @throws Exception
     */
    public static String decrypt(String data, Key key) throws Exception {
        Cipher cipher = Cipher.getInstance(KEY_ALGORITHM);
        cipher.init(Cipher.DECRYPT_MODE, key);
//        return new String(cipher.doFinal(HexEncode.toBytes(data)));
        return new String(cipher.doFinal(Base64.decode(data)));
    }
}

+ 0 - 218
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/file/FileUtil.java

@ -1,218 +0,0 @@
package com.yihu.ehr.util.file;
import java.io.*;
/**
 * @author Air
 * @version 1.0
 * @created 2015.06.25 14:14
 */
public class FileUtil {
    public static boolean writeFile(String filePath, String data, String encoding) throws IOException {
        File file = new File(filePath);
        if (!file.getParentFile().exists()) {
            if (!file.getParentFile().mkdirs()) {
                return false;
            }
        }
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, encoding);
        outputStreamWriter.write(data);
        outputStreamWriter.flush();
        outputStreamWriter.close();
        return true;
    }
    public static boolean writeFile(String filePath, byte[] bytes, String encoding) throws IOException {
        File file = new File(filePath);
        if (!file.getParentFile().exists()) {
            if (!file.getParentFile().mkdirs()) {
                return false;
            }
        }
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        byte[] bbuf = new byte[1024];
        InputStream fis = new ByteArrayInputStream(bytes);
        int hasRead = 0;
        //循环从输入流中取出数据
        while ((hasRead = fis.read(bbuf)) > 0) {
            fileOutputStream.write(bbuf, 0, hasRead);
        }
        fileOutputStream.close();
        return true;
    }
    public static boolean writeFile(String filePath,InputStream fis, String encoding) throws IOException {
        File file = new File(filePath);
        if (!file.getParentFile().exists()) {
            if (!file.getParentFile().mkdirs()) {
                return false;
            }
        }
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        byte[] bbuf = new byte[1024];
        int hasRead = 0;
        //循环从输入流中取出数据
        while ((hasRead = fis.read(bbuf)) > 0) {
            fileOutputStream.write(bbuf, 0, hasRead);
        }
        fileOutputStream.close();
        return true;
    }
    /**
     * 删除整个目录
     *
     * @param dir 目录
     * @return boolean
     * @created Airhead
     */
    public static boolean deleteDirectory(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            //递归删除目录中的子目录下
            for (int i = 0; i < children.length; i++) {
                boolean success = deleteDirectory(new File(dir, children[i]));
                if (!success) {
                    return false;
                }
            }
        }
        // 目录此时为空,可以删除
        return dir.delete();
    }
    /**
     * file转string
     * @param file 文件
     * @return string类型流
     */
    public static String convertFileToString(File file) {
        StringBuilder sb = new StringBuilder();
        if(file.isFile()&&file.exists()) {
            InputStreamReader read = null;
            try {
                read = new InputStreamReader(new FileInputStream(file), "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            BufferedReader reader = new BufferedReader(read);
            String line = null;
            try {
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return sb.toString();
    }
    /**
     * 清空文件内容
     * @param filePath 文件路径
     * @param content 写入内容
     */
    public static void clearInfoForFile(String filePath,String content) {
        File file =new File(filePath);
        try {
            if(!file.exists()) {
                file.createNewFile();
            }
            FileWriter fileWriter =new FileWriter(file);
            fileWriter.write(content);
            fileWriter.flush();
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /**
     * 记录文件最后读取的位置
     * @param readPath  被读取文件路径
     * @param savePath  保存被读取文件的最后位置 的文件路径
     */
    public static Integer  saveFilePos(String  readPath,  String  savePath)  {
        boolean result=false;
        File readFile=new File(readPath);
        Integer lenth=null;
        try  {
            if(readFile.exists()){
                InputStream inputStream = new FileInputStream(readPath);
                lenth = inputStream.available();
                clearInfoForFile(savePath,"");//清空内容
                writeFile(savePath,lenth.toString(),"UTF-8");//重新写入标识
            }
        }
        catch  (Exception  e)  {
            e.printStackTrace();
        }
        return lenth;
    }
    public static Integer getFileSize(String path) {
        Integer size=0;
        InputStream inputStream=null;
        File file=new File(path);
        if (file.exists()){
            try {
                inputStream = new FileInputStream(path);
                size = inputStream.available();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
       return size;
    }
    /**
     * 读取文本文件内容
     * @param file  文件路径
     * @return
     */
    public static String readFileText(File file) {
        StringBuilder stringBuilder = new StringBuilder();
        InputStream in = null;
        BufferedReader br = null;
        try {
            in = new FileInputStream(file);
            br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
            String line = null;
            while ((line = br.readLine()) != null) {
                stringBuilder.append(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e1) {
                }
            }
        }
        return stringBuilder.toString();
    }
}

+ 0 - 43
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HAHttpClient.java

@ -1,43 +0,0 @@
package com.yihu.ehr.util.http;
import org.apache.http.NameValuePair;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import java.util.List;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.16 9:10
 */
public class HAHttpClient implements IHAHttpClient {
    private HAHttpClientImpl haHttpClientImpl;
    public HAHttpClient() {
        haHttpClientImpl = new HAHttpClientImpl();
    }
    @Override
    public Response get(String url) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        return haHttpClientImpl.get(httpClient, url);
    }
    @Override
    public Response postForm(String url, List<NameValuePair> formParams) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        return haHttpClientImpl.postForm(httpClient, url, formParams);
    }
    @Override
    public Response postFile(String url, String filePath) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        return haHttpClientImpl.postFile(httpClient, url, filePath);
    }
    @Override
    public Response postFile(String url, String filePath, List<NameValuePair> formParams) {
        return null;
    }
}

+ 0 - 196
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HAHttpClientImpl.java

@ -1,196 +0,0 @@
package com.yihu.ehr.util.http;
import com.yihu.ehr.config.ThreadConfig;
import com.yihu.ehr.util.log.LogUtil;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.springframework.web.client.RestTemplate;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.16 10:20
 */
public class HAHttpClientImpl {
    public Response postForm(CloseableHttpClient httpClient, String url, List<NameValuePair> formParams) {
        UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
        HttpPost httpPost = new HttpPost(url);
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            RequestConfig requestConfig = RequestConfig.custom().
                    setAuthenticationEnabled(true).build();
            //需要验证
            HttpClientContext context = HttpClientContext.create();
            //通过http的上下文设置账号密码
            CredentialsProvider credsProvider = new BasicCredentialsProvider();
            credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                    new org.apache.http.auth.UsernamePasswordCredentials(ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD));
            context.setCredentialsProvider(credsProvider);
            httpPost.setEntity(postEntity);
            httpPost.setConfig(requestConfig);
            httpPost.setHeader("Authorization","Basic YWRtaW46MTIzNDU2");
            response = httpClient.execute(httpPost, context);
            entity = response.getEntity();
            Response res = new Response(response.getStatusLine().getStatusCode(), EntityUtils.toString(entity));
            return res;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            close(httpClient, entity);
        }
        return null;
    }
    public Response postFile(CloseableHttpClient httpClient, String url, String filePath) {
        File file = new File(filePath);
        //设置请求信息
        RequestConfig requestConfig = RequestConfig.custom().
                setAuthenticationEnabled(true).build();
        //创建httppost请求
        HttpPost httpPost = new HttpPost(url);
        httpPost.setConfig(requestConfig);
        //新建文件对象并且设置文件
        FileBody bin = new FileBody(file);
        MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
        reqEntity.addPart("file", bin);
        httpPost.setEntity(reqEntity.build());
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            //需要验证
            HttpClientContext context = HttpClientContext.create();
            //通过http的上下文设置账号密码
            CredentialsProvider credsProvider = new BasicCredentialsProvider();
            credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                    new org.apache.http.auth.UsernamePasswordCredentials(ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD));
            context.setCredentialsProvider(credsProvider);
            response = httpClient.execute(httpPost, context);
            entity = response.getEntity();
            Response res = new Response(response.getStatusLine().getStatusCode(), EntityUtils.toString(entity));
            return res;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            close(httpClient, entity);
        }
        return null;
    }
    public Response get(CloseableHttpClient httpClient, String url) {
        HttpGet httpget = new HttpGet(url);
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(1000 * 60 * 5).setConnectTimeout(1000 * 60 * 5).
                    setAuthenticationEnabled(true).build();//设置请求和传输超时时间
            httpget.setConfig(requestConfig);
            //需要验证
            HttpClientContext context = HttpClientContext.create();
            //通过http的上下文设置账号密码
            CredentialsProvider credsProvider = new BasicCredentialsProvider();
            credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                    new org.apache.http.auth.UsernamePasswordCredentials(ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD));
            context.setCredentialsProvider(credsProvider);
            response = httpClient.execute(httpget, context);
            entity = response.getEntity();
            Response res = new Response(response.getStatusLine().getStatusCode(), EntityUtils.toString(entity));
            return res;
        } catch (IOException e) {
            LogUtil.error(e.getMessage());
        } finally {
            close(httpClient, entity);
        }
        return null;
    }
    private void close(CloseableHttpClient httpClient, HttpEntity entity) {
        try {
            EntityUtils.consume(entity);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            httpClient.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public Response postFile(CloseableHttpClient httpClient, String url, String filePath, List<NameValuePair> formParams) {
        File file = new File(filePath);
        //设置请求信息
        RequestConfig requestConfig = RequestConfig.custom().
                setAuthenticationEnabled(true).build();
        //创建httppost请求
        HttpPost httpPost = new HttpPost(url);
        httpPost.setConfig(requestConfig);
        //新建文件对象并且设置文件
        FileBody bin = new FileBody(file);
        MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
        reqEntity.addPart("file", bin);
        for (NameValuePair nv : formParams) {
            reqEntity.addTextBody(nv.getName(), nv.getValue(), ContentType.create("text/plain", Charset.forName(HTTP.UTF_8)));
        }
        httpPost.setEntity(reqEntity.build());
        CloseableHttpResponse response = null;
        HttpEntity entity = null;
        try {
            //需要验证
            HttpClientContext context = HttpClientContext.create();
            //通过http的上下文设置账号密码
            CredentialsProvider credsProvider = new BasicCredentialsProvider();
            credsProvider.setCredentials(new org.apache.http.auth.AuthScope(org.apache.http.auth.AuthScope.ANY_HOST, org.apache.http.auth.AuthScope.ANY_PORT),
                    new org.apache.http.auth.UsernamePasswordCredentials(ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD));
            context.setCredentialsProvider(credsProvider);
            response = httpClient.execute(httpPost, context);
            entity = response.getEntity();
            Response res = new Response(response.getStatusLine().getStatusCode(), EntityUtils.toString(entity));
            return res;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            close(httpClient, entity);
        }
        return null;
    }
}

+ 0 - 56
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HAHttpsClient.java

@ -1,56 +0,0 @@
package com.yihu.ehr.util.http;
import org.apache.http.NameValuePair;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import java.util.List;
/**
 * @author Air
 * @version 1.0
 * @created 2015.07.02 15:37
 */
public class HAHttpsClient implements IHAHttpClient {
    private HAHttpClientImpl haHttpClientImpl;
    private SSLConnectionSocketFactory sslConnectionSocketFactory;
    public HAHttpsClient(SSLConnectionSocketFactory sslConnectionSocketFactory) {
        haHttpClientImpl = new HAHttpClientImpl();
        this.sslConnectionSocketFactory = sslConnectionSocketFactory;
    }
    public Response get(String url) {
        CloseableHttpClient httpClient = HttpClients.custom()
                .setSSLSocketFactory(this.sslConnectionSocketFactory)
                .build();
        return haHttpClientImpl.get(httpClient, url);
    }
    public Response postForm(String url, List<NameValuePair> formParams) {
        CloseableHttpClient httpClient = HttpClients.custom()
                .setSSLSocketFactory(this.sslConnectionSocketFactory)
                .build();
        return haHttpClientImpl.postForm(httpClient, url, formParams);
    }
    public Response postFile(String url, String filePath) {
        CloseableHttpClient httpClient = HttpClients.custom()
                .setSSLSocketFactory(this.sslConnectionSocketFactory)
                .build();
        return haHttpClientImpl.postFile(httpClient, url, filePath);
    }
    @Override
    public Response postFile(String url, String filePath, List<NameValuePair> formParams) {
        CloseableHttpClient httpClient = HttpClients.custom()
                .setSSLSocketFactory(this.sslConnectionSocketFactory)
                .build();
        return haHttpClientImpl.postFile(httpClient, url, filePath, formParams);
    }
}

+ 0 - 240
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HOPClient.java

@ -1,240 +0,0 @@
package com.yihu.ehr.util.http;
import com.yihu.ehr.config.SysConfig;
import com.yihu.ehr.util.encrypt.MD5;
import com.yihu.ehr.util.file.FileUtil;
import com.yihu.ehr.util.log.LogUtil;
import com.yihu.ehr.util.operator.StringUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
public class HOPClient {
    static final public String HTTPS = "https";
    static final public String HTTP = "http";
    static private HttpsInitialise initialise = new HttpsInitialise();
    private final String version = "1.0";
    private final String signMethod = "md5";
    private String method;
    private String timestamp;
    private String format;
    private String appId;
    private String accessToken;
    private String url;
    private TreeMap<String, String> paramMap;
    private IHAHttpClient ihaHttpClient;
    public HOPClient(String protocol) {
        paramMap = new TreeMap<>();
        if (protocol.equals(HTTPS)) {
            ihaHttpClient = new HAHttpsClient(initialise.getSslConnectionSocketFactory());
        } else {
            ihaHttpClient = new HAHttpClient();
        }
    }
    public static void initHttps(String trustStorePath, String password) throws Exception {
        initialise.init(trustStorePath, password);
    }
    public void reset() {
        paramMap.clear();
    }
    public void setMethod(String method) {
        this.method = method;
    }
    public void setFormat(String format) {
        this.format = format;
    }
    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public void setParam(String key, String value) {
        paramMap.put(key, value);
    }
    public Response get() {
        String completeUrl = completeUrl();
        if (completeUrl == null) {
            return null;
        }
        return ihaHttpClient.get(completeUrl);
    }
    public boolean downLoad(String path) {
        String completeUrl = completeUrl();
        if (completeUrl == null) {
            return false;
        }
        Response response = ihaHttpClient.get(completeUrl);
        if (response == null || response.statusCode != 200) {
            return false;
        }
        try {
            boolean result = FileUtil.writeFile(path, response.body, "UTF-8");
            if (!result) {
                LogUtil.fatal("下载文件失败.");
            }
            return result;
        } catch (IOException e) {
            e.printStackTrace();
            LogUtil.fatal("下载文件失败:" + e.getMessage());
        }
        return false;
    }
    public Response postForm(List<NameValuePair> formParams) {
        String completeUrl = completeUrl();
        if (completeUrl == null) {
            return null;
        }
        return ihaHttpClient.postForm(completeUrl, formParams);
    }
    public Response postFile(String filePath, List<NameValuePair> formParams) {
        String completeUrl = completeUrl();
        try {
            Response response = ihaHttpClient.postFile(completeUrl, filePath, formParams);
            return response;
        } catch (Exception e) {
            LogUtil.fatal(completeUrl);
            return null;
        }
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    private String completeUrl() {
        try {
//            addParam("method", method, true);
            addParam("format", format, false);
            addParam("app_id", appId, true);
            addParam("timestamp", getTimestamp(), true);
            addParam("v", version, true);
            addParam("sign_method", signMethod, true);
            addParam("access_token", accessToken, false);
            addParam("sign", signParam(), true);
            String completeUrl = url + method + genParam();
            LogUtil.trace(completeUrl);
            return completeUrl;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    private void addParam(String paramName, String paramValue, boolean bMust) throws Exception {
        if (StringUtil.isEmpty(paramValue)) {
            if (bMust) {
                throw new Exception(paramName + "参数不能为空.");
            } else {
                return;
            }
        }
        String encodeValue = URLEncoder.encode(paramValue, "UTF-8");
        paramMap.put(paramName, encodeValue);
    }
    private String signParam() {
        Iterator<Map.Entry<String, String>> iterator = paramMap.entrySet().iterator();
        StringBuilder builder = new StringBuilder();
        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
            String key = next.getKey();
            String value = next.getValue();
            builder.append(key);
            builder.append(value);
        }
        try {
            return MD5.hash(builder.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    private String genParam() throws Exception {
        Iterator<Map.Entry<String, String>> iterator = paramMap.entrySet().iterator();
        StringBuilder builder = new StringBuilder();
        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
            String key = next.getKey();
            String value = next.getValue();
            if (value == null) {
                throw new Exception("参数错误:参数" + key + "值为空.");
            }
            if (builder.length() == 0) {
                builder.append("?");
            } else {
                builder.append("&");
            }
            builder.append(key);
            builder.append("=");
            builder.append(URLEncoder.encode(value, "UTF-8"));
        }
        return builder.toString();
    }
    private String getTimestamp() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        timestamp = format.format(new Date());
        return timestamp;
    }
    public static void main(String[] args) throws Exception {
        HOPClient.initHttps(HOPClient.class.getResource("/config/tomcat.keystore").getPath(), "123456");
        HOPClient hopClient = new HOPClient(HOPClient.HTTPS);
        hopClient.setAppId(SysConfig.getInstance().getPlatformAppId());
        hopClient.setUrl(SysConfig.getInstance().getPlatformUrl());
        hopClient.setMethod("getUpdateFlag");
        // hopClient.setParam("versionCode", "1");
        // hopClient.setParam("systemCode", "MINIESB");
        List<NameValuePair> formParams = new ArrayList<NameValuePair>();
        formParams.add(new BasicNameValuePair("versionCode", "2"));
        formParams.add(new BasicNameValuePair("systemCode", "systemCode"));
        formParams.add(new BasicNameValuePair("orgCode", "3"));
        ;
        //Response response = hopClient.postForm(formParams);
        //Response systemCoderesponse = hopClient.postFile("F:\\server\\idea\\log\\esb_mini.log", formParams);
        Response response = hopClient.postForm(formParams);
        if (response == null || response.statusCode != 200) {
            System.out.println("登录失败!网络错误或者服务器不可用。");
        }
        // System.out.println(response.body);
        HttpComponentsClientHttpRequestFactory hc = new HttpComponentsClientHttpRequestFactory();
        RestTemplate rt = new RestTemplate(hc);
    }
}

+ 0 - 59
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/HttpsInitialise.java

@ -1,59 +0,0 @@
package com.yihu.ehr.util.http;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.ssl.SSLContexts;
import javax.net.ssl.SSLContext;
import java.io.File;
/**
 * Https相关环境初始化
 *
 * @author Air
 * @version 1.0
 * @created 2015.07.07 9:21
 */
public class HttpsInitialise {
    private static volatile HttpsInitialise instance = null;
    private SSLContext sslcontext;
    private SSLConnectionSocketFactory sslConnectionSocketFactory;
    public HttpsInitialise() {
    }
    public void finalize() throws Throwable {
    }
    /**
     * 初始化SSLConnectionSocketFactory.
     *
     * @param password       密码
     * @param trustStorePath 信任库路径
     * @throws Exception
     */
    public void init(String trustStorePath, String password) throws Exception {
        if (sslcontext == null || sslConnectionSocketFactory == null) {
            synchronized (HttpsInitialise.class) {
                sslcontext = SSLContexts.custom()
                        .loadTrustMaterial(new File(trustStorePath), password.toCharArray(),
                                new TrustSelfSignedStrategy())
                        .build();
                // Allow TLSv1 protocol only
                sslConnectionSocketFactory = new SSLConnectionSocketFactory(
                        sslcontext,
                        new String[]{"TLSv1"},
                        null,
                        new HopHostnameVerifier());
            }
        }
    }
    public SSLConnectionSocketFactory getSslConnectionSocketFactory() {
        return sslConnectionSocketFactory;
    }
}

+ 0 - 21
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/http/IHAHttpClient.java

@ -1,21 +0,0 @@
package com.yihu.ehr.util.http;
import org.apache.http.NameValuePair;
import java.util.List;
/**
 * @author Air
 * @version 1.0
 * @created 2015.08.16 9:22
 */
public interface IHAHttpClient {
    Response get(String url);
    Response postForm(String url, List<NameValuePair> formParams);
    Response postFile(String url, String filePath);
    Response postFile(String url, String filePath, List<NameValuePair> formParams);
}

+ 0 - 40
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/log/LogUtil.java

@ -1,40 +0,0 @@
package com.yihu.ehr.util.log;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class LogUtil {
    static Logger logger = LogManager.getLogger(LogUtil.class.getName());
    public static void entry() {
        logger.entry();
    }
    public static void trace(String msg) {
        logger.trace(msg);
    }
    public static void info(String msg) {
        logger.info(msg);
    }
    public static void debug(String msg) {
        logger.debug(msg);
    }
    public static void error(String msg) {
        logger.error(msg);
    }
    public static void warn(String msg) {
        logger.warn(msg);
    }
    public static void fatal(String msg) {
        logger.fatal(msg);
    }
    public static void exit() {
        logger.exit();
    }
}

+ 0 - 47
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/BeanUtil.java

@ -1,47 +0,0 @@
package com.yihu.ehr.util.operator;
import org.apache.commons.beanutils.PropertyUtils;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
 * Created by lingfeng on 2015/12/29.
 */
public class BeanUtil {
    public static List objectArray2Bean(List list, Class beanClass){
        Constructor beanConstructor;
        try        {
            beanConstructor =  beanClass.getConstructor(new Class[] {Object[].class});
        }
        catch (Exception e)        {
            return null;
        }
        Iterator it = list.iterator();
        List result = new ArrayList();
        result.clear();
        while (it.hasNext())        {
            Object bean;
            try            {
                bean = beanConstructor.newInstance(new Object[] {it.next()});
            }
            catch (Exception e)            {
                return null;
            }
            result.add(beanClass.cast(bean));
        }
        return result;
    }
    public static Object getPropertyValue(Object o, String name) {
        try {
            return PropertyUtils.getProperty(o, name);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

+ 0 - 18
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/CollectionUtil.java

@ -1,18 +0,0 @@
package com.yihu.ehr.util.operator;
import org.apache.commons.collections.CollectionUtils;
import java.util.Collection;
/**
 * Hibernate Criteria utils
 *
 * @since 1.0.6
 */
public class CollectionUtil {
    public static boolean isEmpty(Collection coll) {
        return CollectionUtils.isEmpty(coll);
    }
}

+ 0 - 38
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/ConfigureUtil.java

@ -1,38 +0,0 @@
package com.yihu.ehr.util.operator;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import java.io.IOException;
import java.util.Properties;
/**
 *  获取配置文件内容滚工具类
 * Created by HZY on 2015/10/29.
 */
public class ConfigureUtil {
    /**
     * 获取.propertiest文件属性值
     * @param filePath  文件路径
     * @param key        属性名:key
     * @return value     属性值:value
     */
    public static String CRAWLER_PROPERTIES = "config/crawler.properties";
    public static String getProValue(String filePath, String key) {
        Resource resource = null;
        Properties props = null;
        String value = null;
        try {
            resource = new ClassPathResource(filePath);
            EncodedResource encRes = new EncodedResource(resource,"UTF-8");
            props = PropertiesLoaderUtils.loadProperties(encRes);
            value= (String) props.get(key);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return value;
    }
}

+ 0 - 89
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/ListSortUtil.java

@ -1,89 +0,0 @@
/******************************************************************************/
/* SYSTEM     : Commons                                                       */
/*                                                                            */
/* SUBSYSTEM  : Util                                                          */
/******************************************************************************/
package com.yihu.ehr.util.operator;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparableComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.collections.comparators.NullComparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ListSortUtil {
    public static ArrayList sort(ArrayList list, String[] fields) throws IllegalArgumentException {
        if (fields == null) {
            throw new IllegalArgumentException("fields is null.");
        }
        return sort(list, fields, new boolean[fields.length]);
    }
    public static List sort(List list, String[] fields) throws IllegalArgumentException {
        if (fields == null) {
            throw new IllegalArgumentException("fields is null.");
        }
        return sort(list, fields, new boolean[fields.length]);
    }
    public static ArrayList sort(ArrayList list, String[] fields, boolean[] reverses) throws IllegalArgumentException {
        return (ArrayList) sort((List) list, fields, reverses);
    }
    public static List sort(List list, String[] fields, boolean[] reverses) throws IllegalArgumentException {
        if (list == null || list.size() == 0) {
            return list;
        }
        if (fields == null) {
            throw new IllegalArgumentException("fields is null.");
        }
        if (reverses == null) {
            throw new IllegalArgumentException("reverses is null.");
        }
        if (fields.length != reverses.length) {
            throw new IllegalArgumentException("The size of fields and reverses is not in agreement.");
        }
        if (fields.length == 0) {
            return list;
        }
        // マルチカラムソート用のコンパレータ
        ComparatorChain cc = new ComparatorChain();
        for (int i = 0; fields != null && i < fields.length; i++) {
            String field = fields[i];
            boolean reverse = reverses[i];
            if (field.trim().length() == 0) {
                continue;
            }
            cc.addComparator(
                    new BeanComparator(
                            field,
                            new NullComparator(ComparableComparator.getInstance())),
                    reverse);
        }
        if (cc.size() != 0) {
            // ソート
            Collections.sort(list, cc);
        }
        return list;
    }
}

+ 0 - 636
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/NumberUtil.java

@ -1,636 +0,0 @@
package com.yihu.ehr.util.operator;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class NumberUtil {
    public static final BigDecimal DEFAULT_NUMBER = BigDecimal.ZERO;
    public static final String DECIMAL_FORMAT = "#,##0.00";
    public static final String INTEGER_FORMAT = "#,##0";
    public static final String DEFAULT_NUM_GROUP_STYLE_ID = "1";
    public static final String DEFAULT_DECIMAL_STYLE_ID = "2";
    public static final String[][] DECIMAL_STYLE_LIST = {
            {"1", ",", "Comma"},
            {"2", ".", "Period"}
    };
    public static final String[][] NUM_GROUP_STYLE_LIST = {
            {"1", ",", "Comma"},
            {"2", ".", "Period"},
            {"3", " ", "Space"}
    };
    protected NumberUtil() {
    }
    public static boolean isDivisible(BigDecimal dividend, BigDecimal divisor) {
        if (dividend == null || divisor == null) {
            return false;
        }
        if (compare(dividend.remainder(divisor), DEFAULT_NUMBER) == 0) {
            return true;
        }
        return false;
    }
    public static String changeToDecimalFormat(Number num) {
        return formatNumber(num, DECIMAL_FORMAT);
    }
    public static String changeToIntegerFormat(Number num) {
        return formatNumber(num, INTEGER_FORMAT);
    }
    public static String formatNumber(Number num, String format) {
        DecimalFormat noFormat = new DecimalFormat(format);
        return noFormat.format(num);
    }
    public static int compare(BigDecimal num1, BigDecimal num2) {
        if (num1 == null) {
            num1 = DEFAULT_NUMBER;
        }
        if (num2 == null) {
            num2 = DEFAULT_NUMBER;
        }
        return num1.compareTo(num2);
    }
    public static boolean gt(BigDecimal num1, BigDecimal num2) {
        if (compare(num1, num2) > 0) {
            return true;
        }
        return false;
    }
    public static boolean ge(BigDecimal num1, BigDecimal num2) {
        return !lt(num1, num2);
    }
    public static boolean lt(BigDecimal num1, BigDecimal num2) {
        if (compare(num1, num2) < 0) {
            return true;
        }
        return false;
    }
    public static boolean le(BigDecimal num1, BigDecimal num2) {
        return !gt(num1, num2);
    }
    public static boolean equals(BigDecimal num1, BigDecimal num2) {
        if (compare(num1, num2) == 0) {
            return true;
        }
        return false;
    }
    public static boolean equals(int num1, int num2) {
        if (compare(new BigDecimal(String.valueOf(num1)), new BigDecimal(String.valueOf(num2))) == 0) {
            return true;
        }
        return false;
    }
    public static boolean isPositive(BigDecimal num) {
        if (num == null) {
            return false;
        }
        if (gt(num, BigDecimal.ZERO)) {
            return true;
        }
        return false;
    }
    public static boolean isZero(BigDecimal num) {
        if (num == null) {
            return false;
        }
        if (equals(num, BigDecimal.ZERO)) {
            return true;
        }
        return false;
    }
    public static BigDecimal subtractBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).subtract(dec2 != null ? dec2 : DEFAULT_NUMBER);
    }
    public static BigDecimal multiplyBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).multiply(dec2 != null ? dec2 : DEFAULT_NUMBER);
    }
    public static BigDecimal divideBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        if (dec2 == null || dec2.equals(DEFAULT_NUMBER)) {
            return DEFAULT_NUMBER;
        }
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(dec2, 2, BigDecimal.ROUND_HALF_UP);
    }
    public static BigDecimal divideBigDecimal(BigDecimal dec1, BigDecimal dec2, int scale) {
        if (dec2 == null || dec2.equals(DEFAULT_NUMBER)) {
            return DEFAULT_NUMBER;
        }
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(dec2, scale, BigDecimal.ROUND_HALF_UP);
    }
    public static BigDecimal floorDivideBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        if (dec2 == null || dec2.equals(DEFAULT_NUMBER)) {
            return DEFAULT_NUMBER;
        }
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(dec2, 0, BigDecimal.ROUND_FLOOR);
    }
    public static BigDecimal ceilingDivideBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        if (dec2 == null || dec2.equals(DEFAULT_NUMBER)) {
            return DEFAULT_NUMBER;
        }
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(dec2, 0, BigDecimal.ROUND_CEILING);
    }
    public static BigDecimal toBigDecimal(int num) {
        return toBigDecimal(StringUtil.toString(num));
    }
    public static Integer toInteger(long num) {
        return toInteger(StringUtil.toString(num));
    }
    public static BigDecimal roundBigDecimal(BigDecimal dec1, int scale) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(new BigDecimal("1"), scale, BigDecimal.ROUND_HALF_UP);
    }
    public static BigDecimal floorBigDecimal(BigDecimal dec1, int scale) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(new BigDecimal("1"), scale, BigDecimal.ROUND_FLOOR);
    }
    public static BigDecimal ceilingBigDecimal(BigDecimal dec1, int scale) {
        return (dec1 != null ? dec1 : DEFAULT_NUMBER).divide(new BigDecimal("1"), scale, BigDecimal.ROUND_CEILING);
    }
    public static Boolean toBoolean(String str) {
        try {
            return new Boolean(str);
        } catch (Exception e) {
            return null;
        }
    }
    public static int toInt(String str) {
        Integer integer = toInteger(str);
        return (integer == null ? 0 : integer.intValue());
    }
    public static int toInt(Integer integer) {
        return (integer == null ? 0 : integer.intValue());
    }
    public static Integer toInteger(String str) {
        if (str == null) {
            return null;
        }
        if (StringUtil.isBlank(str)) {
            return 0;
        }
        try {
            return new Integer(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static Integer toInteger(int i) {
        try {
            return new Integer(i);
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static BigInteger toBigInteger(String str) {
        if (str == null) {
            return null;
        }
        try {
            return new BigInteger(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static BigDecimal toBigDecimal(String str) {
        if (str == null) {
            return null;
        }
        if (StringUtil.isBlank(str)) {
            return BigDecimal.ZERO;
        }
        try {
            return new BigDecimal(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static BigDecimal toBigDecimal(String str, String decPoPtn) {
        return toBigDecimal(formatDecDefault(str, decPoPtn));
    }
    public static Float toFloat(String str) {
        if (str == null) {
            return null;
        }
        try {
            return new Float(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static float totoPrimitiveFloat(String str) {
        return (str == null ? 0 : Float.parseFloat(str));
    }
    public static Long toLong(String str) {
        if (str == null) {
            return null;
        }
        try {
            return new Long(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static long totoPrimitiveLong(String str) {
        return (str == null ? 0 : Long.parseLong(str));
    }
    public static Double toDouble(String str) {
        if (str == null) {
            return null;
        }
        try {
            return new Double(str.trim());
        } catch (NumberFormatException nfe) {
            return null;
        }
    }
    public static double totoPrimitiveDouble(String str) {
        return (str == null ? 0 : Double.parseDouble(str));
    }
    public static String getDecimalStyleName(String decimalStyleId) {
        String value = null;
        for (int i = 0; i < DECIMAL_STYLE_LIST.length; i++) {
            if (DECIMAL_STYLE_LIST[i][0].equals(decimalStyleId)) {
                value = DECIMAL_STYLE_LIST[i][2];
                break;
            }
        }
        if (value == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return value;
    }
    public static String getDecPo(String decPoPtn) {
        return String.valueOf(getDecimalStyleValue(decPoPtn));
    }
    public static String getDecimalStyleValue(String decimalStyleId) {
        String value = null;
        for (int i = 0; i < DECIMAL_STYLE_LIST.length; i++) {
            if (DECIMAL_STYLE_LIST[i][0].equals(decimalStyleId)) {
                value = DECIMAL_STYLE_LIST[i][1];
                break;
            }
        }
        if (value == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return value;
    }
    public static char getDecimalStyleValueChar(String decimalStyleId) {
        return getDecimalStyleValue(decimalStyleId).charAt(0);
    }
    public static String formatIntValue(int n) {
        return formatIntValue(new Integer(n));
    }
    public static String formatIntView(int n, String numSepPtn) {
        return formatIntView(new Integer(n), numSepPtn);
    }
    public static String formatIntValue(Integer num) {
        if (num == null) {
            return null;
        }
        String format = "#####0";
        return formatNum(num, format, null, null);
    }
    public static String formatIntView(Integer num, String numGroupStyleId) {
        if (num == null) {
            return null;
        }
        String format = "###,##0";
        return formatNum(num, format, null, numGroupStyleId);
    }
    public static String formatDecValue(BigDecimal dec, String decimalStyleId) {
        return formatDecValue(dec, -1, decimalStyleId);
    }
    public static String formatDecValue(BigDecimal dec, Integer decLength, String decimalStyleId) {
        return formatDecValue(dec, decLength != null ? decLength.intValue() : -1, decimalStyleId);
    }
    public static String formatDecValue(BigDecimal dec, int decLength, String decimalStyleId) {
        if (dec == null) {
            return null;
        }
        String format = "#####0";
        if (decLength > 0) {
            // 小数桁数指定あり
            for (int i = 0; i < decLength; i++) {
                if (i == 0) {
                    format += ".";
                }
                format += "0";
            }
        } else {
            // 小数桁数指定なし
            format += ".##########";
        }
        return formatNum(dec, format, decimalStyleId, null);
    }
    public static String formatDecView(BigDecimal dec, String decimalStyleId, String numGroupStyleId) {
        return formatDecView(dec, -1, decimalStyleId, numGroupStyleId);
    }
    public static String formatDecView(BigDecimal dec, Integer decLength,
                                       String decimalStyleId, String numGroupStyleId) {
        return formatDecView(dec,
                decLength != null ? decLength.intValue() : -1,
                decimalStyleId,
                numGroupStyleId);
    }
    public static String formatDecView(BigDecimal dec, int decLength,
                                       String decimalStyleId, String numGroupStyleId) {
        if (dec == null) {
            return null;
        }
        String format = "###,##0";
        if (decLength > 0) {
            // 小数桁数指定あり
            for (int i = 0; i < decLength; i++) {
                if (i == 0) {
                    format += ".";
                }
                format += "0";
            }
        } else {
            // 小数桁数指定なし
            format += ".##########";
        }
        return formatNum(dec, format, decimalStyleId, numGroupStyleId);
    }
    protected static String formatNum(Object obj, String format, String decimalStyleId, String numGroupStyleId) {
        char decPo = decimalStyleId != null ? getDecimalStyleValueChar(decimalStyleId) : ' ';
        char numSep = numGroupStyleId != null ? getNumGroupStyleValueChar(numGroupStyleId) : ' ';
        DecimalFormat df = (DecimalFormat) NumberFormat.getInstance();
        df.applyPattern(format);
        String str = df.format(obj);
        if (str == null) {
            return null;
        }
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (c == ',') {
                sb.append(numSep);
                continue;
            }
            if (c == '.') {
                sb.append(decPo);
                if (i != str.length()) {
                    sb.append(str.substring(i + 1, str.length()));
                }
                break;
            }
            sb.append(c);
        }
        return sb.toString();
    }
    public static String formatDecDefault(String str, String decPoPtn) {
        if (str == null) {
            return null;
        }
        char decPo = getDecimalStyleValueChar(decPoPtn);
        StringBuffer sb = new StringBuffer(str);
        int idx = sb.toString().indexOf(String.valueOf(decPo));
        if (idx != -1) {
            sb.replace(idx, idx + String.valueOf(decPo).length(), String.valueOf('.'));
        }
        return sb.toString();
    }
    public static String getNumGroupStyleValue(String numGroupStyleId) {
        String value = null;
        for (int i = 0; i < NUM_GROUP_STYLE_LIST.length; i++) {
            if (NUM_GROUP_STYLE_LIST[i][0].equals(numGroupStyleId)) {
                value = NUM_GROUP_STYLE_LIST[i][1];
                break;
            }
        }
        if (value == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return value;
    }
    public static char getNumGroupStyleValueChar(String numGroupStyleId) {
        return getNumGroupStyleValue(numGroupStyleId).charAt(0);
    }
    public static String getNumGroupStyleName(String numGroupStyleId) {
        String value = null;
        for (int i = 0; i < NUM_GROUP_STYLE_LIST.length; i++) {
            if (NUM_GROUP_STYLE_LIST[i][0].equals(numGroupStyleId)) {
                value = NUM_GROUP_STYLE_LIST[i][2];
                break;
            }
        }
        if (value == null) {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        return value;
    }
    public static String roundString(String str) {
        BigDecimal dec = toBigDecimal(str);
        return (dec == null ? str : StringUtil.toString(roundBigDecimal(dec)));
    }
    public static BigDecimal roundBigDecimal(BigDecimal dec) {
        return (dec == null ? dec : dec.divide(new BigDecimal("1"), 0, BigDecimal.ROUND_HALF_UP));
    }
    public static int roundBigDecimal(int num) {
        return toInt(roundString(StringUtil.toString(num)));
    }
    public static String fomatNumber(double amount, String pattern) {
        NumberFormat nf = NumberFormat.getCurrencyInstance();
        DecimalFormat df = (DecimalFormat) nf;
        df.setMinimumFractionDigits(2);
        df.setMaximumFractionDigits(2);
        df.setDecimalSeparatorAlwaysShown(true);
        df.applyPattern(pattern);
        return df.format(amount);
    }
    public static String fomatNumber(long amount, String pattern) {
        NumberFormat nf = NumberFormat.getCurrencyInstance();
        DecimalFormat df = (DecimalFormat) nf;
        df.setMinimumFractionDigits(2);
        df.setMaximumFractionDigits(2);
        df.setDecimalSeparatorAlwaysShown(true);
        df.applyPattern(pattern);
        return df.format(amount);
    }
    public static BigDecimal addBigDecimal(BigDecimal dec1, BigDecimal dec2) {
        return (dec1 != null ? dec1 : new BigDecimal(0)).add(dec2 != null ? dec2 : new BigDecimal(0));
    }
    public static boolean isInteger(String target) {
        if (target == null) {
            return false;
        }
        char[] digit = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
        for (int i = 0; i < target.length(); i++) {
            for (int j = 0; j < digit.length; j++) {
                if (target.charAt(i) == digit[j]) {
                    break;
                }
                if (i == 0 && target.charAt(i) == '-') {
                    break;
                }
                if (i == 0 && target.charAt(i) == '+') {
                    break;
                }
                if (j == digit.length - 1) {
                    return false;
                }
            }
        }
        return true;
    }
}

+ 0 - 29
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/Select2.java

@ -1,29 +0,0 @@
package com.yihu.ehr.util.operator;
/**
 * select2类
 *
 * @author llh
 */
public class Select2 {
    private String id;
    private String text;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getText() {
        return text;
    }
    public void setText(String text) {
        this.text = text;
    }
}

+ 0 - 353
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/SqlCreate.java

@ -1,353 +0,0 @@
package com.yihu.ehr.util.operator;
import com.yihu.ehr.common.constants.Constants;
import java.util.List;
import java.util.Map;
/**
 * Created by lingfeng on 2015/6/23.
 */
public class SqlCreate {
    private String primaryKey;
    private String tableName;
    private String tableItem;
    private String tableKey;
    private List<String> itemList;
    private List<String> itemValueList;
    private List<String> conditionList;
    private Map<String, String> keyValueMap;
    private static String[] stdTable = {"std_dataset", "std_metadata", "std_dict", "std_dict_item"};
    private static String[] stdDatasetTable = {"std_dataset", "std_metadata"};
    public SqlCreate() {
    }
    public String createTable() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.CREATE_TABLE + tableName + Constants.LEFT_BRACKET);
        for (String item : itemList) {
            sqlBuffer.append(item + Constants.COMMA);
        }
        if (!primaryKey.equals("")) {
            sqlBuffer.append(Constants.PRIMARY_KEY + Constants.LEFT_BRACKET + primaryKey);
            sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
            sqlBuffer.append(Constants.RIGHT_BRACKET);
        } else {
            sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        }
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.ROW_FORMAT_DYNAMIC + Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String insertData() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.INSERT_INTO + tableName + Constants.LEFT_BRACKET);
        for (String item : itemList) {
            sqlBuffer.append(item + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.VALUES + Constants.LEFT_BRACKET);
        for (String item : itemValueList) {
            sqlBuffer.append(item + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String insertDataByKeyValue() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.INSERT_INTO + this.tableName + Constants.LEFT_BRACKET);
        for (String key : keyValueMap.keySet()) {
            sqlBuffer.append(key + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.VALUES + Constants.LEFT_BRACKET);
        for (String key : keyValueMap.keySet()) {
            sqlBuffer.append(keyValueMap.get(key) + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.RIGHT_BRACKET + Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String updateDataByTableKey() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.UPDATE + tableName + Constants.SET);
        for (String key : keyValueMap.keySet()) {
            sqlBuffer.append(key + Constants.EQUAL_MARK + keyValueMap.get(key) + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.WHERE + Constants.TABLE_KEY + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String getMaxId() {
        String sql = "select max(id) from " + tableName;
        return sql;
    }
    public Boolean isToAdapter() {
        Boolean flg = false;
        for (String str : stdTable) {
            if (tableName.equals(str)) {
                flg = true;
            }
        }
        return flg;
    }
    public Boolean isToAdapterDataset() {
        Boolean flg = false;
        for (String str : stdDatasetTable) {
            if (tableName.equals(str)) {
                flg = true;
            }
        }
        return flg;
    }
    public Boolean isCodeOrValue() {
        Boolean flg = false;
        for (String key : keyValueMap.keySet()) {
            if (key.equals(Constants.CODE_STR) || key.equals(Constants.VALUE_STR)) {
                flg = true;
            }
        }
        return flg;
    }
    public String updateAdapterData() {
        StringBuilder sqlBuffer = new StringBuilder();
        String adapterTableName = tableName.replace(Constants.STD_PREFIX, Constants.ADAPTER_PREFIX);
        sqlBuffer.append(Constants.UPDATE + adapterTableName + Constants.SET);
        for (String key : keyValueMap.keySet()) {
            if (key.equals(Constants.CODE_STR) || key.equals(Constants.VALUE_STR)) {
                sqlBuffer.append(tableName + Constants.UNDERLINE + key + Constants.EQUAL_MARK
                        + keyValueMap.get(key) + Constants.COMMA);
            }
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.WHERE + tableName + Constants.UNDERLINE + Constants.TABLE_KEY
                + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String failureDataByTableKey() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.UPDATE + tableName + Constants.SET);
        sqlBuffer.append(Constants.FAILURE_FLG + Constants.EQUAL_MARK + Constants.NUMBER_ZREO);
        sqlBuffer.append(Constants.WHERE + Constants.TABLE_KEY + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String deleteDataByTableKey() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.DELETE);
        sqlBuffer.append(Constants.FROM + tableName);
        sqlBuffer.append(Constants.WHERE + Constants.TABLE_KEY + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String deleteAdapterData() {
        StringBuilder sqlBuffer = new StringBuilder();
        String adapterTableName = tableName.replace(Constants.STD_PREFIX, Constants.ADAPTER_PREFIX);
        sqlBuffer.append(Constants.DELETE);
        sqlBuffer.append(Constants.FROM + adapterTableName);
        sqlBuffer.append(Constants.WHERE + tableName + Constants.UNDERLINE + Constants.TABLE_KEY
                + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String deleteAdapterOriginData() {
        StringBuilder sqlBuffer = new StringBuilder();
        String adapterOriginTableName = tableName.replace(Constants.STD_PREFIX, Constants.ADAPTER_PREFIX + Constants.ORIGIN_PREFIX);
        String tableKeyStr = tableName.replace(Constants.STD_PREFIX, "") + Constants.UNDERLINE + Constants.TABLE_KEY;
                sqlBuffer.append(Constants.DELETE);
        sqlBuffer.append(Constants.FROM + adapterOriginTableName);
        sqlBuffer.append(Constants.WHERE + tableKeyStr + Constants.EQUAL_MARK + tableKey);
        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String addTableItem() {
        StringBuffer sqlBuffer = new StringBuffer();
        sqlBuffer.append(Constants.ALTER_TABLE + tableName + Constants.ADD + tableItem + Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String deleteData() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.DELETE);
        sqlBuffer.append(Constants.FROM + tableName);
        if (!CollectionUtil.isEmpty(conditionList)) {
            sqlBuffer.append(Constants.WHERE);
            sqlBuffer.append("1=1" + Constants.AND);
            for (String condition : conditionList) {
                sqlBuffer.append(condition + Constants.AND);
            }
            sqlBuffer.delete(sqlBuffer.length() - 4, sqlBuffer.length() - 1);
        }
//        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String selectData() {
        StringBuilder sqlBuffer = new StringBuilder();
        sqlBuffer.append(Constants.SELECT);
        for (String item : itemList) {
            sqlBuffer.append(item + Constants.COMMA);
        }
        sqlBuffer.deleteCharAt(sqlBuffer.length() - 1);
        sqlBuffer.append(Constants.FROM + tableName);
        if (!CollectionUtil.isEmpty(conditionList)) {
            sqlBuffer.append(Constants.WHERE);
            sqlBuffer.append("1=1" + Constants.AND);
            for (String condition : conditionList) {
                sqlBuffer.append(condition + Constants.AND);
            }
            sqlBuffer.delete(sqlBuffer.length() - 4, sqlBuffer.length() - 1);
        }
//        sqlBuffer.append(Constants.SEMICOLON);
        return sqlBuffer.toString();
    }
    public String betweenCondition(String item) {
        String condition = item + Constants.BETWEEN + Constants.QUESTION_MARK + Constants.AND + Constants.QUESTION_MARK;
        return condition;
    }
    public String greaterAndEqualCondition(String item) {
        String condition = item + Constants.GREATER_EQUAL_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String greaterCondition(String item) {
        String condition = item + Constants.GREATER_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String lessAndEqualCondition(String item) {
        String condition = item + Constants.LESS_EQUAL_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String lessCondition(String item) {
        String condition = item + Constants.LESS_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String betweenCondition(String item, String value1, String value2) {
        String condition = item + Constants.BETWEEN + value1 + Constants.AND + value2;
        return condition;
    }
    public String equalCondition(String item) {
        String condition = item + Constants.EQUAL_MARK + Constants.QUESTION_MARK;
        return condition;
    }
    public String equalCondition(String item, String value) {
        String condition = item + Constants.EQUAL_MARK + value;
        return condition;
    }
    public String likeCondition(String item) {
        String condition = item + Constants.LIKE + Constants.QUESTION_MARK;
        return condition;
    }
    public String getTableName() {
        return tableName;
    }
    public void setTableName(String tableName) {
        this.tableName = tableName;
    }
    public String getPrimaryKey() {
        return primaryKey;
    }
    public void setPrimaryKey(String primaryKey) {
        this.primaryKey = primaryKey;
    }
    public List<String> getItemList() {
        return itemList;
    }
    public void setItemList(List<String> itemList) {
        this.itemList = itemList;
    }
    public List<String> getItemValueList() {
        return itemValueList;
    }
    public void setItemValueList(List<String> itemValueList) {
        this.itemValueList = itemValueList;
    }
    public String getTableItem() {
        return tableItem;
    }
    public void setTableItem(String tableItem) {
        this.tableItem = tableItem;
    }
    public List<String> getConditionList() {
        return conditionList;
    }
    public void setConditionList(List<String> conditionList) {
        this.conditionList = conditionList;
    }
    public String getTableKey() {
        return tableKey;
    }
    public void setTableKey(String tableKey) {
        this.tableKey = tableKey;
    }
    public Map<String, String> getKeyValueMap() {
        return keyValueMap;
    }
    public void setKeyValueMap(Map<String, String> keyValueMap) {
        this.keyValueMap = keyValueMap;
    }
}

+ 0 - 88
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/TokenUtil.java

@ -1,88 +0,0 @@
package com.yihu.ehr.util.operator;
import com.yihu.ehr.util.encrypt.DES;
import com.yihu.ehr.util.encrypt.MD5;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
/**
 * Created by Administrator on 2015/7/31.
 */
public class TokenUtil {
    private final static String NUM_CHAR = "0123456789";
    private static int charLen = NUM_CHAR.length();
    public static final String PASS_WORD = "ehrvanguardpassword";
    public static String getRandomNumberSeed(int randomNumberDigit) {
        long seed = System.currentTimeMillis();
        StringBuffer sb = new StringBuffer();
        Random random = new Random(seed);
        for (int i = 0; i < randomNumberDigit; i++) {
            sb.append(NUM_CHAR.charAt(random.nextInt(charLen)));
        }
        return sb.toString();
    }
    /**
     * 1. ������Ȩ�� (������������������MD5����)
     *
     * @throws Exception
     */
    public static String genToken() throws Exception {
        String seed  = getRandomNumberSeed(16);
        String token = MD5.hash(seed);
        return token;
    }
    public static String tokenEncrypt(String userId, String appId, Date createDate, long expiresIn) throws Exception {
        long seed = createDate.getTime();
        String expiredTime = String.valueOf(seed + (expiresIn * 1000));
        String[] arrTmp = {userId, appId, expiredTime};
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < arrTmp.length; i++) {
            if (i == 0) {
                sb.append(arrTmp[i]);
            } else {
                sb.append("," + arrTmp[i]);
            }
        }
        String token = DES.encrypt(sb.toString(), PASS_WORD);
        return token;
    }
    public static Map tokenDecrypt(String token) throws Exception {
        Map map = new HashMap<>();
        String tokenStr = DES.decrypt(token, PASS_WORD);
        String[] tokenInfo = tokenStr.split(",");
        String userId = tokenInfo[0].toString();
        String appId = tokenInfo[1].toString();
        long expriedTime = Long.valueOf(tokenInfo[2].toString()).longValue();
        Date expriedDate = new Date(expriedTime);
        map.put("userId", userId);
        map.put("appId", appId);
        map.put("expriedTime", expriedDate.toString());
        return map;
    }
}

+ 0 - 53
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/util/operator/TreeNode.java

@ -1,53 +0,0 @@
package com.yihu.ehr.util.operator;
/**
 * 树类
 *
 * @author llh
 */
public class TreeNode {
    private String id;
    private String pid;
    private String text;
    private Boolean ischecked;
    public TreeNode(String id, String pid, String text) {
        this.id = id;
        this.pid = pid;
        this.text = text;
        this.ischecked = false;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getText() {
        return text;
    }
    public void setText(String text) {
        this.text = text;
    }
    public String getPid() {
        return pid;
    }
    public void setPid(String pid) {
        this.pid = pid;
    }
    public Boolean getIschecked() {
        return ischecked;
    }
    public void setIschecked(Boolean ischecked) {
        this.ischecked = ischecked;
    }
}

+ 0 - 2
Hos-Resource-Mini-helper/src/main/resources/config/dbhelper.properties

@ -1,2 +0,0 @@
defaultName = localDB
defaultUri = jdbc:sqlite://F:/test/db/localDB.db

+ 0 - 45
Hos-Resource-Mini-helper/src/main/resources/config/threadConfig.properties

@ -1,45 +0,0 @@
soft.versionCode=1
## service address
service.url=https://192.168.131.15:443/api/v1.0/
service.clientId = kHAbVppx44
service.clientKey = Bd2h8rdYhep6NKOO
logThread.sleepTime=1
sqlThread.sleepTime=30
## logThread sleep time  min
logThread.uploadLog=esb/uploadLog
logThread.getUploadFlag=simplified-esb/getUploadFlag
## sqlThread sleep time  min
sqlThread.fillMining=simplified-esb/fillMining
sqlThread.changeFillMiningStatus=simplified-esb/changeFillMiningStatus
sqlThread.hisPenetration=simplified-esb/hisPenetration
sqlThread.changeHisPenetrationStatus=simplified-esb/changeHisPenetrationStatus
##service name
tomcat.servicename=tomcat8-esb-service
##token
token.info={"fingerprint": "abc"}
token.basic=Basic a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P
token.getToken=authorizations/clients/
token.user_name=kHAbVppx44
## updateThread sleep time  min
##updateThread.isUpdate=simplified-esb/getUpdateFlag
##updateThread.downUpdateWar=simplified-esb/downUpdateWar
##updateThread.uploadResult=simplified-esb/uploadResult
##updateThread.sleepTime=30
service.username=admin
service.password=123456
system.code=MINIESB

二進制
Hos-Resource-Mini-helper/src/main/resources/config/tomcat.keystore


+ 0 - 39
Hos-Resource-Mini-helper/src/main/resources/log4j2.xml

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ========================== 自定义输出格式说明================================ -->
<!-- %p 输出优先级,即DEBUG,INFO,WARN,ERROR,FATAL -->
<!-- %r 输出自应用启动到输出该log信息耗费的毫秒数  -->
<!-- %c 输出所属的类目,通常就是所在类的全名 -->
<!-- %t 输出产生该日志事件的线程名 -->
<!-- %m 输出代码中指定的消息, 产生的日志具体信息-->
<!-- %n 输出一个回车换行符,Windows平台为“\r\n”,Unix平台为“\n” -->
<!-- %d 输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比如:%d{yyy MMM dd HH:mm:ss,SSS},输出类似:2002年10月18日 22:10:28,921  -->
<!-- %l 输出日志事件的发生位置,包括类目名、发生的线程,以及在代码中的行数。举例:Testlog4.main(TestLog4.java:10)  -->
<!-- ========================================================================== -->
<Configuration status="WARN"  monitorInterval="1800" >
    <!--<properties> -->
    <!--  <property name="LOG_HOME">logs</property> -->
    <!--<property name="FILE_NAME">hos</property>-->
    <!--</properties>-->
    <Appenders>
        <!-- 日志文件保存-->
        <RollingFile name="RollingFile" fileName="${sys:log4j}/esb_mini.log"
                     filePattern="${sys:log4j}esb_mini-%d{MM-dd-yyyy}-%i.log">
            <PatternLayout charset="UTF-8"
                           pattern='%d{yyyy-MM-dd HH:mm:ss}-- %p %t %c - %m%n'/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="10 MB"/>
            </Policies>
            <DefaultRolloverStrategy fileIndex="max" max="10"/>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="trace">
            <AppenderRef ref="RollingFile"/>
        </Root>
    </Loggers>
</Configuration>

+ 0 - 44
Hos-Resource-Mini-helper/src/main/webapp/WEB-INF/dispatcher-servlet.xml

@ -1,44 +0,0 @@
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:p="http://www.springframework.org/schema/p"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <context:component-scan base-package="com.yihu">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
    </context:component-scan>
    <!-- 允许访问指定路径下的静态资源 -->
    <mvc:resources location="WEB-INF/" mapping="/WEB-INF/**" />
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
    <!-- 自定义json转换类(时间类型) -->
    <mvc:annotation-driven>
        <mvc:message-converters>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="objectMapper">
                    <bean class="com.fasterxml.jackson.databind.ObjectMapper">
                        <property name="dateFormat">
                            <bean class="java.text.SimpleDateFormat">
                                <constructor-arg type="java.lang.String" value="yyyy-MM-dd HH:mm:ss"/>
                            </bean>
                        </property>
                    </bean>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
</beans>

+ 0 - 54
Hos-Resource-Mini-helper/src/main/webapp/WEB-INF/web.xml

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
		  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    <listener>
        <listener-class>
            com.yihu.ehr.common.ApplicationStart
        </listener-class>
    </listener>
    <!--servlet设
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>-->
    <!--过滤器
    <filter>
        <filter-name>characterEncodingFilter</filter-name>
        <filter-class>
            org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    -->
    <!--Spring
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/applicationContext.xml</param-value>
    </context-param>
    -->
</web-app>

+ 0 - 5
Hos-Resource-Mini-helper/src/main/webapp/index.jsp

@ -1,5 +0,0 @@
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>

+ 0 - 2
Hos-Resource-Mini-helper/target/classes/config/dbhelper.properties

@ -1,2 +0,0 @@
defaultName = localDB
defaultUri = jdbc:sqlite://F:/test/db/localDB.db

+ 0 - 45
Hos-Resource-Mini-helper/target/classes/config/threadConfig.properties

@ -1,45 +0,0 @@
soft.versionCode=1
## service address
service.url=https://192.168.131.15:443/api/v1.0/
service.clientId = kHAbVppx44
service.clientKey = Bd2h8rdYhep6NKOO
logThread.sleepTime=1
sqlThread.sleepTime=30
## logThread sleep time  min
logThread.uploadLog=esb/uploadLog
logThread.getUploadFlag=simplified-esb/getUploadFlag
## sqlThread sleep time  min
sqlThread.fillMining=simplified-esb/fillMining
sqlThread.changeFillMiningStatus=simplified-esb/changeFillMiningStatus
sqlThread.hisPenetration=simplified-esb/hisPenetration
sqlThread.changeHisPenetrationStatus=simplified-esb/changeHisPenetrationStatus
##service name
tomcat.servicename=tomcat8-esb-service
##token
token.info={"fingerprint": "abc"}
token.basic=Basic a0hBYlZwcHg0NDpCZDJoOHJkWWhlcDZOS09P
token.getToken=authorizations/clients/
token.user_name=kHAbVppx44
## updateThread sleep time  min
##updateThread.isUpdate=simplified-esb/getUpdateFlag
##updateThread.downUpdateWar=simplified-esb/downUpdateWar
##updateThread.uploadResult=simplified-esb/uploadResult
##updateThread.sleepTime=30
service.username=admin
service.password=123456
system.code=MINIESB

二進制
Hos-Resource-Mini-helper/target/classes/config/tomcat.keystore


+ 0 - 39
Hos-Resource-Mini-helper/target/classes/log4j2.xml

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ========================== 自定义输出格式说明================================ -->
<!-- %p 输出优先级,即DEBUG,INFO,WARN,ERROR,FATAL -->
<!-- %r 输出自应用启动到输出该log信息耗费的毫秒数  -->
<!-- %c 输出所属的类目,通常就是所在类的全名 -->
<!-- %t 输出产生该日志事件的线程名 -->
<!-- %m 输出代码中指定的消息, 产生的日志具体信息-->
<!-- %n 输出一个回车换行符,Windows平台为“\r\n”,Unix平台为“\n” -->
<!-- %d 输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比如:%d{yyy MMM dd HH:mm:ss,SSS},输出类似:2002年10月18日 22:10:28,921  -->
<!-- %l 输出日志事件的发生位置,包括类目名、发生的线程,以及在代码中的行数。举例:Testlog4.main(TestLog4.java:10)  -->
<!-- ========================================================================== -->
<Configuration status="WARN"  monitorInterval="1800" >
    <!--<properties> -->
    <!--  <property name="LOG_HOME">logs</property> -->
    <!--<property name="FILE_NAME">hos</property>-->
    <!--</properties>-->
    <Appenders>
        <!-- 日志文件保存-->
        <RollingFile name="RollingFile" fileName="${sys:log4j}/esb_mini.log"
                     filePattern="${sys:log4j}esb_mini-%d{MM-dd-yyyy}-%i.log">
            <PatternLayout charset="UTF-8"
                           pattern='%d{yyyy-MM-dd HH:mm:ss}-- %p %t %c - %m%n'/>
            <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="10 MB"/>
            </Policies>
            <DefaultRolloverStrategy fileIndex="max" max="10"/>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="trace">
            <AppenderRef ref="RollingFile"/>
        </Root>
    </Loggers>
</Configuration>

+ 0 - 0
Hos-Resource-Mini/Hos-Resource-Mini.iml


部分文件因文件數量過多而無法顯示