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
281d22f3
Commit
281d22f3
authored
Aug 28, 2019
by
Phạm Duy Phi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.myitsol.com/hanv/service-campaign
parents
c2903393
2785f1b2
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
135 additions
and
57 deletions
+135
-57
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
...ign/repository/ccms_full/impl/CampaignRepositoryImpl.java
+1
-0
src/main/java/com/viettel/campaign/service/ScenarioService.java
...in/java/com/viettel/campaign/service/ScenarioService.java
+2
-1
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
...om/viettel/campaign/service/impl/CampaignServiceImpl.java
+1
-0
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+11
-0
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
...om/viettel/campaign/service/impl/ScenarioServiceImpl.java
+82
-12
src/main/java/com/viettel/campaign/web/dto/ScenarioAnswerDTO.java
.../java/com/viettel/campaign/web/dto/ScenarioAnswerDTO.java
+1
-0
src/main/java/com/viettel/campaign/web/dto/ScenarioQuestionDTO.java
...ava/com/viettel/campaign/web/dto/ScenarioQuestionDTO.java
+1
-0
src/main/java/com/viettel/campaign/web/dto/request_dto/RequestImportDTO.java
...iettel/campaign/web/dto/request_dto/RequestImportDTO.java
+15
-0
src/main/java/com/viettel/campaign/web/rest/CampaignController.java
...ava/com/viettel/campaign/web/rest/CampaignController.java
+0
-28
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
...ava/com/viettel/campaign/web/rest/ScenarioController.java
+14
-9
src/main/resources/i18n/language_vi.properties
src/main/resources/i18n/language_vi.properties
+7
-7
No files found.
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
View file @
281d22f3
...
@@ -638,6 +638,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -638,6 +638,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"),\n"
+
"),\n"
+
"data as (\n"
+
"data as (\n"
+
"select a.*, rownum row_ from data_temp a\n"
+
"select a.*, rownum row_ from data_temp a\n"
+
"where a.totalCusList > 0"
+
"),\n"
+
"),\n"
+
"count_data as (\n"
+
"count_data as (\n"
+
"select count(*) totalRow from data_temp\n"
+
"select count(*) totalRow from data_temp\n"
+
...
...
src/main/java/com/viettel/campaign/service/ScenarioService.java
View file @
281d22f3
...
@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.Scenario;
...
@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.Scenario;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.econtact.filter.UserSession
;
import
com.viettel.econtact.filter.UserSession
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -25,5 +26,5 @@ public interface ScenarioService {
...
@@ -25,5 +26,5 @@ public interface ScenarioService {
XSSFWorkbook
buildTemplate
();
XSSFWorkbook
buildTemplate
();
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
UserSession
userSession
);
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
);
}
}
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
View file @
281d22f3
...
@@ -555,6 +555,7 @@ public class CampaignServiceImpl implements CampaignService {
...
@@ -555,6 +555,7 @@ public class CampaignServiceImpl implements CampaignService {
List
<
CampaignCustomer
>
list
=
campaignCustomerRepository
.
findCustomerContacted
(
campaignId
,
companySiteId
,
Long
.
parseLong
(
cusListId
));
List
<
CampaignCustomer
>
list
=
campaignCustomerRepository
.
findCustomerContacted
(
campaignId
,
companySiteId
,
Long
.
parseLong
(
cusListId
));
for
(
CampaignCustomer
campaignCustomer:
list
)
{
for
(
CampaignCustomer
campaignCustomer:
list
)
{
campaignCustomer
.
setInCampaignStatus
((
short
)
0
);
campaignCustomer
.
setInCampaignStatus
((
short
)
0
);
campaignCustomerRepository
.
save
(
campaignCustomer
);
}
}
}
}
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
...
...
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
281d22f3
...
@@ -1587,6 +1587,13 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1587,6 +1587,13 @@ public class CustomerServiceImpl implements CustomerService {
sb
.
append
(
" from customer_contact cc"
);
sb
.
append
(
" from customer_contact cc"
);
sb
.
append
(
" where cc.contact_type = 2"
);
sb
.
append
(
" where cc.contact_type = 2"
);
sb
.
append
(
" and status = 1"
);
sb
.
append
(
" and status = 1"
);
sb
.
append
(
" ),"
+
"cusInCampaign as ("
+
"select * from campaign_customer "
+
"where campaign_id = :p_campaign_id "
+
"and company_site_id = :p_company_site_id "
+
"and customer_list_id is null "
+
"and in_campaign_status = 1"
);
sb
.
append
(
" ), datas as ("
);
sb
.
append
(
" ), datas as ("
);
sb
.
append
(
" select c.customer_id customerId,"
);
sb
.
append
(
" select c.customer_id customerId,"
);
sb
.
append
(
" c.name,"
);
sb
.
append
(
" c.name,"
);
...
@@ -1597,6 +1604,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1597,6 +1604,7 @@ public class CustomerServiceImpl implements CustomerService {
sb
.
append
(
" c.current_address currentAddress,"
);
sb
.
append
(
" c.current_address currentAddress,"
);
sb
.
append
(
" c.description"
);
sb
.
append
(
" c.description"
);
sb
.
append
(
" from customer c"
);
sb
.
append
(
" from customer c"
);
sb
.
append
(
" inner join cusInCampaign cc on c.customer_id = cc.customer_id"
);
sb
.
append
(
" left join cusPhone cP on c.customer_id = cP.cusId"
);
sb
.
append
(
" left join cusPhone cP on c.customer_id = cP.cusId"
);
sb
.
append
(
" left join cusEmail cE on c.customer_id = cE.cusId"
);
sb
.
append
(
" left join cusEmail cE on c.customer_id = cE.cusId"
);
sb
.
append
(
" )"
);
sb
.
append
(
" )"
);
...
@@ -1615,8 +1623,11 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -1615,8 +1623,11 @@ public class CustomerServiceImpl implements CustomerService {
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"p_page_number"
,
campaignCustomerDTO
.
getPage
());
param
.
put
(
"p_page_number"
,
campaignCustomerDTO
.
getPage
());
param
.
put
(
"p_page_size"
,
campaignCustomerDTO
.
getPageSize
());
param
.
put
(
"p_page_size"
,
campaignCustomerDTO
.
getPageSize
());
param
.
put
(
"p_campaign_id"
,
campaignCustomerDTO
.
getCampaignId
());
param
.
put
(
"p_company_site_id"
,
campaignCustomerDTO
.
getCompanySiteId
());
customerList
=
namedParameterJdbcTemplate
.
query
(
sb
.
toString
(),
param
,
new
BeanPropertyRowMapper
<>(
CustomerDTO
.
class
));
customerList
=
namedParameterJdbcTemplate
.
query
(
sb
.
toString
(),
param
,
new
BeanPropertyRowMapper
<>(
CustomerDTO
.
class
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
return
null
;
return
null
;
}
}
return
customerList
;
return
customerList
;
...
...
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
View file @
281d22f3
...
@@ -3,6 +3,7 @@ package com.viettel.campaign.service.impl;
...
@@ -3,6 +3,7 @@ package com.viettel.campaign.service.impl;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.model.ccms_full.*
;
import
com.viettel.campaign.model.ccms_full.*
;
import
com.viettel.campaign.repository.ccms_full.*
;
import
com.viettel.campaign.repository.ccms_full.*
;
import
com.viettel.campaign.service.ScenarioQuestionService
;
import
com.viettel.campaign.service.ScenarioService
;
import
com.viettel.campaign.service.ScenarioService
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.Constants
;
import
com.viettel.campaign.utils.Constants
;
...
@@ -52,6 +53,9 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -52,6 +53,9 @@ public class ScenarioServiceImpl implements ScenarioService {
@Autowired
@Autowired
ContactQuestResultRepository
questResultRepository
;
ContactQuestResultRepository
questResultRepository
;
@Autowired
ScenarioQuestionService
questionService
;
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
Scenario
findScenarioByCampaignIdAndCompanySiteId
(
Long
campaignId
,
Long
companySiteId
)
{
public
Scenario
findScenarioByCampaignIdAndCompanySiteId
(
Long
campaignId
,
Long
companySiteId
)
{
...
@@ -234,7 +238,7 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -234,7 +238,7 @@ public class ScenarioServiceImpl implements ScenarioService {
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
UserSession
userSession
)
{
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
)
{
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
...
@@ -294,7 +298,7 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -294,7 +298,7 @@ public class ScenarioServiceImpl implements ScenarioService {
List
<
Object
[]>
rawDataList
=
new
ArrayList
<>();
List
<
Object
[]>
rawDataList
=
new
ArrayList
<>();
//validate row
//validate row
for
(
int
i
=
3
;
i
<
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
for
(
int
i
=
3
;
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
()];
Object
[]
obj
=
new
Object
[
row
.
getPhysicalNumberOfCells
()];
...
@@ -311,6 +315,7 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -311,6 +315,7 @@ public class ScenarioServiceImpl implements ScenarioService {
}
}
}
}
}
}
rawDataList
.
add
(
obj
);
rawDataList
.
add
(
obj
);
}
}
}
}
...
@@ -350,7 +355,7 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -350,7 +355,7 @@ public class ScenarioServiceImpl implements ScenarioService {
if
((
rawDataList
.
get
(
i
)[
3
]
==
null
||
rawDataList
.
get
(
i
)[
3
].
toString
().
trim
().
equals
(
""
))
&&
(!
selectedType
.
equals
(
BundleUtils
.
getLangString
(
"scenario.template.text"
))))
{
if
((
rawDataList
.
get
(
i
)[
3
]
==
null
||
rawDataList
.
get
(
i
)[
3
].
toString
().
trim
().
equals
(
""
))
&&
(!
selectedType
.
equals
(
BundleUtils
.
getLangString
(
"scenario.template.text"
))))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.answer.required"
));
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.answer.required"
));
}
}
if
(
rawDataList
.
get
(
i
)[
4
]
==
null
&&
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
if
(
rawDataList
.
get
(
i
)[
4
]
==
null
&&
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.hashInput.required"
));
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.hashInput.required"
));
}
}
}
}
...
@@ -371,10 +376,15 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -371,10 +376,15 @@ public class ScenarioServiceImpl implements ScenarioService {
//insert data
//insert data
if
(
isValid
)
{
if
(
isValid
)
{
logger
.
info
(
"----- Data valid, start import scenario question -----"
);
logger
.
info
(
"----- Data valid, start import scenario question -----"
);
for
(
int
i
=
0
;
i
<
rawDataList
.
size
();
i
++)
{
List
<
ScenarioQuestionDTO
>
lstQuestion
=
buildQuestionsLst
(
rawDataList
,
scenarioId
,
campaignId
,
companySiteId
);
buildQuestionsLst
(
rawDataList
);
lstQuestion
.
forEach
(
question
->
{
}
questionService
.
add
(
question
);
}
else
{
});
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.importSuccess"
,
locale
));
}
else
{
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"file"
,
file
);
...
@@ -384,7 +394,7 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -384,7 +394,7 @@ public class ScenarioServiceImpl implements ScenarioService {
logger
.
info
(
ex
.
getMessage
(),
ex
);
logger
.
info
(
ex
.
getMessage
(),
ex
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.errorValidate"
,
locale
));
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.errorValidate"
,
locale
));
}
}
logger
.
info
(
"Import Questions result:"
,
result
);
logger
.
info
(
"Import Questions result:"
,
result
);
return
result
;
return
result
;
}
}
...
@@ -393,15 +403,75 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -393,15 +403,75 @@ public class ScenarioServiceImpl implements ScenarioService {
return
false
;
return
false
;
}
}
private
List
<
ScenarioQuestionDTO
>
buildQuestionsLst
(
List
<
Object
[]>
rawDatas
)
{
private
Long
questionOrderIndex
=
null
;
private
Integer
answerIndex
=
null
;
private
List
<
ScenarioQuestionDTO
>
buildQuestionsLst
(
List
<
Object
[]>
rawDatas
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
)
{
List
<
ScenarioQuestionDTO
>
lstQuestions
=
new
ArrayList
<>();
List
<
ScenarioQuestionDTO
>
lstQuestions
=
new
ArrayList
<>();
List
<
ScenarioAnswerDTO
>
lstAnswerOfQuestion
=
new
ArrayList
<>();
ScenarioQuestionDTO
questionDTO
=
null
;
ScenarioQuestionDTO
questionDTO
=
null
;
for
(
int
i
=
0
;
i
<
rawDatas
.
size
();
i
++)
{
Integer
questionIndex
=
null
;
if
(
rawDatas
.
get
(
i
)[
0
]
!=
null
&&
!
rawDatas
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
{
for
(
int
i
=
0
;
i
<
rawDatas
.
size
();
i
++)
{
if
(
rawDatas
.
get
(
i
)[
0
]
!=
null
&&
!
rawDatas
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
{
questionIndex
=
Double
.
valueOf
(
rawDatas
.
get
(
i
)[
0
].
toString
().
trim
()).
intValue
();
questionDTO
=
new
ScenarioQuestionDTO
();
questionDTO
=
new
ScenarioQuestionDTO
();
// questionDTO.setCampaignId();
questionDTO
.
setScenarioId
(
scenarioId
);
questionDTO
.
setCampaignId
(
campaignId
);
questionDTO
.
setCompanySiteId
(
companySiteId
);
questionDTO
.
setImportIndex
(
questionIndex
);
if
(
rawDatas
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.text"
)))
questionDTO
.
setType
((
short
)
0
);
else
if
(
rawDatas
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.singleChoice"
)))
questionDTO
.
setType
((
short
)
1
);
else
questionDTO
.
setType
((
short
)
2
);
questionDTO
.
setQuestion
(
rawDatas
.
get
(
i
)[
2
].
toString
().
trim
());
if
(
rawDatas
.
get
(
i
)[
5
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.yes"
)))
questionDTO
.
setIsRequire
((
short
)
1
);
else
questionDTO
.
setIsRequire
((
short
)
0
);
if
(
rawDatas
.
get
(
i
)[
6
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.yes"
)))
questionDTO
.
setIsDefault
((
short
)
1
);
else
questionDTO
.
setIsDefault
((
short
)
0
);
lstQuestions
.
add
(
questionDTO
);
}
else
{
ScenarioAnswerDTO
answerDto
=
new
ScenarioAnswerDTO
();
answerDto
.
setAnswer
(
rawDatas
.
get
(
i
)[
3
].
toString
().
trim
());
if
(
rawDatas
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.yes"
)))
answerDto
.
setHasInput
((
short
)
1
);
else
answerDto
.
setHasInput
((
short
)
0
);
if
(
rawDatas
.
get
(
i
)[
7
]
!=
null
&&
!
rawDatas
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
""
))
{
answerDto
.
setMappingQuestionId
(
Double
.
valueOf
(
rawDatas
.
get
(
i
)[
7
].
toString
().
trim
()).
longValue
());
}
answerDto
.
setImportQuestionIndex
(
questionIndex
);
answerDto
.
setCompanySiteId
(
companySiteId
);
lstAnswerOfQuestion
.
add
(
answerDto
);
}
}
}
}
questionOrderIndex
=
questionRepository
.
getMaxOrderId
(
scenarioId
,
campaignId
,
companySiteId
);
if
(
questionOrderIndex
==
null
)
questionOrderIndex
=
0L
;
lstQuestions
.
forEach
(
q
->
{
questionOrderIndex
+=
1
;
q
.
setOrderIndex
(
questionOrderIndex
);
q
.
setCode
(
campaignId
+
"_"
+
questionOrderIndex
);
answerIndex
=
0
;
List
<
ScenarioAnswerDTO
>
answers
=
new
ArrayList
<>();
lstAnswerOfQuestion
.
forEach
(
a
->
{
answerIndex
+=
1
;
a
.
setOrderIndex
(
answerIndex
);
if
(
a
.
getImportQuestionIndex
()
==
q
.
getImportIndex
())
answers
.
add
(
a
);
});
q
.
setLstAnswers
(
answers
);
});
questionOrderIndex
=
null
;
return
lstQuestions
;
return
lstQuestions
;
}
}
}
}
src/main/java/com/viettel/campaign/web/dto/ScenarioAnswerDTO.java
View file @
281d22f3
...
@@ -25,4 +25,5 @@ public class ScenarioAnswerDTO implements Serializable {
...
@@ -25,4 +25,5 @@ public class ScenarioAnswerDTO implements Serializable {
public
Date
deleteTime
;
public
Date
deleteTime
;
public
Long
mappingQuestionId
;
public
Long
mappingQuestionId
;
public
Long
campaignId
;
public
Long
campaignId
;
public
Integer
importQuestionIndex
;
}
}
src/main/java/com/viettel/campaign/web/dto/ScenarioQuestionDTO.java
View file @
281d22f3
...
@@ -29,4 +29,5 @@ public class ScenarioQuestionDTO implements Serializable {
...
@@ -29,4 +29,5 @@ public class ScenarioQuestionDTO implements Serializable {
private
Short
isDefault
;
private
Short
isDefault
;
private
Short
answerIndex
;
private
Short
answerIndex
;
private
List
<
ScenarioAnswerDTO
>
lstAnswers
;
private
List
<
ScenarioAnswerDTO
>
lstAnswers
;
private
Integer
importIndex
;
}
}
src/main/java/com/viettel/campaign/web/dto/request_dto/RequestImportDTO.java
0 → 100644
View file @
281d22f3
package
com.viettel.campaign.web.dto.request_dto
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.springframework.web.multipart.commons.CommonsMultipartFile
;
/**
* @author anhvd_itsol
*/
@Getter
@Setter
public
class
RequestImportDTO
{
CommonsMultipartFile
file
;
}
src/main/java/com/viettel/campaign/web/rest/CampaignController.java
View file @
281d22f3
...
@@ -227,32 +227,4 @@ public class CampaignController {
...
@@ -227,32 +227,4 @@ public class CampaignController {
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/import-file"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<?>
importFile
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestHeader
(
"X-Auth-Token"
)
String
authToken
)
{
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
try
{
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
authToken
);
if
(
file
.
isEmpty
())
{
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileNotSelected"
),
HttpStatus
.
OK
);
}
if
(!
Objects
.
equals
(
FilenameUtils
.
getExtension
(
file
.
getOriginalFilename
()),
Constants
.
FileType
.
xlsx
))
{
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileInvalidFormat"
,
locale
),
HttpStatus
.
OK
);
}
//String path = saveUploadFile(file);
// List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
// Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, customerListId);
// File fileExport = (File) map.get("file");
// String message = (String) map.get("message");
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=template_import_customer.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
return
new
ResponseEntity
<>(
null
,
HttpStatus
.
OK
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
}
}
}
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
View file @
281d22f3
...
@@ -8,6 +8,7 @@ import com.viettel.campaign.utils.RedisUtil;
...
@@ -8,6 +8,7 @@ import com.viettel.campaign.utils.RedisUtil;
import
com.viettel.campaign.web.dto.ContactQuestResultDTO
;
import
com.viettel.campaign.web.dto.ContactQuestResultDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.ScenarioDTO
;
import
com.viettel.campaign.web.dto.ScenarioDTO
;
import
com.viettel.campaign.web.dto.request_dto.RequestImportDTO
;
import
com.viettel.econtact.filter.UserSession
;
import
com.viettel.econtact.filter.UserSession
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
...
@@ -21,6 +22,7 @@ import org.springframework.http.ResponseEntity;
...
@@ -21,6 +22,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.*
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
...
@@ -104,12 +106,11 @@ public class ScenarioController {
...
@@ -104,12 +106,11 @@ public class ScenarioController {
}
}
@RequestMapping
(
value
=
"/import-file"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/import-file"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<?>
importFile
(
@RequestParam
MultipartFile
file
)
{
public
ResponseEntity
<?>
importFile
(
@RequestParam
MultipartFile
file
,
@RequestParam
Long
scenarioId
,
@RequestParam
Long
campaignId
,
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
=
new
UserSession
();
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
request
.
getHeader
(
"X-Auth-Token"
));
// UserSession userSession = (UserSession) RedisUtil.getInstance().get(authToken);
if
(
file
.
isEmpty
())
{
if
(
file
.
isEmpty
())
{
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileNotSelected"
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileNotSelected"
),
HttpStatus
.
OK
);
}
}
...
@@ -117,14 +118,18 @@ public class ScenarioController {
...
@@ -117,14 +118,18 @@ public class ScenarioController {
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileInvalidFormat"
,
locale
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
BundleUtils
.
getLangString
(
"common.fileInvalidFormat"
,
locale
),
HttpStatus
.
OK
);
}
}
String
path
=
saveUploadFile
(
file
);
String
path
=
saveUploadFile
(
file
);
Map
<
String
,
Object
>
map
=
scenarioService
.
readAndValidateCustomer
(
path
,
userSession
);
Map
<
String
,
Object
>
map
=
scenarioService
.
readAndValidateCustomer
(
path
,
scenarioId
,
campaignId
,
userSession
.
getCompanySiteId
()
);
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
()
ResultDTO
resultDTO
=
new
ResultDTO
();
.
header
(
"Content-Type"
,
Constants
.
MIME_TYPE
.
EXCEL_XLSX
)
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
.
header
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=import_scenario_result.xlsx"
)
resultDTO
.
setDescription
(
message
);
.
header
(
"Message"
,
message
)
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
.
body
(
Files
.
readAllBytes
(
fileExport
.
toPath
()));
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=import_scenario_result.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
());
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
...
...
src/main/resources/i18n/language_vi.properties
View file @
281d22f3
...
@@ -62,13 +62,13 @@ DATE_OF_BIRTH = Ngày sinh
...
@@ -62,13 +62,13 @@ DATE_OF_BIRTH = Ngày sinh
MOBILE_NUMBER
=
Số điện thoại
MOBILE_NUMBER
=
Số điện thoại
USERNAME
=
Tài khoản
USERNAME
=
Tài khoản
AREA_CODE
=
Khu vực
AREA_CODE
=
Khu vực
CALL_ALLOWED
=
C
ALL_ALLOWED
CALL_ALLOWED
=
C
ho phép gọi
EMAIL_ALLOWED
=
EMAIL_ALLOWED
EMAIL_ALLOWED
=
Cho phép gửi email
SMS_ALLOWED
=
SMS_ALLOWED
SMS_ALLOWED
=
Cho phép gửi sms
IPCC_STATUS
=
IPCC_STATUS
IPCC_STATUS
=
Trạng thái Ipcc
EMAIL
=
E
MAIL
EMAIL
=
E
mail
CUSTOMER_TYPE
=
CUSTOMER_TYPE
CUSTOMER_TYPE
=
Loại khách hàng
AVATAR_LINK
=
AVATAR_LINK
AVATAR_LINK
=
Đường dẫn ảnh đại diện
#Customer Excel Header
#Customer Excel Header
customer.no
=
STT
customer.no
=
STT
...
...
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