ソースを参照

Initial commit

RYang 5 年 前
コミット
cfd6073928
100 ファイル変更15137 行追加0 行削除
  1. 13 0
      .gitignore
  2. 14 0
      .idea/compiler.xml
  3. 17 0
      .idea/misc.xml
  4. 6 0
      .idea/sbt.xml
  5. 6 0
      .idea/vcs.xml
  6. 452 0
      .idea/workspace.xml
  7. 577 0
      pom.xml
  8. 711 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/AcpService.java
  9. 125 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/BaseHttpSSLSocketFactory.java
  10. 789 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/CertUtil.java
  11. 223 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/DemoBase.java
  12. 314 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/HttpClient.java
  13. 115 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/LogUtil.java
  14. 806 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/SDKConfig.java
  15. 391 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/SDKConstants.java
  16. 875 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/SDKUtil.java
  17. 574 0
      src/main/java/com/lightinit/hsdataportal/Unionsdk/SecureUtil.java
  18. 42 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/IWXPayDomain.java
  19. 45 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/MyPayConfig.java
  20. 53 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/MyWXUtils.java
  21. 687 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/WXPay.java
  22. 103 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayConfig.java
  23. 59 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayConstants.java
  24. 14 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayDomain.java
  25. 265 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayReport.java
  26. 258 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayRequest.java
  27. 296 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayUtil.java
  28. 30 0
      src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayXmlUtil.java
  29. 62 0
      src/main/java/com/lightinit/hsdataportal/annotation/AnnotationHelper.java
  30. 21 0
      src/main/java/com/lightinit/hsdataportal/annotation/FieldDescriber.java
  31. 27 0
      src/main/java/com/lightinit/hsdataportal/annotation/FieldDescriberHelper.java
  32. 54 0
      src/main/java/com/lightinit/hsdataportal/common/AlipayConfig.java
  33. 213 0
      src/main/java/com/lightinit/hsdataportal/common/ApiEncryptUtil.java
  34. 219 0
      src/main/java/com/lightinit/hsdataportal/common/AuthenticUtil.java
  35. 215 0
      src/main/java/com/lightinit/hsdataportal/common/Base64Utils.java
  36. 78 0
      src/main/java/com/lightinit/hsdataportal/common/BaseRemoteClient.java
  37. 35 0
      src/main/java/com/lightinit/hsdataportal/common/BytesUtil.java
  38. 14 0
      src/main/java/com/lightinit/hsdataportal/common/CharEncoding.java
  39. 19 0
      src/main/java/com/lightinit/hsdataportal/common/CharacterUtils.java
  40. 37 0
      src/main/java/com/lightinit/hsdataportal/common/ConfigUtils.java
  41. 84 0
      src/main/java/com/lightinit/hsdataportal/common/DateUtils.java
  42. 41 0
      src/main/java/com/lightinit/hsdataportal/common/ExcelTookitUtils.java
  43. 93 0
      src/main/java/com/lightinit/hsdataportal/common/FTPConfigurationUtilsPro.java
  44. 364 0
      src/main/java/com/lightinit/hsdataportal/common/FTPTookitUtils.java
  45. 59 0
      src/main/java/com/lightinit/hsdataportal/common/GateWayUtils.java
  46. 13 0
      src/main/java/com/lightinit/hsdataportal/common/GuidGenerator.java
  47. 297 0
      src/main/java/com/lightinit/hsdataportal/common/HttpTookitUtils.java
  48. 311 0
      src/main/java/com/lightinit/hsdataportal/common/HttpUtil.java
  49. 148 0
      src/main/java/com/lightinit/hsdataportal/common/IPUtils.java
  50. 53 0
      src/main/java/com/lightinit/hsdataportal/common/MD5Utils.java
  51. 162 0
      src/main/java/com/lightinit/hsdataportal/common/MenuUtils.java
  52. 43 0
      src/main/java/com/lightinit/hsdataportal/common/ObjectConvertorUtils.java
  53. 17 0
      src/main/java/com/lightinit/hsdataportal/common/ObjectMappingUtils.java
  54. 181 0
      src/main/java/com/lightinit/hsdataportal/common/OneTimePasswordAlgorithm.java
  55. 19 0
      src/main/java/com/lightinit/hsdataportal/common/OrderNumberUtils.java
  56. 36 0
      src/main/java/com/lightinit/hsdataportal/common/PermissionUtilsPro.java
  57. 61 0
      src/main/java/com/lightinit/hsdataportal/common/PhoneSendUtils.java
  58. 168 0
      src/main/java/com/lightinit/hsdataportal/common/RSAUtils.java
  59. 43 0
      src/main/java/com/lightinit/hsdataportal/common/RoleComboUtils.java
  60. 127 0
      src/main/java/com/lightinit/hsdataportal/common/RoleModulesUtilsPro.java
  61. 71 0
      src/main/java/com/lightinit/hsdataportal/common/SecureCardUtilsPro.java
  62. 32 0
      src/main/java/com/lightinit/hsdataportal/common/ShiroFilterUtils.java
  63. 43 0
      src/main/java/com/lightinit/hsdataportal/common/SolrUtils.java
  64. 74 0
      src/main/java/com/lightinit/hsdataportal/common/SysContants.java
  65. 27 0
      src/main/java/com/lightinit/hsdataportal/common/ThriftServerConfig.java
  66. 93 0
      src/main/java/com/lightinit/hsdataportal/common/TokenUtils.java
  67. 123 0
      src/main/java/com/lightinit/hsdataportal/common/TripleDESUtilsPro.java
  68. 70 0
      src/main/java/com/lightinit/hsdataportal/common/UploadFileUtils.java
  69. 50 0
      src/main/java/com/lightinit/hsdataportal/common/WebUtilsPro.java
  70. 98 0
      src/main/java/com/lightinit/hsdataportal/common/ssl/MySecureProtocolSocketFactory.java
  71. 28 0
      src/main/java/com/lightinit/hsdataportal/common/ssl/MyX509TrustManager.java
  72. 127 0
      src/main/java/com/lightinit/hsdataportal/controller/BaseController.java
  73. 94 0
      src/main/java/com/lightinit/hsdataportal/controller/CaptchaController.java
  74. 30 0
      src/main/java/com/lightinit/hsdataportal/controller/HomeController.java
  75. 28 0
      src/main/java/com/lightinit/hsdataportal/controller/LoginController.java
  76. 178 0
      src/main/java/com/lightinit/hsdataportal/controller/WXPayController.java
  77. 122 0
      src/main/java/com/lightinit/hsdataportal/controller/open/APIDemandOpenController.java
  78. 109 0
      src/main/java/com/lightinit/hsdataportal/controller/open/APIOpenController.java
  79. 359 0
      src/main/java/com/lightinit/hsdataportal/controller/open/AccountController.java
  80. 243 0
      src/main/java/com/lightinit/hsdataportal/controller/open/AliPayController.java
  81. 49 0
      src/main/java/com/lightinit/hsdataportal/controller/open/BalancePAyController.java
  82. 142 0
      src/main/java/com/lightinit/hsdataportal/controller/open/BusinessIncubationController.java
  83. 299 0
      src/main/java/com/lightinit/hsdataportal/controller/open/DataOpenController.java
  84. 159 0
      src/main/java/com/lightinit/hsdataportal/controller/open/DataRequirementOpenController.java
  85. 21 0
      src/main/java/com/lightinit/hsdataportal/controller/open/DemoController.java
  86. 124 0
      src/main/java/com/lightinit/hsdataportal/controller/open/EntrepreneurshipTutoringController.java
  87. 115 0
      src/main/java/com/lightinit/hsdataportal/controller/open/InnovationActivityController.java
  88. 50 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MakerSpaceController.java
  89. 205 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MicroappOpenController.java
  90. 86 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MyAPIOpenController.java
  91. 88 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MyAccountController.java
  92. 82 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MyApiRequirementController.java
  93. 177 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MyDataOpenController.java
  94. 55 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MyDataRequirementOpenController.java
  95. 46 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MyFollowRequirementOpenController.java
  96. 106 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MyMicroappController.java
  97. 74 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MyMicroappRequirementController.java
  98. 36 0
      src/main/java/com/lightinit/hsdataportal/controller/open/MyReceiveController.java
  99. 50 0
      src/main/java/com/lightinit/hsdataportal/controller/open/NotificationOpenController.java
  100. 0 0
      src/main/java/com/lightinit/hsdataportal/controller/open/OfflineConferenceOpenController.java

+ 13 - 0
.gitignore

@@ -0,0 +1,13 @@
+# Created by .ignore support plugin (hsz.mobi)
+### Maven template
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
+

+ 14 - 0
.idea/compiler.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="true" />
+      <profile name="Maven default annotation processors profile" enabled="true">
+        <sourceOutputDir name="target/generated-sources/annotations" />
+        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
+        <outputRelativeToContentRoot value="true" />
+        <module name="hsdataportal" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>

+ 17 - 0
.idea/misc.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
+  <component name="FrameworkDetectionExcludesConfiguration">
+    <file type="web" url="file://$PROJECT_DIR$" />
+  </component>
+  <component name="MavenProjectsManager">
+    <option name="originalFiles">
+      <list>
+        <option value="$PROJECT_DIR$/pom.xml" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>

+ 6 - 0
.idea/sbt.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ScalaSbtSettings">
+    <option name="customVMPath" />
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 452 - 0
.idea/workspace.xml

@@ -0,0 +1,452 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ArtifactsWorkspaceSettings">
+    <artifacts-to-build>
+      <artifact name="hsdataportal:war" />
+    </artifacts-to-build>
+  </component>
+  <component name="ChangeListManager">
+    <list default="true" id="5e0a6283-3bb9-4464-9eb8-7061908be2e9" name="Default" comment="">
+      <change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/config.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/config.properties" afterDir="false" />
+    </list>
+    <ignored path="$PROJECT_DIR$/target/" />
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
+    <option name="TRACKING_ENABLED" value="true" />
+    <option name="SHOW_DIALOG" value="false" />
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+    <option name="LAST_RESOLUTION" value="IGNORE" />
+  </component>
+  <component name="FileEditorManager">
+    <leaf>
+      <file leaf-file-name=".gitignore" pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/.gitignore">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="195">
+              <caret line="13" selection-start-line="13" selection-end-line="13" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file leaf-file-name="config.properties" pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/src/main/resources/config.properties">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="275">
+              <caret line="74" lean-forward="true" selection-start-line="74" selection-end-line="74" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+    </leaf>
+  </component>
+  <component name="Git.Settings">
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+  </component>
+  <component name="GradleLocalSettings">
+    <option name="projectSyncType">
+      <map>
+        <entry key="$USER_HOME$/Desktop/PAAS中标部署/app-cloud-master" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/PAAS中标部署/dcw-mgmt-server-master" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/apiplatform_2.1.0.201809200314" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/dcw-mgmt-server" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/i慧湖/cmsApi" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/proto-firechat/mars" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/sh-server" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/张家港E管家项目/GIT/bike-h5-zjg" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/张家港E管家项目/GIT/egj-dataserver" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/张家港E管家项目/GIT/egj-epay-server" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/张家港E管家项目/GIT/egj-manager-server" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/张家港E管家项目/GIT/steward-epay" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/智慧党建/GIT/gd-event-service" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/智慧党建/GIT/gd-infomation" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/智慧党建/GIT/partyaffairs" value="PREVIEW" />
+        <entry key="$USER_HOME$/Desktop/软著资料/dcw-mgmt-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/BigData/GIT/analysismgr" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/BigData/GIT/dataportal" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/analysismgr" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/cas" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/coupon-service" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/cspservice" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/dc-lcn" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/dc-tm-manager" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/dcw-boot" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/demoService" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/demoWebService" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/egj-manager-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/event-service" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/information-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/operationmgr" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/payment-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/points" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/securitycall" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/shopping-service" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/third-service" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/userservice" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/GIT/verifyserver" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/LCN事务管理器/GIT/test-tm-appa" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/LCN事务管理器/GIT/test-tm-appb" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/LCN事务管理器/GIT/test-tm-appc" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/developer/GIT/app-cloud" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/developer/GIT/dc-cas-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/developer/GIT/dc-cas-server/dc-cas-server-webapp" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/paycloud/GIT/dc-cas-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/sample/dc-lcn" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/sample/fescar-develop" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/sample/fescar-samples-master" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/sample/springboot-dubbo-fescar-master" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/sample/tx-lcn-5.0.2.RELEASE" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/sample/txlcn-demo-master" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/北京网/GIT/sh-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/大数据平台/GIT/analyflume" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/大数据平台/GIT/analysismgr" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/大数据平台/GIT/dataportal" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/开发者门户/GIT/app-cloud" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/开发者门户/GIT/dcw-mgmt-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../LIGHTINIT/00-项目资料/05-公租房/GIT/housing-common" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../LIGHTINIT/00-项目资料/05-公租房/GIT/housing-datasync" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../LCN事务管理器/GIT/mrf-lcn" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../LCN事务管理器/GIT/mrf-tm-manager" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../daas/GIT/apiOutService" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../daas/GIT/apiService" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../developer/GIT/dcw-mgmt-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../framework/GIT/csp-commons" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../framework/GIT/dc-cas-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../framework/GIT/demoService" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../framework/GIT/mrf-boot" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../framework/GIT/mrf-cas-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../platformBusiness/GIT/cas" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../platformBusiness/GIT/cspservice" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../platformBusiness/GIT/image" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../platformBusiness/GIT/operationmgr" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../platformBusiness/GIT/securitycall" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../platformBusiness/GIT/third-service" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../platformBusiness/GIT/userservice" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../platformBusiness/GIT/ytserver" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../product/鲜果多多/GIT/fruits-service" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../sample/GradleSide-master/20-plugin-proguard" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../sample/Installer-master" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../sample/confusion-master" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../sample/moco-master" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../sample/proguard-spring-boot-example-master" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../sample/sso-master/sso-client1" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../sample/sso-master/sso-client2" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../sample/sso-master/sso-server" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../sample/txlcn-demo-master" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../SR/framework/GIT/dcw-boot" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../TOOLS/lombok-intellij-plugin" value="PREVIEW" />
+      </map>
+    </option>
+  </component>
+  <component name="IdeDocumentHistory">
+    <option name="CHANGED_PATHS">
+      <list>
+        <option value="$PROJECT_DIR$/src/main/resources/config.properties" />
+      </list>
+    </option>
+  </component>
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
+  <component name="JsGulpfileManager">
+    <detection-done>true</detection-done>
+    <sorting>DEFINITION_ORDER</sorting>
+  </component>
+  <component name="LogFilters">
+    <option name="FILTER_ERRORS" value="false" />
+    <option name="FILTER_WARNINGS" value="false" />
+    <option name="FILTER_INFO" value="true" />
+    <option name="FILTER_DEBUG" value="true" />
+    <option name="CUSTOM_FILTER" />
+  </component>
+  <component name="MavenImportPreferences">
+    <option name="importingSettings">
+      <MavenImportingSettings>
+        <option name="importAutomatically" value="true" />
+      </MavenImportingSettings>
+    </option>
+  </component>
+  <component name="NodePackageJsonFileManager">
+    <packageJsonPaths />
+  </component>
+  <component name="ProjectFrameBounds" fullScreen="true">
+    <option name="width" value="1440" />
+    <option name="height" value="900" />
+  </component>
+  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
+  <component name="ProjectView">
+    <navigator proportions="" version="1">
+      <foldersAlwaysOnTop value="true" />
+    </navigator>
+    <panes>
+      <pane id="ProjectPane">
+        <subPane>
+          <expand>
+            <path>
+              <item name="hsdataportal" type="b2602c69:ProjectViewProjectNode" />
+              <item name="hsdataportal" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="hsdataportal" type="b2602c69:ProjectViewProjectNode" />
+              <item name="hsdataportal" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="hsdataportal" type="b2602c69:ProjectViewProjectNode" />
+              <item name="hsdataportal" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="hsdataportal" type="b2602c69:ProjectViewProjectNode" />
+              <item name="hsdataportal" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
+              <item name="resources" type="462c0819:PsiDirectoryNode" />
+            </path>
+          </expand>
+          <select />
+        </subPane>
+      </pane>
+      <pane id="AndroidView" />
+      <pane id="Scope" />
+      <pane id="PackagesPane" />
+    </panes>
+  </component>
+  <component name="PropertiesComponent">
+    <property name="WebServerToolWindowFactoryState" value="false" />
+    <property name="aspect.path.notification.shown" value="true" />
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
+    <property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
+  </component>
+  <component name="RunDashboard">
+    <option name="ruleStates">
+      <list>
+        <RuleState>
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
+        </RuleState>
+        <RuleState>
+          <option name="name" value="StatusDashboardGroupingRule" />
+        </RuleState>
+      </list>
+    </option>
+  </component>
+  <component name="RunManager">
+    <configuration default="true" type="Application" factoryName="Application">
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+    </configuration>
+    <configuration default="true" type="JUnit" factoryName="JUnit">
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+      <option name="ALTERNATIVE_JRE_PATH" />
+      <option name="PACKAGE_NAME" />
+      <option name="MAIN_CLASS_NAME" />
+      <option name="METHOD_NAME" />
+      <option name="TEST_OBJECT" value="class" />
+      <option name="VM_PARAMETERS" value="-ea" />
+      <option name="PARAMETERS" />
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
+      <option name="PASS_PARENT_ENVS" value="true" />
+      <option name="TEST_SEARCH_SCOPE">
+        <value defaultName="singleModule" />
+      </option>
+      <patterns />
+    </configuration>
+    <configuration default="true" type="TestNG" factoryName="TestNG">
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+      <option name="ALTERNATIVE_JRE_PATH" />
+      <option name="SUITE_NAME" />
+      <option name="PACKAGE_NAME" />
+      <option name="MAIN_CLASS_NAME" />
+      <option name="METHOD_NAME" />
+      <option name="GROUP_NAME" />
+      <option name="TEST_OBJECT" value="CLASS" />
+      <option name="VM_PARAMETERS" value="-ea" />
+      <option name="PARAMETERS" />
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
+      <option name="OUTPUT_DIRECTORY" />
+      <option name="PASS_PARENT_ENVS" value="true" />
+      <option name="TEST_SEARCH_SCOPE">
+        <value defaultName="singleModule" />
+      </option>
+      <option name="USE_DEFAULT_REPORTERS" value="false" />
+      <option name="PROPERTIES_FILE" />
+      <properties />
+      <listeners />
+    </configuration>
+    <configuration name="Unnamed" type="#com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory" factoryName="Local" APPLICATION_SERVER_NAME="Tomcat 8.0.30" ALTERNATIVE_JRE_ENABLED="false">
+      <option name="UPDATING_POLICY" value="restart-server" />
+      <deployment>
+        <artifact name="hsdataportal:war">
+          <settings>
+            <option name="CONTEXT_PATH" value="/" />
+          </settings>
+        </artifact>
+      </deployment>
+      <server-settings>
+        <option name="BASE_DIRECTORY_NAME" value="Unnamed_hsdataportal" />
+      </server-settings>
+      <predefined_log_file id="Tomcat" enabled="true" />
+      <predefined_log_file id="Tomcat Catalina" enabled="true" />
+      <predefined_log_file id="Tomcat Manager" enabled="false" />
+      <predefined_log_file id="Tomcat Host Manager" enabled="false" />
+      <predefined_log_file id="Tomcat Localhost Access" enabled="false" />
+      <RunnerSettings RunnerId="Debug">
+        <option name="DEBUG_PORT" value="51411" />
+      </RunnerSettings>
+      <ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Cover">
+        <option name="USE_ENV_VARIABLES" value="true" />
+        <STARTUP>
+          <option name="USE_DEFAULT" value="true" />
+          <option name="SCRIPT" value="" />
+          <option name="VM_PARAMETERS" value="" />
+          <option name="PROGRAM_PARAMETERS" value="" />
+        </STARTUP>
+        <SHUTDOWN>
+          <option name="USE_DEFAULT" value="true" />
+          <option name="SCRIPT" value="" />
+          <option name="VM_PARAMETERS" value="" />
+          <option name="PROGRAM_PARAMETERS" value="" />
+        </SHUTDOWN>
+      </ConfigurationWrapper>
+      <ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Debug">
+        <option name="USE_ENV_VARIABLES" value="true" />
+        <STARTUP>
+          <option name="USE_DEFAULT" value="true" />
+          <option name="SCRIPT" value="" />
+          <option name="VM_PARAMETERS" value="" />
+          <option name="PROGRAM_PARAMETERS" value="" />
+        </STARTUP>
+        <SHUTDOWN>
+          <option name="USE_DEFAULT" value="true" />
+          <option name="SCRIPT" value="" />
+          <option name="VM_PARAMETERS" value="" />
+          <option name="PROGRAM_PARAMETERS" value="" />
+        </SHUTDOWN>
+      </ConfigurationWrapper>
+      <ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Run">
+        <option name="USE_ENV_VARIABLES" value="true" />
+        <STARTUP>
+          <option name="USE_DEFAULT" value="true" />
+          <option name="SCRIPT" value="" />
+          <option name="VM_PARAMETERS" value="" />
+          <option name="PROGRAM_PARAMETERS" value="" />
+        </STARTUP>
+        <SHUTDOWN>
+          <option name="USE_DEFAULT" value="true" />
+          <option name="SCRIPT" value="" />
+          <option name="VM_PARAMETERS" value="" />
+          <option name="PROGRAM_PARAMETERS" value="" />
+        </SHUTDOWN>
+      </ConfigurationWrapper>
+      <method>
+        <option name="BuildArtifacts" enabled="true">
+          <artifact name="hsdataportal:war" />
+        </option>
+      </method>
+    </configuration>
+  </component>
+  <component name="SbtLocalSettings">
+    <option name="projectSyncType">
+      <map>
+        <entry key="$PROJECT_DIR$/../../../../DCW/BigData/GIT/NewSparkApp-MySQL" value="PREVIEW" />
+        <entry key="$PROJECT_DIR$/../../../../DCW/大数据平台/GIT/NewSparkApp-MySQL" value="PREVIEW" />
+      </map>
+    </option>
+  </component>
+  <component name="SvnConfiguration">
+    <configuration />
+  </component>
+  <component name="TaskManager">
+    <task active="true" id="Default" summary="Default task">
+      <changelist id="5e0a6283-3bb9-4464-9eb8-7061908be2e9" name="Default" comment="" />
+      <created>1575597043903</created>
+      <option name="number" value="Default" />
+      <option name="presentableId" value="Default" />
+      <updated>1575597043903</updated>
+      <workItem from="1575597045187" duration="123000" />
+    </task>
+    <servers />
+  </component>
+  <component name="TimeTrackingManager">
+    <option name="totallyTimeSpent" value="123000" />
+  </component>
+  <component name="ToolWindowManager">
+    <frame x="0" y="0" width="1440" height="900" extended-state="0" />
+    <editor active="true" />
+    <layout>
+      <window_info anchor="right" id="Palette" />
+      <window_info anchor="bottom" id="FindBugs-IDEA" />
+      <window_info anchor="bottom" id="Event Log" side_tool="true" />
+      <window_info anchor="bottom" id="Application Servers" weight="0.32969698" />
+      <window_info anchor="right" id="Maven Projects" />
+      <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
+      <window_info id="Capture Tool" />
+      <window_info id="Designer" />
+      <window_info anchor="right" id="Database" />
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
+      <window_info id="UI Designer" />
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
+      <window_info anchor="bottom" id="TODO" order="6" />
+      <window_info anchor="bottom" id="Messages" weight="0.32969698" />
+      <window_info anchor="right" id="Palette&#9;" />
+      <window_info id="Image Layers" />
+      <window_info anchor="bottom" id="Java Enterprise" />
+      <window_info anchor="right" id="Capture Analysis" />
+      <window_info anchor="bottom" id="Run" order="2" />
+      <window_info anchor="bottom" id="Version Control" />
+      <window_info anchor="bottom" id="Spring" />
+      <window_info anchor="bottom" id="Terminal" />
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
+      <window_info anchor="right" id="Bean Validation" />
+      <window_info id="Web" side_tool="true" />
+      <window_info anchor="right" id="Theme Preview" />
+      <window_info id="Favorites" side_tool="true" />
+      <window_info anchor="bottom" id="Find" order="1" />
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
+      <window_info anchor="bottom" id="Message" order="0" />
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
+    </layout>
+  </component>
+  <component name="TypeScriptGeneratedFilesManager">
+    <option name="version" value="1" />
+  </component>
+  <component name="VcsContentAnnotationSettings">
+    <option name="myLimit" value="2678400000" />
+  </component>
+  <component name="editorHistoryManager">
+    <entry file="file://$PROJECT_DIR$/.gitignore">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="195">
+          <caret line="13" selection-start-line="13" selection-end-line="13" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/main/resources/config.properties">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="275">
+          <caret line="74" lean-forward="true" selection-start-line="74" selection-end-line="74" />
+        </state>
+      </provider>
+    </entry>
+  </component>
+  <component name="masterDetails">
+    <states>
+      <state key="ProjectJDKs.UI">
+        <settings>
+          <last-edited>1.8</last-edited>
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
+    </states>
+  </component>
+</project>

+ 577 - 0
pom.xml

@@ -0,0 +1,577 @@
+<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>com.lightinit</groupId>
+  <artifactId>hsdataportal</artifactId>
+  <packaging>war</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>HSDataPortal Maven Webapp</name>
+  <url>http://maven.apache.org</url>
+  <properties>
+    <spring.version>4.2.6.RELEASE</spring.version>
+    <mysql.version>5.1.21</mysql.version>
+    <mybatis.version>3.4.2</mybatis.version>
+    <shiro.version>1.3.2</shiro.version>
+    <druid.version>1.0.29</druid.version>
+    <axis2.version>1.7.5</axis2.version>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-core</artifactId>
+      <version>${spring.version}</version>
+    </dependency>
+    <!--modelmapper映射-->
+    <dependency>
+      <groupId>org.modelmapper</groupId>
+      <artifactId>modelmapper</artifactId>
+      <version>0.7.5</version>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-web</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-orm</artifactId>
+      <version>${spring.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-tx</artifactId>
+      <version>${spring.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>javax.servlet-api</artifactId>
+      <version>3.1.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.servlet.jsp</groupId>
+      <artifactId>jsp-api</artifactId>
+      <version>2.1</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>jstl</groupId>
+      <artifactId>jstl</artifactId>
+      <version>1.2</version>
+    </dependency>
+
+    <dependency>
+      <groupId>taglibs</groupId>
+      <artifactId>standard</artifactId>
+      <version>1.1.2</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-webmvc</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-websocket</artifactId>
+      <version>${spring.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+      <version>${mysql.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis</artifactId>
+      <version>${mybatis.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mybatis</groupId>
+      <artifactId>mybatis-spring</artifactId>
+      <version>1.3.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.codehaus.jackson</groupId>
+      <artifactId>jackson-mapper-asl</artifactId>
+      <version>1.9.12</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.codehaus.jackson</groupId>
+      <artifactId>jackson-core-asl</artifactId>
+      <version>1.9.12</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-dbcp</groupId>
+      <artifactId>commons-dbcp</artifactId>
+      <version>1.4</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-pool</groupId>
+      <artifactId>commons-pool</artifactId>
+      <version>1.5.4</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>3.2.2</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>4.5.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <version>3.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>2.4</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.shiro</groupId>
+      <artifactId>shiro-core</artifactId>
+      <version>${shiro.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.shiro</groupId>
+      <artifactId>shiro-web</artifactId>
+      <version>${shiro.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.shiro</groupId>
+      <artifactId>shiro-quartz</artifactId>
+      <version>${shiro.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.shiro</groupId>
+      <artifactId>shiro-ehcache</artifactId>
+      <version>${shiro.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.shiro</groupId>
+      <artifactId>shiro-spring</artifactId>
+      <version>${shiro.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>net.sf.ehcache</groupId>
+      <artifactId>ehcache-core</artifactId>
+      <version>2.6.11</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-core</artifactId>
+      <version>2.7.4</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>2.7.4</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-annotations</artifactId>
+      <version>2.7.4</version>
+    </dependency>
+    <!--Jaxen is a universal Java XPath engine. -->
+    <dependency>
+      <groupId>jaxen</groupId>
+      <artifactId>jaxen</artifactId>
+      <version>1.1.6</version>
+    </dependency>
+    <!--log4j-->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.7.10</version>
+    </dependency>
+
+    <!--<dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-jdk14</artifactId>
+      <version>1.7.10</version>
+    </dependency>-->
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.17</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>1.7.10</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-fileupload</groupId>
+      <artifactId>commons-fileupload</artifactId>
+      <version>1.2.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.6</version>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>com.github.penggle</groupId>
+      <artifactId>kaptcha</artifactId>
+      <version>2.3.2</version>
+    </dependency>
+
+    <dependency>
+      <groupId>redis.clients</groupId>
+      <artifactId>jedis</artifactId>
+      <version>2.9.0</version>
+      <type>jar</type>
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.data</groupId>
+      <artifactId>spring-data-mongodb</artifactId>
+      <version>1.10.1.RELEASE</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mongodb</groupId>
+      <artifactId>mongo-java-driver</artifactId>
+      <version>3.3.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-beanutils</groupId>
+      <artifactId>commons-beanutils</artifactId>
+      <version>1.9.3</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.alibaba</groupId>
+      <artifactId>druid</artifactId>
+      <version>${druid.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-configuration2</artifactId>
+      <version>2.1.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.zxing</groupId>
+      <artifactId>core</artifactId>
+      <version>3.3.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.zxing</groupId>
+      <artifactId>javase</artifactId>
+      <version>3.3.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <version>2.18.3</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-ftp</artifactId>
+      <version>2.18.3</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.thrift</groupId>
+      <artifactId>libthrift</artifactId>
+      <version>0.9.3</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>zookeeper</artifactId>
+      <version>3.3.1</version>
+    </dependency>
+   <!-- <dependency>
+      <groupId>org.bouncycastle</groupId>
+      <artifactId>bcprov-jdk16</artifactId>
+      <version>1.45</version>
+    </dependency>-->
+	<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
+	<dependency>
+    	<groupId>org.postgresql</groupId>
+    	<artifactId>postgresql</artifactId>
+    	<version>42.1.4</version>
+	</dependency>
+
+    <!-- json -->
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>2.6.2</version>
+    </dependency>
+    <!--axis2-->
+<!-- 
+    <dependency>
+      <groupId>org.apache.axis2</groupId>
+      <artifactId>axis2-adb</artifactId>
+      <version>${axis2.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.axis2</groupId>
+      <artifactId>axis2-kernel</artifactId>
+      <version>${axis2.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.axis2</groupId>
+      <artifactId>axis2-transport-http</artifactId>
+      <version>${axis2.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.axis2</groupId>
+      <artifactId>axis2-transport-local</artifactId>
+      <version>${axis2.version}</version>
+    </dependency> -->
+    <!--&lt;!&ndash; https://mvnrepository.com/artifact/org.apache.axis2/addressing &ndash;&gt;-->
+    <!--<dependency>-->
+      <!--<groupId>org.apache.axis2</groupId>-->
+      <!--<artifactId>addressing</artifactId>-->
+      <!--<version>1.7.5</version>-->
+    <!--</dependency>-->
+
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-api</artifactId>
+      <version>1.2.20</version>
+    </dependency>
+    <dependency>
+      <groupId>com.aliyun</groupId>
+      <artifactId>aliyun-java-sdk-core</artifactId>
+      <version>3.2.2</version>
+    </dependency>
+    <dependency>
+      <groupId>com.aliyun</groupId>
+      <artifactId>aliyun-java-sdk-vod</artifactId>
+      <version>2.2.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.microsoft.sqlserver</groupId>
+      <artifactId>mssql-jdbc</artifactId>
+      <version>6.2.1.jre8</version>
+    </dependency>
+	<!-- https://mvnrepository.com/artifact/org.apache.solr/solr-solrj -->
+	<!--<dependency>
+    	<groupId>org.apache.solr</groupId>
+    	<artifactId>solr-solrj</artifactId>
+    	<version>7.1.0</version>
+	</dependency>-->
+<!-- https://mvnrepository.com/artifact/org.apache.solr/solr-core -->
+<!--<dependency>
+    <groupId>org.apache.solr</groupId>
+    <artifactId>solr-core</artifactId>
+    <version>7.1.0</version>
+</dependency>-->
+
+    <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
+    <dependency>
+      <groupId>org.aspectj</groupId>
+      <artifactId>aspectjweaver</artifactId>
+      <version>1.8.12</version>
+    </dependency>
+    <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjrt -->
+    <dependency>
+      <groupId>org.aspectj</groupId>
+      <artifactId>aspectjrt</artifactId>
+      <version>1.8.12</version>
+    </dependency>
+
+    <!-- https://mvnrepository.com/artifact/org.apache.activemq/activemq-core -->
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-jms</artifactId>
+      <version>${spring.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-core</artifactId>
+      <version>5.7.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-pool</artifactId>
+      <version>5.15.2</version>
+    </dependency>
+    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
+    <dependency>
+      <groupId>org.apache.poi</groupId>
+      <artifactId>poi</artifactId>
+      <version>3.17</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.poi</groupId>
+      <artifactId>poi-ooxml</artifactId>
+      <version>3.17</version>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.validation</groupId>
+      <artifactId>validation-api</artifactId>
+      <version>1.1.0.Final</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-validator</artifactId>
+      <version>5.4.2.Final</version>
+    </dependency>
+
+    <!--支付宝jar-->
+    <dependency>
+      <groupId>com.alipay.sdk</groupId>
+      <artifactId>alipay-sdk-java</artifactId>
+      <version>3.3.87.ALL</version>
+    </dependency>
+
+    <!--阿里云sdk-->
+    <dependency>
+      <groupId>com.aliyun</groupId>
+      <artifactId>aliyun-java-sdk-core</artifactId>
+      <version>4.0.3</version>
+    </dependency>
+
+    <!--银联支付-->
+    <dependency>
+      <groupId>org.bouncycastle</groupId>
+      <artifactId>bcprov-jdk15on</artifactId>
+      <version>1.60</version>
+    </dependency>
+
+    <!--cas 单点登陆-->
+    <dependency>
+      <groupId>org.apache.shiro</groupId>
+      <artifactId>shiro-cas</artifactId>
+      <version>${shiro.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jasig.cas.client</groupId>
+      <artifactId>cas-client-core</artifactId>
+      <version>3.2.1</version>
+    </dependency>
+
+
+    <!--JSONObject-->
+    <dependency>
+      <groupId>net.sf.json-lib</groupId>
+      <artifactId>json-lib</artifactId>
+      <version>2.4</version>
+      <classifier>jdk15</classifier>
+    </dependency>
+  </dependencies>
+  <build>
+    <finalName>hsdataportal</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.mybatis.generator</groupId>
+        <artifactId>mybatis-generator-maven-plugin</artifactId>
+        <version>1.3.5</version>
+        <configuration>
+          <configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile>
+          <verbose>true</verbose>
+          <overwrite>true</overwrite>
+        </configuration>
+        <executions>
+          <execution>
+            <id>Generate MyBatis Artifacts</id>
+            <goals>
+              <goal>generate</goal>
+            </goals>
+          </execution>
+        </executions>
+        <dependencies>
+          <dependency>
+            <groupId>org.mybatis.generator</groupId>
+            <artifactId>mybatis-generator-core</artifactId>
+            <version>1.3.5</version>
+          </dependency>
+          <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>${mysql.version}</version>
+          </dependency>
+          <dependency>
+            <groupId>com.microsoft.sqlserver</groupId>
+            <artifactId>mssql-jdbc</artifactId>
+            <version>6.2.1.jre8</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+      <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>

+ 711 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/AcpService.java

@@ -0,0 +1,711 @@
+package com.lightinit.hsdataportal.Unionsdk;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @ClassName AcpService
+ * @Description acpsdk接口服务类,接入商户集成请可以直接参考使用本类中的方法
+ * @date 2016-7-22 下午2:44:37
+ * 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
+ */
+public class AcpService {
+
+	/**
+	 * 请求报文签名(使用配置文件中配置的私钥证书或者对称密钥签名)<br>
+	 * 功能:对请求报文进行签名,并计算赋值certid,signature字段并返回<br>
+	 * @param reqData 请求报文map<br>
+	 * @param encoding 上送请求报文域encoding字段的值<br>
+	 * @return 签名后的map对象<br>
+	 */
+	public static Map<String, String> sign(Map<String, String> reqData,String encoding) {
+		reqData = SDKUtil.filterBlank(reqData);
+		SDKUtil.sign(reqData, encoding);
+		return reqData;
+	}
+	
+	/**
+	 * 同signByCertInfo<br>
+	 * @param reqData
+	 * @param certPath
+	 * @param certPwd
+	 * @param encoding
+	 * @return
+	 * @deprecated
+	 */
+	public static Map<String, String> sign(Map<String, String> reqData, String certPath, 
+			String certPwd,String encoding) {
+		reqData = SDKUtil.filterBlank(reqData);
+		SDKUtil.signByCertInfo(reqData,certPath,certPwd,encoding);
+		return reqData;
+	}
+	
+	/**
+	 * 多证书签名(通过传入私钥证书路径和密码签名)<br>
+	 * 功能:如果有多个商户号接入银联,每个商户号对应不同的证书可以使用此方法:传入私钥证书和密码(并且在acp_sdk.properties中 配置 acpsdk.singleMode=false)<br>
+	 * @param reqData 请求报文map<br>
+	 * @param certPath 签名私钥文件(带路径)<br>
+	 * @param certPwd 签名私钥密码<br>
+	 * @param encoding 上送请求报文域encoding字段的值<br>
+	 * @return 签名后的map对象<br>
+	 */
+	public static Map<String, String> signByCertInfo(Map<String, String> reqData, String certPath, 
+			String certPwd,String encoding) {
+		reqData = SDKUtil.filterBlank(reqData);
+		SDKUtil.signByCertInfo(reqData,certPath,certPwd,encoding);
+		return reqData;
+	}
+	
+	/**
+	 * 多密钥签名(通过传入密钥签名)<br>
+	 * 功能:如果有多个商户号接入银联,每个商户号对应不同的证书可以使用此方法:传入私钥证书和密码(并且在acp_sdk.properties中 配置 acpsdk.singleMode=false)<br>
+	 * @param reqData 请求报文map<br>
+	 * @param secureKey 签名对称密钥<br>
+	 * @param encoding 上送请求报文域encoding字段的值<br>
+	 * @return 签名后的map对象<br>
+	 */
+	public static Map<String, String> signBySecureKey(Map<String, String> reqData, String secureKey, String encoding) {
+		reqData = SDKUtil.filterBlank(reqData);
+		SDKUtil.signBySecureKey(reqData, secureKey, encoding);
+		return reqData;
+	}
+	
+	/**
+	 * 验证签名(SHA-1摘要算法)<br>
+	 * @param rspData 返回报文数据<br>
+	 * @param encoding 上送请求报文域encoding字段的值<br>
+	 * @return true 通过 false 未通过<br>
+	 */
+	public static boolean validate(Map<String, String> rspData, String encoding) {
+		return SDKUtil.validate(rspData, encoding);
+	}
+	
+	/**
+	 * 多密钥验签(通过传入密钥签名)<br>
+	 * @param rspData 返回报文数据<br>
+	 * @param encoding 上送请求报文域encoding字段的值<br>
+	 * @return true 通过 false 未通过<br>
+	 */
+	public static boolean validateBySecureKey(Map<String, String> rspData, String secureKey, String encoding) {
+		return SDKUtil.validateBySecureKey(rspData, secureKey, encoding);
+	}
+	
+
+	/**
+	 * @deprecated 5.1.0开发包已删除此方法,请直接参考5.1.0开发包中的VerifyAppData.java验签。
+	 * 对控件支付成功返回的结果信息中data域进行验签(控件端获取的应答信息)<br>
+	 * @param jsonData json格式数据,例如:{"sign" : "J6rPLClQ64szrdXCOtV1ccOMzUmpiOKllp9cseBuRqJ71pBKPPkZ1FallzW18gyP7CvKh1RxfNNJ66AyXNMFJi1OSOsteAAFjF5GZp0Xsfm3LeHaN3j/N7p86k3B1GrSPvSnSw1LqnYuIBmebBkC1OD0Qi7qaYUJosyA1E8Ld8oGRZT5RR2gLGBoiAVraDiz9sci5zwQcLtmfpT5KFk/eTy4+W9SsC0M/2sVj43R9ePENlEvF8UpmZBqakyg5FO8+JMBz3kZ4fwnutI5pWPdYIWdVrloBpOa+N4pzhVRKD4eWJ0CoiD+joMS7+C0aPIEymYFLBNYQCjM0KV7N726LA==",  "data" : "pay_result=success&tn=201602141008032671528&cert_id=68759585097"}
+	 * @return 是否成功
+	 */
+	public static boolean validateAppResponse(String jsonData, String encoding) {
+		LogUtil.writeLog("控件应答信息验签处理开始:[" + jsonData + "]");
+		if (SDKUtil.isEmpty(encoding)) {
+			encoding = "UTF-8";
+		}
+
+        Pattern p = Pattern.compile("\\s*\"sign\"\\s*:\\s*\"([^\"]*)\"\\s*");
+		Matcher m = p.matcher(jsonData);
+		if(!m.find()) return false;
+		String sign = m.group(1);
+
+		p = Pattern.compile("\\s*\"data\"\\s*:\\s*\"([^\"]*)\"\\s*");
+		m = p.matcher(jsonData);
+		if(!m.find()) return false;
+		String data = m.group(1);
+
+		p = Pattern.compile("cert_id=(\\d*)");
+		m = p.matcher(jsonData);
+		if(!m.find()) return false;
+		String certId = m.group(1);
+
+		try {
+			// 验证签名需要用银联发给商户的公钥证书.
+			return SecureUtil.validateSignBySoft(CertUtil
+					.getValidatePublicKey(certId), SecureUtil.base64Decode(sign
+					.getBytes(encoding)), SecureUtil.sha1X16(data,
+					encoding));
+		} catch (UnsupportedEncodingException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		} catch (Exception e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		}
+		return false;
+	}
+	
+	/**
+	 * 功能:后台交易提交请求报文并接收同步应答报文<br>
+	 * @param reqData 请求报文<br>
+	 * @param reqUrl  请求地址<br>
+	 * @param encoding<br>
+	 * @return 应答http 200返回true ,其他false<br>
+	 */
+	public static Map<String,String> post(
+			Map<String, String> reqData,String reqUrl,String encoding) {
+		Map<String, String> rspData = new HashMap<String,String>();
+		LogUtil.writeLog("请求银联地址:" + reqUrl);
+		//发送后台请求数据
+		HttpClient hc = new HttpClient(reqUrl, 30000, 30000);//连接超时时间,读超时时间(可自行判断,修改)
+		try {
+			int status = hc.send(reqData, encoding);
+			if (200 == status) {
+				String resultString = hc.getResult();
+				if (null != resultString && !"".equals(resultString)) {
+					// 将返回结果转换为map
+					Map<String,String> tmpRspData  = SDKUtil.convertResultStringToMap(resultString);
+					rspData.putAll(tmpRspData);
+				}
+			}else{
+				LogUtil.writeLog("返回http状态码["+status+"],请检查请求报文或者请求地址是否正确");
+			}
+		} catch (Exception e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		}
+		return rspData;
+	}
+	
+	/**
+	 * 功能:http Get方法 便民缴费产品中使用<br>
+	 * @param reqUrl 请求地址<br>
+	 * @param encoding<br>
+	 * @return
+	 */
+	public static String get(String reqUrl,String encoding) {
+		
+		LogUtil.writeLog("请求银联地址:" + reqUrl);
+		//发送后台请求数据
+		HttpClient hc = new HttpClient(reqUrl, 30000, 30000);
+		try {
+			int status = hc.sendGet(encoding);
+			if (200 == status) {
+				String resultString = hc.getResult();
+				if (null != resultString && !"".equals(resultString)) {
+					return resultString;
+				}
+			}else{
+				LogUtil.writeLog("返回http状态码["+status+"],请检查请求报文或者请求地址是否正确");
+			}
+		} catch (Exception e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		}
+		return null;
+	}
+	
+	
+	/**
+	 * 功能:前台交易构造HTTP POST自动提交表单<br>
+	 * @param hiddens 以MAP形式存储的表单键值<br>
+	 * @param encoding 上送请求报文域encoding字段的值<br>
+	 * @return 构造好的HTTP POST交易表单<br>
+	 */
+	public static String createAutoFormHtml(String reqUrl, Map<String, String> hiddens,String encoding) {
+		StringBuffer sf = new StringBuffer();
+		sf.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset="+encoding+"\"/></head><body>");
+		sf.append("<form id = \"pay_form\" action=\"" + reqUrl
+				+ "\" method=\"post\">");
+		if (null != hiddens && 0 != hiddens.size()) {
+			Set<Entry<String, String>> set = hiddens.entrySet();
+			Iterator<Entry<String, String>> it = set.iterator();
+			while (it.hasNext()) {
+				Entry<String, String> ey = it.next();
+				String key = ey.getKey();
+				String value = ey.getValue();
+				sf.append("<input type=\"hidden\" name=\"" + key + "\" id=\""
+						+ key + "\" value=\"" + value + "\"/>");
+			}
+		}
+		sf.append("</form>");
+		sf.append("</body>");
+		sf.append("<script type=\"text/javascript\">");
+		sf.append("document.all.pay_form.submit();");
+		sf.append("</script>");
+		sf.append("</html>");
+		return sf.toString();
+	}
+
+	
+	/**
+	 * 功能:将批量文件内容使用DEFLATE压缩算法压缩,Base64编码生成字符串并返回<br>
+	 * 适用到的交易:批量代付,批量代收,批量退货<br>
+	 * @param filePath 批量文件-全路径文件名<br>
+	 * @return
+	 */
+	public static String enCodeFileContent(String filePath,String encoding){
+		String baseFileContent = "";
+		
+		File file = new File(filePath);
+		if (!file.exists()) {
+			try {
+				file.createNewFile();
+			} catch (IOException e) {
+				LogUtil.writeErrorLog(e.getMessage(), e);
+			}
+		}
+		InputStream in = null;
+		try {
+			in = new FileInputStream(file);
+			int fl = in.available();
+			if (null != in) {
+				byte[] s = new byte[fl];
+				in.read(s, 0, fl);
+				// 压缩编码.
+				baseFileContent = new String(SecureUtil.base64Encode(SDKUtil.deflater(s)),encoding);
+			}
+		} catch (Exception e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		} finally {
+			if (null != in) {
+				try {
+					in.close();
+				} catch (IOException e) {
+					LogUtil.writeErrorLog(e.getMessage(), e);
+				}
+			}
+		}
+		return baseFileContent;
+	}
+	
+	/**
+	 * 功能:解析交易返回的fileContent字符串并落地 ( 解base64,解DEFLATE压缩并落地)<br>
+	 * 适用到的交易:对账文件下载,批量交易状态查询<br>
+	 * @param resData 返回报文map<br>
+	 * @param fileDirectory 落地的文件目录(绝对路径)
+	 * @param encoding 上送请求报文域encoding字段的值<br>	
+	 */
+	public static String deCodeFileContent(Map<String, String> resData,String fileDirectory,String encoding) {
+		// 解析返回文件
+		String filePath = null;
+		String fileContent = resData.get(SDKConstants.param_fileContent);
+		if (null != fileContent && !"".equals(fileContent)) {
+			FileOutputStream out = null;
+			try {
+				byte[] fileArray = SDKUtil.inflater(SecureUtil
+						.base64Decode(fileContent.getBytes(encoding)));
+				if (SDKUtil.isEmpty(resData.get("fileName"))) {
+					filePath = fileDirectory + File.separator + resData.get("merId")
+							+ "_" + resData.get("batchNo") + "_"
+							+ resData.get("txnTime") + ".txt";
+				} else {
+					filePath = fileDirectory + File.separator + resData.get("fileName");
+				}
+				File file = new File(filePath);
+				if (file.exists()) {
+					file.delete();
+				}
+				file.createNewFile();
+			    out = new FileOutputStream(file);
+				out.write(fileArray, 0, fileArray.length);
+				out.flush();
+			} catch (UnsupportedEncodingException e) {
+				LogUtil.writeErrorLog(e.getMessage(), e);
+			} catch (IOException e) {
+				LogUtil.writeErrorLog(e.getMessage(), e);
+			}finally{
+				try {
+					out.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		return filePath;
+	}
+
+	/**
+	 * 功能:将结果文件内容 转换成明文字符串:解base64,解压缩<br>
+	 * 适用到的交易:批量交易状态查询<br>
+	 * @param fileContent 批量交易状态查询返回的文件内容<br>
+	 * @return 内容明文<br>
+	 */
+	public static String getFileContent(String fileContent,String encoding){
+		String fc = "";
+		try {
+			fc = new String(SDKUtil.inflater(SecureUtil.base64Decode(fileContent.getBytes())),encoding);
+		} catch (UnsupportedEncodingException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		} catch (IOException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		}
+		return fc;
+	}
+	
+	
+	/**
+	 * 功能:持卡人信息域customerInfo构造<br>
+	 * 说明:不勾选对敏感信息加密权限使用旧的构造customerInfo域方式,不对敏感信息进行加密(对 phoneNo,cvn2, expired不加密),但如果送pin的话则加密<br>
+	 * @param customerInfoMap 信息域请求参数 key送域名value送值,必送<br>
+	 *        例如:customerInfoMap.put("certifTp", "01");					//证件类型<br>
+				  customerInfoMap.put("certifId", "341126197709218366");	//证件号码<br>
+				  customerInfoMap.put("customerNm", "互联网");				//姓名<br>
+				  customerInfoMap.put("phoneNo", "13552535506");			//手机号<br>
+				  customerInfoMap.put("smsCode", "123456");					//短信验证码<br>
+				  customerInfoMap.put("pin", "111111");						//密码(加密)<br>
+				  customerInfoMap.put("cvn2", "123");           			//卡背面的cvn2三位数字(不加密)<br>
+				  customerInfoMap.put("expired", "1711");  				    //有效期 年在前月在后(不加密)<br>
+	 * @param accNo  customerInfoMap送了密码那么卡号必送,如果customerInfoMap未送密码pin,此字段可以不送<br>
+	 * @param encoding 上送请求报文域encoding字段的值<br>				  
+	 * @return base64后的持卡人信息域字段<br>
+	 */
+	public static String getCustomerInfo(Map<String,String> customerInfoMap,String accNo,String encoding) {
+		
+		if(customerInfoMap.isEmpty())
+			return "{}";
+		StringBuffer sf = new StringBuffer("{");
+		for(Iterator<String> it = customerInfoMap.keySet().iterator(); it.hasNext();){
+			String key = it.next();
+			String value = customerInfoMap.get(key);
+			if(key.equals("pin")){
+				if(null == accNo || "".equals(accNo.trim())){
+					LogUtil.writeLog("送了密码(PIN),必须在getCustomerInfo参数中上传卡号");
+					throw new RuntimeException("加密PIN没送卡号无法后续处理");
+				}else{
+					value = encryptPin(accNo,value,encoding);
+				}
+			}
+			sf.append(key).append(SDKConstants.EQUAL).append(value);
+			if(it.hasNext())
+				sf.append(SDKConstants.AMPERSAND);
+		}
+		String customerInfo = sf.append("}").toString();
+		LogUtil.writeLog("组装的customerInfo明文:"+customerInfo);
+		try {
+			return new String(SecureUtil.base64Encode(sf.toString().getBytes(
+					encoding)),encoding);
+		} catch (UnsupportedEncodingException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		} catch (IOException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		}
+		return customerInfo;
+	}
+	
+	/**
+	 * 功能:持卡人信息域customerInfo构造,勾选对敏感信息加密权限 适用新加密规范,对pin和phoneNo,cvn2,expired加密 <br>
+	 * 适用到的交易: <br>
+	 * @param customerInfoMap 信息域请求参数 key送域名value送值,必送 <br>
+	 *        例如:customerInfoMap.put("certifTp", "01");					//证件类型 <br>
+				  customerInfoMap.put("certifId", "341126197709218366");	//证件号码 <br>
+				  customerInfoMap.put("customerNm", "互联网");				//姓名 <br>
+				  customerInfoMap.put("smsCode", "123456");					//短信验证码 <br>
+				  customerInfoMap.put("pin", "111111");						//密码(加密) <br>
+				  customerInfoMap.put("phoneNo", "13552535506");			//手机号(加密) <br>
+				  customerInfoMap.put("cvn2", "123");           			//卡背面的cvn2三位数字(加密) <br>
+				  customerInfoMap.put("expired", "1711");  				    //有效期 年在前月在后(加密) <br>
+	 * @param accNo  customerInfoMap送了密码那么卡号必送,如果customerInfoMap未送密码PIN,此字段可以不送<br>
+	 * @param encoding 上送请求报文域encoding字段的值
+	 * @return base64后的持卡人信息域字段 <br>
+	 */
+	public static String getCustomerInfoWithEncrypt(Map<String,String> customerInfoMap,String accNo,String encoding) {
+		if(customerInfoMap.isEmpty())
+			return "{}";
+		StringBuffer sf = new StringBuffer("{");
+		//敏感信息加密域
+		StringBuffer encryptedInfoSb = new StringBuffer("");
+		
+		for(Iterator<String> it = customerInfoMap.keySet().iterator(); it.hasNext();){
+			String key = it.next();
+			String value = customerInfoMap.get(key);
+			if(key.equals("phoneNo") || key.equals("cvn2") || key.equals("expired")){
+				encryptedInfoSb.append(key).append(SDKConstants.EQUAL).append(value).append(SDKConstants.AMPERSAND);
+			}else{
+				if(key.equals("pin")){
+					if(null == accNo || "".equals(accNo.trim())){
+						LogUtil.writeLog("送了密码(PIN),必须在getCustomerInfoWithEncrypt参数中上传卡号");
+						throw new RuntimeException("加密PIN没送卡号无法后续处理");
+					}else{
+						value = encryptPin(accNo,value,encoding);
+					}
+				}
+				sf.append(key).append(SDKConstants.EQUAL).append(value).append(SDKConstants.AMPERSAND);
+			}
+		}
+		
+		if(!encryptedInfoSb.toString().equals("")){
+			encryptedInfoSb.setLength(encryptedInfoSb.length()-1);//去掉最后一个&符号
+			LogUtil.writeLog("组装的customerInfo encryptedInfo明文:"+ encryptedInfoSb.toString());
+			sf.append("encryptedInfo").append(SDKConstants.EQUAL).append(encryptData(encryptedInfoSb.toString(), encoding));
+		}else{
+			sf.setLength(sf.length()-1);
+		}
+		
+		String customerInfo = sf.append("}").toString();
+		LogUtil.writeLog("组装的customerInfo明文:"+customerInfo);
+		try {
+			return new String(SecureUtil.base64Encode(sf.toString().getBytes(encoding)),encoding);
+		} catch (UnsupportedEncodingException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		} catch (IOException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		}
+		return customerInfo;
+	}
+	
+	/**
+	 * 解析返回报文(后台通知)中的customerInfo域:<br>
+	 * 解base64,如果带敏感信息加密 encryptedInfo 则将其解密并将 encryptedInfo中的域放到customerInfoMap返回<br>
+	 * @param customerInfo<br>
+	 * @param encoding<br>
+	 * @return
+	 */
+	public static Map<String,String> parseCustomerInfo(String customerInfo,String encoding){
+		Map<String,String> customerInfoMap = null;
+		try {
+				byte[] b = SecureUtil.base64Decode(customerInfo.getBytes(encoding));
+				String customerInfoNoBase64 = new String(b,encoding);
+				LogUtil.writeLog("解base64后===>" +customerInfoNoBase64);
+				//去掉前后的{}
+				customerInfoNoBase64 = customerInfoNoBase64.substring(1, customerInfoNoBase64.length()-1);
+				customerInfoMap = SDKUtil.parseQString(customerInfoNoBase64);
+				if(customerInfoMap.containsKey("encryptedInfo")){
+					String encInfoStr = customerInfoMap.get("encryptedInfo");
+					customerInfoMap.remove("encryptedInfo");
+					String encryptedInfoStr = decryptData(encInfoStr, encoding);
+					Map<String,String> encryptedInfoMap = SDKUtil.parseQString(encryptedInfoStr);
+					customerInfoMap.putAll(encryptedInfoMap);
+				}
+			} catch (UnsupportedEncodingException e) {
+				LogUtil.writeErrorLog(e.getMessage(), e);
+			} catch (IOException e) {
+				LogUtil.writeErrorLog(e.getMessage(), e);
+			}
+		return customerInfoMap;
+	}
+	
+	/**
+	 * 解析返回报文(后台通知)中的customerInfo域:<br>
+	 * 解base64,如果带敏感信息加密 encryptedInfo 则将其解密并将 encryptedInfo中的域放到customerInfoMap返回<br>
+	 * @param customerInfo<br>
+	 * @param encoding<br>
+	 * @return
+	 */
+	public static Map<String,String> parseCustomerInfo(String customerInfo, String certPath, 
+			String certPwd, String encoding){
+		Map<String,String> customerInfoMap = null;
+		try {
+				byte[] b = SecureUtil.base64Decode(customerInfo.getBytes(encoding));
+				String customerInfoNoBase64 = new String(b,encoding);
+				LogUtil.writeLog("解base64后===>" +customerInfoNoBase64);
+				//去掉前后的{}
+				customerInfoNoBase64 = customerInfoNoBase64.substring(1, customerInfoNoBase64.length()-1);
+				customerInfoMap = SDKUtil.parseQString(customerInfoNoBase64);
+				if(customerInfoMap.containsKey("encryptedInfo")){
+					String encInfoStr = customerInfoMap.get("encryptedInfo");
+					customerInfoMap.remove("encryptedInfo");
+					String encryptedInfoStr = decryptData(encInfoStr, certPath, certPwd, encoding);
+					Map<String,String> encryptedInfoMap = SDKUtil.parseQString(encryptedInfoStr);
+					customerInfoMap.putAll(encryptedInfoMap);
+				}
+			} catch (UnsupportedEncodingException e) {
+				LogUtil.writeErrorLog(e.getMessage(), e);
+			} catch (IOException e) {
+				LogUtil.writeErrorLog(e.getMessage(), e);
+			}
+		return customerInfoMap;
+	}
+
+	/**
+	 * 密码加密并做base64<br>
+	 * @param accNo 卡号<br>
+	 * @param encoding<br>
+	 * @return 加密的内容<br>
+	 */
+	public static String encryptPin(String accNo, String pin, String encoding) {
+		return SecureUtil.encryptPin(accNo, pin, encoding, CertUtil
+				.getEncryptCertPublicKey());
+	}
+	
+	/**
+	 * 敏感信息加密并做base64(卡号,手机号,cvn2,有效期)<br>
+	 * @param data 送 phoneNo,cvn2,有效期<br>
+	 * @param encoding<br>
+	 * @return 加密的密文<br>
+	 */
+	public static String encryptData(String data, String encoding) {
+		return SecureUtil.encryptData(data, encoding, CertUtil
+				.getEncryptCertPublicKey());
+	}
+	
+	/**
+	 * 敏感信息解密,使用配置文件acp_sdk.properties解密<br>
+	 * @param base64EncryptedInfo 加密信息<br>
+	 * @param encoding<br>
+	 * @return 解密后的明文<br>
+	 */
+	public static String decryptData(String base64EncryptedInfo, String encoding) {
+		return SecureUtil.decryptData(base64EncryptedInfo, encoding, CertUtil
+				.getSignCertPrivateKey());
+	}
+	
+	/**
+	 * 敏感信息解密,通过传入的私钥解密<br>
+	 * @param base64EncryptedInfo 加密信息<br>
+	 * @param certPath 私钥文件(带全路径)<br>
+	 * @param certPwd 私钥密码<br>
+	 * @param encoding<br>
+	 * @return
+	 */
+	public static String decryptData(String base64EncryptedInfo, String certPath, 
+			String certPwd, String encoding) {
+		return SecureUtil.decryptData(base64EncryptedInfo, encoding, CertUtil
+				.getSignCertPrivateKeyByStoreMap(certPath, certPwd));
+	}
+
+	/**
+	 * 5.0.0加密磁道信息,5.1.0接口请勿使用<br>
+	 * @param trackData 待加密磁道数据<br>
+	 * @param encoding 编码格式<br>
+	 * @return 加密的密文<br>
+	 * @deprecated
+	 */
+	public static String encryptTrack(String trackData, String encoding) {
+		return SecureUtil.encryptData(trackData, encoding,
+				CertUtil.getEncryptTrackPublicKey());
+	}
+	
+	/**
+	 * 获取敏感信息加密证书的物理序列号<br>
+	 * @return
+	 */
+	public static String getEncryptCertId(){
+		return CertUtil.getEncryptCertId();
+	}
+	
+	/**
+	 * 对字符串做base64<br>
+	 * @param rawStr<br>
+	 * @param encoding<br>
+	 * @return<br>
+	 * @throws IOException
+	 */
+	public static String base64Encode(String rawStr,String encoding) throws IOException{
+		byte [] rawByte = rawStr.getBytes(encoding);
+		return new String(SecureUtil.base64Encode(rawByte),encoding);
+	}
+	/**
+	 * 对base64的字符串解base64<br>
+	 * @param base64Str<br>
+	 * @param encoding<br>
+	 * @return<br>
+	 * @throws IOException
+	 */
+	public static String base64Decode(String base64Str,String encoding) throws IOException{
+		byte [] rawByte = base64Str.getBytes(encoding);
+		return new String(SecureUtil.base64Decode(rawByte),encoding);	
+	}
+
+
+	/**
+	 * 
+	 * 有卡交易信息域(cardTransData)构造<br>
+	 * 所有子域需用“{}”包含,子域间以“&”符号链接。格式如下:{子域名1=值&子域名2=值&子域名3=值}<br>
+	 * 说明:本示例仅供参考,开发时请根据接口文档中的报文要素组装<br>
+	 * 
+	 * @param cardTransDataMap cardTransData的数据<br>
+	 * @param requestData 必须包含merId、orderId、txnTime、txnAmt,磁道加密时需要使用<br>
+	 * @param encoding 编码<br>
+	 * @return
+	 */
+	public static String getCardTransData(Map<String, String> cardTransDataMap, 
+			Map<String, String> requestData,
+			String encoding) { {
+
+		StringBuffer cardTransDataBuffer = new StringBuffer();
+		
+		if(cardTransDataMap.containsKey("track2Data")){
+			StringBuffer track2Buffer = new StringBuffer();
+			track2Buffer.append(requestData.get("merId"))
+					.append(SDKConstants.COLON).append(requestData.get("orderId"))
+					.append(SDKConstants.COLON).append(requestData.get("txnTime"))
+					.append(SDKConstants.COLON).append(requestData.get("txnAmt")==null?0:requestData.get("txnAmt"))
+					.append(SDKConstants.COLON).append(cardTransDataMap.get("track2Data"));
+			cardTransDataMap.put("track2Data", 
+					AcpService.encryptData(track2Buffer.toString(),	encoding));
+		}
+		
+		if(cardTransDataMap.containsKey("track3Data")){
+			StringBuffer track3Buffer = new StringBuffer();
+			track3Buffer.append(requestData.get("merId"))
+				.append(SDKConstants.COLON).append(requestData.get("orderId"))
+				.append(SDKConstants.COLON).append(requestData.get("txnTime"))
+				.append(SDKConstants.COLON).append(requestData.get("txnAmt")==null?0:requestData.get("txnAmt"))
+				.append(SDKConstants.COLON).append(cardTransDataMap.get("track3Data"));
+			cardTransDataMap.put("track3Data", 
+					AcpService.encryptData(track3Buffer.toString(),	encoding));
+		}
+
+		return cardTransDataBuffer.append(SDKConstants.LEFT_BRACE)
+				.append(SDKUtil.coverMap2String(cardTransDataMap))
+				.append(SDKConstants.RIGHT_BRACE).toString();
+		}
+	
+	}
+	
+	/**
+	 * 获取应答报文中的加密公钥证书,并存储到本地,备份原始证书,并自动替换证书<br>
+	 * 更新成功则返回1,无更新返回0,失败异常返回-1<br>
+	 * @param resData 返回报文
+	 * @param encoding
+	 * @return
+	 */
+	public static int updateEncryptCert(Map<String, String> resData,
+			String encoding) {
+		return SDKUtil.getEncryptCert(resData, encoding);
+	}
+	
+	/**
+	 * 获取
+	 * @param number
+	 * @return
+	 */
+	public static int genLuhn(String number){
+		return SecureUtil.genLuhn(number);
+	}
+
+	
+//	/**
+//	 * 功能:对图片进行base64编码(综合认证平台使用)<br>
+//	 * @param filePath 批量文件-全路径文件名<br>
+//	 * @return
+//	 */
+//	public static String enImgContent(String filePath,String encoding){
+//		String imgFileContent = "";
+//		
+//		File file = new File(filePath);
+//		if (!file.exists()) {
+//			LogUtil.writeErrorLog("文件不存在");
+//			return "";
+//		}
+//		InputStream in = null;
+//		try {
+//			in = new FileInputStream(file);
+//			int fl = in.available();
+//			if (null != in) {
+//				byte[] s = new byte[fl];
+//				in.read(s, 0, fl);
+//				// 压缩编码.
+//				imgFileContent = new String(SecureUtil.base64Encode(s),encoding);
+//			}
+//		} catch (Exception e) {
+//			LogUtil.writeErrorLog(e.getMessage(), e);
+//		} finally {
+//			if (null != in) {
+//				try {
+//					in.close();
+//				} catch (IOException e) {
+//					LogUtil.writeErrorLog(e.getMessage(), e);
+//				}
+//			}
+//		}
+//		return imgFileContent;
+//	}
+}

+ 125 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/BaseHttpSSLSocketFactory.java

@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed Property to China UnionPay Co., Ltd.
+ * 
+ * (C) Copyright of China UnionPay Co., Ltd. 2010
+ *     All Rights Reserved.
+ *
+ * 
+ * Modification History:
+ * =============================================================================
+ *   Author         Date          Description
+ *   ------------ ---------- ---------------------------------------------------
+ *   xshu       2014-05-28     SSLSocket 链接工具类(用于https)
+ * =============================================================================
+ */
+package com.lightinit.hsdataportal.Unionsdk;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+/**
+ * 
+ * @ClassName BaseHttpSSLSocketFactory
+ * @Description 忽略验证ssl证书
+ * @date 2016-7-22 下午4:10:14
+ * 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
+ */
+public class BaseHttpSSLSocketFactory extends SSLSocketFactory {
+	private SSLContext getSSLContext() {
+		return createEasySSLContext();
+	}
+
+	@Override
+	public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2,
+			int arg3) throws IOException {
+		return getSSLContext().getSocketFactory().createSocket(arg0, arg1,
+				arg2, arg3);
+	}
+
+	@Override
+	public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3)
+			throws IOException, UnknownHostException {
+		return getSSLContext().getSocketFactory().createSocket(arg0, arg1,
+				arg2, arg3);
+	}
+
+	@Override
+	public Socket createSocket(InetAddress arg0, int arg1) throws IOException {
+		return getSSLContext().getSocketFactory().createSocket(arg0, arg1);
+	}
+
+	@Override
+	public Socket createSocket(String arg0, int arg1) throws IOException,
+			UnknownHostException {
+		return getSSLContext().getSocketFactory().createSocket(arg0, arg1);
+	}
+
+	@Override
+	public String[] getSupportedCipherSuites() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String[] getDefaultCipherSuites() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Socket createSocket(Socket arg0, String arg1, int arg2, boolean arg3)
+			throws IOException {
+		return getSSLContext().getSocketFactory().createSocket(arg0, arg1,
+				arg2, arg3);
+	}
+
+	private SSLContext createEasySSLContext() {
+		try {
+			SSLContext context = SSLContext.getInstance("SSL");
+			context.init(null,
+					new TrustManager[] { MyX509TrustManager.manger }, null);
+			return context;
+		} catch (Exception e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+			return null;
+		}
+	}
+
+	public static class MyX509TrustManager implements X509TrustManager {
+
+		static MyX509TrustManager manger = new MyX509TrustManager();
+
+		public MyX509TrustManager() {
+		}
+
+		public X509Certificate[] getAcceptedIssuers() {
+			return null;
+		}
+
+		public void checkClientTrusted(X509Certificate[] chain, String authType) {
+		}
+
+		public void checkServerTrusted(X509Certificate[] chain, String authType) {
+		}
+	}
+
+	/**
+	 * 解决由于服务器证书问题导致HTTPS无法访问的情况 PS:HTTPS hostname wrong: should be <localhost>
+	 */
+	public static class TrustAnyHostnameVerifier implements HostnameVerifier {
+		public boolean verify(String hostname, SSLSession session) {
+			//直接返回true
+			return true;
+		}
+	}
+}

+ 789 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/CertUtil.java

@@ -0,0 +1,789 @@
+/**
+ *
+ * Licensed Property to China UnionPay Co., Ltd.
+ * 
+ * (C) Copyright of China UnionPay Co., Ltd. 2010
+ *     All Rights Reserved.
+ *
+ * 
+ * Modification History:
+ * =============================================================================
+ *   Author         Date          Description
+ *   ------------ ---------- ---------------------------------------------------
+ *   xshu       2014-05-28       证书工具类.
+ * =============================================================================
+ */
+package com.lightinit.hsdataportal.Unionsdk;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.security.KeyFactory;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.security.Security;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertPathBuilder;
+import java.security.cert.CertStore;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.PKIXCertPathBuilderResult;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509CertSelector;
+import java.security.cert.X509Certificate;
+import java.security.spec.RSAPublicKeySpec;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.UNIONPAY_CNNAME;
+import static com.lightinit.hsdataportal.Unionsdk.SDKUtil.isEmpty;
+/**
+ * @ClassName: CertUtil
+ * @Description: acpsdk证书工具类,主要用于对证书的加载和使用
+ * @date 2016-7-22 下午2:46:20
+ * 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
+ */
+public class CertUtil {
+	/** 证书容器,存储对商户请求报文签名私钥证书. */
+	private static KeyStore keyStore = null;
+	/** 敏感信息加密公钥证书 */
+	private static X509Certificate encryptCert = null;
+	/** 磁道加密公钥 */
+	private static PublicKey encryptTrackKey = null;
+	/** 验证银联返回报文签名证书. */
+	private static X509Certificate validateCert = null;
+	/** 验签中级证书 */
+	private static X509Certificate middleCert = null;
+	/** 验签根证书 */
+	private static X509Certificate rootCert = null;
+	/** 验证银联返回报文签名的公钥证书存储Map. */
+	private static Map<String, X509Certificate> certMap = new HashMap<String, X509Certificate>();
+	/** 商户私钥存储Map */
+	private final static Map<String, KeyStore> keyStoreMap = new ConcurrentHashMap<String, KeyStore>();
+	
+	static {
+		init();
+	}
+	
+	/**
+	 * 初始化所有证书.
+	 */
+	private static void init() {
+		try {
+			addProvider();//向系统添加BC provider
+			initSignCert();//初始化签名私钥证书
+			initMiddleCert();//初始化验签证书的中级证书
+			initRootCert();//初始化验签证书的根证书
+			initEncryptCert();//初始化加密公钥
+			initTrackKey();//构建磁道加密公钥
+			initValidateCertFromDir();//初始化所有的验签证书
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("init失败。(如果是用对称密钥签名的可无视此异常。)", e);
+		}
+	}
+	
+	/**
+	 * 添加签名,验签,加密算法提供者
+	 */
+	private static void addProvider(){
+		if (Security.getProvider("BC") == null) {
+			LogUtil.writeLog("add BC provider");
+			Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
+		} else {
+			Security.removeProvider("BC"); //解决eclipse调试时tomcat自动重新加载时,BC存在不明原因异常的问题。
+			Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
+			LogUtil.writeLog("re-add BC provider");
+		}
+		printSysInfo();
+	}
+	
+	/**
+	 * 用配置文件acp_sdk.properties中配置的私钥路径和密码 加载签名证书
+	 */
+	private static void initSignCert() {
+		if(!"01".equals(SDKConfig.getConfig().getSignMethod())){
+			LogUtil.writeLog("非rsa签名方式,不加载签名证书。");
+			return;
+		}
+		if (SDKConfig.getConfig().getSignCertPath() == null 
+				|| SDKConfig.getConfig().getSignCertPwd() == null
+				|| SDKConfig.getConfig().getSignCertType() == null) {
+			LogUtil.writeErrorLog("WARN: " + SDKConfig.SDK_SIGNCERT_PATH + "或" + SDKConfig.SDK_SIGNCERT_PWD 
+					+ "或" + SDKConfig.SDK_SIGNCERT_TYPE + "为空。 停止加载签名证书。");
+			return;
+		}
+		if (null != keyStore) {
+			keyStore = null;
+		}
+		try {
+			keyStore = getKeyInfo(SDKConfig.getConfig().getSignCertPath(),
+					SDKConfig.getConfig().getSignCertPwd(), SDKConfig
+							.getConfig().getSignCertType());
+			LogUtil.writeLog("InitSignCert Successful. CertId=["
+					+ getSignCertId() + "]");
+		} catch (IOException e) {
+			LogUtil.writeErrorLog("InitSignCert Error", e);
+		}
+	}
+
+	/**
+	 * 用配置文件acp_sdk.properties配置路径 加载敏感信息加密证书
+	 */
+	private static void initMiddleCert() {
+		LogUtil.writeLog("加载中级证书==>"+SDKConfig.getConfig().getMiddleCertPath());
+		if (!isEmpty(SDKConfig.getConfig().getMiddleCertPath())) {
+			middleCert = initCert(SDKConfig.getConfig().getMiddleCertPath());
+			LogUtil.writeLog("Load MiddleCert Successful");
+		} else {
+			LogUtil.writeLog("WARN: acpsdk.middle.path is empty");
+		}
+	}
+
+	/**
+	 * 用配置文件acp_sdk.properties配置路径 加载敏感信息加密证书
+	 */
+	private static void initRootCert() {
+		LogUtil.writeLog("加载根证书==>"+SDKConfig.getConfig().getRootCertPath());
+		if (!isEmpty(SDKConfig.getConfig().getRootCertPath())) {
+			rootCert = initCert(SDKConfig.getConfig().getRootCertPath());
+			LogUtil.writeLog("Load RootCert Successful");
+		} else {
+			LogUtil.writeLog("WARN: acpsdk.rootCert.path is empty");
+		}
+	}
+	
+	/**
+	 * 用配置文件acp_sdk.properties配置路径 加载银联公钥上级证书(中级证书)
+	 */
+	private static void initEncryptCert() {
+		LogUtil.writeLog("加载敏感信息加密证书==>"+SDKConfig.getConfig().getEncryptCertPath());
+		if (!isEmpty(SDKConfig.getConfig().getEncryptCertPath())) {
+			encryptCert = initCert(SDKConfig.getConfig().getEncryptCertPath());
+			LogUtil.writeLog("Load EncryptCert Successful");
+		} else {
+			LogUtil.writeLog("WARN: acpsdk.encryptCert.path is empty");
+		}
+	}
+	
+	/**
+	 * 用配置文件acp_sdk.properties配置路径 加载磁道公钥
+	 */
+	private static void initTrackKey() {
+		if (!isEmpty(SDKConfig.getConfig().getEncryptTrackKeyModulus())
+				&& !isEmpty(SDKConfig.getConfig().getEncryptTrackKeyExponent())) {
+			encryptTrackKey = getPublicKey(SDKConfig.getConfig().getEncryptTrackKeyModulus(), 
+					SDKConfig.getConfig().getEncryptTrackKeyExponent());
+			LogUtil.writeLog("LoadEncryptTrackKey Successful");
+		} else {
+			LogUtil.writeLog("WARN: acpsdk.encryptTrackKey.modulus or acpsdk.encryptTrackKey.exponent is empty");
+		}
+	}
+
+	/**
+	 * 用配置文件acp_sdk.properties配置路径 加载验证签名证书
+	 */
+	private static void initValidateCertFromDir() {
+		if(!"01".equals(SDKConfig.getConfig().getSignMethod())){
+			LogUtil.writeLog("非rsa签名方式,不加载验签证书。");
+			return;
+		}
+		certMap.clear();
+		String dir = SDKConfig.getConfig().getValidateCertDir();
+		LogUtil.writeLog("加载验证签名证书目录==>" + dir +" 注:如果请求报文中version=5.1.0那么此验签证书目录使用不到,可以不需要设置(version=5.0.0必须设置)。");
+		if (isEmpty(dir)) {
+			LogUtil.writeErrorLog("WARN: acpsdk.validateCert.dir is empty");
+			return;
+		}
+		CertificateFactory cf = null;
+		FileInputStream in = null;
+		try {
+			cf = CertificateFactory.getInstance("X.509", "BC");
+		}catch (NoSuchProviderException e) {
+			LogUtil.writeErrorLog("LoadVerifyCert Error: No BC Provider", e);
+			return ;
+		} catch (CertificateException e) {
+			LogUtil.writeErrorLog("LoadVerifyCert Error", e);
+			return ;
+		}
+		File fileDir = new File(dir);
+		File[] files = fileDir.listFiles(new CerFilter());
+		for (int i = 0; i < files.length; i++) {
+			File file = files[i];
+			try {
+				in = new FileInputStream(file.getAbsolutePath());
+				validateCert = (X509Certificate) cf.generateCertificate(in);
+				if(validateCert == null) {
+					LogUtil.writeErrorLog("Load verify cert error, " + file.getAbsolutePath() + " has error cert content.");
+					continue;
+				}
+				certMap.put(validateCert.getSerialNumber().toString(),
+						validateCert);
+				// 打印证书加载信息,供测试阶段调试
+				LogUtil.writeLog("[" + file.getAbsolutePath() + "][CertId="
+						+ validateCert.getSerialNumber().toString() + "]");
+			} catch (CertificateException e) {
+				LogUtil.writeErrorLog("LoadVerifyCert Error", e);
+			}catch (FileNotFoundException e) {
+				LogUtil.writeErrorLog("LoadVerifyCert Error File Not Found", e);
+			}finally {
+				if (null != in) {
+					try {
+						in.close();
+					} catch (IOException e) {
+						LogUtil.writeErrorLog(e.toString());
+					}
+				}
+			}
+		}
+		LogUtil.writeLog("LoadVerifyCert Finish");
+	}
+
+	/**
+	 * 用给定的路径和密码 加载签名证书,并保存到certKeyStoreMap
+	 * 
+	 * @param certFilePath
+	 * @param certPwd
+	 */
+	private static void loadSignCert(String certFilePath, String certPwd) {
+		KeyStore keyStore = null;
+		try {
+			keyStore = getKeyInfo(certFilePath, certPwd, "PKCS12");
+			keyStoreMap.put(certFilePath, keyStore);
+			LogUtil.writeLog("LoadRsaCert Successful");
+		} catch (IOException e) {
+			LogUtil.writeErrorLog("LoadRsaCert Error", e);
+		}
+	}
+
+	/**
+	 * 通过证书路径初始化为公钥证书
+	 * @param path
+	 * @return
+	 */
+	private static X509Certificate initCert(String path) {
+		X509Certificate encryptCertTemp = null;
+		CertificateFactory cf = null;
+		FileInputStream in = null;
+		try {
+			cf = CertificateFactory.getInstance("X.509", "BC");
+			in = new FileInputStream(path);
+			encryptCertTemp = (X509Certificate) cf.generateCertificate(in);
+			// 打印证书加载信息,供测试阶段调试
+			LogUtil.writeLog("[" + path + "][CertId="
+					+ encryptCertTemp.getSerialNumber().toString() + "]");
+		} catch (CertificateException e) {
+			LogUtil.writeErrorLog("InitCert Error", e);
+		} catch (FileNotFoundException e) {
+			LogUtil.writeErrorLog("InitCert Error File Not Found", e);
+		} catch (NoSuchProviderException e) {
+			LogUtil.writeErrorLog("LoadVerifyCert Error No BC Provider", e);
+		} finally {
+			if (null != in) {
+				try {
+					in.close();
+				} catch (IOException e) {
+					LogUtil.writeErrorLog(e.toString());
+				}
+			}
+		}
+		return encryptCertTemp;
+	}
+	
+	/**
+	 * 通过keyStore 获取私钥签名证书PrivateKey对象
+	 * 
+	 * @return
+	 */
+	public static PrivateKey getSignCertPrivateKey() {
+		try {
+			Enumeration<String> aliasenum = keyStore.aliases();
+			String keyAlias = null;
+			if (aliasenum.hasMoreElements()) {
+				keyAlias = aliasenum.nextElement();
+			}
+			PrivateKey privateKey = (PrivateKey) keyStore.getKey(keyAlias,
+					SDKConfig.getConfig().getSignCertPwd().toCharArray());
+			return privateKey;
+		} catch (KeyStoreException e) {
+			LogUtil.writeErrorLog("getSignCertPrivateKey Error", e);
+			return null;
+		} catch (UnrecoverableKeyException e) {
+			LogUtil.writeErrorLog("getSignCertPrivateKey Error", e);
+			return null;
+		} catch (NoSuchAlgorithmException e) {
+			LogUtil.writeErrorLog("getSignCertPrivateKey Error", e);
+			return null;
+		}
+	}
+	/**
+	 * 通过指定路径的私钥证书  获取PrivateKey对象
+	 * 
+	 * @return
+	 */
+	public static PrivateKey getSignCertPrivateKeyByStoreMap(String certPath,
+			String certPwd) {
+		if (!keyStoreMap.containsKey(certPath)) {
+			loadSignCert(certPath, certPwd);
+		}
+		try {
+			Enumeration<String> aliasenum = keyStoreMap.get(certPath)
+					.aliases();
+			String keyAlias = null;
+			if (aliasenum.hasMoreElements()) {
+				keyAlias = aliasenum.nextElement();
+			}
+			PrivateKey privateKey = (PrivateKey) keyStoreMap.get(certPath)
+					.getKey(keyAlias, certPwd.toCharArray());
+			return privateKey;
+		} catch (KeyStoreException e) {
+			LogUtil.writeErrorLog("getSignCertPrivateKeyByStoreMap Error", e);
+			return null;
+		} catch (UnrecoverableKeyException e) {
+			LogUtil.writeErrorLog("getSignCertPrivateKeyByStoreMap Error", e);
+			return null;
+		} catch (NoSuchAlgorithmException e) {
+			LogUtil.writeErrorLog("getSignCertPrivateKeyByStoreMap Error", e);
+			return null;
+		}
+	}
+
+	/**
+	 * 获取敏感信息加密证书PublicKey
+	 * 
+	 * @return
+	 */
+	public static PublicKey getEncryptCertPublicKey() {
+		if (null == encryptCert) {
+			String path = SDKConfig.getConfig().getEncryptCertPath();
+			if (!isEmpty(path)) {
+				encryptCert = initCert(path);
+				return encryptCert.getPublicKey();
+			} else {
+				LogUtil.writeErrorLog("acpsdk.encryptCert.path is empty");
+				return null;
+			}
+		} else {
+			return encryptCert.getPublicKey();
+		}
+	}
+	
+	/**
+	 * 重置敏感信息加密证书公钥
+	 */
+	public static void resetEncryptCertPublicKey() {
+		encryptCert = null;
+	}
+	
+	/**
+	 * 获取磁道加密证书PublicKey
+	 * 
+	 * @return
+	 */
+	public static PublicKey getEncryptTrackPublicKey() {
+		if (null == encryptTrackKey) {
+			initTrackKey();
+		}
+		return encryptTrackKey;
+	}
+	
+	/**
+	 * 通过certId获取验签证书Map中对应证书PublicKey
+	 * 
+	 * @param certId 证书物理序号
+	 * @return 通过证书编号获取到的公钥
+	 */
+	public static PublicKey getValidatePublicKey(String certId) {
+		X509Certificate cf = null;
+		if (certMap.containsKey(certId)) {
+			// 存在certId对应的证书对象
+			cf = certMap.get(certId);
+			return cf.getPublicKey();
+		} else {
+			// 不存在则重新Load证书文件目录
+			initValidateCertFromDir();
+			if (certMap.containsKey(certId)) {
+				// 存在certId对应的证书对象
+				cf = certMap.get(certId);
+				return cf.getPublicKey();
+			} else {
+				LogUtil.writeErrorLog("缺少certId=[" + certId + "]对应的验签证书.");
+				return null;
+			}
+		}
+	}
+	
+	/**
+	 * 获取配置文件acp_sdk.properties中配置的签名私钥证书certId
+	 * 
+	 * @return 证书的物理编号
+	 */
+	public static String getSignCertId() {
+		try {
+			Enumeration<String> aliasenum = keyStore.aliases();
+			String keyAlias = null;
+			if (aliasenum.hasMoreElements()) {
+				keyAlias = aliasenum.nextElement();
+			}
+			X509Certificate cert = (X509Certificate) keyStore
+					.getCertificate(keyAlias);
+			return cert.getSerialNumber().toString();
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("getSignCertId Error", e);
+			return null;
+		}
+	}
+
+	/**
+	 * 获取敏感信息加密证书的certId
+	 * 
+	 * @return
+	 */
+	public static String getEncryptCertId() {
+		if (null == encryptCert) {
+			String path = SDKConfig.getConfig().getEncryptCertPath();
+			if (!isEmpty(path)) {
+				encryptCert = initCert(path);
+				return encryptCert.getSerialNumber().toString();
+			} else {
+				LogUtil.writeErrorLog("acpsdk.encryptCert.path is empty");
+				return null;
+			}
+		} else {
+			return encryptCert.getSerialNumber().toString();
+		}
+	}
+
+	/**
+	 * 将签名私钥证书文件读取为证书存储对象
+	 * 
+	 * @param pfxkeyfile
+	 *            证书文件名
+	 * @param keypwd
+	 *            证书密码
+	 * @param type
+	 *            证书类型
+	 * @return 证书对象
+	 * @throws IOException 
+	 */
+	private static KeyStore getKeyInfo(String pfxkeyfile, String keypwd,
+			String type) throws IOException {
+		LogUtil.writeLog("加载签名证书==>" + pfxkeyfile);
+		FileInputStream fis = null;
+		try {
+			KeyStore ks = KeyStore.getInstance(type, "BC");
+			LogUtil.writeLog("Load RSA CertPath=[" + pfxkeyfile + "],Pwd=["+ keypwd + "],type=["+type+"]");
+			fis = new FileInputStream(pfxkeyfile);
+			char[] nPassword = null;
+			nPassword = null == keypwd || "".equals(keypwd.trim()) ? null: keypwd.toCharArray();
+			if (null != ks) {
+				ks.load(fis, nPassword);
+			}
+			return ks;
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("getKeyInfo Error", e);
+			return null;
+		} finally {
+			if(null!=fis)
+				fis.close();
+		}
+	}
+	
+	/**
+	 * 通过签名私钥证书路径,密码获取私钥证书certId
+	 * @param certPath
+	 * @param certPwd
+	 * @return
+	 */
+	public static String getCertIdByKeyStoreMap(String certPath, String certPwd) {
+		if (!keyStoreMap.containsKey(certPath)) {
+			// 缓存中未查询到,则加载RSA证书
+			loadSignCert(certPath, certPwd);
+		}
+		return getCertIdIdByStore(keyStoreMap.get(certPath));
+	}
+	
+	/**
+	 * 通过keystore获取私钥证书的certId值
+	 * @param keyStore
+	 * @return
+	 */
+	private static String getCertIdIdByStore(KeyStore keyStore) {
+		Enumeration<String> aliasenum = null;
+		try {
+			aliasenum = keyStore.aliases();
+			String keyAlias = null;
+			if (aliasenum.hasMoreElements()) {
+				keyAlias = aliasenum.nextElement();
+			}
+			X509Certificate cert = (X509Certificate) keyStore
+					.getCertificate(keyAlias);
+			return cert.getSerialNumber().toString();
+		} catch (KeyStoreException e) {
+			LogUtil.writeErrorLog("getCertIdIdByStore Error", e);
+			return null;
+		}
+	}
+	
+	/**
+	 * 使用模和指数生成RSA公钥 注意:此代码用了默认补位方式,为RSA/None/PKCS1Padding,不同JDK默认的补位方式可能不同
+	 * 
+	 * @param modulus
+	 *            模
+	 * @param exponent
+	 *            指数
+	 * @return
+	 */
+	private static PublicKey getPublicKey(String modulus, String exponent) {
+		try {
+			BigInteger b1 = new BigInteger(modulus);
+			BigInteger b2 = new BigInteger(exponent);
+			KeyFactory keyFactory = KeyFactory.getInstance("RSA", "BC");
+			RSAPublicKeySpec keySpec = new RSAPublicKeySpec(b1, b2);
+			return keyFactory.generatePublic(keySpec);
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("构造RSA公钥失败:" + e);
+			return null;
+		}
+	}
+	
+	/**
+	 * 将字符串转换为X509Certificate对象.
+	 * 
+	 * @param x509CertString
+	 * @return
+	 */
+	public static X509Certificate genCertificateByStr(String x509CertString) {
+		X509Certificate x509Cert = null;
+		try {
+			CertificateFactory cf = CertificateFactory.getInstance("X.509", "BC"); 
+			InputStream tIn = new ByteArrayInputStream(
+					x509CertString.getBytes("ISO-8859-1"));
+			x509Cert = (X509Certificate) cf.generateCertificate(tIn);
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("gen certificate error", e);			
+		}
+		return x509Cert;
+	}
+	
+	/**
+	 * 从配置文件acp_sdk.properties中获取验签公钥使用的中级证书
+	 * @return
+	 */
+	public static X509Certificate getMiddleCert() {
+		if (null == middleCert) {
+			String path = SDKConfig.getConfig().getMiddleCertPath();
+			if (!isEmpty(path)) {
+				initMiddleCert();
+			} else {
+				LogUtil.writeErrorLog(SDKConfig.SDK_MIDDLECERT_PATH + " not set in " + SDKConfig.FILE_NAME);
+				return null;
+			}
+		}
+		return middleCert;
+	}
+	
+	/**
+	 * 从配置文件acp_sdk.properties中获取验签公钥使用的根证书
+	 * @return
+	 */
+	public static X509Certificate getRootCert() {
+		if (null == rootCert) {
+			String path = SDKConfig.getConfig().getRootCertPath();
+			if (!isEmpty(path)) {
+				initRootCert();
+			} else {
+				LogUtil.writeErrorLog(SDKConfig.SDK_ROOTCERT_PATH + " not set in " + SDKConfig.FILE_NAME);
+				return null;
+			}
+		}
+		return rootCert;
+	}
+
+	/**
+	 * 获取证书的CN
+	 * @param aCert
+	 * @return
+	 */
+	private static String getIdentitiesFromCertficate(X509Certificate aCert) {
+		String tDN = aCert.getSubjectDN().toString(); 
+		String tPart = "";
+		if ((tDN != null)) {
+			String tSplitStr[] = tDN.substring(tDN.indexOf("CN=")).split("@");
+			if (tSplitStr != null && tSplitStr.length > 2
+					&& tSplitStr[2] != null)
+				tPart = tSplitStr[2];
+		}
+		return tPart;
+	}
+	
+	/**
+	 * 验证书链。
+	 * @param cert
+	 * @return
+	 */
+	private static boolean verifyCertificateChain(X509Certificate cert){
+		
+		if ( null == cert) {
+			LogUtil.writeErrorLog("cert must Not null");
+			return false;
+		}
+		
+		X509Certificate middleCert = CertUtil.getMiddleCert();
+		if (null == middleCert) {
+			LogUtil.writeErrorLog("middleCert must Not null");
+			return false;
+		}
+		
+		X509Certificate rootCert = CertUtil.getRootCert();
+		if (null == rootCert) {
+			LogUtil.writeErrorLog("rootCert or cert must Not null");
+			return false;
+		}
+		
+		try {
+		
+	        X509CertSelector selector = new X509CertSelector();
+	        selector.setCertificate(cert);
+	        
+	        Set<TrustAnchor> trustAnchors = new HashSet<TrustAnchor>();
+	        trustAnchors.add(new TrustAnchor(rootCert, null));
+	        PKIXBuilderParameters pkixParams = new PKIXBuilderParameters(
+			        trustAnchors, selector);
+	
+	        Set<X509Certificate> intermediateCerts = new HashSet<X509Certificate>();
+	        intermediateCerts.add(rootCert);
+	        intermediateCerts.add(middleCert);
+	        intermediateCerts.add(cert);
+	        
+	        pkixParams.setRevocationEnabled(false);
+	
+	        CertStore intermediateCertStore = CertStore.getInstance("Collection",
+	                new CollectionCertStoreParameters(intermediateCerts), "BC");
+	        pkixParams.addCertStore(intermediateCertStore);
+	
+	        CertPathBuilder builder = CertPathBuilder.getInstance("PKIX", "BC");
+	        
+        	@SuppressWarnings("unused")
+			PKIXCertPathBuilderResult result = (PKIXCertPathBuilderResult) builder
+                .build(pkixParams);
+			LogUtil.writeLog("verify certificate chain succeed.");
+			return true;
+        } catch (java.security.cert.CertPathBuilderException e){
+			LogUtil.writeErrorLog("verify certificate chain fail.", e);
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("verify certificate chain exception: ", e);
+		}
+		return false;
+	}
+	
+	/**
+	 * 检查证书链
+	 * 
+	 *
+	 * @param cert
+	 *            待验证的证书
+	 * @return
+	 */
+	public static boolean verifyCertificate(X509Certificate cert) {
+		
+		if ( null == cert) {
+			LogUtil.writeErrorLog("cert must Not null");
+			return false;
+		}
+		try {
+			cert.checkValidity();//验证有效期
+//			cert.verify(middleCert.getPublicKey());
+			if(!verifyCertificateChain(cert)){
+				return false;
+			}
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("verifyCertificate fail", e);
+			return false;
+		}
+		
+		if(SDKConfig.getConfig().isIfValidateCNName()){
+			// 验证公钥是否属于银联
+			if(!UNIONPAY_CNNAME.equals(CertUtil.getIdentitiesFromCertficate(cert))) {
+				LogUtil.writeErrorLog("cer owner is not CUP:" + CertUtil.getIdentitiesFromCertficate(cert));
+				return false;
+			}
+		} else {
+			// 验证公钥是否属于银联
+			if(!UNIONPAY_CNNAME.equals(CertUtil.getIdentitiesFromCertficate(cert)) 
+					&& !"00040000:SIGN".equals(CertUtil.getIdentitiesFromCertficate(cert))) {
+				LogUtil.writeErrorLog("cer owner is not CUP:" + CertUtil.getIdentitiesFromCertficate(cert));
+				return false;
+			}
+		}
+		return true;		
+	}
+
+	/**
+	 * 打印系统环境信息
+	 */
+	private static void printSysInfo() {
+		LogUtil.writeLog("================= SYS INFO begin====================");
+		LogUtil.writeLog("os_name:" + System.getProperty("os.name"));
+		LogUtil.writeLog("os_arch:" + System.getProperty("os.arch"));
+		LogUtil.writeLog("os_version:" + System.getProperty("os.version"));
+		LogUtil.writeLog("java_vm_specification_version:"
+				+ System.getProperty("java.vm.specification.version"));
+		LogUtil.writeLog("java_vm_specification_vendor:"
+				+ System.getProperty("java.vm.specification.vendor"));
+		LogUtil.writeLog("java_vm_specification_name:"
+				+ System.getProperty("java.vm.specification.name"));
+		LogUtil.writeLog("java_vm_version:"
+				+ System.getProperty("java.vm.version"));
+		LogUtil.writeLog("java_vm_name:" + System.getProperty("java.vm.name"));
+		LogUtil.writeLog("java.version:" + System.getProperty("java.version"));
+		LogUtil.writeLog("java.vm.vendor=[" + System.getProperty("java.vm.vendor") + "]");
+		LogUtil.writeLog("java.version=[" + System.getProperty("java.version") + "]");
+		printProviders();
+		LogUtil.writeLog("================= SYS INFO end=====================");
+	}
+	
+	/**
+	 * 打jre中印算法提供者列表
+	 */
+	private static void printProviders() {
+		LogUtil.writeLog("Providers List:");
+		Provider[] providers = Security.getProviders();
+		for (int i = 0; i < providers.length; i++) {
+			LogUtil.writeLog(i + 1 + "." + providers[i].getName());
+		}
+	}
+
+	/**
+	 * 证书文件过滤器
+	 * 
+	 */
+	static class CerFilter implements FilenameFilter {
+		public boolean isCer(String name) {
+			if (name.toLowerCase().endsWith(".cer")) {
+				return true;
+			} else {
+				return false;
+			}
+		}
+		public boolean accept(File dir, String name) {
+			return isCer(name);
+		}
+	}
+
+}

+ 223 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/DemoBase.java

@@ -0,0 +1,223 @@
+package com.lightinit.hsdataportal.Unionsdk;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+
+/**
+ * 名称: demo中用到的方法<br>
+ * 日期: 2015-09<br>
+ 
+ * 版权: 中国银联<br>
+ * 声明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障<br>
+ */
+public class DemoBase {
+
+	//默认配置的是UTF-8
+	public static String encoding = "UTF-8";
+	
+	//全渠道固定值
+	public static String version = SDKConfig.getConfig().getVersion();
+	
+	//后台服务对应的写法参照 FrontRcvResponse.java
+	public static String frontUrl = SDKConfig.getConfig().getFrontUrl();
+
+	//后台服务对应的写法参照 BackRcvResponse.java
+	public static String backUrl = SDKConfig.getConfig().getBackUrl();//受理方和发卡方自选填写的域[O]--后台通知地址
+
+	// 商户发送交易时间 格式:YYYYMMDDhhmmss
+	public static String getCurrentTime() {
+		return new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+	}
+	
+	// AN8..40 商户订单号,不能含"-"或"_"
+	public static String getOrderId() {
+		return new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
+	}
+
+	//sx:商户信息:卖家得商户号
+	public static String merId = SDKConfig.getConfig().getMerId();
+   /**
+	 * 组装请求,返回报文字符串用于显示
+	 * @param data
+	 * @return
+	 */
+    public static String genHtmlResult(Map<String, String> data){
+
+    	TreeMap<String, String> tree = new TreeMap<String, String>();
+		Iterator<Entry<String, String>> it = data.entrySet().iterator();
+		while (it.hasNext()) {
+			Entry<String, String> en = it.next();
+			tree.put(en.getKey(), en.getValue());
+		}
+		it = tree.entrySet().iterator();
+		StringBuffer sf = new StringBuffer();
+		while (it.hasNext()) {
+			Entry<String, String> en = it.next();
+			String key = en.getKey(); 
+			String value =  en.getValue();
+			if("respCode".equals(key)){
+				sf.append("<b>"+key + SDKConstants.EQUAL + value+"</br></b>");
+			}else
+				sf.append(key + SDKConstants.EQUAL + value+"</br>");
+		}
+		return sf.toString();
+    }
+    /**
+	 * 功能:解析全渠道商户对账文件中的ZM文件并以List<Map>方式返回
+	 * 适用交易:对账文件下载后对文件的查看
+	 * @param filePath ZM文件全路径
+	 * @return 包含每一笔交易中 序列号 和 值 的map序列
+	 */
+	public static List<Map> parseZMFile(String filePath){
+		int lengthArray[] = {3,11,11,6,10,19,12,4,2,21,2,32,2,6,10,13,13,4,15,2,2,6,2,4,32,1,21,15,1,15,32,13,13,8,32,13,13,12,2,1,32,98};
+		return parseFile(filePath,lengthArray);
+	}
+	
+	/**
+	 * 功能:解析全渠道商户对账文件中的ZME文件并以List<Map>方式返回
+	 * 适用交易:对账文件下载后对文件的查看
+	 * @param filePath ZME文件全路径
+	 * @return 包含每一笔交易中 序列号 和 值 的map序列
+	 */
+	public static List<Map> parseZMEFile(String filePath){
+		int lengthArray[] = {3,11,11,6,10,19,12,4,2,2,6,10,4,12,13,13,15,15,1,12,2,135};
+		return parseFile(filePath,lengthArray);
+	}
+	
+	/**
+	 * 功能:解析全渠道商户 ZM,ZME对账文件
+	 * @param filePath
+	 * @param lengthArray 参照《全渠道平台接入接口规范 第3部分 文件接口》 全渠道商户对账文件 6.1 ZM文件和6.2 ZME 文件 格式的类型长度组成int型数组
+	 * @return
+	 */
+	private static List<Map> parseFile(String filePath,int lengthArray[]){
+	 	List<Map> ZmDataList = new ArrayList<Map>();
+	 	try {
+            String encoding="UTF-8";
+            File file=new File(filePath);
+            if(file.isFile() && file.exists()){ //判断文件是否存在
+                InputStreamReader read = new InputStreamReader(
+                new FileInputStream(file),encoding);//考虑到编码格式
+                BufferedReader bufferedReader = new BufferedReader(read);
+                String lineTxt = null;
+                while((lineTxt = bufferedReader.readLine()) != null){
+                	//解析的结果MAP,key为对账文件列序号,value为解析的值
+        		 	Map<Integer,String> ZmDataMap = new LinkedHashMap<Integer,String>();
+                    //左侧游标
+                    int leftIndex = 0;
+                    //右侧游标
+                    int rightIndex = 0;
+                    for(int i=0;i<lengthArray.length;i++){
+                    	rightIndex = leftIndex + lengthArray[i];
+                    	String filed = lineTxt.substring(leftIndex,rightIndex);
+                    	leftIndex = rightIndex+1;
+                    	ZmDataMap.put(i, filed);
+                    }
+                    ZmDataList.add(ZmDataMap);
+                }
+                read.close();
+        }else{
+            System.out.println("找不到指定的文件");
+        }
+        } catch (Exception e) {
+            System.out.println("读取文件内容出错");
+            e.printStackTrace();
+        }
+	 	
+		return ZmDataList;	
+	}
+	 
+    public static String getFileContentTable(List<Map> dataList,String file){
+    	StringBuffer  tableSb = new StringBuffer("对账文件的规范参考 https://open.unionpay.com/ajweb/help/file/ 产品接口规范->平台接口规范:文件接口</br> 文件【"+file + "】解析后内容如下:");
+    	tableSb.append("<table border=\"1\">");
+    	if(dataList.size() > 0){
+    		Map<Integer,String> dataMapTmp = dataList.get(0);
+    		tableSb.append("<tr>");
+	 		for(Iterator<Integer> it = dataMapTmp.keySet().iterator();it.hasNext();){
+	 			Integer key = it.next();
+	 			String value = dataMapTmp.get(key);
+		 		System.out.println("序号:"+ (key+1) + " 值: '"+ value +"'");
+		 		tableSb.append("<td>序号"+(key+1)+"</td>");
+		 	}
+	 		tableSb.append("</tr>");
+    	}
+    	
+    	for(int i=0;i<dataList.size();i++){
+	 		System.out.println("行数: "+ (i+1));
+	 		Map<Integer,String> dataMapTmp = dataList.get(i);
+	 		tableSb.append("<tr>");
+	 		for(Iterator<Integer> it = dataMapTmp.keySet().iterator();it.hasNext();){
+	 			Integer key = it.next();
+	 			String value = dataMapTmp.get(key);
+		 		System.out.println("序号:"+ (key+1) + " 值: '"+ value +"'");
+		 		tableSb.append("<td>"+value+"</td>");
+		 	}
+	 		tableSb.append("</tr>");
+	 	}
+    	tableSb.append("</table>");
+    	return tableSb.toString();
+    }
+
+	
+	public static List<String> unzip(String zipFilePath,String outPutDirectory){
+		List<String> fileList = new ArrayList<String>();
+		try {
+            ZipInputStream zin = new ZipInputStream(new FileInputStream(zipFilePath));//输入源zip路径  
+            BufferedInputStream bin = new BufferedInputStream(zin);
+            BufferedOutputStream bout = null;
+            File file=null;  
+            ZipEntry entry;
+            try {
+                while((entry = zin.getNextEntry())!=null && !entry.isDirectory()){
+                	file = new File(outPutDirectory,entry.getName());  
+                    if(!file.exists()){  
+                        (new File(file.getParent())).mkdirs();  
+                    }
+                    bout = new BufferedOutputStream(new FileOutputStream(file));  
+                    int b;
+                    while((b=bin.read())!=-1){  
+                    	bout.write(b);  
+                    }
+                    bout.flush();
+                    fileList.add(file.getAbsolutePath());
+                    System.out.println(file+"解压成功");
+                }
+            } catch (IOException e) {  
+                e.printStackTrace();  
+            }finally{
+                try {
+					bin.close();
+					zin.close();
+					if(bout!=null){
+						bout.close();
+					}
+				} catch (IOException e) {
+					e.printStackTrace();
+				}  
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();  
+        }
+		return fileList;
+	}
+
+}

+ 314 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/HttpClient.java

@@ -0,0 +1,314 @@
+/**
+ *
+ * Licensed Property to China UnionPay Co., Ltd.
+ * 
+ * (C) Copyright of China UnionPay Co., Ltd. 2010
+ *     All Rights Reserved.
+ *
+ * 
+ * Modification History:
+ * =============================================================================
+ *   Author         Date          Description
+ *   ------------ ---------- ---------------------------------------------------
+ *   xshu       2014-05-28       HTTP通信工具类
+ * =============================================================================
+ */
+package com.lightinit.hsdataportal.Unionsdk;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.ProtocolException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.net.ssl.HttpsURLConnection;
+
+import com.lightinit.hsdataportal.Unionsdk.BaseHttpSSLSocketFactory.TrustAnyHostnameVerifier;
+/**
+ * 
+ * @ClassName HttpClient
+ * @Description acpsdk发送后台http请求类
+ * @date 2016-7-22 下午4:03:25
+ * 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
+ */
+public class HttpClient {
+	/**
+	 * 目标地址
+	 */
+	private URL url;
+
+	/**
+	 * 通信连接超时时间
+	 */
+	private int connectionTimeout;
+
+	/**
+	 * 通信读超时时间
+	 */
+	private int readTimeOut;
+
+	/**
+	 * 通信结果
+	 */
+	private String result;
+
+	/**
+	 * 获取通信结果
+	 * @return
+	 */
+	public String getResult() {
+		return result;
+	}
+
+	/**
+	 * 设置通信结果
+	 * @param result
+	 */
+	public void setResult(String result) {
+		this.result = result;
+	}
+
+	/**
+	 * 构造函数
+	 * @param url 目标地址
+	 * @param connectionTimeout HTTP连接超时时间
+	 * @param readTimeOut HTTP读写超时时间
+	 */
+	public HttpClient(String url, int connectionTimeout, int readTimeOut) {
+		try {
+			this.url = new URL(url);
+			this.connectionTimeout = connectionTimeout;
+			this.readTimeOut = readTimeOut;
+		} catch (MalformedURLException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		}
+	}
+
+	/**
+	 * 发送信息到服务端
+	 * @param data
+	 * @param encoding
+	 * @return
+	 * @throws Exception
+	 */
+	public int send(Map<String, String> data, String encoding) throws Exception {
+		try {
+			HttpURLConnection httpURLConnection = createConnection(encoding);
+			if (null == httpURLConnection) {
+				throw new Exception("Create httpURLConnection Failure");
+			}
+			String sendData = this.getRequestParamString(data, encoding);
+			LogUtil.writeLog("请求报文(对每个报文域的值均已做url编码):[" + sendData + "]");
+			this.requestServer(httpURLConnection, sendData,
+					encoding);
+			this.result = this.response(httpURLConnection, encoding);
+			LogUtil.writeLog("Response message:[" + result + "]");
+			return httpURLConnection.getResponseCode();
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+	
+	/**
+	 * 发送信息到服务端 GET方式
+	 * @param encoding
+	 * @return
+	 * @throws Exception
+	 */
+	public int sendGet(String encoding) throws Exception {
+		try {
+			HttpURLConnection httpURLConnection = createConnectionGet(encoding);
+			if(null == httpURLConnection){
+				throw new Exception("创建联接失败");
+			}
+			this.result = this.response(httpURLConnection, encoding);
+			LogUtil.writeLog("同步返回报文:[" + result + "]");
+			return httpURLConnection.getResponseCode();
+		} catch (Exception e) {
+			throw e;
+		}
+	}
+
+	
+	/**
+	 * HTTP Post发送消息
+	 *
+	 * @param connection
+	 * @param message
+	 * @throws IOException
+	 */
+	private void requestServer(final URLConnection connection, String message, String encoder)
+			throws Exception {
+		PrintStream out = null;
+		try {
+			connection.connect();
+			out = new PrintStream(connection.getOutputStream(), false, encoder);
+			out.print(message);
+			out.flush();
+		} catch (Exception e) {
+			throw e;
+		} finally {
+			if (null != out) {
+				out.close();
+			}
+		}
+	}
+
+	/**
+	 * 显示Response消息
+	 *
+	 * @param connection
+	 * @return
+	 * @throws URISyntaxException
+	 * @throws IOException
+	 */
+	private String response(final HttpURLConnection connection, String encoding)
+			throws URISyntaxException, IOException, Exception {
+		InputStream in = null;
+		StringBuilder sb = new StringBuilder(1024);
+		BufferedReader br = null;
+		try {
+			if (200 == connection.getResponseCode()) {
+				in = connection.getInputStream();
+				sb.append(new String(read(in), encoding));
+			} else {
+				in = connection.getErrorStream();
+				sb.append(new String(read(in), encoding));
+			}
+			LogUtil.writeLog("HTTP Return Status-Code:["
+					+ connection.getResponseCode() + "]");
+			return sb.toString();
+		} catch (Exception e) {
+			throw e;
+		} finally {
+			if (null != br) {
+				br.close();
+			}
+			if (null != in) {
+				in.close();
+			}
+			if (null != connection) {
+				connection.disconnect();
+			}
+		}
+	}
+	
+	public static byte[] read(InputStream in) throws IOException {
+		byte[] buf = new byte[1024];
+		int length = 0;
+		ByteArrayOutputStream bout = new ByteArrayOutputStream();
+		while ((length = in.read(buf, 0, buf.length)) > 0) {
+			bout.write(buf, 0, length);
+		}
+		bout.flush();
+		return bout.toByteArray();
+	}
+	
+	/**
+	 * 创建连接
+	 *
+	 * @return
+	 * @throws ProtocolException
+	 */
+	private HttpURLConnection createConnection(String encoding) throws ProtocolException {
+		HttpURLConnection httpURLConnection = null;
+		try {
+			httpURLConnection = (HttpURLConnection) url.openConnection();
+		} catch (IOException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+			return null;
+		}
+		httpURLConnection.setConnectTimeout(this.connectionTimeout);// 连接超时时间
+		httpURLConnection.setReadTimeout(this.readTimeOut);// 读取结果超时时间
+		httpURLConnection.setDoInput(true); // 可读
+		httpURLConnection.setDoOutput(true); // 可写
+		httpURLConnection.setUseCaches(false);// 取消缓存
+		httpURLConnection.setRequestProperty("Content-type",
+				"application/x-www-form-urlencoded;charset=" + encoding);
+		httpURLConnection.setRequestMethod("POST");
+		if ("https".equalsIgnoreCase(url.getProtocol())) {
+			HttpsURLConnection husn = (HttpsURLConnection) httpURLConnection;
+			//是否验证https证书,测试环境请设置false,生产环境建议优先尝试true,不行再false
+			if(!SDKConfig.getConfig().isIfValidateRemoteCert()){
+				husn.setSSLSocketFactory(new BaseHttpSSLSocketFactory());
+				husn.setHostnameVerifier(new TrustAnyHostnameVerifier());//解决由于服务器证书问题导致HTTPS无法访问的情况
+			}
+			return husn;
+		}
+		return httpURLConnection;
+	}
+
+	/**
+	 * 创建连接
+	 *
+	 * @return
+	 * @throws ProtocolException
+	 */
+	private HttpURLConnection createConnectionGet(String encoding) throws ProtocolException {
+		HttpURLConnection httpURLConnection = null;
+		try {
+			httpURLConnection = (HttpURLConnection) url.openConnection();
+		} catch (IOException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+			return null;
+		}
+		httpURLConnection.setConnectTimeout(this.connectionTimeout);// 连接超时时间
+		httpURLConnection.setReadTimeout(this.readTimeOut);// 读取结果超时时间
+		httpURLConnection.setUseCaches(false);// 取消缓存
+		httpURLConnection.setRequestProperty("Content-type",
+				"application/x-www-form-urlencoded;charset=" + encoding);
+		httpURLConnection.setRequestMethod("GET");
+		if ("https".equalsIgnoreCase(url.getProtocol())) {
+			HttpsURLConnection husn = (HttpsURLConnection) httpURLConnection;
+			//是否验证https证书,测试环境请设置false,生产环境建议优先尝试true,不行再false
+			if(!SDKConfig.getConfig().isIfValidateRemoteCert()){
+				husn.setSSLSocketFactory(new BaseHttpSSLSocketFactory());
+				husn.setHostnameVerifier(new TrustAnyHostnameVerifier());//解决由于服务器证书问题导致HTTPS无法访问的情况
+			}
+			return husn;
+		}
+		return httpURLConnection;
+	}
+	
+	/**
+	 * 将Map存储的对象,转换为key=value&key=value的字符
+	 *
+	 * @param requestParam
+	 * @param coder
+	 * @return
+	 */
+	private String getRequestParamString(Map<String, String> requestParam, String coder) {
+		if (null == coder || "".equals(coder)) {
+			coder = "UTF-8";
+		}
+		StringBuffer sf = new StringBuffer("");
+		String reqstr = "";
+		if (null != requestParam && 0 != requestParam.size()) {
+			for (Entry<String, String> en : requestParam.entrySet()) {
+				try {
+					sf.append(en.getKey()
+							+ "="
+							+ (null == en.getValue() || "".equals(en.getValue()) ? "" : URLEncoder
+									.encode(en.getValue(), coder)) + "&");
+				} catch (UnsupportedEncodingException e) {
+					LogUtil.writeErrorLog(e.getMessage(), e);
+					return "";
+				}
+			}
+			reqstr = sf.substring(0, sf.length() - 1);
+		}
+		LogUtil.writeLog("Request Message:[" + reqstr + "]");
+		return reqstr;
+	}
+
+}

+ 115 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/LogUtil.java

@@ -0,0 +1,115 @@
+/**
+ *
+ * Licensed Property to China UnionPay Co., Ltd.
+ * 
+ * (C) Copyright of China UnionPay Co., Ltd. 2010
+ *     All Rights Reserved.
+ *
+ * 
+ * Modification History:
+ * =============================================================================
+ *   Author         Date          Description
+ *   ------------ ---------- ---------------------------------------------------
+ *   xshu       2014-05-28       日志打印工具类
+ * =============================================================================
+ */
+package com.lightinit.hsdataportal.Unionsdk;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+/**
+ * 
+ * @ClassName LogUtil
+ * @Description acpsdk日志工具类
+ * @date 2016-7-22 下午4:04:35
+ * 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
+ */
+public class LogUtil {
+
+	private final static Logger GATELOG = LoggerFactory.getLogger("ACP_SDK_LOG");
+	private final static Logger GATELOG_ERROR = LoggerFactory.getLogger("SDK_ERR_LOG");
+	private final static Logger GATELOG_MESSAGE = LoggerFactory.getLogger("SDK_MSG_LOG");
+
+	final static String LOG_STRING_REQ_MSG_BEGIN = "============================== SDK REQ MSG BEGIN ==============================";
+	final static String LOG_STRING_REQ_MSG_END = "==============================  SDK REQ MSG END  ==============================";
+	final static String LOG_STRING_RSP_MSG_BEGIN = "============================== SDK RSP MSG BEGIN ==============================";
+	final static String LOG_STRING_RSP_MSG_END = "==============================  SDK RSP MSG END  ==============================";
+
+	/**
+	 * 记录普通日志
+	 * 
+	 * @param cont
+	 */
+	public static void writeLog(String cont) {
+		GATELOG.info(cont);
+	}
+
+	/**
+	 * 记录ERORR日志
+	 * 
+	 * @param cont
+	 */
+	public static void writeErrorLog(String cont) {
+		GATELOG_ERROR.error(cont);
+	}
+
+	/**
+	 * 记录ERROR日志
+	 * 
+	 * @param cont
+	 * @param ex
+	 */
+	public static void writeErrorLog(String cont, Throwable ex) {
+		GATELOG_ERROR.error(cont, ex);
+	}
+
+	/**
+	 * 记录通信报文
+	 * 
+	 * @param msg
+	 */
+	public static void writeMessage(String msg) {
+		GATELOG_MESSAGE.info(msg);
+	}
+
+	/**
+	 * 打印请求报文
+	 * 
+	 * @param reqParam
+	 */
+	public static void printRequestLog(Map<String, String> reqParam) {
+		writeMessage(LOG_STRING_REQ_MSG_BEGIN);
+		Iterator<Entry<String, String>> it = reqParam.entrySet().iterator();
+		while (it.hasNext()) {
+			Entry<String, String> en = it.next();
+			writeMessage("[" + en.getKey() + "] = [" + en.getValue() + "]");
+		}
+		writeMessage(LOG_STRING_REQ_MSG_END);
+	}
+
+	/**
+	 * 打印响应报文.
+	 * 
+	 * @param res
+	 */
+	public static void printResponseLog(String res) {
+		writeMessage(LOG_STRING_RSP_MSG_BEGIN);
+		writeMessage(res);
+		writeMessage(LOG_STRING_RSP_MSG_END);
+	}
+
+	/**
+	 * debug方法
+	 * 
+	 * @param cont
+	 */
+	public static void debug(String cont) {
+		if (GATELOG.isDebugEnabled()) {
+			GATELOG.debug(cont);
+		}
+	}
+}

+ 806 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/SDKConfig.java

@@ -0,0 +1,806 @@
+/**
+ *
+ * Licensed Property to China UnionPay Co., Ltd.
+ * 
+ * (C) Copyright of China UnionPay Co., Ltd. 2010
+ *     All Rights Reserved.
+ *
+ * 
+ * Modification History:
+ * =============================================================================
+ *   Author         Date          Description
+ *   ------------ ---------- ---------------------------------------------------
+ *   xshu       2014-05-28       MPI基本参数工具类
+ * =============================================================================
+ */
+package com.lightinit.hsdataportal.Unionsdk;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * 
+ * @ClassName SDKConfig
+ * @Description acpsdk配置文件acp_sdk.properties配置信息类
+ * @date 2016-7-22 下午4:04:55
+ * 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
+ */
+public class SDKConfig {
+	public static final String FILE_NAME = "acp_sdk.properties";
+	/** 前台请求URL. */
+	private String frontRequestUrl;
+	/** 后台请求URL. */
+	private String backRequestUrl;
+	/** 单笔查询 */
+	private String singleQueryUrl;
+	/** 批量查询 */
+	private String batchQueryUrl;
+	/** 批量交易 */
+	private String batchTransUrl;
+	/** 文件传输 */
+	private String fileTransUrl;
+	/** 签名证书路径. */
+	private String signCertPath;
+	/** 签名证书密码. */
+	private String signCertPwd;
+	/** 签名证书类型. */
+	private String signCertType;
+	/** 加密公钥证书路径. */
+	private String encryptCertPath;
+	/** 验证签名公钥证书目录. */
+	private String validateCertDir;
+	/** 按照商户代码读取指定签名证书目录. */
+	private String signCertDir;
+	/** 磁道加密证书路径. */
+	private String encryptTrackCertPath;
+	/** 磁道加密公钥模数. */
+	private String encryptTrackKeyModulus;
+	/** 磁道加密公钥指数. */
+	private String encryptTrackKeyExponent;
+	/** 有卡交易. */
+	private String cardRequestUrl;
+	/** app交易 */
+	private String appRequestUrl;
+	/** 证书使用模式(单证书/多证书) */
+	private String singleMode;
+	/** 安全密钥(SHA256和SM3计算时使用) */
+	private String secureKey;
+	/** 中级证书路径  */
+	private String middleCertPath;
+	/** 根证书路径  */
+	private String rootCertPath;
+	/** 是否验证验签证书CN,除了false都验  */
+	private boolean ifValidateCNName = true;
+	/** 是否验证https证书,默认都不验  */
+	private boolean ifValidateRemoteCert = false;
+	/** signMethod,没配按01吧  */
+	private String signMethod = "01";
+	/** version,没配按5.0.0  */
+	private String version = "5.0.0";
+	/** frontUrl  */
+	private String frontUrl;
+	/** backUrl  */
+	private String backUrl;
+
+	/** sx:卖家得商户号  */
+	private String merId;
+
+	/*缴费相关地址*/
+	private String jfFrontRequestUrl;
+	private String jfBackRequestUrl;
+	private String jfSingleQueryUrl;
+	private String jfCardRequestUrl;
+	private String jfAppRequestUrl;
+	
+	private String qrcBackTransUrl;
+	private String qrcB2cIssBackTransUrl;
+	private String qrcB2cMerBackTransUrl;
+	
+	//综合认证
+	private String zhrzFrontRequestUrl;
+	private String zhrzBackRequestUrl;
+	private String zhrzSingleQueryUrl;
+	private String zhrzCardRequestUrl;
+	private String zhrzAppRequestUrl;
+
+	/** 配置文件中的前台URL常量. */
+	public static final String SDK_FRONT_URL = "acpsdk.frontTransUrl";
+	/** 配置文件中的后台URL常量. */
+	public static final String SDK_BACK_URL = "acpsdk.backTransUrl";
+	/** 配置文件中的单笔交易查询URL常量. */
+	public static final String SDK_SIGNQ_URL = "acpsdk.singleQueryUrl";
+	/** 配置文件中的批量交易查询URL常量. */
+	public static final String SDK_BATQ_URL = "acpsdk.batchQueryUrl";
+	/** 配置文件中的批量交易URL常量. */
+	public static final String SDK_BATTRANS_URL = "acpsdk.batchTransUrl";
+	/** 配置文件中的文件类交易URL常量. */
+	public static final String SDK_FILETRANS_URL = "acpsdk.fileTransUrl";
+	/** 配置文件中的有卡交易URL常量. */
+	public static final String SDK_CARD_URL = "acpsdk.cardTransUrl";
+	/** 配置文件中的app交易URL常量. */
+	public static final String SDK_APP_URL = "acpsdk.appTransUrl";
+
+	/** 以下缴费产品使用,其余产品用不到,无视即可 */
+	// 前台请求地址
+	public static final String JF_SDK_FRONT_TRANS_URL= "acpsdk.jfFrontTransUrl";
+	// 后台请求地址
+	public static final String JF_SDK_BACK_TRANS_URL="acpsdk.jfBackTransUrl";
+	// 单笔查询请求地址
+	public static final String JF_SDK_SINGLE_QUERY_URL="acpsdk.jfSingleQueryUrl";
+	// 有卡交易地址
+	public static final String JF_SDK_CARD_TRANS_URL="acpsdk.jfCardTransUrl";
+	// App交易地址
+	public static final String JF_SDK_APP_TRANS_URL="acpsdk.jfAppTransUrl";
+	// 人到人
+	public static final String QRC_BACK_TRANS_URL="acpsdk.qrcBackTransUrl";
+	// 人到人
+	public static final String QRC_B2C_ISS_BACK_TRANS_URL="acpsdk.qrcB2cIssBackTransUrl";
+	// 人到人
+	public static final String QRC_B2C_MER_BACK_TRANS_URL="acpsdk.qrcB2cMerBackTransUrl";
+
+	/** 以下综合认证产品使用,其余产品用不到,无视即可 */
+	// 前台请求地址
+	public static final String ZHRZ_SDK_FRONT_TRANS_URL= "acpsdk.zhrzFrontTransUrl";
+	// 后台请求地址
+	public static final String ZHRZ_SDK_BACK_TRANS_URL="acpsdk.zhrzBackTransUrl";
+	// 单笔查询请求地址
+	public static final String ZHRZ_SDK_SINGLE_QUERY_URL="acpsdk.zhrzSingleQueryUrl";
+	// 有卡交易地址
+	public static final String ZHRZ_SDK_CARD_TRANS_URL="acpsdk.zhrzCardTransUrl";
+	// App交易地址
+	public static final String ZHRZ_SDK_APP_TRANS_URL="acpsdk.zhrzAppTransUrl";
+	
+	/** 配置文件中签名证书路径常量. */
+	public static final String SDK_SIGNCERT_PATH = "acpsdk.signCert.path";
+	/** 配置文件中签名证书密码常量. */
+	public static final String SDK_SIGNCERT_PWD = "acpsdk.signCert.pwd";
+	/** 配置文件中签名证书类型常量. */
+	public static final String SDK_SIGNCERT_TYPE = "acpsdk.signCert.type";
+	/** 配置文件中密码加密证书路径常量. */
+	public static final String SDK_ENCRYPTCERT_PATH = "acpsdk.encryptCert.path";
+	/** 配置文件中磁道加密证书路径常量. */
+	public static final String SDK_ENCRYPTTRACKCERT_PATH = "acpsdk.encryptTrackCert.path";
+	/** 配置文件中磁道加密公钥模数常量. */
+	public static final String SDK_ENCRYPTTRACKKEY_MODULUS = "acpsdk.encryptTrackKey.modulus";
+	/** 配置文件中磁道加密公钥指数常量. */
+	public static final String SDK_ENCRYPTTRACKKEY_EXPONENT = "acpsdk.encryptTrackKey.exponent";
+	/** 配置文件中验证签名证书目录常量. */
+	public static final String SDK_VALIDATECERT_DIR = "acpsdk.validateCert.dir";
+
+	/** 配置文件中是否加密cvn2常量. */
+	public static final String SDK_CVN_ENC = "acpsdk.cvn2.enc";
+	/** 配置文件中是否加密cvn2有效期常量. */
+	public static final String SDK_DATE_ENC = "acpsdk.date.enc";
+	/** 配置文件中是否加密卡号常量. */
+	public static final String SDK_PAN_ENC = "acpsdk.pan.enc";
+	/** 配置文件中证书使用模式 */
+	public static final String SDK_SINGLEMODE = "acpsdk.singleMode";
+	/** 配置文件中安全密钥 */
+	public static final String SDK_SECURITYKEY = "acpsdk.secureKey";
+	/** 配置文件中根证书路径常量  */
+	public static final String SDK_ROOTCERT_PATH = "acpsdk.rootCert.path";
+	/** 配置文件中根证书路径常量  */
+	public static final String SDK_MIDDLECERT_PATH = "acpsdk.middleCert.path";
+	/** 配置是否需要验证验签证书CN,除了false之外的值都当true处理 */
+	public static final String SDK_IF_VALIDATE_CN_NAME = "acpsdk.ifValidateCNName";
+	/** 配置是否需要验证https证书,除了true之外的值都当false处理 */
+	public static final String SDK_IF_VALIDATE_REMOTE_CERT = "acpsdk.ifValidateRemoteCert";
+	/** signmethod */
+	public static final String SDK_SIGN_METHOD ="acpsdk.signMethod";
+	/** version */
+	public static final String SDK_VERSION = "acpsdk.version";
+	/** 后台通知地址  */
+	public static final String SDK_BACKURL = "acpsdk.backUrl";
+	/** 前台通知地址  */
+	public static final String SDK_FRONTURL = "acpsdk.frontUrl";
+	/** 操作对象. */
+	private static SDKConfig config = new SDKConfig();
+	/** 属性文件对象. */
+	private Properties properties;
+
+	/*sx:卖家得商户号*/
+	private static final String MERID="company.merId";
+
+	private SDKConfig() {
+		super();
+	}
+
+	/**
+	 * 获取config对象.
+	 * @return
+	 */
+	public static SDKConfig getConfig() {
+		return config;
+	}
+
+	/**
+	 * 从properties文件加载
+	 * 
+	 * @param rootPath
+	 *            不包含文件名的目录.
+	 */
+	public void loadPropertiesFromPath(String rootPath) {
+		if (rootPath != null && !"".equals(rootPath.trim())) {
+			LogUtil.writeLog("从路径读取配置文件: " + rootPath+File.separator+FILE_NAME);
+			File file = new File(rootPath + File.separator + FILE_NAME);
+			InputStream in = null;
+			if (file.exists()) {
+				try {
+					in = new FileInputStream(file);
+					properties = new Properties();
+					properties.load(in);
+					loadProperties(properties);
+				} catch (FileNotFoundException e) {
+					LogUtil.writeErrorLog(e.getMessage(), e);
+				} catch (IOException e) {
+					LogUtil.writeErrorLog(e.getMessage(), e);
+				} finally {
+					if (null != in) {
+						try {
+							in.close();
+						} catch (IOException e) {
+							LogUtil.writeErrorLog(e.getMessage(), e);
+						}
+					}
+				}
+			} else {
+				// 由于此时可能还没有完成LOG的加载,因此采用标准输出来打印日志信息
+				LogUtil.writeErrorLog(rootPath + FILE_NAME + "不存在,加载参数失败");
+			}
+		} else {
+			loadPropertiesFromSrc();
+		}
+
+	}
+
+	/**
+	 * 从classpath路径下加载配置参数
+	 */
+	public void loadPropertiesFromSrc() {
+		InputStream in = null;
+		try {
+			LogUtil.writeLog("从classpath: " +SDKConfig.class.getClassLoader().getResource("").getPath()+" 获取属性文件"+FILE_NAME);
+			in = SDKConfig.class.getClassLoader().getResourceAsStream(FILE_NAME);
+			if (null != in) {
+				properties = new Properties();
+				try {
+					properties.load(in);
+				} catch (IOException e) {
+					throw e;
+				}
+			} else {
+				LogUtil.writeErrorLog(FILE_NAME + "属性文件未能在classpath指定的目录下 "+SDKConfig.class.getClassLoader().getResource("").getPath()+" 找到!");
+				return;
+			}
+			loadProperties(properties);
+		} catch (IOException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+		} finally {
+			if (null != in) {
+				try {
+					in.close();
+				} catch (IOException e) {
+					LogUtil.writeErrorLog(e.getMessage(), e);
+				}
+			}
+		}
+	}
+
+	/**
+	 * 根据传入的 {@link #(Properties)}对象设置配置参数
+	 * 
+	 * @param pro
+	 */
+	public void loadProperties(Properties pro) {
+		LogUtil.writeLog("开始从属性文件中加载配置项");
+		String value = null;
+		
+		value = pro.getProperty(SDK_SIGNCERT_PATH);
+		if (!SDKUtil.isEmpty(value)) {
+			this.signCertPath = value.trim();
+			LogUtil.writeLog("配置项:私钥签名证书路径==>"+SDK_SIGNCERT_PATH +"==>"+ value+" 已加载");
+		}
+		value = pro.getProperty(SDK_SIGNCERT_PWD);
+		if (!SDKUtil.isEmpty(value)) {
+			this.signCertPwd = value.trim();
+			LogUtil.writeLog("配置项:私钥签名证书密码==>"+SDK_SIGNCERT_PWD +" 已加载");
+		}
+		value = pro.getProperty(SDK_SIGNCERT_TYPE);
+		if (!SDKUtil.isEmpty(value)) {
+			this.signCertType = value.trim();
+			LogUtil.writeLog("配置项:私钥签名证书类型==>"+SDK_SIGNCERT_TYPE +"==>"+ value+" 已加载");
+		}
+		value = pro.getProperty(SDK_ENCRYPTCERT_PATH);
+		if (!SDKUtil.isEmpty(value)) {
+			this.encryptCertPath = value.trim();
+			LogUtil.writeLog("配置项:敏感信息加密证书==>"+SDK_ENCRYPTCERT_PATH +"==>"+ value+" 已加载");
+		}
+		value = pro.getProperty(SDK_VALIDATECERT_DIR);
+		if (!SDKUtil.isEmpty(value)) {
+			this.validateCertDir = value.trim();
+			LogUtil.writeLog("配置项:验证签名证书路径(这里配置的是目录,不要指定到公钥文件)==>"+SDK_VALIDATECERT_DIR +"==>"+ value+" 已加载");
+		}
+		value = pro.getProperty(SDK_FRONT_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.frontRequestUrl = value.trim();
+		}
+		value = pro.getProperty(SDK_BACK_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.backRequestUrl = value.trim();
+		}
+		value = pro.getProperty(SDK_BATQ_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.batchQueryUrl = value.trim();
+		}
+		value = pro.getProperty(SDK_BATTRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.batchTransUrl = value.trim();
+		}
+		value = pro.getProperty(SDK_FILETRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.fileTransUrl = value.trim();
+		}
+		value = pro.getProperty(SDK_SIGNQ_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.singleQueryUrl = value.trim();
+		}
+		value = pro.getProperty(SDK_CARD_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.cardRequestUrl = value.trim();
+		}
+		value = pro.getProperty(SDK_APP_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.appRequestUrl = value.trim();
+		}
+		value = pro.getProperty(SDK_ENCRYPTTRACKCERT_PATH);
+		if (!SDKUtil.isEmpty(value)) {
+			this.encryptTrackCertPath = value.trim();
+		}
+
+		value = pro.getProperty(SDK_SECURITYKEY);
+		if (!SDKUtil.isEmpty(value)) {
+			this.secureKey = value.trim();
+		}
+		value = pro.getProperty(SDK_ROOTCERT_PATH);
+		if (!SDKUtil.isEmpty(value)) {
+			this.rootCertPath = value.trim();
+		}
+		value = pro.getProperty(SDK_MIDDLECERT_PATH);
+		if (!SDKUtil.isEmpty(value)) {
+			this.middleCertPath = value.trim();
+		}
+
+		/**缴费部分**/
+		value = pro.getProperty(JF_SDK_FRONT_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.jfFrontRequestUrl = value.trim();
+		}
+
+		value = pro.getProperty(JF_SDK_BACK_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.jfBackRequestUrl = value.trim();
+		}
+		
+		value = pro.getProperty(JF_SDK_SINGLE_QUERY_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.jfSingleQueryUrl = value.trim();
+		}
+		
+		value = pro.getProperty(JF_SDK_CARD_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.jfCardRequestUrl = value.trim();
+		}
+		
+		value = pro.getProperty(JF_SDK_APP_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.jfAppRequestUrl = value.trim();
+		}
+		
+		value = pro.getProperty(QRC_BACK_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.qrcBackTransUrl = value.trim();
+		}
+		
+		value = pro.getProperty(QRC_B2C_ISS_BACK_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.qrcB2cIssBackTransUrl = value.trim();
+		}
+		
+		value = pro.getProperty(QRC_B2C_MER_BACK_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.qrcB2cMerBackTransUrl = value.trim();
+		}
+		
+		/**综合认证**/
+		value = pro.getProperty(ZHRZ_SDK_FRONT_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.zhrzFrontRequestUrl = value.trim();
+		}
+
+		value = pro.getProperty(ZHRZ_SDK_BACK_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.zhrzBackRequestUrl = value.trim();
+		}
+		
+		value = pro.getProperty(ZHRZ_SDK_SINGLE_QUERY_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.zhrzSingleQueryUrl = value.trim();
+		}
+		
+		value = pro.getProperty(ZHRZ_SDK_CARD_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.zhrzCardRequestUrl = value.trim();
+		}
+		
+		value = pro.getProperty(ZHRZ_SDK_APP_TRANS_URL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.zhrzAppRequestUrl = value.trim();
+		}
+
+		value = pro.getProperty(SDK_ENCRYPTTRACKKEY_EXPONENT);
+		if (!SDKUtil.isEmpty(value)) {
+			this.encryptTrackKeyExponent = value.trim();
+		}
+
+		value = pro.getProperty(SDK_ENCRYPTTRACKKEY_MODULUS);
+		if (!SDKUtil.isEmpty(value)) {
+			this.encryptTrackKeyModulus = value.trim();
+		}
+		
+		value = pro.getProperty(SDK_IF_VALIDATE_CN_NAME);
+		if (!SDKUtil.isEmpty(value)) {
+			if( SDKConstants.FALSE_STRING.equals(value.trim()))
+					this.ifValidateCNName = false;
+		}
+		
+		value = pro.getProperty(SDK_IF_VALIDATE_REMOTE_CERT);
+		if (!SDKUtil.isEmpty(value)) {
+			if( SDKConstants.TRUE_STRING.equals(value.trim()))
+					this.ifValidateRemoteCert = true;
+		}
+		
+		value = pro.getProperty(SDK_SIGN_METHOD);
+		if (!SDKUtil.isEmpty(value)) {
+			this.signMethod = value.trim();
+		}
+		
+		value = pro.getProperty(SDK_SIGN_METHOD);
+		if (!SDKUtil.isEmpty(value)) {
+			this.signMethod = value.trim();
+		}
+		value = pro.getProperty(SDK_VERSION);
+		if (!SDKUtil.isEmpty(value)) {
+			this.version = value.trim();
+		}
+		value = pro.getProperty(SDK_FRONTURL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.frontUrl = value.trim();
+		}
+		value = pro.getProperty(SDK_BACKURL);
+		if (!SDKUtil.isEmpty(value)) {
+			this.backUrl = value.trim();
+		}
+
+		/*sx:卖家得商户号*/
+		value = pro.getProperty(MERID);
+		if(!SDKUtil.isEmpty(value)){
+			this.merId=value.trim();
+		}
+	}
+
+
+	public String getFrontRequestUrl() {
+		return frontRequestUrl;
+	}
+
+	public void setFrontRequestUrl(String frontRequestUrl) {
+		this.frontRequestUrl = frontRequestUrl;
+	}
+
+	public String getBackRequestUrl() {
+		return backRequestUrl;
+	}
+
+	public void setBackRequestUrl(String backRequestUrl) {
+		this.backRequestUrl = backRequestUrl;
+	}
+
+	public String getSignCertPath() {
+		return signCertPath;
+	}
+
+	public void setSignCertPath(String signCertPath) {
+		this.signCertPath = signCertPath;
+	}
+
+	public String getSignCertPwd() {
+		return signCertPwd;
+	}
+
+	public void setSignCertPwd(String signCertPwd) {
+		this.signCertPwd = signCertPwd;
+	}
+
+	public String getSignCertType() {
+		return signCertType;
+	}
+
+	public void setSignCertType(String signCertType) {
+		this.signCertType = signCertType;
+	}
+
+	public String getEncryptCertPath() {
+		return encryptCertPath;
+	}
+
+	public void setEncryptCertPath(String encryptCertPath) {
+		this.encryptCertPath = encryptCertPath;
+	}
+	
+	public String getValidateCertDir() {
+		return validateCertDir;
+	}
+
+	public void setValidateCertDir(String validateCertDir) {
+		this.validateCertDir = validateCertDir;
+	}
+
+	public String getSingleQueryUrl() {
+		return singleQueryUrl;
+	}
+
+	public void setSingleQueryUrl(String singleQueryUrl) {
+		this.singleQueryUrl = singleQueryUrl;
+	}
+
+	public String getBatchQueryUrl() {
+		return batchQueryUrl;
+	}
+
+	public void setBatchQueryUrl(String batchQueryUrl) {
+		this.batchQueryUrl = batchQueryUrl;
+	}
+
+	public String getBatchTransUrl() {
+		return batchTransUrl;
+	}
+
+	public void setBatchTransUrl(String batchTransUrl) {
+		this.batchTransUrl = batchTransUrl;
+	}
+
+	public String getFileTransUrl() {
+		return fileTransUrl;
+	}
+
+	public void setFileTransUrl(String fileTransUrl) {
+		this.fileTransUrl = fileTransUrl;
+	}
+
+	public String getSignCertDir() {
+		return signCertDir;
+	}
+
+	public void setSignCertDir(String signCertDir) {
+		this.signCertDir = signCertDir;
+	}
+
+	public Properties getProperties() {
+		return properties;
+	}
+
+	public void setProperties(Properties properties) {
+		this.properties = properties;
+	}
+
+	public String getCardRequestUrl() {
+		return cardRequestUrl;
+	}
+
+	public void setCardRequestUrl(String cardRequestUrl) {
+		this.cardRequestUrl = cardRequestUrl;
+	}
+
+	public String getAppRequestUrl() {
+		return appRequestUrl;
+	}
+
+	public void setAppRequestUrl(String appRequestUrl) {
+		this.appRequestUrl = appRequestUrl;
+	}
+	
+	public String getEncryptTrackCertPath() {
+		return encryptTrackCertPath;
+	}
+
+	public void setEncryptTrackCertPath(String encryptTrackCertPath) {
+		this.encryptTrackCertPath = encryptTrackCertPath;
+	}
+	
+	public String getJfFrontRequestUrl() {
+		return jfFrontRequestUrl;
+	}
+
+	public void setJfFrontRequestUrl(String jfFrontRequestUrl) {
+		this.jfFrontRequestUrl = jfFrontRequestUrl;
+	}
+
+	public String getJfBackRequestUrl() {
+		return jfBackRequestUrl;
+	}
+
+	public void setJfBackRequestUrl(String jfBackRequestUrl) {
+		this.jfBackRequestUrl = jfBackRequestUrl;
+	}
+
+	public String getJfSingleQueryUrl() {
+		return jfSingleQueryUrl;
+	}
+
+	public void setJfSingleQueryUrl(String jfSingleQueryUrl) {
+		this.jfSingleQueryUrl = jfSingleQueryUrl;
+	}
+
+	public String getJfCardRequestUrl() {
+		return jfCardRequestUrl;
+	}
+
+	public void setJfCardRequestUrl(String jfCardRequestUrl) {
+		this.jfCardRequestUrl = jfCardRequestUrl;
+	}
+
+	public String getJfAppRequestUrl() {
+		return jfAppRequestUrl;
+	}
+
+	public void setJfAppRequestUrl(String jfAppRequestUrl) {
+		this.jfAppRequestUrl = jfAppRequestUrl;
+	}
+
+	public String getSingleMode() {
+		return singleMode;
+	}
+
+	public void setSingleMode(String singleMode) {
+		this.singleMode = singleMode;
+	}
+
+	public String getEncryptTrackKeyExponent() {
+		return encryptTrackKeyExponent;
+	}
+
+	public void setEncryptTrackKeyExponent(String encryptTrackKeyExponent) {
+		this.encryptTrackKeyExponent = encryptTrackKeyExponent;
+	}
+
+	public String getEncryptTrackKeyModulus() {
+		return encryptTrackKeyModulus;
+	}
+
+	public void setEncryptTrackKeyModulus(String encryptTrackKeyModulus) {
+		this.encryptTrackKeyModulus = encryptTrackKeyModulus;
+	}
+	
+	public String getSecureKey() {
+		return secureKey;
+	}
+
+	public void setSecureKey(String securityKey) {
+		this.secureKey = securityKey;
+	}
+	
+	public String getMiddleCertPath() {
+		return middleCertPath;
+	}
+
+	public void setMiddleCertPath(String middleCertPath) {
+		this.middleCertPath = middleCertPath;
+	}
+	
+	public boolean isIfValidateCNName() {
+		return ifValidateCNName;
+	}
+
+	public void setIfValidateCNName(boolean ifValidateCNName) {
+		this.ifValidateCNName = ifValidateCNName;
+	}
+
+	public boolean isIfValidateRemoteCert() {
+		return ifValidateRemoteCert;
+	}
+
+	public void setIfValidateRemoteCert(boolean ifValidateRemoteCert) {
+		this.ifValidateRemoteCert = ifValidateRemoteCert;
+	}
+
+	public String getSignMethod() {
+		return signMethod;
+	}
+
+	public void setSignMethod(String signMethod) {
+		this.signMethod = signMethod;
+	}
+	public String getQrcBackTransUrl() {
+		return qrcBackTransUrl;
+	}
+
+	public void setQrcBackTransUrl(String qrcBackTransUrl) {
+		this.qrcBackTransUrl = qrcBackTransUrl;
+	}
+
+	public String getQrcB2cIssBackTransUrl() {
+		return qrcB2cIssBackTransUrl;
+	}
+
+	public void setQrcB2cIssBackTransUrl(String qrcB2cIssBackTransUrl) {
+		this.qrcB2cIssBackTransUrl = qrcB2cIssBackTransUrl;
+	}
+
+	public String getQrcB2cMerBackTransUrl() {
+		return qrcB2cMerBackTransUrl;
+	}
+
+	public void setQrcB2cMerBackTransUrl(String qrcB2cMerBackTransUrl) {
+		this.qrcB2cMerBackTransUrl = qrcB2cMerBackTransUrl;
+	}
+
+	public String getZhrzFrontRequestUrl() {
+		return zhrzFrontRequestUrl;
+	}
+
+	public String getZhrzBackRequestUrl() {
+		return zhrzBackRequestUrl;
+	}
+
+	public String getZhrzSingleQueryUrl() {
+		return zhrzSingleQueryUrl;
+	}
+
+	public String getZhrzCardRequestUrl() {
+		return zhrzCardRequestUrl;
+	}
+
+	public String getZhrzAppRequestUrl() {
+		return zhrzAppRequestUrl;
+	}
+
+	public String getVersion() {
+		return version;
+	}
+
+	public void setVersion(String version) {
+		this.version = version;
+	}
+
+	public String getFrontUrl() {
+		return frontUrl;
+	}
+
+	public void setFrontUrl(String frontUrl) {
+		this.frontUrl = frontUrl;
+	}
+
+	public String getBackUrl() {
+		return backUrl;
+	}
+
+	public void setBackUrl(String backUrl) {
+		this.backUrl = backUrl;
+	}
+
+	public String getRootCertPath() {
+		return rootCertPath;
+	}
+
+	public void setRootCertPath(String rootCertPath) {
+		this.rootCertPath = rootCertPath;
+	}
+
+	public String getMerId() {
+		return merId;
+	}
+}

+ 391 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/SDKConstants.java

@@ -0,0 +1,391 @@
+/**
+ *
+ * Licensed Property to China UnionPay Co., Ltd.
+ * 
+ * (C) Copyright of China UnionPay Co., Ltd. 2010
+ *     All Rights Reserved.
+ *
+ * 
+ * Modification History:
+ * =============================================================================
+ *   Author         Date          Description
+ *   ------------ ---------- ---------------------------------------------------
+ *   xshu       2014-05-28       MPI插件包常量定义
+ * =============================================================================
+ */
+package com.lightinit.hsdataportal.Unionsdk;
+/**
+ * 
+ * @ClassName SDKConstants
+ * @Description acpsdk常量类
+ * @date 2016-7-22 下午4:05:54
+ * 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
+ */
+public class SDKConstants {
+
+	public final static String COLUMN_DEFAULT = "-";
+
+	public final static String KEY_DELIMITER = "#";
+
+	/** memeber variable: blank. */
+	public static final String BLANK = "";
+
+	/** member variabel: space. */
+	public static final String SPACE = " ";
+
+	/** memeber variable: unline. */
+	public static final String UNLINE = "_";
+
+	/** memeber varibale: star. */
+	public static final String STAR = "*";
+
+	/** memeber variable: line. */
+	public static final String LINE = "-";
+
+	/** memeber variable: add. */
+	public static final String ADD = "+";
+
+	/** memeber variable: colon. */
+	public final static String COLON = "|";
+
+	/** memeber variable: point. */
+	public final static String POINT = ".";
+
+	/** memeber variable: comma. */
+	public final static String COMMA = ",";
+
+	/** memeber variable: slash. */
+	public final static String SLASH = "/";
+
+	/** memeber variable: div. */
+	public final static String DIV = "/";
+
+	/** memeber variable: left . */
+	public final static String LB = "(";
+
+	/** memeber variable: right. */
+	public final static String RB = ")";
+
+	/** memeber variable: rmb. */
+	public final static String CUR_RMB = "RMB";
+
+	/** memeber variable: .page size */
+	public static final int PAGE_SIZE = 10;
+
+	/** memeber variable: String ONE. */
+	public static final String ONE = "1";
+
+	/** memeber variable: String ZERO. */
+	public static final String ZERO = "0";
+
+	/** memeber variable: number six. */
+	public static final int NUM_SIX = 6;
+
+	/** memeber variable: equal mark. */
+	public static final String EQUAL = "=";
+
+	/** memeber variable: operation ne. */
+	public static final String NE = "!=";
+
+	/** memeber variable: operation le. */
+	public static final String LE = "<=";
+
+	/** memeber variable: operation ge. */
+	public static final String GE = ">=";
+
+	/** memeber variable: operation lt. */
+	public static final String LT = "<";
+
+	/** memeber variable: operation gt. */
+	public static final String GT = ">";
+
+	/** memeber variable: list separator. */
+	public static final String SEP = "./";
+
+	/** memeber variable: Y. */
+	public static final String Y = "Y";
+
+	/** memeber variable: AMPERSAND. */
+	public static final String AMPERSAND = "&";
+
+	/** memeber variable: SQL_LIKE_TAG. */
+	public static final String SQL_LIKE_TAG = "%";
+
+	/** memeber variable: @. */
+	public static final String MAIL = "@";
+
+	/** memeber variable: number zero. */
+	public static final int NZERO = 0;
+
+	public static final String LEFT_BRACE = "{";
+
+	public static final String RIGHT_BRACE = "}";
+
+	/** memeber variable: string true. */
+	public static final String TRUE_STRING = "true";
+	/** memeber variable: string false. */
+	public static final String FALSE_STRING = "false";
+
+	/** memeber variable: forward success. */
+	public static final String SUCCESS = "success";
+	/** memeber variable: forward fail. */
+	public static final String FAIL = "fail";
+	/** memeber variable: global forward success. */
+	public static final String GLOBAL_SUCCESS = "$success";
+	/** memeber variable: global forward fail. */
+	public static final String GLOBAL_FAIL = "$fail";
+
+	public static final String UTF_8_ENCODING = "UTF-8";
+	public static final String GBK_ENCODING = "GBK";
+	public static final String CONTENT_TYPE = "Content-type";
+	public static final String APP_XML_TYPE = "application/xml;charset=utf-8";
+	public static final String APP_FORM_TYPE = "application/x-www-form-urlencoded;charset=";
+	
+	public static final String VERSION_1_0_0 = "1.0.0";
+	public static final String VERSION_5_0_0 = "5.0.0";
+	public static final String VERSION_5_0_1 = "5.0.1";
+	public static final String VERSION_5_1_0 = "5.1.0";
+	public static final String SIGNMETHOD_RSA = "01";
+	public static final String SIGNMETHOD_SHA256 = "11";
+	public static final String SIGNMETHOD_SM3 = "12";
+	public static final String UNIONPAY_CNNAME = "中国银联股份有限公司";
+	public static final String CERTTYPE_01 = "01";// 敏感信息加密公钥
+	public static final String CERTTYPE_02 = "02";// 磁道加密公钥
+
+	/******************************************** 5.0报文接口定义 ********************************************/
+	/** 版本号. */
+	public static final String param_version = "version";
+	/** 证书ID. */
+	public static final String param_certId = "certId";
+	/** 签名. */
+	public static final String param_signature = "signature";
+	/** 签名方法. */
+	public static final String param_signMethod = "signMethod";
+	/** 编码方式. */
+	public static final String param_encoding = "encoding";
+	/** 交易类型. */
+	public static final String param_txnType = "txnType";
+	/** 交易子类. */
+	public static final String param_txnSubType = "txnSubType";
+	/** 业务类型. */
+	public static final String param_bizType = "bizType";
+	/** 前台通知地址 . */
+	public static final String param_frontUrl = "frontUrl";
+	/** 后台通知地址. */
+	public static final String param_backUrl = "backUrl";
+	/** 接入类型. */
+	public static final String param_accessType = "accessType";
+	/** 收单机构代码. */
+	public static final String param_acqInsCode = "acqInsCode";
+	/** 商户类别. */
+	public static final String param_merCatCode = "merCatCode";
+	/** 商户类型. */
+	public static final String param_merType = "merType";
+	/** 商户代码. */
+	public static final String param_merId = "merId";
+	/** 商户名称. */
+	public static final String param_merName = "merName";
+	/** 商户简称. */
+	public static final String param_merAbbr = "merAbbr";
+	/** 二级商户代码. */
+	public static final String param_subMerId = "subMerId";
+	/** 二级商户名称. */
+	public static final String param_subMerName = "subMerName";
+	/** 二级商户简称. */
+	public static final String param_subMerAbbr = "subMerAbbr";
+	/** Cupsecure 商户代码. */
+	public static final String param_csMerId = "csMerId";
+	/** 商户订单号. */
+	public static final String param_orderId = "orderId";
+	/** 交易时间. */
+	public static final String param_txnTime = "txnTime";
+	/** 发送时间. */
+	public static final String param_txnSendTime = "txnSendTime";
+	/** 订单超时时间间隔. */
+	public static final String param_orderTimeoutInterval = "orderTimeoutInterval";
+	/** 支付超时时间. */
+	public static final String param_payTimeoutTime = "payTimeoutTime";
+	/** 默认支付方式. */
+	public static final String param_defaultPayType = "defaultPayType";
+	/** 支持支付方式. */
+	public static final String param_supPayType = "supPayType";
+	/** 支付方式. */
+	public static final String param_payType = "payType";
+	/** 自定义支付方式. */
+	public static final String param_customPayType = "customPayType";
+	/** 物流标识. */
+	public static final String param_shippingFlag = "shippingFlag";
+	/** 收货地址-国家. */
+	public static final String param_shippingCountryCode = "shippingCountryCode";
+	/** 收货地址-省. */
+	public static final String param_shippingProvinceCode = "shippingProvinceCode";
+	/** 收货地址-市. */
+	public static final String param_shippingCityCode = "shippingCityCode";
+	/** 收货地址-地区. */
+	public static final String param_shippingDistrictCode = "shippingDistrictCode";
+	/** 收货地址-详细. */
+	public static final String param_shippingStreet = "shippingStreet";
+	/** 商品总类. */
+	public static final String param_commodityCategory = "commodityCategory";
+	/** 商品名称. */
+	public static final String param_commodityName = "commodityName";
+	/** 商品URL. */
+	public static final String param_commodityUrl = "commodityUrl";
+	/** 商品单价. */
+	public static final String param_commodityUnitPrice = "commodityUnitPrice";
+	/** 商品数量. */
+	public static final String param_commodityQty = "commodityQty";
+	/** 是否预授权. */
+	public static final String param_isPreAuth = "isPreAuth";
+	/** 币种. */
+	public static final String param_currencyCode = "currencyCode";
+	/** 账户类型. */
+	public static final String param_accType = "accType";
+	/** 账号. */
+	public static final String param_accNo = "accNo";
+	/** 支付卡类型. */
+	public static final String param_payCardType = "payCardType";
+	/** 发卡机构代码. */
+	public static final String param_issInsCode = "issInsCode";
+	/** 持卡人信息. */
+	public static final String param_customerInfo = "customerInfo";
+	/** 交易金额. */
+	public static final String param_txnAmt = "txnAmt";
+	/** 余额. */
+	public static final String param_balance = "balance";
+	/** 地区代码. */
+	public static final String param_districtCode = "districtCode";
+	/** 附加地区代码. */
+	public static final String param_additionalDistrictCode = "additionalDistrictCode";
+	/** 账单类型. */
+	public static final String param_billType = "billType";
+	/** 账单号码. */
+	public static final String param_billNo = "billNo";
+	/** 账单月份. */
+	public static final String param_billMonth = "billMonth";
+	/** 账单查询要素. */
+	public static final String param_billQueryInfo = "billQueryInfo";
+	/** 账单详情. */
+	public static final String param_billDetailInfo = "billDetailInfo";
+	/** 账单金额. */
+	public static final String param_billAmt = "billAmt";
+	/** 账单金额符号. */
+	public static final String param_billAmtSign = "billAmtSign";
+	/** 绑定标识号. */
+	public static final String param_bindId = "bindId";
+	/** 风险级别. */
+	public static final String param_riskLevel = "riskLevel";
+	/** 绑定信息条数. */
+	public static final String param_bindInfoQty = "bindInfoQty";
+	/** 绑定信息集. */
+	public static final String param_bindInfoList = "bindInfoList";
+	/** 批次号. */
+	public static final String param_batchNo = "batchNo";
+	/** 总笔数. */
+	public static final String param_totalQty = "totalQty";
+	/** 总金额. */
+	public static final String param_totalAmt = "totalAmt";
+	/** 文件类型. */
+	public static final String param_fileType = "fileType";
+	/** 文件名称. */
+	public static final String param_fileName = "fileName";
+	/** 批量文件内容. */
+	public static final String param_fileContent = "fileContent";
+	/** 商户摘要. */
+	public static final String param_merNote = "merNote";
+	/** 商户自定义域. */
+	// public static final String param_merReserved = "merReserved";//接口变更删除
+	/** 请求方保留域. */
+	public static final String param_reqReserved = "reqReserved";// 新增接口
+	/** 保留域. */
+	public static final String param_reserved = "reserved";
+	/** 终端号. */
+	public static final String param_termId = "termId";
+	/** 终端类型. */
+	public static final String param_termType = "termType";
+	/** 交互模式. */
+	public static final String param_interactMode = "interactMode";
+	/** 发卡机构识别模式. */
+	// public static final String param_recognitionMode = "recognitionMode";
+	public static final String param_issuerIdentifyMode = "issuerIdentifyMode";// 接口名称变更
+	/** 商户端用户号. */
+	public static final String param_merUserId = "merUserId";
+	/** 持卡人IP. */
+	public static final String param_customerIp = "customerIp";
+	/** 查询流水号. */
+	public static final String param_queryId = "queryId";
+	/** 原交易查询流水号. */
+	public static final String param_origQryId = "origQryId";
+	/** 系统跟踪号. */
+	public static final String param_traceNo = "traceNo";
+	/** 交易传输时间. */
+	public static final String param_traceTime = "traceTime";
+	/** 清算日期. */
+	public static final String param_settleDate = "settleDate";
+	/** 清算币种. */
+	public static final String param_settleCurrencyCode = "settleCurrencyCode";
+	/** 清算金额. */
+	public static final String param_settleAmt = "settleAmt";
+	/** 清算汇率. */
+	public static final String param_exchangeRate = "exchangeRate";
+	/** 兑换日期. */
+	public static final String param_exchangeDate = "exchangeDate";
+	/** 响应时间. */
+	public static final String param_respTime = "respTime";
+	/** 原交易应答码. */
+	public static final String param_origRespCode = "origRespCode";
+	/** 原交易应答信息. */
+	public static final String param_origRespMsg = "origRespMsg";
+	/** 应答码. */
+	public static final String param_respCode = "respCode";
+	/** 应答码信息. */
+	public static final String param_respMsg = "respMsg";
+	// 新增四个报文字段merUserRegDt merUserEmail checkFlag activateStatus
+	/** 商户端用户注册时间. */
+	public static final String param_merUserRegDt = "merUserRegDt";
+	/** 商户端用户注册邮箱. */
+	public static final String param_merUserEmail = "merUserEmail";
+	/** 验证标识. */
+	public static final String param_checkFlag = "checkFlag";
+	/** 开通状态. */
+	public static final String param_activateStatus = "activateStatus";
+	/** 加密证书ID. */
+	public static final String param_encryptCertId = "encryptCertId";
+	/** 用户MAC、IMEI串号、SSID. */
+	public static final String param_userMac = "userMac";
+	/** 关联交易. */
+	// public static final String param_relationTxnType = "relationTxnType";
+	/** 短信类型 */
+	public static final String param_smsType = "smsType";
+
+	/** 风控信息域 */
+	public static final String param_riskCtrlInfo = "riskCtrlInfo";
+
+	/** IC卡交易信息域 */
+	public static final String param_ICTransData = "ICTransData";
+
+	/** VPC交易信息域 */
+	public static final String param_VPCTransData = "VPCTransData";
+
+	/** 安全类型 */
+	public static final String param_securityType = "securityType";
+
+	/** 银联订单号 */
+	public static final String param_tn = "tn";
+
+	/** 分期付款手续费率 */
+	public static final String param_instalRate = "instalRate";
+
+	/** 分期付款手续费率 */
+	public static final String param_mchntFeeSubsidy = "mchntFeeSubsidy";
+	
+	/** 签名公钥证书 */
+	public static final String param_signPubKeyCert = "signPubKeyCert";
+
+	/** 加密公钥证书 */
+	public static final String param_encryptPubKeyCert = "encryptPubKeyCert";
+	
+	/** 证书类型 */
+	public static final String param_certType = "certType";
+
+}

+ 875 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/SDKUtil.java

@@ -0,0 +1,875 @@
+/**
+ *
+ * Licensed Property to China UnionPay Co., Ltd.
+ * 
+ * (C) Copyright of China UnionPay Co., Ltd. 2010
+ *     All Rights Reserved.
+ *
+ * 
+ * Modification History:
+ * =============================================================================
+ *   Author         Date          Description
+ *   ------------ ---------- ---------------------------------------------------
+ *   xshu       2014-05-28      MPI工具类
+ * =============================================================================
+ */
+package com.lightinit.hsdataportal.Unionsdk;
+
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.CERTTYPE_01;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.CERTTYPE_02;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.POINT;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.SIGNMETHOD_RSA;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.SIGNMETHOD_SHA256;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.SIGNMETHOD_SM3;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.VERSION_5_0_0;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.VERSION_1_0_0;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.VERSION_5_1_0;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.VERSION_5_0_1;
+import static com.lightinit.hsdataportal.Unionsdk.SDKConstants.param_signMethod;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.security.cert.X509Certificate;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.zip.Deflater;
+import java.util.zip.Inflater;
+
+/**
+ * 
+ * @ClassName SDKUtil
+ * @Description acpsdk工具类
+ * @date 2016-7-22 下午4:06:18
+ * 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
+ */
+public class SDKUtil {
+
+	/**
+	 * 根据signMethod的值,提供三种计算签名的方法
+	 * 
+	 * @param data
+	 *            待签名数据Map键值对形式
+	 * @param encoding
+	 *            编码
+	 * @return 签名是否成功
+	 */
+	public static boolean sign(Map<String, String> data, String encoding) {
+		
+		if (isEmpty(encoding)) {
+			encoding = "UTF-8";
+		}
+		String signMethod = data.get(param_signMethod);
+		String version = data.get(SDKConstants.param_version);
+		if (!VERSION_1_0_0.equals(version) && !VERSION_5_0_1.equals(version) && isEmpty(signMethod)) {
+			LogUtil.writeErrorLog("signMethod must Not null");
+			return false;
+		}
+		
+		if (isEmpty(version)) {
+			LogUtil.writeErrorLog("version must Not null");
+			return false;
+		}
+		if (SIGNMETHOD_RSA.equals(signMethod)|| VERSION_1_0_0.equals(version) || VERSION_5_0_1.equals(version)) {
+			if (VERSION_5_0_0.equals(version)|| VERSION_1_0_0.equals(version) || VERSION_5_0_1.equals(version)) {
+				// 设置签名证书序列号
+				data.put(SDKConstants.param_certId, CertUtil.getSignCertId());
+				// 将Map信息转换成key1=value1&key2=value2的形式
+				String stringData = coverMap2String(data);
+				LogUtil.writeLog("打印排序后待签名请求报文串(交易返回11验证签名失败时可以用来同正确的进行比对):[" + stringData + "]");
+				byte[] byteSign = null;
+				String stringSign = null;
+				try {
+					// 通过SHA1进行摘要并转16进制
+					byte[] signDigest = SecureUtil
+							.sha1X16(stringData, encoding);
+					LogUtil.writeLog("打印摘要(交易返回11验证签名失败可以用来同正确的进行比对):[" + new String(signDigest)+ "]");
+					byteSign = SecureUtil.base64Encode(SecureUtil.signBySoft(
+							CertUtil.getSignCertPrivateKey(), signDigest));
+					stringSign = new String(byteSign);
+					// 设置签名域值
+					data.put(SDKConstants.param_signature, stringSign);
+					return true;
+				} catch (Exception e) {
+					LogUtil.writeErrorLog("Sign Error", e);
+					return false;
+				}
+			} else if (VERSION_5_1_0.equals(version)) {
+				// 设置签名证书序列号
+				data.put(SDKConstants.param_certId, CertUtil.getSignCertId());
+				// 将Map信息转换成key1=value1&key2=value2的形式
+				String stringData = coverMap2String(data);
+				LogUtil.writeLog("打印待签名请求报文串(交易返回11验证签名失败时可以用来同正确的进行比对):[" + stringData + "]");
+				byte[] byteSign = null;
+				String stringSign = null;
+				try {
+					// 通过SHA256进行摘要并转16进制
+					byte[] signDigest = SecureUtil
+							.sha256X16(stringData, encoding);
+					LogUtil.writeLog("打印摘要(交易返回11验证签名失败可以用来同正确的进行比对):[" + new String(signDigest)+ "]");
+					byteSign = SecureUtil.base64Encode(SecureUtil.signBySoft256(
+							CertUtil.getSignCertPrivateKey(), signDigest));
+					stringSign = new String(byteSign);
+					// 设置签名域值
+					data.put(SDKConstants.param_signature, stringSign);
+					return true;
+				} catch (Exception e) {
+					LogUtil.writeErrorLog("Sign Error", e);
+					return false;
+				}
+			}
+		} else if (SIGNMETHOD_SHA256.equals(signMethod)) {
+			return signBySecureKey(data, SDKConfig.getConfig()
+					.getSecureKey(), encoding);
+		} else if (SIGNMETHOD_SM3.equals(signMethod)) {
+			return signBySecureKey(data, SDKConfig.getConfig()
+					.getSecureKey(), encoding);
+		}
+		return false;
+	}
+
+	/**
+	 * 通过传入的证书绝对路径和证书密码读取签名证书进行签名并返回签名值<br>
+	 * 
+	 * @param data
+	 *            待签名数据Map键值对形式
+	 * @param encoding
+	 *            编码
+	 * @return 签名值
+	 */
+	public static boolean signBySecureKey(Map<String, String> data, String secureKey,
+			String encoding) {
+		
+		if (isEmpty(encoding)) {
+			encoding = "UTF-8";
+		}
+		if (isEmpty(secureKey)) {
+			LogUtil.writeErrorLog("secureKey is empty");
+			return false;
+		}
+		String signMethod = data.get(param_signMethod);
+		if (isEmpty(signMethod)) {
+			LogUtil.writeErrorLog("signMethod must Not null");
+			return false;
+		}
+		
+		if (SIGNMETHOD_SHA256.equals(signMethod)) {
+			// 将Map信息转换成key1=value1&key2=value2的形式
+			String stringData = coverMap2String(data);
+			LogUtil.writeLog("待签名请求报文串:[" + stringData + "]");
+			String strBeforeSha256 = stringData
+					+ SDKConstants.AMPERSAND
+					+ SecureUtil.sha256X16Str(secureKey, encoding);
+			String strAfterSha256 = SecureUtil.sha256X16Str(strBeforeSha256,
+					encoding);
+			// 设置签名域值
+			data.put(SDKConstants.param_signature, strAfterSha256);
+			return true;
+		} else if (SIGNMETHOD_SM3.equals(signMethod)) {
+			String stringData = coverMap2String(data);
+			LogUtil.writeLog("待签名请求报文串:[" + stringData + "]");
+			String strBeforeSM3 = stringData
+					+ SDKConstants.AMPERSAND
+					+ SecureUtil.sm3X16Str(secureKey, encoding);
+			String strAfterSM3 = SecureUtil.sm3X16Str(strBeforeSM3, encoding);
+			// 设置签名域值
+			data.put(SDKConstants.param_signature, strAfterSM3);
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * 通过传入的签名密钥进行签名并返回签名值<br>
+	 * 
+	 * @param data
+	 *            待签名数据Map键值对形式
+	 * @param encoding
+	 *            编码
+	 * @param certPath
+	 *            证书绝对路径
+	 * @param certPwd
+	 *            证书密码
+	 * @return 签名值
+	 */
+	public static boolean signByCertInfo(Map<String, String> data,
+			String certPath, String certPwd, String encoding) {
+		
+		if (isEmpty(encoding)) {
+			encoding = "UTF-8";
+		}
+		if (isEmpty(certPath) || isEmpty(certPwd)) {
+			LogUtil.writeErrorLog("CertPath or CertPwd is empty");
+			return false;
+		}
+		String signMethod = data.get(param_signMethod);
+		String version = data.get(SDKConstants.param_version);
+		if (!VERSION_1_0_0.equals(version) && !VERSION_5_0_1.equals(version) && isEmpty(signMethod)) {
+			LogUtil.writeErrorLog("signMethod must Not null");
+			return false;
+		}
+		if (isEmpty(version)) {
+			LogUtil.writeErrorLog("version must Not null");
+			return false;
+		}
+		
+		if (SIGNMETHOD_RSA.equals(signMethod) || VERSION_1_0_0.equals(version) || VERSION_5_0_1.equals(version)) {
+			if (VERSION_5_0_0.equals(version) || VERSION_1_0_0.equals(version) || VERSION_5_0_1.equals(version)) {
+				// 设置签名证书序列号
+				data.put(SDKConstants.param_certId, CertUtil.getCertIdByKeyStoreMap(certPath, certPwd));
+				// 将Map信息转换成key1=value1&key2=value2的形式
+				String stringData = coverMap2String(data);
+				LogUtil.writeLog("待签名请求报文串:[" + stringData + "]");
+				byte[] byteSign = null;
+				String stringSign = null;
+				try {
+					// 通过SHA1进行摘要并转16进制
+					byte[] signDigest = SecureUtil
+							.sha1X16(stringData, encoding);
+					byteSign = SecureUtil.base64Encode(SecureUtil.signBySoft(
+							CertUtil.getSignCertPrivateKeyByStoreMap(certPath, certPwd), signDigest));
+					stringSign = new String(byteSign);
+					// 设置签名域值
+					data.put(SDKConstants.param_signature, stringSign);
+					return true;
+				} catch (Exception e) {
+					LogUtil.writeErrorLog("Sign Error", e);
+					return false;
+				}
+			} else if (VERSION_5_1_0.equals(version)) {
+				// 设置签名证书序列号
+				data.put(SDKConstants.param_certId, CertUtil.getCertIdByKeyStoreMap(certPath, certPwd));
+				// 将Map信息转换成key1=value1&key2=value2的形式
+				String stringData = coverMap2String(data);
+				LogUtil.writeLog("待签名请求报文串:[" + stringData + "]");
+				byte[] byteSign = null;
+				String stringSign = null;
+				try {
+					// 通过SHA256进行摘要并转16进制
+					byte[] signDigest = SecureUtil
+							.sha256X16(stringData, encoding);
+					byteSign = SecureUtil.base64Encode(SecureUtil.signBySoft256(
+							CertUtil.getSignCertPrivateKeyByStoreMap(certPath, certPwd), signDigest));
+					stringSign = new String(byteSign);
+					// 设置签名域值
+					data.put(SDKConstants.param_signature, stringSign);
+					return true;
+				} catch (Exception e) {
+					LogUtil.writeErrorLog("Sign Error", e);
+					return false;
+				}
+			}
+			
+		} 
+		return false;
+	}
+	
+	/**
+	 * 验证签名
+	 * 
+	 * @param resData
+	 *            返回报文数据
+	 * @param encoding
+	 *            编码格式
+	 * @return
+	 */
+	public static boolean validateBySecureKey(Map<String, String> resData, String secureKey, String encoding) {
+		LogUtil.writeLog("验签处理开始");
+		if (isEmpty(encoding)) {
+			encoding = "UTF-8";
+		}
+		String signMethod = resData.get(SDKConstants.param_signMethod);
+		if (SIGNMETHOD_SHA256.equals(signMethod)) {
+			// 1.进行SHA256验证
+			String stringSign = resData.get(SDKConstants.param_signature);
+			LogUtil.writeLog("签名原文:["+stringSign+"]");
+			// 将Map信息转换成key1=value1&key2=value2的形式
+			String stringData = coverMap2String(resData);
+			LogUtil.writeLog("待验签返回报文串:["+stringData+"]");
+			String strBeforeSha256 = stringData
+					+ SDKConstants.AMPERSAND
+					+ SecureUtil.sha256X16Str(secureKey, encoding);
+			String strAfterSha256 = SecureUtil.sha256X16Str(strBeforeSha256,
+					encoding);
+			return stringSign.equals(strAfterSha256);
+		} else if (SIGNMETHOD_SM3.equals(signMethod)) {
+			// 1.进行SM3验证
+			String stringSign = resData.get(SDKConstants.param_signature);
+			LogUtil.writeLog("签名原文:["+stringSign+"]");
+			// 将Map信息转换成key1=value1&key2=value2的形式
+			String stringData = coverMap2String(resData);
+			LogUtil.writeLog("待验签返回报文串:["+stringData+"]");
+			String strBeforeSM3 = stringData
+					+ SDKConstants.AMPERSAND
+					+ SecureUtil.sm3X16Str(secureKey, encoding);
+			String strAfterSM3 = SecureUtil
+					.sm3X16Str(strBeforeSM3, encoding);
+			return stringSign.equals(strAfterSM3);
+		}
+		return false;
+	}
+	
+	/**
+	 * 验证签名
+	 * 
+	 * @param resData
+	 *            返回报文数据
+	 * @param encoding
+	 *            编码格式
+	 * @return
+	 */
+	public static boolean validate(Map<String, String> resData, String encoding) {
+		LogUtil.writeLog("验签处理开始");
+		if (isEmpty(encoding)) {
+			encoding = "UTF-8";
+		}
+		String signMethod = resData.get(SDKConstants.param_signMethod);
+		String version = resData.get(SDKConstants.param_version);
+		if (SIGNMETHOD_RSA.equals(signMethod) || VERSION_1_0_0.equals(version) || VERSION_5_0_1.equals(version)) {
+			// 获取返回报文的版本号
+			if (VERSION_5_0_0.equals(version) || VERSION_1_0_0.equals(version) || VERSION_5_0_1.equals(version)) {
+				String stringSign = resData.get(SDKConstants.param_signature);
+				LogUtil.writeLog("签名原文:["+stringSign+"]");
+				// 从返回报文中获取certId ,然后去证书静态Map中查询对应验签证书对象
+				String certId = resData.get(SDKConstants.param_certId);
+				LogUtil.writeLog("对返回报文串验签使用的验签公钥序列号:["+certId+"]");
+				// 将Map信息转换成key1=value1&key2=value2的形式
+				String stringData = coverMap2String(resData);
+				LogUtil.writeLog("待验签返回报文串:["+stringData+"]");
+				try {
+					// 验证签名需要用银联发给商户的公钥证书.
+					return SecureUtil.validateSignBySoft(CertUtil
+							.getValidatePublicKey(certId), SecureUtil
+							.base64Decode(stringSign.getBytes(encoding)),
+							SecureUtil.sha1X16(stringData, encoding));
+				} catch (UnsupportedEncodingException e) {
+					LogUtil.writeErrorLog(e.getMessage(), e);
+				} catch (Exception e) {
+					LogUtil.writeErrorLog(e.getMessage(), e);
+				}
+			} else if (VERSION_5_1_0.equals(version)) {
+				// 1.从返回报文中获取公钥信息转换成公钥对象
+				String strCert = resData.get(SDKConstants.param_signPubKeyCert);
+//				LogUtil.writeLog("验签公钥证书:["+strCert+"]");
+				X509Certificate x509Cert = CertUtil.genCertificateByStr(strCert);
+				if(x509Cert == null) {
+					LogUtil.writeErrorLog("convert signPubKeyCert failed");
+					return false;
+				}
+				// 2.验证证书链
+				if (!CertUtil.verifyCertificate(x509Cert)) {
+					LogUtil.writeErrorLog("验证公钥证书失败,证书信息:["+strCert+"]");
+					return false;
+				}
+				
+				// 3.验签
+				String stringSign = resData.get(SDKConstants.param_signature);
+				LogUtil.writeLog("签名原文:["+stringSign+"]");
+				// 将Map信息转换成key1=value1&key2=value2的形式
+				String stringData = coverMap2String(resData);
+				LogUtil.writeLog("待验签返回报文串:["+stringData+"]");
+				try {
+					// 验证签名需要用银联发给商户的公钥证书.
+					boolean result = SecureUtil.validateSignBySoft256(x509Cert
+							.getPublicKey(), SecureUtil.base64Decode(stringSign
+							.getBytes(encoding)), SecureUtil.sha256X16(
+							stringData, encoding));
+					LogUtil.writeLog("验证签名" + (result? "成功":"失败"));
+					return result;
+				} catch (UnsupportedEncodingException e) {
+					LogUtil.writeErrorLog(e.getMessage(), e);
+				} catch (Exception e) {
+					LogUtil.writeErrorLog(e.getMessage(), e);
+				}
+			}
+
+		} else if (SIGNMETHOD_SHA256.equals(signMethod)) {
+			// 1.进行SHA256验证
+			String stringSign = resData.get(SDKConstants.param_signature);
+			LogUtil.writeLog("签名原文:["+stringSign+"]");
+			// 将Map信息转换成key1=value1&key2=value2的形式
+			String stringData = coverMap2String(resData);
+			LogUtil.writeLog("待验签返回报文串:["+stringData+"]");
+			String strBeforeSha256 = stringData
+					+ SDKConstants.AMPERSAND
+					+ SecureUtil.sha256X16Str(SDKConfig.getConfig()
+							.getSecureKey(), encoding);
+			String strAfterSha256 = SecureUtil.sha256X16Str(strBeforeSha256,
+					encoding);
+			boolean result =  stringSign.equals(strAfterSha256);
+			LogUtil.writeLog("验证签名" + (result? "成功":"失败"));
+			return result;
+		} else if (SIGNMETHOD_SM3.equals(signMethod)) {
+			// 1.进行SM3验证
+			String stringSign = resData.get(SDKConstants.param_signature);
+			LogUtil.writeLog("签名原文:["+stringSign+"]");
+			// 将Map信息转换成key1=value1&key2=value2的形式
+			String stringData = coverMap2String(resData);
+			LogUtil.writeLog("待验签返回报文串:["+stringData+"]");
+			String strBeforeSM3 = stringData
+					+ SDKConstants.AMPERSAND
+					+ SecureUtil.sm3X16Str(SDKConfig.getConfig()
+							.getSecureKey(), encoding);
+			String strAfterSM3 = SecureUtil
+					.sm3X16Str(strBeforeSM3, encoding);
+			boolean result =  stringSign.equals(strAfterSM3);
+			LogUtil.writeLog("验证签名" + (result? "成功":"失败"));
+			return result;
+		}
+		return false;
+	}
+
+	/**
+	 * 将Map中的数据转换成key1=value1&key2=value2的形式 不包含签名域signature
+	 * 
+	 * @param data
+	 *            待拼接的Map数据
+	 * @return 拼接好后的字符串
+	 */
+	public static String coverMap2String(Map<String, String> data) {
+		TreeMap<String, String> tree = new TreeMap<String, String>();
+		Iterator<Entry<String, String>> it = data.entrySet().iterator();
+		while (it.hasNext()) {
+			Entry<String, String> en = it.next();
+			if (SDKConstants.param_signature.equals(en.getKey().trim())) {
+				continue;
+			}
+			tree.put(en.getKey(), en.getValue());
+		}
+		it = tree.entrySet().iterator();
+		StringBuffer sf = new StringBuffer();
+		while (it.hasNext()) {
+			Entry<String, String> en = it.next();
+			sf.append(en.getKey() + SDKConstants.EQUAL + en.getValue()
+					+ SDKConstants.AMPERSAND);
+		}
+		return sf.substring(0, sf.length() - 1);
+	}
+
+
+	/**
+	 * 兼容老方法 将形如key=value&key=value的字符串转换为相应的Map对象
+	 * 
+	 * @param result
+	 * @return
+	 */
+	public static Map<String, String> coverResultString2Map(String result) {
+		return convertResultStringToMap(result);
+	}
+
+	/**
+	 * 将形如key=value&key=value的字符串转换为相应的Map对象
+	 * 
+	 * @param result
+	 * @return
+	 */
+	public static Map<String, String> convertResultStringToMap(String result) {
+		Map<String, String> map = null;
+
+		if (result != null && !"".equals(result.trim())) {
+			if (result.startsWith("{") && result.endsWith("}")) {
+				result = result.substring(1, result.length() - 1);
+			}
+			map = parseQString(result);
+		}
+
+		return map;
+	}
+
+	
+	/**
+	 * 解析应答字符串,生成应答要素
+	 * 
+	 * @param str
+	 *            需要解析的字符串
+	 * @return 解析的结果map
+	 * @throws UnsupportedEncodingException
+	 */
+	public static Map<String, String> parseQString(String str) {
+
+		Map<String, String> map = new HashMap<String, String>();
+		int len = str.length();
+		StringBuilder temp = new StringBuilder();
+		char curChar;
+		String key = null;
+		boolean isKey = true;
+		boolean isOpen = false;//值里有嵌套
+		char openName = 0;
+		if(len>0){
+			for (int i = 0; i < len; i++) {// 遍历整个带解析的字符串
+				curChar = str.charAt(i);// 取当前字符
+				if (isKey) {// 如果当前生成的是key
+					
+					if (curChar == '=') {// 如果读取到=分隔符 
+						key = temp.toString();
+						temp.setLength(0);
+						isKey = false;
+					} else {
+						temp.append(curChar);
+					}
+				} else  {// 如果当前生成的是value
+					if(isOpen){
+						if(curChar == openName){
+							isOpen = false;
+						}
+						
+					}else{//如果没开启嵌套
+						if(curChar == '{'){//如果碰到,就开启嵌套
+							isOpen = true;
+							openName ='}';
+						}
+						if(curChar == '['){
+							isOpen = true;
+							openName =']';
+						}
+					}
+					
+					if (curChar == '&' && !isOpen) {// 如果读取到&分割符,同时这个分割符不是值域,这时将map里添加
+						putKeyValueToMap(temp, isKey, key, map);
+						temp.setLength(0);
+						isKey = true;
+					} else {
+						temp.append(curChar);
+					}
+				}
+				
+			}
+			putKeyValueToMap(temp, isKey, key, map);
+		}
+		return map;
+	}
+
+	private static void putKeyValueToMap(StringBuilder temp, boolean isKey,
+			String key, Map<String, String> map) {
+		if (isKey) {
+			key = temp.toString();
+			if (key.length() == 0) {
+				throw new RuntimeException("QString format illegal");
+			}
+			map.put(key, "");
+		} else {
+			if (key.length() == 0) {
+				throw new RuntimeException("QString format illegal");
+			}
+			map.put(key, temp.toString());
+		}
+	}
+
+	/**
+	 * 
+	 * 获取应答报文中的加密公钥证书,并存储到本地,并备份原始证书<br>
+	 * 更新成功则返回1,无更新返回0,失败异常返回-1。
+	 * 
+	 * @param resData
+	 * @param encoding
+	 * @return
+	 */
+	public static int getEncryptCert(Map<String, String> resData,
+			String encoding) {
+		String strCert = resData.get(SDKConstants.param_encryptPubKeyCert);
+		String certType = resData.get(SDKConstants.param_certType);
+		if (isEmpty(strCert) || isEmpty(certType))
+			return -1;
+		X509Certificate x509Cert = CertUtil.genCertificateByStr(strCert);
+		if (CERTTYPE_01.equals(certType)) {
+			// 更新敏感信息加密公钥
+			if (!CertUtil.getEncryptCertId().equals(
+					x509Cert.getSerialNumber().toString())) {
+				// ID不同时进行本地证书更新操作
+				String localCertPath = SDKConfig.getConfig().getEncryptCertPath();
+				String newLocalCertPath = genBackupName(localCertPath);
+				// 1.将本地证书进行备份存储
+				if (!copyFile(localCertPath, newLocalCertPath))
+					return -1;
+				// 2.备份成功,进行新证书的存储
+				if (!writeFile(localCertPath, strCert, encoding))
+					return -1;
+				LogUtil.writeLog("save new encryptPubKeyCert success");
+				CertUtil.resetEncryptCertPublicKey();
+				return 1;
+			}else {
+				return 0;
+			}
+
+		} else if (CERTTYPE_02.equals(certType)) {
+//			// 更新磁道加密公钥
+//			if (!CertUtil.getEncryptTrackCertId().equals(
+//					x509Cert.getSerialNumber().toString())) {
+//				// ID不同时进行本地证书更新操作
+//				String localCertPath = SDKConfig.getConfig().getEncryptTrackCertPath();
+//				String newLocalCertPath = genBackupName(localCertPath);
+//				// 1.将本地证书进行备份存储
+//				if (!copyFile(localCertPath, newLocalCertPath))
+//					return -1;
+//				// 2.备份成功,进行新证书的存储
+//				if (!writeFile(localCertPath, strCert, encoding))
+//					return -1;
+//				LogUtil.writeLog("save new encryptPubKeyCert success");
+//				CertUtil.resetEncryptTrackCertPublicKey();
+//				return 1;
+//			}else {
+				return 0;
+//			}
+		}else {
+			LogUtil.writeLog("unknown cerType:"+certType);
+			return -1;
+		}
+	}
+	
+	/**
+	 * 文件拷贝方法
+	 * 
+	 * @param srcFile
+	 *            源文件
+	 * @param destFile
+	 *            目标文件
+	 * @return
+	 * @throws IOException
+	 */
+	public static boolean copyFile(String srcFile, String destFile) {
+		boolean flag = false;
+		FileInputStream fin = null;
+		FileOutputStream fout = null;
+		FileChannel fcin = null;
+		FileChannel fcout = null;
+		try {
+			// 获取源文件和目标文件的输入输出流
+			fin = new FileInputStream(srcFile);
+			fout = new FileOutputStream(destFile);
+			// 获取输入输出通道
+			fcin = fin.getChannel();
+			fcout = fout.getChannel();
+			// 创建缓冲区
+			ByteBuffer buffer = ByteBuffer.allocate(1024);
+			while (true) {
+				// clear方法重设缓冲区,使它可以接受读入的数据
+				buffer.clear();
+				// 从输入通道中将数据读到缓冲区
+				int r = fcin.read(buffer);
+				// read方法返回读取的字节数,可能为零,如果该通道已到达流的末尾,则返回-1
+				if (r == -1) {
+					flag = true;
+					break;
+				}
+				// flip方法让缓冲区可以将新读入的数据写入另一个通道
+				buffer.flip();
+				// 从输出通道中将数据写入缓冲区
+				fcout.write(buffer);
+			}
+			fout.flush();
+		} catch (IOException e) {
+			LogUtil.writeErrorLog("CopyFile fail", e);
+		} finally {
+			try {
+				if (null != fin)
+					fin.close();
+				if (null != fout)
+					fout.close();
+				if (null != fcin)
+					fcin.close();
+				if (null != fcout)
+					fcout.close();
+			} catch (IOException ex) {
+				LogUtil.writeErrorLog("Releases any system resources fail", ex);
+			}
+		}
+		return flag;
+	}
+	
+	/**
+	 * 写文件方法
+	 * 
+	 * @param filePath
+	 *            文件路径
+	 * @param fileContent
+	 *            文件内容
+	 * @param encoding
+	 *            编码
+	 * @return
+	 */
+	public static boolean writeFile(String filePath, String fileContent,
+			String encoding) {
+		FileOutputStream fout = null;
+		FileChannel fcout = null;
+		File file = new File(filePath);
+		if (file.exists()) {
+			file.delete();
+		}
+		
+		try {
+			fout = new FileOutputStream(filePath);
+			// 获取输出通道
+			fcout = fout.getChannel();
+			// 创建缓冲区
+			// ByteBuffer buffer = ByteBuffer.allocate(1024);
+			ByteBuffer buffer = ByteBuffer.wrap(fileContent.getBytes(encoding));
+			fcout.write(buffer);
+			fout.flush();
+		} catch (FileNotFoundException e) {
+			LogUtil.writeErrorLog("WriteFile fail", e);
+			return false;
+		} catch (IOException ex) {
+			LogUtil.writeErrorLog("WriteFile fail", ex);
+			return false;
+		} finally {
+			try {
+				if (null != fout)
+					fout.close();
+				if (null != fcout)
+					fcout.close();
+			} catch (IOException ex) {
+				LogUtil.writeErrorLog("Releases any system resources fail", ex);
+				return false;
+			}
+		}
+		return true;
+	}
+	
+	/**
+	 * 将传入的文件名(xxx)改名 <br>
+	 * 结果为: xxx_backup.cer
+	 * 
+	 * @param fileName
+	 * @return
+	 */
+	public static String genBackupName(String fileName) {
+		if (isEmpty(fileName))
+			return "";
+		int i = fileName.lastIndexOf(POINT);
+		String leftFileName = fileName.substring(0, i);
+		String rightFileName = fileName.substring(i + 1);
+		String newFileName = leftFileName + "_backup" + POINT + rightFileName;
+		return newFileName;
+	}
+	
+
+	public static byte[] readFileByNIO(String filePath) {
+		FileInputStream in = null;
+		FileChannel fc = null;
+		ByteBuffer bf = null;
+		try {
+			in = new FileInputStream(filePath);
+			fc = in.getChannel();
+			bf = ByteBuffer.allocate((int) fc.size());
+			fc.read(bf);
+			return bf.array();
+		} catch (Exception e) {
+			LogUtil.writeErrorLog(e.getMessage());
+			return null;
+		} finally {
+			try {
+				if (null != fc) {
+					fc.close();
+				}
+				if (null != in) {
+					in.close();
+				}
+			} catch (Exception e) {
+				LogUtil.writeErrorLog(e.getMessage());
+				return null;
+			}
+		}
+	}
+	
+	/**
+	 * 过滤请求报文中的空字符串或者空字符串
+	 * @param contentData
+	 * @return
+	 */
+	public static Map<String, String> filterBlank(Map<String, String> contentData){
+		LogUtil.writeLog("打印请求报文域 :");
+		Map<String, String> submitFromData = new HashMap<String, String>();
+		Set<String> keyset = contentData.keySet();
+		
+		for(String key:keyset){
+			String value = contentData.get(key);
+			if (value != null && !"".equals(value.trim())) {
+				// 对value值进行去除前后空处理
+				submitFromData.put(key, value.trim());
+				LogUtil.writeLog(key + "-->" + String.valueOf(value));
+			}
+		}
+		return submitFromData;
+	}
+	
+	/**
+	 * 解压缩.
+	 * 
+	 * @param inputByte
+	 *            byte[]数组类型的数据
+	 * @return 解压缩后的数据
+	 * @throws IOException
+	 */
+	public static byte[] inflater(final byte[] inputByte) throws IOException {
+		int compressedDataLength = 0;
+		Inflater compresser = new Inflater(false);
+		compresser.setInput(inputByte, 0, inputByte.length);
+		ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
+		byte[] result = new byte[1024];
+		try {
+			while (!compresser.finished()) {
+				compressedDataLength = compresser.inflate(result);
+				if (compressedDataLength == 0) {
+					break;
+				}
+				o.write(result, 0, compressedDataLength);
+			}
+		} catch (Exception ex) {
+			System.err.println("Data format error!\n");
+			ex.printStackTrace();
+		} finally {
+			o.close();
+		}
+		compresser.end();
+		return o.toByteArray();
+	}
+
+	/**
+	 * 压缩.
+	 * 
+	 * @param inputByte
+	 *            需要解压缩的byte[]数组
+	 * @return 压缩后的数据
+	 * @throws IOException
+	 */
+	public static byte[] deflater(final byte[] inputByte) throws IOException {
+		int compressedDataLength = 0;
+		Deflater compresser = new Deflater();
+		compresser.setInput(inputByte);
+		compresser.finish();
+		ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
+		byte[] result = new byte[1024];
+		try {
+			while (!compresser.finished()) {
+				compressedDataLength = compresser.deflate(result);
+				o.write(result, 0, compressedDataLength);
+			}
+		} finally {
+			o.close();
+		}
+		compresser.end();
+		return o.toByteArray();
+	}
+	
+	/**
+	 * 判断字符串是否为NULL或空
+	 * 
+	 * @param s
+	 *            待判断的字符串数据
+	 * @return 判断结果 true-是 false-否
+	 */
+	public static boolean isEmpty(String s) {
+		return null == s || "".equals(s.trim());
+	}
+	
+}

+ 574 - 0
src/main/java/com/lightinit/hsdataportal/Unionsdk/SecureUtil.java

@@ -0,0 +1,574 @@
+/**
+ *
+ * Licensed Property to China UnionPay Co., Ltd.
+ * 
+ * (C) Copyright of China UnionPay Co., Ltd. 2010
+ *     All Rights Reserved.
+ *
+ * 
+ * Modification History:
+ * =============================================================================
+ *   Author         Date          Description
+ *   ------------ ---------- ---------------------------------------------------
+ *   xshu       2014-05-28     报文加密解密等操作的工具类
+ * =============================================================================
+ */
+package com.lightinit.hsdataportal.Unionsdk;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.Signature;
+
+import javax.crypto.Cipher;
+
+import org.apache.commons.codec.binary.Base64;
+import org.bouncycastle.crypto.digests.SM3Digest;
+/**
+ * 
+ * @ClassName SecureUtil
+ * @Description acpsdk安全算法工具类
+ * @date 2016-7-22 下午4:08:32
+ * 声明:以下代码只是为了方便接入方测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考,不提供编码,性能,规范性等方面的保障
+ */
+public class SecureUtil {
+	/**
+	 * 算法常量: SHA1
+	 */
+	private static final String ALGORITHM_SHA1 = "SHA-1";
+	/**
+	 * 算法常量: SHA256
+	 */
+	private static final String ALGORITHM_SHA256 = "SHA-256";
+	/**
+	 * 算法常量:SHA1withRSA
+	 */
+	private static final String BC_PROV_ALGORITHM_SHA1RSA = "SHA1withRSA";
+	/**
+	 * 算法常量:SHA256withRSA
+	 */
+	private static final String BC_PROV_ALGORITHM_SHA256RSA = "SHA256withRSA";
+
+	/**
+	 * sm3计算后进行16进制转换
+	 * 
+	 * @param data
+	 *            待计算的数据
+	 * @param encoding
+	 *            编码
+	 * @return 计算结果
+	 */
+	public static String sm3X16Str(String data, String encoding) {
+		byte[] bytes = sm3(data, encoding);
+		StringBuilder sm3StrBuff = new StringBuilder();
+		for (int i = 0; i < bytes.length; i++) {
+			if (Integer.toHexString(0xFF & bytes[i]).length() == 1) {
+				sm3StrBuff.append("0").append(
+						Integer.toHexString(0xFF & bytes[i]));
+			} else {
+				sm3StrBuff.append(Integer.toHexString(0xFF & bytes[i]));
+			}
+		}
+		return sm3StrBuff.toString();
+	}
+
+	/**
+	 * sha1计算后进行16进制转换
+	 * 
+	 * @param data
+	 *            待计算的数据
+	 * @param encoding
+	 *            编码
+	 * @return 计算结果
+	 */
+	public static byte[] sha1X16(String data, String encoding) {
+		byte[] bytes = sha1(data, encoding);
+		StringBuilder sha1StrBuff = new StringBuilder();
+		for (int i = 0; i < bytes.length; i++) {
+			if (Integer.toHexString(0xFF & bytes[i]).length() == 1) {
+				sha1StrBuff.append("0").append(
+						Integer.toHexString(0xFF & bytes[i]));
+			} else {
+				sha1StrBuff.append(Integer.toHexString(0xFF & bytes[i]));
+			}
+		}
+		try {
+			return sha1StrBuff.toString().getBytes(encoding);
+		} catch (UnsupportedEncodingException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+			return null;
+		}
+	}
+	
+	
+	/**
+	 * sha256计算后进行16进制转换
+	 * 
+	 * @param data
+	 *            待计算的数据
+	 * @param encoding
+	 *            编码
+	 * @return 计算结果
+	 */
+	public static String sha256X16Str(String data, String encoding) {
+		byte[] bytes = sha256(data, encoding);
+		StringBuilder sha256StrBuff = new StringBuilder();
+		for (int i = 0; i < bytes.length; i++) {
+			if (Integer.toHexString(0xFF & bytes[i]).length() == 1) {
+				sha256StrBuff.append("0").append(
+						Integer.toHexString(0xFF & bytes[i]));
+			} else {
+				sha256StrBuff.append(Integer.toHexString(0xFF & bytes[i]));
+			}
+		}
+		return sha256StrBuff.toString();
+	}
+	
+	/**
+	 * sha256计算后进行16进制转换
+	 * 
+	 * @param data
+	 *            待计算的数据
+	 * @param encoding
+	 *            编码
+	 * @return 计算结果
+	 */
+	public static byte[] sha256X16(String data, String encoding) {
+		byte[] bytes = sha256(data, encoding);
+		StringBuilder sha256StrBuff = new StringBuilder();
+		for (int i = 0; i < bytes.length; i++) {
+			if (Integer.toHexString(0xFF & bytes[i]).length() == 1) {
+				sha256StrBuff.append("0").append(
+						Integer.toHexString(0xFF & bytes[i]));
+			} else {
+				sha256StrBuff.append(Integer.toHexString(0xFF & bytes[i]));
+			}
+		}
+		try {
+			return sha256StrBuff.toString().getBytes(encoding);
+		} catch (UnsupportedEncodingException e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+			return null;
+		}
+	}
+
+	/**
+	 * sha1计算.
+	 * 
+	 * @param data
+	 *            待计算的数据
+	 * @return 计算结果
+	 */
+	private static byte[] sha1(byte[] data) {
+		MessageDigest md = null;
+		try {
+			md = MessageDigest.getInstance(ALGORITHM_SHA1);
+			md.reset();
+			md.update(data);
+			return md.digest();
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("SHA1计算失败", e);
+			return null;
+		}
+	}
+	
+	/**
+	 * sha256计算.
+	 * 
+	 * @param data
+	 *            待计算的数据
+	 * @return 计算结果
+	 */
+	private static byte[] sha256(byte[] data) {
+		MessageDigest md = null;
+		try {
+			md = MessageDigest.getInstance(ALGORITHM_SHA256);
+			md.reset();
+			md.update(data);
+			return md.digest();
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("SHA256计算失败", e);
+			return null;
+		}
+	}
+	
+	/**
+	 * SM3计算.
+	 * 
+	 * @param data
+	 *            待计算的数据
+	 * @return 计算结果
+	 */
+	private static byte[] sm3(byte[] data) {
+		SM3Digest sm3 = new SM3Digest();
+		sm3.update(data, 0, data.length);
+		byte[] result = new byte[sm3.getDigestSize()];
+		sm3.doFinal(result, 0);
+		return result;
+	}
+	
+	/**
+	 * sha1计算
+	 * 
+	 * @param datas
+	 *            待计算的数据
+	 * @param encoding
+	 *            字符集编码
+	 * @return
+	 */
+	private static byte[] sha1(String datas, String encoding) {
+		try {
+			return sha1(datas.getBytes(encoding));
+		} catch (UnsupportedEncodingException e) {
+			LogUtil.writeErrorLog("SHA1计算失败", e);
+			return null;
+		}
+	}
+	
+	/**
+	 * sha256计算
+	 * 
+	 * @param datas
+	 *            待计算的数据
+	 * @param encoding
+	 *            字符集编码
+	 * @return
+	 */
+	private static byte[] sha256(String datas, String encoding) {
+		try {
+			return sha256(datas.getBytes(encoding));
+		} catch (UnsupportedEncodingException e) {
+			LogUtil.writeErrorLog("SHA256计算失败", e);
+			return null;
+		}
+	}
+
+	/**
+	 * sm3计算
+	 * 
+	 * @param datas
+	 *            待计算的数据
+	 * @param encoding
+	 *            字符集编码
+	 * @return
+	 */
+	private static byte[] sm3(String datas, String encoding) {
+		try {
+			return sm3(datas.getBytes(encoding));
+		} catch (UnsupportedEncodingException e) {
+			LogUtil.writeErrorLog("SM3计算失败", e);
+			return null;
+		}
+	}
+
+	/**
+	 * 
+	 * @param privateKey
+	 * @param data
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] signBySoft(PrivateKey privateKey, byte[] data)
+			throws Exception {
+		byte[] result = null;
+		Signature st = Signature.getInstance(BC_PROV_ALGORITHM_SHA1RSA, "BC");
+		st.initSign(privateKey);
+		st.update(data);
+		result = st.sign();
+		return result;
+	}
+	
+	/**
+	 * @param privateKey
+	 * @param data
+	 * @return
+	 * @throws Exception
+	 */
+	public static byte[] signBySoft256(PrivateKey privateKey, byte[] data)
+			throws Exception {
+		byte[] result = null;
+		Signature st = Signature.getInstance(BC_PROV_ALGORITHM_SHA256RSA, "BC");
+		st.initSign(privateKey);
+		st.update(data);
+		result = st.sign();
+		return result;
+	}
+
+	public static boolean validateSignBySoft(PublicKey publicKey,
+			byte[] signData, byte[] srcData) throws Exception {
+		Signature st = Signature.getInstance(BC_PROV_ALGORITHM_SHA1RSA, "BC");
+		st.initVerify(publicKey);
+		st.update(srcData);
+		return st.verify(signData);
+	}
+	
+	public static boolean validateSignBySoft256(PublicKey publicKey,
+			byte[] signData, byte[] srcData) throws Exception {
+		Signature st = Signature.getInstance(BC_PROV_ALGORITHM_SHA256RSA, "BC");
+		st.initVerify(publicKey);
+		st.update(srcData);
+		return st.verify(signData);
+	}
+
+	/**
+	 * 对数据通过公钥进行加密,并进行base64计算
+	 * 
+	 * @param dataString
+	 *            待处理数据
+	 * @param encoding
+	 *            字符编码
+	 * @param key
+	 *            公钥
+	 * @return
+	 */
+	public static String encryptData(String dataString, String encoding,
+			PublicKey key) {
+		/** 使用公钥对密码加密 **/
+		byte[] data = null;
+		try {
+			data = encryptData(key, dataString.getBytes(encoding));
+			return new String(SecureUtil.base64Encode(data), encoding);
+		} catch (Exception e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+			return "";
+		}
+	}
+
+	/**
+	 * 对数据通过公钥进行加密,并进行base64计算
+	 *
+	 * @param encoding
+	 *            字符编码
+	 * @param key
+	 *            公钥
+	 * @return
+	 */
+	public static String encryptPin(String accNo, String pin, String encoding,
+			PublicKey key) {
+		/** 使用公钥对密码加密 **/
+		byte[] data = null;
+		try {
+			data = pin2PinBlockWithCardNO(pin, accNo);
+			data = encryptData(key, data);
+			return new String(SecureUtil.base64Encode(data), encoding);
+		} catch (Exception e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+			return "";
+		}
+	}
+	
+	/**
+	 * 通过私钥解密
+	 * 
+	 * @param dataString
+	 *            base64过的数据
+	 * @param encoding
+	 *            编码
+	 * @param key
+	 *            私钥
+	 * @return 解密后的数据
+	 */
+	public static String decryptData(String dataString, String encoding,
+			PrivateKey key) {
+		byte[] data = null;
+		try {
+			data = SecureUtil.base64Decode(dataString.getBytes(encoding));
+			data = decryptData(key, data);
+			return new String(data, encoding);
+		} catch (Exception e) {
+			LogUtil.writeErrorLog(e.getMessage(), e);
+			return "";
+		}
+	}
+
+	/**
+	 * BASE64解码
+	 * 
+	 * @param inputByte
+	 *            待解码数据
+	 * @return 解码后的数据
+	 * @throws IOException
+	 */
+	public static byte[] base64Decode(byte[] inputByte) throws IOException {
+		return Base64.decodeBase64(inputByte);
+	}
+
+	/**
+	 * BASE64编码
+	 * 
+	 * @param inputByte
+	 *            待编码数据
+	 * @return 解码后的数据
+	 * @throws IOException
+	 */
+	public static byte[] base64Encode(byte[] inputByte) throws IOException {
+		return Base64.encodeBase64(inputByte);
+	}
+
+	/**
+	 * 加密除pin之外的其他信息
+	 * 
+	 * @param publicKey
+	 * @param plainData
+	 * @return
+	 * @throws Exception
+	 */
+	private static byte[] encryptData(PublicKey publicKey, byte[] plainData)
+			throws Exception {
+		try {
+			Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding","BC");
+			cipher.init(Cipher.ENCRYPT_MODE, publicKey);
+			return cipher.doFinal(plainData);
+		} catch (Exception e) {
+			throw new Exception(e.getMessage());
+		}
+	}
+
+	/**
+	 * @param privateKey
+	 * @return
+	 * @throws Exception
+	 */
+	private static byte[] decryptData(PrivateKey privateKey, byte[] data)
+			throws Exception {
+		try {
+			Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding","BC");
+			cipher.init(Cipher.DECRYPT_MODE, privateKey);
+			return cipher.doFinal(data);
+		} catch (Exception e) {
+			LogUtil.writeErrorLog("解密失败", e);
+		}
+		return null;
+	}
+
+	/**
+	 * 
+	 * @param aPin
+	 * @return
+	 */
+	private static byte[] pin2PinBlock(String aPin) {
+		int tTemp = 1;
+		int tPinLen = aPin.length();
+
+		byte[] tByte = new byte[8];
+		try {
+			/*******************************************************************
+			 * if (tPinLen > 9) { tByte[0] = (byte) Integer.parseInt(new
+			 * Integer(tPinLen) .toString(), 16); } else { tByte[0] = (byte)
+			 * Integer.parseInt(new Integer(tPinLen) .toString(), 10); }
+			 ******************************************************************/
+//			tByte[0] = (byte) Integer.parseInt(new Integer(tPinLen).toString(),
+//					10);
+			tByte[0] = (byte) Integer.parseInt(Integer.toString(tPinLen), 10);
+			if (tPinLen % 2 == 0) {
+				for (int i = 0; i < tPinLen;) {
+					String a = aPin.substring(i, i + 2);
+					tByte[tTemp] = (byte) Integer.parseInt(a, 16);
+					if (i == (tPinLen - 2)) {
+						if (tTemp < 7) {
+							for (int x = (tTemp + 1); x < 8; x++) {
+								tByte[x] = (byte) 0xff;
+							}
+						}
+					}
+					tTemp++;
+					i = i + 2;
+				}
+			} else {
+				for (int i = 0; i < tPinLen - 1;) {
+					String a;
+					a = aPin.substring(i, i + 2);
+					tByte[tTemp] = (byte) Integer.parseInt(a, 16);
+					if (i == (tPinLen - 3)) {
+						String b = aPin.substring(tPinLen - 1) + "F";
+						tByte[tTemp + 1] = (byte) Integer.parseInt(b, 16);
+						if ((tTemp + 1) < 7) {
+							for (int x = (tTemp + 2); x < 8; x++) {
+								tByte[x] = (byte) 0xff;
+							}
+						}
+					}
+					tTemp++;
+					i = i + 2;
+				}
+			}
+		} catch (Exception e) {
+		}
+
+		return tByte;
+	}
+
+	/**
+	 * 
+	 * @param aPan
+	 * @return
+	 */
+	private static byte[] formatPan(String aPan) {
+		int tPanLen = aPan.length();
+		byte[] tByte = new byte[8];
+		;
+		int temp = tPanLen - 13;
+		try {
+			tByte[0] = (byte) 0x00;
+			tByte[1] = (byte) 0x00;
+			for (int i = 2; i < 8; i++) {
+				String a = aPan.substring(temp, temp + 2);
+				tByte[i] = (byte) Integer.parseInt(a, 16);
+				temp = temp + 2;
+			}
+		} catch (Exception e) {
+		}
+		return tByte;
+	}
+
+	/**
+	 * 
+	 * @param aPin
+	 * @param aCardNO
+	 * @return
+	 */
+	private static byte[] pin2PinBlockWithCardNO(String aPin, String aCardNO) {
+		byte[] tPinByte = pin2PinBlock(aPin);
+		if (aCardNO.length() == 11) {
+			aCardNO = "00" + aCardNO;
+		} else if (aCardNO.length() == 12) {
+			aCardNO = "0" + aCardNO;
+		}
+		byte[] tPanByte = formatPan(aCardNO);
+		byte[] tByte = new byte[8];
+		for (int i = 0; i < 8; i++) {
+			tByte[i] = (byte) (tPinByte[i] ^ tPanByte[i]);
+		}
+		return tByte;
+	}
+	
+	 /**
+    * luhn算法
+    * 
+    * @param number
+    * @return
+    */
+   public static int genLuhn(String number) {
+       number = number + "0";
+       int s1 = 0, s2 = 0;
+       String reverse = new StringBuffer(number).reverse().toString();
+       for (int i = 0; i < reverse.length(); i++) {
+           int digit = Character.digit(reverse.charAt(i), 10);
+           if (i % 2 == 0) {// this is for odd digits, they are 1-indexed in //
+                            // the algorithm
+               s1 += digit;
+           } else {// add 2 * digit for 0-4, add 2 * digit - 9 for 5-9
+               s2 += 2 * digit;
+               if (digit >= 5) {
+                   s2 -= 9;
+               }
+           }
+       }
+       int check = 10 - ((s1 + s2) % 10);
+       if (check == 10)
+           check = 0;
+       return check;
+   }
+}

+ 42 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/IWXPayDomain.java

@@ -0,0 +1,42 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+/**
+ * 域名管理,实现主备域名自动切换
+ */
+public abstract interface IWXPayDomain {
+    /**
+     * 上报域名网络状况
+     * @param domain 域名。 比如:api.mch.weixin.qq.com
+     * @param elapsedTimeMillis 耗时
+     * @param ex 网络请求中出现的异常。
+     *           null表示没有异常
+     *           ConnectTimeoutException,表示建立网络连接异常
+     *           UnknownHostException, 表示dns解析异常
+     */
+    abstract void report(final String domain, long elapsedTimeMillis, final Exception ex);
+
+    /**
+     * 获取域名
+     * @param config 配置
+     * @return 域名
+     */
+    abstract DomainInfo getDomain(final WXPayConfig config);
+
+    static class DomainInfo{
+        public String domain;       //域名
+        public boolean primaryDomain;     //该域名是否为主域名。例如:api.mch.weixin.qq.com为主域名
+        public DomainInfo(String domain, boolean primaryDomain) {
+            this.domain = domain;
+            this.primaryDomain = primaryDomain;
+        }
+
+        @Override
+        public String toString() {
+            return "DomainInfo{" +
+                    "domain='" + domain + '\'' +
+                    ", primaryDomain=" + primaryDomain +
+                    '}';
+        }
+    }
+
+}

+ 45 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/MyPayConfig.java

@@ -0,0 +1,45 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.SysContants;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+public class MyPayConfig extends WXPayConfig {
+
+    private byte[] certData;
+
+    public MyPayConfig() throws Exception {
+    }
+
+    public String getAppID() {
+        return  ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.APPID);
+    }
+
+    public String getMchID() {
+        return  ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.MCHID);
+    }
+
+    public String getKey() {
+        return  ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.WXKEY);
+    }
+
+    public InputStream getCertStream() {
+        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
+        return certBis;
+    }
+
+    public int getHttpConnectTimeoutMs() {
+        return 8000;
+    }
+
+    public int getHttpReadTimeoutMs() {
+        return 10000;
+    }
+
+    @Override
+    IWXPayDomain getWXPayDomain() {
+        return new WXPayDomain() ;
+    }
+}

+ 53 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/MyWXUtils.java

@@ -0,0 +1,53 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+import com.lightinit.hsdataportal.dictionary.DicWXPayInfo;
+import com.lightinit.hsdataportal.entity.Order;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MyWXUtils {
+
+    private static Logger logger = LoggerFactory.getLogger(MyWXUtils.class);
+
+    //获取当前自己ip
+    public static String getRemoteHost(javax.servlet.http.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.equals("0:0:0:0:0:0:0:1")?"127.0.0.1":ip;
+    }
+
+    //微信合成参数验证签名是否正确
+    public static Map<String, String> getPrepayid(String orderNumber, Order order, String ip) throws Exception {
+        logger.info("-------------验证签名开始-----------------------");
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("appid", DicWXPayInfo.APPID);
+        map.put("mch_id", DicWXPayInfo.MCHID);
+        map.put("nonce_str", WXPayUtil.generateNonceStr());
+        map.put("body", "衡水大数据开放平台");
+        map.put("out_trade_no", orderNumber);
+       String str  = order.getOrderAmount().multiply(BigDecimal.valueOf(100)).intValue()+"" ;
+        map.put("total_fee",str) ;
+//        map.put("total_fee", "1");
+        map.put("spbill_create_ip", ip);
+        map.put("notify_url", DicWXPayInfo.NOTIFYURL);
+        map.put("trade_type", "NATIVE");
+        String sign = WXPayUtil.generateSignature(map, DicWXPayInfo.KEY);
+        map.put("sign", sign);
+        logger.info("sign={}", sign);
+        logger.info("-------------结束-----------------------");
+        return map;
+    }
+
+}

+ 687 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/WXPay.java

@@ -0,0 +1,687 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class WXPay {
+
+    private WXPayConfig config;
+    private WXPayConstants.SignType signType;
+    private boolean autoReport;
+    private boolean useSandbox;
+    private String notifyUrl;
+    private WXPayRequest wxPayRequest;
+
+    public WXPay(final WXPayConfig config) throws Exception {
+        this(config, null, true, false);
+    }
+
+    public WXPay(final WXPayConfig config, final boolean autoReport) throws Exception {
+        this(config, null, autoReport, false);
+    }
+
+
+    public WXPay(final WXPayConfig config, final boolean autoReport, final boolean useSandbox) throws Exception{
+        this(config, null, autoReport, useSandbox);
+    }
+
+    public WXPay(final WXPayConfig config, final String notifyUrl) throws Exception {
+        this(config, notifyUrl, true, false);
+    }
+
+    public WXPay(final WXPayConfig config, final String notifyUrl, final boolean autoReport) throws Exception {
+        this(config, notifyUrl, autoReport, false);
+    }
+
+    public WXPay(final WXPayConfig config, final String notifyUrl, final boolean autoReport, final boolean useSandbox) throws Exception {
+        this.config = config;
+        this.notifyUrl = notifyUrl;
+        this.autoReport = autoReport;
+        this.useSandbox = useSandbox;
+        if (useSandbox) {
+            this.signType = WXPayConstants.SignType.MD5; // 沙箱环境
+        }
+        else {
+            this.signType = WXPayConstants.SignType.HMACSHA256;
+        }
+        this.wxPayRequest = new WXPayRequest(config);
+    }
+
+    private void checkWXPayConfig() throws Exception {
+        if (this.config == null) {
+            throw new Exception("config is null");
+        }
+        if (this.config.getAppID() == null || this.config.getAppID().trim().length() == 0) {
+            throw new Exception("appid in config is empty");
+        }
+        if (this.config.getMchID() == null || this.config.getMchID().trim().length() == 0) {
+            throw new Exception("appid in config is empty");
+        }
+        if (this.config.getCertStream() == null) {
+            throw new Exception("cert stream in config is empty");
+        }
+        if (this.config.getWXPayDomain() == null){
+            throw new Exception("config.getWXPayDomain() is null");
+        }
+
+        if (this.config.getHttpConnectTimeoutMs() < 10) {
+            throw new Exception("http connect timeout is too small");
+        }
+        if (this.config.getHttpReadTimeoutMs() < 10) {
+            throw new Exception("http read timeout is too small");
+        }
+
+    }
+
+    /**
+     * 向 Map 中添加 appid、mch_id、nonce_str、sign_type、sign <br>
+     * 该函数适用于商户适用于统一下单等接口,不适用于红包、代金券接口
+     *
+     * @param reqData
+     * @return
+     * @throws Exception
+     */
+    public Map<String, String> fillRequestData(Map<String, String> reqData) throws Exception {
+        reqData.put("appid", config.getAppID());
+        reqData.put("mch_id", config.getMchID());
+        reqData.put("nonce_str", WXPayUtil.generateNonceStr());
+        if (WXPayConstants.SignType.MD5.equals(this.signType)) {
+            reqData.put("sign_type", WXPayConstants.MD5);
+        }
+        else if (WXPayConstants.SignType.HMACSHA256.equals(this.signType)) {
+            reqData.put("sign_type", WXPayConstants.HMACSHA256);
+        }
+        reqData.put("sign", WXPayUtil.generateSignature(reqData, config.getKey(), this.signType));
+        return reqData;
+    }
+
+    /**
+     * 判断xml数据的sign是否有效,必须包含sign字段,否则返回false。
+     *
+     * @param reqData 向wxpay post的请求数据
+     * @return 签名是否有效
+     * @throws Exception
+     */
+    public boolean isResponseSignatureValid(Map<String, String> reqData) throws Exception {
+        // 返回数据的签名方式和请求中给定的签名方式是一致的
+        return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), this.signType);
+    }
+
+    /**
+     * 判断支付结果通知中的sign是否有效
+     *
+     * @param reqData 向wxpay post的请求数据
+     * @return 签名是否有效
+     * @throws Exception
+     */
+    public boolean isPayResultNotifySignatureValid(Map<String, String> reqData) throws Exception {
+        String signTypeInData = reqData.get(WXPayConstants.FIELD_SIGN_TYPE);
+        WXPayConstants.SignType signType;
+        if (signTypeInData == null) {
+            signType = WXPayConstants.SignType.MD5;
+        }
+        else {
+            signTypeInData = signTypeInData.trim();
+            if (signTypeInData.length() == 0) {
+                signType = WXPayConstants.SignType.MD5;
+            }
+            else if (WXPayConstants.MD5.equals(signTypeInData)) {
+                signType = WXPayConstants.SignType.MD5;
+            }
+            else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) {
+                signType = WXPayConstants.SignType.HMACSHA256;
+            }
+            else {
+                throw new Exception(String.format("Unsupported sign_type: %s", signTypeInData));
+            }
+        }
+        return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), signType);
+    }
+
+
+    /**
+     * 不需要证书的请求
+     * @param urlSuffix String
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 超时时间,单位是毫秒
+     * @param readTimeoutMs 超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public String requestWithoutCert(String urlSuffix, Map<String, String> reqData,
+                                     int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String msgUUID = reqData.get("nonce_str");
+        String reqBody = WXPayUtil.mapToXml(reqData);
+
+        String resp = this.wxPayRequest.requestWithoutCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, autoReport);
+        return resp;
+    }
+
+
+    /**
+     * 需要证书的请求
+     * @param urlSuffix String
+     * @param reqData 向wxpay post的请求数据  Map
+     * @param connectTimeoutMs 超时时间,单位是毫秒
+     * @param readTimeoutMs 超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public String requestWithCert(String urlSuffix, Map<String, String> reqData,
+                                  int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String msgUUID= reqData.get("nonce_str");
+        String reqBody = WXPayUtil.mapToXml(reqData);
+
+        String resp = this.wxPayRequest.requestWithCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, this.autoReport);
+        return resp;
+    }
+
+    /**
+     * 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
+     * @param xmlStr API返回的XML格式数据
+     * @return Map类型数据
+     * @throws Exception
+     */
+    public Map<String, String> processResponseXml(String xmlStr) throws Exception {
+        String RETURN_CODE = "return_code";
+        String return_code;
+        Map<String, String> respData = WXPayUtil.xmlToMap(xmlStr);
+        if (respData.containsKey(RETURN_CODE)) {
+            return_code = respData.get(RETURN_CODE);
+        }
+        else {
+            throw new Exception(String.format("No `return_code` in XML: %s", xmlStr));
+        }
+
+        if (return_code.equals(WXPayConstants.FAIL)) {
+            return respData;
+        }
+        else if (return_code.equals(WXPayConstants.SUCCESS)) {
+           if (this.isResponseSignatureValid(respData)) {
+               return respData;
+           }
+           else {
+               throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr));
+           }
+        }
+        else {
+            throw new Exception(String.format("return_code value %s is invalid in XML: %s", return_code, xmlStr));
+        }
+    }
+
+    /**
+     * 作用:提交刷卡支付<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> microPay(Map<String, String> reqData) throws Exception {
+        return this.microPay(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:提交刷卡支付<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> microPay(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_MICROPAY_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.MICROPAY_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+    /**
+     * 提交刷卡支付,针对软POS,尽可能做成功
+     * 内置重试机制,最多60s
+     * @param reqData
+     * @return
+     * @throws Exception
+     */
+    public Map<String, String> microPayWithPos(Map<String, String> reqData) throws Exception {
+        return this.microPayWithPos(reqData, this.config.getHttpConnectTimeoutMs());
+    }
+
+    /**
+     * 提交刷卡支付,针对软POS,尽可能做成功
+     * 内置重试机制,最多60s
+     * @param reqData
+     * @param connectTimeoutMs
+     * @return
+     * @throws Exception
+     */
+    public Map<String, String> microPayWithPos(Map<String, String> reqData, int connectTimeoutMs) throws Exception {
+        int remainingTimeMs = 60*1000;
+        long startTimestampMs = 0;
+        Map<String, String> lastResult = null;
+        Exception lastException = null;
+
+        while (true) {
+            startTimestampMs = WXPayUtil.getCurrentTimestampMs();
+            int readTimeoutMs = remainingTimeMs - connectTimeoutMs;
+            if (readTimeoutMs > 1000) {
+                try {
+                    lastResult = this.microPay(reqData, connectTimeoutMs, readTimeoutMs);
+                    String returnCode = lastResult.get("return_code");
+                    if (returnCode.equals("SUCCESS")) {
+                        String resultCode = lastResult.get("result_code");
+                        String errCode = lastResult.get("err_code");
+                        if (resultCode.equals("SUCCESS")) {
+                            break;
+                        }
+                        else {
+                            // 看错误码,若支付结果未知,则重试提交刷卡支付
+                            if (errCode.equals("SYSTEMERROR") || errCode.equals("BANKERROR") || errCode.equals("USERPAYING")) {
+                                remainingTimeMs = remainingTimeMs - (int)(WXPayUtil.getCurrentTimestampMs() - startTimestampMs);
+                                if (remainingTimeMs <= 100) {
+                                    break;
+                                }
+                                else {
+                                    WXPayUtil.getLogger().info("microPayWithPos: try micropay again");
+                                    if (remainingTimeMs > 5*1000) {
+                                        Thread.sleep(5*1000);
+                                    }
+                                    else {
+                                        Thread.sleep(1*1000);
+                                    }
+                                    continue;
+                                }
+                            }
+                            else {
+                                break;
+                            }
+                        }
+                    }
+                    else {
+                        break;
+                    }
+                }
+                catch (Exception ex) {
+                    lastResult = null;
+                    lastException = ex;
+                }
+            }
+            else {
+                break;
+            }
+        }
+
+        if (lastResult == null) {
+            throw lastException;
+        }
+        else {
+            return lastResult;
+        }
+    }
+
+
+
+    /**
+     * 作用:统一下单<br>
+     * 场景:公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> unifiedOrder(Map<String, String> reqData) throws Exception {
+        return this.unifiedOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:统一下单<br>
+     * 场景:公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> unifiedOrder(Map<String, String> reqData,  int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_UNIFIEDORDER_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.UNIFIEDORDER_URL_SUFFIX;
+        }
+        if(this.notifyUrl != null) {
+            reqData.put("notify_url", this.notifyUrl);
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:查询订单<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> orderQuery(Map<String, String> reqData) throws Exception {
+        return this.orderQuery(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:查询订单<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据 int
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> orderQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_ORDERQUERY_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.ORDERQUERY_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:撤销订单<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> reverse(Map<String, String> reqData) throws Exception {
+        return this.reverse(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:撤销订单<br>
+     * 场景:刷卡支付<br>
+     * 其他:需要证书
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> reverse(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_REVERSE_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.REVERSE_URL_SUFFIX;
+        }
+        String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:关闭订单<br>
+     * 场景:公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> closeOrder(Map<String, String> reqData) throws Exception {
+        return this.closeOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:关闭订单<br>
+     * 场景:公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> closeOrder(Map<String, String> reqData,  int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_CLOSEORDER_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.CLOSEORDER_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:申请退款<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> refund(Map<String, String> reqData) throws Exception {
+        return this.refund(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:申请退款<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付<br>
+     * 其他:需要证书
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> refund(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_REFUND_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.REFUND_URL_SUFFIX;
+        }
+        String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:退款查询<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> refundQuery(Map<String, String> reqData) throws Exception {
+        return this.refundQuery(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:退款查询<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> refundQuery(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_REFUNDQUERY_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.REFUNDQUERY_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> downloadBill(Map<String, String> reqData) throws Exception {
+        return this.downloadBill(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:对账单下载<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付<br>
+     * 其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data,
+     *      其中return_code为`SUCCESS`,data为对账单数据。
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return 经过封装的API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> downloadBill(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_DOWNLOADBILL_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.DOWNLOADBILL_URL_SUFFIX;
+        }
+        String respStr = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs).trim();
+        Map<String, String> ret;
+        // 出现错误,返回XML数据
+        if (respStr.indexOf("<") == 0) {
+            ret = WXPayUtil.xmlToMap(respStr);
+        }
+        else {
+            // 正常返回csv数据
+            ret = new HashMap<String, String>();
+            ret.put("return_code", WXPayConstants.SUCCESS);
+            ret.put("return_msg", "ok");
+            ret.put("data", respStr);
+        }
+        return ret;
+    }
+
+
+    /**
+     * 作用:交易保障<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> report(Map<String, String> reqData) throws Exception {
+        return this.report(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:交易保障<br>
+     * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> report(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_REPORT_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.REPORT_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return WXPayUtil.xmlToMap(respXml);
+    }
+
+
+    /**
+     * 作用:转换短链接<br>
+     * 场景:刷卡支付、扫码支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> shortUrl(Map<String, String> reqData) throws Exception {
+        return this.shortUrl(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:转换短链接<br>
+     * 场景:刷卡支付、扫码支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> shortUrl(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_SHORTURL_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.SHORTURL_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+    /**
+     * 作用:授权码查询OPENID接口<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> authCodeToOpenid(Map<String, String> reqData) throws Exception {
+        return this.authCodeToOpenid(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+    }
+
+
+    /**
+     * 作用:授权码查询OPENID接口<br>
+     * 场景:刷卡支付
+     * @param reqData 向wxpay post的请求数据
+     * @param connectTimeoutMs 连接超时时间,单位是毫秒
+     * @param readTimeoutMs 读超时时间,单位是毫秒
+     * @return API返回数据
+     * @throws Exception
+     */
+    public Map<String, String> authCodeToOpenid(Map<String, String> reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+        String url;
+        if (this.useSandbox) {
+            url = WXPayConstants.SANDBOX_AUTHCODETOOPENID_URL_SUFFIX;
+        }
+        else {
+            url = WXPayConstants.AUTHCODETOOPENID_URL_SUFFIX;
+        }
+        String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+        return this.processResponseXml(respXml);
+    }
+
+
+} // end class

+ 103 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayConfig.java

@@ -0,0 +1,103 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+import java.io.InputStream;
+
+public abstract class WXPayConfig {
+
+
+
+    /**
+     * 获取 App ID
+     *
+     * @return App ID
+     */
+    abstract String getAppID();
+
+
+    /**
+     * 获取 Mch ID
+     *
+     * @return Mch ID
+     */
+    abstract String getMchID();
+
+
+    /**
+     * 获取 API 密钥
+     *
+     * @return API密钥
+     */
+    abstract String getKey();
+
+
+    /**
+     * 获取商户证书内容
+     *
+     * @return 商户证书内容
+     */
+    abstract InputStream getCertStream();
+
+    /**
+     * HTTP(S) 连接超时时间,单位毫秒
+     *
+     * @return
+     */
+    public int getHttpConnectTimeoutMs() {
+        return 6*1000;
+    }
+
+    /**
+     * HTTP(S) 读数据超时时间,单位毫秒
+     *
+     * @return
+     */
+    public int getHttpReadTimeoutMs() {
+        return 8*1000;
+    }
+
+    /**
+     * 获取WXPayDomain, 用于多域名容灾自动切换
+     * @return
+     */
+    abstract IWXPayDomain getWXPayDomain();
+
+    /**
+     * 是否自动上报。
+     * 若要关闭自动上报,子类中实现该函数返回 false 即可。
+     *
+     * @return
+     */
+    public boolean shouldAutoReport() {
+        return true;
+    }
+
+    /**
+     * 进行健康上报的线程的数量
+     *
+     * @return
+     */
+    public int getReportWorkerNum() {
+        return 6;
+    }
+
+
+    /**
+     * 健康上报缓存消息的最大数量。会有线程去独立上报
+     * 粗略计算:加入一条消息200B,10000消息占用空间 2000 KB,约为2MB,可以接受
+     *
+     * @return
+     */
+    public int getReportQueueMaxSize() {
+        return 10000;
+    }
+
+    /**
+     * 批量上报,一次最多上报多个数据
+     *
+     * @return
+     */
+    public int getReportBatchSize() {
+        return 10;
+    }
+
+}

+ 59 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayConstants.java

@@ -0,0 +1,59 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+import org.apache.http.client.HttpClient;
+
+/**
+ * 常量
+ */
+public class WXPayConstants {
+
+    public enum SignType {
+        MD5, HMACSHA256
+    }
+
+    public static final String DOMAIN_API = "api.mch.weixin.qq.com";
+    public static final String DOMAIN_API2 = "api2.mch.weixin.qq.com";
+    public static final String DOMAIN_APIHK = "apihk.mch.weixin.qq.com";
+    public static final String DOMAIN_APIUS = "apius.mch.weixin.qq.com";
+
+
+    public static final String FAIL     = "FAIL";
+    public static final String SUCCESS  = "SUCCESS";
+    public static final String HMACSHA256 = "HMAC-SHA256";
+    public static final String MD5 = "MD5";
+
+    public static final String FIELD_SIGN = "sign";
+    public static final String FIELD_SIGN_TYPE = "sign_type";
+
+    public static final String WXPAYSDK_VERSION = "WXPaySDK/3.0.9";
+    public static final String USER_AGENT = WXPAYSDK_VERSION +
+            " (" + System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version") +
+            ") Java/" + System.getProperty("java.version") + " HttpClient/" + HttpClient.class.getPackage().getImplementationVersion();
+
+    public static final String MICROPAY_URL_SUFFIX     = "/pay/micropay";
+    public static final String UNIFIEDORDER_URL_SUFFIX = "/pay/unifiedorder";
+    public static final String ORDERQUERY_URL_SUFFIX   = "/pay/orderquery";
+    public static final String REVERSE_URL_SUFFIX      = "/secapi/pay/reverse";
+    public static final String CLOSEORDER_URL_SUFFIX   = "/pay/closeorder";
+    public static final String REFUND_URL_SUFFIX       = "/secapi/pay/refund";
+    public static final String REFUNDQUERY_URL_SUFFIX  = "/pay/refundquery";
+    public static final String DOWNLOADBILL_URL_SUFFIX = "/pay/downloadbill";
+    public static final String REPORT_URL_SUFFIX       = "/payitil/report";
+    public static final String SHORTURL_URL_SUFFIX     = "/tools/shorturl";
+    public static final String AUTHCODETOOPENID_URL_SUFFIX = "/tools/authcodetoopenid";
+
+    // sandbox
+    public static final String SANDBOX_MICROPAY_URL_SUFFIX     = "/sandboxnew/pay/micropay";
+    public static final String SANDBOX_UNIFIEDORDER_URL_SUFFIX = "/sandboxnew/pay/unifiedorder";
+    public static final String SANDBOX_ORDERQUERY_URL_SUFFIX   = "/sandboxnew/pay/orderquery";
+    public static final String SANDBOX_REVERSE_URL_SUFFIX      = "/sandboxnew/secapi/pay/reverse";
+    public static final String SANDBOX_CLOSEORDER_URL_SUFFIX   = "/sandboxnew/pay/closeorder";
+    public static final String SANDBOX_REFUND_URL_SUFFIX       = "/sandboxnew/secapi/pay/refund";
+    public static final String SANDBOX_REFUNDQUERY_URL_SUFFIX  = "/sandboxnew/pay/refundquery";
+    public static final String SANDBOX_DOWNLOADBILL_URL_SUFFIX = "/sandboxnew/pay/downloadbill";
+    public static final String SANDBOX_REPORT_URL_SUFFIX       = "/sandboxnew/payitil/report";
+    public static final String SANDBOX_SHORTURL_URL_SUFFIX     = "/sandboxnew/tools/shorturl";
+    public static final String SANDBOX_AUTHCODETOOPENID_URL_SUFFIX = "/sandboxnew/tools/authcodetoopenid";
+
+}
+

+ 14 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayDomain.java

@@ -0,0 +1,14 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+public class WXPayDomain implements IWXPayDomain {
+    @Override
+    public void report(String domain, long elapsedTimeMillis, Exception ex) {
+
+    }
+
+    @Override
+    public DomainInfo getDomain(WXPayConfig config) {
+
+        return new DomainInfo("api.mch.weixin.qq.com",true);
+    }
+}

+ 265 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayReport.java

@@ -0,0 +1,265 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpPost;
+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.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
+import org.apache.http.util.EntityUtils;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * 交易保障
+ */
+public class WXPayReport {
+
+    public static class ReportInfo {
+
+        /**
+         * 布尔变量使用int。0为false, 1为true。
+         */
+
+        // 基本信息
+        private String version = "v1";
+        private String sdk = WXPayConstants.WXPAYSDK_VERSION;
+        private String uuid;  // 交易的标识
+        private long timestamp;   // 上报时的时间戳,单位秒
+        private long elapsedTimeMillis; // 耗时,单位 毫秒
+
+        // 针对主域名
+        private String firstDomain;  // 第1次请求的域名
+        private boolean primaryDomain; //是否主域名
+        private int firstConnectTimeoutMillis;  // 第1次请求设置的连接超时时间,单位 毫秒
+        private int firstReadTimeoutMillis;  // 第1次请求设置的读写超时时间,单位 毫秒
+        private int firstHasDnsError;  // 第1次请求是否出现dns问题
+        private int firstHasConnectTimeout; // 第1次请求是否出现连接超时
+        private int firstHasReadTimeout; // 第1次请求是否出现连接超时
+
+        public ReportInfo(String uuid, long timestamp, long elapsedTimeMillis, String firstDomain, boolean primaryDomain, int firstConnectTimeoutMillis, int firstReadTimeoutMillis, boolean firstHasDnsError, boolean firstHasConnectTimeout, boolean firstHasReadTimeout) {
+            this.uuid = uuid;
+            this.timestamp = timestamp;
+            this.elapsedTimeMillis = elapsedTimeMillis;
+            this.firstDomain = firstDomain;
+            this.primaryDomain = primaryDomain;
+            this.firstConnectTimeoutMillis = firstConnectTimeoutMillis;
+            this.firstReadTimeoutMillis = firstReadTimeoutMillis;
+            this.firstHasDnsError = firstHasDnsError?1:0;
+            this.firstHasConnectTimeout = firstHasConnectTimeout?1:0;
+            this.firstHasReadTimeout = firstHasReadTimeout?1:0;
+         }
+
+        @Override
+        public String toString() {
+            return "ReportInfo{" +
+                    "version='" + version + '\'' +
+                    ", sdk='" + sdk + '\'' +
+                    ", uuid='" + uuid + '\'' +
+                    ", timestamp=" + timestamp +
+                    ", elapsedTimeMillis=" + elapsedTimeMillis +
+                    ", firstDomain='" + firstDomain + '\'' +
+                    ", primaryDomain=" + primaryDomain +
+                    ", firstConnectTimeoutMillis=" + firstConnectTimeoutMillis +
+                    ", firstReadTimeoutMillis=" + firstReadTimeoutMillis +
+                    ", firstHasDnsError=" + firstHasDnsError +
+                    ", firstHasConnectTimeout=" + firstHasConnectTimeout +
+                    ", firstHasReadTimeout=" + firstHasReadTimeout +
+                    '}';
+        }
+
+        /**
+         * 转换成 csv 格式
+         *
+         * @return
+         */
+        public String toLineString(String key) {
+            String separator = ",";
+            Object[] objects = new Object[] {
+                version, sdk, uuid, timestamp, elapsedTimeMillis,
+                    firstDomain, primaryDomain, firstConnectTimeoutMillis, firstReadTimeoutMillis,
+                    firstHasDnsError, firstHasConnectTimeout, firstHasReadTimeout
+            };
+            StringBuffer sb = new StringBuffer();
+            for(Object obj: objects) {
+                sb.append(obj).append(separator);
+            }
+            try {
+                String sign = WXPayUtil.HMACSHA256(sb.toString(), key);
+                sb.append(sign);
+                return sb.toString();
+            }
+            catch (Exception ex) {
+                return null;
+            }
+
+        }
+
+    }
+
+    private static final String REPORT_URL = "http://report.mch.weixin.qq.com/wxpay/report/default";
+    // private static final String REPORT_URL = "http://127.0.0.1:5000/test";
+
+
+    private static final int DEFAULT_CONNECT_TIMEOUT_MS = 6*1000;
+    private static final int DEFAULT_READ_TIMEOUT_MS = 8*1000;
+
+    private LinkedBlockingQueue<String> reportMsgQueue = null;
+    private WXPayConfig config;
+    private ExecutorService executorService;
+
+    private volatile static WXPayReport INSTANCE;
+
+    private WXPayReport(final WXPayConfig config) {
+        this.config = config;
+        reportMsgQueue = new LinkedBlockingQueue<String>(config.getReportQueueMaxSize());
+
+        // 添加处理线程
+        executorService = Executors.newFixedThreadPool(config.getReportWorkerNum(), new ThreadFactory() {
+            public Thread newThread(Runnable r) {
+                Thread t = Executors.defaultThreadFactory().newThread(r);
+                t.setDaemon(true);
+                return t;
+            }
+        });
+
+        if (config.shouldAutoReport()) {
+            WXPayUtil.getLogger().info("report worker num: {}", config.getReportWorkerNum());
+            for (int i = 0; i < config.getReportWorkerNum(); ++i) {
+                executorService.execute(new Runnable() {
+                    public void run() {
+                        while (true) {
+                            // 先用 take 获取数据
+                            try {
+                                StringBuffer sb = new StringBuffer();
+                                String firstMsg = reportMsgQueue.take();
+                                WXPayUtil.getLogger().info("get first report msg: {}", firstMsg);
+                                String msg = null;
+                                sb.append(firstMsg); //会阻塞至有消息
+                                int remainNum = config.getReportBatchSize() - 1;
+                                for (int j=0; j<remainNum; ++j) {
+                                    WXPayUtil.getLogger().info("try get remain report msg");
+                                    // msg = reportMsgQueue.poll();  // 不阻塞了
+                                    msg = reportMsgQueue.take();
+                                    WXPayUtil.getLogger().info("get remain report msg: {}", msg);
+                                    if (msg == null) {
+                                        break;
+                                    }
+                                    else {
+                                        sb.append("\n");
+                                        sb.append(msg);
+                                    }
+                                }
+                                // 上报
+                                WXPayReport.httpRequest(sb.toString(), DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS);
+                            }
+                            catch (Exception ex) {
+                                WXPayUtil.getLogger().warn("report fail. reason: {}", ex.getMessage());
+                            }
+                        }
+                    }
+                });
+            }
+        }
+
+    }
+
+    /**
+     * 单例,双重校验,请在 JDK 1.5及更高版本中使用
+     *
+     * @param config
+     * @return
+     */
+    public static WXPayReport getInstance(WXPayConfig config) {
+        if (INSTANCE == null) {
+            synchronized (WXPayReport.class) {
+                if (INSTANCE == null) {
+                    INSTANCE = new WXPayReport(config);
+                }
+            }
+        }
+        return INSTANCE;
+    }
+
+    public void report(String uuid, long elapsedTimeMillis,
+                       String firstDomain, boolean primaryDomain, int firstConnectTimeoutMillis, int firstReadTimeoutMillis,
+                       boolean firstHasDnsError, boolean firstHasConnectTimeout, boolean firstHasReadTimeout) {
+        long currentTimestamp = WXPayUtil.getCurrentTimestamp();
+        ReportInfo reportInfo = new ReportInfo(uuid, currentTimestamp, elapsedTimeMillis,
+                firstDomain, primaryDomain, firstConnectTimeoutMillis, firstReadTimeoutMillis,
+                firstHasDnsError, firstHasConnectTimeout, firstHasReadTimeout);
+        String data = reportInfo.toLineString(config.getKey());
+        WXPayUtil.getLogger().info("report {}", data);
+        if (data != null) {
+            reportMsgQueue.offer(data);
+        }
+    }
+
+
+    @Deprecated
+    private void reportSync(final String data) throws Exception {
+        httpRequest(data, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS);
+    }
+
+    @Deprecated
+    private void reportAsync(final String data) throws Exception {
+        new Thread(new Runnable() {
+            public void run() {
+                try {
+                    httpRequest(data, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_READ_TIMEOUT_MS);
+                }
+                catch (Exception ex) {
+                    WXPayUtil.getLogger().warn("report fail. reason: {}", ex.getMessage());
+                }
+            }
+        }).start();
+    }
+
+    /**
+     * http 请求
+     * @param data
+     * @param connectTimeoutMs
+     * @param readTimeoutMs
+     * @return
+     * @throws Exception
+     */
+    private static String httpRequest(String data, int connectTimeoutMs, int readTimeoutMs) throws Exception{
+        BasicHttpClientConnectionManager connManager;
+        connManager = new BasicHttpClientConnectionManager(
+                RegistryBuilder.<ConnectionSocketFactory>create()
+                        .register("http", PlainConnectionSocketFactory.getSocketFactory())
+                        .register("https", SSLConnectionSocketFactory.getSocketFactory())
+                        .build(),
+                null,
+                null,
+                null
+        );
+        HttpClient httpClient = HttpClientBuilder.create()
+                .setConnectionManager(connManager)
+                .build();
+
+        HttpPost httpPost = new HttpPost(REPORT_URL);
+
+        RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeoutMs).setConnectTimeout(connectTimeoutMs).build();
+        httpPost.setConfig(requestConfig);
+
+        StringEntity postEntity = new StringEntity(data, "UTF-8");
+        httpPost.addHeader("Content-Type", "text/xml");
+        httpPost.addHeader("User-Agent", WXPayConstants.USER_AGENT);
+        httpPost.setEntity(postEntity);
+
+        HttpResponse httpResponse = httpClient.execute(httpPost);
+        HttpEntity httpEntity = httpResponse.getEntity();
+        return EntityUtils.toString(httpEntity, "UTF-8");
+    }
+
+}

+ 258 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayRequest.java

@@ -0,0 +1,258 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.DefaultHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
+import org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import java.io.InputStream;
+import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
+import java.security.KeyStore;
+import java.security.SecureRandom;
+
+import static com.lightinit.hsdataportal.WXsdk.WXPayConstants.USER_AGENT;
+
+public class WXPayRequest {
+    private WXPayConfig config;
+    public WXPayRequest(WXPayConfig config) throws Exception{
+
+        this.config = config;
+    }
+
+    /**
+     * 请求,只请求一次,不做重试
+     * @param domain
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @param connectTimeoutMs
+     * @param readTimeoutMs
+     * @param useCert 是否使用证书,针对退款、撤销等操作
+     * @return
+     * @throws Exception
+     */
+    private String requestOnce(final String domain, String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean useCert) throws Exception {
+        BasicHttpClientConnectionManager connManager;
+        if (useCert) {
+            // 证书
+            char[] password = config.getMchID().toCharArray();
+            InputStream certStream = config.getCertStream();
+            KeyStore ks = KeyStore.getInstance("PKCS12");
+            ks.load(certStream, password);
+
+            // 实例化密钥库 & 初始化密钥工厂
+            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+            kmf.init(ks, password);
+
+            // 创建 SSLContext
+            SSLContext sslContext = SSLContext.getInstance("TLS");
+            sslContext.init(kmf.getKeyManagers(), null, new SecureRandom());
+
+            SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(
+                    sslContext,
+                    new String[]{"TLSv1"},
+                    null,
+                    new DefaultHostnameVerifier());
+
+            connManager = new BasicHttpClientConnectionManager(
+                    RegistryBuilder.<ConnectionSocketFactory>create()
+                            .register("http", PlainConnectionSocketFactory.getSocketFactory())
+                            .register("https", sslConnectionSocketFactory)
+                            .build(),
+                    null,
+                    null,
+                    null
+            );
+        }
+        else {
+            connManager = new BasicHttpClientConnectionManager(
+                    RegistryBuilder.<ConnectionSocketFactory>create()
+                            .register("http", PlainConnectionSocketFactory.getSocketFactory())
+                            .register("https", SSLConnectionSocketFactory.getSocketFactory())
+                            .build(),
+                    null,
+                    null,
+                    null
+            );
+        }
+
+        HttpClient httpClient = HttpClientBuilder.create()
+                .setConnectionManager(connManager)
+                .build();
+
+        String url = "https://" + domain + urlSuffix;
+        HttpPost httpPost = new HttpPost(url);
+
+        RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeoutMs).setConnectTimeout(connectTimeoutMs).build();
+        httpPost.setConfig(requestConfig);
+
+        StringEntity postEntity = new StringEntity(data, "UTF-8");
+        httpPost.addHeader("Content-Type", "text/xml");
+        httpPost.addHeader("User-Agent", USER_AGENT + " " + config.getMchID());
+        httpPost.setEntity(postEntity);
+
+        HttpResponse httpResponse = httpClient.execute(httpPost);
+        HttpEntity httpEntity = httpResponse.getEntity();
+        return EntityUtils.toString(httpEntity, "UTF-8");
+
+    }
+
+
+    private String request(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean useCert, boolean autoReport) throws Exception {
+        Exception exception = null;
+        long elapsedTimeMillis = 0;
+        long startTimestampMs = WXPayUtil.getCurrentTimestampMs();
+        boolean firstHasDnsErr = false;
+        boolean firstHasConnectTimeout = false;
+        boolean firstHasReadTimeout = false;
+        IWXPayDomain.DomainInfo domainInfo = config.getWXPayDomain().getDomain(config);
+        if(domainInfo == null){
+            throw new Exception("WXPayConfig.getWXPayDomain().getDomain() is empty or null");
+        }
+        try {
+            String result = requestOnce(domainInfo.domain, urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, useCert);
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            config.getWXPayDomain().report(domainInfo.domain, elapsedTimeMillis, null);
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout);
+            return result;
+        }
+        catch (UnknownHostException ex) {  // dns 解析错误,或域名不存在
+            exception = ex;
+            firstHasDnsErr = true;
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            WXPayUtil.getLogger().warn("UnknownHostException for domainInfo {}", domainInfo);
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout
+            );
+        }
+        catch (ConnectTimeoutException ex) {
+            exception = ex;
+            firstHasConnectTimeout = true;
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            WXPayUtil.getLogger().warn("connect timeout happened for domainInfo {}", domainInfo);
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout
+            );
+        }
+        catch (SocketTimeoutException ex) {
+            exception = ex;
+            firstHasReadTimeout = true;
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            WXPayUtil.getLogger().warn("timeout happened for domainInfo {}", domainInfo);
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout);
+        }
+        catch (Exception ex) {
+            exception = ex;
+            elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+            WXPayReport.getInstance(config).report(
+                    uuid,
+                    elapsedTimeMillis,
+                    domainInfo.domain,
+                    domainInfo.primaryDomain,
+                    connectTimeoutMs,
+                    readTimeoutMs,
+                    firstHasDnsErr,
+                    firstHasConnectTimeout,
+                    firstHasReadTimeout);
+        }
+        config.getWXPayDomain().report(domainInfo.domain, elapsedTimeMillis, exception);
+        throw exception;
+    }
+
+
+    /**
+     * 可重试的,非双向认证的请求
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @return
+     */
+    public String requestWithoutCert(String urlSuffix, String uuid, String data, boolean autoReport) throws Exception {
+        return this.request(urlSuffix, uuid, data, config.getHttpConnectTimeoutMs(), config.getHttpReadTimeoutMs(), false, autoReport);
+    }
+
+    /**
+     * 可重试的,非双向认证的请求
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @param connectTimeoutMs
+     * @param readTimeoutMs
+     * @return
+     */
+    public String requestWithoutCert(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs,  boolean autoReport) throws Exception {
+        return this.request(urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, false, autoReport);
+    }
+
+    /**
+     * 可重试的,双向认证的请求
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @return
+     */
+    public String requestWithCert(String urlSuffix, String uuid, String data, boolean autoReport) throws Exception {
+        return this.request(urlSuffix, uuid, data, config.getHttpConnectTimeoutMs(), config.getHttpReadTimeoutMs(), true, autoReport);
+    }
+
+    /**
+     * 可重试的,双向认证的请求
+     * @param urlSuffix
+     * @param uuid
+     * @param data
+     * @param connectTimeoutMs
+     * @param readTimeoutMs
+     * @return
+     */
+    public String requestWithCert(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean autoReport) throws Exception {
+        return this.request(urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, true, autoReport);
+    }
+}

+ 296 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayUtil.java

@@ -0,0 +1,296 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.security.SecureRandom;
+import java.util.*;
+
+
+public class WXPayUtil {
+
+    private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+    private static final Random RANDOM = new SecureRandom();
+
+    /**
+     * XML格式字符串转换为Map
+     *
+     * @param strXML XML字符串
+     * @return XML数据转换后的Map
+     * @throws Exception
+     */
+    public static Map<String, String> xmlToMap(String strXML) throws Exception {
+        try {
+            Map<String, String> data = new HashMap<String, String>();
+            DocumentBuilder documentBuilder = WXPayXmlUtil.newDocumentBuilder();
+            InputStream stream = new ByteArrayInputStream(strXML.getBytes("UTF-8"));
+            org.w3c.dom.Document doc = documentBuilder.parse(stream);
+            doc.getDocumentElement().normalize();
+            NodeList nodeList = doc.getDocumentElement().getChildNodes();
+            for (int idx = 0; idx < nodeList.getLength(); ++idx) {
+                Node node = nodeList.item(idx);
+                if (node.getNodeType() == Node.ELEMENT_NODE) {
+                    org.w3c.dom.Element element = (org.w3c.dom.Element) node;
+                    data.put(element.getNodeName(), element.getTextContent());
+                }
+            }
+            try {
+                stream.close();
+            } catch (Exception ex) {
+                // do nothing
+            }
+            return data;
+        } catch (Exception ex) {
+            WXPayUtil.getLogger().warn("Invalid XML, can not convert to map. Error message: {}. XML content: {}", ex.getMessage(), strXML);
+            throw ex;
+        }
+
+    }
+
+    /**
+     * 将Map转换为XML格式的字符串
+     *
+     * @param data Map类型数据
+     * @return XML格式的字符串
+     * @throws Exception
+     */
+    public static String mapToXml(Map<String, String> data) throws Exception {
+        org.w3c.dom.Document document = WXPayXmlUtil.newDocument();
+        org.w3c.dom.Element root = document.createElement("xml");
+        document.appendChild(root);
+        for (String key: data.keySet()) {
+            String value = data.get(key);
+            if (value == null) {
+                value = "";
+            }
+            value = value.trim();
+            org.w3c.dom.Element filed = document.createElement(key);
+            filed.appendChild(document.createTextNode(value));
+            root.appendChild(filed);
+        }
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer transformer = tf.newTransformer();
+        DOMSource source = new DOMSource(document);
+        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+        StringWriter writer = new StringWriter();
+        StreamResult result = new StreamResult(writer);
+        transformer.transform(source, result);
+        String output = writer.getBuffer().toString(); //.replaceAll("\n|\r", "");
+        try {
+            writer.close();
+        }
+        catch (Exception ex) {
+        }
+        return output;
+    }
+
+
+    /**
+     * 生成带有 sign 的 XML 格式字符串
+     *
+     * @param data Map类型数据
+     * @param key API密钥
+     * @return 含有sign字段的XML
+     */
+    public static String generateSignedXml(final Map<String, String> data, String key) throws Exception {
+        return generateSignedXml(data, key, WXPayConstants.SignType.MD5);
+    }
+
+    /**
+     * 生成带有 sign 的 XML 格式字符串
+     *
+     * @param data Map类型数据
+     * @param key API密钥
+     * @param signType 签名类型
+     * @return 含有sign字段的XML
+     */
+    public static String generateSignedXml(final Map<String, String> data, String key, WXPayConstants.SignType signType) throws Exception {
+        String sign = generateSignature(data, key, signType);
+        data.put(WXPayConstants.FIELD_SIGN, sign);
+        return mapToXml(data);
+    }
+
+
+    /**
+     * 判断签名是否正确
+     *
+     * @param xmlStr XML格式数据
+     * @param key API密钥
+     * @return 签名是否正确
+     * @throws Exception
+     */
+    public static boolean isSignatureValid(String xmlStr, String key) throws Exception {
+        Map<String, String> data = xmlToMap(xmlStr);
+        if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) {
+            return false;
+        }
+        String sign = data.get(WXPayConstants.FIELD_SIGN);
+        return generateSignature(data, key).equals(sign);
+    }
+
+    /**
+     * 判断签名是否正确,必须包含sign字段,否则返回false。使用MD5签名。
+     *
+     * @param data Map类型数据
+     * @param key API密钥
+     * @return 签名是否正确
+     * @throws Exception
+     */
+    public static boolean isSignatureValid(Map<String, String> data, String key) throws Exception {
+        return isSignatureValid(data, key, WXPayConstants.SignType.MD5);
+    }
+
+    /**
+     * 判断签名是否正确,必须包含sign字段,否则返回false。
+     *
+     * @param data Map类型数据
+     * @param key API密钥
+     * @param signType 签名方式
+     * @return 签名是否正确
+     * @throws Exception
+     */
+    public static boolean isSignatureValid(Map<String, String> data, String key, WXPayConstants.SignType signType) throws Exception {
+        if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) {
+            return false;
+        }
+        String sign = data.get(WXPayConstants.FIELD_SIGN);
+        return generateSignature(data, key, signType).equals(sign);
+    }
+
+    /**
+     * 生成签名
+     *
+     * @param data 待签名数据
+     * @param key API密钥
+     * @return 签名
+     */
+    public static String generateSignature(final Map<String, String> data, String key) throws Exception {
+        return generateSignature(data, key, WXPayConstants.SignType.MD5);
+    }
+
+    /**
+     * 生成签名. 注意,若含有sign_type字段,必须和signType参数保持一致。
+     *
+     * @param data 待签名数据
+     * @param key API密钥
+     * @param signType 签名方式
+     * @return 签名
+     */
+    public static String generateSignature(final Map<String, String> data, String key, WXPayConstants.SignType signType) throws Exception {
+        Set<String> keySet = data.keySet();
+        String[] keyArray = keySet.toArray(new String[keySet.size()]);
+        Arrays.sort(keyArray);
+        StringBuilder sb = new StringBuilder();
+        for (String k : keyArray) {
+            if (k.equals(WXPayConstants.FIELD_SIGN)) {
+                continue;
+            }
+            if (data.get(k).trim().length() > 0) // 参数值为空,则不参与签名
+                sb.append(k).append("=").append(data.get(k).trim()).append("&");
+        }
+        sb.append("key=").append(key);
+        if (WXPayConstants.SignType.MD5.equals(signType)) {
+            return MD5(sb.toString()).toUpperCase();
+        }
+        else if (WXPayConstants.SignType.HMACSHA256.equals(signType)) {
+            return HMACSHA256(sb.toString(), key);
+        }
+        else {
+            throw new Exception(String.format("Invalid sign_type: %s", signType));
+        }
+    }
+
+
+    /**
+     * 获取随机字符串 Nonce Str
+     *
+     * @return String 随机字符串
+     */
+    public static String generateNonceStr() {
+        char[] nonceChars = new char[32];
+        for (int index = 0; index < nonceChars.length; ++index) {
+            nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
+        }
+        return new String(nonceChars);
+    }
+
+
+    /**
+     * 生成 MD5
+     *
+     * @param data 待处理数据
+     * @return MD5结果
+     */
+    public static String MD5(String data) throws Exception {
+        MessageDigest md = MessageDigest.getInstance("MD5");
+        byte[] array = md.digest(data.getBytes("UTF-8"));
+        StringBuilder sb = new StringBuilder();
+        for (byte item : array) {
+            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+        }
+        String s = sb.toString().toUpperCase();
+        return s;
+    }
+
+    /**
+     * 生成 HMACSHA256
+     * @param data 待处理数据
+     * @param key 密钥
+     * @return 加密结果
+     * @throws Exception
+     */
+    public static String HMACSHA256(String data, String key) throws Exception {
+        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
+        SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
+        sha256_HMAC.init(secret_key);
+        byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8"));
+        StringBuilder sb = new StringBuilder();
+        for (byte item : array) {
+            sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+        }
+        String s = sb.toString().toUpperCase();
+        return s;
+    }
+
+    /**
+     * 日志
+     * @return
+     */
+    public static Logger getLogger() {
+        Logger logger = LoggerFactory.getLogger("wxpay java sdk");
+        return logger;
+    }
+
+    /**
+     * 获取当前时间戳,单位秒
+     * @return
+     */
+    public static long getCurrentTimestamp() {
+        return System.currentTimeMillis()/1000;
+    }
+
+    /**
+     * 获取当前时间戳,单位毫秒
+     * @return
+     */
+    public static long getCurrentTimestampMs() {
+        return System.currentTimeMillis();
+    }
+
+}

+ 30 - 0
src/main/java/com/lightinit/hsdataportal/WXsdk/WXPayXmlUtil.java

@@ -0,0 +1,30 @@
+package com.lightinit.hsdataportal.WXsdk;
+
+import org.w3c.dom.Document;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * 2018/7/3
+ */
+public final class WXPayXmlUtil {
+    public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
+        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+        documentBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+        documentBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+        documentBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+        documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+        documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+        documentBuilderFactory.setXIncludeAware(false);
+        documentBuilderFactory.setExpandEntityReferences(false);
+
+        return documentBuilderFactory.newDocumentBuilder();
+    }
+
+    public static Document newDocument() throws ParserConfigurationException {
+        return newDocumentBuilder().newDocument();
+    }
+}

+ 62 - 0
src/main/java/com/lightinit/hsdataportal/annotation/AnnotationHelper.java

@@ -0,0 +1,62 @@
+package com.lightinit.hsdataportal.annotation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author WangYao
+ * @date 2018/6/2 11:02
+ * @description 注解帮助类
+ */
+public class AnnotationHelper {
+
+    /**
+     * @param clazz 目标类.class
+     * @param fieldName 成员变量(字段)名
+     * @param clazzAnnotation 注解.class
+     * @param <T> 泛型,继承自Annotaion
+     * @return 注解类实例或null。
+     */
+    public static <T extends Annotation> T getFieldAnnotation(Class clazz, String fieldName, Class<T> clazzAnnotation){
+        List<Field> fieldList = new ArrayList<>();
+        Class tempClass = clazz;
+        while (tempClass != null) { //当父类为null的时候说明到达了最上层的父类(Object类).
+            Field[] fields = tempClass.getDeclaredFields();
+            fieldList.addAll(Arrays.asList(fields));
+            tempClass = tempClass.getSuperclass(); //得到父类,然后赋给自己
+        }
+        if (fieldList == null || fieldList.size() == 0){
+            return null;
+        }
+        Field targetField = null;
+        for (Field field : fieldList){
+            if (field.getName().equals(fieldName)){
+                targetField = field;
+                break;
+            }
+        }
+        if (targetField == null){
+            return null;
+        }
+        if (!targetField.isAnnotationPresent(clazzAnnotation)){
+            return null;
+        }
+        return targetField.getAnnotation(clazzAnnotation);
+    }
+
+
+    /**
+     * @param object 目标类对象
+     * @param fieldName 成员变量(字段)名
+     * @param clazzAnnotation 注解.class
+     * @param <TObject> 泛型目标类对象
+     * @param <TAnnotation> 泛型注解,继承自Annotaion
+     * @return 注解类实例或null。
+     */
+    public static <TObject, TAnnotation extends Annotation> TAnnotation getFieldAnnotation(TObject object, String fieldName, Class<TAnnotation> clazzAnnotation){
+        return object == null ? null : getFieldAnnotation(object.getClass(), fieldName, clazzAnnotation);
+    }
+}

+ 21 - 0
src/main/java/com/lightinit/hsdataportal/annotation/FieldDescriber.java

@@ -0,0 +1,21 @@
+package com.lightinit.hsdataportal.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author WangYao
+ * @date 2018/6/1 15:30
+ * @description 字段描述器
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface FieldDescriber {
+
+    /**
+     * 字段的描述
+     */
+    String descripton() default "";
+}

+ 27 - 0
src/main/java/com/lightinit/hsdataportal/annotation/FieldDescriberHelper.java

@@ -0,0 +1,27 @@
+package com.lightinit.hsdataportal.annotation;
+
+/**
+ * @author WangYao
+ * @date 2018/6/1 15:39
+ * @description 字段描述器帮助类
+ */
+public class FieldDescriberHelper {
+
+    public static <T> FieldDescriber getFieldDescriber(Class clazz, String fieldName){
+        return AnnotationHelper.getFieldAnnotation(clazz, fieldName, FieldDescriber.class);
+    }
+
+    public static <T> FieldDescriber getFieldDescriber(T object, String fieldName){
+        return AnnotationHelper.getFieldAnnotation(object, fieldName, FieldDescriber.class);
+    }
+
+    public static <T> String getFieldDescription(Class clazz, String fieldName){
+        FieldDescriber fieldDescriber = getFieldDescriber(clazz, fieldName);
+        return fieldDescriber == null ? null : fieldDescriber.descripton();
+    }
+
+    public static <T> String getFieldDescription(T object, String fieldName){
+        FieldDescriber fieldDescriber = getFieldDescriber(object, fieldName);
+        return fieldDescriber == null ? null : fieldDescriber.descripton();
+    }
+}

ファイルの差分が大きいため隠しています
+ 54 - 0
src/main/java/com/lightinit/hsdataportal/common/AlipayConfig.java


ファイルの差分が大きいため隠しています
+ 213 - 0
src/main/java/com/lightinit/hsdataportal/common/ApiEncryptUtil.java


+ 219 - 0
src/main/java/com/lightinit/hsdataportal/common/AuthenticUtil.java

@@ -0,0 +1,219 @@
+package com.lightinit.hsdataportal.common;
+
+import com.alibaba.druid.support.json.JSONUtils;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.lightinit.hsdataportal.common.HttpUtil;
+import com.lightinit.hsdataportal.handler.GlobalExceptionHandler;
+import com.sun.org.apache.bcel.internal.generic.NEW;
+import net.sf.json.JSON;
+import net.sf.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * @Author: sunxiang
+ * @Date: 2019/2/28 17:07
+ * @Description:
+ **/
+public class AuthenticUtil {
+
+    private static final Logger logger = LoggerFactory.getLogger(AuthenticUtil.class);
+    public static final String DEF_CHATSET = "UTF-8";
+    public static final int DEF_CONN_TIMEOUT = 30000;
+    public static final int DEF_READ_TIMEOUT = 30000;
+    public static String userAgent =  "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
+
+
+    public static final String METHOD="GET";
+    public static  String IDCARD_STRURL="";
+    public static  String IDCARD_APPKEY ="";
+    public static  String BANKCARD_STRURL="";
+    public static  String BANKCARD_APPKEY ="";
+    public static  String PHONE_STRURL="";
+    public static  String PHONE_APPKEY ="";
+    static {
+        InputStream inputStream=null;
+        try {
+            inputStream= AuthenticUtil.class.getClassLoader().getResourceAsStream("authentic.properties");
+            Properties properties = new Properties();
+            properties.load(inputStream);
+            IDCARD_STRURL = properties.getProperty("authentic.idcard.strUrl");
+            IDCARD_APPKEY = properties.getProperty("authentic.idcard.appkey");
+            BANKCARD_STRURL = properties.getProperty("authentic.bank.strUrl");
+            BANKCARD_APPKEY = properties.getProperty("authentic.bank.appkey");
+            PHONE_STRURL = properties.getProperty("authentic.phone.strUrl");
+            PHONE_APPKEY = properties.getProperty("authentic.phone.appkey");
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if(inputStream!=null){
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+    public  static boolean authenticByIdCard(String username,String idcard){
+        HashMap<String, String> params = new HashMap<>();
+        params.put("key",IDCARD_APPKEY);
+        params.put("idcard",idcard);
+        params.put("realname",username);
+        try {
+            String result = net(IDCARD_STRURL,params, METHOD);
+            JSONObject object = JSONObject.fromObject(result);
+            if(object.getInt("error_code")==0) {
+                Object obj = object.get("result");
+                System.out.println(obj);
+                JSONObject jsonObject = JSONObject.fromObject(obj);
+                if (jsonObject.getInt("res") == 1) {
+                    return true;
+                }
+            }else{
+                logger.error("调用身份验证网站错误,请查看对应码解释:错误码是:"+object.getInt("error_code"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+
+    public static boolean authenticByBankCard(String username,String bankCard){
+        Map params = new HashMap();//请求参数
+        params.put("bankcard",bankCard);//银行卡卡号
+        params.put("realname",username);//姓名(需utf8编码的urlencode)
+        params.put("key",BANKCARD_APPKEY);//应用APPKEY(应用详细页查询)
+        try {
+            String result =net(BANKCARD_STRURL, params, METHOD);
+            JSONObject object = JSONObject.fromObject(result);
+            if(object.getInt("error_code")==0) {
+                Object obj = object.get("result");
+                System.out.println(obj);
+                JSONObject jsonObject = JSONObject.fromObject(obj);
+                if (jsonObject.getInt("res") == 1) {
+                    return true;
+                }
+            }else{
+                logger.error("调用身份验证网站错误,请查看对应码解释:错误码是:"+object.getInt("error_code"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
+
+    public static boolean authenticByPhone(String username,String idCard,String phone){
+            System.out.println(PHONE_APPKEY);
+            System.out.println(PHONE_STRURL);
+            Map params = new HashMap();//请求参数
+            params.put("idcard",idCard);//银行卡卡号
+            params.put("realname",username);//姓名(需utf8编码的urlencode)
+            params.put("mobile",phone);//姓名(需utf8编码的urlencode)
+            params.put("key",PHONE_APPKEY);//应用APPKEY(应用详细页查询)
+            try {
+                String result =net(PHONE_STRURL, params, METHOD);
+                JSONObject object = JSONObject.fromObject(result);
+                if(object.getInt("error_code")==0) {
+                    Object obj = object.get("result");
+                    System.out.println(obj);
+                    JSONObject jsonObject = JSONObject.fromObject(obj);
+                    if (jsonObject.getInt("res") == 1) {
+                        return true;
+                    }
+                }else{
+                    logger.error("调用身份验证网站错误,请查看对应码解释:错误码是:"+object.getInt("error_code"));
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            return false;
+        }
+
+
+
+
+    /**
+     *
+     * @param strUrl 请求地址
+     * @param params 请求参数
+     * @param method 请求方法
+     * @return  网络请求字符串
+     * @throws Exception
+     */
+    public static String net(String strUrl, Map params,String method) throws Exception {
+        HttpURLConnection conn = null;
+        BufferedReader reader = null;
+        String rs = null;
+        try {
+            StringBuffer sb = new StringBuffer();
+            if(method==null || method.equals("GET")){
+                strUrl = strUrl+"?"+urlencode(params);
+            }
+            URL url = new URL(strUrl);
+            conn = (HttpURLConnection) url.openConnection();
+            if(method==null || method.equals("GET")){
+                conn.setRequestMethod("GET");
+            }else{
+                conn.setRequestMethod("POST");
+                conn.setDoOutput(true);
+            }
+            conn.setRequestProperty("User-agent", userAgent);
+            conn.setUseCaches(false);
+            conn.setConnectTimeout(DEF_CONN_TIMEOUT);
+            conn.setReadTimeout(DEF_READ_TIMEOUT);
+            conn.setInstanceFollowRedirects(false);
+            conn.connect();
+            if (params!= null && method.equals("POST")) {
+                try {
+                    DataOutputStream out = new DataOutputStream(conn.getOutputStream());
+                    out.writeBytes(urlencode(params));
+                } catch (Exception e) {
+                    // handle exception
+                }
+            }
+            InputStream is = conn.getInputStream();
+            reader = new BufferedReader(new InputStreamReader(is, DEF_CHATSET));
+            String strRead = null;
+            while ((strRead = reader.readLine()) != null) {
+                sb.append(strRead);
+            }
+            rs = sb.toString();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (reader != null) {
+                reader.close();
+            }
+            if (conn != null) {
+                conn.disconnect();
+            }
+        }
+        return rs;
+    }
+
+    //将map型转为请求参数型
+    public static String urlencode(Map<String,Object>data) {
+        StringBuilder sb = new StringBuilder();
+        for (Map.Entry i : data.entrySet()) {
+            try {
+                sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue()+"","UTF-8")).append("&");
+            } catch (UnsupportedEncodingException e) {
+                e.printStackTrace();
+            }
+        }
+        return sb.toString();
+    }
+}

+ 215 - 0
src/main/java/com/lightinit/hsdataportal/common/Base64Utils.java

@@ -0,0 +1,215 @@
+package com.lightinit.hsdataportal.common;
+import java.io.UnsupportedEncodingException;
+/**
+ * Created by Mr.Yao on 2017/5/4.
+ */
+public class Base64Utils {
+    public static final String DEFAULT_ENCODING = "UTF-8";
+
+    /*
+     * The methods of this class are static. Do not instantiate this class. Use
+     * its static methods to get the encoded/decoded results
+     */
+    public static String encode(byte[] byteData) throws UnsupportedEncodingException {
+        return encode(byteData, DEFAULT_ENCODING);
+    }
+    public static String encode(byte[] byteData, String encoding) throws UnsupportedEncodingException {
+        if(byteData == null) { throw new IllegalArgumentException("byteData cannot be null"); }
+        return new String(_encode(byteData),encoding);
+    }
+
+    public static byte[] encode(String string) throws UnsupportedEncodingException {
+        return encode(string, DEFAULT_ENCODING);
+    }
+
+    public static byte[] encode(String string, String encoding) throws UnsupportedEncodingException {
+        if(string == null) { throw new IllegalArgumentException("string cannot be null"); }
+        return _encode(string.getBytes(encoding));
+    }
+
+    public final static byte[] _encode(byte[] byteData) {
+        /* If we received a null argument, exit this method. */
+        if (byteData == null) { throw new IllegalArgumentException("byteData cannot be null"); }
+
+        /*
+         * Declare working variables including an array of bytes that will
+         * contain the encoded data to be returned to the caller. Note that the
+         * encoded array is about 1/3 larger than the input. This is because
+         * every group of 3 bytes is being encoded into 4 bytes.
+         */
+        int iSrcIdx; // index into source (byteData)
+        int iDestIdx; // index into destination (byteDest)
+        // byte[] byteData = (byte[])byteData_in.clone();
+        // byte[] byteData = byteData_in;
+        byte[] byteDest = new byte[((byteData.length + 2) / 3) * 4];
+
+        /*
+         * Walk through the input array, 24 bits at a time, converting them from
+         * 3 groups of 8 to 4 groups of 6 with two unset bits between. as per
+         * Base64 spec see
+         * http://www.javaworld.com/javaworld/javatips/jw-javatip36-p2.html for
+         * example explanation
+         */
+        for (iSrcIdx = 0, iDestIdx = 0; iSrcIdx < byteData.length - 2; iSrcIdx += 3) {
+            byteDest[iDestIdx++] = (byte) ((byteData[iSrcIdx] >>> 2) & 077);
+            byteDest[iDestIdx++] = (byte) ((byteData[iSrcIdx + 1] >>> 4) & 017 | (byteData[iSrcIdx] << 4) & 077);
+            byteDest[iDestIdx++] = (byte) ((byteData[iSrcIdx + 2] >>> 6) & 003 | (byteData[iSrcIdx + 1] << 2) & 077);
+            byteDest[iDestIdx++] = (byte) (byteData[iSrcIdx + 2] & 077);
+        }
+
+        /*
+         * If the number of bytes we received in the input array was not an even
+         * multiple of 3, convert the remaining 1 or 2 bytes.
+         */
+        if (iSrcIdx < byteData.length) {
+            byteDest[iDestIdx++] = (byte) ((byteData[iSrcIdx] >>> 2) & 077);
+            if (iSrcIdx < byteData.length - 1) {
+                byteDest[iDestIdx++] = (byte) ((byteData[iSrcIdx + 1] >>> 4) & 017 | (byteData[iSrcIdx] << 4) & 077);
+                byteDest[iDestIdx++] = (byte) ((byteData[iSrcIdx + 1] << 2) & 077);
+            } else
+                byteDest[iDestIdx++] = (byte) ((byteData[iSrcIdx] << 4) & 077);
+        }
+
+        /*
+         * Use the encoded data as indexes into the Base64 alphabet. (The Base64
+         * alphabet is completely documented in RFC 1521.)
+         */
+        for (iSrcIdx = 0; iSrcIdx < iDestIdx; iSrcIdx++) {
+            if (byteDest[iSrcIdx] < 26)
+                byteDest[iSrcIdx] = (byte) (byteDest[iSrcIdx] + 'A');
+            else if (byteDest[iSrcIdx] < 52)
+                byteDest[iSrcIdx] = (byte) (byteDest[iSrcIdx] + 'a' - 26);
+            else if (byteDest[iSrcIdx] < 62)
+                byteDest[iSrcIdx] = (byte) (byteDest[iSrcIdx] + '0' - 52);
+            else if (byteDest[iSrcIdx] < 63)
+                byteDest[iSrcIdx] = '+';
+            else
+                byteDest[iSrcIdx] = '/';
+        }
+
+        /* Pad any unused bytes in the destination string with '=' characters. */
+        for (; iSrcIdx < byteDest.length; iSrcIdx++)
+            byteDest[iSrcIdx] = '=';
+
+        return byteDest;
+    }
+
+    public static String decode(byte[] encoded) throws UnsupportedEncodingException {
+        return decode(encoded, DEFAULT_ENCODING);
+    }
+
+    public static String decode(byte[] encoded, String encoding) throws UnsupportedEncodingException {
+        if(encoded == null) { throw new IllegalArgumentException("encoded cannot be null"); }
+        return new String(_decode(encoded), encoding);
+    }
+
+    public final static byte[] decode(String encoded) throws UnsupportedEncodingException {
+        return decode(encoded,DEFAULT_ENCODING);
+    }
+
+    public final static byte[] decode(String encoded, String encoding) throws IllegalArgumentException, UnsupportedEncodingException {
+        if(null == encoded) { throw new IllegalArgumentException("encoded cannot be null"); }
+        return _decode(encoded.getBytes(encoding));
+    }
+
+    public final static byte[] _decode(byte[] byteData) throws IllegalArgumentException {
+        /* If we received a null argument, exit this method. */
+        if (byteData == null) { throw new IllegalArgumentException("byteData cannot be null"); }
+
+        /*
+         * Declare working variables including an array of bytes that will
+         * contain the decoded data to be returned to the caller. Note that the
+         * decoded array is about 3/4 smaller than the input. This is because
+         * every group of 4 bytes is being encoded into 3 bytes.
+         */
+        int iSrcIdx; // index into source (byteData)
+        int reviSrcIdx; // index from end of the src array (byteData)
+        int iDestIdx; // index into destination (byteDest)
+        byte[] byteTemp = new byte[byteData.length];
+
+        /*
+         * remove any '=' chars from the end of the byteData they would have
+         * been padding to make it up to groups of 4 bytes note that I don't
+         * need to remove it just make sure that when progressing throug array
+         * we don't go past reviSrcIdx ;-)
+         */
+        for (reviSrcIdx = byteData.length; reviSrcIdx -1 > 0 && byteData[reviSrcIdx -1] == '='; reviSrcIdx--) {
+            ; // do nothing. I'm just interested in value of reviSrcIdx
+        }
+
+        /* sanity check */
+        if (reviSrcIdx -1 == 0) { return null; /* ie all padding */ }
+
+        /*
+         * Set byteDest, this is smaller than byteData due to 4 -> 3 byte munge.
+         * Note that this is an integer division! This fact is used in the logic
+         * l8r. to make sure we don't fall out of the array and create an
+         * OutOfBoundsException and also in handling the remainder
+         */
+        byte byteDest[] = new byte[((reviSrcIdx * 3) / 4)];
+
+        /*
+         * Convert from Base64 alphabet to encoded data (The Base64 alphabet is
+         * completely documented in RFC 1521.) The order of the testing is
+         * important as I use the '<' operator which looks at the hex value of
+         * these ASCII chars. So convert from the smallest up
+         *
+         * do all of this in a new array so as not to edit the original input
+         */
+        for (iSrcIdx = 0; iSrcIdx < reviSrcIdx; iSrcIdx++) {
+            if (byteData[iSrcIdx] == '+')
+                byteTemp[iSrcIdx] = 62;
+            else if (byteData[iSrcIdx] == '/')
+                byteTemp[iSrcIdx] = 63;
+            else if (byteData[iSrcIdx] < '0' + 10)
+                byteTemp[iSrcIdx] = (byte) (byteData[iSrcIdx] + 52 - '0');
+            else if (byteData[iSrcIdx] < ('A' + 26))
+                byteTemp[iSrcIdx] = (byte) (byteData[iSrcIdx] - 'A');
+            else if (byteData[iSrcIdx] < 'a' + 26)
+                byteTemp[iSrcIdx] = (byte) (byteData[iSrcIdx] + 26 - 'a');
+        }
+
+        /*
+         * 4bytes -> 3bytes munge Walk through the input array, 32 bits at a
+         * time, converting them from 4 groups of 6 to 3 groups of 8 removing
+         * the two unset most significant bits of each sorce byte as this was
+         * filler, as per Base64 spec. stop before potential buffer overun on
+         * byteDest, remember that byteDest is 3/4 (integer division) the size
+         * of input and won't necessary divide exactly (ie iDestIdx must be <
+         * (integer div byteDest.length / 3)*3 see
+         * http://www.javaworld.com/javaworld/javatips/jw-javatip36-p2.html for
+         * example
+         */
+        for (iSrcIdx = 0, iDestIdx = 0; iSrcIdx < reviSrcIdx
+                && iDestIdx < ((byteDest.length / 3) * 3); iSrcIdx += 4) {
+            byteDest[iDestIdx++] = (byte) ((byteTemp[iSrcIdx] << 2) & 0xFC | (byteTemp[iSrcIdx + 1] >>> 4) & 0x03);
+            byteDest[iDestIdx++] = (byte) ((byteTemp[iSrcIdx + 1] << 4) & 0xF0 | (byteTemp[iSrcIdx + 2] >>> 2) & 0x0F);
+            byteDest[iDestIdx++] = (byte) ((byteTemp[iSrcIdx + 2] << 6) & 0xC0 | byteTemp[iSrcIdx + 3] & 0x3F);
+        }
+
+        /*
+         * tidy up any remainders if iDestIdx >= ((byteDest.length / 3)*3) but
+         * iSrcIdx < reviSrcIdx then we have at most 2 extra destination bytes
+         * to fill and posiblr 3 input bytes yet to process
+         */
+        if (iSrcIdx < reviSrcIdx) {
+            if (iSrcIdx < reviSrcIdx - 2) {
+                // "3 input bytes left"
+                byteDest[iDestIdx++] = (byte) ((byteTemp[iSrcIdx] << 2) & 0xFC | (byteTemp[iSrcIdx + 1] >>> 4) & 0x03);
+                byteDest[iDestIdx++] = (byte) ((byteTemp[iSrcIdx + 1] << 4) & 0xF0 | (byteTemp[iSrcIdx + 2] >>> 2) & 0x0F);
+            } else if (iSrcIdx < reviSrcIdx - 1) {
+                // "2 input bytes left"
+                byteDest[iDestIdx++] = (byte) ((byteTemp[iSrcIdx] << 2) & 0xFC | (byteTemp[iSrcIdx + 1] >>> 4) & 0x03);
+            }
+            /*
+             * wont have just one input byte left (unless input wasn't base64
+             * encoded ) due to the for loop steps and array sizes, after "="
+             * pad removed, but for compleatness
+             */
+            else {
+                throw new IllegalArgumentException("Warning: 1 input bytes left to process. This was not Base64 input");
+            }
+        }
+        return byteDest;
+    }
+}

+ 78 - 0
src/main/java/com/lightinit/hsdataportal/common/BaseRemoteClient.java

@@ -0,0 +1,78 @@
+package com.lightinit.hsdataportal.common;
+
+import com.lightinit.hsdataportal.json.pojo.ServerEntity;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+import org.springframework.util.StringUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+/**
+ * Created by Mr.Yao on 2017/10/10.
+ */
+public class BaseRemoteClient implements Watcher{
+
+    private final Random random=new Random();
+    List<String> list = new ArrayList<String>();
+    private ZooKeeper zooKeeper=null;
+
+    protected BaseRemoteClient(String node, String service){
+        //RegisterServerList(node,service);
+    }
+
+    protected void RegisterServerList(String node, String service) {
+        try {
+            if (zooKeeper == null) {
+                ThriftServerConfig config = new ThriftServerConfig();
+                zooKeeper = new ZooKeeper(config.getHost() + ":" + config.getPort(), 30000, this);
+                if (zooKeeper.exists("/thrift", false) != null) {
+                    if (zooKeeper.exists(String.format("/thrift/%s", node), false) != null) {
+                        if (zooKeeper.exists(String.format("/thrift/%s/%s", node, service), true) != null) {
+                            list = zooKeeper.getChildren(String.format("/thrift/%s/%s", node, service), true);
+                        }
+                    }
+                }
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        } catch (KeeperException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public ServerEntity SelectServer(){
+        ServerEntity item=new ServerEntity();
+        if(list.size()<=0){
+            item.setServerIp("127.0.0.1");
+            item.setServerPort(9876);
+        }else{
+            String serverIp=list.get(random.nextInt(list.size()));
+            if (StringUtils.isEmpty(serverIp)){
+                item.setServerIp("127.0.0.1");
+                item.setServerPort(9876);
+            }else{
+                String []infos= serverIp.split(":");
+                if(infos.length==2) {
+                    item.setServerIp(infos[0]);
+                    item.setServerPort(Integer.valueOf(infos[1]));
+                }else{
+                    item.setServerIp("127.0.0.1");
+                    item.setServerPort(9876);
+                }
+            }
+        }
+        return item;
+    }
+
+    @Override
+    public void process(WatchedEvent watchedEvent) {
+
+    }
+}

+ 35 - 0
src/main/java/com/lightinit/hsdataportal/common/BytesUtil.java

@@ -0,0 +1,35 @@
+package com.lightinit.hsdataportal.common;
+
+/**
+ * Created by Mr.Yao on 2017/5/4.
+ */
+public class BytesUtil {
+
+    private static final char[] HEX_CHAR= {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+    private static int parse(char c) {
+        if (c >= 'a')
+            return (c - 'a' + 10) & 0x0f;
+        if (c >= 'A')
+            return (c - 'A' + 10) & 0x0f;
+        return (c - '0') & 0x0f;
+    }
+
+    public static byte[] HexStringToBytes(String hexstr) {
+        byte[] b = new byte[hexstr.length() / 2];
+        int j = 0;
+        for (int i = 0; i < b.length; i++) {
+            char c0 = hexstr.charAt(j++);
+            char c1 = hexstr.charAt(j++);
+            b[i] = (byte) ((parse(c0) << 4) | parse(c1));
+        }
+        return b;
+    }
+    public static String byteArrayToString(byte[] data){
+        StringBuilder stringBuilder= new StringBuilder();
+        for (int i=0; i<data.length; i++){
+            stringBuilder.append(HEX_CHAR[(data[i] & 0xf0)>>> 4]);
+            stringBuilder.append(HEX_CHAR[(data[i] & 0x0f)]);
+        }
+        return stringBuilder.toString();
+    }
+}

+ 14 - 0
src/main/java/com/lightinit/hsdataportal/common/CharEncoding.java

@@ -0,0 +1,14 @@
+package com.lightinit.hsdataportal.common;
+
+public enum CharEncoding {
+	UTF8("UTF-8"), GBK("GBK"), GB2312("GB2312");
+	String _charset = "UTF-8";
+
+	private CharEncoding(String charset) {
+		_charset = charset;
+	}
+
+	public String value() {
+		return _charset;
+	}
+}

+ 19 - 0
src/main/java/com/lightinit/hsdataportal/common/CharacterUtils.java

@@ -0,0 +1,19 @@
+package com.lightinit.hsdataportal.common;
+
+import java.util.Random;
+
+public class CharacterUtils {
+    /*
+    *随机字符串生成
+    */
+    public static String getRandomString(int length){
+        String str="zxcvbnmlkjhgfdsaqwertyuiopQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
+        Random random=new Random();
+        StringBuffer sb=new StringBuffer();
+        for(int i=0;i<length;i++){
+            int number=random.nextInt(62);
+            sb.append(str.charAt(number));
+        }
+        return sb.toString();
+    }
+}

+ 37 - 0
src/main/java/com/lightinit/hsdataportal/common/ConfigUtils.java

@@ -0,0 +1,37 @@
+package com.lightinit.hsdataportal.common;
+
+import org.apache.commons.configuration2.Configuration;
+import org.apache.commons.configuration2.builder.fluent.Configurations;
+import org.apache.commons.configuration2.ex.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by WangYao on 2018/6/13.
+ */
+public class ConfigUtils {
+
+    private static final Logger logger = LoggerFactory.getLogger(ConfigUtils.class);
+
+    private Configuration configuration=null;
+    private static final Map<String, Configuration> configurationMap = new HashMap<>();
+
+    public static Configuration getConfiguration(String propertiesFile){
+        Configuration configuration = null;
+        if (!configurationMap.containsKey(propertiesFile)){
+            try {
+                Configurations configurations = new Configurations();
+                configuration = configurations.properties(new File(propertiesFile));
+                configurationMap.put(propertiesFile, configuration);
+            } catch (ConfigurationException e) {
+                logger.error(e.getMessage());
+                return null;
+            }
+        }
+        return configurationMap.get(propertiesFile);
+    }
+}

+ 84 - 0
src/main/java/com/lightinit/hsdataportal/common/DateUtils.java

@@ -0,0 +1,84 @@
+package com.lightinit.hsdataportal.common;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * Created by Mr.Yao on 2017/9/26.
+ */
+public class DateUtils {
+    public static int daysBetween(String begindate, String enddate) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(sdf.parse(begindate));
+            long time1 = cal.getTimeInMillis();
+            cal.setTime(sdf.parse(enddate));
+            long time2 = cal.getTimeInMillis();
+            long between_days = (time2 - time1) / (1000 * 3600 * 24);
+
+            return Integer.parseInt(String.valueOf(between_days));
+        } catch (ParseException e) {
+            return 0;
+        }
+    }
+
+    public static String weekBeginDate(Date date) {
+        try {
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(date);
+            int d = 0;
+            if (cal.get(Calendar.DAY_OF_WEEK) == 1) {
+                d = -6;
+            } else {
+                d = 2 - cal.get(Calendar.DAY_OF_WEEK);
+            }
+            cal.add(Calendar.DAY_OF_WEEK, d);
+            return simpleDateFormat.format(cal.getTime());
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    public static String weekEndDate(Date date) {
+        try {
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(date);
+            int d = 0;
+            if (cal.get(Calendar.DAY_OF_WEEK) == 1) {
+                d = -6;
+            } else {
+                d = 2 - cal.get(Calendar.DAY_OF_WEEK);
+            }
+            cal.add(Calendar.DAY_OF_WEEK, d);
+            cal.add(Calendar.DAY_OF_WEEK, 6);
+            return simpleDateFormat.format(cal.getTime());
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    public static Date StringToDate(String str) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Date result = sdf.parse(str);
+            return result;
+        } catch (ParseException ex) {
+            return null;
+        }
+    }
+
+    public static int YearOfDate() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.YEAR);
+    }
+
+    public static int MonthOfDate() {
+        Calendar now = Calendar.getInstance();
+        return now.get(Calendar.MONTH) + 1;
+    }
+}

+ 41 - 0
src/main/java/com/lightinit/hsdataportal/common/ExcelTookitUtils.java

@@ -0,0 +1,41 @@
+package com.lightinit.hsdataportal.common;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+
+/**
+ * Created by Mr.Yao on 2017/6/14.
+ */
+public class ExcelTookitUtils {
+    /**
+     * 获取97-2003EXCEL单元格内容
+     * @param xssfRow 单元格
+     * @return 单元格内容
+     */
+    @SuppressWarnings("static-access")
+    public static String getValue(XSSFCell xssfRow) {
+        if (xssfRow.getCellType() == xssfRow.CELL_TYPE_BOOLEAN) {
+            return String.valueOf(xssfRow.getBooleanCellValue());
+        } else if (xssfRow.getCellType() == xssfRow.CELL_TYPE_NUMERIC) {
+            return String.valueOf(xssfRow.getNumericCellValue());
+        } else {
+            return String.valueOf(xssfRow.getStringCellValue());
+        }
+    }
+
+    /**
+     * 获取xlsx格式的单元格内容
+     * @param hssfCell 单元格
+     * @return 单元格内容
+     */
+    @SuppressWarnings("static-access")
+    public static String getValue(HSSFCell hssfCell) {
+        if (hssfCell.getCellType() == hssfCell.CELL_TYPE_BOOLEAN) {
+            return String.valueOf(hssfCell.getBooleanCellValue());
+        } else if (hssfCell.getCellType() == hssfCell.CELL_TYPE_NUMERIC) {
+            return String.valueOf(hssfCell.getNumericCellValue());
+        } else {
+            return String.valueOf(hssfCell.getStringCellValue());
+        }
+    }
+}

+ 93 - 0
src/main/java/com/lightinit/hsdataportal/common/FTPConfigurationUtilsPro.java

@@ -0,0 +1,93 @@
+package com.lightinit.hsdataportal.common;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by Mr.Yao on 2017/12/13.
+ */
+@Component
+public class FTPConfigurationUtilsPro {
+
+    @Value("${ftp.deploy.host}")
+    private String deploy_host;
+    @Value("${ftp.deploy.port}")
+    private int deploy_port;
+    @Value("${ftp.deploy.username}")
+    private String deploy_username;
+    @Value("${ftp.deploy.password}")
+    private String deploy_password;
+
+    public String getDeploy_host() {
+        return deploy_host;
+    }
+
+    public void setDeploy_host(String deploy_host) {
+        this.deploy_host = deploy_host;
+    }
+
+    public int getDeploy_port() {
+        return deploy_port;
+    }
+
+    public void setDeploy_port(int deploy_port) {
+        this.deploy_port = deploy_port;
+    }
+
+    public String getDeploy_username() {
+        return deploy_username;
+    }
+
+    public void setDeploy_username(String deploy_username) {
+        this.deploy_username = deploy_username;
+    }
+
+    public String getDeploy_password() {
+        return deploy_password;
+    }
+
+    public void setDeploy_password(String deploy_password) {
+        this.deploy_password = deploy_password;
+    }
+
+    @Value("${ftp.apk.host}")
+    private String apk_host;
+    @Value("${ftp.apk.port}")
+    private int apk_port;
+    @Value("${ftp.apk.username}")
+    private String apk_username;
+    @Value("${ftp.apk.password}")
+    private String apk_password;
+
+    public String getApk_host() {
+        return apk_host;
+    }
+
+    public void setApk_host(String apk_host) {
+        this.apk_host = apk_host;
+    }
+
+    public int getApk_port() {
+        return apk_port;
+    }
+
+    public void setApk_port(int apk_port) {
+        this.apk_port = apk_port;
+    }
+
+    public String getApk_username() {
+        return apk_username;
+    }
+
+    public void setApk_username(String apk_username) {
+        this.apk_username = apk_username;
+    }
+
+    public String getApk_password() {
+        return apk_password;
+    }
+
+    public void setApk_password(String apk_password) {
+        this.apk_password = apk_password;
+    }
+}

+ 364 - 0
src/main/java/com/lightinit/hsdataportal/common/FTPTookitUtils.java

@@ -0,0 +1,364 @@
+package com.lightinit.hsdataportal.common;
+import com.lightinit.hsdataportal.json.pojo.FTPConfigurationParameter;
+import org.apache.commons.net.PrintCommandListener;
+import org.apache.commons.net.ftp.*;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.SocketException;
+import java.net.URLEncoder;
+
+/**
+ * Created by Mr.Yao on 2017/5/8.
+ */
+@Component
+public class FTPTookitUtils {
+
+    private FTPClient ftpClient;
+
+    public FTPTookitUtils(){
+        ftpClient=new FTPClient();
+        this.ftpClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
+    }
+
+    private boolean login(String url, int port, String username, String password) throws SocketException, IOException
+    {
+        int reply;
+        ftpClient.connect(url, port);
+        ftpClient.setControlEncoding("UTF-8");
+        FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_NT);
+        conf.setServerLanguageCode("zh");
+        ftpClient.login(username, password);
+        reply = ftpClient.getReplyCode();
+        if (!FTPReply.isPositiveCompletion(reply))
+        {
+            ftpClient.disconnect();
+            return false;
+        }
+        return true;
+    }
+
+    private void free()
+    {
+        if (ftpClient.isAvailable())
+        {
+            try
+            {
+                ftpClient.logout();
+            } catch (IOException e)
+            {
+            }
+        }
+        if (ftpClient.isConnected())
+        {
+            try
+            {
+                ftpClient.disconnect();
+            } catch (IOException e)
+            {
+            }
+        }
+    }
+    public boolean uploadFile(InputStream input, String remoteAdr,FTPConfigurationParameter ftpconfig) throws IOException
+    {
+        boolean success = false;
+        try
+        {
+            success = login(ftpconfig.getHost(), ftpconfig.getPort(), ftpconfig.getUsername(),ftpconfig.getPassword());
+            if (!success)
+            {
+                return success;
+            }
+        } catch (IOException e)
+        {
+            return success;
+        }
+        ftpClient.enterLocalPassiveMode();
+        ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+        String remoteFileName = remoteAdr;
+        if (remoteAdr.contains("/"))
+        {
+            remoteFileName = remoteAdr.substring(remoteAdr.lastIndexOf("/") + 1);
+            String directory = remoteAdr.substring(0, remoteAdr.lastIndexOf("/") + 1);
+            if (!directory.equalsIgnoreCase("/") && !ftpClient.changeWorkingDirectory(directory))
+            {
+                int start = 0, end = 0;
+                if (directory.startsWith("/"))
+                {
+                    start = 1;
+                } else
+                {
+                    start = 0;
+                }
+                end = directory.indexOf("/", start);
+                while (true)
+                {
+                    String subDirectory = remoteAdr.substring(start, end);
+                    if (!ftpClient.changeWorkingDirectory(subDirectory))
+                    {
+                        if (ftpClient.makeDirectory(subDirectory))
+                        {
+                            ftpClient.changeWorkingDirectory(subDirectory);
+                        } else
+                        {
+                            return false;
+                        }
+                    }
+                    start = end + 1;
+                    end = directory.indexOf("/", start);
+                    if (end <= start)
+                    {
+                        break;
+                    }
+                }
+            }
+        }
+        try
+        {
+            success = ftpClient.storeFile(remoteFileName, input);
+            input.close();
+        } catch (IOException e)
+        {
+            if (input != null)
+            {
+                input.close();
+            }
+        } finally
+        {
+            free();
+        }
+        return success;
+    }
+
+    public boolean uploadFile(String localAdr, String remoteAdr,FTPConfigurationParameter ftpconfig) throws IOException
+    {
+        boolean success = false;
+        try
+        {
+            success = login(ftpconfig.getHost(), ftpconfig.getPort(), ftpconfig.getUsername(),ftpconfig.getPassword());
+            if (!success)
+            {
+                return success;
+            }
+        } catch (IOException e)
+        {
+            return success;
+        }
+        ftpClient.enterLocalPassiveMode();
+        ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+        String remoteFileName = remoteAdr;
+        if (remoteAdr.contains("/"))
+        {
+            remoteFileName = remoteAdr.substring(remoteAdr.lastIndexOf("/") + 1);
+            String directory = remoteAdr.substring(0, remoteAdr.lastIndexOf("/") + 1);
+            if (!directory.equalsIgnoreCase("/") && !ftpClient.changeWorkingDirectory(directory))
+            {
+                int start = 0, end = 0;
+                if (directory.startsWith("/"))
+                {
+                    start = 1;
+                } else
+                {
+                    start = 0;
+                }
+                end = directory.indexOf("/", start);
+                while (true)
+                {
+                    String subDirectory = remoteAdr.substring(start, end);
+                    if (!ftpClient.changeWorkingDirectory(subDirectory))
+                    {
+                        if (ftpClient.makeDirectory(subDirectory))
+                        {
+                            ftpClient.changeWorkingDirectory(subDirectory);
+                        } else
+                        {
+                            return false;
+                        }
+                    }
+                    start = end + 1;
+                    end = directory.indexOf("/", start);
+                    if (end <= start)
+                    {
+                        break;
+                    }
+                }
+            }
+        }
+        InputStream input = null;
+        try
+        {
+            File f = new File(localAdr);
+            //FTPFile[] fs = ftpClient.listFiles(remoteFileName);
+            input = new FileInputStream(f);
+            success = ftpClient.storeFile(remoteFileName, input);
+            input.close();
+        } catch (IOException e)
+        {
+            if (input != null)
+            {
+                input.close();
+            }
+        } finally
+        {
+            free();
+        }
+        return success;
+    }
+
+    public boolean deleteFile(String remoteAdr, String localAdr,FTPConfigurationParameter ftpconfig)
+    {
+        boolean success = false;
+        try
+        {
+            success = login(ftpconfig.getHost(), ftpconfig.getPort(), ftpconfig.getUsername(),ftpconfig.getPassword());
+            if (!success)
+            {
+                return success;
+            }
+            ftpClient.changeWorkingDirectory(remoteAdr);
+            FTPFile[] fs = ftpClient.listFiles();
+            if(fs.length>0)
+            {
+                success = ftpClient.removeDirectory(remoteAdr);
+                ftpClient.logout();
+            }
+        } catch (IOException e)
+        {
+        } finally
+        {
+            free();
+        }
+        return success;
+    }
+
+    public boolean deleteDir(String remoteAdr,FTPConfigurationParameter ftpconfig)
+    {
+        boolean success = false;
+        try
+        {
+            success = login(ftpconfig.getHost(), ftpconfig.getPort(), ftpconfig.getUsername(),ftpconfig.getPassword());
+            if (!success)
+            {
+                return success;
+            }
+            ftpClient.changeWorkingDirectory(remoteAdr);
+            FTPFile[] fs = ftpClient.listFiles();
+            if(fs.length>0)
+            {
+                success = ftpClient.removeDirectory(remoteAdr);
+                ftpClient.logout();
+            }
+        } catch (IOException e)
+        {
+        } finally
+        {
+            free();
+        }
+        return success;
+    }
+
+    public boolean downFile(String remoteremoteAdr, String localAdr, HttpServletResponse response,FTPConfigurationParameter ftpconfig)
+    {
+        boolean success = false;
+        try
+        {
+            success = login(ftpconfig.getHost(), ftpconfig.getPort(), ftpconfig.getUsername(),ftpconfig.getPassword());
+            if (!success)
+            {
+                return success;
+            }
+            ftpClient.changeWorkingDirectory(remoteremoteAdr);
+            FTPFile[] fs = ftpClient.listFiles();
+
+            for (FTPFile ftpFile : fs)
+            {
+                if (ftpFile.getName().equals(localAdr))
+                {
+                    response.setHeader("Content-disposition", "attachment;localAdr=" + URLEncoder.encode(localAdr, "UTF-8"));
+                    File f=new File(localAdr);
+                    OutputStream os=new FileOutputStream(f);
+                    ftpClient.retrieveFile(new String(ftpFile.getName().getBytes("UTF-8"), "ISO-8859-1"), os);
+                    os.flush();
+                    os.close();
+                }
+            }
+            ftpClient.logout();
+            success = true;
+        } catch (IOException e)
+        {
+            e.printStackTrace();
+        } finally
+        {
+            free();
+        }
+        return success;
+    }
+
+    public String readFileContent(String remoteremoteAdr, String localAdr,FTPConfigurationParameter ftpconfig)
+    {
+        String content = null;
+        try
+        {
+            boolean success = login(ftpconfig.getHost(), ftpconfig.getPort(), ftpconfig.getUsername(),ftpconfig.getPassword());
+            if (success)
+            {
+                ftpClient.changeWorkingDirectory(remoteremoteAdr);
+                FTPFile[] fs = ftpClient.listFiles();
+                for (FTPFile ftpFile : fs)
+                {
+                    if (ftpFile.getName().equals(localAdr))
+                    {
+                        File f=new File(localAdr);
+                        ftpClient.retrieveFile(new String(ftpFile.getName().getBytes("UTF-8"), "ISO-8859-1"), new FileOutputStream(f));
+                        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                        ftpClient.retrieveFile(ftpFile.getName(), bos);
+                        bos.flush();
+                        bos.close();
+                        content = new String(bos.toByteArray(), "UTF-8");
+                    }
+                }
+            }
+        } catch (IOException e)
+        {
+        } finally
+        {
+            free();
+        }
+        return content;
+    }
+
+    public static boolean isDirExist(String localAdr, FTPFile[] fs)
+    {
+        for (FTPFile ftpFile : fs)
+        {
+            if (ftpFile.getName().equals(localAdr))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static String changeName(String localAdr, FTPFile[] fs)
+    {
+        int n = 0;
+        StringBuffer localAdr_ = new StringBuffer("");
+        localAdr_ = localAdr_.append(localAdr);
+        while (isDirExist(localAdr_.toString(), fs))
+        {
+            n++;
+            String a = "[" + n + "]";
+            int b = localAdr_.lastIndexOf(".");
+            int c = localAdr_.lastIndexOf("[");
+            if (c < 0)
+            {
+                c = b;
+            }
+            StringBuffer name = new StringBuffer(localAdr_.substring(0, c));
+            StringBuffer suffix = new StringBuffer(localAdr_.substring(b + 1));
+            localAdr_ = name.append(a).append(".").append(suffix);
+        }
+        return localAdr_.toString();
+    }
+}

+ 59 - 0
src/main/java/com/lightinit/hsdataportal/common/GateWayUtils.java

@@ -0,0 +1,59 @@
+package com.lightinit.hsdataportal.common;
+
+import com.lightinit.hsdataportal.dictionary.DicNewGateway;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class GateWayUtils {
+
+    public static String gatewayAuthAdd(String ouyId1, String applicationid, String userId, String remark) {
+        String code = null ;
+        Map<String, String> params = new HashMap<>();
+        params.put("routeId", ouyId1);
+        params.put("appId", applicationid);
+        params.put("userId", userId);
+        params.put("remark", remark);
+        try {
+            String str = HttpUtil.httpPost(DicNewGateway.AUTHADD, null, params);
+            Map<String, Object> map1 = HttpUtil.strToMap(str);
+            if (map1.get("code").equals("200")) {
+                code = map1.get("code").toString() ;
+            }else {
+                throw new RuntimeException("新增api鉴权异常:"+map1.get("message"));
+            }
+            System.out.println("=================" + map1 + "==========================");
+        } catch (Exception e) {
+            throw new RuntimeException("新增api鉴权异常!");
+        }
+        return code ;
+    }
+
+    public static String gatewayChargeAdd(String ouyId1, String applicationid, String userId,String chargeType
+            ,String chargeValue, String remark) {
+        String code = null ;
+        Map<String, String> params = new HashMap<>();
+        params.put("routeId", ouyId1);
+        params.put("applicationId", applicationid);
+        params.put("userId", userId);
+        params.put("chargeType", chargeType);
+        params.put("chargeValue", chargeValue);
+        params.put("effectiveTime", new Date().toString());
+        params.put("remark", remark);
+        try {
+            String str = HttpUtil.httpPost(DicNewGateway.CHANGEADD, null, params);
+            Map<String, Object> map1 = HttpUtil.strToMap(str);
+            if (map1.get("code").equals("200")) {
+                code = map1.get("code").toString() ;
+            } else {
+                throw new RuntimeException("新增api鉴权异常:"+map1.get("message"));
+            }
+            System.out.println("=================" + map1 + "==========================");
+        } catch (Exception e) {
+            throw new RuntimeException("新增api计费异常!");
+        }
+        return code ;
+    }
+
+}

+ 13 - 0
src/main/java/com/lightinit/hsdataportal/common/GuidGenerator.java

@@ -0,0 +1,13 @@
+package com.lightinit.hsdataportal.common;
+
+import java.util.UUID;
+
+/**
+ * @author WangYao
+ */
+public abstract class GuidGenerator {
+
+    public static String generate() {
+        return UUID.randomUUID().toString()/*.replaceAll("-", "")*/;
+    }
+}

+ 297 - 0
src/main/java/com/lightinit/hsdataportal/common/HttpTookitUtils.java

@@ -0,0 +1,297 @@
+package com.lightinit.hsdataportal.common;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.ParseException;
+import org.apache.http.StatusLine;
+import org.apache.http.client.ClientProtocolException;
+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.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+//import org.apache.xmlbeans.impl.common.NameUtil;
+import org.springframework.util.StringUtils;
+
+/**
+ * Created by Mr.Yao on 2017/5/4.
+ */
+public class HttpTookitUtils {
+    public static int getApplicationStatus(String url) {
+        int statusCode=-1;
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        try {
+            HttpGet httpget = new HttpGet(url);
+            CloseableHttpResponse response = httpclient.execute(httpget);
+            try {
+                StatusLine statusLine = response.getStatusLine();
+                statusCode= statusLine.getStatusCode();
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (ParseException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return statusCode;
+    }
+    public static String doGet(String url, List<NameValuePair> params, CharEncoding charset,String accept) {
+        String responseContent="";
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        try {
+            String queryParams="";
+            if(params!= null) {
+                for (NameValuePair pair : params) {
+                    if (queryParams.length() > 0) {
+                        queryParams += "&";
+                    }
+                    queryParams += pair.getName() + "=" + pair.getValue();
+                }
+            }
+            if(StringUtils.isEmpty(queryParams)==false){
+                if(url.contains("?")){
+                    url+="&";
+                }else{
+                    url+="?";
+                }
+                url+=queryParams;
+            }
+            HttpGet httpget = new HttpGet(url);
+            if(StringUtils.isEmpty(accept)==false)
+                httpget.addHeader("Accept",accept);
+            CloseableHttpResponse response = httpclient.execute(httpget);
+            try {
+                HttpEntity entity = response.getEntity();
+                if (entity != null) {
+                    responseContent= EntityUtils.toString(entity, charset.value());
+                }
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (ParseException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return responseContent;
+    }
+    public static String doGet(String url, CharEncoding charset,String appId,String userId,String version,String timestamp,String summary) {
+        String responseContent="";
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        try {
+            HttpGet httpget = new HttpGet(url);
+            if(StringUtils.isEmpty(appId)==false) {
+                httpget.addHeader("appId",appId);
+            }
+            if(StringUtils.isEmpty(userId)==false) {
+                httpget.addHeader("userId",userId);
+            }
+            if(StringUtils.isEmpty(version)==false) {
+                httpget.addHeader("version",version);
+            }
+            if(StringUtils.isEmpty(timestamp)==false) {
+                httpget.addHeader("timestamp",timestamp);
+            }
+            if(StringUtils.isEmpty(summary)==false) {
+                httpget.addHeader("summary",summary);
+            }
+            CloseableHttpResponse response = httpclient.execute(httpget);
+            try {
+                HttpEntity entity = response.getEntity();
+                if (entity != null) {
+                    responseContent= EntityUtils.toString(entity, charset.value());
+                }
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (ParseException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return responseContent;
+    }
+    public static String doGet(String url, List<NameValuePair> params, CharEncoding charset) {
+        return doGet(url,params,charset,"");
+    }
+    public static String doPost(String url, List<NameValuePair> params, CharEncoding charset){
+        return doPost(url,params,charset,"");
+    }
+    public static String doPost(String url, List<NameValuePair> params, CharEncoding charset,String accept) {
+        String responseContent="";
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPost httppost = new HttpPost(url);
+        if(StringUtils.isEmpty(accept)==false)
+            httppost.addHeader("Accept",accept);
+        UrlEncodedFormEntity uefEntity;
+        try {
+            uefEntity = new UrlEncodedFormEntity(params, charset.value());
+            httppost.setEntity(uefEntity);
+            CloseableHttpResponse response = httpclient.execute(httppost);
+            try {
+                HttpEntity entity = response.getEntity();
+                if (entity != null) {
+                    responseContent=EntityUtils.toString(entity, charset.value());
+                }
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (UnsupportedEncodingException e1) {
+            e1.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return responseContent;
+    }
+
+    public static String doPost(String url, List<NameValuePair> params, CharEncoding charset, Map<String,String> headers) {
+        String responseContent="";
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPost httppost = new HttpPost(url);
+        if(headers!=null) {
+            for (Map.Entry<String, String> entry : headers.entrySet()) {
+                httppost.addHeader(entry.getKey(), entry.getValue());
+            }
+        }
+        UrlEncodedFormEntity uefEntity;
+        try {
+            uefEntity = new UrlEncodedFormEntity(params, charset.value());
+            httppost.setEntity(uefEntity);
+            CloseableHttpResponse response = httpclient.execute(httppost);
+            try {
+                HttpEntity entity = response.getEntity();
+                if (entity != null) {
+                    responseContent=EntityUtils.toString(entity, charset.value());
+                }
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (UnsupportedEncodingException e1) {
+            e1.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return responseContent;
+    }
+
+    public static String doPost(String url, String body, CharEncoding charset) {
+        String responseContent="";
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPost httppost = new HttpPost(url);
+        try {
+            StringEntity uefEntity=new StringEntity(body, charset.value());
+            httppost.setEntity(uefEntity);
+            httppost.addHeader("Content-type","application/json");
+            CloseableHttpResponse response = httpclient.execute(httppost);
+            try {
+                HttpEntity entity = response.getEntity();
+                if (entity != null) {
+                    responseContent=EntityUtils.toString(entity, charset.value());
+                }
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (UnsupportedEncodingException e1) {
+            e1.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return responseContent;
+    }
+
+    public static String doPost(String url, String body, CharEncoding charset,Map<String,String> headers) {
+        String responseContent="";
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPost httppost = new HttpPost(url);
+        try {
+            StringEntity uefEntity=new StringEntity(body, charset.value());
+            httppost.setEntity(uefEntity);
+            if(headers!=null) {
+                for (Map.Entry<String, String> entry : headers.entrySet()) {
+                    httppost.addHeader(entry.getKey(), entry.getValue());
+                }
+            }else {
+                httppost.addHeader("Content-type", "application/json");
+            }
+            CloseableHttpResponse response = httpclient.execute(httppost);
+            try {
+                HttpEntity entity = response.getEntity();
+                if (entity != null) {
+                    responseContent=EntityUtils.toString(entity, charset.value());
+                }
+            } finally {
+                response.close();
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (UnsupportedEncodingException e1) {
+            e1.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return responseContent;
+    }
+}

+ 311 - 0
src/main/java/com/lightinit/hsdataportal/common/HttpUtil.java

@@ -0,0 +1,311 @@
+package com.lightinit.hsdataportal.common;
+
+
+import com.google.gson.Gson;
+import com.lightinit.hsdataportal.common.ssl.MySecureProtocolSocketFactory;
+import com.lightinit.hsdataportal.dictionary.DicGitToken;
+import com.lightinit.hsdataportal.model.ShareRegisterModel;
+import net.sf.json.JSONObject;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContexts;
+import org.apache.http.ssl.TrustStrategy;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+import java.net.URI;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+
+public class HttpUtil {
+
+    private static Logger logger = LoggerFactory.getLogger(HttpUtil.class);
+
+    /**
+     * @describe:   服务于6.0接口
+     * @param url  访问地址
+     * @param head 请求头
+     * @param req  请求体内容
+     **/
+    public static String httpPost(String url, Map<String,String> head,Map<String,?> req) throws Exception{
+        //声明
+        ProtocolSocketFactory fcty = new MySecureProtocolSocketFactory();
+        //加入相关的https请求方式
+        Protocol.registerProtocol("https", new Protocol("https", fcty, 443));
+        //发送请求即可
+        HttpClient client = new HttpClient();
+        Gson gson = new Gson();
+        PostMethod post = new PostMethod(url);
+        String str = gson.toJson(req);
+        gson.fromJson(str,Map.class) ;
+        RequestEntity re = new StringRequestEntity(str,"application/json","utf-8");
+        if(head!=null){
+            Set<Map.Entry<String,String>> headSet = head.entrySet();
+            for (Map.Entry<String, String> entry : headSet) {
+                post.setRequestHeader(entry.getKey(),entry.getValue());
+            }
+        }
+        post.setRequestEntity(re);
+        int status = client.executeMethod(post);
+
+        System.out.println("=================status:"+status);
+        if(status!=200){
+            //抛出异常
+            byte[] bytes = post.getResponseBody();
+            String content = new String(bytes,"UTF-8");
+            System.out.println(content);
+        }
+        String content = post.getResponseBodyAsString();
+        System.out.println("Access System authenticate, Response: " + content);
+
+        return content;
+    }
+
+    public static String httpPost(String url, Map<String,String> head,String req){
+        try {
+            //声明
+            ProtocolSocketFactory fcty = new MySecureProtocolSocketFactory();
+            //加入相关的https请求方式
+            Protocol.registerProtocol("https", new Protocol("https", fcty, 443));
+            //发送请求即可
+            HttpClient client = new HttpClient();
+            Gson gson = new Gson();
+            PostMethod post = new PostMethod(url);
+       /* String str = gson.toJson(req);
+        gson.fromJson(str,Map.class) ;*/
+            RequestEntity re = new StringRequestEntity(req,"application/json","utf-8");
+            if(head!=null){
+                Set<Map.Entry<String,String>> headSet = head.entrySet();
+                for (Map.Entry<String, String> entry : headSet) {
+                    post.setRequestHeader(entry.getKey(),entry.getValue());
+                }
+            }
+            post.setRequestEntity(re);
+            int status = client.executeMethod(post);
+
+            System.out.println("=================status:"+status);
+            if(status!=200){
+                //抛出异常
+                byte[] bytes = post.getResponseBody();
+                String content = new String(bytes,"UTF-8");
+                System.out.println(content);
+            }
+            String content = post.getResponseBodyAsString();
+            System.out.println("Access System authenticate, Response: " + content);
+
+            return content;
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+    /**
+     * @describe:  服务于5.0接口
+     * @param url  请求路径
+     * @param head  请求头
+     * @param req  请求体内容
+     **/
+    public static String  httpPost2(String url, Map<String,String> head,Map<String,?> req) throws Exception{
+        //声明
+        ProtocolSocketFactory fcty = new MySecureProtocolSocketFactory();
+        //加入相关的https请求方式
+        Protocol.registerProtocol("https", new Protocol("https", fcty, 443));
+        //发送请求即可
+        HttpClient client = new HttpClient();
+        Map<String,Object> strMap = new HashMap();
+        Gson gson = new Gson();
+        PostMethod post = new PostMethod(url);
+        strMap.put("head",head);
+        strMap.put("body",req);
+        String str = gson.toJson(strMap);
+        RequestEntity re = new StringRequestEntity(str,"application/json","utf-8");
+        post.setRequestEntity(re);
+        int status = client.executeMethod(post);
+        System.out.println("Access System authenticate, Status: " + post.getStatusCode());
+        System.out.println("Access System authenticate, Response: " + post.getResponseBodyAsString());
+        String content = post.getResponseBodyAsString();
+        return content;
+    }
+
+
+    public static String httpGet(String url,String accessticket,Map<String,?> param) throws Exception {
+
+        //CloseableHttpClient httpclient = HttpClients.createDefault();
+        CloseableHttpClient httpclient = getIgnoeSSLClient();
+        String resultString = "";
+        CloseableHttpResponse response = null;
+        try {
+            // 创建uri
+            URIBuilder builder = new URIBuilder(url);
+
+            if (param != null) {
+                for (String key : param.keySet()) {
+                    builder.addParameter(key, (String)param.get(key));
+                }
+            }
+            URI uri = builder.build();
+
+            // 创建http GET请求
+            HttpGet httpGet = new HttpGet(uri);
+            if (accessticket!=null)  httpGet.addHeader("accessticket",accessticket);
+            // 执行请求
+            response = httpclient.execute(httpGet);
+            // 判断返回状态是否为200
+            logger.info("访问的路径为:"+url+"状态为:"+response.getStatusLine().getStatusCode());
+            if (response.getStatusLine().getStatusCode() == 200) {
+                byte[] bytes= EntityUtils.toByteArray(response.getEntity());
+                resultString = new String(bytes);
+                //resultString = EntityUtils.toString(response.getEntity(), "ISO-8859-1");
+                //resultString= Base64.encodeBase64String(bytes);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+        logger.info("查询的结果:"+resultString);
+        return resultString;
+    }
+
+    public static String httpGet(String url,Map<String,Object> params) throws Exception {
+        return httpGet(url,null,params);
+    }
+
+    public static String httpGet(String url,String accessticket) throws Exception {
+        return httpGet(url,accessticket,null);
+    }
+
+
+    public static Map<String,Object> strToMap(String message){
+        Gson gson = new Gson();
+        Map<String,Object> map = new HashMap<String, Object>();
+        map = gson.fromJson(message,map.getClass());
+        return map;
+    }
+
+    public static Map<String,String>  getHead(String appid,String appkey){
+        Map<String,String> head = new HashMap<String,String>();
+        head.put("appid",appid);
+        head.put("appkey",appkey);
+        return head;
+    }
+
+    public static String getToken(String url, Map<String,String> head,String contentType) throws Exception{
+        //声明
+        ProtocolSocketFactory fcty = new MySecureProtocolSocketFactory();
+        //加入相关的https请求方式
+        Protocol.registerProtocol("https", new Protocol("https", fcty, 443));
+        //发送请求即可
+        HttpClient client = new HttpClient();
+//        HttpClient client = new HttpClient();
+        PostMethod post = new PostMethod(url);
+        String str = DicGitToken.PARAMS;
+        RequestEntity re = new StringRequestEntity(str,contentType,"utf-8");
+        if(head!=null){
+            Set<Map.Entry<String,String>> headSet = head.entrySet();
+            for (Map.Entry<String, String> entry : headSet) {
+                post.setRequestHeader(entry.getKey(),entry.getValue());
+            }
+        }
+        post.setRequestEntity(re);
+        int status = client.executeMethod(post);
+
+        System.out.println("=================status:"+status);
+        if(status!=200){
+            //抛出异常
+            byte[] bytes = post.getResponseBody();
+            String content = new String(bytes,"UTF-8");
+            System.out.println(content);
+        }
+        String content = post.getResponseBodyAsString();
+        System.out.println("Access System authenticate, Response: " + content);
+
+        return content;
+    }
+
+    /**
+     * 绕过验证
+     *
+     * @return
+     * @throws NoSuchAlgorithmException
+     * @throws KeyManagementException
+     */
+    public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
+        SSLContext sc = SSLContext.getInstance("SSLv3");
+
+        // 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
+        X509TrustManager trustManager = new X509TrustManager() {
+            @Override
+            public void checkClientTrusted(
+                    X509Certificate[] paramArrayOfX509Certificate,
+                    String paramString) throws CertificateException {
+            }
+
+            @Override
+            public void checkServerTrusted(
+                    X509Certificate[] paramArrayOfX509Certificate,
+                    String paramString) throws CertificateException {
+            }
+
+            @Override
+            public X509Certificate[] getAcceptedIssuers() {
+                return null;
+            }
+        };
+
+        sc.init(null, new TrustManager[] { trustManager }, null);
+        return sc;
+    }
+
+    /**
+     * 获取忽略证书验证的client
+     *
+     * @return
+     * @throws Exception
+     */
+
+    public static CloseableHttpClient getIgnoeSSLClient() throws Exception {
+        SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() {
+            @Override
+            public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+                return true;
+            }
+        }).build();
+
+        //创建httpClient
+        CloseableHttpClient client = HttpClients.custom().setSSLContext(sslContext).
+                setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
+        return client;
+    }
+
+
+}

+ 148 - 0
src/main/java/com/lightinit/hsdataportal/common/IPUtils.java

@@ -0,0 +1,148 @@
+package com.lightinit.hsdataportal.common;
+
+import com.lightinit.hsdataportal.json.pojo.PingResultEntity;
+import org.springframework.util.StringUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Created by Mr.Yao on 2017/5/22.
+ */
+public class IPUtils {
+    static List<String> regList=new ArrayList<String>();
+    static {
+        regList.add(":1");
+        regList.add("^10\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$");
+        regList.add("^172\\.((1[6-9]{1})|(2[0-9]{1})|(3[0-1]{1}))\\.[0-9]{1,3}\\.[0-9]{1,3}$");
+        regList.add("^192\\.168\\.[0-9]{1,3}\\.[0-9]{1,3}$");
+    }
+    public static String getIpAddress(HttpServletRequest request){
+        String ip=request.getHeader("HTTP_X_FORWARDED_FOR");
+        if (StringUtils.isEmpty(ip)==false) {
+            String []ipArray=ip.split(",");
+            for (String _ip:ipArray) {
+                if(IsPrivateIpAddress(_ip))
+                    continue;
+                ip=_ip;
+                break;
+            }
+        }
+        if (StringUtils.isEmpty(ip)){
+            ip = request.getRemoteAddr();
+        }
+        return ip;
+    }
+
+    public static boolean IsPrivateIpAddress(String ip){
+        boolean isPrivateIp=false;
+        for (String regIp:regList) {
+            Pattern pattern=Pattern.compile(regIp);
+            Matcher matcher=pattern.matcher(ip);
+           if(matcher.matches())
+           {
+               isPrivateIp=true;
+               break;
+           }
+        }
+        return isPrivateIp;
+    }
+
+    public static PingResultEntity Ping(String domain,int pingTimes,String ping){
+        PingResultEntity entity=new PingResultEntity();
+        BufferedReader in = null;
+        Runtime r = Runtime.getRuntime();
+        // 将要执行的ping命令,此命令是windows格式的命令
+        //String pingCommand = "ping " + domain + " -n " + pingTimes;
+        String pingCommand=String.format(ping,domain,pingTimes);
+        try {
+            // 执行命令并获取输出
+            System.out.println(pingCommand);
+            Process p = r.exec(pingCommand);
+            if (p == null) {
+                entity.setReachable(false);
+            }
+            in = new BufferedReader(new InputStreamReader(p.getInputStream()));
+            // 逐行检查输出,计算类似出现=23ms TTL=62字样的次数
+            int connectedCount = 0;
+            String line = null;
+            while ((line = in.readLine()) != null) {
+                if(StringUtils.isEmpty(entity.getIpAddress())) {
+                    String ipLine = getIpAddress(line);
+                    if (StringUtils.isEmpty(ipLine) == false)
+                        entity.setIpAddress(ipLine);
+                }
+                connectedCount += getCheckWindowsResult(line)+getCheckLinuxResult(line);
+            }
+            // 如果出现类似=23ms TTL=62这样的字样,出现的次数=测试次数则返回真
+            entity.setReachable(connectedCount>0);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            // 出现异常则返回假
+            entity.setReachable(false);
+        } finally {
+            try {
+                in.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return entity;
+    }
+
+    //若line含有=18ms TTL=16字样,说明已经ping通,返回1,否則返回0.
+    private static int getCheckWindowsResult(String line) {
+        // System.out.println("控制台输出的结果为:"+line);
+        Pattern pattern = Pattern.compile("(\\d+ms)(\\s+)(TTL=\\d+)",Pattern.CASE_INSENSITIVE);
+        Matcher matcher = pattern.matcher(line);
+        while (matcher.find()) {
+            return 1;
+        }
+        return 0;
+    }
+    //若line含有=18ms TTL=16字样,说明已经ping通,返回1,否則返回0.
+    private static int getCheckLinuxResult(String line) {
+        // 64 bytes from 150.138.158.3: icmp_seq=1 ttl=43 time=61.8 ms
+        Pattern pattern = Pattern.compile("(icmp_seq=\\d+\\s+ttl=\\d+\\s+time=[0-9]{1,}([.][0-9]*)*\\s*ms)",Pattern.CASE_INSENSITIVE);
+        Matcher matcher = pattern.matcher(line);
+        while (matcher.find()) {
+            return 1;
+        }
+        return 0;
+    }
+    public static String getIpAddress(String line) {
+        // System.out.println("控制台输出的结果为:"+line);
+        Pattern pattern = Pattern.compile("(([1-9]{1})([0-9]{0,2})\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})",Pattern.CASE_INSENSITIVE);
+        Matcher matcher = pattern.matcher(line);
+        while (matcher.find()) {
+            return matcher.group();
+        }
+        return "";
+    }
+    public static String getDomain(String line) {
+        // System.out.println("控制台输出的结果为:"+line);
+        Pattern pattern = Pattern.compile("(([a-zA-Z0-9][a-zA-Z0-9-_]+\\.)+[a-zA-Z0-9-_][^ ]*)",Pattern.CASE_INSENSITIVE);
+        Matcher matcher = pattern.matcher(line);
+        while (matcher.find()) {
+            return matcher.group();
+        }
+        return "";
+    }
+
+    public static boolean checkIpAddress(String targetIp,String rightIp) {
+        if(StringUtils.isEmpty(targetIp) || StringUtils.isEmpty(rightIp))
+            return false;
+        String []rightIps=rightIp.split(";");
+        for (String ip:rightIps) {
+            if(targetIp.trim().equalsIgnoreCase(ip.trim()))
+                return true;
+        }
+        return false;
+    }
+}

+ 53 - 0
src/main/java/com/lightinit/hsdataportal/common/MD5Utils.java

@@ -0,0 +1,53 @@
+package com.lightinit.hsdataportal.common;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.UUID;
+
+/**
+ * Created by Mr.Yao on 2017/4/7.
+ */
+public class MD5Utils {public static String MD5(String sourceStr) {
+    String result = "";
+    try {
+        MessageDigest md = MessageDigest.getInstance("MD5");
+        md.update(sourceStr.getBytes());
+        byte b[] = md.digest();
+        int i;
+        StringBuffer buf = new StringBuffer("");
+        for (int offset = 0; offset < b.length; offset++) {
+            i = b[offset];
+            if (i < 0)
+                i += 256;
+            if (i < 16)
+                buf.append("0");
+            buf.append(Integer.toHexString(i));
+        }
+        result = buf.toString();
+    } catch (NoSuchAlgorithmException e) {
+    }
+    return result;
+}
+
+    private static String[] chars = new String[] { "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", "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" };
+
+    public static String generateShortUuid() {
+        StringBuffer shortBuffer = new StringBuffer();
+        String uuid = UUID.randomUUID().toString().replace("-", "");
+        for (int i = 0; i < 8; i++) {
+            String str = uuid.substring(i * 4, i * 4 + 4);
+            int x = Integer.parseInt(str, 16);
+            shortBuffer.append(chars[x % 0x3E]);
+        }
+        return shortBuffer.toString();
+    }
+
+    public static String generateGuid(){
+        return UUID.randomUUID().toString();
+    }
+}

ファイルの差分が大きいため隠しています
+ 162 - 0
src/main/java/com/lightinit/hsdataportal/common/MenuUtils.java


+ 43 - 0
src/main/java/com/lightinit/hsdataportal/common/ObjectConvertorUtils.java

@@ -0,0 +1,43 @@
+package com.lightinit.hsdataportal.common;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by Mr.Yao on 2017/5/9.
+ */
+public class ObjectConvertorUtils<T> {
+
+    public T DictToObject(Map<String, String> map,Class<T> classType)
+    {
+        T entity= null;
+        try {
+            entity = classType.newInstance();
+            Field[] fields = classType.getDeclaredFields();
+            if(fields!=null) {
+                for (Field field : fields) {
+                    if (map.containsKey(field.getName()))
+                        field.setAccessible(true);
+                        field.set(entity, map.get(field.getName()));
+                }
+            }
+        } catch (InstantiationException e) {
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        }
+        return entity;
+    }
+
+    public List<T> ListToObject(List<Map<String, String>> list, Class<T> classType) {
+        List<T> resultList = new ArrayList<T>();
+        for (Map<String, String> map : list) {
+            T item = DictToObject(map, classType);
+            if (item != null)
+                resultList.add(item);
+        }
+        return resultList;
+    }
+}

+ 17 - 0
src/main/java/com/lightinit/hsdataportal/common/ObjectMappingUtils.java

@@ -0,0 +1,17 @@
+package com.lightinit.hsdataportal.common;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+
+/**
+ * Created by WangYao on 2018/5/23.
+ */
+public class ObjectMappingUtils {
+
+    public static <S, T> T map(S source, Class<T> classType) throws IOException {
+        ObjectMapper objectMapper = new ObjectMapper();
+        String jsonString = objectMapper.writeValueAsString(source);
+        return objectMapper.readValue(jsonString, classType);
+    }
+}

+ 181 - 0
src/main/java/com/lightinit/hsdataportal/common/OneTimePasswordAlgorithm.java

@@ -0,0 +1,181 @@
+/*
+ * OneTimePasswordAlgorithm.java
+ * OATH Initiative,
+ * HOTP one-time password algorithm
+ *
+ */
+/* Copyright (C) 2004, OATH. All rights reserved.
+ *
+ * License to copy and use this software is granted provided that it
+ * is identified as the "OATH HOTP Algorithm" in all material
+ * mentioning or referencing this software or this function.
+ *
+ * License is also granted to make and use derivative works provided
+ * that such works are identified as
+ * "derived from OATH HOTP algorithm"
+ * in all material mentioning or referencing the derived work.
+ *
+ * OATH (Open AuTHentication) and its members make no
+ * representations concerning either the merchantability of this
+ * software or the suitability of this software for any particular
+ * purpose.
+ *
+ * It is provided "as is" without express or implied warranty
+ * of any kind and OATH AND ITS MEMBERS EXPRESSaLY DISCLAIMS
+ * ANY WARRANTY OR LIABILITY OF ANY KIND relating to this software.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software.
+ */
+package com.lightinit.hsdataportal.common;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * This class contains static methods that are used to calculate the One-Time
+ * Password (OTP) using JCE to provide the HMAC-SHA-1.
+ * 
+ * @author Loren Hart
+ * @version 1.0
+ */
+public class OneTimePasswordAlgorithm {
+	private OneTimePasswordAlgorithm() {
+	}
+
+	// These are used to calculate the check-sum digits.
+	// 0 1 2 3 4 5 6 7 8 9
+	private static final int[] doubleDigits = { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 };
+
+	/**
+	 * Calculates the checksum using the credit card algorithm. This algorithm
+	 * has the advantage that it detects any single mistyped digit and any
+	 * single transposition of adjacent digits.
+	 * 
+	 * @param num
+	 *            the number to calculate the checksum for
+	 * @param digits
+	 *            number of significant places in the number
+	 * 
+	 * @return the checksum of num
+	 */
+	public static int calcChecksum(long num, int digits) {
+		boolean doubleDigit = true;
+		int total = 0;
+		while (0 < digits--) {
+			int digit = (int) (num % 10);
+			num /= 10;
+			if (doubleDigit) {
+				digit = doubleDigits[digit];
+			}
+			total += digit;
+			doubleDigit = !doubleDigit;
+		}
+		int result = total % 10;
+		if (result > 0) {
+			result = 10 - result;
+		}
+		return result;
+	}
+
+	/**
+	 * This method uses the JCE to provide the HMAC-SHA-1 algorithm. HMAC
+	 * computes a Hashed Message Authentication Code and in this case SHA1 is
+	 * the hash algorithm used.
+	 * 
+	 * @param keyBytes
+	 *            the bytes to use for the HMAC-SHA-1 key
+	 * @param text
+	 *            the message or text to be authenticated.
+	 * 
+	 * @throws NoSuchAlgorithmException
+	 *             if no provider makes either HmacSHA1 or HMAC-SHA-1 digest
+	 *             algorithms available.
+	 * @throws InvalidKeyException
+	 *             The secret provided was not a valid HMAC-SHA-1 key.
+	 * 
+	 */
+	public static byte[] hmac_sha1(byte[] keyBytes, byte[] text)
+			throws NoSuchAlgorithmException, InvalidKeyException {
+		// try {
+		Mac hmacSha1;
+		try {
+			hmacSha1 = Mac.getInstance("HmacSHA1");
+		} catch (NoSuchAlgorithmException nsae) {
+			hmacSha1 = Mac.getInstance("HMAC-SHA-1");
+		}
+		SecretKeySpec macKey = new SecretKeySpec(keyBytes, "RAW");
+		hmacSha1.init(macKey);
+		return hmacSha1.doFinal(text);
+		// } catch (GeneralSecurityException gse) {
+		// throw new UndeclaredThrowableException(gse);
+		// }
+	}
+
+	private static final int[] DIGITS_POWER
+	// 0 1 2 3 4 5 6 7 8
+	= { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 };
+
+	/**
+	 * This method generates an OTP value for the given set of parameters.
+	 * 
+	 * @param secret
+	 *            the shared secret
+	 * @param movingFactor
+	 *            the counter, time, or other value that changes on a per use
+	 *            basis.
+	 * @param codeDigits
+	 *            the number of digits in the OTP, not including the checksum,
+	 *            if any.
+	 * @param addChecksum
+	 *            a flag that indicates if a checksum digit should be appended
+	 *            to the OTP.
+	 * @param truncationOffset
+	 *            the offset into the MAC result to begin truncation. If this
+	 *            value is out of the range of 0 ... 15, then dynamic truncation
+	 *            will be used. Dynamic truncation is when the last 4 bits of
+	 *            the last byte of the MAC are used to determine the start
+	 *            offset.
+	 * @throws NoSuchAlgorithmException
+	 *             if no provider makes either HmacSHA1 or HMAC-SHA-1 digest
+	 *             algorithms available.
+	 * @throws InvalidKeyException
+	 *             The secret provided was not a valid HMAC-SHA-1 key.
+	 * 
+	 * @return A numeric String in base 10 that includes {@link codeDigits}
+	 *         digits plus the optional checksum digit if requested.
+	 */
+	static public String generateOTP(byte[] secret, long movingFactor,
+			int codeDigits, boolean addChecksum, int truncationOffset)
+			throws NoSuchAlgorithmException, InvalidKeyException {
+		// put movingFactor value into text byte array
+		String result = null;
+		int digits = addChecksum ? (codeDigits + 1) : codeDigits;
+		byte[] text = new byte[8];
+		for (int i = text.length - 1; i >= 0; i--) {
+			text[i] = (byte) (movingFactor & 0xff);
+			movingFactor >>= 8;
+		}
+		// compute hmac hash
+		byte[] hash = hmac_sha1(secret, text);
+		// put selected bytes into result int
+		int offset = hash[hash.length - 1] & 0xf;
+		if ((0 <= truncationOffset) && (truncationOffset < (hash.length - 4))) {
+			offset = truncationOffset;
+		}
+		int binary = ((hash[offset] & 0x7f) << 24)
+				| ((hash[offset + 1] & 0xff) << 16)
+				| ((hash[offset + 2] & 0xff) << 8) | (hash[offset + 3] & 0xff);
+		int otp = binary % DIGITS_POWER[codeDigits];
+		if (addChecksum) {
+			otp = (otp * 10) + calcChecksum(otp, codeDigits);
+		}
+		result = Integer.toString(otp);
+		while (result.length() < digits) {
+			result = "0" + result;
+		}
+		return result;
+	}
+}

+ 19 - 0
src/main/java/com/lightinit/hsdataportal/common/OrderNumberUtils.java

@@ -0,0 +1,19 @@
+package com.lightinit.hsdataportal.common;
+
+import java.util.Random;
+
+public class OrderNumberUtils {
+
+    /**
+     * 生成唯一订单编号
+     * 格式:时间+随机数
+     * @return
+     */
+    public static synchronized String generate(){
+        Random random = new Random() ;
+        System.currentTimeMillis() ;
+        Integer number = random.nextInt(900000)+100000 ;
+        return System.currentTimeMillis() + String.valueOf(number) ;
+    }
+
+}

+ 36 - 0
src/main/java/com/lightinit/hsdataportal/common/PermissionUtilsPro.java

@@ -0,0 +1,36 @@
+package com.lightinit.hsdataportal.common;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.subject.Subject;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by Mr.Yao on 2017/7/6.
+ */
+@Component
+public class PermissionUtilsPro {
+    /***
+     * 是否有超级权限
+     * @return
+     */
+    public boolean IsSuperPermission(){
+        Subject user = SecurityUtils.getSubject();
+        if (null == user)
+            return false;
+        Object objectUserName = user.getPrincipal();
+        if(objectUserName==null)
+            return false;
+        String currentUsername = (String) user.getPrincipal();
+        return "admin".contains(currentUsername.toLowerCase());
+    }
+
+    public String CurrentName(){
+        Subject user = SecurityUtils.getSubject();
+        if (null == user)
+            return "";
+        Object objectUserName = user.getPrincipal();
+        if(objectUserName==null)
+            return "";
+        return (String) user.getPrincipal();
+    }
+}

+ 61 - 0
src/main/java/com/lightinit/hsdataportal/common/PhoneSendUtils.java

@@ -0,0 +1,61 @@
+package com.lightinit.hsdataportal.common;
+
+import com.aliyuncs.CommonRequest;
+import com.aliyuncs.CommonResponse;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.exceptions.ServerException;
+import com.aliyuncs.http.MethodType;
+import com.aliyuncs.profile.DefaultProfile;
+import org.apache.log4j.LogManager;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+public class PhoneSendUtils {
+
+    public static org.apache.log4j.Logger log = LogManager.getLogger(PhoneSendUtils.class);
+
+    public static Map<String,Object> send(String phone){
+        Map<String,Object> map = null ;
+        String regionId = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.REGIONID);
+        String accesskeyId = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.ACCESSKEYID);
+        String secret = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.SECRET);
+        DefaultProfile profile = DefaultProfile.getProfile(regionId, accesskeyId, secret);
+
+        IAcsClient client = new DefaultAcsClient(profile);
+
+        CommonRequest request = new CommonRequest();
+        //request.setProtocol(ProtocolType.HTTPS);
+        request.setMethod(MethodType.POST);
+        request.setDomain("dysmsapi.aliyuncs.com");
+        request.setVersion("2017-05-25");
+        request.setAction("SendSms");
+        request.putQueryParameter("RegionId", "cn-hangzhou");
+        request.putQueryParameter("PhoneNumbers", phone);
+        request.putQueryParameter("SignName", "衡水智慧城市建设有限公司");
+        request.putQueryParameter("TemplateCode", "SMS_158948957");
+        int newNum = (int)((Math.random()*9+1)*100000);
+        String code = String.valueOf(newNum);
+        String newCode = "{\"code\":\""+code+"\"}" ;
+        request.putQueryParameter("TemplateParam", newCode);
+        try {
+            CommonResponse response = client.getCommonResponse(request);
+            String data = response.getData();
+            map = HttpUtil.strToMap(data) ;
+            map.put("returnCode",code) ;
+        } catch (ServerException e) {
+//            throw new RuntimeException("获取短信验证码异常",e.getCause()) ;
+            e.printStackTrace();
+            log.error("获取短信验证码异常:"+e.getErrCode()+e.getMessage());
+        } catch (ClientException e) {
+            e.printStackTrace();
+//            throw new RuntimeException("获取短信验证码异常",e.getCause()) ;
+            log.error("获取短信验证码异常:"+e.getErrCode()+e.getMessage());
+
+        }
+        return map ;
+    }
+
+}

+ 168 - 0
src/main/java/com/lightinit/hsdataportal/common/RSAUtils.java

@@ -0,0 +1,168 @@
+package com.lightinit.hsdataportal.common;
+
+import org.apache.commons.io.IOUtils;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.util.encoders.Base64;
+
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+import java.io.*;
+import java.math.BigInteger;
+import java.security.*;
+import java.security.spec.*;
+
+public class RSAUtils {
+	//private static String RSAPrivateKeyStore = "RSAPrivateKeyStore_devops-server.txt";
+	//private static String PROPERTY = System.getProperty("user.dir");
+	private static String RSAPrivateKeyStore = RSAUtils.class.getClassLoader().getResource("rsa-password/RSAPrivateKeyStore_devops-server.txt").getFile();
+	private static String PROPERTY = null;
+	private static int KEY_SIZE = 1024;
+
+	private static Provider provider = new BouncyCastleProvider();
+
+	private static PrivateKey privateKey;
+	private static PublicKey publicKey;
+
+	private static ThreadLocal<Cipher> localCipher = new ThreadLocal<Cipher>() {
+		protected synchronized Cipher initialValue() {
+			Cipher cipher = null;
+			try {
+				cipher = Cipher.getInstance("RSA");
+			} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
+				e.printStackTrace(System.err);
+			}
+			return cipher;
+		}
+	};
+
+	public static KeyPair generateKeyPair() throws Exception {
+		try {
+			KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA", provider);
+			keyPairGen.initialize(KEY_SIZE, new SecureRandom());
+			KeyPair keyPair = keyPairGen.generateKeyPair();
+			privateKey = keyPair.getPrivate();
+			publicKey = keyPair.getPublic();
+			return keyPair;
+		} catch (Exception e) {
+			throw new Exception(e.getMessage());
+		}
+	}
+
+	public static void saveKeyPair(KeyPair kp) throws Exception {
+		BufferedWriter oos = null;
+		try {
+			PrivateKey aPrivate = kp.getPrivate();
+			String privateKeyString = new String(Base64.encode(aPrivate.getEncoded()));
+			oos = new BufferedWriter(new FileWriter(new File(PROPERTY, RSAPrivateKeyStore)));
+			System.out.println(oos.toString());
+			oos.write(privateKeyString);
+		} finally {
+			IOUtils.closeQuietly(oos);
+		}
+	}
+
+	public static void loadKeyPair() throws Exception {
+		BufferedReader br = null;
+		try {
+			br = new BufferedReader(new FileReader(new File(PROPERTY,RSAPrivateKeyStore)));
+			StringBuilder sb = new StringBuilder();
+			String readLine = null;
+			while (null != (readLine = br.readLine())) {
+				sb.append(readLine);
+			}
+			String privateKeyStr = sb.toString();
+			privateKey = initialPrivateKey(privateKeyStr);
+			publicKey = generatePublicKeyByPrivateKey(privateKey);
+		} catch (IOException e) {
+			throw new Exception("私钥数据读取错误");
+		} catch (NullPointerException e) {
+			throw new Exception("私钥输入流为空");
+		} finally {
+			IOUtils.closeQuietly(br);
+		}
+	}
+
+	public static String encrypt(String plainText) {
+		String cipherText = null;
+		try {
+			byte[] data = plainText.getBytes();
+			Cipher cipher = localCipher.get();
+			cipher.init(Cipher.ENCRYPT_MODE, publicKey);
+			byte[] bytes = cipher.doFinal(data);
+			cipherText = new String(Base64.encode(bytes));
+		} catch (Exception ex) {
+			ex.printStackTrace(System.err);
+		}
+
+		return cipherText;
+	}
+
+	public static String decrypt(String cipherText) {
+		String plainText = null;
+		try {
+			byte[] data = Base64.decode(cipherText);
+			Cipher cipher = localCipher.get();
+			cipher.init(Cipher.DECRYPT_MODE, privateKey);
+			byte[] bytes = cipher.doFinal(data);
+			plainText = new String(bytes);
+		} catch (Exception ex) {
+			ex.printStackTrace(System.err);
+		}
+
+		return plainText;
+	}
+
+	private static PrivateKey initialPrivateKey(String privateKeyStr) throws Exception {
+		try {
+			byte[] buffer = Base64.decode(privateKeyStr);
+			PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(buffer);
+			KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+			return keyFactory.generatePrivate(keySpec);
+		} catch (NoSuchAlgorithmException e) {
+			throw new Exception("无此算法");
+		} catch (InvalidKeySpecException e) {
+			throw new Exception("私钥非法");
+		} catch (NullPointerException e) {
+			throw new Exception("私钥数据为空");
+		}
+	}
+
+	private static PublicKey generatePublicKeyByPrivateKey(PrivateKey privateKey) {
+		PublicKey publicKey = null;
+		try {
+			KeyFactory kf = KeyFactory.getInstance("RSA");
+			RSAPrivateKeySpec priv = kf.getKeySpec(privateKey, RSAPrivateKeySpec.class);
+			RSAPublicKeySpec keySpec = new RSAPublicKeySpec(priv.getModulus(), BigInteger.valueOf(65537));
+			publicKey = kf.generatePublic(keySpec);
+			System.out.println(">>>> PublicKey: " + new String(Base64.encode(publicKey.getEncoded())) + " <<<<");
+		} catch (NoSuchAlgorithmException e) {
+			e.printStackTrace();
+		} catch (InvalidKeySpecException e) {
+			e.printStackTrace();
+		}
+		return publicKey;
+	}
+
+	public static void initialPublicKey(String publicKeyStr) throws Exception {
+		try {
+			byte[] buffer = Base64.decode(publicKeyStr);
+			KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+			X509EncodedKeySpec keySpec = new X509EncodedKeySpec(buffer);
+			publicKey = keyFactory.generatePublic(keySpec);
+		} catch (NoSuchAlgorithmException e) {
+			throw new Exception("无此算法");
+		} catch (InvalidKeySpecException e) {
+			throw new Exception("公钥非法");
+		} catch (NullPointerException e) {
+			throw new Exception("公钥数据为空");
+		}
+	}
+
+
+	/*public static void main(String[] args) {
+        String RSAPrivateKeyStore = RSAUtils.class.getClassLoader().getResource("rsa-password/RSAPrivateKeyStore_devops-server.txt").getFile();
+        File file = new File(RSAPrivateKeyStore);
+        System.out.println(file.length());
+        System.out.println(RSAPrivateKeyStore);
+    }*/
+}

+ 43 - 0
src/main/java/com/lightinit/hsdataportal/common/RoleComboUtils.java

@@ -0,0 +1,43 @@
+package com.lightinit.hsdataportal.common;
+
+import com.lightinit.hsdataportal.json.pojo.RoleAttributesEntity;
+import com.lightinit.hsdataportal.json.pojo.RoleComboEntity;
+import com.lightinit.hsdataportal.entity.SentryRole;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Mr.Yao on 2017/4/24.
+ */
+public class RoleComboUtils {
+
+    public static RoleComboEntity  RoleComboxConverter(SentryRole role) {
+        RoleComboEntity entity=new RoleComboEntity();
+        if (role!=null)
+        {
+            List<RoleComboEntity> tmpList=new ArrayList<RoleComboEntity>();
+            List<SentryRole> list=role.getChildren();
+            if(list!=null && list.size()>0){
+                for (SentryRole _item:list) {
+                    RoleComboEntity _entity=RoleComboxConverter(_item);
+                    if (_entity!=null)
+                        tmpList.add(_entity);
+                }
+                entity.setIconCls("fi-page-copy");
+                entity.setChildren(tmpList);
+            }else {
+                entity.setIconCls("fi-page");
+                entity.setChildren(null);
+            }
+            entity.setId(role.getId());
+            entity.setText(role.getRolename());
+            RoleAttributesEntity roleAttributesEntity=new RoleAttributesEntity();
+            if (role.getParentid()!=null) {
+                roleAttributesEntity.setParentid(role.getParentid());
+            }
+        }
+        return entity;
+    }
+
+}

+ 127 - 0
src/main/java/com/lightinit/hsdataportal/common/RoleModulesUtilsPro.java

@@ -0,0 +1,127 @@
+package com.lightinit.hsdataportal.common;
+
+import com.lightinit.hsdataportal.entity.AdminRole;
+import com.lightinit.hsdataportal.entity.RoleModule;
+import com.lightinit.hsdataportal.entity.SentryRole;
+import com.lightinit.hsdataportal.entity.UserModule;
+import com.lightinit.hsdataportal.service.IRoleService;
+import com.lightinit.hsdataportal.service.IUserModuleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Mr.Yao on 2017/4/25.
+ */
+@Component
+public class RoleModulesUtilsPro {
+    @Autowired
+    private IRoleService roleService;
+    @Autowired
+    private IUserModuleService userModuleService;
+
+    public List<RoleModule> UserHasModules(long uid){
+        List<RoleModule> result=new ArrayList<RoleModule>();
+        if(uid>0) {
+            List<UserModule> userModuleList=userModuleService.QueryUserModuleList(uid);
+            if (userModuleList!=null && userModuleList.size()>0){
+                for (UserModule mUserModule:userModuleList) {
+                    RoleModule roleModule = new RoleModule();
+                    roleModule.setModuleid(mUserModule.getModuleid());
+                    result.add(roleModule);
+                }
+            }
+            if (result.size()>0)
+                return result;
+            List<AdminRole> list= roleService.QueryRoleList(uid);
+            List<Long> roleIds=new ArrayList<Long>();
+            for (AdminRole role:list) {
+                roleIds.add(role.getId());
+            }
+            List<SentryRole> sentryRoles= roleService.QueryManyRole(roleIds);
+            for (SentryRole sentryRole:sentryRoles) {
+                List<RoleModule> _result = roleService.QueryModuleList(sentryRole.getId());
+                if((_result==null || _result.size()==0)&& sentryRole!=null && sentryRole.getParentid()!=null && sentryRole.getParentid()>0){
+                    _result=new ArrayList<RoleModule>();
+                    List<RoleModule> tmpList =RoleModules(sentryRole.getParentid());
+                    if(tmpList!=null){
+                        for (RoleModule item:tmpList) {
+                            if(_result.contains(item)==false){
+                                _result.add(item);
+                            }
+                        }
+                    }
+                }
+                for (RoleModule item:_result) {
+                    if(result.contains(item)==false){
+                        result.add(item);
+                    }
+                }
+            }
+            return result;
+        }else
+            return null;
+    }
+    public List<RoleModule> RoleModules(long role){
+        List<RoleModule> result=new ArrayList<RoleModule>();
+        if(role>0) {
+            SentryRole sentryRole= roleService.QueryOne(role);
+            result = roleService.QueryModuleList(role);
+            if((result==null || result.size()==0)&& sentryRole!=null && sentryRole.getParentid()!=null && sentryRole.getParentid()>0){
+                List<RoleModule> tmpList =RoleModules(sentryRole.getParentid());
+                if(tmpList!=null){
+                    for (RoleModule item:tmpList) {
+                        if(result.contains(item)==false){
+                            result.add(item);
+                        }
+                    }
+                }
+            }
+            return result;
+        }else
+        return null;
+    }
+    public List<Long> RoleHasModules(long role){
+        List<Long> roleHasModules=new ArrayList<Long>();
+        List<RoleModule> result=new ArrayList<RoleModule>();
+        if(role>0) {
+            SentryRole sentryRole= roleService.QueryOne(role);
+            result = roleService.QueryModuleList(role);
+            if((result==null || result.size()==0)&& sentryRole!=null && sentryRole.getParentid()!=null && sentryRole.getParentid()>0){
+                List<RoleModule> tmpList =RoleModules(sentryRole.getParentid());
+                if(tmpList!=null){
+                    for (RoleModule item:tmpList) {
+                        if(result.contains(item)==false){
+                            result.add(item);
+                        }
+                    }
+                }
+            }
+        }
+        for (RoleModule _item:result) {
+            if(roleHasModules.contains(_item.getModuleid())==false){
+                roleHasModules.add(_item.getModuleid());
+            }
+        }
+        return roleHasModules;
+    }
+    public List<Long> RoleIds(SentryRole role){
+        List<Long> result=new ArrayList<Long>();
+        result.add(role.getId());
+        if(role.getChildren()!=null && role.getChildren().size()>0){
+            for (SentryRole item:role.getChildren()) {
+                List<Long> tmpResult=RoleIds(item);
+                if(tmpResult.size()>0){
+                    for (Long _item:tmpResult) {
+                        if(result.contains(_item)==false){
+                            result.add(_item);
+                        }
+                    }
+                }
+            }
+        }
+        return result;
+    }
+}

+ 71 - 0
src/main/java/com/lightinit/hsdataportal/common/SecureCardUtilsPro.java

@@ -0,0 +1,71 @@
+package com.lightinit.hsdataportal.common;
+
+import com.lightinit.hsdataportal.entity.Securekey;
+import com.lightinit.hsdataportal.service.ISecureKeyService;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.subject.Subject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import javax.servlet.http.HttpSession;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Created by Lantinit on 2018/2/1.
+ */
+@Component
+public class SecureCardUtilsPro {
+    @Autowired
+    private ISecureKeyService secureKeyService;
+
+    public boolean verification(HttpSession session,String token,String cardno,long synctime){
+        String capText=session.getAttribute("SECUREKEY_SESSION_KEY")!=null?session.getAttribute("SECUREKEY_SESSION_KEY").toString():"";
+        if(StringUtils.isEmpty(capText)){
+            return false;
+        }
+        String realToken="";
+        String[]TokenArray=capText.split(":::");
+        for (String item:TokenArray) {
+            String secretStr=item.substring(1)+":::"+cardno+":::"+synctime+":::"+item.substring(0,1);
+            try {
+                realToken+=OneTimePasswordAlgorithm.generateOTP(secretStr.getBytes(), 0, 2, false, -1);
+            } catch (NoSuchAlgorithmException e) {
+                e.printStackTrace();
+            } catch (InvalidKeyException e) {
+                e.printStackTrace();
+            }
+        }
+        if(realToken.equalsIgnoreCase(token)==false){
+            return false;
+        }
+        session.removeAttribute("SECUREKEY_SESSION_KEY");
+        return true;
+    }
+
+    public boolean verification(HttpSession session,String token,String username){
+        Securekey securekey= secureKeyService.QueryOne(username);
+        if(securekey==null){
+            return false;
+        }
+        SimpleDateFormat syncDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            Date syncDate= syncDateFormat.parse(syncDateFormat.format(securekey.getSyncdatetime()));
+            return verification(session,token,securekey.getSecurekey(),syncDate.getTime());
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+    public boolean verification(HttpSession session,String token){
+        Subject currentUser = SecurityUtils.getSubject();
+        if(currentUser==null){
+            return false;
+        }
+        return verification(session,token,currentUser.getPrincipal().toString());
+    }
+}

+ 32 - 0
src/main/java/com/lightinit/hsdataportal/common/ShiroFilterUtils.java

@@ -0,0 +1,32 @@
+package com.lightinit.hsdataportal.common;
+
+import java.io.PrintWriter;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+import org.codehaus.jackson.map.ObjectMapper;
+/**
+ * Created by Mr.Yao on 2017/11/8.
+ */
+public class ShiroFilterUtils {
+    private static ObjectMapper objectMapper = new  ObjectMapper();
+    public static boolean isAjax(ServletRequest request){
+        return "XMLHttpRequest".equalsIgnoreCase(((HttpServletRequest) request).getHeader("X-Requested-With"));
+    }
+    public static void out(ServletResponse response, Map<String, String> resultMap){
+        PrintWriter out = null;
+        try {
+//            response.setCharacterEncoding("UTF-8");
+            out = response.getWriter();
+            out.println(objectMapper.writeValueAsString(resultMap));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }finally{
+            if(null != out){
+                out.flush();
+                out.close();
+            }
+        }
+    }
+}

+ 43 - 0
src/main/java/com/lightinit/hsdataportal/common/SolrUtils.java

@@ -0,0 +1,43 @@
+package com.lightinit.hsdataportal.common;
+
+import com.lightinit.hsdataportal.json.pojo.solr.CoreOverViewResponseEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.message.BasicNameValuePair;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.springframework.util.StringUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Mr.Yao on 2017/12/7.
+ */
+public class SolrUtils {
+    public static CoreOverViewResponseEntity parse(String service, String core){
+        CoreOverViewResponseEntity result=null;
+        if(StringUtils.isEmpty(service) || StringUtils.isEmpty(core))
+            return result;
+        List<NameValuePair> nameValuePairs=new ArrayList<NameValuePair>();
+        nameValuePairs.add(new BasicNameValuePair("wt","json"));
+        nameValuePairs.add(new BasicNameValuePair("show","index"));
+        nameValuePairs.add(new BasicNameValuePair("numTerms","0"));
+        nameValuePairs.add(new BasicNameValuePair("_",String.valueOf(System.currentTimeMillis())));
+        String responseBody= HttpTookitUtils.doGet(service+"/"+core+"/admin/luke",nameValuePairs, CharEncoding.UTF8,"application/json");
+        if(StringUtils.isEmpty(responseBody)==false) {
+            ObjectMapper objectMapper = new ObjectMapper();
+            try {
+                result = objectMapper.readValue(responseBody, CoreOverViewResponseEntity.class);
+            } catch (JsonParseException e) {
+                e.printStackTrace();
+            } catch (JsonMappingException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return result;
+    }
+}

+ 74 - 0
src/main/java/com/lightinit/hsdataportal/common/SysContants.java

@@ -0,0 +1,74 @@
+package com.lightinit.hsdataportal.common;
+
+import java.io.File;
+
+/**
+ * @author WangYao
+ * @date 2018/6/12 14:20
+ * @description
+ */
+public class SysContants {
+
+    //Property文件路径
+    public static class PropertyFilePath{
+        public final static String CONFIG = "config.properties";
+        public final static String CAS = "cas.properties";
+    }
+
+    //属性键
+    public static class PropertyKey{
+        public final static String USER_TYPE = "userType"; // 跳转登录页URL
+        public final static String REDIRECT_HOME_URL = "redirectHomeUrl"; // 跳转首页URL
+        public final static String REDIRECT_LOGIN_URL = "redirectLoginUrl"; // 跳转登录页URL
+        public final static String IMAGE_CONTEXT_PATH = "imageContextPath"; // 该key用于获取tomcat中配置的用于显示外部目录中图片的Context的Path值
+        public final static String UPLOAD_FILE_ROOT_DIR = "uploadFileRootDir"; //上传文件存放目录key
+        public final static String UPLOAD_IMAGE_ROOT_DIR = "uploadImageRootDir"; //上传图片存放目录key
+        public final static String DEVOPS = "devops" ; //衡水大数据中心 门户
+        //短信属性
+        public final static String REGIONID = "regionId" ;
+        public final static String ACCESSKEYID = "accessKeyId" ;
+        public final static String SECRET = "secret" ;
+
+        //微信属性
+        public final static String APPID = "appId" ;
+        public final static String MCHID = "mchId" ;
+        public final static String WXKEY = "wxKey" ;
+        public final static String NOTIFYURL = "notifyurl" ;
+
+
+        //新路由规则
+        public final static String NEWGATEWAYPATH = "newGatewayPath" ;
+
+
+        public final static String APPLICATIONID = "applicationId" ;
+        public final static String SIGNAPPID = "signAppId" ;
+
+        //服务开发环境
+        public final static String DEVOPSSERVICE = "devopsService" ;
+        //数据可视化开发
+        public final static String DEVOPSDATE = "devopsDate" ;
+        //大数据分析建模
+        public final static String DEVOPSANALYSIS = "devopsAnalysis" ;
+    }
+
+    //cas属性键
+    public static class CasKey{
+        public final static String CASSERVICE = "casService"; // 跳转登录页URL
+        public final static String REDIRECTURL = "redirectUrl"; // 退出url
+    }
+
+    public static class UploadFilePath{
+        public static final String DATA_REGISTER_ROOT_DIR = "DataRegister" + File.separator;
+        public static final String DATA_REGISTER_DATA_DIR = "DataFile" + File.separator;
+        public static final String DATA_REGISTER_DEMO_DIR = "DemoFile" + File.separator;
+        public static final String MICROAPP_REGISTER_ROOT_DIR = "MicroappRegister" + File.separator;
+        public static final String MICROAPP_PUBLISH_ROOT_DIR = "MicroappPublish" + File.separator;
+        public static final String USER_COMPANY_VERIFY_DIR = "CompanyRegister" + File.separator;
+        public static final String USER_COMPANY_VERIFY_IMG_DIR = "CompanyCommerical" + File.separator;
+        public static final String ACTIVITY_ROOT_DIR = "activity" + File.separator;
+        public static final String ACTIVITY_IMG_DIR = "thumbnail" + File.separator;
+        public static final String ROADSHOW_ROOT_DIR = "roadShow" + File.separator;
+
+    }
+
+}

+ 27 - 0
src/main/java/com/lightinit/hsdataportal/common/ThriftServerConfig.java

@@ -0,0 +1,27 @@
+package com.lightinit.hsdataportal.common;
+
+import org.apache.commons.configuration2.Configuration;
+import org.springframework.stereotype.Component;
+
+/**
+ * Created by Mr.Yao on 2017/5/9.
+ */
+@Component
+public class ThriftServerConfig {
+    private static String zookeeperhost;
+    private static int zookeeperport;
+
+    static {
+        Configuration configuration=ConfigUtils.getConfiguration("thrift.properties");
+        zookeeperhost=configuration.getString("thrift.zookeeper.host");
+        zookeeperport=configuration.getInt("thrift.zookeeper.port");
+    }
+
+    public String getHost() {
+        return zookeeperhost;
+    }
+
+    public int getPort() {
+        return zookeeperport;
+    }
+}

+ 93 - 0
src/main/java/com/lightinit/hsdataportal/common/TokenUtils.java

@@ -0,0 +1,93 @@
+package com.lightinit.hsdataportal.common;
+
+import com.google.gson.Gson;
+import com.lightinit.hsdataportal.dictionary.DicGitToken;
+import org.springframework.util.StringUtils;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Author: sunxiang
+ * @Date: 2018/9/28 10:04
+ * @Description: 获取平台同步需要的token
+ **/
+public class TokenUtils {
+
+    public static  String EXPIRYTIME = "" ;
+
+    public static String STORAGE = "" ;
+
+    public static void main(String[] args) {
+        getToken();
+    }
+
+    public static  String getToken(){
+        Date date = new Date(System.currentTimeMillis());
+        long nowTime = date.getTime() ;
+        if (!getSTORAGE().equals("")){
+            long time = Long.valueOf(getEXPIRYTIME()) ;
+            //没过期
+            if (nowTime<time){
+                return getSTORAGE() ;
+            }
+        }
+        Map<String,String> heads = new HashMap<>() ;
+        heads.put("Authorization", DicGitToken.AUTHORIZATION) ;
+        heads.put("Content-Type","application/x-www-form-urlencoded") ;
+        String token = "" ;
+        try {
+            token =  HttpUtil.getToken(DicGitToken.URL,heads,"application/x-www-form-urlencoded") ;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        Gson gson = new Gson();
+        Map<String,Object> str = gson.fromJson(token,Map.class) ;
+        if(!StringUtils.isEmpty(str.get("access_token"))){
+            String accessToken = (String) str.get("access_token") ;
+            setSTORAGE(accessToken);
+            Double getTime = (Double) str.get("expires_in");
+            long str1 = getTime.longValue()+nowTime ;
+            setEXPIRYTIME(String.valueOf(str1));
+            return accessToken ;
+        }
+        return null;
+    }
+
+    public static String getEXPIRYTIME() {
+        return EXPIRYTIME;
+    }
+
+    public static void setEXPIRYTIME(String EXPIRYTIME) {
+        TokenUtils.EXPIRYTIME = EXPIRYTIME;
+    }
+
+    public static String getSTORAGE() {
+        return STORAGE;
+    }
+
+    public static void setSTORAGE(String STORAGE) {
+        TokenUtils.STORAGE = STORAGE;
+    }
+    /*
+    *@Description 管控平台的配置类
+    *@Param
+    *@Date 2018/9/29
+    *@return
+    **/
+    public static class MsgsServer{
+        public static final String USERPATH="v1/user";
+    }
+
+    /*
+    *@Description 开发平台的配置类
+    *@Param
+    *@Date 2018/9/29
+    *@return
+    **/
+    public static class DevopsServer{
+        public static final String GROUPPATH="api/v1/groups";
+        public static final String USERPATH="api/v1/users";
+    }
+}

+ 123 - 0
src/main/java/com/lightinit/hsdataportal/common/TripleDESUtilsPro.java

@@ -0,0 +1,123 @@
+package com.lightinit.hsdataportal.common;
+
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Created by Mr.Yao on 2016/1/18.
+ */
+public class TripleDESUtilsPro {
+    private static String encypt_des_key="lantinit.com";
+    private static final String Algorithm = "DESede";  //定义 加密算法,可用 DES,DESede,Blowfish
+    private static final char[] HEX_CHAR= {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+    // 加密字符串
+    public static byte[] encryptMode(byte[] src) {
+        try { // 生成密钥
+            SecretKey deskey = new SecretKeySpec(build3DesKey(encypt_des_key), Algorithm); // 加密
+            Cipher c1 = Cipher.getInstance(Algorithm);
+            c1.init(Cipher.ENCRYPT_MODE, deskey);
+            return c1.doFinal(src);
+        } catch (java.security.NoSuchAlgorithmException e1) {
+            e1.printStackTrace();
+        } catch (javax.crypto.NoSuchPaddingException e2) {
+            e2.printStackTrace();
+        } catch (java.lang.Exception e3) {
+            e3.printStackTrace();
+        }
+        return null;
+    }
+    public static String encryptMode(String src) {
+        try {
+            byte[]decryptByte=encryptMode(src.getBytes("utf-8"));
+            if (decryptByte==null)
+                return "";
+            return byteArrayToString(decryptByte);
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+    // 解密字符串
+    public static byte[] decryptMode(byte[] src) {
+        try { // 生成密钥
+            SecretKey deskey = new SecretKeySpec(build3DesKey(encypt_des_key), Algorithm); // 解密
+            Cipher c1 = Cipher.getInstance(Algorithm);
+            c1.init(Cipher.DECRYPT_MODE, deskey);
+            return c1.doFinal(src);
+        } catch (java.security.NoSuchAlgorithmException e1) {
+            e1.printStackTrace();
+        } catch (javax.crypto.NoSuchPaddingException e2) {
+            e2.printStackTrace();
+        } catch (java.lang.Exception e3) {
+            e3.printStackTrace();
+        }
+        return null;
+    }
+    public static String decryptMode(String src) {
+        try {
+            byte[]decryptByte=decryptMode(HexString2Bytes(src));
+            if (decryptByte==null)
+                return "";
+            return new String(decryptByte);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+    public static String decryptHex(String src){
+        byte[]srcByte=HexString2Bytes(src);
+        byte[]decryptByte=decryptMode(srcByte);
+        if (decryptByte==null)
+            return "";
+        try {
+            return new String(decryptByte,"utf-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+    public static byte[] HexString2Bytes(String hexstr) {
+        byte[] b = new byte[hexstr.length() / 2];
+        int j = 0;
+        for (int i = 0; i < b.length; i++) {
+            char c0 = hexstr.charAt(j++);
+            char c1 = hexstr.charAt(j++);
+            b[i] = (byte) ((parse(c0) << 4) | parse(c1));
+        }
+        return b;
+    }
+    public static String byteArrayToString(byte[] data){
+        StringBuilder stringBuilder= new StringBuilder();
+        for (int i=0; i<data.length; i++){
+            stringBuilder.append(HEX_CHAR[(data[i] & 0xf0)>>> 4]);
+            stringBuilder.append(HEX_CHAR[(data[i] & 0x0f)]);
+        }
+        return stringBuilder.toString();
+    }
+    private static int parse(char c) {
+        if (c >= 'a')
+            return (c - 'a' + 10) & 0x0f;
+        if (c >= 'A')
+            return (c - 'A' + 10) & 0x0f;
+        return (c - '0') & 0x0f;
+    }
+
+    public static byte[] build3DesKey(String keyStr){
+        byte[] key = new byte[24];    //声明一个24位的字节数组,默认里面都是0
+        try {
+            byte[] temp = keyStr.getBytes("UTF-8");    //将字符串转成字节数组
+            if (key.length > temp.length) {
+                System.arraycopy(temp, 0, key, 0, temp.length);
+            } else {
+                System.arraycopy(temp, 0, key, 0, key.length);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return key;
+    }
+}

+ 70 - 0
src/main/java/com/lightinit/hsdataportal/common/UploadFileUtils.java

@@ -0,0 +1,70 @@
+package com.lightinit.hsdataportal.common;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @author WangYao
+ * @date 2018/6/13 11:48
+ * @description
+ */
+public class UploadFileUtils {
+
+    private static final Logger logger = LoggerFactory.getLogger(UploadFileUtils.class);
+
+    public static void write(MultipartFile uploadFile, String targetDir) throws IOException {
+        String dataFileName = uploadFile.getOriginalFilename();
+        File dataFilePath = new File(targetDir, dataFileName);
+        //判断路径是否存在,如果不存在就创建一个
+        if (!dataFilePath.getParentFile().exists()) {
+            dataFilePath.getParentFile().mkdirs();
+        }
+        uploadFile.transferTo(new File(targetDir + dataFileName));
+    }
+
+    public static boolean writeUploadFile(MultipartFile dataFile, String relativeDir, String propertieds) {
+        try {
+            String uploadRootDir = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(propertieds);
+            String absoluteDir = uploadRootDir + relativeDir;
+            write(dataFile, absoluteDir);
+        } catch (Exception e) {
+            logger.error(e.getMessage());
+            return false;
+        }
+        return true;
+    }
+
+    public static String buildRelativeDir(String parentDir, String uniqueDir, String childDir){
+        if (!StringUtils.isNotEmpty(uniqueDir)){
+            uniqueDir = GuidGenerator.generate() + File.separator;
+        }
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+        String dir = (parentDir == null ? "" : parentDir) + uniqueDir + (childDir == null ? "" : childDir) + simpleDateFormat.format(new Date()) + File.separator;
+        return dir;
+    }
+
+    public static String getExistingFileRelativeDir(int removeParentDirs, String existingFilePath, int removeChildDirs){
+        String dir = new File(existingFilePath).getParent();
+        for (int i = 0; i < removeParentDirs; i++) {
+            dir = dir.substring(dir.indexOf(File.separator) + 1, dir.length());
+        }
+        for (int i = 0; i < removeChildDirs; i++) {
+            dir = dir.substring(0, dir.lastIndexOf(File.separator));
+        }
+        dir += File.separator;
+        return dir;
+    }
+
+    public static String getFileNameByPath(String filePath){
+        String fileName = new File(filePath).getName();
+        return fileName;
+    }
+
+}

+ 50 - 0
src/main/java/com/lightinit/hsdataportal/common/WebUtilsPro.java

@@ -0,0 +1,50 @@
+package com.lightinit.hsdataportal.common;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.PrintWriter;
+
+/**
+ * Created by Mr.Yao on 2017/4/18.
+ */
+public class WebUtilsPro {
+    public static boolean isAjaxRequest(HttpServletRequest request) {
+        String requestedWith = request.getHeader("x-requested-with");
+        if (requestedWith != null && requestedWith.equalsIgnoreCase("XMLHttpRequest")) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 发送消息 text/html;charset=utf-8
+     * @param response
+     * @param text
+     * @throws Exception
+     */
+    public static void writeText(HttpServletResponse response, String text) throws Exception {
+        response.setContentType("text/html; charset=utf-8");
+        PrintWriter writer = response.getWriter();
+        writer.print(text);
+        writer.close();
+        response.flushBuffer();
+    }
+
+    /**
+     * 将某个对象转换成json格式并发送到客户端
+     * @param response
+     * @param obj
+     * @throws Exception
+     */
+    public static <T> void  writeJson(HttpServletResponse response, T obj) throws Exception {
+        response.setContentType("application/json; charset=utf-8");
+        PrintWriter writer = response.getWriter();
+        ObjectMapper objectMapper = new ObjectMapper();
+        writer.print(objectMapper.writeValueAsString(obj));
+        writer.close();
+        response.flushBuffer();
+    }
+}

+ 98 - 0
src/main/java/com/lightinit/hsdataportal/common/ssl/MySecureProtocolSocketFactory.java

@@ -0,0 +1,98 @@
+package com.lightinit.hsdataportal.common.ssl;
+
+import org.apache.commons.httpclient.ConnectTimeoutException;
+import org.apache.commons.httpclient.HttpClientError;
+import org.apache.commons.httpclient.params.HttpConnectionParams;
+import org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory;
+import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+public class MySecureProtocolSocketFactory implements SecureProtocolSocketFactory {
+
+    //这里添加一个属性,主要目的就是来获取ssl跳过验证
+    private SSLContext sslContext = null;
+    /**
+     * Constructor for MySecureProtocolSocketFactory.
+     */
+    public MySecureProtocolSocketFactory() {
+    }
+    /**
+     * 这个创建一个获取SSLContext的方法,导入MyX509TrustManager进行初始化
+     * @return
+     */
+    private static SSLContext createEasySSLContext() {
+        try {
+            SSLContext context = SSLContext.getInstance("SSL");
+            context.init(null, new TrustManager[] { new MyX509TrustManager() },
+                    null);
+            return context;
+        } catch (Exception e) {
+            throw new HttpClientError(e.toString());
+        }
+    }
+
+    /**
+     * 判断获取SSLContext
+     * @return
+     */
+    private SSLContext getSSLContext() {
+        if (this.sslContext == null) {
+            this.sslContext = createEasySSLContext();
+        }
+        return this.sslContext;
+    }
+    //后面的方法基本上就是带入相关参数就可以了
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.commons.httpclient.protocol.ProtocolSocketFactory#createSocket(java.lang.String,
+     *      int, java.net.InetAddress, int)
+     */
+    public Socket createSocket(String host, int port, InetAddress clientHost,int clientPort) throws IOException, UnknownHostException {
+        return getSSLContext().getSocketFactory().createSocket(host, port,clientHost, clientPort);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.commons.httpclient.protocol.ProtocolSocketFactory#createSocket(java.lang.String,
+     *      int, java.net.InetAddress, int,
+     *      org.apache.commons.httpclient.params.HttpConnectionParams)
+     */
+    public Socket createSocket(final String host, final int port,final InetAddress localAddress, final int localPort,
+                               final HttpConnectionParams params) throws IOException,UnknownHostException, ConnectTimeoutException {
+        if (params == null) {
+            throw new IllegalArgumentException("Parameters may not be null");
+        }
+        int timeout = params.getConnectionTimeout();
+        if (timeout == 0) {
+            return createSocket(host, port, localAddress, localPort);
+        } else {
+            return ControllerThreadSocketFactory.createSocket(this, host, port,localAddress, localPort, timeout);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int)
+     */
+    public Socket createSocket(String host, int port) throws IOException,UnknownHostException {
+        return getSSLContext().getSocketFactory().createSocket(host, port);
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean)
+     */
+    public Socket createSocket(Socket socket, String host, int port,boolean autoClose) throws IOException, UnknownHostException {
+        return getSSLContext().getSocketFactory().createSocket(socket, host,port, autoClose);
+    }
+}

+ 28 - 0
src/main/java/com/lightinit/hsdataportal/common/ssl/MyX509TrustManager.java

@@ -0,0 +1,28 @@
+package com.lightinit.hsdataportal.common.ssl;
+
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+public class MyX509TrustManager implements X509TrustManager {
+    /* (non-Javadoc)
+     * @see javax.net.ssl.X509TrustManager#checkClientTrusted(java.security.cert.X509Certificate[], java.lang.String)
+     */
+    public void checkClientTrusted(X509Certificate[] arg0, String arg1)
+            throws CertificateException {
+
+    }
+    /* (non-Javadoc)
+     * @see javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate[], java.lang.String)
+     */
+    public void checkServerTrusted(X509Certificate[] arg0, String arg1)
+            throws CertificateException {
+
+    }
+    /* (non-Javadoc)
+     * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
+     */
+    public X509Certificate[] getAcceptedIssuers() {
+        return null;
+    }
+}

+ 127 - 0
src/main/java/com/lightinit/hsdataportal/controller/BaseController.java

@@ -0,0 +1,127 @@
+package com.lightinit.hsdataportal.controller;
+
+import com.lightinit.hsdataportal.annotation.FieldDescriberHelper;
+import com.lightinit.hsdataportal.common.WebUtilsPro;
+import com.lightinit.hsdataportal.json.pojo.ErrorEntity;
+import com.lightinit.hsdataportal.json.pojo.LoginResult;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.model.ResultStateCode;
+import org.apache.shiro.authc.AuthenticationException;
+import org.apache.shiro.authz.AuthorizationException;
+import org.apache.shiro.authz.UnauthenticatedException;
+import org.apache.shiro.authz.UnauthorizedException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.PrintWriter;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Created by Mr.Yao on 2017/4/18.
+ */
+public abstract class BaseController
+{
+
+//    /***
+//     * 登录异常返回信息
+//     * @param request 输入
+//     * @param response 输出
+//     * @return AJAX返回JSON数据格式 浏览器访问返回HTML格式
+//     */
+//    @ExceptionHandler({UnauthenticatedException.class,AuthenticationException.class})
+//    public String authenticationException(HttpServletRequest request, HttpServletResponse response){
+//        if(WebUtilsPro.isAjaxRequest(request)){
+//            LoginResult loginResult=new LoginResult();
+//            loginResult.setStatus(2008);
+//            loginResult.setMessage(ErrorEntity.getMsg(loginResult.getStatus()));
+//            writeJson(loginResult,response);
+//            return null;
+//        }else{
+//            return InternalResourceViewResolver.REDIRECT_URL_PREFIX+"/passport/login.htm";
+//        }
+//    }
+//
+//    /***
+//     * 授权异常返回信息
+//     * @param request 输入
+//     * @param response 输出
+//     * @return AJAX返回JSON数据格式 浏览器访问返回HTML格式
+//     */
+//    @ExceptionHandler({ UnauthorizedException.class, AuthorizationException.class })
+//    public String authorizationException(HttpServletRequest request, HttpServletResponse response) {
+//        if (WebUtilsPro.isAjaxRequest(request)) {
+//            LoginResult loginResult=new LoginResult();
+//            loginResult.setStatus(2009);
+//            loginResult.setMessage(ErrorEntity.getMsg(loginResult.getStatus()));
+//            writeJson(loginResult,response);
+//            return null;
+//        } else {
+//            return InternalResourceViewResolver.REDIRECT_URL_PREFIX+"/403.html";
+//        }
+//    }
+
+    private void writeJson(LoginResult result,HttpServletResponse response){
+        PrintWriter out=null;
+        try{
+            response.setContentType("application/json; charset=utf-8");
+            out = response.getWriter();
+            ObjectMapper objectMapper = new ObjectMapper();
+            out.write(objectMapper.writeValueAsString(result));
+        }catch (Exception e){
+            e.printStackTrace();
+        }finally {
+            if(out!=null)
+                out.close();
+        }
+    }
+
+    public static <T> LinkedHashMap<String, String> getAllFieldInvalidMsg(T modelObj, BindingResult bindingResult){
+        if (modelObj == null || bindingResult == null){
+            return null;
+        }
+        LinkedHashMap<String, String> result = new LinkedHashMap<>();
+        for (FieldError error : bindingResult.getFieldErrors()){
+            String fieldName = error.getField();
+            String fieldDescription = FieldDescriberHelper.getFieldDescription(modelObj, fieldName);
+            result.put(fieldName, fieldDescription + error.getDefaultMessage());
+        }
+
+        return result;
+    }
+
+    public static <T> Map.Entry<String, String> getFirstFieldInvalidMsg(T modelObj, BindingResult bindingResult){
+        LinkedHashMap<String, String> allFieldInvalidMsg = getAllFieldInvalidMsg(modelObj, bindingResult);
+        return allFieldInvalidMsg == null ? null : allFieldInvalidMsg.entrySet().stream().findFirst().get();
+    }
+
+    public static ResultState buildInvalidResultState(String message){
+        return buildInvalidResultState(message, null);
+    }
+
+    public static <T> ResultState<T> buildInvalidResultState(int stateCode, String message){
+        return buildInvalidResultState(stateCode, message, null);
+    }
+
+    public static <T> ResultState<T> buildInvalidResultState(String message, T data){
+        return buildInvalidResultState(ResultStateCode.INVALID_DATA, message, data);
+    }
+
+    public static <T> ResultState<T> buildInvalidResultState(int stateCode, String message, T data){
+        return new ResultState(stateCode, message, data);
+    }
+
+    public static <T> ResultState<LinkedHashMap<String, String>> getAllFieldInvalidResultState(T modelObj, BindingResult bindingResult){
+        return buildInvalidResultState("", getAllFieldInvalidMsg(modelObj, bindingResult));
+    }
+
+    public static <T> ResultState getFirstInvalidResultState(T modelObj, BindingResult bindingResult){
+        Map.Entry<String, String> firstFieldInvalidMsg = getFirstFieldInvalidMsg(modelObj, bindingResult);
+        return buildInvalidResultState(firstFieldInvalidMsg == null ? "" : firstFieldInvalidMsg.getValue());
+    }
+}

+ 94 - 0
src/main/java/com/lightinit/hsdataportal/controller/CaptchaController.java

@@ -0,0 +1,94 @@
+package com.lightinit.hsdataportal.controller;
+
+import com.google.code.kaptcha.Constants;
+import com.google.code.kaptcha.Producer;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.WriterException;
+import com.google.zxing.client.j2se.MatrixToImageWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.QRCodeWriter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.imageio.ImageIO;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+
+/**
+ * Created by Mr.Yao on 2017/4/11.
+ */
+@Controller
+@RequestMapping(value = "/captcha")
+public class CaptchaController {
+
+    @Autowired
+    private Producer captchaProducer;
+
+    @RequestMapping(value = "/image.action", method = RequestMethod.GET)
+    public ModelAndView getCaptchaImage(Model model, HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "timestamp", required = false) String timestamp) throws IOException {
+        if (StringUtils.isEmpty(timestamp)) {
+            model.addAttribute("timestamp", System.currentTimeMillis());
+        } else {
+            model.addAttribute("timestamp", timestamp);
+        }
+
+        response.setDateHeader("Expires", 0);
+        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
+        response.addHeader("Cache-Control", "post-check=0, pre-check=0");
+        response.setHeader("Pragma", "no-cache");
+        response.setContentType("image/jpeg");
+        String capText = captchaProducer.createText();
+
+        request.getSession().setAttribute(Constants.KAPTCHA_SESSION_KEY, capText);
+        BufferedImage bi = captchaProducer.createImage(capText);
+        ServletOutputStream out = response.getOutputStream();
+        ImageIO.write(bi, "jpg", out);
+        try {
+            out.flush();
+        } finally {
+            out.close();
+        }
+        return null;
+    }
+    @RequestMapping(value = "/qrcode.action", method = RequestMethod.GET)
+    public ModelAndView getQRCodeImage(Model model, HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "timestamp", required = false) String timestamp) throws IOException {
+        if (StringUtils.isEmpty(timestamp)) {
+            model.addAttribute("timestamp", System.currentTimeMillis());
+        } else {
+            model.addAttribute("timestamp", timestamp);
+        }
+
+        response.setDateHeader("Expires", 0);
+        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
+        response.addHeader("Cache-Control", "post-check=0, pre-check=0");
+        response.setHeader("Pragma", "no-cache");
+        response.setContentType("image/png");
+        String qrCodeText = captchaProducer.createText();
+        ServletOutputStream out = null;
+        QRCodeWriter writer=new QRCodeWriter();
+        int width=200;
+        int height=200;
+        BitMatrix m= null;
+        try {
+            out = response.getOutputStream();
+            m = writer.encode(qrCodeText, BarcodeFormat.QR_CODE, height,width);
+            MatrixToImageWriter.writeToStream(m, "png", out);
+            out.flush();
+        } catch (WriterException e) {
+            e.printStackTrace();
+        }finally {
+            if (out != null)
+                out.close();
+        }
+        return null;
+    }
+}

+ 30 - 0
src/main/java/com/lightinit/hsdataportal/controller/HomeController.java

@@ -0,0 +1,30 @@
+package com.lightinit.hsdataportal.controller;
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.SysContants;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Created by WangYao on 2017/6/6.
+ */
+@Controller
+@RequestMapping(value = {"/", "/home"})
+public class HomeController {
+
+    @RequestMapping(value = {"/", "index"})
+    public String index(ModelMap model, HttpServletRequest request) {
+        String redirectHomeUrl = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.REDIRECT_HOME_URL);
+        if (StringUtils.isEmpty(redirectHomeUrl)){
+            redirectHomeUrl = InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/open/";
+        }else {
+            redirectHomeUrl = InternalResourceViewResolver.REDIRECT_URL_PREFIX + redirectHomeUrl;
+        }
+        return redirectHomeUrl;
+    }
+}

+ 28 - 0
src/main/java/com/lightinit/hsdataportal/controller/LoginController.java

@@ -0,0 +1,28 @@
+package com.lightinit.hsdataportal.controller;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.SysContants;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+/**
+ * @author WangYao
+ * @date 2018/6/22 11:08
+ * @description 登录控制器
+ */
+@Controller
+public class LoginController {
+
+    @RequestMapping(value = "/login.htm")
+    public String login(){
+        String redirectLoginUrl = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.REDIRECT_LOGIN_URL);
+        if (StringUtils.isEmpty(redirectLoginUrl)){
+            redirectLoginUrl = InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/open/";
+        }else {
+            redirectLoginUrl = InternalResourceViewResolver.REDIRECT_URL_PREFIX + redirectLoginUrl;
+        }
+        return redirectLoginUrl;
+    }
+}

+ 178 - 0
src/main/java/com/lightinit/hsdataportal/controller/WXPayController.java

@@ -0,0 +1,178 @@
+package com.lightinit.hsdataportal.controller;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.common.BitMatrix;
+import com.lightinit.hsdataportal.WXsdk.*;
+import com.lightinit.hsdataportal.dictionary.DicPayResult;
+import com.lightinit.hsdataportal.dictionary.DicWXPayInfo;
+import com.lightinit.hsdataportal.entity.Order;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.service.IAlipayService;
+import com.lightinit.hsdataportal.service.IWXPayService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.math.BigDecimal;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
+
+import static com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage;
+
+@Controller
+@RequestMapping("/wxpay")
+public class WXPayController {
+
+    private static Logger logger = LoggerFactory.getLogger(WXPayController.class);
+
+    @Autowired
+    private IWXPayService wxPayService ;
+
+    @Autowired
+    private IAlipayService alipayService;
+
+    /**
+     * @return 支付
+     */
+//    @RequestMapping(value = "wxpay.htm")
+//    public ModelAndView register() {
+//        ModelAndView modelAndView = new ModelAndView("pay/wxpay");
+//        return  modelAndView;
+//    }
+
+    /**
+     * 调用预支付并生成订单
+     */
+    @RequestMapping("/orderPay.action/{orderNumber}")
+    @ResponseBody
+    public Map orderPay(HttpServletRequest request,@PathVariable String orderNumber,HttpServletResponse response) throws Exception {
+        Order order=wxPayService.queryUserOrderByOrderNumber(orderNumber);
+        WXPay wxPay = new WXPay(new MyPayConfig());
+        try {
+            //获取预支付token
+            Map<String, String> payParams = MyWXUtils.getPrepayid(orderNumber, order,MyWXUtils.getRemoteHost(request));
+            Map<String, String> result = wxPay.unifiedOrder(payParams);
+            logger.info("test = {}", result);
+            //获取二维码URL
+            String code_url = result.get("code_url");
+            //根据url生成二维码
+            MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
+            // 设置二维码参数
+            Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
+            hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
+            BitMatrix bitMatrix = multiFormatWriter.encode(code_url, BarcodeFormat.QR_CODE, 300, 300, hints);
+            BufferedImage image = toBufferedImage(bitMatrix);
+            //注意此处拿到字节数据
+            ByteArrayOutputStream os = new ByteArrayOutputStream();
+            ImageIO.write(image, "png", os);
+            byte[] bytes = os.toByteArray();
+            //Base64编码
+            String base64String = Base64.getEncoder().encodeToString(bytes);
+            //返回二维码
+//            MatrixToImageWriter.writeToStream(bitMatrix, "jpg", response.getOutputStream());
+            Map<String, String> resMap = new HashMap<>();
+            logger.info("test = {}", WXPayUtil.getCurrentTimestamp());
+            resMap.put("code", "000000");
+            resMap.put("qrcode", base64String);
+            return resMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+
+
+
+
+    /**
+     * 异步修改订单支付状态
+     */
+    @RequestMapping("/notify.action")
+    @ResponseBody
+    public String updateOrderState(HttpServletRequest request,
+                                   HttpServletResponse response) throws Exception {
+        String resXml = "";
+        logger.info("-------------------门户网站支付异步回调开始---------------------");
+        //取出通知参数
+        InputStream inputStream;
+        StringBuffer sb = new StringBuffer();
+        inputStream = request.getInputStream();
+        String s;
+        BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
+        while ((s = in.readLine()) != null) {
+            sb.append(s);
+        }
+        in.close();
+        inputStream.close();
+        logger.info("-----------xml返回:"+sb.toString()+"---------------");
+        Map<String, String> result = WXPayUtil.xmlToMap(sb.toString()) ;
+        logger.info("-----------获得map打印:"+result+"---------------");
+        if (result.get("result_code").toString().equalsIgnoreCase("SUCCESS")) {
+            String orderNumber = result.get("out_trade_no");
+            logger.info("-----------订单号:"+orderNumber+"---------------");
+            String sign = result.get("sign") ;
+            logger.info("-----------签名:"+sign+"---------------");
+            String totalFee = result.get("total_fee") ;
+            logger.info("-----------订单金额:"+totalFee+"---------------");
+            Order order=wxPayService.queryUserOrderByOrderNumber(orderNumber);
+            //验证签名
+            Boolean falg = WXPayUtil.isSignatureValid(result, DicWXPayInfo.KEY,WXPayConstants.SignType.HMACSHA256);
+            logger.info("falg={}", falg);
+            String title = order.getOrderAmount().multiply(BigDecimal.valueOf(100)).intValue() + "";
+            logger.info("-----------title:"+title+"---------------");
+            if (falg) {
+                logger.info("-----------签名验证通过!---------------");
+                if (title.equals(totalFee)){
+                    resXml = "SUCCESS";
+                    logger.info("-----------金额验证成功!---------------");
+                    logger.info("-----------进入修改订单状态!---------------");
+                    //修改数据库付款状态
+                    ResultState<String> resultState = alipayService.updateUserOderByOrderNumber(order.getId(),order.getOrderNumber());
+                    if(resultState.getStateCode()!=200){
+                        logger.error(resultState.getMsg());
+                    }
+                    logger.info("-----------成功修改订单状态!---------------");
+                }
+            }else {
+                logger.info("-----------修改订单状态时,签名验证未通过!---------------");
+                resXml = "FAIL";
+            }
+        }else {
+            resXml = "FAIL";
+        }
+        return resXml ;
+    }
+
+    /**
+     * 时刻查询订单状态
+     */
+    @RequestMapping("/selectFalgType.action/{orderNumber}")
+    @ResponseBody
+    public String selectFalgType(@PathVariable String orderNumber) {
+        Order order=wxPayService.queryUserOrderByOrderNumber(orderNumber);
+        return order.getOrderState();
+    }
+    @RequestMapping(value = "success.htm")
+    public ModelAndView success(){
+        ModelAndView modelAndView = new ModelAndView("open/pay/feedback") ;
+        return modelAndView ;
+    }
+}

+ 122 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/APIDemandOpenController.java

@@ -0,0 +1,122 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.controller.BaseController;
+import com.lightinit.hsdataportal.dictionary.DicActivityState;
+import com.lightinit.hsdataportal.dictionary.DicPlatformType;
+import com.lightinit.hsdataportal.dictionary.DicRqrmntSourceType;
+import com.lightinit.hsdataportal.dictionary.DicRqrmntType;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IAPIDemandService;
+import com.lightinit.hsdataportal.service.IMyMicroappRequirementService;
+import com.lightinit.hsdataportal.service.IRequirementMicroappService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.StringUtils;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import javax.validation.Valid;
+import java.util.Date;
+import java.util.List;
+
+@Controller
+@RequestMapping("/open/apiDemand")
+public class APIDemandOpenController extends BaseController{
+
+    @Autowired
+    private IAPIDemandService demandService ;
+
+    @Autowired
+    private IRequirementMicroappService requirementMicroappService;
+
+    @RequestMapping(value = "list.htm")
+    public ModelAndView openList(APIDemandOpenSearchModel demandOpenSearchModel, @RequestParam(defaultValue = "1") int pageNo){
+        ModelAndView modelAndView = new ModelAndView("open/apiDemand/list");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageSize(5);
+        pager.setPageNo(pageNo);
+        demandOpenSearchModel.setPage(pager);
+        demandOpenSearchModel.setPlatformType(DicPlatformType.OPEN);
+        demandOpenSearchModel.setRqrmntState(DicActivityState.ONGOING);
+        List<APIDemandOpenListModel> outputModel = demandService.queryOpenList(demandOpenSearchModel);
+        modelAndView.addObject("list", outputModel);
+        modelAndView.addObject("pager", demandService.queryOpenCount(demandOpenSearchModel));
+        modelAndView.addObject("newTime", new Date());
+        modelAndView.addObject("flag",demandOpenSearchModel.getFlag());
+        return modelAndView;
+    }
+    @RequiresAuthentication
+    @ResponseBody
+    @RequestMapping(value = "add.htm")
+    public ModelAndView openList(){
+        ModelAndView modelAndView = new ModelAndView("open/apiDemand/add");
+        return modelAndView;
+    }
+
+    @RequestMapping(value = "release.action")
+    @ResponseBody
+    public ResultState release(@Valid APIDdmandOpenReleaseModel  releaseModel, BindingResult bindingResult, HttpSession session){
+        if(bindingResult.hasErrors()){
+            return getAllFieldInvalidResultState(releaseModel, bindingResult);
+        }
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return demandService.release(releaseModel,loginUser.getId());
+    }
+
+
+    @RequestMapping(value = "view.action/{id}")
+    public ModelAndView openView(@PathVariable Long id, HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        int flag =0 ;
+        if (!StringUtils.isEmpty(loginUser)){
+            flag = demandService.isFollow(loginUser.getId(),id, DicPlatformType.OPEN) ;
+        }
+        ModelAndView modelAndView = new ModelAndView("open/apiDemand/view");
+        APIDemandOpenViewModel demandOpenViewModel = demandService.queryView(id);
+        modelAndView.addObject("demandOpenViewModel", demandOpenViewModel);
+        modelAndView.addObject("isFollow", flag);
+        modelAndView.addObject("isReceive", demandService.isReceive(id));
+        return modelAndView;
+    }
+
+
+    //关注
+    @RequestMapping(value = "follow.action")
+    @ResponseBody
+    public ResultState follow(Long id, HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return demandService.follow(id,loginUser.getId(), DicPlatformType.OPEN);
+    }
+
+    /**
+     * 接单
+     * @param inputModel
+     * @return
+     */
+    @RequestMapping(value = "receive.action/{id}")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState receive(HttpSession session,RequirementReceiveModel inputModel,@PathVariable Long id) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        inputModel.setRqrmntId(id);
+        inputModel.setReceivedBy(loginUser.getId());
+        ResultState   resultState = requirementMicroappService.receive(inputModel);
+        return resultState;
+    }
+
+    @RequestMapping(value="getMore.action")
+    public ModelAndView getMore(APIDemandOpenSearchModel searchModel,@RequestParam(defaultValue = "1") int pageNo){
+        ModelAndView modelAndView = new ModelAndView("open/data_requirement/more");
+        List<APIDemandOpenListModel> outputModel=demandService.getMore(searchModel,pageNo);
+        modelAndView.addObject("outputModel", outputModel);
+        return modelAndView;
+    }
+
+}

+ 109 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/APIOpenController.java

@@ -0,0 +1,109 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.SysContants;
+import com.lightinit.hsdataportal.dictionary.*;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IAPIservice;
+import com.lightinit.hsdataportal.service.IResourceCatelogService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+@Controller
+@RequestMapping("/open/api")
+public class APIOpenController {
+
+    @Autowired
+    private IAPIservice apiService ;
+
+    @Autowired
+    private IResourceCatelogService resourceCatelogService ;
+
+    @RequestMapping(value = "list.htm")
+    public String openList(APIOpenSearchModel apiOpenSearchModel, @RequestParam(defaultValue = "1") int pageNo,Model model){
+        apiOpenSearchModel.setNotOpenType(DicResourceOpenType.NOT_OPEN);
+        apiOpenSearchModel.setPublishState(DicPublishApiState.PUBLISH);
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageNo(pageNo);
+        apiOpenSearchModel.setPage(pager);
+        apiOpenSearchModel.setSortCategory(DicSortCategory.DEFAULT_SORT);
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        model.addAttribute("imageContextPath",imageContextPath) ;
+        List<APIOpenListModel> outputModel = apiService.queryOpenList(apiOpenSearchModel);
+        pager.setTotal(apiService.queryOpenCount(apiOpenSearchModel));
+        model.addAttribute("themes",resourceCatelogService.getResourceCatelogNameByType(DicResourceCatelogType.THEME,DicResourceType.API,DicPlatformType.OPEN)) ;
+        model.addAttribute("sectors",resourceCatelogService.getSectorNameList()) ;
+        model.addAttribute("chargeMethods",DicPublishSettingChargeMethod.getInstacne().getDicMap()) ;
+        model.addAttribute("lists", outputModel);
+        model.addAttribute("pager", pager);
+        List<APIServiceTypeModel> apiServiceTypeModels = apiService.getApiServiceTypes(DicGroupName.FUWUTYPE) ;
+        model.addAttribute("dicAPIServiceType", apiServiceTypeModels);
+        model.addAttribute("apiCount", apiService.queryOpenCount(apiOpenSearchModel));
+        model.addAttribute("searchModel", apiOpenSearchModel);
+        return "open/api/index";
+    }
+    @RequestMapping(value = "view.htm")
+    public String view( Long id,Long settingId,Model model,HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        int flag =0 ;
+        if (!StringUtils.isEmpty(loginUser)){
+            flag = apiService.isFollow(loginUser.getId(),settingId,DicPlatformType.OPEN) ;
+        }
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        model.addAttribute("imageContextPath",imageContextPath) ;
+        APIOpenViewModel outputModel = apiService.queryOpenView(id,settingId,DicPlatformType.OPEN);
+        model.addAttribute("apiOpenViewModel", outputModel);
+        model.addAttribute("isFollow",flag );
+        model.addAttribute("mianfei",DicPublishSettingChargeMethod.FREE) ;
+        return "open/api/view";
+    }
+
+    //关注
+    @RequestMapping(value = "follow.action")
+    @ResponseBody
+    public ResultState follow(Long settingId, HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return apiService.follow(settingId,loginUser.getId(), DicPlatformType.OPEN);
+    }
+
+    @RequestMapping(value = "offlineConference.action")
+    @ResponseBody
+    public ResultState offlineConference(APIOfflineConferenceModel offlineConferenceModel,HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return apiService.offlineConference(offlineConferenceModel,loginUser.getId());
+    }
+
+    @RequestMapping(value = "apply.action/{id}")
+    @ResponseBody
+    public ResultState apply(@PathVariable Long id,String applyReason,HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return apiService.apply(id,loginUser.getId(),DicPlatformType.OPEN,applyReason);
+    }
+
+    @RequestMapping(value = "isApply.action/{id}")
+    @ResponseBody
+    public boolean isApply(@PathVariable Long id,String applyReason,HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return apiService.isApply(id,loginUser.getId(),DicPlatformType.OPEN,applyReason);
+    }
+
+    @RequestMapping(value = "isPay.action/{id}")
+    @ResponseBody
+    public ResultState isPay(@PathVariable Long id,HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return apiService.isPay(id,loginUser.getId(),DicPlatformType.OPEN);
+    }
+}

+ 359 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/AccountController.java

@@ -0,0 +1,359 @@
+package com.lightinit.hsdataportal.controller.open;
+import com.google.code.kaptcha.Constants;
+import com.lightinit.hsdataportal.common.*;
+import com.lightinit.hsdataportal.controller.BaseController;
+import com.lightinit.hsdataportal.dictionary.DicCodeType;
+import com.lightinit.hsdataportal.entity.UserSecurityCode;
+import com.lightinit.hsdataportal.entity.UserSecurityCodeExample;
+import com.lightinit.hsdataportal.model.LoginUser;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.model.ResultStateCode;
+import com.lightinit.hsdataportal.model.ShareRegisterModel;
+import com.lightinit.hsdataportal.service.IUserService;
+import com.lightinit.hsdataportal.service.open.IAccountService;
+import com.lightinit.hsdataportal.spring.UsernamePasswordUserTypeToken;
+import net.sf.json.JSONObject;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.authc.*;
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.web.util.SavedRequest;
+import org.apache.shiro.web.util.WebUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * Created by WangYao on 2018/6/7.
+ */
+@Controller
+@RequestMapping(value = "/open/account")
+public class AccountController extends BaseController {
+
+    @Value("${msgs.server.url}")
+    private String msgsServer;
+
+    @Value("${devops.server.url}")
+    private String devopsServer;
+
+    @Autowired
+    private IAccountService accountService;
+    @Autowired
+    private IUserService userService;
+
+    @RequestMapping(value = "login.htm")
+    public String login(ModelMap model, HttpServletRequest request) {
+        return "open/account/login";
+    }
+
+    @RequestMapping(value = "login.action")
+    public String doLogin(Model model, HttpSession session, HttpServletRequest request, @RequestParam String username, @RequestParam String password, @RequestParam String captcha) {
+        ResultState resultState = new ResultState();
+        model.addAttribute("resultState", resultState);
+        String capText=session.getAttribute(Constants.KAPTCHA_SESSION_KEY)!=null?session.getAttribute(Constants.KAPTCHA_SESSION_KEY).toString():"";
+        if(StringUtils.isEmpty(capText) || StringUtils.isEmpty(captcha)){
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("验证码不能为空");
+            return "open/account/login";
+        }else if (capText.equalsIgnoreCase(captcha)==false){
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("验证码不正确");
+            return "open/account/login";
+        }
+        if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)){
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("用户名和密码不能为空");
+            return "open/account/login";
+        }
+        UsernamePasswordUserTypeToken token = new UsernamePasswordUserTypeToken(username, password, "user");
+        Subject currentUser = SecurityUtils.getSubject();
+        //token.setRememberMe(true);
+        try {
+            //在调用了login方法后,SecurityManager会收到AuthenticationToken,并将其发送给已配置的Realm执行必须的认证检查
+            currentUser.login(token);
+            if (currentUser.isAuthenticated()) {
+                session.setAttribute("userinfo", username);
+                session.setAttribute(LoginUser.SESSION_KEY_LOGIN_USER, accountService.getLoginUserByUsername(username));
+            } else {
+                token.clear();
+            }
+        } catch (UnknownAccountException uae) {
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("用户名不存在");
+            token.clear();
+        } catch (IncorrectCredentialsException ice) {
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("用户名或密码错误");
+            token.clear();
+        } catch (LockedAccountException lae) {
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("用户被锁定");
+            token.clear();
+        } catch (ExcessiveAttemptsException eae) {
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("尝试次数过多");
+            token.clear();
+        } catch (AuthenticationException ae) {
+            //通过处理Shiro的运行时AuthenticationException就可以控制用户登录失败或密码错误时的情景
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("用户名或密码错误");
+        }
+
+        if (resultState.getStateCode() == ResultStateCode.SUCCESS){
+            SavedRequest savedRequest = WebUtils.getSavedRequest(request);
+            if (savedRequest != null){
+                String returnUrl = WebUtils.getSavedRequest(request).getRequestUrl();
+                if (StringUtils.isNotEmpty(returnUrl)){
+                    return InternalResourceViewResolver.REDIRECT_URL_PREFIX + returnUrl;
+                }
+            }
+            return InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/";
+        }
+        return "open/account/login";
+    }
+
+    @RequestMapping(value = "logout.action")
+    public String logout(ModelMap model, HttpSession session){
+        Subject currentUser = SecurityUtils.getSubject();
+        try {
+            currentUser.logout();
+            session.invalidate();
+        } catch (Exception e) {
+        }
+        return InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/";
+    }
+
+    @RequestMapping(value = "register.htm")
+    public String register(ModelMap model, HttpServletRequest request) {
+        return "open/account/register";
+    }
+
+
+    @RequestMapping(value = "register.action")
+    @ResponseBody
+    public ResultState register(ShareRegisterModel shareRegisterModel){
+        if (StringUtils.isEmpty(shareRegisterModel.getUsername()) || StringUtils.isEmpty(shareRegisterModel.getPassword()) || StringUtils.isEmpty(shareRegisterModel.getPassword1())){
+            return buildInvalidResultState("用户名、密码不能为空");
+        }
+        if(!shareRegisterModel.getUsername().matches("^[a-z0-9]+$")){
+            return buildInvalidResultState("用户名只能由小写字母和数字组成");
+        }
+        if(shareRegisterModel.getUsername().length()>30){
+            return buildInvalidResultState("用户名最大长度30个字母");
+        }
+        ResultState resultState = accountService.register(shareRegisterModel);
+        if(resultState.getStateCode()!=200){
+            return resultState;
+        }
+
+        //同步服务开发环境和微服务管控平台
+        ExecutorService executorService = Executors.newCachedThreadPool();
+        executorService.execute(new Runnable() {
+            @Override
+            public void run() {
+                //1.----->同步到管控平台
+                //获取token
+                String token = TokenUtils.getToken();
+                //请求头
+                if(token!=null){
+                    HashMap<String, String> authheaderMap = new HashMap<>();
+                    authheaderMap.put("content-type","application/json");
+                    authheaderMap.put("Authorization","Bearer "+token);
+                    String passMessage = HttpUtil.httpPost(msgsServer + TokenUtils.MsgsServer.USERPATH, authheaderMap, JSONObject.fromObject(shareRegisterModel).toString());
+                }
+
+                //2.------>同步到服务开发环境平台
+                //为服务开发环境平台同步添加必要属性
+                JSONObject group = JSONObject.fromObject(new Object());
+                group.accumulate("groupName","group-"+shareRegisterModel.getUsername());
+                group.accumulate("groupDesc","desc-"+shareRegisterModel.getUsername());
+                group.accumulate("gitLabId",1);
+                group.accumulate("jenkinsId",1);
+                group.accumulate("harborId",1);
+                group.accumulate("managerId",0);
+                group.accumulate("status",1);
+                //新建租户并获取id
+                //json请求头
+                HashMap<String, String> jsonHeaderMap = new HashMap<>();
+                jsonHeaderMap.put("content-type","application/json");
+                String  message= HttpUtil.httpPost(devopsServer+TokenUtils.DevopsServer.GROUPPATH, jsonHeaderMap, group.toString());
+                //从返回的message中获取需要的id
+                JSONObject groupJson = JSONObject.fromObject(message);
+                if(groupJson.get("message")!=null && StringUtils.isNotEmpty(groupJson.get("message").toString()) && "success".equals(groupJson.get("message").toString()) ){
+                    long id = Long.parseLong(JSONObject.fromObject(groupJson.get("data")).get("id").toString());
+                    //为开发平台同步添加必要的属性
+                    JSONObject user = JSONObject.fromObject(new Object());
+                    user.accumulate("userCode",shareRegisterModel.getUsername());
+                    user.accumulate("userName",shareRegisterModel.getUsername());
+                    String encrypt=null;
+                    try{
+                        RSAUtils.loadKeyPair();
+                        encrypt= RSAUtils.encrypt("testone1");//固定不变。鬼知道为啥,不然同步不过去
+                    }catch(Exception e){
+                        e.printStackTrace();
+                    }
+                    user.accumulate("userPass",encrypt);
+                    user.accumulate("groupId",id);
+                    user.accumulate("isValid",1);
+                    HashMap<String, String> map = new HashMap<>();
+                    map.put("content-type","application/json");
+                    String  userMessage= HttpUtil.httpPost(devopsServer+TokenUtils.DevopsServer.USERPATH,jsonHeaderMap,user.toString());
+                    //将pass平台注册的用户id和本地用户id插入到userAuthSetting表中
+                    JSONObject userJson = JSONObject.fromObject(userMessage);
+                    if(userJson.get("message")!=null && StringUtils.isNotEmpty(userJson.get("message").toString()) && "success".equals(userJson.get("message").toString())){
+                        Long passUserId  = Long.parseLong(JSONObject.fromObject(userJson.get("data")).get("id").toString());
+                        ResultState rs = accountService.insertUserAuthSetting(Long.parseLong(resultState.getData().toString()), passUserId);
+                    }else{
+                        ResultState rs = accountService.insertUserAuthSetting(Long.parseLong(resultState.getData().toString()), null);
+                    }
+                }else{
+                    ResultState rs = accountService.insertUserAuthSetting(Long.parseLong(resultState.getData().toString()), null);
+                }
+                executorService.shutdownNow();
+            }
+        });
+        return resultState ;
+    }
+
+    /**
+     * @return 验证码
+     */
+    @RequestMapping(value = "validatePhone.action")
+    @ResponseBody
+    public ResultState validatePhone(String phone) {
+        return  accountService.validatePhone(phone);
+    }
+
+    /**
+     * @return 判断验证码是否正确
+     */
+    @RequestMapping(value = "isCode.action")
+    @ResponseBody
+    public ResultState isCode(String phone,String code) {
+        return  accountService.isCode(phone,code);
+    }
+
+    /**
+     * @return 判断是否显示
+     */
+    @RequestMapping(value = "isSecurityCode.action")
+    @ResponseBody
+    public boolean isSecurityCode() {
+        return  accountService.isSecurityCode();
+    }
+
+    /*
+    *@Description 忘记密码首页
+    *@Param
+    *@Date 2019/4/8
+    *@return
+    **/
+    @RequestMapping(value= "forgetPassword.htm")
+    public ModelAndView forgetPasswordIndex(){
+        ModelAndView modelAndView =new ModelAndView("open/account/forgetPassword");
+        return modelAndView;
+    }
+
+    /*
+    *@Description 忘记密码
+    *@Param
+    *@Date 2019/4/8
+    *@return
+    **/
+    @RequestMapping(value= "forgetPassword.action")
+    @ResponseBody
+    public ResultState forgetPassword( HttpSession session, HttpServletRequest request, @RequestParam String username, @RequestParam String password1,@RequestParam String password2, @RequestParam String captcha,@RequestParam String code){
+        LinkedHashMap<Object, Object> errorMap = new LinkedHashMap<>();
+        ResultState resultState = new ResultState();
+        String capText=session.getAttribute(Constants.KAPTCHA_SESSION_KEY)!=null?session.getAttribute(Constants.KAPTCHA_SESSION_KEY).toString():"";
+        if(StringUtils.isEmpty(capText) || StringUtils.isEmpty(captcha)) {
+            errorMap.put("captcha","验证码不能为空");
+            return buildInvalidResultState("",errorMap);
+        }else if(!capText.equals(captcha)){
+            errorMap.put("captcha","验证码不正确");
+            return buildInvalidResultState("",errorMap);
+        }else if(StringUtils.isEmpty(code) || !code.equals(session.getAttribute("code"))){
+            errorMap.put("code","手机验证码不正确");
+            return buildInvalidResultState("",errorMap);
+        }else if(((Long)session.getAttribute("codeExpire")+1000*60*5) > new Date().getTime()){
+            errorMap.put("code","手机验证码过期");
+            return buildInvalidResultState("",errorMap);
+        }else if(StringUtils.isEmpty(username)){
+            errorMap.put("username","用户名不能为空");
+            return buildInvalidResultState("",errorMap);
+        } else if(StringUtils.isEmpty(password1) || StringUtils.isEmpty(password2)){
+            errorMap.put("password1","密码不能为空");
+            return buildInvalidResultState("",errorMap);
+        }else if(password1.length()>9){
+            errorMap.put("password1","密码长度不能超过9位");
+            return buildInvalidResultState("",errorMap);
+        }else if(!password1.equals(password2)){
+            errorMap.put("password2","两次密码不相同");
+            return buildInvalidResultState("",errorMap);
+        }
+        session.removeAttribute("codeExpire");
+        session.removeAttribute("code");
+        //修改密码
+        resultState=userService.forgetPassword(username,password1);
+        if(resultState.getStateCode()!=200){
+            resultState.setMsg("修改密码失败");
+            return resultState;
+        }
+        resultState.setStateCode(ResultStateCode.SUCCESS);
+        resultState.setMsg("修改密码成功");
+        return resultState;
+    }
+
+    /*
+     *@Description 忘记密码--发送到注册手机“验证码“
+     *@Param
+     *@Date 2019/4/8
+     *@return
+     **/
+    @RequestMapping(value= "getForgetPasswordCode.action")
+    @ResponseBody
+    public ResultState getForgetPasswordCode(String username,String captcha,HttpSession session){
+        String capText=session.getAttribute(Constants.KAPTCHA_SESSION_KEY)!=null?session.getAttribute(Constants.KAPTCHA_SESSION_KEY).toString():"";
+        ResultState resultState = new ResultState();
+        String phone=userService.getForgetPasswordCode(username);
+        if(StringUtils.isEmpty(phone)){
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("用户名不存在,请先注册");
+            return resultState;
+        } else if(StringUtils.isEmpty(capText) || StringUtils.isEmpty(captcha) || !capText.equals(captcha)) {
+            resultState.setStateCode(ResultStateCode.INVALID_DATA);
+            resultState.setMsg("验证码不正确,请重新输入");
+            return resultState;
+        }
+        //发送短信到手机
+        Map<String, Object> map = PhoneSendUtils.send(phone);
+        if (map!=null){
+            if (map.get("Message").equals("OK")&&map.get("Code").equals("OK")){
+                String code = (String) map.get("returnCode") ;
+                session.setAttribute("code",code);
+                session.setAttribute("codeExpire",new Date().getTime());
+            }else {
+                resultState.setStateCode(ResultStateCode.UNAUTHORIZED);
+                resultState.setMsg("获取短信验证码异常!");
+                return resultState;
+            }
+        }else {
+            resultState.setStateCode(ResultStateCode.UNAUTHORIZED);
+            resultState.setMsg("获取短信验证码异常!");
+            return resultState;
+        }
+        resultState.setMsg("验证码发送到注册手机号中,请查收");
+        return resultState;
+    }
+}

+ 243 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/AliPayController.java

@@ -0,0 +1,243 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.internal.util.AlipaySignature;
+import com.alipay.api.request.AlipayTradePagePayRequest;
+import com.lightinit.hsdataportal.common.AlipayConfig;
+import com.lightinit.hsdataportal.dictionary.DicOrderState;
+import com.lightinit.hsdataportal.entity.Order;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.service.IAlipayService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @Author: sunxiang
+ * @Date: 2018/10/27 0:14
+ * @Description:
+ **/
+@Controller
+@RequestMapping(value = "/alipay/")
+public class AliPayController {
+
+    public static final Logger logger= LoggerFactory.getLogger(AlipayConfig.class);
+    @Value("${alipay.url}")
+    private String url;
+    @Value("${alipay.app_id}")
+    private String app_id;
+    @Value("${alipay.app_private_key}")
+    private  String app_private_key;
+    @Value("${alipay.alipay_public_key}")
+    private String alipay_public_key;
+    @Value("${alipay.format}")
+    private String format;
+    @Value("${alipay.charset}")
+    private String charset;
+    @Value("${alipay.sign_type}")
+    private String sign_type;
+    @Autowired
+    private IAlipayService alipayService;
+
+    //获取默认支付对象
+    private DefaultAlipayClient getInstance(){
+        return new DefaultAlipayClient(url, app_id, app_private_key, format, charset, alipay_public_key, sign_type);
+    }
+
+    @RequestMapping(value="index.htm/{orderNumber}/{orderAmount}")
+    public String index(@PathVariable String orderNumber,@PathVariable BigDecimal orderAmount){
+        return "open/pay/userPay";
+    }
+    /*
+    *@Description 用户下订单,付款
+    *@Param     orderNumber:订单号
+    *@Date 2018/10/27
+    *@return
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value="/pay.action/{orderNumber}")
+    public  void tradePage(HttpServletRequest httpRequest,HttpServletResponse httpResponse,@PathVariable String orderNumber) throws AlipayApiException, IOException {
+        Order order=alipayService.queryUserOrderByOrderNumber(orderNumber);
+        if(order==null){//订单号不存在
+            return;
+        }
+        //设置请求参数   必填:商户订单号,付款金额,订单名称,销售产品码 || 可选:商品描述
+        AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
+        String basePath = httpRequest.getScheme()+"://"+httpRequest.getServerName();
+        if(httpRequest.getServerPort()>0){
+            basePath=basePath+":"+httpRequest.getServerPort();
+        }
+        alipayRequest.setReturnUrl(basePath+"/alipay/success.action");
+        alipayRequest.setNotifyUrl(basePath+"/alipay/notice.action");
+
+        String message="{\"out_trade_no\":\""+ order.getOrderNumber() +"\","
+                + "\"total_amount\":\""+ order.getOrderAmount().toString() +"\","
+                + "\"subject\":\""+ "支付费用" +"\","
+                + "\"body\":\""+ order.getRemark() +"\","
+                + "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}";
+        alipayRequest.setBizContent(message);
+        //请求
+        String form = AlipayConfig.getInstance().pageExecute(alipayRequest).getBody();
+        //输出
+        httpResponse.setContentType("text/html;charset=" + AlipayConfig.CHARSET);
+        httpResponse.getWriter().write(form);//直接将完整的表单html输出到页面
+        httpResponse.getWriter().flush();
+        httpResponse.getWriter().close();
+    }
+
+    /*
+    *@Description 支付宝返回同步参数,可以返回自己网站的页面
+    *@Param
+    *@Date 2018/10/27
+    *@return
+    **/
+    @RequestMapping(value="/success.action",method = RequestMethod.GET)
+    public ModelAndView successPage(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws AlipayApiException, IOException {
+        //获取支付宝GET过来反馈信息
+        Map<String,String> params = new HashMap<String,String>();
+        Map<String,String[]> httpRequestParams = httpRequest.getParameterMap();
+        for (Iterator<String> iter = httpRequestParams.keySet().iterator(); iter.hasNext();) {
+            String name = (String) iter.next();
+            String[] values = (String[]) httpRequestParams.get(name);
+            String valueStr = "";
+            for (int i = 0; i < values.length; i++) {
+                valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ",";
+            }
+            //乱码解决,这段代码在出现乱码时使用
+            // valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
+            params.put(name, valueStr);
+        }
+        //调用SDK验证签名
+        boolean signVerified = AlipaySignature.rsaCheckV1(params, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.CHARSET, AlipayConfig.SIGN_TYPE);
+        ModelAndView modelAndView = new ModelAndView("open/pay/feedback");//支付完跳转的页面
+        if(signVerified) {
+            //商户订单号
+            String orderNumber = new String(httpRequest.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
+            modelAndView.addObject("message","支付成功:"+orderNumber);
+            //TODO:暂时修改同步问题为同步改变状态,以后需要删除此代码:
+            Order order = alipayService.queryUserOrderByOrderNumber(orderNumber);
+            ResultState<String> resultState = alipayService.updateUserOderByOrderNumber(order.getId(),order.getOrderNumber());
+            if(resultState.getStateCode()!=200){
+                logger.error(resultState.getMsg());
+            }
+        }else {
+            modelAndView.addObject("message","验签失败,交易错误,请联系商家");
+        }
+       return modelAndView;
+    }
+
+    /*
+    *@Description 支付宝异步通知交易完成情况通知
+    *@Param
+    *@Date 2018/10/27
+    *@return
+    **/
+    @RequestMapping(value="/notice.action",method = RequestMethod.POST)
+    public void tradeNotice(HttpServletRequest httpRequest,HttpServletResponse httpResponse) throws AlipayApiException, IOException {
+        System.out.println("j---------------接受到异步请求----------------------------------");
+        //获取支付宝POST过来反馈信息
+        Map<String,String> params = new HashMap<String,String>();
+        Map<String,String[]> requestParams = httpRequest.getParameterMap();
+        for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext();) {
+            String name = (String) iter.next();
+            String[] values = (String[]) requestParams.get(name);
+            String valueStr = "";
+            for (int i = 0; i < values.length; i++) {
+                valueStr = (i == values.length - 1) ? valueStr + values[i]
+                        : valueStr + values[i] + ",";
+            }
+            //乱码解决,这段代码在出现乱码时使用
+            //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
+            params.put(name, valueStr);
+        }
+        //调用SDK验证签名
+        boolean signVerified = AlipaySignature.rsaCheckV1(params, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.CHARSET, AlipayConfig.SIGN_TYPE);
+        if(signVerified) {
+            //商户订单号
+            String out_trade_no = new String(httpRequest.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");
+            //支付宝交易号
+            String trade_no = new String(httpRequest.getParameter("trade_no").getBytes("ISO-8859-1"), "UTF-8");
+            //订单的实际金额
+            String total_amount = new String(httpRequest.getParameter("total_amount").getBytes("ISO-8859-1"), "UTF-8");
+            // 订单的app_id
+            String app_id = new String(httpRequest.getParameter("app_id").getBytes("ISO-8859-1"), "UTF-8");
+            //交易状态
+            String trade_status = new String(httpRequest.getParameter("trade_status").getBytes("ISO-8859-1"), "UTF-8");
+            //根据订单号查询数据库
+            Order order = alipayService.queryUserOrderByOrderNumber(out_trade_no);
+            //1、需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号
+            //2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
+            //3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email)
+            //4、验证app_id是否为该商户本身。
+            if (order != null && out_trade_no.equals(order.getOrderNumber()) && total_amount.equals(order.getOrderAmount().toString())
+                    && app_id.equals(AlipayConfig.APP_ID) && !DicOrderState.PAY_SUCCESS.equals(order.getOrderState())) {
+                if (trade_status.equals("TRADE_FINISHED")) {
+                    //判断该笔订单是否在商户网站中已经做过处理
+                    logger.info("订单:" + out_trade_no + "已经支付过或已过退款时间");
+                    //退款日期超过可退款期限后(如三个月可退款),支付宝系统发送该交易状态通知
+                } else if (trade_status.equals("TRADE_SUCCESS")) {
+                    //修改数据库付款状态
+                    ResultState<String> resultState = alipayService.updateUserOderByOrderNumber(order.getId(),order.getOrderNumber());
+                    if(resultState.getStateCode()!=200){
+                        logger.error(resultState.getMsg());
+                    }
+                   /* ResultState<String> paymentResultState = alipayService.insertBizOrderPayment(order, resultState.getStateCode());
+                    if(paymentResultState.getStateCode()!=200){
+                        logger.error(resultState.getMsg());
+                    }*/
+                }
+            }
+            //必须写出"success",不然支付宝会轮询发送状态
+            httpResponse.getWriter().println("success");
+            httpResponse.getWriter().flush();
+            httpResponse.getWriter().close();
+            return;
+        }
+        //验证失败
+        String fail_out_trade_no=new String(httpRequest.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");;
+        //调试用,写文本函数记录程序运行情况是否正常
+        String sWord = AlipaySignature.getSignCheckContentV1(params);
+        AlipayConfig.logResult(sWord);
+        logger.info("验证失败:订单号:"+fail_out_trade_no);
+        httpResponse.getWriter().println("fail");
+    }
+
+    /*
+    *@Description 查询支付情况 暂时不开通此功能
+    *@Param
+    *@Date 2018/10/27
+    *@return
+    **/
+   /* @RequestMapping(value="/querynotice")
+    public void queryNotice(HttpServletRequest httpRequest,HttpServletResponse httpResponse) throws AlipayApiException, IOException {
+        AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
+        request.setBizContent("{" +
+                "\"out_trade_no\":\"8\"," +
+                "\"trade_no\":\"2018102722001448580500455544\"" +
+                "  }");
+        AlipayTradeQueryResponse response = AlipayConfig.getInstance().execute(request);
+        if(response.isSuccess()){
+            System.out.println("调用成功");
+        } else {
+            System.out.println("调用失败");
+        }
+    }*/
+
+}

+ 49 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/BalancePAyController.java

@@ -0,0 +1,49 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.entity.Order;
+import com.lightinit.hsdataportal.entity.UserAccount;
+import com.lightinit.hsdataportal.model.LoginUser;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.model.ResultStateCode;
+import com.lightinit.hsdataportal.service.IBalancePAyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.math.BigDecimal;
+
+@Controller
+@RequestMapping(value = "/open/balancePAy")
+public class BalancePAyController {
+    @Autowired
+    private IBalancePAyService balancePAyService;
+
+    @RequestMapping(value = "balancePAy.action/{orderNumber}")
+    @ResponseBody
+    public ResultState balancePAy(HttpSession session,@PathVariable String orderNumber ) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        //查询用户账户余额
+        UserAccount useraccount = balancePAyService.selectBalance(loginUser.getId());
+        //查询支付余额
+        Order order = balancePAyService.selectBalance(orderNumber);
+        ResultState resultState =new ResultState();
+        if(useraccount!=null) {
+            if(useraccount.getBalance().compareTo(order.getOrderAmount())>0) {
+                 resultState =  balancePAyService.updateBalance(loginUser.getId(),order.getOrderAmount(),useraccount.getBalance(),order.getId());
+            }else {
+                resultState.setStateCode(ResultStateCode.INVALID_DATA);
+                resultState.setMsg("余额不足");
+            }
+        }
+        return resultState;
+    }
+    @RequestMapping(value = "toSuccess.htm")
+    public ModelAndView toSuccess() {
+        ModelAndView modelAndView = new ModelAndView("open/pay/feedback");
+        return  modelAndView;
+    }
+}

+ 142 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/BusinessIncubationController.java

@@ -0,0 +1,142 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.GuidGenerator;
+import com.lightinit.hsdataportal.common.SysContants;
+import com.lightinit.hsdataportal.common.UploadFileUtils;
+import com.lightinit.hsdataportal.dictionary.DicRoadShowStage;
+import com.lightinit.hsdataportal.dictionary.DicRoadShowTrade;
+import com.lightinit.hsdataportal.entity.*;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.model.ResultStateCode;
+import com.lightinit.hsdataportal.model.RoadShowSearchModel;
+import com.lightinit.hsdataportal.model.RoadshowAddModel;
+import com.lightinit.hsdataportal.service.IBusinessIncubationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.validation.Valid;
+import java.io.File;
+import java.util.List;
+
+import static com.lightinit.hsdataportal.controller.BaseController.buildInvalidResultState;
+import static com.lightinit.hsdataportal.controller.BaseController.getAllFieldInvalidResultState;
+
+@Controller
+@RequestMapping("/open/roadShow")
+public class BusinessIncubationController {
+    @Autowired
+    private IBusinessIncubationService iBusinessIncubationService;
+
+    @RequestMapping("/index.htm")
+    public ModelAndView index(RoadShowSearchModel roadShowSearchModel,@RequestParam(defaultValue = "1") int pageNo) {
+        ModelAndView modelAndView = new ModelAndView("open/roadShow/roadShowlist");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageSize(6);
+        pager.setPageNo(pageNo);
+        roadShowSearchModel.setPage(pager);
+        List<RoadshowWithBLOBs> list = iBusinessIncubationService.getList(roadShowSearchModel);
+        pager.setTotal(iBusinessIncubationService.getCount(roadShowSearchModel));
+        modelAndView.addObject("list",list);
+        modelAndView.addObject("pager",pager);
+        modelAndView.addObject("searchModel", roadShowSearchModel);
+        modelAndView.addObject("roadShowStage", DicRoadShowStage.getInstacne().getDicMap());
+        modelAndView.addObject("roadShowTrade", DicRoadShowTrade.getInstacne().getDicMap());
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        modelAndView.addObject("imageContextPath", imageContextPath);
+        return modelAndView;
+    }
+
+    @RequestMapping(value = "/more.action")
+    public ModelAndView more(RoadShowSearchModel roadShowSearchModel,@RequestParam(defaultValue = "1") int pageNo) {
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageSize(6);
+        pager.setPageNo(pageNo);
+        roadShowSearchModel.setPage(pager);
+        ModelAndView modelAndView = new ModelAndView("open/roadShow/more");
+        List<RoadshowWithBLOBs> list =  iBusinessIncubationService.getList(roadShowSearchModel);
+        modelAndView.addObject("list", list);
+        return modelAndView;
+    }
+    @RequestMapping(value = "/add.htm")
+    public ModelAndView add() {
+        ModelAndView modelAndView = new ModelAndView("open/roadShow/addRoadShow");
+        modelAndView.addObject("roadShowStage", DicRoadShowStage.getInstacne().getDicMap());
+        modelAndView.addObject("roadShowTrade", DicRoadShowTrade.getInstacne().getDicMap());
+        return modelAndView;
+    }
+    @RequestMapping(value = "/toAdd.action")
+    @ResponseBody
+    public ResultState toAdd(@Valid RoadshowAddModel roadshowAddModel, BindingResult bindingResult, MultipartFile fileImg, MultipartFile file1, MultipartFile file2, MultipartFile file3, MultipartFile file4) {
+        if (bindingResult.hasErrors()){
+            return getAllFieldInvalidResultState(roadshowAddModel, bindingResult);
+        }
+        String uniqueDir = GuidGenerator.generate() + File.separator;
+        String dataFileDir = UploadFileUtils.buildRelativeDir(SysContants.UploadFilePath.ACTIVITY_ROOT_DIR, uniqueDir, SysContants.UploadFilePath.ACTIVITY_IMG_DIR);
+        if (fileImg != null && !fileImg.isEmpty()){
+            if (UploadFileUtils.writeUploadFile(fileImg, dataFileDir, SysContants.PropertyKey.UPLOAD_IMAGE_ROOT_DIR)){
+                roadshowAddModel.setThumbnail(dataFileDir + fileImg.getOriginalFilename());
+            }else {
+                return buildInvalidResultState(ResultStateCode.INVALID_DATA, "资源图片保存失败");
+            }
+        }
+        String uniqueDir1 = GuidGenerator.generate() + File.separator;
+        String dataFileDir1 = UploadFileUtils.buildRelativeDir(SysContants.UploadFilePath.ROADSHOW_ROOT_DIR, uniqueDir, SysContants.UploadFilePath.ACTIVITY_IMG_DIR);
+        if (file1 != null && !file1.isEmpty()) {
+            if (UploadFileUtils.writeUploadFile(file1, dataFileDir1, SysContants.PropertyKey.UPLOAD_IMAGE_ROOT_DIR)) {
+                roadshowAddModel.setMaterial1(dataFileDir1 + file1.getOriginalFilename());
+            } else {
+                return buildInvalidResultState(ResultStateCode.INVALID_DATA, "资源图片保存失败");
+            }
+        }
+        if (file2 != null && !file2.isEmpty()) {
+            if (UploadFileUtils.writeUploadFile(file2, dataFileDir1, SysContants.PropertyKey.UPLOAD_IMAGE_ROOT_DIR)) {
+                roadshowAddModel.setMaterial2(dataFileDir1 + file2.getOriginalFilename());
+            } else {
+                return buildInvalidResultState(ResultStateCode.INVALID_DATA, "资源图片保存失败");
+            }
+        }
+        if (file3 != null && !file3.isEmpty()) {
+            if (UploadFileUtils.writeUploadFile(file3, dataFileDir, SysContants.PropertyKey.UPLOAD_IMAGE_ROOT_DIR)) {
+                roadshowAddModel.setMaterial3(dataFileDir1 + file3.getOriginalFilename());
+            } else {
+                return buildInvalidResultState(ResultStateCode.INVALID_DATA, "资源图片保存失败");
+            }
+        }
+        if (file4 != null && !file4.isEmpty()) {
+            if (UploadFileUtils.writeUploadFile(file4, dataFileDir1, SysContants.PropertyKey.UPLOAD_IMAGE_ROOT_DIR)) {
+                roadshowAddModel.setMaterial4(dataFileDir1 + file4.getOriginalFilename());
+            } else {
+                return buildInvalidResultState(ResultStateCode.INVALID_DATA, "资源图片保存失败");
+            }
+        }
+        ResultState resultState =  iBusinessIncubationService.toAdd(roadshowAddModel);
+        return resultState;
+    }
+    @RequestMapping("/view.htm/{id}")
+    public ModelAndView view(@PathVariable Long id) {
+        ModelAndView modelAndView = new ModelAndView("open/roadShow/view");
+        RoadshowWithBLOBs roadshow = iBusinessIncubationService.view(id);
+        modelAndView.addObject("model",roadshow);
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        modelAndView.addObject("imageContextPath", imageContextPath);
+        return modelAndView;
+    }
+    @RequestMapping("/toLxwm.action")
+    @ResponseBody
+    public ResultState toLxwm( @Valid RoadshowRequirementWithBLOBs roadshowRequirement, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()){
+            return getAllFieldInvalidResultState(roadshowRequirement, bindingResult);
+        }
+        ResultState resultState = iBusinessIncubationService.toLxwm(roadshowRequirement);
+        return resultState;
+    }
+
+}

+ 299 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/DataOpenController.java

@@ -0,0 +1,299 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.SysContants;
+import com.lightinit.hsdataportal.controller.BaseController;
+import com.lightinit.hsdataportal.dictionary.*;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.impl.MyDataServiceImpl;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.*;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.*;
+import java.util.List;
+
+/**
+ * @Author: sunxiang
+ * @Date: 2018/6/9 16:47
+ * @Description:
+ **/
+@Controller
+@RequestMapping(value = "/open/data")
+public class DataOpenController extends BaseController{
+
+    @Autowired
+    private IOderService oderService;
+    @Autowired
+    private IResourceAuthService resourceAuthService;
+    @Autowired
+    private IDataService dataService;
+    @Autowired
+    private IResourceCatelogService resourceCatelogService ;
+    @Autowired
+    private IMyDataService myDataService;
+    /*
+    *@Description 数据查看首页
+    *@Param catelogName:分类/机构;  openType:开放类型
+    *@Date 2018/6/9
+    *@return
+    **/
+    @RequestMapping(value="index.htm")
+    public ModelAndView  getDataIndex(DataSearchModel inputModel,@RequestParam(defaultValue = "1") int pageNo){
+        ModelAndView modelAndView = new ModelAndView("open/data/index");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageNo(pageNo);
+        inputModel.setPage(pager);
+        inputModel.setSortCategory(DicSortCategory.DEFAULT_SORT);
+        List<DataListModel> list=dataService.getDataIndex(inputModel,1);//1:开放平台的标识符
+        //取出图片映射路径
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        for (DataListModel dataListModel : list) {
+            dataListModel.setResourceImg(imageContextPath+dataListModel.getResourceImg());
+        }
+        pager.setTotal(dataService.getIndexCount(inputModel,1));
+        modelAndView.addObject("list",list);
+        modelAndView.addObject("themes",resourceCatelogService.getResourceCatelogNameByType(DicResourceCatelogType.THEME,DicResourceType.DATA,DicPlatformType.OPEN)) ;
+        modelAndView.addObject("sectors",resourceCatelogService.getSectorNameList()) ;
+        modelAndView.addObject("chargeMethods",DicPublishSettingChargeMethod.getInstacne().getDicMap()) ;
+        modelAndView.addObject("searchModel", inputModel);
+        modelAndView.addObject("pager",pager);
+        return modelAndView;
+    }
+
+    /*
+    *@Description 查询开放平台某一个数据的详细情况
+    *@Param
+    *@Date 2018/6/9
+    *@return
+    **/
+    @RequestMapping(value="detail.htm/{id}")
+    public ModelAndView getDataDetail(@PathVariable Long id,HttpSession session,HttpServletRequest req,HttpServletResponse resp){
+        ModelAndView modelAndView = new ModelAndView("open/data/detail");
+        String paramType=(String)req.getAttribute("paramType");//是否已经申请标识符
+        String toPayed=(String)req.getAttribute("toPayed");//支付标志符
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        Long userId=null;
+        if(loginUser !=null){
+            userId=loginUser.getId();
+        }
+        DataDetailModel dataDetailModel=dataService.getDataDetail(id,userId,1);//1:开放平台的标识符
+        //取出图片映射路径
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        if(dataDetailModel!=null){
+            dataDetailModel.setResourceImg(imageContextPath+dataDetailModel.getResourceImg());
+            if(dataDetailModel.getDataFile()!=null){
+                dataDetailModel.setDataFileName(StringUtils.substringAfterLast(dataDetailModel.getDataFile(),File.separator));
+            }
+            if(dataDetailModel.getDemoFile()!=null){
+                dataDetailModel.setDemoFileName(StringUtils.substringAfterLast(dataDetailModel.getDemoFile(),File.separator));
+            }
+        }
+        modelAndView.addObject("paramType",paramType);//是否已经申请标识符
+        modelAndView.addObject("toPayed",toPayed);//支付标志符
+        modelAndView.addObject("outputModel",dataDetailModel);
+        return modelAndView;
+    }
+
+    /*
+     *@Description 开放数据申请,从数据库中判断是否 免费/收费数据/需申请
+     *@Param    id:publish_setting表     applyReasn:如果是申请,申请理由
+     *@Date 2018/6/10
+     *@return  免费/收费数据/
+     **/
+    @RequiresAuthentication
+    @RequestMapping(value="apply.action")
+    @ResponseBody
+    public ResultState<Long> getDataOpenType(MyDataShareListModel inputModel, HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        //判断是否已经申请过
+        Long resourceAuthId= myDataService.getResourceAuthId(inputModel.getPublishSettingId(),loginUser.getId(), DicPlatformType.OPEN);
+        if(resourceAuthId !=null){
+            ResultState resultState = new ResultState();
+            resultState.setMsg("已经申请过了,请前往用户中心下载");
+            return resultState;
+        }
+
+        DataApplyPriceModel dataApplyPriceModel =dataService.getDataOpenType(inputModel.getPublishSettingId());
+        if(dataApplyPriceModel !=null){
+            BeanUtils.copyProperties(dataApplyPriceModel,inputModel);
+           inputModel.setPlatformType(DicPlatformType.OPEN);
+           inputModel.setUserORAdminId(loginUser.getId());
+        }
+        ResultState<Long> resultState=new ResultState<>();
+        if(DicResourceOpenType.UNCONDITIONAL.equals(dataApplyPriceModel ==null?null:dataApplyPriceModel.getOpenType())) {
+            if (DicPublishSettingChargeMethod.FREE.equals(dataApplyPriceModel.getChargeMethod())) {
+                resultState = dataService.insertDataApply(inputModel, DicPublishSettingChargeMethod.FREE, 1);
+            }else{
+                resultState = dataService.insertDataApply(inputModel, DicPublishSettingChargeMethod.BY_NUMBER_OF_TIMES, 1);
+            }
+        } else if(DicResourceOpenType.NEED_TO_APPLY.equals(dataApplyPriceModel ==null?null:dataApplyPriceModel.getOpenType())){
+            resultState = dataService.insertDataApply(inputModel, null, 2);
+        }else{
+            resultState.setMsg("操作失败");
+        }
+        return resultState;
+    }
+
+
+    /*
+    *@Description 关注
+    *@Param id:关注的publishSettingId
+    *@Date 2018/6/14
+    *@return
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value="follow.action/{id}")
+    @ResponseBody
+    public ResultState<Long> follow(@PathVariable Long id,HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return dataService.follow(DicPlatformType.OPEN,id,loginUser.getId());
+    }
+
+    /**
+     *取消关注
+     * 关注表id
+     * @param
+     * @param
+     * @return
+     */
+    @RequiresAuthentication
+    @RequestMapping(value = "delfollow.action/{delId}")
+    @ResponseBody
+    public ResultState delfollow(@PathVariable long delId,HttpSession session) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ResultState  resultState = dataService.delfollow(delId, loginUser.getId());
+        return resultState;
+    }
+
+    /*
+    *@Description 洽谈
+    *@Param
+    *@Date 2018/6/14
+    *@return
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value = "offlineConference.action")
+    @ResponseBody
+    public ResultState offlineConference(@Validated DataOfflineConferenceModel inputModel, BindingResult bindingResult, HttpSession session){
+        if(bindingResult.hasErrors()){
+            return getAllFieldInvalidResultState(inputModel, bindingResult);
+        }
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return dataService.offlineConference(inputModel,loginUser.getId());
+    }
+
+    /*
+    *@Description 数据视图
+    *@Param
+    *@Date 2018/7/1
+    *@return
+    **/
+    @RequestMapping(value="dataview.htm")
+    public ModelAndView  getDateView(@RequestParam(defaultValue = "1") int pageNo){
+        ModelAndView modelAndView = new ModelAndView("open/data/view");
+        List<DataViewListModel> dataViewList=dataService.getDataViewList(DicPlatformType.OPEN);
+        List<DataStructListModel> dataStructModel=dataService.getDataStructreList(DicPlatformType.OPEN);
+        Long sectorTotal=dataService.getSectorTotal(DicPlatformType.OPEN);
+        Long sectorDataTotal=dataService.getSectorDataTotal(DicPlatformType.OPEN);
+        //取出图片映射路径
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        for (DataViewListModel dataListModel : dataViewList) {
+            dataListModel.setCatelogImg(imageContextPath+dataListModel.getCatelogImg());
+        }
+        modelAndView.addObject("dataViewList",dataViewList);//结构视图
+        modelAndView.addObject("dataStructModel",dataStructModel);//结构视图
+        modelAndView.addObject("sectorTotal",sectorTotal);//部门总数
+        modelAndView.addObject("sectorDataTotal",sectorDataTotal);//所有部门的数据总数
+        return modelAndView;
+    }
+
+    /*
+    *@Description 文件下载
+    *@Param Id:publishSettingId     type:示例/数据类型
+    *@Date 2018/7/9
+    *@return 
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value="download.action/{type}/{id}")
+    public String  download(@PathVariable int type,@PathVariable Long id,HttpSession session,HttpServletRequest req,HttpServletResponse resp) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        Long resourceAuthId= myDataService.getResourceAuthId(id,loginUser.getId(), DicPlatformType.OPEN);
+        if(resourceAuthId ==null){
+            //申请页面
+            req.setAttribute("paramType","1");//未申请标识符
+            return "forward:/open/data/detail.htm/"+id;
+        }
+        MyDataShareListModel myDataShareListModel = myDataService.selectResourceAuth(loginUser.getId(), resourceAuthId, DicPlatformType.OPEN);
+        if(myDataShareListModel ==null){
+            //申请页面
+            req.setAttribute("paramType","1");
+            return "forward:/open/data/detail.htm/"+id;
+        }else if(DicOrderState.PAY_SUCCESS.equals(myDataShareListModel.getOrderState())){
+            BufferedInputStream bis = null;
+            try {
+                String demoFile="";
+                if (type == 1) {
+                    demoFile =  myDataShareListModel.getDemoFile();//示例文件下载
+                }
+                if (type == 2) {
+                    demoFile = myDataShareListModel.getDataFile();//数据文件下载
+                }
+                String filename = StringUtils.substringAfterLast(demoFile, File.separator);
+                filename = new String(filename.getBytes("UTF-8"), "ISO8859-1");
+                String urlPath= ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.UPLOAD_FILE_ROOT_DIR);
+                File file =new File(urlPath+demoFile);
+                resp.reset();
+                resp.setContentType("application/octet-stream");
+                resp.setCharacterEncoding("utf-8");
+                resp.setContentLength((int) file.length());
+                resp.setHeader("Content-Disposition", "attachment;filename=" + filename);
+                byte[] buff = new byte[1024];
+                OutputStream os = null;
+                os = resp.getOutputStream();
+                bis = new BufferedInputStream(new FileInputStream(file));
+                int i = 0;
+                while ((i = bis.read(buff)) != -1) {
+                    os.write(buff, 0, i);
+                    os.flush();
+                }
+                return null;
+            } catch (IOException e) {
+                e.printStackTrace();
+            } finally {
+                try {
+                    bis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            return null;
+        }else{
+            //return new ResponseEntity<byte[]>(null,headers, HttpStatus.OK);
+            req.setAttribute("paramType","2");//已经申请过标识符
+            req.setAttribute("toPayed","3");//付费标识符
+            return "forward:/open/data/detail.htm/"+id;
+        }
+    }
+}
+

+ 159 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/DataRequirementOpenController.java

@@ -0,0 +1,159 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.controller.BaseController;
+import com.lightinit.hsdataportal.controller.share.DataRequirementShareController;
+import com.lightinit.hsdataportal.dictionary.DicPlatformType;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IDataRequirementService;
+import com.mongodb.AggregationOptions;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import javax.validation.Valid;
+import javax.xml.bind.annotation.XmlType;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author: sunxiang
+ * @Date: 2018/6/11 18:08
+ * @Description:
+ **/
+@Controller
+@RequestMapping(value = "/open/dataRequirement")
+public class DataRequirementOpenController extends BaseController{
+    private static final Logger logger = LoggerFactory.getLogger(DataRequirementShareController.class);
+    @Autowired
+    private IDataRequirementService dataRequirementService;
+
+    /*
+    *@Description 列表页面
+    *@Param
+    *@Date 2018/6/24
+    *@return
+    **/
+
+    @RequestMapping(value="index.htm")
+    public ModelAndView index(DataRequirementSearchModel dataRequirementSearchModel,@RequestParam(defaultValue = "1") int pageNo){
+        ModelAndView modelAndView = new ModelAndView("open/data_requirement/index");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageSize(5);
+        pager.setPageNo(pageNo);
+        dataRequirementSearchModel.setPage(pager);
+        dataRequirementSearchModel.setPlatformType(DicPlatformType.OPEN);
+        List<DataRequirementListModel> list=dataRequirementService.getDataRequirementList(dataRequirementSearchModel);
+        pager.setTotal(dataRequirementService.getDataRequirementCount(dataRequirementSearchModel));
+        modelAndView.addObject("outputModel",list);
+        modelAndView.addObject("flag",dataRequirementSearchModel.getFlag());
+        modelAndView.addObject("pager", pager);
+        return modelAndView;
+    }
+
+   /*
+   *@Description 详情页面
+   *@Param
+   *@Date 2018/6/24
+   *@return
+   **/
+    @RequestMapping(value="detail.htm/{id}")
+    public ModelAndView getDataRequirementOpenDetail(@PathVariable("id")  Long id, HttpSession session){
+        ModelAndView modelAndView = new ModelAndView("open/data_requirement/detail");
+         LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+         Long userId=null;
+         if(loginUser!=null){
+             userId =loginUser.getId();
+         }
+        DataRequirementDetailModel outputModol=dataRequirementService.getDataRequirementDetail(id,userId,DicPlatformType.OPEN);//
+        modelAndView.addObject("outputModel",outputModol);
+        return modelAndView;
+    }
+
+    /*
+    *@Description 发布页面
+    *@Param
+    *@Date 2018/6/24
+    *@return
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value="publish.htm")
+    public ModelAndView publish(){
+        ModelAndView modelAndView = new ModelAndView("/open/data_requirement/publish");
+        List<Map<Long,String>> list=dataRequirementService.getSectorParentNames();
+        modelAndView.addObject("sectorNames",list);
+        return modelAndView;
+    }
+
+    /*
+    *@Description 发布
+    *@Param
+    *@Date 2018/6/24
+    *@return
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value="publish.action")
+    @ResponseBody
+    public ResultState publishDo(@Valid DataRequirementAddModel dataRequirementAddModel, BindingResult bindingResult, HttpSession session){
+        if(bindingResult.hasErrors()){
+            return getAllFieldInvalidResultState(dataRequirementAddModel, bindingResult);
+        }
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        dataRequirementAddModel.setUserId(loginUser.getId());
+        dataRequirementAddModel.setPlatformType(DicPlatformType.OPEN);
+        ResultState resultState= dataRequirementService.addDataRequirement(dataRequirementAddModel);
+        return resultState;
+    }
+
+    /*
+    *@Description 关注
+    *@Param
+    *@Date 2018/6/24
+    *@return
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value="follow.action/{id}")
+    @ResponseBody
+    public ResultState<Long> follow(@PathVariable Long id,HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return dataRequirementService.follow(DicPlatformType.OPEN,id,loginUser.getId());
+    }
+
+    /*
+    *@Description 取消关注
+    *@Param
+    *@Date 2018/6/24
+    *@return
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value="delFollow.action/{id}")
+    @ResponseBody
+    public ResultState<Long> delFollow(@PathVariable Long id,HttpSession session){
+      ResultState  resultState = dataRequirementService.delfollow(id);
+      return resultState;
+    }
+    
+    /*
+    *@Description 查看更多
+    *@Param 
+    *@Date 2018/7/2
+    *@return 
+    **/
+    @RequestMapping(value="getMore.action")
+    public ModelAndView getMore(DataRequirementSearchModel dataRequirementSearchModel,@RequestParam(defaultValue = "1") int pageNo){
+        ModelAndView modelAndView = new ModelAndView("open/data_requirement/more");
+        dataRequirementSearchModel.setPlatformType(DicPlatformType.OPEN);
+        List<DataRequirementListModel> outputModel=dataRequirementService.getMore(dataRequirementSearchModel,pageNo);
+        modelAndView.addObject("outputModel", outputModel);
+        return modelAndView;
+    }
+}

+ 21 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/DemoController.java

@@ -0,0 +1,21 @@
+package com.lightinit.hsdataportal.controller.open;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Created by WangYao on 2018/6/8.
+ */
+@Controller
+@RequestMapping(value = "/open/demo")
+public class DemoController {
+
+    @RequiresAuthentication
+    @RequestMapping(value = "index.htm")
+    public String index(ModelMap model, HttpServletRequest request) {
+        return "open/demo/index";
+    }
+}

+ 124 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/EntrepreneurshipTutoringController.java

@@ -0,0 +1,124 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.SysContants;
+import com.lightinit.hsdataportal.controller.BaseController;
+import com.lightinit.hsdataportal.dictionary.DicNewsCategory;
+import com.lightinit.hsdataportal.dictionary.DicNewsState;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IEntrepreneurshipTutoringService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+@Controller
+@RequestMapping(value = "/open/EntrepreneurshipTutoring")
+public class EntrepreneurshipTutoringController extends BaseController {
+    @Autowired
+    private IEntrepreneurshipTutoringService entrepreneurshipTutoring;
+    @RequestMapping(value = "index.action")
+    public ModelAndView index(HttpSession session, EntrepreneurshipTutoringSearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo){
+        ModelAndView modelAndView = new ModelAndView("open/EntrepreneurshipTutoring/index");
+        EntrepreneurshipTutoringController aa = new EntrepreneurshipTutoringController();
+        BaseExample.Page pager = new BaseExample.Page(pageNo,3);
+        inputModel.setPage(pager);
+        inputModel.setNewsCategory(DicNewsCategory.INFORMAT);
+        inputModel.setNewsState(DicNewsState.PUBLISHED);
+        List<EntrepreneurshipTutoringListModel> informatList = entrepreneurshipTutoring.selectList(inputModel);
+        inputModel.setNewsCategory(DicNewsCategory.OPENCLASS);
+        List<EntrepreneurshipTutoringListModel> openClassList = entrepreneurshipTutoring.selectList(inputModel);
+        inputModel.setNewsCategory(DicNewsCategory.UNSCRAMBLE);
+        List<EntrepreneurshipTutoringListModel> unscrambleList = entrepreneurshipTutoring.selectList(inputModel);
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        modelAndView.addObject("informatList", informatList);
+        modelAndView.addObject("openClassList", openClassList);
+        modelAndView.addObject("unscrambleList", unscrambleList);
+            modelAndView.addObject("imageContextPath", imageContextPath);
+        return modelAndView;
+    }
+
+    /**
+     * 创业辅导
+     * @param session
+     * @param pageNo
+     * @return
+     */
+    @RequestMapping(value = "informatList.action")
+    @ResponseBody
+    public ModelAndView informatList(HttpSession session, EntrepreneurshipTutoringSearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo) {
+        ModelAndView modelAndView = new ModelAndView("open/EntrepreneurshipTutoring/information");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageNo(pageNo);
+        inputModel.setPage(pager);
+        inputModel.setNewsCategory(DicNewsCategory.INFORMAT);
+        inputModel.setNewsState(DicNewsState.PUBLISHED);
+        List<EntrepreneurshipTutoringListModel> outputModel = entrepreneurshipTutoring.selectList(inputModel);
+        pager.setTotal(entrepreneurshipTutoring.selectCount(inputModel));
+        modelAndView.addObject("list", outputModel);
+        modelAndView.addObject("pager", pager);
+        return modelAndView;
+    }
+    /**
+     * 政策解读
+     * @param session
+     * @param pageNo
+     * @return
+     */
+    @RequestMapping(value = "unscrambleList.action")
+    @ResponseBody
+    public ModelAndView unscrambleList(HttpSession session,EntrepreneurshipTutoringSearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo) {
+        ModelAndView modelAndView = new ModelAndView("open/EntrepreneurshipTutoring/unscramble");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageNo(pageNo);
+        inputModel.setPage(pager);
+        inputModel.setNewsCategory(DicNewsCategory.UNSCRAMBLE);
+        inputModel.setNewsState(DicNewsState.PUBLISHED);
+        List<EntrepreneurshipTutoringListModel> outputModel = entrepreneurshipTutoring.selectList(inputModel);
+        pager.setTotal(entrepreneurshipTutoring.selectCount(inputModel));
+        modelAndView.addObject("list", outputModel);
+        modelAndView.addObject("pager", pager);
+        return modelAndView;
+    }
+    /**
+     * 咨询服务
+     * @param session
+     * @param pageNo
+     * @return
+     */
+    @RequestMapping(value = "openClassList.action")
+    @ResponseBody
+    public ModelAndView openClassList(HttpSession session,EntrepreneurshipTutoringSearchModel inputModel,@RequestParam(defaultValue = "1") int pageNo) {
+        ModelAndView modelAndView = new ModelAndView("open/EntrepreneurshipTutoring/openClass");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageNo(pageNo);
+        inputModel.setPage(pager);
+        inputModel.setNewsCategory(DicNewsCategory.OPENCLASS);
+        inputModel.setNewsState(DicNewsState.PUBLISHED);
+        List<EntrepreneurshipTutoringListModel> outputModel = entrepreneurshipTutoring.selectList(inputModel);
+        pager.setTotal(entrepreneurshipTutoring.selectCount(inputModel));
+        modelAndView.addObject("list", outputModel);
+        modelAndView.addObject("pager", pager);
+        return modelAndView;
+    }
+    @RequestMapping(value = "view.htm/{id}")
+    public ModelAndView view(@PathVariable long id) {
+        ModelAndView modelAndView = new ModelAndView("open/EntrepreneurshipTutoring/view");
+        EntrepreneurshipTutoringViewModel model = entrepreneurshipTutoring.view(id);
+        String newsContent = model.getNewsContent();
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        String imgTag = "<img src=\"";
+        String consult = newsContent.replaceAll(imgTag, imgTag + imageContextPath);
+        model.setNewsContent(consult);
+        modelAndView.addObject("model", model);
+        return modelAndView;
+    }
+}

+ 115 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/InnovationActivityController.java

@@ -0,0 +1,115 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.GuidGenerator;
+import com.lightinit.hsdataportal.common.SysContants;
+import com.lightinit.hsdataportal.common.UploadFileUtils;
+import com.lightinit.hsdataportal.dictionary.DicActivityState;
+import com.lightinit.hsdataportal.dictionary.DicActivityType;
+import com.lightinit.hsdataportal.entity.Activity;
+import com.lightinit.hsdataportal.entity.ActivityEnroll;
+import com.lightinit.hsdataportal.entity.ActivityWithBLOBs;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.model.ActivityModel;
+import com.lightinit.hsdataportal.model.ActivitySearchModel;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.model.ResultStateCode;
+import com.lightinit.hsdataportal.service.IInnovationActivityService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.validation.Valid;
+import java.io.File;
+import java.util.List;
+
+import static com.lightinit.hsdataportal.controller.BaseController.buildInvalidResultState;
+import static com.lightinit.hsdataportal.controller.BaseController.getAllFieldInvalidResultState;
+
+@Controller
+@RequestMapping(value = "/open/innovationActivity")
+public class InnovationActivityController {
+    @Autowired
+    private IInnovationActivityService iInnovationActivityService;
+    @RequestMapping(value = "/index.htm")
+    public ModelAndView index(ActivitySearchModel activitySearchModel,@RequestParam(defaultValue = "1") int pageNo) {
+        ModelAndView modelAndView = new ModelAndView("open/innovationActivity/activitylist");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageSize(6);
+        pager.setPageNo(pageNo);
+        activitySearchModel.setPage(pager);
+      List<ActivityWithBLOBs> list =  iInnovationActivityService.getList(activitySearchModel);
+        pager.setTotal(iInnovationActivityService.getCount(activitySearchModel));
+        modelAndView.addObject("list",list);
+        modelAndView.addObject("pager",pager);
+        modelAndView.addObject("searchModel", activitySearchModel);
+        modelAndView.addObject("activityType",DicActivityType.getInstacne().getDicMap());
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        modelAndView.addObject("imageContextPath", imageContextPath);
+        return  modelAndView;
+    }
+    @RequestMapping(value = "/more.action")
+    public ModelAndView more(ActivitySearchModel activitySearchModel,@RequestParam(defaultValue = "1") int pageNo) {
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageSize(6);
+        pager.setPageNo(pageNo);
+        activitySearchModel.setPage(pager);
+        ModelAndView modelAndView = new ModelAndView("open/innovationActivity/more");
+        List<ActivityWithBLOBs> list =  iInnovationActivityService.getList(activitySearchModel);
+        modelAndView.addObject("list", list);
+        return modelAndView;
+    }
+    @RequestMapping(value = "/add.htm")
+    public ModelAndView add() {
+        ModelAndView modelAndView = new ModelAndView("open/innovationActivity/addActivity");
+        modelAndView.addObject("activityType",DicActivityType.getInstacne().getDicMap());
+        return  modelAndView;
+    }
+    @RequestMapping(value = "/toAdd.action")
+    @ResponseBody
+    private ResultState toAdd(@Valid ActivityModel activity, BindingResult bindingResult, MultipartFile fileImg) {
+        if (bindingResult.hasErrors()){
+            return getAllFieldInvalidResultState(activity, bindingResult);
+        }
+        if(activity.getFlag().equals("1")) {
+            activity.setActivityState(DicActivityState.PENDING);//审核中
+        }else{
+            activity.setActivityState(DicActivityState.DRAFT);//待提交
+        }
+        String uniqueDir = GuidGenerator.generate() + File.separator;
+        String dataFileDir = UploadFileUtils.buildRelativeDir(SysContants.UploadFilePath.ACTIVITY_ROOT_DIR, uniqueDir, SysContants.UploadFilePath.ACTIVITY_IMG_DIR);
+        if (fileImg != null && !fileImg.isEmpty()){
+            if (UploadFileUtils.writeUploadFile(fileImg, dataFileDir, SysContants.PropertyKey.UPLOAD_IMAGE_ROOT_DIR)){
+                activity.setThumbnail(dataFileDir + fileImg.getOriginalFilename());
+            }else {
+                return buildInvalidResultState(ResultStateCode.INVALID_DATA, "资源图片保存失败");
+            }
+        }
+        ResultState resultState = iInnovationActivityService.toAdd(activity);
+        return resultState;
+    }
+    @RequestMapping(value = "/view.htm/{id}")
+    public ModelAndView view(@PathVariable Long id) {
+        ModelAndView modelAndView =new ModelAndView("open/innovationActivity/activityView");
+        ActivityWithBLOBs model = iInnovationActivityService.view(id);
+        modelAndView.addObject("model",model);
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        modelAndView.addObject("imageContextPath", imageContextPath);
+        return modelAndView;
+    }
+    @RequestMapping(value = "/enroll.action")
+    @ResponseBody
+    public ResultState enroll(@Valid ActivityEnroll activityEnroll, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()){
+            return getAllFieldInvalidResultState(activityEnroll, bindingResult);
+        }
+        ResultState resultState = iInnovationActivityService.enroll(activityEnroll);
+        return resultState;
+    }
+}

+ 50 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MakerSpaceController.java

@@ -0,0 +1,50 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.SysContants;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author WangYao
+ * @date 2018/6/29 15:21
+ * @description
+ */
+@Controller
+@RequestMapping(value = "/open/makerspace")
+public class MakerSpaceController {
+
+   /* @RequestMapping(value = "index.htm")
+    public String index(HttpServletRequest request, Model model) {
+        String devopsUrl = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.DEVOPS);
+        String devopsService = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.DEVOPSSERVICE);
+        String devopsDate = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.DEVOPSDATE);
+        String devopsAnalysis = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.DEVOPSANALYSIS);
+        model.addAttribute("devopsUrl",devopsUrl) ;
+        model.addAttribute("devopsService",devopsService) ;
+        model.addAttribute("devopsDate",devopsDate) ;
+        model.addAttribute("devopsAnalysis",devopsAnalysis) ;
+        return "open/makerspace/index";
+    }*/
+
+    @RequestMapping(value = "index.htm")
+    public ModelAndView index(String id) {
+        ModelAndView modelAndView = new ModelAndView("open/makerspace/index");
+        modelAndView.addObject("id",id);
+        String devopsUrl = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.DEVOPS);
+        String devopsService = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.DEVOPSSERVICE);
+        String devopsDate = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.DEVOPSDATE);
+        String devopsAnalysis = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.DEVOPSANALYSIS);
+        modelAndView.addObject("devopsUrl",devopsUrl) ;
+        modelAndView.addObject("devopsService",devopsService) ;
+        modelAndView.addObject("devopsDate",devopsDate) ;
+        modelAndView.addObject("devopsAnalysis",devopsAnalysis) ;
+        return modelAndView;
+    }
+}

+ 205 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MicroappOpenController.java

@@ -0,0 +1,205 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.google.gson.Gson;
+import com.lightinit.hsdataportal.common.*;
+import com.lightinit.hsdataportal.controller.BaseController;
+import com.lightinit.hsdataportal.dictionary.*;
+import com.lightinit.hsdataportal.entity.*;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IMicroappService;
+import com.lightinit.hsdataportal.service.IMyDataService;
+import com.lightinit.hsdataportal.service.IResourceCatelogService;
+import com.sun.deploy.net.HttpUtils;
+import org.apache.http.NameValuePair;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.validation.Valid;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.*;
+
+@RequestMapping(value = "/open/microapp")
+@Controller
+public class MicroappOpenController extends BaseController {
+    @Value("${applicationId}")
+    private String appId;
+    @Autowired
+    private IMicroappService microappService;
+    @Autowired
+    private IResourceCatelogService resourceCatelogService ;
+    @Autowired
+    private IMyDataService myDataService;
+    @RequestMapping(value = "openList.action")
+    public ModelAndView openList(MicroappSearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo) {
+        ModelAndView modelAndView = new ModelAndView("/open/microapp/index");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageNo(pageNo);
+        inputModel.setPage(pager);
+        inputModel.setPublishState(DicPublishApiState.PUBLISH);
+        inputModel.setSortCategory(DicSortCategory.DEFAULT_SORT);
+        List<MicroappListModel> outputModel = microappService.selectOpenList(inputModel);
+        pager.setTotal(microappService.selectOpenCount(inputModel));
+        modelAndView.addObject("themes",resourceCatelogService.getResourceCatelogNameByType(DicResourceCatelogType.THEME,DicResourceType.MICROAPP,DicPlatformType.OPEN)) ;
+        modelAndView.addObject("sectors",resourceCatelogService.getSectorNameList()) ;
+        modelAndView.addObject("chargeMethods",DicPublishSettingChargeMethod.getInstacne().getDicMap()) ;
+        modelAndView.addObject("list", outputModel);
+        modelAndView.addObject("pager", pager);
+        modelAndView.addObject("searchModel", inputModel);
+        modelAndView.addObject("flag", inputModel.getFlag());
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        modelAndView.addObject("imageContextPath", imageContextPath);
+        return modelAndView;
+    }
+
+    /**
+     * 详情页面
+     * settingId
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "view.htm/{id}")
+    @ResponseBody
+    public ModelAndView view(HttpSession session,@PathVariable long id) {
+        ModelAndView modelAndView = new ModelAndView("/open/microapp/detail");
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        String platformType = DicPlatformType.OPEN;
+        MicroappViewModel microappModel = microappService.queryView(id,platformType);
+        modelAndView.addObject("model", microappModel);
+        String imageContextPath = ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.IMAGE_CONTEXT_PATH);
+        modelAndView.addObject("imageContextPath", imageContextPath);
+        List<ResourceAuth> list =null;
+        if(loginUser!=null) {
+            list =  microappService.isAPPly(loginUser.getId(),microappModel.getPublishSettingId());
+
+        }
+        modelAndView.addObject("list",list);
+        return modelAndView;
+    }
+
+
+    @RequestMapping(value = "apply.action")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState doApply(HttpSession session,MicroappApplyModel inputModel) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        inputModel.setApplier(loginUser.getId());//在申请人
+        inputModel.setPlatformType(DicPlatformType.OPEN);
+        //判断是否已经申请过
+        Long resourceAuthId= myDataService.getResourceAuthId(inputModel.getPublishSettingId(),loginUser.getId(), DicPlatformType.OPEN);
+        if(resourceAuthId !=null){
+            ResultState resultState = new ResultState();
+            resultState.setMsg("已经申请过了,请前往用户中心下载");
+            return resultState;
+        }
+        return microappService.doApply(inputModel);
+    }
+
+
+
+    /**
+     *查看演示
+     * resource_microapp表id
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "openDemo.action/{id}/{flag}", produces = "text/html; charset=UTF-8")
+    @RequiresAuthentication
+    @ResponseBody
+    public String openDemo(@PathVariable long id,@PathVariable int flag,HttpSession session) throws Exception {
+        LoginUser loginUser =(LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ResourceMicroappWithBLOBs outputModel=microappService.demo(id);
+        ApiEncryptUtil apiEncryptUtil = new ApiEncryptUtil();
+        long userId = loginUser.getId();
+        String publicKey =  microappService.getPublicKey(userId);
+        String username = loginUser.getUsername();
+        Long date = new Date().getTime();
+        String version = "1.0";
+        String timestamp = date.toString();
+        String summary = apiEncryptUtil.encrypt(appId+username+timestamp,apiEncryptUtil.getPublicKey(publicKey));
+        String html ="";
+        if(flag==1) {
+             html = HttpTookitUtils.doGet(outputModel.getUrl(),CharEncoding.UTF8,appId,username,version,timestamp,summary);
+//             html = HttpTookitUtils.doGet(outputModel.getUrl(),null,  CharEncoding.UTF8);
+        }else {
+            html = HttpTookitUtils.doGet(outputModel.getDemoUrl(),CharEncoding.UTF8,appId,username,version,timestamp,summary);
+
+        }
+        return html;
+    }
+
+
+
+
+
+    /**
+     *关注
+     * setting表id
+     * @param session
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "follow.action/{id}")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState follow(HttpSession session,@PathVariable long id) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ResourceFollow model = new ResourceFollow();
+        model.setFollowerId(loginUser.getId());//关注人id
+        model.setPublishSettingId(id);//资源发布id
+        model.setPlatformType(DicPlatformType.OPEN);
+        ResultState   resultState = microappService.follow(model);
+        return resultState;
+    }
+    /**
+     *取消关注
+     * 关注表id
+     * @param
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "delfollow.action/{id}")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState delfollow(@PathVariable long id) {
+        ResultState   resultState = microappService.delfollow(id);
+        return resultState;
+    }
+    @RequestMapping(value = "offline.htm/{id}")
+    public ModelAndView offline(@PathVariable long id) {
+        ModelAndView modelAndView = new ModelAndView("/open/microapp/offline");
+        modelAndView.addObject("publishSettingId",id );
+        return modelAndView;
+    }
+
+    @RequestMapping(value = "offlineConference.action")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState offlineConference(HttpSession session, @Valid MicroappOfflineConferenceModel inputModel, BindingResult bindingResult){
+        if (bindingResult.hasErrors()){
+            return getAllFieldInvalidResultState(inputModel, bindingResult);
+        }
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return microappService.offlineConference(inputModel,loginUser.getId());
+    }
+
+
+
+
+
+}

+ 86 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MyAPIOpenController.java

@@ -0,0 +1,86 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.dictionary.DicPlatformType;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IResourceFollowService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+@Controller
+@RequestMapping("/open/myApi")
+public class MyAPIOpenController {
+
+    @Autowired
+    private IResourceFollowService followService ;
+
+
+
+    //关注列表
+    @RequiresAuthentication
+    @RequestMapping(value = "list.htm")
+    public ModelAndView openList(@RequestParam(defaultValue = "0")Long falg,Long msg ,HttpSession session,@RequestParam(defaultValue = "1") int pageNo){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ModelAndView modelAndView = new ModelAndView("open/myApi/list");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageNo(pageNo);
+        List<MyAPIOpenFollowListModel> outputModel = followService.queryOpenList(DicPlatformType.OPEN,loginUser.getId(),pager);
+        modelAndView.addObject("followList", outputModel);
+        List<MyAPIApplyListModel> myAPIApplyListModels = followService.applyList(loginUser.getId(), DicPlatformType.OPEN,pager);
+        modelAndView.addObject("applyList", myAPIApplyListModels);
+        modelAndView.addObject("falg", falg);
+        modelAndView.addObject("msg", msg);
+        return modelAndView;
+    }
+
+    @RequestMapping(value = "noFollow.action/{id}")
+    public String view(@PathVariable Long id){
+        ResultState  resultState  =  followService.noFollow(id);
+        if (StringUtils.isEmpty(resultState.getMsg())){
+            return InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/open/myApi/list.htm?falg=1&msg="+resultState.getMsg()+"#shujv" ;
+        }
+        return InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/open/myApi/list.htm?falg=1#shujv" ;
+
+    }
+
+//    //申请列表
+//    @RequestMapping(value = "applyList.action")
+//    public ModelAndView applyList(HttpSession session,@RequestParam(defaultValue = "1") int pageNo){
+//        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+//        ModelAndView modelAndView = new ModelAndView("open/myApi/applyList");
+//        BaseExample.Page pager = new BaseExample.Page();
+//        pager.setPageNo(pageNo);
+//        List<MyAPIApplyListModel> myAPIApplyListModels = followService.applyList(loginUser.getId(), DicPlatformType.OPEN,pager);
+//        pager.setTotal(followService.applyCount(loginUser.getId(), DicPlatformType.OPEN));
+//        modelAndView.addObject("list", myAPIApplyListModels);
+//        modelAndView.addObject("pager", pager);
+//        return modelAndView ;
+//    }
+
+    //申请
+    @RequestMapping(value = "apply.action")
+    @ResponseBody
+    public ResultState apply(APIApplyModel apiApplyModel,HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        return followService.apply(apiApplyModel,loginUser.getId(),DicPlatformType.OPEN);
+    }
+    //查看反馈
+    @RequestMapping(value = "feedback.htm/{id}")
+    @ResponseBody
+    public MyAPIFeedbackModel feedback(@PathVariable Long id){
+        return followService.feedback(id);
+    }
+    
+}

+ 88 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MyAccountController.java

@@ -0,0 +1,88 @@
+package com.lightinit.hsdataportal.controller.open;
+
+
+import com.lightinit.hsdataportal.entity.Order;
+import com.lightinit.hsdataportal.model.DicAccountManageTransactionTransType;
+import com.lightinit.hsdataportal.model.LoginUser;
+import com.lightinit.hsdataportal.model.MyAccountManageRechargeVOModel;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.service.IOrderService;
+import com.lightinit.hsdataportal.service.open.IMyAccountService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.math.BigDecimal;
+import java.util.List;
+
+@Controller
+@RequestMapping(value = "/open/myAccount")
+public class MyAccountController {
+
+    @Autowired
+    private IMyAccountService myAccountService ;
+    @Autowired
+    private IOrderService iOrderService;
+
+    @RequiresAuthentication
+    @RequestMapping(value = "index.htm")
+    public ModelAndView index(HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ModelAndView modelAndView = new ModelAndView("/open/myAccount/index") ;
+        List<MyAccountManageRechargeVOModel> outputModel = myAccountService.queryRechargeList(loginUser.getId(), DicAccountManageTransactionTransType.RECHARGE);
+        modelAndView.addObject("recharges",outputModel) ;
+        List<MyAccountManageRechargeVOModel> outputModel1 = myAccountService.queryTransactionList(loginUser.getId(), DicAccountManageTransactionTransType.TRANSACTION);
+        modelAndView.addObject("transactions",outputModel1) ;
+        BigDecimal balance = myAccountService.getMyBalance(loginUser.getId()) ;
+        modelAndView.addObject("balance",balance) ;
+        return modelAndView ;
+    }
+
+    /**
+     * 跳转充值页面
+     * @param balance
+     * @return
+     */
+    @RequestMapping(value = "recharge.htm")
+    public ModelAndView recharge(BigDecimal balance) {
+        BigDecimal b = BigDecimal.valueOf(0.0);
+        if(balance==null) {
+            balance=b;
+        }
+        ModelAndView modelAndView = new ModelAndView("/open/myAccount/recharge");
+        modelAndView.addObject("balance",balance);
+        return modelAndView;
+    }
+
+    /**
+     * 生成充值订单
+     * @param session
+     * @return
+     */
+    @RequestMapping(value = "toRecharge.action")
+    @ResponseBody
+    public ResultState toRecharge(HttpSession session,Order order) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ResultState resultState = iOrderService.generateOrder(loginUser.getId(),order);
+        return resultState;
+    }
+
+    /**
+     * 跳转支付页面
+     * @param orderAmount
+     * @return
+     */
+    @RequestMapping(value = "payment.htm")
+    public ModelAndView payment(BigDecimal orderAmount,String orderNumber) {
+    ModelAndView modelAndView = new ModelAndView("/open/myAccount/pay");
+    modelAndView.addObject("transAmount",orderAmount);
+    modelAndView.addObject("orderNumber",orderNumber);
+
+    return modelAndView;
+    }
+
+}

+ 82 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MyApiRequirementController.java

@@ -0,0 +1,82 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.dictionary.DicRequirmentAuditState;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.entity.Requirement;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IAPIDemandService;
+import com.lightinit.hsdataportal.service.IMyApiRequirementService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+@Controller
+@RequestMapping(value = "/open/MyApiRequirement")
+public class MyApiRequirementController {
+    @Autowired
+    private IMyApiRequirementService myApiRequirementService;
+    @Autowired
+    private IAPIDemandService demandService ;
+
+    @RequestMapping(value = "list.action")
+    @ResponseBody
+    @RequiresAuthentication
+    public ModelAndView list(HttpSession session) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ModelAndView modelAndView = new ModelAndView("open/myrequirement/myapi/list");
+        List<MyRequirementListModel> outputModel = myApiRequirementService.selectOpenList(loginUser.getId());
+        modelAndView.addObject("list", outputModel);
+        return modelAndView;
+    }
+
+    /**
+     * 详情
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "view.action/{id}")
+    @RequiresAuthentication
+    public ModelAndView openView(@PathVariable Long id){
+        ModelAndView modelAndView = new ModelAndView("open/apiDemand/view");
+        APIDemandOpenViewModel demandOpenViewModel = demandService.queryView(id);
+        modelAndView.addObject("demandOpenViewModel", demandOpenViewModel);
+        return modelAndView;
+    }
+
+    @RequestMapping(value = "edit.action")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState<Long> edit(APIDdmandOpenReleaseModel releaseModel){
+        return myApiRequirementService.edit(releaseModel);
+    }
+    /**
+     * 我的接单列表
+     * @return
+     */
+    @RequestMapping(value = "receiveList.action/{id}")
+    @ResponseBody
+    @RequiresAuthentication
+    public ModelAndView receiveList(@PathVariable Long id) {
+        ModelAndView modelAndView = new ModelAndView("open/myrequirement/myapi/receiveList");
+        List<APIReceiveListModel> outputModel = myApiRequirementService.selectReceiveList(id);
+        modelAndView.addObject("list", outputModel);
+
+        return modelAndView;
+    }
+    @RequestMapping(value = "delfollow.action/{id}")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState<Long> offLine(@PathVariable Long id){
+        Requirement requirement = myApiRequirementService.selectRequirementById(id);
+        requirement.setRqrmntState(DicRequirmentAuditState.OFFSHELVES);
+        return myApiRequirementService.offLine(requirement);
+    }
+}

+ 177 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MyDataOpenController.java

@@ -0,0 +1,177 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.SysContants;
+import com.lightinit.hsdataportal.dictionary.*;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IDataService;
+import com.lightinit.hsdataportal.service.IMyDataService;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.*;
+import java.util.List;
+
+/**
+ * @Author: sunxiang
+ * @Date: 2018/6/15 22:29
+ * @Description:
+ **/
+@Controller
+@RequestMapping(value = "/open/mydata")
+public class MyDataOpenController {
+
+    @Autowired
+    private IMyDataService myDataService;
+    @Autowired
+    private IDataService dataService;
+    /*
+    *@Description "申请的数据"页面
+    *@Param tab:页面显示的tab页 1:“申请的数据”,2:“关注的数据”
+    *@Date 2018/6/15
+    *@return 
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value="index.htm/{tab}")/*分页待加入*/
+    public ModelAndView getApplyIndex(@PathVariable Integer tab, HttpSession session, HttpServletRequest req, HttpServletResponse resp){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ModelAndView modelAndView = new ModelAndView("open/my_data/index");
+        List<MyDataShareListModel> list=myDataService.getIndex(null,loginUser.getId(), DicPlatformType.OPEN);
+        modelAndView.addObject("outputModel",list);
+        String paramType = (String)req.getAttribute("paramType");
+        MyDataShareListModel toPay=(MyDataShareListModel)req.getAttribute("toPay");
+        modelAndView.addObject("paramType",paramType);
+        modelAndView.addObject("toPay",toPay);
+        modelAndView.addObject("tab",tab);
+
+        /*待分离的“关注的数据”*/
+        List<FollowDataListModel> followDataList=myDataService.getFollowDateList(loginUser.getId(),DicPlatformType.OPEN);
+        modelAndView.addObject("followDataList",followDataList);
+        /**/
+
+        return modelAndView;
+    }
+
+    /*
+     *@Description 下载
+     *@Param
+     *@Date 2018/6/15
+     *@return
+     **/
+    @RequiresAuthentication
+    @RequestMapping(value="download.action/{id}")
+    public String  download(@PathVariable Long id,  HttpSession session, HttpServletRequest req, HttpServletResponse resp){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        MyDataShareListModel myDataShareListModel=myDataService.selectResourceAuth(loginUser.getId(),id,DicPlatformType.OPEN);
+        ResultState resultState = new ResultState();
+        if(myDataShareListModel ==null){
+            //转发到详情申请页面
+            req.setAttribute("paramType","1");
+            return "forward:/open/data/detail.htm/"+id;
+        }else if(DicOrderState.PAY_SUCCESS.equals(myDataShareListModel.getOrderState())){
+            BufferedInputStream bis = null;
+            try {
+                String demoFile = myDataShareListModel.getDataFile();//数据文件下载
+                String filename = StringUtils.substringAfterLast(demoFile, File.separator);
+                filename = new String(filename.getBytes("UTF-8"), "ISO8859-1");
+                String urlPath= ConfigUtils.getConfiguration(SysContants.PropertyFilePath.CONFIG).getString(SysContants.PropertyKey.UPLOAD_FILE_ROOT_DIR);
+                File file =new File(urlPath+demoFile);
+                resp.reset();
+                resp.setContentType("application/octet-stream");
+                resp.setCharacterEncoding("utf-8");
+                resp.setContentLength((int) file.length());
+                resp.setHeader("Content-Disposition", "attachment;filename=" + filename);
+                byte[] buff = new byte[1024];
+                OutputStream os = null;
+                os = resp.getOutputStream();
+                bis = new BufferedInputStream(new FileInputStream(file));
+                int i = 0;
+                while ((i = bis.read(buff)) != -1) {
+                    os.write(buff, 0, i);
+                    os.flush();
+                }
+                return null;
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                try {
+                    if(bis!=null){
+                        bis.close();
+                    }
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            //req.setAttribute("paramType","4");//下载失败
+            return "redirect:/open/mydata/index.htm/1";
+        }else{
+            //弹出支付页面
+            req.setAttribute("paramType","2");
+            req.setAttribute("toPay",myDataService.getIndex(id,loginUser.getId(), DicPlatformType.OPEN).get(0));//id:resourceAuthId
+            return "forward:/open/mydata/index.htm/1";
+        }
+    }
+
+    /*
+     *@Description “授权成功”后申请
+     *@Param
+     *@Date 2018/6/15
+     *@return
+     **/
+   /* @RequestMapping(value="apply.action/{id}")
+    @ResponseBody
+    public ResultState  apply(@PathVariable Long id, HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        MyDataShareListModel myDataShareListModel=myDataService.selectResourceAuth(loginUser.getId(),id,DicPlatformType.OPEN);
+        ResultState resultState = null;
+        myDataShareListModel.setUserORAdminId(loginUser.getId());
+        if(DicResourceAuthAuditResult.AUTHORIZATION_SUCCESS.equals(myDataShareListModel.getAuthState())){
+            if( DicPublishSettingChargeMethod.FREE.equals(myDataShareListModel.getChargeMethod())){
+                resultState=dataService.insertDataApply(myDataShareListModel,DicPublishSettingChargeMethod.FREE,1);
+            }else if(DicPublishSettingChargeMethod.BY_NUMBER_OF_TIMES.equals(myDataShareListModel.getChargeMethod())) {
+                resultState=dataService.insertDataApply(myDataShareListModel,DicPublishSettingChargeMethod.BY_NUMBER_OF_TIMES,1);
+            }else if(DicPublishSettingChargeMethod.BY_TIME.equals(myDataShareListModel.getChargeMethod())) {
+                resultState=dataService.insertDataApply(myDataShareListModel,DicPublishSettingChargeMethod.BY_TIME,1);
+            }
+        }
+        return resultState;
+    }*/
+
+    /*
+     *@Description “关注的数据”页面
+     *@Param
+     *@Date 2018/6/15
+     *@return
+     **/
+    @RequiresAuthentication
+    @RequestMapping(value="follow.htm")
+    @ResponseBody
+    public List<MyDataShareListModel>  getFollowIndex(HttpSession session){
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        List<MyDataShareListModel> list=myDataService.getIndex(null,loginUser.getId(), DicPlatformType.OPEN);
+        return list;
+    }
+
+    /*
+    *@Description 取消关注
+    *@Param 
+    *@Date 2018/6/25
+    *@return 
+    **/
+    @RequiresAuthentication
+    @RequestMapping(value="delFollow.action/{tabNum}/{id}")
+    public String delFollow(@PathVariable Integer tabNum ,@PathVariable Long id,HttpSession session){
+         LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ResultState  resultState = dataService.delfollow(id, loginUser.getId());
+        return "redirect:/open/mydata/index.htm/2";//2:tab,表示页面显示“关注的数据”
+    }
+}

+ 55 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MyDataRequirementOpenController.java

@@ -0,0 +1,55 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.dictionary.DicRequirmentAuditState;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.entity.Requirement;
+import com.lightinit.hsdataportal.model.LoginUser;
+import com.lightinit.hsdataportal.model.MyRequirementListModel;
+import com.lightinit.hsdataportal.model.MyRequirementSearchModel;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.service.IMyDataRequirementService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+@Controller
+@RequestMapping(value = "/open/MyOpenDataRequirement")
+public class MyDataRequirementOpenController {
+    @Autowired
+    private IMyDataRequirementService myDataRequirementService;
+
+    @RequestMapping(value = "list.action")
+    @ResponseBody
+    @RequiresAuthentication
+    public ModelAndView list(HttpSession session) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ModelAndView modelAndView = new ModelAndView("open/myrequirement/mydata/list");
+        List<MyRequirementListModel> outputModel = myDataRequirementService.selectOpenList(loginUser.getId());
+        modelAndView.addObject("list", outputModel);
+        return modelAndView;
+    }
+
+    /**
+     * 下架
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "offLine.action/{id}")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState<Long> offLine(@PathVariable Long id){
+        Requirement requirement = myDataRequirementService.selectRequirementById(id);
+        requirement.setRqrmntState(DicRequirmentAuditState.OFFSHELVES);
+        return myDataRequirementService.offLine(requirement);
+    }
+
+
+}

+ 46 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MyFollowRequirementOpenController.java

@@ -0,0 +1,46 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.model.LoginUser;
+import com.lightinit.hsdataportal.model.MyFollowRequirementListModel;
+import com.lightinit.hsdataportal.model.MyFollowRequirementSearchModel;
+import com.lightinit.hsdataportal.model.ResultState;
+import com.lightinit.hsdataportal.service.IMyFollowRequirementService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+@Controller
+@RequestMapping(value = "/open/MyOpenFollow")
+public class MyFollowRequirementOpenController {
+    @Autowired
+    private IMyFollowRequirementService myFollowRequirementService;
+
+
+    @RequestMapping(value = "list.action")
+    @ResponseBody
+    @RequiresAuthentication
+    public ModelAndView list(HttpSession session) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ModelAndView modelAndView = new ModelAndView("open/myrequirement/myfollow/list");
+        List<MyFollowRequirementListModel> outputModel = myFollowRequirementService.selectOpenList(loginUser.getId());
+        modelAndView.addObject("list", outputModel);
+        return modelAndView;
+    }
+
+    @RequestMapping(value = "delfollow.action/{id}")
+    @RequiresAuthentication
+    @ResponseBody
+    public ResultState delfollow(@PathVariable long id) {
+        ResultState   resultState = myFollowRequirementService.delfollow(id);
+        return resultState;
+    }
+}

+ 106 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MyMicroappController.java

@@ -0,0 +1,106 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.dictionary.DicPlatformType;
+import com.lightinit.hsdataportal.dictionary.DicResourceType;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IMicroappService;
+import com.lightinit.hsdataportal.service.IMyApiRequirementService;
+import com.lightinit.hsdataportal.service.IMyMicroappService;
+import com.lightinit.hsdataportal.service.IResourceFollowService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+@Controller
+@RequestMapping("/open/myMicroapp")
+public class MyMicroappController {
+    @Autowired
+    private IMyMicroappService myMicroappService;
+    @Autowired
+    private IResourceFollowService followService ;
+
+    /**
+     * 申请列表
+     * @param inputModel
+     * @param pageNo
+     * @return
+     */
+    @RequiresAuthentication
+    @RequestMapping(value = "list.htm")
+    public String applyList(@RequestParam(defaultValue = "0")Long falg,Long msg ,MyMicroappApplySearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo,Model model, HttpSession session) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        inputModel.setApplyBy(loginUser.getId());
+        BaseExample.Page pager = new BaseExample.Page(pageNo, 10);
+        inputModel.setPage(pager);
+        inputModel.setResourceType(DicResourceType.MICROAPP);
+        inputModel.setPlatformType(DicPlatformType.OPEN);
+        List<MyMicroappApplyListModel> applyListModels = myMicroappService.selectOpenList(inputModel);
+        model.addAttribute("applyList", applyListModels);
+        MyMicroappFollowSearchModel followSearchModel = new MyMicroappFollowSearchModel() ;
+        BeanUtils.copyProperties(inputModel,followSearchModel);
+        followSearchModel.setFollowId(loginUser.getId());
+        List<MyMicroappFollowListModel> followListModels = myMicroappService.selectFollowOpenList(followSearchModel);
+        model.addAttribute("followList", followListModels);
+        model.addAttribute("falg", falg);
+        model.addAttribute("msg", msg);
+        return "open/myMicroapp/list";
+    }
+
+    /**
+     * 关注列表
+     * @param
+     * @param
+     * @return
+     */
+//    public ModelAndView followList(MyMicroappFollowSearchModel inputModel, @RequestParam(defaultValue = "1") int pageNo) {
+//        ModelAndView modelAndView = new ModelAndView("admin/microapp_register/list");
+//        BaseExample.Page pager = new BaseExample.Page(pageNo, 10);
+//        inputModel.setPage(pager);
+//        inputModel.setResourceType(DicResourceType.MICROAPP);
+//        inputModel.setPlatformType(DicPlatformType.OPEN);
+//        List<MyMicroappFollowListModel> outputModel = myMicroappService.selectFollowOpenList(inputModel);
+//        pager.setTotal(myMicroappService.selectFollowOpenCount(inputModel));
+//        modelAndView.addObject("list", outputModel);
+//        modelAndView.addObject("pager", pager);
+//        return modelAndView;
+//    }
+
+    //查看反馈
+    @RequestMapping(value = "feedback.htm/{id}")
+    @ResponseBody
+    public MyMicroappFeedbackModel feedback(@PathVariable Long id){
+
+        return myMicroappService.feedback(id, DicPlatformType.OPEN);
+    }
+
+//    @RequestMapping(value = "apply.action")
+//    public ResultState doApply(HttpSession session, MicroappApplyModel inputModel, String chargeMethod, String openCondition ) {
+//        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+//        inputModel.setApplier(loginUser.getId());//在申请人
+//        inputModel.setPlatformType(DicPlatformType.OPEN);
+//        return microappService.doApply(inputModel,openCondition);
+//    }
+
+    @RequestMapping(value = "noFollow.action/{id}")
+    public String view(@PathVariable Long id){
+        ResultState  resultState  =  followService.noFollow(id);
+        if (StringUtils.isEmpty(resultState.getMsg())){
+            return InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/open/myMicroapp/list.htm?falg=1&msg="+resultState.getMsg()+"#shujv" ;
+        }
+        return InternalResourceViewResolver.REDIRECT_URL_PREFIX + "/open/myMicroapp/list.htm?falg=1#shujv" ;
+
+    }
+}

+ 74 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MyMicroappRequirementController.java

@@ -0,0 +1,74 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.dictionary.DicRequirmentAuditState;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.entity.Requirement;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.IMyMicroappRequirementService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+@Controller
+@RequestMapping(value = "/open/MyMicroappRequirement")
+public class MyMicroappRequirementController {
+    @Autowired
+    private IMyMicroappRequirementService myMicrroappRequirementService;
+
+    @RequestMapping(value = "list.action")
+    @ResponseBody
+    @RequiresAuthentication
+    public ModelAndView list(HttpSession session) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ModelAndView modelAndView = new ModelAndView("open/myrequirement/mymicroapp/list");
+        List<MyRequirementListModel> outputModel = myMicrroappRequirementService.selectOpenList(loginUser.getId());
+        modelAndView.addObject("list", outputModel);
+        return modelAndView;
+    }
+
+    @RequestMapping(value = "edit.action")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState<Long> edit(RequirementMicroappPublishModel inputModel){
+        return myMicrroappRequirementService.edit(inputModel);
+    }
+
+    /**
+     * 下架
+     * @param id
+     * @return
+     */
+    @RequestMapping(value = "offLine.action/{id}")
+    @ResponseBody
+    @RequiresAuthentication
+    public ResultState<Long> offLine(@PathVariable Long id){
+        Requirement requirement = myMicrroappRequirementService.selectRequirementById(id);
+        requirement.setRqrmntState(DicRequirmentAuditState.OFFSHELVES);
+        return myMicrroappRequirementService.offLine(requirement);
+    }
+
+
+    /**
+     * 我的接单列表
+     * @return
+     */
+    @RequestMapping(value = "receiveList.action/{id}")
+    @ResponseBody
+    @RequiresAuthentication
+    public ModelAndView receiveList(@PathVariable Long id) {
+        ModelAndView modelAndView = new ModelAndView("open/myrequirement/mymicroapp/receiveList");
+        List<APIReceiveListModel> outputModel = myMicrroappRequirementService.selectReceiveList(id);
+        modelAndView.addObject("list", outputModel);
+        return modelAndView;
+    }
+
+
+}

+ 36 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/MyReceiveController.java

@@ -0,0 +1,36 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.model.APIReceiveListModel;
+import com.lightinit.hsdataportal.model.LoginUser;
+import com.lightinit.hsdataportal.model.ReceiveListModel;
+import com.lightinit.hsdataportal.service.IMyReceiveService;
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+@Controller
+@RequestMapping(value = "/open/Receive")
+public class MyReceiveController {
+    @Autowired
+    private IMyReceiveService myReceiveService;
+    /**
+     * 我的接单列表
+     * @return
+     */
+    @RequestMapping(value = "receiveList.action")
+    @ResponseBody
+    @RequiresAuthentication
+    public ModelAndView receiveList(HttpSession session) {
+        LoginUser loginUser = (LoginUser) session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        ModelAndView modelAndView = new ModelAndView("open/myreceive/list");
+        List<ReceiveListModel> outputModel = myReceiveService.selectReceiveList(loginUser.getId());
+        modelAndView.addObject("list", outputModel);
+        return modelAndView;
+    }
+}

+ 50 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/NotificationOpenController.java

@@ -0,0 +1,50 @@
+package com.lightinit.hsdataportal.controller.open;
+
+import com.lightinit.hsdataportal.common.ConfigUtils;
+import com.lightinit.hsdataportal.common.SysContants;
+import com.lightinit.hsdataportal.dictionary.DicPlatformType;
+import com.lightinit.hsdataportal.dictionary.DicPublishSettingChargeMethod;
+import com.lightinit.hsdataportal.dictionary.DicResourceCatelogType;
+import com.lightinit.hsdataportal.dictionary.DicResourceType;
+import com.lightinit.hsdataportal.entity.BaseExample;
+import com.lightinit.hsdataportal.model.*;
+import com.lightinit.hsdataportal.service.INotificationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
+
+/**
+ * @Author: sunxiang
+ * @Date: 2018/7/11 14:54
+ * @Description:
+ **/
+@Controller
+@RequestMapping(value = "/open/notification")
+public class NotificationOpenController {
+    @Autowired
+    private INotificationService notificationService;
+    @RequestMapping(value="index.htm")
+    public ModelAndView getDataIndex(@RequestParam(defaultValue = "1") int pageNo, HttpSession session){
+        ModelAndView modelAndView = new ModelAndView("open/notification/index");
+        BaseExample.Page pager = new BaseExample.Page();
+        pager.setPageNo(pageNo);
+        LoginUser loginUser= (LoginUser)session.getAttribute(LoginUser.SESSION_KEY_LOGIN_USER);
+        long id=0;
+        if(loginUser!=null){
+            id=loginUser.getId();
+        }
+        List<NotificationListModel> outputModel=notificationService.getNotificationIndex(pager,id);
+        pager.setTotal(notificationService.getNotificationCount(id));
+        modelAndView.addObject("outputModel", outputModel);
+        modelAndView.addObject("pager",pager);
+        return modelAndView;
+    }
+
+}

+ 0 - 0
src/main/java/com/lightinit/hsdataportal/controller/open/OfflineConferenceOpenController.java


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません