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
81b82c09
Commit
81b82c09
authored
Feb 24, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改提交分辨率更新
parent
be66e51a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
28 deletions
+52
-28
common-lib/src/main/java/com/mortals/xhx/common/pdu/DeviceReq.java
...b/src/main/java/com/mortals/xhx/common/pdu/DeviceReq.java
+1
-1
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+51
-27
No files found.
common-lib/src/main/java/com/mortals/xhx/common/pdu/DeviceReq.java
View file @
81b82c09
...
...
@@ -176,7 +176,7 @@ public class DeviceReq implements Serializable {
System
.
out
.
println
(
NumberUtil
.
div
(
1920
,
1080
,
2
));
System
.
out
.
println
(
NumberUtil
.
div
(
1080
,
1920
,
2
));
System
.
out
.
println
(
NumberUtil
.
div
(
8
00
,
1280
,
2
));
System
.
out
.
println
(
NumberUtil
.
div
(
4
00
,
1280
,
2
));
System
.
out
.
println
(
NumberUtil
.
div
(
1024
,
600
,
2
));
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
81b82c09
...
...
@@ -6,6 +6,7 @@ import cn.hutool.core.lang.Validator;
import
cn.hutool.core.net.URLDecoder
;
import
cn.hutool.core.net.url.UrlBuilder
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.NumberUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.URLUtil
;
import
cn.hutool.extra.servlet.ServletUtil
;
...
...
@@ -215,6 +216,7 @@ public class DeviceApiController {
//判断当前设备是否设置了分辨率 如果设置了 查询当前设备的资源路径是否存在 如果存在
String
resolution
=
deviceEntity
.
getResolution
();
if
(!
ObjectUtils
.
isEmpty
(
resolution
))
{
//存在分辨率
DeviceModuleDistributeQuery
query
=
new
DeviceModuleDistributeQuery
();
query
.
setProductId
(
productEntity
.
getId
());
query
.
setSiteId
(
deviceEntity
.
getSiteId
());
...
...
@@ -222,6 +224,7 @@ public class DeviceApiController {
query
.
setDistribute
(
DistributeEnum
.
是
.
getValue
());
DeviceModuleDistributeEntity
distribute
=
deviceModuleDistributeService
.
selectOne
(
query
);
if
(!
ObjectUtils
.
isEmpty
(
distribute
))
{
//当前分辨率资源存在
String
homeUrl
=
String
.
format
(
"/homeDeviceUrl/%s/%s/%s"
,
distribute
.
getSiteId
(),
distribute
.
getProductCode
(),
distribute
.
getImageResolutionValue
());
//根据部署的资源 生成homeurl
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11078"
);
...
...
@@ -237,6 +240,7 @@ public class DeviceApiController {
serverInfo
.
setEventUrl
(
productEntity
.
getEventUrl
());
}
}
else
{
//当前分辨率资源部存在,如果存在高宽,则用高宽比查询生成相近homeurl
buildHomeUrlBySite
(
deviceEntity
,
productEntity
,
serverInfo
,
serverName
,
serverPort
);
}
}
else
{
...
...
@@ -456,33 +460,18 @@ public class DeviceApiController {
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
/* if (!ObjectUtils.isEmpty(width) && !ObjectUtils.isEmpty(height)) {
//根据分辨率 自适应设置分辨率
double div = NumberUtil.div(width, height, 2);
if (div >= 1.7 && div <= 1.8) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1920X1080.getDesc());
//System.out.println("1.7 < div < 1.8");
} else if (div >= 0.4 && div <= 0.7) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1080X1920.getDesc());
//System.out.println("1.7 < div < 1.8");
} else if (div >= 0.9 && div <= 1.1) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1280X1280.getDesc());
//System.out.println("div >= 0.9 && div <= 1.1");
}
}*/
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
//初始化新增基础设备,后续在线完善信息后再行注册添加
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
initAttrValue
();
checkAndUpdateImageRe
(
width
,
height
,
productEntity
,
deviceEntity
);
saveDevice
(
req
,
platformEntity
,
productEntity
,
deviceEntity
);
deviceEntity
.
setCreateTime
(
new
Date
());
deviceEntity
.
setCreateUserId
(
1L
);
deviceService
.
save
(
deviceEntity
,
null
);
}
else
{
//更新
checkAndUpdateImageRe
(
width
,
height
,
productEntity
,
deviceEntity
);
updateDevice
(
req
,
platformEntity
,
productEntity
,
deviceEntity
);
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceEntity
.
setUpdateUserId
(
1L
);
...
...
@@ -491,10 +480,7 @@ public class DeviceApiController {
if
(
deviceEntity
.
getDeviceStatus
()
==
DeviceStatusEnum
.
未激活
.
getValue
())
{
throw
new
AppException
(
DEVICE_UNACTIVE
,
DEVICE_UNACTIVE_CONTENT
);
}
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
)
&&
!
ObjectUtils
.
isEmpty
(
width
)
&&
!
ObjectUtils
.
isEmpty
(
height
))
{
deviceEntity
.
setWidth
(
width
);
deviceEntity
.
setHeight
(
height
);
}
DeviceQueueAuthInfo
authInfo
=
new
DeviceQueueAuthInfo
();
URL
url
=
getServerUrl
();
authInfo
.
setHost
(
url
.
getHost
());
...
...
@@ -584,6 +570,49 @@ public class DeviceApiController {
return
JSON
.
toJSONString
(
rsp
);
}
private
void
checkAndUpdateImageRe
(
Double
width
,
Double
height
,
ProductEntity
productEntity
,
DeviceEntity
deviceEntity
)
{
if
(!
ObjectUtils
.
isEmpty
(
width
)
&&
!
ObjectUtils
.
isEmpty
(
height
)
&&
ObjectUtils
.
isEmpty
(
deviceEntity
.
getResolution
()))
{
deviceEntity
.
setWidth
(
width
);
deviceEntity
.
setHeight
(
height
);
deviceEntity
.
setResolution
(
width
+
"x"
+
height
);
deviceEntity
.
setResolutionValue
(
width
+
"x"
+
height
);
//查询是否存在资源,如果不存在 则添加为相似资源
DeviceModuleDistributeQuery
query
=
new
DeviceModuleDistributeQuery
();
query
.
setSiteId
(
deviceEntity
.
getSiteId
());
query
.
setProductId
(
productEntity
.
getId
());
query
.
setDistribute
(
DistributeEnum
.
是
.
getValue
());
query
.
setImageResolution
(
deviceEntity
.
getResolution
());
query
.
setOrderColList
(
Arrays
.
asList
(
new
OrderCol
(
"version"
,
OrderCol
.
DESCENDING
)));
DeviceModuleDistributeEntity
deviceModuleDistributeEntity
=
deviceModuleDistributeService
.
selectOne
(
query
);
if
(
ObjectUtils
.
isEmpty
(
deviceModuleDistributeEntity
))
{
//没有资源 根据宽和高存在 找一个相近的资源。
if
(!
ObjectUtils
.
isEmpty
(
width
)
&&
!
ObjectUtils
.
isEmpty
(
height
))
{
//根据分辨率 自适应设置分辨率
double
div
=
NumberUtil
.
div
(
width
,
height
,
2
);
if
(
div
>=
1.3
&&
div
<=
5.0
)
{
deviceEntity
.
setResolutionValue
(
ImageReEnum
.
RE_1920X1080
.
getDesc
());
deviceEntity
.
setResolution
(
ImageReEnum
.
RE_1920X1080
.
getDesc
());
log
.
info
(
"1.3 < div < 5.0"
);
//System.out.println("1.7 < div < 1.8");
}
else
if
(
div
>=
0.1
&&
div
<=
0.79
)
{
deviceEntity
.
setResolutionValue
(
ImageReEnum
.
RE_1080X1920
.
getDesc
());
deviceEntity
.
setResolution
(
ImageReEnum
.
RE_1080X1920
.
getDesc
());
log
.
info
(
"0.1 < div < 0.79"
);
//System.out.println("1.7 < div < 1.8");
}
else
if
(
div
>=
0.8
&&
div
<=
1.29
)
{
deviceEntity
.
setResolutionValue
(
ImageReEnum
.
RE_1280X1280
.
getDesc
());
deviceEntity
.
setResolution
(
ImageReEnum
.
RE_1280X1280
.
getDesc
());
log
.
info
(
"div >= 0.9 && div <= 1.1"
);
//System.out.println("div >= 0.9 && div <= 1.1");
}
}
}
}
}
/**
* 检查设备最新版本信息
...
...
@@ -1142,6 +1171,7 @@ public class DeviceApiController {
String
scheme
=
serverInfo
.
getScheme
();
String
homeUrl
=
""
;
//根据站点与资源部署来生成homeurl
DeviceModuleDistributeQuery
query
=
new
DeviceModuleDistributeQuery
();
query
.
setSiteId
(
deviceEntity
.
getSiteId
());
query
.
setProductId
(
productEntity
.
getId
());
...
...
@@ -1151,13 +1181,9 @@ public class DeviceApiController {
DeviceModuleDistributeEntity
deviceModuleDistributeEntity
=
deviceModuleDistributeService
.
selectOne
(
query
);
if
(
ObjectUtils
.
isEmpty
(
deviceModuleDistributeEntity
))
{
//判断如果宽和高存在 找一个相近的资源。
}
else
{
//homeDeviceUrl/1/pdj/1920x1080
homeUrl
=
String
.
format
(
"/homeDeviceUrl/%s/%s/%s"
,
deviceModuleDistributeEntity
.
getSiteId
(),
deviceModuleDistributeEntity
.
getProductCode
(),
deviceModuleDistributeEntity
.
getImageResolutionValue
());
//根据部署的资源 生成homeurl
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11078"
);
if
(!
ObjectUtils
.
isEmpty
(
serverName
)
&&
Validator
.
isIpv4
(
serverName
))
{
...
...
@@ -1200,7 +1226,6 @@ public class DeviceApiController {
String
decodeStr
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
productVersionInfo
.
setDownloadUrl
(
decodeStr
);
}
log
.
info
(
"downurl:"
+
productVersionInfo
.
getDownloadUrl
());
}
...
...
@@ -1415,7 +1440,6 @@ public class DeviceApiController {
updateDevice
(
req
,
platformEntity
,
productEntity
,
deviceEntity
);
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceEntity
.
setUpdateUserId
(
1L
);
//cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE, deviceEntity);
deviceService
.
update
(
deviceEntity
,
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