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
cf98968d
Commit
cf98968d
authored
Jul 13, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备列表导出优化
parent
29fc4619
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
4 deletions
+48
-4
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+48
-4
No files found.
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
cf98968d
...
@@ -78,6 +78,52 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -78,6 +78,52 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
super
.
validData
(
entity
,
context
);
super
.
validData
(
entity
,
context
);
}
}
@Override
public
String
importList
(
List
<
DeviceEntity
>
list
,
Boolean
updateSupport
,
Context
context
)
{
if
(
ObjectUtils
.
isEmpty
(
list
))
{
throw
new
AppException
(
"导入数据不能为空!"
);
}
int
successNum
=
0
;
int
failureNum
=
0
;
StringBuilder
successMsg
=
new
StringBuilder
();
StringBuilder
failureMsg
=
new
StringBuilder
();
//去掉list中设备编码已重复的
for
(
DeviceEntity
entity
:
list
)
{
try
{
entity
.
setDeviceCode
(
StrUtil
.
replace
(
entity
.
getDeviceCode
(),
":"
,
"-"
));
DeviceEntity
deviceEntity
=
this
.
getCache
(
entity
.
getDeviceCode
());
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
//新增
entity
.
setCreateUserId
(
context
==
null
?
1L
:
context
.
getUser
()
==
null
?
1L
:
context
.
getUser
().
getId
());
entity
.
setCreateTime
(
new
Date
());
DeviceEntity
save
=
this
.
save
(
entity
,
context
);
if
(
save
!=
null
)
{
successNum
++;
}
}
else
{
//更新
entity
.
setId
(
deviceEntity
.
getId
());
entity
.
setUpdateUserId
(
getContextUserId
(
context
));
entity
.
setUpdateTime
(
new
Date
());
DeviceEntity
update
=
this
.
update
(
entity
,
context
);
if
(
update
!=
null
)
{
successNum
++;
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"导入异常"
,
e
);
failureNum
++;
}
}
successMsg
.
append
(
"导入成功!共 "
+
successNum
+
" 条"
);
if
(
failureNum
>
0
)
{
successMsg
.
append
(
"\n"
);
failureMsg
.
append
(
"导入失败!共 "
+
failureNum
+
" 条数据格式不正确"
);
successMsg
.
append
(
failureMsg
);
}
return
successMsg
.
toString
();
}
@Override
@Override
public
ApiResp
<
String
>
sendDeviceMessage
(
DeviceEntity
deviceEntity
,
TopicPartitionInfo
info
,
TbQueueMsgHeaders
header
,
String
message
,
Context
context
)
{
public
ApiResp
<
String
>
sendDeviceMessage
(
DeviceEntity
deviceEntity
,
TopicPartitionInfo
info
,
TbQueueMsgHeaders
header
,
String
message
,
Context
context
)
{
ApiResp
<
String
>
resp
=
new
ApiResp
<>();
ApiResp
<
String
>
resp
=
new
ApiResp
<>();
...
@@ -315,7 +361,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -315,7 +361,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity
.
setProductCode
(
productEntity
.
getProductCode
());
entity
.
setProductCode
(
productEntity
.
getProductCode
());
entity
.
setProductName
(
productEntity
.
getProductName
());
entity
.
setProductName
(
productEntity
.
getProductName
());
//根据产品查询平台
//根据产品查询平台
if
(!
ObjectUtils
.
isEmpty
(
productEntity
.
getPlatformId
()))
{
if
(!
ObjectUtils
.
isEmpty
(
productEntity
.
getPlatformId
()))
{
PlatformEntity
platformEntity
=
platformService
.
get
(
productEntity
.
getPlatformId
());
PlatformEntity
platformEntity
=
platformService
.
get
(
productEntity
.
getPlatformId
());
entity
.
setPlatformId
(
platformEntity
.
getId
());
entity
.
setPlatformId
(
platformEntity
.
getId
());
entity
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
entity
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
...
@@ -330,7 +376,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -330,7 +376,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity
.
setProductId
(
productEntity
.
getId
());
entity
.
setProductId
(
productEntity
.
getId
());
entity
.
setProductName
(
productEntity
.
getProductName
());
entity
.
setProductName
(
productEntity
.
getProductName
());
//根据产品查询平台
//根据产品查询平台
if
(!
ObjectUtils
.
isEmpty
(
productEntity
.
getPlatformId
()))
{
if
(!
ObjectUtils
.
isEmpty
(
productEntity
.
getPlatformId
()))
{
PlatformEntity
platformEntity
=
platformService
.
get
(
productEntity
.
getPlatformId
());
PlatformEntity
platformEntity
=
platformService
.
get
(
productEntity
.
getPlatformId
());
entity
.
setPlatformId
(
platformEntity
.
getId
());
entity
.
setPlatformId
(
platformEntity
.
getId
());
entity
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
entity
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
...
@@ -351,6 +397,4 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -351,6 +397,4 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
}
}
}
}
\ 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