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 d3087f12
authored
Sep 24, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改导入错误信息提示
1 parent
1216a8cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
11 deletions
src/main/java/cn/com/glsx/admin/modules/model/imports/VehicleInfoImportListener.java
src/test/java/cn/com/glsx/admin/modules/service/VehicleServiceTest.java
src/main/java/cn/com/glsx/admin/modules/model/imports/VehicleInfoImportListener.java
View file @
d3087f1
...
@@ -216,22 +216,30 @@ public class VehicleInfoImportListener extends AnalysisEventListener<VehicleInfo
...
@@ -216,22 +216,30 @@ public class VehicleInfoImportListener extends AnalysisEventListener<VehicleInfo
// 校验组织机构
// 校验组织机构
if
(
StringUtils
.
isNullOrEmpty
(
vi
.
getOrganizationName
()))
{
if
(
StringUtils
.
isNullOrEmpty
(
vi
.
getOrganizationName
()))
{
failMsg
.
add
(
new
VehicleInfoFailExport
(
"组织机构"
,
"必填项"
));
failMsg
.
add
(
new
VehicleInfoFailExport
(
"组织机构"
,
"必填项"
));
}
}
else
{
// 校验组织机构 是否存在
// 校验组织机构 是否存在
Long
userId
=
userApiService
.
getUserIdByUsername
(
vi
.
getOrganizationName
());
Long
userId
=
userApiService
.
getUserIdByUsername
(
vi
.
getOrganizationName
());
if
(
userId
==
null
)
{
if
(
userId
==
null
)
{
failMsg
.
add
(
new
VehicleInfoFailExport
(
vi
.
getOrganizationName
(),
"该组织机构不存在,请选择用户级别的组织名称"
));
failMsg
.
add
(
new
VehicleInfoFailExport
(
vi
.
getOrganizationName
(),
"该组织机构不存在,请选择用户级别的组织名称"
));
}
}
}
// 校验车架号
// 校验车架号
if
(
StringUtils
.
isNullOrEmpty
(
vi
.
getVin
()))
{
if
(
StringUtils
.
isNullOrEmpty
(
vi
.
getVin
()))
{
failMsg
.
add
(
new
VehicleInfoFailExport
(
"车架号"
,
"必填项"
));
failMsg
.
add
(
new
VehicleInfoFailExport
(
"车架号"
,
"必填项"
));
}
}
else
{
boolean
flag
=
true
;
// 校验车架号时候存在
String
pattern
=
"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{17}$"
;
if
(
vinList
.
contains
(
vi
.
getVin
()))
{
boolean
matches
=
vi
.
getVin
().
matches
(
pattern
);
failMsg
.
add
(
new
VehicleInfoFailExport
(
vi
.
getVin
(),
"车架号已经存在,请勿重复导入"
));
if
(!
matches
)
{
flag
=
false
;
failMsg
.
add
(
new
VehicleInfoFailExport
(
vi
.
getVin
(),
"车架号车架号必须是17位数字+字母组合"
));
}
// 校验车架号时候存在
if
(
flag
&&
vinList
.
contains
(
vi
.
getVin
()))
{
failMsg
.
add
(
new
VehicleInfoFailExport
(
vi
.
getVin
(),
"车架号已经存在,请勿重复导入"
));
}
}
}
// 校验设备号是否存在
// 校验设备号是否存在
...
...
src/test/java/cn/com/glsx/admin/modules/service/VehicleServiceTest.java
View file @
d3087f1
...
@@ -41,6 +41,8 @@ import org.springframework.boot.test.context.SpringBootTest;
...
@@ -41,6 +41,8 @@ import org.springframework.boot.test.context.SpringBootTest;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.util.*
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -2158,4 +2160,16 @@ public class VehicleServiceTest {
...
@@ -2158,4 +2160,16 @@ public class VehicleServiceTest {
deviceService
.
updateDevice
(
device
);
deviceService
.
updateDevice
(
device
);
}
}
@Test
public
void
test16
(){
String
pattern
=
"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{17}$"
;
String
line
=
"1231231234qwe54789"
;
boolean
matches
=
line
.
matches
(
pattern
);
if
(
matches
){
System
.
out
.
println
(
"matches = "
+
matches
);
}
}
}
}
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