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
910b93b7
Commit
910b93b7
authored
Aug 29, 2019
by
Vu Duy Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
anhvd commit scenario import services
parent
eccfdb95
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
15 deletions
+22
-15
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
...om/viettel/campaign/service/impl/ScenarioServiceImpl.java
+7
-8
src/main/java/com/viettel/campaign/utils/Constants.java
src/main/java/com/viettel/campaign/utils/Constants.java
+7
-0
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
...ava/com/viettel/campaign/web/rest/ScenarioController.java
+2
-6
src/main/resources/application.yml
src/main/resources/application.yml
+1
-1
src/main/resources/i18n/language_en.properties
src/main/resources/i18n/language_en.properties
+2
-0
src/main/resources/i18n/language_vi.properties
src/main/resources/i18n/language_vi.properties
+3
-0
No files found.
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
View file @
910b93b7
...
@@ -281,7 +281,7 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -281,7 +281,7 @@ public class ScenarioServiceImpl implements ScenarioService {
Cell
cell
=
row
.
getCell
(
i
);
Cell
cell
=
row
.
getCell
(
i
);
if
(!
cell
.
getStringCellValue
().
equals
(
fileHeaderList
.
get
(
i
).
split
(
"#"
)[
0
]))
{
if
(!
cell
.
getStringCellValue
().
equals
(
fileHeaderList
.
get
(
i
).
split
(
"#"
)[
0
]))
{
result
.
put
(
"file"
,
file
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"
message"
,
BundleUtils
.
getLangString
(
"common.invalidTemplate"
,
locale
)
);
result
.
put
(
"
code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
INVALID_FORMAT
);
return
result
;
return
result
;
}
}
}
}
...
@@ -289,7 +289,7 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -289,7 +289,7 @@ public class ScenarioServiceImpl implements ScenarioService {
//kt file du lieu rong
//kt file du lieu rong
if
(
sheet
.
getPhysicalNumberOfRows
()
==
2
)
{
if
(
sheet
.
getPhysicalNumberOfRows
()
==
2
)
{
result
.
put
(
"
message"
,
BundleUtils
.
getLangString
(
"customer.noData"
,
locale
)
);
result
.
put
(
"
code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
EMPTY
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"file"
,
file
);
return
result
;
return
result
;
}
else
{
}
else
{
...
@@ -385,7 +385,7 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -385,7 +385,7 @@ public class ScenarioServiceImpl implements ScenarioService {
isValid
=
false
;
isValid
=
false
;
}
else
{
}
else
{
// isValid = true;
// isValid = true;
resultCell
.
setCellValue
(
"Ok"
);
resultCell
.
setCellValue
(
BundleUtils
.
getLangString
(
"ok"
)
);
}
}
sb
=
new
StringBuilder
();
sb
=
new
StringBuilder
();
}
}
...
@@ -395,23 +395,22 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -395,23 +395,22 @@ public class ScenarioServiceImpl implements ScenarioService {
if
(
isValid
)
{
if
(
isValid
)
{
List
<
ScenarioQuestionDTO
>
lstQuestion
=
buildQuestionsLst
(
rawDataList
,
scenarioId
,
campaignId
,
companySiteId
);
List
<
ScenarioQuestionDTO
>
lstQuestion
=
buildQuestionsLst
(
rawDataList
,
scenarioId
,
campaignId
,
companySiteId
);
lstQuestion
.
forEach
(
question
->
{
lstQuestion
.
forEach
(
question
->
{
questionService
.
add
(
question
);
//
questionService.add(question);
});
});
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"
message"
,
BundleUtils
.
getLangString
(
"customer.importSuccess"
,
locale
)
);
result
.
put
(
"
code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
SUCCESS
);
}
else
{
}
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
);
result
.
put
(
"
message"
,
BundleUtils
.
getLangString
(
"customer.importFailed"
,
locale
)
);
result
.
put
(
"
code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
ERROR
);
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
logger
.
info
(
ex
.
getMessage
(),
ex
);
logger
.
info
(
ex
.
getMessage
(),
ex
);
result
.
put
(
"
message"
,
BundleUtils
.
getLangString
(
"customer.errorValidate"
,
locale
)
);
result
.
put
(
"
code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
ERROR
);
}
}
logger
.
info
(
"Import Questions result:"
,
result
);
return
result
;
return
result
;
}
}
...
...
src/main/java/com/viettel/campaign/utils/Constants.java
View file @
910b93b7
...
@@ -47,4 +47,11 @@ public class Constants {
...
@@ -47,4 +47,11 @@ public class Constants {
public
interface
MIME_TYPE
{
public
interface
MIME_TYPE
{
String
EXCEL_XLSX
=
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
;
String
EXCEL_XLSX
=
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
;
}
}
public
interface
FILE_UPLOAD_RESP_CODE
{
String
SUCCESS
=
"00"
;
String
ERROR
=
"01"
;
String
INVALID_FORMAT
=
"02"
;
String
EMPTY
=
"03"
;
}
}
}
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
View file @
910b93b7
...
@@ -120,14 +120,10 @@ public class ScenarioController {
...
@@ -120,14 +120,10 @@ public class ScenarioController {
String
path
=
saveUploadFile
(
file
);
String
path
=
saveUploadFile
(
file
);
Map
<
String
,
Object
>
map
=
scenarioService
.
readAndValidateCustomer
(
path
,
scenarioId
,
campaignId
,
userSession
.
getCompanySiteId
());
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
code
=
(
String
)
map
.
get
(
"code"
);
ResultDTO
resultDTO
=
new
ResultDTO
();
resultDTO
.
setErrorCode
(
"00"
);
resultDTO
.
setDescription
(
message
);
resultDTO
.
setData
(
fileExport
);
HttpHeaders
headers
=
new
HttpHeaders
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"Content-Type"
,
Constants
.
MIME_TYPE
.
EXCEL_XLSX
);
headers
.
add
(
"Content-Type"
,
Constants
.
MIME_TYPE
.
EXCEL_XLSX
);
headers
.
add
(
"Message"
,
messag
e
);
headers
.
add
(
"Message"
,
cod
e
);
return
ResponseEntity
.
ok
()
return
ResponseEntity
.
ok
()
.
headers
(
headers
)
.
headers
(
headers
)
.
body
(
Files
.
readAllBytes
(
fileExport
.
toPath
()));
.
body
(
Files
.
readAllBytes
(
fileExport
.
toPath
()));
...
...
src/main/resources/application.yml
View file @
910b93b7
server
:
server
:
port
:
1111
port
:
9999
spring
:
spring
:
application
:
application
:
name
:
campaign
name
:
campaign
...
...
src/main/resources/i18n/language_en.properties
View file @
910b93b7
...
@@ -134,3 +134,5 @@ scenario.required.required="Require is required"
...
@@ -134,3 +134,5 @@ scenario.required.required="Require is required"
scenario.default.required
=
"Default is required"
scenario.default.required
=
"Default is required"
scenario.mappingQuestion.invalid
=
"Mapping question invalid"
scenario.mappingQuestion.invalid
=
"Mapping question invalid"
ok
=
"Imported"
error
=
"Error"
src/main/resources/i18n/language_vi.properties
View file @
910b93b7
...
@@ -136,6 +136,9 @@ scenario.required.required="Trường Bắt buộc bắt buộc nhập"
...
@@ -136,6 +136,9 @@ scenario.required.required="Trường Bắt buộc bắt buộc nhập"
scenario.default.required
=
"Trường Mặc định bắt buộc nhập"
scenario.default.required
=
"Trường Mặc định bắt buộc nhập"
scenario.mappingQuestion.invalid
=
"Câu hỏi liên kết không hợp lệ"
scenario.mappingQuestion.invalid
=
"Câu hỏi liên kết không hợp lệ"
ok
=
"Thành công"
error
=
"Thất bạ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