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
069b326f
Commit
069b326f
authored
Dec 16, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分组更新设备
parent
8b8fff95
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
13 deletions
+30
-13
device-manager/src/main/java/com/mortals/xhx/daemon/DemoApiController.java
...c/main/java/com/mortals/xhx/daemon/DemoApiController.java
+24
-13
device-manager/src/test/java/com/mortals/httpclient/system.http
...-manager/src/test/java/com/mortals/httpclient/system.http
+6
-0
No files found.
device-manager/src/main/java/com/mortals/xhx/daemon/DemoApiController.java
View file @
069b326f
package
com.mortals.xhx.daemon
;
import
cn.hutool.core.util.IdUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.b
usiz.req.UploadDeviceReq
;
import
com.mortals.xhx.b
ase.system.message.impl.MessageProducer
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
com.mortals.xhx.common.code.OneThingRespCodeEnum
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.QueueKey
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
...
...
@@ -19,10 +21,7 @@ import com.mortals.xhx.module.platform.model.PlatformEntity;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TbQueueProducer
;
import
com.mortals.xhx.queue.TopicPartitionInfo
;
import
com.mortals.xhx.queue.*
;
import
com.mortals.xhx.queue.provider.TbCoreQueueProducerProvider
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -44,7 +43,7 @@ import java.util.Map;
@RequestMapping
(
"/test/"
)
public
class
DemoApiController
{
// @Autowired
// @Autowired
private
TbCoreQueueProducerProvider
producerProvider
;
@Autowired
private
DeviceService
deviceService
;
...
...
@@ -55,16 +54,19 @@ public class DemoApiController {
@Autowired
private
MessageService
messageService
;
@Autowired
private
MessageProducer
messageProducer
;
@PostMapping
(
"/sentry"
)
public
String
sentry
(
@RequestBody
String
body
)
{
log
.
info
(
"body==>{}"
,
body
);
log
.
info
(
"body==>{}"
,
body
);
return
"success"
;
}
@PostMapping
(
"/getToken"
)
public
String
getToken
()
{
return
messageService
.
getBasePlatformToken
();
return
messageService
.
getBasePlatformToken
();
}
...
...
@@ -143,7 +145,7 @@ public class DemoApiController {
*/
@PostMapping
(
"upload"
)
@UnAuth
public
String
upload
(
@RequestParam
(
value
=
"deviceId"
)
Long
deviceId
)
{
public
String
upload
(
@RequestParam
(
value
=
"deviceId"
)
Long
deviceId
)
{
ApiResp
<
String
>
rsp
=
new
ApiResp
<>();
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
...
...
@@ -164,16 +166,25 @@ public class DemoApiController {
}
String
exchangeName
=
platformEntity
.
getPlatformSn
()
+
Constant
.
EXCHANGE_SPLIT
+
productEntity
.
getProductCode
();
TopicPartitionInfo
info
=
TopicPartitionInfo
.
builder
().
exchangeName
(
exchangeName
).
topic
(
Constant
.
UPLOAD_TOPIC
+
deviceEntity
.
getDeviceMac
()).
build
();
/*
TopicPartitionInfo info = TopicPartitionInfo.builder().exchangeName(exchangeName).topic(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceMac()).build();
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, Constant.MESSAGETYPE_HEARTBEAT);
UploadDeviceReq uploadDeviceReq = new UploadDeviceReq();
//uploadDeviceReq.setDeviceMac(deviceEntity.getDeviceMac());
uploadDeviceReq.setDeviceCode(deviceEntity.getDeviceCode());
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
deviceService
.
sendDeviceMessage
(
deviceEntity
,
info
,
header
,
JSON
.
toJSONString
(
deviceEntity
),
null
,
null
);
}
deviceService.sendDeviceMessage(deviceEntity, info, header, JSON.toJSONString(deviceEntity), null, null);
*/
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
Constant
.
MESSAGETYPE_HEARTBEAT
);
header
.
put
(
MessageHeader
.
DEVICECODE
,
deviceEntity
.
getDeviceCode
());
// header.put(MessageHeader.TIMESTAMP, );
TbQueueMsg
queueMsg
=
new
DefaultTbQueueMsg
(
IdUtil
.
fastUUID
(),
"w=="
,
header
);
messageProducer
.
sendMsg
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
(),
JSON
.
toJSONString
(
queueMsg
));
}
}
catch
(
Exception
e
)
{
...
...
device-manager/src/test/java/com/mortals/httpclient/system.http
View file @
069b326f
...
...
@@ -65,6 +65,12 @@ Authorization: {{authToken}}
Accept: application/json
###设备上报
POST {{baseUrl}}/test/upload?deviceId=1
...
...
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