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
9ae55436
Commit
9ae55436
authored
Feb 05, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加批量激活设备
parent
cf881f2c
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
216 additions
and
129 deletions
+216
-129
device-manager-ui/admin/src/components/Pagination.vue
device-manager-ui/admin/src/components/Pagination.vue
+2
-2
device-manager-ui/admin/src/views/device/list.vue
device-manager-ui/admin/src/views/device/list.vue
+54
-1
device-manager-ui/admin/src/views/device/log/list.vue
device-manager-ui/admin/src/views/device/log/list.vue
+7
-1
device-manager/src/main/java/com/mortals/xhx/base/framework/config/RabbitConfig.java
...a/com/mortals/xhx/base/framework/config/RabbitConfig.java
+1
-2
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
...va/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
+36
-23
device-manager/src/main/java/com/mortals/xhx/common/key/Constant.java
...er/src/main/java/com/mortals/xhx/common/key/Constant.java
+5
-0
device-manager/src/main/java/com/mortals/xhx/common/utils/DownMsgTask.java
...c/main/java/com/mortals/xhx/common/utils/DownMsgTask.java
+41
-61
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
.../com/mortals/xhx/module/device/service/DeviceService.java
+9
-0
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceLogServiceImpl.java
.../xhx/module/device/service/impl/DeviceLogServiceImpl.java
+1
-1
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+41
-0
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
...a/com/mortals/xhx/module/device/web/DeviceController.java
+19
-0
device-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductServiceImpl.java
...s/xhx/module/product/service/impl/ProductServiceImpl.java
+0
-38
No files found.
device-manager-ui/admin/src/components/Pagination.vue
View file @
9ae55436
// 列表-分页
// 列表-分页
<
template
>
<div
class=
"pagination-wapper flex"
>
...
...
@@ -7,7 +7,7 @@
@
size-change=
"handleSizeChange"
:current-page=
"currPage"
:page-size=
"currSize"
:page-sizes=
"[10, 20, 50, 100, 200]"
:page-sizes=
"[10, 20, 50, 100, 200
, 500
]"
layout=
"sizes, total, prev, pager, next, jumper"
:total=
"total"
>
...
...
device-manager-ui/admin/src/views/device/list.vue
View file @
9ae55436
...
...
@@ -47,7 +47,15 @@
icon=
"el-icon-tickets"
size=
"mini"
@
click=
"batchActiveDevice"
>
批量激活设备
</el-button
>
批量激活
</el-button
>
<el-button
slot=
"table-head-left2"
style=
"margin-left: 10px"
icon=
"el-icon-tickets"
size=
"mini"
@
click=
"batchRestartApp"
>
批量重启
</el-button
>
<el-tag
slot=
"table-head-row2-left"
...
...
@@ -357,6 +365,36 @@ export default {
});
},
batchRestartApp
(
row
)
{
this
.
$post
(
"
/device/restartApp
"
,
{
idList
:
this
.
selection
,
})
.
then
((
res
)
=>
{
if
(
res
.
code
==
1
)
{
this
.
$message
.
success
(
"
批量重启设备应用成功!
"
);
this
.
getData
();
}
})
.
catch
((
error
)
=>
{
this
.
$message
.
error
(
error
.
message
);
});
},
restartApp
(
row
)
{
this
.
$post
(
"
/device/restartApp
"
,
{
idList
:
[
row
.
id
],
})
.
then
((
res
)
=>
{
if
(
res
.
code
==
1
)
{
this
.
$message
.
success
(
"
重启设备应用成功!
"
);
this
.
getData
();
}
})
.
catch
((
error
)
=>
{
this
.
$message
.
error
(
error
.
message
);
});
},
updateSite
(
row
)
{
this
.
$get
(
"
/sitestat/siteTree
"
,
{}).
then
(({
data
})
=>
{
this
.
areaData
=
data
.
siteTree
;
...
...
@@ -464,6 +502,12 @@ export default {
config
:
{
getsocketData
:
null
,
search
:
[
{
name
:
"
deviceName
"
,
type
:
"
text
"
,
label
:
"
设备名称
"
,
fuzzy
:
true
,
},
{
name
:
"
deviceCode
"
,
type
:
"
text
"
,
...
...
@@ -578,6 +622,15 @@ export default {
二维码
<
/el-button
>
<
/div
>
<
span
>
<
/span
>
<
el
-
button
type
=
"
text
"
size
=
"
mini
"
onClick
=
{()
=>
this
.
restart
(
row
.
id
)}
>
重启
<
/el-button
>
);
},
},
...
...
device-manager-ui/admin/src/views/device/log/list.vue
View file @
9ae55436
...
...
@@ -46,6 +46,12 @@ export default {
label
:
"
设备编号
"
,
fuzzy
:
true
,
},
{
name
:
"
messageHead
"
,
type
:
"
text
"
,
label
:
"
业务标识
"
,
fuzzy
:
true
,
},
{
name
:
"
logType
"
,
type
:
"
select
"
,
...
...
@@ -114,4 +120,4 @@ export default {
};
},
};
</
script
>
\ No newline at end of file
</
script
>
device-manager/src/main/java/com/mortals/xhx/base/framework/config/RabbitConfig.java
View file @
9ae55436
...
...
@@ -5,7 +5,6 @@ import com.mortals.xhx.base.framework.listener.RabbitLoggingErrorHandler;
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
org.checkerframework.checker.units.qual.A
;
import
org.springframework.amqp.core.AcknowledgeMode
;
import
org.springframework.amqp.rabbit.AsyncRabbitTemplate
;
import
org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory
;
...
...
@@ -56,7 +55,7 @@ public class RabbitConfig {
return
message
;
});
//设置异常处理
container
.
setErrorHandler
(
rabbitLoggingErrorHandler
);
//
container.setErrorHandler(rabbitLoggingErrorHandler);
// 并发消费,不使用
// container.setConsumersPerQueue(3);
// container.setMaxConcurrentConsumers(10);
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceSendMsgController.java
View file @
9ae55436
package
com.mortals.xhx.busiz.web
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.util.IdUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -31,6 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
MESSAGETYPE_NOTIFY_REFRESH
;
...
...
@@ -46,7 +48,6 @@ public class DeviceSendMsgController {
private
DeviceLogService
deviceLogService
;
@PostMapping
(
"refreshMessage"
)
@UnAuth
public
String
refreshMessage
(
@RequestBody
UploadDeviceReq
req
)
{
...
...
@@ -57,29 +58,41 @@ public class DeviceSendMsgController {
try
{
//查询站点设备并通知每个设备
List
<
DeviceEntity
>
deviceList
=
deviceService
.
find
(
new
DeviceQuery
().
siteId
(
req
.
getSiteId
()));
for
(
DeviceEntity
deviceEntity
:
deviceList
)
{
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
MESSAGETYPE_NOTIFY_REFRESH
);
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
));
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
(
MESSAGETYPE_NOTIFY_REFRESH
);
deviceLogEntity
.
setContent
(
"W10="
);
deviceLogEntity
.
setLogType
(
LogTypeEnum
.
下发服务
.
getValue
());
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
,
null
);
Runnable
runnable
=
()
->
{
try
{
List
<
List
<
DeviceEntity
>>
partition
=
ListUtil
.
partition
(
deviceList
,
10
);
for
(
List
<
DeviceEntity
>
deviceEntities
:
partition
)
{
for
(
DeviceEntity
deviceEntity
:
deviceEntities
)
{
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
MESSAGETYPE_NOTIFY_REFRESH
);
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
));
}
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
(
MESSAGETYPE_NOTIFY_REFRESH
);
deviceLogEntity
.
setContent
(
"W10="
);
deviceLogEntity
.
setLogType
(
LogTypeEnum
.
下发服务
.
getValue
());
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
,
null
);
}
TimeUnit
.
SECONDS
.
sleep
(
1
);
}
}
catch
(
InterruptedException
e
)
{
log
.
error
(
"异常"
,
e
);
}
};
Thread
thread
=
new
Thread
(
runnable
);
thread
.
start
();
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
...
...
device-manager/src/main/java/com/mortals/xhx/common/key/Constant.java
View file @
9ae55436
...
...
@@ -113,6 +113,11 @@ public final class Constant {
*/
public
static
final
String
MESSAGETYPE_NOTIFY_REFRESH
=
"sitechange"
;
/**
* 消息类型(重启应用)
*/
public
static
final
String
MESSAGETYPE_NOTIFY_RESTART_APP
=
"restartapp"
;
/**
* 消息类型(upgread)
*/
...
...
device-manager/src/main/java/com/mortals/xhx/common/utils/DownMsgTask.java
View file @
9ae55436
package
com.mortals.xhx.common.utils
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.util.IdUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
...
...
@@ -25,6 +26,8 @@ import org.springframework.util.ObjectUtils;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
/**
* 接收消息
...
...
@@ -41,29 +44,52 @@ public class DownMsgTask implements Runnable {
private
ProductService
productService
;
private
DeviceService
deviceService
;
private
DeviceLogService
deviceLogService
;
private
MessageProducer
messageProducer
;
@Override
public
void
run
()
{
try
{
List
<
DeviceMsgReq
>
collect
=
list
.
stream
().
sorted
(
Comparator
.
comparing
(
DeviceMsgReq:
:
getTimestamp
)).
collect
(
Collectors
.
toList
());
List
<
List
<
DeviceMsgReq
>>
partition
=
ListUtil
.
partition
(
collect
,
10
);
for
(
List
<
DeviceMsgReq
>
deviceMsgReqs
:
partition
)
{
for
(
DeviceMsgReq
item
:
deviceMsgReqs
)
{
//根据设备编码查询设备
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
item
.
getDeviceCode
());
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
item
.
getMessageType
());
header
.
put
(
MessageHeader
.
DEVICECODE
,
item
.
getDeviceCode
());
header
.
put
(
MessageHeader
.
TIMESTAMP
,
item
.
getTimestamp
().
toString
());
TbQueueMsg
queueMsg
=
new
DefaultTbQueueMsg
(
IdUtil
.
fastUUID
(),
item
.
getData
(),
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
(
item
.
getMessageType
());
deviceLogEntity
.
setContent
(
item
.
getData
());
deviceLogEntity
.
setLogType
(
LogTypeEnum
.
下发服务
.
getValue
());
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
,
null
);
}
else
{
log
.
info
(
"未找到设备,deviceCode:{}"
,
item
.
getDeviceCode
());
}
}
TimeUnit
.
SECONDS
.
sleep
(
1
);
}
/*
list.stream().sorted(Comparator.comparing(DeviceMsgReq::getTimestamp)).forEach(item -> {
//根据设备编码查询设备
DeviceEntity deviceEntity = deviceService.getExtCache(item.getDeviceCode());
if (!ObjectUtils.isEmpty(deviceEntity)) {
//将上报信息转发到mq中
/* PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
if (ObjectUtils.isEmpty(platformEntity)) {
log.error("当前设备未配置所属系统平台,请在后台配置后再激活!");
return;
}
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (ObjectUtils.isEmpty(productEntity)) {
log.error("当前设备未配置所属产品,请在后台配置后再激活!");
return;
}*/
// String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
// TopicPartitionInfo info = TopicPartitionInfo.builder().exchangeName(exchangeName).topic(Constant.DOWN_TOPIC + deviceEntity.getDeviceMac()).build();
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, item.getMessageType());
header.put(MessageHeader.DEVICECODE, item.getDeviceCode());
...
...
@@ -86,56 +112,10 @@ public class DownMsgTask implements Runnable {
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,null);
/*
TbQueueCallback callback = new TbQueueCallback() {
@Override
public void onSuccess(TbQueueMsgMetadata metadata) {
//下行业务消息保存日志
if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(item.getMessageType())) {
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(metadata.getMessageId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(item.getMessageType());
deviceLogEntity.setContent(item.getData());
deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity);
}
log.info("消息投递成功,设备通道编码:" + deviceEntity.getDeviceMac());
}
@Override
public void onFailure(Throwable t) {
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
String traceID = IdUtil.fastSimpleUUID();
deviceLogEntity.setTraceID(traceID);
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(item.getMessageType());
deviceLogEntity.setContent(item.getData());
deviceLogEntity.setLogType(LogTypeEnum.消息异常.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity);
log.error("traceID:"+traceID,"消息投递失败,设备通道编码:" + deviceEntity.getDeviceMac(), t);
}
};
deviceService.sendDeviceMessage(deviceEntity, info, header, item.getData(),callback, null);
*/
} else {
log.info("未找到设备,deviceCode:{}", item.getDeviceCode());
}
});
});
*/
}
catch
(
Exception
e
)
{
log
.
error
(
"异常:"
,
e
);
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
View file @
9ae55436
...
...
@@ -37,6 +37,15 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
*/
void
active
(
String
deviceCode
,
Context
context
);
/**
* 设备重启应用
* @param deviceEntity
* @param context
*/
void
restartApp
(
DeviceEntity
deviceEntity
,
Context
context
);
/**
* 设备启用停用
* @param id
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceLogServiceImpl.java
View file @
9ae55436
...
...
@@ -50,7 +50,7 @@ public class DeviceLogServiceImpl extends AbstractCRUDServiceImpl<DeviceLogDao,
@Override
protected
void
saveAfter
(
DeviceLogEntity
entity
,
Context
context
)
throws
AppException
{
log
.
info
(
"业务日志保存成功!"
);
log
.
debug
(
"业务日志保存成功!"
);
BizLogPdu
bizLogPdu
=
new
BizLogPdu
();
bizLogPdu
.
initAttrValue
();
bizLogPdu
.
setAppName
(
appName
);
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
9ae55436
...
...
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import
cn.hutool.core.lang.PatternPool
;
import
cn.hutool.core.net.url.UrlBuilder
;
import
cn.hutool.core.net.url.UrlPath
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
...
...
@@ -18,6 +19,8 @@ import com.mortals.xhx.busiz.rsp.ApiResp;
import
com.mortals.xhx.common.code.*
;
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.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
...
...
@@ -53,6 +56,7 @@ import java.nio.charset.Charset;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
MESSAGETYPE_NOTIFY_RESTART_APP
;
import
static
java
.
math
.
BigDecimal
.
ROUND_HALF_DOWN
;
import
static
java
.
util
.
stream
.
Collectors
.
counting
;
...
...
@@ -220,6 +224,43 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
}
@Override
public
void
restartApp
(
DeviceEntity
deviceEntity
,
Context
context
)
{
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
.
getIdList
())){
throw
new
AppException
(
"请选择需要重启应用的设备!"
);
}
List
<
DeviceEntity
>
deviceEntities
=
this
.
find
(
deviceEntity
,
context
);
for
(
DeviceEntity
device
:
deviceEntities
)
{
if
(!
ObjectUtils
.
isEmpty
(
device
))
{
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
MESSAGETYPE_NOTIFY_RESTART_APP
);
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
));
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
(
MESSAGETYPE_NOTIFY_RESTART_APP
);
deviceLogEntity
.
setContent
(
"W10="
);
deviceLogEntity
.
setLogType
(
LogTypeEnum
.
下发服务
.
getValue
());
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
,
null
);
}
else
{
log
.
info
(
"未找到设备,deviceCode:{}"
,
device
.
getDeviceCode
());
}
}
}
@Override
public
void
deviceEnabled
(
Long
id
,
Integer
enabled
,
Context
context
)
{
DeviceEntity
deviceEntity
=
this
.
get
(
id
,
context
);
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
View file @
9ae55436
...
...
@@ -176,6 +176,25 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
return
rest
;
}
/**
* 设备批量重启应用
*/
@PostMapping
(
value
=
"batchRestartApp"
)
public
Rest
<
Void
>
batchRestartApp
(
@RequestBody
DeviceEntity
deviceEntity
)
{
log
.
info
(
"批量设备重启"
,
deviceEntity
.
getDeviceCode
());
String
busiDesc
=
this
.
getModuleDesc
()
+
"设备重启"
;
Rest
<
Void
>
rest
=
Rest
.
ok
(
busiDesc
+
" 【成功】"
);
try
{
this
.
service
.
restartApp
(
deviceEntity
,
getContext
());
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"批量设备重启"
,
e
);
rest
=
Rest
.
fail
(
super
.
convertException
(
e
));
}
return
rest
;
}
/**
* 查看二维码
*/
...
...
device-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductServiceImpl.java
View file @
9ae55436
...
...
@@ -158,44 +158,6 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
,
context
);
/* TbQueueCallback callback = new TbQueueCallback() {
@Override
public void onSuccess(TbQueueMsgMetadata metadata) {
log.info("【成功】发送升级版本信息,设备编码:{}",deviceEntity.getDeviceCode());
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(metadata.getMessageId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(MESSAGETYPE_UPGREAD);
deviceLogEntity.setContent(Base64.getEncoder().encodeToString(JSON.toJSONString(productVersionInfo).getBytes()));
deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,context);
}
@Override
public void onFailure(Throwable t) {
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
String traceID = IdUtil.fastSimpleUUID();
deviceLogEntity.setTraceID(traceID);
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(MESSAGETYPE_UPGREAD);
deviceLogEntity.setContent(Base64.getEncoder().encodeToString(JSON.toJSONString(productVersionInfo).getBytes()));
deviceLogEntity.setLogType(LogTypeEnum.消息异常.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,context);
}
};*/
log
.
info
(
"【发送中】发送升级版本信息,设备编码:{}"
,
deviceEntity
.
getDeviceCode
());
// deviceService.sendDeviceMessage(deviceEntity, info, header, Base64.getEncoder().encodeToString(JSON.toJSONString(productVersionInfo).getBytes()), callback, null);
...
...
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