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
9607ebf2
Commit
9607ebf2
authored
Aug 26, 2019
by
Đào Nhật Quang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quangdn
parent
59197718
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
41 deletions
+78
-41
src/main/java/com/viettel/campaign/filter/CorsFilter.java
src/main/java/com/viettel/campaign/filter/CorsFilter.java
+1
-4
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+57
-29
src/main/java/com/viettel/campaign/utils/Config.java
src/main/java/com/viettel/campaign/utils/Config.java
+1
-1
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
...ava/com/viettel/campaign/web/rest/CustomerController.java
+14
-6
src/main/resources/application.yml
src/main/resources/application.yml
+5
-1
No files found.
src/main/java/com/viettel/campaign/filter/CorsFilter.java
View file @
9607ebf2
package
com.viettel.campaign.filter
;
package
com.viettel.campaign.filter
;
import
com.viettel.campaign.utils.RedisUtil
;
import
com.viettel.econtact.filter.UserSession
;
import
org.apache.log4j.Logger
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.*
;
import
javax.servlet.*
;
...
@@ -31,7 +28,7 @@ public class CorsFilter implements Filter {
...
@@ -31,7 +28,7 @@ public class CorsFilter implements Filter {
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
chain
.
doFilter
(
req
,
resp
);
chain
.
doFilter
(
req
,
resp
onse
);
// if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
// if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
// chain.doFilter(req, resp);
// chain.doFilter(req, resp);
...
...
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
9607ebf2
...
@@ -421,6 +421,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -421,6 +421,7 @@ public class CustomerServiceImpl implements CustomerService {
}
}
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
getCustomerDetailById
(
Long
companySiteId
,
Long
customerListId
,
Long
customerId
)
{
public
ResultDTO
getCustomerDetailById
(
Long
companySiteId
,
Long
customerListId
,
Long
customerId
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
...
@@ -880,6 +881,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -880,6 +881,7 @@ public class CustomerServiceImpl implements CustomerService {
}
}
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
List
<
CustomizeFields
>
getDynamicHeader
(
Long
companySiteId
)
{
public
List
<
CustomizeFields
>
getDynamicHeader
(
Long
companySiteId
)
{
LOGGER
.
info
(
"------------------GET DYNAMIC HEADER-------------------"
);
LOGGER
.
info
(
"------------------GET DYNAMIC HEADER-------------------"
);
List
<
CustomizeFields
>
headerList
;
List
<
CustomizeFields
>
headerList
;
...
@@ -893,10 +895,12 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -893,10 +895,12 @@ public class CustomerServiceImpl implements CustomerService {
}
}
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
List
<
CustomizeFields
>
dynamicHeader
,
UserSession
userSession
,
Long
customerListId
)
{
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
List
<
CustomizeFields
>
dynamicHeader
,
UserSession
userSession
,
Long
customerListId
)
{
LOGGER
.
info
(
"------------READ AND VALIDATE--------------"
);
LOGGER
.
info
(
"------------READ AND VALIDATE--------------"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
DataFormatter
dataFormat
=
new
DataFormatter
();
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy"
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
boolean
validateOk
=
false
;
boolean
validateOk
=
false
;
...
@@ -972,14 +976,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -972,14 +976,7 @@ public class CustomerServiceImpl implements CustomerService {
for
(
int
j
=
0
;
j
<
row
.
getPhysicalNumberOfCells
();
j
++)
{
for
(
int
j
=
0
;
j
<
row
.
getPhysicalNumberOfCells
();
j
++)
{
Cell
dataCell
=
dataRow
.
getCell
(
j
);
Cell
dataCell
=
dataRow
.
getCell
(
j
);
if
(
dataCell
!=
null
)
{
if
(
dataCell
!=
null
)
{
switch
(
dataCell
.
getCellTypeEnum
())
{
obj
[
j
]
=
dataFormat
.
formatCellValue
(
dataCell
);
case
NUMERIC:
obj
[
j
]
=
dataCell
.
getNumericCellValue
();
break
;
default
:
obj
[
j
]
=
dataCell
.
getStringCellValue
();
break
;
}
}
else
{
}
else
{
Cell
headerCell
=
row
.
getCell
(
j
);
Cell
headerCell
=
row
.
getCell
(
j
);
if
(
headerCell
.
getStringCellValue
().
equals
(
BundleUtils
.
getLangString
(
"customer.cusType"
,
locale
)))
{
if
(
headerCell
.
getStringCellValue
().
equals
(
BundleUtils
.
getLangString
(
"customer.cusType"
,
locale
)))
{
...
@@ -1016,9 +1013,12 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1016,9 +1013,12 @@ public class CustomerServiceImpl implements CustomerService {
&&
!
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
=
validatePhone
(
rawDataList
.
get
(
i
)[
2
].
toString
().
trim
(),
locale
);
str
.
concat
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.secondPhone"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
3
].
toString
(),
50
,
locale
));
str
.
concat
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.secondPhone"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
3
].
toString
(),
50
,
locale
));
if
(
validateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
()))
{
if
(!
validateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
()))
{
str
.
concat
(
BundleUtils
.
getLangString
(
"customer.emailMax50"
,
locale
));
str
.
concat
(
BundleUtils
.
getLangString
(
"customer.emailInvalid"
,
locale
));
}
else
{
str
.
concat
(
validateDuplicateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
(),
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
{
sb
.
append
(
BundleUtils
.
getLangString
(
"customer.invalidCustomer"
,
locale
));
sb
.
append
(
BundleUtils
.
getLangString
(
"customer.invalidCustomer"
,
locale
));
...
@@ -1032,17 +1032,17 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1032,17 +1032,17 @@ public class CustomerServiceImpl implements CustomerService {
if
(
rawDataList
.
get
(
i
).
length
>
8
&&
rawDataList
.
get
(
i
)[
8
]
!=
null
)
{
if
(
rawDataList
.
get
(
i
).
length
>
8
&&
rawDataList
.
get
(
i
)[
8
]
!=
null
)
{
sb
.
append
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.description"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
8
].
toString
(),
2000
,
locale
));
sb
.
append
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.description"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
8
].
toString
(),
2000
,
locale
));
}
}
for
(
int
j
=
12
;
j
<
header
.
size
();
j
++)
{
//
for (int j = 12; j < header.size(); j++) {
if
(
rawDataList
.
get
(
i
).
length
>
j
&&
rawDataList
.
get
(
i
)[
j
]
!=
null
)
{
//
if (rawDataList.get(i).length > j && rawDataList.get(i)[j] != null) {
if
(
header
.
get
(
j
).
getType
().
equals
(
"text"
))
{
//
if (header.get(j).getType().equals("text")) {
sb
.
append
(
validateDynamicLength
(
header
.
get
(
j
).
getTitle
(),
rawDataList
.
get
(
i
)[
j
].
toString
(),
header
.
get
(
j
).
getMinLength
(),
header
.
get
(
j
).
getMaxLength
(),
locale
));
//
sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMinLength(), header.get(j).getMaxLength(), locale));
}
else
if
(
header
.
get
(
j
).
getType
().
equals
(
"date"
))
{
//
} else if (header.get(j).getType().equals("date")) {
sb
.
append
(
validateUsingRegexp
(
header
.
get
(
j
).
getTitle
(),
rawDataList
.
get
(
i
)[
j
].
toString
(),
header
.
get
(
j
).
getRegexpForValidation
(),
locale
));
//
sb.append(validateUsingRegexp(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getRegexpForValidation(), locale));
}
else
if
(
header
.
get
(
j
).
getType
().
equals
(
"number"
))
{
//
} else if (header.get(j).getType().equals("number")) {
sb
.
append
(
validateDynamicLength
(
header
.
get
(
j
).
getTitle
(),
rawDataList
.
get
(
i
)[
j
].
toString
(),
header
.
get
(
j
).
getMin
(),
header
.
get
(
j
).
getMax
(),
locale
));
//
sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMin(), header.get(j).getMax(), locale));
}
//
}
}
//
}
}
//
}
Row
dataRow
=
sheet
.
getRow
(
4
+
i
);
Row
dataRow
=
sheet
.
getRow
(
4
+
i
);
Cell
resultCell
=
dataRow
.
createCell
(
row
.
getPhysicalNumberOfCells
()
-
1
);
Cell
resultCell
=
dataRow
.
createCell
(
row
.
getPhysicalNumberOfCells
()
-
1
);
if
(
sb
.
length
()
>
0
)
{
if
(
sb
.
length
()
>
0
)
{
...
@@ -1061,7 +1061,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1061,7 +1061,7 @@ public class CustomerServiceImpl implements CustomerService {
for
(
int
i
=
0
;
i
<
rawDataList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
rawDataList
.
size
();
i
++)
{
Customer
c
=
new
Customer
();
Customer
c
=
new
Customer
();
c
.
setName
(
rawDataList
.
get
(
i
)[
1
].
toString
());
c
.
setName
(
rawDataList
.
get
(
i
)[
1
].
toString
());
c
.
setSiteId
(
userSession
.
get
Company
SiteId
());
c
.
setSiteId
(
userSession
.
getSiteId
());
c
.
setCode
(
null
);
c
.
setCode
(
null
);
c
.
setDescription
(
rawDataList
.
get
(
i
)[
8
].
toString
());
c
.
setDescription
(
rawDataList
.
get
(
i
)[
8
].
toString
());
c
.
setCompanyName
(
rawDataList
.
get
(
i
)[
7
].
toString
());
c
.
setCompanyName
(
rawDataList
.
get
(
i
)[
7
].
toString
());
...
@@ -1107,11 +1107,12 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1107,11 +1107,12 @@ public class CustomerServiceImpl implements CustomerService {
}
}
c
.
setIpccStatus
(
"active"
);
c
.
setIpccStatus
(
"active"
);
Customer
saved
=
customerRepository
.
save
(
c
);
Customer
saved
=
customerRepository
.
save
(
c
);
CustomerContact
cc
=
new
CustomerContact
();
cc
.
setCustomerId
(
saved
.
getCustomerId
());
if
(
rawDataList
.
get
(
i
).
length
>
2
&&
rawDataList
.
get
(
i
)[
2
]
!=
null
)
{
if
(
rawDataList
.
get
(
i
).
length
>
2
&&
rawDataList
.
get
(
i
)[
2
]
!=
null
)
{
String
[]
mainPhone
=
rawDataList
.
get
(
i
)[
2
].
toString
().
split
(
";"
);
String
[]
mainPhone
=
rawDataList
.
get
(
i
)[
2
].
toString
().
split
(
";"
);
for
(
int
j
=
0
;
j
<
mainPhone
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
mainPhone
.
length
;
j
++)
{
CustomerContact
cc
=
new
CustomerContact
();
cc
.
setCustomerId
(
saved
.
getCustomerId
());
cc
.
setSiteId
(
userSession
.
getSiteId
());
cc
.
setContactType
((
short
)
5
);
cc
.
setContactType
((
short
)
5
);
cc
.
setContact
(
mainPhone
[
j
]);
cc
.
setContact
(
mainPhone
[
j
]);
cc
.
setIsDirectLine
((
short
)
1
);
cc
.
setIsDirectLine
((
short
)
1
);
...
@@ -1126,6 +1127,9 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1126,6 +1127,9 @@ public class CustomerServiceImpl implements CustomerService {
if
(
rawDataList
.
get
(
i
).
length
>
3
&&
rawDataList
.
get
(
i
)[
3
]
!=
null
)
{
if
(
rawDataList
.
get
(
i
).
length
>
3
&&
rawDataList
.
get
(
i
)[
3
]
!=
null
)
{
String
[]
subPhone
=
rawDataList
.
get
(
i
)[
3
].
toString
().
split
(
";"
);
String
[]
subPhone
=
rawDataList
.
get
(
i
)[
3
].
toString
().
split
(
";"
);
for
(
int
j
=
0
;
j
<
subPhone
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
subPhone
.
length
;
j
++)
{
CustomerContact
cc
=
new
CustomerContact
();
cc
.
setCustomerId
(
saved
.
getCustomerId
());
cc
.
setSiteId
(
userSession
.
getSiteId
());
cc
.
setContactType
((
short
)
5
);
cc
.
setContactType
((
short
)
5
);
cc
.
setContact
(
subPhone
[
j
]);
cc
.
setContact
(
subPhone
[
j
]);
cc
.
setIsDirectLine
((
short
)
0
);
cc
.
setIsDirectLine
((
short
)
0
);
...
@@ -1138,8 +1142,11 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1138,8 +1142,11 @@ public class CustomerServiceImpl implements CustomerService {
}
}
}
}
if
(
rawDataList
.
get
(
i
).
length
>
4
&&
rawDataList
.
get
(
i
)[
4
]
!=
null
)
{
if
(
rawDataList
.
get
(
i
).
length
>
4
&&
rawDataList
.
get
(
i
)[
4
]
!=
null
)
{
String
[]
email
=
rawDataList
.
get
(
i
)[
3
].
toString
().
split
(
";"
);
String
[]
email
=
rawDataList
.
get
(
i
)[
4
].
toString
().
split
(
";"
);
for
(
int
j
=
0
;
j
<
email
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
email
.
length
;
j
++)
{
CustomerContact
cc
=
new
CustomerContact
();
cc
.
setCustomerId
(
saved
.
getCustomerId
());
cc
.
setSiteId
(
userSession
.
getSiteId
());
cc
.
setContactType
((
short
)
2
);
cc
.
setContactType
((
short
)
2
);
cc
.
setContact
(
email
[
j
]);
cc
.
setContact
(
email
[
j
]);
cc
.
setIsDirectLine
((
short
)
1
);
cc
.
setIsDirectLine
((
short
)
1
);
...
@@ -1156,7 +1163,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1156,7 +1163,7 @@ public class CustomerServiceImpl implements CustomerService {
for
(
int
j
=
0
;
j
<
dynamicHeader
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
dynamicHeader
.
size
();
j
++)
{
cfo
.
setCustomizeFieldId
(
dynamicHeader
.
get
(
j
).
getCustomizeFieldId
());
cfo
.
setCustomizeFieldId
(
dynamicHeader
.
get
(
j
).
getCustomizeFieldId
());
if
(
rawDataList
.
get
(
i
).
length
>
(
12
+
j
)
&&
rawDataList
.
get
(
i
)[
12
+
j
]
!=
null
)
{
if
(
rawDataList
.
get
(
i
).
length
>
(
12
+
j
)
&&
rawDataList
.
get
(
i
)[
12
+
j
]
!=
null
)
{
switch
(
dynamicHeader
.
get
(
i
).
getType
())
{
switch
(
dynamicHeader
.
get
(
j
).
getType
())
{
case
"combobox"
:
case
"combobox"
:
CustomizeFieldOptionValue
cfov
=
CustomizeFieldOptionValue
cfov
=
customizeFieldOptionValueRepository
.
findCustomizeFieldOptionValueByNameEqualsAndStatus
(
rawDataList
.
get
(
i
)[
12
+
j
].
toString
(),
1L
);
customizeFieldOptionValueRepository
.
findCustomizeFieldOptionValueByNameEqualsAndStatus
(
rawDataList
.
get
(
i
)[
12
+
j
].
toString
(),
1L
);
...
@@ -1221,7 +1228,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1221,7 +1228,7 @@ public class CustomerServiceImpl implements CustomerService {
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
<
str
.
length
()
;
i
++)
{
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
CustomerContact
cc
=
customerContactRepository
.
findCustomerContactByContactEquals
(
arr
[
i
]);
CustomerContact
cc
=
customerContactRepository
.
findCustomerContactByContactEquals
(
arr
[
i
]);
if
(
cc
!=
null
)
{
if
(
cc
!=
null
)
{
return
result
.
concat
(
BundleUtils
.
getLangString
(
"customer.phoneExists"
,
locale
));
return
result
.
concat
(
BundleUtils
.
getLangString
(
"customer.phoneExists"
,
locale
));
...
@@ -1230,6 +1237,18 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1230,6 +1237,18 @@ public class CustomerServiceImpl implements CustomerService {
return
result
;
return
result
;
}
}
private
String
validateDuplicateEmail
(
String
str
,
Locale
locale
)
{
String
result
=
""
;
String
[]
arr
=
str
.
split
(
";"
);
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
CustomerContact
cc
=
customerContactRepository
.
findCustomerContactByContactEquals
(
arr
[
i
]);
if
(
cc
!=
null
)
{
return
result
.
concat
(
BundleUtils
.
getLangString
(
"customer.emailExists"
,
locale
));
}
}
return
result
;
}
private
String
validateUsingRegexp
(
String
header
,
String
data
,
String
regexp
,
Locale
locale
)
{
private
String
validateUsingRegexp
(
String
header
,
String
data
,
String
regexp
,
Locale
locale
)
{
if
(
data
.
matches
(
regexp
))
{
if
(
data
.
matches
(
regexp
))
{
return
header
+
" "
+
BundleUtils
.
getLangString
(
"customer.notMatch"
,
locale
);
return
header
+
" "
+
BundleUtils
.
getLangString
(
"customer.notMatch"
,
locale
);
...
@@ -1251,8 +1270,14 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1251,8 +1270,14 @@ public class CustomerServiceImpl implements CustomerService {
}
}
private
boolean
validateEmail
(
String
str
)
{
private
boolean
validateEmail
(
String
str
)
{
String
[]
arr
=
str
.
split
(
";"
);
String
regexp
=
"^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$"
;
String
regexp
=
"^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$"
;
return
str
.
matches
(
regexp
);
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
if
(!
arr
[
i
].
matches
(
regexp
))
{
return
false
;
}
}
return
true
;
}
}
private
boolean
validateLetter
(
String
str
)
{
private
boolean
validateLetter
(
String
str
)
{
...
@@ -1262,6 +1287,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1262,6 +1287,7 @@ public class CustomerServiceImpl implements CustomerService {
//</editor-fold>
//</editor-fold>
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
byte
[]
buildTemplate
(
Long
companySiteId
)
{
public
byte
[]
buildTemplate
(
Long
companySiteId
)
{
LOGGER
.
info
(
"-----------BUILD TEMPLATE-----------"
);
LOGGER
.
info
(
"-----------BUILD TEMPLATE-----------"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
...
@@ -1414,6 +1440,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1414,6 +1440,7 @@ public class CustomerServiceImpl implements CustomerService {
}
}
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
List
<
CustomizeFieldObject
>
getCustomizeField
(
Long
customerId
)
{
public
List
<
CustomizeFieldObject
>
getCustomizeField
(
Long
customerId
)
{
List
<
CustomizeFieldObject
>
customizeFieldDTOList
;
List
<
CustomizeFieldObject
>
customizeFieldDTOList
;
try
{
try
{
...
@@ -1494,6 +1521,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1494,6 +1521,7 @@ public class CustomerServiceImpl implements CustomerService {
}
}
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
List
<
CustomerDTO
>
getIndividualCustomerInfo
(
CampaignCustomerDTO
campaignCustomerDTO
)
{
public
List
<
CustomerDTO
>
getIndividualCustomerInfo
(
CampaignCustomerDTO
campaignCustomerDTO
)
{
List
<
CustomerDTO
>
customerList
;
List
<
CustomerDTO
>
customerList
;
try
{
try
{
...
...
src/main/java/com/viettel/campaign/utils/Config.java
View file @
9607ebf2
package
com.viettel.campaign.utils
;
package
com.viettel.campaign.utils
;
import
com.viettel.security.PassTranformer
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
import
java.io.File
;
import
java.io.File
;
...
@@ -16,6 +15,7 @@ public class Config {
...
@@ -16,6 +15,7 @@ public class Config {
public
static
final
String
APP_CONF_FILE_PATH
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"etc"
+
File
.
separator
+
"app.conf"
;
public
static
final
String
APP_CONF_FILE_PATH
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"etc"
+
File
.
separator
+
"app.conf"
;
public
static
final
String
LOG_CONF_FILE_PATH
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"etc"
+
File
.
separator
+
"log.conf"
;
public
static
final
String
LOG_CONF_FILE_PATH
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"etc"
+
File
.
separator
+
"log.conf"
;
public
static
final
String
EXCEL_DIR
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"etc"
;
public
static
String
amcd_xmlrpc_url
;
public
static
String
amcd_xmlrpc_url
;
public
static
int
num_client_amcd_xmlprc
;
public
static
int
num_client_amcd_xmlprc
;
...
...
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
View file @
9607ebf2
...
@@ -5,6 +5,7 @@ import com.viettel.campaign.model.ccms_full.CustomizeFieldObject;
...
@@ -5,6 +5,7 @@ import com.viettel.campaign.model.ccms_full.CustomizeFieldObject;
import
com.viettel.campaign.model.ccms_full.CustomizeFields
;
import
com.viettel.campaign.model.ccms_full.CustomizeFields
;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.Config
;
import
com.viettel.campaign.utils.Constants
;
import
com.viettel.campaign.utils.Constants
;
import
com.viettel.campaign.utils.RedisUtil
;
import
com.viettel.campaign.utils.RedisUtil
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.*
;
...
@@ -187,12 +188,17 @@ public class CustomerController {
...
@@ -187,12 +188,17 @@ public class CustomerController {
@PostMapping
(
value
=
"/importFile"
)
@PostMapping
(
value
=
"/importFile"
)
public
ResponseEntity
<?>
importFile
(
@RequestParam
(
"file"
)
MultipartFile
file
,
public
ResponseEntity
<?>
importFile
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"customerListId"
)
Lo
ng
customerListId
,
@RequestParam
(
"customerListId"
)
Stri
ng
customerListId
,
@RequestHeader
(
"X-Auth-Token"
)
String
authToken
)
{
HttpServletRequest
request
)
{
LOGGER
.
info
(
"------------IMPORT FILE TEMPLATE--------------"
);
LOGGER
.
info
(
"------------IMPORT FILE TEMPLATE--------------"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
try
{
try
{
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
authToken
);
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
request
.
getHeader
(
"X-Auth-Token"
));
if
(
userSession
==
null
)
{
userSession
=
new
UserSession
();
userSession
.
setSiteId
(
662691L
);
userSession
.
setUserName
(
"its3"
);
}
if
(
file
.
isEmpty
())
{
if
(
file
.
isEmpty
())
{
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"customer.fileNotSelected"
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"customer.fileNotSelected"
),
HttpStatus
.
OK
);
}
}
...
@@ -201,7 +207,7 @@ public class CustomerController {
...
@@ -201,7 +207,7 @@ public class CustomerController {
}
}
String
path
=
saveUploadFile
(
file
);
String
path
=
saveUploadFile
(
file
);
List
<
CustomizeFields
>
dynamicHeaders
=
customerService
.
getDynamicHeader
(
userSession
.
getCompanySiteId
());
List
<
CustomizeFields
>
dynamicHeaders
=
customerService
.
getDynamicHeader
(
userSession
.
getCompanySiteId
());
Map
<
String
,
Object
>
map
=
customerService
.
readAndValidateCustomer
(
path
,
dynamicHeaders
,
userSession
,
customerListId
);
Map
<
String
,
Object
>
map
=
customerService
.
readAndValidateCustomer
(
path
,
dynamicHeaders
,
userSession
,
Long
.
parseLong
(
customerListId
)
);
File
fileExport
=
(
File
)
map
.
get
(
"file"
);
File
fileExport
=
(
File
)
map
.
get
(
"file"
);
String
message
=
(
String
)
map
.
get
(
"message"
);
String
message
=
(
String
)
map
.
get
(
"message"
);
return
ResponseEntity
.
ok
()
return
ResponseEntity
.
ok
()
...
@@ -239,11 +245,13 @@ public class CustomerController {
...
@@ -239,11 +245,13 @@ public class CustomerController {
String
currentTime
=
new
SimpleDateFormat
(
"yyyy_MM_dd_hh_mm_ss"
).
format
(
new
Date
());
String
currentTime
=
new
SimpleDateFormat
(
"yyyy_MM_dd_hh_mm_ss"
).
format
(
new
Date
());
String
fileName
=
FilenameUtils
.
getBaseName
(
file
.
getOriginalFilename
())
+
"_"
+
currentTime
+
"."
+
FilenameUtils
.
getExtension
(
file
.
getOriginalFilename
());
String
fileName
=
FilenameUtils
.
getBaseName
(
file
.
getOriginalFilename
())
+
"_"
+
currentTime
+
"."
+
FilenameUtils
.
getExtension
(
file
.
getOriginalFilename
());
byte
[]
content
=
file
.
getBytes
();
byte
[]
content
=
file
.
getBytes
();
File
uploadFolder
=
new
File
(
BundleUtils
.
getGlobalConfig
(
"import.uploadFolder"
));
// File uploadFolder = new File(BundleUtils.getGlobalConfig("import.uploadFolder"));
File
uploadFolder
=
new
File
(
Config
.
EXCEL_DIR
);
if
(!
uploadFolder
.
exists
())
{
if
(!
uploadFolder
.
exists
())
{
uploadFolder
.
mkdir
();
uploadFolder
.
mkdir
();
}
}
Path
path
=
Paths
.
get
(
BundleUtils
.
getGlobalConfig
(
"import.uploadFolder"
),
fileName
);
// Path path = Paths.get(BundleUtils.getGlobalConfig("import.uploadFolder"), fileName);
Path
path
=
Paths
.
get
(
Config
.
EXCEL_DIR
,
fileName
);
Files
.
write
(
path
,
content
);
Files
.
write
(
path
,
content
);
return
path
.
toString
();
return
path
.
toString
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/resources/application.yml
View file @
9607ebf2
...
@@ -11,6 +11,11 @@ spring:
...
@@ -11,6 +11,11 @@ spring:
ddl-auto
:
none
ddl-auto
:
none
naming
:
naming
:
physical-strategy
:
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
physical-strategy
:
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
servlet
:
multipart
:
enabled
:
true
max-file-size
:
3MB
max-request-size
:
3MB
# kafka:
# kafka:
# consumer:
# consumer:
# bootstrap-servers: 192.168.1.201:9092
# bootstrap-servers: 192.168.1.201:9092
...
@@ -40,4 +45,3 @@ datasource-property:
...
@@ -40,4 +45,3 @@ datasource-property:
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