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
08576119
Commit
08576119
authored
Aug 30, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加产品升级功能
parent
46e8a47f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
20 deletions
+79
-20
device-manager/src/main/java/com/mortals/xhx/base/system/message/MessageProducer.java
.../com/mortals/xhx/base/system/message/MessageProducer.java
+0
-1
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DeviceMsgComsumerStartedService.java
...n/applicationservice/DeviceMsgComsumerStartedService.java
+1
-17
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceLogServiceImpl.java
.../xhx/module/device/service/impl/DeviceLogServiceImpl.java
+29
-0
device-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductServiceImpl.java
...s/xhx/module/product/service/impl/ProductServiceImpl.java
+49
-2
No files found.
device-manager/src/main/java/com/mortals/xhx/base/system/message/MessageProducer.java
View file @
08576119
...
...
@@ -22,7 +22,6 @@ public class MessageProducer implements IMessageProduceService {
private
RabbitTemplate
rabbitTemplate
;
public
void
syncAccessSend
(
AccessLogPdu
accessLogPdu
)
{
//log.info("accessinfo==>{}",JSON.toJSONString(accessLogPdu));
rabbitTemplate
.
convertAndSend
(
QueueKey
.
EXCHANGE
,
QueueKey
.
ACCESS_LOG_QUEUE
,
JSON
.
toJSONString
(
accessLogPdu
));
}
...
...
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DeviceMsgComsumerStartedService.java
View file @
08576119
...
...
@@ -58,8 +58,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
private
SendTaskThreadPool
sendTaskThreadPool
;
@Autowired
private
ICacheService
cacheService
;
@Value
(
"${spring.application.name:''}"
)
private
String
appName
;
@Autowired
private
IMessageProduceService
messageProduceService
;
...
...
@@ -196,21 +195,6 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
);
//埋点业务事件,消息上报
BizLogPdu
bizLogPdu
=
new
BizLogPdu
();
bizLogPdu
.
initAttrValue
();
bizLogPdu
.
setAppName
(
appName
);
bizLogPdu
.
setTraceID
(
IdUtil
.
objectId
());
bizLogPdu
.
setUserCode
(
"system"
);
bizLogPdu
.
setDeviceCode
(
deviceEntity
.
getDeviceCode
());
bizLogPdu
.
setEventTopic
(
messageType
);
bizLogPdu
.
setEventTopicName
(
LogTypeEnum
.
下发服务
.
name
());
bizLogPdu
.
setMsg
(
queueMsg
.
getData
());
bizLogPdu
.
setLogLevel
(
"INFO"
);
bizLogPdu
.
setLogTime
(
new
Date
());
messageProduceService
.
syncBizSend
(
bizLogPdu
);
}
//获取exchange,
PlatformEntity
platformEntity
=
platformService
.
get
(
deviceEntity
.
getPlatformId
());
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceLogServiceImpl.java
View file @
08576119
package
com.mortals.xhx.module.device.service.impl
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.util.IdUtil
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.BizLogPdu
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.xhx.base.system.message.MessageProducer
;
import
com.mortals.xhx.common.code.LogTypeEnum
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.xhx.module.device.dao.DeviceLogDao
;
import
com.mortals.xhx.module.device.model.DeviceLogEntity
;
import
com.mortals.xhx.module.device.service.DeviceLogService
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -22,6 +29,11 @@ import java.util.List;
@Service
(
"deviceLogService"
)
public
class
DeviceLogServiceImpl
extends
AbstractCRUDServiceImpl
<
DeviceLogDao
,
DeviceLogEntity
,
Long
>
implements
DeviceLogService
{
@Value
(
"${spring.application.name:''}"
)
private
String
appName
;
@Autowired
private
MessageProducer
messageProducer
;
@Override
protected
void
findAfter
(
DeviceLogEntity
params
,
PageInfo
pageInfo
,
Context
context
,
List
<
DeviceLogEntity
>
list
)
throws
AppException
{
...
...
@@ -34,4 +46,21 @@ public class DeviceLogServiceImpl extends AbstractCRUDServiceImpl<DeviceLogDao,
});
}
@Override
protected
void
saveAfter
(
DeviceLogEntity
entity
,
Context
context
)
throws
AppException
{
BizLogPdu
bizLogPdu
=
new
BizLogPdu
();
bizLogPdu
.
initAttrValue
();
bizLogPdu
.
setAppName
(
appName
);
bizLogPdu
.
setTraceID
(
IdUtil
.
objectId
());
bizLogPdu
.
setUserCode
(
"system"
);
bizLogPdu
.
setDeviceCode
(
entity
.
getDeviceCode
());
bizLogPdu
.
setEventTopic
(
entity
.
getMessageHead
());
bizLogPdu
.
setEventTopicName
(
LogTypeEnum
.
下发服务
.
name
());
bizLogPdu
.
setMsg
(
entity
.
getContent
());
bizLogPdu
.
setLogLevel
(
"INFO"
);
bizLogPdu
.
setLogTime
(
new
Date
());
messageProducer
.
syncBizSend
(
bizLogPdu
);
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductServiceImpl.java
View file @
08576119
...
...
@@ -2,6 +2,7 @@ package com.mortals.xhx.module.product.service.impl;
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.URLUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.ap.GlobalSysInfo
;
...
...
@@ -10,12 +11,15 @@ import com.mortals.framework.model.Context;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.busiz.rsp.ProductVersionInfo
;
import
com.mortals.xhx.common.code.LogTypeEnum
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceLogEntity
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
com.mortals.xhx.module.device.service.DeviceLogService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.platform.model.PlatformEntity
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
...
...
@@ -23,7 +27,9 @@ import com.mortals.xhx.module.product.model.ProductQuery;
import
com.mortals.xhx.module.product.model.ProductVersionEntity
;
import
com.mortals.xhx.module.product.model.ProductVersionQuery
;
import
com.mortals.xhx.module.product.service.ProductVersionService
;
import
com.mortals.xhx.queue.TbQueueCallback
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TbQueueMsgMetadata
;
import
com.mortals.xhx.queue.TopicPartitionInfo
;
import
com.sun.jndi.toolkit.url.UrlUtil
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -37,6 +43,7 @@ import org.springframework.util.ObjectUtils;
import
java.nio.charset.Charset
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
PARAM_SERVER_HTTP_URL
;
...
...
@@ -61,6 +68,8 @@ public class ProductServiceImpl extends AbstractCRUDServiceImpl<ProductDao, Prod
private
MessageService
messageService
;
@Autowired
private
PlatformService
platformService
;
@Autowired
private
DeviceLogService
deviceLogService
;
@Override
protected
void
saveBefore
(
ProductEntity
entity
,
Context
context
)
throws
AppException
{
...
...
@@ -124,11 +133,49 @@ public class ProductServiceImpl extends AbstractCRUDServiceImpl<ProductDao, Prod
header
.
put
(
MessageHeader
.
DEVICECODE
,
deviceEntity
.
getDeviceCode
());
ProductVersionInfo
productVersionInfo
=
new
ProductVersionInfo
();
BeanUtils
.
copyProperties
(
productVersionEntity
,
productVersionInfo
,
BeanUtil
.
getNullPropertyNames
(
productVersionEntity
));
buildDownloadUrl
(
productVersionEntity
,
productVersionInfo
);
deviceService
.
sendDeviceMessage
(
deviceEntity
,
info
,
header
,
JSON
.
toJSONString
(
productVersionInfo
),
null
,
null
);
buildDownloadUrl
(
productVersionEntity
,
productVersionInfo
);
TbQueueCallback
callback
=
new
TbQueueCallback
()
{
@Override
public
void
onSuccess
(
TbQueueMsgMetadata
metadata
)
{
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
(
Constant
.
MESSAGETYPE_UPGREAD
);
deviceLogEntity
.
setContent
(
JSON
.
toJSONString
(
productVersionInfo
));
deviceLogEntity
.
setLogType
(
LogTypeEnum
.
下发服务
.
getValue
());
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
);
}
@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
(
Constant
.
MESSAGETYPE_UPGREAD
);
deviceLogEntity
.
setContent
(
JSON
.
toJSONString
(
productVersionInfo
));
deviceLogEntity
.
setLogType
(
LogTypeEnum
.
消息异常
.
getValue
());
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
);
}
};
deviceService
.
sendDeviceMessage
(
deviceEntity
,
info
,
header
,
JSON
.
toJSONString
(
productVersionInfo
),
callback
,
null
);
});
}
private
void
buildDownloadUrl
(
ProductVersionEntity
productVersionEntity
,
ProductVersionInfo
productVersionInfo
)
{
String
download
=
""
;
...
...
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