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
0945855e
Commit
0945855e
authored
Aug 30, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加设备版本信息
parent
535cdc5c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
14 deletions
+122
-14
device-manager/src/main/java/com/mortals/xhx/busiz/rsp/DeviceResp.java
...r/src/main/java/com/mortals/xhx/busiz/rsp/DeviceResp.java
+2
-0
device-manager/src/main/java/com/mortals/xhx/busiz/rsp/ProductVersionInfo.java
...in/java/com/mortals/xhx/busiz/rsp/ProductVersionInfo.java
+41
-0
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+76
-14
device-manager/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
...r/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
+3
-0
No files found.
device-manager/src/main/java/com/mortals/xhx/busiz/rsp/DeviceResp.java
View file @
0945855e
...
...
@@ -14,4 +14,6 @@ public class DeviceResp implements Serializable {
private
String
content
;
}
device-manager/src/main/java/com/mortals/xhx/busiz/rsp/ProductVersionInfo.java
0 → 100644
View file @
0945855e
package
com.mortals.xhx.busiz.rsp
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* 产品版本信息
*/
@Data
public
class
ProductVersionInfo
implements
Serializable
{
private
Integer
productId
;
/**
* 产品编号
*/
private
String
productCode
;
/**
* 产品名称
*/
private
String
productName
;
/**
* 版本号
*/
private
String
version
;
/**
* 备注信息
*/
private
String
remark
;
/**
* 版本下载地址
*/
private
String
downloadUrl
;
}
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
0945855e
...
...
@@ -12,6 +12,7 @@ import com.mortals.framework.annotation.UnAuth;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.OrderCol
;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ILogService
;
...
...
@@ -48,7 +49,10 @@ import com.mortals.xhx.module.platform.model.PlatformQuery;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
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.ProductService
;
import
com.mortals.xhx.module.product.service.ProductVersionService
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TopicPartitionInfo
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -61,6 +65,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -87,7 +92,7 @@ public class DeviceApiController {
@Autowired
private
UserService
userService
;
@Autowired
private
IAuthTokenService
authToke
nService
;
private
ProductVersionService
productVersio
nService
;
@Autowired
private
PlatformService
platformService
;
@Value
(
"${queue.rabbitmq.virtual_host:}"
)
...
...
@@ -175,6 +180,7 @@ public class DeviceApiController {
deviceInfo
.
setSiteCode
(
deviceEntity
.
getSiteCode
());
deviceInfo
.
setSiteName
(
deviceEntity
.
getSiteName
());
deviceInfo
.
setProductId
(
productEntity
.
getId
());
deviceInfo
.
setProductCode
(
productEntity
.
getProductCode
());
deviceInfo
.
setProductName
(
productEntity
.
getProductName
());
deviceInfo
.
setEnabled
(
deviceEntity
.
getEnabled
());
deviceInfo
.
setSource
(
deviceEntity
.
getSource
());
...
...
@@ -203,19 +209,7 @@ public class DeviceApiController {
return
JSON
.
toJSONString
(
rsp
);
}
private
void
buildHomeUrl
(
DeviceEntity
deviceEntity
,
ProductEntity
productEntity
,
ServerInfo
serverInfo
)
{
String
homeUrl
=
""
;
if
(!
ObjectUtils
.
isEmpty
(
productEntity
.
getHomeUrl
()))
{
homeUrl
=
productEntity
.
getHomeUrl
();
}
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
.
getHomeUrl
()))
{
homeUrl
=
deviceEntity
.
getHomeUrl
();
}
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11091"
);
serverInfo
.
setHomeUrl
(
UrlBuilder
.
of
(
domain
).
addPath
(
homeUrl
).
toString
());
}
/**
* 获取Token
...
...
@@ -269,7 +263,6 @@ public class DeviceApiController {
List
<
ProductInfo
>
productInfoList
=
productService
.
find
(
new
ProductEntity
()).
stream
().
map
(
item
->
{
ProductInfo
productInfo
=
new
ProductInfo
();
BeanUtils
.
copyProperties
(
item
,
productInfo
,
BeanUtil
.
getNullPropertyNames
(
item
));
productInfo
.
setProductId
(
item
.
getId
());
return
productInfo
;
}).
collect
(
Collectors
.
toList
());
...
...
@@ -420,6 +413,51 @@ public class DeviceApiController {
return
JSON
.
toJSONString
(
rsp
);
}
/**
* 检查设备最新版本信息
*
* @param req
* @return
*/
@PostMapping
(
"checkVersion"
)
public
String
checkVersion
(
@RequestBody
DeviceReq
req
)
{
log
.
info
(
"【检查设备最新版本信息】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
ApiResp
<
DeviceResp
>
rsp
=
new
ApiResp
<>();
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
DeviceResp
deviceResp
=
new
DeviceResp
();
try
{
DeviceEntity
deviceEntity
=
checkDeviceExist
(
req
);
//查找版本号最大的.
ProductVersionQuery
productVersionQuery
=
new
ProductVersionQuery
();
productVersionQuery
.
setProductId
(
deviceEntity
.
getProductId
());
productVersionQuery
.
setOrderColList
(
Arrays
.
asList
(
new
OrderCol
(
"version"
)));
productVersionQuery
.
setOrderKind
(
OrderCol
.
ASCENDING
);
ProductVersionEntity
productVersionEntity
=
productVersionService
.
selectOne
(
productVersionQuery
);
if
(
ObjectUtils
.
isEmpty
(
productVersionEntity
))
throw
new
AppException
(
DEVICE_VERSION_UNEXIST
,
DEVICE_VERSION_UNEXIST_CONTENT
);
ProductVersionInfo
productVersionInfo
=
new
ProductVersionInfo
();
BeanUtils
.
copyProperties
(
productVersionEntity
,
productVersionInfo
,
BeanUtil
.
getNullPropertyNames
(
productVersionEntity
));
buildDownloadUrl
(
productVersionEntity
,
productVersionInfo
);
String
content
=
EncryptUtil
.
myEnscrt
(
JSON
.
toJSONString
(
productVersionInfo
),
9
,
DES_STR
,
ENCRYPT_STR
);
deviceResp
.
setContent
(
content
);
}
catch
(
AppException
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
e
.
getCode
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
log
.
info
(
"响应【设备版本检查】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
}
private
void
saveOrUpdate
(
DeviceReq
req
,
PlatformEntity
platformEntity
,
ProductEntity
productEntity
,
DeviceEntity
deviceEntity
)
{
BeanUtils
.
copyProperties
(
req
,
deviceEntity
,
BeanUtil
.
getNullPropertyNames
(
req
));
...
...
@@ -762,5 +800,29 @@ public class DeviceApiController {
}
}
private
void
buildHomeUrl
(
DeviceEntity
deviceEntity
,
ProductEntity
productEntity
,
ServerInfo
serverInfo
)
{
String
homeUrl
=
""
;
if
(!
ObjectUtils
.
isEmpty
(
productEntity
.
getHomeUrl
()))
{
homeUrl
=
productEntity
.
getHomeUrl
();
}
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
.
getHomeUrl
()))
{
homeUrl
=
deviceEntity
.
getHomeUrl
();
}
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11091"
);
serverInfo
.
setHomeUrl
(
UrlBuilder
.
of
(
domain
).
addPath
(
homeUrl
).
toString
());
}
private
void
buildDownloadUrl
(
ProductVersionEntity
productVersionEntity
,
ProductVersionInfo
productVersionInfo
)
{
String
download
=
""
;
if
(!
ObjectUtils
.
isEmpty
(
productVersionEntity
.
getFilePath
()))
{
download
=
productVersionEntity
.
getFilePath
();
}
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11091"
);
productVersionInfo
.
setDownloadUrl
(
UrlBuilder
.
of
(
domain
).
addPath
(
download
).
toString
());
}
}
device-manager/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
View file @
0945855e
...
...
@@ -111,6 +111,9 @@ public interface ErrorCode {
public
static
final
int
TOKEN_AUTH_FAIL
=
1010
;
public
static
final
String
TOKEN_AUTH_FAIL_CONTENT
=
"token认证失败!"
;
public
static
final
int
DEVICE_VERSION_UNEXIST
=
1011
;
public
static
final
String
DEVICE_VERSION_UNEXIST_CONTENT
=
"未找到设备版本信息!"
;
public
static
final
int
ERROR_TOKEN_EXPIRED
=
9001
;
public
static
final
String
ERROR_TOKEN_EXPIRED_CONTENT
=
"用户登录过期,请重新登录!"
;
...
...
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