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
64515fa9
Commit
64515fa9
authored
Feb 13, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改站点请求地址
parent
0ece7525
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
359 additions
and
131 deletions
+359
-131
device-manager-ui/admin/.env.yibin
device-manager-ui/admin/.env.yibin
+0
-2
device-manager-ui/admin/src/assets/utils/ajax.js
device-manager-ui/admin/src/assets/utils/ajax.js
+0
-1
device-manager-ui/admin/src/components/SearchForm.vue
device-manager-ui/admin/src/components/SearchForm.vue
+5
-0
device-manager-ui/admin/src/components/Table.vue
device-manager-ui/admin/src/components/Table.vue
+3
-3
device-manager-ui/admin/src/views/device/list.vue
device-manager-ui/admin/src/views/device/list.vue
+5
-5
device-manager/pom.xml
device-manager/pom.xml
+5
-1
device-manager/src/main/java/com/mortals/xhx/base/framework/aspect/WebLogAspect.java
...a/com/mortals/xhx/base/framework/aspect/WebLogAspect.java
+11
-9
device-manager/src/main/java/com/mortals/xhx/base/framework/listener/DirectDynamicListener.java
...ls/xhx/base/framework/listener/DirectDynamicListener.java
+5
-2
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+37
-16
device-manager/src/main/java/com/mortals/xhx/busiz/web/TestSendMsgController.java
...java/com/mortals/xhx/busiz/web/TestSendMsgController.java
+37
-54
device-manager/src/main/java/com/mortals/xhx/common/key/Constant.java
...er/src/main/java/com/mortals/xhx/common/key/Constant.java
+2
-0
device-manager/src/main/java/com/mortals/xhx/common/utils/ImgUtils.java
.../src/main/java/com/mortals/xhx/common/utils/ImgUtils.java
+178
-0
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DeviceMsgComsumerStartedService.java
...n/applicationservice/DeviceMsgComsumerStartedService.java
+6
-7
device-manager/src/main/java/com/mortals/xhx/daemon/task/SiteStatTaskImpl.java
...in/java/com/mortals/xhx/daemon/task/SiteStatTaskImpl.java
+0
-1
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+19
-26
device-manager/src/main/java/com/mortals/xhx/module/platform/service/impl/PlatformServiceImpl.java
...xhx/module/platform/service/impl/PlatformServiceImpl.java
+0
-1
device-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductVersionServiceImpl.java
...odule/product/service/impl/ProductVersionServiceImpl.java
+39
-2
device-manager/src/main/java/com/mortals/xhx/module/product/web/ProductController.java
...com/mortals/xhx/module/product/web/ProductController.java
+3
-1
device-manager/src/test/java/com/mortals/httpclient/http-client.env.json
...src/test/java/com/mortals/httpclient/http-client.env.json
+4
-0
No files found.
device-manager-ui/admin/.env.yibin
View file @
64515fa9
...
...
@@ -4,8 +4,6 @@ NODE_ENV = production
# 地址
VUE_APP_BASE_API = /basics_api/m
# websocket地址
VUE_APP_WEBSOCKET_API =192.168.2.144:18222/m
# 门户登录地址
VUE_APP_PORTAL_URL = /portal_home
...
...
device-manager-ui/admin/src/assets/utils/ajax.js
View file @
64515fa9
...
...
@@ -36,7 +36,6 @@ instance.interceptors.request.use(
// console.log("sessionStorage",window.sessionStorage)
config
.
headers
.
Authorization
=
window
.
sessionStorage
.
getItem
(
"
token
"
)
||
""
;
//console.log("request config and session",config,window.sessionStorage);
console
.
log
(
config
);
return
config
;
},
(
err
)
=>
{
...
...
device-manager-ui/admin/src/components/SearchForm.vue
View file @
64515fa9
...
...
@@ -229,6 +229,9 @@ export default {
let
newFormData
=
{};
// this.form = this.encode(data, this.form);
this
.
search
.
forEach
((
item
)
=>
{
console
.
log
(
"
item
"
,
this
.
form
[
item
.
name
])
//复选框
if
(
item
.
type
===
"
checkbox
"
)
{
if
(
this
.
form
[
item
.
name
]
==
undefined
)
{
...
...
@@ -272,6 +275,8 @@ export default {
},
onSubmit
()
{
let
{
path
,
query
}
=
this
.
$route
;
let
data
=
this
.
decode
(
this
.
form
);
this
.
$router
.
push
({
path
:
path
,
...
...
device-manager-ui/admin/src/components/Table.vue
View file @
64515fa9
...
...
@@ -67,10 +67,10 @@
<slot
name=
"table-head-left2"
></slot>
</el-row>
</div>
</div>
<el-row>
<slot
name=
"table-head-row2-left"
></slot>
</el-row>
</div>
<div
class=
"table-head-right"
>
<div
class=
"extend flex flex-pack-justify"
>
...
...
device-manager-ui/admin/src/views/device/list.vue
View file @
64515fa9
...
...
@@ -58,7 +58,7 @@
>
批量重启
</el-button
>
<el-tag
slot=
"table-
head-row2-left
"
slot=
"table-
body-head
"
size=
"mini"
class=
"cursord"
@
click=
"changeStat(null)"
...
...
@@ -66,7 +66,7 @@
>
<el-tag
slot=
"table-
head-row2-left
"
slot=
"table-
body-head
"
size=
"mini"
style=
"margin: 5px"
type=
"success"
...
...
@@ -76,7 +76,7 @@
>
<el-tag
slot=
"table-
head-row2-left
"
slot=
"table-
body-head
"
size=
"mini"
style=
"margin: 5px"
type=
"danger"
...
...
@@ -86,7 +86,7 @@
>
<el-tag
slot=
"table-
head-row2-left
"
slot=
"table-
body-head
"
size=
"mini"
style=
"margin: 5px"
type=
"danger"
...
...
@@ -96,7 +96,7 @@
>
<el-tag
slot=
"table-
head-row2-left
"
slot=
"table-
body-head
"
size=
"mini"
style=
"margin: 5px"
type=
"danger"
...
...
device-manager/pom.xml
View file @
64515fa9
...
...
@@ -210,7 +210,6 @@
</properties>
<dependencies>
<dependency>
<groupId>
com.mortals.xhx
</groupId>
<artifactId>
common-lib
</artifactId>
...
...
@@ -252,6 +251,11 @@
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
</dependency>
<dependency>
<groupId>
net.sourceforge.tess4j
</groupId>
<artifactId>
tess4j
</artifactId>
<version>
5.6.0
</version>
</dependency>
<dependency>
<groupId>
p6spy
</groupId>
<artifactId>
p6spy
</artifactId>
...
...
device-manager/src/main/java/com/mortals/xhx/base/framework/aspect/WebLogAspect.java
View file @
64515fa9
package
com.mortals.xhx.base.framework.aspect
;
import
cn.hutool.core.net.Ipv4Util
;
import
cn.hutool.extra.servlet.ServletUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.slf4j.MDC
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.util.ContentCachingRequestWrapper
;
...
...
@@ -22,7 +17,9 @@ import org.springframework.web.util.ContentCachingRequestWrapper;
import
javax.servlet.http.HttpServletRequest
;
import
java.net.URLDecoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 打印每个请求的入参、出参等信息
...
...
@@ -69,12 +66,13 @@ public class WebLogAspect {
if
(
map
!=
null
&&
result
!=
null
)
{
String
startTime
=
map
.
getOrDefault
(
"startTime"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
long
takeTime
=
(
System
.
currentTimeMillis
()
-
Long
.
parseLong
(
startTime
));
String
req
=
map
.
getOrDefault
(
"req"
,
""
);
if
(
result
instanceof
String
)
{
log
.
info
(
" \n 请求路径:{} 耗时:{}ms 客户端IP:{} \n 请求报文:{} \n 响应报文:{} "
,
request
.
getRequestURI
(),
takeTime
,
ServletUtil
.
getClientIP
(
request
),
map
.
getOrDefault
(
"req"
,
""
)
,
result
);
log
.
info
(
" \n 请求路径:{} 耗时:{}ms 客户端IP:{} \n 请求报文:{} \n 响应报文:{}
\n cookies:{}
"
,
request
.
getRequestURI
(),
takeTime
,
ServletUtil
.
getClientIP
(
request
),
req
,
result
);
}
else
{
log
.
info
(
" \n 请求路径:{} 耗时:{}ms 客户端IP:{}\n 请求报文:{} \n 响应报文:{}"
,
request
.
getRequestURI
(),
takeTime
,
ServletUtil
.
getClientIP
(
request
),
map
.
getOrDefault
(
"req"
,
""
)
,
JSON
.
toJSONString
(
result
));
log
.
info
(
" \n 请求路径:{} 耗时:{}ms 客户端IP:{}\n 请求报文:{} \n 响应报文:{}
\n cookies:{}
"
,
request
.
getRequestURI
(),
takeTime
,
ServletUtil
.
getClientIP
(
request
),
req
,
JSON
.
toJSONString
(
result
));
}
}
...
...
@@ -97,11 +95,15 @@ public class WebLogAspect {
requestInfo
.
put
(
"remoteAddr"
,
remoteAddr
);
if
(
req
instanceof
ContentCachingRequestWrapper
)
{
ContentCachingRequestWrapper
wrapper
=
(
ContentCachingRequestWrapper
)
req
;
String
bodyStr
=
new
String
(
wrapper
.
getContentAsByteArray
(),
StandardCharsets
.
UTF_8
);
if
(
bodyStr
.
startsWith
(
"{"
))
{
JSONObject
jsonObject
=
JSON
.
parseObject
(
bodyStr
);
requestInfo
.
put
(
"requestBody"
,
jsonObject
);
}
String
cookieStr
=
Arrays
.
asList
(
wrapper
.
getCookies
()).
stream
().
map
(
item
->
JSON
.
toJSONString
(
item
)).
collect
(
Collectors
.
joining
(
"|"
));
requestInfo
.
put
(
"cookieStr"
,
cookieStr
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"解析请求失败"
,
e
);
...
...
device-manager/src/main/java/com/mortals/xhx/base/framework/listener/DirectDynamicListener.java
View file @
64515fa9
...
...
@@ -27,6 +27,7 @@ import org.springframework.util.ObjectUtils;
import
java.util.Date
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
PARAM_SERVER_PHP_IN_HTTP_URL
;
import
static
com
.
mortals
.
xhx
.
common
.
model
.
MessageHeader
.
DEVICECODE
;
import
static
com
.
mortals
.
xhx
.
common
.
model
.
MessageHeader
.
MESSAGETYPE
;
...
...
@@ -97,11 +98,13 @@ public class DirectDynamicListener implements MessageListener {
}
//获取exchange,
PlatformEntity
platformEntity
=
platformService
.
get
(
deviceEntity
.
getPlatformId
());
String
phpInUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_IN_HTTP_URL
,
"http://172.15.28.116:8090"
);
if
(!
Constant
.
MESSAGETYPE_HEARTBEAT
.
equalsIgnoreCase
(
messageType
)
&&
!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
platformEntity
.
getSendSwitch
()
==
YesNoEnum
.
YES
.
getValue
())
{
if
(
platformEntity
.
getSendMsgType
()
==
SendMsgTypeEnum
.
http
.
getValue
()
&&
!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
)
{
SendTask
sendTask
=
new
SendTask
(
p
latformEntity
.
getSendUrl
()
,
queueMsg
.
getData
());
if
(
platformEntity
.
getSendMsgType
()
==
SendMsgTypeEnum
.
http
.
getValue
())
{
SendTask
sendTask
=
new
SendTask
(
p
hpInUrl
,
queueMsg
.
getData
());
sendTaskThreadPool
.
execute
(
sendTask
);
}
}
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
64515fa9
package
com.mortals.xhx.busiz.web
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.net.URLDecoder
;
import
cn.hutool.core.net.url.UrlBuilder
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.URLUtil
;
import
cn.hutool.extra.servlet.ServletUtil
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -183,9 +185,9 @@ public class DeviceApiController {
//判断设备是否设置了url 如果设置了,则用设备的 否则用产品的
buildHomeUrl
(
deviceEntity
,
productEntity
,
serverInfo
);
//对外
//
serverInfo.setServerUrl(platformEntity.getSendUrl());
String
phpUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_HTTP_URL
,
"http://10.12.185.213:8090"
);
serverInfo
.
setServerUrl
(
phpUrl
);
serverInfo
.
setServerUrl
(
platformEntity
.
getSendUrl
());
//
String phpUrl=GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://10.12.185.213:8090");
//
serverInfo.setServerUrl(phpUrl);
registerResp
.
setServiceInfo
(
serverInfo
);
DeviceInfo
deviceInfo
=
new
DeviceInfo
();
deviceInfo
.
setSiteId
(
deviceEntity
.
getSiteId
());
...
...
@@ -206,7 +208,7 @@ public class DeviceApiController {
deviceEntity
.
setDeviceVersion
(
req
.
getDeviceVersion
()
==
null
?
""
:
req
.
getDeviceVersion
());
deviceService
.
getDeviceDao
().
update
(
deviceEntity
);
rsp
.
setData
(
deviceResp
);
SendThirdPartyTask
sendThirdPartyTask
=
new
SendThirdPartyTask
(
deviceEntity
,
productEntity
,
platformEntity
,
deviceService
);
SendThirdPartyTask
sendThirdPartyTask
=
new
SendThirdPartyTask
(
deviceEntity
,
productEntity
,
platformEntity
,
deviceService
);
sendTaskThreadPool
.
execute
(
sendThirdPartyTask
);
}
catch
(
AppException
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
...
...
@@ -219,7 +221,7 @@ public class DeviceApiController {
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
log
.
info
(
"响应【设备注册】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
//
log.info("响应【设备注册】【响应体】--> " + JSONObject.toJSONString(rsp));
return
JSON
.
toJSONString
(
rsp
);
}
...
...
@@ -410,9 +412,9 @@ public class DeviceApiController {
ServerInfo
serverInfo
=
new
ServerInfo
();
buildHomeUrl
(
deviceEntity
,
productEntity
,
serverInfo
);
//
serverInfo.setServerUrl(platformEntity.getSendUrl());
String
phpUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_HTTP_URL
,
"http://10.12.185.213:8090"
);
serverInfo
.
setServerUrl
(
phpUrl
);
serverInfo
.
setServerUrl
(
platformEntity
.
getSendUrl
());
//
String phpUrl=GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://10.12.185.213:8090");
//
serverInfo.setServerUrl(phpUrl);
registerResp
.
setServiceInfo
(
serverInfo
);
DeviceInfo
deviceInfo
=
new
DeviceInfo
();
...
...
@@ -439,7 +441,7 @@ public class DeviceApiController {
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
log
.
info
(
"响应【设备前端新增或更新】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
//
log.info("响应【设备前端新增或更新】【响应体】--> " + JSONObject.toJSONString(rsp));
return
JSON
.
toJSONString
(
rsp
);
}
...
...
@@ -470,7 +472,6 @@ public class DeviceApiController {
throw
new
AppException
(
DEVICE_VERSION_UNEXIST
,
DEVICE_VERSION_UNEXIST_CONTENT
);
}
ProductVersionInfo
productVersionInfo
=
new
ProductVersionInfo
();
BeanUtils
.
copyProperties
(
productVersionEntity
,
productVersionInfo
,
BeanUtil
.
getNullPropertyNames
(
productVersionEntity
));
buildDownloadUrl
(
productVersionEntity
,
productVersionInfo
);
...
...
@@ -576,11 +577,11 @@ public class DeviceApiController {
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
try
{
ProductEntity
productEntity
=
productService
.
selectOne
(
new
ProductQuery
().
productCode
(
deviceMsgReq
.
getProductCode
()));
if
(!
ObjectUtils
.
isEmpty
(
productEntity
))
{
if
(!
ObjectUtils
.
isEmpty
(
productEntity
))
{
List
<
DeviceEntity
>
deviceEntities
=
deviceService
.
find
(
new
DeviceQuery
().
productId
(
productEntity
.
getId
()).
siteId
(
deviceMsgReq
.
getSiteid
()));
List
<
DeviceMsgReq
>
list
=
deviceEntities
.
stream
().
map
(
item
->
{
DeviceMsgReq
msgReq
=
new
DeviceMsgReq
();
BeanUtils
.
copyProperties
(
deviceMsgReq
,
msgReq
,
BeanUtil
.
getNullPropertyNames
(
deviceMsgReq
));
BeanUtils
.
copyProperties
(
deviceMsgReq
,
msgReq
,
BeanUtil
.
getNullPropertyNames
(
deviceMsgReq
));
msgReq
.
setDeviceCode
(
item
.
getDeviceCode
());
return
msgReq
;
}).
collect
(
Collectors
.
toList
());
...
...
@@ -913,7 +914,16 @@ public class DeviceApiController {
private
void
buildDownloadUrl
(
ProductVersionEntity
productVersionEntity
,
ProductVersionInfo
productVersionInfo
)
{
String
download
=
""
;
if
(!
ObjectUtils
.
isEmpty
(
productVersionEntity
.
getFilePath
()))
{
String
fileType
=
FileUtil
.
extName
(
productVersionEntity
.
getFilePath
());
if
(
"zip"
.
equals
(
fileType
))
{
String
mainName
=
FileUtil
.
mainName
(
productVersionEntity
.
getFilePath
());
String
replace
=
StrUtil
.
replace
(
productVersionEntity
.
getFilePath
(),
FileUtil
.
getName
(
productVersionEntity
.
getFilePath
()),
""
);
download
=
replace
+
mainName
+
"/"
;
log
.
info
(
"download:"
+
download
);
}
else
{
download
=
productVersionEntity
.
getFilePath
();
log
.
info
(
"download:"
+
download
);
}
}
String
domain
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_HTTP_URL
,
"http://192.168.0.98:11091"
);
//String temp = domain + "/" + download;
...
...
@@ -930,13 +940,24 @@ public class DeviceApiController {
System
.
out
.
println
(
urlBuilder
.
build
());
String
str
=
"http://10.12.185.213:11078/homeDeviceUrl%2Fdsj%2F1920x1080
"
;
String
str
=
"http://10.12.185.213:11078/homeDeviceUrl%2Fdsj%2F1920x1080/
"
;
System
.
out
.
println
(
str
);
String
decode
=
URLDecoder
.
decode
(
str
,
Charset
.
defaultCharset
());
System
.
out
.
println
(
decode
);
str
=
"/file/uploadfile/1675836231156.zip"
;
System
.
out
.
println
(
FileUtil
.
getPrefix
(
str
));
System
.
out
.
println
(
FileUtil
.
mainName
(
str
));
System
.
out
.
println
(
FileUtil
.
getName
(
str
));
String
replace
=
StrUtil
.
replace
(
str
,
FileUtil
.
getName
(
str
),
""
);
System
.
out
.
println
(
replace
);
//FileUtil.getName()
//URL url = URLUtil.url(domain);
// System.out.println(StrUtil.removeAllLineBreaks(domain));
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/web/TestSendMsgController.java
View file @
64515fa9
package
com.mortals.xhx.busiz.web
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ILogService
;
import
com.mortals.framework.service.impl.FileLogServiceImpl
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.busiz.req.TestReq
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.busiz.rsp.DeviceResp
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
com.mortals.xhx.common.utils.SendTaskThreadPool
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.device.service.DeviceLogService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.firm.service.FirmService
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.module.product.service.ProductVersionService
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.common.utils.ImgUtils
;
import
com.mortals.xhx.common.utils.Tess4J
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.File
;
/**
* 设备
*
...
...
@@ -38,47 +32,6 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RequestMapping
(
"/test"
)
public
class
TestSendMsgController
{
@Autowired
private
DeviceService
deviceService
;
@Autowired
private
ProductService
productService
;
@Autowired
private
UserService
userService
;
@Autowired
private
ProductVersionService
productVersionService
;
@Autowired
private
PlatformService
platformService
;
@Value
(
"${spring..rabbitmq.virtual_host:}"
)
private
String
virtualHost
;
@Value
(
"${spring..rabbitmq.password:}"
)
private
String
password
;
@Value
(
"${spring..rabbitmq.host:}"
)
private
String
host
;
@Value
(
"${spring..rabbitmq.port:0}"
)
private
int
port
;
@Value
(
"${spring..rabbitmq.username:}"
)
private
String
username
;
@Value
(
"${spring..rabbitmq.queue-properties.x-message-ttl:86400000}"
)
private
String
messageTtl
;
@Value
(
"${token.secret}"
)
private
String
secret
;
@Autowired
private
SendTaskThreadPool
sendTaskThreadPool
;
@Autowired
private
ISiteFeign
siteFeign
;
@Value
(
"${platform.type:cloud}"
)
private
String
platFormType
;
//版本,默认云服务版本
@Autowired
private
SiteService
siteService
;
@Autowired
private
FirmService
firmService
;
@Autowired
private
DeviceLogService
deviceLogService
;
@Autowired
private
ICacheService
cacheService
;
@Autowired
private
MessageProducer
messageProducer
;
@Autowired
protected
ILogService
logService
=
FileLogServiceImpl
.
getInstance
();
...
...
@@ -100,5 +53,35 @@ public class TestSendMsgController {
}
public
static
void
main
(
String
[]
args
)
{
String
resp
=
HttpUtil
.
get
(
"http://59.225.206.13:8331/oauth-pro/admin-pro/sys/randomImage/1675827431800?_t=1675827431"
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
resp
);
// log.info("resp:{}",resp);
log
.
info
(
"result:{}"
,
jsonObject
.
get
(
"result"
));
String
OriginalImg
=
"F:\\pics\\2.jpg"
;
String
ocrResult
=
"F:\\pics\\2-1.jpg"
;
Base64
.
decodeToFile
(
StrUtil
.
replace
(
jsonObject
.
get
(
"result"
).
toString
(),
"data:image/jpg;base64,"
,
""
),
new
File
(
OriginalImg
));
ImgUtils
.
removeBackground
(
OriginalImg
,
ocrResult
);
String
code
=
Tess4J
.
executeTess4J
(
ocrResult
);
log
.
info
(
code
);
/*
//原始验证码地址
//识别样本输出地址
String ocrResult = "F:\\pics\\2.jpg";
//测试登录
//获取并识别验证码
ImgUtils.removeBackground(OriginalImg, ocrResult);
*/
}
}
device-manager/src/main/java/com/mortals/xhx/common/key/Constant.java
View file @
64515fa9
...
...
@@ -88,6 +88,8 @@ public final class Constant {
*/
public
final
static
String
PARAM_SERVER_PHP_HTTP_URL
=
"server_php_http_url"
;
public
final
static
String
PARAM_SERVER_PHP_IN_HTTP_URL
=
"server_php_in_http_url"
;
/**
* 短信平台url
*/
...
...
device-manager/src/main/java/com/mortals/xhx/common/utils/ImgUtils.java
0 → 100644
View file @
64515fa9
package
com.mortals.xhx.common.utils
;
import
javax.imageio.ImageIO
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
public
class
ImgUtils
{
public
static
void
removeBackground
(
String
imgUrl
,
String
resUrl
){
//定义一个临界阈值
int
threshold
=
300
;
try
{
BufferedImage
img
=
ImageIO
.
read
(
new
File
(
imgUrl
));
int
width
=
img
.
getWidth
();
int
height
=
img
.
getHeight
();
for
(
int
i
=
1
;
i
<
width
;
i
++){
for
(
int
x
=
0
;
x
<
width
;
x
++){
for
(
int
y
=
0
;
y
<
height
;
y
++){
Color
color
=
new
Color
(
img
.
getRGB
(
x
,
y
));
System
.
out
.
println
(
"red:"
+
color
.
getRed
()+
" | green:"
+
color
.
getGreen
()+
" | blue:"
+
color
.
getBlue
());
int
num
=
color
.
getRed
()+
color
.
getGreen
()+
color
.
getBlue
();
if
(
num
>=
threshold
){
img
.
setRGB
(
x
,
y
,
Color
.
WHITE
.
getRGB
());
}
}
}
}
for
(
int
i
=
1
;
i
<
width
;
i
++){
Color
color1
=
new
Color
(
img
.
getRGB
(
i
,
1
));
int
num1
=
color1
.
getRed
()+
color1
.
getGreen
()+
color1
.
getBlue
();
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
for
(
int
y
=
0
;
y
<
height
;
y
++)
{
Color
color
=
new
Color
(
img
.
getRGB
(
x
,
y
));
int
num
=
color
.
getRed
()+
color
.
getGreen
()+
color
.
getBlue
();
if
(
num
==
num1
){
img
.
setRGB
(
x
,
y
,
Color
.
BLACK
.
getRGB
());
}
else
{
img
.
setRGB
(
x
,
y
,
Color
.
WHITE
.
getRGB
());
}
}
}
}
File
file
=
new
File
(
resUrl
);
if
(!
file
.
exists
())
{
File
dir
=
file
.
getParentFile
();
if
(!
dir
.
exists
())
{
dir
.
mkdirs
();
}
try
{
file
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
ImageIO
.
write
(
img
,
"jpg"
,
file
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
public
static
void
removeBackground
(
BufferedImage
img
,
String
resUrl
){
//定义一个临界阈值
int
threshold
=
300
;
try
{
// BufferedImage img = ImageIO.read(new File(imgUrl));
int
width
=
img
.
getWidth
();
int
height
=
img
.
getHeight
();
for
(
int
i
=
1
;
i
<
width
;
i
++){
for
(
int
x
=
0
;
x
<
width
;
x
++){
for
(
int
y
=
0
;
y
<
height
;
y
++){
Color
color
=
new
Color
(
img
.
getRGB
(
x
,
y
));
System
.
out
.
println
(
"red:"
+
color
.
getRed
()+
" | green:"
+
color
.
getGreen
()+
" | blue:"
+
color
.
getBlue
());
int
num
=
color
.
getRed
()+
color
.
getGreen
()+
color
.
getBlue
();
if
(
num
>=
threshold
){
img
.
setRGB
(
x
,
y
,
Color
.
WHITE
.
getRGB
());
}
}
}
}
for
(
int
i
=
1
;
i
<
width
;
i
++){
Color
color1
=
new
Color
(
img
.
getRGB
(
i
,
1
));
int
num1
=
color1
.
getRed
()+
color1
.
getGreen
()+
color1
.
getBlue
();
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
for
(
int
y
=
0
;
y
<
height
;
y
++)
{
Color
color
=
new
Color
(
img
.
getRGB
(
x
,
y
));
int
num
=
color
.
getRed
()+
color
.
getGreen
()+
color
.
getBlue
();
if
(
num
==
num1
){
img
.
setRGB
(
x
,
y
,
Color
.
BLACK
.
getRGB
());
}
else
{
img
.
setRGB
(
x
,
y
,
Color
.
WHITE
.
getRGB
());
}
}
}
}
File
file
=
new
File
(
resUrl
);
if
(!
file
.
exists
())
{
File
dir
=
file
.
getParentFile
();
if
(!
dir
.
exists
())
{
dir
.
mkdirs
();
}
try
{
file
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
ImageIO
.
write
(
img
,
"jpg"
,
file
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
public
static
void
cuttingImg
(
String
imgUrl
){
try
{
File
newfile
=
new
File
(
imgUrl
);
BufferedImage
bufferedimage
=
ImageIO
.
read
(
newfile
);
int
width
=
bufferedimage
.
getWidth
();
int
height
=
bufferedimage
.
getHeight
();
if
(
width
>
52
)
{
bufferedimage
=
ImgUtils
.
cropImage
(
bufferedimage
,(
int
)
((
width
-
52
)
/
2
),
0
,(
int
)
(
width
-
(
width
-
52
)
/
2
),(
int
)
(
height
));
if
(
height
>
16
)
{
bufferedimage
=
ImgUtils
.
cropImage
(
bufferedimage
,
0
,(
int
)
((
height
-
16
)
/
2
),
52
,(
int
)
(
height
-
(
height
-
16
)
/
2
));
}
}
else
{
if
(
height
>
16
)
{
bufferedimage
=
ImgUtils
.
cropImage
(
bufferedimage
,
0
,(
int
)
((
height
-
16
)
/
2
),(
int
)
(
width
),(
int
)
(
height
-
(
height
-
16
)
/
2
));
}
}
ImageIO
.
write
(
bufferedimage
,
"jpg"
,
new
File
(
imgUrl
));
}
catch
(
IOException
e
){
e
.
printStackTrace
();
}
}
public
static
BufferedImage
cropImage
(
BufferedImage
bufferedImage
,
int
startX
,
int
startY
,
int
endX
,
int
endY
)
{
int
width
=
bufferedImage
.
getWidth
();
int
height
=
bufferedImage
.
getHeight
();
if
(
startX
==
-
1
)
{
startX
=
0
;
}
if
(
startY
==
-
1
)
{
startY
=
0
;
}
if
(
endX
==
-
1
)
{
endX
=
width
-
1
;
}
if
(
endY
==
-
1
)
{
endY
=
height
-
1
;
}
BufferedImage
result
=
new
BufferedImage
(
endX
-
startX
,
endY
-
startY
,
4
);
for
(
int
x
=
startX
;
x
<
endX
;
++
x
)
{
for
(
int
y
=
startY
;
y
<
endY
;
++
y
)
{
int
rgb
=
bufferedImage
.
getRGB
(
x
,
y
);
result
.
setRGB
(
x
-
startX
,
y
-
startY
,
rgb
);
}
}
return
result
;
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DeviceMsgComsumerStartedService.java
View file @
64515fa9
...
...
@@ -3,9 +3,7 @@ package com.mortals.xhx.daemon.applicationservice;
import
cn.hutool.core.util.IdUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.model.BizLogPdu
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.IMessageProduceService
;
import
com.mortals.framework.springcloud.service.IApplicationStartedService
;
import
com.mortals.xhx.common.code.*
;
import
com.mortals.xhx.common.key.Constant
;
...
...
@@ -27,8 +25,6 @@ import com.mortals.xhx.queue.TopicPartitionInfo;
import
com.mortals.xhx.utils.IotThreadFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
java.util.*
;
...
...
@@ -37,7 +33,9 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
xhx
.
common
.
model
.
MessageHeader
.*;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
PARAM_SERVER_PHP_IN_HTTP_URL
;
import
static
com
.
mortals
.
xhx
.
common
.
model
.
MessageHeader
.
DEVICECODE
;
import
static
com
.
mortals
.
xhx
.
common
.
model
.
MessageHeader
.
MESSAGETYPE
;
//@Component
...
...
@@ -198,13 +196,14 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
}
//获取exchange,
PlatformEntity
platformEntity
=
platformService
.
get
(
deviceEntity
.
getPlatformId
());
String
phpInUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_IN_HTTP_URL
,
"http://172.15.28.116:8090"
);
if
(!
Constant
.
MESSAGETYPE_HEARTBEAT
.
equalsIgnoreCase
(
messageType
)
&&
!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
platformEntity
.
getSendSwitch
()
==
YesNoEnum
.
YES
.
getValue
())
{
if
(
platformEntity
.
getSendMsgType
()
==
SendMsgTypeEnum
.
http
.
getValue
()
&&
!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
)
{
if
(
platformEntity
.
getSendMsgType
()
==
SendMsgTypeEnum
.
http
.
getValue
())
{
//http方式
//通过线程池进行发送消息
SendTask
sendTask
=
new
SendTask
(
p
latformEntity
.
getSendUrl
()
,
queueMsg
.
getData
());
SendTask
sendTask
=
new
SendTask
(
p
hpInUrl
,
queueMsg
.
getData
());
sendTaskThreadPool
.
execute
(
sendTask
);
}
}
...
...
device-manager/src/main/java/com/mortals/xhx/daemon/task/SiteStatTaskImpl.java
View file @
64515fa9
...
...
@@ -12,7 +12,6 @@ import com.mortals.xhx.module.site.model.SiteQuery;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.module.sitestat.model.SitestatEntity
;
import
com.mortals.xhx.module.sitestat.service.SitestatService
;
import
lombok.extern.apachecommons.CommonsLog
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
64515fa9
package
com.mortals.xhx.module.device.service.impl
;
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.ap.GlobalSysInfo
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
...
...
@@ -57,6 +57,7 @@ import java.util.*;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
MESSAGETYPE_NOTIFY_RESTART_APP
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.
PARAM_SERVER_PHP_IN_HTTP_URL
;
import
static
java
.
math
.
BigDecimal
.
ROUND_HALF_DOWN
;
import
static
java
.
util
.
stream
.
Collectors
.
counting
;
...
...
@@ -226,7 +227,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override
public
void
restartApp
(
DeviceEntity
deviceEntity
,
Context
context
)
{
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
.
getIdList
()))
{
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
.
getIdList
()))
{
throw
new
AppException
(
"请选择需要重启应用的设备!"
);
}
...
...
@@ -235,24 +236,24 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
if
(!
ObjectUtils
.
isEmpty
(
device
))
{
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
MESSAGETYPE_NOTIFY_RESTART_APP
);
header
.
put
(
MessageHeader
.
DEVICECODE
,
device
Entity
.
getDeviceCode
());
header
.
put
(
MessageHeader
.
DEVICECODE
,
device
.
getDeviceCode
());
header
.
put
(
MessageHeader
.
TIMESTAMP
,
DateUtils
.
getCurrStrDateTime
());
TbQueueMsg
queueMsg
=
new
DefaultTbQueueMsg
(
IdUtil
.
fastUUID
(),
"W10="
,
header
);
messageProducer
.
sendMsg
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
device
Entity
.
getDeviceCode
(),
JSON
.
toJSONString
(
queueMsg
));
messageProducer
.
sendMsg
(
QueueKey
.
DEFAULT_EXCHANGE
,
Constant
.
DOWN_TOPIC
+
device
.
getDeviceCode
(),
JSON
.
toJSONString
(
queueMsg
));
DeviceLogEntity
deviceLogEntity
=
new
DeviceLogEntity
();
deviceLogEntity
.
initAttrValue
();
deviceLogEntity
.
setTraceID
(
IdUtil
.
fastSimpleUUID
());
deviceLogEntity
.
setSiteId
(
device
Entity
.
getSiteId
());
deviceLogEntity
.
setDeviceId
(
device
Entity
.
getId
());
deviceLogEntity
.
setDeviceName
(
device
Entity
.
getDeviceName
());
deviceLogEntity
.
setDeviceCode
(
device
Entity
.
getDeviceCode
());
deviceLogEntity
.
setSiteId
(
device
.
getSiteId
());
deviceLogEntity
.
setDeviceId
(
device
.
getId
());
deviceLogEntity
.
setDeviceName
(
device
.
getDeviceName
());
deviceLogEntity
.
setDeviceCode
(
device
.
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
);
deviceLogService
.
save
(
deviceLogEntity
,
null
);
}
else
{
log
.
info
(
"未找到设备,deviceCode:{}"
,
device
.
getDeviceCode
());
}
...
...
@@ -336,19 +337,11 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
deviceReq
.
setDeviceStatus
(
update
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
//&& platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue()
&&
entity
.
getSwitchSend
())
{
//http://192.168.0.98:8090/inter/device/deviceIn
if
(
PatternPool
.
URL_HTTP
.
matcher
(
platformEntity
.
getSendUrl
()).
find
())
{
ApiResp
<
String
>
resp
=
messageService
.
sendThirdParty
(
UrlBuilder
.
of
(
platformEntity
.
getSendUrl
()
).
addPath
(
thirdPartyPath
).
build
(),
deviceReq
);
String
phpInUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_IN_HTTP_URL
,
"http://172.15.28.116:8090"
);
ApiResp
<
String
>
resp
=
messageService
.
sendThirdParty
(
UrlBuilder
.
of
(
phpInUrl
).
addPath
(
thirdPartyPath
).
build
(),
deviceReq
);
log
.
info
(
"sendThirtyis resp ==>{}"
,
JSON
.
toJSONString
(
resp
));
}
else
{
throw
new
AppException
(
"http send url 不合法!"
+
platformEntity
.
getSendUrl
());
}
}
else
{
log
.
info
(
"sendThirtyis null ==>{}"
,
JSON
.
toJSONString
(
platformEntity
));
}
}
@Override
...
...
@@ -707,7 +700,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
protected
void
updateBefore
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
super
.
updateBefore
(
entity
,
context
);
ProductEntity
productEntity
=
productService
.
get
(
entity
.
getProductId
(),
context
);
entity
.
setProductCode
(
productEntity
==
null
?
""
:
productEntity
.
getProductCode
());
entity
.
setProductCode
(
productEntity
==
null
?
""
:
productEntity
.
getProductCode
());
updateDeviceHomeUrl
(
entity
);
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/platform/service/impl/PlatformServiceImpl.java
View file @
64515fa9
...
...
@@ -23,7 +23,6 @@ public class PlatformServiceImpl extends AbstractCRUDCacheServiceImpl<PlatformDa
protected
void
validData
(
PlatformEntity
entity
,
Context
context
)
throws
AppException
{
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getSendUrl
())){
if
(!
PatternPool
.
URL_HTTP
.
matcher
(
entity
.
getSendUrl
()).
find
())
{
throw
new
AppException
(
"URL不合法"
);
}
...
...
device-manager/src/main/java/com/mortals/xhx/module/product/service/impl/ProductVersionServiceImpl.java
View file @
64515fa9
package
com.mortals.xhx.module.product.service.impl
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.xhx.base.system.message.impl.MessageProducer
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.common.code.LogTypeEnum
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.QueueKey
;
...
...
@@ -25,10 +29,16 @@ import com.mortals.xhx.module.product.service.ProductVersionService;
import
com.mortals.xhx.queue.DefaultTbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.utils.EncodeUtil
;
import
lombok.Getter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.io.File
;
import
java.nio.charset.Charset
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -42,6 +52,7 @@ import static com.mortals.xhx.common.key.Constant.MESSAGETYPE_UPGREAD;
* @date 2022-08-22
*/
@Service
(
"productVersionService"
)
@Slf4j
public
class
ProductVersionServiceImpl
extends
AbstractCRUDServiceImpl
<
ProductVersionDao
,
ProductVersionEntity
,
Long
>
implements
ProductVersionService
{
@Autowired
...
...
@@ -52,6 +63,12 @@ public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVe
private
MessageProducer
messageProducer
;
@Autowired
private
DeviceLogService
deviceLogService
;
@Autowired
private
UploadService
uploadService
;
@Value
(
"${upload.path}"
)
@Getter
private
String
filePathGlob
;
@Override
...
...
@@ -109,7 +126,7 @@ public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVe
deviceLogEntity
.
setLogType
(
LogTypeEnum
.
下发服务
.
getValue
());
deviceLogEntity
.
setCreateUserId
(
1L
);
deviceLogEntity
.
setCreateTime
(
new
Date
());
deviceLogService
.
save
(
deviceLogEntity
,
null
);
deviceLogService
.
save
(
deviceLogEntity
,
null
);
}
}
}
...
...
@@ -117,6 +134,26 @@ public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVe
@Override
public
void
appPublish
(
ProductVersionEntity
productVersionEntity
,
Context
context
)
{
String
filePath
=
productVersionEntity
.
getFilePath
();
String
targetFilePath
=
uploadService
.
getFilePath
(
productVersionEntity
.
getFilePath
());
String
mainName
=
FileUtil
.
mainName
(
targetFilePath
);
String
type
=
FileUtil
.
extName
(
filePath
);
if
(
"zip"
.
equals
(
type
))
{
String
disPath
=
filePath
+
"/file/fileupload/"
+
mainName
;
String
replace
=
StrUtil
.
replace
(
productVersionEntity
.
getFilePath
(),
FileUtil
.
getName
(
productVersionEntity
.
getFilePath
()),
""
);
disPath
=
filePathGlob
+
"/"
+
replace
+
mainName
+
"/"
;
if
(!
FileUtil
.
isDirectory
(
new
File
(
disPath
))){
FileUtil
.
mkdir
(
disPath
);
}
String
fileEncode
=
"UTF-8"
;
try
{
fileEncode
=
EncodeUtil
.
getEncode
(
targetFilePath
,
true
);
}
catch
(
Exception
e
)
{
log
.
error
(
"异常"
,
e
);
}
log
.
info
(
"unzip disPath:{}"
,
disPath
);
ZipUtil
.
unzip
(
targetFilePath
,
disPath
,
Charset
.
forName
(
fileEncode
));
}
pushUpgradMsg
(
productVersionEntity
,
context
);
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/product/web/ProductController.java
View file @
64515fa9
...
...
@@ -46,7 +46,9 @@ public class ProductController extends BaseCRUDJsonBodyMappingController<Product
@Override
protected
void
init
(
Map
<
String
,
Object
>
model
,
Context
context
)
{
//获取所有产品皮肤 分组显示
Rest
<
RespData
<
List
<
SkinBasePdu
>>>
resp
=
skinBaseFeign
.
list
(
new
SkinBasePdu
());
SkinBasePdu
skinBasePdu
=
new
SkinBasePdu
();
skinBasePdu
.
setSize
(-
1
);
Rest
<
RespData
<
List
<
SkinBasePdu
>>>
resp
=
skinBaseFeign
.
list
(
skinBasePdu
);
if
(
resp
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
Map
<
String
,
Map
<
String
,
String
>>
skinProductCodeMap
=
resp
.
getData
().
getData
().
stream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getProductCode
(),
Collectors
.
toMap
(
a
->
a
.
getImageResolution
()
==
null
?
""
:
a
.
getImageResolution
()+
""
,
b
->
b
.
getImageResolutionValue
()
==
null
?
""
:
b
.
getImageResolutionValue
(),
(
o
,
n
)
->
n
)));
this
.
addDict
(
model
,
"skinProductCodeMap"
,
skinProductCodeMap
);
...
...
device-manager/src/test/java/com/mortals/httpclient/http-client.env.json
View file @
64515fa9
...
...
@@ -14,5 +14,9 @@
"portal"
:
{
"baseUrl"
:
"http://192.168.0.98:11072/zwfw"
,
"baseLogin"
:
"http://192.168.0.98:11078/base"
},
"yibin"
:
{
"baseUrl"
:
"http://10.12.185.213:11078/m"
}
}
\ No newline at end of file
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