CX 3 年之前
当前提交
dbd4cee00e
共有 100 个文件被更改,包括 23542 次插入0 次删除
  1. 2 0
      META-INF/MANIFEST.MF
  2. 178 0
      pom.xml
  3. 二进制
      src/lib/dingtalk-1.0.0.jar
  4. 44 0
      src/main/java/com/dashitech/Application.java
  5. 43 0
      src/main/java/com/dashitech/bean/BaseBean.java
  6. 17 0
      src/main/java/com/dashitech/businessdata/dao/ICallLogDAO.java
  7. 48 0
      src/main/java/com/dashitech/businessdata/dao/IDepartmentDAO.java
  8. 26 0
      src/main/java/com/dashitech/businessdata/dao/IDictionaryDAO.java
  9. 18 0
      src/main/java/com/dashitech/businessdata/dao/IDrugsBagDAO.java
  10. 15 0
      src/main/java/com/dashitech/businessdata/dao/IDrugsDAO.java
  11. 19 0
      src/main/java/com/dashitech/businessdata/dao/IHospitalConfigDAO.java
  12. 38 0
      src/main/java/com/dashitech/businessdata/dao/IInspectDAO.java
  13. 18 0
      src/main/java/com/dashitech/businessdata/dao/IJPBagDAO.java
  14. 12 0
      src/main/java/com/dashitech/businessdata/dao/IJPDetailsDAO.java
  15. 33 0
      src/main/java/com/dashitech/businessdata/dao/IPatientDAO.java
  16. 20 0
      src/main/java/com/dashitech/businessdata/dao/IPatientLogDAO.java
  17. 41 0
      src/main/java/com/dashitech/businessdata/dao/ISpecimenDAO.java
  18. 22 0
      src/main/java/com/dashitech/businessdata/dao/ISpecimenHistoryDAO.java
  19. 19 0
      src/main/java/com/dashitech/businessdata/dao/ISystemConfigureDAO.java
  20. 24 0
      src/main/java/com/dashitech/businessdata/dao/IUserDAO.java
  21. 20 0
      src/main/java/com/dashitech/businessdata/dao/IWorkOrderDAO.java
  22. 41 0
      src/main/java/com/dashitech/businessdata/dao/TestDao.java
  23. 165 0
      src/main/java/com/dashitech/businessdata/entity/CallLogEntity.java
  24. 167 0
      src/main/java/com/dashitech/businessdata/entity/DepartmentEntity.java
  25. 225 0
      src/main/java/com/dashitech/businessdata/entity/DictionaryEntity.java
  26. 145 0
      src/main/java/com/dashitech/businessdata/entity/DrugsBagEntity.java
  27. 137 0
      src/main/java/com/dashitech/businessdata/entity/DrugsEntity.java
  28. 68 0
      src/main/java/com/dashitech/businessdata/entity/HospitalConfig.java
  29. 270 0
      src/main/java/com/dashitech/businessdata/entity/InspectEntity.java
  30. 120 0
      src/main/java/com/dashitech/businessdata/entity/JPBagEntity.java
  31. 114 0
      src/main/java/com/dashitech/businessdata/entity/JPDetailsEntity.java
  32. 236 0
      src/main/java/com/dashitech/businessdata/entity/PatientEntity.java
  33. 125 0
      src/main/java/com/dashitech/businessdata/entity/PatientLogEntity.java
  34. 291 0
      src/main/java/com/dashitech/businessdata/entity/SpecimenEntity.java
  35. 91 0
      src/main/java/com/dashitech/businessdata/entity/SpecimenHistoryEntity.java
  36. 76 0
      src/main/java/com/dashitech/businessdata/entity/SystemConfigureEntity.java
  37. 241 0
      src/main/java/com/dashitech/businessdata/entity/UserEntity.java
  38. 88 0
      src/main/java/com/dashitech/businessdata/entity/WorkOrderEntity.java
  39. 63 0
      src/main/java/com/dashitech/callcenter/init/SocketInit.java
  40. 397 0
      src/main/java/com/dashitech/callcenter/socket/HandlerThread.java
  41. 33 0
      src/main/java/com/dashitech/callcenter/webSocket/core/CacheHandlerAdapter.java
  42. 56 0
      src/main/java/com/dashitech/callcenter/webSocket/core/SessionCache.java
  43. 69 0
      src/main/java/com/dashitech/callcenter/webSocket/core/WebSocketSender.java
  44. 144 0
      src/main/java/com/dashitech/callcenter/webSocket/service/PhoneWebSocket.java
  45. 46 0
      src/main/java/com/dashitech/callcenter/webSocket/service/demo/Data.java
  46. 75 0
      src/main/java/com/dashitech/callcenter/webSocket/service/demo/WebSocketChat.java
  47. 89 0
      src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/application2.js
  48. 27 0
      src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/index.html
  49. 27 0
      src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/index2.html
  50. 90 0
      src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/javascript/application.js
  51. 1152 0
      src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/javascript/atmosphere-min.js
  52. 3430 0
      src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/javascript/atmosphere.js
  53. 8829 0
      src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/javascript/jquery-2.0.3.js
  54. 58 0
      src/main/java/com/dashitech/config/ApiFilterConfig.java
  55. 48 0
      src/main/java/com/dashitech/config/ApiWeblogFilterConfig.java
  56. 32 0
      src/main/java/com/dashitech/config/DataSourceConfig.java
  57. 16 0
      src/main/java/com/dashitech/config/DruidConfig.java
  58. 14 0
      src/main/java/com/dashitech/config/DruidFilter.java
  59. 30 0
      src/main/java/com/dashitech/config/TomcatConfig.java
  60. 108 0
      src/main/java/com/dashitech/config/datasource/MySQL2DataSourceConfig.java
  61. 71 0
      src/main/java/com/dashitech/redis/core/JedisPoolFactory.java
  62. 162 0
      src/main/java/com/dashitech/redis/core/RedisHashCmd.java
  63. 33 0
      src/main/java/com/dashitech/redis/core/RedisKeys.java
  64. 182 0
      src/main/java/com/dashitech/redis/core/RedisListCmd.java
  65. 46 0
      src/main/java/com/dashitech/redis/core/RedisPubSubCmd.java
  66. 149 0
      src/main/java/com/dashitech/redis/core/RedisStringCmd.java
  67. 54 0
      src/main/java/com/dashitech/redis/core/init/RedisInit.java
  68. 107 0
      src/main/java/com/dashitech/utils/CaptchaUtil.java
  69. 228 0
      src/main/java/com/dashitech/utils/CaptchaUtil2.java
  70. 250 0
      src/main/java/com/dashitech/utils/CommonUtil.java
  71. 318 0
      src/main/java/com/dashitech/utils/DateUtil.java
  72. 670 0
      src/main/java/com/dashitech/utils/DateUtil2.java
  73. 49 0
      src/main/java/com/dashitech/utils/DecimalUtil.java
  74. 675 0
      src/main/java/com/dashitech/utils/FileUtil.java
  75. 372 0
      src/main/java/com/dashitech/utils/HttpUtil.java
  76. 20 0
      src/main/java/com/dashitech/utils/I18n.java
  77. 120 0
      src/main/java/com/dashitech/utils/JsonParam.java
  78. 100 0
      src/main/java/com/dashitech/utils/JsonResponse.java
  79. 163 0
      src/main/java/com/dashitech/utils/JsonUtil.java
  80. 17 0
      src/main/java/com/dashitech/utils/MyObjectMapper.java
  81. 119 0
      src/main/java/com/dashitech/utils/MyObjectMapperDateFormat.java
  82. 18 0
      src/main/java/com/dashitech/utils/MyX509TrustManager.java
  83. 506 0
      src/main/java/com/dashitech/utils/PropertiesHelper.java
  84. 179 0
      src/main/java/com/dashitech/utils/PropertiesUtil.java
  85. 69 0
      src/main/java/com/dashitech/utils/Sha1Util.java
  86. 70 0
      src/main/java/com/dashitech/utils/SpringContextHolder.java
  87. 274 0
      src/main/java/com/dashitech/utils/SystemCmdExecutor.java
  88. 31 0
      src/main/java/com/dashitech/utils/ThreadPoolFactory.java
  89. 118 0
      src/main/java/com/dashitech/utils/XmlToJson.java
  90. 83 0
      src/main/java/com/dashitech/utils/XmlToMap.java
  91. 32 0
      src/main/resources/application-context.xml
  92. 1 0
      src/main/resources/application-custom.properties
  93. 41 0
      src/main/resources/application.properties
  94. 22 0
      src/main/resources/banner.txt
  95. 37 0
      src/main/resources/log4j.properties
  96. 5 0
      src/main/resources/start.bat
  97. 15 0
      src/main/resources/start.sh
  98. 20 0
      src/main/resources/startCollect.sh
  99. 26 0
      src/main/webapp/WEB-INF/web.xml
  100. 0 0
      src/test/java/com/dashitech/mc/AppTest.java

+ 2 - 0
META-INF/MANIFEST.MF

@@ -0,0 +1,2 @@
1
+Manifest-Version: 1.0
2
+

+ 178 - 0
pom.xml

@@ -0,0 +1,178 @@
1
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
+	<modelVersion>4.0.0</modelVersion>
4
+
5
+	<groupId>com.dashitech</groupId>
6
+	<artifactId>HSMSV1-CallSocket</artifactId>
7
+	<version>1.0.0</version>
8
+	<packaging>jar</packaging>
9
+
10
+	<name>HSMSV1-CallSocket</name>
11
+
12
+	<parent>
13
+		<groupId>org.springframework.boot</groupId>
14
+		<artifactId>spring-boot-starter-parent</artifactId>
15
+		<version>1.5.8.RELEASE</version>
16
+		<relativePath />
17
+	</parent>
18
+<!--	<artifactId>spring-boot-starter-logging</artifactId>
19
+	<name>Spring Boot Logging Starter</name>
20
+	<description>Starter for logging using Logback. Default logging starter</description>
21
+	<url>http://projects.spring.io/spring-boot/</url>-->
22
+	<properties>
23
+		<tomcat.version>7.0.59</tomcat.version>
24
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25
+		<java.version>1.8</java.version>
26
+	</properties>
27
+
28
+	<dependencies>
29
+
30
+	<!--	<dependency>
31
+			<groupId>org.slf4j</groupId>
32
+			<artifactId>slf4j-nop</artifactId>
33
+			<version>1.7.24</version>
34
+		</dependency>-->
35
+	<!--	<dependency>
36
+			<groupId>org.springframework.boot</groupId>
37
+			<artifactId>spring-boot-starter</artifactId>
38
+			<exclusions>
39
+				<exclusion>
40
+					<groupId>org.springframework.boot</groupId>
41
+					<artifactId>spring-boot-starter-logging</artifactId>
42
+				</exclusion>
43
+			</exclusions>
44
+		</dependency>-->
45
+
46
+		<dependency>
47
+			<groupId>org.springframework.boot</groupId>
48
+			<artifactId>spring-boot-starter-test</artifactId>
49
+			<scope>test</scope>
50
+		</dependency>
51
+
52
+		<dependency>
53
+			<groupId>org.springframework.boot</groupId>
54
+			<artifactId>spring-boot-starter-web</artifactId>
55
+		</dependency>
56
+
57
+		<dependency>
58
+			<groupId>org.springframework.boot</groupId>
59
+			<artifactId>spring-boot-starter-aop</artifactId>
60
+		</dependency>
61
+
62
+<!--		<dependency>
63
+			<groupId>org.springframework.boot</groupId>
64
+			<artifactId>spring-boot-starter-log4j</artifactId>
65
+		</dependency>-->
66
+
67
+		<dependency>
68
+			<groupId>org.springframework.boot</groupId>
69
+			<artifactId>spring-boot-devtools</artifactId>
70
+			<optional>true</optional>
71
+		</dependency>
72
+
73
+		<dependency>
74
+			<groupId>org.apache.commons</groupId>
75
+			<artifactId>commons-lang3</artifactId>
76
+			<version>3.3.2</version>
77
+		</dependency>
78
+
79
+		<dependency>
80
+			<groupId>net.sf.json-lib</groupId>
81
+			<artifactId>json-lib</artifactId>
82
+			<version>2.4</version>
83
+		</dependency>
84
+
85
+		<dependency>
86
+			<groupId>commons-httpclient</groupId>
87
+			<artifactId>commons-httpclient</artifactId>
88
+			<version>3.0.1</version>
89
+		</dependency>
90
+
91
+		<dependency>
92
+			<groupId>org.apache.httpcomponents</groupId>
93
+			<artifactId>httpmime</artifactId>
94
+			<version>4.3.4</version>
95
+		</dependency>
96
+
97
+		<dependency>
98
+			<groupId>org.springframework</groupId>
99
+			<artifactId>spring-context-support</artifactId>
100
+			<version>4.2.4.RELEASE</version>
101
+		</dependency>
102
+
103
+
104
+		<!-- db -->
105
+		<dependency>
106
+			<groupId>org.springframework.boot</groupId>
107
+			<artifactId>spring-boot-starter-data-jpa</artifactId>
108
+			<exclusions>
109
+				<exclusion>
110
+					<groupId>javax.transaction</groupId>
111
+					<artifactId>javax.transaction-api</artifactId>
112
+				</exclusion>
113
+			</exclusions>
114
+		</dependency>
115
+
116
+		<dependency>
117
+			<groupId>org.jboss.spec.javax.transaction</groupId>
118
+			<artifactId>jboss-transaction-api_1.2_spec</artifactId>
119
+			<version>1.0.0.Final</version>
120
+		</dependency>
121
+
122
+		<dependency>
123
+			<groupId>org.hibernate</groupId>
124
+			<artifactId>hibernate-entitymanager</artifactId>
125
+		</dependency>
126
+
127
+		<dependency>
128
+			<groupId>com.alibaba</groupId>
129
+			<artifactId>druid</artifactId>
130
+			<version>1.0.18</version>
131
+		</dependency>
132
+
133
+		<dependency>
134
+			<groupId>com.alibaba</groupId>
135
+			<artifactId>fastjson</artifactId>
136
+			<version>1.2.83</version>
137
+		</dependency>
138
+
139
+		<dependency>
140
+			<groupId>mysql</groupId>
141
+			<artifactId>mysql-connector-java</artifactId>
142
+			<version>5.1.34</version>
143
+		</dependency>
144
+
145
+		<dependency>
146
+			<groupId>redis.clients</groupId>
147
+			<artifactId>jedis</artifactId>
148
+			<version>2.9.0</version>
149
+		</dependency>
150
+		<dependency>
151
+			<groupId>org.atmosphere</groupId>
152
+			<artifactId>atmosphere-runtime</artifactId>
153
+			<version>2.4.28</version>
154
+		</dependency>
155
+		<dependency>
156
+			<groupId>org.jboss.netty</groupId>
157
+			<artifactId>netty</artifactId>
158
+			<version>3.2.5.Final</version>
159
+		</dependency>
160
+		<!-- end -->
161
+	</dependencies>
162
+	<build>
163
+
164
+		<plugins>
165
+			<plugin>
166
+				<groupId>org.springframework.boot</groupId>
167
+				<artifactId>spring-boot-maven-plugin</artifactId>
168
+				<executions>
169
+					<execution>
170
+						<goals>
171
+							<goal>repackage</goal>
172
+						</goals>
173
+					</execution>
174
+				</executions>
175
+			</plugin>
176
+		</plugins>
177
+	</build>
178
+</project>

二进制
src/lib/dingtalk-1.0.0.jar


+ 44 - 0
src/main/java/com/dashitech/Application.java

@@ -0,0 +1,44 @@
1
+package com.dashitech;
2
+
3
+import org.atmosphere.cpr.AtmosphereServlet;
4
+import org.springframework.boot.SpringApplication;
5
+import org.springframework.boot.autoconfigure.SpringBootApplication;
6
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.ImportResource;
9
+import org.springframework.context.annotation.PropertySource;
10
+import org.springframework.core.Ordered;
11
+import org.springframework.scheduling.annotation.EnableAsync;
12
+import org.springframework.scheduling.annotation.EnableScheduling;
13
+
14
+import java.text.SimpleDateFormat;
15
+import java.util.Date;
16
+
17
+//import org.mybatis.spring.annotation.MapperScan;
18
+
19
+
20
+@SpringBootApplication
21
+@EnableAsync
22
+@EnableScheduling
23
+@PropertySource({"classpath:application-custom.properties", "application.properties"})
24
+@ImportResource(locations = "classpath*:/application-context.xml")
25
+//@Import({DynamicDataSourceRegister.class}) // 注册动态多数据源
26
+//@MapperScan("com.dashitech.dao.mysqldb1")//将项目中对应的mapper类的路径加进来就可以了
27
+public class Application {
28
+
29
+    @Bean
30
+    public ServletRegistrationBean camelWebSocketServlet() {
31
+        ServletRegistrationBean bean = new ServletRegistrationBean(new AtmosphereServlet(), "/webSocket/*");
32
+        bean.setName("phoneWebSocket");
33
+        bean.setLoadOnStartup(0);
34
+        bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
35
+        return bean;
36
+    }
37
+
38
+    public static void main(String[] args) {
39
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
40
+        System.out.println("hsmsV1-CallSocket>>>>>>>>>>>>>>>>>>startData"+sdf.format(new Date()));
41
+        SpringApplication.run(Application.class, args);
42
+    }
43
+
44
+}

+ 43 - 0
src/main/java/com/dashitech/bean/BaseBean.java

@@ -0,0 +1,43 @@
1
+package com.dashitech.bean;
2
+
3
+import java.io.Serializable;
4
+import java.util.List;
5
+
6
+/**
7
+ * Created by chi on 2019/9/9.
8
+ */
9
+public class BaseBean implements Serializable {
10
+    /**
11
+     * bean类型
12
+     */
13
+    private String beanType;
14
+
15
+    /**
16
+     *对象数组
17
+    */
18
+    private List<Object> objectList;
19
+
20
+    public String getBeanType() {
21
+        return beanType;
22
+    }
23
+
24
+    public void setBeanType(String beanType) {
25
+        this.beanType = beanType;
26
+    }
27
+
28
+    public List<Object> getObjectList() {
29
+        return objectList;
30
+    }
31
+
32
+    public void setObjectList(List<Object> objectList) {
33
+        this.objectList = objectList;
34
+    }
35
+
36
+    @Override
37
+    public String toString() {
38
+        return "BaseBean{" +
39
+                "beanType='" + beanType + '\'' +
40
+                ", objectList=" + objectList +
41
+                '}';
42
+    }
43
+}

+ 17 - 0
src/main/java/com/dashitech/businessdata/dao/ICallLogDAO.java

@@ -0,0 +1,17 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.CallLogEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Query;
6
+
7
+/**
8
+ * Created by chi on 2020/8/25.
9
+ */
10
+public interface ICallLogDAO extends JpaRepository<CallLogEntity, String> {
11
+
12
+    @SuppressWarnings("unchecked")
13
+    CallLogEntity save(CallLogEntity callLogEntity);
14
+
15
+    @Query(value = "select hos_id from itsm_system_hospital_config where _key = ?1 and _value =?2 limit 1 ",nativeQuery = true)
16
+    String selectSernelNo(String key,String value);
17
+}

+ 48 - 0
src/main/java/com/dashitech/businessdata/dao/IDepartmentDAO.java

@@ -0,0 +1,48 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.DepartmentEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.query.Param;
7
+import org.springframework.stereotype.Repository;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * Created by chi on 2019/9/12.
13
+ */
14
+@Repository
15
+public interface IDepartmentDAO extends JpaRepository<DepartmentEntity, String> {
16
+
17
+    @SuppressWarnings("unchecked")
18
+    DepartmentEntity save(DepartmentEntity departmentEntity);
19
+
20
+    //@Query(value = "select id from DepartmentEntity where deleteFlag = 0 and pcode =?1 limit 1 ",nativeQuery = true)
21
+    @Query(value = "select id from itsm_uc_dept where delete_flag = 0 and code =?1 limit 1 ",nativeQuery = true)
22
+    Long selectIdByCode(String code);
23
+
24
+    @Query(value = "SELECT id FROM itsm_uc_hospital WHERE delete_flag = 0 and _hos_no=?1 limit 1", nativeQuery = true)
25
+    Long getHospitalIdByHosNo(String hosNo);
26
+
27
+/*    @Query(value = "SELECT dept FROM itsm_uc_dept g WHERE g._phone =?1 AND g.delete_flag = 0 limit 1", nativeQuery = true)
28
+    String getDeptNameByPhone(String phone);*/
29
+    @Query(value = "SELECT dept FROM itsm_uc_dept g WHERE g.many_phone like CONCAT('%',:phone,'%') AND g.delete_flag = 0 limit 1", nativeQuery = true)
30
+    String getDeptNameByPhone(@Param("phone")String phone);
31
+
32
+    @Query(value = "SELECT d.dept FROM itsm_uc_dept d WHERE id = (SELECT create_department_id FROM itsm_transport_workorder g WHERE g.work_order_phone =?1 LIMIT 1);",nativeQuery = true)
33
+    String getDeptNameByWorkOrderPhone(String phone);
34
+
35
+    @Query(value = "select code from itsm_uc_dept where delete_flag = 0",nativeQuery = true)
36
+    List<String> getDeptCodeList();
37
+
38
+
39
+    //用来补数据的查询
40
+    @Query(value = "select * from itsm_uc_dept where delete_flag = 0 and (input_code is null or pinyin is null)",nativeQuery = true)
41
+    List<DepartmentEntity> getNoPyDeptList();
42
+//    @Modifying
43
+//    @Query("update itsm_uc_dept set input_code = ?1 ,pinyin = ?2 where input_code is null or pinyin is null")
44
+//    void upPinyin(String inputCode,String pinyin);
45
+
46
+    @Query(value = "SELECT id FROM itsm_uc_hospital WHERE _hos_no =?1 AND delete_flag = 0 ", nativeQuery = true)
47
+    Long getHosIdByCode(String gender);
48
+}

+ 26 - 0
src/main/java/com/dashitech/businessdata/dao/IDictionaryDAO.java

@@ -0,0 +1,26 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.DictionaryEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.query.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * Created by chi on 2020/8/25.
12
+ */
13
+public interface IDictionaryDAO extends JpaRepository<DictionaryEntity, String> {
14
+
15
+    @SuppressWarnings("unchecked")
16
+    DictionaryEntity save(DictionaryEntity dictionaryEntity);
17
+
18
+    @Query(value = "SELECT * FROM itsm_base_dictionary g WHERE g.deleted = FALSE AND g._key =?1",nativeQuery = true)
19
+    List<DictionaryEntity> selectDictionaryByKey(String key);
20
+
21
+    @Query(value = "SELECT id FROM itsm_base_dictionary g WHERE g._key =:_key and g._value =:_value",nativeQuery = true)
22
+    Long selectDictionaryByKeyValueId(@Param("_key")String _key, @Param("_value")String _value);
23
+
24
+    @Query(value = "SELECT _value FROM itsm_base_dictionary g WHERE g._key =:_key and g._desc =:_desc limit 1",nativeQuery = true)
25
+    String selectDictionaryByKeyDescValue(@Param("_key")String _key, @Param("_desc")String _desc);
26
+}

+ 18 - 0
src/main/java/com/dashitech/businessdata/dao/IDrugsBagDAO.java

@@ -0,0 +1,18 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.DrugsBagEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.query.Param;
7
+
8
+/**
9
+ * Created by chi on 2019/9/12.
10
+ */
11
+public interface IDrugsBagDAO  extends JpaRepository<DrugsBagEntity, String> {
12
+
13
+    @SuppressWarnings("unchecked")
14
+    DrugsBagEntity save(DrugsBagEntity drugsBagEntity);
15
+
16
+    @Query(value = "select id from DrugsBagEntity where packid=:packid")
17
+    Long selectIdByPackid(@Param("packid")String packid);
18
+}

+ 15 - 0
src/main/java/com/dashitech/businessdata/dao/IDrugsDAO.java

@@ -0,0 +1,15 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.DrugsEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+
6
+/**
7
+ * Created by chi on 2019/9/10.
8
+ */
9
+public interface IDrugsDAO extends JpaRepository<DrugsEntity, String> {
10
+
11
+    @SuppressWarnings("unchecked")
12
+    DrugsEntity save(DrugsEntity drugsEntity);
13
+
14
+
15
+}

+ 19 - 0
src/main/java/com/dashitech/businessdata/dao/IHospitalConfigDAO.java

@@ -0,0 +1,19 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.HospitalConfig;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Query;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * Created by xuweihua on 2021/5/8.
11
+ */
12
+public interface IHospitalConfigDAO  extends JpaRepository<HospitalConfig, String> {
13
+    @SuppressWarnings("unchecked")
14
+    HospitalConfig save(HospitalConfig hospitalConfig);
15
+
16
+    @Query(value = "select * from itsm_system_hospital_config where _active = 1 and _key LIKE CONCAT(?1,'%') and hos_id = ?2",nativeQuery = true)
17
+    List<HospitalConfig> getHospitalConfigList(String key,String hosid);
18
+
19
+}

+ 38 - 0
src/main/java/com/dashitech/businessdata/dao/IInspectDAO.java

@@ -0,0 +1,38 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.InspectEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Modifying;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.query.Param;
8
+import org.springframework.transaction.annotation.Transactional;
9
+
10
+import java.util.List;
11
+
12
+/**
13
+ * Created by chi on 2019/9/12.
14
+ */
15
+public interface IInspectDAO  extends JpaRepository<InspectEntity, String> {
16
+
17
+    @SuppressWarnings("unchecked")
18
+    InspectEntity save(InspectEntity inspectEntity);
19
+
20
+    @Query(value = "select id from InspectEntity where inspectCode=:inspectCode")
21
+    Long selectIdByInspectCode(@Param("inspectCode")String inspectCode);
22
+
23
+    @Query(value = "select ie from InspectEntity ie where ie.inspectCode=:inspectCode")
24
+    List<InspectEntity> selectInspectByInspectCode(@Param("inspectCode")String inspectCode);
25
+
26
+    @Query(value = "select ie from InspectEntity ie where ie.inspectCode like CONCAT(:inspectCode,'%')")
27
+    List<InspectEntity> selectInspectByInspectCodeLike(@Param("inspectCode")String inspectCode);
28
+
29
+    @Query(value = "select ie from InspectEntity ie where ie.inspectState in (307,443) and ie.patientCode=:patientCode")
30
+    List<InspectEntity> selectInspectByPatientCode(@Param("patientCode")String patientCode);
31
+
32
+    @Modifying
33
+    @Transactional
34
+    @Query(value = "UPDATE itsm_transport_inspect set yytime = ?2 WHERE inspect_code = ?1",nativeQuery = true)
35
+    int upInspectYyTime(String inspectCode,String yytime);
36
+
37
+
38
+}

+ 18 - 0
src/main/java/com/dashitech/businessdata/dao/IJPBagDAO.java

@@ -0,0 +1,18 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.JPBagEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.query.Param;
7
+
8
+/**
9
+ * Created by chi on 2019/9/12.
10
+ */
11
+public interface IJPBagDAO extends JpaRepository<JPBagEntity, String> {
12
+
13
+    @SuppressWarnings("unchecked")
14
+    JPBagEntity save(JPBagEntity jpBagEntity);
15
+
16
+    @Query(value = "select id from JPBagEntity where packid=:packid")
17
+    Long selectIdByPackid(@Param("packid")String packid);
18
+}

+ 12 - 0
src/main/java/com/dashitech/businessdata/dao/IJPDetailsDAO.java

@@ -0,0 +1,12 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.JPDetailsEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+
6
+/**
7
+ * Created by chi on 2019/9/12.
8
+ */
9
+public interface IJPDetailsDAO extends JpaRepository<JPDetailsEntity, String> {
10
+    @SuppressWarnings("unchecked")
11
+    JPDetailsEntity save(JPDetailsEntity jpDetailsEntity);
12
+}

+ 33 - 0
src/main/java/com/dashitech/businessdata/dao/IPatientDAO.java

@@ -0,0 +1,33 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.PatientEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Modifying;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.transaction.annotation.Transactional;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * Created by chi on 2019/9/11.
13
+ */
14
+public interface IPatientDAO extends JpaRepository<PatientEntity, String> {
15
+
16
+    @SuppressWarnings("unchecked")
17
+    PatientEntity save(PatientEntity patientEntity);
18
+
19
+    //@Query(value = "select id from PatientEntity where patientcode =?1 limit 1 ")
20
+    @Query(value = "select id from itsm_patient where patientcode =?1 limit 1 ",nativeQuery = true)
21
+    Integer selectIdByCode(String code);
22
+
23
+    @Query(value = "select * from itsm_patient where bednum is not null and pinyin is null",nativeQuery = true)
24
+    List<PatientEntity> selectPatient();
25
+
26
+    @Query(value = "select * from itsm_patient where patientcode =?1 limit 1 ",nativeQuery = true)
27
+    PatientEntity selectPatientByCode(String code);
28
+
29
+    @Modifying
30
+    @Transactional
31
+    @Query(value = "UPDATE itsm_patient set bednum = null WHERE patientcode <> ?1 and bednum = ?2 and roomnum = ?3 and department = ?4 ",nativeQuery = true)
32
+    int upPatientBednum(String patientcode,String bednum,String roomnum,Integer department);
33
+}

+ 20 - 0
src/main/java/com/dashitech/businessdata/dao/IPatientLogDAO.java

@@ -0,0 +1,20 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.PatientLogEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Modifying;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.transaction.annotation.Transactional;
8
+
9
+/**
10
+ * Created by xuweihua on 2021/1/13.
11
+ */
12
+public interface IPatientLogDAO extends JpaRepository<PatientLogEntity, String> {
13
+    @SuppressWarnings("unchecked")
14
+    PatientLogEntity save(PatientLogEntity patientLogEntity);
15
+
16
+    @Modifying
17
+    @Transactional
18
+    @Query(value = "DELETE FROM itsm_patient_log WHERE time < date_add(now(),interval-1 month)",nativeQuery = true)
19
+    int deletePatientLog();
20
+}

+ 41 - 0
src/main/java/com/dashitech/businessdata/dao/ISpecimenDAO.java

@@ -0,0 +1,41 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.SpecimenEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Modifying;
6
+import org.springframework.data.jpa.repository.Query;
7
+import org.springframework.data.repository.query.Param;
8
+import org.springframework.transaction.annotation.Transactional;
9
+
10
+import java.util.List;
11
+
12
+/**
13
+ * Created by chi on 2019/9/10.
14
+ */
15
+public interface ISpecimenDAO extends JpaRepository<SpecimenEntity, String> {
16
+
17
+    @SuppressWarnings("unchecked")
18
+    SpecimenEntity save(SpecimenEntity specimen);
19
+
20
+    @Query(value = "select se from SpecimenEntity se where id=:id")
21
+    SpecimenEntity getById(@Param("id") Long id);
22
+
23
+    @Query(value = "select id from SpecimenEntity where scode=:scode")
24
+    Long selectIdByScode(@Param("scode")String scode);
25
+
26
+    @Query(value = "SELECT id FROM itsm_uc_hospital WHERE _hos_no =?1 AND delete_flag = 0 ", nativeQuery = true)
27
+    Long getHosIdByCode(String gender);
28
+
29
+    @Query(value = "select se from SpecimenEntity se where se.orderNumber=:orderNumber")
30
+    List<SpecimenEntity> selectListByorderNumber(@Param("orderNumber")String orderNumber);
31
+
32
+    @Modifying
33
+    @Transactional
34
+    @Query(value = "UPDATE itsm_transport_specimen set spe_state = ?1 WHERE patient_no = ?2 and spe_state = 332 and gdid is null",nativeQuery = true)
35
+    int upSpecimenState(Long state,Integer patientNo);
36
+
37
+    @Modifying
38
+    @Transactional
39
+    @Query(value = "update itsm_transport_specimen SET spe_state = (SELECT id from itsm_base_dictionary WHERE _key = 'speState' and _value = '110') WHERE spe_state = (SELECT id from itsm_base_dictionary WHERE _key = 'speState' and _value = '1') and print_date <= date_add(now(),interval-1 day)",nativeQuery = true)
40
+    int upSpecimenState();
41
+}

+ 22 - 0
src/main/java/com/dashitech/businessdata/dao/ISpecimenHistoryDAO.java

@@ -0,0 +1,22 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.SpecimenEntity;
4
+import com.dashitech.businessdata.entity.SpecimenHistoryEntity;
5
+import org.springframework.data.jpa.repository.JpaRepository;
6
+import org.springframework.data.jpa.repository.Modifying;
7
+import org.springframework.data.jpa.repository.Query;
8
+import org.springframework.transaction.annotation.Transactional;
9
+
10
+/**
11
+ * Created by xuweihua on 2020/12/17.
12
+ */
13
+public interface ISpecimenHistoryDAO  extends JpaRepository<SpecimenHistoryEntity, String> {
14
+    @SuppressWarnings("unchecked")
15
+    SpecimenEntity save(SpecimenEntity specimen);
16
+
17
+
18
+    @Modifying
19
+    @Transactional
20
+    @Query(value = "DELETE FROM itsm_specimen_history WHERE creat_time < date_add(now(),interval-1 month)",nativeQuery = true)
21
+    int deleteSpecimenHistoryLog();
22
+}

+ 19 - 0
src/main/java/com/dashitech/businessdata/dao/ISystemConfigureDAO.java

@@ -0,0 +1,19 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.SystemConfigureEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Query;
6
+import org.springframework.data.repository.query.Param;
7
+
8
+/**
9
+ * Created by chi on 2020/8/25.
10
+ */
11
+public interface ISystemConfigureDAO extends JpaRepository<SystemConfigureEntity, String> {
12
+    @SuppressWarnings("unchecked")
13
+    SystemConfigureEntity save(SystemConfigureEntity systemConfigureEntity);
14
+
15
+    @Query(value = "select valueconfig from SystemConfigureEntity where keyconfig=:keyconfig")
16
+    String selectValueByKey(@Param("keyconfig")String keyconfig);
17
+
18
+
19
+}

+ 24 - 0
src/main/java/com/dashitech/businessdata/dao/IUserDAO.java

@@ -0,0 +1,24 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.UserEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Query;
6
+
7
+/**
8
+ * Created by chi on 2019/9/12.
9
+ */
10
+public interface IUserDAO extends JpaRepository<UserEntity, String> {
11
+
12
+    @SuppressWarnings("unchecked")
13
+    UserEntity save(UserEntity userEntity);
14
+
15
+    //@Query(value = "select id from UserEntity where ACCOUNT =?1")
16
+    @Query(value = "select id from itsm_uc_user where ACCOUNT =?1 limit 1",nativeQuery = true)
17
+    Long selectIdByAccount(String account);
18
+
19
+    @Query(value = "SELECT id FROM itsm_base_dictionary WHERE _key='user_gender' and _value =?1", nativeQuery = true)
20
+    Long getGenderIdById(String gender);
21
+
22
+    @Query(value = "select * from itsm_uc_user where ACCOUNT =?1 limit 1",nativeQuery = true)
23
+    UserEntity selectByAccount(String account);
24
+}

+ 20 - 0
src/main/java/com/dashitech/businessdata/dao/IWorkOrderDAO.java

@@ -0,0 +1,20 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import com.dashitech.businessdata.entity.WorkOrderEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.data.jpa.repository.Query;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * Created by xuweihua on 2020/11/20.
11
+ */
12
+public interface IWorkOrderDAO  extends JpaRepository<WorkOrderEntity, String> {
13
+    @SuppressWarnings("unchecked")
14
+    WorkOrderEntity save(WorkOrderEntity workOrderEntity);
15
+
16
+    @Query(value = "select * from itsm_transport_workorder where patientId =?1 and gdstate in(69,70,71,433) " +
17
+            "and task_type_id in (SELECT id from itsm_task_type WHERE delete_flag = 0 and association_type_id = " +
18
+            "(SELECT id from itsm_base_dictionary WHERE _key = 'association_types' and _value = 'inspect' LIMIT 1))",nativeQuery = true)
19
+    List<WorkOrderEntity> selectWorkOrderByPatientId(String patientId);
20
+}

+ 41 - 0
src/main/java/com/dashitech/businessdata/dao/TestDao.java

@@ -0,0 +1,41 @@
1
+package com.dashitech.businessdata.dao;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.jdbc.core.JdbcTemplate;
5
+import org.springframework.stereotype.Service;
6
+
7
+import java.util.List;
8
+import java.util.Map;
9
+
10
+
11
+/**
12
+ * Created by chi on 2019/9/26.
13
+ */
14
+@Service
15
+public class TestDao {
16
+
17
+    @Autowired
18
+    private JdbcTemplate jdbcTemplate;
19
+    /*     
20
+     *不指定数据源使用默认数据源
21
+     *
22
+    *@return
23
+     */
24
+
25
+//    public List<CallOnEntity> getList1() {
26
+//
27
+//        String sql = "select * from itsm_transport_callon";
28
+//        List<Map<String, Object>> callOnEntities = jdbcTemplate.queryForList(sql);
29
+//
30
+//        return null;
31
+//    }
32
+//
33
+//    public List<CallOnEntity> getList2() {
34
+//
35
+//        String sql = "select * from itsm_transport_callon";
36
+//        List<Map<String, Object>> callOnEntities = jdbcTemplate.queryForList(sql);
37
+//
38
+//        return null;
39
+//    }
40
+
41
+}

+ 165 - 0
src/main/java/com/dashitech/businessdata/entity/CallLogEntity.java

@@ -0,0 +1,165 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+import org.springframework.format.annotation.DateTimeFormat;
5
+
6
+import javax.persistence.*;
7
+import java.io.Serializable;
8
+import java.util.Date;
9
+
10
+/**
11
+ * Created by chi on 2020/8/25.
12
+ */
13
+
14
+@Entity
15
+@Table(name = "itsm_call_log")
16
+public class CallLogEntity implements Serializable {
17
+
18
+    private static final long serialVersionUID = 1L;
19
+
20
+    @Id
21
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
22
+    @Column(name="id",length = 20)
23
+    private Long id;
24
+
25
+    @I18n("version")
26
+    @Column(name = "verion")
27
+    private Integer version;
28
+
29
+    @I18n("来电科室")
30
+    @Column(name = "call_dept")
31
+    private String callDept;
32
+
33
+    @I18n("通道号")
34
+    @Column(name = "phyIDA")
35
+    private String phyIDA;
36
+
37
+    @I18n("主叫号码")
38
+    @Column(name = "DTMFA")
39
+    private String dTMFA;
40
+
41
+    @I18n("被叫号码")
42
+    @Column(name = "DTMFB")
43
+    private String dTMFB;
44
+
45
+    @I18n("录音起始时间")
46
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
47
+    @Column(name = "response_time")
48
+    private Date responseTime;
49
+
50
+    @I18n("录音时长单位秒")
51
+    @Column(name = "long_time")
52
+    private String longTime;
53
+
54
+    @I18n("原文件存放位置")
55
+    @Column(name = "_path")
56
+    private String path;
57
+
58
+    @I18n("呼入呼出 1 呼入 0 呼出")
59
+    @Column(name = "call_type")
60
+    private Integer callType;
61
+
62
+    @I18n("已接未接 1 已接 0 未接")
63
+    @Column(name = "call_state")
64
+    private Integer callState;
65
+
66
+    @I18n("院区id")
67
+    @Column(name = "hos_id")
68
+    private Integer hosId;
69
+
70
+    public Integer getHosId() {
71
+        return hosId;
72
+    }
73
+
74
+    public void setHosId(Integer hosId) {
75
+        this.hosId = hosId;
76
+    }
77
+
78
+    public Long getId() {
79
+        return id;
80
+    }
81
+
82
+    public void setId(Long id) {
83
+        this.id = id;
84
+    }
85
+
86
+    public String getCallDept() {
87
+        return callDept;
88
+    }
89
+
90
+    public void setCallDept(String callDept) {
91
+        this.callDept = callDept;
92
+    }
93
+
94
+    public String getPhyIDA() {
95
+        return phyIDA;
96
+    }
97
+
98
+    public void setPhyIDA(String phyIDA) {
99
+        this.phyIDA = phyIDA;
100
+    }
101
+
102
+    public String getdTMFA() {
103
+        return dTMFA;
104
+    }
105
+
106
+    public void setdTMFA(String dTMFA) {
107
+        this.dTMFA = dTMFA;
108
+    }
109
+
110
+    public String getdTMFB() {
111
+        return dTMFB;
112
+    }
113
+
114
+    public void setdTMFB(String dTMFB) {
115
+        this.dTMFB = dTMFB;
116
+    }
117
+
118
+    public Date getResponseTime() {
119
+        return responseTime;
120
+    }
121
+
122
+    public void setResponseTime(Date responseTime) {
123
+        this.responseTime = responseTime;
124
+    }
125
+
126
+    public String getLongTime() {
127
+        return longTime;
128
+    }
129
+
130
+    public void setLongTime(String longTime) {
131
+        this.longTime = longTime;
132
+    }
133
+
134
+    public String getPath() {
135
+        return path;
136
+    }
137
+
138
+    public void setPath(String path) {
139
+        this.path = path;
140
+    }
141
+
142
+    public Integer getCallType() {
143
+        return callType;
144
+    }
145
+
146
+    public void setCallType(Integer callType) {
147
+        this.callType = callType;
148
+    }
149
+
150
+    public Integer getCallState() {
151
+        return callState;
152
+    }
153
+
154
+    public void setCallState(Integer callState) {
155
+        this.callState = callState;
156
+    }
157
+
158
+    public Integer getVersion() {
159
+        return version;
160
+    }
161
+
162
+    public void setVersion(Integer version) {
163
+        this.version = version;
164
+    }
165
+}

+ 167 - 0
src/main/java/com/dashitech/businessdata/entity/DepartmentEntity.java

@@ -0,0 +1,167 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+
5
+import javax.persistence.*;
6
+import java.io.Serializable;
7
+
8
+/**
9
+ *  hospital 主表为id,这里为编码
10
+ */
11
+
12
+@Entity
13
+@Table(name = "itsm_uc_dept")
14
+public class DepartmentEntity implements Serializable {
15
+
16
+	private static final long serialVersionUID = 1L;
17
+
18
+	@Id
19
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
20
+	@Column(name="id",length = 20)
21
+	private Long id;
22
+
23
+	@I18n("科室名")
24
+	@Column(name="dept")
25
+	private String dept;
26
+
27
+	@I18n("科室编码")
28
+	@Column(name="code")
29
+	private String pcode;
30
+
31
+
32
+	@I18n("删除标识")
33
+	@Column(name = "delete_flag")
34
+	private Integer deleteFlag;
35
+
36
+	@I18n("科室别名")
37
+	@Column(name = "dept_alias")
38
+	private String deptalias;
39
+
40
+
41
+	@I18n("科室类型,检查科室1、检验科室2、临床科室3、其他科室4")
42
+	@Column(name = "_type")
43
+	private String type;
44
+
45
+	@I18n("科室位置")
46
+	@Column(name = "_address")
47
+	private String address;
48
+
49
+	@I18n("所属院区")
50
+	@Column(name = "_hospital_id")
51
+	private Long hospital;
52
+
53
+	@I18n("电话号码")
54
+	@Column(name = "_phone")
55
+	private String phone;
56
+
57
+	@I18n("开头字母拼音")
58
+	@Column(name = "input_code")
59
+	private String inputCode;
60
+
61
+	@I18n("全拼")
62
+	@Column(name = "pinyin")
63
+	private String pinyin;
64
+
65
+	public String getInputCode() {
66
+		return inputCode;
67
+	}
68
+
69
+	public void setInputCode(String inputCode) {
70
+		this.inputCode = inputCode;
71
+	}
72
+
73
+	public String getPinyin() {
74
+		return pinyin;
75
+	}
76
+
77
+	public void setPinyin(String pinyin) {
78
+		this.pinyin = pinyin;
79
+	}
80
+
81
+	public Long getId() {
82
+		return id;
83
+	}
84
+
85
+	public void setId(Long id) {
86
+		this.id = id;
87
+	}
88
+
89
+	public String getDept() {
90
+		return dept;
91
+	}
92
+
93
+	public void setDept(String dept) {
94
+		this.dept = dept;
95
+	}
96
+
97
+	public String getPcode() {
98
+		return pcode;
99
+	}
100
+
101
+	public void setPcode(String pcode) {
102
+		this.pcode = pcode;
103
+	}
104
+
105
+	public Integer getDeleteFlag() {
106
+		return deleteFlag;
107
+	}
108
+
109
+	public void setDeleteFlag(Integer deleteFlag) {
110
+		this.deleteFlag = deleteFlag;
111
+	}
112
+
113
+	public String getDeptalias() {
114
+		return deptalias;
115
+	}
116
+
117
+	public void setDeptalias(String deptalias) {
118
+		this.deptalias = deptalias;
119
+	}
120
+
121
+	public String getType() {
122
+		return type;
123
+	}
124
+
125
+	public void setType(String type) {
126
+		this.type = type;
127
+	}
128
+
129
+	public String getAddress() {
130
+		return address;
131
+	}
132
+
133
+	public void setAddress(String address) {
134
+		this.address = address;
135
+	}
136
+
137
+	public Long getHospital() {
138
+		return hospital;
139
+	}
140
+
141
+	public void setHospital(Long hospital) {
142
+		this.hospital = hospital;
143
+	}
144
+
145
+	public String getPhone() {
146
+		return phone;
147
+	}
148
+
149
+	public void setPhone(String phone) {
150
+		this.phone = phone;
151
+	}
152
+
153
+	@Override
154
+	public String toString() {
155
+		return "DepartmentEntity{" +
156
+				"id=" + id +
157
+				", dept='" + dept + '\'' +
158
+				", pcode='" + pcode + '\'' +
159
+				", deleteFlag=" + deleteFlag +
160
+				", deptalias='" + deptalias + '\'' +
161
+				", type='" + type + '\'' +
162
+				", address='" + address + '\'' +
163
+				", hospital=" + hospital +
164
+				", phone='" + phone + '\'' +
165
+				'}';
166
+	}
167
+}

+ 225 - 0
src/main/java/com/dashitech/businessdata/entity/DictionaryEntity.java

@@ -0,0 +1,225 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import javax.persistence.*;
4
+import java.io.Serializable;
5
+import java.util.Date;
6
+
7
+/**
8
+ * Created by chi on 2020/8/25.
9
+ */
10
+
11
+@Entity
12
+@Table(name = "itsm_base_dictionary")
13
+public class DictionaryEntity implements Serializable {
14
+
15
+    private static final long serialVersionUID = 1L;
16
+
17
+    @Id
18
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
19
+    @Column(name="id",length = 20)
20
+    private Long id;
21
+
22
+    /**
23
+     * 所属模块
24
+     */
25
+    @Column(name="model")
26
+    private String model;
27
+
28
+    /**
29
+     * key
30
+     */
31
+    @Column(name="_key")
32
+    private String key;
33
+
34
+    /**
35
+     * 显示名称
36
+     */
37
+    @Column(name="_name")
38
+    private String name;
39
+
40
+    /**
41
+     * 值
42
+     */
43
+    @Column(name="_value")
44
+    private String value;
45
+
46
+    /**
47
+     * 描述
48
+     */
49
+    @Column(name="_desc")
50
+    private String desc;
51
+
52
+    /**
53
+     * 排序
54
+     */
55
+    @Column(name="orders")
56
+    private Integer orders;
57
+
58
+    /**
59
+     * 是否已删除,1删除,0正常
60
+     */
61
+    @Column(name = "deleted",columnDefinition = "BIT")
62
+    private Boolean deleted = false;
63
+
64
+    /**
65
+     * 是不是系统字段
66
+     */
67
+    @Column(name="system",columnDefinition = "BIT")
68
+    private Boolean system = false;
69
+
70
+    /**
71
+     * 添加时间
72
+     */
73
+    @Column(name="add_time")
74
+    private Date addTime = new Date();
75
+
76
+    /**
77
+     * 修改时间
78
+     */
79
+    @Column(name="up_time")
80
+    private Date upTime;
81
+
82
+    /**
83
+     * 修改人
84
+     */
85
+    @Column(name="operator")
86
+    private String operator;
87
+
88
+    /**
89
+     * 拼音简写
90
+     */
91
+    @Column(name="input_code")
92
+    private String inputcode;
93
+
94
+    /**
95
+     * 扩展字段1
96
+     */
97
+    @Column(name = "extra1")
98
+    private String extra1;
99
+
100
+    /**
101
+     * 扩展字段2
102
+     */
103
+    @Column(name = "extra2")
104
+    private String extra2;
105
+
106
+    public Long getId() {
107
+        return id;
108
+    }
109
+
110
+    public void setId(Long id) {
111
+        this.id = id;
112
+    }
113
+
114
+    public String getModel() {
115
+        return model;
116
+    }
117
+
118
+    public void setModel(String model) {
119
+        this.model = model;
120
+    }
121
+
122
+    public String getKey() {
123
+        return key;
124
+    }
125
+
126
+    public void setKey(String key) {
127
+        this.key = key;
128
+    }
129
+
130
+    public String getName() {
131
+        return name;
132
+    }
133
+
134
+    public void setName(String name) {
135
+        this.name = name;
136
+    }
137
+
138
+    public String getValue() {
139
+        return value;
140
+    }
141
+
142
+    public void setValue(String value) {
143
+        this.value = value;
144
+    }
145
+
146
+    public String getDesc() {
147
+        return desc;
148
+    }
149
+
150
+    public void setDesc(String desc) {
151
+        this.desc = desc;
152
+    }
153
+
154
+    public Integer getOrders() {
155
+        return orders;
156
+    }
157
+
158
+    public void setOrders(Integer orders) {
159
+        this.orders = orders;
160
+    }
161
+
162
+    public Boolean getDeleted() {
163
+        return deleted;
164
+    }
165
+
166
+    public void setDeleted(Boolean deleted) {
167
+        this.deleted = deleted;
168
+    }
169
+
170
+    public Boolean getSystem() {
171
+        return system;
172
+    }
173
+
174
+    public void setSystem(Boolean system) {
175
+        this.system = system;
176
+    }
177
+
178
+    public Date getAddTime() {
179
+        return addTime;
180
+    }
181
+
182
+    public void setAddTime(Date addTime) {
183
+        this.addTime = addTime;
184
+    }
185
+
186
+    public Date getUpTime() {
187
+        return upTime;
188
+    }
189
+
190
+    public void setUpTime(Date upTime) {
191
+        this.upTime = upTime;
192
+    }
193
+
194
+    public String getOperator() {
195
+        return operator;
196
+    }
197
+
198
+    public void setOperator(String operator) {
199
+        this.operator = operator;
200
+    }
201
+
202
+    public String getInputcode() {
203
+        return inputcode;
204
+    }
205
+
206
+    public void setInputcode(String inputcode) {
207
+        this.inputcode = inputcode;
208
+    }
209
+
210
+    public String getExtra1() {
211
+        return extra1;
212
+    }
213
+
214
+    public void setExtra1(String extra1) {
215
+        this.extra1 = extra1;
216
+    }
217
+
218
+    public String getExtra2() {
219
+        return extra2;
220
+    }
221
+
222
+    public void setExtra2(String extra2) {
223
+        this.extra2 = extra2;
224
+    }
225
+}

+ 145 - 0
src/main/java/com/dashitech/businessdata/entity/DrugsBagEntity.java

@@ -0,0 +1,145 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+import org.springframework.format.annotation.DateTimeFormat;
5
+
6
+import javax.persistence.*;
7
+import java.io.Serializable;
8
+import java.util.Date;
9
+
10
+/**
11
+ * Created by chi on 2019/9/12.
12
+ * 药品大包表
13
+ *
14
+ * launch、target 这里为编码 主表为id
15
+ */
16
+@Entity
17
+@Table(name = "itsm_transport_drugs_bag")
18
+public class DrugsBagEntity implements Serializable {
19
+
20
+    private static final long serialVersionUID = 1L;
21
+    @Id
22
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
23
+    @Column(name="id",length = 20)
24
+    private Long id;
25
+
26
+    @I18n("来源科室(发药科室),这里为编码 主表为id")
27
+    @Column(name="launch")
28
+    private String launch;
29
+
30
+    @I18n("目标科室(申请科室),这里为编码 主表为id")
31
+    @Column(name="target")
32
+    private String target;
33
+
34
+    @I18n("药品包号")
35
+    @Column(name = "packid")
36
+    private String packid;
37
+
38
+    @I18n("药品状态")
39
+    @Column(name = "drugs_state")
40
+    private Long drugsState;
41
+
42
+    @I18n("打包时间")
43
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
44
+    @Column(name = "pack_time")
45
+    private Date packTime;
46
+
47
+    @I18n("批次创建时间")
48
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
49
+    @Column(name = "creat_time")
50
+    private Date creatTime;
51
+
52
+    @I18n("批次号")
53
+    @Column(name = "batch_No")
54
+    private String batchNo;
55
+
56
+    @I18n("院区编码")
57
+    @Column(name = "hos_id")
58
+    private String hosId;
59
+
60
+    public String getHosId() {
61
+        return hosId;
62
+    }
63
+
64
+    public void setHosId(String hosId) {
65
+        this.hosId = hosId;
66
+    }
67
+
68
+    public String getLaunch() {
69
+        return launch;
70
+    }
71
+
72
+    public void setLaunch(String launch) {
73
+        this.launch = launch;
74
+    }
75
+
76
+    public String getTarget() {
77
+        return target;
78
+    }
79
+
80
+    public void setTarget(String target) {
81
+        this.target = target;
82
+    }
83
+
84
+    public String getPackid() {
85
+        return packid;
86
+    }
87
+
88
+    public void setPackid(String packid) {
89
+        this.packid = packid;
90
+    }
91
+
92
+    public Long getDrugsState() {
93
+        return drugsState;
94
+    }
95
+
96
+    public void setDrugsState(Long drugsState) {
97
+        this.drugsState = drugsState;
98
+    }
99
+
100
+    public Date getPackTime() {
101
+        return packTime;
102
+    }
103
+
104
+    public void setPackTime(Date packTime) {
105
+        this.packTime = packTime;
106
+    }
107
+
108
+    public Long getId() {
109
+        return id;
110
+    }
111
+
112
+    public void setId(Long id) {
113
+        this.id = id;
114
+    }
115
+
116
+    public Date getCreatTime() {
117
+        return creatTime;
118
+    }
119
+
120
+    public void setCreatTime(Date creatTime) {
121
+        this.creatTime = creatTime;
122
+    }
123
+
124
+    public String getBatchNo() {
125
+        return batchNo;
126
+    }
127
+
128
+    public void setBatchNo(String batchNo) {
129
+        this.batchNo = batchNo;
130
+    }
131
+
132
+    @Override
133
+    public String toString() {
134
+        return "DrugsBagEntity{" +
135
+                "id=" + id +
136
+                ", launch='" + launch + '\'' +
137
+                ", target='" + target + '\'' +
138
+                ", packid='" + packid + '\'' +
139
+                ", drugsState=" + drugsState +
140
+                ", packTime=" + packTime +
141
+                ", creatTime=" + creatTime +
142
+                ", batchNo='" + batchNo + '\'' +
143
+                '}';
144
+    }
145
+}

+ 137 - 0
src/main/java/com/dashitech/businessdata/entity/DrugsEntity.java

@@ -0,0 +1,137 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+
5
+import javax.persistence.*;
6
+import java.io.Serializable;
7
+
8
+/**
9
+ * Created by chi on 2019/9/10.
10
+ */
11
+@Entity
12
+@Table(name = "itsm_transport_drugs")
13
+public class DrugsEntity implements Serializable {
14
+
15
+    private static final long serialVersionUID = 1L;
16
+
17
+    @Id
18
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
19
+    @Column(name="id",length = 20)
20
+    private Integer id;
21
+
22
+    @I18n("病人唯一标识")
23
+    @Column(name = "patient_no")
24
+    private String patientNo;
25
+
26
+    @I18n("病人信息")
27
+    @Column(name = "patient_info")
28
+    private String patientInfo;
29
+
30
+    @I18n("药品具体信息")
31
+    @Column(name = "drugs_info")
32
+    private String drugsInfo;
33
+
34
+    @I18n("药品计量")
35
+    @Column(name = "drugs_num")
36
+    private Integer drugsNum;
37
+
38
+    @I18n("打包号批次号")
39
+    @Column(name = "bag_id")
40
+    private Long bagId;
41
+
42
+    @I18n("床号")
43
+    @Column(name = "bed_num")
44
+    private String bedNum;
45
+
46
+    @I18n("院区编码")
47
+    @Column(name = "hos_id")
48
+    private String hosId;
49
+
50
+    @I18n("药品类型")
51
+    @Column(name = "drug_type")
52
+    private String drugType;
53
+
54
+    public String getDrugType() {
55
+        return drugType;
56
+    }
57
+
58
+    public void setDrugType(String drugType) {
59
+        this.drugType = drugType;
60
+    }
61
+
62
+    public String getHosId() {
63
+        return hosId;
64
+    }
65
+
66
+    public void setHosId(String hosId) {
67
+        this.hosId = hosId;
68
+    }
69
+    public Integer getId() {
70
+        return id;
71
+    }
72
+
73
+    public void setId(Integer id) {
74
+        this.id = id;
75
+    }
76
+
77
+    public String getPatientNo() {
78
+        return patientNo;
79
+    }
80
+
81
+    public void setPatientNo(String patientNo) {
82
+        this.patientNo = patientNo;
83
+    }
84
+
85
+    public String getPatientInfo() {
86
+        return patientInfo;
87
+    }
88
+
89
+    public void setPatientInfo(String patientInfo) {
90
+        this.patientInfo = patientInfo;
91
+    }
92
+
93
+    public String getDrugsInfo() {
94
+        return drugsInfo;
95
+    }
96
+
97
+    public void setDrugsInfo(String drugsInfo) {
98
+        this.drugsInfo = drugsInfo;
99
+    }
100
+
101
+    public Integer getDrugsNum() {
102
+        return drugsNum;
103
+    }
104
+
105
+    public void setDrugsNum(Integer drugsNum) {
106
+        this.drugsNum = drugsNum;
107
+    }
108
+
109
+    public Long getBagId() {
110
+        return bagId;
111
+    }
112
+
113
+    public void setBagId(Long bagId) {
114
+        this.bagId = bagId;
115
+    }
116
+
117
+    public String getBedNum() {
118
+        return bedNum;
119
+    }
120
+
121
+    public void setBedNum(String bedNum) {
122
+        this.bedNum = bedNum;
123
+    }
124
+
125
+    @Override
126
+    public String toString() {
127
+        return "DrugsEntity{" +
128
+                "id=" + id +
129
+                ", patientNo='" + patientNo + '\'' +
130
+                ", patientInfo='" + patientInfo + '\'' +
131
+                ", drugsInfo='" + drugsInfo + '\'' +
132
+                ", drugsNum=" + drugsNum +
133
+                ", bagId=" + bagId +
134
+                ", bedNum='" + bedNum + '\'' +
135
+                '}';
136
+    }
137
+}

+ 68 - 0
src/main/java/com/dashitech/businessdata/entity/HospitalConfig.java

@@ -0,0 +1,68 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+
5
+import javax.persistence.*;
6
+import java.io.Serializable;
7
+
8
+/**
9
+ * Created by xuweihua on 2021/5/8.
10
+ */
11
+@Entity
12
+@Table(name = "itsm_system_hospital_config")
13
+public class HospitalConfig  implements Serializable {
14
+    private static final long serialVersionUID = 1L;
15
+    @Id
16
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
17
+    @Column(name="id",length = 20)
18
+    private Integer id;
19
+
20
+    @Column(name = "_key")
21
+    private String key;
22
+    @Column(name = "_value")
23
+    private String value;
24
+    @Column(name = "_value2")
25
+    private String value2;
26
+    @Column(name = "hos_id")
27
+    private Long hosId;
28
+
29
+    public Integer getId() {
30
+        return id;
31
+    }
32
+
33
+    public void setId(Integer id) {
34
+        this.id = id;
35
+    }
36
+
37
+    public String getKey() {
38
+        return key;
39
+    }
40
+
41
+    public void setKey(String key) {
42
+        this.key = key;
43
+    }
44
+
45
+    public String getValue() {
46
+        return value;
47
+    }
48
+
49
+    public void setValue(String value) {
50
+        this.value = value;
51
+    }
52
+
53
+    public String getValue2() {
54
+        return value2;
55
+    }
56
+
57
+    public void setValue2(String value2) {
58
+        this.value2 = value2;
59
+    }
60
+
61
+    public Long getHosId() {
62
+        return hosId;
63
+    }
64
+
65
+    public void setHosId(Long hosId) {
66
+        this.hosId = hosId;
67
+    }
68
+}

+ 270 - 0
src/main/java/com/dashitech/businessdata/entity/InspectEntity.java

@@ -0,0 +1,270 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+import org.springframework.format.annotation.DateTimeFormat;
5
+
6
+import javax.persistence.*;
7
+import java.io.Serializable;
8
+import java.util.Date;
9
+
10
+/**
11
+ * Created by chi on 2019/9/12.
12
+ * 送检信息,病人检查
13
+ * execDept、applyDept 主表为id,这里是编码
14
+ */
15
+@Entity
16
+@Table(name = "itsm_transport_inspect")
17
+public class InspectEntity implements Serializable {
18
+    private static final long serialVersionUID = 1L;
19
+
20
+    @Id
21
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
22
+    @Column(name="id",length = 20)
23
+    private Long id;
24
+
25
+    @I18n("病人标识")
26
+    @Column(name = "patient_code")
27
+    private String patientCode;
28
+
29
+    @I18n("病人姓名")
30
+    @Column(name = "patient_name")
31
+    private String patientName;
32
+
33
+    @I18n("腕带条码")
34
+    @Column(name = "patient_bar_code")
35
+    private String barCode;
36
+
37
+    @I18n("状态")//待检查  待到达 待送达 检查中 已完成,申请
38
+    @Column(name="inspect_state")
39
+    private Integer inspectState;
40
+
41
+    @I18n("自定义检查状态")
42
+    @Column(name = "inspect_check_type")
43
+    private Integer inspectCheckType;
44
+
45
+    @I18n("申请检查单标识")
46
+    @Column(name = "inspect_code")
47
+    private String inspectCode;
48
+
49
+    @I18n("检查标识类型")
50
+    @Column(name = "inspect_type_code")
51
+    private String inspectTypeCode;
52
+
53
+    @I18n("检查类型名称")
54
+    @Column(name = "inspect_type_name")
55
+    private String inspectName;
56
+
57
+    @I18n("申请科室,主表为id这里为编码")
58
+    @Column(name="apply_dept")
59
+    private String applyDept;
60
+
61
+    @I18n("检查部位名称")
62
+    @Column(name = "inspect_bwname")
63
+    private String bwName;
64
+
65
+    @I18n("执行科室,主表为id这里为编码")
66
+    @Column(name="exec_Dept")
67
+    private String execDept;
68
+
69
+    @I18n("预约时间")
70
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
71
+    @Column(name = "yytime")
72
+    private Date yyTime;
73
+
74
+    @I18n("床号")
75
+    @Column(name = "bed_num")
76
+    private String bedNum;
77
+
78
+    @I18n("检查时间")
79
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
80
+    @Column(name = "inspect_time")
81
+    private Date inspectTime;
82
+
83
+    @I18n("检查人")
84
+    @Column(name = "inspector")
85
+    private String inspector;
86
+
87
+    @I18n("预约号码")
88
+    @Column(name = "reservation_number")
89
+    private String reservationNumber;
90
+
91
+    @I18n("优先级")
92
+    @Column(name = "priority")
93
+    private String priority;
94
+
95
+    @I18n("院区id")
96
+    @Column(name = "hos_id")
97
+    private Long hosId;
98
+
99
+    public Integer getInspectCheckType() {
100
+        return inspectCheckType;
101
+    }
102
+
103
+    public void setInspectCheckType(Integer inspectCheckType) {
104
+        this.inspectCheckType = inspectCheckType;
105
+    }
106
+
107
+    public Long getHosId() {
108
+        return hosId;
109
+    }
110
+
111
+    public void setHosId(Long hosId) {
112
+        this.hosId = hosId;
113
+    }
114
+
115
+    public String getPriority() {
116
+        return priority;
117
+    }
118
+
119
+    public void setPriority(String priority) {
120
+        this.priority = priority;
121
+    }
122
+
123
+    public String getReservationNumber() {
124
+        return reservationNumber;
125
+    }
126
+
127
+    public void setReservationNumber(String reservationNumber) {
128
+        this.reservationNumber = reservationNumber;
129
+    }
130
+
131
+    public String getInspectName() {
132
+        return inspectName;
133
+    }
134
+
135
+    public void setInspectName(String inspectName) {
136
+        this.inspectName = inspectName;
137
+    }
138
+
139
+    public Long getId() {
140
+        return id;
141
+    }
142
+
143
+    public void setId(Long id) {
144
+        this.id = id;
145
+    }
146
+
147
+    public String getPatientCode() {
148
+        return patientCode;
149
+    }
150
+
151
+    public void setPatientCode(String patientCode) {
152
+        this.patientCode = patientCode;
153
+    }
154
+
155
+    public String getPatientName() {
156
+        return patientName;
157
+    }
158
+
159
+    public void setPatientName(String patientName) {
160
+        this.patientName = patientName;
161
+    }
162
+
163
+    public String getBarCode() {
164
+        return barCode;
165
+    }
166
+
167
+    public void setBarCode(String barCode) {
168
+        this.barCode = barCode;
169
+    }
170
+
171
+    public Integer getInspectState() {
172
+        return inspectState;
173
+    }
174
+
175
+    public void setInspectState(Integer inspectState) {
176
+        this.inspectState = inspectState;
177
+    }
178
+
179
+    public String getInspectCode() {
180
+        return inspectCode;
181
+    }
182
+
183
+    public void setInspectCode(String inspectCode) {
184
+        this.inspectCode = inspectCode;
185
+    }
186
+
187
+    public String getInspectTypeCode() {
188
+        return inspectTypeCode;
189
+    }
190
+
191
+    public void setInspectTypeCode(String inspectTypeCode) {
192
+        this.inspectTypeCode = inspectTypeCode;
193
+    }
194
+
195
+    public String getBwName() {
196
+        return bwName;
197
+    }
198
+
199
+    public void setBwName(String bwName) {
200
+        this.bwName = bwName;
201
+    }
202
+
203
+    public Date getYyTime() {
204
+        return yyTime;
205
+    }
206
+
207
+    public void setYyTime(Date yyTime) {
208
+        this.yyTime = yyTime;
209
+    }
210
+
211
+    public String getBedNum() {
212
+        return bedNum;
213
+    }
214
+
215
+    public void setBedNum(String bedNum) {
216
+        this.bedNum = bedNum;
217
+    }
218
+
219
+    public Date getInspectTime() {
220
+        return inspectTime;
221
+    }
222
+
223
+    public void setInspectTime(Date inspectTime) {
224
+        this.inspectTime = inspectTime;
225
+    }
226
+
227
+    public String getInspector() {
228
+        return inspector;
229
+    }
230
+
231
+    public void setInspector(String inspector) {
232
+        this.inspector = inspector;
233
+    }
234
+
235
+    public String getApplyDept() {
236
+        return applyDept;
237
+    }
238
+
239
+    public void setApplyDept(String applyDept) {
240
+        this.applyDept = applyDept;
241
+    }
242
+
243
+    public String getExecDept() {
244
+        return execDept;
245
+    }
246
+
247
+    public void setExecDept(String execDept) {
248
+        this.execDept = execDept;
249
+    }
250
+
251
+    @Override
252
+    public String toString() {
253
+        return "InspectEntity{" +
254
+                "id=" + id +
255
+                ", patientCode='" + patientCode + '\'' +
256
+                ", patientName='" + patientName + '\'' +
257
+                ", barCode='" + barCode + '\'' +
258
+                ", inspectState=" + inspectState +
259
+                ", inspectCode='" + inspectCode + '\'' +
260
+                ", inspectTypeCode='" + inspectTypeCode + '\'' +
261
+                ", applyDept='" + applyDept + '\'' +
262
+                ", bwName='" + bwName + '\'' +
263
+                ", execDept='" + execDept + '\'' +
264
+                ", yyTime=" + yyTime +
265
+                ", bedNum='" + bedNum + '\'' +
266
+                ", inspectTime=" + inspectTime +
267
+                ", inspector='" + inspector + '\'' +
268
+                '}';
269
+    }
270
+}

+ 120 - 0
src/main/java/com/dashitech/businessdata/entity/JPBagEntity.java

@@ -0,0 +1,120 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+import org.springframework.format.annotation.DateTimeFormat;
5
+
6
+import javax.persistence.*;
7
+import java.io.Serializable;
8
+import java.util.Date;
9
+
10
+/**
11
+ * Created by chi on 2019/9/12.
12
+ * 静配大包表
13
+ * target、launch 这里为编码 主表为id
14
+ */
15
+@Entity
16
+@Table(name = "itsm_jp_bag")
17
+public class JPBagEntity implements Serializable {
18
+
19
+    private static final long serialVersionUID = 1L;
20
+
21
+    @Id
22
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
23
+    @Column(name="id",length = 20)
24
+    private Long id;
25
+
26
+    @I18n("大包id")
27
+    @Column(name = "packid")
28
+    private String packid;
29
+
30
+    @I18n("目标科室编码,这里为编码 主表为id(发起申请的临床科室编码)")
31
+    @Column(name = "target")
32
+    private String target;
33
+
34
+    @I18n("来源科室编码,这里为编码 主表为id(发药科室编码)")
35
+    @Column(name = "launch")
36
+    private String launch;
37
+
38
+    @I18n("大包创建时间")
39
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
40
+    @Column(name = "creat_time")
41
+    private Date creatTime;
42
+
43
+    @I18n("药品状态")
44
+    @Column(name = "jp_state")
45
+    private Integer jpState;
46
+
47
+    @I18n("院区编码")
48
+    @Column(name = "hos_id")
49
+    private String hosID;
50
+
51
+
52
+    public Long getId() {
53
+        return id;
54
+    }
55
+
56
+    public void setId(Long id) {
57
+        this.id = id;
58
+    }
59
+
60
+    public String getPackid() {
61
+        return packid;
62
+    }
63
+
64
+    public void setPackid(String packid) {
65
+        this.packid = packid;
66
+    }
67
+
68
+    public String getTarget() {
69
+        return target;
70
+    }
71
+
72
+    public void setTarget(String target) {
73
+        this.target = target;
74
+    }
75
+
76
+    public String getLaunch() {
77
+        return launch;
78
+    }
79
+
80
+    public void setLaunch(String launch) {
81
+        this.launch = launch;
82
+    }
83
+
84
+    public Date getCreatTime() {
85
+        return creatTime;
86
+    }
87
+
88
+    public void setCreatTime(Date creatTime) {
89
+        this.creatTime = creatTime;
90
+    }
91
+
92
+    public Integer getJpState() {
93
+        return jpState;
94
+    }
95
+
96
+    public void setJpState(Integer jpState) {
97
+        this.jpState = jpState;
98
+    }
99
+
100
+    public String getHosID() {
101
+        return hosID;
102
+    }
103
+
104
+    public void setHosID(String hosID) {
105
+        this.hosID = hosID;
106
+    }
107
+
108
+    @Override
109
+    public String toString() {
110
+        return "JPBagEntity{" +
111
+                "id=" + id +
112
+                ", packid='" + packid + '\'' +
113
+                ", target='" + target + '\'' +
114
+                ", launch='" + launch + '\'' +
115
+                ", creatTime=" + creatTime +
116
+                ", jpState=" + jpState +
117
+                ", hosID='" + hosID + '\'' +
118
+                '}';
119
+    }
120
+}

+ 114 - 0
src/main/java/com/dashitech/businessdata/entity/JPDetailsEntity.java

@@ -0,0 +1,114 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+
5
+import javax.persistence.*;
6
+import java.io.Serializable;
7
+
8
+/**
9
+ * Created by chi on 2019/9/12.
10
+ * 静配详情
11
+ */
12
+@Entity
13
+@Table(name = "itsm_jp_details")
14
+public class JPDetailsEntity implements Serializable {
15
+    private static final long serialVersionUID = 1L;
16
+
17
+    @Id
18
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
19
+    @Column(name="id",length = 20)
20
+    private Integer id;
21
+
22
+    @I18n("病人唯一标识")
23
+    @Column(name = "patient_no")
24
+    private String patientNo;
25
+
26
+    @I18n("病人信息")
27
+    @Column(name = "patient_info")
28
+    private String patientInfo;
29
+
30
+    @I18n("药品具体信息")
31
+    @Column(name = "jp_info")
32
+    private String jpInfo;
33
+
34
+    @I18n("药品计量")
35
+    @Column(name = "jp_num")
36
+    private Integer jpNum;
37
+
38
+    @I18n("关联大包,批次号")
39
+    @Column(name = "bag_id")
40
+    private Long bagId;
41
+
42
+    @I18n("床号")
43
+    @Column(name = "bed_num")
44
+    private String bedNum;
45
+
46
+    public Integer getId() {
47
+        return id;
48
+    }
49
+
50
+    public void setId(Integer id) {
51
+        this.id = id;
52
+    }
53
+
54
+    public String getPatientNo() {
55
+        return patientNo;
56
+    }
57
+
58
+    public void setPatientNo(String patientNo) {
59
+        this.patientNo = patientNo;
60
+    }
61
+
62
+    public String getPatientInfo() {
63
+        return patientInfo;
64
+    }
65
+
66
+    public void setPatientInfo(String patientInfo) {
67
+        this.patientInfo = patientInfo;
68
+    }
69
+
70
+    public String getJpInfo() {
71
+        return jpInfo;
72
+    }
73
+
74
+    public void setJpInfo(String jpInfo) {
75
+        this.jpInfo = jpInfo;
76
+    }
77
+
78
+    public Integer getJpNum() {
79
+        return jpNum;
80
+    }
81
+
82
+    public void setJpNum(Integer jpNum) {
83
+        this.jpNum = jpNum;
84
+    }
85
+
86
+    public Long getBagId() {
87
+        return bagId;
88
+    }
89
+
90
+    public void setBagId(Long bagId) {
91
+        this.bagId = bagId;
92
+    }
93
+
94
+    public String getBedNum() {
95
+        return bedNum;
96
+    }
97
+
98
+    public void setBedNum(String bedNum) {
99
+        this.bedNum = bedNum;
100
+    }
101
+
102
+    @Override
103
+    public String toString() {
104
+        return "JPDetailsEntity{" +
105
+                "id=" + id +
106
+                ", patientNo='" + patientNo + '\'' +
107
+                ", patientInfo='" + patientInfo + '\'' +
108
+                ", jpInfo='" + jpInfo + '\'' +
109
+                ", jpNum=" + jpNum +
110
+                ", bagId=" + bagId +
111
+                ", bedNum='" + bedNum + '\'' +
112
+                '}';
113
+    }
114
+}

+ 236 - 0
src/main/java/com/dashitech/businessdata/entity/PatientEntity.java

@@ -0,0 +1,236 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+import org.springframework.format.annotation.DateTimeFormat;
5
+
6
+import javax.persistence.*;
7
+import java.io.Serializable;
8
+import java.util.Date;
9
+
10
+/**
11
+ * Created by chi on 2019/9/11.
12
+ *
13
+ * department主表为id 这里为编码
14
+ */
15
+@Entity
16
+@Table(name = "itsm_patient")
17
+public class PatientEntity  implements Serializable {
18
+    private static final long serialVersionUID = 1L;
19
+
20
+    @Id
21
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
22
+    @Column(name="id",length = 20)
23
+    private Integer id;
24
+
25
+    @I18n("病人标识")
26
+    @Column(name = "patientcode")
27
+    private String patientcode;
28
+
29
+    @I18n("病人姓名")
30
+    @Column(name = "patientname")
31
+    private String patientname;
32
+
33
+    @I18n("住院科室id,主表为id这里为编码")
34
+    @Column(name = "department")
35
+    private Integer department;
36
+
37
+    @I18n("住院号")
38
+    @Column(name = "residence_no")
39
+    private String residenceNo;
40
+
41
+    @I18n("腕带条码")
42
+    @Column(name = "Bar_code")
43
+    private String barCode;
44
+
45
+    @I18n("房间号")
46
+    @Column(name = "roomnum")
47
+    private String roomnum;
48
+
49
+    @I18n("床号")
50
+    @Column(name = "bednum" )
51
+    private String bednum;
52
+
53
+    @I18n("年龄")
54
+    @Column(name = "age" )
55
+    private String age;
56
+
57
+    @Column(name = "VERSION" )
58
+    private Integer version;
59
+
60
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
61
+    @Column(name = "hospitalized_time" )
62
+    private Date hospitalizedTime;
63
+
64
+    @I18n("拼音")
65
+    @Column(name = "pinyin" )
66
+    private String pinyin;
67
+    @I18n("拼音简写")
68
+    @Column(name = "input_code" )
69
+    private String inputCode;
70
+
71
+    @I18n("是否重点关注,1为重点关注 0为不需重点关注")
72
+    @Column(name = "focus_patient")
73
+    private Integer focusPatient;
74
+
75
+    @I18n("院区id")
76
+    @Column(name = "hos_id")
77
+    private Long hosId;
78
+
79
+    @I18n("护理等级(字典表id)")
80
+    @Column(name = "level_of_care_id")
81
+    private Long levelOfCare;
82
+
83
+    @I18n("病情代理(字典表id)")
84
+    @Column(name = "state_of_an_illness_id")
85
+    private Long stateOfAnIllness;
86
+
87
+    public Long getStateOfAnIllness() {
88
+        return stateOfAnIllness;
89
+    }
90
+
91
+    public void setStateOfAnIllness(Long stateOfAnIllness) {
92
+        this.stateOfAnIllness = stateOfAnIllness;
93
+    }
94
+
95
+    public Long getLevelOfCare() {
96
+        return levelOfCare;
97
+    }
98
+
99
+    public void setLevelOfCare(Long levelOfCare) {
100
+        this.levelOfCare = levelOfCare;
101
+    }
102
+
103
+    public Long getHosId() {
104
+        return hosId;
105
+    }
106
+
107
+    public void setHosId(Long hosId) {
108
+        this.hosId = hosId;
109
+    }
110
+
111
+    public Integer getFocusPatient() {
112
+        return focusPatient;
113
+    }
114
+
115
+    public void setFocusPatient(Integer focusPatient) {
116
+        this.focusPatient = focusPatient;
117
+    }
118
+
119
+    public String getPinyin() {
120
+        return pinyin;
121
+    }
122
+
123
+    public void setPinyin(String pinyin) {
124
+        this.pinyin = pinyin;
125
+    }
126
+
127
+    public String getInputCode() {
128
+        return inputCode;
129
+    }
130
+
131
+    public void setInputCode(String inputCode) {
132
+        this.inputCode = inputCode;
133
+    }
134
+
135
+    public Integer getVersion() {
136
+        return version;
137
+    }
138
+
139
+    public void setVersion(Integer version) {
140
+        this.version = version;
141
+    }
142
+
143
+    public Date getHospitalizedTime() {
144
+        return hospitalizedTime;
145
+    }
146
+
147
+    public void setHospitalizedTime(Date hospitalizedTime) {
148
+        this.hospitalizedTime = hospitalizedTime;
149
+    }
150
+
151
+    public String getPatientcode() {
152
+        return patientcode;
153
+    }
154
+
155
+    public void setPatientcode(String patientcode) {
156
+        this.patientcode = patientcode;
157
+    }
158
+
159
+    public String getPatientname() {
160
+        return patientname;
161
+    }
162
+
163
+    public void setPatientname(String patientname) {
164
+        this.patientname = patientname;
165
+    }
166
+
167
+    public Integer getDepartment() {
168
+        return department;
169
+    }
170
+
171
+    public void setDepartment(Integer department) {
172
+        this.department = department;
173
+    }
174
+
175
+    public String getBarCode() {
176
+        return barCode;
177
+    }
178
+
179
+    public void setBarCode(String barCode) {
180
+        this.barCode = barCode;
181
+    }
182
+
183
+    public String getRoomnum() {
184
+        return roomnum;
185
+    }
186
+
187
+    public void setRoomnum(String roomnum) {
188
+        this.roomnum = roomnum;
189
+    }
190
+
191
+    public String getBednum() {
192
+        return bednum;
193
+    }
194
+
195
+    public void setBednum(String bednum) {
196
+        this.bednum = bednum;
197
+    }
198
+
199
+    public String getResidenceNo() {
200
+        return residenceNo;
201
+    }
202
+
203
+    public void setResidenceNo(String residenceNo) {
204
+        this.residenceNo = residenceNo;
205
+    }
206
+
207
+    public String getAge() {
208
+        return age;
209
+    }
210
+
211
+    public void setAge(String age) {
212
+        this.age = age;
213
+    }
214
+
215
+    public Integer getId() {
216
+        return id;
217
+    }
218
+
219
+    public void setId(Integer id) {
220
+        this.id = id;
221
+    }
222
+    @Override
223
+    public String toString() {
224
+        return "PatientEntity{" +
225
+                "id=" + id +
226
+                ", patientcode='" + patientcode + '\'' +
227
+                ", patientname='" + patientname + '\'' +
228
+                ", department='" + department + '\'' +
229
+                ", residenceNo='" + residenceNo + '\'' +
230
+                ", barCode='" + barCode + '\'' +
231
+                ", roomnum='" + roomnum + '\'' +
232
+                ", bednum='" + bednum + '\'' +
233
+                ", age='" + age + '\'' +
234
+                '}';
235
+    }
236
+}

+ 125 - 0
src/main/java/com/dashitech/businessdata/entity/PatientLogEntity.java

@@ -0,0 +1,125 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+import org.springframework.format.annotation.DateTimeFormat;
5
+
6
+import javax.persistence.*;
7
+import java.io.Serializable;
8
+import java.util.Date;
9
+
10
+/**
11
+ * Created by xuweihua on 2021/1/12.
12
+ */
13
+@Entity
14
+@Table(name = "itsm_patient_log")
15
+public class PatientLogEntity implements Serializable {
16
+    private static final long serialVersionUID = 1L;
17
+    @Id
18
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
19
+    @Column(name="id",length = 20)
20
+    private Long id;
21
+
22
+    @I18n("类型")
23
+    @Column(name = "type")
24
+    private Long type;
25
+
26
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
27
+    @Column(name = "time" )
28
+    private Date time;
29
+
30
+    @I18n("申请科室")
31
+    @Column(name = "sq_dept")
32
+    private Long sqDept;
33
+
34
+    @I18n("转入科室")
35
+    @Column(name = "zr_dept")
36
+    private Long zrDept;
37
+
38
+    @I18n("病人id")
39
+    @Column(name = "patient_id")
40
+    private Long patientId;
41
+
42
+    @I18n("前床号")
43
+    @Column(name = "qbednum")
44
+    private String qbednum;
45
+
46
+    @I18n("床号")
47
+    @Column(name = "bednum")
48
+    private String bednum;
49
+
50
+    @I18n("院区id")
51
+    @Column(name = "hos_id")
52
+    private Long hosId;
53
+
54
+    public Long getHosId() {
55
+        return hosId;
56
+    }
57
+
58
+    public void setHosId(Long hosId) {
59
+        this.hosId = hosId;
60
+    }
61
+
62
+    public String getQbednum() {
63
+        return qbednum;
64
+    }
65
+
66
+    public void setQbednum(String qbednum) {
67
+        this.qbednum = qbednum;
68
+    }
69
+
70
+    public String getBednum() {
71
+        return bednum;
72
+    }
73
+
74
+    public void setBednum(String bednum) {
75
+        this.bednum = bednum;
76
+    }
77
+
78
+    public Long getId() {
79
+        return id;
80
+    }
81
+
82
+    public void setId(Long id) {
83
+        this.id = id;
84
+    }
85
+
86
+    public Long getType() {
87
+        return type;
88
+    }
89
+
90
+    public void setType(Long type) {
91
+        this.type = type;
92
+    }
93
+
94
+    public Date getTime() {
95
+        return time;
96
+    }
97
+
98
+    public void setTime(Date time) {
99
+        this.time = time;
100
+    }
101
+
102
+    public Long getSqDept() {
103
+        return sqDept;
104
+    }
105
+
106
+    public void setSqDept(Long sqDept) {
107
+        this.sqDept = sqDept;
108
+    }
109
+
110
+    public Long getZrDept() {
111
+        return zrDept;
112
+    }
113
+
114
+    public void setZrDept(Long zrDept) {
115
+        this.zrDept = zrDept;
116
+    }
117
+
118
+    public Long getPatientId() {
119
+        return patientId;
120
+    }
121
+
122
+    public void setPatientId(Long patientId) {
123
+        this.patientId = patientId;
124
+    }
125
+}

+ 291 - 0
src/main/java/com/dashitech/businessdata/entity/SpecimenEntity.java

@@ -0,0 +1,291 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+import org.springframework.format.annotation.DateTimeFormat;
5
+
6
+import javax.persistence.*;
7
+import java.io.Serializable;
8
+import java.util.Date;
9
+
10
+/**
11
+ * Created by chi on 2019/9/10.
12
+ *标本
13
+ * doctor、putNurse、collectNurse、inspector、patientNo、sickRoom、checkDept,主表为id 这里为编码
14
+ */
15
+@Entity
16
+@Table(name = "itsm_transport_specimen")
17
+public class SpecimenEntity implements Serializable {
18
+    private static final long serialVersionUID = 1L;
19
+
20
+
21
+    @Id
22
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
23
+    @Column(name="id",length = 20)
24
+    private Long id;
25
+
26
+    @I18n("标本采集时间")
27
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
28
+    @Column(name = "print_date")
29
+    private Date printDate;
30
+
31
+    @I18n("医生申请时间")
32
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
33
+    @Column(name = "doctor_apply_time")
34
+    private Date doctorApplyTime;
35
+
36
+    @I18n("护士贴标时间")
37
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
38
+    @Column(name = "nurse_put_time")
39
+    private Date nursePutTime;
40
+
41
+
42
+    @I18n("采集护士,主表为id 这里为编码")
43
+    @Column(name="collect_nurse_id")
44
+    private String collectNurse;
45
+
46
+    @I18n("检验人员,主表为id 这里为编码")
47
+    @Column(name="inspector")
48
+    private String inspector;
49
+
50
+    @I18n("检验时间")
51
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
52
+    @Column(name = "inspection_time")
53
+    private Date inspectionTime;
54
+
55
+    @I18n("标本状态: 0新标本,1已取标本  2已送达标本")
56
+    @Column(name="spe_state")
57
+    private Integer speState;
58
+
59
+    @I18n("标本类型")
60
+    @Column(name="stype")
61
+    private String stype;
62
+
63
+    @I18n("标本条码")
64
+    @Column(name = "scode")
65
+    private String scode;
66
+
67
+    @I18n("病人唯一标识,主表为id 这里为编码")
68
+    @Column(name = "patient_no")
69
+    private String patientNo;
70
+
71
+    @I18n("病人姓名")
72
+    @Column(name = "patientname")
73
+    private String patientName;
74
+
75
+    @I18n("住院科室(起点科室),主表为id 这里为编码")
76
+    @Column(name="sick_room")
77
+    private String sickRoom;
78
+
79
+    @I18n("检验科室(目标科室),主表为id 这里为编码")
80
+    @Column(name="check_dept")
81
+    private String checkDept;
82
+
83
+    @I18n("房间号")
84
+    @Column(name = "roomnum")
85
+    private String roomNum;
86
+
87
+    @I18n("床号")
88
+    @Column(name = "bednum")
89
+    private String bedNum;
90
+
91
+    @I18n("是否紧急,0一般,1加急")
92
+    @Column(name = "urgent")
93
+    private Integer  urgent;
94
+
95
+    @I18n("院区编码")
96
+    @Column(name = "hos_id")
97
+    private String hosID;
98
+
99
+    @I18n("检验的单号")
100
+    @Column(name = "order_number")
101
+    private String orderNumber;
102
+
103
+    @I18n("系统送达时间")
104
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
105
+    @Column(name = "sys_arrive_time")
106
+    private Date sysArriveTime;
107
+
108
+    public Date getSysArriveTime() {
109
+        return sysArriveTime;
110
+    }
111
+
112
+    public void setSysArriveTime(Date sysArriveTime) {
113
+        this.sysArriveTime = sysArriveTime;
114
+    }
115
+
116
+    public String getOrderNumber() {
117
+        return orderNumber;
118
+    }
119
+
120
+    public void setOrderNumber(String orderNumber) {
121
+        this.orderNumber = orderNumber;
122
+    }
123
+
124
+    public Long getId() {
125
+        return id;
126
+    }
127
+
128
+    public void setId(Long id) {
129
+        this.id = id;
130
+    }
131
+
132
+    public Date getPrintDate() {
133
+        return printDate;
134
+    }
135
+
136
+    public void setPrintDate(Date printDate) {
137
+        this.printDate = printDate;
138
+    }
139
+
140
+    public Date getDoctorApplyTime() {
141
+        return doctorApplyTime;
142
+    }
143
+
144
+    public void setDoctorApplyTime(Date doctorApplyTime) {
145
+        this.doctorApplyTime = doctorApplyTime;
146
+    }
147
+
148
+    public Date getNursePutTime() {
149
+        return nursePutTime;
150
+    }
151
+
152
+    public void setNursePutTime(Date nursePutTime) {
153
+        this.nursePutTime = nursePutTime;
154
+    }
155
+
156
+    public String getCollectNurse() {
157
+        return collectNurse;
158
+    }
159
+
160
+    public void setCollectNurse(String collectNurse) {
161
+        this.collectNurse = collectNurse;
162
+    }
163
+
164
+    public void setSickRoom(String sickRoom) {
165
+        this.sickRoom = sickRoom;
166
+    }
167
+
168
+    public void setCheckDept(String checkDept) {
169
+        this.checkDept = checkDept;
170
+    }
171
+
172
+    public String getInspector() {
173
+        return inspector;
174
+    }
175
+
176
+    public void setInspector(String inspector) {
177
+        this.inspector = inspector;
178
+    }
179
+
180
+    public Date getInspectionTime() {
181
+        return inspectionTime;
182
+    }
183
+
184
+    public void setInspectionTime(Date inspectionTime) {
185
+        this.inspectionTime = inspectionTime;
186
+    }
187
+
188
+    public Integer getSpeState() {
189
+        return speState;
190
+    }
191
+
192
+    public void setSpeState(Integer speState) {
193
+        this.speState = speState;
194
+    }
195
+
196
+    public String getStype() {
197
+        return stype;
198
+    }
199
+
200
+    public void setStype(String stype) {
201
+        this.stype = stype;
202
+    }
203
+
204
+    public String getScode() {
205
+        return scode;
206
+    }
207
+
208
+    public void setScode(String scode) {
209
+        this.scode = scode;
210
+    }
211
+
212
+    public String getPatientNo() {
213
+        return patientNo;
214
+    }
215
+
216
+    public void setPatientNo(String patientNo) {
217
+        this.patientNo = patientNo;
218
+    }
219
+
220
+    public String getPatientName() {
221
+        return patientName;
222
+    }
223
+
224
+    public void setPatientName(String patientName) {
225
+        this.patientName = patientName;
226
+    }
227
+
228
+    public String getRoomNum() {
229
+        return roomNum;
230
+    }
231
+
232
+    public void setRoomNum(String roomNum) {
233
+        this.roomNum = roomNum;
234
+    }
235
+
236
+    public String getBedNum() {
237
+        return bedNum;
238
+    }
239
+
240
+    public void setBedNum(String bedNum) {
241
+        this.bedNum = bedNum;
242
+    }
243
+
244
+    public Integer getUrgent() {
245
+        return urgent;
246
+    }
247
+
248
+    public void setUrgent(Integer urgent) {
249
+        this.urgent = urgent;
250
+    }
251
+
252
+    public String getSickRoom() {
253
+        return sickRoom;
254
+    }
255
+
256
+    public String getCheckDept() {
257
+        return checkDept;
258
+    }
259
+
260
+    public String getHosID() {
261
+        return hosID;
262
+    }
263
+
264
+    public void setHosID(String hosID) {
265
+        this.hosID = hosID;
266
+    }
267
+
268
+    @Override
269
+    public String toString() {
270
+        return "SpecimenEntity{" +
271
+                "id=" + id +
272
+                ", printDate=" + printDate +
273
+                ", doctorApplyTime=" + doctorApplyTime +
274
+                ", nursePutTime=" + nursePutTime +
275
+                ", collectNurse='" + collectNurse + '\'' +
276
+                ", inspector='" + inspector + '\'' +
277
+                ", inspectionTime=" + inspectionTime +
278
+                ", speState=" + speState +
279
+                ", stype='" + stype + '\'' +
280
+                ", scode='" + scode + '\'' +
281
+                ", patientNo='" + patientNo + '\'' +
282
+                ", patientName='" + patientName + '\'' +
283
+                ", sickRoom='" + sickRoom + '\'' +
284
+                ", checkDept='" + checkDept + '\'' +
285
+                ", roomNum='" + roomNum + '\'' +
286
+                ", bedNum='" + bedNum + '\'' +
287
+                ", urgent=" + urgent +
288
+                ", hosID='" + hosID + '\'' +
289
+                '}';
290
+    }
291
+}

+ 91 - 0
src/main/java/com/dashitech/businessdata/entity/SpecimenHistoryEntity.java

@@ -0,0 +1,91 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+import org.springframework.format.annotation.DateTimeFormat;
5
+
6
+import javax.persistence.*;
7
+import java.io.Serializable;
8
+import java.util.Date;
9
+import java.util.Dictionary;
10
+
11
+/**
12
+ * Created by xuweihua on 2020/12/17.
13
+ * 标本历史
14
+ */
15
+@Entity
16
+@Table(name = "itsm_specimen_history")
17
+public class SpecimenHistoryEntity implements Serializable {
18
+    @Id
19
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
20
+    @Column(name="id",length = 20)
21
+    private Long id;
22
+
23
+    @I18n("创建")
24
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
25
+    @Column(name = "creat_time")
26
+    private Date creatTime;
27
+
28
+    @I18n("操作类型")
29
+    @Column(name="operation_type")
30
+    private Long operationType;
31
+
32
+    @I18n("操作人")
33
+    @Column(name = "operation_user_name")
34
+    private String operationUserName;
35
+
36
+    @I18n("操作人id")
37
+    @Column(name = "operation_user_id")
38
+    private Long operationUserId;
39
+
40
+    @I18n("标本编码")
41
+    @Column(name = "scode")
42
+    private String scode;
43
+
44
+    public Long getId() {
45
+        return id;
46
+    }
47
+
48
+    public void setId(Long id) {
49
+        this.id = id;
50
+    }
51
+
52
+    public Date getCreatTime() {
53
+        return creatTime;
54
+    }
55
+
56
+    public void setCreatTime(Date creatTime) {
57
+        this.creatTime = creatTime;
58
+    }
59
+
60
+    public Long getOperationType() {
61
+        return operationType;
62
+    }
63
+
64
+    public void setOperationType(Long operationType) {
65
+        this.operationType = operationType;
66
+    }
67
+
68
+    public String getOperationUserName() {
69
+        return operationUserName;
70
+    }
71
+
72
+    public void setOperationUserName(String operationUserName) {
73
+        this.operationUserName = operationUserName;
74
+    }
75
+
76
+    public Long getOperationUserId() {
77
+        return operationUserId;
78
+    }
79
+
80
+    public void setOperationUserId(Long operationUserId) {
81
+        this.operationUserId = operationUserId;
82
+    }
83
+
84
+    public String getScode() {
85
+        return scode;
86
+    }
87
+
88
+    public void setScode(String scode) {
89
+        this.scode = scode;
90
+    }
91
+}

+ 76 - 0
src/main/java/com/dashitech/businessdata/entity/SystemConfigureEntity.java

@@ -0,0 +1,76 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+
5
+import javax.persistence.*;
6
+import java.io.Serializable;
7
+
8
+/**
9
+ * Created by chi on 2020/8/25.
10
+ */
11
+@Entity
12
+@Table(name = "itsm_system_configurations")
13
+public class SystemConfigureEntity implements Serializable {
14
+    private static final long serialVersionUID = 1L;
15
+
16
+    @Id
17
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
18
+    @Column(name="id",length = 20)
19
+    private Long id;
20
+
21
+    @I18n("字段名")
22
+    @Column(name="keyconfig")
23
+    private String keyconfig;
24
+
25
+    @I18n("字段中文名")
26
+    @Column(name="label")
27
+    private String label;
28
+
29
+    @I18n("字段值")
30
+    @Column(name="valueconfig")
31
+    private String valueconfig;
32
+
33
+    @I18n("排序")
34
+    @Column(name="orders")
35
+    private String orders;
36
+
37
+    public Long getId() {
38
+        return id;
39
+    }
40
+
41
+    public void setId(Long id) {
42
+        this.id = id;
43
+    }
44
+
45
+    public String getKeyconfig() {
46
+        return keyconfig;
47
+    }
48
+
49
+    public void setKeyconfig(String keyconfig) {
50
+        this.keyconfig = keyconfig;
51
+    }
52
+
53
+    public String getLabel() {
54
+        return label;
55
+    }
56
+
57
+    public void setLabel(String label) {
58
+        this.label = label;
59
+    }
60
+
61
+    public String getValueconfig() {
62
+        return valueconfig;
63
+    }
64
+
65
+    public void setValueconfig(String valueconfig) {
66
+        this.valueconfig = valueconfig;
67
+    }
68
+
69
+    public String getOrders() {
70
+        return orders;
71
+    }
72
+
73
+    public void setOrders(String orders) {
74
+        this.orders = orders;
75
+    }
76
+}

+ 241 - 0
src/main/java/com/dashitech/businessdata/entity/UserEntity.java

@@ -0,0 +1,241 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+
5
+import javax.persistence.*;
6
+import java.io.Serializable;
7
+
8
+/**
9
+ * Created by chi on 2019/10/9.
10
+ *
11
+ *  hospital、dept 字段为编码、转换到主表要变成id
12
+ */
13
+@Entity
14
+@Table(name = "itsm_uc_user")
15
+public class UserEntity  implements Serializable {
16
+
17
+    private static final long serialVersionUID = 1L;
18
+
19
+    @Id
20
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
21
+    @Column(name="id",length = 20)
22
+    private Long id;
23
+
24
+
25
+    /**
26
+     * 账号、工号
27
+     */
28
+    @I18n("账号")
29
+    @Column(name = "ACCOUNT", nullable = false)
30
+    private String account;
31
+
32
+    @I18n("密码")
33
+    @Column(name = "PWD", nullable = false)
34
+    private String pwd;
35
+    /**
36
+     * 姓名
37
+     */
38
+    @I18n("名称")
39
+    @Column(name = "NAME", nullable = false)
40
+    private String name;
41
+
42
+    @I18n("院区编码,主表为id这里为编码")
43
+    @Column(name = "hospital_id")
44
+    private String hospital;
45
+    /**
46
+     * 性别key male
47
+     */
48
+    @I18n("性别")
49
+    @Column(name="GENDER")
50
+    private Long genderId;
51
+    /**
52
+     * 电话号码
53
+     */
54
+//    @I18n("电话号码")
55
+//    @Column(name = "PHONE")
56
+//    private String phone;
57
+//
58
+//    @I18n("座机号码")
59
+//    @Column(name = "DIALING")
60
+//    private String dialing;
61
+
62
+    @I18n("所属科室为科室id")
63
+    @Column(name="DEPTID")
64
+    private String dept;
65
+
66
+//    @I18n("微信号")
67
+//    @Column(name = "WEIXIN")
68
+//    private String weixin;
69
+
70
+
71
+    @I18n("删除标识")
72
+    @Column(name = "delete_flag")
73
+    private Integer deleteFlag;
74
+
75
+    @I18n("用户类型,护士1、工友2、医生3")
76
+    @Column(name="usertype")
77
+    private String usertype;
78
+
79
+//    @I18n("HIS系统员工ID")
80
+//    @Column(name = "hisid")
81
+//    private String hisid;
82
+//
83
+//    @I18n("跟登录账号一样没啥用,单点登录标识")
84
+//    @Column(name = "emp_no")
85
+//    private String empno;
86
+
87
+    @I18n("拼音全拼")
88
+    @Column(name="pinyin")
89
+    private  String pingYin;
90
+
91
+    @I18n("拼音首字符")
92
+    @Column(name = "input_code")
93
+    private String inputCode;
94
+
95
+    public String getPwd() {
96
+        return pwd;
97
+    }
98
+
99
+    public void setPwd(String pwd) {
100
+        this.pwd = pwd;
101
+    }
102
+
103
+    public String getPingYin() {
104
+        return pingYin;
105
+    }
106
+
107
+    public void setPingYin(String pingYin) {
108
+        this.pingYin = pingYin;
109
+    }
110
+
111
+    public String getInputCode() {
112
+        return inputCode;
113
+    }
114
+
115
+    public void setInputCode(String inputCode) {
116
+        this.inputCode = inputCode;
117
+    }
118
+
119
+    public Long getId() {
120
+        return id;
121
+    }
122
+
123
+    public void setId(Long id) {
124
+        this.id = id;
125
+    }
126
+
127
+    public String getAccount() {
128
+        return account;
129
+    }
130
+
131
+    public void setAccount(String account) {
132
+        this.account = account;
133
+    }
134
+
135
+    public String getName() {
136
+        return name;
137
+    }
138
+
139
+    public void setName(String name) {
140
+        this.name = name;
141
+    }
142
+
143
+    public Long getGenderId() {
144
+        return genderId;
145
+    }
146
+
147
+    public void setGenderId(Long genderId) {
148
+        this.genderId = genderId;
149
+    }
150
+
151
+
152
+//    public String getPhone() {
153
+//        return phone;
154
+//    }
155
+//
156
+//    public void setPhone(String phone) {
157
+//        this.phone = phone;
158
+//    }
159
+//
160
+//    public String getDialing() {
161
+//        return dialing;
162
+//    }
163
+//
164
+//    public void setDialing(String dialing) {
165
+//        this.dialing = dialing;
166
+//    }
167
+
168
+//    public String getWeixin() {
169
+//        return weixin;
170
+//    }
171
+//
172
+//    public void setWeixin(String weixin) {
173
+//        this.weixin = weixin;
174
+//    }
175
+
176
+    public Integer getDeleteFlag() {
177
+        return deleteFlag;
178
+    }
179
+
180
+    public void setDeleteFlag(Integer deleteFlag) {
181
+        this.deleteFlag = deleteFlag;
182
+    }
183
+
184
+    public String getUsertype() {
185
+        return usertype;
186
+    }
187
+
188
+    public void setUsertype(String usertype) {
189
+        this.usertype = usertype;
190
+    }
191
+
192
+//    public String getHisid() {
193
+//        return hisid;
194
+//    }
195
+//
196
+//    public void setHisid(String hisid) {
197
+//        this.hisid = hisid;
198
+//    }
199
+//
200
+//    public String getEmpno() {
201
+//        return empno;
202
+//    }
203
+//
204
+//    public void setEmpno(String empno) {
205
+//        this.empno = empno;
206
+//    }
207
+
208
+    public String getHospital() {
209
+        return hospital;
210
+    }
211
+
212
+    public void setHospital(String hospital) {
213
+        this.hospital = hospital;
214
+    }
215
+
216
+    public String getDept() {
217
+        return dept;
218
+    }
219
+
220
+    public void setDept(String dept) {
221
+        this.dept = dept;
222
+    }
223
+
224
+    @Override
225
+    public String toString() {
226
+        return "UserEntity{" +
227
+                "id=" + id +
228
+                ", account='" + account + '\'' +
229
+                ", name='" + name + '\'' +
230
+                ", gender='" + genderId + '\'' +
231
+//                ", phone='" + phone + '\'' +
232
+//                ", dialing='" + dialing + '\'' +
233
+                ", dept=" + dept +
234
+//                ", weixin='" + weixin + '\'' +
235
+                ", deleteFlag=" + deleteFlag +
236
+                ", usertype='" + usertype + '\'' +
237
+//                ", hisid='" + hisid + '\'' +
238
+//                ", empno='" + empno + '\'' +
239
+                '}';
240
+    }
241
+}

+ 88 - 0
src/main/java/com/dashitech/businessdata/entity/WorkOrderEntity.java

@@ -0,0 +1,88 @@
1
+package com.dashitech.businessdata.entity;
2
+
3
+import com.dashitech.utils.I18n;
4
+
5
+import javax.persistence.*;
6
+import java.io.Serializable;
7
+
8
+/**
9
+ * Created by xuweihua on 2020/11/20.
10
+ */
11
+@Entity
12
+@Table(name = "itsm_transport_workorder")
13
+public class WorkOrderEntity  implements Serializable {
14
+    private static final long serialVersionUID = 1L;
15
+
16
+    @Id
17
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
18
+    @Column(name="id",length = 20)
19
+    private Integer id;
20
+
21
+    // 创建科室不展示实体
22
+    @I18n("创建科室")
23
+    @Column(name="create_department_id")
24
+    private Integer  createDept;
25
+    @I18n("起点科室id")
26
+    @Column(name="start_department_id")
27
+    private Integer  startDept;
28
+
29
+    @I18n("终点科室")
30
+    @Column(name="end_department_ids")
31
+    private String endDeptIds;
32
+
33
+    @I18n("工单状态")
34
+    @Column(name="gdstate")
35
+    private Integer  gdState;
36
+
37
+    @I18n("病人唯一标识")
38
+    @Column(name="patientId")
39
+    private String patientId;
40
+
41
+    public Integer getId() {
42
+        return id;
43
+    }
44
+
45
+    public void setId(Integer id) {
46
+        this.id = id;
47
+    }
48
+
49
+    public Integer getStartDept() {
50
+        return startDept;
51
+    }
52
+
53
+    public void setStartDept(Integer startDept) {
54
+        this.startDept = startDept;
55
+    }
56
+
57
+    public Integer getGdState() {
58
+        return gdState;
59
+    }
60
+
61
+    public void setGdState(Integer gdState) {
62
+        this.gdState = gdState;
63
+    }
64
+
65
+    public String getPatientId() {
66
+        return patientId;
67
+    }
68
+
69
+    public void setPatientId(String patientId) {
70
+        this.patientId = patientId;
71
+    }
72
+
73
+    public Integer getCreateDept() {
74
+        return createDept;
75
+    }
76
+
77
+    public void setCreateDept(Integer createDept) {
78
+        this.createDept = createDept;
79
+    }
80
+
81
+    public String getEndDeptIds() {
82
+        return endDeptIds;
83
+    }
84
+
85
+    public void setEndDeptIds(String endDeptIds) {
86
+        this.endDeptIds = endDeptIds;
87
+    }
88
+}

+ 63 - 0
src/main/java/com/dashitech/callcenter/init/SocketInit.java

@@ -0,0 +1,63 @@
1
+package com.dashitech.callcenter.init;
2
+
3
+import com.dashitech.businessdata.dao.ISystemConfigureDAO;
4
+import com.dashitech.callcenter.socket.HandlerThread;
5
+import com.dashitech.utils.ThreadPoolFactory;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.boot.ApplicationArguments;
8
+import org.springframework.boot.ApplicationRunner;
9
+import org.springframework.stereotype.Service;
10
+
11
+import java.io.IOException;
12
+import java.net.ServerSocket;
13
+import java.net.Socket;
14
+
15
+/**
16
+ * Created by chi on 2020/8/25.
17
+ */
18
+@Service
19
+public class SocketInit implements ApplicationRunner {
20
+
21
+    @Autowired
22
+    ISystemConfigureDAO systemConfigureDAO;
23
+
24
+    @Override
25
+    public void run(ApplicationArguments args) throws Exception {
26
+        //如果系统配置表的开关字段为1则连接话机socket 否则不连
27
+        if (systemConfigureDAO.selectValueByKey("callSocketSwitch").equals("1")) {
28
+            int PORT = 8087;
29
+            // TODO Auto-generated method stub
30
+            ServerSocket sock = null;
31
+            sock = new ServerSocket(PORT);
32
+
33
+            try {
34
+                while (true) {
35
+                    final Socket Client = sock.accept();
36
+                //    System.out.println("1111111111111111");
37
+                    //启动一个线程执行后续客户端发来的监听
38
+                    ThreadPoolFactory.getCachedPool().submit(new Runnable() {
39
+                        @Override
40
+                        public void run() {
41
+                            new HandlerThread(Client).run();
42
+                //            System.out.println("22222222222222222");
43
+                        }
44
+                    });
45
+                }
46
+            } catch (Exception e) {
47
+                e.printStackTrace();
48
+            } finally {
49
+                if (sock != null) {
50
+                    try {
51
+                        sock.close();
52
+                        System.out.println("电话socket关闭连接");
53
+                    } catch (IOException e) {
54
+                        // TODO Auto-generated catch block
55
+                        e.printStackTrace();
56
+                    }
57
+                }
58
+            }
59
+        } else {
60
+            System.out.println("callSocketSwitch 字段未开启");
61
+        }
62
+    }
63
+}

+ 397 - 0
src/main/java/com/dashitech/callcenter/socket/HandlerThread.java

@@ -0,0 +1,397 @@
1
+package com.dashitech.callcenter.socket;
2
+
3
+import com.dashitech.businessdata.dao.ICallLogDAO;
4
+import com.dashitech.businessdata.dao.IDepartmentDAO;
5
+import com.dashitech.businessdata.dao.IDictionaryDAO;
6
+import com.dashitech.businessdata.dao.IHospitalConfigDAO;
7
+import com.dashitech.businessdata.entity.CallLogEntity;
8
+import com.dashitech.businessdata.entity.HospitalConfig;
9
+import com.dashitech.callcenter.webSocket.service.PhoneWebSocket;
10
+import com.dashitech.utils.JsonUtil;
11
+import com.fasterxml.jackson.databind.ObjectMapper;
12
+import net.sf.json.JSONObject;
13
+import org.apache.commons.lang.StringUtils;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.stereotype.Service;
16
+
17
+import java.io.DataInputStream;
18
+import java.io.DataOutputStream;
19
+import java.net.Socket;
20
+import java.text.ParseException;
21
+import java.text.SimpleDateFormat;
22
+import java.util.Date;
23
+import java.util.HashMap;
24
+import java.util.List;
25
+import java.util.Map;
26
+
27
+/**
28
+ * Created by chi on 2020/8/6.
29
+ */
30
+@Service
31
+public class HandlerThread  {
32
+
33
+    //  这里使用静态,让 service 属于类
34
+    private static ICallLogDAO callLogDAO;
35
+    @Autowired
36
+    public void setCallLogDAO(ICallLogDAO callLogDAO) {
37
+        HandlerThread.callLogDAO = callLogDAO;
38
+    }
39
+
40
+    private static IDictionaryDAO dictionaryDAO;
41
+    @Autowired
42
+    public void setDictionaryDAO(IDictionaryDAO dictionaryDAO) {
43
+        HandlerThread.dictionaryDAO = dictionaryDAO;
44
+    }
45
+
46
+    private static IDepartmentDAO departmentDAO;
47
+    @Autowired
48
+    public void setDepartmentDAO(IDepartmentDAO departmentDAO) {
49
+        HandlerThread.departmentDAO = departmentDAO;
50
+    }
51
+
52
+    private static IHospitalConfigDAO hospitalConfigDAO;
53
+    @Autowired
54
+    public void setHospitalConfigDAO(IHospitalConfigDAO hospitalConfigDAO) {
55
+        HandlerThread.hospitalConfigDAO = hospitalConfigDAO;
56
+    }
57
+
58
+    private Socket sc;
59
+
60
+    private static Map<String,String> phoneMap = new HashMap<>();
61
+
62
+    private static Map<String,CallLogEntity> phoneLog = new HashMap<>();
63
+    private String his = "";
64
+    public HandlerThread() {
65
+    }
66
+
67
+    public HandlerThread(Socket client) {
68
+        sc = client;
69
+    }
70
+
71
+    public void run() {
72
+        // TODO Auto-generated method stub
73
+        DataInputStream input = null;
74
+        DataOutputStream output = null;
75
+        try {
76
+           // sc.setSoTimeout(10000);
77
+            input = new DataInputStream(sc.getInputStream());
78
+            output = new DataOutputStream(sc.getOutputStream());
79
+            String reset = "";
80
+            //持续读取内部消息
81
+            while (true) {
82
+               //  System.out.println("处理客户端数据:"+input.readUTF());
83
+             //   System.out.println("3333333333333333333333");
84
+                //获取信息流长度
85
+                byte[] b = new byte[4];
86
+                reset = "keepalive";
87
+                input.read(b);
88
+                int count = bytes2Int(b);
89
+             //   System.out.println("count::"+count);
90
+                //根据信息流长度获取信息流
91
+                byte[] b1 = new byte[count];
92
+                input.read(b1);
93
+                //将信息流转换为String
94
+                String data = new String(b1);
95
+                System.out.println("data:"+data+"his"+his);
96
+                if (data != null || !data.equals("")&&data.substring(0,1).equals("{")) {
97
+                    if (JsonUtil.toJSONObject(data).containsKey("channelStatusList")){
98
+                        List llist = JsonUtil.toJSONObject(data).optJSONArray("channelStatusList");
99
+                        JSONObject jsonObject = JsonUtil.toJSONObject(llist.get(0).toString());
100
+                        sendSocket(jsonObject,his);
101
+                        handleCallLog(jsonObject,his);
102
+                        reset = "channelstatus";
103
+                    }else if(JsonUtil.toJSONObject(data).containsKey("recordList")){
104
+                        saveCallLog(data,his);
105
+                        reset = "addrec";
106
+                    }
107
+                }
108
+                if (data != null && data.length() >= 10) {
109
+                    String dataStr = "";
110
+                    if (reset.equals("addrec")){
111
+                        dataStr = "{\"cmd\":\""+reset+"\",\"error\":\"0\", \"timestamp\":\""+(System.currentTimeMillis() / 1000)+"\"}";
112
+                    }else{
113
+                        dataStr = "{\"cmd\":\""+reset+"\", \"timestamp\":\""+(System.currentTimeMillis() / 1000)+"\"}";
114
+                    }
115
+                    if (data.indexOf("loginreq") >= 0){
116
+                        his = JsonUtil.toJSONObject(data).getString("sernelNo");
117
+                        his = callLogDAO.selectSernelNo("sernelNo",his);
118
+                        dataStr = "{\"cmd\":\"loginres\", \"error\":\"0\", \"timestamp\":\"" + (System.currentTimeMillis() / 1000) + "\"}";
119
+                    }
120
+                    System.out.println("redate>>"+dataStr+"his"+his);
121
+                    output.write(dataToBytes(dataStr));
122
+                }
123
+            }
124
+        } catch (Exception e) {
125
+            e.printStackTrace();
126
+            System.out.println("服务器EOFException异常");
127
+        } finally {
128
+            if (output != null) {
129
+                try {
130
+                    output.close();
131
+                } catch (Exception e) {
132
+                    output = null;
133
+                }
134
+            }
135
+            if (input != null) {
136
+                try {
137
+                    input.close();
138
+                } catch (Exception e) {
139
+                    input = null;
140
+                }
141
+            }
142
+            if (sc != null) {
143
+                try {
144
+                    sc.close();
145
+                } catch (Exception e) {
146
+                    sc = null;
147
+                }
148
+            }
149
+        }
150
+    }
151
+
152
+    /**
153
+     * 将发送内容转换为byte数组
154
+     * 需要注意:byte前面四位需要描述整个发送内容的长度(dataStr)
155
+     *
156
+     * @param dataStr
157
+     */
158
+    public byte[] dataToBytes(String dataStr) {
159
+        //将int转换为byte数组
160
+        byte[] lengthBytes = int2Bytes(dataStr.length());
161
+        //将string转换为byte数组
162
+        byte[] dataBytes = dataStr.getBytes();
163
+        //最终发送的byte数组,int byte数组长度和string byte数组长度相加得到最终长度
164
+        byte[] lengthAndDataBytes = new byte[(lengthBytes.length + dataBytes.length)];
165
+        //将int byte数组四位加入到新byte数组中
166
+        lengthAndDataBytes[0] = lengthBytes[0];
167
+        lengthAndDataBytes[1] = lengthBytes[1];
168
+        lengthAndDataBytes[2] = lengthBytes[2];
169
+        lengthAndDataBytes[3] = lengthBytes[3];
170
+        //将string byte数组四位加入到新byte数组中
171
+        for (int index = 4; index < lengthAndDataBytes.length; index++) {
172
+            lengthAndDataBytes[index] = dataBytes[index - 4];
173
+        }
174
+        return lengthAndDataBytes;
175
+
176
+    }
177
+
178
+    /**
179
+     * byte数组转换为int
180
+     *
181
+     * @param bytes
182
+     * @return
183
+     */
184
+    public static int bytes2Int(byte[] bytes) {
185
+        //如果不与0xff进行按位与操作,转换结果将出错,有兴趣的同学可以试一下。
186
+        int int1 = bytes[0] & 0xff;
187
+        int int2 = (bytes[1] & 0xff) << 8;
188
+        int int3 = (bytes[2] & 0xff) << 16;
189
+        int int4 = (bytes[3] & 0xff) << 24;
190
+        return int1 | int2 | int3 | int4;
191
+    }
192
+
193
+    /**
194
+     * int 转换为 byte数组
195
+     *
196
+     * @param integer
197
+     * @return
198
+     */
199
+    public static byte[] int2Bytes(int integer) {
200
+        byte[] bytes = new byte[4];
201
+        bytes[3] = (byte) ((byte) integer >> 24);
202
+        bytes[2] = (byte) ((byte) integer >> 16);
203
+        bytes[1] = (byte) ((byte) integer >> 8);
204
+        bytes[0] = (byte) integer;
205
+        return bytes;
206
+    }
207
+
208
+    /**
209
+     * 发送弹屏socket,将电话号码返回过去
210
+     * 201为通话中
211
+     * 202为振铃
212
+     *
213
+     */
214
+    public  void sendSocket(JSONObject jsonObject,String his) {
215
+        try {
216
+                putPhoneMap("phone_num_port",his);
217
+                if (jsonObject != null && jsonObject.containsKey("calldirection") && jsonObject.get("calldirection").toString().equals("1") || jsonObject.get("calldirection").toString() == "1") {
218
+                    if (jsonObject.containsKey("phonestate") && jsonObject.get("phonestate").toString().equals("3") || jsonObject.get("phonestate").toString() == "3") {
219
+                        if (jsonObject.containsKey("channel")&&jsonObject.get("channel").toString()!=null) {
220
+                            Map rMap = new HashMap();
221
+                            if (jsonObject.containsKey("dtmfa") && jsonObject.get("dtmfa").toString() != null && !jsonObject.optString("dtmfa").toString().equals("")){
222
+                                rMap.put("phone", jsonObject.opt("dtmfa"));
223
+                                rMap.put("status", 201);
224
+                            }else {
225
+                                rMap.put("phone","");
226
+                                rMap.put("status", 201);
227
+                            }
228
+                            ObjectMapper objectMapper = new ObjectMapper();
229
+                            String json = objectMapper.writeValueAsString(rMap);
230
+                            PhoneWebSocket.sendMessage(phoneMap.get(his+jsonObject.get("channel").toString()),json);
231
+                        }
232
+                    } else if (jsonObject.containsKey("phonestate") && jsonObject.get("phonestate").toString().equals("4") || jsonObject.get("phonestate").toString() == "4") {
233
+                        Map rMap = new HashMap();
234
+                        rMap.put("msg","来电话啦!" );
235
+                        rMap.put("status", 202);
236
+                        ObjectMapper objectMapper = new ObjectMapper();
237
+                        String json = objectMapper.writeValueAsString(rMap);
238
+                        if (jsonObject.containsKey("channel")&&jsonObject.get("channel").toString()!=null){
239
+                            PhoneWebSocket.sendMessage(phoneMap.get(his+jsonObject.get("channel").toString()),json);
240
+                        }
241
+                        CallLogEntity callLog = new CallLogEntity();
242
+                        callLog.setCallState(0);
243
+                    }
244
+                }
245
+
246
+        } catch (Exception e) {
247
+            e.printStackTrace();
248
+        }
249
+    }
250
+    private void handleCallLog(JSONObject jsonObject,String his){
251
+        if(jsonObject.get("phonestate").toString().equals("4")){
252
+            // 主叫号码不等于空字符串,并且不等于座机号(通道号获得),即可判断为来电号码
253
+            if(!jsonObject.get("dtmfa").toString().equals("") && !jsonObject.get("dtmfa").toString().equals(phoneMap.get(his+jsonObject.get("channel").toString()))){
254
+                phoneLog.put(his+jsonObject.get("channel").toString(),getCallLog(jsonObject));
255
+            }
256
+            //如果phonestate 为零则表示话机为空闲状态,则保存通话记录
257
+        }else if(jsonObject.get("phonestate").toString().equals("0")){
258
+            CallLogEntity callLog  = phoneLog.get(his+jsonObject.get("channel").toString());
259
+            if (callLog!=null){
260
+                if (jsonObject.containsKey("dtmfa")&& StringUtils.isNotEmpty(jsonObject.get("dtmfa").toString())&&!jsonObject.get("dtmfa").toString().equals("")&&!jsonObject.get("dtmfa").toString().equals(" ")){
261
+                    // 查询科室信息 并赋值
262
+                    callLog.setCallDept(getDeptByDTMFA(jsonObject.get("dtmfa").toString()));
263
+                }else {
264
+                    callLog.setCallDept("暂无");
265
+                }
266
+                callLog.setHosId(Integer.parseInt(his));
267
+                callLogDAO.save(callLog);
268
+            }
269
+        }else if(jsonObject.get("phonestate").toString().equals("1")){
270
+            phoneLog.put(his+jsonObject.get("channel").toString(),null);
271
+        }else if(jsonObject.get("phonestate").toString().equals("3")){
272
+            phoneLog.put(his+jsonObject.get("channel").toString(),null);
273
+        }
274
+    }
275
+
276
+    /**
277
+     * 将json转换为实体
278
+     * 默认 已接未接为 未接
279
+     * 默认 通话类型为 呼入
280
+     * 默认 时间为 当前时间。
281
+     * @param jsonObject
282
+     * @return
283
+     */
284
+    private CallLogEntity getCallLog(JSONObject jsonObject){
285
+        CallLogEntity callLog = new CallLogEntity();
286
+        if (jsonObject.containsKey("channel")){
287
+            callLog.setPhyIDA(jsonObject.get("channel").toString());
288
+        }
289
+        if (jsonObject.containsKey("dtmfa")) {
290
+            callLog.setdTMFA(jsonObject.get("dtmfa").toString());
291
+            callLog.setCallDept(getDeptByDTMFA(jsonObject.get("dtmfa").toString()));
292
+        }
293
+        if (jsonObject.containsKey("dtmfb")){
294
+            callLog.setdTMFB(jsonObject.get("dtmfb").toString());
295
+        }
296
+        callLog.setResponseTime(new Date());
297
+        callLog.setCallState(0);
298
+        callLog.setCallType(1);
299
+        return callLog;
300
+    }
301
+
302
+    public void putPhoneMap(String key,String his){
303
+//        List<DictionaryEntity> dictionaryEntityList = dictionaryDAO.selectDictionaryByKey(key);
304
+        List<HospitalConfig> hospitalConfigList =  hospitalConfigDAO.getHospitalConfigList(key,his);
305
+        if (hospitalConfigList!=null&&hospitalConfigList.size()>0){
306
+            for (HospitalConfig hospitalConfig:hospitalConfigList){
307
+                phoneMap.put(his+hospitalConfig.getValue2(),hospitalConfig.getValue());
308
+            }
309
+        }
310
+    }
311
+
312
+    /**
313
+     * 保存通话记录
314
+     * @param message
315
+     */
316
+    public void saveCallLog(String message,String his){
317
+        if (JsonUtil.toJSONObject(message).containsKey("recordList")) {
318
+            List list = JsonUtil.toJSONObject(message).optJSONArray("recordList");
319
+            if (list!=null&&list.size()>0){
320
+                JSONObject jsonObject = JsonUtil.toJSONObject(list.get(0).toString());
321
+                CallLogEntity callLog = new CallLogEntity();
322
+                if (jsonObject.containsKey("phyIDA")){
323
+                    callLog.setPhyIDA(jsonObject.get("phyIDA").toString());
324
+                }
325
+                if (jsonObject.containsKey("DTMFA")){
326
+                    callLog.setdTMFA(jsonObject.get("DTMFA").toString());
327
+                    callLog.setCallDept(getDeptByDTMFA(jsonObject.get("DTMFA").toString()));
328
+                }
329
+                if (jsonObject.containsKey("DTMFB")){
330
+                    callLog.setdTMFB(jsonObject.get("DTMFB").toString());
331
+                }
332
+                if (jsonObject.containsKey("rstime")){
333
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
334
+                    try {
335
+                        callLog.setResponseTime(sdf.parse(jsonObject.get("rstime").toString()));
336
+                    } catch (ParseException e) {
337
+                        e.printStackTrace();
338
+                    }
339
+                }
340
+                if (jsonObject.containsKey("longtime")){
341
+                    callLog.setLongTime(jsonObject.get("longtime").toString());
342
+                }
343
+                if (jsonObject.containsKey("path")){
344
+                    callLog.setPath(jsonObject.get("path").toString());
345
+                }
346
+
347
+                if(callLog.getPhyIDA() != null){
348
+                    // 判断为呼出(主叫号码等于分机号(通道号)为呼出)
349
+                    if(callLog.getdTMFA() != null &&phoneMap!=null&&phoneMap.size()>0&& phoneMap.get(his+callLog.getPhyIDA()).equals(callLog.getdTMFA())){
350
+                        callLog.setCallType(0);
351
+//                     callLog.setCallState(1);
352
+                        //  判断为呼入(被叫号码等于分机号(通道号)为呼入)
353
+                    }else if(callLog.getdTMFB()!= null &&phoneMap!=null&&phoneMap.size()>0&& phoneMap.get(his+callLog.getPhyIDA()).equals(callLog.getdTMFB())){
354
+                        callLog.setCallType(1);
355
+//                     callLog.setCallState(1);
356
+                    }else{//未知
357
+                        callLog.setCallType(2);
358
+                    }
359
+                    callLog.setCallState(1);
360
+                }
361
+                callLog.setHosId(Integer.parseInt(his));
362
+                callLogDAO.save(callLog);
363
+            }
364
+        }
365
+    }
366
+
367
+    private String getDeptByDTMFA(String phone){
368
+        try {
369
+            if (phone!=null){
370
+                phone = phone.trim();
371
+                if (phone.equals("")){
372
+                    return "暂无";
373
+                }
374
+                //给来电科室赋值
375
+                String deptName = departmentDAO.getDeptNameByPhone(phone);
376
+                if (deptName!=null&&!deptName.equals("")){
377
+                    return deptName;
378
+                }else {
379
+               /*     String deptName2 = departmentDAO.getDeptNameByWorkOrderPhone(phone);
380
+                    if (deptName2!=null&&!deptName2.equals("")){
381
+                        return deptName2;
382
+                    }else {
383
+                        return "暂无";
384
+                    }*/
385
+                    return "暂无";
386
+                }
387
+            }
388
+        }catch (Exception e){
389
+            e.printStackTrace();
390
+        }
391
+        return "暂无";
392
+    }
393
+
394
+    public static void main(String[] args) {
395
+        System.out.println(System.currentTimeMillis() / 1000);
396
+    }
397
+}

+ 33 - 0
src/main/java/com/dashitech/callcenter/webSocket/core/CacheHandlerAdapter.java

@@ -0,0 +1,33 @@
1
+package com.dashitech.callcenter.webSocket.core;
2
+
3
+import org.apache.commons.lang3.StringUtils;
4
+import org.atmosphere.cpr.AtmosphereResource;
5
+import org.atmosphere.websocket.WebSocketHandlerAdapter;
6
+
7
+import java.io.IOException;
8
+
9
+/**
10
+ * 带缓存的WebSocket类
11
+ */
12
+public class CacheHandlerAdapter extends WebSocketHandlerAdapter {
13
+    private SessionCache CACHE = new SessionCache();
14
+
15
+    public SessionCache getCACHE() {
16
+        return CACHE;
17
+    }
18
+
19
+    public void logout(AtmosphereResource resource) {
20
+        CACHE.removeByUUID(resource.uuid());
21
+    }
22
+
23
+    public SessionCache login(AtmosphereResource resource, String identity) throws IOException {
24
+        //缓存登录的浏览器,模板:{login:'123'}
25
+        if (StringUtils.isNotEmpty(identity)) {
26
+            if(CACHE.contains(identity)){
27
+                CACHE.removeByUUID(identity);
28
+            }
29
+                CACHE.put(identity,resource);
30
+        }
31
+        return CACHE;
32
+    }
33
+}

+ 56 - 0
src/main/java/com/dashitech/callcenter/webSocket/core/SessionCache.java

@@ -0,0 +1,56 @@
1
+package com.dashitech.callcenter.webSocket.core;
2
+
3
+import org.atmosphere.cpr.AtmosphereResource;
4
+import org.jboss.netty.util.internal.ConcurrentHashMap;
5
+
6
+
7
+import java.util.Map;
8
+
9
+/**
10
+ * WebSocket缓存类
11
+ * Created by CX on 2018/8/9 0009.
12
+ */
13
+public class SessionCache {
14
+    /**
15
+     * 关键字缓存
16
+     */
17
+    private final ConcurrentHashMap<String, AtmosphereResource> indentityCache = new ConcurrentHashMap<String, AtmosphereResource>();
18
+
19
+    /**
20
+     * 所有浏览器的缓存,如果有需要可以扩展
21
+     */
22
+//    private final ConcurrentHashMap<String, AtmosphereResource> allCache = new ConcurrentHashMap<String, AtmosphereResource>();
23
+    public SessionCache() {
24
+    }
25
+
26
+    public ConcurrentHashMap<String, AtmosphereResource> getIndentityCache() {
27
+        return indentityCache;
28
+    }
29
+
30
+    public AtmosphereResource get(String identity) {
31
+        return this.indentityCache.get(identity);
32
+    }
33
+
34
+    public boolean contains(String identity) {
35
+        return this.indentityCache.containsKey(identity);
36
+    }
37
+
38
+    public void put(String identity, AtmosphereResource atmosphereResource) {
39
+        this.indentityCache.put(identity, atmosphereResource);
40
+    }
41
+
42
+    public AtmosphereResource remove(String identity) {
43
+        return indentityCache.remove(identity);
44
+    }
45
+
46
+    public AtmosphereResource removeByUUID(String uuid) {
47
+        for (Map.Entry<String, AtmosphereResource> entry : indentityCache.entrySet()) {
48
+            if (entry.getValue().uuid().equals(uuid)) {
49
+                return indentityCache.remove(entry.getKey());
50
+            }
51
+        }
52
+        return null;
53
+    }
54
+
55
+
56
+}

+ 69 - 0
src/main/java/com/dashitech/callcenter/webSocket/core/WebSocketSender.java

@@ -0,0 +1,69 @@
1
+package com.dashitech.callcenter.webSocket.core;
2
+
3
+import org.atmosphere.cpr.AtmosphereResource;
4
+
5
+import java.util.Map;
6
+
7
+/**
8
+ * Websocket发送消息工具类
9
+ * Created by CX on 2018/8/9 0022.
10
+ */
11
+public class WebSocketSender {
12
+    private SessionCache cache;
13
+
14
+    public SessionCache getCache() {
15
+        return cache;
16
+    }
17
+
18
+    public void setCache(SessionCache cache) {
19
+        this.cache = cache;
20
+    }
21
+
22
+    /**
23
+     * 检查是否有浏览器连接进来,是否已经有缓存
24
+     *
25
+     * @return true有
26
+     */
27
+    public boolean isReady() {
28
+        if (this.cache != null) {
29
+            return true;
30
+        }
31
+        return false;
32
+    }
33
+
34
+    /**
35
+     * 给指定浏览器发送消息
36
+     *
37
+     * @param identity 浏览器唯一标识
38
+     * @param message  消息
39
+     * @throws Exception
40
+     */
41
+    public void identityMessage(String identity, String message) throws Exception {
42
+        if (this.cache != null && this.cache.contains(identity)) {
43
+            AtmosphereResource atmosphereResource = this.cache.get(identity);
44
+            if(atmosphereResource!=null && !atmosphereResource.isCancelled()){
45
+                atmosphereResource.getResponse().getWriter().write(message);
46
+            }else {
47
+                cache.removeByUUID(identity);
48
+            }
49
+        }
50
+    }
51
+
52
+    /**
53
+     * 广播给所有缓存浏览器发送消息
54
+     *
55
+     * @param message 消息
56
+     * @throws Exception
57
+     */
58
+    public void identityBroadcastMessage(String message) throws Exception {
59
+        if (this.cache != null) {
60
+            for (Map.Entry<String, AtmosphereResource> entry : cache.getIndentityCache().entrySet()) {
61
+                if(!entry.getValue().isCancelled()){
62
+                    entry.getValue().getResponse().getWriter().write(message);
63
+                }else {
64
+                    cache.removeByUUID(entry.getKey());
65
+                }
66
+            }
67
+        }
68
+    }
69
+}

+ 144 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/PhoneWebSocket.java

@@ -0,0 +1,144 @@
1
+package com.dashitech.callcenter.webSocket.service;
2
+
3
+import com.dashitech.businessdata.dao.IDictionaryDAO;
4
+import com.dashitech.businessdata.entity.DictionaryEntity;
5
+import com.dashitech.callcenter.socket.HandlerThread;
6
+import com.dashitech.callcenter.webSocket.core.CacheHandlerAdapter;
7
+import com.dashitech.callcenter.webSocket.core.WebSocketSender;
8
+import com.dashitech.utils.JsonUtil;
9
+import com.fasterxml.jackson.databind.ObjectMapper;
10
+import net.sf.json.JSONObject;
11
+import org.atmosphere.cache.UUIDBroadcasterCache;
12
+import org.atmosphere.client.TrackMessageSizeInterceptor;
13
+import org.atmosphere.config.service.WebSocketHandlerService;
14
+import org.atmosphere.interceptor.HeartbeatInterceptor;
15
+import org.atmosphere.util.SimpleBroadcaster;
16
+import org.atmosphere.websocket.WebSocket;
17
+import org.atmosphere.websocket.WebSocketProcessor;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.stereotype.Service;
20
+
21
+import java.io.IOException;
22
+import java.util.*;
23
+
24
+/**
25
+ * Created by chi on 2020/8/6.
26
+ */
27
+
28
+/**
29
+ * 给前端推送消息
30
+ */
31
+//@WebServlet(name="phoneWebSocket",urlPatterns="/webSocket")
32
+@Service
33
+@WebSocketHandlerService(path = "/webSocket/message/phone", interceptors = {
34
+        TrackMessageSizeInterceptor.class,  //校验消息大小,验证数据完整性,需要前端参数配合
35
+        HeartbeatInterceptor.class},    //保持心跳,维持链接,需要前端参数配合
36
+        broadcaster = SimpleBroadcaster.class,  //简单广播
37
+        broadcasterCache = UUIDBroadcasterCache.class,//加入缓存,防止消息丢失
38
+        atmosphereConfig = {"org.atmosphere.websocket.WebSocketProtocol=org.atmosphere.websocket.protocol.StreamingHttpProtocol"})
39
+public class PhoneWebSocket extends CacheHandlerAdapter {
40
+    public final static WebSocketSender webSocketSender = new WebSocketSender();
41
+
42
+    private static IDictionaryDAO dictionaryDAO;
43
+    @Autowired
44
+    public void setDictionaryDAO(IDictionaryDAO dictionaryDAO) {
45
+        PhoneWebSocket.dictionaryDAO = dictionaryDAO;
46
+    }
47
+
48
+    private  static Map<String,String> phoneMap = new HashMap<>();
49
+    private List<String> phoneChannelList = new ArrayList<>();
50
+    private String likeName;
51
+
52
+    @Override
53
+    public void onByteMessage(WebSocket webSocket, byte[] data, int offset, int length) throws IOException {
54
+        super.onByteMessage(webSocket, data, offset, length);
55
+    }
56
+
57
+    @Override
58
+    public void onOpen(WebSocket webSocket) throws IOException {
59
+        super.onOpen(webSocket);
60
+    }
61
+
62
+    @Override
63
+    public void onClose(WebSocket webSocket) {
64
+        //连接关闭同时销毁绑定话机连接
65
+        System.out.println(likeName + "哥们被关闭了!!!");
66
+   /*     for (String phoneChannel : phoneChannelList){
67
+            phoneMap.remove(phoneChannel);
68
+        }*/
69
+        super.onClose(webSocket);
70
+    }
71
+
72
+    @Override
73
+    public void onError(WebSocket webSocket, WebSocketProcessor.WebSocketException t) {
74
+        System.out.println(likeName + "哥们报错了!!!");
75
+        super.onError(webSocket, t);
76
+    }
77
+
78
+    @Override
79
+    public void onTextMessage(WebSocket webSocket, String data) throws IOException {
80
+        //如果没有缓存,初始化缓存
81
+        synchronized (this) {
82
+            if (!webSocketSender.isReady()) {
83
+                webSocketSender.setCache(this.getCACHE());
84
+            }
85
+        }
86
+        JSONObject jsonObject = JsonUtil.toJSONObject(data);
87
+        String identity = jsonObject.optString("userCount");
88
+        String[] nameAndPhone = identity.split("\\|");
89
+        String[] loginPhones = nameAndPhone[1].split("_");
90
+//        System.out.println(loginPhones.length+":33333333333333333333333333");
91
+       // List<DictionaryEntity> list = getPhoneDictionaryList("phone_num_port");
92
+        for (String phone:loginPhones){
93
+//            System.out.println( "777777777777777 "+ nameAndPhone[1] + " " + phone);
94
+            //if(a[1].equals(dictionaryEntity.getName())) {
95
+                //保存通道号,后续根据key销毁Map中的值。
96
+            phoneChannelList.add(phone);
97
+            phoneMap.put(phone, identity);
98
+            //}
99
+        }
100
+        //通过userCount的方式确定缓存的人员
101
+        login(webSocket.resource(),identity);
102
+        likeName = identity;
103
+        Map rMap=new HashMap();
104
+        rMap.put("status",200);
105
+        rMap.put("phone",nameAndPhone[1]);
106
+        ObjectMapper objectMapper=new ObjectMapper();
107
+        String json = objectMapper.writeValueAsString(rMap);
108
+        webSocket.resource().getResponse().getWriter().write(json);
109
+    }
110
+
111
+    public static void sendMessage(String phone,String json) throws Exception {
112
+        String identity = getIdentity(phone);
113
+//        System.out.println("888888888888888888888888 " + phone + " " +  identity);
114
+        if (identity!=null&&!identity.equals("")){
115
+            PhoneWebSocket.webSocketSender.identityMessage(identity,json);
116
+        }else {
117
+//            System.out.println("这个电话没有被绑定"+new Date());
118
+        }
119
+    }
120
+
121
+    public static String getIdentity(String phone){
122
+        //System.out.println();
123
+        for(String key : phoneMap.keySet()){
124
+//            System.out.println("getIdentity --> phoneMap (" + key + " " + phoneMap.get(key));
125
+        }
126
+        if (phone!=null){
127
+            String identity = phoneMap.get(phone);
128
+            if(identity != null){
129
+                return identity;
130
+            }else{
131
+                //System.out.println(phone);
132
+                return null;
133
+            }
134
+        }
135
+       return null;
136
+    }
137
+
138
+    public List<DictionaryEntity> getPhoneDictionaryList(String key){
139
+        List<DictionaryEntity> dictionaryEntityList= dictionaryDAO.selectDictionaryByKey(key);
140
+        return dictionaryEntityList;
141
+    }
142
+
143
+
144
+}

+ 46 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/demo/Data.java

@@ -0,0 +1,46 @@
1
+package com.dashitech.callcenter.webSocket.service.demo;
2
+
3
+import java.util.Date;
4
+
5
+/**
6
+ * Created by CX on 2018/8/8 0008.
7
+ */
8
+public class Data {
9
+    private String message;
10
+    private String author;
11
+    private long time;
12
+
13
+    public Data() {
14
+        this("", "");
15
+    }
16
+
17
+    public Data(String author, String message) {
18
+        this.author = author;
19
+        this.message = message;
20
+        this.time = new Date().getTime();
21
+    }
22
+
23
+    public String getMessage() {
24
+        return message;
25
+    }
26
+
27
+    public String getAuthor() {
28
+        return author;
29
+    }
30
+
31
+    public void setAuthor(String author) {
32
+        this.author = author;
33
+    }
34
+
35
+    public void setMessage(String message) {
36
+        this.message = message;
37
+    }
38
+
39
+    public long getTime() {
40
+        return time;
41
+    }
42
+
43
+    public void setTime(long time) {
44
+        this.time = time;
45
+    }
46
+}

+ 75 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/demo/WebSocketChat.java

@@ -0,0 +1,75 @@
1
+package com.dashitech.callcenter.webSocket.service.demo;
2
+
3
+import com.fasterxml.jackson.databind.ObjectMapper;
4
+import org.atmosphere.cache.UUIDBroadcasterCache;
5
+import org.atmosphere.client.TrackMessageSizeInterceptor;
6
+import org.atmosphere.config.service.WebSocketHandlerService;
7
+import org.atmosphere.interceptor.HeartbeatInterceptor;
8
+import org.atmosphere.util.SimpleBroadcaster;
9
+import org.atmosphere.websocket.WebSocket;
10
+import org.atmosphere.websocket.WebSocketProcessor;
11
+import org.atmosphere.websocket.WebSocketStreamingHandlerAdapter;
12
+
13
+import java.io.BufferedReader;
14
+import java.io.IOException;
15
+import java.io.Reader;
16
+
17
+/**
18
+ * Websocket示例 <br/>
19
+ * <p>
20
+ * 事件优先级:会先触发onClose事件,在触发订阅的事件
21
+ */
22
+@WebSocketHandlerService(path = "/chat/A", interceptors = {
23
+        TrackMessageSizeInterceptor.class,  //校验消息大小,验证数据完整性,需要前端参数配合
24
+        HeartbeatInterceptor.class},    //保持心跳,维持链接,需要前端参数配合
25
+        broadcaster = SimpleBroadcaster.class,  //简单广播
26
+        broadcasterCache = UUIDBroadcasterCache.class,//加入缓存,防止消息丢失
27
+        atmosphereConfig = {"org.atmosphere.websocket.WebSocketProtocol=org.atmosphere.websocket.protocol.StreamingHttpProtocol"})
28
+public class WebSocketChat extends WebSocketStreamingHandlerAdapter {
29
+    private final ObjectMapper mapper = new ObjectMapper();
30
+
31
+    @Override
32
+    public void onOpen(WebSocket webSocket) throws IOException {
33
+        System.out.println("A   onOpen   ");
34
+        //对当前会话进行事件注册
35
+//        webSocket.resource().addEventListener(new WebSocketEventListenerAdapter() {
36
+//            @Override
37
+//            public void onDisconnect(AtmosphereResourceEvent event) {
38
+//                if (event.isCancelled()) {
39
+//                    System.out.println("A   isCancelled    " + event.getResource().uuid());
40
+//                } else if (event.isClosedByClient()) {
41
+//                    System.out.println("A   isClosedByClient    " + event.getResource().uuid());
42
+//                }
43
+//            }
44
+//        });
45
+    }
46
+
47
+    @Override
48
+    public void onClose(WebSocket webSocket) {
49
+        System.out.println("A   onClose   "+ webSocket.resource().uuid());
50
+    }
51
+
52
+    @Override
53
+    public void onError(WebSocket webSocket, WebSocketProcessor.WebSocketException t) {
54
+        System.out.println("A   onError   " + t.toString());
55
+    }
56
+
57
+    @Override
58
+    public void onTextStream(WebSocket webSocket, Reader reader) throws IOException {
59
+        System.out.println("A   onTextStream   " + webSocket.resource().uuid());
60
+        webSocket.broadcast(mapper.writeValueAsString(mapper.readValue(new BufferedReader(reader).readLine(), Data.class)));
61
+
62
+        System.out.println("AAAAA " + webSocket.resource().getRequest().toString());
63
+        webSocket.resource().getResponse().getWriter().print("aaaaaaaaaaaaaa");
64
+
65
+        try {
66
+           //BossScreen.webSocketSender.identityBroadcastMessage(JsonUtil.toJSONObject(new Data("AAAA","11111")).toString());
67
+           // BossScreen.webSocketSender.identityMessage("123", JsonUtil.toJSONObject(new Data("BBBBBB","222222")).toString());
68
+           // BossScreen.webSocketSender.identityMessage("321", JsonUtil.toJSONObject(new Data("CCCCCCC","33333")).toString());
69
+        } catch (Exception ex) {
70
+            ex.printStackTrace();
71
+        }
72
+
73
+    }
74
+
75
+}

+ 89 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/application2.js

@@ -0,0 +1,89 @@
1
+$(function () {
2
+    "use strict";
3
+
4
+    var detect = $('#detect');
5
+    var header = $('#header');
6
+    var content = $('#content');
7
+    var input = $('#input');
8
+    var status = $('#status');
9
+    var myName = false;
10
+    var author = null;
11
+    var logged = false;
12
+    var socket = atmosphere;
13
+
14
+	var subSocket;
15
+
16
+    // We are now ready to cut the request
17
+    var request = { url: 'ws://localhost:8080/webSocket/message/manage',
18
+        contentType : "application/json",
19
+		shared : true,	// 标签共享
20
+		trackMessageLength : true,	//校验数据完整性
21
+        transport : 'websocket'};
22
+
23
+    request.onOpen = function(response) {
24
+        content.html($('<p>', { text: 'Atmosphere connected using ' + response.transport }));
25
+        input.removeAttr('disabled').focus();
26
+        status.text('Choose name:');
27
+		subSocket.push(JSON.stringify({userCount:'fuwutai'}));
28
+    };
29
+
30
+    request.onMessage = function (response) {
31
+        var message = response.responseBody;
32
+        try {
33
+            var json = JSON.parse(message);
34
+            alert(message);
35
+        } catch (e) {
36
+            console.log('This doesn\'t look like a valid JSON: ', message);
37
+            return;
38
+        }
39
+
40
+        input.removeAttr('disabled').focus();
41
+        if (!logged && myName) {
42
+            status.text(myName + ': ').css('color', 'blue');
43
+            input.removeAttr('disabled').focus();
44
+            logged = true;
45
+        } else {
46
+            var me = json.author == author;
47
+            var date = typeof(json.time) == 'string' ? parseInt(json.time) : json.time;
48
+            addMessage(json.author, json.message, me ? 'blue' : 'black', new Date(date));
49
+        }
50
+    };
51
+
52
+    request.onClose = function(response) {
53
+        logged = false;
54
+    }
55
+
56
+    request.onError = function(response) {
57
+        content.html($('<p>', { text: 'Sorry, but there\'s some problem with your '
58
+            + 'socket or the server is down' }));
59
+    };
60
+
61
+    subSocket = socket.subscribe(request);
62
+
63
+    input.keydown(function(e) {
64
+        if (e.keyCode === 13) {
65
+            var msg = $(this).val();
66
+
67
+            // First message is always the author's name
68
+            if (author == null) {
69
+                author = msg;
70
+            }
71
+
72
+            subSocket.push(JSON.stringify({ author: author, message: msg }));
73
+            $(this).val('');
74
+
75
+            input.attr('disabled', 'disabled');
76
+            if (myName === false) {
77
+                myName = msg;
78
+            }
79
+        }
80
+    });
81
+
82
+    function addMessage(author, message, color, datetime) {
83
+        content.append('<p><span style="color:' + color + '">' + author + '</span> @ ' +
84
+            + (datetime.getHours() < 10 ? '0' + datetime.getHours() : datetime.getHours()) + ':'
85
+            + (datetime.getMinutes() < 10 ? '0' + datetime.getMinutes() : datetime.getMinutes())
86
+            + ': ' + message + '</p>');
87
+    }
88
+});
89
+

+ 27 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/index.html

@@ -0,0 +1,27 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+    <meta charset="utf-8">
5
+    <title>Atmosphere WebSocket Chat</title>
6
+    <script type="text/javascript" src="./javascript/jquery-2.0.3.js"></script>
7
+    <script type="text/javascript" src="./javascript/atmosphere.js"></script>
8
+    <script type="text/javascript" src="./javascript/application.js"></script>
9
+    <style>
10
+    * {font-family: tahoma; font-size: 12px; padding: 0px; margin: 0px;}
11
+    p {line-height: 18px;}
12
+    div {width: 500px; margin-left: auto; margin-right: auto;}
13
+    #content {padding: 5px; background: #ddd; border-radius: 5px; border: 1px solid #CCC; margin-top: 10px;}
14
+    #header {padding: 5px; background: #f5deb3; border-radius: 5px; border: 1px solid #CCC; margin-top: 10px;}
15
+    #input {border-radius: 2px; border: 1px solid #ccc; margin-top: 10px; padding: 5px; width: 400px;}
16
+    #status {width: 88px; display: block; float: left; margin-top: 15px;}
17
+    </style>
18
+</head>
19
+<body>
20
+    <div id="header"><h3>Atmosphere WebSocket ONLY Chat</h3></div>
21
+    <div id="content"></div>
22
+    <div>
23
+        <span id="status">Connecting...</span>
24
+        <input type="text" id="input" disabled="disabled"/>
25
+    </div>
26
+</body>
27
+</html>

+ 27 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/index2.html

@@ -0,0 +1,27 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+    <meta charset="utf-8">
5
+    <title>Atmosphere WebSocket Chat</title>
6
+    <script type="text/javascript" src="./javascript/jquery-2.0.3.js"></script>
7
+    <script type="text/javascript" src="./javascript/atmosphere.js"></script>
8
+    <script type="text/javascript" src="./application2.js"></script>
9
+    <style>
10
+    * {font-family: tahoma; font-size: 12px; padding: 0px; margin: 0px;}
11
+    p {line-height: 18px;}
12
+    div {width: 500px; margin-left: auto; margin-right: auto;}
13
+    #content {padding: 5px; background: #ddd; border-radius: 5px; border: 1px solid #CCC; margin-top: 10px;}
14
+    #header {padding: 5px; background: #f5deb3; border-radius: 5px; border: 1px solid #CCC; margin-top: 10px;}
15
+    #input {border-radius: 2px; border: 1px solid #ccc; margin-top: 10px; padding: 5px; width: 400px;}
16
+    #status {width: 88px; display: block; float: left; margin-top: 15px;}
17
+    </style>
18
+</head>
19
+<body>
20
+    <div id="header"><h3>Atmosphere WebSocket ONLY Chat</h3></div>
21
+    <div id="content"></div>
22
+    <div>
23
+        <span id="status">Connecting...</span>
24
+        <input type="text" id="input" disabled="disabled"/>
25
+    </div>
26
+</body>
27
+</html>

+ 90 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/javascript/application.js

@@ -0,0 +1,90 @@
1
+$(function () {
2
+    "use strict";
3
+
4
+    var detect = $('#detect');
5
+    var header = $('#header');
6
+    var content = $('#content');
7
+    var input = $('#input');
8
+    var status = $('#status');
9
+    var myName = false;
10
+    var author = null;
11
+    var logged = false;
12
+    var socket = atmosphere;
13
+
14
+	var subSocket;
15
+
16
+    // We are now ready to cut the request
17
+    var request = { url: 'ws://localhost:8080/chat/A',
18
+        contentType : "application/json",
19
+		shared : true,	// 标签共享
20
+		trackMessageLength : true,	//校验数据完整性
21
+        transport : 'websocket'};
22
+
23
+    request.onOpen = function(response) {
24
+        content.html($('<p>', { text: 'Atmosphere connected using ' + response.transport }));
25
+        input.removeAttr('disabled').focus();
26
+        status.text('Choose name:');
27
+		subSocket.push(JSON.stringify({ author: 'author', message: 'msg' }));
28
+    };
29
+
30
+    request.onMessage = function (response) {
31
+        var message = response.responseBody;
32
+        try {
33
+            var json = JSON.parse(message);
34
+            alert(message);
35
+
36
+        } catch (e) {
37
+            console.log('This doesn\'t look like a valid JSON: ', message);
38
+            return;
39
+        }
40
+
41
+        input.removeAttr('disabled').focus();
42
+        if (!logged && myName) {
43
+            status.text(myName + ': ').css('color', 'blue');
44
+            input.removeAttr('disabled').focus();
45
+            logged = true;
46
+        } else {
47
+            var me = json.author == author;
48
+            var date = typeof(json.time) == 'string' ? parseInt(json.time) : json.time;
49
+            addMessage(json.author, json.message, me ? 'blue' : 'black', new Date(date));
50
+        }
51
+    };
52
+
53
+    request.onClose = function(response) {
54
+        logged = false;
55
+    }
56
+
57
+    request.onError = function(response) {
58
+        content.html($('<p>', { text: 'Sorry, but there\'s some problem with your '
59
+            + 'socket or the server is down' }));
60
+    };
61
+
62
+    subSocket = socket.subscribe(request);
63
+
64
+    input.keydown(function(e) {
65
+        if (e.keyCode === 13) {
66
+            var msg = $(this).val();
67
+
68
+            // First message is always the author's name
69
+            if (author == null) {
70
+                author = msg;
71
+            }
72
+
73
+            subSocket.push(JSON.stringify({ author: author, message: msg }));
74
+            $(this).val('');
75
+
76
+            input.attr('disabled', 'disabled');
77
+            if (myName === false) {
78
+                myName = msg;
79
+            }
80
+        }
81
+    });
82
+
83
+    function addMessage(author, message, color, datetime) {
84
+        content.append('<p><span style="color:' + color + '">' + author + '</span> @ ' +
85
+            + (datetime.getHours() < 10 ? '0' + datetime.getHours() : datetime.getHours()) + ':'
86
+            + (datetime.getMinutes() < 10 ? '0' + datetime.getMinutes() : datetime.getMinutes())
87
+            + ': ' + message + '</p>');
88
+    }
89
+});
90
+

文件差异内容过多而无法显示
+ 1152 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/javascript/atmosphere-min.js


文件差异内容过多而无法显示
+ 3430 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/javascript/atmosphere.js


文件差异内容过多而无法显示
+ 8829 - 0
src/main/java/com/dashitech/callcenter/webSocket/service/demo/js/javascript/jquery-2.0.3.js


+ 58 - 0
src/main/java/com/dashitech/config/ApiFilterConfig.java

@@ -0,0 +1,58 @@
1
+package com.dashitech.config;
2
+
3
+import org.apache.commons.logging.Log;
4
+import org.apache.commons.logging.LogFactory;
5
+import org.springframework.web.servlet.ModelAndView;
6
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
7
+
8
+import javax.servlet.http.HttpServletRequest;
9
+import javax.servlet.http.HttpServletResponse;
10
+
11
+/**
12
+ * API-rest服务拦截器 <br/>
13
+ * 对请求进行ip校验,出错返回拒绝信息
14
+ */
15
+public class ApiFilterConfig extends HandlerInterceptorAdapter {
16
+    private static Log log = LogFactory.getLog(ApiFilterConfig.class);
17
+
18
+    @Override
19
+    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
20
+        super.postHandle(request, response, handler, modelAndView);
21
+    }
22
+
23
+    @Override
24
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
25
+        super.afterCompletion(request, response, handler, ex);
26
+    }
27
+
28
+    @Override
29
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
30
+        response.setCharacterEncoding("UTF-8");
31
+
32
+//        HandlerMethod hm = (HandlerMethod) handler;
33
+//        String visitMethod = hm.getMethod().getName();
34
+
35
+        //校验
36
+        boolean flag = check(request.getRemoteHost());
37
+
38
+        //验证失败,拒绝请求
39
+  /*      if (!flag) {
40
+            MessageResult result = new MessageResult();
41
+            result.setSuccess(false);
42
+            result.setMsg("403 forbidden");
43
+            response.getWriter().print(JsonUtil.toJsonString(result));
44
+        }else {
45
+            log.error("ApiFilter Check Error:"+ request.getRequestURL().toString() + "  IP:"+ request.getRemoteAddr());
46
+        }*/
47
+
48
+        return flag;
49
+    }
50
+
51
+    private boolean check(String ip) {
52
+//        if (StringUtils.isNotEmpty(ip) && (ip.equals("127.0.0.1") || ip.equals("localhost") || ip.equals("0:0:0:0:0:0:0:1"))) {
53
+//            return true;
54
+//        }
55
+//        return false;
56
+        return true;
57
+    }
58
+}

+ 48 - 0
src/main/java/com/dashitech/config/ApiWeblogFilterConfig.java

@@ -0,0 +1,48 @@
1
+package com.dashitech.config;
2
+
3
+import org.apache.commons.logging.Log;
4
+import org.apache.commons.logging.LogFactory;
5
+import org.aspectj.lang.JoinPoint;
6
+import org.aspectj.lang.annotation.AfterReturning;
7
+import org.aspectj.lang.annotation.Aspect;
8
+import org.aspectj.lang.annotation.Before;
9
+import org.aspectj.lang.annotation.Pointcut;
10
+import org.springframework.core.annotation.Order;
11
+import org.springframework.stereotype.Component;
12
+import org.springframework.web.context.request.RequestContextHolder;
13
+import org.springframework.web.context.request.ServletRequestAttributes;
14
+
15
+import javax.servlet.http.HttpServletRequest;
16
+
17
+/**
18
+ * 路径拦截器
19
+ */
20
+@Aspect
21
+@Order(2)
22
+@Component
23
+public class ApiWeblogFilterConfig {
24
+    private static Log log = LogFactory.getLog(ApiWeblogFilterConfig.class);
25
+
26
+    ThreadLocal<Long> startTime = new ThreadLocal<Long>();
27
+
28
+    @Pointcut("execution(public * com.dashitech.api..*.*(..))")
29
+    public void webLog() {
30
+        log.info("show()");
31
+    }
32
+
33
+    @Before("webLog()")
34
+    public void doBefore(JoinPoint joinPoint) throws Throwable {
35
+        startTime.set(System.currentTimeMillis());
36
+        // 接收到请求,记录请求内容
37
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
38
+        HttpServletRequest request = attributes.getRequest();
39
+        // 记录下请求内容
40
+        log.info(Thread.currentThread().getName() + "   ApiLog-URL : " + request.getRequestURL().toString() + "   IP : " + request.getRemoteAddr());
41
+//        log.info(Thread.currentThread().getName() + "   ApiLog-ARGS : " + Arrays.toString(joinPoint.getArgs()));
42
+    }
43
+
44
+    @AfterReturning(returning = "ret", pointcut = "webLog()")
45
+    public void doAfterReturning(Object ret) throws Throwable {
46
+        log.info(Thread.currentThread().getName() + "   ApiLog-AVG/MS : " + (System.currentTimeMillis() - startTime.get()) + "/ms ");
47
+    }
48
+}

+ 32 - 0
src/main/java/com/dashitech/config/DataSourceConfig.java

@@ -0,0 +1,32 @@
1
+
2
+package com.dashitech.config;
3
+
4
+import org.springframework.beans.factory.annotation.Qualifier;
5
+import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
6
+import org.springframework.boot.context.properties.ConfigurationProperties;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.Configuration;
9
+import org.springframework.context.annotation.Primary;
10
+
11
+import javax.sql.DataSource;
12
+
13
+
14
+/**
15
+ * Created by chi on 2019/9/20.
16
+ */
17
+
18
+@Configuration
19
+public class DataSourceConfig {
20
+
21
+    /**
22
+     *  数据源2
23
+     */
24
+
25
+    @Bean(name = "mysql2DataSource")
26
+    @Qualifier(value = "mysql2DataSource")
27
+    @ConfigurationProperties(prefix = "mysql2.spring.datasource")
28
+    public DataSource mysql2DataSource(){
29
+        return DataSourceBuilder.create().build();
30
+    }
31
+}
32
+

+ 16 - 0
src/main/java/com/dashitech/config/DruidConfig.java

@@ -0,0 +1,16 @@
1
+package com.dashitech.config;
2
+
3
+import javax.servlet.annotation.WebInitParam;
4
+import javax.servlet.annotation.WebServlet;
5
+
6
+@WebServlet(urlPatterns = "/druid/*", 
7
+    initParams={
8
+            @WebInitParam(name="allow",value="127.0.0.1"),// IP白名单 (没有配置或者为空,则允许所有访问)
9
+            @WebInitParam(name="deny",value="192.168.16.111"),// IP黑名单 (存在共同时,deny优先于allow)
10
+            @WebInitParam(name="loginUsername",value="itsm"),// 用户名
11
+            @WebInitParam(name="loginPassword",value="100100"),// 密码
12
+            @WebInitParam(name="resetEnable",value="false")// 禁用HTML页面上的“Reset All”功能
13
+    })
14
+public class DruidConfig {
15
+
16
+}

+ 14 - 0
src/main/java/com/dashitech/config/DruidFilter.java

@@ -0,0 +1,14 @@
1
+package com.dashitech.config;
2
+
3
+import com.alibaba.druid.support.http.WebStatFilter;
4
+
5
+import javax.servlet.annotation.WebFilter;
6
+import javax.servlet.annotation.WebInitParam;
7
+
8
+@WebFilter(filterName="druidWebStatFilter",urlPatterns="/*",
9
+	    initParams={
10
+	        @WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")// 忽略资源
11
+	})
12
+public class DruidFilter extends WebStatFilter{
13
+
14
+}

+ 30 - 0
src/main/java/com/dashitech/config/TomcatConfig.java

@@ -0,0 +1,30 @@
1
+package com.dashitech.config;
2
+
3
+import org.apache.catalina.connector.Connector;
4
+import org.apache.coyote.http11.Http11NioProtocol;
5
+import org.springframework.boot.context.embedded.EmbeddedServletContainer;
6
+//import org.springframework.boot.context.embedded.ServletContextInitializer;
7
+import org.springframework.boot.web.servlet.ServletContextInitializer;
8
+import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
9
+import org.springframework.stereotype.Component;
10
+
11
+import java.nio.charset.Charset;
12
+
13
+@Component
14
+public class TomcatConfig extends TomcatEmbeddedServletContainerFactory {
15
+	public EmbeddedServletContainer getEmbeddedServletContainer(ServletContextInitializer... initializers) {
16
+		return super.getEmbeddedServletContainer(initializers);
17
+	}
18
+
19
+	protected void customizeConnector(Connector connector) {
20
+		super.customizeConnector(connector);
21
+		setUriEncoding(Charset.forName("UTF-8"));
22
+		Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
23
+		// 设置最大连接数
24
+		protocol.setMaxConnections(1000);
25
+		// 设置最大线程数
26
+		protocol.setMaxThreads(1000);
27
+		protocol.setConnectionTimeout(30000);
28
+	}
29
+
30
+}

+ 108 - 0
src/main/java/com/dashitech/config/datasource/MySQL2DataSourceConfig.java

@@ -0,0 +1,108 @@
1
+package com.dashitech.config.datasource;
2
+
3
+/**
4
+ * Created by chi on 2019/10/17.
5
+ */
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.beans.factory.annotation.Qualifier;
8
+import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
9
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
10
+import org.springframework.context.annotation.Bean;
11
+import org.springframework.context.annotation.Configuration;
12
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
13
+import org.springframework.orm.jpa.JpaTransactionManager;
14
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
15
+import org.springframework.orm.jpa.vendor.Database;
16
+import org.springframework.transaction.PlatformTransactionManager;
17
+import org.springframework.transaction.annotation.EnableTransactionManagement;
18
+
19
+import javax.persistence.EntityManager;
20
+import javax.sql.DataSource;
21
+import java.util.HashMap;
22
+import java.util.Map;
23
+
24
+/**
25
+ * Created by chi on 2019/9/20.
26
+ */
27
+@Configuration
28
+@EnableTransactionManagement
29
+@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactoryMysql2",   //EntityManagerFactory引用
30
+        transactionManagerRef = "transactionManagerMysql2",      //transactionManager引用
31
+        basePackages = {"com.dashitech.businessdata"})         //设置 基因网orderDiscountDataSource应用到的包
32
+
33
+public class MySQL2DataSourceConfig {
34
+    /**
35
+     * 注入 基因网订单折扣数据源
36
+     */
37
+    @Autowired()
38
+    @Qualifier("mysql2DataSource")
39
+    private DataSource mysql2DataSource;
40
+
41
+    /**
42
+     * 注入JPA配置实体
43
+     */
44
+    @Autowired
45
+    private JpaProperties jpaProperties;
46
+
47
+    /**
48
+     * 通过调用JPA配置实体中的解析方法,解析datasource中各属性的值
49
+     * @param dataSource    数据源
50
+     * @return     本数据源中各参数
51
+     * Map中设值分别为:
52
+     *      hibernate-dialect   方言
53
+     *      hibernate.hbm2ddl.auto  DDL执行策略
54
+     *      hibernate.physical_naming_strategy  命名策略
55
+     *
56
+     *这些和不同类型数据库密切相关的属性设置,不能设置在application.properties中,所以需要再不同的数据源中具体设置,赋值给JpaProperties
57
+     */
58
+    private Map<String,String> getVendorProperties(DataSource dataSource){
59
+        jpaProperties.setDatabase(Database.MYSQL);
60
+        Map<String,String> map = new HashMap<>();
61
+        map.put("hibernate.dialect","org.hibernate.dialect.MySQL5Dialect");
62
+        map.put("hibernate.hbm2ddl.auto","update");
63
+        map.put("hibernate.physical_naming_strategy","org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl");
64
+        jpaProperties.setProperties(map);
65
+        return  jpaProperties.getHibernateProperties(dataSource);
66
+    }
67
+
68
+    /**
69
+     * 配置EntityManagerFactory实体
70
+     * @param builder
71
+     * @return      实体管理工厂
72
+     * packages     扫描@Entity注释的软件包名称
73
+     * persistenceUnit  持久性单元的名称。 如果只建立一个EntityManagerFactory,你可以省略这个,但是如果在同一个应用程序中有多个,你应该给它们不同的名字
74
+     * properties       标准JPA或供应商特定配置的通用属性。 这些属性覆盖构造函数中提供的任何值。
75
+     *
76
+     */
77
+    @Bean(name = "entityManagerFactoryMysql2")
78
+    public LocalContainerEntityManagerFactoryBean entityManagerFactoryMysql2(EntityManagerFactoryBuilder builder){
79
+        return builder
80
+                .dataSource(mysql2DataSource)
81
+                .properties(getVendorProperties(mysql2DataSource))
82
+                .packages(new String[]{"com.dashitech.businessdata"})
83
+                .persistenceUnit("mysql2PersistenceUnit")
84
+                .build();
85
+    }
86
+
87
+    /**
88
+     * 配置EntityManager实体
89
+     * @param builder
90
+     * @return      实体管理器
91
+     */
92
+    @Bean(name = "entityManagerMysql2")
93
+    public EntityManager entityManager(EntityManagerFactoryBuilder builder){
94
+        return entityManagerFactoryMysql2(builder).getObject().createEntityManager();
95
+    }
96
+
97
+
98
+    /**
99
+     * 配置事务transactionManager
100
+     * @param builder
101
+     * @return      事务管理器
102
+     */
103
+    @Bean(name = "transactionManagerMysql2")
104
+    public PlatformTransactionManager transactionManagerOrderDiscount(EntityManagerFactoryBuilder builder){
105
+        return  new JpaTransactionManager(entityManagerFactoryMysql2(builder).getObject());
106
+    }
107
+
108
+}

+ 71 - 0
src/main/java/com/dashitech/redis/core/JedisPoolFactory.java

@@ -0,0 +1,71 @@
1
+package com.dashitech.redis.core;
2
+
3
+import com.dashitech.utils.PropertiesUtil;
4
+import redis.clients.jedis.Jedis;
5
+import redis.clients.jedis.JedisPool;
6
+import redis.clients.jedis.JedisPoolConfig;
7
+
8
+/**
9
+ * Redis抽象工厂实例类,务必在Spring的数据库配置加载完成后在调用此类!否则会报错
10
+ * Created by CX on 2018/8/20 0020.
11
+ */
12
+public abstract class JedisPoolFactory {
13
+    private static JedisPool pool;
14
+
15
+
16
+    private synchronized static JedisPool getJedisPool() {
17
+        if (pool == null) {
18
+            String host = PropertiesUtil.getProperty("spring.redis.host");
19
+            Integer port = PropertiesUtil.getInteger("spring.redis.port");
20
+            String password = PropertiesUtil.getProperty("spring.redis.password");
21
+            JedisPoolConfig config = new JedisPoolConfig();
22
+            config.setMaxTotal(PropertiesUtil.getInteger("spring.redis.pool.max-total"));
23
+            config.setMaxIdle(PropertiesUtil.getInteger("spring.redis.pool.max-idle"));
24
+            config.setMaxWaitMillis(PropertiesUtil.getInteger("spring.redis.pool.max-wait-millis"));
25
+            config.setTestOnBorrow(true);
26
+            pool = new JedisPool(config, host, port,5000,password);
27
+        }
28
+        return pool;
29
+    }
30
+
31
+
32
+    private synchronized static JedisPool getDefaultJedisPool() {
33
+        if (pool == null) {
34
+            String host = "127.0.0.1";
35
+            Integer port = 6379;
36
+            JedisPoolConfig config = new JedisPoolConfig();
37
+            config.setMaxTotal(100);
38
+            config.setMaxIdle(20);
39
+            config.setMaxWaitMillis(10000);
40
+            config.setTestOnBorrow(true);
41
+            pool = new JedisPool(config, host, port);
42
+        }
43
+        return pool;
44
+    }
45
+
46
+    /**
47
+     * 使用默认127.0.0.1和默认6379端口
48
+     *
49
+     * @return
50
+     */
51
+    public synchronized static Jedis getDefaultJedis() {
52
+        if (pool == null) {
53
+            return getDefaultJedisPool().getResource();
54
+        } else {
55
+            return pool.getResource();
56
+        }
57
+    }
58
+
59
+
60
+    /**
61
+     * 读数据库userRedisIp和userRedisPort,如果没有读取到报错
62
+     */
63
+    public synchronized static Jedis getJedis() {
64
+        if (pool == null) {
65
+            return getJedisPool().getResource();
66
+        } else {
67
+            return pool.getResource();
68
+        }
69
+    }
70
+
71
+}

+ 162 - 0
src/main/java/com/dashitech/redis/core/RedisHashCmd.java

@@ -0,0 +1,162 @@
1
+package com.dashitech.redis.core;
2
+
3
+import redis.clients.jedis.Jedis;
4
+
5
+import java.util.HashMap;
6
+import java.util.List;
7
+import java.util.Map;
8
+import java.util.Set;
9
+
10
+/**
11
+ * Redis键值队列,元素key不可重复,注意并发问题
12
+ * Created by CX on 2018/8/20 0020.
13
+ */
14
+public class RedisHashCmd {
15
+
16
+    public static void main(String[] args) {
17
+        Map<String, String> map = new HashMap<>();
18
+        map.put("A", "1");
19
+        map.put("B", "2");
20
+
21
+        JedisPoolFactory.getDefaultJedis();
22
+        RedisHashCmd redisMap = new RedisHashCmd();
23
+        redisMap.putAll("MapA", map);
24
+
25
+
26
+        redisMap.put("MapA", "C", "3");
27
+        redisMap.put("MapA", "C", "4");
28
+
29
+        System.out.println(redisMap.containsKey("MapA", "C"));
30
+        System.out.println(redisMap.get("MapA", "C"));
31
+        System.out.println(redisMap.values("MapA"));
32
+        redisMap.remove("MapA", "A");
33
+
34
+        redisMap.drop("MapA");
35
+    }
36
+
37
+    /**
38
+     * 新增,如果队列不存在,新建这个队列,如果存在直接覆盖键和值
39
+     *
40
+     * @param name  队列名称
41
+     * @param key   主键
42
+     * @param value 值
43
+     */
44
+    public static void put(String name, String key, String value) {
45
+        Jedis jedis = JedisPoolFactory.getJedis();
46
+        try {
47
+            jedis.hset(name, key, value);
48
+        } finally {
49
+            jedis.close();
50
+        }
51
+    }
52
+
53
+    /**
54
+     * 批量新增,如果队列不存在,新建这个队列,如果存在直接覆盖键和值
55
+     */
56
+    public static void putAll(String name, Map<String, String> map) {
57
+        Jedis jedis = JedisPoolFactory.getJedis();
58
+        try {
59
+            jedis.hmset(name, map);
60
+        } catch (Exception ex) {
61
+            ex.printStackTrace();
62
+        } finally {
63
+            jedis.close();
64
+        }
65
+    }
66
+
67
+    /**
68
+     * 删除key和对应值
69
+     */
70
+    public static void remove(String name, String key) {
71
+        Jedis jedis = JedisPoolFactory.getJedis();
72
+        try {
73
+            jedis.hdel(name, key);
74
+        }catch (Exception ex) {
75
+            ex.printStackTrace();
76
+        }finally {
77
+            jedis.close();
78
+        }
79
+    }
80
+
81
+    /**
82
+     * 直接删除队列本身
83
+     */
84
+    public static void drop(String name) {
85
+        Jedis jedis = JedisPoolFactory.getJedis();
86
+        try {
87
+            jedis.del(name);
88
+        } finally {
89
+            jedis.close();
90
+        }
91
+    }
92
+
93
+    /**
94
+     * 获取key对应值
95
+     */
96
+    public static String get(String name, String key) {
97
+        Jedis jedis = JedisPoolFactory.getJedis();
98
+        try {
99
+            return jedis.hget(name, key);
100
+        } finally {
101
+            jedis.close();
102
+        }
103
+    }
104
+
105
+    /**
106
+     * key集合
107
+     */
108
+    public static Set<String> keySet(String name) {
109
+        Jedis jedis = JedisPoolFactory.getJedis();
110
+        try {
111
+            return jedis.hkeys(name);
112
+        } finally {
113
+            jedis.close();
114
+        }
115
+    }
116
+
117
+    /**
118
+     * value集合
119
+     */
120
+    public static List<String> values(String name) {
121
+        Jedis jedis = JedisPoolFactory.getJedis();
122
+        try {
123
+            return jedis.hvals(name);
124
+        } finally {
125
+            jedis.close();
126
+        }
127
+    }
128
+
129
+    public static Map<String, String> getAll(String name) {
130
+        Jedis jedis = JedisPoolFactory.getJedis();
131
+        try {
132
+            return jedis.hgetAll(name);
133
+        } finally {
134
+            jedis.close();
135
+        }
136
+    }
137
+
138
+    /**
139
+     * 是否存在这个key
140
+     */
141
+    public static boolean containsKey(String name, String key) {
142
+        Jedis jedis = JedisPoolFactory.getJedis();
143
+        try {
144
+            return jedis.hexists(name, key);
145
+        } finally {
146
+            jedis.close();
147
+        }
148
+    }
149
+
150
+    /**
151
+     * 队列大小
152
+     */
153
+    public static Long size(String name) {
154
+        Jedis jedis = JedisPoolFactory.getJedis();
155
+        try {
156
+            return jedis.hlen(name);
157
+        } finally {
158
+            jedis.close();
159
+        }
160
+    }
161
+
162
+}

+ 33 - 0
src/main/java/com/dashitech/redis/core/RedisKeys.java

@@ -0,0 +1,33 @@
1
+package com.dashitech.redis.core;
2
+
3
+/**
4
+ * Created by chi on 2020/6/12.
5
+ */
6
+public class RedisKeys {
7
+
8
+    /**
9
+     * 自动建单订阅
10
+     */
11
+    public static final String ITSM_ORDER_CREATE_PUBSUB = "itsm_order_create_pubsub";
12
+
13
+    /**
14
+     * 任务类型
15
+     */
16
+    public static final String ITSM_TASKTYPE_HASH = "itsm_taskType_hash";
17
+
18
+    /**
19
+     * 自动建单,消息队列
20
+     */
21
+    public static final String ITSM_CREATE_ORDER_LIST = "itsm_create_order_list";
22
+
23
+    /**
24
+     * 数据同步,消息队列
25
+     */
26
+    public static final String ITSM_SYS_DATA_LIST = "itsm_sys_data_list";
27
+
28
+    /**
29
+     * 标本收取状态变更,是否需要闭环上报队列
30
+     */
31
+    public static final String ITSM_SPECIMEN_STATUS_LIST = "itsm_specimen_status_list";
32
+
33
+}

+ 182 - 0
src/main/java/com/dashitech/redis/core/RedisListCmd.java

@@ -0,0 +1,182 @@
1
+package com.dashitech.redis.core;
2
+
3
+import redis.clients.jedis.Jedis;
4
+
5
+import java.util.ArrayList;
6
+import java.util.List;
7
+
8
+/**
9
+ * Redis队列,元素可重复,注意并发问题
10
+ * Created by CX on 2018/8/20 0020.
11
+ */
12
+public class RedisListCmd {
13
+
14
+    public static void main(String[] args) {
15
+        JedisPoolFactory.getDefaultJedis();
16
+        RedisListCmd redisList = new RedisListCmd();
17
+
18
+        redisList.add("AAAAAAAAA", "A");
19
+        redisList.add("AAAAAAAAA", "B");
20
+        redisList.add("AAAAAAAAA", 0, "C");
21
+        redisList.add("AAAAAAAAA", "A");
22
+
23
+        List<String> list = new ArrayList<>();
24
+        list.add("1111");
25
+        list.add("2222");
26
+        redisList.addAll("AAAAAAAAA", list);
27
+
28
+        System.out.println(redisList.indexOf("AAAAAAAAA", "A"));
29
+        System.out.println(redisList.contains("AAAAAAAAA", "B"));
30
+        System.out.println(redisList.get("AAAAAAAAA", 1));
31
+        System.out.println(redisList.get("AAAAAAAAA"));
32
+        System.out.println(redisList.size("AAAAAAAAA"));
33
+
34
+        redisList.remove("AAAAAAAAA", "B");
35
+
36
+        redisList.drop("AAAAAAAAA");
37
+
38
+    }
39
+
40
+    /**
41
+     * 新增,如果队列不存在,新建这个队列,如果存在插入值到队列最后面
42
+     *
43
+     * @param name  队列名称
44
+     * @param value 值
45
+     */
46
+    public static void add(String name, String value) {
47
+        Jedis jedis = JedisPoolFactory.getJedis();
48
+        try {
49
+            jedis.rpush(name, value);
50
+        } finally {
51
+            jedis.close();
52
+        }
53
+    }
54
+
55
+    /**
56
+     * 在指定下标插入值,注意!原下标值会被当前值覆盖!如果下标出错,会报错
57
+     */
58
+    public static void add(String name, int index, String value) {
59
+        Jedis jedis = JedisPoolFactory.getJedis();
60
+        try {
61
+            jedis.lset(name, index, value);
62
+        } finally {
63
+            jedis.close();
64
+        }
65
+    }
66
+
67
+    /**
68
+     * 批量新增,如果队列不存在,新建这个队列,如果存在插入值到队列最后面
69
+     */
70
+    public static void addAll(String name, List<String> list) {
71
+        Jedis jedis = JedisPoolFactory.getJedis();
72
+        try {
73
+            if (list != null && list.size() > 0) {
74
+                String[] values = new String[list.size()];
75
+                for (int i = 0; i < list.size(); i++) {
76
+                    values[i] = list.get(i);
77
+                }
78
+                jedis.rpush(name, values);
79
+            }
80
+        } finally {
81
+            jedis.close();
82
+        }
83
+    }
84
+
85
+    /**
86
+     * 删除所有和value值相等的对象
87
+     */
88
+    public static void remove(String name, String value) {
89
+        Jedis jedis = JedisPoolFactory.getJedis();
90
+        try {
91
+            jedis.lrem(name, 0, value);
92
+        } finally {
93
+            jedis.close();
94
+        }
95
+    }
96
+
97
+    /**
98
+     * 直接删除队列本身
99
+     */
100
+    public static void drop(String name) {
101
+        Jedis jedis = JedisPoolFactory.getJedis();
102
+        try {
103
+            jedis.del(name);
104
+        } finally {
105
+            jedis.close();
106
+        }
107
+    }
108
+
109
+    /**
110
+     * 根据下标获取值
111
+     */
112
+    public static String get(String name, int index) {
113
+        Jedis jedis = JedisPoolFactory.getJedis();
114
+        try {
115
+            return jedis.lindex(name, index);
116
+        } finally {
117
+            jedis.close();
118
+        }
119
+    }
120
+
121
+    /**
122
+     * 获取所有值
123
+     */
124
+    public static List<String> get(String name) {
125
+        Jedis jedis = JedisPoolFactory.getJedis();
126
+        try {
127
+            return jedis.lrange(name, 0, -1);
128
+        } finally {
129
+            jedis.close();
130
+        }
131
+    }
132
+
133
+    /**
134
+     * 直接比对返回下标
135
+     */
136
+    public static int indexOf(String name, String value) {
137
+        List<String> list = get(name);
138
+        if (list != null && list.size() > 0) {
139
+            for (int i = 0; i < list.size(); i++) {
140
+                String _value = list.get(i);
141
+                if (_value.equals(value)) {
142
+                    return i;
143
+                }
144
+            }
145
+        }
146
+        return -1;
147
+    }
148
+
149
+    /**
150
+     * 获取并移除列表第一个值,如果队列空了,返回null
151
+     */
152
+    public static String pop(String name) {
153
+        Jedis jedis = JedisPoolFactory.getJedis();
154
+        try {
155
+            return jedis.lpop(name);
156
+        } finally {
157
+            jedis.close();
158
+        }
159
+    }
160
+
161
+
162
+    /**
163
+     * 直接返回是否包含
164
+     */
165
+    public static boolean contains(String name, String value) {
166
+        int index = indexOf(name, value);
167
+        return index > -1;
168
+    }
169
+
170
+    /**
171
+     * 队列大小
172
+     */
173
+    public static Long size(String name) {
174
+        Jedis jedis = JedisPoolFactory.getJedis();
175
+        try {
176
+            return jedis.llen(name);
177
+        } finally {
178
+            jedis.close();
179
+        }
180
+    }
181
+
182
+}

+ 46 - 0
src/main/java/com/dashitech/redis/core/RedisPubSubCmd.java

@@ -0,0 +1,46 @@
1
+package com.dashitech.redis.core;
2
+
3
+import org.apache.commons.logging.Log;
4
+import org.apache.commons.logging.LogFactory;
5
+import redis.clients.jedis.Jedis;
6
+import redis.clients.jedis.JedisPubSub;
7
+
8
+/**
9
+ * Redis发布和订阅
10
+ * Created by CX on 2018/8/20 0020.
11
+ */
12
+public class RedisPubSubCmd {
13
+    private static Log log = LogFactory.getLog(RedisPubSubCmd.class);
14
+
15
+    public static void main(String[] args) {
16
+        JedisPoolFactory.getDefaultJedis();
17
+
18
+    }
19
+
20
+    public static boolean subscribe(JedisPubSub jedisPubSub, String topic) {
21
+        final Jedis jedis = JedisPoolFactory.getJedis();
22
+        try {
23
+            jedis.subscribe(jedisPubSub, topic);
24
+        } catch (Exception ex) {
25
+            ex.printStackTrace();
26
+            return false;
27
+        } finally {
28
+            jedis.close();
29
+        }
30
+        return true;
31
+    }
32
+
33
+
34
+    public static void publish(String topic, String message) {
35
+        Jedis jedis = JedisPoolFactory.getJedis();
36
+        try {
37
+            jedis.publish(topic, message);
38
+        } catch (Exception ex) {
39
+            ex.printStackTrace();
40
+        } finally {
41
+            jedis.close();
42
+        }
43
+    }
44
+
45
+
46
+}

+ 149 - 0
src/main/java/com/dashitech/redis/core/RedisStringCmd.java

@@ -0,0 +1,149 @@
1
+package com.dashitech.redis.core;
2
+
3
+import redis.clients.jedis.Jedis;
4
+
5
+/**
6
+ * Redis字符串,注意并发问题
7
+ * Created by CX on 2018/8/20 0020.
8
+ */
9
+public class RedisStringCmd {
10
+
11
+    public static void main(String[] args) {
12
+        JedisPoolFactory.getDefaultJedis();
13
+
14
+        RedisStringCmd.drop("testString");
15
+        RedisStringCmd.set("testString","ABC");
16
+        System.out.println(RedisStringCmd.getset("testString", "CBA"));
17
+        System.out.println(RedisStringCmd.getset("testString111", "CBA"));
18
+        RedisStringCmd.append("testString","DEF");
19
+        System.out.println(RedisStringCmd.get("testString"));
20
+    }
21
+
22
+    /**
23
+     * 新增,如果已存在,覆盖当前值
24
+     * @param name  名称
25
+     * @param value 值
26
+     */
27
+    public static void set(String name, String value) {
28
+        Jedis jedis = JedisPoolFactory.getJedis();
29
+        try {
30
+            jedis.set(name, value);
31
+        } finally {
32
+            jedis.close();
33
+        }
34
+    }
35
+
36
+    public static void set(byte[] name, byte[] value) {
37
+        Jedis jedis = JedisPoolFactory.getJedis();
38
+        try {
39
+            jedis.set(name, value);
40
+        } finally {
41
+            jedis.close();
42
+        }
43
+    }
44
+
45
+    /**
46
+     * 有生命周期的新增,如果已存在,覆盖当前值和时间
47
+     * @param seconds  时间秒数
48
+     */
49
+    public static void setex(String name, String value,int seconds) {
50
+        Jedis jedis = JedisPoolFactory.getJedis();
51
+        try {
52
+            jedis.setex(name, seconds,value);
53
+        } finally {
54
+            jedis.close();
55
+        }
56
+    }
57
+
58
+    public static void setex(byte[] name, byte[] value,int seconds) {
59
+        Jedis jedis = JedisPoolFactory.getJedis();
60
+        try {
61
+            jedis.setex(name, seconds, value);
62
+        } finally {
63
+            jedis.close();
64
+        }
65
+    }
66
+
67
+    /**
68
+     *  key不存在时才成功
69
+     * @return 成功1 失败 0
70
+     */
71
+    public static Long setnx(String name,String value) {
72
+        Jedis jedis = JedisPoolFactory.getJedis();
73
+        try {
74
+            return jedis.setnx(name, value);
75
+        } finally {
76
+            jedis.close();
77
+        }
78
+    }
79
+
80
+    /**
81
+     * 设置值,并返回旧值,旧值不存在时返回null
82
+     */
83
+    public static String getset(String name,String value) {
84
+        Jedis jedis = JedisPoolFactory.getJedis();
85
+        try {
86
+           return jedis.getSet(name, value);
87
+        } finally {
88
+            jedis.close();
89
+        }
90
+    }
91
+
92
+    /**
93
+     * 追加值到末尾,如果不存在key,新增
94
+     */
95
+    public static void append(String name,String value) {
96
+        Jedis jedis = JedisPoolFactory.getJedis();
97
+        try {
98
+            jedis.append(name, value);
99
+        } finally {
100
+            jedis.close();
101
+        }
102
+    }
103
+
104
+    /**
105
+     * 直接删除key
106
+     */
107
+    public static void drop(String name) {
108
+        Jedis jedis = JedisPoolFactory.getJedis();
109
+        try {
110
+            jedis.del(name);
111
+        } finally {
112
+            jedis.close();
113
+        }
114
+    }
115
+
116
+    /**
117
+     * 获取值
118
+     */
119
+    public static String get(String name) {
120
+        Jedis jedis = JedisPoolFactory.getJedis();
121
+        try {
122
+            return jedis.get(name);
123
+        } finally {
124
+            jedis.close();
125
+        }
126
+    }
127
+
128
+    public static byte[] get(byte[] name) {
129
+        Jedis jedis = JedisPoolFactory.getJedis();
130
+        try {
131
+            return jedis.get(name);
132
+        } finally {
133
+            jedis.close();
134
+        }
135
+    }
136
+
137
+    /**
138
+     * 值大小
139
+     */
140
+    public static Long size(String name) {
141
+        Jedis jedis = JedisPoolFactory.getJedis();
142
+        try {
143
+            return jedis.strlen(name);
144
+        } finally {
145
+            jedis.close();
146
+        }
147
+    }
148
+
149
+}

+ 54 - 0
src/main/java/com/dashitech/redis/core/init/RedisInit.java

@@ -0,0 +1,54 @@
1
+//package com.dashitech.redis.core.init;
2
+//
3
+//import com.dashitech.job.SpecimenStatusJob;
4
+//import com.dashitech.redis.core.RedisKeys;
5
+//import com.dashitech.redis.core.RedisListCmd;
6
+//import com.dashitech.utils.ThreadPoolFactory;
7
+//import org.apache.commons.lang.StringUtils;
8
+//import org.springframework.beans.factory.annotation.Autowired;
9
+//import org.springframework.boot.ApplicationArguments;
10
+//import org.springframework.boot.ApplicationRunner;
11
+//import org.springframework.core.annotation.Order;
12
+//import org.springframework.stereotype.Service;
13
+//
14
+//import java.util.concurrent.TimeUnit;
15
+//
16
+///**
17
+// * Redis订阅服务,启动类
18
+// * Created by CX on 2022/2/14.
19
+// */
20
+//@Service
21
+//@Order(10)
22
+//public class RedisInit implements ApplicationRunner {
23
+//
24
+//    @Autowired
25
+//    SpecimenStatusJob specimenStatusJob;
26
+//
27
+//    @Override
28
+//    public void run(ApplicationArguments applicationArguments) throws Exception {
29
+//        System.out.println("标本状态,闭环上报消息订阅:" + RedisKeys.ITSM_SPECIMEN_STATUS_LIST);
30
+//        //标本状态,闭环上报
31
+//        //使用scheduleWithFixedDelay,任务结束才开始算间隔
32
+//        ThreadPoolFactory.getScheduledPool().scheduleWithFixedDelay(new Runnable() {
33
+//            @Override
34
+//            public void run() {
35
+//                try {
36
+//                    onMessage();
37
+//                } catch (Exception ex) {
38
+//                    ex.printStackTrace();
39
+//                }
40
+//            }
41
+//        }, 0, 5, TimeUnit.SECONDS);
42
+//    }
43
+//
44
+//    /**
45
+//     * 获取消息队列信息,循环自动建单,直到没有消息停止
46
+//     */
47
+//    public void onMessage() {
48
+//        String message = RedisListCmd.pop(RedisKeys.ITSM_SPECIMEN_STATUS_LIST);
49
+//        while (StringUtils.isNotEmpty(message)) {
50
+//            specimenStatusJob.onMessage(message);
51
+//            message = RedisListCmd.pop(RedisKeys.ITSM_SPECIMEN_STATUS_LIST);
52
+//        }
53
+//    }
54
+//}

+ 107 - 0
src/main/java/com/dashitech/utils/CaptchaUtil.java

@@ -0,0 +1,107 @@
1
+package com.dashitech.utils;
2
+
3
+import java.awt.Color;
4
+import java.awt.Font;
5
+import java.awt.Graphics;
6
+import java.awt.image.BufferedImage;
7
+import java.io.IOException;
8
+import java.util.Random;
9
+
10
+import javax.imageio.ImageIO;
11
+import javax.servlet.http.HttpServletResponse;
12
+
13
+public class CaptchaUtil {
14
+	
15
+	private String code = "";
16
+	private BufferedImage image;
17
+	
18
+	public String getCode() {
19
+		return code;
20
+	}
21
+	public void setCode(String code) {
22
+		this.code = code;
23
+	}
24
+	public BufferedImage getImage() {
25
+		return image;
26
+	}
27
+	public void setImage(BufferedImage image) {
28
+		this.image = image;
29
+	}
30
+	
31
+	public CaptchaUtil() {
32
+		init();
33
+	}
34
+
35
+	private Color getRandColor(int fc, int bc) {// 给定范围获得随机颜色
36
+		Random random = new Random();
37
+		if (fc > 255)
38
+			fc = 255;
39
+		if (bc > 255)
40
+			bc = 255;
41
+		int r = fc + random.nextInt(bc - fc);
42
+		int g = fc + random.nextInt(bc - fc);
43
+		int b = fc + random.nextInt(bc - fc);
44
+		return new Color(r, g, b);
45
+	}
46
+
47
+	private void init() {
48
+		// 在内存中创建图象
49
+		int width=60, height=20;
50
+		image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
51
+		
52
+		// 获取图形上下文
53
+		Graphics g = image.getGraphics();
54
+		
55
+		//生成随机类
56
+		Random random = new Random();
57
+		
58
+		// 设定背景色
59
+		g.setColor(getRandColor(200,250));
60
+		g.fillRect(0, 0, width, height);
61
+		
62
+		//设定字体
63
+		g.setFont(new Font("Times New Roman",Font.PLAIN,18));
64
+		
65
+		//画边框
66
+		//g.setColor(new Color());
67
+		//g.drawRect(0,0,width-1,height-1);
68
+		
69
+		// 随机产生155条干扰线,使图象中的认证码不易被其它程序探测到
70
+		g.setColor(getRandColor(160,200));
71
+		for (int i=0;i<155;i++)
72
+		{
73
+		 int x = random.nextInt(width);
74
+		 int y = random.nextInt(height);
75
+		        int xl = random.nextInt(12);
76
+		        int yl = random.nextInt(12);
77
+		 g.drawLine(x,y,x+xl,y+yl);
78
+		}
79
+		
80
+		// 取随机产生的认证码(4位数字)
81
+		for (int i=0;i<4;i++){
82
+		    String rand=String.valueOf(random.nextInt(10));
83
+		    code+=rand;
84
+		    // 将认证码显示到图象中
85
+		    g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110)));
86
+		//调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
87
+		    g.drawString(rand,13*i+6,16);
88
+		}
89
+		
90
+		// 图象生效
91
+		g.dispose();
92
+		
93
+	}
94
+	
95
+	public static void writeCaptcha(HttpServletResponse resp,CaptchaUtil captcha) {
96
+		resp.setHeader("Pragma","No-cache");
97
+		resp.setHeader("Cache-Control","no-cache");
98
+		resp.setDateHeader("Expires", 0);
99
+		BufferedImage image = captcha.getImage();
100
+		// 输出图象到页面
101
+		try {
102
+			ImageIO.write(image, "JPEG", resp.getOutputStream());
103
+		} catch (IOException e) {
104
+			e.printStackTrace();
105
+		}
106
+	}
107
+}

+ 228 - 0
src/main/java/com/dashitech/utils/CaptchaUtil2.java

@@ -0,0 +1,228 @@
1
+package com.dashitech.utils;
2
+
3
+import java.awt.Color;
4
+import java.awt.Font;
5
+import java.awt.Graphics;
6
+import java.awt.image.BufferedImage;
7
+import java.util.Random;
8
+
9
+public class CaptchaUtil2 {
10
+
11
+	/**
12
+	 * 验证码类型为仅数字,即0~9
13
+	 */
14
+	public static final int TYPE_NUM_ONLY = 0;
15
+
16
+	/**
17
+	 * 验证码类型为仅字母,即大小写字母混合
18
+	 */
19
+	public static final int TYPE_LETTER_ONLY = 1;
20
+
21
+	/**
22
+	 * 验证码类型为数字和大小写字母混合
23
+	 */
24
+	public static final int TYPE_ALL_MIXED = 2;
25
+
26
+	/**
27
+	 * 验证码类型为数字和大写字母混合
28
+	 */
29
+	public static final int TYPE_NUM_UPPER = 3;
30
+
31
+	/**
32
+	 * 验证码类型为数字和小写字母混合
33
+	 */
34
+	public static final int TYPE_NUM_LOWER = 4;
35
+
36
+	/**
37
+	 * 验证码类型为仅大写字母
38
+	 */
39
+	public static final int TYPE_UPPER_ONLY = 5;
40
+
41
+	/**
42
+	 * 验证码类型为仅小写字母
43
+	 */
44
+	public static final int TYPE_LOWER_ONLY = 6;
45
+
46
+	/**
47
+	 * 生成随机颜色
48
+	 */
49
+	private static Color generateRandomColor() {
50
+		Random random = new Random();
51
+		return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
52
+	}
53
+
54
+	/**
55
+	 * 生成图片验证码
56
+	 * 
57
+	 * @param type
58
+	 *            验证码类型,参见本类的静态属性
59
+	 * @param length
60
+	 *            验证码字符长度,要求大于0的整数
61
+	 * @param excludeString
62
+	 *            需排除的特殊字符
63
+	 * @param width
64
+	 *            图片宽度(注意此宽度若过小,容易造成验证码文本显示不全,如4个字符的文本可使用85到90的宽度)
65
+	 * @param height
66
+	 *            图片高度
67
+	 * @param interLine
68
+	 *            图片中干扰线的条数
69
+	 * @param randomLocation
70
+	 *            每个字符的高低位置是否随机
71
+	 * @param backColor
72
+	 *            图片颜色,若为null则表示采用随机颜色
73
+	 * @param foreColor
74
+	 *            字体颜色,若为null则表示采用随机颜色
75
+	 * @param lineColor
76
+	 *            干扰线颜色,若为null则表示采用随机颜色
77
+	 * @return 图片缓存对象
78
+	 */
79
+	public static BufferedImage generateImageCode(int type, int length, String excludeString, int width, int height, int interLine, boolean randomLocation, Color backColor, Color foreColor, Color lineColor) {
80
+		String textCode = generateTextCode(type, length, excludeString);
81
+		return generateImageCode(textCode, width, height, interLine, randomLocation, backColor, foreColor, lineColor);
82
+	}
83
+
84
+	/**
85
+	 * 生成验证码字符串
86
+	 * 
87
+	 * @param type
88
+	 *            验证码类型,参见本类的静态属性
89
+	 * @param length
90
+	 *            验证码长度,要求大于0的整数
91
+	 * @param excludeString
92
+	 *            需排除的特殊字符(无需排除则为null)
93
+	 * @return 验证码字符串
94
+	 */
95
+	public static String generateTextCode(int type, int length, String excludeString) {
96
+		if (length <= 0) {
97
+			return "";
98
+		}
99
+		StringBuffer verifyCode = new StringBuffer();
100
+		int i = 0;
101
+		Random random = new Random();
102
+		switch (type) {
103
+		case TYPE_NUM_ONLY:
104
+			while (i < length) {
105
+				int t = random.nextInt(10);
106
+				// 排除特殊字符
107
+				if (null == excludeString || excludeString.indexOf(t + "") < 0) {
108
+					verifyCode.append(t);
109
+					i++;
110
+				}
111
+			}
112
+			break;
113
+		case TYPE_LETTER_ONLY:
114
+			while (i < length) {
115
+				int t = random.nextInt(123);
116
+				if ((t >= 97 || (t >= 65 && t <= 90)) && (null == excludeString || excludeString.indexOf((char) t) < 0)) {
117
+					verifyCode.append((char) t);
118
+					i++;
119
+				}
120
+			}
121
+			break;
122
+		case TYPE_ALL_MIXED:
123
+			while (i < length) {
124
+				int t = random.nextInt(123);
125
+				if ((t >= 97 || (t >= 65 && t <= 90) || (t >= 48 && t <= 57)) && (null == excludeString || excludeString.indexOf((char) t) < 0)) {
126
+					verifyCode.append((char) t);
127
+					i++;
128
+				}
129
+			}
130
+			break;
131
+		case TYPE_NUM_UPPER:
132
+			while (i < length) {
133
+				int t = random.nextInt(91);
134
+				if ((t >= 65 || (t >= 48 && t <= 57)) && (null == excludeString || excludeString.indexOf((char) t) < 0)) {
135
+					verifyCode.append((char) t);
136
+					i++;
137
+				}
138
+			}
139
+			break;
140
+		case TYPE_NUM_LOWER:
141
+			while (i < length) {
142
+				int t = random.nextInt(123);
143
+				if ((t >= 97 || (t >= 48 && t <= 57)) && (null == excludeString || excludeString.indexOf((char) t) < 0)) {
144
+					verifyCode.append((char) t);
145
+					i++;
146
+				}
147
+			}
148
+			break;
149
+		case TYPE_UPPER_ONLY:
150
+			while (i < length) {
151
+				int t = random.nextInt(91);
152
+				if ((t >= 65) && (null == excludeString || excludeString.indexOf((char) t) < 0)) {
153
+					verifyCode.append((char) t);
154
+					i++;
155
+				}
156
+			}
157
+			break;
158
+		case TYPE_LOWER_ONLY:
159
+			while (i < length) {
160
+				int t = random.nextInt(123);
161
+				if ((t >= 97) && (null == excludeString || excludeString.indexOf((char) t) < 0)) {
162
+					verifyCode.append((char) t);
163
+					i++;
164
+				}
165
+			}
166
+			break;
167
+		}
168
+		return verifyCode.toString();
169
+	}
170
+
171
+	/**
172
+	 * 已有验证码,生成验证码图片
173
+	 * 
174
+	 * @param textCode
175
+	 *            文本验证码
176
+	 * @param width
177
+	 *            图片宽度(注意此宽度若过小,容易造成验证码文本显示不全,如4个字符的文本可使用85到90的宽度)
178
+	 * @param height
179
+	 *            图片高度
180
+	 * @param interLine
181
+	 *            图片中干扰线的条数
182
+	 * @param randomLocation
183
+	 *            每个字符的高低位置是否随机
184
+	 * @param backColor
185
+	 *            图片颜色,若为null则表示采用随机颜色
186
+	 * @param foreColor
187
+	 *            字体颜色,若为null则表示采用随机颜色
188
+	 * @param lineColor
189
+	 *            干扰线颜色,若为null则表示采用随机颜色
190
+	 * @return 图片缓存对象
191
+	 */
192
+	public static BufferedImage generateImageCode(String textCode, int width, int height, int interLine, boolean randomLocation, Color backColor, Color foreColor, Color lineColor) {
193
+		// 创建内存图像
194
+		BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
195
+		// 获取图形上下文
196
+		Graphics graphics = bufferedImage.getGraphics();
197
+		// 画背景图
198
+		graphics.setColor(null == backColor ? generateRandomColor() : backColor);
199
+		graphics.fillRect(0, 0, width, height);
200
+		// 画干扰线
201
+		Random random = new Random();
202
+		if (interLine > 0) {
203
+			int x = 0, y = 0, x1 = width, y1 = 0;
204
+			for (int i = 0; i < interLine; i++) {
205
+				graphics.setColor(null == lineColor ? generateRandomColor() : lineColor);
206
+				y = random.nextInt(height);
207
+				y1 = random.nextInt(height);
208
+				graphics.drawLine(x, y, x1, y1);
209
+			}
210
+		}
211
+		// 字体大小为图片高度的80%
212
+		int fsize = (int) (height * 0.8);
213
+		int fx = height - fsize;
214
+		int fy = fsize;
215
+		// 设定字体
216
+		graphics.setFont(new Font("Default", Font.PLAIN, fsize));
217
+		// 写验证码字符
218
+		for (int i = 0; i < textCode.length(); i++) {
219
+			fy = randomLocation ? (int) ((Math.random() * 0.3 + 0.6) * height) : fy;
220
+			graphics.setColor(null == foreColor ? generateRandomColor() : foreColor);
221
+			// 将验证码字符显示到图象中
222
+			graphics.drawString(textCode.charAt(i) + "", fx, fy);
223
+			fx += fsize * 0.9;
224
+		}
225
+		graphics.dispose();
226
+		return bufferedImage;
227
+	}
228
+}

+ 250 - 0
src/main/java/com/dashitech/utils/CommonUtil.java

@@ -0,0 +1,250 @@
1
+package com.dashitech.utils;
2
+
3
+import org.apache.commons.lang.StringUtils;
4
+import org.slf4j.Logger;
5
+import org.slf4j.LoggerFactory;
6
+
7
+import java.io.File;
8
+import java.io.UnsupportedEncodingException;
9
+import java.lang.reflect.Method;
10
+import java.net.URL;
11
+import java.net.URLClassLoader;
12
+import java.net.URLDecoder;
13
+import java.net.URLEncoder;
14
+import java.util.*;
15
+
16
+/**
17
+ * 混杂工具类
18
+ * Created by CX on 2017/3/31 0031.
19
+ */
20
+public class CommonUtil {
21
+    private static final Logger LOG = LoggerFactory.getLogger(CommonUtil.class);
22
+
23
+    private CommonUtil(){}
24
+
25
+    public static <T> List<?> transList(List<?> list) {
26
+        return list;
27
+    }
28
+
29
+    /**
30
+     * 把新地址加入到classpath中
31
+     * @param path 新地址,绝对路劲
32
+     * @return  是否成功
33
+     */
34
+    public static boolean addJavaClassPath(String path) {
35
+        try {
36
+            File programRootDir = new File(path);
37
+            URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
38
+            Method add = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
39
+            add.setAccessible(true);
40
+            add.invoke(classLoader, programRootDir.toURI().toURL());
41
+            return true;
42
+        } catch (Exception e) {
43
+            e.printStackTrace();
44
+        }
45
+        return false;
46
+    }
47
+
48
+    /**
49
+     * 在source的下标 start和end中间插入newStr
50
+     */
51
+    public static String cutInsertString(String source, int start, int end, String newStr) {
52
+        String startStr = source.substring(0, start);
53
+        String endStr = source.substring(end, source.length());
54
+        String result = startStr + newStr + endStr;
55
+        return result;
56
+    }
57
+
58
+    /**
59
+     * 获取中文类型长度,中文长度2,其他1
60
+     */
61
+    public static int getChineseLength(String source) {
62
+        int valueLength = 0;
63
+        String chinese = "[\u0391-\uFFE5]";
64
+		/* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */
65
+        for (int i = 0; i < source.length(); i++) {
66
+			/* 获取一个字符 */
67
+            String temp = source.substring(i, i + 1);
68
+			/* 判断是否为中文字符 */
69
+            if (temp.matches(chinese)) {
70
+				/* 中文字符长度为2 */
71
+                valueLength += 2;
72
+            } else {
73
+				/* 其他字符长度为1 */
74
+                valueLength += 1;
75
+            }
76
+        }
77
+        return valueLength;
78
+    }
79
+
80
+    /**
81
+     * 获取翻页数
82
+     *
83
+     * @param itemTotal
84
+     *            总条数
85
+     * @param PageCount
86
+     *            一页数
87
+     * @return 翻页数
88
+     */
89
+    public static int getPageTotal(Integer itemTotal, int PageCount) {
90
+        // 设置总页数
91
+        int total = 0;
92
+        if (itemTotal % PageCount == 0) {
93
+            total = itemTotal / PageCount;
94
+        } else {
95
+            total = (itemTotal / PageCount) + 1;
96
+        }
97
+        return total;
98
+    }
99
+
100
+    /**
101
+     * 自己写sql分页必须处理pageIndex
102
+     */
103
+    public static int getPageIndex(int pageIndex,int showCount) {
104
+        int result = 0;
105
+        if(pageIndex <= 1) {
106
+            result = 0;
107
+        }else if(pageIndex > 1) {
108
+            result = ((pageIndex * showCount) - showCount);
109
+        }
110
+        return result;
111
+    }
112
+
113
+    /**
114
+     * url中文编码
115
+     */
116
+    public static String urlEncode(String url) {
117
+        String s = url;
118
+        try {
119
+            s = URLEncoder.encode(url, "UTF-8");
120
+        } catch (UnsupportedEncodingException e) {
121
+            e.printStackTrace();
122
+        }
123
+        return s;
124
+    }
125
+
126
+    /**
127
+     * url中文解码
128
+     */
129
+    public static String urlDecode(String url) {
130
+        String s = url;
131
+        try {
132
+            s = URLDecoder.decode(url, "UTF-8");
133
+        } catch (UnsupportedEncodingException e) {
134
+            e.printStackTrace();
135
+        }
136
+        return s;
137
+    }
138
+
139
+    /**
140
+     * 排序
141
+     * @param list
142
+     * @param field 字段名称,必须有get方法
143
+     * @param fieldType 字段类型
144
+     */
145
+    public static void sort(List<?> list,final String field,final String fieldType) {
146
+        Collections.sort(list, new Comparator<Object>() {
147
+            public int compare(Object o1, Object o2) {
148
+                Method m = null;
149
+                try {
150
+                    String getKey = "get" + field.toUpperCase().charAt(0) + field.substring(1, field.length());
151
+                    m = o1.getClass().getMethod(getKey);
152
+                    Object o1Value = m.invoke(o1);
153
+
154
+                    m = o2.getClass().getMethod(getKey);
155
+                    Object o2Value = m.invoke(o2);
156
+
157
+                    if(o1Value == null && o2Value == null) {
158
+                        return 0;
159
+                    }else if(o1Value == null && o2Value != null) {
160
+                        return -1;
161
+                    }else if(o1Value != null && o2Value == null) {
162
+                        return 1;
163
+                    }
164
+
165
+                    if("Integer".equals(fieldType.toString())) {
166
+                        Integer _o1 = (Integer)o1Value;
167
+                        Integer _o2 = (Integer)o2Value;
168
+                        return _o1.compareTo(_o2);
169
+                    }else if("String".equals(fieldType.toString())) {
170
+                        String _o1 = (String)o1Value;
171
+                        String _o2 = (String)o2Value;
172
+                        return _o1.compareTo(_o2);
173
+                    }else if("StringNumber".equals(fieldType.toString())) {
174
+                        try{
175
+                            Double _o1 = Double.valueOf(o1Value.toString());
176
+                            Double _o2 = Double.valueOf(o2Value.toString());
177
+                            return _o1.compareTo(_o2);
178
+                        }catch (NumberFormatException ex) {
179
+                            ex.printStackTrace();
180
+                        }
181
+                    }
182
+                }catch (Exception e) {
183
+                    e.printStackTrace();
184
+                }
185
+                return 0;
186
+            }
187
+        });
188
+    }
189
+
190
+    /**
191
+     * 逻辑分页
192
+     *
193
+     * @param src
194
+     *            源数据
195
+     * @param start
196
+     *            分页页数,1起始
197
+     * @param size
198
+     *            分页limit
199
+     * @return 新的分页后的List
200
+     * @throws Exception
201
+     */
202
+    public static <T> List<T> paginateList(List<T> src, int start, int size) {
203
+        if(src == null) {
204
+            return Collections.emptyList();
205
+        }
206
+
207
+        List<T> list = null;
208
+        if(start <= 1) {
209
+            start = 0;
210
+        }else {
211
+            start = (start-1) * size;
212
+        }
213
+
214
+        size = size + start;
215
+        if (size > src.size()) {
216
+            size = src.size();
217
+        }
218
+
219
+        try {
220
+            list = src.subList(start, size);
221
+        } catch (Exception e) {
222
+            System.out.println("list.size:"+src.size()+"start:" + start + " , size" + size);
223
+            e.printStackTrace();
224
+        }
225
+        return list;
226
+    }
227
+
228
+
229
+    /**
230
+     * map.toString之后,转回map
231
+     */
232
+    public static Map<String,String> string2Map(String mapString) {
233
+        Map<String,String> map = new LinkedHashMap<String,String>();
234
+        try {
235
+            if(StringUtils.isNotEmpty(mapString)) {
236
+                String args = mapString.substring(1,mapString.length()-1);
237
+                String[] argArr = args.split(", ");
238
+                for (String entry : argArr) {
239
+                    int index = entry.indexOf("=");
240
+                    String key = entry.substring(0,index);
241
+                    String value = entry.substring(index+1);
242
+                    map.put(key, value);
243
+                }
244
+            }
245
+        }catch (Exception ex) {
246
+            ex.printStackTrace();
247
+        }
248
+        return map;
249
+    }
250
+}

+ 318 - 0
src/main/java/com/dashitech/utils/DateUtil.java

@@ -0,0 +1,318 @@
1
+package com.dashitech.utils;
2
+
3
+import java.text.ParseException;
4
+import java.text.SimpleDateFormat;
5
+import java.util.ArrayList;
6
+import java.util.Arrays;
7
+import java.util.Calendar;
8
+import java.util.Date;
9
+import java.util.List;
10
+import java.util.Locale;
11
+
12
+public class DateUtil {
13
+    private static final int FIRST_DAY = Calendar.MONDAY;
14
+    public final static SimpleDateFormat SDF_DATE = new SimpleDateFormat("yyyy-MM-dd");
15
+    public final static SimpleDateFormat SDF_DATETIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
16
+    
17
+    
18
+	private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
19
+	
20
+	public static String formatTimestamp(Date date){
21
+		String formattedDate = dateFormat.format(date);
22
+		return formattedDate;
23
+	}
24
+	
25
+	public static Date parseTimestamp(String text){
26
+		try {
27
+			return dateFormat.parse(text);
28
+		} catch (ParseException e) {
29
+			// TODO Auto-generated catch block
30
+			e.printStackTrace();
31
+		}
32
+		return null;
33
+	}
34
+
35
+    private static void setToFirstDay(Calendar calendar) {
36
+        while (calendar.get(Calendar.DAY_OF_WEEK) != FIRST_DAY) {
37
+            calendar.add(Calendar.DATE, -1);
38
+        }
39
+    }
40
+    
41
+    public static String formatDateTime (Date date) {
42
+    	return SDF_DATETIME.format(date);
43
+    }
44
+    
45
+    public static String formatDate (Date date) {
46
+    	return SDF_DATE.format(date);
47
+    }
48
+
49
+	public static Date parseUTCDateTime(String date){
50
+		Date d = null;
51
+		try {
52
+			date = date.replace("Z", " UTC");//注意是空格+UTC
53
+			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");//注意格式化的表达式
54
+			d = format.parse(date);
55
+		} catch (ParseException e) {
56
+			e.printStackTrace();
57
+		}
58
+		return d;
59
+	}
60
+    
61
+    public static Date parseDateTime(String date){
62
+    	Date d = null;
63
+    	try {
64
+			d = SDF_DATETIME.parse(date);
65
+		} catch (ParseException e) {
66
+			e.printStackTrace();
67
+		}
68
+		return d;
69
+    }
70
+    
71
+    public static Date parseDate(String date){
72
+    	Date d = null;
73
+    	try {
74
+			d = SDF_DATE.parse(date);
75
+		} catch (ParseException e) {
76
+			e.printStackTrace();
77
+		}
78
+		return d;
79
+    }
80
+
81
+    /**
82
+     * 从周一开始7天
83
+     */
84
+    public static List<String> getWeekdays(Date date) {
85
+        List<String> list = new ArrayList<String>();
86
+        Calendar calendar = Calendar.getInstance();
87
+        calendar.setTime(date);
88
+        
89
+        setToFirstDay(calendar);
90
+        
91
+        for (int i = 0; i < 7; i++) {
92
+            list.add(SDF_DATE.format(calendar.getTime()));
93
+            calendar.add(Calendar.DATE, 1);
94
+        }
95
+        return list;
96
+    }
97
+    
98
+    /**
99
+     * 从周一开始7天
100
+     */
101
+    public static List<String> getWeekdaysAndColor(Date date) {
102
+        List<String> list = new ArrayList<String>();
103
+        Calendar calendar = Calendar.getInstance();
104
+        calendar.setTime(date);
105
+        
106
+        setToFirstDay(calendar);
107
+        
108
+        for (int i = 0; i < 7; i++) {
109
+        	if(i == 6 || i == 5)
110
+                list.add("<font class='weekColor'>" + SDF_DATE.format(calendar.getTime()) + "</font>");
111
+        	else
112
+        		list.add(SDF_DATE.format(calendar.getTime()));
113
+            calendar.add(Calendar.DATE, 1);
114
+        }
115
+        return list;
116
+    }
117
+    public static String getMonday(Date date) {
118
+        Calendar calendar = Calendar.getInstance();
119
+        calendar.setTime(date);
120
+        setToFirstDay(calendar);
121
+        return SDF_DATE.format(calendar.getTime());
122
+    }
123
+    
124
+    public static String getSunday(Date date) {
125
+        Calendar calendar = Calendar.getInstance();
126
+        calendar.setTime(date);
127
+        setToFirstDay(calendar);
128
+        calendar.add(Calendar.DATE, 6);
129
+        return SDF_DATE.format(calendar.getTime());
130
+    }
131
+    
132
+    /**
133
+     * 当前日期  + 7
134
+     * @param date
135
+     * @return
136
+     */
137
+    public static Date getAfterWeekByDay(Date date) {
138
+        Calendar calendar = Calendar.getInstance();
139
+        calendar.setTime(date);
140
+        calendar.add(Calendar.DATE, 7);
141
+        return calendar.getTime();
142
+    }
143
+    
144
+    /**
145
+     * 当前日期  - 7
146
+     * @param date
147
+     * @return
148
+     */
149
+    public static Date getBeforeWeekByDay(Date date) {
150
+        Calendar calendar = Calendar.getInstance();
151
+        calendar.setTime(date);
152
+        calendar.add(Calendar.DATE, -7);
153
+        return calendar.getTime();
154
+    }
155
+
156
+    /**
157
+	 * 获取星期一
158
+	 * 
159
+	 * @param date 传入的日期
160
+	 * @return
161
+	 */
162
+	public static Date getMOnday(Date date) {
163
+		Calendar cal = Calendar.getInstance();
164
+		cal.setTime(date);
165
+		// 判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了
166
+		int dayWeek = cal.get(Calendar.DAY_OF_WEEK);// 获得当前日期是一个星期的第几天
167
+		if (1 == dayWeek) {
168
+			cal.add(Calendar.DAY_OF_MONTH, -1);
169
+		}
170
+		cal.setFirstDayOfWeek(Calendar.MONDAY);// 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
171
+		int day = cal.get(Calendar.DAY_OF_WEEK);// 获得当前日期是一个星期的第几天
172
+		cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);// 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
173
+		return cal.getTime();
174
+	}
175
+
176
+	/**
177
+	 * 判断传入的日期的周数是否大于当前日期的周数
178
+	 * @param dutyDate 传入的日期
179
+	 * @return
180
+	 */
181
+	public static boolean isBeforeThisWeek(Date dutyDate){ 
182
+		return getMOnday(new Date()).getTime() < getMOnday(dutyDate).getTime();
183
+	}
184
+	
185
+	public static boolean equals(Date d1,Date d2,SimpleDateFormat sdf) {
186
+	    String a = sdf.format(d1);
187
+	    String b = sdf.format(d2);
188
+	    if(a != null && b != null) {
189
+	        return a.equals(b);
190
+	    }
191
+	    return false;
192
+	}
193
+
194
+	public static String ignoreFrmat(String source,SimpleDateFormat sdf) {
195
+	    List<String> list = Arrays.asList("yyyy-M-d","yyyy-MM-dd","yyyy-M","yyyy-MM","yyyy/M/d","yyyy/MM/dd","yyyy/M","yyyy/MM");
196
+	    String result = "";
197
+	    for(int i = 0;i<list.size();i++) {
198
+	        try {
199
+                Date d = new SimpleDateFormat(list.get(i)).parse(source);
200
+                result = sdf.format(d);
201
+                return result;
202
+            } catch (Exception e) {
203
+                
204
+            }
205
+	    }
206
+	    try {
207
+            Date d = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy",Locale.US).parse(source);
208
+            result = sdf.format(d);
209
+        } catch (Exception e) {
210
+        }
211
+	    return result;
212
+	}
213
+	
214
+	public static Date ignoreFrmat_Date(String source,SimpleDateFormat sdf) {
215
+	    String result = ignoreFrmat(source,sdf);
216
+	    Date d = null;
217
+        try {
218
+            d = sdf.parse(result);
219
+        } catch (ParseException e) {
220
+            e.printStackTrace();
221
+        }
222
+	    return d;
223
+	}
224
+	
225
+	/**
226
+	 * 两个时间相差天数
227
+	 * date1  开始时间
228
+	 * date2  结束时间
229
+	 * 
230
+	 * */
231
+	public static int getMonthSpace(String staticTime, String endTime) throws ParseException {
232
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
233
+		long startT=sdf.parse(staticTime).getTime(); //定义开始时间
234
+		long endT=sdf.parse(endTime).getTime();  //定义结束时间
235
+		long overDay=(endT-startT) /(1000 * 60 * 60 * 24);
236
+		int day = Integer.parseInt(String.valueOf(overDay));
237
+		return day;
238
+	}
239
+	
240
+	/**
241
+	 * 获取年份
242
+	 * */
243
+	private static int getYear(String date1) throws ParseException { 
244
+	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
245
+	    Calendar cal = Calendar.getInstance(); 
246
+	    Date dt = null; 
247
+	    try { 
248
+	      dt = sdf.parse(date1); 
249
+	      cal.setTime(dt); 
250
+	    } catch (ParseException e) { 
251
+	      // TODO Auto-generated catch block 
252
+	      e.printStackTrace(); 
253
+	    } 
254
+	    int year = cal.get(Calendar.YEAR); 
255
+	    int month = cal.get(Calendar.MONTH) + 1; 
256
+	    int day = cal.get(Calendar.DAY_OF_MONTH); 
257
+	    int hour = cal.get(Calendar.HOUR_OF_DAY); 
258
+	    int minute = cal.get(Calendar.MINUTE); 
259
+	    int second = cal.get(Calendar.SECOND); 
260
+	    return year;
261
+	  }
262
+
263
+	public static boolean isInDates(Date date, Date startDate, Date endDate) {
264
+		SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
265
+		Date myDate = null;
266
+		Date dateBegin = null;
267
+		Date dateEnd = null;
268
+		String strDate = sd.format(date);
269
+		String strDateBegin = sd.format(startDate);
270
+		String strDateEnd = sd.format(endDate);
271
+		try {
272
+			myDate = sd.parse(strDate);
273
+			dateBegin = sd.parse(strDateBegin);
274
+			dateEnd = sd.parse(strDateEnd);
275
+		} catch (ParseException e) {
276
+			// TODO Auto-generated catch block
277
+			e.printStackTrace();
278
+		}
279
+		strDate = String.valueOf(myDate);
280
+		strDateBegin = String.valueOf(dateBegin);
281
+		strDateEnd = String.valueOf(dateEnd);
282
+
283
+		int strDateH = Integer.parseInt(strDate.substring(11, 13));
284
+		int strDateM = Integer.parseInt(strDate.substring(14, 16));
285
+		int strDateS = Integer.parseInt(strDate.substring(17, 19));
286
+
287
+		int strDateBeginH = Integer.parseInt(strDateBegin.substring(11, 13));
288
+		int strDateBeginM = Integer.parseInt(strDateBegin.substring(14, 16));
289
+		//int strDateBeginS = Integer.parseInt(strDateBegin.substring(17,19));
290
+
291
+		int strDateEndH = Integer.parseInt(strDateEnd.substring(11, 13));
292
+		int strDateEndM = Integer.parseInt(strDateEnd.substring(14, 16));
293
+		//int strDateEndS = Integer.parseInt(strDateEnd.substring(17,19));
294
+
295
+		if ((strDateH >= strDateBeginH && strDateH <= strDateEndH)) {
296
+			if (strDateH > strDateBeginH && strDateH < strDateEndH) {
297
+				return true;
298
+			} else if (strDateH == strDateBeginH && strDateM > strDateBeginM && strDateH < strDateEndH) {
299
+				return true;
300
+			} else if (strDateH == strDateBeginH && strDateM == strDateBeginM && strDateH < strDateEndH) {
301
+				return true;
302
+			} else if (strDateH == strDateBeginH && strDateM == strDateBeginM && strDateH < strDateEndH) {
303
+				return true;
304
+			} else if (strDateH > strDateBeginH && strDateH == strDateEndH && strDateM < strDateEndM) {
305
+				return true;
306
+			} else if (strDateH > strDateBeginH && strDateH == strDateEndH && strDateM == strDateEndM) {
307
+				return true;
308
+			} else if (strDateH > strDateBeginH && strDateH == strDateEndH && strDateM == strDateEndM) {
309
+				return true;
310
+			} else {
311
+				return false;
312
+			}
313
+		} else {
314
+			return false;
315
+		}
316
+	}
317
+	
318
+}	

+ 670 - 0
src/main/java/com/dashitech/utils/DateUtil2.java

@@ -0,0 +1,670 @@
1
+package com.dashitech.utils;
2
+
3
+import java.text.ParseException;
4
+import java.text.SimpleDateFormat;
5
+import java.util.ArrayList;
6
+import java.util.Calendar;
7
+import java.util.Date;
8
+import java.util.GregorianCalendar;
9
+import java.util.HashMap;
10
+import java.util.List;
11
+import java.util.Map;
12
+
13
+import org.apache.commons.lang.StringUtils;
14
+
15
+public class DateUtil2 {
16
+
17
+    public static final String FORMAT_DATE = "yyyy-MM-dd";
18
+
19
+    public static final String FORMAT_TIME = "HH:mm:ss";
20
+
21
+    public static final String FORMAT_DATE_TIME = "yyyy-MM-dd HH:mm:ss";
22
+
23
+    public static final SimpleDateFormat SDFD = new SimpleDateFormat(FORMAT_DATE);
24
+
25
+    public static final SimpleDateFormat SDFT = new SimpleDateFormat(FORMAT_TIME);
26
+
27
+    public static final SimpleDateFormat SDFDT = new SimpleDateFormat(FORMAT_DATE_TIME);
28
+
29
+    /**
30
+     * 得到以yyyy-MM-dd格式表示的当前日期字符串
31
+     */
32
+    public static String getCurrentDate() {
33
+        // return sdfd.format(new Date());
34
+        GregorianCalendar tGCalendar = new GregorianCalendar();
35
+        StringBuffer tStringBuffer = new StringBuffer(10);
36
+        int sYears = tGCalendar.get(Calendar.YEAR);
37
+        tStringBuffer.append(sYears);
38
+        tStringBuffer.append('-');
39
+        int sMonths = tGCalendar.get(Calendar.MONTH) + 1;
40
+        if (sMonths < 10) {
41
+            tStringBuffer.append('0');
42
+        }
43
+        tStringBuffer.append(sMonths);
44
+        tStringBuffer.append('-');
45
+        int sDays = tGCalendar.get(Calendar.DAY_OF_MONTH);
46
+        if (sDays < 10) {
47
+            tStringBuffer.append('0');
48
+        }
49
+        tStringBuffer.append(sDays);
50
+        String tString = tStringBuffer.toString();
51
+        return tString;
52
+    }
53
+
54
+    /**
55
+     * 得到以format格式表示的当前日期字符串
56
+     */
57
+    public static String getCurrentDate(String format) {
58
+        SimpleDateFormat t = new SimpleDateFormat(format);
59
+        return t.format(new Date());
60
+    }
61
+
62
+    /**
63
+     * 得到以HH:mm:ss表示的当前时间字符串
64
+     */
65
+    public static String getCurrentTime() {
66
+        // return sdft.format(new Date());
67
+        GregorianCalendar tGCalendar = new GregorianCalendar();
68
+        StringBuffer tStringBuffer = new StringBuffer(8);
69
+        int sHOUR = tGCalendar.get(Calendar.HOUR_OF_DAY);
70
+        if (sHOUR < 10) {
71
+            tStringBuffer.append('0');
72
+        }
73
+        tStringBuffer.append(sHOUR);
74
+        tStringBuffer.append(':');
75
+        int sMINUTE = tGCalendar.get(Calendar.MINUTE);
76
+        if (sMINUTE < 10) {
77
+            tStringBuffer.append('0');
78
+        }
79
+        tStringBuffer.append(sMINUTE);
80
+        tStringBuffer.append(':');
81
+        int sSECOND = tGCalendar.get(Calendar.SECOND);
82
+        if (sSECOND < 10) {
83
+            tStringBuffer.append('0');
84
+        }
85
+        tStringBuffer.append(sSECOND);
86
+        String tString = tStringBuffer.toString();
87
+        return tString;
88
+    }
89
+
90
+    /**
91
+     * 得到以format格式表示的当前时间字符串
92
+     */
93
+    public static String getCurrentTime(String format) {
94
+        SimpleDateFormat t = new SimpleDateFormat(format);
95
+        return t.format(new Date());
96
+    }
97
+
98
+    /**
99
+     * 得到以yyyy-MM-dd HH:mm:ss表示的当前时间字符串
100
+     */
101
+    public static String getCurrentDateTime() {
102
+        String format = FORMAT_DATE + " " + FORMAT_TIME;
103
+        return getCurrentDateTime(format);
104
+    }
105
+
106
+    public static int getDayOfWeek() {
107
+        Calendar cal = Calendar.getInstance();
108
+        return cal.get(Calendar.DAY_OF_WEEK);
109
+    }
110
+
111
+    public static int getDayOfWeek(Date date) {
112
+        Calendar cal = Calendar.getInstance();
113
+        cal.setTime(date);
114
+        return cal.get(Calendar.DAY_OF_WEEK);
115
+    }
116
+
117
+    public static int getDayOfMonth() {
118
+        Calendar cal = Calendar.getInstance();
119
+        return cal.get(Calendar.DAY_OF_MONTH);
120
+    }
121
+
122
+    public static int getDayOfMonth(Date date) {
123
+        Calendar cal = Calendar.getInstance();
124
+        cal.setTime(date);
125
+        return cal.get(Calendar.DAY_OF_MONTH);
126
+    }
127
+
128
+    // 获取某一个月的天数
129
+    public static int getMaxDayOfMonth(Date date) {
130
+        Calendar cal = Calendar.getInstance();
131
+        cal.setTime(date);
132
+        return cal.getActualMaximum(Calendar.DATE);
133
+    }
134
+
135
+    // 获取某月的第一天
136
+    public static String getFirstDayOfMonth(String date) {
137
+        Calendar cal = Calendar.getInstance();
138
+        cal.setTime(parse(date));
139
+        cal.set(Calendar.DAY_OF_MONTH, 1);
140
+        return SDFD.format(cal.getTime());
141
+    }
142
+
143
+    public static int getDayOfYear() {
144
+        Calendar cal = Calendar.getInstance();
145
+        return cal.get(Calendar.DAY_OF_YEAR);
146
+    }
147
+
148
+    public static int getDayOfYear(Date date) {
149
+        Calendar cal = Calendar.getInstance();
150
+        cal.setTime(date);
151
+        return cal.get(Calendar.DAY_OF_YEAR);
152
+    }
153
+
154
+    public static int getDayOfWeek(String date) {
155
+        Calendar cal = Calendar.getInstance();
156
+        cal.setTime(parse(date));
157
+        return cal.get(Calendar.DAY_OF_WEEK);
158
+    }
159
+
160
+    public static int getDayOfMonth(String date) {
161
+        Calendar cal = Calendar.getInstance();
162
+        cal.setTime(parse(date));
163
+        return cal.get(Calendar.DAY_OF_MONTH);
164
+    }
165
+
166
+    public static int getDayOfYear(String date) {
167
+        Calendar cal = Calendar.getInstance();
168
+        cal.setTime(parse(date));
169
+        return cal.get(Calendar.DAY_OF_YEAR);
170
+    }
171
+
172
+    public static String getCurrentDateTime(String format) {
173
+        SimpleDateFormat t = new SimpleDateFormat(format);
174
+        return t.format(new Date());
175
+    }
176
+
177
+    /**
178
+     * 输出只带日期的字符串
179
+     */
180
+    public static String toString(Date date) {
181
+        if (date == null) {
182
+            return "";
183
+        }
184
+        return SDFD.format(date);
185
+    }
186
+
187
+    /**
188
+     * 输出带有日期和时间的字符串
189
+     */
190
+    public static String toDateTimeString(Date date) {
191
+        if (date == null) {
192
+            return "";
193
+        }
194
+        return SDFDT.format(date);
195
+    }
196
+
197
+    /**
198
+     * 按指定的format输出日期字符串
199
+     */
200
+    public static String toString(Date date, String format) {
201
+        SimpleDateFormat t = new SimpleDateFormat(format);
202
+        return t.format(date);
203
+    }
204
+
205
+    /**
206
+     * 输出只带时间的字符串
207
+     */
208
+    public static String toTimeString(Date date) {
209
+        if (date == null) {
210
+            return "";
211
+        }
212
+        return SDFDT.format(date);
213
+    }
214
+
215
+    public static int compare(String date1, String date2) {
216
+        return compare(date1, date2, FORMAT_DATE);
217
+    }
218
+
219
+    public static int compareTime(String time1, String time2) {
220
+        return compareTime(time1, time2, FORMAT_TIME);
221
+    }
222
+
223
+    public static int compare(String date1, String date2, String format) {
224
+        Date d1 = parse(date1, format);
225
+        Date d2 = parse(date2, format);
226
+        return d1.compareTo(d2);
227
+    }
228
+
229
+    public static int compareTime(String time1, String time2, String format) {
230
+        String[] arr1 = time1.split(":");
231
+        String[] arr2 = time2.split(":");
232
+        if (arr1.length < 2) {
233
+            throw new RuntimeException("错误的时间值:" + time1);
234
+        }
235
+        if (arr2.length < 2) {
236
+            throw new RuntimeException("错误的时间值:" + time2);
237
+        }
238
+        int h1 = Integer.parseInt(arr1[0]);
239
+        int m1 = Integer.parseInt(arr1[1]);
240
+        int h2 = Integer.parseInt(arr2[0]);
241
+        int m2 = Integer.parseInt(arr2[1]);
242
+        int s1 = 0, s2 = 0;
243
+        if (arr1.length == 3) {
244
+            s1 = Integer.parseInt(arr1[2]);
245
+        }
246
+        if (arr2.length == 3) {
247
+            s2 = Integer.parseInt(arr2[2]);
248
+        }
249
+        if (h1 < 0 || h1 > 23 || m1 < 0 || m1 > 59 || s1 < 0 || s1 > 59) {
250
+            throw new RuntimeException("错误的时间值:" + time1);
251
+        }
252
+        if (h2 < 0 || h2 > 23 || m2 < 0 || m2 > 59 || s2 < 0 || s2 > 59) {
253
+            throw new RuntimeException("错误的时间值:" + time2);
254
+        }
255
+        if (h1 != h2) {
256
+            return h1 > h2 ? 1 : -1;
257
+        } else {
258
+            if (m1 == m2) {
259
+                if (s1 == s2) {
260
+                    return 0;
261
+                } else {
262
+                    return s1 > s2 ? 1 : -1;
263
+                }
264
+            } else {
265
+                return m1 > m2 ? 1 : -1;
266
+            }
267
+        }
268
+    }
269
+
270
+    public static boolean isTime(String time) {
271
+        String[] arr = time.split(":");
272
+        if (arr.length < 2) {
273
+            return false;
274
+        }
275
+        try {
276
+            int h = Integer.parseInt(arr[0]);
277
+            int m = Integer.parseInt(arr[1]);
278
+            int s = 0;
279
+            if (arr.length == 3) {
280
+                s = Integer.parseInt(arr[2]);
281
+            }
282
+            if (h < 0 || h > 23 || m < 0 || m > 59 || s < 0 || s > 59) {
283
+                return false;
284
+            }
285
+        } catch (Exception e) {
286
+            return false;
287
+        }
288
+        return true;
289
+    }
290
+
291
+    public static boolean isDate(String date) {
292
+        String[] arr = date.split("-");
293
+        if (arr.length < 3) {
294
+            return false;
295
+        }
296
+        try {
297
+            int y = Integer.parseInt(arr[0]);
298
+            int m = Integer.parseInt(arr[1]);
299
+            int d = Integer.parseInt(arr[2]);
300
+            if (y < 0 || m > 12 || m < 0 || d < 0 || d > 31) {
301
+                return false;
302
+            }
303
+        } catch (Exception e) {
304
+            return false;
305
+        }
306
+        return true;
307
+    }
308
+
309
+    public static boolean isWeekend(Date date) {
310
+        Calendar cal = Calendar.getInstance();
311
+        cal.setTime(date);
312
+        int t = cal.get(Calendar.DAY_OF_WEEK);
313
+        if (t == Calendar.SATURDAY || t == Calendar.SUNDAY) {
314
+            return true;
315
+        }
316
+        return false;
317
+    }
318
+
319
+    public static boolean isWeekend(String str) {
320
+        return isWeekend(parse(str));
321
+    }
322
+
323
+    public static Date parse(String str) {
324
+        if (StringUtils.isEmpty(str)) {
325
+            return null;
326
+        }
327
+        try {
328
+            return SDFD.parse(str);
329
+        } catch (ParseException e) {
330
+            e.printStackTrace();
331
+            return null;
332
+        }
333
+    }
334
+
335
+    public static Date parse(String str, String format) {
336
+        if (StringUtils.isEmpty(str)) {
337
+            return null;
338
+        }
339
+        try {
340
+            SimpleDateFormat t = new SimpleDateFormat(format);
341
+            return t.parse(str);
342
+        } catch (ParseException e) {
343
+            e.printStackTrace();
344
+            return null;
345
+        }
346
+    }
347
+
348
+    public static Date parseDateTime(String str) {
349
+        if (StringUtils.isEmpty(str)) {
350
+            return null;
351
+        }
352
+        if (str.length() == 10) {
353
+            return parse(str);
354
+        }
355
+        try {
356
+            return SDFDT.parse(str);
357
+        } catch (ParseException e) {
358
+            e.printStackTrace();
359
+            return null;
360
+        }
361
+    }
362
+
363
+    public static Date parseDateTime(String str, String format) {
364
+        if (StringUtils.isEmpty(str)) {
365
+            return null;
366
+        }
367
+        try {
368
+            SimpleDateFormat t = new SimpleDateFormat(format);
369
+            return t.parse(str);
370
+        } catch (ParseException e) {
371
+            e.printStackTrace();
372
+            return null;
373
+        }
374
+    }
375
+
376
+    /**
377
+     * 格式化时间,按照yyyy-MM-dd HH:mm:ss格式
378
+     * 
379
+     * @param date
380
+     *            时间
381
+     * 
382
+     * @return String
383
+     */
384
+    public static String formatDateTime(Date date) {
385
+        return SDFDT.format(date);
386
+    }
387
+
388
+    /**
389
+     * 格式化时间,按照yyyy-MM-dd格式
390
+     * 
391
+     * @param date
392
+     *            时间
393
+     * 
394
+     * @return String
395
+     */
396
+    public static String formatDate(Date date) {
397
+        return SDFD.format(date);
398
+    }
399
+
400
+    /**
401
+     * 日期date上加count分钟,count为负表示减
402
+     */
403
+    public static Date addMinute(Date date, int count) {
404
+        return new Date(date.getTime() + 60000L * count);
405
+    }
406
+
407
+    /**
408
+     * 日期date上加count妙,count为负表示减
409
+     */
410
+    public static Date addSeconds(Date date, int count) {
411
+        return new Date(date.getTime() + 1000L * count);
412
+    }
413
+
414
+    /**
415
+     * 日期date上加count小时,count为负表示减
416
+     */
417
+    public static Date addHour(Date date, int count) {
418
+        return new Date(date.getTime() + 3600000L * count);
419
+    }
420
+
421
+    /**
422
+     * 日期date上加count天,count为负表示减
423
+     */
424
+    public static Date addDay(Date date, int count) {
425
+        return new Date(date.getTime() + 86400000L * count);
426
+    }
427
+
428
+    /**
429
+     * 日期date上加count星期,count为负表示减
430
+     */
431
+    public static Date addWeek(Date date, int count) {
432
+        Calendar c = Calendar.getInstance();
433
+        c.setTime(date);
434
+        c.add(Calendar.WEEK_OF_YEAR, count);
435
+        return c.getTime();
436
+    }
437
+
438
+    /**
439
+     * 日期date上加count月,count为负表示减
440
+     */
441
+    public static Date addMonth(Date date, int count) {
442
+        /* ${_ZVING_LICENSE_CODE_} */
443
+
444
+        Calendar c = Calendar.getInstance();
445
+        c.setTime(date);
446
+        c.add(Calendar.MONTH, count);
447
+        return c.getTime();
448
+    }
449
+
450
+    /**
451
+     * 日期date上加count年,count为负表示减
452
+     */
453
+    public static Date addYear(Date date, int count) {
454
+        Calendar c = Calendar.getInstance();
455
+        c.setTime(date);
456
+        c.add(Calendar.YEAR, count);
457
+        return c.getTime();
458
+    }
459
+
460
+    /**
461
+     * 根据一个日期,返回是星期几的字符串
462
+     * 
463
+     * @param date
464
+     * @return
465
+     */
466
+    public static String getWeek(String date) {
467
+        String[] weeks = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
468
+        Calendar cal = Calendar.getInstance();
469
+        cal.setTime(parse(date));
470
+        int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
471
+        if (week_index < 0) {
472
+            week_index = 0;
473
+        }
474
+        return weeks[week_index];
475
+    }
476
+
477
+    /**
478
+     * 获取一周列表
479
+     * 
480
+     * @return List
481
+     * 
482
+     */
483
+    public static List<Map<String, String>> getWeekdayList() {
484
+        String[] weekday = { "周一", "周二", "周三", "周四", "周五", "周六", "周日" };
485
+        List<Map<String, String>> weekdayList = new ArrayList<Map<String, String>>();
486
+        for (int i = 0; i < weekday.length; i++) {
487
+            Map<String, String> map = new HashMap<String, String>();
488
+            map.put("name", weekday[i]);
489
+            map.put("value", String.valueOf(i + 1));
490
+            map.put("checked", "");
491
+            weekdayList.add(map);
492
+        }
493
+        return weekdayList;
494
+    }
495
+
496
+    /**
497
+     * 日期返回星期几
498
+     * 
499
+     * @param date
500
+     * 
501
+     * @return int
502
+     */
503
+    public static int dayOfWeek(String date) {
504
+        try {
505
+            Calendar c = Calendar.getInstance();
506
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
507
+            c.setTime(dateFormat.parse(date));
508
+            int dayOfWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
509
+            return dayOfWeek == 0 ? 7 : dayOfWeek;
510
+        } catch (Exception e) {
511
+            e.printStackTrace();
512
+            return 0;
513
+        }
514
+    }
515
+
516
+    /**
517
+     * 取得当前日期是多少周
518
+     * 
519
+     * @param date
520
+     * @return
521
+     */
522
+    public static int getWeekOfYear(Date date) {
523
+        Calendar c = new GregorianCalendar();
524
+        c.setFirstDayOfWeek(Calendar.MONDAY);
525
+        c.setMinimalDaysInFirstWeek(7);
526
+        c.setTime(date);
527
+
528
+        return c.get(Calendar.WEEK_OF_YEAR);
529
+    }
530
+
531
+    /**
532
+     * 得到某年某周的第一天
533
+     * 
534
+     * @param year
535
+     * @param week
536
+     * @return
537
+     */
538
+    public static String getFirstDayOfWeek(int year, int week) {
539
+        Calendar c = new GregorianCalendar();
540
+        c.set(Calendar.YEAR, year);
541
+        c.set(Calendar.MONTH, Calendar.JANUARY);
542
+        c.set(Calendar.DATE, 1);
543
+
544
+        Calendar cal = (GregorianCalendar) c.clone();
545
+        cal.add(Calendar.DATE, week * 7);
546
+
547
+        return formatDate(getFirstDayOfWeek(cal.getTime()));
548
+    }
549
+
550
+    /**
551
+     * 得到某年某周的最后一天
552
+     * 
553
+     * @param year
554
+     * @param week
555
+     * @return
556
+     */
557
+    public static String getLastDayOfWeek(int year, int week) {
558
+        Calendar c = new GregorianCalendar();
559
+        c.set(Calendar.YEAR, year);
560
+        c.set(Calendar.MONTH, Calendar.JANUARY);
561
+        c.set(Calendar.DATE, 1);
562
+
563
+        Calendar cal = (GregorianCalendar) c.clone();
564
+        cal.add(Calendar.DATE, week * 7);
565
+
566
+        return formatDate(getLastDayOfWeek(cal.getTime()));
567
+    }
568
+
569
+    /**
570
+     * 取得当前日期所在周的第一天
571
+     * 
572
+     * @param date
573
+     * @return
574
+     */
575
+    public static Date getFirstDayOfWeek(Date date) {
576
+        Calendar c = new GregorianCalendar();
577
+        c.setFirstDayOfWeek(Calendar.MONDAY);
578
+        c.setTime(date);
579
+        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); // Monday
580
+        return c.getTime();
581
+    }
582
+
583
+    /**
584
+     * 取得当前日期所在周的最后一天
585
+     * 
586
+     * @param date
587
+     * @return
588
+     */
589
+    public static Date getLastDayOfWeek(Date date) {
590
+        Calendar c = new GregorianCalendar();
591
+        c.setFirstDayOfWeek(Calendar.MONDAY);
592
+        c.setTime(date);
593
+        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); // Sunday
594
+        return c.getTime();
595
+    }
596
+
597
+    /**
598
+     * 取得当前月份的第一天
599
+     * 
600
+     * @param date
601
+     * @return
602
+     */
603
+    public static String getFirstDayOfMonth(Date date) {
604
+        Calendar c = new GregorianCalendar();
605
+        c.setTime(date);
606
+        c.set(Calendar.DAY_OF_MONTH, 1);
607
+        return formatDate(c.getTime());
608
+    }
609
+
610
+    /**
611
+     * 获取N天前的日期
612
+     * 
613
+     * @param date
614
+     *            当前日期 num 几天前
615
+     * @return
616
+     * */
617
+    public static Date getBeginData(Date date, int num) {
618
+        Calendar c = new GregorianCalendar();
619
+        c.setTime(date);
620
+        c.add(Calendar.DATE, -num);
621
+        return c.getTime();
622
+    }
623
+
624
+    public static int getBetweenDays(Date d1, Date nextD) {
625
+        Calendar c1 = new GregorianCalendar();
626
+        c1.setTime(d1);
627
+        Calendar c2 = new GregorianCalendar();
628
+        c2.setTime(nextD);
629
+        return c1.get(Calendar.DAY_OF_YEAR) - c2.get(Calendar.DAY_OF_YEAR);
630
+    }
631
+
632
+    public static int getBetweenMinutes(Date max, Date min) {
633
+        Calendar c1 = new GregorianCalendar();
634
+        c1.setTime(max);
635
+        Calendar c2 = new GregorianCalendar();
636
+        c2.setTime(min);
637
+        return (int) ((c1.getTimeInMillis() - c2.getTimeInMillis()) / (1000 * 60));
638
+    }
639
+
640
+    /**
641
+     * 获取当前年
642
+     * 
643
+     * @return
644
+     */
645
+    public static int getCurrentYear() {
646
+        Calendar cal = Calendar.getInstance();
647
+        int year = cal.get(Calendar.YEAR);
648
+        return year;
649
+    }
650
+
651
+    /**
652
+     * 获取当前月
653
+     * 
654
+     * @return
655
+     */
656
+    public static int getCurrentMonth() {
657
+        Calendar cal = Calendar.getInstance();
658
+        int month = cal.get(Calendar.MONTH) + 1;
659
+        return month;
660
+    }
661
+    
662
+    /**
663
+     * 把年月日变数字
664
+     * */
665
+    public static int getDate(String date){
666
+    	String [] date1 = date.split("-");
667
+    	int date2 = Integer.parseInt(date1[0]+date1[1]+date1[2]);
668
+    	return date2;
669
+    }
670
+}

+ 49 - 0
src/main/java/com/dashitech/utils/DecimalUtil.java

@@ -0,0 +1,49 @@
1
+package com.dashitech.utils;
2
+
3
+import java.math.BigDecimal;
4
+
5
+
6
+
7
+/**
8
+ * 价格计算工具类
9
+ */
10
+public class DecimalUtil {
11
+	private static final int DIV_SCALE = 50;
12
+ 
13
+	/**
14
+	 * 相加
15
+	 */
16
+	public static BigDecimal sum(Object first,Object second) {
17
+		BigDecimal _first = new BigDecimal(first.toString());
18
+		BigDecimal _second = new BigDecimal(second.toString());
19
+		return _first.add(_second);
20
+	}
21
+	
22
+	/**
23
+	 * 相减
24
+	 */
25
+	public static BigDecimal sub(Object first,Object second) {
26
+		BigDecimal _first = new BigDecimal(first.toString());
27
+		BigDecimal _second = new BigDecimal(second.toString());
28
+		return _first.subtract(_second);
29
+	}
30
+	
31
+	/**
32
+	 * 相乘
33
+	 */
34
+	public static BigDecimal ride(Object first,Object second) {
35
+		BigDecimal _first = new BigDecimal(first.toString());
36
+		BigDecimal _second = new BigDecimal(second.toString());
37
+		return _first.multiply(_second);
38
+    }
39
+	
40
+	/**
41
+	 * 相除
42
+	 */
43
+	public static BigDecimal div(Object first,Object second) {
44
+		BigDecimal _first = new BigDecimal(first.toString());
45
+		BigDecimal _second = new BigDecimal(second.toString());
46
+		 return _first.divide(_second,DIV_SCALE,BigDecimal.ROUND_HALF_DOWN);
47
+	}
48
+
49
+}

+ 675 - 0
src/main/java/com/dashitech/utils/FileUtil.java

@@ -0,0 +1,675 @@
1
+package com.dashitech.utils;
2
+
3
+import org.apache.commons.logging.Log;
4
+import org.apache.commons.logging.LogFactory;
5
+
6
+import java.io.*;
7
+import java.net.URL;
8
+import java.util.ArrayList;
9
+import java.util.Collections;
10
+import java.util.Comparator;
11
+import java.util.List;
12
+import java.util.zip.ZipInputStream;
13
+
14
+public class FileUtil {
15
+	private static Log log = LogFactory.getLog(FileUtil.class);
16
+	
17
+	/**
18
+	 * 根据日期给文件排序,
19
+	 * @param list
20
+	 * @param desc true为倒序(最新日期在前面),false正序
21
+	 */
22
+	public static void sortByDate(List<File> list,final boolean desc) {
23
+		Collections.sort(list, new Comparator<File>() {
24
+			public int compare(File o1, File o2) {
25
+				Long a = o1.lastModified();
26
+				Long b = o2.lastModified();
27
+				int sort = 0;
28
+				if(desc) {
29
+					sort = b.compareTo(a);
30
+				}else {
31
+					sort = a.compareTo(b);
32
+				}
33
+				return sort;
34
+			}
35
+		});
36
+	}
37
+
38
+	/**
39
+	 * 写文件
40
+	 * 
41
+	 * @param f
42
+	 * @param content
43
+	 */
44
+	public static void writeFile(File f, String content) {
45
+		writeFile(f, content, "utf-8");
46
+	}
47
+
48
+	/**
49
+	 * 写文件
50
+	 * 
51
+	 * @param f
52
+	 * @param content
53
+	 */
54
+	public static void writeFile(File f, String content, String encode) {
55
+		try {
56
+			// 如果目录不存在,创建目录
57
+			File parent = new File(f.getParent());
58
+			parent.mkdirs();
59
+
60
+			if (!f.exists()) {
61
+				f.createNewFile();
62
+			}
63
+			OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(f), encode);
64
+			BufferedWriter utput = new BufferedWriter(osw);
65
+			FileOutputStream fo = null;
66
+			try {
67
+				fo = new FileOutputStream(f);
68
+				osw = new OutputStreamWriter(fo, encode);
69
+				utput = new BufferedWriter(osw);
70
+				utput.write(content);
71
+				utput.flush();
72
+			} catch (IOException ioException) {
73
+				ioException.printStackTrace();
74
+			} finally {
75
+				try {
76
+					if (fo != null) {
77
+						fo.close();
78
+					}
79
+					if (utput != null) {
80
+						utput.close();
81
+					}
82
+					if (osw != null) {
83
+						osw.close();
84
+					}
85
+				} catch (IOException e) {
86
+					log.error(e.getMessage(), e);
87
+				}
88
+			}
89
+		} catch (Exception e) {
90
+			log.error(e.getMessage(), e);
91
+		}
92
+	}
93
+
94
+	/**
95
+	 * 写出url内容为文件
96
+	 * @param file 写出的文件
97
+	 * @param url 写出的内容
98
+	 */
99
+	public static void writeFileByUrl(String file, String url) {
100
+		byte[] bytes = null;
101
+		InputStream in = null;
102
+		ByteArrayOutputStream bos = null;
103
+		
104
+		try {
105
+			URL resourceUrl = new URL(url);
106
+			in = (InputStream) resourceUrl.getContent();
107
+			
108
+			bos = new ByteArrayOutputStream();
109
+			byte[] b = new byte[1024];
110
+			int n;
111
+			while ((n = in.read(b)) != -1) {
112
+				bos.write(b, 0, n);
113
+			}
114
+			
115
+			bytes = bos.toByteArray();
116
+			
117
+			File f = new File(file);
118
+			
119
+			writeFile(f, bytes);
120
+			
121
+		} catch (IOException e) {
122
+			log.error(file+"   "+url);
123
+			log.error(e.getMessage(),e);
124
+		} finally {
125
+			try {
126
+				if (in != null) {
127
+					in.close();
128
+				}
129
+				if (bos != null) {
130
+					bos.close();
131
+				}
132
+			} catch (IOException e) {
133
+				log.error(e.getMessage(), e);
134
+			}
135
+		}
136
+	}
137
+
138
+	/**
139
+	 * 写文件
140
+	 * 
141
+	 * @param f
142
+	 * @param bytes
143
+	 */
144
+	public static void writeFile(File f, byte[] bytes) {
145
+		try {
146
+			// 如果目录不存在,创建目录
147
+			File parent = new File(f.getParent());
148
+			parent.mkdirs();
149
+
150
+			if (!f.exists()) {
151
+				f.createNewFile();
152
+			}
153
+
154
+			BufferedOutputStream bos = null;
155
+			FileOutputStream fo = null;
156
+			try {
157
+				fo = new FileOutputStream(f);
158
+				bos = new BufferedOutputStream(fo);
159
+				bos.write(bytes);
160
+				bos.flush();
161
+			} catch (IOException ioException) {
162
+				ioException.printStackTrace();
163
+			} finally {
164
+				try {
165
+					if (fo != null) {
166
+						fo.close();
167
+					}
168
+					if (bos != null) {
169
+						bos.close();
170
+					}
171
+				} catch (IOException e) {
172
+					log.error(e.getMessage(), e);
173
+				}
174
+			}
175
+		} catch (Exception e) {
176
+			log.error(e.getMessage(), e);
177
+		}
178
+	}
179
+
180
+	/**
181
+	 * 写文件
182
+	 * 
183
+	 * @param path
184
+	 * @param content
185
+	 */
186
+	public static void writeFile(String path, String content, String encode) {
187
+		File f = new File(path);
188
+		writeFile(f, content, encode);
189
+	}
190
+
191
+	/**
192
+	 * 写文件
193
+	 * 
194
+	 * @param path
195
+	 * @param content
196
+	 */
197
+	public static void writeFile(String path, String content) {
198
+		File f = new File(path);
199
+		writeFile(f, content, "utf-8");
200
+	}
201
+
202
+	/**
203
+	 * 读取文件
204
+	 * 
205
+	 * @param file
206
+	 * @return
207
+	 */
208
+	public static String readFile(File file) {
209
+		return readFile(file, "UTF-8");
210
+	}
211
+
212
+	/**
213
+	 * 读取文件
214
+	 * 
215
+	 * @param file
216
+	 * @return
217
+	 */
218
+	public static String readFile(File file, String encode) {
219
+		String output = "";
220
+		InputStreamReader isr = null;
221
+		BufferedReader input = null;
222
+
223
+		if (file.exists()) {
224
+			if (file.isFile()) {
225
+				try {
226
+					isr = new InputStreamReader(new FileInputStream(file), encode);
227
+					input = new BufferedReader(isr);
228
+					StringBuffer buffer = new StringBuffer();
229
+					String text;
230
+					while ((text = input.readLine()) != null)
231
+						buffer.append(text + "\n");
232
+					output = buffer.toString();
233
+
234
+				} catch (IOException ioException) {
235
+					ioException.printStackTrace();
236
+				} finally {
237
+					try {
238
+						if (input != null) {
239
+							input.close();
240
+						}
241
+						if (isr != null) {
242
+							isr.close();
243
+						}
244
+					} catch (IOException e) {
245
+						log.error(e.getMessage(), e);
246
+					}
247
+				}
248
+			} else if (file.isDirectory()) {
249
+				throw new RuntimeException(file.getPath() + " isDirectory!");
250
+			}
251
+
252
+		} else {
253
+			throw new RuntimeException(file.getPath() + " Does not exist!");
254
+		}
255
+
256
+		return output;
257
+	}
258
+
259
+	public static byte[] readFileBytes(File file) {
260
+		byte[] bytes = null;
261
+		FileInputStream fis = null;
262
+		ByteArrayOutputStream bos = null;
263
+		if (file.exists()) {
264
+			if (file.isFile()) {
265
+				try {
266
+					fis = new FileInputStream(file);
267
+					bos = new ByteArrayOutputStream();
268
+					byte[] b = new byte[1024];
269
+					int n;
270
+					while ((n = fis.read(b)) != -1) {
271
+						bos.write(b, 0, n);
272
+					}
273
+					fis.close();
274
+					bos.close();
275
+					bytes = bos.toByteArray();
276
+				} catch (IOException ioException) {
277
+					ioException.printStackTrace();
278
+				} finally {
279
+					try {
280
+						if (fis != null) {
281
+							fis.close();
282
+						}
283
+						if (bos != null) {
284
+							bos.close();
285
+						}
286
+					} catch (IOException e) {
287
+						log.error(e.getMessage(), e);
288
+					}
289
+				}
290
+			} else if (file.isDirectory()) {
291
+				throw new RuntimeException(file.getPath() + " isDirectory!");
292
+			}
293
+
294
+		} else {
295
+			throw new RuntimeException(file.getPath() + " Does not exist!");
296
+		}
297
+
298
+		return bytes;
299
+	}
300
+
301
+	/**
302
+	 * 读取文件
303
+	 * 
304
+	 * @param fileName
305
+	 * @return
306
+	 */
307
+	public static String readFile(String fileName, String encode) {
308
+		File file = new File(fileName);
309
+		return readFile(file, encode);
310
+	}
311
+
312
+	/**
313
+	 * 读取文件
314
+	 * 
315
+	 * @param fileName
316
+	 * @return
317
+	 */
318
+	public static String readFile(String fileName) {
319
+		return readFile(fileName, "utf-8");
320
+	}
321
+
322
+	/**
323
+	 * 获取目录下所有文件,一级
324
+	 * 
325
+	 * @param folder
326
+	 * @return
327
+	 */
328
+	public static List<File> getFiles(String folder) {
329
+		return getFiles(folder, null);
330
+	}
331
+
332
+	/**
333
+	 * 获取目录下所有文件,一级,后缀区分
334
+	 * 
335
+	 * @param folder
336
+	 * @return
337
+	 */
338
+	public static List<File> getFiles(String folder, String suffix) {
339
+		File file = new File(folder);
340
+		List<File> list = new ArrayList<File>();
341
+		if (file.exists() && file.isDirectory()) {
342
+			File[] files = file.listFiles();
343
+			for (File f : files) {
344
+				String fileName = f.getName();
345
+				if (suffix == null) {
346
+					list.add(f);
347
+				} else if (fileName.endsWith(suffix)) {
348
+					list.add(f);
349
+				}
350
+			}
351
+		}
352
+		return list;
353
+	}
354
+
355
+	/**
356
+	 * 遍历所有文件夹,取出文件
357
+	 */
358
+	public static List<File> getFileDeeps(String folder, String suffix) {
359
+		File file = new File(folder);
360
+		List<File> list = new ArrayList<File>();
361
+		if (file.exists() && file.isDirectory()) {
362
+			File[] files = file.listFiles();
363
+
364
+			for (File f : files) {
365
+				if (f.isFile()) {
366
+					String fileName = f.getName();
367
+					if (suffix == null) {
368
+						list.add(f);
369
+					} else if (fileName.endsWith(suffix)) {
370
+						list.add(f);
371
+					}
372
+				} else if (f.isDirectory()) {
373
+					list.addAll(getFileDeeps(f.getAbsolutePath(), suffix));
374
+				}
375
+			}
376
+		}
377
+		return list;
378
+	}
379
+
380
+	/**
381
+	 * 遍历所有文件夹,取出文件
382
+	 */
383
+	public static List<File> getFileDeeps(String folder, List<String> suffixs) {
384
+		File file = new File(folder);
385
+		List<File> list = new ArrayList<File>();
386
+		if (file.exists() && file.isDirectory()) {
387
+			File[] files = file.listFiles();
388
+
389
+			for (File f : files) {
390
+				if (f.isFile()) {
391
+					String fileName = f.getName();
392
+					for (String suffix : suffixs) {
393
+						if (suffix == null) {
394
+							list.add(f);
395
+						} else if (fileName.toLowerCase().endsWith(suffix)) {
396
+							list.add(f);
397
+						}
398
+					}
399
+				} else if (f.isDirectory()) {
400
+					list.addAll(getFileDeeps(f.getAbsolutePath(), suffixs));
401
+				}
402
+			}
403
+		}
404
+		return list;
405
+	}
406
+
407
+	/**
408
+	 * 获取目录下所有文件夹,一级
409
+	 * 
410
+	 * @param folder
411
+	 * @return
412
+	 */
413
+	public static List<File> getFolders(String folder) {
414
+		File file = new File(folder);
415
+		List<File> files = new ArrayList<File>();
416
+		if (file.exists()) {
417
+			File[] sonFiles = file.listFiles();
418
+			if (sonFiles != null && sonFiles.length > 0) {
419
+				for (int i = 0; i < sonFiles.length; i++) {
420
+					if (sonFiles[i].isDirectory()) {
421
+						files.add(sonFiles[i]);
422
+					}
423
+				}
424
+			}
425
+		}
426
+		return files;
427
+	}
428
+
429
+	/**
430
+	 * 判断是否有子目录
431
+	 * 
432
+	 * @param folder
433
+	 * @return
434
+	 */
435
+	public static boolean hasSonFolder(String folder) {
436
+		File file = new File(folder);
437
+		return hasSonFolder(file);
438
+	}
439
+
440
+	/**
441
+	 * 判断是否有子目录
442
+	 * 
443
+	 * @param file
444
+	 * @return
445
+	 */
446
+	public static boolean hasSonFolder(File file) {
447
+		if (file.exists()) {
448
+			File[] sonFiles = file.listFiles();
449
+			if (sonFiles != null && sonFiles.length > 0) {
450
+				for (int i = 0; i < sonFiles.length; i++) {
451
+					if (sonFiles[i].isDirectory()) {
452
+						return true;
453
+					}
454
+				}
455
+			}
456
+		}
457
+		return false;
458
+	}
459
+
460
+	/**
461
+	 * 创建目录
462
+	 * 
463
+	 * @param folder
464
+	 */
465
+	public static void mkdirs(String folder) {
466
+		File file = new File(folder);
467
+		if (!file.exists()) {
468
+			file.mkdirs();
469
+		}
470
+	}
471
+
472
+	/**
473
+	 * 复制文件
474
+	 * 
475
+	 * @param src
476
+	 * @param dst
477
+	 */
478
+	public static void copy(File src, File dst) {
479
+		try {
480
+			// 如果是文件夹,并且已存在则什么都不做
481
+			if (dst.isDirectory() && dst.exists()) {
482
+				return;
483
+			}
484
+			if (!dst.getParentFile().exists()) {
485
+				dst.getParentFile().mkdirs();
486
+			}
487
+
488
+			int BUFFER_SIZE = 32 * 1024;
489
+			InputStream in = null;
490
+			OutputStream out = null;
491
+			try {
492
+				in = new FileInputStream(src);
493
+				out = new FileOutputStream(dst);
494
+				byte[] buffer = new byte[BUFFER_SIZE];
495
+				int count;
496
+				while ((count = in.read(buffer)) != -1) {
497
+					out.write(buffer, 0, count);
498
+				}
499
+				out.flush();
500
+			} catch (Exception e) {
501
+				log.error(src.getAbsolutePath() + "," + dst.getAbsolutePath() + ";" + e.getMessage(), e);
502
+			} finally {
503
+				if (null != in) {
504
+					in.close();
505
+				}
506
+				if (null != out) {
507
+					out.close();
508
+				}
509
+			}
510
+		} catch (Exception e2) {
511
+			log.error(e2.getMessage(), e2);
512
+		}
513
+	}
514
+
515
+	/**
516
+	 * 复制文件夹,包含内容,如果已有覆盖已有文件
517
+	 * 
518
+	 * @param overwrite
519
+	 *            是否覆盖文件
520
+	 */
521
+	public static void copyDirectiory(String sourceDir, String targetDir, boolean overwrite) throws IOException {
522
+		if (new File(sourceDir).exists()) {
523
+			// 新建目标目录
524
+			File targetFolder = new File(targetDir);
525
+			if (!targetFolder.exists()) {
526
+				targetFolder.mkdirs();
527
+			}
528
+			// 获取源文件夹当前下的文件或目录
529
+			File[] file = (new File(sourceDir)).listFiles();
530
+			for (int i = 0; i < file.length; i++) {
531
+
532
+				try {
533
+					if (file[i].isFile()) {
534
+						// 源文件
535
+						File sourceFile = file[i];
536
+						// 目标文件
537
+						File targetFile = new File(new File(targetDir).getAbsolutePath() + File.separator + file[i].getName());
538
+
539
+						// 如果重写为true,直接覆盖现有文件
540
+						if (overwrite) {
541
+							copy(sourceFile, targetFile);
542
+						} else if (!targetFile.exists()) {
543
+							// 如果文件不存在才写文件
544
+							copy(sourceFile, targetFile);
545
+						}
546
+
547
+					}
548
+					if (file[i].isDirectory()) {
549
+						// 准备复制的源文件夹
550
+						String dir1 = sourceDir + "/" + file[i].getName();
551
+						// 准备复制的目标文件夹
552
+						String dir2 = targetDir + "/" + file[i].getName();
553
+						File fileDir2 = new File(targetDir);
554
+						if (!fileDir2.exists()) {
555
+							fileDir2.mkdirs();
556
+						}
557
+						copyDirectiory(dir1, dir2, overwrite);
558
+					}
559
+				} catch (Exception e) {
560
+					log.error(e.getMessage(), e);
561
+				}
562
+
563
+			}
564
+		}
565
+	}
566
+
567
+	/**
568
+	 * 获取扩展名 .jpg
569
+	 */
570
+	public static String getExt(File src) {
571
+		if (src != null) {
572
+			String name = src.getName();
573
+			return name.substring(name.lastIndexOf("."), name.length());
574
+		}
575
+		return "";
576
+	}
577
+
578
+	/**
579
+	 * 获取扩展名 .jpg
580
+	 */
581
+	public static String getExt(String src) {
582
+		if (src != null) {
583
+			return src.substring(src.lastIndexOf("."), src.length());
584
+		}
585
+		return "";
586
+	}
587
+
588
+	/**
589
+	 * 删除指定文件
590
+	 * 
591
+	 * @param path
592
+	 */
593
+	public static void del(String path) {
594
+		File file = new File(path);
595
+		deleteFile(file);
596
+	}
597
+
598
+	/**
599
+	 * 递归删除文件夹下所有文件
600
+	 * 
601
+	 * @param file
602
+	 */
603
+	public static void deleteFile(File file) {
604
+		if (file.exists() && file.canRead()) { // 判断文件是否存在
605
+			try {
606
+				if (file.isFile()) { // 判断是否是文件
607
+					file.delete(); // delete()方法 你应该知道 是删除的意思;
608
+				} else if (file.isDirectory()) { // 否则如果它是一个目录
609
+					File files[] = file.listFiles(); // 声明目录下所有的文件 files[];
610
+					for (int i = 0; i < files.length; i++) { // 遍历目录下所有的文件
611
+						deleteFile(files[i]); // 把每个文件 用这个方法进行迭代
612
+					}
613
+				}
614
+				file.delete();
615
+			} catch (Exception e) {
616
+				log.error(e.getMessage(), e);
617
+			}
618
+		}
619
+	}
620
+
621
+	public static void deleteFile(List<File> files) {
622
+		for (File f : files) {
623
+			deleteFile(f);
624
+		}
625
+	}
626
+
627
+
628
+
629
+	/**
630
+	 * 解压缩
631
+	 * 
632
+	 * @param sZipPathFile
633
+	 *            要解压的文件
634
+	 * @param sDestPath
635
+	 *            解压到某文件夹
636
+	 * @return
637
+	 */
638
+	public static List<String> unzip(String sZipPathFile, String sDestPath) {
639
+		List<String> allFileName = new ArrayList<String>();
640
+		try {
641
+			// 先指定压缩档的位置和档名,建立FileInputStream对象
642
+			FileInputStream fins = new FileInputStream(sZipPathFile);
643
+			// 将fins传入ZipInputStream中
644
+			ZipInputStream zins = new ZipInputStream(fins);
645
+			java.util.zip.ZipEntry ze = null;
646
+			byte[] ch = new byte[256];
647
+			while ((ze = zins.getNextEntry()) != null) {
648
+				File zfile = new File(sDestPath + ze.getName());
649
+				File fpath = new File(zfile.getParentFile().getPath());
650
+				if (ze.isDirectory()) {
651
+					if (!zfile.exists())
652
+						zfile.mkdirs();
653
+					zins.closeEntry();
654
+				} else {
655
+					if (!fpath.exists())
656
+						fpath.mkdirs();
657
+					FileOutputStream fouts = new FileOutputStream(zfile);
658
+					int i;
659
+					allFileName.add(zfile.getAbsolutePath());
660
+					while ((i = zins.read(ch)) != -1)
661
+						fouts.write(ch, 0, i);
662
+					zins.closeEntry();
663
+					fouts.close();
664
+				}
665
+			}
666
+			fins.close();
667
+			zins.close();
668
+		} catch (Exception e) {
669
+			log.error(e.getMessage(), e);
670
+		}
671
+		return allFileName;
672
+	}
673
+
674
+
675
+}

+ 372 - 0
src/main/java/com/dashitech/utils/HttpUtil.java

@@ -0,0 +1,372 @@
1
+package com.dashitech.utils;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import org.apache.commons.lang.StringUtils;
5
+import org.apache.http.HttpEntity;
6
+import org.apache.http.NameValuePair;
7
+import org.apache.http.client.config.RequestConfig;
8
+import org.apache.http.client.entity.UrlEncodedFormEntity;
9
+import org.apache.http.client.methods.CloseableHttpResponse;
10
+import org.apache.http.client.methods.HttpGet;
11
+import org.apache.http.client.methods.HttpPost;
12
+import org.apache.http.impl.client.CloseableHttpClient;
13
+import org.apache.http.impl.client.HttpClientBuilder;
14
+import org.apache.http.message.BasicNameValuePair;
15
+import org.apache.http.util.EntityUtils;
16
+
17
+import javax.servlet.http.HttpServletResponse;
18
+import java.io.*;
19
+import java.net.HttpURLConnection;
20
+import java.net.MalformedURLException;
21
+import java.net.SocketException;
22
+import java.net.URL;
23
+import java.util.ArrayList;
24
+import java.util.List;
25
+import java.util.Map;
26
+
27
+public class HttpUtil {
28
+
29
+    public static CloseableHttpClient getHttpClient() {
30
+    	 RequestConfig config = RequestConfig.custom().setConnectTimeout(60000).setSocketTimeout(15000).build();
31
+    	 CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
32
+         return httpClient;
33
+    }
34
+
35
+    /**
36
+     * HTTP Get 获取内容
37
+     * @param url  请求的url地址 ?之前的地址
38
+     * @param params	请求的参数
39
+     * @param charset	编码格式
40
+     * @return	页面内容
41
+     */
42
+    public static String doGet(String url,Map<String,String> params,String charset){
43
+    	if(StringUtils.isBlank(url)){
44
+    		return null;
45
+    	}
46
+    	try {
47
+    		if(params != null && !params.isEmpty()){
48
+    			List<NameValuePair> pairs = new ArrayList<NameValuePair>(params.size());
49
+    			for(Map.Entry<String,String> entry : params.entrySet()){
50
+    				String value = entry.getValue();
51
+    				if(value != null){
52
+    					pairs.add(new BasicNameValuePair(entry.getKey(),value));
53
+    				}
54
+    			}
55
+    			url += "?" + EntityUtils.toString(new UrlEncodedFormEntity(pairs, charset));
56
+    		}
57
+    		HttpGet httpGet = new HttpGet(url);
58
+    		CloseableHttpResponse response = getHttpClient().execute(httpGet);
59
+    		int statusCode = response.getStatusLine().getStatusCode();
60
+    		if (statusCode != 200) {
61
+    			httpGet.abort();
62
+    			throw new RuntimeException("HttpClient,error status code :" + statusCode);
63
+    		}
64
+    		HttpEntity entity = response.getEntity();
65
+    		String result = null;
66
+    		if (entity != null){
67
+    			result = EntityUtils.toString(entity, charset);
68
+    		}
69
+    		EntityUtils.consume(entity);
70
+    		response.close();
71
+    		return result;
72
+    	} catch (Exception e) {
73
+    		e.printStackTrace();
74
+    	}
75
+    	return null;
76
+    }
77
+    
78
+    /**
79
+     * HTTP Post 获取内容
80
+     * @param url  请求的url地址 ?之前的地址
81
+     * @param params	请求的参数
82
+     * @param charset	编码格式
83
+     * @return	页面内容
84
+     */
85
+    public static String doPost(String url,Map<String,String> params,String charset){
86
+    	if(StringUtils.isBlank(url)){
87
+    		return null;
88
+    	}
89
+    	try {
90
+    		List<NameValuePair> pairs = null;
91
+    		if(params != null && !params.isEmpty()){
92
+    			pairs = new ArrayList<NameValuePair>(params.size());
93
+    			for(Map.Entry<String,String> entry : params.entrySet()){
94
+    				String value = entry.getValue();
95
+    				if(value != null){
96
+    					pairs.add(new BasicNameValuePair(entry.getKey(),value));
97
+    				}
98
+    			}
99
+    		}
100
+    		HttpPost httpPost = new HttpPost(url);
101
+    		if(pairs != null && pairs.size() > 0){
102
+    			httpPost.setEntity(new UrlEncodedFormEntity(pairs,charset));
103
+    		}
104
+    		CloseableHttpResponse response = getHttpClient().execute(httpPost);
105
+    		int statusCode = response.getStatusLine().getStatusCode();
106
+    		if (statusCode != 200) {
107
+    			httpPost.abort();
108
+    			throw new RuntimeException("HttpClient,error status code :" + statusCode);
109
+    		}
110
+    		HttpEntity entity = response.getEntity();
111
+    		String result = null;
112
+    		if (entity != null){
113
+    			result = EntityUtils.toString(entity, charset);
114
+    		}
115
+    		EntityUtils.consume(entity);
116
+    		response.close();
117
+    		return result;
118
+    	} catch (Exception e) {
119
+    		e.printStackTrace();
120
+    	}
121
+    	return null;
122
+    }
123
+
124
+	public static void outPrint(HttpServletResponse response, String content, String charset) {
125
+		response.setCharacterEncoding(charset);
126
+		response.setContentType(new StringBuilder().append("text/html;charset=").append(charset).toString());
127
+		PrintWriter out = null;
128
+		try {
129
+			out = response.getWriter();
130
+			out.println(content);
131
+			out.flush();
132
+		} catch (Exception e) {
133
+			e.printStackTrace();
134
+		} finally {
135
+			out.close();
136
+		}
137
+	}
138
+	
139
+	public static String readResponse(String requestUrl, Map<String, String> params, String method, String charset) {
140
+		StringBuffer sb = new StringBuffer();
141
+		String paramsStr = "";
142
+		if ((params != null) && (params.size() > 0)) {
143
+			for (Map.Entry e : params.entrySet()) {
144
+				sb.append((String) e.getKey());
145
+				sb.append("=");
146
+				sb.append((String) e.getValue());
147
+				sb.append("&");
148
+			}
149
+			paramsStr = sb.substring(0, sb.length() - 1);
150
+		}
151
+		return readResponse(requestUrl, paramsStr, method, charset);
152
+	}
153
+	
154
+	public static String readPostResponse(String requestUrl, String json, String contentType) {
155
+		HttpURLConnection conn = null;
156
+		OutputStreamWriter out = null;
157
+		BufferedReader in = null;
158
+		String line = null;
159
+		try {
160
+			URL url = new URL(requestUrl);
161
+			conn = (HttpURLConnection) url.openConnection();
162
+			conn.setRequestMethod("POST");
163
+			conn.setRequestProperty("Content-Type", contentType);
164
+			conn.setRequestProperty("Accept-Charset", "UTF-8");
165
+			conn.setRequestProperty("Content-Length", new StringBuilder().append("").append(json.length()).toString());
166
+			conn.setUseCaches(false);
167
+			conn.setDoOutput(true);
168
+			out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
169
+			out.write(json);
170
+			out.flush();
171
+			out.close();
172
+
173
+			if (conn.getResponseCode() != 200) {
174
+				System.err.println("connect failed!" + conn.getResponseCode());
175
+				String str1 = "";
176
+				return str1;
177
+			}
178
+			String result = "";
179
+			in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
180
+			while ((line = in.readLine()) != null) {
181
+				result = new StringBuilder().append(result).append(line).append("\n").toString();
182
+			}
183
+			String str2 = result;
184
+			return str2;
185
+		} catch (SocketException se) {
186
+			se.printStackTrace();
187
+			line = null;
188
+			return line;
189
+		} catch (Exception e) {
190
+			e.printStackTrace();
191
+			line = null;
192
+			return line;
193
+		} finally {
194
+			if (out != null) {
195
+				try {
196
+					out.close();
197
+				} catch (IOException e) {
198
+					e.printStackTrace();
199
+				}
200
+			}
201
+			if (in != null) {
202
+				try {
203
+					in.close();
204
+				} catch (IOException e) {
205
+					e.printStackTrace();
206
+				}
207
+			}
208
+			if (conn != null)
209
+				conn.disconnect();
210
+		}
211
+	}
212
+	
213
+	public static String readResponse(String requestUrl, String requestData, String method, String charset) {
214
+		HttpURLConnection conn = null;
215
+		OutputStreamWriter out = null;
216
+		BufferedReader in = null;
217
+		String line = null;
218
+		try {
219
+			URL url = new URL(requestUrl);
220
+			conn = (HttpURLConnection) url.openConnection();
221
+			conn.setRequestMethod(method);
222
+			conn.setRequestProperty("Content-Type", "text/html");
223
+			conn.setRequestProperty("Accept-Charset", charset);
224
+			conn.setUseCaches(false);
225
+			conn.setDoOutput(true);
226
+			conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
227
+			conn.setRequestProperty("Content-Length", new StringBuilder().append("").append(requestData.length()).toString());
228
+			out = new OutputStreamWriter(conn.getOutputStream(), charset);
229
+			out.write(requestData);
230
+			out.flush();
231
+			out.close();
232
+
233
+			if (conn.getResponseCode() != 200) {
234
+				System.err.println("connect failed!" + conn.getResponseCode());
235
+				String str1 = "";
236
+				return str1;
237
+			}
238
+			String result = "";
239
+			in = new BufferedReader(new InputStreamReader(conn.getInputStream(), charset));
240
+			while ((line = in.readLine()) != null) {
241
+				result = new StringBuilder().append(result).append(line).append("\n").toString();
242
+			}
243
+			String str2 = result;
244
+			return str2;
245
+		} catch (SocketException se) {
246
+			se.printStackTrace();
247
+			line = null;
248
+			return line;
249
+		} catch (Exception e) {
250
+			e.printStackTrace();
251
+			line = null;
252
+			return line;
253
+		} finally {
254
+			if (out != null) {
255
+				try {
256
+					out.close();
257
+				} catch (IOException e) {
258
+					e.printStackTrace();
259
+				}
260
+			}
261
+			if (in != null) {
262
+				try {
263
+					in.close();
264
+				} catch (IOException e) {
265
+					e.printStackTrace();
266
+				}
267
+			}
268
+			if (conn != null)
269
+				conn.disconnect();
270
+		}
271
+	}
272
+
273
+	public static String getString(byte[] b, int offset, int len, String encoding) {
274
+		try {
275
+			return new String(b, offset, len, encoding);
276
+		} catch (UnsupportedEncodingException e) {
277
+		}
278
+		return new String(b, offset, len);
279
+	}
280
+
281
+
282
+	public static String doPost(String httpUrl,Object param) {
283
+
284
+		HttpURLConnection connection = null;
285
+		InputStream is = null;
286
+		OutputStream out = null;
287
+		BufferedReader br = null;
288
+		String result = null;
289
+		try {
290
+			URL url = new URL(httpUrl);
291
+			// 通过远程url连接对象打开连接
292
+			connection = (HttpURLConnection) url.openConnection();
293
+			// 设置连接请求方式
294
+			connection.setRequestMethod("POST");
295
+			// 设置连接主机服务器超时时间:15000毫秒
296
+			connection.setConnectTimeout(60000);
297
+			// 设置读取主机服务器返回数据超时时间:60000毫秒
298
+			connection.setReadTimeout(60000);
299
+
300
+			// 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true
301
+			connection.setDoOutput(true);
302
+			// 默认值为:true,当前向远程服务读取数据时,设置为true,该参数可有可无
303
+			connection.setDoInput(true);
304
+			// 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。
305
+			connection.setRequestProperty("Content-Type", "application/json");
306
+			// 设置鉴权信息:Authorization: Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0
307
+			//connection.setRequestProperty("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0");
308
+			// 通过连接对象获取一个输出流
309
+			out = connection.getOutputStream();
310
+			// 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
311
+			//os.write(param.getBytes());
312
+			//JSONObject obj = new JSONObject();
313
+			// java.net.URLEncoder.encode 编码之后会有%多余%的问题,在传输的过程中无法被解析
314
+			// String json = java.net.URLEncoder.encode(obj.toString(), "utf-8");
315
+			Object o = JSONObject.toJSON(param);
316
+			Object jsonObject = JSONObject.parse(o.toString());
317
+			out.write(jsonObject.toString().getBytes());
318
+
319
+
320
+			// 通过连接对象获取一个输入流,向远程读取
321
+			if (connection.getResponseCode() == 200) {
322
+
323
+				is = connection.getInputStream();
324
+				// 对输入流对象进行包装:charset根据工作项目组的要求来设置
325
+				br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
326
+
327
+				StringBuffer sbf = new StringBuffer();
328
+				String temp = null;
329
+				// 循环遍历一行一行读取数据
330
+				while ((temp = br.readLine()) != null) {
331
+					sbf.append(temp);
332
+					sbf.append("\r\n");
333
+				}
334
+				result = sbf.toString();
335
+			}
336
+		} catch (MalformedURLException e) {
337
+			e.printStackTrace();
338
+		} catch (IOException e) {
339
+			e.printStackTrace();
340
+		} finally {
341
+			// 关闭资源
342
+			if (null != br) {
343
+				try {
344
+					br.close();
345
+				} catch (IOException e) {
346
+					e.printStackTrace();
347
+				}
348
+			}
349
+			if (null != out) {
350
+				try {
351
+					out.close();
352
+				} catch (IOException e) {
353
+					e.printStackTrace();
354
+				}
355
+			}
356
+			if (null != is) {
357
+				try {
358
+					is.close();
359
+				} catch (IOException e) {
360
+					e.printStackTrace();
361
+				}
362
+			}
363
+			// 断开与远程地址url的连接
364
+			connection.disconnect();
365
+		}
366
+		return result;
367
+	}
368
+	public static void main(String[] args) {
369
+		String re=readResponse("www.baidu.com","","get","UTF-8");
370
+		System.out.println(re);
371
+	}
372
+}

+ 20 - 0
src/main/java/com/dashitech/utils/I18n.java

@@ -0,0 +1,20 @@
1
+package com.dashitech.utils;
2
+
3
+import java.lang.annotation.Documented;
4
+import java.lang.annotation.Retention;
5
+import java.lang.annotation.Target;
6
+
7
+import static java.lang.annotation.ElementType.FIELD;
8
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
9
+/**
10
+ * Created by chi on 2019/9/10.
11
+ * 实体说明注解
12
+ */
13
+
14
+
15
+@Target(FIELD)
16
+@Retention(RUNTIME)
17
+@Documented
18
+public @interface I18n {
19
+    String value();
20
+}

+ 120 - 0
src/main/java/com/dashitech/utils/JsonParam.java

@@ -0,0 +1,120 @@
1
+package com.dashitech.utils;
2
+
3
+import net.sf.json.JSONArray;
4
+import net.sf.json.JSONObject;
5
+
6
+import java.io.Serializable;
7
+import java.util.ArrayList;
8
+import java.util.List;
9
+import java.util.Map;
10
+
11
+
12
+public class JsonParam implements Serializable {
13
+
14
+	private static final long serialVersionUID = -4882852696761401880L;
15
+
16
+	private Integer total;
17
+
18
+	private Integer pageIndex = 1;
19
+
20
+	private Integer pageSize = 20;
21
+
22
+	private Integer totalPage = 0;
23
+
24
+	/**
25
+	 * 实体bean
26
+	 */
27
+	private Map<String, Object> model;
28
+	/**
29
+	 * 实体bean列表
30
+	 */
31
+	private List<Map<String,Object>> list;
32
+	/**
33
+	 * 其他参数
34
+	 */
35
+	private Map<String, Object> param;
36
+	
37
+	
38
+	
39
+	public Integer getTotal() {
40
+		return total;
41
+	}
42
+
43
+	public void setTotal(Integer total) {
44
+		this.total = total;
45
+	}
46
+
47
+	public Integer getPageIndex() {
48
+		return pageIndex;
49
+	}
50
+
51
+	public void setPageIndex(Integer pageIndex) {
52
+		this.pageIndex = pageIndex;
53
+	}
54
+
55
+	public Integer getPageSize() {
56
+		return pageSize;
57
+	}
58
+
59
+	public void setPageSize(Integer pageSize) {
60
+		this.pageSize = pageSize;
61
+	}
62
+
63
+	public Integer getTotalPage() {
64
+		return totalPage;
65
+	}
66
+
67
+	public void setTotalPage(Integer totalPage) {
68
+		this.totalPage = totalPage;
69
+	}
70
+
71
+	public Map<String, Object> getModel() {
72
+		return model;
73
+	}
74
+
75
+	public void setModel(Map<String, Object> model) {
76
+		this.model = model;
77
+	}
78
+
79
+	public Map<String, Object> getParam() {
80
+		return param;
81
+	}
82
+
83
+	public void setParam(Map<String, Object> param) {
84
+		this.param = param;
85
+	}
86
+	
87
+	public List<Map<String, Object>> getList() {
88
+		return list;
89
+	}
90
+
91
+	public void setList(List<Map<String, Object>> list) {
92
+		this.list = list;
93
+	}
94
+
95
+	@SuppressWarnings({ "rawtypes", "unchecked" })
96
+	public <T> T getModelBean(Class clazz) {
97
+		JSONObject jsonObj = JsonUtil.toJSONObject(getModel());
98
+		Object temp = JsonUtil.toObject(jsonObj.toString(), clazz);
99
+		if(temp != null) {
100
+			return (T)temp;
101
+		}
102
+		return null;
103
+	}
104
+	
105
+	@SuppressWarnings({ "rawtypes", "unchecked" })
106
+	public <T> List<T> getModelListBean(Class clazz) {
107
+		JSONArray jsonArr = JsonUtil.toJSONArray(getList());
108
+		List<T> temp = JsonUtil.toList2(jsonArr.toString(), clazz);
109
+		if(temp != null) {
110
+			return temp;
111
+		}
112
+		return new ArrayList<T>();
113
+	}
114
+
115
+	@Override
116
+	public String toString() {
117
+		return "JsonParamBean [total=" + total + ", pageIndex=" + pageIndex + ", pageSize=" + pageSize + ", totalPage=" + totalPage + ", model=" + model + ", list=" + list + ", param=" + param + "]";
118
+	}
119
+
120
+}

+ 100 - 0
src/main/java/com/dashitech/utils/JsonResponse.java

@@ -0,0 +1,100 @@
1
+package com.dashitech.utils;
2
+
3
+import java.io.Serializable;
4
+
5
+
6
+import net.sf.json.JSONObject;
7
+
8
+public class JsonResponse implements Serializable{
9
+	private static final long serialVersionUID = 2275655193720587417L;
10
+	
11
+	/**
12
+	 * 消息
13
+	 */
14
+	private String msg;
15
+	/**
16
+	 * 状态
17
+	 */
18
+	private Integer status;
19
+	/**
20
+	 * 数据
21
+	 */
22
+	private Object data;
23
+	
24
+	public String getMsg() {
25
+		return msg;
26
+	}
27
+
28
+	public void setMsg(String msg) {
29
+		this.msg = msg;
30
+	}
31
+
32
+	public Integer getStatus() {
33
+		return status;
34
+	}
35
+
36
+	public void setStatus(Integer status) {
37
+		this.status = status;
38
+	}
39
+
40
+	public Object getData() {
41
+		return data;
42
+	}
43
+
44
+	public void setData(Object data) {
45
+		this.data = data;
46
+	}
47
+
48
+	public JsonResponse() {
49
+		
50
+	}
51
+	
52
+	public JsonResponse(String msg, Integer status, Object data) {
53
+		super();
54
+		this.msg = msg;
55
+		this.status = status;
56
+		this.data = data;
57
+	}
58
+	
59
+	public static JsonResponse success(Object data) {
60
+		JsonResponse bean = new JsonResponse();
61
+		bean.setData(data);
62
+		bean.setMsg("成功!");
63
+		bean.setStatus(200);
64
+		return bean;
65
+	}
66
+	
67
+	public static JsonResponse error(String msg) {
68
+		JsonResponse bean = new JsonResponse();
69
+		bean.setMsg("服务出错!");
70
+		bean.setStatus(500);
71
+		return bean;
72
+	}
73
+	
74
+	public static JsonResponse forbidden() {
75
+		JsonResponse bean = new JsonResponse();
76
+		bean.setMsg("没有权限!");
77
+		bean.setStatus(403);
78
+		return bean;
79
+	}
80
+	
81
+	public static JsonResponse forbidden(String msg) {
82
+		JsonResponse bean = new JsonResponse();
83
+		bean.setMsg(msg);
84
+		bean.setStatus(403);
85
+		return bean;
86
+	}
87
+
88
+	@Override
89
+	public String toString() {
90
+		try {
91
+			JSONObject json = JsonUtil.toJSONObject(this);
92
+			return json.toString();
93
+		} catch (Exception e) {
94
+			e.printStackTrace();
95
+		}
96
+		return error("json转换错误!").toString();
97
+	}
98
+	
99
+	
100
+}

+ 163 - 0
src/main/java/com/dashitech/utils/JsonUtil.java

@@ -0,0 +1,163 @@
1
+package com.dashitech.utils;
2
+
3
+import com.fasterxml.jackson.databind.DeserializationFeature;
4
+import com.fasterxml.jackson.databind.JavaType;
5
+import com.fasterxml.jackson.databind.SerializationFeature;
6
+import net.sf.json.JSONArray;
7
+import net.sf.json.JSONObject;
8
+import net.sf.json.JsonConfig;
9
+import net.sf.json.processors.JsonValueProcessor;
10
+import net.sf.json.util.CycleDetectionStrategy;
11
+
12
+import java.util.ArrayList;
13
+import java.util.Date;
14
+import java.util.List;
15
+import java.util.Map;
16
+
17
+
18
+public class JsonUtil {
19
+
20
+    public static JSONObject toJSONObject(Object obj) {
21
+        return JSONObject.fromObject(obj, getJsonConfig());
22
+    }
23
+
24
+    public static String toJsonString(Object obj) {
25
+        com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
26
+        mapper.setDateFormat(DateUtil.SDF_DATETIME);
27
+        mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
28
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
29
+        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
30
+        try {
31
+            return mapper.writeValueAsString(obj);
32
+        } catch (Exception e) {
33
+            e.printStackTrace();
34
+        }
35
+        return "";
36
+    }
37
+
38
+    public static JSONArray toJSONArray(Object obj) {
39
+        return JSONArray.fromObject(obj, getJsonConfig());
40
+    }
41
+
42
+    public static <T> List<T> toList(Object obj, Class<T> clazz) {
43
+        JSONArray arr = toJSONArray(obj);
44
+        @SuppressWarnings({"unchecked", "deprecation"}) List<T> list = JSONArray.toList(arr, clazz);
45
+        return list;
46
+    }
47
+
48
+    public static <T> List<T> toList(Object obj, Class<T> clazz, Map classMap) {
49
+        JSONArray arr = toJSONArray(obj);
50
+        @SuppressWarnings({"unchecked", "deprecation"}) List<T> list = JSONArray.toList(arr, clazz, classMap);
51
+        return list;
52
+    }
53
+
54
+    /**
55
+     * 会格式化日期为yyyy-MM-dd HH:mm:ss
56
+     */
57
+    @SuppressWarnings({"deprecation"})
58
+    public static <T> List<T> toList2(String json, Class<T> clazz) {
59
+        try {
60
+            com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
61
+            mapper.setDateFormat(DateUtil.SDF_DATETIME);
62
+            mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
63
+            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
64
+
65
+            JavaType javaType = mapper.getTypeFactory().constructParametricType(ArrayList.class, clazz);
66
+            List<T> result = mapper.readValue(json, javaType);
67
+            return result;
68
+        } catch (Exception e) {
69
+            e.printStackTrace();
70
+        }
71
+        return null;
72
+    }
73
+
74
+    /**
75
+     * 2016-03-01 00:00:00 替换为 2016-03-01 <br/>
76
+     * 如果报错返回原始数据
77
+     */
78
+    public static JSONObject replaceDateTime(JSONObject source) {
79
+        JSONObject result = source;
80
+        try {
81
+            String ss = source.toString();
82
+            String formatJson = ss.replaceAll(" \\d{2}:\\d{2}:\\d{2}", "");
83
+            result = JSONObject.fromObject(formatJson);
84
+        } catch (Exception e) {
85
+        }
86
+        return result;
87
+    }
88
+
89
+
90
+    public static <T> T toObject(String json, Class<T> valueType) {
91
+        com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
92
+        mapper.setDateFormat(DateUtil.SDF_DATETIME);
93
+        mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
94
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
95
+        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
96
+
97
+        try {
98
+            return mapper.readValue(json, valueType);
99
+        } catch (Exception e) {
100
+            e.printStackTrace();
101
+        }
102
+        return null;
103
+    }
104
+
105
+    public static <T> List<T> toListObject(String json, Class<T> valueType) {
106
+        com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
107
+        mapper.setDateFormat(DateUtil.SDF_DATETIME);
108
+        mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
109
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
110
+        mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
111
+
112
+        try {
113
+            List<T> result = new ArrayList<>();
114
+            List<Map> list = mapper.readValue(json, ArrayList.class);
115
+            for (Map map : list) {
116
+                T t = toObject(toJSONObject(map).toString(), valueType);
117
+                result.add(t);
118
+            }
119
+            return result;
120
+        } catch (Exception e) {
121
+            e.printStackTrace();
122
+        }
123
+        return null;
124
+    }
125
+
126
+    public static JsonConfig getJsonConfig() {
127
+        JsonConfig config = new JsonConfig();
128
+        //去掉class
129
+        config.setIgnoreDefaultExcludes(false);
130
+        //禁止自包含
131
+        config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
132
+        //处理日期转换
133
+        config.registerJsonValueProcessor(Date.class, new Date_JsonValueProcessor());
134
+        return config;
135
+    }
136
+
137
+}
138
+
139
+class Date_JsonValueProcessor implements JsonValueProcessor {
140
+
141
+    public Object processArrayValue(Object value, JsonConfig config) {
142
+        return process(value, config);
143
+    }
144
+
145
+    public Object processObjectValue(String key, Object value, JsonConfig config) {
146
+        return process(value, config);
147
+    }
148
+
149
+    ;
150
+
151
+    private Object process(Object value, JsonConfig config) {
152
+        if (value == null) {
153
+            return "";
154
+        }
155
+        if (value instanceof Date) {
156
+            String date = DateUtil.SDF_DATETIME.format((Date) value);
157
+            return date;
158
+        } else {
159
+            return value == null ? null : value.toString();
160
+        }
161
+    }
162
+
163
+}

+ 17 - 0
src/main/java/com/dashitech/utils/MyObjectMapper.java

@@ -0,0 +1,17 @@
1
+package com.dashitech.utils;
2
+
3
+import com.fasterxml.jackson.databind.ObjectMapper;
4
+import com.fasterxml.jackson.databind.SerializationFeature;
5
+
6
+
7
+
8
+public class MyObjectMapper extends ObjectMapper{
9
+	
10
+	private static final long serialVersionUID = 1L;
11
+
12
+	public MyObjectMapper() {
13
+		this.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
14
+		this.setDateFormat(new MyObjectMapperDateFormat());
15
+	}
16
+
17
+}

+ 119 - 0
src/main/java/com/dashitech/utils/MyObjectMapperDateFormat.java

@@ -0,0 +1,119 @@
1
+package com.dashitech.utils;
2
+
3
+import java.text.FieldPosition;
4
+import java.text.ParseException;
5
+import java.text.SimpleDateFormat;
6
+import java.util.Date;
7
+
8
+import org.apache.commons.lang.StringUtils;
9
+
10
+public class MyObjectMapperDateFormat extends SimpleDateFormat{
11
+	private static final long serialVersionUID = 1L;
12
+	public static final String Y_M_D = "yyyy-MM-dd";  
13
+    public static final String Y_M_D_HM = "yyyy-MM-dd HH:mm";  
14
+    public static final String Y_M_D_HMS = "yyyy-MM-dd HH:mm:ss";  
15
+    public static final String YMD = "yyyyMMdd";  
16
+    public static final String YMDHM = "yyyyMMddHHmm";  
17
+    public static final String YMDHMS = "yyyyMMddHHmmss";  
18
+    public static final String ymd = "yyyy/MM/dd";  
19
+    public static final String ymd_HM = "yyyy/MM/dd HH:mm";  
20
+    public static final String ymd_HMS = "yyyy/MM/dd HH:mm:ss";  
21
+	
22
+	@Override  
23
+    public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos) {  
24
+        return new StringBuffer(smartFormat(date));  
25
+    }  
26
+  
27
+    @Override  
28
+    public Date parse(String text) throws ParseException {  
29
+        return smartFormat(text);  
30
+    }  
31
+    
32
+    public static String smartFormat(Date date) {  
33
+        String dateStr = null;  
34
+        if (date == null) {  
35
+            dateStr = "";  
36
+        } else {  
37
+            try {  
38
+                dateStr = formatDate(date, Y_M_D_HMS);  
39
+                //时分秒  
40
+                if (dateStr.endsWith(" 00:00:00")) {  
41
+                    dateStr = dateStr.substring(0, 10);  
42
+                }  
43
+                //时分  
44
+                else if (dateStr.endsWith("00:00")) {  
45
+                    dateStr = dateStr.substring(0, 16);  
46
+                }  
47
+                //秒  
48
+                else if (dateStr.endsWith(":00")) {  
49
+                    dateStr = dateStr.substring(0, 16);  
50
+                }  
51
+            } catch (Exception ex) {  
52
+                throw new IllegalArgumentException("转换日期失败: " + ex.getMessage(), ex);  
53
+            }  
54
+        }  
55
+        return dateStr;  
56
+    }  
57
+  
58
+    /** 
59
+     * 智能转换日期 
60
+     * 
61
+     * @param text 
62
+     * @return 
63
+     */  
64
+    public static Date smartFormat(String text) {  
65
+        Date date = null;  
66
+        try {  
67
+            if (text == null || text.length() == 0) {  
68
+                date = null;  
69
+            } else if (text.length() == 10) {  
70
+                date = formatStringToDate(text, Y_M_D);  
71
+            } else if (text.length() == 13) {  
72
+                date = new Date(Long.parseLong(text));  
73
+            } else if (text.length() == 16) {  
74
+                date = formatStringToDate(text, Y_M_D_HM);  
75
+            } else if (text.length() == 19) {  
76
+                date = formatStringToDate(text, Y_M_D_HMS);  
77
+            } else {  
78
+                throw new IllegalArgumentException("日期长度不符合要求!");  
79
+            }  
80
+        } catch (Exception e) {  
81
+            throw new IllegalArgumentException("日期转换失败!");  
82
+        }  
83
+        return date;  
84
+    }  
85
+    
86
+    public static String formatDate(Date argDate, String argFormat) throws Exception {  
87
+        if (argDate == null) {  
88
+            throw new Exception("参数[日期]不能为空!");  
89
+        }  
90
+        if (StringUtils.isEmpty(argFormat)) {  
91
+            argFormat = Y_M_D;  
92
+        }  
93
+        SimpleDateFormat sdfFrom = new SimpleDateFormat(argFormat);  
94
+        return sdfFrom.format(argDate).toString();  
95
+    }  
96
+  
97
+    public static Date formatStringToDate(String argDateStr, String argFormat) throws Exception {  
98
+        if (argDateStr == null || argDateStr.trim().length() < 1) {  
99
+            throw new Exception("参数[日期]不能为空!");  
100
+        }  
101
+        String strFormat = argFormat;  
102
+        if (StringUtils.isEmpty(strFormat)) {  
103
+            strFormat = Y_M_D;  
104
+            if (argDateStr.length() > 16) {  
105
+                strFormat = Y_M_D_HMS;  
106
+            } else if (argDateStr.length() > 10) {  
107
+                strFormat = Y_M_D_HM;  
108
+            }  
109
+        }  
110
+        SimpleDateFormat sdfFormat = new SimpleDateFormat(strFormat);  
111
+        //严格模式  
112
+        sdfFormat.setLenient(false);  
113
+        try {  
114
+            return sdfFormat.parse(argDateStr);  
115
+        } catch (ParseException e) {  
116
+            throw new Exception(e);  
117
+        }  
118
+    } 
119
+}

+ 18 - 0
src/main/java/com/dashitech/utils/MyX509TrustManager.java

@@ -0,0 +1,18 @@
1
+package com.dashitech.utils;
2
+
3
+import javax.net.ssl.X509TrustManager;
4
+import java.security.cert.CertificateException;
5
+import java.security.cert.X509Certificate;
6
+
7
+public class MyX509TrustManager implements X509TrustManager {
8
+	  
9
+    public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
10
+    }  
11
+  
12
+    public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
13
+    }  
14
+  
15
+    public X509Certificate[] getAcceptedIssuers() {
16
+        return null;  
17
+    }  
18
+}  

+ 506 - 0
src/main/java/com/dashitech/utils/PropertiesHelper.java

@@ -0,0 +1,506 @@
1
+package com.dashitech.utils;
2
+
3
+import java.io.ByteArrayInputStream;
4
+import java.io.IOException;
5
+import java.io.InputStream;
6
+import java.io.OutputStream;
7
+import java.io.PrintStream;
8
+import java.io.PrintWriter;
9
+import java.net.MalformedURLException;
10
+import java.net.URL;
11
+import java.util.Collection;
12
+import java.util.Enumeration;
13
+import java.util.InvalidPropertiesFormatException;
14
+import java.util.Map;
15
+import java.util.Properties;
16
+import java.util.Set;
17
+import java.util.Map.Entry;
18
+
19
+/**
20
+ * Properties的操作的工具类,为Properties提供一个代理增加相关工具方法如
21
+ * getRequiredString(),getInt(),getBoolean()等方法
22
+ * 并可以通过systemPropertiesMode属性指定是否搜索System.getProperty()及System.getenv()来查找值.
23
+ * 默认不搜索系统属性
24
+ * 
25
+ * <pre>
26
+ * 使用1:
27
+ * public class ConnectionUtils {
28
+ *     static Properties properties = new Properties(); 
29
+ *     // ... do load properties 
30
+ *     
31
+ *     // delegate to properties
32
+ * 	   static PropertiesHelper props = new PropertiesHelper(properties);
33
+ *     public static Connection getConnection() {
34
+ *     		// use getRequiredProperty() 
35
+ *     		DriverManager.getConnection(props.getRequiredString("jdbc.url"));
36
+ *     }
37
+ * }
38
+ * 指定是否搜索系统属性:
39
+ * new PropertiesHelper(properties,PropertiesHelper.SYSTEM_PROPERTIES_MODE_OVERRIDE)
40
+ * </pre>
41
+ * 
42
+ * @author badqiu
43
+ */
44
+public class PropertiesHelper {
45
+	/**
46
+	 * 不使用系统属性,这个是默认值
47
+	 **/
48
+	public static final int SYSTEM_PROPERTIES_MODE_NEVER = 0;
49
+
50
+	/**
51
+	 * 如果在properties中没有找到属性值,则查找系统属性
52
+	 */
53
+	public static final int SYSTEM_PROPERTIES_MODE_FALLBACK = 1;
54
+
55
+	/**
56
+	 * 首先查找系统属性,如果没有找到值,再查找properties,这可以用于系统属性覆盖properties中的值
57
+	 */
58
+	public static final int SYSTEM_PROPERTIES_MODE_OVERRIDE = 2;
59
+
60
+	private int systemPropertiesMode = SYSTEM_PROPERTIES_MODE_NEVER;
61
+
62
+	private Properties p;
63
+
64
+	public PropertiesHelper(Properties p) {
65
+		setProperties(p);
66
+	}
67
+
68
+	public PropertiesHelper(Properties p, int systemPropertiesMode) {
69
+		setProperties(p);
70
+		if (systemPropertiesMode != SYSTEM_PROPERTIES_MODE_NEVER && systemPropertiesMode != SYSTEM_PROPERTIES_MODE_FALLBACK
71
+				&& systemPropertiesMode != SYSTEM_PROPERTIES_MODE_OVERRIDE) {
72
+			throw new IllegalArgumentException("error systemPropertiesMode mode:" + systemPropertiesMode);
73
+		}
74
+		this.systemPropertiesMode = systemPropertiesMode;
75
+	}
76
+
77
+	public Properties getProperties() {
78
+		return p;
79
+	}
80
+
81
+	public void setProperties(Properties props) {
82
+		if (props == null)
83
+			throw new IllegalArgumentException("properties must be not null");
84
+		this.p = props;
85
+	}
86
+
87
+	/**
88
+	 * 必须存在这个key的值,不然抛 IllegalStateException异常
89
+	 **/
90
+	public String getRequiredProperty(String key) throws IllegalStateException {
91
+		String value = getProperty(key);
92
+		if (isBlankString(value)) {
93
+			throw new IllegalStateException("required property is blank by key=" + key);
94
+		}
95
+		return value;
96
+	}
97
+
98
+	/**
99
+	 * 返回null,如果查值的属性值是blank
100
+	 * 
101
+	 * @param key
102
+	 * @return
103
+	 */
104
+	public String getNullIfBlank(String key) {
105
+		String value = getProperty(key);
106
+		if (isBlankString(value)) {
107
+			return null;
108
+		}
109
+		return value;
110
+	}
111
+
112
+	/**
113
+	 * 返回null,如果查值的属性值是empty
114
+	 * 
115
+	 * @param key
116
+	 * @return
117
+	 */
118
+	public String getNullIfEmpty(String key) {
119
+		String value = getProperty(key);
120
+		if (value == null || "".equals(value)) {
121
+			return null;
122
+		}
123
+		return value;
124
+	}
125
+
126
+	/**
127
+	 * 尝试从System.getProperty(key)及System.getenv(key)得到值
128
+	 * 
129
+	 * @return
130
+	 */
131
+	public String getAndTryFromSystem(String key) {
132
+		String value = getProperty(key);
133
+		if (isBlankString(value)) {
134
+			value = getSystemProperty(key);
135
+		}
136
+		return value;
137
+	}
138
+
139
+	private String getSystemProperty(String key) {
140
+		String value;
141
+		value = System.getProperty(key);
142
+		if (isBlankString(value)) {
143
+			value = System.getenv(key);
144
+		}
145
+		return value;
146
+	}
147
+
148
+	public Integer getInteger(String key) {
149
+		String value = getProperty(key);
150
+		if (isBlankString(value)) {
151
+			return null;
152
+		}
153
+		return Integer.parseInt(value);
154
+	}
155
+
156
+	public int getInt(String key, int defaultValue) {
157
+		String value = getProperty(key);
158
+		if (isBlankString(value)) {
159
+			return defaultValue;
160
+		}
161
+		return Integer.parseInt(value);
162
+	}
163
+
164
+	/**
165
+	 * 必须存在这个key的值,不然抛 IllegalStateException异常
166
+	 **/
167
+	public int getRequiredInt(String key) throws IllegalStateException {
168
+		return Integer.parseInt(getRequiredProperty(key));
169
+	}
170
+
171
+	public Long getLong(String key) {
172
+		String value = getProperty(key);
173
+		if (isBlankString(value)) {
174
+			return null;
175
+		}
176
+		return Long.parseLong(value);
177
+	}
178
+
179
+	public long getLong(String key, long defaultValue) {
180
+		String value = getProperty(key);
181
+		if (isBlankString(value)) {
182
+			return defaultValue;
183
+		}
184
+		return Long.parseLong(value);
185
+	}
186
+
187
+	/**
188
+	 * 必须存在这个key的值,不然抛 IllegalStateException异常
189
+	 **/
190
+	public long getRequiredLong(String key) throws IllegalStateException {
191
+		return Long.parseLong(getRequiredProperty(key));
192
+	}
193
+
194
+	public Boolean getBoolean(String key) {
195
+		String value = getProperty(key);
196
+		if (isBlankString(value)) {
197
+			return null;
198
+		}
199
+		return Boolean.parseBoolean(value);
200
+	}
201
+
202
+	public boolean getBoolean(String key, boolean defaultValue) {
203
+		String value = getProperty(key);
204
+		if (isBlankString(value)) {
205
+			return defaultValue;
206
+		}
207
+		return Boolean.parseBoolean(value);
208
+	}
209
+
210
+	/**
211
+	 * 必须存在这个key的值,不然抛 IllegalStateException异常
212
+	 **/
213
+	public boolean getRequiredBoolean(String key) throws IllegalStateException {
214
+		return Boolean.parseBoolean(getRequiredProperty(key));
215
+	}
216
+
217
+	public Float getFloat(String key) {
218
+		String value = getProperty(key);
219
+		if (isBlankString(value)) {
220
+			return null;
221
+		}
222
+		return Float.parseFloat(value);
223
+	}
224
+
225
+	public float getFloat(String key, float defaultValue) {
226
+		String value = getProperty(key);
227
+		if (isBlankString(value)) {
228
+			return defaultValue;
229
+		}
230
+		return Float.parseFloat(value);
231
+	}
232
+
233
+	/**
234
+	 * 必须存在这个key的值,不然抛 IllegalStateException异常
235
+	 **/
236
+	public float getRequiredFloat(String key) throws IllegalStateException {
237
+		return Float.parseFloat(getRequiredProperty(key));
238
+	}
239
+
240
+	public Double getDouble(String key) {
241
+		String value = getProperty(key);
242
+		if (isBlankString(value)) {
243
+			return null;
244
+		}
245
+		return Double.parseDouble(value);
246
+	}
247
+
248
+	public double getDouble(String key, double defaultValue) {
249
+		String value = getProperty(key);
250
+		if (isBlankString(value)) {
251
+			return defaultValue;
252
+		}
253
+		return Double.parseDouble(value);
254
+	}
255
+
256
+	/**
257
+	 * 必须存在这个key的值,不然抛 IllegalStateException异常
258
+	 **/
259
+	public double getRequiredDouble(String key) throws IllegalStateException {
260
+		return Double.parseDouble(getRequiredProperty(key));
261
+	}
262
+
263
+	public URL getURL(String key) throws IllegalArgumentException {
264
+		try {
265
+			return new URL(getProperty(key));
266
+		} catch (MalformedURLException e) {
267
+			throw new IllegalArgumentException("Property " + key + " must be a valid URL (" + getProperty(key) + ")");
268
+		}
269
+	}
270
+
271
+	public Object getClassInstance(String key) throws IllegalArgumentException {
272
+		String s = (String) getProperty(key);
273
+		if (s == null || "".equals(s.trim())) {
274
+			throw new IllegalArgumentException("Property " + key + " must be a valid classname  : " + key);
275
+		}
276
+		try {
277
+			return Class.forName(s).newInstance();
278
+		} catch (ClassNotFoundException nfe) {
279
+			throw new IllegalArgumentException(s + ": invalid class name for key " + key, nfe);
280
+		} catch (InstantiationException e) {
281
+			throw new IllegalArgumentException(s + ": class could not be reflected " + s, e);
282
+		} catch (IllegalAccessException e) {
283
+			throw new IllegalArgumentException(s + ": class could not be reflected " + s, e);
284
+		}
285
+	}
286
+
287
+	public Object getClassInstance(String key, Object defaultinstance) throws IllegalArgumentException {
288
+		return (containsKey(key) ? getClassInstance(key) : defaultinstance);
289
+	}
290
+
291
+	/**
292
+	 * 将一个property按"逗号,空格,换行符"分隔,并返回一个String[]数组
293
+	 **/
294
+	public String[] getStringArray(String key) {
295
+		String v = getProperty(key);
296
+		if (v == null) {
297
+			return new String[0];
298
+		} else {
299
+			return org.springframework.util.StringUtils.tokenizeToStringArray(v, ", \t\n\r\f");
300
+		}
301
+	}
302
+
303
+	/**
304
+	 * 将一个property按"逗号,空格,换行符"分隔,并返回一个int[]数组
305
+	 **/
306
+	public int[] getIntArray(String key) {
307
+		return toIntArray(getStringArray(key));
308
+	}
309
+
310
+	/**
311
+	 * 得到以某个前缀开始的所有属性,返回的属性值为移除前缀后的属性值.
312
+	 * 
313
+	 * @param prefix
314
+	 * @return
315
+	 */
316
+	public Properties getStartsWithProperties(String prefix) {
317
+		if (prefix == null)
318
+			throw new IllegalArgumentException("'prefix' must be not null");
319
+
320
+		Properties props = getProperties();
321
+
322
+		Properties result = new Properties();
323
+		for (Entry<Object, Object> entry : props.entrySet()) {
324
+			String key = (String) entry.getKey();
325
+			if (key != null && key.startsWith(prefix)) {
326
+				result.put(key.substring(prefix.length()), entry.getValue());
327
+			}
328
+		}
329
+		return result;
330
+	}
331
+
332
+	/** setProperty(String key,int value) ... start */
333
+
334
+	public Object setProperty(String key, int value) {
335
+		return setProperty(key, String.valueOf(value));
336
+	}
337
+
338
+	public Object setProperty(String key, long value) {
339
+		return setProperty(key, String.valueOf(value));
340
+	}
341
+
342
+	public Object setProperty(String key, float value) {
343
+		return setProperty(key, String.valueOf(value));
344
+	}
345
+
346
+	public Object setProperty(String key, double value) {
347
+		return setProperty(key, String.valueOf(value));
348
+	}
349
+
350
+	public Object setProperty(String key, boolean value) {
351
+		return setProperty(key, String.valueOf(value));
352
+	}
353
+
354
+	/** delegate method start */
355
+
356
+	public String getProperty(String key, String defaultValue) {
357
+		String value = getProperty(key);
358
+		if (isBlankString(value)) {
359
+			return defaultValue;
360
+		}
361
+		return value;
362
+	}
363
+
364
+	public String getProperty(String key) {
365
+		String propVal = null;
366
+		if (systemPropertiesMode == SYSTEM_PROPERTIES_MODE_OVERRIDE) {
367
+			propVal = getSystemProperty(key);
368
+		}
369
+		if (propVal == null) {
370
+			propVal = p.getProperty(key);
371
+		}
372
+		if (propVal == null && systemPropertiesMode == SYSTEM_PROPERTIES_MODE_FALLBACK) {
373
+			propVal = getSystemProperty(key);
374
+		}
375
+		return propVal == null ? null : propVal.trim();
376
+	}
377
+
378
+	public Object setProperty(String key, String value) {
379
+		return p.setProperty(key, value);
380
+	}
381
+
382
+	public void clear() {
383
+		p.clear();
384
+	}
385
+
386
+	public Set<Entry<Object, Object>> entrySet() {
387
+		return p.entrySet();
388
+	}
389
+
390
+	public Enumeration<?> propertyNames() {
391
+		return p.propertyNames();
392
+	}
393
+
394
+	public boolean contains(Object value) {
395
+		return p.contains(value);
396
+	}
397
+
398
+	public boolean containsKey(Object key) {
399
+		return p.containsKey(key);
400
+	}
401
+
402
+	public boolean containsValue(Object value) {
403
+		return p.containsValue(value);
404
+	}
405
+
406
+	public Enumeration<Object> elements() {
407
+		return p.elements();
408
+	}
409
+
410
+	public Object get(Object key) {
411
+		return p.get(key);
412
+	}
413
+
414
+	public boolean isEmpty() {
415
+		return p.isEmpty();
416
+	}
417
+
418
+	public Enumeration<Object> keys() {
419
+		return p.keys();
420
+	}
421
+
422
+	public Set<Object> keySet() {
423
+		return p.keySet();
424
+	}
425
+
426
+	public void list(PrintStream out) {
427
+		p.list(out);
428
+	}
429
+
430
+	public void list(PrintWriter out) {
431
+		p.list(out);
432
+	}
433
+
434
+	public void load(InputStream inStream) throws IOException {
435
+		p.load(inStream);
436
+	}
437
+
438
+	public void loadFromXML(InputStream in) throws IOException, InvalidPropertiesFormatException {
439
+		p.loadFromXML(in);
440
+	}
441
+
442
+	public Object put(Object key, Object value) {
443
+		return p.put(key, value);
444
+	}
445
+
446
+	public void putAll(Map<? extends Object, ? extends Object> t) {
447
+		p.putAll(t);
448
+	}
449
+
450
+	public Object remove(Object key) {
451
+		return p.remove(key);
452
+	}
453
+
454
+	/** @deprecated */
455
+	public void save(OutputStream out, String comments) {
456
+		p.save(out, comments);
457
+	}
458
+
459
+	public int size() {
460
+		return p.size();
461
+	}
462
+
463
+	public void store(OutputStream out, String comments) throws IOException {
464
+		p.store(out, comments);
465
+	}
466
+
467
+	public void storeToXML(OutputStream os, String comment, String encoding) throws IOException {
468
+		p.storeToXML(os, comment, encoding);
469
+	}
470
+
471
+	public void storeToXML(OutputStream os, String comment) throws IOException {
472
+		p.storeToXML(os, comment);
473
+	}
474
+
475
+	public Collection<Object> values() {
476
+		return p.values();
477
+	}
478
+
479
+	public String toString() {
480
+		return p.toString();
481
+	}
482
+
483
+	public static Properties restoreFromString(String str) {
484
+		if (str == null)
485
+			return new Properties();
486
+		Properties p = new Properties();
487
+		try {
488
+			p.load(new ByteArrayInputStream(str.getBytes()));
489
+		} catch (IOException e) {
490
+			throw new IllegalStateException("restore properties from String occer error. str:" + str, e);
491
+		}
492
+		return p;
493
+	}
494
+
495
+	private static boolean isBlankString(String value) {
496
+		return value == null || "".equals(value.trim());
497
+	}
498
+
499
+	private static int[] toIntArray(String[] array) {
500
+		int[] result = new int[array.length];
501
+		for (int i = 0; i < array.length; i++) {
502
+			result[i] = Integer.parseInt(array[i]);
503
+		}
504
+		return result;
505
+	}
506
+}

+ 179 - 0
src/main/java/com/dashitech/utils/PropertiesUtil.java

@@ -0,0 +1,179 @@
1
+package com.dashitech.utils;
2
+
3
+import org.apache.commons.logging.Log;
4
+import org.apache.commons.logging.LogFactory;
5
+import org.springframework.beans.factory.InitializingBean;
6
+import org.springframework.util.Assert;
7
+
8
+import java.net.URL;
9
+import java.util.HashMap;
10
+import java.util.Map;
11
+import java.util.Properties;
12
+
13
+/**
14
+ * 用于持有Properties,将Propereis变成静态方法使用.
15
+ */
16
+public class PropertiesUtil implements InitializingBean {
17
+	private static Log log = LogFactory.getLog(PropertiesUtil.class);
18
+
19
+	public static PropertiesHelper properies = null;
20
+
21
+	public void setProperties(Properties properies) {
22
+		Assert.isNull(PropertiesUtil.properies, "PropertiesUtil alreade hold properties");
23
+		PropertiesUtil.properies = new PropertiesHelper(properies);
24
+	}
25
+
26
+	// /**
27
+	// * 重新设置properties
28
+	// * @param properties
29
+	// */
30
+	// public void resetProperties(Properties properties) {
31
+	// clearHolder();
32
+	// new PropertiesUtil().setProperties(properties);
33
+	// }
34
+
35
+	/**
36
+	 * 清空 holder,只有清空Holder才可以重新设置 Properties
37
+	 */
38
+	public static void clearHolder() {
39
+		properies = null;
40
+	}
41
+
42
+	public static void setProperty(String key, String value) {
43
+		getRequiredHelper().setProperty(key, value);
44
+	}
45
+
46
+	/**
47
+	 * get readonly Properties
48
+	 **/
49
+	public static Properties getProperies() {
50
+		return (Properties) getRequiredHelper().getProperties().clone();
51
+	}
52
+
53
+	public static boolean getBoolean(String key, boolean defaultValue) {
54
+		return getRequiredHelper().getBoolean(key, defaultValue);
55
+	}
56
+
57
+	public static Boolean getBoolean(String key) {
58
+		return getRequiredHelper().getBoolean(key);
59
+	}
60
+
61
+	public static Object getClassInstance(String key, Object defaultinstance) throws IllegalArgumentException {
62
+		return getRequiredHelper().getClassInstance(key, defaultinstance);
63
+	}
64
+
65
+	public static Object getClassInstance(String key) throws IllegalArgumentException {
66
+		return getRequiredHelper().getClassInstance(key);
67
+	}
68
+
69
+	public static double getDouble(String key, double defaultValue) {
70
+		return getRequiredHelper().getDouble(key, defaultValue);
71
+	}
72
+
73
+	public static Double getDouble(String key) {
74
+		return getRequiredHelper().getDouble(key);
75
+	}
76
+
77
+	public static float getFloat(String key, float defaultValue) {
78
+		return getRequiredHelper().getFloat(key, defaultValue);
79
+	}
80
+
81
+	public static Float getFloat(String key) {
82
+		return getRequiredHelper().getFloat(key);
83
+	}
84
+
85
+	public static int getInt(String key, int defaultValue) {
86
+		return getRequiredHelper().getInt(key, defaultValue);
87
+	}
88
+
89
+	public static int[] getIntArray(String key) {
90
+		return getRequiredHelper().getIntArray(key);
91
+	}
92
+
93
+	public static Integer getInteger(String key) {
94
+		return getRequiredHelper().getInteger(key);
95
+	}
96
+
97
+	public static long getLong(String key, long defaultValue) {
98
+		return getRequiredHelper().getLong(key, defaultValue);
99
+	}
100
+
101
+	public static Long getLong(String key) {
102
+		return getRequiredHelper().getLong(key);
103
+	}
104
+
105
+	public static String getNullIfBlank(String key) {
106
+		return getRequiredHelper().getNullIfBlank(key);
107
+	}
108
+
109
+	public static String getNullIfEmpty(String key) {
110
+		return getRequiredHelper().getNullIfEmpty(key);
111
+	}
112
+
113
+	public static String getProperty(String key, String defaultValue) {
114
+		return getRequiredHelper().getProperty(key, defaultValue);
115
+	}
116
+
117
+	public static String getProperty(String key) {
118
+		return getRequiredHelper().getProperty(key);
119
+	}
120
+
121
+	public static boolean getRequiredBoolean(String key) throws IllegalStateException {
122
+		return getRequiredHelper().getRequiredBoolean(key);
123
+	}
124
+
125
+	public static double getRequiredDouble(String key) throws IllegalStateException {
126
+		return getRequiredHelper().getRequiredDouble(key);
127
+	}
128
+
129
+	public static float getRequiredFloat(String key) throws IllegalStateException {
130
+		return getRequiredHelper().getRequiredFloat(key);
131
+	}
132
+
133
+	public static int getRequiredInt(String key) throws IllegalStateException {
134
+		return getRequiredHelper().getRequiredInt(key);
135
+	}
136
+
137
+	public static long getRequiredLong(String key) throws IllegalStateException {
138
+		return getRequiredHelper().getRequiredLong(key);
139
+	}
140
+
141
+	public static String getRequiredProperty(String key) throws IllegalStateException {
142
+		return getRequiredHelper().getRequiredProperty(key);
143
+	}
144
+
145
+	public static Properties getStartsWithProperties(String prefix) {
146
+		return getRequiredHelper().getStartsWithProperties(prefix);
147
+	}
148
+
149
+	public static String[] getStringArray(String key) {
150
+		return getRequiredHelper().getStringArray(key);
151
+	}
152
+
153
+	public static URL getURL(String key) throws IllegalArgumentException {
154
+		return getRequiredHelper().getURL(key);
155
+	}
156
+
157
+	private static PropertiesHelper getRequiredHelper() {
158
+		assertHolderInited();
159
+		return properies;
160
+	}
161
+
162
+	private static void assertHolderInited() {
163
+		if (properies == null)
164
+			throw new IllegalStateException("PropertiesUtil.properties must be not null, PropertiesUtil not yet init.");
165
+	}
166
+
167
+	public void afterPropertiesSet() throws Exception {
168
+		assertHolderInited();
169
+		log.info("PropertiesUtil holded properties:" + getProperies());
170
+	}
171
+	
172
+	public static Map<String,String> getAsMap() {
173
+		Map<String,String> configs = new HashMap<String, String>();
174
+		for( Map.Entry<Object,Object> entry : properies.entrySet()) {
175
+			configs.put(entry.getKey().toString(), entry.getValue().toString());
176
+		}
177
+		return configs;
178
+	}
179
+}

+ 69 - 0
src/main/java/com/dashitech/utils/Sha1Util.java

@@ -0,0 +1,69 @@
1
+package com.dashitech.utils;
2
+
3
+
4
+import java.security.MessageDigest;
5
+import java.util.Formatter;
6
+import java.util.UUID;
7
+
8
+public class Sha1Util {
9
+
10
+    public static String getNonce() {
11
+        String uuid = UUID.randomUUID().toString();
12
+        return uuid;
13
+    }
14
+
15
+    public static String getTimestamp() {
16
+        return String.valueOf(System.currentTimeMillis() / 1000);
17
+    }
18
+
19
+
20
+    private static String byteToHex(final byte[] hash) {
21
+        Formatter formatter = new Formatter();
22
+        for (byte b : hash) {
23
+            formatter.format("%02x", b);
24
+        }
25
+        String result = formatter.toString();
26
+        formatter.close();
27
+        return result;
28
+    }
29
+
30
+    //SHA1
31
+    public static String sha1(String str) {
32
+        if (str == null || str.length() == 0) {
33
+            return null;
34
+        }
35
+        char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
36
+
37
+        try {
38
+            MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
39
+            mdTemp.update(str.getBytes("UTF-8"));
40
+
41
+            byte[] md = mdTemp.digest();
42
+            int j = md.length;
43
+            char buf[] = new char[j * 2];
44
+            int k = 0;
45
+            for (int i = 0; i < j; i++) {
46
+                byte byte0 = md[i];
47
+                buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
48
+                buf[k++] = hexDigits[byte0 & 0xf];
49
+            }
50
+            return new String(buf);
51
+        } catch (Exception e) {
52
+            return null;
53
+        }
54
+    }
55
+
56
+    //SHA-1
57
+    public static String sha_1(String str) {
58
+        try {
59
+            MessageDigest crypt = MessageDigest.getInstance("SHA-1");
60
+            crypt.reset();
61
+            crypt.update(str.getBytes("UTF-8"));
62
+            String signature = byteToHex(crypt.digest());
63
+            return signature;
64
+        } catch (Exception ex) {
65
+            ex.printStackTrace();
66
+        }
67
+        return null;
68
+    }
69
+}

+ 70 - 0
src/main/java/com/dashitech/utils/SpringContextHolder.java

@@ -0,0 +1,70 @@
1
+package com.dashitech.utils;
2
+
3
+import org.springframework.context.ApplicationContext;
4
+import org.springframework.context.ApplicationContextAware;
5
+import org.springframework.stereotype.Component;
6
+
7
+import java.lang.annotation.Annotation;
8
+import java.util.ArrayList;
9
+import java.util.List;
10
+import java.util.Map;
11
+
12
+/**
13
+ * 以静态变量保存Spring ApplicationContext, 可在任何地方getBean
14
+ */
15
+@Component
16
+public class SpringContextHolder implements ApplicationContextAware {
17
+    private static ApplicationContext applicationContext;
18
+
19
+    /**
20
+     * 实现ApplicationContextAware接口的context注入函数, 将其存入静态变量.
21
+     */
22
+    @Override
23
+    public void setApplicationContext(ApplicationContext applicationContext) {
24
+        SpringContextHolder.applicationContext = applicationContext; // NOSONAR
25
+    }
26
+
27
+    /**
28
+     * 取得存储在静态变量中的ApplicationContext.
29
+     */
30
+    public static ApplicationContext getApplicationContext() {
31
+        checkApplicationContext();
32
+        return applicationContext;
33
+    }
34
+
35
+    public static <T> T getBean(String name) {
36
+        return (T) getApplicationContext().getBean(name);
37
+    }
38
+
39
+    public static <T> T getBean(Class<T> clazz) {
40
+        return (T) getApplicationContext().getBeansOfType(clazz);
41
+    }
42
+
43
+    public static <T> T getBean(Class<T> beanType, Class<? extends Annotation> annotationType) {
44
+        if (annotationType == null) {
45
+            return getBean(beanType);
46
+        }
47
+        Map<String, T> results = getApplicationContext().getBeansOfType(beanType);
48
+        List<T> resultsWithAnnotation = new ArrayList<T>();
49
+        for (Map.Entry<String, T> entry : results.entrySet()) {
50
+            if (getApplicationContext().findAnnotationOnBean(entry.getKey(), annotationType) != null) {
51
+                resultsWithAnnotation.add(entry.getValue());
52
+            }
53
+        }
54
+        if (resultsWithAnnotation.isEmpty()) {
55
+            return null;
56
+        }
57
+        if (resultsWithAnnotation.size() == 1) {
58
+            return resultsWithAnnotation.get(0);
59
+        }
60
+        throw new IllegalStateException("参数错误!未获取到对应Bean");
61
+    }
62
+
63
+
64
+    private static void checkApplicationContext() {
65
+        if (applicationContext == null) {
66
+            throw new IllegalStateException("applicaitonContext未注入,请在applicationContext.xml中定义SpringContextHolder");
67
+        }
68
+    }
69
+
70
+}

+ 274 - 0
src/main/java/com/dashitech/utils/SystemCmdExecutor.java

@@ -0,0 +1,274 @@
1
+package com.dashitech.utils;
2
+
3
+import java.io.*;
4
+import java.util.Locale;
5
+import java.util.UUID;
6
+
7
+import org.apache.commons.logging.Log;
8
+import org.apache.commons.logging.LogFactory;
9
+
10
+/**
11
+ * 执行系统命令,并返回完成信息
12
+ */
13
+public class SystemCmdExecutor {
14
+	private static Log log = LogFactory.getLog(SystemCmdExecutor.class);
15
+
16
+	
17
+
18
+	/**
19
+	 * 根据传来的命令执行,返回命令执行完后的信息
20
+	 * 
21
+	 * @param command
22
+	 *            命令
23
+	 * @param fileRoot
24
+	 *            命令所在目录
25
+	 * @param charset
26
+	 *            返回流字符编码
27
+	 * @return 完成信息,根据结果处理报错
28
+	 * @throws IOException
29
+	 *             如果执行报错,需要抓取错误自主处理
30
+	 */
31
+	public static String execute(String command, String fileRoot, String charset) {
32
+		class ProcessStream extends Thread {
33
+			private InputStream is;
34
+			private String type;
35
+			private String charset;
36
+			private String info;
37
+			private String error;
38
+			ProcessStream(InputStream is, String type,String charset) {
39
+				this.is = is;
40
+				this.type = type;
41
+				this.charset = charset;
42
+			}
43
+			public void run() {
44
+				try {
45
+					InputStreamReader isr = new InputStreamReader(is, charset);
46
+					BufferedReader br = new BufferedReader(isr);
47
+					String line = null;
48
+					while ((line = br.readLine()) != null) {
49
+						if (type.equals("ERROR")) {
50
+							error += line;
51
+							log.error(line);
52
+						}else if (type.equals("INFO")) {
53
+							info += line;
54
+							log.info(line);
55
+						}
56
+					}
57
+					is.close();
58
+					isr.close();
59
+					br.close();
60
+				} catch (IOException ioe) {
61
+					ioe.printStackTrace();
62
+				}
63
+			}
64
+			public String getInfo() {
65
+				return info;
66
+			}
67
+			public String getError() {
68
+				return error;
69
+			}
70
+		}
71
+		
72
+		String result = "";
73
+		Runtime rt = Runtime.getRuntime();
74
+		Process p = null;
75
+		try {
76
+			if (fileRoot == null) {
77
+				p = rt.exec(command);
78
+			} else {
79
+				p = rt.exec(command, null, new File(fileRoot));
80
+			}
81
+			
82
+			
83
+
84
+			ProcessStream errorStream = new ProcessStream(p.getErrorStream(), "ERROR",charset);
85
+			ProcessStream infoStream = new ProcessStream(p.getInputStream(), "INFO",charset);
86
+			errorStream.start();
87
+			infoStream.start();
88
+
89
+			int code = p.waitFor();
90
+			//0 正常,其他错误
91
+			if(code == 0) {
92
+				result = infoStream.getInfo();
93
+			}else {
94
+				result = errorStream.getError();
95
+			}
96
+			
97
+		} catch (Exception e) {
98
+			e.printStackTrace();
99
+			throw new RuntimeException("执行系统命令错误!" + command + ";" + e.getMessage());
100
+		} finally {
101
+			try {
102
+				if (p != null) {
103
+					p.getOutputStream().close();
104
+					p.destroy();
105
+				}
106
+			} catch (IOException e) {
107
+				e.printStackTrace();
108
+			}
109
+		}
110
+		return result;
111
+	}
112
+
113
+	/**
114
+	 * 返回字符使用GBK,使用命令路径
115
+	 * 
116
+	 * @throws IOException
117
+	 */
118
+	public static String execute(String command, String fileRoot) {
119
+		return execute(command, fileRoot, "GBK");
120
+	}
121
+
122
+	/**
123
+	 * 返回字符使用GBK,使用系统命令不需要命令目录
124
+	 * 
125
+	 * @throws IOException
126
+	 */
127
+	public static String execute(String command) {
128
+		return execute(command, null, "GBK");
129
+	}
130
+
131
+	public static void main(String[] args) throws IOException {
132
+		String cmd = "D:/G/workbench/myeclipse9_workplace/11cms/src/";
133
+		String cmd2 = "nginnxReload.bat";
134
+		// String cmd = "D:/E/software/environment/nginx-1.8.0/";
135
+		// String cmd2 = "nginx.exe -s reload";
136
+		// String cmd =
137
+		// "D:/G/workbench/myeclipse9_workplace/11cms/src/nginnxReload.bat";
138
+		// String cmd2 = "";
139
+		// System.out.println(SystemCmdExecutor.execute(cmd + cmd2));
140
+		System.out.println(SystemCmdExecutor.execute(cmd + cmd2, cmd));
141
+
142
+	}
143
+
144
+	public static String executeLinuxCmd(String cmd) {
145
+		System.out.println("执行命令[ " + cmd + "]");
146
+		Runtime run = Runtime.getRuntime();
147
+		try {
148
+			Process process = run.exec(cmd);
149
+			String line;
150
+			BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
151
+			StringBuffer out = new StringBuffer();
152
+			while ((line = stdoutReader.readLine()) != null ) {
153
+				out.append(line);
154
+			}
155
+			try {
156
+				process.waitFor();
157
+			} catch (InterruptedException e) {
158
+				e.printStackTrace();
159
+			}
160
+			process.destroy();
161
+			return out.toString();
162
+		} catch (IOException e) {
163
+			e.printStackTrace();
164
+		}
165
+		return null;
166
+	}
167
+
168
+	/**
169
+	 * 修改系统时间
170
+	 * yyyy-MM-dd HH:mm:ss
171
+	 * @param dataStr_   2017-11-11   yyyy-MM-dd
172
+	 * @param timeStr_   11:11:11     HH:mm:ss
173
+	 */
174
+	public static void updateSysDateTime(String dataStr_,String timeStr_){
175
+		try {
176
+			String osName = System.getProperty("os.name");
177
+			// Window 系统
178
+			if (osName.matches("^(?i)Windows.*$")) {
179
+				String cmd;
180
+				// 格式:yyyy-MM-dd
181
+				cmd = " cmd /c date " + dataStr_;
182
+				Runtime.getRuntime().exec(cmd);
183
+				// 格式 HH:mm:ss
184
+				cmd = " cmd /c time " + timeStr_;
185
+				String res = runAndResult(cmd);
186
+				System.out.println("windows 时间修改" + res);
187
+			} else if (osName.matches("^(?i)Linux.*$")) {
188
+				// Linux 系统 格式:yyyy-MM-dd HH:mm:ss   date -s "2017-11-11 11:11:11"
189
+				String datash = PropertiesUtil.getProperty("date.sh");
190
+				FileWriter excutefw = new FileWriter(datash+"updateSysTime.sh");
191
+				BufferedWriter excutebw=new BufferedWriter(excutefw);
192
+				excutebw.write("date -s \"" + dataStr_ +" "+ timeStr_ +"\"\r\n");
193
+				excutebw.close();
194
+				excutefw.close();
195
+				String cmd_date ="sh "+datash+"updateSysTime.sh";
196
+				String res = runAndResult(cmd_date);
197
+				System.out.println("cmd :" + cmd_date + " date :" + dataStr_ +" time :" + timeStr_);
198
+				System.out.println("linux 时间修改" + res);
199
+			} else {
200
+				System.out.println("操作系统无法识别");
201
+			}
202
+		} catch (Exception e) {
203
+			e.getMessage();
204
+		}
205
+	}
206
+
207
+	/**
208
+	 * 执行 脚本命令  关心结果
209
+	 * @param cmd
210
+	 * @return
211
+	 */
212
+	public static String runAndResult(String cmd) throws Exception{
213
+		StringBuilder sb = new StringBuilder();
214
+		BufferedReader br = null;
215
+		boolean execFlag = true;
216
+
217
+		String uuid = UUID.randomUUID().toString().replace("-","");
218
+		String tempFileName = "./temp" + uuid +".sh";
219
+		try {
220
+			String osName = System.getProperty("os.name").toUpperCase(Locale.ENGLISH);
221
+
222
+			if (osName.matches("^(?i)LINUX.*$") || osName.contains("MAC")) {
223
+				FileWriter excutefw = new FileWriter(tempFileName);
224
+				BufferedWriter excutebw=new BufferedWriter(excutefw);
225
+				excutebw.write(cmd + "\n");
226
+				excutebw.close();
227
+				excutefw.close();
228
+				String command ="bash " + tempFileName;
229
+
230
+				Process p = Runtime.getRuntime().exec(command);
231
+				p.waitFor();
232
+
233
+				br = new BufferedReader(new InputStreamReader(p.getInputStream()));
234
+				String line;
235
+				while ((line = br.readLine()) != null) {
236
+					//sb.append("<br/>");
237
+					sb.append(System.lineSeparator());
238
+					sb.append(line);
239
+				}
240
+				br.close();
241
+
242
+				br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
243
+				while ((line = br.readLine()) != null) {
244
+					//sb.append("<br/>");
245
+					sb.append(System.lineSeparator());
246
+					sb.append(line);
247
+					if (line.length() > 0){
248
+						execFlag = false;
249
+					}
250
+				}
251
+				br.close();
252
+
253
+				if (execFlag){
254
+					System.out.println("exec [ {"+cmd+"} ]  OK , result : [ {"+sb.toString()+"} ]");
255
+				}else {
256
+					throw new RuntimeException(sb.toString());
257
+				}
258
+			}else {
259
+				throw new RuntimeException("不支持的操作系统类型");
260
+			}
261
+		} catch (Exception e) {
262
+			System.out.println("exec [ {"+cmd+"} ]  fail : {"+e.getMessage()+"}");
263
+			throw e;
264
+		}finally {
265
+			if (br != null){
266
+				br.close();
267
+			}
268
+			File excutefw = new File(tempFileName);
269
+			excutefw.delete();
270
+		}
271
+		return sb.toString();
272
+	}
273
+
274
+}

+ 31 - 0
src/main/java/com/dashitech/utils/ThreadPoolFactory.java

@@ -0,0 +1,31 @@
1
+package com.dashitech.utils;
2
+
3
+import java.util.concurrent.*;
4
+
5
+/**
6
+ * Created by chi on 2020/8/25.
7
+ */
8
+
9
+public abstract class ThreadPoolFactory {
10
+   // private static final Logger LOG = LoggerFactory.getLogger(ThreadPoolFactory.class);
11
+    private static ThreadPoolExecutor pool;
12
+    private static ScheduledThreadPoolExecutor scheduler;
13
+
14
+    public synchronized static ExecutorService getCachedPool() {
15
+        if (pool == null) {
16
+            pool = (ThreadPoolExecutor) Executors.newCachedThreadPool();
17
+         //   LOG.info("缓存线程池启动完成!初始化线程池大小:" + pool.getPoolSize());
18
+        }
19
+        return pool;
20
+    }
21
+
22
+    public synchronized static ScheduledExecutorService getScheduledPool() {
23
+        if (scheduler == null) {
24
+            scheduler = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5);
25
+           // LOG.info("定时线程池启动完成!初始化线程池大小:" + scheduler.getPoolSize());
26
+        }
27
+        return scheduler;
28
+    }
29
+
30
+}
31
+

文件差异内容过多而无法显示
+ 118 - 0
src/main/java/com/dashitech/utils/XmlToJson.java


+ 83 - 0
src/main/java/com/dashitech/utils/XmlToMap.java

@@ -0,0 +1,83 @@
1
+package com.dashitech.utils;
2
+
3
+import org.dom4j.Document;
4
+import org.dom4j.DocumentHelper;
5
+import org.dom4j.Element;
6
+
7
+import java.util.*;
8
+
9
+/**
10
+ * Created by xuweihua on 2021/3/29.
11
+ */
12
+public class XmlToMap {
13
+    public static Map<String, Object> Dom2Map(String xmlStr){
14
+        Map<String, Object> map = new HashMap<String, Object>();
15
+        try{
16
+            Document doc= DocumentHelper.parseText(xmlStr);
17
+            if(doc == null)
18
+                return null;
19
+            Element root = doc.getRootElement();
20
+            for (Iterator iterator = root.elementIterator(); iterator.hasNext();) {
21
+                Element e = (Element) iterator.next();
22
+                //System.out.println(e.getName());
23
+                List list = e.elements();
24
+                if(list.size() > 0){
25
+                    map.put(e.getName(), Dom2Map(e));
26
+                }else
27
+                    map.put(e.getName(), e.getText());
28
+            }
29
+            return map;
30
+        }catch (Exception e){
31
+            e.printStackTrace();
32
+        }
33
+        return null;
34
+    }
35
+
36
+
37
+    public static Map Dom2Map(Element e){
38
+        Map map = new HashMap();
39
+        List list = e.elements();
40
+        if(list.size() > 0){
41
+            for (int i = 0;i < list.size(); i++) {
42
+                Element iter = (Element) list.get(i);
43
+                List mapList = new ArrayList();
44
+
45
+                if(iter.elements().size() > 0){
46
+                    Map m = Dom2Map(iter);
47
+                    if(map.get(iter.getName()) != null){
48
+                        Object obj = map.get(iter.getName());
49
+                        if(!obj.getClass().getName().equals("java.util.ArrayList")){
50
+                            mapList = new ArrayList();
51
+                            mapList.add(obj);
52
+                            mapList.add(m);
53
+                        }
54
+                        if(obj.getClass().getName().equals("java.util.ArrayList")){
55
+                            mapList = (List) obj;
56
+                            mapList.add(m);
57
+                        }
58
+                        map.put(iter.getName(), mapList);
59
+                    }else
60
+                        map.put(iter.getName(), m);
61
+                }
62
+                else{
63
+                    if(map.get(iter.getName()) != null){
64
+                        Object obj = map.get(iter.getName());
65
+                        if(!obj.getClass().getName().equals("java.util.ArrayList")){
66
+                            mapList = new ArrayList();
67
+                            mapList.add(obj);
68
+                            mapList.add(iter.getText());
69
+                        }
70
+                        if(obj.getClass().getName().equals("java.util.ArrayList")){
71
+                            mapList = (List) obj;
72
+                            mapList.add(iter.getText());
73
+                        }
74
+                        map.put(iter.getName(), mapList);
75
+                    }else
76
+                        map.put(iter.getName(), iter.getText());
77
+                }
78
+            }
79
+        }else
80
+            map.put(e.getName(), e.getText());
81
+        return map;
82
+    }
83
+}

+ 32 - 0
src/main/resources/application-context.xml

@@ -0,0 +1,32 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<beans xmlns="http://www.springframework.org/schema/beans"
3
+	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
4
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
5
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
6
+						http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
7
+						http://www.springframework.org/schema/mvc
8
+						http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
9
+						http://www.springframework.org/schema/aop 
10
+						http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
11
+						http://www.springframework.org/schema/context
12
+						http://www.springframework.org/schema/context/spring-context-3.0.xsd">
13
+
14
+
15
+	<!-- 初始化静态资源类 -->
16
+	<bean id="applicationProperties"
17
+		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
18
+		<property name="ignoreResourceNotFound" value="true" />
19
+		<property name="locations">
20
+			<list>
21
+				<value>classpath:application.properties</value>
22
+				<value>classpath:application-custom.properties</value>
23
+			</list>
24
+		</property>
25
+	</bean>
26
+
27
+	<bean class="com.dashitech.utils.PropertiesUtil" lazy-init="false">
28
+		<property name="properties" ref="applicationProperties" />
29
+	</bean>
30
+
31
+	<bean class="com.dashitech.utils.SpringContextHolder" lazy-init="false" />
32
+</beans>

+ 1 - 0
src/main/resources/application-custom.properties

@@ -0,0 +1 @@
1
+custom.redis.expire=60

+ 41 - 0
src/main/resources/application.properties

@@ -0,0 +1,41 @@
1
+mysql2.spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
2
+#\u8F6C\u8FD0\u4E1A\u52A1\u5E93\u6570\u636E\u6E90
3
+mysql2.spring.datasource.driver-class-name=com.mysql.jdbc.Driver
4
+mysql2.spring.datasource.url=jdbc:mysql://localhost:3306/hsms2_1129?autoReconnect=true&useUnicode=true&characterEncoding=utf8
5
+#mysql2.spring.datasource.url=jdbc:mysql://192.168.3.108:3306/hsms2_tjzy_0622?autoReconnect=true&useUnicode=true&characterEncoding=utf8
6
+mysql2.spring.datasource.username=root
7
+mysql2.spring.datasource.password=100100
8
+
9
+
10
+# \u4E0B\u9762\u4E3A\u8FDE\u63A5\u6C60\u7684\u8865\u5145\u8BBE\u7F6E\uFF0C\u5E94\u7528\u5230\u4E0A\u9762\u6240\u6709\u6570\u636E\u6E90\u4E2D
11
+# \u521D\u59CB\u5316\u5927\u5C0F\uFF0C\u6700\u5C0F\uFF0C\u6700\u5927
12
+mysql2.spring.datasource.initialSize=5
13
+mysql2.spring.datasource.minIdle=1
14
+mysql2.spring.datasource.maxActive=150
15
+# \u914D\u7F6E\u83B7\u53D6\u8FDE\u63A5\u7B49\u5F85\u8D85\u65F6\u7684\u65F6\u95F4
16
+mysql2.spring.datasource.maxWait=60000
17
+# \u914D\u7F6E\u95F4\u9694\u591A\u4E45\u624D\u8FDB\u884C\u4E00\u6B21\u68C0\u6D4B\uFF0C\u68C0\u6D4B\u9700\u8981\u5173\u95ED\u7684\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
18
+mysql2.spring.datasource.timeBetweenEvictionRunsMillis=60000
19
+# \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5C0F\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
20
+mysql2.spring.datasource.minEvictableIdleTimeMillis=300000
21
+# Oracle\u8BF7\u4F7F\u7528select 1 from dual
22
+mysql2.spring.datasource.validationQuery=SELECT 'x'
23
+mysql2.spring.datasource.testWhileIdle=true
24
+mysql2.spring.datasource.testOnBorrow=true
25
+mysql2.spring.datasource.testOnReturn=true
26
+
27
+
28
+spring.redis.host=192.168.245.108
29
+#spring.redis.host=localhost
30
+spring.redis.port=6379
31
+spring.redis.password=Redis@#6379pwD
32
+spring.redis.pool.max-total=100
33
+spring.redis.pool.max-idle=20
34
+spring.redis.pool.max-wait-millis=10000
35
+spring.profiles.active=custom
36
+
37
+server.port=29999
38
+spring.jps.showsql=true
39
+server.tomcat.compression=on
40
+
41
+spring.jackson.parser.allow-numeric-leading-zeros=true

+ 22 - 0
src/main/resources/banner.txt

@@ -0,0 +1,22 @@
1
+////////////////////////////////////////////////////////////////////
2
+//                          _ooOoo_                               //
3
+//                         o8888888o                              //
4
+//                         88" . "88                              //
5
+//                         (| ^_^ |)                              //
6
+//                         O\  =  /O                              //
7
+//                      ____/`---'\____                           //
8
+//                    .'  \\|     |//  `.                         //
9
+//                   /  \\|||  :  |||//  \                        //
10
+//                  /  _||||| -卍-|||||-  \                       //
11
+//                  |   | \\\  -  /// |   |                       //
12
+//                  | \_|  ''\---/''  |   |                       //
13
+//                  \  .-\__  `-`  ___/-. /                       //
14
+//                ___`. .'  /--.--\  `. . ___                     //
15
+//              ."" '<  `.___\_<|>_/___.'  >'"".                  //
16
+//            | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 //
17
+//            \  \ `-.   \_ __\ /__ _/   .-` /  /                 //
18
+//      ========`-.____`-.___\_____/___.-`____.-'========         //
19
+//                           `=---='                              //
20
+//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
21
+//          佛祖保佑   永不宕机   永无BUG  大势雄起               //
22
+////////////////////////////////////////////////////////////////////

+ 37 - 0
src/main/resources/log4j.properties

@@ -0,0 +1,37 @@
1
+log4j.rootLogger=INFO,conso,stdout
2
+
3
+log4j.appender.conso=org.apache.log4j.ConsoleAppender
4
+log4j.appender.conso.layout=org.apache.log4j.PatternLayout
5
+log4j.appender.conso.layout.ConversionPattern=%d %p [%c.%M_%L] - %m%n
6
+
7
+log4j.appender.stdout=org.apache.log4j.RollingFileAppender
8
+log4j.appender.stdout.File=logs/master.log
9
+log4j.appender.stdout.MaxFileSize=10240KB
10
+log4j.appender.stdout.Encoding=UTF-8
11
+#log4j.appender.stdout.MaxBackupIndex=3
12
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
13
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c.%M_%L] - %m%n
14
+
15
+
16
+log4j.appender.error=org.apache.log4j.RollingFileAppender
17
+log4j.appender.error.File=logs/error.log
18
+log4j.appender.error.MaxFileSize=10240KB
19
+log4j.appender.error.Encoding=UTF-8
20
+log4j.appender.error.layout=org.apache.log4j.PatternLayout
21
+log4j.appender.error.layout.ConversionPattern=%d %p [%c.%M_%L] - %m%n
22
+
23
+log4j.logger.com.dashitech.mc.core=TRACE
24
+
25
+log4j.logger.org.springframework=ERROR
26
+#log4j.logger.com.ibatis=debug
27
+#log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
28
+#log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
29
+#log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
30
+#log4j.logger.org.hibernate.SQL=debug
31
+#log4j.logger.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
32
+#log4j.logger.org.hibernate.tool.hbm2ddl=debug 
33
+#log4j.logger.java.sql=DEBUG
34
+#log4j.logger.java.sql.Connection=debug
35
+#log4j.logger.java.sql.Statement=debug
36
+#log4j.logger.java.sql.PreparedStatement=debug
37
+#log4j.logger.java.sql.ResultSet=debug

+ 5 - 0
src/main/resources/start.bat

@@ -0,0 +1,5 @@
1
+echo "start ing"
2
+
3
+java -Xmx512m -XX:MaxPermSize=256m -jar C:/Users/Administrator/Desktop/hsmsV1-DataService-1.0.0.jar --server.port=8080 &
4
+
5
+echo "start end"

+ 15 - 0
src/main/resources/start.sh

@@ -0,0 +1,15 @@
1
+#!/bin/bash
2
+
3
+HOME=`pwd`
4
+NAME=hsmsV1-CallSocket
5
+LOG=$HOME/logs/itsm.log
6
+
7
+echo "service $NAME start"
8
+echo ""
9
+
10
+
11
+
12
+nohup java -server -Xms256m -Djava.security.egd=file:/dev/./urandom -jar /home/itsm/itsm_v2/hsmsV1-CallSocket/HSMSV1-CallSocket-1.0.0.jar --server.port=29999 > $LOG 2>&1 &
13
+
14
+echo ""
15
+echo "service $NAME completed"

+ 20 - 0
src/main/resources/startCollect.sh

@@ -0,0 +1,20 @@
1
+#!/bin/bash
2
+
3
+NAME=hsmsV1-DataService
4
+
5
+echo "service $NAME start"
6
+echo ""
7
+
8
+HOME=`pwd`
9
+LOG=$HOME/logs/itsm.log
10
+CONFS=$HOME/conf
11
+CLASSES=$HOME/classes
12
+LIBS=$HOME/lib
13
+JARS=`ls $LIBS|grep .jar|awk '{print "'$LIBS'/"$0}'|tr "\n" ":"`
14
+JAVA_OPTS=" -server -Xms10g -Xmx20g -XX:PermSize=2g -XX:SurvivorRatio=2 -XX:+UseParallelGC "
15
+CLASS_PATH=$CONFS:$CLASSES:$JARS:$NAME
16
+
17
+nohup java $JAVA_OPTS -classpath $CLASS_PATH com.dashitech.Application > $LOG 2>&1 &
18
+
19
+echo ""
20
+echo "service $NAME completed"

+ 26 - 0
src/main/webapp/WEB-INF/web.xml

@@ -0,0 +1,26 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
3
+        "http://java.sun.com/dtd/web-app_2_3.dtd">
4
+<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
5
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
7
+  <display-name></display-name>
8
+
9
+    <servlet>
10
+        <servlet-name>AtmosphereServlet</servlet-name>
11
+        <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
12
+        <init-param>
13
+            <param-name>org.atmosphere.cpr.packages</param-name>
14
+            <param-value>com.dashitech.callcenter.webSocket.service</param-value>
15
+        </init-param>
16
+        <load-on-startup>0</load-on-startup>
17
+    </servlet>
18
+
19
+
20
+    <servlet-mapping>
21
+        <servlet-name>AtmosphereServlet</servlet-name>
22
+        <url-pattern>/webSocket/*</url-pattern>
23
+    </servlet-mapping>
24
+
25
+
26
+</web-app>

+ 0 - 0
src/test/java/com/dashitech/mc/AppTest.java


部分文件因为文件数量过多而无法显示