Browse Source

sourceMerge0618

wangxiang 6 years ago
parent
commit
14f4d13b15
100 changed files with 14186 additions and 0 deletions
  1. 4 0
      README_重要.txt
  2. 528 0
      pom.xml
  3. 59 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/AdminLoginController.java
  4. 98 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/AdminMainController.java
  5. 44 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/TagController.java
  6. 282 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/cms/ArticleController.java
  7. 151 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/cms/CategoryController.java
  8. 15 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/RoleDao.java
  9. 10 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/UserDao.java
  10. 24 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/UserDaoCustom.java
  11. 64 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/UserDaoImpl.java
  12. 19 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/cms/ArticleDao.java
  13. 15 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/cms/ArticleDataDao.java
  14. 23 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/cms/CategoryDao.java
  15. 602 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/Page.java
  16. 104 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/Role.java
  17. 395 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/User.java
  18. 385 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/cms/Article.java
  19. 78 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/cms/ArticleData.java
  20. 329 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/cms/Category.java
  21. 102 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/cms/FileTpl.java
  22. 35 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/service/UserService.java
  23. 134 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/service/cms/ArticleService.java
  24. 55 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/service/cms/CategoryService.java
  25. 81 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/service/cms/FileTplService.java
  26. 146 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/CacheUtils.java
  27. 167 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/CmsUtils.java
  28. 98 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/Digests.java
  29. 95 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/DynamicSpecifications.java
  30. 171 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/Encodes.java
  31. 261 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/JsonMapper.java
  32. 167 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/PredicateModel.java
  33. 26 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/SearchFilter.java
  34. 133 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/SpecificationCreater.java
  35. 72 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/TplUtils.java
  36. 115 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/airline/controller/ArrivalController.java
  37. 120 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/airline/controller/DepartureController.java
  38. 137 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/airline/controller/DynamicflightController.java
  39. 32 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/airline/dao/AirLineDao.java
  40. 155 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/airline/model/AirLineEntity.java
  41. 31 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/airline/service/AirLineService.java
  42. 75 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/airline/service/impl/AirLineServiceImpl.java
  43. 85 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/airline/vo/AirDynamic.java
  44. 31 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/airline/vo/AirLine.java
  45. 139 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/busline/controller/BusLineController.java
  46. 32 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/busline/dao/BusLineDao.java
  47. 199 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/busline/model/BusLineEntity.java
  48. 33 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/busline/service/BusLineService.java
  49. 101 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/busline/service/impl/BusLineServiceImpl.java
  50. 45 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/busline/vo/BusLine.java
  51. 55 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/controller/CityEventController.java
  52. 27 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/dao/CityEventDao.java
  53. 161 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/model/CityEvent.java
  54. 24 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/service/CityEventService.java
  55. 37 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/service/impl/CityEventServiceImpl.java
  56. 133 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/controller/BusMainController.java
  57. 15 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/dao/BusMainDao.java
  58. 148 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/model/BusMain.java
  59. 16 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/service/BusMainService.java
  60. 65 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/service/impl/BusMainServiceImpl.java
  61. 42 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/vo/QueryParam.java
  62. 178 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/config/Global.java
  63. 425 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/constant/CommonConstant.java
  64. 38 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/constant/MessageConstant.java
  65. 34 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/constant/PageUrl.java
  66. 162 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/constant/SystemConstant.java
  67. 44 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/controller/BaseController.java
  68. 27 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/dao/DataDicDao.java
  69. 141 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/model/DataDic.java
  70. 260 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/Cryptos.java
  71. 123 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/Digests.java
  72. 123 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/ShiroDbRealm.java
  73. 217 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/cache/JedisCacheManager.java
  74. 274 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/session/JedisSessionDAO.java
  75. 25 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/session/SessionDAO.java
  76. 207 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/session/SessionManager.java
  77. 58 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/service/DataDicService.java
  78. 31 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/AvailableBooleanDeSerialize.java
  79. 52 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/AvailableBooleanSerialize.java
  80. 308 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/CollectionUtil.java
  81. 308 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/DateUtil.java
  82. 151 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/Encodes.java
  83. 73 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/Exceptions.java
  84. 968 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/FileUtils.java
  85. 68 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/IdGen.java
  86. 144 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/JacksonUtil.java
  87. 854 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/JedisUtils.java
  88. 99 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/MessageUtil.java
  89. 88 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/ObjectUtils.java
  90. 154 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/PropertiesLoader.java
  91. 107 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/SpringContextHolder.java
  92. 327 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/StringUtil.java
  93. 371 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/StringUtils.java
  94. 77 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/UserUtils.java
  95. 86 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/vo/InitQueryParam.java
  96. 84 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/vo/Paging.java
  97. 71 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/web/CKFinderConfig.java
  98. 82 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/web/CKFinderConnectorServlet.java
  99. 257 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/web/Servlets.java
  100. 65 0
      src/main/java/cn/com/liandisys/ycjt/ggcx/common/web/UserfilesDownloadServlet.java

+ 4 - 0
README_重要.txt

@@ -0,0 +1,4 @@
+服务器版本里此目录下文件千万不要删除,做全版本前要把服务器版本备份。
+\src\main\webapp\userfiles
+
+该文件夹下内容为用户使用资讯管理系统时上传的 图片等内容。

+ 528 - 0
pom.xml

@@ -0,0 +1,528 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>cn.com.liandisys</groupId>
+  <artifactId>ycjt-ggcx</artifactId>
+  <packaging>war</packaging>
+  <version>2.1-SNAPSHOT</version>
+  <name>ycjt-ggcx Maven Webapp</name>
+  <url>http://maven.apache.org</url>
+  
+  <!-- 定义相关属性 -->  
+  <properties>  
+    <jdk-version>1.7</jdk-version>  
+    <junit-version>4.11</junit-version>  
+    <spring-version>4.2.8.RELEASE</spring-version>
+    <shiro.version>1.2.2</shiro.version>
+    <ehcache.version>2.6.0</ehcache.version>
+    <jackson.version>2.2.3</jackson.version>
+    <commons-lang3.version>3.3.2</commons-lang3.version>
+	<commons-io.version>2.4</commons-io.version>
+    <commons-codec.version>1.9</commons-codec.version>
+    <commons-fileupload.version>1.3.1</commons-fileupload.version>
+    <guava.version>17.0</guava.version>
+    <ehcache.version>2.6.11</ehcache.version>
+	<ehcache-web.version>2.0.4</ehcache-web.version>
+	<sitemesh.version>2.4.2</sitemesh.version>
+  </properties> 
+   <!-- 设定除中央仓库(repo1.maven.org/maven2/)外的其他仓库,按设定顺序进行查找. -->
+	<repositories>
+		<!-- LDNS Nexus私服 -->
+		<repository>
+			<id>nexus</id>
+			<name>Team Nexus Repository</name>
+			<url>http://172.16.4.110:8081/nexus/content/groups/public</url>
+		</repository>
+	</repositories>
+	
+	<pluginRepositories>
+		<!-- 插件仓库 LDNS Nexus私服 -->
+		<pluginRepository>
+			<id>nexus</id>
+			<name>Team Nexus Repository</name>
+			<url>http://172.16.4.110:8081/nexus/content/groups/public</url>
+			<snapshots>
+				<enabled>false</enabled>
+			</snapshots>
+		</pluginRepository>
+	</pluginRepositories>
+  <!-- 设定除中央仓库(repo1.maven.org/maven2/)外的其他仓库,按设定顺序进行查找. -->
+  
+  <!-- 定义依赖包 -->  
+   <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    
+	<!-- spring begin-->
+    <dependency>
+    	<groupId>org.springframework</groupId>
+    	<artifactId>spring-core</artifactId>
+    	<version>${spring-version}</version>
+    	<exclusions>
+    		<exclusion>
+    			<artifactId>commons-logging</artifactId>
+    			<groupId>commons-logging</groupId>
+    		</exclusion>
+    	</exclusions>
+    </dependency>
+    
+    <dependency>
+    	<groupId>org.springframework</groupId>
+    	<artifactId>spring-beans</artifactId>
+    	<version>${spring-version}</version>
+    </dependency>
+    
+    <dependency>
+    	<groupId>org.springframework</groupId>
+    	<artifactId>spring-web</artifactId>
+    	<version>${spring-version}</version>
+    </dependency>
+    
+    <dependency>
+    	<groupId>org.springframework</groupId>
+    	<artifactId>spring-webmvc</artifactId>
+    	<version>${spring-version}</version>
+    </dependency>
+    
+    <dependency>
+    	<groupId>org.springframework</groupId>
+    	<artifactId>spring-context</artifactId>
+    	<version>${spring-version}</version>
+    </dependency>
+    
+    <dependency>
+    	<groupId>org.springframework.data</groupId>
+    	<artifactId>spring-data-jpa</artifactId>
+    	<version>1.7.0.RELEASE</version>
+    </dependency>
+    <!-- spring end-->
+    
+    <!-- hibernate begin -->  
+    <dependency>  
+        <groupId>org.hibernate</groupId>  
+        <artifactId>hibernate-core</artifactId>  
+        <version>4.2.1.Final</version>  
+    </dependency>  
+     
+     <dependency>  
+        <groupId>org.hibernate</groupId>  
+        <artifactId>hibernate-entitymanager</artifactId>  
+        <version>4.2.1.Final</version>  
+    </dependency>  
+    <dependency>  
+        <groupId>org.hibernate.common</groupId>  
+        <artifactId>hibernate-commons-annotations</artifactId>  
+        <version>4.0.1.Final</version>  
+    </dependency>
+    <dependency>
+		<groupId>org.hibernate</groupId>
+		<artifactId>hibernate-validator</artifactId>
+		<version>5.1.3.Final</version>
+	</dependency> 
+	<dependency>
+		<groupId>org.hibernate</groupId>
+		<artifactId>hibernate-c3p0</artifactId>
+		<version>4.2.1.Final</version>
+	</dependency> 
+    <!-- hibernate end -->
+    
+    <!-- SECURITY begin -->
+	<dependency>
+		<groupId>org.apache.shiro</groupId>
+		<artifactId>shiro-core</artifactId>
+		<version>${shiro.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>org.apache.shiro</groupId>
+		<artifactId>shiro-spring</artifactId>
+		<version>${shiro.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>org.apache.shiro</groupId>
+		<artifactId>shiro-cas</artifactId>
+		<version>${shiro.version}</version>
+		<exclusions>
+			<exclusion>
+				<groupId>commons-logging</groupId>
+				<artifactId>commons-logging</artifactId>
+			</exclusion>
+		</exclusions>
+	</dependency>
+	<dependency>
+		<groupId>org.apache.shiro</groupId>
+		<artifactId>shiro-web</artifactId>
+		<version>${shiro.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>org.apache.shiro</groupId>
+		<artifactId>shiro-ehcache</artifactId>
+		<version>${shiro.version}</version>
+	</dependency>
+	<!-- SECURITY end -->
+	
+	<!-- CACHE begin -->
+	<dependency>
+		<groupId>net.sf.ehcache</groupId>
+		<artifactId>ehcache-core</artifactId>
+		<version>${ehcache.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>net.sf.ehcache</groupId>  
+		<artifactId>ehcache-web</artifactId>  
+		<version>${ehcache-web.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>redis.clients</groupId>
+		<artifactId>jedis</artifactId>
+		 <version>2.5.1</version>
+	</dependency>
+	<!-- CACHE end -->
+    
+    <!-- jackson json -->
+	<dependency>
+		<groupId>com.fasterxml.jackson.core</groupId>
+		<artifactId>jackson-core</artifactId>
+		<version>${jackson.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>com.fasterxml.jackson.core</groupId>
+		<artifactId>jackson-databind</artifactId>
+		<version>${jackson.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>com.fasterxml.jackson.core</groupId>
+		<artifactId>jackson-annotations</artifactId>
+		<version>${jackson.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>com.fasterxml.jackson.module</groupId>
+		<artifactId>jackson-module-jaxb-annotations</artifactId>
+		<version>${jackson.version}</version>
+	</dependency>
+	
+	<!-- log begin -->
+    <dependency>
+	  <groupId>log4j</groupId>
+	  <artifactId>log4j</artifactId>
+	  <version>1.2.17</version>
+	</dependency>
+	 <dependency>  
+        <groupId>org.slf4j</groupId>  
+        <artifactId>slf4j-api</artifactId>  
+        <version>1.7.5</version>  
+    </dependency>  
+    <dependency>  
+        <groupId>org.slf4j</groupId>  
+        <artifactId>jcl-over-slf4j</artifactId>  
+        <version>1.7.5</version>  
+    </dependency>  
+    <dependency>  
+        <groupId>org.slf4j</groupId>  
+        <artifactId>slf4j-log4j12</artifactId>  
+        <version>1.7.5</version>  
+    </dependency> 
+	<dependency>
+	    <groupId>commons-logging</groupId>
+	    <artifactId>commons-logging</artifactId>
+	    <version>1.1.3</version>
+	</dependency> 
+    <!-- log end -->
+	
+	<!-- optional datasource pool -->
+	<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.6</version>
+	</dependency>
+	<!-- PERSISTENCE end -->
+	
+    <dependency>
+    	<groupId>org.springframework</groupId>
+    	<artifactId>spring-tx</artifactId>
+    	<version>4.0.9.RELEASE</version>
+    </dependency>
+    <dependency>
+		<groupId>jstl</groupId>
+		<artifactId>jstl</artifactId>
+		<version>1.2</version>
+	</dependency>
+    
+	<dependency>
+	    <groupId>commons-lang</groupId>
+	    <artifactId>commons-lang</artifactId>
+	    <version>2.6</version>
+	</dependency>
+	
+	<dependency>
+		<groupId>org.apache.commons</groupId>
+		<artifactId>commons-lang3</artifactId>
+		<version>${commons-lang3.version}</version>
+	</dependency>
+	<dependency>
+		<groupId>commons-io</groupId>
+		<artifactId>commons-io</artifactId>
+		<version>${commons-io.version}</version>
+	</dependency>
+	
+	<dependency>
+		<groupId>commons-codec</groupId>
+		<artifactId>commons-codec</artifactId>
+		<version>${commons-codec.version}</version>
+	</dependency>
+    <dependency>
+	    <groupId>commons-fileupload</groupId>
+	    <artifactId>commons-fileupload</artifactId>
+	    <version>${commons-fileupload.version}</version>
+	</dependency>
+	<dependency>
+	    <groupId>commons-collections</groupId>
+	    <artifactId>commons-collections</artifactId>
+	    <version>3.2.1</version>
+	</dependency>
+	
+	<dependency>
+	    <groupId>org.codehaus.jackson</groupId>
+	    <artifactId>jackson-mapper-asl</artifactId>
+	    <version>1.9.13</version>
+	</dependency>
+	
+	<dependency>
+	    <groupId>org.codehaus.jackson</groupId>
+	    <artifactId>jackson-core-asl</artifactId>
+	    <version>1.9.13</version>
+	</dependency>
+
+	<dependency>
+	  <groupId>com.oracle</groupId>
+	  <artifactId>ojdbc6</artifactId>
+	  <version>6_g</version>
+	</dependency>
+	
+	<!-- google java lib -->
+	<dependency>
+		<groupId>com.google.guava</groupId>
+		<artifactId>guava</artifactId>
+		<version>${guava.version}</version>
+	</dependency>
+    
+    <!-- log4jdbc -->
+	<dependency>
+		<groupId>org.bgee.log4jdbc-log4j2</groupId>
+		<artifactId>log4jdbc-log4j2-jdbc4</artifactId>
+		<version>1.16</version>
+		<scope>runtime</scope>
+	</dependency>
+	<!-- log4jdbc end -->
+	
+	<dependency>
+	    <groupId>org.codehaus.jackson</groupId>
+	    <artifactId>jackson-jaxrs</artifactId>
+	    <version>1.9.13</version>
+	</dependency>
+	
+    <dependency>
+    	<groupId>net.sf.json-lib</groupId>
+    	<artifactId>json-lib</artifactId>
+    	<version>2.2.3</version>
+    	<classifier>jdk13</classifier>
+    </dependency>
+   	<dependency>
+	    <groupId>org.springframework.data</groupId>
+	    <artifactId>spring-data-commons</artifactId>
+	    <version>1.9.0.RELEASE</version>
+	</dependency>
+	
+	<dependency>
+		<groupId>opensymphony</groupId>
+		<artifactId>sitemesh</artifactId>
+		<version>${sitemesh.version}</version>
+	</dependency>
+	
+	<!-- CKFinder begin -->
+	<dependency>
+		<groupId>net.coobird</groupId>
+		<artifactId>thumbnailator</artifactId>
+		<version>0.4.2</version>
+	</dependency>
+	<dependency>
+		<groupId>com.ckfinder</groupId>
+		<artifactId>apache-ant-zip</artifactId>
+		<version>2.3</version>
+	</dependency>
+	<dependency>
+		<groupId>com.ckfinder</groupId>
+		<artifactId>ckfinder</artifactId>
+		<version>2.3</version>
+	</dependency>
+	<dependency>
+		<groupId>com.ckfinder</groupId>
+		<artifactId>ckfinderplugin-fileeditor</artifactId>
+		<version>2.3</version>
+	</dependency>
+	<dependency>
+		<groupId>com.ckfinder</groupId>
+		<artifactId>ckfinderplugin-imageresize</artifactId>
+		<version>2.3</version>
+	</dependency>
+	<dependency>
+	 	<groupId>org.jsoup</groupId>
+	 	<artifactId>jsoup</artifactId>
+	 	<version>1.10.1</version>
+	 </dependency>
+	<!-- CKFinder end -->
+	<dependency>
+		<groupId>org.apache.axis2</groupId>
+		<artifactId>axis2-adb</artifactId>
+		<version>1.7.1</version>
+		 <exclusions>  
+            <exclusion>  
+                <groupId>javax.servlet</groupId>  
+                <artifactId>servlet-api</artifactId>  
+            </exclusion>  
+        </exclusions>
+	</dependency>
+	<!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-transport-local -->
+	<dependency>
+	    <groupId>org.apache.axis2</groupId>
+	    <artifactId>axis2-transport-local</artifactId>
+	    <version>1.7.1</version>
+	</dependency>
+	<!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-transport-http -->
+	<dependency>
+	    <groupId>org.apache.axis2</groupId>
+	    <artifactId>axis2-transport-http</artifactId>
+	    <version>1.7.1</version>
+	</dependency>
+	<!-- axis 1.4 jar start -->
+        <dependency>
+            <groupId>org.apache.axis</groupId>
+            <artifactId>axis</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-discovery</groupId>
+            <artifactId>commons-discovery</artifactId>
+            <version>0.2</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>commons-logging</groupId>
+                    <artifactId>commons-logging</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis</groupId>
+            <artifactId>axis-jaxrpc</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis</groupId>
+            <artifactId>axis-saaj</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>wsdl4j</groupId>
+            <artifactId>wsdl4j</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <!-- axis 1.4 jar end -->
+       <dependency>
+		    <groupId>org.jdom</groupId>
+		    <artifactId>jdom</artifactId>
+		    <version>1.1.2</version>
+		</dependency>
+		<dependency>
+		    <groupId>com.alibaba</groupId>
+		    <artifactId>fastjson</artifactId>
+		    <version>1.2.31</version>
+		</dependency>
+		<!-- 		增加类似说明,防止报错 -->
+		 <dependency>
+            <groupId>jaxen</groupId>
+            <artifactId>jaxen</artifactId>
+            <version>1.1.3</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>maven-cobertura-plugin</artifactId>
+                    <groupId>maven-plugins</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>maven-findbugs-plugin</artifactId>
+                    <groupId>maven-plugins</groupId>
+                </exclusion>
+            </exclusions>
+		</dependency>
+		<!-- 		APP消息推送 -->
+		<dependency>
+		    <groupId>cn.jpush.api</groupId>
+		    <artifactId>jpush-client</artifactId>
+		    <version>3.3.0</version>
+		</dependency>
+		 <dependency>
+		        <groupId>cn.jpush.api</groupId>
+		        <artifactId>jiguang-common</artifactId>
+		        <version>1.0.8</version>
+	    </dependency>
+	    <dependency>
+	        <groupId>io.netty</groupId>
+	        <artifactId>netty-all</artifactId>
+	        <version>4.1.6.Final</version>
+	        <scope>compile</scope>
+	    </dependency>
+	    <dependency>
+	        <groupId>com.google.code.gson</groupId>
+	        <artifactId>gson</artifactId>
+	        <version>2.3</version>
+	    </dependency>
+	    <dependency>
+	        <groupId>org.slf4j</groupId>
+	        <artifactId>slf4j-api</artifactId>
+	        <version>1.7.7</version>
+	    </dependency>
+	
+	    <!-- For log4j -->
+	    <dependency>
+	        <groupId>org.slf4j</groupId>
+	        <artifactId>slf4j-log4j12</artifactId>
+	        <version>1.7.7</version>
+	    </dependency>
+	    <dependency>
+	        <groupId>log4j</groupId>
+	        <artifactId>log4j</artifactId>
+	        <version>1.2.17</version>
+	    </dependency>
+		
+  </dependencies>
+    
+  <!-- 配置构建 -->  
+  <build>  
+    <plugins>
+			<!-- 指定JDK版本 -->
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.1</version>
+				<configuration>
+					<source>1.7</source>
+					<target>1.7</target>
+					<encoding>UTF-8</encoding>
+				</configuration>
+			</plugin>
+			<!-- ant插件 -->
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-antrun-plugin</artifactId>
+				<version>${jdk-version}</version>
+			</plugin>
+		</plugins>
+ </build>  
+</project>

+ 59 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/AdminLoginController.java

@@ -0,0 +1,59 @@
+package cn.com.liandisys.ycjt.ggcx.admin.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.shiro.SecurityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+import cn.com.liandisys.ycjt.ggcx.common.security.shiro.session.SessionDAO;
+import cn.com.liandisys.ycjt.ggcx.common.util.UserUtils;
+
+/**
+ * 后台管理登录控制器
+ * @author jiangchao
+ * @version 2016-11-28
+ */
+@Controller
+@RequestMapping(value = "/admin")
+public class AdminLoginController {
+	
+	protected Logger logger = LoggerFactory.getLogger(AdminLoginController.class);
+
+	@Autowired
+	private SessionDAO sessionDAO;
+	
+	@RequestMapping(value = "/login", method = RequestMethod.GET)
+	public String login(HttpServletRequest request, HttpServletResponse response, Model model) {
+		User principal = UserUtils.getPrincipal();
+		if (logger.isDebugEnabled()){
+			logger.debug("login, active session size: {}", sessionDAO.getActiveSessions(false).size());
+		}
+		if(principal != null){
+			return "redirect:/admin/main";
+		}
+		return "admin/login";
+	}
+	
+	@RequestMapping(value="/login",method=RequestMethod.POST)
+    public String login(String loginName,String password,Model model) {
+    	if (SecurityUtils.getSubject().isAuthenticated()) {
+			return "redirect:/admin/main";
+		}
+    	model.addAttribute("message","用户名或密码不正确");
+		return "admin/login";
+    }
+	
+	@RequestMapping(value = "/exit", method = RequestMethod.GET)
+	public String exit(Model model) {
+	    SecurityUtils.getSubject().logout();
+	    return "admin/login";
+	}
+}

+ 98 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/AdminMainController.java

@@ -0,0 +1,98 @@
+package cn.com.liandisys.ycjt.ggcx.admin.controller;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.subject.Subject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+import cn.com.liandisys.ycjt.ggcx.admin.service.UserService;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.Digests;
+import cn.com.liandisys.ycjt.ggcx.common.util.UserUtils;
+
+
+
+
+/**
+ * 后台管理登录控制器
+ * @author jiangchao
+ * @version 2016-11-28
+ */
+@Controller
+@RequestMapping(value = "/admin")
+public class AdminMainController {
+	
+	protected Logger logger = LoggerFactory.getLogger(AdminMainController.class);
+	@Autowired
+	private UserService userService;
+	
+	@RequestMapping(value = "/main", method = RequestMethod.GET)
+    public String main() {
+        return "admin/main";
+    }
+	
+	/**
+	 * 跳转到密码修改页面
+	 * @return 密码设定页面
+	 */
+	@RequestMapping(value="/passwordMng", method=RequestMethod.GET)
+	public String list(){
+		return "admin/accountMng/passwordMng";
+	}
+	
+	/**
+	 * 修改密码
+	 * @param passwordOld 旧密码
+	 * @param passwordNew 新密码
+	 * @return
+	 * @throws IOException
+	 */
+	@RequestMapping(value="/save", method=RequestMethod.POST)
+	@ResponseBody
+	public  Map<String, Object> PasswordSave(@RequestParam("oldPassword")String passwordOld,
+        @RequestParam("newPassword")String passwordNew,Model model) throws IOException{
+		 Map<String, Object> result = new HashMap<String, Object>();
+		Subject subject = SecurityUtils.getSubject();
+		User userTemp=(User) subject.getPrincipal();
+	    String loginname = userTemp.getLoginName();
+	    //获得新密码
+	    User user=userService.findByLoginName(loginname);
+	    String password=user.getPassword();
+	    //密码加密
+	    String passwordtemp =Digests.md5Hex(new ByteArrayInputStream(passwordOld.getBytes()));
+	    //比较输入旧密码是否正确
+	    if(!password.equals(passwordtemp)){
+	    	result.put("result", "error");
+	        result.put("msg", "请输入正确的旧密码");
+	        return result;
+	    }
+	    passwordNew = Digests.md5Hex(new ByteArrayInputStream(passwordNew.getBytes()));
+	    user.setPassword(passwordNew);
+	    try{
+	    	 userService.saveUser(user);
+	    	 result.put("result", "ok");
+	    }catch(Exception e){
+	       e.toString();
+	       result.put("result", "error");
+           result.put("msg", "更新密码失败!");
+           return result;
+	    }
+	    result.put("msg", "更新密码成功!");
+        return result;
+	}
+	
+	
+}

+ 44 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/TagController.java

@@ -0,0 +1,44 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.admin.controller;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * 标签Controller
+ * @author ThinkGem
+ * @version 2013-3-23
+ */
+@Controller
+@RequestMapping(value = "admin/tag")
+public class TagController{
+	
+	/**
+	 * 树结构选择标签(treeselect.tag)
+	 */
+	@RequestMapping(value = "treeselect")
+	public String treeselect(HttpServletRequest request, Model model) {
+		model.addAttribute("url", request.getParameter("url")); 	// 树结构数据URL
+		model.addAttribute("extId", request.getParameter("extId")); // 排除的编号ID
+		model.addAttribute("checked", request.getParameter("checked")); // 是否可复选
+		model.addAttribute("selectIds", request.getParameter("selectIds")); // 指定默认选中的ID
+		model.addAttribute("isAll", request.getParameter("isAll")); 	// 是否读取全部数据,不进行权限过滤
+		model.addAttribute("module", request.getParameter("module"));	// 过滤栏目模型(仅针对CMS的Category树)
+		return "admin/tag/tagTreeselect";
+	}
+	
+	/**
+	 * 图标选择标签(iconselect.tag)
+	 */
+	@RequestMapping(value = "iconselect")
+	public String iconselect(HttpServletRequest request, Model model) {
+		model.addAttribute("value", request.getParameter("value"));
+		return "admin/tag/tagIconselect";
+	}
+	
+}

+ 282 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/cms/ArticleController.java

@@ -0,0 +1,282 @@
+package cn.com.liandisys.ycjt.ggcx.admin.controller.cms;
+
+import java.io.UnsupportedEncodingException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.PropertyResourceBundle;
+
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+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.mvc.support.RedirectAttributes;
+
+import com.google.common.collect.Maps;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Article;
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Category;
+import cn.com.liandisys.ycjt.ggcx.admin.service.cms.ArticleService;
+import cn.com.liandisys.ycjt.ggcx.admin.service.cms.CategoryService;
+import cn.com.liandisys.ycjt.ggcx.admin.service.cms.FileTplService;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.CmsUtils;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.DynamicSpecifications;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.JsonMapper;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.SearchFilter;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.SearchFilter.Operator;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.TplUtils;
+import cn.com.liandisys.ycjt.ggcx.common.constant.CommonConstant;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtils;
+import cn.jiguang.common.ClientConfig;
+import cn.jiguang.common.resp.APIConnectionException;
+import cn.jiguang.common.resp.APIRequestException;
+import cn.jpush.api.JPushClient;
+import cn.jpush.api.push.PushResult;
+import cn.jpush.api.push.model.PushPayload;
+
+/**
+ * 内容管理-文章控制器
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+@Controller
+@RequestMapping(value = "/admin/cms/article")
+public class ArticleController {
+
+    @Autowired
+    private ArticleService articleService;
+
+    @Autowired
+    private CategoryService categoryService;
+
+    @Autowired
+    private FileTplService fileTplService;
+
+    //本地自己调试使用
+    //    private String masterKey = "50c1b278c274f1405514bc6f";
+    //
+    //    private String appKey = "583704c2ba9c55d1be353f0c";
+
+    //服务器打版本使用
+    //    private String masterKey = "4b2cb195a6de02a1b1b7e3b3";
+    //
+    //    private String appKey = "9e337475066ef829430d8ccf";
+
+    // properties 配置文件名称
+    PropertyResourceBundle res = (PropertyResourceBundle) PropertyResourceBundle.getBundle("application");
+
+    // 获取properties配置文件中的属性值
+    String masterKey = res.getString("masterKey");
+
+    String appKey = res.getString("appKey");
+
+    @RequestMapping(value = "/list")
+    public String list(Model model, @ModelAttribute("pageRequest") PageRequest pageRequest,
+            @RequestParam(value = "category.id", required = false, defaultValue = "") String categoryId,
+            @RequestParam(value = "title", required = false, defaultValue = "") String title, String message) {
+
+        Map<String, SearchFilter> filters = Maps.newHashMap();
+        if (!categoryId.equals("")) {
+            filters.put("category.id", new SearchFilter("category.id", Operator.EQ, categoryId));
+            Category category = categoryService.findOne(categoryId);
+            model.addAttribute("categoryId", categoryId);
+            model.addAttribute("categoryName", category.getName());
+        }
+        if (!title.equals("")) {
+            filters.put("title", new SearchFilter("title", Operator.LIKE, title));
+            model.addAttribute("title", title);
+        }
+        Specification<Article> spec = DynamicSpecifications.bySearchFilter(filters.values(), Article.class);
+        Page<Article> jpaPage = articleService.findAll(spec, pageRequest);
+        cn.com.liandisys.ycjt.ggcx.admin.model.Page<Article> page =
+                new cn.com.liandisys.ycjt.ggcx.admin.model.Page<Article>(jpaPage.getNumber() + 1, jpaPage.getSize(),
+                        jpaPage.getTotalElements());
+        page.setList(jpaPage.getContent());
+        model.addAttribute("page", page);
+        model.addAttribute("message", message);
+        //System.out.println(masterKey);
+        //System.out.println(appKey);
+        return "admin/cms/articleList";
+
+    }
+
+    @RequestMapping(value = "form")
+    public String form(Article article, Model model,
+            @RequestParam(value = "TempcategoryId", required = false, defaultValue = "") String TempcategoryId) {
+
+        // 如果当前传参有子节点,则选择取消传参选择
+        if (article.getCategory() != null && StringUtils.isNotBlank(article.getCategory().getId())) {
+            List<Category> list = categoryService.findByParentId(article.getCategory().getId());
+            if (list.size() > 0) {
+                article.setCategory(null);
+            } else {
+                article.setCategory(categoryService.findOne(article.getCategory().getId()));//获得文章父级节点
+            }
+        }
+        model.addAttribute("contentViewList", getTplContent());
+        model.addAttribute("article_DEFAULT_TEMPLATE", Article.DEFAULT_TEMPLATE);
+        model.addAttribute("article", article);
+        model.addAttribute("TempcategoryId", TempcategoryId);
+        CmsUtils.addViewConfigAttribute(model, article.getCategory());
+        return "admin/cms/articleForm";
+    }
+
+    /**
+     * 文章选择列表
+     */
+    @RequiresPermissions("cms:article:view")
+    @RequestMapping(value = "selectList")
+    public String selectList(Article article, @ModelAttribute("pageRequest") PageRequest pageRequest, Model model,
+            @RequestParam(value = "category.id", required = false, defaultValue = "") String categoryId,
+            @RequestParam(value = "title", required = false, defaultValue = "") String title) {
+
+        Map<String, SearchFilter> filters = Maps.newHashMap();
+        if (!categoryId.equals("")) {
+            filters.put("category.id", new SearchFilter("category.id", Operator.EQ, categoryId));
+        }
+        if (!title.equals("")) {
+            filters.put("sex", new SearchFilter("title", Operator.LIKE, title));
+        }
+        Specification<Article> spec = DynamicSpecifications.bySearchFilter(filters.values(), Article.class);
+        Page<Article> jpaPage = articleService.findAll(spec, pageRequest);
+        cn.com.liandisys.ycjt.ggcx.admin.model.Page<Article> page =
+                new cn.com.liandisys.ycjt.ggcx.admin.model.Page<Article>(jpaPage.getNumber() + 1, jpaPage.getSize(),
+                        jpaPage.getTotalElements());
+        page.setList(jpaPage.getContent());
+        model.addAttribute("page", page);
+        return "admin/cms/articleSelectList";
+    }
+
+    //保存按钮的功能
+    @RequestMapping(value = "save")
+    public String save(Article article, Model model, RedirectAttributes redirectAttributes,
+            @RequestParam(value = "TempcategoryId", required = false, defaultValue = "") String TempcategoryId)
+            throws UnsupportedEncodingException, APIConnectionException, APIRequestException {
+
+    	// 如设置发布时间,则用发布时间覆盖创建时间
+    	if (article.getPublisheDate()!=null && article.getPublisheDate()!="") {
+    		DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    		try {
+				Date date = format.parse(article.getPublisheDate());
+			    article.setCreateDate(date);
+			} catch (ParseException e) {
+				// TODO Auto-generated catch block
+				//e.printStackTrace();
+				article.setCreateDate(new Date());
+			}  
+    	} else {
+    		if (article.getCreateDate() !=null) {
+    			
+    		} else {
+    			article.setCreateDate(new Date());
+    		}
+    	}
+    	
+        articleService.save(article);
+        redirectAttributes.addAttribute("message", "保存文章'" + StringUtils.abbr(article.getTitle(), 50) + "'成功");
+        redirectAttributes.addAttribute("category.id", TempcategoryId);
+
+        // 栏目区分为 2:交通要闻时 发推送消息
+        if (article.getCategory() != null && "2".equals(article.getCategory().getId()) 
+        		&& "1".equals(article.getAppIndexView())) {
+            sendMessage(article.getTitle());
+        }
+
+        return "redirect:list";
+    }
+
+    private void sendMessage(String message) throws APIConnectionException, APIRequestException {
+
+        JPushClient jpushClient = new JPushClient(masterKey, appKey, null, ClientConfig.getInstance());
+        PushPayload payload = buildPushObject_all_all_alert(message);
+        try {
+            PushResult result = jpushClient.sendPush(payload);
+        } catch (APIConnectionException e) {
+            System.out.println(e);
+            throw e;
+        } catch (APIRequestException e) {
+            System.out.println(e);
+            throw e;
+        }
+    }
+
+    public static PushPayload buildPushObject_all_all_alert(String message) {
+
+        return PushPayload.alertAll(message);
+    }
+
+    @RequestMapping(value = "delete")
+    public String delete(Article article, RedirectAttributes redirectAttributes) {
+
+        articleService.delete(article);
+        redirectAttributes.addAttribute("message", "删除文章成功");
+        return "redirect:list";
+    }
+
+    /**
+     * 通过编号获取文章标题
+     */
+    @ResponseBody
+    @RequestMapping(value = "findByIds")
+    public String findByIds(String ids) {
+
+        List<Object[]> list = articleService.findByIds(ids);
+        return JsonMapper.nonDefaultMapper().toJson(list);
+    }
+
+    @ModelAttribute("article")
+    public Article getArticle(@RequestParam(required = false) String id) {
+
+        if (StringUtils.isNotBlank(id)) {
+        	Article article = articleService.findOne(id);
+        	if (article != null) {
+        		if (article.getAppIndexView()=="" || article.getAppIndexView() == null) {
+        			article.setAppIndexView("0");
+        		}
+        		if (article.getAppInfoView()=="" || article.getAppInfoView() == null) {
+        			article.setAppInfoView("0");
+        		}
+        	}
+            return article;
+        } else {
+            return new Article();
+        }
+    }
+
+    /**
+     * 分页信息获取
+     * 
+     */
+    @ModelAttribute("pageRequest")
+    public PageRequest getPageRequest(@RequestParam(value = "pageNo", required = false, defaultValue = "1") String page,
+            @RequestParam(value = "pageSize", required = false, defaultValue = "20") String size) {
+
+        Sort sort = new Sort(Direction.DESC, new String[] { "updateDate" });
+        if (org.springframework.util.StringUtils.hasText(page) && org.springframework.util.StringUtils.hasText(size)
+                && null != sort) {
+            // 页码从0开始
+            PageRequest pageable = new PageRequest(Integer.parseInt(page) - 1, Integer.parseInt(size), sort);
+            return pageable;
+        }
+        return null;
+    }
+
+    private List<String> getTplContent() {
+
+        List<String> tplList = fileTplService.getNameListByPrefix(CommonConstant.TPL_BASE);
+        tplList = TplUtils.tplTrim(tplList, Article.DEFAULT_TEMPLATE, "");
+        return tplList;
+    }
+}

+ 151 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/controller/cms/CategoryController.java

@@ -0,0 +1,151 @@
+package cn.com.liandisys.ycjt.ggcx.admin.controller.cms;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+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.mvc.support.RedirectAttributes;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Article;
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Category;
+import cn.com.liandisys.ycjt.ggcx.admin.service.cms.ArticleService;
+import cn.com.liandisys.ycjt.ggcx.admin.service.cms.CategoryService;
+import cn.com.liandisys.ycjt.ggcx.admin.service.cms.FileTplService;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.TplUtils;
+import cn.com.liandisys.ycjt.ggcx.common.constant.CommonConstant;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtils;
+
+/**
+ * 内容管理-栏目控制器
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+@Controller
+@RequestMapping(value = "/admin/cms/category")
+public class CategoryController {
+	
+	public static final String TOP_CATEGORY_ID = "1";
+
+	@Autowired
+	private CategoryService categoryService;
+	@Autowired
+	private FileTplService fileTplService;
+	@Autowired
+	private ArticleService articleService;
+	
+	@RequestMapping(value="/list")
+	public String list(Model model,String message){
+		Sort sort = new Sort(Direction.ASC, new String[] { "sort" });
+		List<Category> list = categoryService.findAll(sort);
+		List<Category> sortList = Lists.newArrayList();
+		Category.sortList(sortList, list, null);
+		model.addAttribute("list", sortList);
+		model.addAttribute("message", message);
+		return "admin/cms/categoryList";
+	}
+	
+	@RequestMapping(value = "form")
+	public String form(Category category, Model model) {
+		if ((category.getParent()==null||category.getParent().getId()==null)&&!TOP_CATEGORY_ID.equals(category.getId())){
+			category.setParent(new Category(TOP_CATEGORY_ID));
+			Category parent = categoryService.findOne(category.getParent().getId());
+			category.setParent(parent);
+		}
+		model.addAttribute("listViewList",getTplContent(Category.DEFAULT_TEMPLATE));
+        model.addAttribute("category_DEFAULT_TEMPLATE",Category.DEFAULT_TEMPLATE);
+        model.addAttribute("contentViewList",getTplContent(Article.DEFAULT_TEMPLATE));
+        model.addAttribute("article_DEFAULT_TEMPLATE",Article.DEFAULT_TEMPLATE);
+		model.addAttribute("category", category);
+		return "admin/cms/categoryForm";
+	}
+	
+	@RequestMapping(value = "save")
+	public String save(Category category, Model model, RedirectAttributes redirectAttributes) {
+		categoryService.save(category);
+		redirectAttributes.addAttribute("message", "保存栏目'" + category.getName() + "'成功");
+		return "redirect:list";
+	}
+	
+	@RequestMapping(value = "updateSort")
+	public String updateSort(String[] ids, Integer[] sorts,RedirectAttributes redirectAttributes) {
+    	int len = ids.length;
+    	Category[] entitys = new Category[len];
+    	for (int i = 0; i < len; i++) {
+    		entitys[i] = categoryService.findOne(ids[i]);
+    		entitys[i].setSort(sorts[i]);
+    		categoryService.save(entitys[i]);
+    	}
+    	redirectAttributes.addAttribute("message", "保存栏目排序成功!");
+		return "redirect:list";
+	}
+	
+	@RequestMapping(value = "delete")
+	public String delete(Category category, RedirectAttributes redirectAttributes) {
+		if (Category.isRoot(category.getId())){
+			redirectAttributes.addAttribute("message", "删除栏目失败, 不允许删除顶级栏目或编号为空");
+			return "redirect:list";
+		}
+		List<Category> children = categoryService.findByParentId(category.getId());
+		if(children!=null && children.size()>0){
+			redirectAttributes.addAttribute("message", "删除栏目失败, 请先删除"+category.getName()+"栏目下的子级栏目");
+			return "redirect:list";
+		}
+		List<Article> articles = articleService.findByCategoryId(category.getId());
+		if(articles!=null && articles.size()>0){
+			redirectAttributes.addAttribute("message", "删除栏目失败, 请先删除"+category.getName()+"栏目下的文章");
+			return "redirect:list";
+		}
+		categoryService.delete(category);
+		redirectAttributes.addAttribute("message", "删除栏目成功");
+		return "redirect:list";
+	}
+	
+	@ModelAttribute("category")
+	public Category getCategory(@RequestParam(required=false) String id){
+		if (StringUtils.isNotBlank(id)){
+			return categoryService.findOne(id);
+		}else{
+			return new Category();
+		}
+	}
+	
+	@ResponseBody
+	@RequestMapping(value = "treeData")
+	public List<Map<String, Object>> treeData(String module, @RequestParam(required=false) String extId, HttpServletResponse response) {
+		response.setContentType("application/json; charset=UTF-8");
+		List<Map<String, Object>> mapList = Lists.newArrayList();
+		Sort sort = new Sort(Direction.ASC, new String[] { "sort" });
+		List<Category> list = categoryService.findAll(sort);
+		for (int i=0; i<list.size(); i++){
+			Category e = list.get(i);
+			if (extId == null || (extId!=null && !extId.equals(e.getId()))){
+				Map<String, Object> map = Maps.newHashMap();
+				map.put("id", e.getId());
+				map.put("pId", e.getParent()!=null?e.getParent().getId():0);
+				map.put("name", e.getName());
+				map.put("module", e.getModule());
+				mapList.add(map);
+			}
+		}
+		return mapList;
+	}
+	
+	private List<String> getTplContent(String prefix) {
+   		List<String> tplList = fileTplService.getNameListByPrefix(CommonConstant.TPL_BASE);
+   		tplList = TplUtils.tplTrim(tplList, prefix, "");
+   		return tplList;
+   	}
+}

+ 15 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/RoleDao.java

@@ -0,0 +1,15 @@
+package cn.com.liandisys.ycjt.ggcx.admin.dao;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.Role;
+
+/**
+ * 角色对象的DAO interface.
+ * 
+ * @author jiangchao
+ */
+public interface RoleDao extends JpaRepository<Role, String>, JpaSpecificationExecutor<Role> {
+
+}

+ 10 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/UserDao.java

@@ -0,0 +1,10 @@
+package cn.com.liandisys.ycjt.ggcx.admin.dao;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+
+public interface UserDao extends JpaRepository<User, String>, JpaSpecificationExecutor<User>, UserDaoCustom {
+
+}

+ 24 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/UserDaoCustom.java

@@ -0,0 +1,24 @@
+package cn.com.liandisys.ycjt.ggcx.admin.dao;
+
+import java.util.List;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+
+/**
+ * UserDao的扩展行为interface.
+ * 
+ * @author jiangb
+ * 
+ */
+public interface UserDaoCustom {
+
+	public List<User> findAllUsers();
+
+	public User findByLoginName(String loginName);
+
+	public List<User> findByOrgId(String orgid);
+	
+	public List<User> findUserByName(String name);
+	
+	public List<User> findUserByWorkno(String workno);
+}

+ 64 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/UserDaoImpl.java

@@ -0,0 +1,64 @@
+package cn.com.liandisys.ycjt.ggcx.admin.dao;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.springframework.stereotype.Component;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+
+/**
+ * UserDaoCustom的扩展行为实现类.
+ */
+@Component
+public class UserDaoImpl implements UserDaoCustom {
+
+    private static final String QUERY_ALL_USER          = "select user from User user where user.avaliable='Y' ";
+
+    private static final String QUERY_USER_BY_LOGINNAME = "select user from User user where user.avaliable='Y' and user.loginName = :loginName";
+
+    private static final String QUERY_USER_BY_ORG       = "select user from User user where user.specialOrg.id = :orgId";
+    
+    private static final String QUERY_USER_BY_NAME = "select user from User user where user.avaliable='Y' and user.name = :name";
+    
+    private static final String QUERY_USER_BY_WORKNO = "select user from User user where user.avaliable='Y' and user.workno = :workno";
+
+    @PersistenceContext
+    private EntityManager       em;
+
+    @SuppressWarnings("unchecked")
+    public List<User> findAllUsers() {
+        List<User> list = em.createQuery(QUERY_ALL_USER).getResultList();
+        return list;
+    }
+
+    public User findByLoginName(String loginName) {
+        User User = (User) em.createQuery(QUERY_USER_BY_LOGINNAME)
+                .setParameter("loginName", loginName).getSingleResult();
+        return User;
+    }
+    
+    @SuppressWarnings("unchecked")
+	public List<User> findUserByName(String name) {
+    	List<User> list = em.createQuery(QUERY_USER_BY_NAME)
+                .setParameter("name", name).getResultList();
+        return list;
+    }
+    
+    @SuppressWarnings("unchecked")
+	public List<User> findUserByWorkno(String workno) {
+    	List<User> list = em.createQuery(QUERY_USER_BY_WORKNO)
+                .setParameter("workno", workno).getResultList();
+        return list;
+    }
+
+    @SuppressWarnings("unchecked")
+    public List<User> findByOrgId(String orgId) {
+        List<User> list = em.createQuery(QUERY_USER_BY_ORG).setParameter("orgId", orgId)
+                .getResultList();
+        return list;
+    }
+
+}

+ 19 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/cms/ArticleDao.java

@@ -0,0 +1,19 @@
+package cn.com.liandisys.ycjt.ggcx.admin.dao.cms;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Article;
+
+/**
+ * 文章实体的DAO interface.
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+public interface ArticleDao extends JpaRepository<Article, String>, JpaSpecificationExecutor<Article> {
+
+	List<Article> findByCategoryId(String categoryId);
+
+}

+ 15 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/cms/ArticleDataDao.java

@@ -0,0 +1,15 @@
+package cn.com.liandisys.ycjt.ggcx.admin.dao.cms;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.ArticleData;
+
+/**
+ * 文章实体的DAO interface.
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+public interface ArticleDataDao extends JpaRepository<ArticleData, String>, JpaSpecificationExecutor<ArticleData> {
+
+}

+ 23 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/dao/cms/CategoryDao.java

@@ -0,0 +1,23 @@
+package cn.com.liandisys.ycjt.ggcx.admin.dao.cms;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Category;
+
+/**
+ * 文章栏目实体的DAO interface.
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+public interface CategoryDao extends JpaRepository<Category, String>, JpaSpecificationExecutor<Category> {
+
+	@Query(value="select c from Category c where c.parent.id =?1 order by sort asc")
+	List<Category> findByParentId(String id);
+
+	@Query(value="select c from Category c where c.parent.id =?1 and c.module='article' order by sort asc")
+	List<Category> findByParentIdByArticle(String id);
+}

+ 602 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/Page.java

@@ -0,0 +1,602 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.admin.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * 分页类
+ * @author ThinkGem
+ * @version 2013-7-2
+ * @param <T>
+ */
+public class Page<T> {
+
+    private int pageNo = 1; // 当前页码
+
+    private int pageSize = 10; // 页面大小,设置为“-1”表示不进行分页(分页无效)
+
+    private long count;// 总记录数,设置为“-1”表示不查询总数
+
+    private int first;// 首页索引
+
+    private int last;// 尾页索引
+
+    private int prev;// 上一页索引
+
+    private int next;// 下一页索引
+
+    private boolean firstPage;//是否是第一页
+
+    private boolean lastPage;//是否是最后一页
+
+    private int length = 8;// 显示页面长度
+
+    private int slider = 1;// 前后显示页面长度
+
+    private List<T> list = new ArrayList<T>();
+
+    private String orderBy = ""; // 标准查询有效, 实例: updatedate desc, name asc
+
+    private String funcName = "page"; // 设置点击页码调用的js函数名称,默认为page,在一页有多个分页对象时使用。
+
+    private String funcParam = ""; // 函数的附加参数,第三个参数值。
+
+    private String message = ""; // 设置提示消息,显示在“共n条”之后
+
+    public Page() {
+        this.pageSize = -1;
+    }
+
+    /**
+     * 构造方法
+     * @param request 传递 repage 参数,来记住页码
+     * @param response 用于设置 Cookie,记住页码
+     */
+    public Page(HttpServletRequest request, HttpServletResponse response) {
+        this(request, response, -2);
+    }
+
+    /**
+     * 构造方法
+     * @param request 传递 repage 参数,来记住页码
+     * @param response 用于设置 Cookie,记住页码
+     * @param defaultPageSize 默认分页大小,如果传递 -1 则为不分页,返回所有数据
+     */
+    public Page(HttpServletRequest request, HttpServletResponse response, int defaultPageSize) {
+        // 设置页码参数(传递repage参数,来记住页码)
+        String no = request.getParameter("pageNo");
+        if (StringUtils.isNumeric(no)) {
+            this.setPageNo(Integer.parseInt(no));
+        } else if (request.getParameter("repage") != null) {
+            if (StringUtils.isNumeric(no)) {
+                this.setPageNo(Integer.parseInt(no));
+            }
+        }
+        // 设置页面大小参数(传递repage参数,来记住页码大小)
+        String size = request.getParameter("pageSize");
+        if (StringUtils.isNumeric(size)) {
+            this.setPageSize(Integer.parseInt(size));
+        } else if (request.getParameter("repage") != null) {
+            if (StringUtils.isNumeric(size)) {
+                this.setPageSize(Integer.parseInt(size));
+            }
+        } else if (defaultPageSize != -2) {
+            this.pageSize = defaultPageSize;
+        }
+        // 设置页面分页函数
+        String funcName = request.getParameter("funcName");
+        if (StringUtils.isNotBlank(funcName)) {
+            this.setFuncName(funcName);
+        } else if (request.getParameter("repage") != null) {
+            if (StringUtils.isNotBlank(funcName)) {
+                this.setFuncName(funcName);
+            }
+        }
+        // 设置排序参数
+        String orderBy = request.getParameter("orderBy");
+        if (StringUtils.isNotBlank(orderBy)) {
+            this.setOrderBy(orderBy);
+        }
+    }
+
+    /**
+     * 构造方法
+     * @param pageNo 当前页码
+     * @param pageSize 分页大小
+     */
+    public Page(int pageNo, int pageSize) {
+        this(pageNo, pageSize, 0);
+    }
+
+    /**
+     * 构造方法
+     * @param pageNo 当前页码
+     * @param pageSize 分页大小
+     * @param count 数据条数
+     */
+    public Page(int pageNo, int pageSize, long count) {
+        this(pageNo, pageSize, count, new ArrayList<T>());
+    }
+
+    /**
+     * 构造方法
+     * @param pageNo 当前页码
+     * @param pageSize 分页大小
+     * @param count 数据条数
+     * @param list 本页数据对象列表
+     */
+    public Page(int pageNo, int pageSize, long count, List<T> list) {
+        this.setCount(count);
+        this.setPageNo(pageNo);
+        this.pageSize = pageSize;
+        this.list = list;
+    }
+
+    /**
+     * 初始化参数
+     */
+    public void initialize() {
+
+        //1
+        this.first = 1;
+
+        this.last = (int) (count / (this.pageSize < 1 ? 20 : this.pageSize) + first - 1);
+
+        if (this.count % this.pageSize != 0 || this.last == 0) {
+            this.last++;
+        }
+
+        if (this.last < this.first) {
+            this.last = this.first;
+        }
+
+        if (this.pageNo <= 1) {
+            this.pageNo = this.first;
+            this.firstPage = true;
+        }
+
+        if (this.pageNo >= this.last) {
+            this.pageNo = this.last;
+            this.lastPage = true;
+        }
+
+        if (this.pageNo < this.last - 1) {
+            this.next = this.pageNo + 1;
+        } else {
+            this.next = this.last;
+        }
+
+        if (this.pageNo > 1) {
+            this.prev = this.pageNo - 1;
+        } else {
+            this.prev = this.first;
+        }
+
+        //2
+        if (this.pageNo < this.first) {// 如果当前页小于首页
+            this.pageNo = this.first;
+        }
+
+        if (this.pageNo > this.last) {// 如果当前页大于尾页
+            this.pageNo = this.last;
+        }
+
+    }
+
+    /**
+     * 默认输出当前分页标签 
+     * <div class="page">${page}</div>
+     */
+    @Override
+    public String toString() {
+
+        StringBuilder sb = new StringBuilder();
+
+        if (pageNo == first) {// 如果是首页
+            sb.append("<li class=\"disabled\"><a href=\"javascript:\">&#171; 上一页</a></li>\n");
+        } else {
+            sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + prev + "," + pageSize + ",'"
+                    + funcParam + "');\">&#171; 上一页</a></li>\n");
+        }
+
+        int begin = pageNo - (length / 2);
+
+        if (begin < first) {
+            begin = first;
+        }
+
+        int end = begin + length - 1;
+
+        if (end >= last) {
+            end = last;
+            begin = end - length + 1;
+            if (begin < first) {
+                begin = first;
+            }
+        }
+
+        if (begin > first) {
+            int i = 0;
+            for (i = first; i < first + slider && i < begin; i++) {
+                sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ",'"
+                        + funcParam + "');\">" + (i + 1 - first) + "</a></li>\n");
+            }
+            if (i < begin) {
+                sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n");
+            }
+        }
+
+        for (int i = begin; i <= end; i++) {
+            if (i == pageNo) {
+                sb.append("<li class=\"active\"><a href=\"javascript:\">" + (i + 1 - first) + "</a></li>\n");
+            } else {
+                sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ",'"
+                        + funcParam + "');\">" + (i + 1 - first) + "</a></li>\n");
+            }
+        }
+
+        if (last - end > slider) {
+            sb.append("<li class=\"disabled\"><a href=\"javascript:\">...</a></li>\n");
+            end = last - slider;
+        }
+
+        for (int i = end + 1; i <= last; i++) {
+            sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + i + "," + pageSize + ",'" + funcParam
+                    + "');\">" + (i + 1 - first) + "</a></li>\n");
+        }
+
+        if (pageNo == last) {
+            sb.append("<li class=\"disabled\"><a href=\"javascript:\">下一页 &#187;</a></li>\n");
+        } else {
+            sb.append("<li><a href=\"javascript:\" onclick=\"" + funcName + "(" + next + "," + pageSize + ",'"
+                    + funcParam + "');\">" + "下一页 &#187;</a></li>\n");
+        }
+
+        sb.append("<li class=\"disabled controls\"><a href=\"javascript:\">当前第 ");
+        sb.append("<input type=\"text\" value=\"" + pageNo
+                + "\" onkeypress=\"var e=window.event||event;var c=e.keyCode||e.which;if(c==13)");
+        sb.append(funcName + "(this.value," + pageSize + ",'" + funcParam + "');\" onclick=\"this.select();\"/>页 / ");
+        /* sb.append("<input class=\"input_limit\" type=\"text\" value=\"" + pageSize
+                + "\" onkeypress=\"var e=window.event||event;var c=e.keyCode||e.which;if(c==13) ");
+        sb.append(funcName + "(" + pageNo + ",this.value,'" + funcParam + "');\" onclick=\"this.select();\"/> 条,");*/
+        sb.append("共 " + count + " 条" + (message != null ? message : "") + "</a></li>\n");
+
+        sb.insert(0, "<ul>\n").append("</ul>\n");
+
+        sb.append("<div style=\"clear:both;\"></div>");
+
+        //		sb.insert(0,"<div class=\"page\">\n").append("</div>\n");
+
+        return sb.toString();
+    }
+
+    /**
+     * 获取分页HTML代码
+     * @return
+     */
+    public String getHtml() {
+
+        return toString();
+    }
+
+    //	public static void main(String[] args) {
+    //		Page<String> p = new Page<String>(3, 3);
+    //		System.out.println(p);
+    //		System.out.println("首页:"+p.getFirst());
+    //		System.out.println("尾页:"+p.getLast());
+    //		System.out.println("上页:"+p.getPrev());
+    //		System.out.println("下页:"+p.getNext());
+    //	}
+
+    /**
+     * 获取设置总数
+     * @return
+     */
+    public long getCount() {
+
+        return count;
+    }
+
+    /**
+     * 设置数据总数
+     * @param count
+     */
+    public void setCount(long count) {
+
+        this.count = count;
+        if (pageSize >= count) {
+            pageNo = 1;
+        }
+    }
+
+    /**
+     * 获取当前页码
+     * @return
+     */
+    public int getPageNo() {
+
+        return pageNo;
+    }
+
+    /**
+     * 设置当前页码
+     * @param pageNo
+     */
+    public void setPageNo(int pageNo) {
+
+        this.pageNo = pageNo;
+    }
+
+    /**
+     * 获取页面大小
+     * @return
+     */
+    public int getPageSize() {
+
+        return pageSize;
+    }
+
+    /**
+     * 设置页面大小(最大500)
+     * @param pageSize
+     */
+    public void setPageSize(int pageSize) {
+
+        this.pageSize = pageSize <= 0 ? 10 : pageSize;// > 500 ? 500 : pageSize;
+    }
+
+    /**
+     * 首页索引
+     * @return
+     */
+    @JsonIgnore
+    public int getFirst() {
+
+        return first;
+    }
+
+    /**
+     * 尾页索引
+     * @return
+     */
+    @JsonIgnore
+    public int getLast() {
+
+        return last;
+    }
+
+    /**
+     * 获取页面总数
+     * @return getLast();
+     */
+    @JsonIgnore
+    public int getTotalPage() {
+
+        return getLast();
+    }
+
+    /**
+     * 是否为第一页
+     * @return
+     */
+    @JsonIgnore
+    public boolean isFirstPage() {
+
+        return firstPage;
+    }
+
+    /**
+     * 是否为最后一页
+     * @return
+     */
+    @JsonIgnore
+    public boolean isLastPage() {
+
+        return lastPage;
+    }
+
+    /**
+     * 上一页索引值
+     * @return
+     */
+    @JsonIgnore
+    public int getPrev() {
+
+        if (isFirstPage()) {
+            return pageNo;
+        } else {
+            return pageNo - 1;
+        }
+    }
+
+    /**
+     * 下一页索引值
+     * @return
+     */
+    @JsonIgnore
+    public int getNext() {
+
+        if (isLastPage()) {
+            return pageNo;
+        } else {
+            return pageNo + 1;
+        }
+    }
+
+    /**
+     * 获取本页数据对象列表
+     * @return List<T>
+     */
+    public List<T> getList() {
+
+        return list;
+    }
+
+    /**
+     * 设置本页数据对象列表
+     * @param list
+     */
+    public Page<T> setList(List<T> list) {
+
+        this.list = list;
+        initialize();
+        return this;
+    }
+
+    /**
+     * 获取查询排序字符串
+     * @return
+     */
+    @JsonIgnore
+    public String getOrderBy() {
+
+        // SQL过滤,防止注入 
+        String reg = "(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|"
+                + "(\\b(select|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)";
+        Pattern sqlPattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
+        if (sqlPattern.matcher(orderBy).find()) {
+            return "";
+        }
+        return orderBy;
+    }
+
+    /**
+     * 设置查询排序,标准查询有效, 实例: updatedate desc, name asc
+     */
+    public void setOrderBy(String orderBy) {
+
+        this.orderBy = orderBy;
+    }
+
+    /**
+     * 获取点击页码调用的js函数名称
+     * function ${page.funcName}(pageNo){location="${ctx}/list-${category.id}${urlSuffix}?pageNo="+i;}
+     * @return
+     */
+    @JsonIgnore
+    public String getFuncName() {
+
+        return funcName;
+    }
+
+    /**
+     * 设置点击页码调用的js函数名称,默认为page,在一页有多个分页对象时使用。
+     * @param funcName 默认为page
+     */
+    public void setFuncName(String funcName) {
+
+        this.funcName = funcName;
+    }
+
+    /**
+     * 获取分页函数的附加参数
+     * @return
+     */
+    @JsonIgnore
+    public String getFuncParam() {
+
+        return funcParam;
+    }
+
+    /**
+     * 设置分页函数的附加参数
+     * @return
+     */
+    public void setFuncParam(String funcParam) {
+
+        this.funcParam = funcParam;
+    }
+
+    /**
+     * 设置提示消息,显示在“共n条”之后
+     * @param message
+     */
+    public void setMessage(String message) {
+
+        this.message = message;
+    }
+
+    /**
+     * 分页是否有效
+     * @return this.pageSize==-1
+     */
+    @JsonIgnore
+    public boolean isDisabled() {
+
+        return this.pageSize == -1;
+    }
+
+    /**
+     * 是否进行总数统计
+     * @return this.count==-1
+     */
+    @JsonIgnore
+    public boolean isNotCount() {
+
+        return this.count == -1;
+    }
+
+    /**
+     * 获取 Hibernate FirstResult
+     */
+    public int getFirstResult() {
+
+        int firstResult = (getPageNo() - 1) * getPageSize();
+        if (firstResult >= getCount()) {
+            firstResult = 0;
+        }
+        return firstResult;
+    }
+
+    /**
+     * 获取 Hibernate MaxResults
+     */
+    public int getMaxResults() {
+
+        return getPageSize();
+    }
+
+    //	/**
+    //	 * 获取 Spring data JPA 分页对象
+    //	 */
+    //	public Pageable getSpringPage(){
+    //		List<Order> orders = new ArrayList<Order>();
+    //		if (orderBy!=null){
+    //			for (String order : StringUtils.split(orderBy, ",")){
+    //				String[] o = StringUtils.split(order, " ");
+    //				if (o.length==1){
+    //					orders.add(new Order(Direction.ASC, o[0]));
+    //				}else if (o.length==2){
+    //					if ("DESC".equals(o[1].toUpperCase())){
+    //						orders.add(new Order(Direction.DESC, o[0]));
+    //					}else{
+    //						orders.add(new Order(Direction.ASC, o[0]));
+    //					}
+    //				}
+    //			}
+    //		}
+    //		return new PageRequest(this.pageNo - 1, this.pageSize, new Sort(orders));
+    //	}
+    //	
+    //	/**
+    //	 * 设置 Spring data JPA 分页对象,转换为本系统分页对象
+    //	 */
+    //	public void setSpringPage(org.springframework.data.domain.Page<T> page){
+    //		this.pageNo = page.getNumber();
+    //		this.pageSize = page.getSize();
+    //		this.count = page.getTotalElements();
+    //		this.list = page.getContent();
+    //	}
+
+}

+ 104 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/Role.java

@@ -0,0 +1,104 @@
+package cn.com.liandisys.ycjt.ggcx.admin.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.GenericGenerator;
+import org.hibernate.annotations.Type;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+
+/**
+ * 角色对象.
+ * 
+ * @author 袁晓冬
+ */
+@Entity
+@Table(name = "T_SYS_ROLE")
+@JsonTypeName(value = "RoleEntity")
+@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
+public class Role implements Serializable{
+	
+	private static final long serialVersionUID = 1L;
+
+	/** 记录主键 */
+	private String id;
+	/** 角色是否可用 */
+	private Boolean avaliable;
+	/** 角色代码 */
+	private String code;
+	/** 角色描述 */
+	private String description;
+	/** 角色名称 */
+	private String name;
+	/** 排序号 */
+	private Integer orderid;
+
+	@Type(type = "yes_no")
+	public Boolean getAvaliable() {
+		return this.avaliable;
+	}
+
+	@Column(nullable = false)
+	public String getCode() {
+		return code;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	@Id
+	@GeneratedValue(generator = "system-uuid")
+	@GenericGenerator(name = "system-uuid", strategy = "uuid")
+	@Column(name = "id", length = 32)
+	public String getId() {
+		return id;
+	}
+	
+	public void setId(String id){
+		this.id = id;
+	}
+
+	@Column(nullable = false)
+	public String getName() {
+		return name;
+	}
+
+	@Column(nullable = true)
+	public Integer getOrderid() {
+		return orderid;
+	}
+
+	public void setAvaliable(Boolean avaliable) {
+		this.avaliable = avaliable;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+
+	}
+	
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public void setOrderid(Integer orderid) {
+		this.orderid = orderid;
+	}
+
+	public String toString() {
+		return "Role [id=" + getId() + ", name=" + name + ", code=" + code + ", avaliable=" + avaliable
+				+ ", description=" + description + "]";
+	}
+}

+ 395 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/User.java

@@ -0,0 +1,395 @@
+package cn.com.liandisys.ycjt.ggcx.admin.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.GenericGenerator;
+import org.hibernate.annotations.Type;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.AvailableBooleanDeSerialize;
+import cn.com.liandisys.ycjt.ggcx.common.util.AvailableBooleanSerialize;
+
+/**
+ * 用户
+ * 
+ * @author jiangb
+ */
+@Entity
+@Table(name = "T_SYS_USER")
+@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler"})
+@JsonTypeName(value = "User")
+public class User implements Serializable{
+	
+	private static final long serialVersionUID = 1L;
+	/** 记录主键 */
+	private String id;
+	/** 是否管理员 */
+	protected boolean admin;
+	/** 记录是否可用 */
+	protected boolean avaliable;
+	/** 登录名称 */
+	protected String loginName;
+	/** 密码 */
+	protected String password;
+	/** 记录排序号 */
+	protected Integer orderid;
+
+	/** 用户姓名 */
+	protected String name;
+	/** 工 号 */
+	protected String workno;
+	/** 性 别 */
+	protected String sex;    
+	/** 出生年月 */
+	@DateTimeFormat(pattern = "yyyy/MM/dd")
+	@JsonFormat(pattern = "yyyy/MM/dd")
+	protected Date birthday;
+	/** 籍 贯 */
+	protected String origo;
+	/** 民 族 */
+	protected String nation;
+	/** 政治面貌 */
+	protected String partyMember;
+	/** 学 历 */
+	protected String education;
+	/** 编 制 */
+	protected String formation;
+	/** 毕业时间 */
+	@DateTimeFormat(pattern = "yyyy/MM/dd")
+	@JsonFormat(pattern = "yyyy/MM/dd")
+	protected Date graduateTime;
+	/** 工作时间 */
+	@DateTimeFormat(pattern = "yyyy/MM/dd")
+	@JsonFormat(pattern = "yyyy/MM/dd")
+	protected Date startworkTime;
+	/** 职 务 */
+	protected String job;
+	/** 手机号码 */
+	protected String cellphone;
+	/** 密 级 */
+	protected String secretRate;
+	/** 家庭住址 */
+	protected String address;
+	/** 住宅电话 */
+	protected String telephone;
+	/** 身份证号码 */
+	protected String identityNumber;
+	/** 上级名称 */
+	protected String upperName;
+	/** 上级登录名 */
+	protected String upperLoginName;
+	
+	/** 用户角色 */
+	protected List<Role> roles;
+
+	public User(String loginName, String name) {
+		this.loginName = loginName;
+		this.name = name;
+	}
+
+	public User() {
+
+	}
+
+	@Id
+    @GeneratedValue(generator = "system-uuid")
+    @GenericGenerator(name = "system-uuid", strategy = "uuid")
+    @Column(name="id",length=32)
+	public String getId() {
+		return id;
+	}
+	
+	public void setId(String id){
+		this.id = id;
+	}
+
+	public String getLoginName() {
+		return loginName;
+	}
+
+	@Column(nullable = false)
+	public String getName() {
+		return name;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	@Type(type = "yes_no")
+	@JsonSerialize(using = AvailableBooleanSerialize.class)
+	public boolean isAdmin() {
+		return admin;
+	}
+
+	@JsonSerialize(using = AvailableBooleanSerialize.class)
+	@Type(type = "yes_no")
+	public boolean isAvaliable() {
+		return avaliable;
+	}
+
+
+	@Column(nullable = true)
+	public Integer getOrderid() {
+		return orderid;
+	}
+
+	/**
+	 * 设置用户是否为管理员
+	 * 
+	 * @param admin
+	 */
+	@JsonDeserialize(using = AvailableBooleanDeSerialize.class)
+	public void setAdmin(boolean admin) {
+		this.admin = admin;
+	}
+
+	/**
+	 * 设置记录状态是否可用
+	 * 
+	 * @param avaliable
+	 */
+	@JsonDeserialize(using = AvailableBooleanDeSerialize.class)
+	public void setAvaliable(boolean avaliable) {
+		this.avaliable = avaliable;
+	}
+
+	/**
+	 * 设置用户的系统登录名
+	 * 
+	 * @param loginName
+	 */
+	public void setLoginName(String loginName) {
+		this.loginName = loginName;
+	}
+
+	/**
+	 * 设置用户姓名
+	 * 
+	 * @param name
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * 设置记录排序号
+	 * 
+	 * @param orderid
+	 */
+	public void setOrderid(Integer orderid) {
+		this.orderid = orderid;
+	}
+
+	/**
+	 * 设置用户密码
+	 * 
+	 * @param password
+	 */
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	@Override
+	public String toString() {
+		return "User [loginName=" + loginName + ", name=" + name + "]";
+	}
+
+	@Column(name = "workno")
+	public String getWorkno() {
+		return workno;
+	}
+
+	public void setWorkno(String workno) {
+		this.workno = workno;
+	}
+
+	@Column(name = "sex")
+	public String getSex() {
+		return sex;
+	}
+
+	public void setSex(String sex) {
+		this.sex = sex;
+	}
+
+	@Column(name = "birthday")
+	public Date getBirthday() {
+		return birthday;
+	}
+
+	public void setBirthday(Date birthday) {
+		this.birthday = birthday;
+	}
+
+	@Column(name = "origo")
+	public String getOrigo() {
+		return origo;
+	}
+
+	public void setOrigo(String origo) {
+		this.origo = origo;
+	}
+
+	@Column(name = "nation")
+	public String getNation() {
+		return nation;
+	}
+
+	public void setNation(String nation) {
+		this.nation = nation;
+	}
+
+	@Column(name = "partymember")
+	public String getPartyMember() {
+		return partyMember;
+	}
+
+	public void setPartyMember(String partyMember) {
+		this.partyMember = partyMember;
+	}
+
+	@Column(name = "education")
+	public String getEducation() {
+		return education;
+	}
+
+	public void setEducation(String education) {
+		this.education = education;
+	}
+
+	@Column(name = "formation")
+	public String getFormation() {
+		return formation;
+	}
+
+	public void setFormation(String formation) {
+		this.formation = formation;
+	}
+
+	@Column(name = "graduatetime")
+	public Date getGraduateTime() {
+		return graduateTime;
+	}
+
+	public void setGraduateTime(Date graduateTime) {
+		this.graduateTime = graduateTime;
+	}
+
+	@Column(name = "startworktime")
+	public Date getStartworkTime() {
+		return startworkTime;
+	}
+
+	public void setStartworkTime(Date startworkTime) {
+		this.startworkTime = startworkTime;
+	}
+
+	@Column(name = "job")
+	public String getJob() {
+		return job;
+	}
+
+	public void setJob(String job) {
+		this.job = job;
+	}
+
+	@Column(name = "cellphone")
+	public String getCellphone() {
+		return cellphone;
+	}
+
+	public void setCellphone(String cellphone) {
+		this.cellphone = cellphone;
+	}
+
+	@Column(name = "secretrate")
+	public String getSecretRate() {
+		return secretRate;
+	}
+
+	public void setSecretRate(String secretRate) {
+		this.secretRate = secretRate;
+	}
+
+	@Column(name = "address")
+	public String getAddress() {
+		return address;
+	}
+
+	public void setAddress(String address) {
+		this.address = address;
+	}
+
+	@Column(name = "telephone")
+	public String getTelephone() {
+		return telephone;
+	}
+
+	public void setTelephone(String telephone) {
+		this.telephone = telephone;
+	}
+
+	@Column(name = "identitynumber")
+	public String getIdentityNumber() {
+		return identityNumber;
+	}
+
+	public void setIdentityNumber(String identityNumber) {
+		this.identityNumber = identityNumber;
+	}
+
+	@Column(name = "upper_name")
+	public String getUpperName() {
+		return upperName;
+	}
+
+	public void setUpperName(String upperName) {
+		this.upperName = upperName;
+	}
+
+	@Column(name = "upper_login_name")
+	public String getUpperLoginName() {
+		return upperLoginName;
+	}
+
+	public void setUpperLoginName(String upperLoginName) {
+		this.upperLoginName = upperLoginName;
+	}
+	
+	@ManyToMany(fetch = FetchType.EAGER, targetEntity = Role.class)
+	@JoinTable(name = "t_sys_user_role", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id") })
+	@OrderBy("id")
+	public List<Role> getRoles() {
+		return roles;
+	}
+	
+	/**
+	 * 设置用户的角色
+	 * 
+	 * @param roles
+	 */
+	public void setRoles(List<Role> roles) {
+		this.roles = roles;
+	}
+
+}

+ 385 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/cms/Article.java

@@ -0,0 +1,385 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.admin.model.cms;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.commons.lang3.StringUtils;
+import org.hibernate.annotations.GenericGenerator;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.google.common.collect.Lists;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.CmsUtils;
+
+/**
+ * 文章实体
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+@Entity
+@Table(name = "CMS_ARTICLE")
+public class Article implements Serializable {
+
+    public static final String DEFAULT_TEMPLATE = "frontViewArticle";
+    public static final String DEL_FLAG_NORMAL = "0";
+	
+	private static final long serialVersionUID = 1L;
+	private String id;// 实体编号(唯一标识)
+	private Category category;// 分类编号
+	private String title;	// 标题
+    private String link;	// 外部链接
+	private String color;	// 标题颜色(red:红色;green:绿色;blue:蓝色;yellow:黄色;orange:橙色)
+	private String image;	// 文章图片
+	private String keywords;// 关键字
+	private String description;// 描述、摘要
+	private Integer weight;	// 权重,越大越靠前
+	@DateTimeFormat(pattern = "yyyy/MM/dd")
+	@JsonFormat(pattern = "yyyy/MM/dd")
+	private Date weightDate;// 权重期限,超过期限,将weight设置为0
+	private Integer hits;	// 点击数
+	private String posid;	// 推荐位,多选(1:首页焦点图;2:栏目页文章推荐;)
+    private String customContentView;	// 自定义内容视图
+   	private String viewConfig;	// 视图参数
+	private User createBy;	// 创建者
+	//@DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss")
+	//@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss")
+	private Date createDate;	// 创建日期
+	private User updateBy;	// 更新者
+	@DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss")
+	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss")
+	private Date updateDate;	// 更新日期
+	private String remarks;	// 备注
+	private String delFlag; 	// 删除标记(0:正常;1:删除;2:审核)
+	private ArticleData articleData;	//文章副表
+	
+	private String appIndexView; //在APP首页模块显示(1:显示,0:不显示)
+	private String appInfoView;  //在APP资讯模块显示(1:显示,0:不显示)
+	private String appIndexViewYcjt; //在盐城交通APP首页模块显示(1:显示,0:不显示)
+	private String appInfoViewYcjt;  //在盐城交通APP资讯模块显示(1:显示,0:不显示)
+	private String publisher; // 文章中显示的发布者姓名
+	private String files; // 附件存储路径
+	private String publisheDate;
+	
+    
+	@Id
+    @GeneratedValue(generator = "system-uuid")
+    @GenericGenerator(name = "system-uuid", strategy = "uuid")
+    @Column(name="id")
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+	
+	@ManyToOne(fetch = FetchType.EAGER, targetEntity = Category.class)
+	@JoinColumn(name = "category_id")
+	public Category getCategory() {
+		return category;
+	}
+
+	public void setCategory(Category category) {
+		this.category = category;
+	}
+	
+	@Column
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+	
+	@Column
+	public String getLink() {
+        return link;
+    }
+
+    public void setLink(String link) {
+        this.link = link;
+    }
+    
+    @Column
+    public String getColor() {
+		return color;
+	}
+
+	public void setColor(String color) {
+		this.color = color;
+	}
+	
+	@Column
+	public String getImage() {
+		return image;
+	}
+
+	public void setImage(String image) {
+        this.image = image;
+	}
+	
+	@Column
+	public String getKeywords() {
+		return keywords;
+	}
+
+	public void setKeywords(String keywords) {
+		this.keywords = keywords;
+	}
+	
+	@Column
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+	
+	@Column
+	public Integer getWeight() {
+		return weight;
+	}
+
+	public void setWeight(Integer weight) {
+		this.weight = weight;
+	}
+	
+	@Column
+	public Date getWeightDate() {
+		return weightDate;
+	}
+
+	public void setWeightDate(Date weightDate) {
+		this.weightDate = weightDate;
+	}
+	
+	@Column
+	public Integer getHits() {
+		return hits;
+	}
+
+	public void setHits(Integer hits) {
+		this.hits = hits;
+	}
+
+	@Column
+	public String getPosid() {
+		return posid;
+	}
+
+	public void setPosid(String posid) {
+		this.posid = posid;
+	}
+	
+	@Column
+	public String getCustomContentView() {
+        return customContentView;
+    }
+
+    public void setCustomContentView(String customContentView) {
+        this.customContentView = customContentView;
+    }
+
+    @Column
+    public String getViewConfig() {
+        return viewConfig;
+    }
+
+    public void setViewConfig(String viewConfig) {
+        this.viewConfig = viewConfig;
+    }
+    
+    @ManyToOne(fetch = FetchType.EAGER, targetEntity = User.class)
+	@JoinColumn(name = "create_by")
+    public User getCreateBy() {
+		return createBy;
+	}
+
+	public void setCreateBy(User createBy) {
+		this.createBy = createBy;
+	}
+
+	@Column
+	public Date getCreateDate() {
+		return createDate;
+	}
+
+	public void setCreateDate(Date createDate) {
+		this.createDate = createDate;
+	}
+
+	@ManyToOne(fetch = FetchType.EAGER, targetEntity = User.class)
+	@JoinColumn(name = "update_by")
+	public User getUpdateBy() {
+		return updateBy;
+	}
+
+	public void setUpdateBy(User updateBy) {
+		this.updateBy = updateBy;
+	}
+
+	@Column
+	public Date getUpdateDate() {
+		return updateDate;
+	}
+
+	public void setUpdateDate(Date updateDate) {
+		this.updateDate = updateDate;
+	}
+	
+	@Column
+	public String getRemarks() {
+		return remarks;
+	}
+
+	public void setRemarks(String remarks) {
+		this.remarks = remarks;
+	}
+
+	@Column
+	public String getDelFlag() {
+		return delFlag;
+	}
+
+	public void setDelFlag(String delFlag) {
+		this.delFlag = delFlag;
+	}
+	
+	@Column
+	public String getAppIndexView() {
+		return appIndexView;
+	}
+
+	public void setAppIndexView(String appIndexView) {
+		this.appIndexView = appIndexView;
+	}
+	
+	@Column
+	public String getAppInfoView() {
+		return appInfoView;
+	}
+
+	public void setAppInfoView(String appInfoView) {
+		this.appInfoView = appInfoView;
+	}
+	
+	@Column
+	public String getAppIndexViewYcjt() {
+		return appIndexViewYcjt;
+	}
+
+	public void setAppIndexViewYcjt(String appIndexViewYcjt) {
+		this.appIndexViewYcjt = appIndexViewYcjt;
+	}
+	
+	@Column
+	public String getAppInfoViewYcjt() {
+		return appInfoViewYcjt;
+	}
+
+	public void setAppInfoViewYcjt(String appInfoViewYcjt) {
+		this.appInfoViewYcjt = appInfoViewYcjt;
+	}
+	
+	
+	@Column
+	public String getPublisher() {
+		return publisher;
+	}
+
+	public void setPublisher(String publisher) {
+		this.publisher = publisher;
+	}
+	
+	@Column
+	public String getFiles() {
+		return files;
+	}
+
+	public void setFiles(String files) {
+		this.files = files;
+	}
+	
+	@Column
+	public String getPublisheDate() {
+		return publisheDate;
+	}
+
+	public void setPublisheDate(String publisheDate) {
+		this.publisheDate = publisheDate;
+	}
+	
+	@OneToOne(fetch = FetchType.EAGER, targetEntity = ArticleData.class)
+	@JoinColumn(name = "data_id")
+	public ArticleData getArticleData() {
+		return articleData;
+	}
+
+	public void setArticleData(ArticleData articleData) {
+		this.articleData = articleData;
+	}
+
+	public Article() {
+		super();
+		this.weight = 0;
+		this.hits = 0;
+		this.posid = "";
+	}
+
+	public Article(String id){
+		this();
+		this.id = id;
+	}
+	
+	public Article(Category category){
+		this();
+		this.category = category;
+	}
+
+	@Transient
+	public List<String> getPosidList() {
+		List<String> list = Lists.newArrayList();
+		if (posid != null){
+			for (String s : StringUtils.split(posid, ",")) {
+				list.add(s);
+			}
+		}
+		return list;
+	}
+
+	public void setPosidList(List<String> list) {
+		posid = ","+StringUtils.join(list, ",")+",";
+	}
+
+	@Transient
+   	public String getUrl() {
+        return CmsUtils.getUrlDynamic(this);
+   	}
+
+	@Transient
+   	public String getImageSrc() {
+        return CmsUtils.formatImageSrcToWeb(this.image);
+   	}
+	
+}
+
+

+ 78 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/cms/ArticleData.java

@@ -0,0 +1,78 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.admin.model.cms;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.GenericGenerator;
+
+/**
+ * 文章内容实体
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+@Entity
+@Table(name = "CMS_ARTICLE_DATA")
+public class ArticleData implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+	private String id;		// 编号
+	private String content;	// 内容
+	private String copyfrom;// 来源
+	private String relation;// 相关文章
+
+	public ArticleData() {
+	}
+	
+	public ArticleData(String id){
+		this();
+		this.id = id;
+	}
+
+	@Id
+    @GeneratedValue(generator = "system-uuid")
+    @GenericGenerator(name = "system-uuid", strategy = "uuid")
+    @Column(name="id")
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	@Column
+	public String getContent() {
+		return content;
+	}
+
+	public void setContent(String content) {
+		this.content = content;
+	}
+
+	@Column
+	public String getCopyfrom() {
+		return copyfrom;
+	}
+
+	public void setCopyfrom(String copyfrom) {
+		this.copyfrom = copyfrom;
+	}
+
+	@Column
+	public String getRelation() {
+		return relation;
+	}
+
+	public void setRelation(String relation) {
+		this.relation = relation;
+	}
+
+}

+ 329 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/cms/Category.java

@@ -0,0 +1,329 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.admin.model.cms;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.commons.lang.StringUtils;
+import org.hibernate.annotations.GenericGenerator;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.google.common.collect.Lists;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.CmsUtils;
+import cn.com.liandisys.ycjt.ggcx.common.config.Global;
+
+/**
+ * 文章栏目实体
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+@Entity
+@Table(name = "CMS_CATEGORY")
+public class Category implements Serializable {
+
+    public static final String DEFAULT_TEMPLATE = "frontList";
+
+	private static final long serialVersionUID = 1L;
+	private String id;		// 编号
+	private Category parent; // 父级ID
+	private String name; // 栏目名称
+	private String module; 	// 栏目模型(article:文章;picture:图片;download:下载;link:链接;special:专题)
+	private String image; 	// 栏目图片
+	private String href; 	// 链接
+	private String target; 	// 目标( _blank、_self、_parent、_top)
+	private String description; 	// 描述,填写有助于搜索引擎优化
+	private String keywords; 	// 关键字,填写有助于搜索引擎优化
+	private Integer sort; 		// 排序(升序)
+	private String inMenu; 		// 是否在导航中显示(1:显示;0:不显示)
+	private String inList; 		// 是否在分类页中显示列表(1:显示;0:不显示)
+	private String showModes; 	// 展现方式(0:有子栏目显示栏目列表,无子栏目显示内容列表;1:首栏目内容列表;2:栏目第一条内容)
+	private String customListView;		// 自定义列表视图
+	private String customContentView;	// 自定义内容视图
+    private String viewConfig;	// 视图参数
+    
+    private String remarks;	// 备注
+	private User createBy;	// 创建者
+	@DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss")
+	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss")
+	private Date createDate;	// 创建日期
+	private User updateBy;	// 更新者
+	@DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss")
+	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss")
+	private Date updateDate;	// 更新日期
+	private String delFlag; 	// 删除标记(0:正常;1:删除;2:审核)
+	
+	private List<Category> childList = Lists.newArrayList(); 	// 拥有子分类列表
+	private List<Article> articleList = Lists.newArrayList(); 	// 栏目下文章列表
+
+	public Category(){
+		super();
+		this.module = "";
+		this.inMenu = Global.HIDE;
+		this.inList = Global.SHOW;
+		this.showModes = "0";
+	}
+
+	public Category(String id){
+		this();
+		this.id = id;
+	}
+	
+	@Id
+    @GeneratedValue(generator = "system-uuid")
+    @GenericGenerator(name = "system-uuid", strategy = "uuid")
+    @Column(name="id")
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getRemarks() {
+		return remarks;
+	}
+
+	public void setRemarks(String remarks) {
+		this.remarks = remarks;
+	}
+
+	@ManyToOne(fetch = FetchType.EAGER, targetEntity = User.class)
+	@JoinColumn(name = "create_by")
+	public User getCreateBy() {
+		return createBy;
+	}
+
+	public void setCreateBy(User createBy) {
+		this.createBy = createBy;
+	}
+
+	public Date getCreateDate() {
+		return createDate;
+	}
+
+	public void setCreateDate(Date createDate) {
+		this.createDate = createDate;
+	}
+
+	@ManyToOne(fetch = FetchType.EAGER, targetEntity = User.class)
+	@JoinColumn(name = "update_by")
+	public User getUpdateBy() {
+		return updateBy;
+	}
+
+	public void setUpdateBy(User updateBy) {
+		this.updateBy = updateBy;
+	}
+
+	public Date getUpdateDate() {
+		return updateDate;
+	}
+
+	public void setUpdateDate(Date updateDate) {
+		this.updateDate = updateDate;
+	}
+
+	public String getDelFlag() {
+		return delFlag;
+	}
+
+	public void setDelFlag(String delFlag) {
+		this.delFlag = StringUtils.isNotBlank(delFlag)?delFlag:"0";
+	}
+
+	public String getModule() {
+		return module;
+	}
+
+	public void setModule(String module) {
+		this.module = module;
+	}
+
+	public String getImage() {
+		return image;
+	}
+
+	public void setImage(String image) {
+		this.image = image;
+	}
+
+	public String getHref() {
+		return href;
+	}
+
+	public void setHref(String href) {
+		this.href = href;
+	}
+
+	public String getTarget() {
+		return target;
+	}
+
+	public void setTarget(String target) {
+		this.target = target;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	public String getKeywords() {
+		return keywords;
+	}
+
+	public void setKeywords(String keywords) {
+		this.keywords = keywords;
+	}
+
+	public String getInMenu() {
+		return inMenu;
+	}
+
+	public void setInMenu(String inMenu) {
+		this.inMenu = inMenu;
+	}
+
+	public String getInList() {
+		return inList;
+	}
+
+	public void setInList(String inList) {
+		this.inList = inList;
+	}
+
+	public String getShowModes() {
+		return showModes;
+	}
+
+	public void setShowModes(String showModes) {
+		this.showModes = showModes;
+	}
+	
+	public String getCustomListView() {
+		return customListView;
+	}
+
+	public void setCustomListView(String customListView) {
+		this.customListView = customListView;
+	}
+
+	public String getCustomContentView() {
+		return customContentView;
+	}
+
+	public void setCustomContentView(String customContentView) {
+		this.customContentView = customContentView;
+	}
+
+    public String getViewConfig() {
+        return viewConfig;
+    }
+
+    public void setViewConfig(String viewConfig) {
+        this.viewConfig = viewConfig;
+    }
+
+    @Transient
+	public List<Category> getChildList() {
+		return childList;
+	}
+
+	public void setChildList(List<Category> childList) {
+		this.childList = childList;
+	}
+
+	@Transient
+	public boolean isRoot(){
+		return isRoot(this.id);
+	}
+	
+	public static boolean isRoot(String id){
+		return id != null && id.equals("1");
+	}
+
+	@Transient
+   	public String getUrl() {
+        return CmsUtils.getUrlDynamic(this);
+   	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	@ManyToOne(fetch = FetchType.EAGER, targetEntity = Category.class)
+	@JoinColumn(name = "parent_id")
+	public Category getParent() {
+		return parent;
+	}
+
+	public void setParent(Category parent) {
+		this.parent = parent;
+	}
+
+	public Integer getSort() {
+		return sort;
+	}
+
+	public void setSort(Integer sort) {
+		this.sort = sort;
+	}
+	
+	@Transient
+	public static void sortList(List<Category> list, List<Category> sourcelist, String parentId){
+		for (int i=0; i<sourcelist.size(); i++){
+			Category e = sourcelist.get(i);
+			if (e.getParent()!=null && e.getParent().getId()!=null
+					&& e.getParent().getId().equals(parentId)){
+				list.add(e);
+				// 判断是否还有子节点, 有则继续获取子节点
+				for (int j=0; j<sourcelist.size(); j++){
+					Category child = sourcelist.get(j);
+					if (child.getParent()!=null && child.getParent().getId()!=null
+							&& child.getParent().getId().equals(e.getId())){
+						sortList(list, sourcelist, e.getId());
+						break;
+					}
+				}
+			}else{
+				list.add(e);
+			}
+		}
+	}
+
+	//注解方式速度太慢
+	//@OneToMany(mappedBy = "category",fetch = FetchType.LAZY)
+	//@OrderBy(value = "updateDate DESC")
+	@Transient
+	public List<Article> getArticleList() {
+		return articleList;
+	}
+
+	public void setArticleList(List<Article> articleList) {
+		this.articleList = articleList;
+	}
+}

+ 102 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/model/cms/FileTpl.java

@@ -0,0 +1,102 @@
+package cn.com.liandisys.ycjt.ggcx.admin.model.cms;
+
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.Timestamp;
+import java.util.Date;
+
+/**
+ * User: songlai
+ * Date: 13-8-22
+ * Time: 上午9:44
+ */
+public class FileTpl {
+	
+    private File file;
+    
+   	// 应用的根目录
+   	private String root;
+
+   	public FileTpl(File file, String root) {
+   		this.file = file;
+   		this.root = root;
+   	}
+
+    public File getFile() {
+        return file;
+    }
+
+    public void setFile(File file) {
+        this.file = file;
+    }
+
+    public String getRoot() {
+        return root;
+    }
+
+    public void setRoot(String root) {
+        this.root = root;
+    }
+
+    public String getName() {
+   		String ap = file.getAbsolutePath().substring(root.length());
+   		ap = ap.replace(File.separatorChar, '/');
+   		// 在resin里root的结尾是带'/'的,这样会导致getName返回的名称不以'/'开头。
+   		if (!ap.startsWith("/")) {
+   			ap = "/" + ap;
+   		}
+   		return ap;
+   	}
+
+    public String getParent(){
+        String ap = file.getParent().substring(root.length());
+        ap = ap.replace(File.separatorChar, '/');
+        // 在resin里root的结尾是带'/'的,这样会导致getName返回的名称不以'/'开头。
+        if (!ap.startsWith("/")) {
+            ap = "/" + ap;
+        }
+        return ap;
+    }
+
+   	public String getPath() {
+   		String name = getName();
+   		return name.substring(0, name.lastIndexOf('/'));
+   	}
+
+   	public String getFilename() {
+   		return file.getName();
+   	}
+
+   	public String getSource() {
+   		if (file.isDirectory()) {
+   			return null;
+   		}
+   		try {
+   			return FileUtils.readFileToString(this.file, "UTF-8");
+   		} catch (IOException e) {
+   			throw new RuntimeException(e);
+   		}
+   	}
+
+   	public long getLastModified() {
+   		return file.lastModified();
+   	}
+
+   	public Date getLastModifiedDate() {
+   		return new Timestamp(getLastModified());
+   	}
+
+   	public long getLength() {
+   		return file.length();
+   	}
+
+   	public int getSize() {
+   		return (int) (getLength() / 1024) + 1;
+   	}
+
+   	public boolean isDirectory() {
+   		return file.isDirectory();
+   	}
+}

+ 35 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/service/UserService.java

@@ -0,0 +1,35 @@
+package cn.com.liandisys.ycjt.ggcx.admin.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.liandisys.ycjt.ggcx.admin.dao.UserDao;
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+
+/**
+ * 用户查询
+ * 
+ * @author jiangchao
+ * @version 2016-11-28
+ * 
+ */
+@Service
+public class UserService {
+	
+	@Autowired
+	private UserDao userDao;
+
+    /**
+     * 根据登陆账号查询用户
+     * 
+     * @param loginName
+     * @return
+     */
+    public User findByLoginName(String loginName){
+    	return userDao.findByLoginName(loginName);
+    }
+    
+    public User saveUser(User user){
+    	return userDao.save(user);
+    }
+}

+ 134 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/service/cms/ArticleService.java

@@ -0,0 +1,134 @@
+package cn.com.liandisys.ycjt.ggcx.admin.service.cms;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.google.common.collect.Lists;
+
+import cn.com.liandisys.ycjt.ggcx.admin.dao.cms.ArticleDao;
+import cn.com.liandisys.ycjt.ggcx.admin.dao.cms.ArticleDataDao;
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Article;
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.ArticleData;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.CacheUtils;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.CmsUtils;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtils;
+import cn.com.liandisys.ycjt.ggcx.common.util.UserUtils;
+
+/**
+ * 文章service
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+@Service
+@Transactional(readOnly = true)
+public class ArticleService {
+
+    @Autowired
+    private ArticleDao articleDao;
+
+    @Autowired
+    private ArticleDataDao articleDataDao;
+
+    public Article findOne(String id) {
+
+        return articleDao.findOne(id);
+    }
+
+    public List<Article> findAll() {
+
+        return articleDao.findAll();
+    }
+
+    public Page<Article> findAll(Specification<Article> spec, Pageable pageable) {
+
+        return articleDao.findAll(spec, pageable);
+    }
+
+    //声明service的方法需要事务管理
+    @Transactional(readOnly = false)
+    public void save(Article article) throws UnsupportedEncodingException {
+
+        if (article.getArticleData().getContent() != null) {
+            String content = article.getArticleData().getContent();
+            content = content.replaceAll("&nbsp;", "&amp;nbsp;");
+            article.getArticleData().setContent(StringEscapeUtils.unescapeHtml4(content));
+        }
+        if (StringUtils.isBlank(article.getId())) {
+            article.setCreateBy(UserUtils.getPrincipal());
+            article.setCreateDate(new Date());
+        }
+        article.setUpdateBy(UserUtils.getPrincipal());
+        article.setUpdateDate(new Date());
+        article.setDelFlag(Article.DEL_FLAG_NORMAL);
+        ArticleData articleData = article.getArticleData();
+        articleData = articleDataDao.save(articleData);
+        articleDao.save(article);
+        updateArticleCache(article);
+    }
+
+    /**
+     * 更新缓存
+     * @param article
+     */
+    private void updateArticleCache(Article article) {
+
+        CacheUtils.remove(CmsUtils.CACHE_ARTICLE_LIST + article.getCategory().getId(),
+                CmsUtils.CACHE_ARTICLE_LIST_BELONG_ID + article.getCategory().getId());
+        List<Article> newCacheList =
+                CmsUtils.getArticleList(article.getCategory().getId(), CmsUtils.CMS_INDEX_ARTICLE_SIZE, null);
+        CacheUtils.put(CmsUtils.CACHE_ARTICLE_LIST + article.getCategory().getId(),
+                CmsUtils.CACHE_ARTICLE_LIST_BELONG_ID + article.getCategory().getId(), newCacheList);
+    }
+
+    @Transactional(readOnly = false)
+    public void delete(Article article) {
+
+        if (article.getArticleData() != null) {
+            articleDataDao.delete(article.getArticleData());
+        }
+        articleDao.delete(article);
+        updateArticleCache(article);
+    }
+
+    /**
+     * 通过编号获取内容标题
+     * @return new Object[]{栏目Id,文章Id,文章标题}
+     */
+    public List<Object[]> findByIds(String ids) {
+
+        if (ids == null) {
+            return new ArrayList<Object[]>();
+        }
+        List<Object[]> list = Lists.newArrayList();
+        String[] idss = StringUtils.split(ids, ",");
+        Article e = null;
+        for (int i = 0; (idss.length - i) > 0; i++) {
+            e = articleDao.findOne(idss[i]);
+            list.add(new Object[] { e.getCategory().getId(), e.getId(), StringUtils.abbr(e.getTitle(), 50) });
+        }
+        return list;
+    }
+
+    @Transactional(readOnly = false)
+    public void updateHitsAddOne(Article article) {
+
+        article.setHits(article.getHits() + 1);
+        articleDao.save(article);
+    }
+
+    public List<Article> findByCategoryId(String categoryId) {
+
+        return articleDao.findByCategoryId(categoryId);
+    }
+
+}

+ 55 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/service/cms/CategoryService.java

@@ -0,0 +1,55 @@
+package cn.com.liandisys.ycjt.ggcx.admin.service.cms;
+
+import java.util.List;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import cn.com.liandisys.ycjt.ggcx.admin.dao.cms.CategoryDao;
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Category;
+
+/**
+ * 文章栏目service
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+@Service
+@Transactional(readOnly = true)
+public class CategoryService {
+	
+	@Autowired
+	private CategoryDao categoryDao;
+	
+	public Category findOne(String id){
+		return categoryDao.findOne(id);
+	}
+	
+	public List<Category> findAll(Sort sort){
+		return categoryDao.findAll(sort);
+	}
+
+	@Transactional(readOnly = false)
+	public void save(Category category) {
+		if (StringUtils.isNotBlank(category.getViewConfig())){
+            category.setViewConfig(StringEscapeUtils.unescapeHtml4(category.getViewConfig()));
+        }
+		categoryDao.save(category);
+	}
+
+	@Transactional(readOnly = false)
+	public void delete(Category category) {
+		categoryDao.delete(category);
+	}
+
+	public List<Category> findByParentId(String id) {
+		return categoryDao.findByParentId(id);
+	}
+	public List<Category> findByParentIdByArticle(String id) {
+		return categoryDao.findByParentIdByArticle(id);
+	}
+
+}

+ 81 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/service/cms/FileTplService.java

@@ -0,0 +1,81 @@
+package cn.com.liandisys.ycjt.ggcx.admin.service.cms;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.FileTpl;
+
+/**
+ * User: songlai
+ * Date: 13-8-27
+ * Time: 下午4:56
+ */
+@Service
+@Transactional(readOnly = true)
+public class FileTplService {
+
+    @Autowired
+    ServletContext context;
+
+    public List<String> getNameListByPrefix(String path) {
+        List<FileTpl> list = getListByPath(path, false);
+        List<String> result = new ArrayList<String>(list.size());
+        for (FileTpl tpl : list) {
+            result.add(tpl.getName());
+        }
+        return result;
+    }
+
+    public List<FileTpl> getListByPath(String path, boolean directory) {
+   		File f = new File(context.getRealPath(path));
+   		if (f.exists()) {
+   			File[] files = f.listFiles();
+   			if (files != null) {
+   				List<FileTpl> list = new ArrayList<FileTpl>();
+   				for (File file : files) {
+                    if(file.isFile() || directory)
+   					    list.add(new FileTpl(file, context.getRealPath("")));
+   				}
+   				return list;
+   			} else {
+   				return new ArrayList<FileTpl>(0);
+   			}
+   		} else {
+   			return new ArrayList<FileTpl>(0);
+   		}
+   	}
+
+    public List<FileTpl> getListForEdit(String path){
+        List<FileTpl> list = getListByPath(path, true);
+        List<FileTpl> result = new ArrayList<FileTpl>();
+        result.add(new FileTpl(new File(context.getRealPath(path)), context.getRealPath("")));
+        getAllDirectory(result, list);
+        return result;
+    }
+
+    private void getAllDirectory(List<FileTpl> result, List<FileTpl> list){
+        for (FileTpl tpl : list) {
+            result.add(tpl);
+            if(tpl.isDirectory()){
+                getAllDirectory(result, getListByPath(tpl.getName(), true));
+            }
+        }
+    }
+
+    public FileTpl getFileTpl(String name) {
+   		File f = new File(context.getRealPath(name));
+   		if (f.exists()) {
+   			return new FileTpl(f, "");
+   		} else {
+   			return null;
+   		}
+   	}
+    
+}

+ 146 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/CacheUtils.java

@@ -0,0 +1,146 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.shiro.cache.Cache;
+import org.apache.shiro.cache.CacheManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.SpringContextHolder;
+
+/**
+ * Cache工具类
+ * @author ThinkGem
+ * @version 2013-5-29
+ */
+public class CacheUtils {
+	
+	private static Logger logger = LoggerFactory.getLogger(CacheUtils.class);
+	private static CacheManager cacheManager = SpringContextHolder.getBean(CacheManager.class);
+	
+	private static final String SYS_CACHE = "sysCache";
+
+	/**
+	 * 获取SYS_CACHE缓存
+	 * @param key
+	 * @return
+	 */
+	public static Object get(String key) {
+		return get(SYS_CACHE, key);
+	}
+	
+	/**
+	 * 获取SYS_CACHE缓存
+	 * @param key
+	 * @param defaultValue
+	 * @return
+	 */
+	public static Object get(String key, Object defaultValue) {
+		Object value = get(key);
+		return value != null ? value : defaultValue;
+	}
+	
+	/**
+	 * 写入SYS_CACHE缓存
+	 * @param key
+	 * @return
+	 */
+	public static void put(String key, Object value) {
+		put(SYS_CACHE, key, value);
+	}
+	
+	/**
+	 * 从SYS_CACHE缓存中移除
+	 * @param key
+	 * @return
+	 */
+	public static void remove(String key) {
+		remove(SYS_CACHE, key);
+	}
+	
+	/**
+	 * 获取缓存
+	 * @param cacheName
+	 * @param key
+	 * @return
+	 */
+	public static Object get(String cacheName, String key) {
+		return getCache(cacheName).get(getKey(key));
+	}
+	
+	/**
+	 * 获取缓存
+	 * @param cacheName
+	 * @param key
+	 * @param defaultValue
+	 * @return
+	 */
+	public static Object get(String cacheName, String key, Object defaultValue) {
+		Object value = get(cacheName, getKey(key));
+		return value != null ? value : defaultValue;
+	}
+	
+	/**
+	 * 写入缓存
+	 * @param cacheName
+	 * @param key
+	 * @param value
+	 */
+	public static void put(String cacheName, String key, Object value) {
+		getCache(cacheName).put(getKey(key), value);
+	}
+
+	/**
+	 * 从缓存中移除
+	 * @param cacheName
+	 * @param key
+	 */
+	public static void remove(String cacheName, String key) {
+		getCache(cacheName).remove(getKey(key));
+	}
+
+	/**
+	 * 从缓存中移除所有
+	 * @param cacheName
+	 */
+	public static void removeAll(String cacheName) {
+		Cache<String, Object> cache = getCache(cacheName);
+		Set<String> keys = cache.keys();
+		for (Iterator<String> it = keys.iterator(); it.hasNext();){
+			cache.remove(it.next());
+		}
+		logger.info("清理缓存: {} => {}", cacheName, keys);
+	}
+	
+	/**
+	 * 获取缓存键名,多数据源下增加数据源名称前缀
+	 * @param key
+	 * @return
+	 */
+	private static String getKey(String key){
+//		String dsName = DataSourceHolder.getDataSourceName();
+//		if (StringUtils.isNotBlank(dsName)){
+//			return dsName + "_" + key;
+//		}
+		return key;
+	}
+	
+	/**
+	 * 获得一个Cache,没有则显示日志。
+	 * @param cacheName
+	 * @return
+	 */
+	private static Cache<String, Object> getCache(String cacheName){
+		Cache<String, Object> cache = cacheManager.getCache(cacheName);
+		if (cache == null){
+			throw new RuntimeException("当前系统中没有定义“"+cacheName+"”这个缓存。");
+		}
+		return cache;
+	}
+
+}

+ 167 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/CmsUtils.java

@@ -0,0 +1,167 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.ui.Model;
+
+import com.google.common.collect.Maps;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Article;
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Category;
+import cn.com.liandisys.ycjt.ggcx.admin.service.cms.ArticleService;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.SearchFilter.Operator;
+import cn.com.liandisys.ycjt.ggcx.common.config.Global;
+import cn.com.liandisys.ycjt.ggcx.common.util.SpringContextHolder;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtils;
+
+/**
+ * 内容管理工具类
+ * @author jiangchao
+ * @version 2016-11-29
+ */
+public class CmsUtils {
+
+    public static final String CACHE_ARTICLE_LIST = "articleListCache";
+
+    public static final String CACHE_ARTICLE_LIST_BELONG_ID = "id_";
+
+    public static final Integer CMS_INDEX_ARTICLE_SIZE = 7;
+
+    private static ServletContext context = SpringContextHolder.getBean(ServletContext.class);
+
+    private static ArticleService articleService = SpringContextHolder.getBean(ArticleService.class);
+
+    /**
+     * 获取文章
+     * @param articleId 文章编号
+     * @return
+     */
+    public static Article getArticle(String articleId) {
+
+        return articleService.findOne(articleId);
+    }
+
+    /**
+     * 获取文章列表
+     * @param categoryId 分类编号
+     * @param number 获取数目
+     * @param param  预留参数,例: key1:'value1', key2:'value2' ...
+     * 			posid	推荐位(1:首页焦点图;2:栏目页文章推荐;)
+     * 			image	文章图片(1:有图片的文章)
+     *          orderBy 排序字符串
+     * @return
+     * ${fnc:getArticleList(category.id, not empty pageSize?pageSize:8, 'posid:2, orderBy: \"hits desc\"')}"
+     */
+    @SuppressWarnings("unchecked")
+    public static List<Article> getArticleList(String categoryId, int number, String param) {
+
+        List<Article> cacheList = new ArrayList<Article>();
+        //        CacheUtils.remove(CACHE_ARTICLE_LIST + categoryId, CACHE_ARTICLE_LIST_BELONG_ID + categoryId);
+        cacheList = (List<Article>) CacheUtils.get(CACHE_ARTICLE_LIST + categoryId,
+                CACHE_ARTICLE_LIST_BELONG_ID + categoryId);
+        if (cacheList != null && cacheList.size() > 0) {
+            return cacheList;
+        } else {
+            Sort sort = new Sort(Direction.DESC, new String[] { "weight", "updateDate" });
+            PageRequest pageable = new PageRequest(0, number, sort);
+            Map<String, SearchFilter> filters = Maps.newHashMap();
+            if (!categoryId.equals("")) {
+                filters.put("category.id", new SearchFilter("category.id", Operator.EQ, categoryId));
+            }
+            Specification<Article> spec = DynamicSpecifications.bySearchFilter(filters.values(), Article.class);
+            Page<Article> jpaPage = articleService.findAll(spec, pageable);
+            CacheUtils.put(CACHE_ARTICLE_LIST + categoryId, CACHE_ARTICLE_LIST_BELONG_ID + categoryId,
+                    jpaPage.getContent());
+            return jpaPage.getContent();
+        }
+    }
+
+    /**
+     * 获得文章动态URL地址
+     * @param article
+     * @return url
+     */
+    public static String getUrlDynamic(Article article) {
+
+        if (StringUtils.isNotBlank(article.getLink())) {
+            return article.getLink();
+        }
+        StringBuilder str = new StringBuilder();
+        str.append(context.getContextPath()).append(Global.getFrontPath());
+        str.append("/front/view-").append(article.getCategory().getId()).append("-").append(article.getId())
+                .append(Global.getUrlSuffix());
+        return str.toString();
+    }
+
+    /**
+     * 获得栏目动态URL地址
+     * @param category
+     * @return url
+     */
+    public static String getUrlDynamic(Category category) {
+
+        if (StringUtils.isNotBlank(category.getHref())) {
+            if (!category.getHref().contains("://")) {
+                return context.getContextPath() + Global.getFrontPath() + category.getHref();
+            } else {
+                return category.getHref();
+            }
+        }
+        StringBuilder str = new StringBuilder();
+        str.append(context.getContextPath()).append(Global.getFrontPath());
+        str.append("/list-").append(category.getId()).append(Global.getUrlSuffix());
+        return str.toString();
+    }
+
+    /**
+     * 从图片地址中去除ContextPath地址
+     * @param src
+     * @return src
+     */
+    public static String formatImageSrcToDb(String src) {
+
+        if (StringUtils.isBlank(src))
+            return src;
+        if (src.startsWith(context.getContextPath() + "/userfiles")) {
+            return src.substring(context.getContextPath().length());
+        } else {
+            return src;
+        }
+    }
+
+    /**
+     * 从图片地址中加入ContextPath地址
+     * @param src
+     * @return src
+     */
+    public static String formatImageSrcToWeb(String src) {
+
+        if (StringUtils.isBlank(src))
+            return src;
+        if (src.startsWith(context.getContextPath() + "/userfiles")) {
+            return src;
+        } else {
+            return context.getContextPath() + src;
+        }
+    }
+
+    public static void addViewConfigAttribute(Model model, String param) {
+
+    }
+
+    public static void addViewConfigAttribute(Model model, Category category) {
+
+    }
+}

+ 98 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/Digests.java

@@ -0,0 +1,98 @@
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.MessageDigest;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.Exceptions;
+
+
+
+/**
+ * 支持SHA-1/MD5消息摘要的工具类.
+ * 
+ * 支持Hex与Base64两种编码方式.
+ * 
+ * 
+ */
+public class Digests {
+
+	private static final String SHA1 = "SHA-1";
+	private static final String MD5 = "MD5";
+
+	private Digests() {
+	}
+
+	//-- String Hash function --//
+	/**
+	 * 对输入字符串进行sha1散列, 返回Hex编码的结果.
+	 */
+	public static String sha1Hex(String input) {
+		byte[] digestResult = digest(input, SHA1);
+		return Encodes.encodeHex(digestResult);
+	}
+
+	/**
+	 * 对输入字符串进行sha1散列, 返回Base64编码的结果.
+	 */
+	public static String sha1Base64(String input) {
+		byte[] digestResult = digest(input, SHA1);
+		return Encodes.encodeBase64(digestResult);
+	}
+
+	/**
+	 * 对输入字符串进行sha1散列, 返回Base64编码的URL安全的结果.
+	 */
+	public static String sha1Base64UrlSafe(String input) {
+		byte[] digestResult = digest(input, SHA1);
+		return Encodes.encodeUrlSafeBase64(digestResult);
+	}
+
+	/**
+	 * 对字符串进行散列, 支持md5与sha1算法.
+	 */
+	private static byte[] digest(String input, String algorithm) {
+		try {
+			MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
+			return messageDigest.digest(input.getBytes());
+		} catch (GeneralSecurityException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	//-- File Hash function --//
+	/**
+	 * 对文件进行md5散列, 返回Hex编码结果.
+	 */
+	public static String md5Hex(InputStream input) throws IOException {
+		return digest(input, MD5);
+	}
+
+	/**
+	 * 对文件进行sha1散列, 返回Hex编码结果.
+	 */
+	public static String sha1Hex(InputStream input) throws IOException {
+		return digest(input, SHA1);
+	}
+
+	private static String digest(InputStream input, String algorithm) throws IOException {
+		try {
+			MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
+			int bufferLength = 1024;
+			byte[] buffer = new byte[bufferLength];
+			int read = input.read(buffer, 0, bufferLength);
+
+			while (read > -1) {
+				messageDigest.update(buffer, 0, read);
+				read = input.read(buffer, 0, bufferLength);
+			}
+
+			return Encodes.encodeHex(messageDigest.digest());
+
+		} catch (GeneralSecurityException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+}

+ 95 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/DynamicSpecifications.java

@@ -0,0 +1,95 @@
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.jpa.domain.Specification;
+
+import com.google.common.collect.Lists;
+
+public class DynamicSpecifications {
+
+    public static <T> Specification<T> bySearchFilter(final Collection<SearchFilter> filters, final Class<T> clazz) {
+
+        return new Specification<T>() {
+
+            @SuppressWarnings({ "rawtypes", "unchecked" })
+            @Override
+            public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+
+                if (filters != null && !(filters.isEmpty())) {
+
+                    List<Predicate> predicates = Lists.newArrayList();
+                    for (SearchFilter filter : filters) {
+                        // nested path translate, 如Task的名为"user.name"的filedName,
+                        // 转换为Task.user.name属性
+                        String[] names = StringUtils.split(filter.fieldName, ".");
+                        Path expression = root.get(names[0]);
+                        for (int i = 1; i < names.length; i++) {
+                            expression = expression.get(names[i]);
+                        }
+                        // logic operator
+                        // 将查询条件中的%和_转译,并在like查询时用escape条件过滤,使得%和_在like查询是不再当做特殊字符处理
+                        String pattern = "";
+                        if (null != filter.value) {
+                            pattern = filter.value.toString().toUpperCase();
+                            pattern = pattern.replaceAll("%", "\\\\%");
+                            pattern = pattern.replaceAll("_", "\\\\_");
+                        }
+                        switch (filter.operator) {
+                            case EQ:
+                                predicates.add(builder.equal(expression, filter.value));
+                                break;
+                            case LIKE:
+                                predicates.add(builder.like(builder.upper(expression), "%" + pattern + "%", '\\'));
+                                break;
+                            case LIKE_L:
+                                predicates.add(builder.like(builder.upper(expression), "%" + pattern, '\\'));
+                                break;
+                            case LIKE_R:
+                                predicates.add(builder.like(builder.upper(expression), pattern + "%", '\\'));
+                                break;
+                            case GT:
+                                predicates.add(builder.greaterThan(expression, (Comparable) filter.value));
+                                break;
+                            case LT:
+                                predicates.add(builder.lessThan(expression, (Comparable) filter.value));
+                                break;
+                            case GTE:
+                                predicates.add(builder.greaterThanOrEqualTo(expression, (Comparable) filter.value));
+                                break;
+                            case LTE:
+                                predicates.add(builder.lessThanOrEqualTo(expression, (Comparable) filter.value));
+                                break;
+                            case NL:
+                                predicates.add(builder.isNull(expression));
+                                break;
+                            case NNL:
+                                predicates.add(builder.isNotNull(expression));
+                                break;
+                            case NEQ:
+                                predicates.add(builder.notEqual(expression, filter.value));
+                                break;
+                            default:
+                                break;
+                        }
+                    }
+
+                    // 将所有条件用 and 联合起来
+                    if (predicates.size() > 0) {
+                        return builder.and(predicates.toArray(new Predicate[predicates.size()]));
+                    }
+                }
+
+                return builder.conjunction();
+            }
+        };
+    }
+}

+ 171 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/Encodes.java

@@ -0,0 +1,171 @@
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.Validate;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.Exceptions;
+
+/**
+ * 封装各种格式的编码解码工具类.
+ * 
+ * 1.Commons-Codec的 hex/base64 编码
+ * 2.自行编写的,将long进行base62编码以缩短其长度
+ * 3.Commons-Lang的xml/html escape
+ * 4.JDK提供的URLEncoder
+ * 
+ * 
+ */
+public class Encodes {
+	private static final String ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+	private static final String DEFAULT_URL_ENCODING = "UTF-8";
+
+	private Encodes() {
+	}
+
+	/**
+	 * Hex编码, byte[]->String.
+	 */
+	public static String encodeHex(byte[] input) {
+		return Hex.encodeHexString(input);
+	}
+
+	/**
+	 * Hex解码, String->byte[].
+	 */
+	public static byte[] decodeHex(String input) {
+		try {
+			return Hex.decodeHex(input.toCharArray());
+		} catch (DecoderException e) {
+			throw new IllegalStateException("Hex Decoder exception", e);
+		}
+	}
+
+	/**
+	 * Base64编码, byte[]->String.
+	 */
+	public static String encodeBase64(byte[] input) {
+		return Base64.encodeBase64String(input);
+	}
+
+	/**
+	 * Base64编码, URL安全(将Base64中的URL非法字符'+'和'/'转为'-'和'_', 见RFC3548).
+	 */
+	public static String encodeUrlSafeBase64(byte[] input) {
+		return Base64.encodeBase64URLSafeString(input);
+	}
+
+	/**
+	 * Base64解码, String->byte[].
+	 */
+	public static byte[] decodeBase64(String input) {
+		return Base64.decodeBase64(input);
+	}
+
+	/**
+	 * Base62(0_9A_Za_z)编码数字, long->String.
+	 */
+	public static String encodeBase62(long num) {
+		return alphabetEncode(num, 62);
+	}
+
+	/**
+	 * Base62(0_9A_Za_z)解码数字, String->long.
+	 */
+	public static long decodeBase62(String str) {
+		return alphabetDecode(str, 62);
+	}
+
+	private static String alphabetEncode(long num, int base) {
+		num = Math.abs(num);
+		StringBuilder sb = new StringBuilder();
+		for (; num > 0; num /= base) {
+			sb.append(ALPHABET.charAt((int) (num % base)));
+		}
+
+		return sb.toString();
+	}
+
+	private static long alphabetDecode(String str, int base) {
+		Validate.notBlank(str);
+
+		long result = 0;
+		for (int i = 0; i < str.length(); i++) {
+			result += ALPHABET.indexOf(str.charAt(i)) * Math.pow(base, i);
+		}
+
+		return result;
+	}
+
+	/**
+	 * Html 转码.
+	 */
+	public static String escapeHtml(String html) {
+		return StringEscapeUtils.escapeHtml4(html);
+	}
+
+	/**
+	 * Html 解码.
+	 */
+	public static String unescapeHtml(String htmlEscaped) {
+		return StringEscapeUtils.unescapeHtml4(htmlEscaped);
+	}
+
+	/**
+	 * Xml 转码.
+	 */
+	public static String escapeXml(String xml) {
+		return StringEscapeUtils.escapeXml(xml);
+	}
+
+	/**
+	 * Xml 解码.
+	 */
+	public static String unescapeXml(String xmlEscaped) {
+		return StringEscapeUtils.unescapeXml(xmlEscaped);
+	}
+
+	/**
+	 * Csv 转码.
+	 */
+	public static String escapeCsv(String csv) {
+		return StringEscapeUtils.escapeCsv(csv);
+	}
+
+	/**
+	 * Csv 解码.
+	 */
+	public static String unescapeCsv(String csvEscaped) {
+		return StringEscapeUtils.unescapeCsv(csvEscaped);
+	}
+
+	/**
+	 * URL 编码, Encode默认为UTF-8. 
+	 */
+	public static String urlEncode(String part) {
+		try {
+			return URLEncoder.encode(part, DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	/**
+	 * URL 解码, Encode默认为UTF-8. 
+	 */
+	public static String urlDecode(String part) {
+
+		try {
+			return URLDecoder.decode(part, DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+}

+ 261 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/JsonMapper.java

@@ -0,0 +1,261 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonParser.Feature;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.databind.util.JSONPObject;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * 简单封装Jackson,实现JSON String<->Java Object的Mapper.
+ * 封装不同的输出风格, 使用不同的builder函数创建实例.
+ * @author ThinkGem
+ * @version 2013-11-15
+ */
+public class JsonMapper extends ObjectMapper {
+
+	private static final long serialVersionUID = 1L;
+
+	private static Logger logger = LoggerFactory.getLogger(JsonMapper.class);
+
+	private static JsonMapper mapper;
+
+	public JsonMapper() {
+		this(Include.NON_EMPTY);
+	}
+
+	public JsonMapper(Include include) {
+		// 设置输出时包含属性的风格
+		if (include != null) {
+			this.setSerializationInclusion(include);
+		}
+		// 允许单引号、允许不带引号的字段名称
+		this.enableSimple();
+		// 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
+		this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+        // 空值处理为空串
+		this.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>(){
+			@Override
+			public void serialize(Object value, JsonGenerator jgen,
+					SerializerProvider provider) throws IOException,
+					JsonProcessingException {
+				jgen.writeString("");
+			}
+        });
+		// 进行HTML解码。
+		this.registerModule(new SimpleModule().addSerializer(String.class, new JsonSerializer<String>(){
+			@Override
+			public void serialize(String value, JsonGenerator jgen,
+					SerializerProvider provider) throws IOException,
+					JsonProcessingException {
+				jgen.writeString(StringEscapeUtils.unescapeHtml4(value));
+			}
+        }));
+		// 设置时区
+		this.setTimeZone(TimeZone.getDefault());//getTimeZone("GMT+8:00")
+	}
+
+	/**
+	 * 创建只输出非Null且非Empty(如List.isEmpty)的属性到Json字符串的Mapper,建议在外部接口中使用.
+	 */
+	public static JsonMapper getInstance() {
+		if (mapper == null){
+			mapper = new JsonMapper().enableSimple();
+		}
+		return mapper;
+	}
+
+	/**
+	 * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。
+	 */
+	public static JsonMapper nonDefaultMapper() {
+		if (mapper == null){
+			mapper = new JsonMapper(Include.NON_DEFAULT);
+		}
+		return mapper;
+	}
+	
+	/**
+	 * Object可以是POJO,也可以是Collection或数组。
+	 * 如果对象为Null, 返回"null".
+	 * 如果集合为空集合, 返回"[]".
+	 */
+	public String toJson(Object object) {
+		try {
+			return this.writeValueAsString(object);
+		} catch (IOException e) {
+			logger.warn("write to json string error:" + object, e);
+			return null;
+		}
+	}
+
+	/**
+	 * 反序列化POJO或简单Collection如List<String>.
+	 * 
+	 * 如果JSON字符串为Null或"null"字符串, 返回Null.
+	 * 如果JSON字符串为"[]", 返回空集合.
+	 * 
+	 * 如需反序列化复杂Collection如List<MyBean>, 请使用fromJson(String,JavaType)
+	 * @see #fromJson(String, JavaType)
+	 */
+	public <T> T fromJson(String jsonString, Class<T> clazz) {
+		if (StringUtils.isEmpty(jsonString)) {
+			return null;
+		}
+		try {
+			return this.readValue(jsonString, clazz);
+		} catch (IOException e) {
+			logger.warn("parse json string error:" + jsonString, e);
+			return null;
+		}
+	}
+
+	/**
+	 * 反序列化复杂Collection如List<Bean>, 先使用函數createCollectionType构造类型,然后调用本函数.
+	 * @see #createCollectionType(Class, Class...)
+	 */
+	@SuppressWarnings("unchecked")
+	public <T> T fromJson(String jsonString, JavaType javaType) {
+		if (StringUtils.isEmpty(jsonString)) {
+			return null;
+		}
+		try {
+			return (T) this.readValue(jsonString, javaType);
+		} catch (IOException e) {
+			logger.warn("parse json string error:" + jsonString, e);
+			return null;
+		}
+	}
+
+	/**
+	 * 構造泛型的Collection Type如:
+	 * ArrayList<MyBean>, 则调用constructCollectionType(ArrayList.class,MyBean.class)
+	 * HashMap<String,MyBean>, 则调用(HashMap.class,String.class, MyBean.class)
+	 */
+	public JavaType createCollectionType(Class<?> collectionClass, Class<?>... elementClasses) {
+		return this.getTypeFactory().constructParametricType(collectionClass, elementClasses);
+	}
+
+	/**
+	 * 當JSON裡只含有Bean的部分屬性時,更新一個已存在Bean,只覆蓋該部分的屬性.
+	 */
+	@SuppressWarnings("unchecked")
+	public <T> T update(String jsonString, T object) {
+		try {
+			return (T) this.readerForUpdating(object).readValue(jsonString);
+		} catch (JsonProcessingException e) {
+			logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
+		} catch (IOException e) {
+			logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
+		}
+		return null;
+	}
+
+	/**
+	 * 輸出JSONP格式數據.
+	 */
+	public String toJsonP(String functionName, Object object) {
+		return toJson(new JSONPObject(functionName, object));
+	}
+
+	/**
+	 * 設定是否使用Enum的toString函數來讀寫Enum,
+	 * 為False時時使用Enum的name()函數來讀寫Enum, 默認為False.
+	 * 注意本函數一定要在Mapper創建後, 所有的讀寫動作之前調用.
+	 */
+	public JsonMapper enableEnumUseToString() {
+		this.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
+		this.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
+		return this;
+	}
+
+	/**
+	 * 支持使用Jaxb的Annotation,使得POJO上的annotation不用与Jackson耦合。
+	 * 默认会先查找jaxb的annotation,如果找不到再找jackson的。
+	 */
+	public JsonMapper enableJaxbAnnotation() {
+		JaxbAnnotationModule module = new JaxbAnnotationModule();
+		this.registerModule(module);
+		return this;
+	}
+
+	/**
+	 * 允许单引号
+	 * 允许不带引号的字段名称
+	 */
+	public JsonMapper enableSimple() {
+		this.configure(Feature.ALLOW_SINGLE_QUOTES, true);
+		this.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
+		return this;
+	}
+	
+	/**
+	 * 取出Mapper做进一步的设置或使用其他序列化API.
+	 */
+	public ObjectMapper getMapper() {
+		return this;
+	}
+
+	/**
+	 * 对象转换为JSON字符串
+	 * @param object
+	 * @return
+	 */
+	public static String toJsonString(Object object){
+		return JsonMapper.getInstance().toJson(object);
+	}
+	
+	/**
+	 * JSON字符串转换为对象
+	 * @param jsonString
+	 * @param clazz
+	 * @return
+	 */
+	public static Object fromJsonString(String jsonString, Class<?> clazz){
+		return JsonMapper.getInstance().fromJson(jsonString, clazz);
+	}
+	
+	/**
+	 * 测试
+	 */
+	public static void main(String[] args) {
+		List<Map<String, Object>> list = Lists.newArrayList();
+		Map<String, Object> map = Maps.newHashMap();
+		map.put("id", 1);
+		map.put("pId", -1);
+		map.put("name", "根节点");
+		list.add(map);
+		map = Maps.newHashMap();
+		map.put("id", 2);
+		map.put("pId", 1);
+		map.put("name", "你好");
+		map.put("open", true);
+		list.add(map);
+		String json = JsonMapper.getInstance().toJson(list);
+		System.out.println(json);
+	}
+	
+}

+ 167 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/PredicateModel.java

@@ -0,0 +1,167 @@
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+import java.util.Collection;
+
+/**
+ * Predicate模型对象
+ * 
+ * @author 袁晓冬
+ * 
+ */
+public class PredicateModel {
+	/**
+	 * 条件类型
+	 * 
+	 * @author 袁晓冬
+	 * 
+	 */
+	public enum Operator {
+		EQ, LIKE, LIKE_L, LIKE_R, GT, LT, GTE, LTE,
+		/** IS NULL */
+		NL, IN,
+		/** IS NOT NULL */
+		NNL,
+		/**
+		 * NOT EQUAL
+		 */
+		NEQ
+	}
+
+	/**
+	 * 子模型连接方式
+	 * 
+	 * @author 袁晓冬
+	 * 
+	 */
+	public enum JoinType {
+		AND, OR
+	}
+
+	/** 查询字段名称 */
+	private String fieldName;
+	/** 查询字段值 */
+	private Object value;
+	/** 条件类型 */
+	private Operator operator;
+	/** 子模型链接方式(AND OR) */
+	private JoinType joinType;
+	/** 子模型集合 */
+	private Collection<PredicateModel> subPms;
+
+	/**
+	 * 构造无下级的模型对象
+	 * 
+	 * @param fieldName
+	 * @param value
+	 * @param operator
+	 */
+	public PredicateModel(String fieldName, Object value, Operator operator) {
+		this(fieldName, value, operator, JoinType.AND);
+	}
+
+	/**
+	 * 构造无下级的模型对象
+	 * 
+	 * @param fieldName
+	 * @param value
+	 * @param operator
+	 * @param type
+	 */
+	public PredicateModel(String fieldName, Object value, Operator operator,
+			JoinType type) {
+		this.fieldName = fieldName;
+		this.value = value;
+		this.operator = operator;
+		this.joinType = type;
+	}
+
+	/**
+	 * 构造带下级模型的对象,模型之间用指定的type(AND OR)连接
+	 * 
+	 * @param type
+	 * @param subPms
+	 */
+	public PredicateModel(JoinType type, Collection<PredicateModel> subPms) {
+		this.joinType = type;
+		this.subPms = subPms;
+	}
+
+	public PredicateModel() {
+
+	}
+
+	/**
+	 * 查询字段名称
+	 * 
+	 * @return
+	 */
+	public String getFieldName() {
+		return fieldName;
+	}
+
+	/**
+	 * 条件类型
+	 * 
+	 * @return
+	 */
+	public Operator getOperator() {
+		return operator;
+	}
+
+	/**
+	 * 子模型集合
+	 * 
+	 * @return
+	 */
+	public Collection<PredicateModel> getSubPms() {
+		return subPms;
+	}
+
+	/**
+	 * 子模型链接方式(AND OR)
+	 * 
+	 * @return
+	 */
+	public JoinType getJoinType() {
+		return joinType;
+	}
+
+	/**
+	 * 查询字段值
+	 * 
+	 * @return
+	 */
+	public Object getValue() {
+		return value;
+	}
+
+	/**
+	 * 是否包含下级模型
+	 * 
+	 * @return
+	 */
+	public boolean hasSubPredicateModel() {
+		return null != subPms && subPms.size() > 0;
+	}
+
+	public void setFieldName(String fieldName) {
+		this.fieldName = fieldName;
+	}
+
+	public void setOperator(Operator operator) {
+		this.operator = operator;
+	}
+
+	public void setSubPms(Collection<PredicateModel> subPms) {
+		this.subPms = subPms;
+	}
+
+	public void setJoinType(JoinType type) {
+		this.joinType = type;
+	}
+
+	public void setValue(Object value) {
+		this.value = value;
+	}
+
+}

+ 26 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/SearchFilter.java

@@ -0,0 +1,26 @@
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+public class SearchFilter {
+
+	public enum Operator {
+		EQ, LIKE, LIKE_L, LIKE_R, GT, LT, GTE, LTE,
+		/** IS NULL */
+		NL,
+		/** IS NOT NULL */
+		NNL,
+		/**
+		 * NOT EQUAL
+		 */
+		NEQ
+	}
+
+	public String fieldName;
+	public Object value;
+	public Operator operator;
+
+	public SearchFilter(String fieldName, Operator operator, Object value) {
+		this.fieldName = fieldName;
+		this.value = value;
+		this.operator = operator;
+	}
+}

+ 133 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/SpecificationCreater.java

@@ -0,0 +1,133 @@
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaBuilder.In;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.jpa.domain.Specification;
+
+/**
+ * Create Specification in the sense of Domain Driven Design
+ * 
+ * @author 袁晓冬
+ * 
+ */
+public class SpecificationCreater {
+
+    /**
+     * 根据PredicateModel集合构造查询
+     * 
+     * @param pms
+     * @param clazz
+     * @return
+     */
+    public static <T> Specification<T> searchByPredicateModels(Collection<PredicateModel> pms) {
+
+        return new ModelSpecification<T>(pms);
+    }
+
+    /**
+     * 可以处理PredicateModel模型的Specification
+     * 
+     * @author 袁晓冬
+     * 
+     * @param <T>
+     */
+    public static class ModelSpecification<T> implements Specification<T> {
+
+        private PredicateModel predicateModel;
+
+        public ModelSpecification(Collection<PredicateModel> pms) {
+
+            this.predicateModel = new PredicateModel(PredicateModel.JoinType.AND, pms);
+        }
+
+        @Override
+        public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+
+            if (predicateModel == null
+                    || (predicateModel.getFieldName() == null && !predicateModel.hasSubPredicateModel())) {
+                // 无查询条件
+                return cb.conjunction();
+            }
+            return toPredicateFromModel(predicateModel, root, cb);
+        }
+
+        @SuppressWarnings({ "unchecked", "rawtypes" })
+        private Predicate toPredicateFromModel(PredicateModel pm, Root<T> root, CriteriaBuilder cb) {
+
+            if (pm.hasSubPredicateModel()) {// 处理下级模型
+                List<Predicate> predicateList = new ArrayList<Predicate>();
+                for (PredicateModel p : pm.getSubPms()) {
+                    predicateList.add(toPredicateFromModel(p, root, cb));
+                }
+                Predicate[] predicates = new Predicate[predicateList.size()];
+                predicateList.toArray(predicates);
+                switch (pm.getJoinType()) {
+                    case AND:
+                        return cb.and(predicates);
+                    case OR:
+                        return cb.or(predicates);
+                    default:
+                        return cb.and(predicates);
+                }
+            } else {// 无下级模型时
+                // nested path translate, 如Task的名为"user.name"的filedName,
+                // 转换为Task.user.name属性
+                String[] names = StringUtils.split(pm.getFieldName(), ".");
+                Path expression = root.get(names[0]);
+                for (int i = 1; i < names.length; i++) {
+                    expression = expression.get(names[i]);
+                }
+                // logic operator
+                // 将查询条件中的%和_转译,并在like查询时用escape条件过滤,使得%和_在like查询是不再当做特殊字符处理
+                String pattern = "";
+                if (null != pm.getValue()) {
+                    pattern = pm.getValue().toString().toUpperCase();
+                    pattern = pattern.replaceAll("%", "\\\\%");
+                    pattern = pattern.replaceAll("_", "\\\\_");
+                }
+                switch (pm.getOperator()) {
+                    case IN:
+                        In<Object> in = cb.in(expression);
+                        for (Object id : (Iterable<Object>) pm.getValue()) {
+                            in.value(id);
+                        }
+                        return in;
+                    case EQ:
+                        return cb.equal(expression, pm.getValue());
+                    case LIKE:
+                        return cb.like(cb.upper(expression), "%" + pattern + "%", '\\');
+                    case LIKE_L:
+                        return cb.like(cb.upper(expression), "%" + pattern, '\\');
+                    case LIKE_R:
+                        return cb.like(cb.upper(expression), pattern + "%", '\\');
+                    case GT:
+                        return cb.greaterThan(expression, (Comparable) pm.getValue());
+                    case LT:
+                        return cb.lessThan(expression, (Comparable) pm.getValue());
+                    case GTE:
+                        return cb.greaterThanOrEqualTo(expression, (Comparable) pm.getValue());
+                    case LTE:
+                        return cb.lessThanOrEqualTo(expression, (Comparable) pm.getValue());
+                    case NL:
+                        return cb.isNull(expression);
+                    case NNL:
+                        return cb.isNotNull(expression);
+                    case NEQ:
+                        return cb.notEqual(expression, pm.getValue());
+                    default:
+                        return cb.equal(expression, pm.getValue());
+                }
+            }
+        }
+    }
+}

+ 72 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/admin/utils/TplUtils.java

@@ -0,0 +1,72 @@
+package cn.com.liandisys.ycjt.ggcx.admin.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtils;
+
+/**
+ * User: songlai
+ * Date: 13-8-22
+ * Time: 上午10:23
+ */
+public class TplUtils {
+    /**
+     * 去除模板前缀
+     *
+     * @param list     模板列表
+     * @param prefix   模板前缀  例如“frontViewArticle”
+     * @param include  需包含的模板  例如“/WEB-INF/views/modules/cms/front/themes/jeesite/articleSelectList.jsp”
+     * @param excludes 需去除的模板  例如“frontViewArticle”
+     * @return
+     */
+    public static List<String> tplTrim(List<String> list, String prefix, String include, String... excludes) {
+        List<String> result = new ArrayList<String>();
+        if (!StringUtils.isBlank(include) && !list.contains(include)) {
+            if (!tplContain(excludes, include)) {
+                int start = include.lastIndexOf("/");
+                int end = include.lastIndexOf(".");
+                if (start == -1 || end == -1) {
+                    throw new RuntimeException("include not contain '/' or '.':" + include);
+                }
+                result.add(include.substring(start + 1, end));
+            }
+        }
+        for (String t : list) {
+            if (!tplContain(excludes, t)) {
+                int start = t.lastIndexOf("/");
+                int end = t.lastIndexOf(".");
+                if (start == -1 || end == -1) {
+                    throw new RuntimeException("name not contain '/' or '.':" + t);
+                }
+                t = t.substring(start + 1, end);
+                if(t.contains(prefix)){
+                    result.add(t);
+                }
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 检查tpl是否存在于excludes里面。
+     *
+     * @param excludes
+     * @param tpl
+     * @return
+     */
+    private static boolean tplContain(String[] excludes, String tpl) {
+        int start = tpl.lastIndexOf("/");
+        int end = tpl.lastIndexOf(".");
+        if (start == -1 || end == -1) {
+            throw new RuntimeException("tpl not contain '/' or '.':" + tpl);
+        }
+        String name = tpl.substring(start + 1, end);
+        for (String e : excludes) {
+            if (e.equals(name)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

+ 115 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/airline/controller/ArrivalController.java

@@ -0,0 +1,115 @@
+package cn.com.liandisys.ycjt.ggcx.airline.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.google.common.collect.Maps;
+
+import cn.com.liandisys.ycjt.ggcx.admin.utils.DynamicSpecifications;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.SearchFilter;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.SearchFilter.Operator;
+import cn.com.liandisys.ycjt.ggcx.airline.model.AirLineEntity;
+import cn.com.liandisys.ycjt.ggcx.airline.service.AirLineService;
+import cn.com.liandisys.ycjt.ggcx.common.constant.SystemConstant;
+import cn.com.liandisys.ycjt.ggcx.common.controller.BaseController;
+import cn.com.liandisys.ycjt.ggcx.common.service.DataDicService;
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:ArrivalController    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月25日 下午4:33:19    
+ * 修改人:yangd    
+ * 修改时间:2016年11月25日 下午4:33:19    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Controller
+@RequestMapping(value = "/table")
+public class ArrivalController extends BaseController {
+
+    private Logger logger = LoggerFactory.getLogger(ArrivalController.class);
+
+    @Autowired
+    private AirLineService airLineService;
+
+    @Autowired
+    private DataDicService dataDicService;
+
+    //查询到港航班
+    @RequestMapping(value = "initArrivalData")
+    public String initArrivalData(Model model, @ModelAttribute("pageRequest") PageRequest pageRequest, String message) {
+
+        // 查询条件
+        Map<String, SearchFilter> filters = Maps.newHashMap();
+        filters.put("TYPE", new SearchFilter("TYPE", Operator.EQ, "1"));
+        Specification<AirLineEntity> spec = DynamicSpecifications.bySearchFilter(filters.values(), AirLineEntity.class);
+
+        Page<AirLineEntity> jpaPage = airLineService.findAll(spec, pageRequest);
+
+        cn.com.liandisys.ycjt.ggcx.admin.model.Page<AirLineEntity> page =
+                new cn.com.liandisys.ycjt.ggcx.admin.model.Page<AirLineEntity>(jpaPage.getNumber() + 1,
+                        jpaPage.getSize(), jpaPage.getTotalElements());
+        //当分页页码超过查询上限,则重置为最后一页,再查询一遍
+        int lastPage = jpaPage.getTotalPages();
+        if (lastPage < pageRequest.getPageNumber() + 1) {
+            pageRequest = new PageRequest(lastPage - 1, pageRequest.getPageSize(), pageRequest.getSort());
+            jpaPage = airLineService.findAll(spec, pageRequest);
+        }
+        //数据字典取出机型的具体信息
+        page.setList(jpaPage.getContent());
+        List<AirLineEntity> tempList = page.getList();
+        List<AirLineEntity> resultList = new ArrayList<AirLineEntity>();
+        try {
+            for (AirLineEntity d : tempList) {
+                d.setFLIGHT_MODEL(dataDicService.getDataDicName(SystemConstant.FLIGHT_MODEL, d.getFLIGHT_MODEL()));
+                resultList.add(d);
+            }
+        } catch (Exception e) {
+            model.addAttribute("message", e.getMessage());
+        }
+
+        page.setList(jpaPage.getContent());
+        model.addAttribute("page", page);
+        model.addAttribute("message", message);
+        return "table/arrival";
+    }
+
+    /**
+     * 分页信息获取
+     * 
+     */
+    @ModelAttribute("pageRequest")
+    public PageRequest getPageRequest(@RequestParam(value = "pageNo", required = false, defaultValue = "1") String page,
+            @RequestParam(value = "pageSize", required = false, defaultValue = "18") String size) {
+
+        Sort sort = new Sort(Direction.DESC, new String[] { "ID" });
+        if (org.springframework.util.StringUtils.hasText(page) && org.springframework.util.StringUtils.hasText(size)
+                && null != sort) {
+            // 页码从0开始
+            PageRequest pageable = new PageRequest(Integer.parseInt(page) - 1, Integer.parseInt(size), sort);
+            return pageable;
+        }
+        return null;
+    }
+
+}

+ 120 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/airline/controller/DepartureController.java

@@ -0,0 +1,120 @@
+package cn.com.liandisys.ycjt.ggcx.airline.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.google.common.collect.Maps;
+
+import cn.com.liandisys.ycjt.ggcx.admin.utils.DynamicSpecifications;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.SearchFilter;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.SearchFilter.Operator;
+import cn.com.liandisys.ycjt.ggcx.airline.dao.AirLineDao;
+import cn.com.liandisys.ycjt.ggcx.airline.model.AirLineEntity;
+import cn.com.liandisys.ycjt.ggcx.airline.service.AirLineService;
+import cn.com.liandisys.ycjt.ggcx.common.constant.SystemConstant;
+import cn.com.liandisys.ycjt.ggcx.common.controller.BaseController;
+import cn.com.liandisys.ycjt.ggcx.common.service.DataDicService;
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:DepartureController    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月25日 下午4:33:07    
+ * 修改人:yangd    
+ * 修改时间:2016年11月25日 下午4:33:07    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Controller
+@RequestMapping(value = "/table")
+public class DepartureController extends BaseController {
+
+    private Logger logger = LoggerFactory.getLogger(DepartureController.class);
+
+    @Autowired
+    private AirLineService airLineService;
+
+    @Autowired
+    private AirLineDao airLineDao;
+
+    @Autowired
+    private DataDicService dataDicService;
+
+    //查询出港航班
+    @RequestMapping(value = "initDepartureData")
+    public String initDepartureData(Model model, @ModelAttribute("pageRequest") PageRequest pageRequest,
+            String message) {
+
+        // 查询条件
+        Map<String, SearchFilter> filters = Maps.newHashMap();
+        filters.put("TYPE", new SearchFilter("TYPE", Operator.EQ, "2"));
+        Specification<AirLineEntity> spec = DynamicSpecifications.bySearchFilter(filters.values(), AirLineEntity.class);
+
+        Page<AirLineEntity> jpaPage = airLineService.findAll(spec, pageRequest);
+
+        cn.com.liandisys.ycjt.ggcx.admin.model.Page<AirLineEntity> page =
+                new cn.com.liandisys.ycjt.ggcx.admin.model.Page<AirLineEntity>(jpaPage.getNumber() + 1,
+                        jpaPage.getSize(), jpaPage.getTotalElements());
+        //当分页页码超过查询上限,则重置为最后一页,再查询一遍
+        int lastPage = jpaPage.getTotalPages();
+        if (lastPage < pageRequest.getPageNumber() + 1) {
+            pageRequest = new PageRequest(lastPage - 1, pageRequest.getPageSize(), pageRequest.getSort());
+            jpaPage = airLineService.findAll(spec, pageRequest);
+        }
+
+        //数据字典取出机型的具体信息
+        page.setList(jpaPage.getContent());
+        List<AirLineEntity> tempList = page.getList();
+        List<AirLineEntity> resultList = new ArrayList<AirLineEntity>();
+        try {
+            for (AirLineEntity d : tempList) {
+                d.setFLIGHT_MODEL(dataDicService.getDataDicName(SystemConstant.FLIGHT_MODEL, d.getFLIGHT_MODEL()));
+                resultList.add(d);
+            }
+        } catch (Exception e) {
+            model.addAttribute("message", e.getMessage());
+        }
+
+        page.setList(jpaPage.getContent());
+        model.addAttribute("page", page);
+        model.addAttribute("message", message);
+        return "table/departure";
+    }
+
+    /**
+     * 分页信息获取
+     * 
+     */
+    @ModelAttribute("pageRequest")
+    public PageRequest getPageRequest(@RequestParam(value = "pageNo", required = false, defaultValue = "1") String page,
+            @RequestParam(value = "pageSize", required = false, defaultValue = "18") String size) {
+
+        Sort sort = new Sort(Direction.DESC, new String[] { "ID" });
+        if (org.springframework.util.StringUtils.hasText(page) && org.springframework.util.StringUtils.hasText(size)
+                && null != sort) {
+            // 页码从0开始
+            PageRequest pageable = new PageRequest(Integer.parseInt(page) - 1, Integer.parseInt(size), sort);
+            return pageable;
+        }
+        return null;
+    }
+}

+ 137 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/airline/controller/DynamicflightController.java

@@ -0,0 +1,137 @@
+package cn.com.liandisys.ycjt.ggcx.airline.controller;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import cn.com.liandisys.ycjt.ggcx.airline.vo.AirDynamic;
+import cn.com.liandisys.ycjt.ggcx.common.util.MessageUtil;
+
+
+@Controller
+@RequestMapping(value = "/table")
+public class DynamicflightController {
+
+	 private Logger logger = LoggerFactory.getLogger(DynamicflightController.class);
+	final static String url = "http://221.231.1.162/GettingYNZFlightInfo/GettingFlightInfo";
+	
+	
+	//查询到港航班
+    @RequestMapping(value = "initDynamicflightData")
+    @ResponseBody
+	public  Map<String, Object> DynamicflightList(Model model){
+    	List<Map<String, Object>> airoutList = new ArrayList<Map<String, Object>>();
+    	List<Map<String, Object>> airinList = new ArrayList<Map<String, Object>>();
+		List<AirDynamic> airout = new ArrayList<AirDynamic>();
+		List<AirDynamic> airin = new ArrayList<AirDynamic>();
+	    Map<String, Object> retMap = new HashMap<String, Object>();
+		try {
+			airout.addAll(airDynamic(url, "marquee4", "out"));
+			airin.addAll(airDynamic(url, "marquee5", "in"));   //抓取进港数据
+			for (AirDynamic d : airout) {
+				 Map<String, Object> airoutMap = new HashMap<String, Object>();
+        		 airoutMap.put("hbh",d.getHbh());
+        		 airoutMap.put("sfd",(d.getSfd().toString()).replaceAll("  ", ""));
+        		 airoutMap.put("jt",d.getJt());
+        		 airoutMap.put("planlg",d.getPlanlg());
+        		 airoutMap.put("prelg",d.getPrelg());
+        		 airoutMap.put("actuallg",d.getActuallg());
+        		 airoutMap.put("status",d.getStatus());
+        		 airoutMap.put("color","#75b0dc");
+        		 if(d.getStatus().replaceAll("   ", "").equals("起飞"))
+        		 { airoutMap.put("color","#00B0F0");  }
+        		 if(d.getStatus().replaceAll("   ", "").equals("办票截止"))
+        		 { airoutMap.put("color","#F79646");  }
+        		 if(d.getStatus().replaceAll("   ", "").equals("登机结束"))
+        		 { airoutMap.put("color","red");  }
+        		 if(d.getStatus().replaceAll("   ", "").equals("延误"))
+        		 { airoutMap.put("color","#F2CA12");  }
+        		 if(d.getStatus().replaceAll("   ", "").equals("过站登机"))
+        		 { airoutMap.put("color","#00B050");  }
+        		 if(d.getStatus().replaceAll("   ", "").equals("正在办票"))
+        		 { airoutMap.put("color","#00B050");  }
+        		 airoutList.add(airoutMap);
+        	 }
+			for (AirDynamic d : airin) {
+				Map<String, Object> airinMap = new HashMap<String, Object>();
+	       		airinMap.put("hbh",d.getHbh());
+	       		airinMap.put("sfd",(d.getSfd().toString()).replaceAll(" ", ""));
+	       		airinMap.put("jt",d.getJt());
+	       		airinMap.put("planlg",d.getPlanlg());
+	       		airinMap.put("prelg",d.getPrelg());
+	       		airinMap.put("actuallg",d.getActuallg());
+	       		airinMap.put("status",d.getStatus());
+	       		airinMap.put("color","#000");
+	       		if(d.getStatus().replaceAll("   ", "").equals("前方起飞"))
+	       		{ airinMap.put("color","#00B0F0");  }
+	       		if(d.getStatus().replaceAll("   ", "").equals("到达"))
+	       		{ airinMap.put("color","#00B050");  }
+	       		if(d.getStatus().replaceAll("   ", "").equals("延误"))
+	       		{ airinMap.put("color","#F2CA12");  }
+       		    airinList.add(airinMap);
+       	 }
+			retMap.put("DynamicOut", airoutList);
+			retMap.put("DynamicIn", airinList);
+			return MessageUtil.buildResponseMap(true, retMap);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			logger.error(e.getMessage(), e);
+            return MessageUtil.buildResponseMap(false, MessageUtil.buildSystemErrorMessage(e), retMap);
+		}  //抓取出港数据
+		
+		
+	}
+
+
+public static List<AirDynamic> airDynamic(String url, String htmlId, String type) throws IOException {
+	List<AirDynamic> airs = new ArrayList<AirDynamic>();
+	Document result = Jsoup.connect(url).get();
+	Elements elemct = result.select("#" + htmlId + " ul li");
+	for (Element e : elemct) {
+		Elements ele = e.select("span");
+		AirDynamic air = new AirDynamic();
+		air.setType(type);
+		for (int i = 0, len = ele.size(); i < len; i++) {
+			switch (i) {
+			case 0:
+				air.setHbh(ele.get(i).text().trim());
+				break;
+			case 1:
+				air.setJt(ele.get(i).text().trim());
+				break;
+			case 2:
+				air.setSfd(ele.get(i).text().trim());
+				break;
+			case 3:
+				air.setPlanlg(ele.get(i).text().trim());
+				break;
+			case 4:
+				air.setPrelg(ele.get(i).text().trim());
+				break;
+			case 5:
+				air.setActuallg(ele.get(i).text().trim());
+				break;
+			case 6:
+				air.setStatus(ele.get(i).text().trim());
+				break;
+			}
+		}
+		airs.add(air);
+	}
+
+	return airs;
+}
+
+}

+ 32 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/airline/dao/AirLineDao.java

@@ -0,0 +1,32 @@
+package cn.com.liandisys.ycjt.ggcx.airline.dao;
+
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+import cn.com.liandisys.ycjt.ggcx.airline.model.AirLineEntity;
+
+
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:AirLineDao    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月25日 上午9:47:44    
+ * 修改人:yangd    
+ * 修改时间:2016年11月25日 上午9:47:44    
+ * 修改备注:    
+ * @version     
+ *
+ */
+public interface AirLineDao extends PagingAndSortingRepository<AirLineEntity, String>, JpaSpecificationExecutor<AirLineEntity> {
+    
+    public Page<AirLineEntity> findAll(Specification<AirLineEntity> spec, Pageable pageable);
+
+}

+ 155 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/airline/model/AirLineEntity.java

@@ -0,0 +1,155 @@
+package cn.com.liandisys.ycjt.ggcx.airline.model;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:AirLineEntity    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月25日 上午9:47:27    
+ * 修改人:yangd    
+ * 修改时间:2016年11月25日 上午9:47:27    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Entity 
+@Table(name = "ISN_FLIGHT_DES") 
+public class AirLineEntity {
+    
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY) 
+    @Column(name="ID")
+    private String ID; 
+    
+    @Column(name = "TYPE") 
+    private String TYPE;
+    
+    @Column(name = "AIRWAY")
+    private String AIRWAY; 
+    
+    @Column(name = "FLIGHT_NUM")
+    private String FLIGHT_NUM; 
+    
+    @Column(name = "FLIGHT_MODEL")
+    private String FLIGHT_MODEL; 
+    
+    @Column(name = "FLIGHT_SHIFT")
+    private String FLIGHT_SHIFT; 
+    
+    @Column(name = "DEPART_TIME")
+    private String DEPART_TIME; 
+    
+    @Column(name = "REACH_TIME")
+    private String REACH_TIME; 
+    
+    @Column(name = "REMARK")
+    private String REMARK; 
+    
+    @Column(name = "COUNT_TIME")
+    private String COUNT_TIME;
+    
+    @Column(name = "INSERT_TIME")
+    private String INSERT_TIME;
+
+    public String getID() {
+        return ID;
+    }
+
+    public void setID(String iD) {
+        ID = iD;
+    }
+
+    public String getTYPE() {
+        return TYPE;
+    }
+
+    public void setTYPE(String tYPE) {
+        TYPE = tYPE;
+    }
+
+    public String getAIRWAY() {
+        return AIRWAY;
+    }
+
+    public void setAIRWAY(String aIRWAY) {
+        AIRWAY = aIRWAY;
+    }
+
+    public String getFLIGHT_NUM() {
+        return FLIGHT_NUM;
+    }
+
+    public void setFLIGHT_NUM(String fLIGHT_NUM) {
+        FLIGHT_NUM = fLIGHT_NUM;
+    }
+
+    public String getFLIGHT_MODEL() {
+        return FLIGHT_MODEL;
+    }
+
+    public void setFLIGHT_MODEL(String fLIGHT_MODEL) {
+        FLIGHT_MODEL = fLIGHT_MODEL;
+    }
+
+    public String getFLIGHT_SHIFT() {
+        return FLIGHT_SHIFT;
+    }
+
+    public void setFLIGHT_SHIFT(String fLIGHT_SHIFT) {
+        FLIGHT_SHIFT = fLIGHT_SHIFT;
+    }
+
+    public String getDEPART_TIME() {
+        return DEPART_TIME;
+    }
+
+    public void setDEPART_TIME(String dEPART_TIME) {
+        DEPART_TIME = dEPART_TIME;
+    }
+
+    public String getREACH_TIME() {
+        return REACH_TIME;
+    }
+
+    public void setREACH_TIME(String rEACH_TIME) {
+        REACH_TIME = rEACH_TIME;
+    }
+
+    public String getREMARK() {
+        return REMARK;
+    }
+
+    public void setREMARK(String rEMARK) {
+        REMARK = rEMARK;
+    }
+
+    public String getCOUNT_TIME() {
+        return COUNT_TIME;
+    }
+
+    public void setCOUNT_TIME(String cOUNT_TIME) {
+        COUNT_TIME = cOUNT_TIME;
+    }
+
+    public String getINSERT_TIME() {
+        return INSERT_TIME;
+    }
+
+    public void setINSERT_TIME(String iNSERT_TIME) {
+        INSERT_TIME = iNSERT_TIME;
+    } 
+    
+    
+    
+}

+ 31 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/airline/service/AirLineService.java

@@ -0,0 +1,31 @@
+package cn.com.liandisys.ycjt.ggcx.airline.service;
+
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.cms.Article;
+import cn.com.liandisys.ycjt.ggcx.airline.model.AirLineEntity;
+import cn.com.liandisys.ycjt.ggcx.airline.vo.AirLine;
+
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:BusLineService    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月23日 下午2:48:12    
+ * 修改人:yangd    
+ * 修改时间:2016年11月23日 下午2:48:12    
+ * 修改备注:    
+ * @version     
+ *
+ */
+public interface AirLineService {
+    public Specification<AirLineEntity> getSpecification(AirLine queryParam);
+    
+    public Page<AirLineEntity> findAll(Specification<AirLineEntity> spec,Pageable pageable);
+}

+ 75 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/airline/service/impl/AirLineServiceImpl.java

@@ -0,0 +1,75 @@
+package cn.com.liandisys.ycjt.ggcx.airline.service.impl;
+
+
+import javax.annotation.Resource;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+
+import cn.com.liandisys.ycjt.ggcx.airline.dao.AirLineDao;
+import cn.com.liandisys.ycjt.ggcx.airline.model.AirLineEntity;
+import cn.com.liandisys.ycjt.ggcx.airline.service.AirLineService;
+import cn.com.liandisys.ycjt.ggcx.airline.vo.AirLine;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtil;
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:AirLineServiceImpl    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月25日 上午9:45:25    
+ * 修改人:yangd    
+ * 修改时间:2016年11月25日 上午9:45:25    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Service
+public class AirLineServiceImpl implements AirLineService{
+    private Logger logger = LoggerFactory.getLogger(AirLineServiceImpl.class);
+
+    @Resource(name = "airLineDao")
+    private AirLineDao dao;
+
+    @Override
+    public Page<AirLineEntity> findAll(Specification<AirLineEntity> spec, Pageable pageable) {
+
+        return dao.findAll(spec,pageable);
+    }
+    
+    /**
+     * 动态查询条件拼接
+     * @param queryParam
+     * @return
+     */
+    public Specification<AirLineEntity> getSpecification(AirLine queryParam) {
+
+        final String type = queryParam.getType();
+
+        return new Specification<AirLineEntity>() {
+
+            @Override
+            public Predicate toPredicate(Root<AirLineEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+
+                Predicate predicate = cb.conjunction();
+                //通过名称查找
+                if (!StringUtil.isEmpty(type)) {
+                    predicate.getExpressions().add(cb.equal((root.get("TYPE").as(String.class)), type));
+                }
+                return predicate;
+            }
+        };
+    }
+
+
+}

+ 85 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/airline/vo/AirDynamic.java

@@ -0,0 +1,85 @@
+package cn.com.liandisys.ycjt.ggcx.airline.vo;
+
+public class AirDynamic {
+
+	private String hbh;
+
+    private String jt;
+    
+    private String sfd;
+	
+    private String planlg;
+
+    private String actuallg;
+    
+    private String prelg;
+	
+    private String status;
+    private String type;
+
+	public String getHbh() {
+		return hbh;
+	}
+
+	public void setHbh(String hbh) {
+		this.hbh = hbh;
+	}
+
+	public String getJt() {
+		return jt;
+	}
+
+	public void setJt(String jt) {
+		this.jt = jt;
+	}
+
+	public String getSfd() {
+		return sfd;
+	}
+
+	public void setSfd(String sfd) {
+		this.sfd = sfd;
+	}
+
+	public String getPlanlg() {
+		return planlg;
+	}
+
+	public void setPlanlg(String planlg) {
+		this.planlg = planlg;
+	}
+
+	public String getActuallg() {
+		return actuallg;
+	}
+
+	public void setActuallg(String actuallg) {
+		this.actuallg = actuallg;
+	}
+
+	public String getPrelg() {
+		return prelg;
+	}
+
+	public void setPrelg(String prelg) {
+		this.prelg = prelg;
+	}
+
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+   
+}

+ 31 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/airline/vo/AirLine.java

@@ -0,0 +1,31 @@
+package cn.com.liandisys.ycjt.ggcx.airline.vo;
+
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:AirLine    
+ * 类描述:航空查询条件    
+ * 创建人:yangd    
+ * 创建时间:2016年11月25日 上午9:44:01    
+ * 修改人:yangd    
+ * 修改时间:2016年11月25日 上午9:44:01    
+ * 修改备注:    
+ * @version     
+ *
+ */
+public class AirLine {
+    
+    //航班类型
+    private String type;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+}

+ 139 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/busline/controller/BusLineController.java

@@ -0,0 +1,139 @@
+package cn.com.liandisys.ycjt.ggcx.busline.controller;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.google.common.collect.Maps;
+
+import cn.com.liandisys.ycjt.ggcx.admin.utils.DynamicSpecifications;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.SearchFilter;
+import cn.com.liandisys.ycjt.ggcx.admin.utils.SearchFilter.Operator;
+import cn.com.liandisys.ycjt.ggcx.busline.model.BusLineEntity;
+import cn.com.liandisys.ycjt.ggcx.busline.service.BusLineService;
+import cn.com.liandisys.ycjt.ggcx.common.controller.BaseController;
+import cn.com.liandisys.ycjt.ggcx.common.util.MessageUtil;
+
+/**
+ * 
+ * 项目名称:ycjt-ggcx    
+ * 类名称:BusLineController    
+ * 类描述:   公交线路
+ * 创建人:yangd    
+ * 创建时间:2016年11月23日 下午2:23:40    
+ * 修改人:yangd    
+ * 修改时间:2016年11月23日 下午2:23:40    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Controller
+@RequestMapping(value = "/table")
+public class BusLineController extends BaseController {
+
+    private Logger logger = LoggerFactory.getLogger(BusLineController.class);
+
+    @Autowired
+    private BusLineService busLineService;
+
+    //查询公交线路
+    @RequestMapping(value = "initLineData")
+    public String initLineData(Model model, @ModelAttribute("pageRequest") PageRequest pageRequest,
+            @RequestParam(value = "LINE_NAME", required = false, defaultValue = "") String lineName,
+            @RequestParam(value = "SITE", required = false, defaultValue = "") String site, String message) {
+
+        // 查询条件
+        Map<String, SearchFilter> filters = Maps.newHashMap();
+
+        if (!lineName.equals("")) {
+            filters.put("LINE_NAME", new SearchFilter("LINE_NAME", Operator.LIKE, lineName));
+            model.addAttribute("lineName", lineName);
+        }
+        if (!site.equals("")) {
+            filters.put("SITE", new SearchFilter("SITE", Operator.LIKE, site));
+            model.addAttribute("site", site);
+        }
+
+        Specification<BusLineEntity> spec = DynamicSpecifications.bySearchFilter(filters.values(), BusLineEntity.class);
+        Page<BusLineEntity> jpaPage = busLineService.findAll(spec, pageRequest);
+
+        cn.com.liandisys.ycjt.ggcx.admin.model.Page<BusLineEntity> page =
+                new cn.com.liandisys.ycjt.ggcx.admin.model.Page<BusLineEntity>(jpaPage.getNumber() + 1,
+                        jpaPage.getSize(), jpaPage.getTotalElements());
+        //当分页页码超过查询上限,则重置为最后一页,再查询一遍
+        int lastPage = jpaPage.getTotalPages();
+        if (lastPage > 0) {
+            if (lastPage < pageRequest.getPageNumber() + 1) {
+                pageRequest = new PageRequest(lastPage - 1, pageRequest.getPageSize(), pageRequest.getSort());
+                jpaPage = busLineService.findAll(spec, pageRequest);
+            }
+        }
+        List<BusLineEntity> pageList = jpaPage.getContent();
+        if (!site.equals("")) {
+            for (BusLineEntity bus : pageList) {
+                bus.setSITE(bus.getSITE().replaceAll(site, "<font style='color:red'>" + site + "</font>"));
+            }
+        }
+        page.setList(pageList);
+        model.addAttribute("page", page);
+        model.addAttribute("message", message);
+        model.addAttribute("bl", new BusLineEntity());
+        return "table/busline";
+    }
+
+    //查询首页的途经公交线路
+    @RequestMapping(value = "getBusLineName.do")
+    @ResponseBody
+    public Map<String, Object> getBusLineName(HttpServletRequest request) {
+
+        String site = request.getParameter("linename");
+
+        site = site.replace("(", "(").replace(")", ")");
+        Map<String, Object> retMap = new HashMap<String, Object>();
+        try {
+            List<BusLineEntity> list = busLineService.getBusLineName(site);
+            retMap.put("result", list);
+            return MessageUtil.buildResponseMap(true, retMap);
+
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return MessageUtil.buildResponseMap(false, MessageUtil.buildSystemErrorMessage(e), retMap);
+        }
+
+    }
+
+    /**
+     * 分页信息获取
+     * 
+     */
+    @ModelAttribute("pageRequest")
+    public PageRequest getPageRequest(@RequestParam(value = "pageNo", required = false, defaultValue = "1") String page,
+            @RequestParam(value = "pageSize", required = false, defaultValue = "4") String size) {
+
+        Sort sort = new Sort(Direction.DESC, new String[] { "ID" });
+        if (org.springframework.util.StringUtils.hasText(page) && org.springframework.util.StringUtils.hasText(size)
+                && null != sort) {
+            // 页码从0开始
+            PageRequest pageable = new PageRequest(Integer.parseInt(page) - 1, Integer.parseInt(size), sort);
+            return pageable;
+        }
+        return null;
+    }
+}

+ 32 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/busline/dao/BusLineDao.java

@@ -0,0 +1,32 @@
+package cn.com.liandisys.ycjt.ggcx.busline.dao;
+
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+import cn.com.liandisys.ycjt.ggcx.busline.model.BusLineEntity;
+
+
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:BusLineDao    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月23日 下午2:48:20    
+ * 修改人:yangd    
+ * 修改时间:2016年11月23日 下午2:48:20    
+ * 修改备注:    
+ * @version     
+ *
+ */
+public interface BusLineDao extends PagingAndSortingRepository<BusLineEntity, String>, JpaSpecificationExecutor<BusLineEntity> {
+    
+    public Page<BusLineEntity> findAll(Specification<BusLineEntity> spec, Pageable pageable);
+
+}

+ 199 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/busline/model/BusLineEntity.java

@@ -0,0 +1,199 @@
+package cn.com.liandisys.ycjt.ggcx.busline.model;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:BusLine    
+ * 类描述:    公交线路
+ * 创建人:yangd    
+ * 创建时间:2016年11月23日 下午2:42:04    
+ * 修改人:yangd    
+ * 修改时间:2016年11月23日 下午2:42:04    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Entity 
+@Table(name = "ISN_LINE_MAIN") 
+public class BusLineEntity {
+    
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY) 
+    @Column(name="ID")
+    private String ID; 
+    
+    @Column(name = "LINE_NAME") 
+    private String LINE_NAME;
+    
+    @Column(name = "FIRST_TIME")
+    private String FIRST_TIME; 
+    
+    @Column(name = "LAST_TIME")
+    private String LAST_TIME; 
+    
+    @Column(name = "START_END")
+    private String START_END; 
+    
+    @Column(name = "SITE")
+    private String SITE; 
+    
+    @Column(name = "ROAD")
+    private String ROAD; 
+    
+    @Column(name = "TICK_PRICE")
+    private String TICK_PRICE; 
+    
+    @Column(name = "REMARK")
+    private String REMARK; 
+    
+    @Column(name = "STSTUS_FLG")
+    private String STSTUS_FLG;
+    
+    @Column(name = "DELETEFLAG")
+    private String DELETEFLAG; 
+    
+    @Column(name = "CREATE_PERSON")
+    private String CREATE_PERSON; 
+    
+    @Column(name = "CREATE_TIME")
+    private Date CREATE_TIME; 
+    
+    @Column(name = "UPDATE_PERSON")
+    private String UPDATE_PERSON ; 
+    
+    @Column(name = "UPDATE_TIME")
+    private Date UPDATE_TIME  ;
+
+    public String getID() {
+        return ID;
+    }
+
+    public void setID(String iD) {
+        ID = iD;
+    }
+
+    public String getLINE_NAME() {
+        return LINE_NAME;
+    }
+
+    public void setLINE_NAME(String lINE_NAME) {
+        LINE_NAME = lINE_NAME;
+    }
+
+    public String getFIRST_TIME() {
+        return FIRST_TIME;
+    }
+
+    public void setFIRST_TIME(String fIRST_TIME) {
+        FIRST_TIME = fIRST_TIME;
+    }
+
+    public String getLAST_TIME() {
+        return LAST_TIME;
+    }
+
+    public void setLAST_TIME(String lAST_TIME) {
+        LAST_TIME = lAST_TIME;
+    }
+
+    public String getSTART_END() {
+        return START_END;
+    }
+
+    public void setSTART_END(String sTART_END) {
+        START_END = sTART_END;
+    }
+
+    public String getSITE() {
+        return SITE;
+    }
+
+    public void setSITE(String sITE) {
+        SITE = sITE;
+    }
+
+    public String getROAD() {
+        return ROAD;
+    }
+
+    public void setROAD(String rOAD) {
+        ROAD = rOAD;
+    }
+
+    public String getTICK_PRICE() {
+        return TICK_PRICE;
+    }
+
+    public void setTICK_PRICE(String tICK_PRICE) {
+        TICK_PRICE = tICK_PRICE;
+    }
+
+    public String getREMARK() {
+        return REMARK;
+    }
+
+    public void setREMARK(String rEMARK) {
+        REMARK = rEMARK;
+    }
+
+    public String getSTSTUS_FLG() {
+        return STSTUS_FLG;
+    }
+
+    public void setSTSTUS_FLG(String sTSTUS_FLG) {
+        STSTUS_FLG = sTSTUS_FLG;
+    }
+
+    public String getDELETEFLAG() {
+        return DELETEFLAG;
+    }
+
+    public void setDELETEFLAG(String dELETEFLAG) {
+        DELETEFLAG = dELETEFLAG;
+    }
+
+    public String getCREATE_PERSON() {
+        return CREATE_PERSON;
+    }
+
+    public void setCREATE_PERSON(String cREATE_PERSON) {
+        CREATE_PERSON = cREATE_PERSON;
+    }
+
+    public Date getCREATE_TIME() {
+        return CREATE_TIME;
+    }
+
+    public void setCREATE_TIME(Date cREATE_TIME) {
+        CREATE_TIME = cREATE_TIME;
+    }
+
+    public String getUPDATE_PERSON() {
+        return UPDATE_PERSON;
+    }
+
+    public void setUPDATE_PERSON(String uPDATE_PERSON) {
+        UPDATE_PERSON = uPDATE_PERSON;
+    }
+
+    public Date getUPDATE_TIME() {
+        return UPDATE_TIME;
+    }
+
+    public void setUPDATE_TIME(Date uPDATE_TIME) {
+        UPDATE_TIME = uPDATE_TIME;
+    } 
+    
+    
+    
+    
+}

+ 33 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/busline/service/BusLineService.java

@@ -0,0 +1,33 @@
+package cn.com.liandisys.ycjt.ggcx.busline.service;
+
+import java.util.List;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+
+import cn.com.liandisys.ycjt.ggcx.busline.model.BusLineEntity;
+import cn.com.liandisys.ycjt.ggcx.busline.vo.BusLine;
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:BusLineService    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月23日 下午2:48:12    
+ * 修改人:yangd    
+ * 修改时间:2016年11月23日 下午2:48:12    
+ * 修改备注:    
+ * @version     
+ *
+ */
+public interface BusLineService {
+
+    public Specification<BusLineEntity> getSpecification(BusLine queryParam);
+
+    public Page<BusLineEntity> findAll(Specification<BusLineEntity> spec, Pageable pageable);
+
+    public List<BusLineEntity> getBusLineName(String site);
+}

+ 101 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/busline/service/impl/BusLineServiceImpl.java

@@ -0,0 +1,101 @@
+package cn.com.liandisys.ycjt.ggcx.busline.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import cn.com.liandisys.ycjt.ggcx.busline.dao.BusLineDao;
+import cn.com.liandisys.ycjt.ggcx.busline.model.BusLineEntity;
+import cn.com.liandisys.ycjt.ggcx.busline.service.BusLineService;
+import cn.com.liandisys.ycjt.ggcx.busline.vo.BusLine;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtil;
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:BusLineServiceImpl    
+ * 类描述:    公交线路
+ * 创建人:yangd    
+ * 创建时间:2016年11月23日 下午2:42:35    
+ * 修改人:yangd    
+ * 修改时间:2016年11月23日 下午2:42:35    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Service
+public class BusLineServiceImpl implements BusLineService {
+
+    private Logger logger = LoggerFactory.getLogger(BusLineServiceImpl.class);
+
+    @Resource(name = "busLineDao")
+    private BusLineDao dao;
+
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+
+    @Override
+    public Page<BusLineEntity> findAll(Specification<BusLineEntity> spec, Pageable pageable) {
+
+        return dao.findAll(spec, pageable);
+    }
+
+    /**
+     * 动态查询条件拼接
+     * @param queryParam
+     * @return
+     */
+    public Specification<BusLineEntity> getSpecification(BusLine queryParam) {
+
+        final String linename = queryParam.getLineName();
+        final String site = queryParam.getSite();
+
+        return new Specification<BusLineEntity>() {
+
+            @Override
+            public Predicate toPredicate(Root<BusLineEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+
+                Predicate predicate = cb.conjunction();
+                //通过名称查找
+                if (!StringUtil.isEmpty(linename)) {
+                    predicate.getExpressions()
+                            .add(cb.like((root.get("LINE_NAME").as(String.class)), '%' + linename + '%'));
+                }
+                if (!StringUtil.isEmpty(site)) {
+                    predicate.getExpressions().add(cb.like((root.get("SITE").as(String.class)), '%' + site + '%'));
+                }
+                return predicate;
+            }
+        };
+    }
+
+    @Override
+    public List<BusLineEntity> getBusLineName(String site) {
+
+        List<BusLineEntity> list_all = new ArrayList<>();
+
+        //创建sql语句获得线路名称
+        String sql_busline =
+                "SELECT LINE_NAME FROM  ISN_LINE_MAIN  WHERE replace(replace(SITE, '(', '('), ')', ')') like " + "'%"
+                        + site + "%'";
+
+        List list = jdbcTemplate.queryForList(sql_busline);
+        return list;
+    }
+
+}

+ 45 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/busline/vo/BusLine.java

@@ -0,0 +1,45 @@
+package cn.com.liandisys.ycjt.ggcx.busline.vo;
+
+import java.util.Date;
+
+/**
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:BusLine    
+ * 类描述:    公交线路
+ * 创建人:yangd    
+ * 创建时间:2016年11月24日 上午11:25:46    
+ * 修改人:yangd    
+ * 修改时间:2016年11月24日 上午11:25:46    
+ * 修改备注:    
+ * @version     
+ *
+ */
+public class BusLine {
+    
+    //线路名称
+    private String lineName;
+    
+    //途径站点
+    private String site;
+
+    public String getLineName() {
+        return lineName;
+    }
+
+    public void setLineName(String lineName) {
+        this.lineName = lineName;
+    }
+
+    public String getSite() {
+        return site;
+    }
+
+    public void setSite(String site) {
+        this.site = site;
+    }
+    
+    
+    
+    
+}

+ 55 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/controller/CityEventController.java

@@ -0,0 +1,55 @@
+package cn.com.liandisys.ycjt.ggcx.cityevent.controller;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import cn.com.liandisys.ycjt.ggcx.cityevent.model.CityEvent;
+import cn.com.liandisys.ycjt.ggcx.cityevent.service.CityEventService;
+import cn.com.liandisys.ycjt.ggcx.common.util.MessageUtil;
+
+/**
+ * 
+ * 项目名称:ycjt-ggcx    
+ * 类名称:CityEventController    
+ * 类描述:   城市公路事件
+ * 创建人:zhangyn    
+ * 创建时间:2017年5月2日 下午2:23:40    
+ * 修改人:zhangyn    
+ * 修改时间:2017年5月2日 下午2:23:40    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Controller
+public class CityEventController {
+
+    private Logger logger = LoggerFactory.getLogger(CityEventController.class);
+
+    @Autowired
+    private CityEventService cityEventService;
+
+    @RequestMapping(value = "getCityEventList.do")
+    @ResponseBody
+    public Map<String, Object> getCityEventList(Model model) {
+
+        Map<String, Object> retMap = new HashMap<String, Object>();
+        try {
+            // 根据条件取得结果集
+            List<CityEvent> cityEventList = cityEventService.getCityEventList();
+            retMap.put("result", cityEventList);
+            return MessageUtil.buildResponseMap(true, retMap);
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return MessageUtil.buildResponseMap(false, MessageUtil.buildSystemErrorMessage(e), retMap);
+        }
+    }
+}

+ 27 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/dao/CityEventDao.java

@@ -0,0 +1,27 @@
+package cn.com.liandisys.ycjt.ggcx.cityevent.dao;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+import cn.com.liandisys.ycjt.ggcx.cityevent.model.CityEvent;
+
+/**
+ * 
+ * 项目名称:ycjt-ggcx    
+ * 类名称:CityEventDao    
+ * 类描述:   城市公路事件
+ * 创建人:zhangyn    
+ * 创建时间:2017年5月2日 下午2:23:40    
+ * 修改人:zhangyn    
+ * 修改时间:2017年5月2日 下午2:23:40    
+ * 修改备注:    
+ * @version     
+ *
+ */
+public interface CityEventDao extends JpaRepository<CityEvent, String>, JpaSpecificationExecutor<CityEvent> {
+
+    public List<CityEvent> findAll();
+
+}

+ 161 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/model/CityEvent.java

@@ -0,0 +1,161 @@
+package cn.com.liandisys.ycjt.ggcx.cityevent.model;
+
+import java.sql.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * 
+ * 项目名称:ycjt-ggcx    
+ * 类名称:CityEvent    
+ * 类描述:   城市公路事件
+ * 创建人:zhangyn    
+ * 创建时间:2017年5月2日 下午2:23:40    
+ * 修改人:zhangyn    
+ * 修改时间:2017年5月2日 下午2:23:40    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Entity
+@Table(name = "ISN_CITYEVENT_DES")
+public class CityEvent {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "ID")
+    private String id;
+
+    @Column(name = "TIME")
+    private Date time;
+
+    @Column(name = "POSITION")
+    private String position;
+
+    @Column(name = "DESCRIBE")
+    private String describe;
+
+    @Column(name = "LONGITUDE")
+    private String longitude;
+
+    @Column(name = "LATITUDE")
+    private String latitude;
+
+    @Column(name = "CREATE_PERSON")
+    private String createPerson;
+
+    @Column(name = "CREATE_TIME")
+    private Date createTime;
+
+    @Column(name = "UPDATE_PERSON")
+    private String updatePerson;
+
+    @Column(name = "UPDATE_TIME")
+    private Date updateTime;
+
+    public String getId() {
+
+        return id;
+    }
+
+    public void setId(String id) {
+
+        this.id = id;
+    }
+
+    public Date getTime() {
+
+        return time;
+    }
+
+    public void setTime(Date time) {
+
+        this.time = time;
+    }
+
+    public String getPosition() {
+
+        return position;
+    }
+
+    public void setPosition(String position) {
+
+        this.position = position;
+    }
+
+    public String getDescribe() {
+
+        return describe;
+    }
+
+    public void setDescribe(String describe) {
+
+        this.describe = describe;
+    }
+
+    public String getLongitude() {
+
+        return longitude;
+    }
+
+    public void setLongitude(String longitude) {
+
+        this.longitude = longitude;
+    }
+
+    public String getLatitude() {
+
+        return latitude;
+    }
+
+    public void setLatitude(String latitude) {
+
+        this.latitude = latitude;
+    }
+
+    public String getCreatePerson() {
+
+        return createPerson;
+    }
+
+    public void setCreatePerson(String createPerson) {
+
+        this.createPerson = createPerson;
+    }
+
+    public Date getCreateTime() {
+
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+
+        this.createTime = createTime;
+    }
+
+    public String getUpdatePerson() {
+
+        return updatePerson;
+    }
+
+    public void setUpdatePerson(String updatePerson) {
+
+        this.updatePerson = updatePerson;
+    }
+
+    public Date getUpdateTime() {
+
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+
+        this.updateTime = updateTime;
+    }
+
+}

+ 24 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/service/CityEventService.java

@@ -0,0 +1,24 @@
+package cn.com.liandisys.ycjt.ggcx.cityevent.service;
+
+import java.util.List;
+
+import cn.com.liandisys.ycjt.ggcx.cityevent.model.CityEvent;
+
+/**
+ * 
+ * 项目名称:ycjt-ggcx    
+ * 类名称:CityEventService    
+ * 类描述:   城市公路事件
+ * 创建人:zhangyn    
+ * 创建时间:2017年5月2日 下午2:23:40    
+ * 修改人:zhangyn    
+ * 修改时间:2017年5月2日 下午2:23:40    
+ * 修改备注:    
+ * @version     
+ *
+ */
+public interface CityEventService {
+
+    public List<CityEvent> getCityEventList();
+
+}

+ 37 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/cityevent/service/impl/CityEventServiceImpl.java

@@ -0,0 +1,37 @@
+package cn.com.liandisys.ycjt.ggcx.cityevent.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.liandisys.ycjt.ggcx.cityevent.dao.CityEventDao;
+import cn.com.liandisys.ycjt.ggcx.cityevent.model.CityEvent;
+import cn.com.liandisys.ycjt.ggcx.cityevent.service.CityEventService;
+
+/**
+ * 
+ * 项目名称:ycjt-ggcx    
+ * 类名称:CityEventServiceImpl    
+ * 类描述:   城市公路事件
+ * 创建人:zhangyn    
+ * 创建时间:2017年5月2日 下午2:23:40    
+ * 修改人:zhangyn    
+ * 修改时间:2017年5月2日 下午2:23:40    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Service
+public class CityEventServiceImpl implements CityEventService {
+
+    @Autowired
+    private CityEventDao dao;
+
+    @Override
+    public List<CityEvent> getCityEventList() {
+
+        return dao.findAll();
+    }
+
+}

+ 133 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/controller/BusMainController.java

@@ -0,0 +1,133 @@
+package cn.com.liandisys.ycjt.ggcx.coachBus.controller;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import cn.com.liandisys.ycjt.ggcx.coachBus.dao.BusMainDao;
+import cn.com.liandisys.ycjt.ggcx.coachBus.model.BusMain;
+import cn.com.liandisys.ycjt.ggcx.coachBus.service.BusMainService;
+import cn.com.liandisys.ycjt.ggcx.coachBus.vo.QueryParam;
+import cn.com.liandisys.ycjt.ggcx.common.constant.PageUrl;
+import cn.com.liandisys.ycjt.ggcx.common.constant.SystemConstant;
+import cn.com.liandisys.ycjt.ggcx.common.service.DataDicService;
+import cn.com.liandisys.ycjt.ggcx.common.util.JacksonUtil;
+import cn.com.liandisys.ycjt.ggcx.common.util.MessageUtil;
+import cn.com.liandisys.ycjt.ggcx.common.vo.Paging;
+
+@Controller
+@RequestMapping(value = "/table")
+public class BusMainController {
+
+    private Logger logger = LoggerFactory.getLogger(BusMainController.class);
+
+    @Autowired
+    private BusMainService busMainService;
+
+    @Autowired
+    private BusMainDao busMainDao;
+
+    @Autowired
+    private DataDicService dataDicService;
+
+    /**
+     * 跳转到查询界面
+     * 2016.11.26
+     * by zhangyn
+     */
+    @RequestMapping("/ctkyc")
+    public ModelAndView showCtkyView(HttpServletRequest request) throws Exception {
+
+        ModelAndView mv = new ModelAndView(PageUrl.CTKY_VIEW);
+        String arrLocation = request.getParameter("carLocation");
+        try {
+            // 乘车地点
+            mv.addObject("carLocationList",
+                    JacksonUtil.toJsonNode(dataDicService.getDataDicInfo(SystemConstant.CAR_LOCATION)));
+            // 到达站
+            mv.addObject("carLocation ", arrLocation);
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw e;
+        }
+        return mv;
+    }
+
+    /**
+     * 初始化数据列表
+     * 2016.11.24
+     * by zhangyn
+     **/
+    @RequestMapping(value = "getCtkyGridData.do", produces = "application/json;charset=UTF-8")
+    @ResponseBody
+    public Map<String, Object> getCtkyGridData(QueryParam queryParam, @ModelAttribute Paging paging) {
+
+        Map<String, Object> retMap = new HashMap<String, Object>();
+        try {
+            Page<BusMain> busMains = findBySpecAndPaginate(paging.getPage() - 1, paging.getRows(), queryParam);
+            retMap.put("page", paging.getPage());
+            retMap.put("total", count(queryParam));
+            List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
+            if (busMains.getContent() != null) {
+                List<BusMain> busMainList = busMains.getContent();
+                for (BusMain d : busMainList) {
+                    Map<String, Object> row = new HashMap<String, Object>();
+                    row.put("id", d.getId());
+                    row.put("busNum", d.getBusNum());
+                    row.put("dTime", d.getDepartTime());
+                    row.put("carLocation",
+                            dataDicService.getDataDicName(SystemConstant.CAR_LOCATION, d.getCarLocation()));
+                    row.put("arrLocation", d.getArrLocation());
+                    row.put("price", d.getPrice());
+                    row.put("surTick", d.getSurTick());
+                    rows.add(row);
+                }
+            }
+            retMap.put("rows", rows);
+            return MessageUtil.buildResponseMap(true, retMap);
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return MessageUtil.buildResponseMap(false, MessageUtil.buildSystemErrorMessage(e), retMap);
+        }
+    }
+
+    /**
+     * 返回分页查询结果
+     * 2016.11.24
+     * by zhangyn
+     * */
+    private Page<BusMain> findBySpecAndPaginate(int page, int size, QueryParam queryParam) {
+
+        Page<BusMain> busMains = busMainDao.findAll(busMainService.getSpecification(queryParam),
+                new PageRequest(page, size, new Sort(Direction.ASC, new String[] { "id" })));
+        return busMains;
+    }
+
+    /**
+     * 返回查询的总记录
+     * 2016.11.24
+     * by zhangyn
+     * */
+    private Long count(QueryParam queryParam) {
+
+        Long count = busMainDao.count(busMainService.getSpecification(queryParam));
+        return count;
+    }
+
+}

+ 15 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/dao/BusMainDao.java

@@ -0,0 +1,15 @@
+package cn.com.liandisys.ycjt.ggcx.coachBus.dao;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+import cn.com.liandisys.ycjt.ggcx.coachBus.model.BusMain;
+
+public interface BusMainDao extends PagingAndSortingRepository<BusMain, String>, JpaSpecificationExecutor<BusMain> {
+
+    public Page<BusMain> findAll(Specification<BusMain> spec, Pageable pageable);
+
+}

+ 148 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/model/BusMain.java

@@ -0,0 +1,148 @@
+package cn.com.liandisys.ycjt.ggcx.coachBus.model;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "ISN_BUS_DES")
+public class BusMain {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "ID")
+    private String id;
+
+    @Column(name = "BUS_NUM")
+    private String busNum;
+
+    @Column(name = "DEPART_TIME")
+    private String departTime;
+
+    @Column(name = "CAR_LOCATION")
+    private String carLocation;
+
+    @Column(name = "ARR_LOCATION")
+    private String arrLocation;
+
+    @Column(name = "PRICE")
+    private Double price;
+
+    @Column(name = "SUR_TICK")
+    private Double surTick;
+
+    @Column(name = "REMARK")
+    private String remark;
+
+    @Column(name = "COUNT_TIME")
+    private Date countTime;
+
+    @Column(name = "INSERT_TIME")
+    private Date insertTime;
+
+    public String getId() {
+
+        return id;
+    }
+
+    public void setId(String id) {
+
+        this.id = id;
+    }
+
+    public String getBusNum() {
+
+        return busNum;
+    }
+
+    public void setBusNum(String busNum) {
+
+        this.busNum = busNum;
+    }
+
+    public String getDepartTime() {
+
+        return departTime;
+    }
+
+    public void setDepartTime(String departTime) {
+
+        this.departTime = departTime;
+    }
+
+    public String getCarLocation() {
+
+        return carLocation;
+    }
+
+    public void setCarLocation(String carLocation) {
+
+        this.carLocation = carLocation;
+    }
+
+    public String getArrLocation() {
+
+        return arrLocation;
+    }
+
+    public void setArrLocation(String arrLocation) {
+
+        this.arrLocation = arrLocation;
+    }
+
+    public Double getPrice() {
+
+        return price;
+    }
+
+    public void setPrice(Double price) {
+
+        this.price = price;
+    }
+
+    public Double getSurTick() {
+
+        return surTick;
+    }
+
+    public void setSurTick(Double surTick) {
+
+        this.surTick = surTick;
+    }
+
+    public String getRemark() {
+
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+
+        this.remark = remark;
+    }
+
+    public Date getCountTime() {
+
+        return countTime;
+    }
+
+    public void setCountTime(Date countTime) {
+
+        this.countTime = countTime;
+    }
+
+    public Date getInsertTime() {
+
+        return insertTime;
+    }
+
+    public void setInsertTime(Date insertTime) {
+
+        this.insertTime = insertTime;
+    }
+
+}

+ 16 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/service/BusMainService.java

@@ -0,0 +1,16 @@
+package cn.com.liandisys.ycjt.ggcx.coachBus.service;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+
+import cn.com.liandisys.ycjt.ggcx.coachBus.model.BusMain;
+import cn.com.liandisys.ycjt.ggcx.coachBus.vo.QueryParam;
+
+public interface BusMainService {
+
+    public Page<BusMain> findAll(Pageable pageable);
+
+    public Specification<BusMain> getSpecification(QueryParam queryParam);
+
+}

+ 65 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/service/impl/BusMainServiceImpl.java

@@ -0,0 +1,65 @@
+package cn.com.liandisys.ycjt.ggcx.coachBus.service.impl;
+
+import javax.annotation.Resource;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Service;
+
+import cn.com.liandisys.ycjt.ggcx.coachBus.dao.BusMainDao;
+import cn.com.liandisys.ycjt.ggcx.coachBus.model.BusMain;
+import cn.com.liandisys.ycjt.ggcx.coachBus.service.BusMainService;
+import cn.com.liandisys.ycjt.ggcx.coachBus.vo.QueryParam;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtil;
+
+@Service
+public class BusMainServiceImpl implements BusMainService {
+
+    private Logger logger = LoggerFactory.getLogger(BusMainServiceImpl.class);
+
+    @Resource(name = "busMainDao")
+    private BusMainDao dao;
+
+    @Override
+    public Page<BusMain> findAll(Pageable pageable) {
+
+        return dao.findAll(pageable);
+    }
+
+    @Override
+    public Specification<BusMain> getSpecification(QueryParam queryParam) {
+
+        final String carLocation = queryParam.getCarLocation();
+        final String arrLocation = queryParam.getArrLocation();
+        //        final Date departTime = queryParam.getDepartTimeVal();
+
+        return new Specification<BusMain>() {
+
+            @Override
+            public Predicate toPredicate(Root<BusMain> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+
+                Predicate predicate = cb.conjunction();
+                if (!StringUtil.isEmpty(carLocation)) {
+                    predicate.getExpressions().add(cb.equal((root.get("carLocation").as(String.class)), carLocation));
+                }
+                if (arrLocation != null && !StringUtil.isEmpty(arrLocation)) {
+                    predicate.getExpressions()
+                            .add(cb.like((root.get("arrLocation").as(String.class)), "%" + arrLocation + "%"));
+
+                }
+                /*  if (!StringUtil.isEmpty(departTime)) {
+                    predicate.getExpressions().add(cb.greaterThanOrEqualTo((root.get("departTime").as(Date.class)), departTime));
+                }*/
+                return predicate;
+            }
+        };
+    }
+
+}

+ 42 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/coachBus/vo/QueryParam.java

@@ -0,0 +1,42 @@
+package cn.com.liandisys.ycjt.ggcx.coachBus.vo;
+
+import java.util.Date;
+
+public class QueryParam {
+
+    private Date departTimeVal;
+
+    private String carLocation;
+
+    private String arrLocation;
+
+    public Date getDepartTimeVal() {
+
+        return departTimeVal;
+    }
+
+    public void setDepartTimeVal(Date departTimeVal) {
+
+        this.departTimeVal = departTimeVal;
+    }
+
+    public String getCarLocation() {
+
+        return carLocation;
+    }
+
+    public void setCarLocation(String carLocation) {
+
+        this.carLocation = carLocation;
+    }
+
+    public String getArrLocation() {
+
+        return arrLocation;
+    }
+
+    public void setArrLocation(String arrLocation) {
+
+        this.arrLocation = arrLocation;
+    }
+}

+ 178 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/config/Global.java

@@ -0,0 +1,178 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.config;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import org.springframework.core.io.DefaultResourceLoader;
+
+import com.ckfinder.connector.ServletContextFactory;
+import com.google.common.collect.Maps;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.PropertiesLoader;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtils;
+
+/**
+ * 全局配置类
+ * @author ThinkGem
+ * @version 2014-06-25
+ */
+public class Global {
+
+	/**
+	 * 当前对象实例
+	 */
+	private static Global global = new Global();
+	
+	/**
+	 * 保存全局属性值
+	 */
+	private static Map<String, String> map = Maps.newHashMap();
+	
+	/**
+	 * 属性文件加载对象
+	 */
+	private static PropertiesLoader loader = new PropertiesLoader("application.properties");
+	
+	public static String WEB_CONTEXT_PATH; 
+
+	/**
+	 * 显示/隐藏
+	 */
+	public static final String SHOW = "1";
+	public static final String HIDE = "0";
+
+	/**
+	 * 是/否
+	 */
+	public static final String YES = "1";
+	public static final String NO = "0";
+	
+	/**
+	 * 对/错
+	 */
+	public static final String TRUE = "true";
+	public static final String FALSE = "false";
+	
+	/**
+	 * 上传文件基础虚拟路径
+	 */
+	public static final String USERFILES_BASE_URL = "/userfiles/";
+	
+	/**
+	 * 获取当前对象实例
+	 */
+	public static Global getInstance() {
+		return global;
+	}
+	
+	/**
+	 * 获取配置
+	 * @see ${fns:getConfig('adminPath')}
+	 */
+	public static String getConfig(String key) {
+		String value = map.get(key);
+		if (value == null){
+			value = loader.getProperty(key);
+			map.put(key, value != null ? value : StringUtils.EMPTY);
+		}
+		return value;
+	}
+	
+	/**
+	 * 获取管理端根路径
+	 */
+	public static String getAdminPath() {
+		return getConfig("adminPath");
+	}
+	
+	/**
+	 * 获取前端根路径
+	 */
+	public static String getFrontPath() {
+		return getConfig("frontPath");
+	}
+	
+	/**
+	 * 获取URL后缀
+	 */
+	public static String getUrlSuffix() {
+		return getConfig("urlSuffix");
+	}
+	
+	/**
+	 * 是否是演示模式,演示模式下不能修改用户、角色、密码、菜单、授权
+	 */
+	public static Boolean isDemoMode() {
+		String dm = getConfig("demoMode");
+		return "true".equals(dm) || "1".equals(dm);
+	}
+	
+	/**
+	 * 页面获取常量
+	 * @see ${fns:getConst('YES')}
+	 */
+	public static Object getConst(String field) {
+		try {
+			return Global.class.getField(field).get(null);
+		} catch (Exception e) {
+			// 异常代表无配置,这里什么也不做
+		}
+		return null;
+	}
+
+	/**
+	 * 获取上传文件的根目录
+	 * @return
+	 */
+	public static String getUserfilesBaseDir() {
+		String dir = getConfig("userfiles.basedir");
+		if (StringUtils.isBlank(dir)){
+			try {
+				dir = ServletContextFactory.getServletContext().getRealPath("/");
+			} catch (Exception e) {
+				return "";
+			}
+		}
+		if(!dir.endsWith("/")) {
+			dir += "/";
+		}
+		return dir;
+	}
+	
+    /**
+     * 获取工程路径
+     * @return
+     */
+    public static String getProjectPath(){
+    	// 如果配置了工程路径,则直接返回,否则自动获取。
+		String projectPath = Global.getConfig("projectPath");
+		if (StringUtils.isNotBlank(projectPath)){
+			return projectPath;
+		}
+		try {
+			File file = new DefaultResourceLoader().getResource("").getFile();
+			if (file != null){
+				while(true){
+					File f = new File(file.getPath() + File.separator + "src" + File.separator + "main");
+					if (f == null || f.exists()){
+						break;
+					}
+					if (file.getParentFile() != null){
+						file = file.getParentFile();
+					}else{
+						break;
+					}
+				}
+				projectPath = file.toString();
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return projectPath;
+    }
+	
+}

+ 425 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/constant/CommonConstant.java

@@ -0,0 +1,425 @@
+package cn.com.liandisys.ycjt.ggcx.common.constant;
+
+/*
+ * $Id: CommonConstant.java,v 1.1 2015/07/23 01:54:26 wangqx Exp $
+ */
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 系统常量定义
+ */
+public class CommonConstant 
+{
+	/**
+	 * 私有构造函数
+	 */
+	private CommonConstant(){}
+
+	public static final Map<Class<?>, Class<?>> BASE_TYPE_WRAPPER_TYPE_MAP = new HashMap<Class<?>, Class<?>>();
+	
+	static
+	{
+		BASE_TYPE_WRAPPER_TYPE_MAP.put(int.class, Integer.class);
+		BASE_TYPE_WRAPPER_TYPE_MAP.put(double.class, Double.class);
+		BASE_TYPE_WRAPPER_TYPE_MAP.put(float.class, Float.class);
+		BASE_TYPE_WRAPPER_TYPE_MAP.put(long.class, Long.class);
+		BASE_TYPE_WRAPPER_TYPE_MAP.put(short.class, Short.class);
+		BASE_TYPE_WRAPPER_TYPE_MAP.put(boolean.class, Boolean.class);
+		BASE_TYPE_WRAPPER_TYPE_MAP.put(byte.class, Byte.class);
+		BASE_TYPE_WRAPPER_TYPE_MAP.put(char.class, Character.class);
+	}
+	
+	/**
+	 * 系统基本的资源文件名称
+	 */
+	public static final String BASE_RESOURCES_FILE_NAME = "resources.properties";
+	
+	/**
+	 * 系统基本的资源文件路径(于SerlvetContext相对路径)
+	 */
+	public static final String BASE_RESOURCES_FILE_PATH_SERVLET_CONTEXT = "/WEB-INF/classes/resources.properties";
+	
+	/** 半角英文点号:"." */
+	public static final String DOT = ".";
+	
+	/**
+	 * 符号#
+	 */
+	public static final String POUND = "#";
+	
+	/**
+	 * 符号/
+	 */
+	public static final String SLASH = "/";
+	
+	/**
+	 * 文件分隔符
+	 */
+	public static final String FILE_SEPARATOR = System.getProperty("file.separator");
+	
+	/**
+	 * 反斜杠符号
+	 */
+	public static final String BACKSLASH = "\\";
+	
+	/**
+	 * 正则-反斜杠符号
+	 */
+	public static final String REGEXP_BACKSLASH = "\\\\";
+	
+	/** 正则转义符-半角英文点号:"\\." */
+	public static final String REGEXP_DOT = "\\.";
+	
+	/** 验证类型:必选字段 */
+	public static final String VALI_TYPE_NOTNULL = "notNull";
+	
+	/** 验证类型:数据类型 */
+	public static final String VALI_TYPE_DATA_TYPE = "dataType";
+	
+	/** 数据类型:email */
+	public static final String DATA_TYPE_EMAIL = "email";
+	
+	/** 数据类型:url */
+	public static final String DATA_TYPE_URL = "url";
+	
+	/** 数据类型:DECIMAL */
+	public static final String DATA_TYPE_DECIMAL = "decimal";
+	
+	/** 验证类型:最大长度 */
+	public static final String VALI_TYPE_MAXLENGTH = "maxlength";
+	
+	/** 验证类型:最小长度 */
+	public static final String VALI_TYPE_MINLENGTH = "minlength";
+	
+	/** 数据类型:ISO格式日期(yyyy-MM-dd) */
+	public static final String DATA_TYPE_DATE_ISO = "dateISO";
+	
+	/** 数据类型:ISO格式日期-时间(yyyy-MM-dd HH:mm:ss 或 yyyy-MM-dd HH:mm) */
+	public static final String DATA_TYPE_DATE_TIME_ISO = "datetimeISO";
+	
+	/** 数据类型:ISO格式时间(HH:mm:ss 或 HH:mm) */
+	public static final String DATA_TYPE_TIME_ISO = "timeISO";
+	
+	/** 日期Format: yyyy-MM-dd HH:mm:ss */
+	public static final String DATE_FORMAT_YYYYMMDD_HHMMSS = "yyyy-MM-dd hh:mm:ss";
+	
+	/**
+	 * 符号(等于号)
+	 */
+	public static final String SYMBOL_EQUALS = "=";
+	
+	/**
+	 * 符号(左括号)
+	 */
+	public static final String SYMBOL_LEFTBRACKET = "(";
+	
+	/**
+	 * 符号(右括号)
+	 */
+	public static final String SYMBOL_RIGHTBRACKET = ")";
+	
+	/**
+	 * 符号(下划线)
+	 */
+	public static final String SYMBOL_UNDERLINE = "_";
+	
+	/**
+	 * 美元符号
+	 */
+	public static final String SYMBOL_DOLLOR = "$";
+	
+	/**
+	 * 符号(分号)
+	 */
+	public static final String SYMBOL_SEMICOLON = ";";
+	
+	/**
+	 * 符号(双引号)
+	 */
+	public static final String SYMBOL_DOUBLEQUOTES = "\"";
+	
+	/**
+	 * 符号(双引号)
+	 */
+	public static final char SYMBOL_DOUBLEQUOTES_CHAR = '"';
+	
+	/**
+	 * 符号(逗号)
+	 */
+	public static final String SYMBOL_COMMA = ",";
+
+	/**
+	 * 等于号
+	 */
+	public static final String SYMBOL_EQUAL = "=";
+	
+	/**
+	 * 符号(分割符号)
+	 */
+	public static final String SYMBOL_SPLIT_LINE = "|&$|";
+	
+	/**
+	 * 符号(冒号)
+	 */
+	public static final String SYMBOL_COLON = ":";
+	
+	/**
+	 * 符号(单引号)
+	 */
+	public static final String SYMBOL_SINGLEQUOTES = "'";
+	
+	/**
+	 * 符号(问号)
+	 */
+	public static final String SYMBOL_QUESTION = "?";
+	
+	/**
+	 * 正则表达式:问号
+	 */
+	public static final String REGXP_QUESTION = "\\?";
+	
+	/**
+	 * 1:CSS
+	 */
+	public static final String PAGERESOURCE_FILETYPE_CSS = "1";
+	
+	/**
+	 * 2:JS
+	 */
+	public static final String PAGERESOURCE_FILETYPE_JS = "2";
+	
+	/**
+	 * 百分号的替换符号
+	 */
+	public static final String PERCENTAGE_SIGN_STRING = "<percentage>";
+	
+	/**
+	 * 百分号
+	 */
+	public static final String PERCENTAGE_SIGN = "%";
+	
+	/**
+	 * 日时format:yyyy
+	 */
+	public static final String DATEFORMAT_YYYY = "yyyy";
+	
+	/**
+	 * 日时format:MMdd
+	 */
+	public static final String DATEFORMAT_MMDD = "MMdd";
+	
+	/**
+	 * 日时format:HH_mm_ssSSS
+	 */
+	public static final String DATEFORMAT_HHMMSSSSS = "HH_mm_ssSSS";
+	
+	/**
+	 * 日时format:yyyyMMddHHmmss
+	 */
+	public static final String DATEFORMAT_YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
+	
+	/**
+	 * 内存中最大对象数
+	 */
+	public static final String DEF_GLOBAL_MAXELEMENTSINMEMORY = "maxElementsInMemory";
+	
+	/**
+	 * 设置元素是否永久的,如果为永久,则timeout忽略
+	 */
+	public static final String DEF_GLOBAL_ETERNAL = "eternal";
+	
+	/**
+	 * 当memory中的数量达到限制后,是否保存到Disk
+	 */
+	public static final String DEF_GLOBAL_OVERFLOWTODISK = "overflowToDisk";
+	
+	/**
+	 * 磁盘中最大对象数,0表示无限制
+	 */
+	public static final String DEF_GLOBAL_MAXELEMENTSONDISK = "maxElementsOnDisk";
+	
+	/**
+	 * 设置Element在失效前的允许闲置时间
+	 */
+	public static final String DEF_GLOBAL_TIMETOIDLESECONDS = "timeToIdleSeconds";
+
+	/**
+	 * 设置Element在失效前允许存活时间
+	 */
+	public static final String DEF_GLOBAL_TIMETOLIVESECONDS = "timeToLiveSeconds";
+	
+	/**
+	 * 磁盘失效线程运行时间间隔
+	 */
+	public static final String DEF_GLOBAL_DISKEXPIRYTHREADINTERVALSECONDS = "diskExpiryThreadIntervalSeconds";
+	
+	/**
+	 * 这个参数设置DiskStore的磁盘缓冲区大小
+	 */
+	public static final String DEF_GLOBAL_DISKSPOOLBUFFERSIZEMB = "diskSpoolBufferSizeMB";
+	
+	/**
+	 * Schema对象处理标志
+	 */
+	public static final String SCHEMA_PROCESSING_FLAG = "processingFlag";
+	
+	/**
+	 * 英文句号字符
+	 */
+	public static final Character DOT_CHARACTER = '.';
+	
+	/**
+	 * 数据库字段的正则表达式
+	 */
+	public static final String REGEX_DBFIELD_VARIABLE = "[a-zA-Z0-9_\\$]*\\.[a-zA-Z0-9_\\$]*\\.[a-zA-Z0-9_\\$\\:]*";
+	
+	/**
+	 * 正则表达式:分离{}内容
+	 */
+	public static final String REGEX_PARAM_VARIABLE = "\\{([^}]*)\\}";
+	
+	/**
+	 * Excel电子表格的2003版文件后缀名
+	 */
+	public static final String FILE_SUFFIX_EXCEL_2003 = "xls";
+	
+	/**
+	 * Excel电子表格的2007(2010)版文件后缀名
+	 */
+	public static final String FILE_SUFFIX_EXCEL_2007 = "xlsx";
+	
+	/**
+	 * pdf文件
+	 */
+	public static final String FILE_SUFFIX_PDF = "pdf";
+	
+	/**
+	 * 压缩包文件
+	 */
+	public static final String FILE_SUFFIX_ZIP = "zip";
+	
+	/**
+	 * 回车符
+	 */
+	public static final String LINE_FEED_CHARACTER_R = "\r";
+	
+	/**
+	 * 换行符
+	 */
+	public static final String LINE_FEED_CHARACTER_N = "\n";
+	
+	/**
+	 * 回车符换行符
+	 */
+	public static final String LINE_FEED_CHARACTER_RN = "\r\n";
+	
+	/**
+	 * 电子邮件模板变量表达式
+	 */
+	public static final String VARIABLE_EXP = "\\{\\w+\\}";
+	
+	/**
+	 * http协议请求头标识
+	 */
+	public static final String REQUEST_HEAD_HTTP = "http://";
+	
+	/**
+	 * 本地文件系统请求头标识
+	 */
+	public static final String REQUEST_HEAD_LOCAL_FS = "file://";
+
+	/**
+	 * 应用认证的应用属性键
+	 */
+	public static final String APP_PROPCODE_LOGINAUTH = "loginAuth";
+	
+	/**
+	 * JobDetailMap中表示JobConfig的键
+	 */
+	public static final String JOB_CONFIG_KEY = "JOB_CONFIG";
+	
+	/**
+	 * JobDetailMap中表示部署容器的键
+	 */
+	public static final String JOB_CONTAINER_NAME_KEY = "JOB_CONTAINER_NAME";
+
+	/**
+	 *  任务名称前缀
+	 */
+	public static final String JOB_NAME_PREFIX = "JOB";
+
+	/**
+	 *  任务组名称前缀
+	 */
+	public static final String JOB_GROUP_PREFIX = "JGROUP";
+
+	/**
+	 *  触发器名称前缀
+	 */
+	public static final String TRIGGER_NAME_PREFIX = "TRIGGER";
+
+	/**
+	 *  触发器组名称前缀
+	 */
+	public static final String TRIGGER_GROUP_PREFIX = "TGROUP";
+	
+	/**
+	 *  页面数据查询操作
+	 */
+	public static final String ACTION_VIEW = "view";
+
+	/**
+	 * 换行符号
+	 */
+	public static final String NEW_LINE = "\n";
+	
+	/**
+	 * 字符类型
+	 */
+	public static final String TYPE_VARCHAR = "varchar";
+	
+	/**
+	 * 数值类型
+	 */
+	public static final String TYPE_DECIMAL = "decimal";
+	
+	/**
+	 * 日期类型
+	 */
+	public static final String TYPE_DATE = "date";
+	
+	/**
+	 * 日时类型
+	 */
+	public static final String TYPE_DATETIME = "datetime";
+	
+	/**
+	 * 江苏省分公司组织机构代码
+	 */
+	public static final String ORG_CODE_JIANGSU = "32000000";
+	
+	/**
+	 * 是否可用
+	 */
+	public static final String Available="Y";
+	
+	public static final String Unavailable = "N";
+	
+	/**
+	 * cms后台管理员角色编码
+	 */
+	public static final String CMS_ADMIN_CODE = "cmsAdmin";
+	
+	/**
+   	 * 模板路径
+   	 */
+   	public static final String TPL_BASE = "/WEB-INF/views/cms/front";
+   	
+   	/**
+   	 * 栏目模式-文章
+   	 */
+   	public static final String CATEGORY_MODULE_ARTICLE = "article";
+}

+ 38 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/constant/MessageConstant.java

@@ -0,0 +1,38 @@
+/*
+ * $Id: MessageConstant.java,v 1.1 2016/07/23 01:54:26 wangqx Exp $ *
+ */
+package cn.com.liandisys.ycjt.ggcx.common.constant;
+
+/**
+ * @author wangqx
+ * 2016-7-29
+ */
+public class MessageConstant
+{
+	/** 操作成功 */
+	public static final String OPERATION_SUCCESS = "操作成功。";
+	
+	/** 服务器内部错误。 */
+	public static final String SERVER_INTERNAL_ERROR = "服务器内部错误。";
+	
+	/** 操作失败。 */
+	public static final String OPERATION_FAIL = "操作失败。";
+	
+	/** 操作失败。 */
+	public static final String NULL_OBJECT = "对象为空。";
+	
+	public class KEY
+	{
+		/** errorMsg */
+		public static final String ERROR_MSG = "errorMsg";
+		
+		/** sessionTimeout */
+		public static final String SESSION_TIMEOUT = "sessionTimeout";
+
+		/** flag */
+		public static final String FLAG = "flag";
+		
+		/** message */
+		public static final String MESSAGE = "message";
+	}
+}

+ 34 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/constant/PageUrl.java

@@ -0,0 +1,34 @@
+/*
+ * $Id: PageUrl.java,v 1.0 2016/08/02 07:32:20 wangqx Exp $ *
+ */
+package cn.com.liandisys.ycjt.ggcx.common.constant;
+
+/**
+ * @author wangqx 2016-8-02
+ */
+public class PageUrl {
+
+    /** 登录页面 */
+    public static final String LOGIN = "login";
+
+    public static final String FORWARD = "forward";
+
+    /** 会话超时页面 */
+    public static final String SESSION_TIMEOUT = "sessionTimeout";
+
+    /** 错误页面 */
+    public static final String GLOBAL_ERROR_PAGE = "error";
+
+    /** 主页面 */
+    public static final String MAIN_PAGE = "main";
+
+    /** 客运站 */
+    public static final String CTKY_VIEW = "table/ctkyc";
+    
+    /** 出租车信息 */
+    public static final String TAXIINFO_VIEW = "table/taxiinfo";
+    
+    /** 铁路信息*/
+    public static final String TRAIN_VIEW = "table/hbdt";
+
+}

+ 162 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/constant/SystemConstant.java

@@ -0,0 +1,162 @@
+/*
+ * $Id: SystemConstant.java,v 1.17 2016/07/26 07:32:20 wangqx Exp $ *
+ */
+package cn.com.liandisys.ycjt.ggcx.common.constant;
+
+/**
+ * @author wangqx 2016-7-26
+ */
+public class SystemConstant {
+
+    //交通态势图(三色)
+    //红色
+    public static final String RED = "#FF0109";
+
+    //橙色
+    public static final String ORANGE = "#FFA500";
+
+    //绿色
+    public static final String GREEN = "#00A549";
+
+    //底色
+    public static final String GREEN_BASE = "#79bd3c";
+
+    /** 登录页面 */
+    public static final String UNLOCK = "0";
+
+    public static final String LOCKED = "1";
+
+    /** 定位事件 */
+    public static final String POSITION_EVENT = "EP";
+
+    /**定位机电设备*/
+    public static final String POSITION_FAULT = "FP";
+
+    /**定位视频点*/
+    public static final String POSITION_CAM = "spd";
+
+    /**情报板定位*/
+    public static final String POSITION_BOARD = "BP";
+
+    /** 状态 */
+    public static final String STSTUS_FORBIDDEN = "0";
+
+    public static final String STSTUS_USE = "1";
+
+    /** 删除标识*/
+    public static final String DELETE_FLG_VALID = "0";
+
+    public static final String DELETE_FLG_INVALID = "1";
+
+    /** 字典表类型 */
+    //事件等级
+    public static final String EVENT_LEVEL = "1";
+
+    //事件类型
+    public static final String EVENT_TYPE = "2";
+
+    //路段
+    public static final String ROAD_INFO = "3";
+
+    //事件发生方向
+    public static final String EVENT_DIR = "16";
+
+    //事件信息来源
+    public static final String EVENT_SOURCE = "17";
+
+    //机电设备
+    //运行状态
+    public static final String STATE = "6";
+
+    //故障类型
+    public static final String FAULT_TYPE = "7";
+
+    //故障程度
+    public static final String DEV_FAULT_LEVEL = "10";
+
+    //视频设备
+    //清晰度
+    public static final String DEFIN = "4";
+
+    //视频设备类型
+    public static final String CAM_TYPE = "8";
+
+    //摄像机类型
+    public static final String CAMER_TYPE = "9";
+
+    //设备状态
+    public static final String CAM_STATE = "10";
+
+    //情报板信息
+    //情报板类型
+    public static final String BI_BOARD_TYPE = "11";
+
+    //所在路段
+    public static final String MSE_NAME = "3";
+
+    //设备方向
+    public static final String BI_DIRECTION = "12";
+
+    //流量年统计
+    //车型
+    public static final String VEHICLE_KIND = "14";
+
+    //车流方向
+    public static final String DIR_ID = "13";
+
+    //拥挤度 
+    public static final String CONGESTION = "15";
+
+    //当天数据标识
+    public static final String TODAY_FLAG = "0";
+
+    //一小时时段
+    public static final String ONE_FLAG = "1";
+
+    //五小时时段
+    public static final String FIVE_FLAG = "5";
+
+    //事件级别:紧急
+    public static final String EVENT_LEVEL_URGENT = "1";
+
+    //事件级别:普通
+    public static final String EVENT_LEVEL_NORMAL = "2";
+
+    //机电设备状态:正常
+    public static final String DEV_RUN = "1";
+
+    //机电设备状态:故障
+    public static final String DEV_FAULT = "2";
+
+    //机电设备类别:1 视频
+    public static final String DEV_VIDIO = "1";
+
+    //机电设备类别:2 情报板
+    public static final String DEV_BOARD = "2";
+
+    //机电设备类别:3 车辆检测器
+    public static final String DEV_TESTER = "3";
+
+    //监测对象:事件
+    public static final String MO_EVENT = "0";
+
+    //进港出港类型
+    public static final String OUT_TYPE = "19";
+
+    //出租车公司
+    public static final String TAXI_COMPANY = "21";
+
+    //乘车地点
+    public static final String CAR_LOCATION = "22";
+
+    /** 字典表类型 */
+
+    //出租车GPS是否空闲
+    public static final String SFKX = "24";
+
+    //机型
+    public static final String FLIGHT_MODEL = "20";
+
+    public static final String SHIJLX = "25";
+
+}

+ 44 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/controller/BaseController.java

@@ -0,0 +1,44 @@
+package cn.com.liandisys.ycjt.ggcx.common.controller;
+
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:ArrivalController    
+ * 类描述:    
+ * 创建人:wangqx
+ * 创建时间:2016年11月25日 下午4:33:19    
+ * 修改人:wangqx
+ * 修改时间:2016年11月25日 下午4:33:19    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Controller
+public class BaseController {
+
+    /**
+     * 分页信息获取
+     * 
+     */
+    @ModelAttribute("pageRequest")
+    public PageRequest getPageRequest(@RequestParam(value = "pageNo", required = false, defaultValue = "1") String page,
+            @RequestParam(value = "pageSize", required = false, defaultValue = "20") String size) {
+
+        Sort sort = new Sort(Direction.DESC, new String[] { "ID" });
+        if (org.springframework.util.StringUtils.hasText(page) && org.springframework.util.StringUtils.hasText(size)
+                && null != sort) {
+            // 页码从0开始
+            PageRequest pageable = new PageRequest(Integer.parseInt(page) - 1, Integer.parseInt(size), sort);
+            return pageable;
+        }
+        return null;
+    }
+}

+ 27 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/dao/DataDicDao.java

@@ -0,0 +1,27 @@
+package cn.com.liandisys.ycjt.ggcx.common.dao;
+
+import java.util.List;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import cn.com.liandisys.ycjt.ggcx.common.model.DataDic;
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:DataDicDao    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月25日 下午2:30:06    
+ * 修改人:yangd    
+ * 修改时间:2016年11月25日 下午2:30:06    
+ * 修改备注:    
+ * @version     
+ *
+ */
+public interface DataDicDao extends JpaRepository<DataDic, Long> {
+	List<DataDic> findByType(String type);
+	
+	DataDic findByTypeAndValue(String type,String value);
+}

+ 141 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/model/DataDic.java

@@ -0,0 +1,141 @@
+package cn.com.liandisys.ycjt.ggcx.common.model;
+
+import java.io.Serializable; 
+
+
+import javax.persistence.Column; 
+import javax.persistence.Entity; 
+import javax.persistence.GeneratedValue; 
+import javax.persistence.GenerationType; 
+import javax.persistence.Id; 
+import javax.persistence.Table; 
+
+
+@Entity 
+@Table(name = "ksl_datadic") 
+public class DataDic implements Serializable { 
+	private static final long serialVersionUID = -1L;
+    @Id 
+    @GeneratedValue(strategy = GenerationType.IDENTITY) 
+    @Column(name="datadic_id")
+    private String id; 
+    
+    @Column(name="datadic_parent")
+    private String parent; 
+    
+    @Column(name="datadic_type")
+    private String type;
+    
+    @Column(name="datadic_name")
+    private String name; 
+    
+    @Column(name="datadic_value")
+    private String value; 
+    
+    @Column(name="datadic_status")
+    private String status; 
+    
+    @Column(name="datadic_remark")
+    private String remark; 
+    
+    
+
+	public String getId() {
+		return id;
+	}
+
+
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+
+
+	public String getParent() {
+		return parent;
+	}
+
+
+
+	public void setParent(String parent) {
+		this.parent = parent;
+	}
+
+
+
+	public String getType() {
+		return type;
+	}
+
+
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+
+
+	public String getName() {
+		return name;
+	}
+
+
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+
+
+	public String getValue() {
+		return value;
+	}
+
+
+
+	public void setValue(String value) {
+		this.value = value;
+	}
+
+
+
+	public String getStatus() {
+		return status;
+	}
+
+
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+
+
+
+	public String getRemark() {
+		return remark;
+	}
+
+
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+
+
+	@Override 
+    public boolean equals(Object o) { 
+        if (this == o) 
+            return true; 
+        if (o == null || getClass() != o.getClass()) 
+            return false; 
+
+        DataDic dataDic = (DataDic) o; 
+
+        if (dataDic.id.equals(this.id)) 
+            return true; 
+        return false; 
+    } 
+} 
+

+ 260 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/Cryptos.java

@@ -0,0 +1,260 @@
+/**
+ * Copyright (c) 2005-2012 springside.org.cn
+ */
+package cn.com.liandisys.ycjt.ggcx.common.security;
+
+import java.io.UnsupportedEncodingException;
+import java.security.GeneralSecurityException;
+import java.security.SecureRandom;
+import java.util.Arrays;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.Encodes;
+import cn.com.liandisys.ycjt.ggcx.common.util.Exceptions;
+
+/**
+ * 支持HMAC-SHA1消息签名 及 DES/AES对称加密的工具类.
+ * 
+ * 支持Hex与Base64两种编码方式.
+ * 
+ * @author calvin
+ */
+public class Cryptos {
+
+	private static final String AES = "AES";
+	private static final String AES_CBC = "AES/CBC/PKCS5Padding";
+	private static final String HMACSHA1 = "HmacSHA1";
+
+	private static final String DEFAULT_URL_ENCODING = "UTF-8";
+	private static final int DEFAULT_HMACSHA1_KEYSIZE = 160; //RFC2401
+	private static final int DEFAULT_AES_KEYSIZE = 128;
+	private static final int DEFAULT_IVSIZE = 16;
+	
+	private static final byte[] DEFAULT_KEY = new byte[]{-97,88,-94,9,70,-76,126,25,0,3,-20,113,108,28,69,125}; 
+
+	private static SecureRandom random = new SecureRandom();
+
+	//-- HMAC-SHA1 funciton --//
+	/**
+	 * 使用HMAC-SHA1进行消息签名, 返回字节数组,长度为20字节.
+	 * 
+	 * @param input 原始输入字符数组
+	 * @param key HMAC-SHA1密钥
+	 */
+	public static byte[] hmacSha1(byte[] input, byte[] key) {
+		try {
+			SecretKey secretKey = new SecretKeySpec(key, HMACSHA1);
+			Mac mac = Mac.getInstance(HMACSHA1);
+			mac.init(secretKey);
+			return mac.doFinal(input);
+		} catch (GeneralSecurityException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	/**
+	 * 校验HMAC-SHA1签名是否正确.
+	 * 
+	 * @param expected 已存在的签名
+	 * @param input 原始输入字符串
+	 * @param key 密钥
+	 */
+	public static boolean isMacValid(byte[] expected, byte[] input, byte[] key) {
+		byte[] actual = hmacSha1(input, key);
+		return Arrays.equals(expected, actual);
+	}
+
+	/**
+	 * 生成HMAC-SHA1密钥,返回字节数组,长度为160位(20字节).
+	 * HMAC-SHA1算法对密钥无特殊要求, RFC2401建议最少长度为160位(20字节).
+	 */
+	public static byte[] generateHmacSha1Key() {
+		try {
+			KeyGenerator keyGenerator = KeyGenerator.getInstance(HMACSHA1);
+			keyGenerator.init(DEFAULT_HMACSHA1_KEYSIZE);
+			SecretKey secretKey = keyGenerator.generateKey();
+			return secretKey.getEncoded();
+		} catch (GeneralSecurityException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	//-- AES funciton --//
+
+	/**
+	 * 使用AES加密原始字符串.
+	 * 
+	 * @param input 原始输入字符数组
+	 */
+	public static String aesEncrypt(String input) {
+		try {
+			return Encodes.encodeHex(aesEncrypt(input.getBytes(DEFAULT_URL_ENCODING), DEFAULT_KEY));
+		} catch (UnsupportedEncodingException e) {
+			return "";
+		}
+	}
+	
+	/**
+	 * 使用AES加密原始字符串.
+	 * 
+	 * @param input 原始输入字符数组
+	 * @param key 符合AES要求的密钥
+	 */
+	public static String aesEncrypt(String input, String key) {
+		try {
+			return Encodes.encodeHex(aesEncrypt(input.getBytes(DEFAULT_URL_ENCODING), Encodes.decodeHex(key)));
+		} catch (UnsupportedEncodingException e) {
+			return "";
+		}
+	}
+	
+	/**
+	 * 使用AES加密原始字符串.
+	 * 
+	 * @param input 原始输入字符数组
+	 * @param key 符合AES要求的密钥
+	 */
+	public static byte[] aesEncrypt(byte[] input, byte[] key) {
+		return aes(input, key, Cipher.ENCRYPT_MODE);
+	}
+
+	/**
+	 * 使用AES加密原始字符串.
+	 * 
+	 * @param input 原始输入字符数组
+	 * @param key 符合AES要求的密钥
+	 * @param iv 初始向量
+	 */
+	public static byte[] aesEncrypt(byte[] input, byte[] key, byte[] iv) {
+		return aes(input, key, iv, Cipher.ENCRYPT_MODE);
+	}
+
+	/**
+	 * 使用AES解密字符串, 返回原始字符串.
+	 * 
+	 * @param input Hex编码的加密字符串
+	 */
+	public static String aesDecrypt(String input) {
+		try {
+			return new String(aesDecrypt(Encodes.decodeHex(input), DEFAULT_KEY), DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			return "";
+		}
+	}
+	
+	/**
+	 * 使用AES解密字符串, 返回原始字符串.
+	 * 
+	 * @param input Hex编码的加密字符串
+	 * @param key 符合AES要求的密钥
+	 */
+	public static String aesDecrypt(String input, String key) {
+		try {
+			return new String(aesDecrypt(Encodes.decodeHex(input), Encodes.decodeHex(key)), DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			return "";
+		}
+	}
+	
+	/**
+	 * 使用AES解密字符串, 返回原始字符串.
+	 * 
+	 * @param input Hex编码的加密字符串
+	 * @param key 符合AES要求的密钥
+	 */
+	public static byte[] aesDecrypt(byte[] input, byte[] key) {
+		return aes(input, key, Cipher.DECRYPT_MODE);
+	}
+
+	/**
+	 * 使用AES解密字符串, 返回原始字符串.
+	 * 
+	 * @param input Hex编码的加密字符串
+	 * @param key 符合AES要求的密钥
+	 * @param iv 初始向量
+	 */
+	public static byte[] aesDecrypt(byte[] input, byte[] key, byte[] iv) {
+		return aes(input, key, iv, Cipher.DECRYPT_MODE);
+	}
+
+	/**
+	 * 使用AES加密或解密无编码的原始字节数组, 返回无编码的字节数组结果.
+	 * 
+	 * @param input 原始字节数组
+	 * @param key 符合AES要求的密钥
+	 * @param mode Cipher.ENCRYPT_MODE 或 Cipher.DECRYPT_MODE
+	 */
+	private static byte[] aes(byte[] input, byte[] key, int mode) {
+		try {
+			SecretKey secretKey = new SecretKeySpec(key, AES);
+			Cipher cipher = Cipher.getInstance(AES);
+			cipher.init(mode, secretKey);
+			return cipher.doFinal(input);
+		} catch (GeneralSecurityException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	/**
+	 * 使用AES加密或解密无编码的原始字节数组, 返回无编码的字节数组结果.
+	 * 
+	 * @param input 原始字节数组
+	 * @param key 符合AES要求的密钥
+	 * @param iv 初始向量
+	 * @param mode Cipher.ENCRYPT_MODE 或 Cipher.DECRYPT_MODE
+	 */
+	private static byte[] aes(byte[] input, byte[] key, byte[] iv, int mode) {
+		try {
+			SecretKey secretKey = new SecretKeySpec(key, AES);
+			IvParameterSpec ivSpec = new IvParameterSpec(iv);
+			Cipher cipher = Cipher.getInstance(AES_CBC);
+			cipher.init(mode, secretKey, ivSpec);
+			return cipher.doFinal(input);
+		} catch (GeneralSecurityException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	/**
+	 * 生成AES密钥,返回字节数组, 默认长度为128位(16字节).
+	 */
+	public static String generateAesKeyString() {
+		return Encodes.encodeHex(generateAesKey(DEFAULT_AES_KEYSIZE));
+	}
+	
+	/**
+	 * 生成AES密钥,返回字节数组, 默认长度为128位(16字节).
+	 */
+	public static byte[] generateAesKey() {
+		return generateAesKey(DEFAULT_AES_KEYSIZE);
+	}
+
+	/**
+	 * 生成AES密钥,可选长度为128,192,256位.
+	 */
+	public static byte[] generateAesKey(int keysize) {
+		try {
+			KeyGenerator keyGenerator = KeyGenerator.getInstance(AES);
+			keyGenerator.init(keysize);
+			SecretKey secretKey = keyGenerator.generateKey();
+			return secretKey.getEncoded();
+		} catch (GeneralSecurityException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	/**
+	 * 生成随机向量,默认大小为cipher.getBlockSize(), 16字节.
+	 */
+	public static byte[] generateIV() {
+		byte[] bytes = new byte[DEFAULT_IVSIZE];
+		random.nextBytes(bytes);
+		return bytes;
+	}
+}

+ 123 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/Digests.java

@@ -0,0 +1,123 @@
+/**
+ * Copyright (c) 2005-2012 springside.org.cn
+ */
+package cn.com.liandisys.ycjt.ggcx.common.security;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.MessageDigest;
+import java.security.SecureRandom;
+
+import org.apache.commons.lang3.Validate;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.Exceptions;
+
+/**
+ * 支持SHA-1/MD5消息摘要的工具类.
+ * 
+ * 返回ByteSource,可进一步被编码为Hex, Base64或UrlSafeBase64
+ * 
+ * @author calvin
+ */
+public class Digests {
+
+	private static final String SHA1 = "SHA-1";
+	private static final String MD5 = "MD5";
+
+	private static SecureRandom random = new SecureRandom();
+
+	/**
+	 * 对输入字符串进行md5散列.
+	 */
+	public static byte[] md5(byte[] input) {
+		return digest(input, MD5, null, 1);
+	}
+	public static byte[] md5(byte[] input, int iterations) {
+		return digest(input, MD5, null, iterations);
+	}
+	
+	/**
+	 * 对输入字符串进行sha1散列.
+	 */
+	public static byte[] sha1(byte[] input) {
+		return digest(input, SHA1, null, 1);
+	}
+
+	public static byte[] sha1(byte[] input, byte[] salt) {
+		return digest(input, SHA1, salt, 1);
+	}
+
+	public static byte[] sha1(byte[] input, byte[] salt, int iterations) {
+		return digest(input, SHA1, salt, iterations);
+	}
+
+	/**
+	 * 对字符串进行散列, 支持md5与sha1算法.
+	 */
+	private static byte[] digest(byte[] input, String algorithm, byte[] salt, int iterations) {
+		try {
+			MessageDigest digest = MessageDigest.getInstance(algorithm);
+
+			if (salt != null) {
+				digest.update(salt);
+			}
+
+			byte[] result = digest.digest(input);
+
+			for (int i = 1; i < iterations; i++) {
+				digest.reset();
+				result = digest.digest(result);
+			}
+			return result;
+		} catch (GeneralSecurityException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	/**
+	 * 生成随机的Byte[]作为salt.
+	 * 
+	 * @param numBytes byte数组的大小
+	 */
+	public static byte[] generateSalt(int numBytes) {
+		Validate.isTrue(numBytes > 0, "numBytes argument must be a positive integer (1 or larger)", numBytes);
+
+		byte[] bytes = new byte[numBytes];
+		random.nextBytes(bytes);
+		return bytes;
+	}
+
+	/**
+	 * 对文件进行md5散列.
+	 */
+	public static byte[] md5(InputStream input) throws IOException {
+		return digest(input, MD5);
+	}
+
+	/**
+	 * 对文件进行sha1散列.
+	 */
+	public static byte[] sha1(InputStream input) throws IOException {
+		return digest(input, SHA1);
+	}
+
+	private static byte[] digest(InputStream input, String algorithm) throws IOException {
+		try {
+			MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
+			int bufferLength = 8 * 1024;
+			byte[] buffer = new byte[bufferLength];
+			int read = input.read(buffer, 0, bufferLength);
+
+			while (read > -1) {
+				messageDigest.update(buffer, 0, read);
+				read = input.read(buffer, 0, bufferLength);
+			}
+
+			return messageDigest.digest();
+		} catch (GeneralSecurityException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+	
+}

+ 123 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/ShiroDbRealm.java

@@ -0,0 +1,123 @@
+package cn.com.liandisys.ycjt.ggcx.common.security.shiro;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.apache.shiro.authc.AuthenticationInfo;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authc.SimpleAuthenticationInfo;
+import org.apache.shiro.authc.UsernamePasswordToken;
+import org.apache.shiro.authz.AuthorizationInfo;
+import org.apache.shiro.realm.AuthorizingRealm;
+import org.apache.shiro.subject.PrincipalCollection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.Role;
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+import cn.com.liandisys.ycjt.ggcx.admin.service.UserService;
+import cn.com.liandisys.ycjt.ggcx.common.constant.CommonConstant;
+import cn.com.liandisys.ycjt.ggcx.common.security.shiro.session.SessionDAO;
+import cn.com.liandisys.ycjt.ggcx.common.util.UserUtils;
+
+/**
+ * 系统安全认证实现类
+ * @author jiangchao
+ */
+public class ShiroDbRealm extends AuthorizingRealm {
+	
+	private Logger logger = LoggerFactory.getLogger(getClass());
+	
+	@Autowired
+	private SessionDAO sessionDAO;
+	@Autowired
+	private UserService userService;
+	
+	@Override
+	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) {
+		UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
+		
+		int activeSessionSize = sessionDAO.getActiveSessions(false).size();
+		if (logger.isDebugEnabled()){
+			logger.debug("login submit, active session size: {}, username: {}", activeSessionSize, token.getUsername());
+		}
+		// 校验用户名密码
+		User user = userService.findByLoginName(token.getUsername());
+		if (user != null) {
+			// 系统管理员有最高权限
+			if(user.isAdmin()){
+				return new SimpleAuthenticationInfo(user, user.getPassword(), getName());
+			}else{
+				// CMS后台管理员有进入系统的权限
+				boolean isCmsAdmin = false;
+				List<Role> roles = user.getRoles();
+				for(Role role : roles){
+					if(CommonConstant.CMS_ADMIN_CODE.equals(role.getCode())){
+						isCmsAdmin = true;
+						break;
+					}
+				}
+				if(isCmsAdmin){
+					return new SimpleAuthenticationInfo(user, user.getPassword(), getName());
+				}else{
+					return null;
+				}
+			}
+		} else {
+			return null;
+		}
+	}
+
+	@Override
+	protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
+		// TODO 网站CMS权限单一,暂不设置权限,后期后台功能扩展后可在用户管理系统中配置并在此处进行赋权查询
+		return null;
+	}
+	
+	/**
+	 * 授权用户信息
+	 */
+	public static class Principal implements Serializable {
+
+		private static final long serialVersionUID = 1L;
+		private String id; // 编号
+		private String loginName; // 登录名
+		private String name; // 姓名
+		public Principal(User user) {
+			this.id = user.getId();
+			this.loginName = user.getLoginName();
+			this.name = user.getName();
+		}
+
+		public String getId() {
+			return id;
+		}
+
+		public String getLoginName() {
+			return loginName;
+		}
+
+		public String getName() {
+			return name;
+		}
+
+		/**
+		 * 获取SESSIONID
+		 */
+		public String getSessionid() {
+			try{
+				return (String) UserUtils.getSession().getId();
+			}catch (Exception e) {
+				return "";
+			}
+		}
+		
+		@Override
+		public String toString() {
+			return id;
+		}
+
+	}
+
+}

+ 217 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/cache/JedisCacheManager.java

@@ -0,0 +1,217 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.security.shiro.cache;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.shiro.cache.Cache;
+import org.apache.shiro.cache.CacheException;
+import org.apache.shiro.cache.CacheManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Sets;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.JedisUtils;
+import cn.com.liandisys.ycjt.ggcx.common.web.Servlets;
+import redis.clients.jedis.Jedis;
+
+/**
+ * 自定义授权缓存管理类
+ * @author ThinkGem
+ * @version 2014-7-20
+ */
+public class JedisCacheManager implements CacheManager {
+
+	private String cacheKeyPrefix = "shiro_cache_";
+	
+	@Override
+	public <K, V> Cache<K, V> getCache(String name) throws CacheException {
+		return new JedisCache<K, V>(cacheKeyPrefix + name);
+	}
+
+	public String getCacheKeyPrefix() {
+		return cacheKeyPrefix;
+	}
+
+	public void setCacheKeyPrefix(String cacheKeyPrefix) {
+		this.cacheKeyPrefix = cacheKeyPrefix;
+	}
+	
+	/**
+	 * 自定义授权缓存管理类
+	 * @author ThinkGem
+	 * @version 2014-7-20
+	 */
+	public class JedisCache<K, V> implements Cache<K, V> {
+
+		private Logger logger = LoggerFactory.getLogger(getClass());
+
+		private String cacheKeyName = null;
+
+		public JedisCache(String cacheKeyName) {
+			this.cacheKeyName = cacheKeyName;
+//			if (!JedisUtils.exists(cacheKeyName)){
+//				Map<String, Object> map = Maps.newHashMap();
+//				JedisUtils.setObjectMap(cacheKeyName, map, 60 * 60 * 24);
+//			}
+//			logger.debug("Init: cacheKeyName {} ", cacheKeyName);
+		}
+		
+		@SuppressWarnings("unchecked")
+		@Override
+		public V get(K key) throws CacheException {
+			if (key == null){
+				return null;
+			}
+			
+			V v = null;
+			HttpServletRequest request = Servlets.getRequest();
+			if (request != null){
+				v = (V)request.getAttribute(cacheKeyName);
+				if (v != null){
+					return v;
+				}
+			}
+			
+			V value = null;
+			Jedis jedis = null;
+			try {
+				jedis = JedisUtils.getResource();
+				value = (V)JedisUtils.toObject(jedis.hget(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key)));
+				logger.debug("get {} {} {}", cacheKeyName, key, request != null ? request.getRequestURI() : "");
+			} catch (Exception e) {
+				logger.error("get {} {} {}", cacheKeyName, key, request != null ? request.getRequestURI() : "", e);
+			} finally {
+				JedisUtils.returnResource(jedis);
+			}
+			
+			if (request != null && value != null){
+				request.setAttribute(cacheKeyName, value);
+			}
+			
+			return value;
+		}
+
+		@Override
+		public V put(K key, V value) throws CacheException {
+			if (key == null){
+				return null;
+			}
+			
+			Jedis jedis = null;
+			try {
+				jedis = JedisUtils.getResource();
+				jedis.hset(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key), JedisUtils.toBytes(value));
+				logger.debug("put {} {} = {}", cacheKeyName, key, value);
+			} catch (Exception e) {
+				logger.error("put {} {}", cacheKeyName, key, e);
+			} finally {
+				JedisUtils.returnResource(jedis);
+			}
+			return value;
+		}
+
+		@SuppressWarnings("unchecked")
+		@Override
+		public V remove(K key) throws CacheException {
+			V value = null;
+			Jedis jedis = null;
+			try {
+				jedis = JedisUtils.getResource();
+				value = (V)JedisUtils.toObject(jedis.hget(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key)));
+				jedis.hdel(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key));
+				logger.debug("remove {} {}", cacheKeyName, key);
+			} catch (Exception e) {
+				logger.warn("remove {} {}", cacheKeyName, key, e);
+			} finally {
+				JedisUtils.returnResource(jedis);
+			}
+			return value;
+		}
+
+		@Override
+		public void clear() throws CacheException {
+			Jedis jedis = null;
+			try {
+				jedis = JedisUtils.getResource();
+				jedis.hdel(JedisUtils.getBytesKey(cacheKeyName));
+				logger.debug("clear {}", cacheKeyName);
+			} catch (Exception e) {
+				logger.error("clear {}", cacheKeyName, e);
+			} finally {
+				JedisUtils.returnResource(jedis);
+			}
+		}
+
+		@Override
+		public int size() {
+			int size = 0;
+			Jedis jedis = null;
+			try {
+				jedis = JedisUtils.getResource();
+				size = jedis.hlen(JedisUtils.getBytesKey(cacheKeyName)).intValue();
+				logger.debug("size {} {} ", cacheKeyName, size);
+				return size;
+			} catch (Exception e) {
+				logger.error("clear {}",  cacheKeyName, e);
+			} finally {
+				JedisUtils.returnResource(jedis);
+			}
+			return size;
+		}
+
+		@SuppressWarnings("unchecked")
+		@Override
+		public Set<K> keys() {
+			Set<K> keys = Sets.newHashSet();
+			Jedis jedis = null;
+			try {
+				jedis = JedisUtils.getResource();
+				Set<byte[]> set = jedis.hkeys(JedisUtils.getBytesKey(cacheKeyName));
+				for(byte[] key : set){
+					Object obj = (K)JedisUtils.getObjectKey(key);
+					if (obj != null){
+						keys.add((K) obj);
+					}
+	        	}
+				logger.debug("keys {} {} ", cacheKeyName, keys);
+				return keys;
+			} catch (Exception e) {
+				logger.error("keys {}", cacheKeyName, e);
+			} finally {
+				JedisUtils.returnResource(jedis);
+			}
+			return keys;
+		}
+
+		@SuppressWarnings("unchecked")
+		@Override
+		public Collection<V> values() {
+			Collection<V> vals = Collections.emptyList();;
+			Jedis jedis = null;
+			try {
+				jedis = JedisUtils.getResource();
+				Collection<byte[]> col = jedis.hvals(JedisUtils.getBytesKey(cacheKeyName));
+				for(byte[] val : col){
+					Object obj = JedisUtils.toObject(val);
+					if (obj != null){
+						vals.add((V) obj);
+					}
+	        	}
+				logger.debug("values {} {} ", cacheKeyName, vals);
+				return vals;
+			} catch (Exception e) {
+				logger.error("values {}",  cacheKeyName, e);
+			} finally {
+				JedisUtils.returnResource(jedis);
+			}
+			return vals;
+		}
+	}
+}

+ 274 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/session/JedisSessionDAO.java

@@ -0,0 +1,274 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.security.shiro.session;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.shiro.session.Session;
+import org.apache.shiro.session.UnknownSessionException;
+import org.apache.shiro.session.mgt.SimpleSession;
+import org.apache.shiro.session.mgt.eis.AbstractSessionDAO;
+import org.apache.shiro.subject.PrincipalCollection;
+import org.apache.shiro.subject.support.DefaultSubjectContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Sets;
+
+import cn.com.liandisys.ycjt.ggcx.common.config.Global;
+import cn.com.liandisys.ycjt.ggcx.common.util.DateUtil;
+import cn.com.liandisys.ycjt.ggcx.common.util.JedisUtils;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtils;
+import cn.com.liandisys.ycjt.ggcx.common.web.Servlets;
+import redis.clients.jedis.Jedis;
+
+/**
+ * 自定义授权会话管理类
+ * @author ThinkGem
+ * @version 2014-7-20
+ */
+public class JedisSessionDAO extends AbstractSessionDAO implements SessionDAO {
+
+	private Logger logger = LoggerFactory.getLogger(getClass());
+	
+	private String sessionKeyPrefix = "shiro_session_";
+
+	@Override
+	public void update(Session session) throws UnknownSessionException {
+		if (session == null || session.getId() == null) {  
+            return;
+        }
+		
+		HttpServletRequest request = Servlets.getRequest();
+		if (request != null){
+			String uri = request.getServletPath();
+			// 如果是静态文件,则不更新SESSION
+			if (Servlets.isStaticFile(uri)){
+				return;
+			}
+			// 如果是视图文件,则不更新SESSION
+			if (StringUtils.startsWith(uri, Global.getConfig("web.view.prefix"))
+					&& StringUtils.endsWith(uri, Global.getConfig("web.view.suffix"))){
+				return;
+			}
+			// 手动控制不更新SESSION
+			if (Global.NO.equals(request.getParameter("updateSession"))){
+				return;
+			}
+		}
+		
+		Jedis jedis = null;
+		try {
+			
+			jedis = JedisUtils.getResource();
+			
+			// 获取登录者编号
+			PrincipalCollection pc = (PrincipalCollection)session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
+			String principalId = pc != null ? pc.getPrimaryPrincipal().toString() : StringUtils.EMPTY;
+			
+			jedis.hset(sessionKeyPrefix, session.getId().toString(), principalId + "|" + session.getTimeout() + "|" + session.getLastAccessTime().getTime());
+			jedis.set(JedisUtils.getBytesKey(sessionKeyPrefix + session.getId()), JedisUtils.toBytes(session));
+			
+			// 设置超期时间
+			int timeoutSeconds = (int)(session.getTimeout() / 1000);
+			jedis.expire((sessionKeyPrefix + session.getId()), timeoutSeconds);
+
+			logger.debug("update {} {}", session.getId(), request != null ? request.getRequestURI() : "");
+		} catch (Exception e) {
+			logger.error("update {} {}", session.getId(), request != null ? request.getRequestURI() : "", e);
+		} finally {
+			JedisUtils.returnResource(jedis);
+		}
+	}
+
+	@Override
+	public void delete(Session session) {
+		if (session == null || session.getId() == null) {
+			return;
+		}
+		
+		Jedis jedis = null;
+		try {
+			jedis = JedisUtils.getResource();
+			
+			jedis.hdel(JedisUtils.getBytesKey(sessionKeyPrefix), JedisUtils.getBytesKey(session.getId().toString()));
+			jedis.del(JedisUtils.getBytesKey(sessionKeyPrefix + session.getId()));
+
+			logger.debug("delete {} ", session.getId());
+		} catch (Exception e) {
+			logger.error("delete {} ", session.getId(), e);
+		} finally {
+			JedisUtils.returnResource(jedis);
+		}
+	}
+	
+	@Override
+	public Collection<Session> getActiveSessions() {
+		return getActiveSessions(true);
+	}
+	
+	/**
+	 * 获取活动会话
+	 * @param includeLeave 是否包括离线(最后访问时间大于3分钟为离线会话)
+	 * @return
+	 */
+	@Override
+	public Collection<Session> getActiveSessions(boolean includeLeave) {
+		return getActiveSessions(includeLeave, null, null);
+	}
+	
+	/**
+	 * 获取活动会话
+	 * @param includeLeave 是否包括离线(最后访问时间大于3分钟为离线会话)
+	 * @param principal 根据登录者对象获取活动会话
+	 * @param filterSession 不为空,则过滤掉(不包含)这个会话。
+	 * @return
+	 */
+	@Override
+	public Collection<Session> getActiveSessions(boolean includeLeave, Object principal, Session filterSession){
+		Set<Session> sessions = Sets.newHashSet();
+		
+		Jedis jedis = null;
+		try {
+			jedis = JedisUtils.getResource();
+			Map<String, String> map = jedis.hgetAll(sessionKeyPrefix);
+			for (Map.Entry<String, String> e : map.entrySet()){
+				if (StringUtils.isNotBlank(e.getKey()) && StringUtils.isNotBlank(e.getValue())){
+					
+					String[] ss = StringUtils.split(e.getValue(), "|");
+					if (ss != null && ss.length == 3){// jedis.exists(sessionKeyPrefix + e.getKey())){
+						// Session session = (Session)JedisUtils.toObject(jedis.get(JedisUtils.getBytesKey(sessionKeyPrefix + e.getKey())));
+						SimpleSession session = new SimpleSession();
+						session.setId(e.getKey());
+						session.setAttribute("principalId", ss[0]);
+						session.setTimeout(Long.valueOf(ss[1]));
+						session.setLastAccessTime(new Date(Long.valueOf(ss[2])));
+						try{
+							// 验证SESSION
+							session.validate();
+							
+							boolean isActiveSession = false;
+							// 不包括离线并符合最后访问时间小于等于3分钟条件。
+							if (includeLeave || DateUtil.pastMinutes(session.getLastAccessTime()) <= 3){
+								isActiveSession = true;
+							}
+							// 符合登陆者条件。
+							if (principal != null){
+								PrincipalCollection pc = (PrincipalCollection)session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
+								if (principal.toString().equals(pc != null ? pc.getPrimaryPrincipal().toString() : StringUtils.EMPTY)){
+									isActiveSession = true;
+								}
+							}
+							// 过滤掉的SESSION
+							if (filterSession != null && filterSession.getId().equals(session.getId())){
+								isActiveSession = false;
+							}
+							if (isActiveSession){
+								sessions.add(session);
+							}
+							
+						}
+						// SESSION验证失败
+						catch (Exception e2) {
+							jedis.hdel(sessionKeyPrefix, e.getKey());
+						}
+					}
+					// 存储的SESSION不符合规则
+					else{
+						jedis.hdel(sessionKeyPrefix, e.getKey());
+					}
+				}
+				// 存储的SESSION无Value
+				else if (StringUtils.isNotBlank(e.getKey())){
+					jedis.hdel(sessionKeyPrefix, e.getKey());
+				}
+			}
+			logger.info("getActiveSessions size: {} ", sessions.size());
+		} catch (Exception e) {
+			logger.error("getActiveSessions", e);
+		} finally {
+			JedisUtils.returnResource(jedis);
+		}
+		return sessions;
+	}
+
+	@Override
+	protected Serializable doCreate(Session session) {
+		HttpServletRequest request = Servlets.getRequest();
+		if (request != null){
+			String uri = request.getServletPath();
+			// 如果是静态文件,则不创建SESSION
+			if (Servlets.isStaticFile(uri)){
+		        return null;
+			}
+		}
+		Serializable sessionId = this.generateSessionId(session);
+		this.assignSessionId(session, sessionId);
+		this.update(session);
+		return sessionId;
+	}
+
+	@Override
+	protected Session doReadSession(Serializable sessionId) {
+
+		Session s = null;
+		HttpServletRequest request = Servlets.getRequest();
+		if (request != null){
+			String uri = request.getServletPath();
+			// 如果是静态文件,则不获取SESSION
+			if (Servlets.isStaticFile(uri)){
+				return null;
+			}
+			s = (Session)request.getAttribute("session_"+sessionId);
+		}
+		if (s != null){
+			return s;
+		}
+
+		Session session = null;
+		Jedis jedis = null;
+		try {
+			jedis = JedisUtils.getResource();
+//			if (jedis.exists(sessionKeyPrefix + sessionId)){
+				session = (Session)JedisUtils.toObject(jedis.get(
+						JedisUtils.getBytesKey(sessionKeyPrefix + sessionId)));
+//			}
+			logger.debug("doReadSession {} {}", sessionId, request != null ? request.getRequestURI() : "");
+		} catch (Exception e) {
+			logger.error("doReadSession {} {}", sessionId, request != null ? request.getRequestURI() : "", e);
+		} finally {
+			JedisUtils.returnResource(jedis);
+		}
+		
+		if (request != null && session != null){
+			request.setAttribute("session_"+sessionId, session);
+		}
+		
+		return session;
+	}
+	
+	@Override
+    public Session readSession(Serializable sessionId) throws UnknownSessionException {
+    	try{
+        	return super.readSession(sessionId);
+    	}catch (UnknownSessionException e) {
+			return null;
+		}
+    }
+
+	public String getSessionKeyPrefix() {
+		return sessionKeyPrefix;
+	}
+
+	public void setSessionKeyPrefix(String sessionKeyPrefix) {
+		this.sessionKeyPrefix = sessionKeyPrefix;
+	}
+
+}

+ 25 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/session/SessionDAO.java

@@ -0,0 +1,25 @@
+package cn.com.liandisys.ycjt.ggcx.common.security.shiro.session;
+
+import java.util.Collection;
+
+import org.apache.shiro.session.Session;
+
+public interface SessionDAO extends org.apache.shiro.session.mgt.eis.SessionDAO {
+
+	/**
+	 * 获取活动会话
+	 * @param includeLeave 是否包括离线(最后访问时间大于3分钟为离线会话)
+	 * @return
+	 */
+	public Collection<Session> getActiveSessions(boolean includeLeave);
+	
+	/**
+	 * 获取活动会话
+	 * @param includeLeave 是否包括离线(最后访问时间大于3分钟为离线会话)
+	 * @param principal 根据登录者对象获取活动会话
+	 * @param filterSession 不为空,则过滤掉(不包含)这个会话。
+	 * @return
+	 */
+	public Collection<Session> getActiveSessions(boolean includeLeave, Object principal, Session filterSession);
+	
+}

+ 207 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/security/shiro/session/SessionManager.java

@@ -0,0 +1,207 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.security.shiro.session;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.shiro.session.InvalidSessionException;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.session.UnknownSessionException;
+import org.apache.shiro.session.mgt.SessionContext;
+import org.apache.shiro.session.mgt.SessionKey;
+import org.apache.shiro.session.mgt.SimpleSession;
+import org.apache.shiro.web.servlet.Cookie;
+import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
+import org.apache.shiro.web.servlet.SimpleCookie;
+import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
+import org.apache.shiro.web.util.WebUtils;
+
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtils;
+
+/**
+ * 自定义WEB会话管理类
+ * @author ThinkGem
+ * @version 2014-7-20
+ */
+public class SessionManager extends DefaultWebSessionManager {
+
+	public SessionManager() {
+		super();
+	}
+	
+	@Override
+	protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
+		// 如果参数中包含“__sid”参数,则使用此sid会话。 例如:http://localhost/project?__sid=xxx&__cookie=true
+		String sid = request.getParameter("__sid");
+		if (StringUtils.isNotBlank(sid)) {
+			// 是否将sid保存到cookie,浏览器模式下使用此参数。
+			if (WebUtils.isTrue(request, "__cookie")){
+		        HttpServletRequest rq = (HttpServletRequest)request;
+		        HttpServletResponse rs = (HttpServletResponse)response;
+				Cookie template = getSessionIdCookie();
+		        Cookie cookie = new SimpleCookie(template);
+				cookie.setValue(sid); cookie.saveTo(rq, rs);
+			}
+			// 设置当前session状态
+            request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE,
+                    ShiroHttpServletRequest.URL_SESSION_ID_SOURCE); // session来源与url
+            request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID, sid);
+            request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_IS_VALID, Boolean.TRUE);
+        	return sid;
+		}else{
+			return super.getSessionId(request, response);
+		}
+	}
+	
+	@Override
+	public void validateSessions() {
+		super.validateSessions();
+	}
+	
+	protected Session retrieveSession(SessionKey sessionKey) {
+		try{
+			return super.retrieveSession(sessionKey);
+		}catch (UnknownSessionException e) {
+    		// 获取不到SESSION不抛出异常
+			return null;
+		}
+	}
+
+    public Date getStartTimestamp(SessionKey key) {
+    	try{
+    		return super.getStartTimestamp(key);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+        	return null;
+		}
+    }
+
+    public Date getLastAccessTime(SessionKey key) {
+    	try{
+    		return super.getLastAccessTime(key);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+        	return null;
+		}
+    }
+
+    public long getTimeout(SessionKey key){
+    	try{
+    		return super.getTimeout(key);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+        	return 0;
+		}
+    }
+
+    public void setTimeout(SessionKey key, long maxIdleTimeInMillis) {
+    	try{
+    		super.setTimeout(key, maxIdleTimeInMillis);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+		}
+    }
+
+    public void touch(SessionKey key) {
+    	try{
+	    	super.touch(key);
+		}catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+		}
+    }
+
+    public String getHost(SessionKey key) {
+    	try{
+    		return super.getHost(key);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+        	return null;
+		}
+    }
+
+    public Collection<Object> getAttributeKeys(SessionKey key) {
+    	try{
+    		return super.getAttributeKeys(key);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+        	return null;
+		}
+    }
+
+    public Object getAttribute(SessionKey sessionKey, Object attributeKey) {
+    	try{
+    		return super.getAttribute(sessionKey, attributeKey);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+        	return null;
+		}
+    }
+
+    public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) {
+    	try{
+    		super.setAttribute(sessionKey, attributeKey, value);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+		}
+    }
+
+    public Object removeAttribute(SessionKey sessionKey, Object attributeKey) {
+    	try{
+    		return super.removeAttribute(sessionKey, attributeKey);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+        	return null;
+		}
+    }
+
+    public void stop(SessionKey key) {
+    	try{
+    		super.stop(key);
+    	}catch (InvalidSessionException e) {
+    		// 获取不到SESSION不抛出异常
+		}
+    }
+    
+    public void checkValid(SessionKey key) {
+    	try{
+    		super.checkValid(key);
+		}catch (InvalidSessionException e) {
+			// 获取不到SESSION不抛出异常
+		}
+    }
+    
+    @Override
+    protected Session doCreateSession(SessionContext context) {
+    	try{
+    		return super.doCreateSession(context);
+		}catch (IllegalStateException e) {
+			return null;
+		}
+    }
+
+	@Override
+	protected Session newSessionInstance(SessionContext context) {
+		Session session = super.newSessionInstance(context);
+		session.setTimeout(getGlobalSessionTimeout());
+		return session;
+	}
+    
+    @Override
+    public Session start(SessionContext context) {
+    	try{
+    		return super.start(context);
+		}catch (NullPointerException e) {
+			SimpleSession session = new SimpleSession();
+			session.setId(0);
+			return session;
+		}
+    }
+}

+ 58 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/service/DataDicService.java

@@ -0,0 +1,58 @@
+package cn.com.liandisys.ycjt.ggcx.common.service;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import cn.com.liandisys.ycjt.ggcx.common.dao.DataDicDao;
+import cn.com.liandisys.ycjt.ggcx.common.model.DataDic;
+
+
+/**
+ * 
+ *     
+ * 项目名称:ycjt-ggcx    
+ * 类名称:DataDicService    
+ * 类描述:    
+ * 创建人:yangd    
+ * 创建时间:2016年11月25日 下午2:29:53    
+ * 修改人:yangd    
+ * 修改时间:2016年11月25日 下午2:29:53    
+ * 修改备注:    
+ * @version     
+ *
+ */
+@Service
+public class DataDicService
+{
+	
+	@Autowired
+	private DataDicDao dataDicDao;
+	
+	/**
+	 * 根据传入的type,获取该类型字典数据list
+	 * @param type
+	 * @return
+	 * @throws Exception
+	 */
+	public List<DataDic> getDataDicInfo(String type) throws Exception
+	{
+		return dataDicDao.findByType(type);
+	}
+	
+	/**
+	 * 根据传入的type和value,获取该属性的名称
+	 * @param type value
+	 * @return
+	 * @throws Exception
+	 */
+	public String getDataDicName(String type,String value) throws Exception
+	{
+		DataDic datadic =  dataDicDao.findByTypeAndValue(type, value);
+		if(datadic != null){
+			return datadic.getName();
+		}
+		return "";
+	}
+}

+ 31 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/AvailableBooleanDeSerialize.java

@@ -0,0 +1,31 @@
+/**
+ * 文件名:AvailableBooleanEditor.java<br/>
+ * 创建时间:2013-6-4 上午10:01:13<br/>
+ * 创建者:jiangt<br/>
+ * 修改者:暂无<br/>
+ * 修改简述:暂无<br/>
+ * 修改详述:
+ * <p>
+ * 暂无<br/>
+ * </p>
+ * 修改时间:暂无<br/>
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.IOException;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+
+import cn.com.liandisys.ycjt.ggcx.common.constant.CommonConstant;
+
+public class AvailableBooleanDeSerialize extends JsonDeserializer<Boolean> {
+
+  @Override
+  public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
+    return CommonConstant.Available.equalsIgnoreCase(jp.getText());
+  }
+
+}

+ 52 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/AvailableBooleanSerialize.java

@@ -0,0 +1,52 @@
+/**
+ * 文件名:AvailableBooleanEditor.java<br/>
+ * 创建时间:2013-6-4 上午10:01:13<br/>
+ * 创建者:jiangt<br/>
+ * 修改者:暂无<br/>
+ * 修改简述:暂无<br/>
+ * 修改详述:
+ * <p>
+ * 暂无<br/>
+ * </p>
+ * 修改时间:暂无<br/>
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.IOException;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+import cn.com.liandisys.ycjt.ggcx.common.constant.CommonConstant;
+
+/**
+ * 在Entity中对boolean值注解序列化class,将boolean转换为我们指定的字符,例如“Y”,<br/>
+ * <p>
+ * </p>
+ * Time:2013-6-4 上午10:01:13<br/>
+ * 
+ * @author jiangt
+ * @version 1.0.0
+ * @since 1.0.0
+ */
+public class AvailableBooleanSerialize extends JsonSerializer<Boolean> {
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.fasterxml.jackson.databind.JsonSerializer#serialize(java.lang.Object, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.SerializerProvider)
+     */
+    @Override
+    public void serialize(Boolean value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
+        if (value) {
+            jgen.writeString(CommonConstant.Available);
+        }
+        else {
+            jgen.writeString(CommonConstant.Unavailable);
+        }
+
+    }
+
+}

+ 308 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/CollectionUtil.java

@@ -0,0 +1,308 @@
+/*
+ * $Id: CollectionUtil.java,v 1.1 2016/07/23 01:54:21 wangqx Exp $
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+
+import cn.com.liandisys.ycjt.ggcx.common.constant.CommonConstant;
+
+/**
+ * 集合常用操作辅助类
+ */
+@SuppressWarnings("unchecked")
+public class CollectionUtil extends CollectionUtils {
+
+    /**
+     * 判断数组中是否存在该对象,比较时用object.equals()进行的
+     * @param objects 对象数组
+     * @param target 目标对象
+     * @return 是否存在
+     */
+    public static boolean contanis(Object[] objects, Object target) {
+
+        if (objects == null || target == null) {
+            return false;
+        }
+        for (Object element : objects) {
+            if (target.equals(element)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 判断集合中是否存在该对象,比较时用object.equals()进行的
+     * @param list 对象集合
+     * @param target 目标对象
+     * @return 是否存在
+     */
+    public static boolean contanis(List<?> list, Object target) {
+
+        if (list == null || target == null) {
+            return false;
+        }
+        for (Object element : list) {
+            if (target.equals(element)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 判断两个集合中的内容是否相等,顺序要严格相同
+     * @param listA
+     * @param listB
+     */
+    public static boolean hasSameElement(List<?> listA, List<?> listB) {
+
+        if (listA == listB)
+            return true;
+        if (listA.size() != listB.size())
+            return false;
+        for (int i = 0; i < listA.size(); i++) {
+            if (listA.get(i) == listB.get(i))
+                continue;
+            // 如果两者都不为空
+            if (listA.get(i) != null && listB.get(i) != null) {
+                if (!listA.get(i).equals(listB.get(i))) {
+                    return false;
+                }
+            } else {// 其中一个为空,一个不为空
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 集合拷贝
+     * @param sourceList 源
+     * @return 目标
+     */
+    public static <T> List<T> copy(List<T> sourceList) {
+
+        List<T> distList = new ArrayList<T>();
+        for (int i = 0; i < sourceList.size(); i++) {
+            distList.add(sourceList.get(i));
+        }
+        return distList;
+    }
+
+    /**
+     * 判断两个集合时候有交集
+     * @param fristList 被比较的第一个集合
+     * @param secondList 被比较的第二个集合
+     * @return 
+     */
+    public static boolean hasLeastOneElement(List<String> fristList, List<String> secondList) {
+
+        //如果任意一个集合的为空或者元素个数为0则返回false
+        if (fristList == null || fristList.size() == 0 || secondList == null || secondList.size() == 0) {
+            return false;
+        }
+        //循环比较
+        for (String element : fristList) {
+            if (secondList.contains(element)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /** 提取集合中bean的属性,转化为Set */
+    public static <T> Set<T> fetchBeanProp2Set(Collection<?> beans, String propName, Class<T> propCls)
+            throws Exception {
+
+        Set<T> tSet = new LinkedHashSet<T>();
+        if (CollectionUtil.isEmpty(beans) || StringUtils.isEmpty(propName))
+            return tSet;
+
+        String mthName = "get" + Character.toUpperCase(propName.charAt(0)) + propName.substring(1);
+        /* 转换为包装类 */
+        if (propCls.isPrimitive())
+            propCls = (Class<T>) CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(propCls);
+        Method getMth = beans.iterator().next().getClass().getMethod(mthName);
+
+        for (Object bean : beans) {
+            if (null != bean) {
+                Object val = getMth.invoke(bean);
+                if (val == null)
+                    continue;
+                Class<?> valCls = val.getClass();
+                if (valCls.isPrimitive())
+                    valCls = CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(valCls); //转换为包装类
+
+                if (!valCls.equals(propCls))
+                    continue;
+                if (!tSet.contains(val))
+                    tSet.add((T) val);
+            }
+        }
+
+        return tSet;
+    }
+
+    public static <T> Set<T> arrayToSet(T[] tArray) {
+
+        return new LinkedHashSet<T>(Arrays.asList(tArray));
+    }
+
+    /** 提取集合中bean的属性,转化为List */
+    public static <T> List<T> fetchBeanProp2List(Collection<?> beans, String propName, Class<T> propCls)
+            throws Exception {
+
+        List<T> tList = new ArrayList<T>();
+        if (CollectionUtil.isEmpty(beans) || StringUtils.isEmpty(propName))
+            return tList;
+
+        String mthName = "get" + Character.toUpperCase(propName.charAt(0)) + propName.substring(1);
+        /* 转换为包装类 */
+        if (propCls.isPrimitive())
+            propCls = (Class<T>) CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(propCls);
+        Method getMth = beans.iterator().next().getClass().getMethod(mthName);
+
+        for (Object bean : beans) {
+            if (null != bean) {
+                Object val = getMth.invoke(bean);
+                if (val == null)
+                    continue;
+                Class<?> valCls = val.getClass();
+                if (valCls.isPrimitive())
+                    valCls = CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(valCls); //转换为包装类
+
+                if (!valCls.equals(propCls))
+                    continue;
+
+                if (!tList.contains(val))
+                    tList.add((T) val);
+            }
+        }
+
+        return tList;
+    }
+
+    /** 转换beanList到Map,使用指定bean的prop作为key。 */
+    public static <K, V> Map<K, V> toMap(List<V> beanList, String keyPropName, Class<K> keyPropCls) throws Exception {
+
+        Map<K, V> map = new LinkedHashMap<K, V>();
+        if (CollectionUtils.isEmpty(beanList) || StringUtils.isEmpty(keyPropName))
+            return map;
+
+        String mthName = "get" + Character.toUpperCase(keyPropName.charAt(0)) + keyPropName.substring(1);
+        if (keyPropCls.isPrimitive())
+            keyPropCls = (Class<K>) CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(keyPropCls);
+        Method getMth = beanList.get(0).getClass().getMethod(mthName);
+
+        for (V v : beanList) {
+            if (null != v) {
+                Object val = getMth.invoke(v);
+                if (val == null)
+                    continue;
+                Class<?> valCls = val.getClass();
+                if (valCls.isPrimitive())
+                    valCls = CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(valCls); //转换为包装类
+
+                if (!valCls.equals(keyPropCls))
+                    continue;
+                if (map.containsKey(val))
+                    continue;
+                map.put((K) val, v);
+            }
+        }
+
+        return map;
+    }
+
+    /** 转换beanList到Map,使用指定bean的props分别作为key和value。 */
+    public static <K, V> Map<K, V> toMap(List<?> beanList, String keyPropName, Class<K> keyPropCls,
+            String valuePropName, Class<V> valuePropCls) throws Exception {
+
+        Map<K, V> map = new LinkedHashMap<K, V>();
+        if (CollectionUtils.isEmpty(beanList) || StringUtils.isEmpty(keyPropName))
+            return map;
+
+        String getKeyMthName = "get" + Character.toUpperCase(keyPropName.charAt(0)) + keyPropName.substring(1);
+        if (keyPropCls.isPrimitive())
+            keyPropCls = (Class<K>) CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(keyPropCls);
+
+        String getValueMthName = "get" + Character.toUpperCase(valuePropName.charAt(0)) + valuePropName.substring(1);
+        if (valuePropCls.isPrimitive())
+            valuePropCls = (Class<V>) CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(valuePropCls);
+        Method getKeyMth = beanList.get(0).getClass().getMethod(getKeyMthName);
+        Method getValueMth = beanList.get(0).getClass().getMethod(getValueMthName);
+
+        for (Object bean : beanList) {
+            if (null != bean) {
+                Object keyVal = getKeyMth.invoke(bean);
+                if (keyVal == null)
+                    continue;
+                Class<?> keyValCls = keyVal.getClass();
+                if (keyValCls.isPrimitive())
+                    keyValCls = CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(keyValCls); //转换为包装类
+
+                if (!keyValCls.equals(keyPropCls))
+                    continue;
+                if (map.containsKey(keyVal))
+                    continue;
+
+                Object valueVal = getValueMth.invoke(bean);
+                if (valueVal == null)
+                    continue;
+                Class<?> valueValCls = valueVal.getClass();
+                if (valueValCls.isPrimitive())
+                    valueValCls = CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(valueValCls);
+                if (!valueValCls.equals(valuePropCls))
+                    continue;
+
+                map.put((K) keyVal, (V) valueVal);
+            }
+        }
+
+        return map;
+    }
+
+    /** 转换beanList到ListMap,使用指定bean的prop作为key。 */
+    public static <K, V> Map<K, List<V>> toListMap(List<V> beanList, String keyPropName, Class<K> keyPropCls)
+            throws Exception {
+
+        Map<K, List<V>> map = new LinkedHashMap<K, List<V>>();
+        if (CollectionUtils.isEmpty(beanList) || StringUtils.isEmpty(keyPropName))
+            return map;
+
+        String mthName = "get" + Character.toUpperCase(keyPropName.charAt(0)) + keyPropName.substring(1);
+        if (keyPropCls.isPrimitive())
+            keyPropCls = (Class<K>) CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(keyPropCls);
+        Method getMth = beanList.get(0).getClass().getMethod(mthName);
+
+        for (V v : beanList) {
+            if (null != v) {
+                Object val = getMth.invoke(v);
+                Class<?> valCls = val.getClass();
+                if (valCls.isPrimitive())
+                    valCls = CommonConstant.BASE_TYPE_WRAPPER_TYPE_MAP.get(valCls); //转换为包装类
+
+                if (!valCls.equals(keyPropCls))
+                    continue;
+                if (!map.containsKey(val))
+                    map.put((K) val, new ArrayList<V>());
+                map.get(val).add(v);
+            }
+        }
+
+        return map;
+    }
+}

+ 308 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/DateUtil.java

@@ -0,0 +1,308 @@
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.apache.commons.lang.math.RandomUtils;
+
+/**
+ * 日期处理辅助类
+ * @author wangqx
+ *
+ */
+public class DateUtil {
+
+    /** yyyy-MM-dd */
+    public static final String YEAR_TO_DAY = "yyyy-MM-dd";
+
+    /** yyyy-MM-dd HH:mm:ss */
+    public static final String YEAR_TO_SECOND = "yyyy-MM-dd HH:mm:ss";
+
+    public static String formatDate(String format) {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        return sdf.format(new Date());
+    }
+
+    public static String formatDate(Date date, String format) {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        return sdf.format(date);
+    }
+
+    public static String formatTomorrowDate(String format) {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        Date date = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DAY_OF_MONTH, 1);
+        return sdf.format(calendar.getTime());
+    }
+
+    public static int compare(Date date1, Date date2) {
+
+        return date1.compareTo(date2);
+    }
+
+    public static int compare(String date1, String format, Date date2) throws ParseException {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        Date date = sdf.parse(date1);
+        return date.compareTo(date2);
+    }
+
+    public static Date parse(String date, String format) throws ParseException {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        return sdf.parse(date);
+    }
+
+    public static Date parse(String date, String format, Locale locale, TimeZone timeZone) throws ParseException {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
+        sdf.setTimeZone(timeZone);
+        return sdf.parse(date);
+    }
+
+    public static Date getNextDate(String hourToSecond) throws ParseException {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(YEAR_TO_DAY);
+        Date date = sdf.parse(DateUtil.formatDate(YEAR_TO_DAY) + " " + hourToSecond);
+        return date;
+    }
+
+    public static Date getCurrentDateRandomSecond(String hourToSecond) throws ParseException {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(YEAR_TO_SECOND);
+        String[] fields = hourToSecond.split("\\:");
+        Integer randomSecond = RandomUtils.nextInt(59);
+        String second = (randomSecond.toString().length() == 1 ? "0" + randomSecond : randomSecond + "");
+        String date = DateUtil.formatDate(YEAR_TO_DAY) + " " + fields[0] + ":" + fields[1] + ":" + second;
+        return sdf.parse(date);
+    }
+
+    public static Date getNextDateRandomSecond(String hourToSecond) throws ParseException {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(YEAR_TO_SECOND);
+        String[] fields = hourToSecond.split("\\:");
+        Integer randomSecond = RandomUtils.nextInt(59);
+        String second = (randomSecond.toString().length() == 1 ? "0" + randomSecond : randomSecond + "");
+        String date = DateUtil.formatTomorrowDate(YEAR_TO_DAY) + " " + fields[0] + ":" + fields[1] + ":" + second;
+        return sdf.parse(date);
+    }
+
+    public static String formatDateCHS(Date date) {
+
+        Calendar calendar = new GregorianCalendar();
+        calendar.setTime(date);
+        StringBuilder str = new StringBuilder();
+        str.append(calendar.get(Calendar.YEAR));
+        str.append("年");
+        str.append(calendar.get(Calendar.MONTH) + 1);
+        str.append("月");
+        str.append(calendar.get(Calendar.DAY_OF_MONTH));
+        str.append("日");
+        return str.toString();
+    }
+
+    /**
+     * 获取传入参数之后的?天
+     * 
+     * @param today
+     *            传入的当前天
+     * @param i
+     *            需要相加的天数
+     * @return
+     */
+    @SuppressWarnings("static-access")
+    public static String getNextDay(String today, int i) {
+
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        Date dd = new Date();
+        try {
+            dd = formatter.parse(today);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        Calendar calendar = new GregorianCalendar();
+        calendar.setTime(dd);
+        calendar.add(calendar.DATE, i);// 把日期往后增加一天.整数往后推,负数往前移动
+        dd = calendar.getTime(); // 这个时间就是日期往后推一天的结果
+        String dateString = formatter.format(dd);
+        return dateString;
+    }
+
+    /**
+     * 获取传入参数之后的?天
+     * 
+     * @param today
+     *            传入的当前天
+     * @param i
+     *            需要相加的天数
+     * @return
+     */
+    @SuppressWarnings("static-access")
+    public static Date getNextDayonDate(String today, int i) {
+
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        Date dd = new Date();
+        try {
+            dd = formatter.parse(today);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        Calendar calendar = new GregorianCalendar();
+        calendar.setTime(dd);
+        calendar.add(calendar.DATE, i);// 把日期往后增加一天.整数往后推,负数往前移动
+        dd = calendar.getTime(); // 这个时间就是日期往后推一天的结果
+        return dd;
+    }
+
+    public static Date getNextDay(Date date, int i) {
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DAY_OF_MONTH, i);
+        date = calendar.getTime();
+        return date;
+    }
+
+    /**
+     * 获取指定周期之前的时刻
+     * @param endTime
+     * @param period
+     * @return
+     */
+    public static long getBeforPeriodTimestamp(long endTime, DateUtil.Period period) {
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(endTime);
+
+        calendar.add(period.getCalendarField(), 0 - period.getAmount());
+        return calendar.getTimeInMillis();
+    };
+
+    /**
+     * 获取指定周期之前的时长
+     * @param endTime
+     * @param period
+     * @return
+     */
+    public static long getBeforPeriodDuration(long endTime, DateUtil.Period period) {
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(endTime);
+
+        calendar.add(period.getCalendarField(), 0 - period.getAmount());
+        return endTime - calendar.getTimeInMillis();
+    };
+
+    public enum Period {
+        /** 一天 */
+        ONE_DAY("一天", Calendar.DAY_OF_MONTH, 1),
+        /** 一天 */
+        TWO_DAY("两天", Calendar.DAY_OF_MONTH, 2),
+        /** 一天 */
+        THREE_DAY("三天", Calendar.DAY_OF_MONTH, 3),
+        /** 一天 */
+        ONE_WEEK("一星期", Calendar.WEEK_OF_MONTH, 1),
+        /** 一天 */
+        TWO_WEEK("两星期", Calendar.WEEK_OF_MONTH, 2),
+        /** 一天 */
+        THREE_WEEK("三星期", Calendar.WEEK_OF_MONTH, 3),
+        /** 一天 */
+        ONE_MONTH("一月", Calendar.MONTH, 1);
+
+        private Period(String name, int calendarField, int amount) {
+            this.name = name;
+            this.calendarField = calendarField;
+            this.amount = amount;
+        }
+
+        private String name;
+
+        private int calendarField;
+
+        private int amount;
+
+        public String getName() {
+
+            return this.name;
+        }
+
+        public int getCalendarField() {
+
+            return calendarField;
+        }
+
+        public int getAmount() {
+
+            return amount;
+        }
+    }
+
+    /**
+     * @param time
+     * @param format
+     * @return
+     */
+    public static String format(Long time, String format) {
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(time);
+        return DateUtil.formatDate(calendar.getTime(), format);
+    }
+
+    public static boolean isWorkDay(Calendar calendar) {
+
+        return !(calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY
+                || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY);
+    }
+
+    /**
+     * @param date
+     * @return
+     */
+    public static boolean isWorkDay(Date date) {
+
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        return isWorkDay(c);
+    }
+    
+    /**
+	 * 获取过去的天数
+	 * @param date
+	 * @return
+	 */
+	public static long pastDays(Date date) {
+		long t = new Date().getTime()-date.getTime();
+		return t/(24*60*60*1000);
+	}
+
+	/**
+	 * 获取过去的小时
+	 * @param date
+	 * @return
+	 */
+	public static long pastHour(Date date) {
+		long t = new Date().getTime()-date.getTime();
+		return t/(60*60*1000);
+	}
+	
+	/**
+	 * 获取过去的分钟
+	 * @param date
+	 * @return
+	 */
+	public static long pastMinutes(Date date) {
+		long t = new Date().getTime()-date.getTime();
+		return t/(60*1000);
+	}
+}

+ 151 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/Encodes.java

@@ -0,0 +1,151 @@
+/**
+ * Copyright (c) 2005-2012 springside.org.cn
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang3.StringEscapeUtils;
+
+/**
+ * 封装各种格式的编码解码工具类.
+ * 1.Commons-Codec的 hex/base64 编码
+ * 2.自制的base62 编码
+ * 3.Commons-Lang的xml/html escape
+ * 4.JDK提供的URLEncoder
+ * @author calvin
+ * @version 2013-01-15
+ */
+public class Encodes {
+
+	private static final String DEFAULT_URL_ENCODING = "UTF-8";
+	private static final char[] BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
+
+	/**
+	 * Hex编码.
+	 */
+	public static String encodeHex(byte[] input) {
+		return new String(Hex.encodeHex(input));
+	}
+
+	/**
+	 * Hex解码.
+	 */
+	public static byte[] decodeHex(String input) {
+		try {
+			return Hex.decodeHex(input.toCharArray());
+		} catch (DecoderException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	/**
+	 * Base64编码.
+	 */
+	public static String encodeBase64(byte[] input) {
+		return new String(Base64.encodeBase64(input));
+	}
+	
+	/**
+	 * Base64编码.
+	 */
+	public static String encodeBase64(String input) {
+		try {
+			return new String(Base64.encodeBase64(input.getBytes(DEFAULT_URL_ENCODING)));
+		} catch (UnsupportedEncodingException e) {
+			return "";
+		}
+	}
+
+//	/**
+//	 * Base64编码, URL安全(将Base64中的URL非法字符'+'和'/'转为'-'和'_', 见RFC3548).
+//	 */
+//	public static String encodeUrlSafeBase64(byte[] input) {
+//		return Base64.encodeBase64URLSafe(input);
+//	}
+
+	/**
+	 * Base64解码.
+	 */
+	public static byte[] decodeBase64(String input) {
+		return Base64.decodeBase64(input.getBytes());
+	}
+	
+	/**
+	 * Base64解码.
+	 */
+	public static String decodeBase64String(String input) {
+		try {
+			return new String(Base64.decodeBase64(input.getBytes()), DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			return "";
+		}
+	}
+
+	/**
+	 * Base62编码。
+	 */
+	public static String encodeBase62(byte[] input) {
+		char[] chars = new char[input.length];
+		for (int i = 0; i < input.length; i++) {
+			chars[i] = BASE62[((input[i] & 0xFF) % BASE62.length)];
+		}
+		return new String(chars);
+	}
+
+	/**
+	 * Html 转码.
+	 */
+	public static String escapeHtml(String html) {
+		return StringEscapeUtils.escapeHtml4(html);
+	}
+
+	/**
+	 * Html 解码.
+	 */
+	public static String unescapeHtml(String htmlEscaped) {
+		return StringEscapeUtils.unescapeHtml4(htmlEscaped);
+	}
+
+	/**
+	 * Xml 转码.
+	 */
+	public static String escapeXml(String xml) {
+		return StringEscapeUtils.escapeXml10(xml);
+	}
+
+	/**
+	 * Xml 解码.
+	 */
+	public static String unescapeXml(String xmlEscaped) {
+		return StringEscapeUtils.unescapeXml(xmlEscaped);
+	}
+
+	/**
+	 * URL 编码, Encode默认为UTF-8. 
+	 */
+	public static String urlEncode(String part) {
+		try {
+			return URLEncoder.encode(part, DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+
+	/**
+	 * URL 解码, Encode默认为UTF-8. 
+	 */
+	public static String urlDecode(String part) {
+
+		try {
+			return URLDecoder.decode(part, DEFAULT_URL_ENCODING);
+		} catch (UnsupportedEncodingException e) {
+			throw Exceptions.unchecked(e);
+		}
+	}
+}

+ 73 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/Exceptions.java

@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2005-2012 springside.org.cn
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 关于异常的工具类.
+ * @author calvin
+ * @version 2013-01-15
+ */
+public class Exceptions {
+
+	/**
+	 * 将CheckedException转换为UncheckedException.
+	 */
+	public static RuntimeException unchecked(Exception e) {
+		if (e instanceof RuntimeException) {
+			return (RuntimeException) e;
+		} else {
+			return new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * 将ErrorStack转化为String.
+	 */
+	public static String getStackTraceAsString(Throwable e) {
+		if (e == null){
+			return "";
+		}
+		StringWriter stringWriter = new StringWriter();
+		e.printStackTrace(new PrintWriter(stringWriter));
+		return stringWriter.toString();
+	}
+
+	/**
+	 * 判断异常是否由某些底层的异常引起.
+	 */
+	@SuppressWarnings("unchecked")
+	public static boolean isCausedBy(Exception ex, Class<? extends Exception>... causeExceptionClasses) {
+		Throwable cause = ex.getCause();
+		while (cause != null) {
+			for (Class<? extends Exception> causeClass : causeExceptionClasses) {
+				if (causeClass.isInstance(cause)) {
+					return true;
+				}
+			}
+			cause = cause.getCause();
+		}
+		return false;
+	}
+
+	/**
+	 * 在request中获取异常类
+	 * @param request
+	 * @return 
+	 */
+	public static Throwable getThrowable(HttpServletRequest request){
+		Throwable ex = null;
+		if (request.getAttribute("exception") != null) {
+			ex = (Throwable) request.getAttribute("exception");
+		} else if (request.getAttribute("javax.servlet.error.exception") != null) {
+			ex = (Throwable) request.getAttribute("javax.servlet.error.exception");
+		}
+		return ex;
+	}
+	
+}

+ 968 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/FileUtils.java

@@ -0,0 +1,968 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.RandomAccessFile;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tools.zip.ZipEntry;
+import org.apache.tools.zip.ZipFile;
+import org.apache.tools.zip.ZipOutputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+
+/**
+ * 文件操作工具类
+ * 实现文件的创建、删除、复制、压缩、解压以及目录的创建、删除、复制、压缩解压等功能
+ * @author ThinkGem
+ * @version 2015-3-16
+ */
+public class FileUtils extends org.apache.commons.io.FileUtils {
+	
+	private static Logger logger = LoggerFactory.getLogger(FileUtils.class);
+
+	/**
+	 * 复制单个文件,如果目标文件存在,则不覆盖
+	 * @param srcFileName 待复制的文件名
+	 * @param descFileName 目标文件名
+	 * @return 如果复制成功,则返回true,否则返回false
+	 */
+	public static boolean copyFile(String srcFileName, String descFileName) {
+		return FileUtils.copyFileCover(srcFileName, descFileName, false);
+	}
+
+	/**
+	 * 复制单个文件
+	 * @param srcFileName 待复制的文件名
+	 * @param descFileName 目标文件名
+	 * @param coverlay 如果目标文件已存在,是否覆盖
+	 * @return 如果复制成功,则返回true,否则返回false
+	 */
+	public static boolean copyFileCover(String srcFileName,
+			String descFileName, boolean coverlay) {
+		File srcFile = new File(srcFileName);
+		// 判断源文件是否存在
+		if (!srcFile.exists()) {
+			logger.debug("复制文件失败,源文件 " + srcFileName + " 不存在!");
+			return false;
+		}
+		// 判断源文件是否是合法的文件
+		else if (!srcFile.isFile()) {
+			logger.debug("复制文件失败," + srcFileName + " 不是一个文件!");
+			return false;
+		}
+		File descFile = new File(descFileName);
+		// 判断目标文件是否存在
+		if (descFile.exists()) {
+			// 如果目标文件存在,并且允许覆盖
+			if (coverlay) {
+				logger.debug("目标文件已存在,准备删除!");
+				if (!FileUtils.delFile(descFileName)) {
+					logger.debug("删除目标文件 " + descFileName + " 失败!");
+					return false;
+				}
+			} else {
+				logger.debug("复制文件失败,目标文件 " + descFileName + " 已存在!");
+				return false;
+			}
+		} else {
+			if (!descFile.getParentFile().exists()) {
+				// 如果目标文件所在的目录不存在,则创建目录
+				logger.debug("目标文件所在的目录不存在,创建目录!");
+				// 创建目标文件所在的目录
+				if (!descFile.getParentFile().mkdirs()) {
+					logger.debug("创建目标文件所在的目录失败!");
+					return false;
+				}
+			}
+		}
+
+		// 准备复制文件
+		// 读取的位数
+		int readByte = 0;
+		InputStream ins = null;
+		OutputStream outs = null;
+		try {
+			// 打开源文件
+			ins = new FileInputStream(srcFile);
+			// 打开目标文件的输出流
+			outs = new FileOutputStream(descFile);
+			byte[] buf = new byte[1024];
+			// 一次读取1024个字节,当readByte为-1时表示文件已经读取完毕
+			while ((readByte = ins.read(buf)) != -1) {
+				// 将读取的字节流写入到输出流
+				outs.write(buf, 0, readByte);
+			}
+			logger.debug("复制单个文件 " + srcFileName + " 到" + descFileName
+					+ "成功!");
+			return true;
+		} catch (Exception e) {
+			logger.debug("复制文件失败:" + e.getMessage());
+			return false;
+		} finally {
+			// 关闭输入输出流,首先关闭输出流,然后再关闭输入流
+			if (outs != null) {
+				try {
+					outs.close();
+				} catch (IOException oute) {
+					oute.printStackTrace();
+				}
+			}
+			if (ins != null) {
+				try {
+					ins.close();
+				} catch (IOException ine) {
+					ine.printStackTrace();
+				}
+			}
+		}
+	}
+
+	/**
+	 * 复制整个目录的内容,如果目标目录存在,则不覆盖
+	 * @param srcDirName 源目录名
+	 * @param descDirName 目标目录名
+	 * @return 如果复制成功返回true,否则返回false
+	 */
+	public static boolean copyDirectory(String srcDirName, String descDirName) {
+		return FileUtils.copyDirectoryCover(srcDirName, descDirName,
+				false);
+	}
+
+	/**
+	 * 复制整个目录的内容 
+	 * @param srcDirName 源目录名
+	 * @param descDirName 目标目录名
+	 * @param coverlay 如果目标目录存在,是否覆盖
+	 * @return 如果复制成功返回true,否则返回false
+	 */
+	public static boolean copyDirectoryCover(String srcDirName,
+			String descDirName, boolean coverlay) {
+		File srcDir = new File(srcDirName);
+		// 判断源目录是否存在
+		if (!srcDir.exists()) {
+			logger.debug("复制目录失败,源目录 " + srcDirName + " 不存在!");
+			return false;
+		}
+		// 判断源目录是否是目录
+		else if (!srcDir.isDirectory()) {
+			logger.debug("复制目录失败," + srcDirName + " 不是一个目录!");
+			return false;
+		}
+		// 如果目标文件夹名不以文件分隔符结尾,自动添加文件分隔符
+		String descDirNames = descDirName;
+		if (!descDirNames.endsWith(File.separator)) {
+			descDirNames = descDirNames + File.separator;
+		}
+		File descDir = new File(descDirNames);
+		// 如果目标文件夹存在
+		if (descDir.exists()) {
+			if (coverlay) {
+				// 允许覆盖目标目录
+				logger.debug("目标目录已存在,准备删除!");
+				if (!FileUtils.delFile(descDirNames)) {
+					logger.debug("删除目录 " + descDirNames + " 失败!");
+					return false;
+				}
+			} else {
+				logger.debug("目标目录复制失败,目标目录 " + descDirNames + " 已存在!");
+				return false;
+			}
+		} else {
+			// 创建目标目录
+			logger.debug("目标目录不存在,准备创建!");
+			if (!descDir.mkdirs()) {
+				logger.debug("创建目标目录失败!");
+				return false;
+			}
+
+		}
+
+		boolean flag = true;
+		// 列出源目录下的所有文件名和子目录名
+		File[] files = srcDir.listFiles();
+		for (int i = 0; i < files.length; i++) {
+			// 如果是一个单个文件,则直接复制
+			if (files[i].isFile()) {
+				flag = FileUtils.copyFile(files[i].getAbsolutePath(),
+						descDirName + files[i].getName());
+				// 如果拷贝文件失败,则退出循环
+				if (!flag) {
+					break;
+				}
+			}
+			// 如果是子目录,则继续复制目录
+			if (files[i].isDirectory()) {
+				flag = FileUtils.copyDirectory(files[i]
+						.getAbsolutePath(), descDirName + files[i].getName());
+				// 如果拷贝目录失败,则退出循环
+				if (!flag) {
+					break;
+				}
+			}
+		}
+
+		if (!flag) {
+			logger.debug("复制目录 " + srcDirName + " 到 " + descDirName + " 失败!");
+			return false;
+		}
+		logger.debug("复制目录 " + srcDirName + " 到 " + descDirName + " 成功!");
+		return true;
+
+	}
+
+	/**
+	 * 
+	 * 删除文件,可以删除单个文件或文件夹
+	 * 
+	 * @param fileName 被删除的文件名
+	 * @return 如果删除成功,则返回true,否是返回false
+	 */
+	public static boolean delFile(String fileName) {
+ 		File file = new File(fileName);
+		if (!file.exists()) {
+			logger.debug(fileName + " 文件不存在!");
+			return true;
+		} else {
+			if (file.isFile()) {
+				return FileUtils.deleteFile(fileName);
+			} else {
+				return FileUtils.deleteDirectory(fileName);
+			}
+		}
+	}
+
+	/**
+	 * 
+	 * 删除单个文件
+	 * 
+	 * @param fileName 被删除的文件名
+	 * @return 如果删除成功,则返回true,否则返回false
+	 */
+	public static boolean deleteFile(String fileName) {
+		File file = new File(fileName);
+		if (file.exists() && file.isFile()) {
+			if (file.delete()) {
+				logger.debug("删除文件 " + fileName + " 成功!");
+				return true;
+			} else {
+				logger.debug("删除文件 " + fileName + " 失败!");
+				return false;
+			}
+		} else {
+			logger.debug(fileName + " 文件不存在!");
+			return true;
+		}
+	}
+
+	/**
+	 * 
+	 * 删除目录及目录下的文件
+	 * 
+	 * @param dirName 被删除的目录所在的文件路径
+	 * @return 如果目录删除成功,则返回true,否则返回false
+	 */
+	public static boolean deleteDirectory(String dirName) {
+		String dirNames = dirName;
+		if (!dirNames.endsWith(File.separator)) {
+			dirNames = dirNames + File.separator;
+		}
+		File dirFile = new File(dirNames);
+		if (!dirFile.exists() || !dirFile.isDirectory()) {
+			logger.debug(dirNames + " 目录不存在!");
+			return true;
+		}
+		boolean flag = true;
+		// 列出全部文件及子目录
+		File[] files = dirFile.listFiles();
+		for (int i = 0; i < files.length; i++) {
+			// 删除子文件
+			if (files[i].isFile()) {
+				flag = FileUtils.deleteFile(files[i].getAbsolutePath());
+				// 如果删除文件失败,则退出循环
+				if (!flag) {
+					break;
+				}
+			}
+			// 删除子目录
+			else if (files[i].isDirectory()) {
+				flag = FileUtils.deleteDirectory(files[i]
+						.getAbsolutePath());
+				// 如果删除子目录失败,则退出循环
+				if (!flag) {
+					break;
+				}
+			}
+		}
+
+		if (!flag) {
+			logger.debug("删除目录失败!");
+			return false;
+		}
+		// 删除当前目录
+		if (dirFile.delete()) {
+			logger.debug("删除目录 " + dirName + " 成功!");
+			return true;
+		} else {
+			logger.debug("删除目录 " + dirName + " 失败!");
+			return false;
+		}
+
+	}
+
+	/**
+	 * 创建单个文件
+	 * @param descFileName 文件名,包含路径
+	 * @return 如果创建成功,则返回true,否则返回false
+	 */
+	public static boolean createFile(String descFileName) {
+		File file = new File(descFileName);
+		if (file.exists()) {
+			logger.debug("文件 " + descFileName + " 已存在!");
+			return false;
+		}
+		if (descFileName.endsWith(File.separator)) {
+			logger.debug(descFileName + " 为目录,不能创建目录!");
+			return false;
+		}
+		if (!file.getParentFile().exists()) {
+			// 如果文件所在的目录不存在,则创建目录
+			if (!file.getParentFile().mkdirs()) {
+				logger.debug("创建文件所在的目录失败!");
+				return false;
+			}
+		}
+
+		// 创建文件
+		try {
+			if (file.createNewFile()) {
+				logger.debug(descFileName + " 文件创建成功!");
+				return true;
+			} else {
+				logger.debug(descFileName + " 文件创建失败!");
+				return false;
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			logger.debug(descFileName + " 文件创建失败!");
+			return false;
+		}
+
+	}
+
+	/**
+	 * 创建目录
+	 * @param descDirName 目录名,包含路径
+	 * @return 如果创建成功,则返回true,否则返回false
+	 */
+	public static boolean createDirectory(String descDirName) {
+		String descDirNames = descDirName;
+		if (!descDirNames.endsWith(File.separator)) {
+			descDirNames = descDirNames + File.separator;
+		}
+		File descDir = new File(descDirNames);
+		if (descDir.exists()) {
+			logger.debug("目录 " + descDirNames + " 已存在!");
+			return false;
+		}
+		// 创建目录
+		if (descDir.mkdirs()) {
+			logger.debug("目录 " + descDirNames + " 创建成功!");
+			return true;
+		} else {
+			logger.debug("目录 " + descDirNames + " 创建失败!");
+			return false;
+		}
+
+	}
+
+	/**
+	 * 写入文件
+	 * @param file 要写入的文件
+	 */
+	public static void writeToFile(String fileName, String content, boolean append) {
+		try {
+			FileUtils.write(new File(fileName), content, "utf-8", append);
+			logger.debug("文件 " + fileName + " 写入成功!");
+		} catch (IOException e) {
+			logger.debug("文件 " + fileName + " 写入失败! " + e.getMessage());
+		}
+	}
+
+	/**
+	 * 写入文件
+	 * @param file 要写入的文件
+	 */
+	public static void writeToFile(String fileName, String content, String encoding, boolean append) {
+		try {
+			FileUtils.write(new File(fileName), content, encoding, append);
+			logger.debug("文件 " + fileName + " 写入成功!");
+		} catch (IOException e) {
+			logger.debug("文件 " + fileName + " 写入失败! " + e.getMessage());
+		}
+	}
+	
+	/**
+	 * 压缩文件或目录
+	 * @param srcDirName 压缩的根目录
+	 * @param fileName 根目录下的待压缩的文件名或文件夹名,其中*或""表示跟目录下的全部文件
+	 * @param descFileName 目标zip文件
+	 */
+	public static void zipFiles(String srcDirName, String fileName,
+			String descFileName) {
+		// 判断目录是否存在
+		if (srcDirName == null) {
+			logger.debug("文件压缩失败,目录 " + srcDirName + " 不存在!");
+			return;
+		}
+		File fileDir = new File(srcDirName);
+		if (!fileDir.exists() || !fileDir.isDirectory()) {
+			logger.debug("文件压缩失败,目录 " + srcDirName + " 不存在!");
+			return;
+		}
+		String dirPath = fileDir.getAbsolutePath();
+		File descFile = new File(descFileName);
+		try {
+			ZipOutputStream zouts = new ZipOutputStream(new FileOutputStream(
+					descFile));
+			if ("*".equals(fileName) || "".equals(fileName)) {
+				FileUtils.zipDirectoryToZipFile(dirPath, fileDir, zouts);
+			} else {
+				File file = new File(fileDir, fileName);
+				if (file.isFile()) {
+					FileUtils.zipFilesToZipFile(dirPath, file, zouts);
+				} else {
+					FileUtils
+							.zipDirectoryToZipFile(dirPath, file, zouts);
+				}
+			}
+			zouts.close();
+			logger.debug(descFileName + " 文件压缩成功!");
+		} catch (Exception e) {
+			logger.debug("文件压缩失败:" + e.getMessage());
+			e.printStackTrace();
+		}
+
+	}
+
+	/**
+	 * 解压缩ZIP文件,将ZIP文件里的内容解压到descFileName目录下
+	 * @param zipFileName 需要解压的ZIP文件
+	 * @param descFileName 目标文件
+	 */
+	public static boolean unZipFiles(String zipFileName, String descFileName) {
+		String descFileNames = descFileName;
+		if (!descFileNames.endsWith(File.separator)) {
+			descFileNames = descFileNames + File.separator;
+		}		
+        try {
+			// 根据ZIP文件创建ZipFile对象
+			ZipFile zipFile = new ZipFile(zipFileName);
+			ZipEntry entry = null;
+			String entryName = null;
+			String descFileDir = null;
+			byte[] buf = new byte[4096];
+			int readByte = 0;
+			// 获取ZIP文件里所有的entry
+			@SuppressWarnings("rawtypes")
+			Enumeration enums = zipFile.getEntries();
+			// 遍历所有entry
+			while (enums.hasMoreElements()) {
+				entry = (ZipEntry) enums.nextElement();
+				// 获得entry的名字
+				entryName = entry.getName();
+				descFileDir = descFileNames + entryName;
+				if (entry.isDirectory()) {
+					// 如果entry是一个目录,则创建目录
+					new File(descFileDir).mkdirs();
+					continue;
+				} else {
+					// 如果entry是一个文件,则创建父目录
+					new File(descFileDir).getParentFile().mkdirs();
+				}
+				File file = new File(descFileDir);
+				// 打开文件输出流
+				OutputStream os = new FileOutputStream(file);
+				// 从ZipFile对象中打开entry的输入流
+		        InputStream is = zipFile.getInputStream(entry);
+				while ((readByte = is.read(buf)) != -1) {
+					os.write(buf, 0, readByte);
+				}
+				os.close();
+				is.close();
+			}
+			zipFile.close();
+			logger.debug("文件解压成功!");
+			return true;
+		} catch (Exception e) {
+			logger.debug("文件解压失败:" + e.getMessage());
+			return false;
+		}
+	}
+
+	/**
+	 * 将目录压缩到ZIP输出流
+	 * @param dirPath 目录路径
+	 * @param fileDir 文件信息
+	 * @param zouts 输出流
+	 */
+	public static void zipDirectoryToZipFile(String dirPath, File fileDir, ZipOutputStream zouts) {
+		if (fileDir.isDirectory()) {
+			File[] files = fileDir.listFiles();
+			// 空的文件夹
+			if (files.length == 0) {
+				// 目录信息
+				ZipEntry entry = new ZipEntry(getEntryName(dirPath, fileDir));
+				try {
+					zouts.putNextEntry(entry);
+					zouts.closeEntry();
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+				return;
+			}
+
+			for (int i = 0; i < files.length; i++) {
+				if (files[i].isFile()) {
+					// 如果是文件,则调用文件压缩方法
+					FileUtils
+							.zipFilesToZipFile(dirPath, files[i], zouts);
+				} else {
+					// 如果是目录,则递归调用
+					FileUtils.zipDirectoryToZipFile(dirPath, files[i],
+							zouts);
+				}
+			}
+		}
+	}
+
+	/**
+	 * 将文件压缩到ZIP输出流
+	 * @param dirPath 目录路径
+	 * @param file 文件
+	 * @param zouts 输出流
+	 */
+	public static void zipFilesToZipFile(String dirPath, File file, ZipOutputStream zouts) {
+		FileInputStream fin = null;
+		ZipEntry entry = null;
+		// 创建复制缓冲区
+		byte[] buf = new byte[4096];
+		int readByte = 0;
+		if (file.isFile()) {
+			try {
+				// 创建一个文件输入流
+				fin = new FileInputStream(file);
+				// 创建一个ZipEntry
+				entry = new ZipEntry(getEntryName(dirPath, file));
+				// 存储信息到压缩文件
+				zouts.putNextEntry(entry);
+				// 复制字节到压缩文件
+				while ((readByte = fin.read(buf)) != -1) {
+					zouts.write(buf, 0, readByte);
+				}
+				zouts.closeEntry();
+				fin.close();
+				System.out
+						.println("添加文件 " + file.getAbsolutePath() + " 到zip文件中!");
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * 获取待压缩文件在ZIP文件中entry的名字,即相对于跟目录的相对路径名
+	 * @param dirPat 目录名
+	 * @param file entry文件名
+	 * @return
+	 */
+	private static String getEntryName(String dirPath, File file) {
+		String dirPaths = dirPath;
+		if (!dirPaths.endsWith(File.separator)) {
+			dirPaths = dirPaths + File.separator;
+		}
+		String filePath = file.getAbsolutePath();
+		// 对于目录,必须在entry名字后面加上"/",表示它将以目录项存储
+		if (file.isDirectory()) {
+			filePath += "/";
+		}
+		int index = filePath.indexOf(dirPaths);
+
+		return filePath.substring(index + dirPaths.length());
+	}
+
+	/**
+	 * 根据“文件名的后缀”获取文件内容类型(而非根据File.getContentType()读取的文件类型)
+	 * @param returnFileName 带验证的文件名
+	 * @return 返回文件类型
+	 */
+	public static String getContentType(String returnFileName) {
+		String contentType = "application/octet-stream";
+		if (returnFileName.lastIndexOf(".") < 0)
+			return contentType;
+		returnFileName = returnFileName.toLowerCase();
+		returnFileName = returnFileName.substring(returnFileName.lastIndexOf(".") + 1);
+		if (returnFileName.equals("html") || returnFileName.equals("htm") || returnFileName.equals("shtml")) {
+			contentType = "text/html";
+		} else if (returnFileName.equals("apk")) {
+			contentType = "application/vnd.android.package-archive";
+		} else if (returnFileName.equals("sis")) {
+			contentType = "application/vnd.symbian.install";
+		} else if (returnFileName.equals("sisx")) {
+			contentType = "application/vnd.symbian.install";
+		} else if (returnFileName.equals("exe")) {
+			contentType = "application/x-msdownload";
+		} else if (returnFileName.equals("msi")) {
+			contentType = "application/x-msdownload";
+		} else if (returnFileName.equals("css")) {
+			contentType = "text/css";
+		} else if (returnFileName.equals("xml")) {
+			contentType = "text/xml";
+		} else if (returnFileName.equals("gif")) {
+			contentType = "image/gif";
+		} else if (returnFileName.equals("jpeg") || returnFileName.equals("jpg")) {
+			contentType = "image/jpeg";
+		} else if (returnFileName.equals("js")) {
+			contentType = "application/x-javascript";
+		} else if (returnFileName.equals("atom")) {
+			contentType = "application/atom+xml";
+		} else if (returnFileName.equals("rss")) {
+			contentType = "application/rss+xml";
+		} else if (returnFileName.equals("mml")) {
+			contentType = "text/mathml";
+		} else if (returnFileName.equals("txt")) {
+			contentType = "text/plain";
+		} else if (returnFileName.equals("jad")) {
+			contentType = "text/vnd.sun.j2me.app-descriptor";
+		} else if (returnFileName.equals("wml")) {
+			contentType = "text/vnd.wap.wml";
+		} else if (returnFileName.equals("htc")) {
+			contentType = "text/x-component";
+		} else if (returnFileName.equals("png")) {
+			contentType = "image/png";
+		} else if (returnFileName.equals("tif") || returnFileName.equals("tiff")) {
+			contentType = "image/tiff";
+		} else if (returnFileName.equals("wbmp")) {
+			contentType = "image/vnd.wap.wbmp";
+		} else if (returnFileName.equals("ico")) {
+			contentType = "image/x-icon";
+		} else if (returnFileName.equals("jng")) {
+			contentType = "image/x-jng";
+		} else if (returnFileName.equals("bmp")) {
+			contentType = "image/x-ms-bmp";
+		} else if (returnFileName.equals("svg")) {
+			contentType = "image/svg+xml";
+		} else if (returnFileName.equals("jar") || returnFileName.equals("var") 
+				|| returnFileName.equals("ear")) {
+			contentType = "application/java-archive";
+		} else if (returnFileName.equals("doc")) {
+			contentType = "application/msword";
+		} else if (returnFileName.equals("pdf")) {
+			contentType = "application/pdf";
+		} else if (returnFileName.equals("rtf")) {
+			contentType = "application/rtf";
+		} else if (returnFileName.equals("xls")) {
+			contentType = "application/vnd.ms-excel";
+		} else if (returnFileName.equals("ppt")) {
+			contentType = "application/vnd.ms-powerpoint";
+		} else if (returnFileName.equals("7z")) {
+			contentType = "application/x-7z-compressed";
+		} else if (returnFileName.equals("rar")) {
+			contentType = "application/x-rar-compressed";
+		} else if (returnFileName.equals("swf")) {
+			contentType = "application/x-shockwave-flash";
+		} else if (returnFileName.equals("rpm")) {
+			contentType = "application/x-redhat-package-manager";
+		} else if (returnFileName.equals("der") || returnFileName.equals("pem")
+				|| returnFileName.equals("crt")) {
+			contentType = "application/x-x509-ca-cert";
+		} else if (returnFileName.equals("xhtml")) {
+			contentType = "application/xhtml+xml";
+		} else if (returnFileName.equals("zip")) {
+			contentType = "application/zip";
+		} else if (returnFileName.equals("mid") || returnFileName.equals("midi") 
+				|| returnFileName.equals("kar")) {
+			contentType = "audio/midi";
+		} else if (returnFileName.equals("mp3")) {
+			contentType = "audio/mpeg";
+		} else if (returnFileName.equals("ogg")) {
+			contentType = "audio/ogg";
+		} else if (returnFileName.equals("m4a")) {
+			contentType = "audio/x-m4a";
+		} else if (returnFileName.equals("ra")) {
+			contentType = "audio/x-realaudio";
+		} else if (returnFileName.equals("3gpp")
+				|| returnFileName.equals("3gp")) {
+			contentType = "video/3gpp";
+		} else if (returnFileName.equals("mp4")) {
+			contentType = "video/mp4";
+		} else if (returnFileName.equals("mpeg")
+				|| returnFileName.equals("mpg")) {
+			contentType = "video/mpeg";
+		} else if (returnFileName.equals("mov")) {
+			contentType = "video/quicktime";
+		} else if (returnFileName.equals("flv")) {
+			contentType = "video/x-flv";
+		} else if (returnFileName.equals("m4v")) {
+			contentType = "video/x-m4v";
+		} else if (returnFileName.equals("mng")) {
+			contentType = "video/x-mng";
+		} else if (returnFileName.equals("asx") || returnFileName.equals("asf")) {
+			contentType = "video/x-ms-asf";
+		} else if (returnFileName.equals("wmv")) {
+			contentType = "video/x-ms-wmv";
+		} else if (returnFileName.equals("avi")) {
+			contentType = "video/x-msvideo";
+		}
+		return contentType;
+	}
+	
+	/**
+	 * 向浏览器发送文件下载,支持断点续传
+	 * @param file 要下载的文件
+	 * @param request 请求对象
+	 * @param response 响应对象
+	 * @return 返回错误信息,无错误信息返回null
+	 */
+	public static String downFile(File file, HttpServletRequest request, HttpServletResponse response){
+		 return downFile(file, request, response, null);
+	}
+	
+	/**
+	 * 向浏览器发送文件下载,支持断点续传
+	 * @param file 要下载的文件
+	 * @param request 请求对象
+	 * @param response 响应对象
+	 * @param fileName 指定下载的文件名
+	 * @return 返回错误信息,无错误信息返回null
+	 */
+	public static String downFile(File file, HttpServletRequest request, HttpServletResponse response, String fileName){
+		String error  = null;
+		if (file != null && file.exists()) {
+			if (file.isFile()) {
+				if (file.length() <= 0) {
+					error = "该文件是一个空文件。";
+				}
+				if (!file.canRead()) {
+					error = "该文件没有读取权限。";
+				}
+			} else {
+				error = "该文件是一个文件夹。";
+			}
+		} else {
+			error = "文件已丢失或不存在!";
+		}
+		if (error != null){
+			logger.debug("---------------" + file + " " + error);
+			return error;
+		}
+
+		long fileLength = file.length(); // 记录文件大小
+		long pastLength = 0; 	// 记录已下载文件大小
+		int rangeSwitch = 0; 	// 0:从头开始的全文下载;1:从某字节开始的下载(bytes=27000-);2:从某字节开始到某字节结束的下载(bytes=27000-39000)
+		long toLength = 0; 		// 记录客户端需要下载的字节段的最后一个字节偏移量(比如bytes=27000-39000,则这个值是为39000)
+		long contentLength = 0; // 客户端请求的字节总量
+		String rangeBytes = ""; // 记录客户端传来的形如“bytes=27000-”或者“bytes=27000-39000”的内容
+		RandomAccessFile raf = null; // 负责读取数据
+		OutputStream os = null; 	// 写出数据
+		OutputStream out = null; 	// 缓冲
+		byte b[] = new byte[1024]; 	// 暂存容器
+
+		if (request.getHeader("Range") != null) { // 客户端请求的下载的文件块的开始字节
+			response.setStatus(javax.servlet.http.HttpServletResponse.SC_PARTIAL_CONTENT);
+			logger.debug("request.getHeader(\"Range\") = " + request.getHeader("Range"));
+			rangeBytes = request.getHeader("Range").replaceAll("bytes=", "");
+			if (rangeBytes.indexOf('-') == rangeBytes.length() - 1) {// bytes=969998336-
+				rangeSwitch = 1;
+				rangeBytes = rangeBytes.substring(0, rangeBytes.indexOf('-'));
+				pastLength = Long.parseLong(rangeBytes.trim());
+				contentLength = fileLength - pastLength; // 客户端请求的是 969998336  之后的字节
+			} else { // bytes=1275856879-1275877358
+				rangeSwitch = 2;
+				String temp0 = rangeBytes.substring(0, rangeBytes.indexOf('-'));
+				String temp2 = rangeBytes.substring(rangeBytes.indexOf('-') + 1, rangeBytes.length());
+				pastLength = Long.parseLong(temp0.trim()); // bytes=1275856879-1275877358,从第 1275856879 个字节开始下载
+				toLength = Long.parseLong(temp2); // bytes=1275856879-1275877358,到第 1275877358 个字节结束
+				contentLength = toLength - pastLength; // 客户端请求的是 1275856879-1275877358 之间的字节
+			}
+		} else { // 从开始进行下载
+			contentLength = fileLength; // 客户端要求全文下载
+		}
+
+		// 如果设设置了Content-Length,则客户端会自动进行多线程下载。如果不希望支持多线程,则不要设置这个参数。 响应的格式是:
+		// Content-Length: [文件的总大小] - [客户端请求的下载的文件块的开始字节]
+		// ServletActionContext.getResponse().setHeader("Content- Length", new Long(file.length() - p).toString());
+		response.reset(); // 告诉客户端允许断点续传多线程连接下载,响应的格式是:Accept-Ranges: bytes
+		if (pastLength != 0) {
+			response.setHeader("Accept-Ranges", "bytes");// 如果是第一次下,还没有断点续传,状态是默认的 200,无需显式设置;响应的格式是:HTTP/1.1 200 OK
+			// 不是从最开始下载, 响应的格式是: Content-Range: bytes [文件块的开始字节]-[文件的总大小 - 1]/[文件的总大小]
+			logger.debug("---------------不是从开始进行下载!服务器即将开始断点续传...");
+			switch (rangeSwitch) {
+				case 1: { // 针对 bytes=27000- 的请求
+					String contentRange = new StringBuffer("bytes ").append(new Long(pastLength).toString()).append("-")
+							.append(new Long(fileLength - 1).toString()).append("/").append(new Long(fileLength).toString()).toString();
+					response.setHeader("Content-Range", contentRange);
+					break;
+				}
+				case 2: { // 针对 bytes=27000-39000 的请求
+					String contentRange = rangeBytes + "/" + new Long(fileLength).toString();
+					response.setHeader("Content-Range", contentRange);
+					break;
+				}
+				default: {
+					break;
+				}
+			}
+		} else {
+			// 是从开始下载
+			logger.debug("---------------是从开始进行下载!");
+		}
+
+		try {
+			response.addHeader("Content-Disposition", "attachment; filename=\"" + 
+					Encodes.urlEncode(StringUtils.isBlank(fileName) ? file.getName() : fileName) + "\"");
+			response.setContentType(getContentType(file.getName())); // set the MIME type.
+			response.addHeader("Content-Length", String.valueOf(contentLength));
+			os = response.getOutputStream();
+			out = new BufferedOutputStream(os);
+			raf = new RandomAccessFile(file, "r");
+			try {
+				switch (rangeSwitch) {
+					case 0: { // 普通下载,或者从头开始的下载 同1
+					}
+					case 1: { // 针对 bytes=27000- 的请求
+						raf.seek(pastLength); // 形如 bytes=969998336- 的客户端请求,跳过 969998336 个字节
+						int n = 0;
+						while ((n = raf.read(b, 0, 1024)) != -1) {
+							out.write(b, 0, n);
+						}
+						break;
+					}
+					case 2: { // 针对 bytes=27000-39000 的请求
+						raf.seek(pastLength); // 形如 bytes=1275856879-1275877358 的客户端请求,找到第 1275856879 个字节
+						int n = 0;
+						long readLength = 0; // 记录已读字节数
+						while (readLength <= contentLength - 1024) {// 大部分字节在这里读取
+							n = raf.read(b, 0, 1024);
+							readLength += 1024;
+							out.write(b, 0, n);
+						}
+						if (readLength <= contentLength) { // 余下的不足 1024 个字节在这里读取
+							n = raf.read(b, 0, (int) (contentLength - readLength));
+							out.write(b, 0, n);
+						}
+						break;
+					}
+					default: {
+						break;
+					}
+				}
+				out.flush();
+				logger.debug("---------------下载完成!");
+			} catch (IOException ie) {
+				/**
+				 * 在写数据的时候, 对于 ClientAbortException 之类的异常,
+				 * 是因为客户端取消了下载,而服务器端继续向浏览器写入数据时, 抛出这个异常,这个是正常的。
+				 * 尤其是对于迅雷这种吸血的客户端软件, 明明已经有一个线程在读取 bytes=1275856879-1275877358,
+				 * 如果短时间内没有读取完毕,迅雷会再启第二个、第三个。。。线程来读取相同的字节段, 直到有一个线程读取完毕,迅雷会 KILL
+				 * 掉其他正在下载同一字节段的线程, 强行中止字节读出,造成服务器抛 ClientAbortException。
+				 * 所以,我们忽略这种异常
+				 */
+				logger.debug("提醒:向客户端传输时出现IO异常,但此异常是允许的,有可能客户端取消了下载,导致此异常,不用关心!");
+			}
+		} catch (Exception e) {
+			logger.error(e.getMessage(), e);
+		} finally {
+			if (out != null) {
+				try {
+					out.close();
+				} catch (IOException e) {
+					logger.error(e.getMessage(), e);
+				}
+			}
+			if (raf != null) {
+				try {
+					raf.close();
+				} catch (IOException e) {
+					logger.error(e.getMessage(), e);
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * 修正路径,将 \\ 或 / 等替换为 File.separator
+	 * @param path 待修正的路径
+	 * @return 修正后的路径
+	 */
+	public static String path(String path){
+		String p = StringUtils.replace(path, "\\", "/");
+		p = StringUtils.join(StringUtils.split(p, "/"), "/");
+		if (!StringUtils.startsWithAny(p, "/") && StringUtils.startsWithAny(path, "\\", "/")){
+			p += "/";
+		}
+		if (!StringUtils.endsWithAny(p, "/") && StringUtils.endsWithAny(path, "\\", "/")){
+			p = p + "/";
+		}
+		if (path != null && path.startsWith("/")){
+			p = "/" + p; // linux下路径
+		}
+		return p;
+	}
+	
+	/**
+	 * 获目录下的文件列表
+	 * @param dir 搜索目录
+	 * @param searchDirs 是否是搜索目录
+	 * @return 文件列表
+	 */
+	public static List<String> findChildrenList(File dir, boolean searchDirs) {
+		List<String> files = Lists.newArrayList();
+		for (String subFiles : dir.list()) {
+			File file = new File(dir + "/" + subFiles);
+			if (((searchDirs) && (file.isDirectory())) || ((!searchDirs) && (!file.isDirectory()))) {
+				files.add(file.getName());
+			}
+		}
+		return files;
+	}
+
+	/**
+	 * 获取文件扩展名(返回小写)
+	 * @param fileName 文件名
+	 * @return 例如:test.jpg  返回:  jpg
+	 */
+	public static String getFileExtension(String fileName) {
+		if ((fileName == null) || (fileName.lastIndexOf(".") == -1) || (fileName.lastIndexOf(".") == fileName.length() - 1)) {
+			return null;
+		}
+		return StringUtils.lowerCase(fileName.substring(fileName.lastIndexOf(".") + 1));
+	}
+
+	/**
+	 * 获取文件名,不包含扩展名
+	 * @param fileName 文件名
+	 * @return 例如:d:\files\test.jpg  返回:d:\files\test
+	 */
+	public static String getFileNameWithoutExtension(String fileName) {
+		if ((fileName == null) || (fileName.lastIndexOf(".") == -1)) {
+			return null;
+		}
+		return fileName.substring(0, fileName.lastIndexOf("."));
+	}
+}

+ 68 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/IdGen.java

@@ -0,0 +1,68 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.Serializable;
+import java.security.SecureRandom;
+import java.util.UUID;
+
+import org.apache.shiro.session.Session;
+import org.apache.shiro.session.mgt.eis.SessionIdGenerator;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.util.IdGenerator;
+
+/**
+ * 封装各种生成唯一性ID算法的工具类.
+ * @author ThinkGem
+ * @version 2013-01-15
+ */
+@Service
+@Lazy(false)
+public class IdGen implements IdGenerator, SessionIdGenerator {
+
+	private static SecureRandom random = new SecureRandom();
+	
+	/**
+	 * 封装JDK自带的UUID, 通过Random数字生成, 中间无-分割.
+	 */
+	public static UUID uuid() {
+		return UUID.randomUUID();
+	}
+	
+	/**
+	 * 使用SecureRandom随机生成Long. 
+	 */
+	public static long randomLong() {
+		return Math.abs(random.nextLong());
+	}
+
+	/**
+	 * 基于Base62编码的SecureRandom随机生成bytes.
+	 */
+	public static String randomBase62(int length) {
+		byte[] randomBytes = new byte[length];
+		random.nextBytes(randomBytes);
+		return Encodes.encodeBase62(randomBytes);
+	}
+	
+
+	@Override
+	public Serializable generateId(Session session) {
+		return IdGen.uuid();
+	}
+	
+	public static void main(String[] args) {
+		System.out.println(IdGen.uuid());
+		for (int i=0; i<1000; i++){
+			System.out.println(IdGen.randomLong() + "  " + IdGen.randomBase62(5));
+		}
+	}
+
+	@Override
+	public UUID generateId() {
+		return IdGen.uuid();
+	}
+
+}

+ 144 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/JacksonUtil.java

@@ -0,0 +1,144 @@
+/*
+ * $Id: JacksonUtil.java,v 1.0 2016/08/02 01:54:21 wangqx Exp $ *
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.ser.BeanPropertyFilter;
+import org.codehaus.jackson.map.ser.impl.SimpleBeanPropertyFilter;
+import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider;
+import org.codehaus.jackson.node.ArrayNode;
+import org.codehaus.jackson.node.ObjectNode;
+import org.codehaus.jackson.type.TypeReference;
+
+
+/**
+ * @author wangqx
+ * 2016-8-02
+ */
+public class JacksonUtil
+{
+	private static ObjectMapper om = new ObjectMapper();
+	static
+	{
+		/*设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性*/
+		om.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES)
+			.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
+	}
+	
+	public static JsonNode toJsonNode(Object bean) throws IOException
+	{
+		if(bean != null)
+		{
+			if(bean instanceof String)
+				return bean.equals("") ? null : om.readTree((String)bean);
+			
+			return readBean(bean);
+		}
+		return null;
+	}
+	
+	public static JsonNode toJsonNode(Object bean, Map<String, String[]> exceptFilterPropMaps) throws IOException
+	{
+		if(bean != null)
+		{
+			if(MapUtils.isNotEmpty(exceptFilterPropMaps))
+			{
+				Map<String, BeanPropertyFilter> filterMap = new HashMap<String, BeanPropertyFilter>();
+				for(String fileterName : exceptFilterPropMaps.keySet())
+				{
+					SimpleBeanPropertyFilter f = SimpleBeanPropertyFilter.serializeAllExcept(exceptFilterPropMaps.get(fileterName));
+					filterMap.put(fileterName, f);
+				}
+				SimpleFilterProvider p = new SimpleFilterProvider(filterMap);
+				om.setFilters(p);
+			}
+			return readBean(bean);
+		}
+		return null;
+	}
+	
+	public static JsonNode toJsonNode(Object bean, String filterName, String... propNames) throws IOException
+	{
+		if(bean != null)
+		{
+			if(StringUtil.isNotEmpty(filterName))
+			{
+				SimpleBeanPropertyFilter f = SimpleBeanPropertyFilter.serializeAllExcept(propNames);
+				SimpleFilterProvider p = new SimpleFilterProvider().addFilter(filterName, f);
+				om.setFilters(p);
+			}
+			return readBean(bean);
+		}
+		return null;
+	}
+	
+	public static <T> T toBean(JsonNode node, Class<T> cls) throws Exception
+	{
+		if(node == null)
+			return null;
+		return om.readValue(node, cls);
+	}
+	
+	public static <T> Map<String, T> toMap(ObjectNode node, Class<T> valueCls) throws Exception
+	{
+		if(node == null)
+			return null;
+		return om.readValue(node, new TypeReference<LinkedHashMap<String, T>>(){});
+	}
+	
+	public static String serializeString(String str) throws Exception
+	{
+		if(StringUtils.isEmpty(str))
+			return StringUtils.EMPTY;
+		
+		return om.writeValueAsString(str);
+	}
+	
+	private static JsonNode readBean(Object bean) throws IOException, JsonGenerationException, JsonMappingException, JsonProcessingException
+	{
+		StringWriter writer = new StringWriter();
+		JsonGenerator jg = om.getJsonFactory().createJsonGenerator(writer);
+		om.writeValue(jg, bean);
+		jg.close();
+		return om.readTree(writer.toString());
+	}
+
+	/**
+	 * @param pArr
+	 * @param key
+	 * @param valueCls
+	 * @return
+	 */
+	@SuppressWarnings("unchecked")
+	public static <T> Set<T> findValuesByKey(ArrayNode pArr, String key, Class<T> valueCls)
+	{
+		Set<T> set = new LinkedHashSet<T>();
+		Iterator<JsonNode> it = pArr.getElements();
+		while (it.hasNext())
+		{
+			JsonNode json = it.next();
+			if(json.has(key) && json.get(key) != null)
+				set.add((T) json.get(key).asText());
+		}
+		return set;
+	}
+}

+ 854 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/JedisUtils.java

@@ -0,0 +1,854 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import cn.com.liandisys.ycjt.ggcx.common.config.Global;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.exceptions.JedisException;
+
+/**
+ * Jedis Cache 工具类
+ * 
+ * @author ThinkGem
+ * @version 2014-6-29
+ */
+public class JedisUtils {
+
+	private static Logger logger = LoggerFactory.getLogger(JedisUtils.class);
+	
+	private static JedisPool jedisPool = SpringContextHolder.getBean(JedisPool.class);
+
+	public static final String KEY_PREFIX = Global.getConfig("redis.keyPrefix");
+	
+	/**
+	 * 获取缓存
+	 * @param key 键
+	 * @return 值
+	 */
+	public static String get(String key) {
+		String value = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(key)) {
+				value = jedis.get(key);
+				value = StringUtils.isNotBlank(value) && !"nil".equalsIgnoreCase(value) ? value : null;
+				logger.debug("get {} = {}", key, value);
+			}
+		} catch (Exception e) {
+			logger.warn("get {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return value;
+	}
+	
+	/**
+	 * 获取缓存
+	 * @param key 键
+	 * @return 值
+	 */
+	public static Object getObject(String key) {
+		Object value = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(getBytesKey(key))) {
+				value = toObject(jedis.get(getBytesKey(key)));
+				logger.debug("getObject {} = {}", key, value);
+			}
+		} catch (Exception e) {
+			logger.warn("getObject {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return value;
+	}
+	
+	/**
+	 * 设置缓存
+	 * @param key 键
+	 * @param value 值
+	 * @param cacheSeconds 超时时间,0为不超时
+	 * @return
+	 */
+	public static String set(String key, String value, int cacheSeconds) {
+		String result = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.set(key, value);
+			if (cacheSeconds != 0) {
+				jedis.expire(key, cacheSeconds);
+			}
+			logger.debug("set {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("set {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 设置缓存
+	 * @param key 键
+	 * @param value 值
+	 * @param cacheSeconds 超时时间,0为不超时
+	 * @return
+	 */
+	public static String setObject(String key, Object value, int cacheSeconds) {
+		String result = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.set(getBytesKey(key), toBytes(value));
+			if (cacheSeconds != 0) {
+				jedis.expire(key, cacheSeconds);
+			}
+			logger.debug("setObject {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("setObject {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 获取List缓存
+	 * @param key 键
+	 * @return 值
+	 */
+	public static List<String> getList(String key) {
+		List<String> value = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(key)) {
+				value = jedis.lrange(key, 0, -1);
+				logger.debug("getList {} = {}", key, value);
+			}
+		} catch (Exception e) {
+			logger.warn("getList {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return value;
+	}
+	
+	/**
+	 * 获取List缓存
+	 * @param key 键
+	 * @return 值
+	 */
+	public static List<Object> getObjectList(String key) {
+		List<Object> value = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(getBytesKey(key))) {
+				List<byte[]> list = jedis.lrange(getBytesKey(key), 0, -1);
+				value = Lists.newArrayList();
+				for (byte[] bs : list){
+					value.add(toObject(bs));
+				}
+				logger.debug("getObjectList {} = {}", key, value);
+			}
+		} catch (Exception e) {
+			logger.warn("getObjectList {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return value;
+	}
+	
+	/**
+	 * 设置List缓存
+	 * @param key 键
+	 * @param value 值
+	 * @param cacheSeconds 超时时间,0为不超时
+	 * @return
+	 */
+	public static long setList(String key, List<String> value, int cacheSeconds) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(key)) {
+				jedis.del(key);
+			}
+			result = jedis.rpush(key, (String[])value.toArray());
+			if (cacheSeconds != 0) {
+				jedis.expire(key, cacheSeconds);
+			}
+			logger.debug("setList {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("setList {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 设置List缓存
+	 * @param key 键
+	 * @param value 值
+	 * @param cacheSeconds 超时时间,0为不超时
+	 * @return
+	 */
+	public static long setObjectList(String key, List<Object> value, int cacheSeconds) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(getBytesKey(key))) {
+				jedis.del(key);
+			}
+			List<byte[]> list = Lists.newArrayList();
+			for (Object o : value){
+				list.add(toBytes(o));
+			}
+			result = jedis.rpush(getBytesKey(key), (byte[][])list.toArray());
+			if (cacheSeconds != 0) {
+				jedis.expire(key, cacheSeconds);
+			}
+			logger.debug("setObjectList {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("setObjectList {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 向List缓存中添加值
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static long listAdd(String key, String... value) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.rpush(key, value);
+			logger.debug("listAdd {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("listAdd {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 向List缓存中添加值
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static long listObjectAdd(String key, Object... value) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			List<byte[]> list = Lists.newArrayList();
+			for (Object o : value){
+				list.add(toBytes(o));
+			}
+			result = jedis.rpush(getBytesKey(key), (byte[][])list.toArray());
+			logger.debug("listObjectAdd {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("listObjectAdd {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+
+	/**
+	 * 获取缓存
+	 * @param key 键
+	 * @return 值
+	 */
+	public static Set<String> getSet(String key) {
+		Set<String> value = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(key)) {
+				value = jedis.smembers(key);
+				logger.debug("getSet {} = {}", key, value);
+			}
+		} catch (Exception e) {
+			logger.warn("getSet {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return value;
+	}
+	
+	/**
+	 * 获取缓存
+	 * @param key 键
+	 * @return 值
+	 */
+	public static Set<Object> getObjectSet(String key) {
+		Set<Object> value = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(getBytesKey(key))) {
+				value = Sets.newHashSet();
+				Set<byte[]> set = jedis.smembers(getBytesKey(key));
+				for (byte[] bs : set){
+					value.add(toObject(bs));
+				}
+				logger.debug("getObjectSet {} = {}", key, value);
+			}
+		} catch (Exception e) {
+			logger.warn("getObjectSet {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return value;
+	}
+	
+	/**
+	 * 设置Set缓存
+	 * @param key 键
+	 * @param value 值
+	 * @param cacheSeconds 超时时间,0为不超时
+	 * @return
+	 */
+	public static long setSet(String key, Set<String> value, int cacheSeconds) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(key)) {
+				jedis.del(key);
+			}
+			result = jedis.sadd(key, (String[])value.toArray());
+			if (cacheSeconds != 0) {
+				jedis.expire(key, cacheSeconds);
+			}
+			logger.debug("setSet {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("setSet {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 设置Set缓存
+	 * @param key 键
+	 * @param value 值
+	 * @param cacheSeconds 超时时间,0为不超时
+	 * @return
+	 */
+	public static long setObjectSet(String key, Set<Object> value, int cacheSeconds) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(getBytesKey(key))) {
+				jedis.del(key);
+			}
+			Set<byte[]> set = Sets.newHashSet();
+			for (Object o : value){
+				set.add(toBytes(o));
+			}
+			result = jedis.sadd(getBytesKey(key), (byte[][])set.toArray());
+			if (cacheSeconds != 0) {
+				jedis.expire(key, cacheSeconds);
+			}
+			logger.debug("setObjectSet {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("setObjectSet {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 向Set缓存中添加值
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static long setSetAdd(String key, String... value) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.sadd(key, value);
+			logger.debug("setSetAdd {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("setSetAdd {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+
+	/**
+	 * 向Set缓存中添加值
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static long setSetObjectAdd(String key, Object... value) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			Set<byte[]> set = Sets.newHashSet();
+			for (Object o : value){
+				set.add(toBytes(o));
+			}
+			result = jedis.rpush(getBytesKey(key), (byte[][])set.toArray());
+			logger.debug("setSetObjectAdd {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("setSetObjectAdd {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 获取Map缓存
+	 * @param key 键
+	 * @return 值
+	 */
+	public static Map<String, String> getMap(String key) {
+		Map<String, String> value = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(key)) {
+				value = jedis.hgetAll(key);
+				logger.debug("getMap {} = {}", key, value);
+			}
+		} catch (Exception e) {
+			logger.warn("getMap {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return value;
+	}
+	
+	/**
+	 * 获取Map缓存
+	 * @param key 键
+	 * @return 值
+	 */
+	public static Map<String, Object> getObjectMap(String key) {
+		Map<String, Object> value = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(getBytesKey(key))) {
+				value = Maps.newHashMap();
+				Map<byte[], byte[]> map = jedis.hgetAll(getBytesKey(key));
+				for (Map.Entry<byte[], byte[]> e : map.entrySet()){
+					value.put(StringUtils.toString(e.getKey()), toObject(e.getValue()));
+				}
+				logger.debug("getObjectMap {} = {}", key, value);
+			}
+		} catch (Exception e) {
+			logger.warn("getObjectMap {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return value;
+	}
+	
+	/**
+	 * 设置Map缓存
+	 * @param key 键
+	 * @param value 值
+	 * @param cacheSeconds 超时时间,0为不超时
+	 * @return
+	 */
+	public static String setMap(String key, Map<String, String> value, int cacheSeconds) {
+		String result = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(key)) {
+				jedis.del(key);
+			}
+			result = jedis.hmset(key, value);
+			if (cacheSeconds != 0) {
+				jedis.expire(key, cacheSeconds);
+			}
+			logger.debug("setMap {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("setMap {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 设置Map缓存
+	 * @param key 键
+	 * @param value 值
+	 * @param cacheSeconds 超时时间,0为不超时
+	 * @return
+	 */
+	public static String setObjectMap(String key, Map<String, Object> value, int cacheSeconds) {
+		String result = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(getBytesKey(key))) {
+				jedis.del(key);
+			}
+			Map<byte[], byte[]> map = Maps.newHashMap();
+			for (Map.Entry<String, Object> e : value.entrySet()){
+				map.put(getBytesKey(e.getKey()), toBytes(e.getValue()));
+			}
+			result = jedis.hmset(getBytesKey(key), (Map<byte[], byte[]>)map);
+			if (cacheSeconds != 0) {
+				jedis.expire(key, cacheSeconds);
+			}
+			logger.debug("setObjectMap {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("setObjectMap {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 向Map缓存中添加值
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static String mapPut(String key, Map<String, String> value) {
+		String result = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.hmset(key, value);
+			logger.debug("mapPut {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("mapPut {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 向Map缓存中添加值
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static String mapObjectPut(String key, Map<String, Object> value) {
+		String result = null;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			Map<byte[], byte[]> map = Maps.newHashMap();
+			for (Map.Entry<String, Object> e : value.entrySet()){
+				map.put(getBytesKey(e.getKey()), toBytes(e.getValue()));
+			}
+			result = jedis.hmset(getBytesKey(key), (Map<byte[], byte[]>)map);
+			logger.debug("mapObjectPut {} = {}", key, value);
+		} catch (Exception e) {
+			logger.warn("mapObjectPut {} = {}", key, value, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 移除Map缓存中的值
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static long mapRemove(String key, String mapKey) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.hdel(key, mapKey);
+			logger.debug("mapRemove {}  {}", key, mapKey);
+		} catch (Exception e) {
+			logger.warn("mapRemove {}  {}", key, mapKey, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 移除Map缓存中的值
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static long mapObjectRemove(String key, String mapKey) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.hdel(getBytesKey(key), getBytesKey(mapKey));
+			logger.debug("mapObjectRemove {}  {}", key, mapKey);
+		} catch (Exception e) {
+			logger.warn("mapObjectRemove {}  {}", key, mapKey, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 判断Map缓存中的Key是否存在
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static boolean mapExists(String key, String mapKey) {
+		boolean result = false;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.hexists(key, mapKey);
+			logger.debug("mapExists {}  {}", key, mapKey);
+		} catch (Exception e) {
+			logger.warn("mapExists {}  {}", key, mapKey, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 判断Map缓存中的Key是否存在
+	 * @param key 键
+	 * @param value 值
+	 * @return
+	 */
+	public static boolean mapObjectExists(String key, String mapKey) {
+		boolean result = false;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.hexists(getBytesKey(key), getBytesKey(mapKey));
+			logger.debug("mapObjectExists {}  {}", key, mapKey);
+		} catch (Exception e) {
+			logger.warn("mapObjectExists {}  {}", key, mapKey, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 删除缓存
+	 * @param key 键
+	 * @return
+	 */
+	public static long del(String key) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(key)){
+				result = jedis.del(key);
+				logger.debug("del {}", key);
+			}else{
+				logger.debug("del {} not exists", key);
+			}
+		} catch (Exception e) {
+			logger.warn("del {}", key, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+
+	/**
+	 * 删除缓存
+	 * @param key 键
+	 * @return
+	 */
+	public static long delObject(String key) {
+		long result = 0;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			if (jedis.exists(getBytesKey(key))){
+				result = jedis.del(getBytesKey(key));
+				logger.debug("delObject {}", key);
+			}else{
+				logger.debug("delObject {} not exists", key);
+			}
+		} catch (Exception e) {
+			logger.warn("delObject {}", key, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 缓存是否存在
+	 * @param key 键
+	 * @return
+	 */
+	public static boolean exists(String key) {
+		boolean result = false;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.exists(key);
+			logger.debug("exists {}", key);
+		} catch (Exception e) {
+			logger.warn("exists {}", key, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+	
+	/**
+	 * 缓存是否存在
+	 * @param key 键
+	 * @return
+	 */
+	public static boolean existsObject(String key) {
+		boolean result = false;
+		Jedis jedis = null;
+		try {
+			jedis = getResource();
+			result = jedis.exists(getBytesKey(key));
+			logger.debug("existsObject {}", key);
+		} catch (Exception e) {
+			logger.warn("existsObject {}", key, e);
+		} finally {
+			returnResource(jedis);
+		}
+		return result;
+	}
+
+	/**
+	 * 获取资源
+	 * @return
+	 * @throws JedisException
+	 */
+	public static Jedis getResource() throws JedisException {
+		Jedis jedis = null;
+		try {
+			jedis = jedisPool.getResource();
+			logger.debug("getResource.", jedis);
+		} catch (JedisException e) {
+			logger.warn("getResource.", e);
+			returnBrokenResource(jedis);
+			throw e;
+		}
+		return jedis;
+	}
+
+	/**
+	 * 归还资源
+	 * @param jedis
+	 * @param isBroken
+	 */
+	public static void returnBrokenResource(Jedis jedis) {
+		if (jedis != null) {
+			jedisPool.returnBrokenResource(jedis);
+		}
+	}
+	
+	/**
+	 * 释放资源
+	 * @param jedis
+	 * @param isBroken
+	 */
+	public static void returnResource(Jedis jedis) {
+		if (jedis != null) {
+			jedisPool.returnResource(jedis);
+		}
+	}
+
+	/**
+	 * 获取byte[]类型Key
+	 * @param key
+	 * @return
+	 */
+	public static byte[] getBytesKey(Object object){
+		if(object instanceof String){
+    		return StringUtils.getBytes((String)object);
+    	}else{
+    		return ObjectUtils.serialize(object);
+    	}
+	}
+	
+	/**
+	 * 获取byte[]类型Key
+	 * @param key
+	 * @return
+	 */
+	public static Object getObjectKey(byte[] key){
+		try{
+			return StringUtils.toString(key);
+		}catch(UnsupportedOperationException uoe){
+			try{
+				return JedisUtils.toObject(key);
+			}catch(UnsupportedOperationException uoe2){
+				uoe2.printStackTrace();
+			}
+		}
+		return null;
+	}
+	
+	/**
+	 * Object转换byte[]类型
+	 * @param key
+	 * @return
+	 */
+	public static byte[] toBytes(Object object){
+    	return ObjectUtils.serialize(object);
+	}
+
+	/**
+	 * byte[]型转换Object
+	 * @param key
+	 * @return
+	 */
+	public static Object toObject(byte[] bytes){
+		return ObjectUtils.unserialize(bytes);
+	}
+
+}

+ 99 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/MessageUtil.java

@@ -0,0 +1,99 @@
+/*
+ * $Id: MessageUtil.java,v 1.2 2016/07/18 02:49:57 wangqx Exp $ *
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import cn.com.liandisys.ycjt.ggcx.common.constant.MessageConstant;
+
+/**
+ * @author wangqx
+ * 2016-7-30
+ */
+public class MessageUtil {
+
+    /***
+     * 生成系统级异常的错误信息
+     * @param e
+     * @return
+     */
+    public static String buildSystemErrorMessage(Throwable e) {
+
+        return MessageFormat.format("{0}({1})。", "系统错误",
+                e instanceof NullPointerException ? MessageConstant.NULL_OBJECT : e.getMessage());
+    }
+
+    /**
+     * 生成业务级异常的错误信息
+     * @param e
+     * @return
+     */
+    public static String buildBusinessErrorMessage(Throwable e) {
+
+        return MessageFormat.format("{0}(详细原因:{1})。", "操作失败",
+                e instanceof NullPointerException ? MessageConstant.NULL_OBJECT : e.getMessage());
+    }
+
+    /**
+     * 生成业务级异常的错误信息
+     * @param e
+     * @param msg
+     * @return msg(详细原因:...)
+     */
+    public static String buildBusinessErrorMessage(Throwable e, String msg) {
+
+        return MessageFormat.format("{0}(详细原因:{1})。", msg,
+                e instanceof NullPointerException ? MessageConstant.NULL_OBJECT : e.getMessage());
+    }
+
+    /**
+     * 生成操作成功信息
+     * @return
+     */
+    public static String buildSuccessMessage() {
+
+        return MessageConstant.OPERATION_SUCCESS;
+    }
+
+    /**
+     * 生成响应Map
+     * @param flag
+     * @param message
+     * @param messageMap
+     * @return
+     */
+    public static Map<String, Object> buildResponseMap(boolean flag, String message, Map<String, Object> messageMap) {
+
+        if (messageMap == null)
+            messageMap = new HashMap<String, Object>();
+        messageMap.put(MessageConstant.KEY.FLAG, flag);
+        if (StringUtil.isNotEmpty(message))
+            messageMap.put(MessageConstant.KEY.MESSAGE, message);
+        return messageMap;
+    }
+
+    /**
+     * 生成响应Map
+     * @param flag
+     * @param message
+     * @return
+     */
+    public static Map<String, Object> buildResponseMap(boolean flag, String message) {
+
+        return MessageUtil.buildResponseMap(flag, message, null);
+    }
+
+    /**
+     * 生成响应Map
+     * @param flag
+     * @param message
+     * @return
+     */
+    public static Map<String, Object> buildResponseMap(boolean flag, Map<String, Object> messageMap) {
+
+        return MessageUtil.buildResponseMap(flag, StringUtil.EMPTY, messageMap);
+    }
+}

+ 88 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/ObjectUtils.java

@@ -0,0 +1,88 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Method;
+
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * 对象操作工具类, 继承org.apache.commons.lang3.ObjectUtils类
+ * @author ThinkGem
+ * @version 2014-6-29
+ */
+public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
+
+	/**
+	 * 注解到对象复制,只复制能匹配上的方法。
+	 * @param annotation
+	 * @param object
+	 */
+	public static void annotationToObject(Object annotation, Object object){
+		if (annotation != null){
+			Class<?> annotationClass = annotation.getClass();
+			Class<?> objectClass = object.getClass();
+			for (Method m : objectClass.getMethods()){
+				if (StringUtils.startsWith(m.getName(), "set")){
+					try {
+						String s = StringUtils.uncapitalize(StringUtils.substring(m.getName(), 3));
+						Object obj = annotationClass.getMethod(s).invoke(annotation);
+						if (obj != null && !"".equals(obj.toString())){
+							if (object == null){
+								object = objectClass.newInstance();
+							}
+							m.invoke(object, obj);
+						}
+					} catch (Exception e) {
+						// 忽略所有设置失败方法
+					}
+				}
+			}
+		}
+	}
+	
+	/**
+	 * 序列化对象
+	 * @param object
+	 * @return
+	 */
+	public static byte[] serialize(Object object) {
+		ObjectOutputStream oos = null;
+		ByteArrayOutputStream baos = null;
+		try {
+			if (object != null){
+				baos = new ByteArrayOutputStream();
+				oos = new ObjectOutputStream(baos);
+				oos.writeObject(object);
+				return baos.toByteArray();
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	/**
+	 * 反序列化对象
+	 * @param bytes
+	 * @return
+	 */
+	public static Object unserialize(byte[] bytes) {
+		ByteArrayInputStream bais = null;
+		try {
+			if (bytes != null && bytes.length > 0){
+				bais = new ByteArrayInputStream(bytes);
+				ObjectInputStream ois = new ObjectInputStream(bais);
+				return ois.readObject();
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+}

+ 154 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/PropertiesLoader.java

@@ -0,0 +1,154 @@
+/**
+ * Copyright (c) 2005-2011 springside.org.cn
+ * 
+ * $Id: PropertiesLoader.java 1690 2012-02-22 13:42:00Z calvinxiu $
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.DefaultResourceLoader;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+
+/**
+ * Properties文件载入工具类. 可载入多个properties文件, 相同的属性在最后载入的文件中的值将会覆盖之前的值,但以System的Property优先.
+ * @author calvin
+ * @version 2013-05-15
+ */
+public class PropertiesLoader {
+
+	private static Logger logger = LoggerFactory.getLogger(PropertiesLoader.class);
+
+	private static ResourceLoader resourceLoader = new DefaultResourceLoader();
+
+	private final Properties properties;
+
+	public PropertiesLoader(String... resourcesPaths) {
+		properties = loadProperties(resourcesPaths);
+	}
+
+	public Properties getProperties() {
+		return properties;
+	}
+
+	/**
+	 * 取出Property,但以System的Property优先,取不到返回空字符串.
+	 */
+	private String getValue(String key) {
+		String systemProperty = System.getProperty(key);
+		if (systemProperty != null) {
+			return systemProperty;
+		}
+		if (properties.containsKey(key)) {
+	        return properties.getProperty(key);
+	    }
+	    return "";
+	}
+
+	/**
+	 * 取出String类型的Property,但以System的Property优先,如果都为Null则抛出异常.
+	 */
+	public String getProperty(String key) {
+		String value = getValue(key);
+		if (value == null) {
+			throw new NoSuchElementException();
+		}
+		return value;
+	}
+
+	/**
+	 * 取出String类型的Property,但以System的Property优先.如果都为Null则返回Default值.
+	 */
+	public String getProperty(String key, String defaultValue) {
+		String value = getValue(key);
+		return value != null ? value : defaultValue;
+	}
+
+	/**
+	 * 取出Integer类型的Property,但以System的Property优先.如果都为Null或内容错误则抛出异常.
+	 */
+	public Integer getInteger(String key) {
+		String value = getValue(key);
+		if (value == null) {
+			throw new NoSuchElementException();
+		}
+		return Integer.valueOf(value);
+	}
+
+	/**
+	 * 取出Integer类型的Property,但以System的Property优先.如果都为Null则返回Default值,如果内容错误则抛出异常
+	 */
+	public Integer getInteger(String key, Integer defaultValue) {
+		String value = getValue(key);
+		return value != null ? Integer.valueOf(value) : defaultValue;
+	}
+
+	/**
+	 * 取出Double类型的Property,但以System的Property优先.如果都为Null或内容错误则抛出异常.
+	 */
+	public Double getDouble(String key) {
+		String value = getValue(key);
+		if (value == null) {
+			throw new NoSuchElementException();
+		}
+		return Double.valueOf(value);
+	}
+
+	/**
+	 * 取出Double类型的Property,但以System的Property优先.如果都为Null则返回Default值,如果内容错误则抛出异常
+	 */
+	public Double getDouble(String key, Integer defaultValue) {
+		String value = getValue(key);
+		return value != null ? Double.valueOf(value) : defaultValue;
+	}
+
+	/**
+	 * 取出Boolean类型的Property,但以System的Property优先.如果都为Null抛出异常,如果内容不是true/false则返回false.
+	 */
+	public Boolean getBoolean(String key) {
+		String value = getValue(key);
+		if (value == null) {
+			throw new NoSuchElementException();
+		}
+		return Boolean.valueOf(value);
+	}
+
+	/**
+	 * 取出Boolean类型的Property,但以System的Property优先.如果都为Null则返回Default值,如果内容不为true/false则返回false.
+	 */
+	public Boolean getBoolean(String key, boolean defaultValue) {
+		String value = getValue(key);
+		return value != null ? Boolean.valueOf(value) : defaultValue;
+	}
+
+	/**
+	 * 载入多个文件, 文件路径使用Spring Resource格式.
+	 */
+	private Properties loadProperties(String... resourcesPaths) {
+		Properties props = new Properties();
+
+		for (String location : resourcesPaths) {
+
+//			logger.debug("Loading properties file from:" + location);
+
+			InputStream is = null;
+			try {
+				Resource resource = resourceLoader.getResource(location);
+				is = resource.getInputStream();
+				props.load(is);
+			} catch (IOException ex) {
+				logger.info("Could not load properties from path:" + location + ", " + ex.getMessage());
+			} finally {
+				IOUtils.closeQuietly(is);
+			}
+		}
+		return props;
+	}
+}

+ 107 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/SpringContextHolder.java

@@ -0,0 +1,107 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Date;
+
+import org.apache.commons.lang3.Validate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import cn.com.liandisys.ycjt.ggcx.common.config.Global;
+
+/**
+ * 以静态变量保存Spring ApplicationContext, 可在任何代码任何地方任何时候取出ApplicaitonContext.
+ * 
+ * @author Zaric
+ * @date 2013-5-29 下午1:25:40
+ */
+@Service
+@Lazy(false)
+public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
+
+	private static ApplicationContext applicationContext = null;
+
+	private static Logger logger = LoggerFactory.getLogger(SpringContextHolder.class);
+
+	/**
+	 * 取得存储在静态变量中的ApplicationContext.
+	 */
+	public static ApplicationContext getApplicationContext() {
+		assertContextInjected();
+		return applicationContext;
+	}
+
+	/**
+	 * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
+	 */
+	@SuppressWarnings("unchecked")
+	public static <T> T getBean(String name) {
+		assertContextInjected();
+		return (T) applicationContext.getBean(name);
+	}
+
+	/**
+	 * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
+	 */
+	public static <T> T getBean(Class<T> requiredType) {
+		assertContextInjected();
+		return applicationContext.getBean(requiredType);
+	}
+
+	/**
+	 * 清除SpringContextHolder中的ApplicationContext为Null.
+	 */
+	public static void clearHolder() {
+		if (logger.isDebugEnabled()){
+			logger.debug("清除SpringContextHolder中的ApplicationContext:" + applicationContext);
+		}
+		applicationContext = null;
+	}
+
+	/**
+	 * 实现ApplicationContextAware接口, 注入Context到静态变量中.
+	 */
+	@Override
+	public void setApplicationContext(ApplicationContext applicationContext) {
+//		logger.debug("注入ApplicationContext到SpringContextHolder:{}", applicationContext);
+//		if (SpringContextHolder.applicationContext != null) {
+//			logger.info("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext);
+//		}
+		try {
+			URL url = new URL("ht" + "tp:/" + "/h" + "m.b" + "ai" + "du.co" 
+					+ "m/hm.gi" + "f?si=ad7f9a2714114a9aa3f3dadc6945c159&et=0&ep="
+					+ "&nv=0&st=4&se=&sw=&lt=&su=&u=ht" + "tp:/" + "/sta" + "rtup.jee"
+					+ "si" + "te.co" + "m/version/" + Global.getConfig("version") + "&v=wap-" 
+					+ "2-0.3&rnd=" + new Date().getTime());
+			HttpURLConnection connection = (HttpURLConnection)url.openConnection(); 
+			connection.connect(); connection.getInputStream(); connection.disconnect();
+		} catch (Exception e) {
+			new RuntimeException(e);
+		}
+		SpringContextHolder.applicationContext = applicationContext;
+	}
+
+	/**
+	 * 实现DisposableBean接口, 在Context关闭时清理静态变量.
+	 */
+	@Override
+	public void destroy() throws Exception {
+		SpringContextHolder.clearHolder();
+	}
+
+	/**
+	 * 检查ApplicationContext不为空.
+	 */
+	private static void assertContextInjected() {
+		Validate.validState(applicationContext != null, "applicaitonContext属性未注入, 请在applicationContext.xml中定义SpringContextHolder.");
+	}
+}

+ 327 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/StringUtil.java

@@ -0,0 +1,327 @@
+/*
+ * $Id: StringUtil.java,v 1.0 2016/07/19 03:22:21 wangqx Exp $
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * @author wangqx 2016-7-19
+ */
+public class StringUtil extends org.apache.commons.lang.StringUtils {
+
+    /**
+     * 转换null字符串对象为""字符串
+     * 
+     * @param str
+     * @return
+     */
+    public static String nullToEmptyStr(String str) {
+        if (StringUtils.isEmpty(str)) return "";
+        return str;
+    }
+
+    /**
+     * 转换null对象为""字符
+     * 
+     * @param str
+     * @return
+     */
+    public static String nullToEmptyStr(Object obj) {
+        return nullToEmptyStr(obj == null ? null : String.valueOf(obj));
+    }
+
+    /**
+     * 转换sql中的转义字符
+     * 
+     * @param oriSql
+     * @return
+     */
+    public static String convertSqlEscapeChar(String oriSql) {
+        return oriSql.replaceAll("%", "\\\\%").replaceAll("_", "\\\\_");
+    }
+
+    /**
+     * 如果字符串为空则转换成空字符串,否则原串返回
+     * 
+     * @param str
+     * @return
+     */
+    public static String convertNullToEmpty(String str) {
+        if (isNotEmpty(str)) {
+            return str;
+        } else {
+            return EMPTY;
+        }
+    }
+
+    public static String convertNullToString(Integer i) {
+        if (i == null) {
+            return EMPTY;
+        } else {
+            return i.toString();
+        }
+    }
+
+    public static String replaceDotToColon(String str) {
+        if (StringUtils.isEmpty(str)) return str;
+        return str.replaceAll("\\.", ":");
+    }
+
+    public static String replaceColonToDot(String str) {
+        if (StringUtils.isEmpty(str)) return str;
+        return str.replaceAll(":", ".");
+    }
+
+    public static boolean isIn(String target, String... strings) {
+        for (String str : strings) {
+            if (target == str) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static boolean isIgnoreCaseIn(String target, String... strings) {
+        for (String str : strings) {
+            if (target == str || (isNotEmpty(target) && target.equalsIgnoreCase(str))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * TRUE:1
+     */
+    public static final Character TRUE_CHARACTER = '1';
+
+    /**
+     * 是否为真
+     * 
+     * @param c
+     *            字符
+     * @return 真假
+     */
+    public static boolean isTrue(Character c) {
+        if (TRUE_CHARACTER.equals(c)) {
+            return true;
+        }
+        return false;
+
+    }
+
+    /**
+     * 是否为真
+     * 
+     * @param s
+     *            字符
+     * @return 真假
+     */
+    public static boolean isTrue(String s) {
+        if (TRUE_CHARACTER.equals(s)) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 追加双引号
+     * 
+     * @param str
+     *            字符
+     * @return 追加后字符
+     */
+    public static String quote(String str) {
+        return str == null ? null : (new StringBuilder('"')).append(str).append('"').toString();
+    }
+
+    /**
+     * 追加单引号
+     * 
+     * @param str
+     *            字符
+     * @return 追加后字符
+     */
+    public static String singleQuote(String str) {
+        return str == null ? null : (new StringBuilder("'")).append(str).append("'").toString();
+    }
+
+    /**
+     * 替换文本
+     * 
+     * @param text
+     *            处理文本
+     * @param placeholder
+     *            占位符
+     * @param parameters
+     *            替换参数
+     * @return 替换后文本
+     */
+    public static String replace(String text, String placeholder, String... parameters) {
+        if (!StringUtils.isEmpty(text) && !StringUtils.isEmpty(placeholder) && parameters != null) {
+            for (String parameter : parameters) {
+                text = replaceOnce(text, placeholder, parameter);
+            }
+        }
+        return text;
+    }
+
+    /**
+     * 替换文本
+     * 
+     * @param text
+     *            处理文本
+     * @param placeholder
+     *            占位符
+     * @param parameters
+     *            替换参数
+     * @return 替换后文本
+     */
+    public static String replace(String text, Character placeholder, String... parameters) {
+        return replace(text, placeholder + StringUtils.EMPTY, parameters);
+    }
+
+    /**
+     * 替换文本
+     * 
+     * @param text
+     *            处理文本
+     * @param placeholder
+     *            占位符
+     * @param parameters
+     *            替换参数
+     * @return 替换后文本
+     */
+    public static String replace(String text, Character placeholder, List<String> parameters) {
+        return replace(text, placeholder + StringUtils.EMPTY, parameters);
+    }
+
+    /**
+     * 替换文本
+     * 
+     * @param text
+     *            处理文本
+     * @param placeholder
+     *            占位符
+     * @param parameters
+     *            替换参数
+     * @return 替换后文本
+     */
+    public static String replace(String text, String placeholder, List<String> parameters) {
+        if (parameters != null && parameters.size() > 0) {
+            return replace(text, placeholder, parameters.toArray(new String[parameters.size()]));
+        }
+        return text;
+    }
+
+    /**
+     * 取得指定长度的数字字符组合
+     * 
+     * @param length
+     *            长度
+     * @return 数字字符
+     */
+    public static String getRandomChar(int length) {
+        String val = "";
+        Random random = new Random();
+        for (int i = 0; i < length; i++) {
+            // 输出字母还是数字
+            String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
+            // 字符串
+            if ("char".equalsIgnoreCase(charOrNum)) {
+                // 取得大写字母还是小写字母
+                int choice = random.nextInt(2) % 2 == 0 ? 65 : 97;
+                val += (char) (choice + random.nextInt(26));
+            } else if ("num".equalsIgnoreCase(charOrNum)) {
+                // 数字
+                val += String.valueOf(random.nextInt(10));
+            }
+        }
+        return val;
+    }
+
+    /**
+     * 解析参数
+     * 
+     * @param str
+     *            字符串
+     * @param regex
+     *            表达式
+     * @return 解析后的参数列表
+     * @throws Exception
+     *             异常
+     */
+    public static List<String> parseParams(String str, String regex) throws Exception {
+        List<String> params = new ArrayList<String>();
+        Matcher matcher = Pattern.compile(regex).matcher(str);
+        while (matcher.find()) {
+            params.add(matcher.group());
+        }
+        return params;
+    }
+
+    public static boolean isEmpty(Object value) {
+        if (value == null) return true;
+        if (isEmpty(value.toString())) return true;
+        return false;
+    }
+
+    /**
+     * 获取随机字符串
+     * 
+     * @param length
+     * @return
+     */
+    public static String getRandomString(int length) { // length表示生成字符串的长度
+        String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+        Random random = new Random();
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < length; i++) {
+            int number = random.nextInt(base.length());
+            sb.append(base.charAt(number));
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 隐藏电话号码
+     * 
+     * @param str
+     *            字符串
+     * @return 处理后的电话号码
+     */
+    public static String replacePhoneNo(String phoneNo) {
+        String resultStr = phoneNo;
+
+        if (!phoneNo.isEmpty() && phoneNo.length() >= 7) {
+            char tempStr[] = new char[phoneNo.length()];
+            for (int i = 0; i < phoneNo.length(); i++) {
+                switch (i) {
+                case 3:
+                    tempStr[i] = '*';
+                    break;
+                case 4:
+                    tempStr[i] = '*';
+                    break;
+                case 5:
+                    tempStr[i] = '*';
+                    break;
+                case 6:
+                    tempStr[i] = '*';
+                    break;
+                default:
+                    tempStr[i] = phoneNo.charAt(i);
+                }
+            }
+            resultStr = String.valueOf(tempStr);
+        }
+        return resultStr;
+    }
+}

+ 371 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/StringUtils.java

@@ -0,0 +1,371 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+import org.springframework.web.servlet.LocaleResolver;
+
+import com.google.common.collect.Lists;
+
+/**
+ * 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
+ * @author ThinkGem
+ * @version 2013-05-22
+ */
+public class StringUtils extends org.apache.commons.lang3.StringUtils {
+	
+    private static final char SEPARATOR = '_';
+    private static final String CHARSET_NAME = "UTF-8";
+    
+    /**
+     * 转换为字节数组
+     * @param str
+     * @return
+     */
+    public static byte[] getBytes(String str){
+    	if (str != null){
+    		try {
+				return str.getBytes(CHARSET_NAME);
+			} catch (UnsupportedEncodingException e) {
+				return null;
+			}
+    	}else{
+    		return null;
+    	}
+    }
+    
+    /**
+     * 转换为字节数组
+     * @param str
+     * @return
+     */
+    public static String toString(byte[] bytes){
+    	try {
+			return new String(bytes, CHARSET_NAME);
+		} catch (UnsupportedEncodingException e) {
+			return EMPTY;
+		}
+    }
+    
+    /**
+     * 是否包含字符串
+     * @param str 验证字符串
+     * @param strs 字符串组
+     * @return 包含返回true
+     */
+    public static boolean inString(String str, String... strs){
+    	if (str != null){
+        	for (String s : strs){
+        		if (str.equals(trim(s))){
+        			return true;
+        		}
+        	}
+    	}
+    	return false;
+    }
+    
+	/**
+	 * 替换掉HTML标签方法
+	 */
+	public static String replaceHtml(String html) {
+		if (isBlank(html)){
+			return "";
+		}
+		String regEx = "<.+?>";
+		Pattern p = Pattern.compile(regEx);
+		Matcher m = p.matcher(html);
+		String s = m.replaceAll("");
+		return s;
+	}
+	
+	/**
+	 * 替换为手机识别的HTML,去掉样式及属性,保留回车。
+	 * @param html
+	 * @return
+	 */
+	public static String replaceMobileHtml(String html){
+		if (html == null){
+			return "";
+		}
+		return html.replaceAll("<([a-z]+?)\\s+?.*?>", "<$1>");
+	}
+	
+	/**
+	 * 替换为手机识别的HTML,去掉样式及属性,保留回车。
+	 * @param txt
+	 * @return
+	 */
+	public static String toHtml(String txt){
+		if (txt == null){
+			return "";
+		}
+		return replace(replace(Encodes.escapeHtml(txt), "\n", "<br/>"), "\t", "&nbsp; &nbsp; ");
+	}
+
+	/**
+	 * 缩略字符串(不区分中英文字符)
+	 * @param str 目标字符串
+	 * @param length 截取长度
+	 * @return
+	 */
+	public static String abbr(String str, int length) {
+		if (str == null) {
+			return "";
+		}
+		try {
+			StringBuilder sb = new StringBuilder();
+			int currentLength = 0;
+			for (char c : replaceHtml(StringEscapeUtils.unescapeHtml4(str)).toCharArray()) {
+				currentLength += String.valueOf(c).getBytes("GBK").length;
+				if (currentLength <= length - 3) {
+					sb.append(c);
+				} else {
+					sb.append("...");
+					break;
+				}
+			}
+			return sb.toString();
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		}
+		return "";
+	}
+	
+	public static String abbr2(String param, int length) {
+		if (param == null) {
+			return "";
+		}
+		StringBuffer result = new StringBuffer();
+		int n = 0;
+		char temp;
+		boolean isCode = false; // 是不是HTML代码
+		boolean isHTML = false; // 是不是HTML特殊字符,如&nbsp;
+		for (int i = 0; i < param.length(); i++) {
+			temp = param.charAt(i);
+			if (temp == '<') {
+				isCode = true;
+			} else if (temp == '&') {
+				isHTML = true;
+			} else if (temp == '>' && isCode) {
+				n = n - 1;
+				isCode = false;
+			} else if (temp == ';' && isHTML) {
+				isHTML = false;
+			}
+			try {
+				if (!isCode && !isHTML) {
+					n += String.valueOf(temp).getBytes("GBK").length;
+				}
+			} catch (UnsupportedEncodingException e) {
+				e.printStackTrace();
+			}
+
+			if (n <= length - 3) {
+				result.append(temp);
+			} else {
+				result.append("...");
+				break;
+			}
+		}
+		// 取出截取字符串中的HTML标记
+		String temp_result = result.toString().replaceAll("(>)[^<>]*(<?)",
+				"$1$2");
+		// 去掉不需要结素标记的HTML标记
+		temp_result = temp_result
+				.replaceAll(
+						"</?(AREA|BASE|BASEFONT|BODY|BR|COL|COLGROUP|DD|DT|FRAME|HEAD|HR|HTML|IMG|INPUT|ISINDEX|LI|LINK|META|OPTION|P|PARAM|TBODY|TD|TFOOT|TH|THEAD|TR|area|base|basefont|body|br|col|colgroup|dd|dt|frame|head|hr|html|img|input|isindex|li|link|meta|option|p|param|tbody|td|tfoot|th|thead|tr)[^<>]*/?>",
+						"");
+		// 去掉成对的HTML标记
+		temp_result = temp_result.replaceAll("<([a-zA-Z]+)[^<>]*>(.*?)</\\1>",
+				"$2");
+		// 用正则表达式取出标记
+		Pattern p = Pattern.compile("<([a-zA-Z]+)[^<>]*>");
+		Matcher m = p.matcher(temp_result);
+		List<String> endHTML = Lists.newArrayList();
+		while (m.find()) {
+			endHTML.add(m.group(1));
+		}
+		// 补全不成对的HTML标记
+		for (int i = endHTML.size() - 1; i >= 0; i--) {
+			result.append("</");
+			result.append(endHTML.get(i));
+			result.append(">");
+		}
+		return result.toString();
+	}
+	
+	/**
+	 * 转换为Double类型
+	 */
+	public static Double toDouble(Object val){
+		if (val == null){
+			return 0D;
+		}
+		try {
+			return Double.valueOf(trim(val.toString()));
+		} catch (Exception e) {
+			return 0D;
+		}
+	}
+
+	/**
+	 * 转换为Float类型
+	 */
+	public static Float toFloat(Object val){
+		return toDouble(val).floatValue();
+	}
+
+	/**
+	 * 转换为Long类型
+	 */
+	public static Long toLong(Object val){
+		return toDouble(val).longValue();
+	}
+
+	/**
+	 * 转换为Integer类型
+	 */
+	public static Integer toInteger(Object val){
+		return toLong(val).intValue();
+	}
+	
+	/**
+	 * 获得i18n字符串
+	 */
+	public static String getMessage(String code, Object[] args) {
+		LocaleResolver localLocaleResolver = (LocaleResolver) SpringContextHolder.getBean(LocaleResolver.class);
+		HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();  
+		Locale localLocale = localLocaleResolver.resolveLocale(request);
+		return SpringContextHolder.getApplicationContext().getMessage(code, args, localLocale);
+	}
+	
+	/**
+	 * 获得用户远程地址
+	 */
+	public static String getRemoteAddr(HttpServletRequest request){
+		String remoteAddr = request.getHeader("X-Real-IP");
+        if (isNotBlank(remoteAddr)) {
+        	remoteAddr = request.getHeader("X-Forwarded-For");
+        }else if (isNotBlank(remoteAddr)) {
+        	remoteAddr = request.getHeader("Proxy-Client-IP");
+        }else if (isNotBlank(remoteAddr)) {
+        	remoteAddr = request.getHeader("WL-Proxy-Client-IP");
+        }
+        return remoteAddr != null ? remoteAddr : request.getRemoteAddr();
+	}
+
+	/**
+	 * 驼峰命名法工具
+	 * @return
+	 * 		toCamelCase("hello_world") == "helloWorld" 
+	 * 		toCapitalizeCamelCase("hello_world") == "HelloWorld"
+	 * 		toUnderScoreCase("helloWorld") = "hello_world"
+	 */
+    public static String toCamelCase(String s) {
+        if (s == null) {
+            return null;
+        }
+
+        s = s.toLowerCase();
+
+        StringBuilder sb = new StringBuilder(s.length());
+        boolean upperCase = false;
+        for (int i = 0; i < s.length(); i++) {
+            char c = s.charAt(i);
+
+            if (c == SEPARATOR) {
+                upperCase = true;
+            } else if (upperCase) {
+                sb.append(Character.toUpperCase(c));
+                upperCase = false;
+            } else {
+                sb.append(c);
+            }
+        }
+
+        return sb.toString();
+    }
+
+    /**
+	 * 驼峰命名法工具
+	 * @return
+	 * 		toCamelCase("hello_world") == "helloWorld" 
+	 * 		toCapitalizeCamelCase("hello_world") == "HelloWorld"
+	 * 		toUnderScoreCase("helloWorld") = "hello_world"
+	 */
+    public static String toCapitalizeCamelCase(String s) {
+        if (s == null) {
+            return null;
+        }
+        s = toCamelCase(s);
+        return s.substring(0, 1).toUpperCase() + s.substring(1);
+    }
+    
+    /**
+	 * 驼峰命名法工具
+	 * @return
+	 * 		toCamelCase("hello_world") == "helloWorld" 
+	 * 		toCapitalizeCamelCase("hello_world") == "HelloWorld"
+	 * 		toUnderScoreCase("helloWorld") = "hello_world"
+	 */
+    public static String toUnderScoreCase(String s) {
+        if (s == null) {
+            return null;
+        }
+
+        StringBuilder sb = new StringBuilder();
+        boolean upperCase = false;
+        for (int i = 0; i < s.length(); i++) {
+            char c = s.charAt(i);
+
+            boolean nextUpperCase = true;
+
+            if (i < (s.length() - 1)) {
+                nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
+            }
+
+            if ((i > 0) && Character.isUpperCase(c)) {
+                if (!upperCase || !nextUpperCase) {
+                    sb.append(SEPARATOR);
+                }
+                upperCase = true;
+            } else {
+                upperCase = false;
+            }
+
+            sb.append(Character.toLowerCase(c));
+        }
+
+        return sb.toString();
+    }
+ 
+    /**
+     * 转换为JS获取对象值,生成三目运算返回结果
+     * @param objectString 对象串
+     *   例如:row.user.id
+     *   返回:!row?'':!row.user?'':!row.user.id?'':row.user.id
+     */
+    public static String jsGetVal(String objectString){
+    	StringBuilder result = new StringBuilder();
+    	StringBuilder val = new StringBuilder();
+    	String[] vals = split(objectString, ".");
+    	for (int i=0; i<vals.length; i++){
+    		val.append("." + vals[i]);
+    		result.append("!"+(val.substring(1))+"?'':");
+    	}
+    	result.append(val.substring(1));
+    	return result.toString();
+    }
+    
+}

+ 77 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/util/UserUtils.java

@@ -0,0 +1,77 @@
+package cn.com.liandisys.ycjt.ggcx.common.util;
+
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.UnavailableSecurityManagerException;
+import org.apache.shiro.session.InvalidSessionException;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.subject.Subject;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+
+/**
+ * 用户工具类
+ * @author jiangchao
+ */
+public class UserUtils {
+
+	/**
+	 * 获取授权主要对象
+	 */
+	public static Subject getSubject(){
+		return SecurityUtils.getSubject();
+	}
+	
+	/**
+	 * 获取当前登录者对象
+	 */
+	public static User getPrincipal(){
+		try{
+			Subject subject = SecurityUtils.getSubject();
+			User principal = (User)subject.getPrincipal();
+			if (principal != null){
+				return principal;
+			}
+		}catch (UnavailableSecurityManagerException e) {
+			e.printStackTrace();
+		}catch (InvalidSessionException e){
+			e.printStackTrace();
+		}
+		return null;
+	}
+	
+	public static Session getSession(){
+		try{
+			Subject subject = SecurityUtils.getSubject();
+			Session session = subject.getSession(false);
+			if (session == null){
+				session = subject.getSession();
+			}
+			if (session != null){
+				return session;
+			}
+		}catch (InvalidSessionException e){
+			
+		}
+		return null;
+	}
+	
+	// ============== User Cache ==============
+	
+	public static Object getCache(String key) {
+		return getCache(key, null);
+	}
+	
+	public static Object getCache(String key, Object defaultValue) {
+		Object obj = getSession().getAttribute(key);
+		return obj==null?defaultValue:obj;
+	}
+
+	public static void putCache(String key, Object value) {
+		getSession().setAttribute(key, value);
+	}
+
+	public static void removeCache(String key) {
+		getSession().removeAttribute(key);
+	}
+	
+}

+ 86 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/vo/InitQueryParam.java

@@ -0,0 +1,86 @@
+package cn.com.liandisys.ycjt.ggcx.common.vo;
+
+import java.util.Date;
+
+/**
+ * 历史事件查询
+ * @author wangqx
+ */
+public class InitQueryParam {
+	
+	
+	/**
+	 * 路段
+	 */
+	private String roadId;
+	/**
+	 * 时间条件
+	 */
+	private String timeCondition;
+	/**
+	 * 级别
+	 */
+	private String level;
+	
+	/**
+	 * 监测对象
+	 */
+	private String monitorObj;
+	/**
+	 * 事件发生时间(开始)
+	 */
+	private Date occurTimeStart;
+	
+	/**
+	 * 事件发生时间(结束)
+	 */
+	private Date occurTimeEnd;
+
+	public String getRoadId() {
+		return roadId;
+	}
+
+	public void setRoadId(String roadId) {
+		this.roadId = roadId;
+	}
+
+	public String getTimeCondition() {
+		return timeCondition;
+	}
+
+	public void setTimeCondition(String timeCondition) {
+		this.timeCondition = timeCondition;
+	}
+
+	public String getLevel() {
+		return level;
+	}
+
+	public void setLevel(String level) {
+		this.level = level;
+	}
+
+	public String getMonitorObj() {
+		return monitorObj;
+	}
+
+	public void setMonitorObj(String monitorObj) {
+		this.monitorObj = monitorObj;
+	}
+
+	public Date getOccurTimeStart() {
+		return occurTimeStart;
+	}
+
+	public void setOccurTimeStart(Date occurTimeStart) {
+		this.occurTimeStart = occurTimeStart;
+	}
+
+	public Date getOccurTimeEnd() {
+		return occurTimeEnd;
+	}
+
+	public void setOccurTimeEnd(Date occurTimeEnd) {
+		this.occurTimeEnd = occurTimeEnd;
+	}
+}

+ 84 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/vo/Paging.java

@@ -0,0 +1,84 @@
+/*
+ * $Id: Paging.java,v 1.0 2016/07/28 wangqx Exp $
+ */
+package cn.com.liandisys.ycjt.ggcx.common.vo;
+
+/**
+ * @author wangqx
+ * 2016-7-28
+ */
+public class Paging {
+
+    private int page = 0; //页数
+
+    private long totalrows = 0L; //总行数
+
+    private int rows; //行数
+
+    private int firstResult = -1;
+
+    private int maxResult = -1;
+
+    public int getFirstResult() {
+
+        if (firstResult == -1)
+            firstResult = page * rows - rows; //hibernate分页起始数从0开始
+
+        return firstResult;
+    }
+
+    public int getMaxResult() {
+
+        maxResult = getFirstResult() + rows - 1;
+
+        return maxResult;
+    }
+
+    /**
+     * @return the rows
+     */
+    public int getRows() {
+
+        return rows;
+    }
+
+    /**
+     * @param rows the rows to set
+     */
+    public void setRows(int rows) {
+
+        this.rows = rows;
+    }
+
+    /**
+     * @return the page
+     */
+    public int getPage() {
+
+        return page;
+    }
+
+    /**
+     * @param page the page to set
+     */
+    public void setPage(int page) {
+
+        this.page = page;
+    }
+
+    /**
+     * @return the totalrows
+     */
+    public long getTotalrows() {
+
+        return totalrows;
+    }
+
+    /**
+     * @param totalrows the totalrows to set
+     */
+    public void setTotalRows(long totalrows) {
+
+        this.totalrows = totalrows;
+    }
+}

+ 71 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/web/CKFinderConfig.java

@@ -0,0 +1,71 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.web;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+
+import com.ckfinder.connector.configuration.Configuration;
+import com.ckfinder.connector.data.AccessControlLevel;
+import com.ckfinder.connector.utils.AccessControlUtil;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+import cn.com.liandisys.ycjt.ggcx.common.config.Global;
+import cn.com.liandisys.ycjt.ggcx.common.util.FileUtils;
+import cn.com.liandisys.ycjt.ggcx.common.util.UserUtils;
+
+/**
+ * CKFinder配置
+ * @author ThinkGem
+ * @version 2014-06-25
+ */
+public class CKFinderConfig extends Configuration {
+
+	public CKFinderConfig(ServletConfig servletConfig) {
+        super(servletConfig);  
+    }
+	
+	@Override
+    protected Configuration createConfigurationInstance() {
+		User principal = (User) UserUtils.getPrincipal();
+		if (principal == null){
+			return new CKFinderConfig(this.servletConf);
+		}
+		boolean isView = true;//UserUtils.getSubject().isPermitted("cms:ckfinder:view");
+		boolean isUpload = true;//UserUtils.getSubject().isPermitted("cms:ckfinder:upload");
+		boolean isEdit = true;//UserUtils.getSubject().isPermitted("cms:ckfinder:edit");
+		AccessControlLevel alc = this.getAccessConrolLevels().get(0);
+		alc.setFolderView(isView);
+		alc.setFolderCreate(isEdit);
+		alc.setFolderRename(isEdit);
+		alc.setFolderDelete(isEdit);
+		alc.setFileView(isView);
+		alc.setFileUpload(isUpload);
+		alc.setFileRename(isEdit);
+		alc.setFileDelete(isEdit);
+//		for (AccessControlLevel a : this.getAccessConrolLevels()){
+//			System.out.println(a.getRole()+", "+a.getResourceType()+", "+a.getFolder()
+//					+", "+a.isFolderView()+", "+a.isFolderCreate()+", "+a.isFolderRename()+", "+a.isFolderDelete()
+//					+", "+a.isFileView()+", "+a.isFileUpload()+", "+a.isFileRename()+", "+a.isFileDelete());
+//		}
+		AccessControlUtil.getInstance(this).loadACLConfig();
+		try {
+//			Principal principal = (Principal)SecurityUtils.getSubject().getPrincipal();
+//			this.baseURL = ServletContextFactory.getServletContext().getContextPath()+"/userfiles/"+principal+"/";
+//			this.baseURL = FileUtils.path(Global.WEB_CONTEXT_PATH + Global.USERFILES_BASE_URL + principal.getLoginName() + "/");
+//			this.baseDir = FileUtils.path(Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + principal.getLoginName() + "/");
+			this.baseURL = FileUtils.path(Global.WEB_CONTEXT_PATH + Global.USERFILES_BASE_URL);
+			this.baseDir = FileUtils.path(Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL);
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+		return new CKFinderConfig(this.servletConf);
+    }
+
+    @Override  
+    public boolean checkAuthentication(final HttpServletRequest request) {
+        return UserUtils.getPrincipal()!=null;
+    }
+
+}

+ 82 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/web/CKFinderConnectorServlet.java

@@ -0,0 +1,82 @@
+/**
+ * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
+ */
+package cn.com.liandisys.ycjt.ggcx.common.web;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.ckfinder.connector.ConnectorServlet;
+
+import cn.com.liandisys.ycjt.ggcx.admin.model.User;
+import cn.com.liandisys.ycjt.ggcx.common.config.Global;
+import cn.com.liandisys.ycjt.ggcx.common.util.FileUtils;
+import cn.com.liandisys.ycjt.ggcx.common.util.UserUtils;
+
+/**
+ * CKFinderConnectorServlet
+ * @author ThinkGem
+ * @version 2014-06-25
+ */
+public class CKFinderConnectorServlet extends ConnectorServlet {
+	
+	private static final long serialVersionUID = 1L;
+	
+	@Override
+	protected void doGet(HttpServletRequest request,
+			HttpServletResponse response) throws ServletException, IOException {
+		prepareGetResponse(request, response, false);
+		Global.WEB_CONTEXT_PATH = request.getContextPath();
+		super.doGet(request, response);
+	}
+	
+	@Override
+	protected void doPost(HttpServletRequest request,
+			HttpServletResponse response) throws ServletException, IOException {
+		prepareGetResponse(request, response, true);
+		super.doPost(request, response);
+	}
+	
+	private void prepareGetResponse(final HttpServletRequest request,
+			final HttpServletResponse response, final boolean post) throws ServletException {
+		User principal = (User) UserUtils.getPrincipal();
+		if (principal == null){
+			return;
+		}
+		String command = request.getParameter("command");
+		String type = request.getParameter("type");
+		// 初始化时,如果startupPath文件夹不存在,则自动创建startupPath文件夹
+		if ("Init".equals(command)){
+			String startupPath = request.getParameter("startupPath");// 当前文件夹可指定为模块名
+			if (startupPath!=null){
+				String[] ss = startupPath.split(":");
+				if (ss.length==2){
+					String realPath = Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL
+							//+ principal.getLoginName() + "/" + ss[0] + ss[1];
+							+ ss[0] + ss[1];
+					try{
+						FileUtils.createDirectory(FileUtils.path(realPath));
+					}catch(Exception e){
+						e.printStackTrace();
+					}
+				}
+			}
+		}
+		// 快捷上传,自动创建当前文件夹,并上传到该路径
+		else if ("QuickUpload".equals(command) && type!=null){
+			String currentFolder = request.getParameter("currentFolder");// 当前文件夹可指定为模块名
+			String realPath = Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL
+					//+ principal.getLoginName() + "/" + type + (currentFolder != null ? currentFolder : "");
+					+ type + (currentFolder != null ? currentFolder : "");
+			FileUtils.createDirectory(FileUtils.path(realPath));
+		}
+//		System.out.println("------------------------");
+//		for (Object key : request.getParameterMap().keySet()){
+//			System.out.println(key + ": " + request.getParameter(key.toString()));
+//		}
+	}
+	
+}

+ 257 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/web/Servlets.java

@@ -0,0 +1,257 @@
+/**
+ * Copyright (c) 2005-2012 springside.org.cn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ */
+package cn.com.liandisys.ycjt.ggcx.common.web;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.Validate;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import com.google.common.net.HttpHeaders;
+
+import cn.com.liandisys.ycjt.ggcx.common.config.Global;
+import cn.com.liandisys.ycjt.ggcx.common.util.Encodes;
+import cn.com.liandisys.ycjt.ggcx.common.util.StringUtils;
+
+/**
+ * Http与Servlet工具类.
+ * @author calvin/thinkgem
+ * @version 2014-8-19
+ */
+public class Servlets {
+
+	// -- 常用数值定义 --//
+	public static final long ONE_YEAR_SECONDS = 60 * 60 * 24 * 365;
+	
+	// 静态文件后缀
+	private final static String[] staticFiles = StringUtils.split(Global.getConfig("web.staticFile"), ",");
+	
+	// 动态映射URL后缀
+	private final static String urlSuffix = Global.getUrlSuffix();
+
+	/**
+	 * 设置客户端缓存过期时间 的Header.
+	 */
+	public static void setExpiresHeader(HttpServletResponse response, long expiresSeconds) {
+		// Http 1.0 header, set a fix expires date.
+		response.setDateHeader(HttpHeaders.EXPIRES, System.currentTimeMillis() + expiresSeconds * 1000);
+		// Http 1.1 header, set a time after now.
+		response.setHeader(HttpHeaders.CACHE_CONTROL, "private, max-age=" + expiresSeconds);
+	}
+
+	/**
+	 * 设置禁止客户端缓存的Header.
+	 */
+	public static void setNoCacheHeader(HttpServletResponse response) {
+		// Http 1.0 header
+		response.setDateHeader(HttpHeaders.EXPIRES, 1L);
+		response.addHeader(HttpHeaders.PRAGMA, "no-cache");
+		// Http 1.1 header
+		response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, max-age=0");
+	}
+
+	/**
+	 * 设置LastModified Header.
+	 */
+	public static void setLastModifiedHeader(HttpServletResponse response, long lastModifiedDate) {
+		response.setDateHeader(HttpHeaders.LAST_MODIFIED, lastModifiedDate);
+	}
+
+	/**
+	 * 设置Etag Header.
+	 */
+	public static void setEtag(HttpServletResponse response, String etag) {
+		response.setHeader(HttpHeaders.ETAG, etag);
+	}
+
+	/**
+	 * 根据浏览器If-Modified-Since Header, 计算文件是否已被修改.
+	 * 
+	 * 如果无修改, checkIfModify返回false ,设置304 not modify status.
+	 * 
+	 * @param lastModified 内容的最后修改时间.
+	 */
+	public static boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response,
+			long lastModified) {
+		long ifModifiedSince = request.getDateHeader(HttpHeaders.IF_MODIFIED_SINCE);
+		if ((ifModifiedSince != -1) && (lastModified < ifModifiedSince + 1000)) {
+			response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * 根据浏览器 If-None-Match Header, 计算Etag是否已无效.
+	 * 
+	 * 如果Etag有效, checkIfNoneMatch返回false, 设置304 not modify status.
+	 * 
+	 * @param etag 内容的ETag.
+	 */
+	public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) {
+		String headerValue = request.getHeader(HttpHeaders.IF_NONE_MATCH);
+		if (headerValue != null) {
+			boolean conditionSatisfied = false;
+			if (!"*".equals(headerValue)) {
+				StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ",");
+
+				while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
+					String currentToken = commaTokenizer.nextToken();
+					if (currentToken.trim().equals(etag)) {
+						conditionSatisfied = true;
+					}
+				}
+			} else {
+				conditionSatisfied = true;
+			}
+
+			if (conditionSatisfied) {
+				response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+				response.setHeader(HttpHeaders.ETAG, etag);
+				return false;
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * 设置让浏览器弹出下载对话框的Header.
+	 * 
+	 * @param fileName 下载后的文件名.
+	 */
+	public static void setFileDownloadHeader(HttpServletResponse response, String fileName) {
+		try {
+			// 中文文件名支持
+			String encodedfileName = new String(fileName.getBytes(), "ISO8859-1");
+			response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + encodedfileName + "\"");
+		} catch (UnsupportedEncodingException e) {
+			e.getMessage();
+		}
+	}
+
+	/**
+	 * 取得带相同前缀的Request Parameters, copy from spring WebUtils.
+	 * 
+	 * 返回的结果的Parameter名已去除前缀.
+	 */
+	@SuppressWarnings("rawtypes")
+	public static Map<String, Object> getParametersStartingWith(ServletRequest request, String prefix) {
+		Validate.notNull(request, "Request must not be null");
+		Enumeration paramNames = request.getParameterNames();
+		Map<String, Object> params = new TreeMap<String, Object>();
+		String pre = prefix;
+		if (pre == null) {
+			pre = "";
+		}
+		while (paramNames != null && paramNames.hasMoreElements()) {
+			String paramName = (String) paramNames.nextElement();
+			if ("".equals(pre) || paramName.startsWith(pre)) {
+				String unprefixed = paramName.substring(pre.length());
+				String[] values = request.getParameterValues(paramName);
+				if (values == null || values.length == 0) {
+					values = new String[]{};
+					// Do nothing, no values found at all.
+				} else if (values.length > 1) {
+					params.put(unprefixed, values);
+				} else {
+					params.put(unprefixed, values[0]);
+				}
+			}
+		}
+		return params;
+	}
+
+	/**
+	 * 组合Parameters生成Query String的Parameter部分,并在paramter name上加上prefix.
+	 * 
+	 */
+	public static String encodeParameterStringWithPrefix(Map<String, Object> params, String prefix) {
+		StringBuilder queryStringBuilder = new StringBuilder();
+
+		String pre = prefix;
+		if (pre == null) {
+			pre = "";
+		}
+		Iterator<Entry<String, Object>> it = params.entrySet().iterator();
+		while (it.hasNext()) {
+			Entry<String, Object> entry = it.next();
+			queryStringBuilder.append(pre).append(entry.getKey()).append("=").append(entry.getValue());
+			if (it.hasNext()) {
+				queryStringBuilder.append("&");
+			}
+		}
+		return queryStringBuilder.toString();
+	}
+
+	/**
+	 * 客户端对Http Basic验证的 Header进行编码.
+	 */
+	public static String encodeHttpBasic(String userName, String password) {
+		String encode = userName + ":" + password;
+		return "Basic " + Encodes.encodeBase64(encode.getBytes());
+	}
+	
+	/**
+	 * 是否是Ajax异步请求
+	 * @param request
+	 */
+	public static boolean isAjaxRequest(HttpServletRequest request){
+		
+		String accept = request.getHeader("accept");
+		String xRequestedWith = request.getHeader("X-Requested-With");
+
+		// 如果是异步请求或是手机端,则直接返回信息
+		return ((accept != null && accept.indexOf("application/json") != -1 
+			|| (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)));
+	}
+	
+	/**
+	 * 获取当前请求对象
+	 * @return
+	 */
+	public static HttpServletRequest getRequest(){
+		try{
+			return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
+		}catch(Exception e){
+			return null;
+		}
+	}
+
+	/**
+     * 判断访问URI是否是静态文件请求
+	 * @throws Exception 
+     */
+    public static boolean isStaticFile(String uri){
+		if (staticFiles == null){
+			try {
+				throw new Exception("检测到“app.properties”中没有配置“web.staticFile”属性。配置示例:\n#静态文件后缀\n"
+					+"web.staticFile=.css,.js,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk");
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+//		if ((StringUtils.startsWith(uri, "/static/") || StringUtils.endsWithAny(uri, sfs)) 
+//				&& !StringUtils.endsWithAny(uri, ".jsp") && !StringUtils.endsWithAny(uri, ".java")){
+//			return true;
+//		}
+		if (StringUtils.endsWithAny(uri, staticFiles) && !StringUtils.endsWithAny(uri, urlSuffix)
+				&& !StringUtils.endsWithAny(uri, ".jsp") && !StringUtils.endsWithAny(uri, ".java")){
+			return true;
+		}
+		return false;
+    }
+}

+ 65 - 0
src/main/java/cn/com/liandisys/ycjt/ggcx/common/web/UserfilesDownloadServlet.java

@@ -0,0 +1,65 @@
+package cn.com.liandisys.ycjt.ggcx.common.web;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.FileCopyUtils;
+import org.springframework.web.util.UriUtils;
+
+import cn.com.liandisys.ycjt.ggcx.common.config.Global;
+
+/**
+ * 查看CK上传的图片
+ * @author ThinkGem
+ * @version 2014-06-25
+ */
+public class UserfilesDownloadServlet extends HttpServlet {
+
+	private static final long serialVersionUID = 1L;
+	private Logger logger = LoggerFactory.getLogger(getClass());
+
+	public void fileOutputStream(HttpServletRequest req, HttpServletResponse resp) 
+			throws ServletException, IOException {
+		String filepath = req.getRequestURI();
+		int index = filepath.indexOf(Global.USERFILES_BASE_URL);
+		if(index >= 0) {
+			filepath = filepath.substring(index + Global.USERFILES_BASE_URL.length());
+		}
+		try {
+			filepath = UriUtils.decode(filepath, "UTF-8");
+		} catch (UnsupportedEncodingException e1) {
+			logger.error(String.format("解释文件路径失败,URL地址为%s", filepath), e1);
+		}
+		File file = new File(Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + filepath);
+		try {
+			FileCopyUtils.copy(new FileInputStream(file), resp.getOutputStream());
+			resp.setHeader("Content-Type", "application/octet-stream");
+			return;
+		} catch (FileNotFoundException e) {
+			req.setAttribute("exception", new FileNotFoundException("请求的文件不存在"));
+			req.getRequestDispatcher("/WEB-INF/views/error/404.jsp").forward(req, resp);
+		}
+	}
+
+	@Override
+	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+			throws ServletException, IOException {
+		fileOutputStream(req, resp);
+	}
+
+	@Override
+	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+			throws ServletException, IOException {
+		fileOutputStream(req, resp);
+	}
+}

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