Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
ed536606
Commit
ed536606
authored
Oct 17, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更改上传文件大小限制
parent
ac6d2318
Changes
25
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
702 additions
and
411 deletions
+702
-411
common-lib/src/main/java/com/mortals/xhx/queue/TbQueueCoreSettings.java
.../main/java/com/mortals/xhx/queue/TbQueueCoreSettings.java
+1
-2
common-lib/src/main/java/com/mortals/xhx/queue/rabbitmq/TbRabbitMqSettings.java
...va/com/mortals/xhx/queue/rabbitmq/TbRabbitMqSettings.java
+1
-2
db/base.sql
db/base.sql
+3
-15
db/menu.sql
db/menu.sql
+1
-0
db/module.sql
db/module.sql
+211
-201
db/params.sql
db/params.sql
+25
-2
device-manager/pom.xml
device-manager/pom.xml
+54
-12
device-manager/src/main/java/com/mortals/xhx/base/framework/aspect/OperlogAspect.java
.../com/mortals/xhx/base/framework/aspect/OperlogAspect.java
+4
-31
device-manager/src/main/java/com/mortals/xhx/base/framework/config/RabbitConfig.java
...a/com/mortals/xhx/base/framework/config/RabbitConfig.java
+6
-7
device-manager/src/main/java/com/mortals/xhx/base/framework/config/RedissonConfig.java
...com/mortals/xhx/base/framework/config/RedissonConfig.java
+4
-5
device-manager/src/main/java/com/mortals/xhx/base/framework/listener/DirectDynamicListener.java
...ls/xhx/base/framework/listener/DirectDynamicListener.java
+1
-4
device-manager/src/main/java/com/mortals/xhx/base/system/message/MessageCallbackService.java
...rtals/xhx/base/system/message/MessageCallbackService.java
+8
-0
device-manager/src/main/java/com/mortals/xhx/base/system/message/MessageService.java
...a/com/mortals/xhx/base/system/message/MessageService.java
+0
-1
device-manager/src/main/java/com/mortals/xhx/base/system/message/RabbitMessageService.java
...mortals/xhx/base/system/message/RabbitMessageService.java
+1
-9
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageCallbackServiceImpl.java
.../base/system/message/impl/MessageCallbackServiceImpl.java
+26
-0
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageProducer.java
...mortals/xhx/base/system/message/impl/MessageProducer.java
+4
-13
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageServiceImpl.java
...tals/xhx/base/system/message/impl/MessageServiceImpl.java
+0
-6
device-manager/src/main/java/com/mortals/xhx/busiz/req/TestReq.java
...ager/src/main/java/com/mortals/xhx/busiz/req/TestReq.java
+148
-0
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+6
-18
device-manager/src/main/java/com/mortals/xhx/busiz/web/TestSendMsgController.java
...java/com/mortals/xhx/busiz/web/TestSendMsgController.java
+104
-0
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/NettyStartedService.java
...ls/xhx/daemon/applicationservice/NettyStartedService.java
+1
-4
device-manager/src/main/java/com/mortals/xhx/daemon/netty/server/controlserver/ControlServer.java
.../xhx/daemon/netty/server/controlserver/ControlServer.java
+1
-3
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+0
-30
device-manager/src/main/resources/bootstrap.yml
device-manager/src/main/resources/bootstrap.yml
+1
-46
device-manager/src/test/java/producer/ProducerTest.java
device-manager/src/test/java/producer/ProducerTest.java
+91
-0
No files found.
common-lib/src/main/java/com/mortals/xhx/queue/TbQueueCoreSettings.java
View file @
ed536606
...
@@ -2,10 +2,9 @@ package com.mortals.xhx.queue;
...
@@ -2,10 +2,9 @@ package com.mortals.xhx.queue;
import
lombok.Data
;
import
lombok.Data
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
@Data
@Data
@Component
//
@Component
public
class
TbQueueCoreSettings
{
public
class
TbQueueCoreSettings
{
@Value
(
"${queue.core.topic}"
)
@Value
(
"${queue.core.topic}"
)
...
...
common-lib/src/main/java/com/mortals/xhx/queue/rabbitmq/TbRabbitMqSettings.java
View file @
ed536606
...
@@ -7,7 +7,6 @@ import lombok.Getter;
...
@@ -7,7 +7,6 @@ import lombok.Getter;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
...
@@ -20,7 +19,7 @@ public class TbRabbitMqSettings {
...
@@ -20,7 +19,7 @@ public class TbRabbitMqSettings {
private
String
exchangeName
;
private
String
exchangeName
;
@Value
(
"${queue.rabbitmq.host:}"
)
@Value
(
"${queue.rabbitmq.host:}"
)
private
String
host
;
private
String
host
;
@Value
(
"${queue.rabbitmq.port:}"
)
@Value
(
"${queue.rabbitmq.port:
0
}"
)
private
int
port
;
private
int
port
;
@Value
(
"${queue.rabbitmq.virtual_host:}"
)
@Value
(
"${queue.rabbitmq.virtual_host:}"
)
private
String
virtualHost
;
private
String
virtualHost
;
...
...
db/base.sql
View file @
ed536606
/*
DROP
database
if
exists
`device-platform`
;
Navicat MySQL Data Transfer
CREATE
database
`device-platform`
default
charset
=
utf8
;
use
`device-platform`
;
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 80018
Source Host : localhost:3306
Source Schema : base-platform
Target Server Type : MySQL
Target Server Version : 80018
File Encoding : 65001
Date: 05/11/2021 09:39:57
*/
SET
NAMES
utf8mb4
;
SET
NAMES
utf8mb4
;
SET
FOREIGN_KEY_CHECKS
=
0
;
SET
FOREIGN_KEY_CHECKS
=
0
;
...
...
db/menu.sql
View file @
ed536606
use
`device-platform`
;
-- ----------------------------
-- ----------------------------
-- 设备生产厂商菜单 SQL
-- 设备生产厂商菜单 SQL
-- ----------------------------
-- ----------------------------
...
...
db/module.sql
View file @
ed536606
This diff is collapsed.
Click to expand it.
db/params.sql
View file @
ed536606
use
`device-platform`
;
-- ----------------------------
-- ----------------------------
-- 设备生产厂商参数 SQL
-- 设备生产厂商参数 SQL
-- ----------------------------
-- ----------------------------
...
@@ -32,4 +32,27 @@ INSERT INTO `mortals_xhx_param` VALUES (null, '日志类型,', 'DeviceLog', 'l
...
@@ -32,4 +32,27 @@ INSERT INTO `mortals_xhx_param` VALUES (null, '日志类型,', 'DeviceLog', 'l
INSERT
INTO
`mortals_xhx_param`
VALUES
(
null
,
'日志类型,'
,
'DeviceLog'
,
'logType'
,
'1'
,
'下发服务'
,
1
,
4
,
0
,
'logType'
,
NULL
,
NULL
,
NULL
);
INSERT
INTO
`mortals_xhx_param`
VALUES
(
null
,
'日志类型,'
,
'DeviceLog'
,
'logType'
,
'1'
,
'下发服务'
,
1
,
4
,
0
,
'logType'
,
NULL
,
NULL
,
NULL
);
INSERT
INTO
`mortals_xhx_param`
VALUES
(
null
,
'数据获取方式'
,
'Device'
,
'deviceDataSourceWay'
,
'1'
,
'被动拉取'
,
1
,
4
,
0
,
'deviceDataSourceWay'
,
NULL
,
NULL
,
NULL
);
INSERT
INTO
`mortals_xhx_param`
VALUES
(
null
,
'数据获取方式'
,
'Device'
,
'deviceDataSourceWay'
,
'1'
,
'被动拉取'
,
1
,
4
,
0
,
'deviceDataSourceWay'
,
NULL
,
NULL
,
NULL
);
\ No newline at end of file
INSERT
INTO
`mortals_xhx_platform`
VALUES
(
1
,
'排号系统'
,
'phxt'
,
0
,
'http://192.168.0.98:8090'
,
''
,
1
,
''
,
''
,
1
,
'2022-05-31 15:56:20'
,
1
,
'2022-07-02 11:46:48'
);
INSERT
INTO
`mortals_xhx_platform`
VALUES
(
2
,
'无感一码通'
,
'noninductive'
,
0
,
'baidu.com'
,
''
,
1
,
'baidu.com'
,
'noninductivenoninductive'
,
1
,
'2022-07-07 15:24:31'
,
1
,
'2022-07-07 15:24:40'
);
INSERT
INTO
`mortals_xhx_platform`
VALUES
(
3
,
'短信系统'
,
'information'
,
0
,
'baidu.baodu'
,
''
,
0
,
'baidu.baodu'
,
'baidu.baodu'
,
1
,
'2022-07-07 15:26:03'
,
1
,
'2022-07-07 15:26:03'
);
INSERT
INTO
`mortals_xhx_platform`
VALUES
(
4
,
'存取件平台'
,
'cqj'
,
0
,
'http://192.168.0.98:8090'
,
''
,
0
,
''
,
''
,
1
,
'2022-07-26 10:28:08'
,
1
,
'2022-07-29 10:09:11'
);
INSERT
INTO
`mortals_xhx_platform`
VALUES
(
5
,
'信息发布系统'
,
'xxfbxt'
,
0
,
'http://192.168.0.98:8090'
,
''
,
1
,
''
,
''
,
1
,
'2022-08-04 09:46:43'
,
1
,
'2022-08-04 14:52:56'
);
INSERT
INTO
`mortals_xhx_platform`
VALUES
(
6
,
'评价系统'
,
'pjxt'
,
0
,
'http://192.168.0.98:8090'
,
''
,
1
,
''
,
''
,
1
,
'2022-08-17 16:33:34'
,
1
,
'2022-08-17 16:34:22'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
1
,
1
,
'排队机'
,
'pdj'
,
1
,
'1920x1080'
,
'/homeDeviceUrl/pdj/1920x1080'
,
''
,
1
,
'2022-05-12 10:35:18'
,
1
,
'2022-08-03 10:14:18'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
2
,
1
,
'窗口屏'
,
'ckp'
,
1
,
'1920x1080'
,
'/homeDeviceUrl/ckp/1920x1080'
,
'1111'
,
1
,
'2022-05-31 15:52:59'
,
1
,
'2022-08-01 16:59:54'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
3
,
1
,
'呼叫器'
,
'hjq'
,
1
,
'1920x1080'
,
'/homeDeviceUrl/hjq/1920x1080'
,
''
,
1
,
'2022-05-31 15:53:12'
,
1
,
'2022-08-02 09:28:19'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
4
,
1
,
'集中显示屏'
,
'jzxsp'
,
1
,
'1920x1080'
,
'/homeDeviceUrl/jzxsp/1920x1080'
,
''
,
1
,
'2022-05-31 15:53:27'
,
1
,
'2022-08-02 09:28:28'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
5
,
1
,
'导视机'
,
'dsj'
,
NULL
,
NULL
,
NULL
,
''
,
1
,
'2022-05-31 15:53:41'
,
1
,
'2022-05-31 15:53:41'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
6
,
1
,
'评价器'
,
'pjq'
,
NULL
,
NULL
,
NULL
,
''
,
1
,
'2022-05-31 15:53:55'
,
1
,
'2022-09-19 09:41:01'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
7
,
1
,
'自助服务终端'
,
'zzfwzd'
,
NULL
,
NULL
,
NULL
,
''
,
1
,
'2022-05-31 15:54:09'
,
1
,
'2022-05-31 15:54:09'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
8
,
1
,
'填单机'
,
'tdj'
,
NULL
,
NULL
,
NULL
,
''
,
1
,
'2022-05-31 15:54:20'
,
1
,
'2022-05-31 15:54:20'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
9
,
1
,
'样表机'
,
'ybj'
,
NULL
,
NULL
,
NULL
,
''
,
1
,
'2022-05-31 15:54:29'
,
1
,
'2022-05-31 15:54:29'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
10
,
2
,
'一码通'
,
'ymt'
,
NULL
,
NULL
,
NULL
,
'123'
,
1
,
'2022-07-12 15:08:51'
,
1
,
'2022-07-12 15:08:51'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
11
,
1
,
'LED通屏'
,
'ledtp'
,
NULL
,
NULL
,
'http://www.baidu.com'
,
''
,
1
,
'2022-07-19 10:13:06'
,
1
,
'2022-07-19 10:13:06'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
13
,
4
,
'取件柜'
,
'qjg'
,
NULL
,
NULL
,
'http://www.baidu.com'
,
''
,
1
,
'2022-07-26 10:28:42'
,
1
,
'2022-07-26 10:28:42'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
14
,
5
,
'信息发布屏'
,
'xxfbp'
,
NULL
,
''
,
''
,
''
,
1
,
'2022-08-04 09:42:01'
,
1
,
'2022-08-04 09:46:51'
);
INSERT
INTO
`mortals_xhx_product`
VALUES
(
15
,
6
,
'背靠背评价设备'
,
'bkb'
,
NULL
,
''
,
''
,
'背靠背评价设备'
,
1
,
'2022-08-17 16:35:05'
,
1
,
'2022-08-17 16:35:05'
);
\ No newline at end of file
device-manager/pom.xml
View file @
ed536606
...
@@ -36,12 +36,11 @@
...
@@ -36,12 +36,11 @@
<profiles.redis.database>
7
</profiles.redis.database>
<profiles.redis.database>
7
</profiles.redis.database>
<profiles.kafka.brokers>
192.168.0.251:9092
</profiles.kafka.brokers>
<profiles.kafka.brokers>
192.168.0.251:9092
</profiles.kafka.brokers>
<profiles.queue.type>
rabbitmq
</profiles.queue.type>
<profiles.queue.type>
rabbitmq
</profiles.queue.type>
<profiles.rabbitmq.host>
1
27.0.0.1
</profiles.rabbitmq.host>
<profiles.rabbitmq.host>
1
92.168.0.98
</profiles.rabbitmq.host>
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.username>
guest
</profiles.rabbitmq.username>
<profiles.rabbitmq.username>
taxi_mq
</profiles.rabbitmq.username>
<profiles.rabbitmq.password>
guest
</profiles.rabbitmq.password>
<profiles.rabbitmq.password>
admin@2020
</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>
/test
</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.virtualhost>
/
</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.virtualhost1>
/
</profiles.rabbitmq.virtualhost1>
<profiles.rabbitmq.exchange>
amp.direct
</profiles.rabbitmq.exchange>
<profiles.rabbitmq.exchange>
amp.direct
</profiles.rabbitmq.exchange>
<profiles.sms.smsSendUrl>
http://127.0.0.1:8089/api/index/index
</profiles.sms.smsSendUrl>
<profiles.sms.smsSendUrl>
http://127.0.0.1:8089/api/index/index
</profiles.sms.smsSendUrl>
<profiles.sms.apiId>
k6BVS1PEbyzcJAE4
</profiles.sms.apiId>
<profiles.sms.apiId>
k6BVS1PEbyzcJAE4
</profiles.sms.apiId>
...
@@ -78,8 +77,7 @@
...
@@ -78,8 +77,7 @@
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.username>
taxi_mq
</profiles.rabbitmq.username>
<profiles.rabbitmq.username>
taxi_mq
</profiles.rabbitmq.username>
<profiles.rabbitmq.password>
admin@2020
</profiles.rabbitmq.password>
<profiles.rabbitmq.password>
admin@2020
</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>
/test
</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.virtualhost>
/
</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.virtualhost1>
/test
</profiles.rabbitmq.virtualhost1>
<profiles.rabbitmq.exchange>
amp.direct
</profiles.rabbitmq.exchange>
<profiles.rabbitmq.exchange>
amp.direct
</profiles.rabbitmq.exchange>
<profiles.sms.smsSendUrl>
http://127.0.0.1:8089/api/index/index
</profiles.sms.smsSendUrl>
<profiles.sms.smsSendUrl>
http://127.0.0.1:8089/api/index/index
</profiles.sms.smsSendUrl>
<profiles.sms.apiId>
k6BVS1PEbyzcJAE4
</profiles.sms.apiId>
<profiles.sms.apiId>
k6BVS1PEbyzcJAE4
</profiles.sms.apiId>
...
@@ -97,14 +95,35 @@
...
@@ -97,14 +95,35 @@
<id>
product
</id>
<id>
product
</id>
<properties>
<properties>
<profiles.active>
product
</profiles.active>
<profiles.active>
product
</profiles.active>
<profiles.server.port>
17214
</profiles.server.port>
<profiles.server.port>
18222
</profiles.server.port>
<profiles.platform.type>
cloud
</profiles.platform.type>
<profiles.queue.type>
rabbitmq
</profiles.queue.type>
<profiles.queue.type>
rabbitmq
</profiles.queue.type>
<profiles.kafka.brokers>
192.168.0.100:9092
</profiles.kafka.brokers>
<profiles.datasource.uri>
<profiles.rabbitmq.host>
192.168.0.100
</profiles.rabbitmq.host>
<![CDATA[jdbc:mysql://127.0.0.1:3306/device-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]>
</profiles.datasource.uri>
<profiles.datasource.username>
root
</profiles.datasource.username>
<profiles.datasource.password>
12345678
</profiles.datasource.password>
<profiles.redis.uri>
127.0.0.1
</profiles.redis.uri>
<profiles.redis.port>
6379
</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password>
12345678
</profiles.redis.password>
<profiles.redis.database>
6
</profiles.redis.database>
<profiles.kafka.brokers>
192.168.0.251:9092
</profiles.kafka.brokers>
<profiles.queue.type>
rabbitmq
</profiles.queue.type>
<profiles.rabbitmq.host>
192.168.0.251
</profiles.rabbitmq.host>
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.nacos.server-addr>
192.168.0.100:8848
</profiles.nacos.server-addr>
<profiles.rabbitmq.username>
root_mq
</profiles.rabbitmq.username>
<profiles.rabbitmq.password>
xhx@2022
</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>
/
</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.exchange>
amp.direct
</profiles.rabbitmq.exchange>
<profiles.sms.smsSendUrl>
http://127.0.0.1:8089/api/index/index
</profiles.sms.smsSendUrl>
<profiles.sms.apiId>
k6BVS1PEbyzcJAE4
</profiles.sms.apiId>
<profiles.sms.type>
3
</profiles.sms.type>
<profiles.filepath>
/mortals/app/data
</profiles.filepath>
<profiles.log.level>
INFO
</profiles.log.level>
<profiles.data.path>
/data
</profiles.data.path>
<profiles.nacos.server-addr>
127.0.0.1:8848
</profiles.nacos.server-addr>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.group>
DEFAULT_GROUP
</profiles.nacos.group>
<profiles.nacos.namespace>
s
tp
</profiles.nacos.namespace>
<profiles.nacos.namespace>
s
mart-gov
</profiles.nacos.namespace>
<profiles.log.path>
/mortals/app/logs
</profiles.log.path>
<profiles.log.path>
/mortals/app/logs
</profiles.log.path>
</properties>
</properties>
</profile>
</profile>
...
@@ -168,6 +187,12 @@
...
@@ -168,6 +187,12 @@
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
...
@@ -228,6 +253,23 @@
...
@@ -228,6 +253,23 @@
</resources>
</resources>
</configuration>
</configuration>
</execution>
</execution>
<execution>
<id>
copy-db
</id>
<phase>
package
</phase>
<goals>
<goal>
copy-resources
</goal>
</goals>
<configuration>
<encoding>
UTF-8
</encoding>
<outputDirectory>
${project.parent.basedir}/dist/${project.parent.artifactId}/db
</outputDirectory>
<resources>
<resource>
<directory>
../db/
</directory>
<filtering>
true
</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</executions>
</plugin>
</plugin>
</plugins>
</plugins>
...
...
device-manager/src/main/java/com/mortals/xhx/base/framework/aspect/OperlogAspect.java
View file @
ed536606
...
@@ -2,8 +2,8 @@ package com.mortals.xhx.base.framework.aspect;
...
@@ -2,8 +2,8 @@ package com.mortals.xhx.base.framework.aspect;
import
com.mortals.framework.model.OperateLogPdu
;
import
com.mortals.framework.model.OperateLogPdu
;
import
com.mortals.framework.service.ILogService
;
import
com.mortals.framework.service.ILogService
;
import
com.mortals.framework.service.IMessageProduceService
;
import
com.mortals.framework.service.impl.FileLogServiceImpl
;
import
com.mortals.framework.service.impl.FileLogServiceImpl
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
import
com.mortals.xhx.base.system.oper.service.OperLogService
;
import
com.mortals.xhx.base.system.oper.service.OperLogService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -24,7 +24,8 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
...
@@ -24,7 +24,8 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
@Autowired
@Autowired
private
OperLogService
operLogService
;
private
OperLogService
operLogService
;
@Autowired
@Autowired
private
IMessageProduceService
messageProduceService
;
private
MessageProducer
messageProducer
;
//private IMessageProduceService messageProduceService;
@Override
@Override
public
void
doHandlerLog
(
String
platformMark
,
Long
userId
,
String
userName
,
String
loginName
,
String
requestUrl
,
public
void
doHandlerLog
(
String
platformMark
,
Long
userId
,
String
userName
,
String
loginName
,
String
requestUrl
,
...
@@ -42,7 +43,7 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
...
@@ -42,7 +43,7 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
operateLogPdu
.
setLogDate
(
logDate
);
operateLogPdu
.
setLogDate
(
logDate
);
operateLogPdu
.
setContent
(
content
);
operateLogPdu
.
setContent
(
content
);
operateLogPdu
.
setOperType
(
1
);
operateLogPdu
.
setOperType
(
1
);
messageProduce
Service
.
syncOperSend
(
operateLogPdu
);
messageProduce
r
.
syncOperSend
(
operateLogPdu
);
}
}
...
@@ -54,32 +55,4 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
...
@@ -54,32 +55,4 @@ public class OperlogAspect extends FileLogServiceImpl implements ILogService {
}
}
/*@Pointcut("execution(public * com.mortals.xhx..*Controller.*(..))")
public void accessLog() {
}
@Before("accessLog()")
public void doBefore(JoinPoint joinPoint) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
// url
log.info("ip[{}]url[{}]", request.getRemoteAddr(), request.getRequestURL());
// 参数第1和第2个参数为HttpServletRequest request, HttpServletResponse
// response
if (joinPoint.getArgs().length > 2) {
log.info("args={}", joinPoint.getArgs()[2]);
} else {
log.info("args={}", joinPoint.getArgs());
}
}
@AfterReturning(returning = "object", pointcut = "accessLog()")
public void doAfterReturning(Object object) {
if (null != object) {
log.info("response={}", object.toString());
}
}*/
}
}
device-manager/src/main/java/com/mortals/xhx/base/framework/config/RabbitConfig.java
View file @
ed536606
package
com.mortals.xhx.base.framework.config
;
package
com.mortals.xhx.base.framework.config
;
import
com.mortals.xhx.base.framework.listener.DirectDynamicListener
;
import
com.mortals.xhx.base.framework.listener.RabbitLoggingErrorHandler
;
import
com.mortals.xhx.base.framework.listener.RabbitLoggingErrorHandler
;
import
com.mortals.xhx.base.framework.listener.SimpleDynamicListener
;
import
com.mortals.xhx.base.framework.listener.SimpleDynamicListener
;
import
com.mortals.xhx.base.system.message.MessageCallbackService
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
import
com.mortals.xhx.base.system.message.impl.MessageServiceImpl
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.amqp.core.AcknowledgeMode
;
import
org.springframework.amqp.core.AcknowledgeMode
;
import
org.springframework.amqp.core.MessageListener
;
import
org.springframework.amqp.rabbit.AsyncRabbitTemplate
;
import
org.springframework.amqp.rabbit.AsyncRabbitTemplate
;
import
org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory
;
import
org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory
;
import
org.springframework.amqp.rabbit.connection.CachingConnectionFactory
;
import
org.springframework.amqp.rabbit.connection.CachingConnectionFactory
;
...
@@ -30,11 +29,11 @@ public class RabbitConfig {
...
@@ -30,11 +29,11 @@ public class RabbitConfig {
@Autowired
@Autowired
private
SimpleDynamicListener
simpleDynamicListener
;
private
SimpleDynamicListener
simpleDynamicListener
;
@Autowired
@Autowired
private
DirectDynamicListener
directDynamicListener
;
@Autowired
private
RabbitLoggingErrorHandler
rabbitLoggingErrorHandler
;
private
RabbitLoggingErrorHandler
rabbitLoggingErrorHandler
;
@Autowired
@Autowired
private
MessageProducer
messageProducer
;
private
MessageProducer
messageProducer
;
@Autowired
private
MessageCallbackService
messageCallbackService
;
//@Bean("simpleMessageListenerContainer")
//@Bean("simpleMessageListenerContainer")
public
SimpleMessageListenerContainer
simpleMessageListenerContainer
(
CachingConnectionFactory
cachingConnectionFactory
)
{
public
SimpleMessageListenerContainer
simpleMessageListenerContainer
(
CachingConnectionFactory
cachingConnectionFactory
)
{
...
@@ -69,8 +68,8 @@ public class RabbitConfig {
...
@@ -69,8 +68,8 @@ public class RabbitConfig {
@Bean
@Bean
public
RabbitTemplate
rabbitTemplate
(
ConnectionFactory
connectionFactory
)
{
public
RabbitTemplate
rabbitTemplate
(
ConnectionFactory
connectionFactory
)
{
RabbitTemplate
rabbitTemplate
=
new
RabbitTemplate
(
connectionFactory
);
RabbitTemplate
rabbitTemplate
=
new
RabbitTemplate
(
connectionFactory
);
rabbitTemplate
.
setReturnCallback
(
message
Producer
);
rabbitTemplate
.
setReturnCallback
(
message
CallbackService
);
rabbitTemplate
.
setConfirmCallback
(
message
Producer
);
rabbitTemplate
.
setConfirmCallback
(
message
CallbackService
);
return
rabbitTemplate
;
return
rabbitTemplate
;
}
}
...
...
device-manager/src/main/java/com/mortals/xhx/base/framework/config/RedissonConfig.java
View file @
ed536606
...
@@ -7,8 +7,6 @@ import org.redisson.api.RedissonClient;
...
@@ -7,8 +7,6 @@ import org.redisson.api.RedissonClient;
import
org.redisson.client.codec.Codec
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.codec.JsonJacksonCodec
;
import
org.redisson.codec.JsonJacksonCodec
;
import
org.redisson.config.Config
;
import
org.redisson.config.Config
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -19,8 +17,8 @@ import org.springframework.context.annotation.Configuration;
...
@@ -19,8 +17,8 @@ import org.springframework.context.annotation.Configuration;
* @author: zxfei
* @author: zxfei
* @date: 2022/8/8 16:02
* @date: 2022/8/8 16:02
*/
*/
//
@Configuration
@Configuration
//
@ConfigurationProperties(prefix = "spring.redis")
@ConfigurationProperties
(
prefix
=
"spring.redis"
)
@Slf4j
@Slf4j
@Data
@Data
public
class
RedissonConfig
{
public
class
RedissonConfig
{
...
@@ -33,12 +31,13 @@ public class RedissonConfig {
...
@@ -33,12 +31,13 @@ public class RedissonConfig {
private
int
database
;
private
int
database
;
//
@Bean
@Bean
public
RedissonClient
redissonClient
()
{
public
RedissonClient
redissonClient
()
{
RedissonClient
redissonClient
;
RedissonClient
redissonClient
;
Config
config
=
new
Config
();
Config
config
=
new
Config
();
String
url
=
"redis://"
+
host
+
":"
+
port
;
String
url
=
"redis://"
+
host
+
":"
+
port
;
// 单节点配置
// 单节点配置
if
(
""
.
equalsIgnoreCase
(
password
))
password
=
null
;
config
.
useSingleServer
().
setAddress
(
url
).
setDatabase
(
database
).
setPassword
(
password
);
config
.
useSingleServer
().
setAddress
(
url
).
setDatabase
(
database
).
setPassword
(
password
);
//使用json序列化方式
//使用json序列化方式
Codec
codec
=
new
JsonJacksonCodec
();
Codec
codec
=
new
JsonJacksonCodec
();
...
...
device-manager/src/main/java/com/mortals/xhx/base/framework/listener/DirectDynamicListener.java
View file @
ed536606
...
@@ -18,12 +18,9 @@ import com.mortals.xhx.module.platform.model.PlatformEntity;
...
@@ -18,12 +18,9 @@ import com.mortals.xhx.module.platform.model.PlatformEntity;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.queue.DefaultTbQueueMsg
;
import
com.rabbitmq.client.Channel
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.core.MessageListener
;
import
org.springframework.amqp.core.MessageListener
;
import
org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -62,7 +59,7 @@ public class DirectDynamicListener implements MessageListener {
...
@@ -62,7 +59,7 @@ public class DirectDynamicListener implements MessageListener {
String
queue
=
message
.
getMessageProperties
().
getConsumerQueue
();
String
queue
=
message
.
getMessageProperties
().
getConsumerQueue
();
byte
[]
body
=
message
.
getBody
();
byte
[]
body
=
message
.
getBody
();
String
data
=
new
String
(
body
);
String
data
=
new
String
(
body
);
log
.
info
(
"接收到:{} ,\n消息内容为:{}"
,
queue
,
data
);
//
log.info("接收到:{} ,\n消息内容为:{}", queue, data);
DefaultQueueMsg
queueMsg
=
JSON
.
parseObject
(
data
,
DefaultQueueMsg
.
class
);
DefaultQueueMsg
queueMsg
=
JSON
.
parseObject
(
data
,
DefaultQueueMsg
.
class
);
//做相应业务,做日志操作
//做相应业务,做日志操作
String
deviceCode
=
queueMsg
.
getHeaders
().
getData
().
get
(
DEVICECODE
);
String
deviceCode
=
queueMsg
.
getHeaders
().
getData
().
get
(
DEVICECODE
);
...
...
device-manager/src/main/java/com/mortals/xhx/base/system/message/MessageCallbackService.java
0 → 100644
View file @
ed536606
package
com.mortals.xhx.base.system.message
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
public
interface
MessageCallbackService
extends
RabbitTemplate
.
ConfirmCallback
,
RabbitTemplate
.
ReturnCallback
{
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/base/system/message/MessageService.java
View file @
ed536606
...
@@ -9,7 +9,6 @@ import com.mortals.xhx.queue.TopicPartitionInfo;
...
@@ -9,7 +9,6 @@ import com.mortals.xhx.queue.TopicPartitionInfo;
public
interface
MessageService
{
public
interface
MessageService
{
/**
/**
* 发送消息
* 发送消息
*
*
...
...
device-manager/src/main/java/com/mortals/xhx/base/system/message/RabbitMessageService.java
View file @
ed536606
package
com.mortals.xhx.base.system.message
;
package
com.mortals.xhx.base.system.message
;
import
com.mortals.xhx.busiz.req.DeviceReq
;
public
interface
RabbitMessageService
{
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.queue.TbQueueCallback
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TopicPartitionInfo
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
public
interface
RabbitMessageService
extends
RabbitTemplate
.
ConfirmCallback
,
RabbitTemplate
.
ReturnCallback
{
/**
/**
...
...
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageCallbackServiceImpl.java
0 → 100644
View file @
ed536606
package
com.mortals.xhx.base.system.message.impl
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.xhx.base.system.message.MessageCallbackService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.rabbit.connection.CorrelationData
;
import
org.springframework.stereotype.Service
;
@Service
@Slf4j
public
class
MessageCallbackServiceImpl
implements
MessageCallbackService
{
@Override
public
void
confirm
(
CorrelationData
correlationData
,
boolean
ack
,
String
cause
)
{
log
.
info
(
"returnedMessage,correlationData:{},ack:{},cause:{},routingKey:{}"
,
JSON
.
toJSONString
(
correlationData
),
ack
,
cause
);
}
@Override
public
void
returnedMessage
(
Message
message
,
int
replyCode
,
String
replyText
,
String
exchange
,
String
routingKey
)
{
log
.
info
(
"returnedMessage,replyCode:{},replyText:{},exchange:{},routingKey:{}"
,
replyCode
,
replyText
,
exchange
,
routingKey
);
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageProducer.java
View file @
ed536606
...
@@ -44,13 +44,15 @@ public class MessageProducer implements IMessageProduceService, RabbitMessageSer
...
@@ -44,13 +44,15 @@ public class MessageProducer implements IMessageProduceService, RabbitMessageSer
@Override
@Override
public
void
syncErrorSend
(
ErrorLogPdu
errorLogPdu
)
{
public
void
syncErrorSend
(
ErrorLogPdu
errorLogPdu
)
{
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
ERROR_LOG_QUEUE
,
JSON
.
toJSONString
(
errorLogPdu
));
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
ERROR_LOG_QUEUE
,
JSON
.
toJSONString
(
errorLogPdu
));
}
}
@Override
@Override
public
void
syncOperSend
(
OperateLogPdu
operLogPdu
)
{
public
void
syncOperSend
(
OperateLogPdu
operLogPdu
)
{
log
.
info
(
"send poerate log ==>{}"
,
JSON
.
toJSONString
(
operLogPdu
));
log
.
info
(
"send poerate log ==>{}"
,
JSON
.
toJSONString
(
operLogPdu
));
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
OPERATION_LOG_QUEUE
,
JSON
.
toJSONString
(
operLogPdu
));
String
send
=
JSON
.
toJSONString
(
operLogPdu
);
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
OPERATION_LOG_QUEUE
,
send
);
}
}
@Override
@Override
...
@@ -81,17 +83,6 @@ public class MessageProducer implements IMessageProduceService, RabbitMessageSer
...
@@ -81,17 +83,6 @@ public class MessageProducer implements IMessageProduceService, RabbitMessageSer
return
rabbitAdmin
.
deleteQueue
(
queue
);
return
rabbitAdmin
.
deleteQueue
(
queue
);
}
}
@Override
public
void
confirm
(
CorrelationData
correlationData
,
boolean
ack
,
String
cause
)
{
}
@Override
public
void
returnedMessage
(
Message
message
,
int
replyCode
,
String
replyText
,
String
exchange
,
String
routingKey
)
{
}
@Override
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
public
void
afterPropertiesSet
()
throws
Exception
{
System
.
out
.
println
(
111
);
System
.
out
.
println
(
111
);
...
...
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageServiceImpl.java
View file @
ed536606
...
@@ -167,19 +167,13 @@ public class MessageServiceImpl implements MessageService{
...
@@ -167,19 +167,13 @@ public class MessageServiceImpl implements MessageService{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
try
{
try
{
throw
new
Exception
(
"1213"
);
throw
new
Exception
(
"1213"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
String
stacktrace
=
ExceptionUtil
.
stacktraceToString
(
e
.
fillInStackTrace
());
String
stacktrace
=
ExceptionUtil
.
stacktraceToString
(
e
.
fillInStackTrace
());
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"stacktrace"
,
stacktrace
);
jsonObject
.
put
(
"stacktrace"
,
stacktrace
);
System
.
out
.
println
(
JSON
.
toJSONString
(
jsonObject
));
System
.
out
.
println
(
JSON
.
toJSONString
(
jsonObject
));
}
}
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/req/TestReq.java
0 → 100644
View file @
ed536606
package
com.mortals.xhx.busiz.req
;
import
com.fasterxml.jackson.databind.annotation.JsonDeserialize
;
import
com.mortals.xhx.base.framework.CustomJsonDateDeserializer
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
public
class
TestReq
implements
Serializable
{
/**
* 1:新增,2:修改,3:删除,4:激活,5:启用,6:停用
*/
private
Integer
receiveMethod
;
// /**
// * 平台系统id
// */
// private Long platformId;
// /**
// * 平台系统编码
// */
// private String platformCode;
/**
* 产品id
*/
private
Long
productId
;
/**
* 产品编码
*/
private
String
productCode
;
/**
* 设备生产厂商ID
*/
private
Long
deviceFirmId
;
/**
* 设备生产厂商名称
*/
private
String
deviceFirmname
;
/**
* 设备名称
*/
private
String
deviceName
;
/**
* 设备编码(暂定mac地址)
*/
private
String
deviceCode
;
/**
* 设备Mac
*/
private
String
deviceMac
;
/**
* 所属站点Id
*/
private
Long
siteId
;
/**
* 所属站点编码
*/
private
String
siteCode
;
/**
* 所属站点名称
*/
private
String
siteName
;
/**
* 设备备注信息
*/
private
String
deviceRemark
;
/**
* 设备
*/
private
String
homeUrl
;
/**
* 设备访问ip
*/
private
String
ip
;
/**
* 中心设备编码
*/
private
String
centernum
;
/**
* 端口
*/
private
String
port
;
/**
* 经度
*/
private
String
lon
;
/**
* 纬度
*/
private
String
lati
;
/**
* 楼层
*/
private
Integer
deviceInBuilding
;
/**
* 所属楼栋
*/
private
Integer
deviceInFloor
;
/**
* 负责人
*/
private
String
leadingOfficial
;
/**
* 联系电话
*/
private
String
leadingOfficialTelephone
;
/**
* 保修期至
*/
@JsonDeserialize
(
using
=
CustomJsonDateDeserializer
.
class
)
private
Date
defectsLiabilityPeriod
;
/**
* 设备状态 (0.未激活,1.离线,2.在线)
*/
private
Integer
deviceStatus
;
/**
* 设备来源(0.旧设备,1.新设备)
*/
private
Integer
source
;
/**
* 激活(0.否,1.是)
*/
private
Integer
active
;
/**
* 设备版本信息
*/
private
String
deviceVersion
;
}
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
ed536606
package
com.mortals.xhx.busiz.web
;
package
com.mortals.xhx.busiz.web
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.net.url.UrlBuilder
;
import
cn.hutool.core.net.url.UrlBuilder
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.extra.servlet.ServletUtil
;
import
cn.hutool.extra.servlet.ServletUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ILogService
;
import
com.mortals.framework.service.ILogService
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.service.impl.FileLogServiceImpl
;
import
com.mortals.framework.service.impl.FileLogServiceImpl
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.base.framework.annotation.ApiUserAuth
;
import
com.mortals.xhx.base.framework.annotation.ApiUserAuth
;
import
com.mortals.xhx.base.login.web.LoginForm
;
import
com.mortals.xhx.base.login.web.LoginForm
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
...
@@ -34,8 +28,6 @@ import com.mortals.xhx.common.key.Constant;
...
@@ -34,8 +28,6 @@ import com.mortals.xhx.common.key.Constant;
import
com.mortals.xhx.common.key.QueueKey
;
import
com.mortals.xhx.common.key.QueueKey
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.pdu.DefaultQueueMsg
;
import
com.mortals.xhx.common.pdu.DefaultQueueMsgHeader
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.BeanUtil
;
...
@@ -49,7 +41,6 @@ import com.mortals.xhx.module.device.service.DeviceService;
...
@@ -49,7 +41,6 @@ import com.mortals.xhx.module.device.service.DeviceService;
import
com.mortals.xhx.module.firm.model.FirmEntity
;
import
com.mortals.xhx.module.firm.model.FirmEntity
;
import
com.mortals.xhx.module.firm.service.FirmService
;
import
com.mortals.xhx.module.firm.service.FirmService
;
import
com.mortals.xhx.module.platform.model.PlatformEntity
;
import
com.mortals.xhx.module.platform.model.PlatformEntity
;
import
com.mortals.xhx.module.platform.model.PlatformQuery
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.model.ProductQuery
;
import
com.mortals.xhx.module.product.model.ProductQuery
;
...
@@ -62,14 +53,12 @@ import com.mortals.xhx.module.site.service.SiteService;
...
@@ -62,14 +53,12 @@ import com.mortals.xhx.module.site.service.SiteService;
import
com.mortals.xhx.queue.DefaultTbQueueMsg
;
import
com.mortals.xhx.queue.DefaultTbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TopicPartitionInfo
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -78,7 +67,6 @@ import java.util.Date;
...
@@ -78,7 +67,6 @@ import java.util.Date;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
framework
.
ap
.
SysConstains
.
PROP_PLATFORM_MARK
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.*;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.*;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
ErrorCode
.*;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
ErrorCode
.*;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
RedisKey
.
KEY_TOKEN_API_CACHE
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
RedisKey
.
KEY_TOKEN_API_CACHE
;
...
@@ -103,17 +91,17 @@ public class DeviceApiController {
...
@@ -103,17 +91,17 @@ public class DeviceApiController {
private
ProductVersionService
productVersionService
;
private
ProductVersionService
productVersionService
;
@Autowired
@Autowired
private
PlatformService
platformService
;
private
PlatformService
platformService
;
@Value
(
"${
queue.rabbitmq.virtual_
host:}"
)
@Value
(
"${
rabbitmq.virtual-
host:}"
)
private
String
virtualHost
;
private
String
virtualHost
;
@Value
(
"${
queue.
rabbitmq.password:}"
)
@Value
(
"${rabbitmq.password:}"
)
private
String
password
;
private
String
password
;
@Value
(
"${
queue.
rabbitmq.host:}"
)
@Value
(
"${rabbitmq.host:}"
)
private
String
host
;
private
String
host
;
@Value
(
"${
queue.rabbitmq.port:
}"
)
@Value
(
"${
rabbitmq.port:0
}"
)
private
int
port
;
private
int
port
;
@Value
(
"${
queue.
rabbitmq.username:}"
)
@Value
(
"${rabbitmq.username:}"
)
private
String
username
;
private
String
username
;
@Value
(
"${
queue.
rabbitmq.queue-properties.x-message-ttl:86400000}"
)
@Value
(
"${rabbitmq.queue-properties.x-message-ttl:86400000}"
)
private
String
messageTtl
;
private
String
messageTtl
;
@Value
(
"${token.secret}"
)
@Value
(
"${token.secret}"
)
private
String
secret
;
private
String
secret
;
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/web/TestSendMsgController.java
0 → 100644
View file @
ed536606
package
com.mortals.xhx.busiz.web
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ILogService
;
import
com.mortals.framework.service.impl.FileLogServiceImpl
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.busiz.req.TestReq
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.busiz.rsp.DeviceResp
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
com.mortals.xhx.common.utils.SendTaskThreadPool
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.device.service.DeviceLogService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.firm.service.FirmService
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.module.product.service.ProductVersionService
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 设备
*
* @author: zxfei
* @date: 2021/8/24 20:28
*/
@RestController
@Slf4j
@RequestMapping
(
"/test"
)
public
class
TestSendMsgController
{
@Autowired
private
DeviceService
deviceService
;
@Autowired
private
ProductService
productService
;
@Autowired
private
UserService
userService
;
@Autowired
private
ProductVersionService
productVersionService
;
@Autowired
private
PlatformService
platformService
;
@Value
(
"${queue.rabbitmq.virtual_host:}"
)
private
String
virtualHost
;
@Value
(
"${queue.rabbitmq.password:}"
)
private
String
password
;
@Value
(
"${queue.rabbitmq.host:}"
)
private
String
host
;
@Value
(
"${queue.rabbitmq.port:0}"
)
private
int
port
;
@Value
(
"${queue.rabbitmq.username:}"
)
private
String
username
;
@Value
(
"${queue.rabbitmq.queue-properties.x-message-ttl:86400000}"
)
private
String
messageTtl
;
@Value
(
"${token.secret}"
)
private
String
secret
;
@Autowired
private
SendTaskThreadPool
sendTaskThreadPool
;
@Autowired
private
ISiteFeign
siteFeign
;
@Value
(
"${platform.type:cloud}"
)
private
String
platFormType
;
//版本,默认云服务版本
@Autowired
private
SiteService
siteService
;
@Autowired
private
FirmService
firmService
;
@Autowired
private
DeviceLogService
deviceLogService
;
@Autowired
private
ICacheService
cacheService
;
@Autowired
private
MessageProducer
messageProducer
;
@Autowired
protected
ILogService
logService
=
FileLogServiceImpl
.
getInstance
();
/**
* 发送日志消息
*
* @param req
* @return
*/
@PostMapping
(
"log"
)
public
String
register
(
@RequestBody
TestReq
req
)
{
log
.
info
(
"【测试消息】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
ApiResp
<
DeviceResp
>
rsp
=
new
ApiResp
<>();
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
log
.
info
(
"响应【设备注册】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
}
}
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/NettyStartedService.java
View file @
ed536606
package
com.mortals.xhx.daemon.applicationservice
;
package
com.mortals.xhx.daemon.applicationservice
;
import
com.mortals.framework.springcloud.service.IApplicationStartedService
;
import
com.mortals.framework.springcloud.service.IApplicationStartedService
;
import
com.mortals.xhx.daemon.netty.config.NettyServerConfig
;
import
com.mortals.xhx.daemon.netty.server.controlserver.ControlServer
;
import
com.mortals.xhx.daemon.netty.server.controlserver.ControlServer
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -40,7 +37,7 @@ public class NettyStartedService implements IApplicationStartedService {
...
@@ -40,7 +37,7 @@ public class NettyStartedService implements IApplicationStartedService {
@Override
@Override
public
void
stop
()
{
public
void
stop
()
{
log
.
info
(
"停止服务.."
);
log
.
info
(
"
netty
停止服务.."
);
if
(
thread
!=
null
)
{
if
(
thread
!=
null
)
{
thread
.
interrupt
();
thread
.
interrupt
();
}
}
...
...
device-manager/src/main/java/com/mortals/xhx/daemon/netty/server/controlserver/ControlServer.java
View file @
ed536606
package
com.mortals.xhx.daemon.netty.server.controlserver
;
package
com.mortals.xhx.daemon.netty.server.controlserver
;
import
com.mortals.xhx.daemon.netty.config.NettyServerConfig
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
io.netty.bootstrap.Bootstrap
;
import
io.netty.bootstrap.Bootstrap
;
import
io.netty.channel.Channel
;
import
io.netty.channel.Channel
;
...
@@ -14,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -14,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PreDestroy
;
import
javax.annotation.PreDestroy
;
import
javax.annotation.Resource
;
import
java.net.Inet4Address
;
import
java.net.Inet4Address
;
@Component
@Component
...
@@ -63,9 +61,9 @@ public class ControlServer {
...
@@ -63,9 +61,9 @@ public class ControlServer {
@PreDestroy
@PreDestroy
public
void
release
()
{
public
void
release
()
{
isClosed
=
true
;
closeChannel
();
closeChannel
();
closeServerBootstrap
();
closeServerBootstrap
();
isClosed
=
true
;
}
}
/**
/**
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
ed536606
...
@@ -170,8 +170,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -170,8 +170,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
resp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
resp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
resp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
resp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
//messageProducer.sendMsg();
messageService
.
send
(
info
,
header
,
message
,
callback
);
messageService
.
send
(
info
,
header
,
message
,
callback
);
return
resp
;
return
resp
;
}
}
...
@@ -272,39 +270,11 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -272,39 +270,11 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
super
.
saveAfter
(
entity
,
context
);
super
.
saveAfter
(
entity
,
context
);
}
}
/* private void registerRabbitQueue(DeviceEntity entity, PlatformEntity platformEntity, ProductEntity productEntity) {
String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
TopicPartitionInfo info = TopicPartitionInfo.builder().exchangeName(exchangeName).topic(Constant.UPLOAD_TOPIC + entity.getDeviceCode()).build();
TbQueueCallback callback = new TbQueueCallback() {
@Override
public void onSuccess(TbQueueMsgMetadata metadata) {
log.debug("队列创建成功,设备编码:{}", entity.getDeviceCode());
}
@Override
public void onFailure(Throwable t) {
log.error("队列创建失败,设备通道编码:{},{}", entity.getDeviceCode(), t);
}
};
messageService.queueDeclare(info, callback);
//消费监听线程添加当前声明队列
Set<TopicPartitionInfo> partitions = new HashSet<>();
partitions.add(info);
consumerService.getMainConsumer().subscribe(partitions);
//创建下行队列
info = TopicPartitionInfo.builder().exchangeName(exchangeName).topic(Constant.DOWN_TOPIC + entity.getDeviceCode()).build();
messageService.queueDeclare(info, callback);
}*/
@Override
@Override
protected
void
updateAfter
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
updateAfter
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
PlatformEntity
platformEntity
=
platformService
.
get
(
entity
.
getPlatformId
());
PlatformEntity
platformEntity
=
platformService
.
get
(
entity
.
getPlatformId
());
ProductEntity
productEntity
=
productService
.
get
(
entity
.
getProductId
());
ProductEntity
productEntity
=
productService
.
get
(
entity
.
getProductId
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
!
ObjectUtils
.
isEmpty
(
productEntity
))
{
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
!
ObjectUtils
.
isEmpty
(
productEntity
))
{
//新增设备通知第三方平台 激活后的设备才通知和更新
//新增设备通知第三方平台 激活后的设备才通知和更新
if
(
entity
.
getDeviceStatus
()
>
0
)
{
if
(
entity
.
getDeviceStatus
()
>
0
)
{
//注册rabbmit相关队列与绑定
//注册rabbmit相关队列与绑定
...
...
device-manager/src/main/resources/bootstrap.yml
View file @
ed536606
...
@@ -20,11 +20,6 @@ spring:
...
@@ -20,11 +20,6 @@ spring:
default-property-inclusion
:
NON_NULL
default-property-inclusion
:
NON_NULL
# time-zone: GMT+8
# time-zone: GMT+8
# date-format: yyyy-MM-dd HH:mm:ss
# date-format: yyyy-MM-dd HH:mm:ss
security
:
enable
:
true
user
:
name
:
admin
password
:
1
redis
:
redis
:
host
:
@
profiles.redis.uri@
host
:
@
profiles.redis.uri@
port
:
@
profiles.redis.port@
port
:
@
profiles.redis.port@
...
@@ -58,7 +53,7 @@ spring:
...
@@ -58,7 +53,7 @@ spring:
username
:
@
profiles.rabbitmq.username@
username
:
@
profiles.rabbitmq.username@
password
:
@
profiles.rabbitmq.password@
password
:
@
profiles.rabbitmq.password@
exchange-name
:
@
profiles.rabbitmq.exchange@
exchange-name
:
@
profiles.rabbitmq.exchange@
virtual-host
:
@
profiles.rabbitmq.virtualhost
1
@
virtual-host
:
@
profiles.rabbitmq.virtualhost@
publisher-returns
:
true
publisher-returns
:
true
publisher-confirm-type
:
correlated
publisher-confirm-type
:
correlated
dao
:
dao
:
...
@@ -98,44 +93,4 @@ sms:
...
@@ -98,44 +93,4 @@ sms:
apiId
:
@
profiles.sms.apiId@
apiId
:
@
profiles.sms.apiId@
type
:
@
profiles.sms.type@
type
:
@
profiles.sms.type@
queue
:
type
:
@
profiles.queue.type@
# memory or kafka (Apache Kafka) or rabbitmq (RabbitMQ)
core
:
topic
:
tb_core
poll-interval
:
25
partitions
:
10
pack-processing-timeout
:
2000
in_memory
:
stats
:
print-interval-ms
:
60000
kafka
:
bootstrap.servers
:
@
profiles.kafka.brokers@
acks
:
all
retries
:
1
batch.size
:
16384
linger.ms
:
1
buffer.memory
:
33554432
replication_factor
:
1
max_poll_interval_ms
:
300000
max_poll_records
:
8192
max_partition_fetch_bytes
:
16777216
fetch_max_bytes
:
134217728
use_confluent_cloud
:
false
consumer-stats
:
enabled
:
true
print-interval-ms
:
60000
kafka-response-timeout-ms
:
1000
rabbitmq
:
exchange_name
:
@
profiles.rabbitmq.exchange@
host
:
@
profiles.rabbitmq.host@
port
:
@
profiles.rabbitmq.port@
virtual_host
:
@
profiles.rabbitmq.virtualhost@
username
:
@
profiles.rabbitmq.username@
password
:
@
profiles.rabbitmq.password@
automatic_recovery_enabled
:
false
connection_timeout
:
5000
handshake_timeout
:
10000
queue-properties
:
x-message-ttl
:
86400000
x-max-length-bytes
:
1048576000
device-manager/src/test/java/producer/ProducerTest.java
0 → 100644
View file @
ed536606
package
producer
;
//package producer;
import
cn.hutool.core.util.IdUtil
;
import
com.mortals.framework.model.AccessLogPdu
;
import
com.mortals.framework.model.BizLogPdu
;
import
com.mortals.framework.model.ErrorLogPdu
;
import
com.mortals.framework.model.OperateLogPdu
;
import
com.mortals.framework.service.IMessageProduceService
;
import
com.mortals.xhx.ManagerApplication
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.util.Date
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
ManagerApplication
.
class
)
@Slf4j
public
class
ProducerTest
{
@Autowired
private
IMessageProduceService
producer
;
// private MessageProducer producer;
@Test
public
void
testSyncAccessSend
()
{
for
(
int
i
=
0
;
i
<
50
;
i
++)
{
AccessLogPdu
accessLogPdu
=
new
AccessLogPdu
();
accessLogPdu
.
initAttrValue
();
accessLogPdu
.
setTraceID
(
IdUtil
.
fastSimpleUUID
());
accessLogPdu
.
setLogTime
(
new
Date
());
producer
.
syncAccessSend
(
accessLogPdu
);
log
.
info
(
"[testSyncSend][发送编号:[{}] 发送成功]"
,
accessLogPdu
.
getTraceID
());
}
}
@Test
public
void
testSyncBizSend
()
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
BizLogPdu
bizLogEntity
=
new
BizLogPdu
();
bizLogEntity
.
initAttrValue
();
bizLogEntity
.
setTraceID
(
IdUtil
.
fastSimpleUUID
());
bizLogEntity
.
setLogTime
(
new
Date
());
producer
.
syncBizSend
(
bizLogEntity
);
log
.
info
(
"[testSyncSend][发送编号:[{}] 发送成功]"
,
bizLogEntity
.
getTraceID
());
}
}
@Test
public
void
testSyncErrorSend
()
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
ErrorLogPdu
errorLogPdu
=
new
ErrorLogPdu
();
errorLogPdu
.
initAttrValue
();
errorLogPdu
.
setTraceID
(
IdUtil
.
fastSimpleUUID
());
errorLogPdu
.
setLogTime
(
new
Date
());
producer
.
syncErrorSend
(
errorLogPdu
);
log
.
info
(
"[testSyncSend][发送编号:[{}] 发送成功]"
,
errorLogPdu
.
getTraceID
());
}
}
@Test
public
void
testSyncOperSend
()
{
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
OperateLogPdu
operateLogPdu
=
new
OperateLogPdu
();
operateLogPdu
.
initAttrValue
();
operateLogPdu
.
setIp
(
"192.168.0.98"
);
operateLogPdu
.
setRequestUrl
(
"requestUrl"
);
operateLogPdu
.
setUserId
(
1L
);
operateLogPdu
.
setUserName
(
"userName"
);
operateLogPdu
.
setLoginName
(
"loginName"
);
operateLogPdu
.
setPlatformMark
(
"platformMark"
);
operateLogPdu
.
setLogDate
(
new
Date
());
operateLogPdu
.
setContent
(
"content"
);
operateLogPdu
.
setOperType
(
1
);
producer
.
syncOperSend
(
operateLogPdu
);
log
.
info
(
"[testSyncOperSend][发送成功]"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment