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
0ca26c69
Commit
0ca26c69
authored
May 14, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加离线 上线日志
parent
777344ec
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
128 additions
and
10 deletions
+128
-10
device-manager/pom.xml
device-manager/pom.xml
+0
-2
device-manager/src/main/java/com/mortals/xhx/busiz/req/UploadDeviceReq.java
.../main/java/com/mortals/xhx/busiz/req/UploadDeviceReq.java
+6
-1
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+14
-1
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
...va/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
+68
-6
device-manager/src/main/java/com/mortals/xhx/busiz/web/TestSendMsgController.java
...java/com/mortals/xhx/busiz/web/TestSendMsgController.java
+2
-0
doc/api.md
doc/api.md
+38
-0
No files found.
device-manager/pom.xml
View file @
0ca26c69
...
...
@@ -148,8 +148,6 @@
<profiles.redis.password>
hotel@2020
</profiles.redis.password>
<profiles.redis.database>
6
</profiles.redis.database>
<profiles.redis.database>
6
</profiles.redis.database>
<profiles.rabbitmq.host>
172.15.28.115
</profiles.rabbitmq.host>
<profiles.rabbitmq.port>
5672
</profiles.rabbitmq.port>
<profiles.rabbitmq.username>
taxi_mq
</profiles.rabbitmq.username>
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/req/UploadDeviceReq.java
View file @
0ca26c69
...
...
@@ -2,7 +2,7 @@ package com.mortals.xhx.busiz.req;
import
lombok.Data
;
import
java.
io.Serializable
;
import
java.
util.List
;
@Data
...
...
@@ -14,5 +14,10 @@ public class UploadDeviceReq extends DeviceReq {
private
String
action
;
private
List
<
String
>
deviceCodeList
;
private
String
content
;
}
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
0ca26c69
package
com.mortals.xhx.busiz.web
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.lang.Validator
;
import
cn.hutool.core.net.URLDecoder
;
...
...
@@ -990,7 +991,7 @@ public class DeviceApiController {
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
domain
=
"http://10.12.185.213:11078"
;
UrlBuilder
urlBuilder
=
UrlBuilder
.
ofHttp
(
domain
).
addPath
(
"test"
);
...
...
@@ -1025,6 +1026,18 @@ public class DeviceApiController {
System.out.println(decrypt);*/
//String content = EncryptUtil.myEnscrt("", 9, DES_STR, ENCRYPT_STR);
//System.out.println(content);
/* String decrypt = EncryptUtil.decrypt("W10=", ENCRYPT_STR);
System.out.println(decrypt);*/
System
.
out
.
println
(
new
String
(
Base64
.
decode
(
"W10="
)));
}
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
View file @
0ca26c69
package
com.mortals.xhx.busiz.web
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.util.IdUtil
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -25,6 +26,7 @@ import com.mortals.xhx.queue.TbQueueMsg;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -68,7 +70,7 @@ public class DeviceSendMsgController {
header
.
put
(
MessageHeader
.
DEVICECODE
,
deviceEntity
.
getDeviceCode
());
header
.
put
(
MessageHeader
.
TIMESTAMP
,
DateUtils
.
getCurrStrDateTime
());
TbQueueMsg
queueMsg
=
new
DefaultTbQueueMsg
(
IdUtil
.
fastUUID
(),
"W10="
,
header
);
messageProducer
.
sendMsg
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
(),
JSON
.
toJSONString
(
queueMsg
));
messageProducer
.
sendMsg
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
(),
JSON
.
toJSONString
(
queueMsg
));
DeviceLogEntity
deviceLogEntity
=
new
DeviceLogEntity
();
deviceLogEntity
.
initAttrValue
();
...
...
@@ -82,13 +84,12 @@ public class DeviceSendMsgController {
deviceLogEntity
.
setLogType
(
LogTypeEnum
.
下发服务
.
getValue
());
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
,
null
);
deviceLogService
.
save
(
deviceLogEntity
,
null
);
}
TimeUnit
.
SECONDS
.
sleep
(
1
);
}
}
catch
(
InterruptedException
e
)
{
log
.
error
(
"异常"
,
e
);
}
catch
(
InterruptedException
e
)
{
log
.
error
(
"异常"
,
e
);
}
};
Thread
thread
=
new
Thread
(
runnable
);
...
...
@@ -105,5 +106,66 @@ public class DeviceSendMsgController {
}
/**
* 下发消息
*
* @param req
* @return
*/
@PostMapping
(
"downMsg"
)
@UnAuth
public
String
downMsg
(
@RequestBody
UploadDeviceReq
req
)
{
log
.
info
(
"【设备通知数据】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
ApiResp
<
String
>
rsp
=
new
ApiResp
<>();
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
try
{
if
(
ObjectUtils
.
isEmpty
(
req
.
getDeviceCodeList
()))
{
DeviceQuery
deviceQuery
=
new
DeviceQuery
();
deviceQuery
.
setDeviceCodeList
(
req
.
getDeviceCodeList
());
//查询站点设备并通知每个设备
List
<
DeviceEntity
>
deviceList
=
deviceService
.
find
(
deviceQuery
);
String
content
=
"W10="
;
if
(
ObjectUtils
.
isEmpty
(
req
.
getContent
()))
{
content
=
Base64
.
encode
(
req
.
getContent
());
}
try
{
for
(
DeviceEntity
deviceEntity
:
deviceList
)
{
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
req
.
getAction
());
header
.
put
(
MessageHeader
.
DEVICECODE
,
deviceEntity
.
getDeviceCode
());
header
.
put
(
MessageHeader
.
TIMESTAMP
,
DateUtils
.
getCurrStrDateTime
());
TbQueueMsg
queueMsg
=
new
DefaultTbQueueMsg
(
IdUtil
.
fastUUID
(),
content
,
header
);
messageProducer
.
sendMsg
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
(),
JSON
.
toJSONString
(
queueMsg
));
DeviceLogEntity
deviceLogEntity
=
new
DeviceLogEntity
();
deviceLogEntity
.
initAttrValue
();
deviceLogEntity
.
setTraceID
(
IdUtil
.
fastSimpleUUID
());
deviceLogEntity
.
setSiteId
(
deviceEntity
.
getSiteId
());
deviceLogEntity
.
setDeviceId
(
deviceEntity
.
getId
());
deviceLogEntity
.
setDeviceName
(
deviceEntity
.
getDeviceName
());
deviceLogEntity
.
setDeviceCode
(
deviceEntity
.
getDeviceCode
());
deviceLogEntity
.
setMessageHead
(
req
.
getAction
());
deviceLogEntity
.
setContent
(
content
);
deviceLogEntity
.
setLogType
(
LogTypeEnum
.
下发服务
.
getValue
());
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
,
null
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"异常"
,
e
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
log
.
debug
(
"响应【设备通知刷新数据】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
}
}
device-manager/src/main/java/com/mortals/xhx/busiz/web/TestSendMsgController.java
View file @
0ca26c69
...
...
@@ -152,6 +152,8 @@ public class TestSendMsgController {
*/
}
...
...
doc/api.md
View file @
0ca26c69
...
...
@@ -726,6 +726,44 @@ data|object|数据对象|-
```
### 接收第三方平台下发设备消息
**请求URL:**
m/notify/downMsg
**请求方式:**
POST
**内容类型:**
application/json;charset=utf-8
**简要描述:**
**请求参数:**
参数名称| 类型 |备注|必填|其它
:------|:--------|:--|:---|:---
deviceCodeList| Arrays |设备编码列表|是|-
action| String |设备下发消息行为,消息类型编号|是|-
content| String |下发消息内容|是|默认为[]数组内容
**请求样例:**
```
{}
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码|见附录码表
msg|String|消息|-
data|object|数据对象|-
**响应消息样例:**
```
```
### 接收第三方平台命令消息
**请求URL:**
m/api/callback
...
...
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