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
d1d11717
Commit
d1d11717
authored
Jul 07, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改设备导入功能
parent
b36ac61e
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
379 additions
and
143 deletions
+379
-143
device-manager-ui/admin/src/assets/utils/index.js
device-manager-ui/admin/src/assets/utils/index.js
+232
-125
device-manager-ui/admin/src/views/Home.vue
device-manager-ui/admin/src/views/Home.vue
+0
-4
device-manager-ui/admin/src/views/device/drawershow.vue
device-manager-ui/admin/src/views/device/drawershow.vue
+4
-1
device-manager-ui/admin/src/views/device/list.vue
device-manager-ui/admin/src/views/device/list.vue
+4
-4
device-manager-ui/admin/src/views/device/view.vue
device-manager-ui/admin/src/views/device/view.vue
+1
-1
device-manager/src/main/java/com/mortals/xhx/common/key/RedisKey.java
...er/src/main/java/com/mortals/xhx/common/key/RedisKey.java
+7
-0
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DeviceStartService.java
...als/xhx/daemon/applicationservice/DeviceStartService.java
+48
-2
device-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceEntity.java
...ava/com/mortals/xhx/module/device/model/DeviceEntity.java
+3
-2
device-manager/src/main/java/com/mortals/xhx/module/device/model/vo/DeviceVo.java
...java/com/mortals/xhx/module/device/model/vo/DeviceVo.java
+14
-3
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+28
-1
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
...a/com/mortals/xhx/module/device/web/DeviceController.java
+38
-0
No files found.
device-manager-ui/admin/src/assets/utils/index.js
View file @
d1d11717
import
Qs
from
'
qs
'
;
import
Qs
from
'
qs
'
;
import
{
post
,
get
,
upload
}
from
'
./ajax
'
;
import
{
post
,
get
,
upload
}
from
'
./ajax
'
;
import
queue
from
'
./queue
'
;
import
queue
from
'
./queue
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
cookie
from
'
./cookie
'
;
import
cookie
from
'
./cookie
'
;
...
@@ -41,7 +41,7 @@ export const query = () => {
...
@@ -41,7 +41,7 @@ export const query = () => {
* @returns string
* @returns string
*/
*/
export
const
encodeURI
=
(
data
)
=>
{
export
const
encodeURI
=
(
data
)
=>
{
return
Qs
.
stringify
(
data
,
{
arrayFormat
:
'
repeat
'
,
allowDots
:
true
});
return
Qs
.
stringify
(
data
,
{
arrayFormat
:
'
repeat
'
,
allowDots
:
true
});
}
}
/**
/**
...
@@ -51,15 +51,15 @@ export const encodeURI = (data) => {
...
@@ -51,15 +51,15 @@ export const encodeURI = (data) => {
* @returns {string} val 解析后的结果
* @returns {string} val 解析后的结果
*/
*/
export
function
formatterDate
(
time
)
{
export
function
formatterDate
(
time
)
{
if
(
!
time
)
return
''
;
if
(
!
time
)
return
''
;
let
date
=
new
Date
(
Number
(
time
));
let
date
=
new
Date
(
Number
(
time
));
let
Y
=
date
.
getFullYear
()
+
'
-
'
;
let
Y
=
date
.
getFullYear
()
+
'
-
'
;
let
M
=
(
date
.
getMonth
()
+
1
<
10
?
'
0
'
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
)
+
'
-
'
;
let
M
=
(
date
.
getMonth
()
+
1
<
10
?
'
0
'
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
)
+
'
-
'
;
let
D
=
panLeft
(
date
.
getDate
())
+
'
'
;
let
D
=
panLeft
(
date
.
getDate
())
+
'
'
;
let
h
=
panLeft
(
date
.
getHours
())
+
'
:
'
;
let
h
=
panLeft
(
date
.
getHours
())
+
'
:
'
;
let
m
=
panLeft
(
date
.
getMinutes
())
+
'
:
'
;
let
m
=
panLeft
(
date
.
getMinutes
())
+
'
:
'
;
let
s
=
panLeft
(
date
.
getSeconds
());
let
s
=
panLeft
(
date
.
getSeconds
());
return
Y
+
M
+
D
+
h
+
m
+
s
;
return
Y
+
M
+
D
+
h
+
m
+
s
;
};
};
/**
/**
* formatterDate
* formatterDate
...
@@ -68,53 +68,53 @@ export function formatterDate(time) {
...
@@ -68,53 +68,53 @@ export function formatterDate(time) {
* @returns {string} val 解析后的结果 yyyy-MM-dd
* @returns {string} val 解析后的结果 yyyy-MM-dd
*/
*/
export
function
formatterDateDay
(
datetime
)
{
export
function
formatterDateDay
(
datetime
)
{
if
(
!
datetime
)
return
""
;
if
(
!
datetime
)
return
""
;
if
(
datetime
instanceof
Date
)
{
if
(
datetime
instanceof
Date
)
{
let
Y
=
datetime
.
getFullYear
()
+
"
-
"
;
let
Y
=
datetime
.
getFullYear
()
+
"
-
"
;
let
M
=
let
M
=
(
datetime
.
getMonth
()
+
1
<
10
(
datetime
.
getMonth
()
+
1
<
10
?
"
0
"
+
(
datetime
.
getMonth
()
+
1
)
?
"
0
"
+
(
datetime
.
getMonth
()
+
1
)
:
datetime
.
getMonth
()
+
1
)
+
"
-
"
;
:
datetime
.
getMonth
()
+
1
)
+
"
-
"
;
let
D
=
panLeft
(
datetime
.
getDate
());
let
D
=
panLeft
(
datetime
.
getDate
());
return
Y
+
M
+
D
;
return
Y
+
M
+
D
;
}
else
{
}
else
{
let
transformDate
=
new
Date
(
Number
(
datetime
));
let
transformDate
=
new
Date
(
Number
(
datetime
));
let
Y
=
transformDate
.
getFullYear
()
+
"
-
"
;
let
Y
=
transformDate
.
getFullYear
()
+
"
-
"
;
let
M
=
let
M
=
(
transformDate
.
getMonth
()
+
1
<
10
(
transformDate
.
getMonth
()
+
1
<
10
?
"
0
"
+
(
transformDate
.
getMonth
()
+
1
)
?
"
0
"
+
(
transformDate
.
getMonth
()
+
1
)
:
transformDate
.
getMonth
()
+
1
)
+
"
-
"
;
:
transformDate
.
getMonth
()
+
1
)
+
"
-
"
;
let
D
=
panLeft
(
transformDate
.
getDate
());
let
D
=
panLeft
(
transformDate
.
getDate
());
return
Y
+
M
+
D
;
return
Y
+
M
+
D
;
}
}
return
datetime
;
return
datetime
;
};
};
/**
/**
* 当前日期加天数后得到的相应日期
* 当前日期加天数后得到的相应日期
* @param {*} day
* @param {*} day
*/
*/
export
function
getAddDay
(
day
){
export
function
getAddDay
(
day
)
{
var
today
=
new
Date
();
var
today
=
new
Date
();
var
targetday_milliseconds
=
today
.
getTime
()
+
1000
*
60
*
60
*
24
*
day
;
var
targetday_milliseconds
=
today
.
getTime
()
+
1000
*
60
*
60
*
24
*
day
;
today
.
setTime
(
targetday_milliseconds
);
today
.
setTime
(
targetday_milliseconds
);
var
tYear
=
today
.
getFullYear
();
var
tYear
=
today
.
getFullYear
();
var
tMonth
=
today
.
getMonth
();
var
tMonth
=
today
.
getMonth
();
var
tDate
=
today
.
getDate
();
var
tDate
=
today
.
getDate
();
tMonth
=
doHandleMonth
(
tMonth
+
1
);
tMonth
=
doHandleMonth
(
tMonth
+
1
);
tDate
=
doHandleMonth
(
tDate
);
tDate
=
doHandleMonth
(
tDate
);
return
tYear
+
""
+
tMonth
+
""
+
tDate
;
return
tYear
+
""
+
tMonth
+
""
+
tDate
;
}
}
function
doHandleMonth
(
month
){
function
doHandleMonth
(
month
)
{
var
m
=
month
;
var
m
=
month
;
if
(
month
.
toString
().
length
==
1
)
{
if
(
month
.
toString
().
length
==
1
)
{
m
=
"
0
"
+
month
;
m
=
"
0
"
+
month
;
}
}
return
m
;
return
m
;
}
}
function
panLeft
(
num
){
function
panLeft
(
num
)
{
return
num
<
10
?
'
0
'
+
num
:
num
;
return
num
<
10
?
'
0
'
+
num
:
num
;
}
}
...
@@ -128,10 +128,10 @@ function panLeft(num){
...
@@ -128,10 +128,10 @@ function panLeft(num){
* @returns {Promise} axios请求
* @returns {Promise} axios请求
*/
*/
const
call
=
(
callMethod
,
url
,
formData
,
config
=
{})
=>
{
const
call
=
(
callMethod
,
url
,
formData
,
config
=
{})
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
callMethod
(
url
,
formData
,
config
).
then
(
res
=>
{
callMethod
(
url
,
formData
,
config
).
then
(
res
=>
{
const
{
code
,
msg
,
data
}
=
res
;
const
{
code
,
msg
,
data
}
=
res
;
if
(
code
!==
1
)
{
if
(
code
!==
1
)
{
reject
({
reject
({
message
:
msg
||
''
message
:
msg
||
''
});
});
...
@@ -139,12 +139,12 @@ const call = (callMethod, url, formData, config = {}) => {
...
@@ -139,12 +139,12 @@ const call = (callMethod, url, formData, config = {}) => {
}
}
resolve
(
res
);
resolve
(
res
);
})
})
.
catch
(
error
=>
{
.
catch
(
error
=>
{
if
(
error
.
status
===
403
)
{
if
(
error
.
status
===
403
)
{
window
.
location
.
href
=
'
/#/login
'
window
.
location
.
href
=
'
/#/login
'
}
}
reject
(
error
);
reject
(
error
);
})
})
})
})
};
};
...
@@ -168,14 +168,14 @@ export const normalCallPost = (url, formData, config = {}) => {
...
@@ -168,14 +168,14 @@ export const normalCallPost = (url, formData, config = {}) => {
* @param {Object} [config] 配置
* @param {Object} [config] 配置
* @returns 科里化后的call方法
* @returns 科里化后的call方法
*/
*/
export
const
normalCallGet
=
(
url
,
formData
,
config
=
{})
=>
{
export
const
normalCallGet
=
(
url
,
formData
,
config
=
{})
=>
{
return
call
(
get
,
url
,
formData
,
config
);
return
call
(
get
,
url
,
formData
,
config
);
};
};
const
mimeMap
=
{
const
mimeMap
=
{
xlsx
:
'
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
'
,
xlsx
:
'
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
'
,
zip
:
'
application/zip
'
,
zip
:
'
application/zip
'
,
doc
:
'
application/msword
'
doc
:
'
application/msword
'
}
}
/**
/**
...
@@ -186,35 +186,39 @@ const mimeMap = {
...
@@ -186,35 +186,39 @@ const mimeMap = {
* @param {Object} [config] 配置
* @param {Object} [config] 配置
* @returns {Promise<blob>}
* @returns {Promise<blob>}
*/
*/
export
const
download
=
(
url
,
formData
,
config
=
{})
=>
{
export
const
download
=
(
url
,
formData
,
config
=
{})
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
option
=
Object
.
assign
({},
config
,
{
const
option
=
Object
.
assign
({},
config
,
{
responseType
:
'
blob
'
responseType
:
'
blob
'
})
})
try
{
try
{
const
data
=
await
post
(
url
,
formData
,
option
)
const
data
=
await
post
(
url
,
formData
,
option
)
const
link
=
document
.
createElement
(
'
a
'
)
const
link
=
document
.
createElement
(
'
a
'
)
let
blob
let
blob
let
extName
let
extName
if
(
option
.
type
==
"
zip
"
)
{
if
(
option
.
type
==
"
zip
"
)
{
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
zip
})
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
zip
})
extName
=
"
zip
"
extName
=
"
zip
"
}
else
if
(
option
.
type
==
"
excel
"
)
{
}
else
if
(
option
.
type
==
"
excel
"
)
{
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
xlsx
})
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
xlsx
})
extName
=
"
xlsx
"
extName
=
"
xlsx
"
}
else
if
(
option
.
type
==
"
doc
"
)
{
}
else
if
(
option
.
type
==
"
doc
"
)
{
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
doc
})
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
doc
})
extName
=
"
doc
"
extName
=
"
doc
"
}
else
{
}
else
{
extName
=
"
xlsx
"
extName
=
"
xlsx
"
}
let
fileName
=
"
导出
"
if
(
option
.
fileName
)
{
fileName
=
option
.
fileName
}
}
link
.
href
=
URL
.
createObjectURL
(
blob
)
link
.
href
=
URL
.
createObjectURL
(
blob
)
link
.
setAttribute
(
'
download
'
,
`
${
url
.
substr
(
1
).
replace
(
/
\/
/g
,
'
_
'
)}
_
${
new
Date
().
getTime
()
}
.
${
extName
}
`
)
// 设置下载文件名称
link
.
setAttribute
(
'
download
'
,
`
${
fileName
}
.
${
extName
}
`
)
// 设置下载文件名称
document
.
body
.
appendChild
(
link
)
document
.
body
.
appendChild
(
link
)
link
.
click
()
link
.
click
()
document
.
body
.
appendChild
(
link
)
document
.
body
.
appendChild
(
link
)
resolve
();
resolve
();
}
catch
(
error
)
{
}
catch
(
error
)
{
reject
(
error
);
reject
(
error
);
...
@@ -223,10 +227,10 @@ export const download = (url, formData, config= {}) => {
...
@@ -223,10 +227,10 @@ export const download = (url, formData, config= {}) => {
};
};
export
const
downloadWithCustName
=
(
url
,
formData
,
config
=
{})
=>
{
export
const
downloadWithCustName
=
(
url
,
formData
,
config
=
{})
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
option
=
Object
.
assign
({},
config
,
{
const
option
=
Object
.
assign
({},
config
,
{
responseType
:
'
blob
'
,
responseType
:
'
blob
'
,
baseURL
:
'
/m
'
,
baseURL
:
'
/m
'
,
headers
:
{
headers
:
{
post
:
{
post
:
{
...
@@ -235,36 +239,36 @@ export const downloadWithCustName = (url, formData, config= {}) => {
...
@@ -235,36 +239,36 @@ export const downloadWithCustName = (url, formData, config= {}) => {
}
}
})
})
try
{
try
{
const
params
=
Object
.
assign
({},
formData
,
{
const
params
=
Object
.
assign
({},
formData
,
{
__mortals_token__
:
cookie
.
getItem
(
'
__mortals_token__
'
),
__mortals_token__
:
cookie
.
getItem
(
'
__mortals_token__
'
),
})
})
var
requestData
=
Qs
.
stringify
(
params
,
{
arrayFormat
:
'
repeat
'
,
allowDots
:
true
});
var
requestData
=
Qs
.
stringify
(
params
,
{
arrayFormat
:
'
repeat
'
,
allowDots
:
true
});
axios
.
post
(
url
,
requestData
,
option
)
axios
.
post
(
url
,
requestData
,
option
)
.
then
(
response
=>
{
.
then
(
response
=>
{
if
(
response
.
data
.
type
==
'
application/json
'
)
{
if
(
response
.
data
.
type
==
'
application/json
'
)
{
var
reader
=
new
FileReader
();
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
event
)
{
reader
.
onload
=
function
(
event
)
{
var
content
=
reader
.
result
;
var
content
=
reader
.
result
;
reject
(
content
);
reject
(
content
);
};
};
reader
.
readAsText
(
response
.
data
);
reader
.
readAsText
(
response
.
data
);
return
;
return
;
}
}
const
filename
=
decodeURI
(
response
.
headers
[
'
content-disposition
'
].
split
(
'
;
'
)[
1
].
split
(
'
=
'
)[
1
])
||
`
${
url
.
substr
(
1
).
replace
(
/
\/
/g
,
'
_
'
)}
_
${
new
Date
().
getTime
()}
.xls`
const
filename
=
decodeURI
(
response
.
headers
[
'
content-disposition
'
].
split
(
'
;
'
)[
1
].
split
(
'
=
'
)[
1
])
||
`
${
url
.
substr
(
1
).
replace
(
/
\/
/g
,
'
_
'
)}
_
${
new
Date
().
getTime
()}
.xls`
let
downloadUrl
=
window
.
URL
.
createObjectURL
(
new
Blob
([
response
.
data
]))
let
downloadUrl
=
window
.
URL
.
createObjectURL
(
new
Blob
([
response
.
data
]))
let
link
=
document
.
createElement
(
'
a
'
)
let
link
=
document
.
createElement
(
'
a
'
)
link
.
style
.
display
=
'
none
'
;
link
.
style
.
display
=
'
none
'
;
link
.
href
=
downloadUrl
;
link
.
href
=
downloadUrl
;
link
.
setAttribute
(
'
download
'
,
filename
);
link
.
setAttribute
(
'
download
'
,
filename
);
document
.
body
.
appendChild
(
link
);
document
.
body
.
appendChild
(
link
);
link
.
click
();
link
.
click
();
document
.
body
.
removeChild
(
link
);
document
.
body
.
removeChild
(
link
);
resolve
();
resolve
();
},
err
=>
{
},
err
=>
{
reject
(
err
);
reject
(
err
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
reject
(
error
)
reject
(
error
)
})
})
}
catch
(
error
)
{
}
catch
(
error
)
{
reject
(
error
);
reject
(
error
);
}
}
...
@@ -279,7 +283,7 @@ export const downloadWithCustName = (url, formData, config= {}) => {
...
@@ -279,7 +283,7 @@ export const downloadWithCustName = (url, formData, config= {}) => {
* @param {Object} [config] 配置
* @param {Object} [config] 配置
* @returns 科里化后的call方法
* @returns 科里化后的call方法
*/
*/
export
const
normalCallUpload
=
(
url
,
formData
,
config
=
{})
=>
{
export
const
normalCallUpload
=
(
url
,
formData
,
config
=
{})
=>
{
return
call
(
upload
,
url
,
formData
,
config
);
return
call
(
upload
,
url
,
formData
,
config
);
};
};
...
@@ -299,17 +303,17 @@ export const queueCall = (url, formData, config = {}) => {
...
@@ -299,17 +303,17 @@ export const queueCall = (url, formData, config = {}) => {
* 根据条件查询用户列表
* 根据条件查询用户列表
*/
*/
export
async
function
getUserListByQuery
(
query
)
{
export
async
function
getUserListByQuery
(
query
)
{
try
{
try
{
/* //下拉只获取正常状态数据:status{0: "停用", 1: "正常", 2: "冻结", 3: "销户", 4: "离职"}
/* //下拉只获取正常状态数据:status{0: "停用", 1: "正常", 2: "冻结", 3: "销户", 4: "离职"}
query["query.status"] = 1;*/
query["query.status"] = 1;*/
const
data
=
await
normalCallPost
(
'
/user/list
'
,
query
);
const
data
=
await
normalCallPost
(
'
/user/list
'
,
query
);
const
list
=
data
.
data
.
data
.
map
(({
id
,
loginName
,
realName
,
mobile
})
=>
{
const
list
=
data
.
data
.
result
.
map
(({
id
,
loginName
,
realName
,
mobile
})
=>
{
return
{
id
,
loginName
,
realName
,
mobile
}
return
{
id
,
loginName
,
realName
,
mobile
}
});
});
return
list
;
return
list
;
}
catch
(
error
)
{
}
catch
(
error
)
{
return
[];
return
[];
}
}
};
};
...
@@ -321,27 +325,130 @@ export async function getUserListByQuery(query) {
...
@@ -321,27 +325,130 @@ export async function getUserListByQuery(query) {
* @param {*} children 孩子节点字段 默认 'children'
* @param {*} children 孩子节点字段 默认 'children'
* @param {*} rootId 根Id 默认 0
* @param {*} rootId 根Id 默认 0
*/
*/
export
function
handleTree
(
data
,
id
,
parentId
,
children
,
rootId
)
{
export
function
handleTree
(
data
,
id
,
parentId
,
children
,
rootId
)
{
console
.
log
(
"
00000000
"
)
id
=
id
||
'
id
'
id
=
id
||
'
id
'
parentId
=
parentId
||
'
parentId
'
parentId
=
parentId
||
'
parentId
'
children
=
children
||
'
children
'
children
=
children
||
'
children
'
rootId
=
rootId
||
Math
.
min
.
apply
(
Math
,
data
.
map
(
item
=>
{
return
item
[
parentId
]
}))
||
0
rootId
=
rootId
||
Math
.
min
.
apply
(
Math
,
data
.
map
(
item
=>
{
return
item
[
parentId
]
}))
||
0
//对源数据深度克隆
//对源数据深度克隆
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
//循环所有项
//循环所有项
console
.
log
(
"
11111
"
,
cloneData
)
console
.
log
(
"
11111
"
,
cloneData
)
const
treeData
=
cloneData
.
filter
(
father
=>
{
const
treeData
=
cloneData
.
filter
(
father
=>
{
let
branchArr
=
cloneData
.
filter
(
child
=>
{
let
branchArr
=
cloneData
.
filter
(
child
=>
{
//返回每一项的子级数组
//返回每一项的子级数组
return
father
[
id
]
===
child
[
parentId
]
return
father
[
id
]
===
child
[
parentId
]
});
});
branchArr
.
length
>
0
?
father
.
children
=
branchArr
:
''
;
branchArr
.
length
>
0
?
father
.
children
=
branchArr
:
''
;
//返回第一层
//返回第一层
return
father
[
parentId
]
===
rootId
;
return
father
[
parentId
]
===
rootId
;
});
});
console
.
log
(
"
treeData
"
,
treeData
)
console
.
log
(
"
treeData
"
,
treeData
)
return
treeData
!=
''
?
treeData
:
data
;
return
treeData
!=
''
?
treeData
:
data
;
};
};
/**
* 下载文件
* @param {String} path - 下载地址/下载请求地址。
* @param {String} name - 下载文件的名字/重命名(考虑到兼容性问题,最好加上后缀名)
*/
export
function
downloadFile
(
path
,
name
)
{
if
(
path
&&
name
)
{
const
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
"
get
"
,
path
);
xhr
.
responseType
=
"
blob
"
;
xhr
.
send
();
xhr
.
onload
=
function
()
{
if
(
this
.
status
===
200
||
this
.
status
===
304
)
{
// 如果是IE10及以上,不支持download属性,采用msSaveOrOpenBlob方法,但是IE10以下也不支持msSaveOrOpenBlob
if
(
"
msSaveOrOpenBlob
"
in
navigator
)
{
navigator
.
msSaveOrOpenBlob
(
this
.
response
,
name
);
return
;
}
// const blob = new Blob([this.response], { type: xhr.getResponseHeader('Content-Type') });
// const url = URL.createObjectURL(blob);
const
url
=
URL
.
createObjectURL
(
this
.
response
);
const
a
=
document
.
createElement
(
"
a
"
);
a
.
style
.
display
=
"
none
"
;
a
.
href
=
url
;
a
.
download
=
name
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
document
.
body
.
removeChild
(
a
);
URL
.
revokeObjectURL
(
url
);
}
};
}
}
// 当元素滚动条被滚动时运行的脚本
export
function
handleScroll
()
{
let
scrollbarEl
=
this
.
$refs
[
"
scroll
"
].
wrap
;
let
jump
=
document
.
querySelectorAll
(
"
.step-jump
"
);
scrollbarEl
.
onscroll
=
()
=>
{
let
distance
=
scrollbarEl
.
scrollTop
;
jump
.
forEach
((
item
,
index
)
=>
{
if
(
distance
>=
item
.
offsetTop
)
{
this
.
activeStep
=
index
;
}
});
};
}
// 锚点点击
export
function
jump
(
index
)
{
console
.
log
(
index
);
let
_this
=
this
;
this
.
activeStep
=
index
;
// 用 class=".step-jump" 添加锚点,此时的类名要放在tr上,放在td上不对,
// 以后做的时候要注意这点,不是表格的时候,如何放置锚点
let
jump
=
document
.
querySelectorAll
(
"
.step-jump
"
);
console
.
log
(
"
jump
"
,
jump
);
// 通过 offsetTop 获取对象到窗体顶部的距离,然后赋值给 scrollTop,就能实现锚点的功能
let
total
=
jump
[
index
].
offsetTop
;
console
.
log
(
total
);
// scrollTop滚动条距离页面的距离
let
distance
=
this
.
$refs
[
"
scroll
"
].
wrap
.
scrollTop
;
// 平滑滚动,时长500ms,每10ms一跳,共50跳
let
step
=
total
/
50
;
if
(
total
>
distance
)
{
smoothDown
();
}
else
{
let
newTotal
=
distance
-
total
;
step
=
newTotal
/
50
;
smoothUp
();
}
function
smoothDown
()
{
if
(
distance
<
total
)
{
distance
+=
step
;
_this
.
$refs
[
"
scroll
"
].
wrap
.
scrollTop
=
distance
;
setTimeout
(
smoothDown
,
10
);
}
else
{
_this
.
$refs
[
"
scroll
"
].
wrap
.
scrollTop
=
distance
;
document
.
body
.
scrollTop
=
total
;
document
.
documentElement
.
scrollTop
=
total
;
window
.
pageYOffset
=
total
;
}
}
function
smoothUp
()
{
if
(
distance
>
total
)
{
distance
-=
step
;
_this
.
$refs
[
"
scroll
"
].
wrap
.
scrollTop
=
distance
;
setTimeout
(
smoothUp
,
10
);
}
else
{
_this
.
$refs
[
"
scroll
"
].
wrap
.
scrollTop
=
distance
;
}
}
};
device-manager-ui/admin/src/views/Home.vue
View file @
d1d11717
...
@@ -193,9 +193,6 @@ export default {
...
@@ -193,9 +193,6 @@ export default {
},
},
created
()
{
created
()
{
let
today
=
new
Date
();
let
today
=
new
Date
();
console
.
log
(
"
year:
"
,
today
.
getFullYear
())
let
query
=
{
let
query
=
{
year
:
today
.
getFullYear
(),
year
:
today
.
getFullYear
(),
month
:
today
.
getMonth
()
+
1
,
month
:
today
.
getMonth
()
+
1
,
...
@@ -208,7 +205,6 @@ export default {
...
@@ -208,7 +205,6 @@ export default {
if
(
res
.
code
==
1
)
{
if
(
res
.
code
==
1
)
{
console
.
log
(
"
res
"
,
res
);
console
.
log
(
"
res
"
,
res
);
this
.
statData
=
res
.
data
.
data
[
0
];
this
.
statData
=
res
.
data
.
data
[
0
];
console
.
log
(
"
statData
"
,
this
.
statData
);
console
.
log
(
"
statData
"
,
this
.
statData
);
}
}
this
.
loading
=
false
;
this
.
loading
=
false
;
...
...
device-manager-ui/admin/src/views/device/drawershow.vue
View file @
d1d11717
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<el-row>
<el-row>
<Field
label=
"设备名称"
prop=
"deviceName"
v-model=
"form.deviceName"
placeholder=
"请输入设备名称"
/>
<Field
label=
"设备名称"
prop=
"deviceName"
v-model=
"form.deviceName"
placeholder=
"请输入设备名称"
/>
<Field
label=
"
SN码"
prop=
"deviceCode"
v-model=
"form.deviceCode"
placeholder=
"请输入设备SN
码"
/>
<Field
label=
"
设备编码"
prop=
"deviceCode"
v-model=
"form.deviceCode"
placeholder=
"请输入设备编码
码"
/>
<Field
label=
"MAC地址"
prop=
"deviceMac"
v-model=
"form.deviceMac"
placeholder=
"请输入设备的MAC地址"
/>
<Field
label=
"MAC地址"
prop=
"deviceMac"
v-model=
"form.deviceMac"
placeholder=
"请输入设备的MAC地址"
/>
<Field
label=
"平台类型"
prop=
"platformId"
v-model=
"form.platformId"
type=
"select"
:enumData=
"dict.platformId"
placeholder=
"请选择平台类型"
/>
<Field
label=
"平台类型"
prop=
"platformId"
v-model=
"form.platformId"
type=
"select"
:enumData=
"dict.platformId"
placeholder=
"请选择平台类型"
/>
<Field
label=
"产品类型"
prop=
"productId"
v-model=
"form.productId"
type=
"select"
:enumData=
"dict.productId"
placeholder=
"请选择产品类型"
/>
<Field
label=
"产品类型"
prop=
"productId"
v-model=
"form.productId"
type=
"select"
:enumData=
"dict.productId"
placeholder=
"请选择产品类型"
/>
...
@@ -77,6 +77,9 @@
...
@@ -77,6 +77,9 @@
{
required
:
true
,
message
:
"
请输入设备名称
"
,
trigger
:
"
blur
"
},
{
required
:
true
,
message
:
"
请输入设备名称
"
,
trigger
:
"
blur
"
},
{
max
:
20
,
message
:
"
最多只能录入20个字符
"
,
trigger
:
"
blur
"
,},
{
max
:
20
,
message
:
"
最多只能录入20个字符
"
,
trigger
:
"
blur
"
,},
],
],
deviceCode
:
[
{
required
:
true
,
message
:
"
请输入设备编码
"
,
trigger
:
"
blur
"
},
],
platformId
:
[
platformId
:
[
{
required
:
true
,
message
:
"
请选择平台
"
,
trigger
:
"
blur
"
},
{
required
:
true
,
message
:
"
请选择平台
"
,
trigger
:
"
blur
"
},
],
],
...
...
device-manager-ui/admin/src/views/device/list.vue
View file @
d1d11717
...
@@ -80,7 +80,7 @@
...
@@ -80,7 +80,7 @@
:limit=
"1"
:limit=
"1"
accept=
".xlsx, .xls"
accept=
".xlsx, .xls"
:headers=
"upload.headers"
:headers=
"upload.headers"
:action=
"upload.url + '?
updateSupport=' + upload.updateSupport
"
:action=
"upload.url + '?
siteId=' + siteId
"
:disabled=
"upload.isUploading"
:disabled=
"upload.isUploading"
:on-progress=
"handleFileUploadProgress"
:on-progress=
"handleFileUploadProgress"
:on-success=
"handleFileSuccess"
:on-success=
"handleFileSuccess"
...
@@ -154,7 +154,7 @@ export default {
...
@@ -154,7 +154,7 @@ export default {
/** 下载模板操作 */
/** 下载模板操作 */
downloadTemplate
()
{
downloadTemplate
()
{
this
.
isExport
=
true
;
this
.
isExport
=
true
;
this
.
$download
(
"
/device/downloadTemplate
"
,
{},
{
type
:
"
excel
"
})
this
.
$download
(
"
/device/downloadTemplate
"
,
{},
{
type
:
"
excel
"
,
fileName
:
"
设备导入模板
"
})
.
then
(()
=>
(
this
.
isExport
=
false
))
.
then
(()
=>
(
this
.
isExport
=
false
))
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
this
.
isExport
=
false
;
this
.
isExport
=
false
;
...
@@ -187,7 +187,7 @@ export default {
...
@@ -187,7 +187,7 @@ export default {
"
deviceName
"
:
this
.
$route
.
query
[
"
deviceName
"
],
"
deviceName
"
:
this
.
$route
.
query
[
"
deviceName
"
],
"
siteId
"
:
this
.
$route
.
query
[
"
siteId
"
],
"
siteId
"
:
this
.
$route
.
query
[
"
siteId
"
],
},
},
{
type
:
"
excel
"
}
{
type
:
"
excel
"
,
fileName
:
"
设备表
"
}
)
)
.
then
(()
=>
(
this
.
isExport
=
false
))
.
then
(()
=>
(
this
.
isExport
=
false
))
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
...
@@ -357,7 +357,7 @@ export default {
...
@@ -357,7 +357,7 @@ export default {
<
div
>
<
div
>
<
table
-
buttons
<
table
-
buttons
noAdd
noAdd
noEdit
row
=
{
row
}
row
=
{
row
}
onEdit
=
{
this
.
toEdit
}
onEdit
=
{
this
.
toEdit
}
onView
=
{
this
.
toView
}
onView
=
{
this
.
toView
}
...
...
device-manager-ui/admin/src/views/device/view.vue
View file @
d1d11717
...
@@ -149,7 +149,7 @@
...
@@ -149,7 +149,7 @@
content-class-name=
"contentClass"
content-class-name=
"contentClass"
>
>
<Image
Upload
v-model=
"form.devicePhotoPath"
prePath=
"/file/preview"
/>
<Image
Preview
:src=
"form.devicePhotoPath"
/>
</el-descriptions-item>
</el-descriptions-item>
...
...
device-manager/src/main/java/com/mortals/xhx/common/key/RedisKey.java
View file @
d1d11717
...
@@ -14,4 +14,11 @@ public class RedisKey {
...
@@ -14,4 +14,11 @@ public class RedisKey {
*/
*/
public
static
final
String
KEY_DEVICE_ONLINE_CACHE
=
"device:online:"
;
public
static
final
String
KEY_DEVICE_ONLINE_CACHE
=
"device:online:"
;
public
static
final
String
KEY_SITE_CACHE
=
"siteDict"
;
public
static
final
String
KEY_PLATFORM_CACHE
=
"platformDict"
;
public
static
final
String
KEY_PRODUCT_CACHE
=
"productDict"
;
}
}
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DeviceStartService.java
View file @
d1d11717
package
com.mortals.xhx.daemon.applicationservice
;
package
com.mortals.xhx.daemon.applicationservice
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.springcloud.service.IApplicationService
;
import
com.mortals.framework.springcloud.service.IApplicationService
;
import
com.mortals.framework.springcloud.service.IApplicationStartedService
;
import
com.mortals.xhx.common.pdu.site.SitePdu
;
import
com.mortals.xhx.common.utils.SendTaskThreadPool
;
import
com.mortals.xhx.common.utils.SendTaskThreadPool
;
import
com.mortals.xhx.common.utils.SmsQueueManager
;
import
com.mortals.xhx.common.utils.SmsQueueManager
;
import
com.mortals.xhx.feign.site.ISiteFeign
;
import
com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity
;
import
com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity
;
import
com.mortals.xhx.module.platform.model.PlatformQuery
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.model.ProductQuery
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.queue.TbQueueMsg
;
import
com.mortals.xhx.utils.IotThreadFactory
;
import
com.mortals.xhx.utils.IotThreadFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -19,21 +29,31 @@ import java.util.concurrent.ExecutorService;
...
@@ -19,21 +29,31 @@ import java.util.concurrent.ExecutorService;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
RedisKey
.*;
@Component
@Component
@Slf4j
@Slf4j
public
class
DeviceStartService
implements
IApplicationService
{
public
class
DeviceStartService
implements
IApplicationS
tartedS
ervice
{
@Autowired
@Autowired
private
SendTaskThreadPool
sendTaskThreadPool
;
private
SendTaskThreadPool
sendTaskThreadPool
;
protected
Boolean
stopped
=
false
;
protected
Boolean
stopped
=
false
;
@Autowired
private
ICacheService
cacheService
;
@Autowired
private
ISiteFeign
siteFeign
;
@Autowired
private
PlatformService
platformService
;
@Autowired
private
ProductService
productService
;
@Override
@Override
public
void
start
()
{
public
void
start
()
{
log
.
info
(
"初始化发送线程数量"
);
log
.
info
(
"初始化发送线程数量"
);
sendTaskThreadPool
.
init
(
20
);
sendTaskThreadPool
.
init
(
20
);
//启动短信发送响应更新线程
//启动短信发送响应更新线程
sendTaskThreadPool
.
execute
(()
->
{
sendTaskThreadPool
.
execute
(()
->
{
int
waitTime
=
1000
;
int
waitTime
=
1000
;
while
(!
stopped
)
{
while
(!
stopped
)
{
...
@@ -55,6 +75,27 @@ public class DeviceStartService implements IApplicationService {
...
@@ -55,6 +75,27 @@ public class DeviceStartService implements IApplicationService {
});
});
//初始化站点缓存
String
resp
=
siteFeign
.
list
(
new
SitePdu
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
resp
);
if
(
jsonObject
.
getInteger
(
"code"
)
==
1
)
{
List
<
SitePdu
>
sitePduList
=
jsonObject
.
getJSONObject
(
"data"
).
getObject
(
"data"
,
new
TypeReference
<
List
<
SitePdu
>>()
{
});
sitePduList
.
stream
().
forEach
(
sitePdu
->
{
cacheService
.
hset
(
KEY_SITE_CACHE
,
sitePdu
.
getId
().
toString
(),
sitePdu
.
getSiteName
());
});
}
productService
.
find
(
new
ProductQuery
()).
stream
().
forEach
(
item
->
{
cacheService
.
hset
(
KEY_PRODUCT_CACHE
,
item
.
getProductCode
(),
item
.
getProductName
());
});
platformService
.
find
(
new
PlatformQuery
()).
stream
().
forEach
(
item
->
{
cacheService
.
hset
(
KEY_PLATFORM_CACHE
,
item
.
getPlatformSn
(),
item
.
getPlatformName
());
});
log
.
info
(
"开始服务..[配置已加载完成,但部分框架还未初始化,比如:Kafka]"
);
log
.
info
(
"开始服务..[配置已加载完成,但部分框架还未初始化,比如:Kafka]"
);
}
}
...
@@ -63,4 +104,9 @@ public class DeviceStartService implements IApplicationService {
...
@@ -63,4 +104,9 @@ public class DeviceStartService implements IApplicationService {
log
.
info
(
"停止服务.."
);
log
.
info
(
"停止服务.."
);
}
}
@Override
public
int
getOrder
()
{
return
50
;
}
}
}
device-manager/src/main/java/com/mortals/xhx/module/device/model/DeviceEntity.java
View file @
d1d11717
...
@@ -27,7 +27,7 @@ public class DeviceEntity extends DeviceVo {
...
@@ -27,7 +27,7 @@ public class DeviceEntity extends DeviceVo {
/**
/**
* 设备编码,SN码等,默认为MAC地址
* 设备编码,SN码等,默认为MAC地址
*/
*/
@Excel
(
name
=
"设备编码
,SN码等,默认为MAC地址
"
)
@Excel
(
name
=
"设备编码"
)
private
String
deviceCode
;
private
String
deviceCode
;
/**
/**
* 设备的MAC地址
* 设备的MAC地址
...
@@ -36,6 +36,7 @@ public class DeviceEntity extends DeviceVo {
...
@@ -36,6 +36,7 @@ public class DeviceEntity extends DeviceVo {
/**
/**
* 站点Id,来源基础服务平台
* 站点Id,来源基础服务平台
*/
*/
//@Excel(name = "站点名称",cacheDict = "siteDict")
private
Long
siteId
;
private
Long
siteId
;
/**
/**
* 站点编号,来源基础服务平台
* 站点编号,来源基础服务平台
...
@@ -68,7 +69,6 @@ public class DeviceEntity extends DeviceVo {
...
@@ -68,7 +69,6 @@ public class DeviceEntity extends DeviceVo {
/**
/**
* 设备生产厂商名称
* 设备生产厂商名称
*/
*/
@Excel
(
name
=
"设备生产厂商名称"
)
private
String
deviceFirmname
;
private
String
deviceFirmname
;
/**
/**
* 设备来源(0.子设备,1.网关设备,2.直连设备)
* 设备来源(0.子设备,1.网关设备,2.直连设备)
...
@@ -114,6 +114,7 @@ public class DeviceEntity extends DeviceVo {
...
@@ -114,6 +114,7 @@ public class DeviceEntity extends DeviceVo {
/**
/**
* 设备图片
* 设备图片
*/
*/
@Excel
(
name
=
"设备图片"
,
height
=
90
,
type
=
Excel
.
Type
.
EXPORT
,
cellType
=
Excel
.
ColumnType
.
IMAGE
)
private
String
devicePhotoPath
;
private
String
devicePhotoPath
;
/**
/**
* 设备访问ip
* 设备访问ip
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/model/vo/DeviceVo.java
View file @
d1d11717
package
com.mortals.xhx.module.device.model.vo
;
package
com.mortals.xhx.module.device.model.vo
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
com.mortals.framework.annotation.Excel
;
import
com.mortals.framework.annotation.Excel
;
import
com.mortals.framework.model.BaseEntityLong
;
import
com.mortals.framework.model.BaseEntityLong
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
lombok.Data
;
import
lombok.Data
;
import
org.apache.poi.ss.usermodel.PictureData
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -22,14 +26,13 @@ public class DeviceVo extends BaseEntityLong {
...
@@ -22,14 +26,13 @@ public class DeviceVo extends BaseEntityLong {
/**
/**
* 平台编码
* 平台编码
*/
*/
@Excel
(
name
=
"平台
编码"
,
combo
=
{
"排号系统"
},
readConverterExp
=
"phxt=排号系统
"
)
@Excel
(
name
=
"平台
"
,
cacheDict
=
"platformDict
"
)
private
String
platformCode
;
private
String
platformCode
;
/**
/**
* 产品编码
* 产品编码
*/
*/
@Excel
(
name
=
"产品编码"
,
combo
=
{
"排队机"
,
"窗口屏"
,
"呼叫器"
,
"集中显示屏"
,
"导视机"
,
"评价器"
,
"自助服务终端"
,
"填单机"
,
"样表机"
}
@Excel
(
name
=
"产品"
,
cacheDict
=
"productDict"
)
,
readConverterExp
=
"pdj=排队机,ckp=窗口屏,hjq=呼叫器,jzxsp=集中显示屏,dsj=导视机,pjq=评价器,zzfwzd=自助服务终端,tdj=填单机,ybj=样表机"
)
private
String
productCode
;
private
String
productCode
;
...
@@ -37,4 +40,12 @@ public class DeviceVo extends BaseEntityLong {
...
@@ -37,4 +40,12 @@ public class DeviceVo extends BaseEntityLong {
* 是否通知第三方
* 是否通知第三方
*/
*/
private
Boolean
switchSend
=
true
;
private
Boolean
switchSend
=
true
;
/**
* 设备图片附件
*/
@Excel
(
name
=
"设备图片"
,
type
=
Excel
.
Type
.
IMPORT
,
cellType
=
Excel
.
ColumnType
.
IMAGE
)
@JSONField
(
deserialize
=
false
,
serialize
=
false
)
@JsonIgnore
private
PictureData
picObj
;
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
d1d11717
...
@@ -19,8 +19,10 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
...
@@ -19,8 +19,10 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.device.service.DeviceService
;
import
com.mortals.xhx.module.platform.model.PlatformEntity
;
import
com.mortals.xhx.module.platform.model.PlatformEntity
;
import
com.mortals.xhx.module.platform.model.PlatformQuery
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.platform.service.PlatformService
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.model.ProductQuery
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.queue.*
;
import
com.mortals.xhx.queue.*
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -283,13 +285,38 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -283,13 +285,38 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override
@Override
protected
void
saveBefore
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
saveBefore
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
if
(
ObjectUtils
.
isEmpty
(
entity
.
getDeviceCode
()))
{
throw
new
AppException
(
"设备编码不能为空!"
);
}
entity
.
setDeviceCode
(
StrUtil
.
replace
(
entity
.
getDeviceCode
(),
":"
,
"-"
));
if
(
ObjectUtils
.
isEmpty
(
entity
.
getDeviceMac
()))
{
entity
.
setDeviceMac
(
entity
.
getDeviceCode
());
}
//产品编码唯一
//产品编码唯一
DeviceEntity
deviceEntity
=
this
.
selectOne
(
new
DeviceQuery
().
deviceCode
(
entity
.
getDeviceCode
()));
DeviceEntity
deviceEntity
=
this
.
selectOne
(
new
DeviceQuery
().
deviceCode
(
entity
.
getDeviceCode
()));
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
throw
new
AppException
(
"设备编码重复!"
);
throw
new
AppException
(
"设备编码重复!"
);
}
}
entity
.
setDeviceCode
(
StrUtil
.
replace
(
entity
.
getDeviceCode
(),
":"
,
"-"
));
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getPlatformCode
()))
{
PlatformEntity
platformEntity
=
platformService
.
selectOne
(
new
PlatformQuery
().
platformSn
(
entity
.
getPlatformCode
()));
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
))
{
entity
.
setPlatformId
(
platformEntity
.
getId
());
entity
.
setPlatformName
(
platformEntity
.
getPlatformName
());
}
}
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getProductCode
()))
{
ProductEntity
productEntity
=
productService
.
selectOne
(
new
ProductQuery
().
productCode
(
entity
.
getProductCode
()));
if
(!
ObjectUtils
.
isEmpty
(
productEntity
))
{
entity
.
setProductId
(
productEntity
.
getId
());
entity
.
setProductName
(
productEntity
.
getProductName
());
}
}
super
.
saveBefore
(
entity
,
context
);
super
.
saveBefore
(
entity
,
context
);
...
...
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
View file @
d1d11717
package
com.mortals.xhx.module.device.web
;
package
com.mortals.xhx.module.device.web
;
import
cn.hutool.core.convert.Convert
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.util.FileUtil
;
import
com.mortals.framework.utils.ReflectUtils
;
import
com.mortals.framework.utils.poi.ExcelUtil
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
...
@@ -32,7 +37,10 @@ import com.mortals.xhx.queue.TopicPartitionInfo;
...
@@ -32,7 +37,10 @@ import com.mortals.xhx.queue.TopicPartitionInfo;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -60,6 +68,8 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
...
@@ -60,6 +68,8 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
private
PlatformService
platformService
;
private
PlatformService
platformService
;
@Autowired
@Autowired
private
MessageService
messageService
;
private
MessageService
messageService
;
@Autowired
private
UploadService
uploadService
;
public
DeviceController
()
{
public
DeviceController
()
{
super
.
setModuleDesc
(
"设备"
);
super
.
setModuleDesc
(
"设备"
);
...
@@ -244,4 +254,32 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
...
@@ -244,4 +254,32 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
return
jsonObject
.
toJSONString
();
return
jsonObject
.
toJSONString
();
}
}
@Override
public
void
doImportDataBefore
(
List
<
DeviceEntity
>
list
,
boolean
updateSupport
,
Context
context
)
throws
AppException
{
String
siteId
=
request
.
getParameter
(
"siteId"
);
if
(!
ObjectUtils
.
isEmpty
(
siteId
)){
list
.
stream
().
forEach
(
item
->
item
.
setSiteId
(
Convert
.
toLong
(
siteId
,
0L
)));
}
list
.
stream
().
peek
(
item
->
{
if
(!
ObjectUtils
.
isEmpty
(
item
.
getPicObj
()))
{
String
extension
=
item
.
getPicObj
().
suggestFileExtension
();
String
newName
=
"/file/uploadfile/"
+
new
Date
().
getTime
()
+
"."
+
extension
;
String
filePath
=
uploadService
.
getFilePath
(
newName
);
try
{
boolean
bool
=
FileUtil
.
write
(
filePath
,
item
.
getPicObj
().
getData
(),
true
,
true
);
if
(
bool
)
{
item
.
setDevicePhotoPath
(
newName
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
).
count
();
super
.
doImportDataBefore
(
list
,
updateSupport
,
context
);
}
}
}
\ 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