Przeglądaj źródła

智能仓房添加shardingSphere + rocketMQ

hanqingsong 3 lat temu
rodzic
commit
de4d904bdd

+ 26 - 37
pom.xml

@@ -8,7 +8,6 @@
8 8
     <artifactId>depot-intelligent</artifactId>
9 9
     <version>0.0.1</version>
10 10
     <packaging>jar</packaging>
11
-    <!--<packaging>war</packaging>-->
12 11
 
13 12
     <name>depot-intelligent</name>
14 13
     <description>Demo project for Spring Boot</description>
@@ -16,26 +15,38 @@
16 15
     <parent>
17 16
         <groupId>org.springframework.boot</groupId>
18 17
         <artifactId>spring-boot-starter-parent</artifactId>
19
-        <version>2.0.2.RELEASE</version>
18
+        <version>2.3.12.RELEASE</version>
20 19
         <relativePath/> <!-- lookup parent from repository -->
21 20
     </parent>
22
-    <distributionManagement>
23
-        <repository>
24
-            <id>nexus</id>
25
-            <!--名称自己定义-->
26
-            <name>release</name>
27
-            <url>http://10.10.1.25:8081/repository/host_repository/</url>
28
-        </repository>
29
-    </distributionManagement>
30 21
     <properties>
31 22
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32 23
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
33 24
         <java.version>1.8</java.version>
34
-        <spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
25
+        <skipTests>true</skipTests>
26
+        <spring-cloud.version>Hoxton.SR12</spring-cloud.version>
27
+        <rocketmq-client.version>4.9.3</rocketmq-client.version>
28
+        <rocketmq-starter.version>2.2.1</rocketmq-starter.version>
35 29
     </properties>
36 30
 
37 31
     <dependencies>
38 32
         <dependency>
33
+            <groupId>org.apache.shardingsphere</groupId>
34
+            <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
35
+            <version>5.1.0</version>
36
+        </dependency>
37
+        <!-- MQ client -->
38
+        <dependency>
39
+            <groupId>org.apache.rocketmq</groupId>
40
+            <artifactId>rocketmq-client</artifactId>
41
+            <version>${rocketmq-client.version}</version>
42
+        </dependency>
43
+        <!-- rocketMQ -->
44
+        <dependency>
45
+            <groupId>org.apache.rocketmq</groupId>
46
+            <artifactId>rocketmq-spring-boot-starter</artifactId>
47
+            <version>${rocketmq-starter.version}</version>
48
+        </dependency>
49
+        <dependency>
39 50
             <groupId>org.springframework.boot</groupId>
40 51
             <artifactId>spring-boot-starter-web</artifactId>
41 52
         </dependency>
@@ -49,18 +60,13 @@
49 60
         </dependency>
50 61
         <!--添加webservice-->
51 62
         <dependency>
52
-            <groupId>org.springframework.boot</groupId>
53
-            <artifactId>spring-boot-starter-web-services</artifactId>
54
-        </dependency>
55
-        <dependency>
56 63
             <groupId>org.apache.cxf</groupId>
57
-            <artifactId>cxf-rt-frontend-jaxws</artifactId>
58
-            <version>3.1.6</version>
64
+            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
65
+            <version>3.2.4</version>
59 66
         </dependency>
60 67
         <dependency>
61
-            <groupId>org.apache.cxf</groupId>
62
-            <artifactId>cxf-rt-transports-http</artifactId>
63
-            <version>3.1.6</version>
68
+            <groupId>org.springframework.boot</groupId>
69
+            <artifactId>spring-boot-starter-web-services</artifactId>
64 70
         </dependency>
65 71
         <!--添加webservice end-->
66 72
         <dependency>
@@ -102,7 +108,6 @@
102 108
         <dependency>
103 109
             <groupId>org.springframework.boot</groupId>
104 110
             <artifactId>spring-boot-starter-test</artifactId>
105
-            <scope>test</scope>
106 111
         </dependency>
107 112
         <dependency>
108 113
             <groupId>org.apache.poi</groupId>
@@ -141,20 +146,12 @@
141 146
             <artifactId>quartz</artifactId>
142 147
             <version>2.3.0</version>
143 148
         </dependency>
