Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6835560a
authored
Mar 15, 2022
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
假性离线需求开发--- 优化导入校验
1 parent
8c0cc7bf
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
7 deletions
src/main/java/cn/com/glsx/admin/modules/controller/FakeOfflineController.java
src/main/java/cn/com/glsx/admin/modules/model/imports/WhiteListSnImport.java
src/main/java/cn/com/glsx/admin/modules/model/imports/WhiteListSnImportListener.java
src/test/java/cn/com/glsx/test/MainTest.java
src/main/java/cn/com/glsx/admin/modules/controller/FakeOfflineController.java
View file @
6835560
...
@@ -87,7 +87,7 @@ public class FakeOfflineController {
...
@@ -87,7 +87,7 @@ public class FakeOfflineController {
WhiteListSnImportListener
listener
=
new
WhiteListSnImportListener
(
vehicleService
,
deviceService
,
fakeOfflineService
);
WhiteListSnImportListener
listener
=
new
WhiteListSnImportListener
(
vehicleService
,
deviceService
,
fakeOfflineService
);
EasyExcel
.
read
(
file
.
getInputStream
(),
WhiteListSnImport
.
class
,
listener
)
EasyExcel
.
read
(
file
.
getInputStream
(),
WhiteListSnImport
.
class
,
listener
)
.
head
(
WhiteListSnImport
.
class
)
.
head
(
WhiteListSnImport
.
class
)
.
ignoreEmptyRow
(
fals
e
)
.
ignoreEmptyRow
(
tru
e
)
.
sheet
().
doRead
();
.
sheet
().
doRead
();
BaseImportInfo
importInfo
=
listener
.
getBaseImportInfo
();
BaseImportInfo
importInfo
=
listener
.
getBaseImportInfo
();
return
R
.
ok
().
data
(
importInfo
);
return
R
.
ok
().
data
(
importInfo
);
...
...
src/main/java/cn/com/glsx/admin/modules/model/imports/WhiteListSnImport.java
View file @
6835560
...
@@ -2,15 +2,15 @@ package cn.com.glsx.admin.modules.model.imports;
...
@@ -2,15 +2,15 @@ package cn.com.glsx.admin.modules.model.imports;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
/**
* @author Yanglinlong
* @author Yanglinlong
* @date 2022/3/10 20:15
* @date 2022/3/10 20:15
*/
*/
@Data
@Data
@Accessors
(
chain
=
true
)
public
class
WhiteListSnImport
implements
Serializable
{
public
class
WhiteListSnImport
{
/**
/**
* 车架号
* 车架号
*/
*/
...
...
src/main/java/cn/com/glsx/admin/modules/model/imports/WhiteListSnImportListener.java
View file @
6835560
...
@@ -225,6 +225,7 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
...
@@ -225,6 +225,7 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
List
<
String
>
importSnList
=
Lists
.
newArrayList
();
List
<
String
>
importSnList
=
Lists
.
newArrayList
();
importList
.
forEach
(
vi
->
{
importList
.
forEach
(
vi
->
{
log
.
info
(
"vin==="
+
vi
.
getVin
()
+
",sn:"
+
vi
.
getSn
());
StringBuilder
stringBuilder
=
new
StringBuilder
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
// 校验车架号
// 校验车架号
...
@@ -236,10 +237,13 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
...
@@ -236,10 +237,13 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
// 校验车辆数据权限受限
// 校验车辆数据权限受限
checkVinPermission
(
stringBuilder
,
vi
.
getVin
(),
vehicleListByPermission
);
checkVinPermission
(
stringBuilder
,
vi
.
getVin
(),
vehicleListByPermission
);
if
(
StringUtils
.
isNotEmpty
(
vi
.
getVin
())
&&
StringUtils
.
isNotEmpty
(
vi
.
getSn
()))
{
// 校验车辆和设备的绑定关系
// 校验车辆和设备的绑定关系
checkVinAndDevice
(
stringBuilder
,
vi
.
getVin
(),
vi
.
getSn
(),
importSnList
,
vehicleAndDeviceMap
);
checkVinAndDevice
(
stringBuilder
,
vi
.
getVin
(),
vi
.
getSn
(),
importSnList
,
vehicleAndDeviceMap
);
importSnList
.
add
((
vi
.
getVin
()
==
null
?
""
:
vi
.
getVin
()).
concat
(
"-"
).
concat
(
vi
.
getSn
()));
importSnList
.
add
(
vi
.
getVin
().
concat
(
"-"
).
concat
(
vi
.
getSn
()));
}
if
(
StringUtils
.
isNotEmpty
(
stringBuilder
))
{
if
(
StringUtils
.
isNotEmpty
(
stringBuilder
))
{
WhiteListFailExport
failExport
=
new
WhiteListFailExport
();
WhiteListFailExport
failExport
=
new
WhiteListFailExport
();
...
@@ -253,7 +257,9 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
...
@@ -253,7 +257,9 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
});
});
log
.
info
(
"this time succ:"
+
whiteListSnImportList
.
size
()
+
"; fail:"
+
failList
.
size
());
log
.
info
(
"this time succ:"
+
whiteListSnImportList
.
size
()
+
"; fail:"
+
failList
.
size
());
//4.插入数据
//4.插入数据
if
(
CollectionUtil
.
isNotEmpty
(
whiteListSnImportList
))
{
fakeOfflineService
.
insertFakeOfflineList
(
whiteListSnImportList
);
fakeOfflineService
.
insertFakeOfflineList
(
whiteListSnImportList
);
}
succNum
.
getAndAdd
(
whiteListSnImportList
.
size
());
succNum
.
getAndAdd
(
whiteListSnImportList
.
size
());
}
}
...
@@ -281,8 +287,8 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
...
@@ -281,8 +287,8 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
*/
*/
private
void
checkVinAndDevice
(
StringBuilder
stringBuilder
,
String
vin
,
String
sn
,
List
<
String
>
importSnList
,
Map
<
String
,
String
>
vehicleAndDeviceMap
)
{
private
void
checkVinAndDevice
(
StringBuilder
stringBuilder
,
String
vin
,
String
sn
,
List
<
String
>
importSnList
,
Map
<
String
,
String
>
vehicleAndDeviceMap
)
{
// 校验设备号是否重复
// 校验设备号是否重复
if
(
importSnList
.
contains
(
(
vin
==
null
?
""
:
vin
)
.
concat
(
"-"
).
concat
(
sn
)))
{
if
(
importSnList
.
contains
(
vin
.
concat
(
"-"
).
concat
(
sn
)))
{
stringBuilder
.
append
(
(
vin
==
null
?
""
:
vin
)
.
concat
(
"-"
).
concat
(
sn
)).
append
(
"重复数据;"
);
stringBuilder
.
append
(
vin
.
concat
(
"-"
).
concat
(
sn
)).
append
(
"重复数据;"
);
}
}
String
sns
=
vehicleAndDeviceMap
.
get
(
vin
);
String
sns
=
vehicleAndDeviceMap
.
get
(
vin
);
...
...
src/test/java/cn/com/glsx/test/MainTest.java
0 → 100644
View file @
6835560
package
cn
.
com
.
glsx
.
test
;
/**
* @author Yanglinlong
* @date 2022/3/15 18:06
*/
public
class
MainTest
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"args = "
+
""
.
concat
(
"-"
).
concat
(
null
));
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment