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
34f4766e
Commit
34f4766e
authored
Aug 27, 2019
by
Vu Duy Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
anhvd commit
parent
d4565414
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
139 additions
and
272 deletions
+139
-272
log/campaign.log
log/campaign.log
+1
-229
src/main/java/com/viettel/campaign/filter/CorsFilter.java
src/main/java/com/viettel/campaign/filter/CorsFilter.java
+23
-21
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/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/ScenarioController.java
...ava/com/viettel/campaign/web/rest/ScenarioController.java
+14
-9
No files found.
log/campaign.log
View file @
34f4766e
This diff is collapsed.
Click to expand it.
src/main/java/com/viettel/campaign/filter/CorsFilter.java
View file @
34f4766e
package
com.viettel.campaign.filter
;
package
com.viettel.campaign.filter
;
import
com.viettel.campaign.utils.RedisUtil
;
import
com.viettel.econtact.filter.UserSession
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.*
;
import
javax.servlet.*
;
...
@@ -28,27 +30,27 @@ public class CorsFilter implements Filter {
...
@@ -28,27 +30,27 @@ public class CorsFilter implements Filter {
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
chain
.
doFilter
(
req
,
response
);
//
chain.doFilter(req, response);
//
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
if
(
"OPTIONS"
.
equalsIgnoreCase
(
request
.
getMethod
()))
{
//
chain.doFilter(req, resp);
chain
.
doFilter
(
req
,
resp
);
//
return;
return
;
//
}
}
//
if ("/".equals(request.getRequestURI())) {
if
(
"/"
.
equals
(
request
.
getRequestURI
()))
{
//
chain.doFilter(req, resp);
chain
.
doFilter
(
req
,
resp
);
//
return;
return
;
//
}
}
//
String xAuthToken = request.getHeader("X-Auth-Token");
String
xAuthToken
=
request
.
getHeader
(
"X-Auth-Token"
);
//
if (xAuthToken == null || "".equals(xAuthToken)) {
if
(
xAuthToken
==
null
||
""
.
equals
(
xAuthToken
))
{
//
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null.");
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
"The token is null."
);
//
return;
return
;
//
}
}
//
Object obj = RedisUtil.getInstance().get(xAuthToken);
Object
obj
=
RedisUtil
.
getInstance
().
get
(
xAuthToken
);
//
if (obj instanceof UserSession) {
if
(
obj
instanceof
UserSession
)
{
//
chain.doFilter(req, resp);
chain
.
doFilter
(
req
,
resp
);
//
} else {
}
else
{
//
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid.");
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
"The token is invalid."
);
//
}
}
}
}
@Override
@Override
...
...
src/main/java/com/viettel/campaign/service/ScenarioService.java
View file @
34f4766e
...
@@ -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/ScenarioServiceImpl.java
View file @
34f4766e
...
@@ -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 @
34f4766e
...
@@ -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 @
34f4766e
...
@@ -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 @
34f4766e
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/ScenarioController.java
View file @
34f4766e
...
@@ -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
);
...
...
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