144
-
145
-        <dependency>
146
-            <groupId>org.springframework.boot</groupId>
147
-            <artifactId>spring-boot-starter-test</artifactId>
148
-        </dependency>
149
-
150
-       
151 149
         <!--短信发送平台jar包-->
152 150
         <dependency>
153 151
             <groupId>org.projectlombok</groupId>
154 152
             <artifactId>lombok</artifactId>
155 153
             <optional>true</optional>
156 154
         </dependency>
157
-
158 155
         <dependency>
159 156
             <groupId>org.springframework.boot</groupId>
160 157
             <artifactId>spring-boot-starter-data-redis</artifactId>
@@ -184,14 +181,6 @@
184 181
                 <groupId>org.springframework.boot</groupId>
185 182
                 <artifactId>spring-boot-maven-plugin</artifactId>
186 183
             </plugin>
187
-            <!--<plugin>
188
-                <groupId>org.apache.maven.plugins</groupId>
189
-                <artifactId>maven-jar-plugin</artifactId>
190
-                <version>2.6</version>
191
-                <configuration>
192
-                    <failOnMissingWebXml>false</failOnMissingWebXml>
193
-                </configuration>
194
-            </plugin>-->
195 184
         </plugins>
196 185
 
197 186
         <!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->

+ 0 - 28
src/main/java/com/DepotIntelligentApplication.java

@@ -3,19 +3,12 @@ package com;
3 3
 import org.mybatis.spring.annotation.MapperScan;
4 4
 import org.springframework.boot.SpringApplication;
5 5
 import org.springframework.boot.autoconfigure.SpringBootApplication;
6
-import org.springframework.boot.web.servlet.ServletComponentScan;
7
-import org.springframework.boot.web.servlet.ServletRegistrationBean;
8
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
9 6
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
10 7
 import org.springframework.context.annotation.Bean;
11 8
 import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
12
-import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
13
-import org.springframework.web.servlet.DispatcherServlet;
14 9
 
15 10
 @EnableEurekaClient
16
-@EnableDiscoveryClient
17 11
 @SpringBootApplication
18
-@ServletComponentScan
19 12
 @MapperScan(basePackages = {"com.chinaitop.depot.**.mapper"})
