Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
service-campaign
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
Nguyen Ha
service-campaign
Commits
fbeac132
Commit
fbeac132
authored
Sep 05, 2019
by
Đào Nhật Quang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quangdn - add download template and import template
parent
fe4bf96d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
23 deletions
+46
-23
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+40
-18
src/main/resources/i18n/language_en.properties
src/main/resources/i18n/language_en.properties
+3
-1
src/main/resources/i18n/language_vi.properties
src/main/resources/i18n/language_vi.properties
+3
-4
No files found.
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
fbeac132
...
@@ -51,11 +51,14 @@ import java.nio.file.Files;
...
@@ -51,11 +51,14 @@ import java.nio.file.Files;
import
java.text.DateFormat
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@Service
@Service
public
class
CustomerServiceImpl
implements
CustomerService
{
public
class
CustomerServiceImpl
implements
CustomerService
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CustomerServiceImpl
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CustomerServiceImpl
.
class
);
private
static
final
Pattern
EMAIL_REGEXP
=
Pattern
.
compile
(
"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\\\.[A-Z]{2,6}$"
,
Pattern
.
CASE_INSENSITIVE
);
@Autowired
@Autowired
@PersistenceContext
(
unitName
=
DataSourceQualify
.
JPA_UNIT_NAME_CCMS_FULL
)
@PersistenceContext
(
unitName
=
DataSourceQualify
.
JPA_UNIT_NAME_CCMS_FULL
)
...
@@ -1016,7 +1019,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1016,7 +1019,7 @@ public class CustomerServiceImpl implements CustomerService {
//</editor-fold>
//</editor-fold>
//<editor-fold desc="Đọc dữ liệu từng dòng 1" defaultstate="collapsed">
//<editor-fold desc="Đọc dữ liệu từng dòng 1" defaultstate="collapsed">
for
(
int
i
=
4
;
i
<
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
for
(
int
i
=
4
;
i
<
=
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
Row
dataRow
=
sheet
.
getRow
(
i
);
Row
dataRow
=
sheet
.
getRow
(
i
);
if
(
dataRow
!=
null
)
{
if
(
dataRow
!=
null
)
{
Object
[]
obj
=
new
Object
[
row
.
getPhysicalNumberOfCells
()
-
1
];
Object
[]
obj
=
new
Object
[
row
.
getPhysicalNumberOfCells
()
-
1
];
...
@@ -1057,23 +1060,28 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1057,23 +1060,28 @@ public class CustomerServiceImpl implements CustomerService {
&&
!
rawDataList
.
get
(
i
)[
3
].
toString
().
trim
().
equals
(
""
)
&&
!
rawDataList
.
get
(
i
)[
3
].
toString
().
trim
().
equals
(
""
)
&&
rawDataList
.
get
(
i
)[
4
]
!=
null
&&
rawDataList
.
get
(
i
)[
4
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
&&
!
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
String
str
=
validatePhone
(
rawDataList
.
get
(
i
)[
2
].
toString
().
trim
(),
locale
);
String
str
=
""
;
if
(
validateNumberOnly
(
rawDataList
.
get
(
i
)[
2
].
toString
().
trim
()))
{
str
=
validateExistPhone
(
rawDataList
.
get
(
i
)[
2
].
toString
().
trim
(),
locale
);
}
else
{
str
+=
BundleUtils
.
getLangString
(
"customer.onlyNumber"
,
locale
);
}
if
(
validateNumberOnly
(
rawDataList
.
get
(
i
)[
3
].
toString
().
trim
()))
{
str
+=
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.secondPhone"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
3
].
toString
(),
50
,
locale
));
str
+=
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.secondPhone"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
3
].
toString
(),
50
,
locale
));
}
else
{
str
+=
BundleUtils
.
getLangString
(
"customer.onlyNumber"
,
locale
);
}
if
(!
validateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
()))
{
if
(!
validateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
()))
{
str
+=
(
BundleUtils
.
getLangString
(
"customer.emailInvalid"
,
locale
));
str
+=
(
BundleUtils
.
getLangString
(
"customer.emailInvalid"
,
locale
));
}
else
{
}
else
{
if
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.email"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
4
].
toString
(),
100
,
locale
).
equals
(
""
))
{
str
+=
(
validateDuplicateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
(),
locale
));
str
+=
(
validateDuplicateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
(),
locale
));
}
else
str
+=
validateLength
(
BundleUtils
.
getLangString
(
"customer.email"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
4
].
toString
(),
50
,
locale
);
}
}
sb
.
append
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.email"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
4
].
toString
(),
50
,
locale
));
sb
.
append
(
str
);
sb
.
append
(
str
);
}
else
{
}
else
{
if
(
rawDataList
.
get
(
i
).
length
>
2
&&
rawDataList
.
get
(
i
)[
2
]
==
null
)
{
sb
.
append
(
BundleUtils
.
getLangString
(
"customer.invalidRecord"
,
locale
));
sb
.
append
(
BundleUtils
.
getLangString
(
"customer.mainPhoneRequired"
,
locale
));
}
else
if
(
rawDataList
.
get
(
i
).
length
>
3
&&
rawDataList
.
get
(
i
)[
3
]
==
null
)
{
sb
.
append
(
BundleUtils
.
getLangString
(
"customer.secondPhoneRequired"
,
locale
));
}
else
if
(
rawDataList
.
get
(
i
).
length
>
4
&&
rawDataList
.
get
(
i
)[
4
]
==
null
)
{
sb
.
append
(
BundleUtils
.
getLangString
(
"customer.emailRequired"
,
locale
));
}
}
}
if
(
rawDataList
.
get
(
i
).
length
>
5
&&
rawDataList
.
get
(
i
)[
5
]
!=
null
)
{
if
(
rawDataList
.
get
(
i
).
length
>
5
&&
rawDataList
.
get
(
i
)[
5
]
!=
null
)
{
sb
.
append
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.address"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
5
].
toString
(),
500
,
locale
));
sb
.
append
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.address"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
5
].
toString
(),
500
,
locale
));
...
@@ -1279,14 +1287,15 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1279,14 +1287,15 @@ public class CustomerServiceImpl implements CustomerService {
}
}
//<editor-fold desc="Validate Methods" defaultstate="collapsed">
//<editor-fold desc="Validate Methods" defaultstate="collapsed">
private
String
validatePhone
(
String
str
,
Locale
locale
)
{
private
String
validate
Exist
Phone
(
String
str
,
Locale
locale
)
{
String
result
=
""
;
String
result
=
""
;
String
[]
arr
=
str
.
split
(
";"
);
String
[]
arr
=
str
.
split
(
";"
);
List
<
CustomerContact
>
contactList
;
if
(
str
.
length
()
>
50
)
{
if
(
str
.
length
()
>
50
)
{
result
=
BundleUtils
.
getLangString
(
"customer.phoneMax50"
,
locale
);
result
=
BundleUtils
.
getLangString
(
"customer.phoneMax50"
,
locale
);
}
}
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
List
<
CustomerContact
>
contactList
=
customerContactRepository
.
findCustomerContactsByContactEquals
(
arr
[
i
]);
contactList
=
customerContactRepository
.
findCustomerContactsByContactEquals
(
arr
[
i
]);
if
(
contactList
.
size
()
!=
0
)
{
if
(
contactList
.
size
()
!=
0
)
{
return
result
.
concat
(
BundleUtils
.
getLangString
(
"customer.phoneExists"
,
locale
));
return
result
.
concat
(
BundleUtils
.
getLangString
(
"customer.phoneExists"
,
locale
));
}
}
...
@@ -1294,11 +1303,24 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1294,11 +1303,24 @@ public class CustomerServiceImpl implements CustomerService {
return
result
;
return
result
;
}
}
private
boolean
validateNumberOnly
(
String
str
)
{
String
regexp
=
"\\b\\d+\\b"
;
String
[]
arr
=
str
.
split
(
";"
);
int
count
=
0
;
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
if
(!
arr
[
i
].
matches
(
regexp
))
{
count
++;
}
}
return
count
==
0
;
}
private
String
validateDuplicateEmail
(
String
str
,
Locale
locale
)
{
private
String
validateDuplicateEmail
(
String
str
,
Locale
locale
)
{
String
result
=
""
;
String
result
=
""
;
String
[]
arr
=
str
.
split
(
";"
);
String
[]
arr
=
str
.
split
(
";"
);
List
<
CustomerContact
>
contactList
;
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
List
<
CustomerContact
>
contactList
=
customerContactRepository
.
findCustomerContactsByContactEquals
(
arr
[
i
]);
contactList
=
customerContactRepository
.
findCustomerContactsByContactEquals
(
arr
[
i
]);
if
(
contactList
.
size
()
!=
0
)
{
if
(
contactList
.
size
()
!=
0
)
{
return
result
.
concat
(
BundleUtils
.
getLangString
(
"customer.emailExists"
,
locale
));
return
result
.
concat
(
BundleUtils
.
getLangString
(
"customer.emailExists"
,
locale
));
}
}
...
@@ -1328,9 +1350,9 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1328,9 +1350,9 @@ public class CustomerServiceImpl implements CustomerService {
private
boolean
validateEmail
(
String
str
)
{
private
boolean
validateEmail
(
String
str
)
{
String
[]
arr
=
str
.
split
(
";"
);
String
[]
arr
=
str
.
split
(
";"
);
String
regexp
=
"^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$"
;
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
if
(!
arr
[
i
].
matches
(
regexp
))
{
Matcher
matcher
=
EMAIL_REGEXP
.
matcher
(
arr
[
i
]);
if
(!
matcher
.
find
())
{
return
false
;
return
false
;
}
}
}
}
...
@@ -2045,7 +2067,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -2045,7 +2067,7 @@ public class CustomerServiceImpl implements CustomerService {
query
.
setMaxResults
(
pageable
.
getPageSize
());
query
.
setMaxResults
(
pageable
.
getPageSize
());
}
}
List
<
CustomerDTO
>
data
=
query
.
list
();
List
<
CustomerDTO
>
data
=
query
.
list
();
Page
<
CustomerDTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
Page
<
CustomerDTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
resultDTO
.
setData
(
dataPage
);
resultDTO
.
setData
(
dataPage
);
resultDTO
.
setTotalRow
(
count
);
resultDTO
.
setTotalRow
(
count
);
...
...
src/main/resources/i18n/language_en.properties
View file @
fbeac132
...
@@ -89,7 +89,9 @@ customer.yes = Yes
...
@@ -89,7 +89,9 @@ customer.yes = Yes
customer.not
=
No
customer.not
=
No
customer.noData
=
Template empty
customer.noData
=
Template empty
customer.nameRequired
=
Full name required;
customer.nameRequired
=
Full name required;
customer.emailMax50
=
Email must less than 50 character;
customer.emailMax100
=
Email must less than 100 character;
customer.invalidRecord
=
Invalid Record, required one more contact information;
customer.onlyNumber
=
Phone contain number only;
customer.importSuccess
=
Import Successful
customer.importSuccess
=
Import Successful
customer.importFailed
=
Import Failed
customer.importFailed
=
Import Failed
customer.errorValidate
=
Error while validating
customer.errorValidate
=
Error while validating
...
...
src/main/resources/i18n/language_vi.properties
View file @
fbeac132
...
@@ -91,10 +91,9 @@ customer.yes = Có
...
@@ -91,10 +91,9 @@ customer.yes = Có
customer.not
=
Không
customer.not
=
Không
customer.noData
=
Template không có dữ liệu
customer.noData
=
Template không có dữ liệu
customer.nameRequired
=
Họ và tên không được để trống;
customer.nameRequired
=
Họ và tên không được để trống;
customer.emailMax50
=
Email không được quá 50 kí tự;
customer.emailMax100
=
Email không được quá 100 kí tự;
customer.mainPhoneRequired
=
Số điện thoại chính không được để trống
customer.invalidRecord
=
Bắt buộc nhập 1 trong 3 thông tin liên lạc(Số điện thoại chính, Số điện thoại phụ, Email);
customer.secondPhoneRequired
=
Số điện thoại phụ không được để trống
customer.onlyNumber
=
Số điện thoại chỉ được nhập số;
customer.emailRequired
=
Số điện thoại email không được để trống
customer.importSuccess
=
Import dữ liệu thành công
customer.importSuccess
=
Import dữ liệu thành công
customer.importFailed
=
Import dữ liệu thất bại
customer.importFailed
=
Import dữ liệu thất bại
customer.errorValidate
=
Validate dữ liệu lỗi
customer.errorValidate
=
Validate dữ liệu lỗi
...
...
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