20 13
 public class DepotIntelligentApplication {
21 14
 
@@ -23,27 +16,6 @@ public class DepotIntelligentApplication {
23 16
 		SpringApplication.run(DepotIntelligentApplication.class, args);
24 17
 	}
25 18
 
26
-	/**
27
-	 * 注册一个dispatcherServlet,解决增加ws之后https接口访问不了问题
28
-	 */
29
-	@Bean
30
-	public ServletRegistrationBean restServlet(){
31
-		//注解扫描上下文
32
-		AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
33
-		//base package
34
-		applicationContext.scan("com.unissoft");
35
-		//通过构造函数指定dispatcherServlet的上下文
36
-		DispatcherServlet rest_dispatcherServlet = new DispatcherServlet(applicationContext);
37
-		//用ServletRegistrationBean包装servlet
38
-		ServletRegistrationBean registrationBean = new ServletRegistrationBean(rest_dispatcherServlet);
39
-		registrationBean.setLoadOnStartup(1);
40
-		//指定urlmapping
41
-		registrationBean.addUrlMappings("/*");
42
-		//指定name,如果不指定默认为dispatcherServlet
43
-		registrationBean.setName("rest");
44
-		return registrationBean;
45
-	}
46
-
47 19
 	@Bean
48 20
 	public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
49 21
 		return new ThreadPoolTaskScheduler();

+ 3 - 3
src/main/java/com/chinaitop/depot/intelligent/basicdata/mapper/WareHouseBasicInfoMapper.xml

@@ -24,7 +24,7 @@
24 24
                 t1.cjsj AS cjsj,
25 25
                 t1.UnitID
26 26
             FROM
27
-            `lsreport_ts`.data_kcgl_kcsw_default AS t1
27
+            data_kcgl_kcsw_default AS t1
28 28
             LEFT JOIN basic_storehouse t2 ON t1.UnitID = t2.org_id
29 29
             AND t1.ch = t2.storehouse_id
30 30
             LEFT JOIN (
@@ -36,8 +36,8 @@
36 36
                     t3.ch,
37 37
                     t3.scnf scnfEnumId
38 38
                 FROM
39
-                `lsreport_ts`.data_kcgl_fcbgz_default t3
40
-                INNER JOIN `lsreport_ts`.enumitem t4 ON t3.scnf = t4.EnumItemId
39
+                data_kcgl_fcbgz_default t3
40
+                INNER JOIN enumitem t4 ON t3.scnf = t4.EnumItemId
41 41
                 AND t3.srsl > 0
42 42
                 AND t3.UnitID = #{org_id}
43 43
                 GROUP BY

+ 1 - 1
src/main/java/com/chinaitop/depot/intelligent/ventilation/mapper/DataKcglKcswDefaultMapper.xml

@@ -90,7 +90,7 @@
90 90
       distinct
91 91
     </if>
92 92
     <include refid="Base_Column_List" />
93
-    from lsreport_ts.data_kcgl_kcsw_default
93
+    from data_kcgl_kcsw_default
94 94
     <if test="_parameter != null">
95 95
       <include refid="Example_Where_Clause" />
96 96
     </if>

+ 1 - 1
src/main/java/com/chinaitop/depot/intelligent/ventilation/mapper/StorageFoodbasicinfoMapper.xml

@@ -946,7 +946,7 @@
946 946
         SELECT
947 947
             *
948 948
         FROM
949
-            lsreport_ts.data_kcgl_fcbgz_default fcbgz
949
+            data_kcgl_fcbgz_default fcbgz
950 950
         WHERE 1=1 
951 951
         <if test="houseId != null">
952 952
         AND fcbgz.ch = #{houseId} 

+ 1 - 4
src/main/java/com/unissoft/serviceconfig/CxfConfig.java

@@ -14,10 +14,7 @@ import javax.xml.ws.Endpoint;
14 14
 
15 15
 @Configuration
16 16
 public class CxfConfig {
17
-    @Bean
18
-    public ServletRegistrationBean dispatcherServlet() {
19
-        return new ServletRegistrationBean(new CXFServlet(),"/intelligent/*");
20
-    }
17
+
21 18
     @Bean(name = Bus.DEFAULT_BUS_ID)
22 19
     public SpringBus springBus() {
23 20
         return new SpringBus();

BIN
src/main/resources/RXTXcomm-2.0.1.jar


+ 54 - 81
src/main/resources/bootstrap.yml

@@ -1,47 +1,59 @@
1
-spring:
2
-  profiles:
3
-    active: clouda
4 1
 server:
5 2
   port: 9028
6 3
   tomcat:
7 4
     uri-encoding: utf-8
8
----
9
-# 注册中心配置 defaultZone: http://eureka-depot:9001/eureka/
10
-eureka:
11
-  client:
12
-    service-url:
13
-      defaultZone: http://eureka-depot:9001/eureka/
14
-    registerWithEureka: false
15
-    fetchRegistry: false
16
-  instance:
17
-    prefer-ip-address: true
18
-    ip-address: eureka-depot
19
-    status-page-url: http://eureka-depot:${server.port}/swagger-ui.html
20
-    instance-id: ${eureka.instance.ip-address}:${server.port}
21
-
22 5
 spring:
23
-  profiles: locala
24 6
   application:
25 7
     name: depot-intelligent
26
-  # 数据库配置
27
-  datasource:
28
-    driver-class-name: com.mysql.jdbc.Driver
29
-    url: jdbc:mysql://172.16.0.5:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
30
-    username: root
31
-    password: 123456
8
+  shardingsphere:
9
+    props:
10
+      sql-show: true
11
+    mode:
12
+      type: Standalone
13
+      overwrite: true
14
+      repository:
15
+        type: File
16
+        props:
17
+          path: D:/Standalone/depot-intelligent
18
+    datasource:
19
+      names: depot-master-01,depot-slave-01
20
+      depot-master-01:
21
+        type: com.zaxxer.hikari.HikariDataSource
22
+        driver-class-name: com.mysql.cj.jdbc.Driver
23
+        jdbc-url: jdbc:mysql://172.16.0.8:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
24
+        username: root
25
+        password: 123456
26
+      depot-slave-01:
27
+        type: com.zaxxer.hikari.HikariDataSource
28
+        driver-class-name: com.mysql.cj.jdbc.Driver
29
+        jdbc-url: jdbc:mysql://172.16.0.9:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
30
+        username: root
31
+        password: 123456
32
+    rules:
33
+      readwrite-splitting:
34
+        data-sources:
35
+          depot:
36
+            type: Static
37
+            props:
38
+              write-data-source-name: depot-master-01
39
+              read-data-source-names: depot-slave-01
40
+            load-balancer-name: depot_algorithm
41
+        load-balancers:
42
+          depot_algorithm:
43
+            type: ROUND_ROBIN
32 44
   # 缓存配置
33 45
   session:
34 46
     store-type: redis
35 47
   redis:
36
-    database: 0
37
-    host: 10.10.1.25
48
+    database: 13
49
+    host: 172.16.0.2
38 50
     port: 6379
39 51
     password: 123456
40
-    timeout: 3000
52
+    timeout: 3000ms
41 53
     jedis:
42 54
       pool:
43 55
         max-active: 8
44
-        max-wait: -1
56
+        max-wait: -1ms
45 57
         max-idle: 8
46 58
         min-idle: 0
47 59
   # 静态资源配置
@@ -50,68 +62,20 @@ spring:
50 62
   jackson:
51 63
     date-format: yyyy-MM-dd HH:mm:ss
52 64
     time-zone: GMT+8
53
-web:
54
-  upload-path: D:/upload
55
-
56
-#socket地址
57
-#socket-url: 127.0.0.1
58
-#socket-port: 8999
59
-socket-url: localhost
60
-socket-port: 8999
61
-
62
-#设置全局变量判断是云端还是库端;1云端,2本地
63
-localOrCloud: 2
64
-
65
-# 多通道气体
66
-gas-org-ids: 386,177,273,280,300
67
-
68
-# 数量检测版本区分version3
69
-num_version3: :20013
70
----
71 65
 # 注册中心配置 defaultZone: http://eureka-depot:9001/eureka/
72 66
 eureka:
73 67
   client:
74 68
     service-url:
75
-      defaultZone: http://172.16.0.46:9511/eureka/
69
+      defaultZone: http://172.16.0.8:9001/eureka/
76 70
   instance:
77 71
     prefer-ip-address: true
72
+    ip-address: ${spring.cloud.client.ip-address}
73
+    # 每隔10s发送一次心跳(默认30s)
78 74
     lease-renewal-interval-in-seconds: 10
75
+    # 告知服务端30秒还未收到心跳的话,就将该服务移除列表(默认90s)
79 76
     lease-expiration-duration-in-seconds: 30
80
-
81
-spring:
82
-  profiles: clouda
83
-  application:
84
-    name: depot-intelligent
85
-  # 数据库配置
86
-  datasource:
87
-    driver-class-name: com.mysql.jdbc.Driver
88
-    url: jdbc:mysql://172.16.0.5:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
89
-    username: root
90
-    password: 123456
91
-  # 缓存配置
92
-  session:
93
-    store-type: redis
94
-  redis:
95
-    database: 1
96
-    host: 172.16.0.46
97
-    port: 6679
98
-    password: 123456
99
-    timeout: 3000
100
-    jedis:
101
-      pool:
102
-        max-active: 8
103
-        max-wait: -1
104
-        max-idle: 8
105
-        min-idle: 0
106
-  # 静态资源配置
107
-  resources:
108
-    static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.upload-path}
109
-  jackson:
110
-    date-format: yyyy-MM-dd HH:mm:ss
111
-    time-zone: GMT+8
112 77
 web:
113
-  upload-path: /home
114
-
78
+  upload-path: D:/upload
115 79
 #socket地址
116 80
 #socket-url: 127.0.0.1
117 81
 #socket-port: 8999
@@ -126,3 +90,12 @@ gas-org-ids: 386,177,273,280,300
126 90
 
127 91
 # 数量检测版本区分version3
128 92
 num_version3: :20013
93
+cxf:
94
+  path: /intelligent
95
+# rocketMQ
96
+rocketmq:
97
+  # slave
98
+  name-server: 172.16.0.9:9876
99
+  consumer:
100
+    # depot_云南consumer_group
101
+    group: depot_ync_group

BIN
src/main/resources/smslib-3.5.4.jar