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
80a659bd
Commit
80a659bd
authored
Aug 28, 2019
by
Vu Duy Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
anhvd commit
parent
662b775b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
48 additions
and
18 deletions
+48
-18
.DS_Store
.DS_Store
+0
-0
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
...om/viettel/campaign/service/impl/ScenarioServiceImpl.java
+39
-15
src/main/java/com/viettel/campaign/web/dto/ScenarioAnswerDTO.java
.../java/com/viettel/campaign/web/dto/ScenarioAnswerDTO.java
+2
-1
src/main/java/com/viettel/campaign/web/dto/ScenarioQuestionDTO.java
...ava/com/viettel/campaign/web/dto/ScenarioQuestionDTO.java
+1
-1
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
...ava/com/viettel/campaign/web/rest/ScenarioController.java
+3
-0
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
+1
-0
src/main/resources/i18n/language_vi.properties
src/main/resources/i18n/language_vi.properties
+1
-0
No files found.
.DS_Store
View file @
80a659bd
No preview for this file type
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
View file @
80a659bd
...
...
@@ -243,7 +243,7 @@ public class ScenarioServiceImpl implements ScenarioService {
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
StringBuilder
sb
=
new
StringBuilder
();
boolean
isValid
=
fals
e
;
boolean
isValid
=
tru
e
;
try
{
List
<
String
>
fileHeaderList
=
new
ArrayList
<>();
fileHeaderList
.
add
(
BundleUtils
.
getLangString
(
"scenario.template.questionCode"
,
locale
));
...
...
@@ -322,9 +322,19 @@ public class ScenarioServiceImpl implements ScenarioService {
//<editor-fold desc="Validate dữ liệu" defaultstate="collapsed">
String
selectedType
=
""
;
List
<
String
>
lstImportQuestionCodes
=
new
ArrayList
<>();
String
tmpCurrentQuestionCode
=
null
;
rawDataList
.
forEach
(
item
->
{
if
(
item
[
0
]
!=
null
&&
!
item
[
0
].
toString
().
trim
().
equals
(
""
))
lstImportQuestionCodes
.
add
(
item
[
0
].
toString
().
trim
());
});
for
(
int
i
=
0
;
i
<
rawDataList
.
size
();
i
++)
{
if
(
rawDataList
.
get
(
i
)[
0
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
if
(
rawDataList
.
get
(
i
)[
0
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
{
selectedType
=
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
();
tmpCurrentQuestionCode
=
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
();
}
//validate question
if
((
rawDataList
.
get
(
i
)[
0
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
||
(
rawDataList
.
get
(
i
)[
1
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
""
))
||
...
...
@@ -358,6 +368,12 @@ public class ScenarioServiceImpl implements ScenarioService {
if
(
rawDataList
.
get
(
i
)[
4
]
==
null
&&
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.hashInput.required"
));
}
if
((
rawDataList
.
get
(
i
)[
7
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
""
)))
{
if
((
rawDataList
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
tmpCurrentQuestionCode
))
||
validateMappingQuestion
(
rawDataList
.
get
(
i
)[
7
].
toString
().
trim
(),
tmpCurrentQuestionCode
,
lstImportQuestionCodes
))
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.mappingQuestion.invalid"
));
}
}
Row
dataRow
=
sheet
.
getRow
(
3
+
i
);
Cell
resultCell
=
dataRow
.
createCell
(
row
.
getPhysicalNumberOfCells
()
-
1
);
...
...
@@ -365,12 +381,11 @@ public class ScenarioServiceImpl implements ScenarioService {
resultCell
.
setCellValue
(
sb
.
toString
());
isValid
=
false
;
}
else
{
isValid
=
true
;
//
isValid = true;
resultCell
.
setCellValue
(
"Ok"
);
}
sb
=
new
StringBuilder
();
}
selectedType
=
""
;
//</editor-fold>
//insert data
...
...
@@ -378,13 +393,14 @@ public class ScenarioServiceImpl implements ScenarioService {
logger
.
info
(
"----- Data valid, start import scenario question -----"
);
List
<
ScenarioQuestionDTO
>
lstQuestion
=
buildQuestionsLst
(
rawDataList
,
scenarioId
,
campaignId
,
companySiteId
);
lstQuestion
.
forEach
(
question
->
{
questionService
.
add
(
question
);
//
questionService.add(question);
});
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.importSuccess"
,
locale
));
}
else
{
logger
.
info
(
"----- Data invalid, can't import scenario question -----"
);
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
...
...
@@ -398,9 +414,17 @@ public class ScenarioServiceImpl implements ScenarioService {
return
result
;
}
private
boolean
validateQuestionIndex
(
Object
index
)
{
if
(
index
!=
null
&&
DataUtil
.
isLong
(
index
.
toString
()))
return
true
;
return
false
;
private
boolean
validateMappingQuestion
(
String
mappingQuestion
,
String
currentQuestionCode
,
List
<
String
>
lstQuestionCode
)
{
if
(
mappingQuestion
==
currentQuestionCode
)
return
false
;
String
duplicateCode
=
lstQuestionCode
.
stream
().
filter
(
p
->
(
p
.
equals
(
mappingQuestion
)
&&
p
.
equals
(
currentQuestionCode
))).
findAny
().
orElse
(
null
);
if
(
duplicateCode
==
null
)
return
false
;
// String notMappedCode = lstQuestionCode.stream().filter(p -> (!p.equals(mappingQuestion))).findAny().orElse(null);
// if(notMappedCode != null) return false;
return
true
;
}
...
...
@@ -411,15 +435,15 @@ public class ScenarioServiceImpl implements ScenarioService {
List
<
ScenarioQuestionDTO
>
lstQuestions
=
new
ArrayList
<>();
List
<
ScenarioAnswerDTO
>
lstAnswerOfQuestion
=
new
ArrayList
<>();
ScenarioQuestionDTO
questionDTO
=
null
;
Integer
questionIndex
=
null
;
String
questionCode
=
null
;
for
(
int
i
=
0
;
i
<
rawDatas
.
size
();
i
++)
{
if
(
rawDatas
.
get
(
i
)[
0
]
!=
null
&&
!
rawDatas
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
{
question
Index
=
Double
.
valueOf
(
rawDatas
.
get
(
i
)[
0
].
toString
().
trim
()).
intValue
();
question
Code
=
rawDatas
.
get
(
i
)[
0
].
toString
().
trim
();
questionDTO
=
new
ScenarioQuestionDTO
();
questionDTO
.
setScenarioId
(
scenarioId
);
questionDTO
.
setCampaignId
(
campaignId
);
questionDTO
.
setCompanySiteId
(
companySiteId
);
questionDTO
.
setImport
Index
(
questionIndex
);
questionDTO
.
setImport
Code
(
questionCode
);
if
(
rawDatas
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.text"
)))
questionDTO
.
setType
((
short
)
0
);
...
...
@@ -445,9 +469,9 @@ public class ScenarioServiceImpl implements ScenarioService {
answerDto
.
setHasInput
((
short
)
1
);
else
answerDto
.
setHasInput
((
short
)
0
);
if
(
rawDatas
.
get
(
i
)[
7
]
!=
null
&&
!
rawDatas
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
""
))
{
answerDto
.
setMappingQuestion
Id
(
Double
.
valueOf
(
rawDatas
.
get
(
i
)[
7
].
toString
().
trim
()).
longValue
());
answerDto
.
setMappingQuestion
Code
(
rawDatas
.
get
(
i
)[
7
].
toString
().
trim
());
}
answerDto
.
setImportQuestion
Index
(
questionIndex
);
answerDto
.
setImportQuestion
Code
(
questionCode
);
answerDto
.
setCompanySiteId
(
companySiteId
);
lstAnswerOfQuestion
.
add
(
answerDto
);
...
...
@@ -456,7 +480,7 @@ public class ScenarioServiceImpl implements ScenarioService {
questionOrderIndex
=
questionRepository
.
getMaxOrderId
(
scenarioId
,
campaignId
,
companySiteId
);
if
(
questionOrderIndex
==
null
)
questionOrderIndex
=
0L
;
if
(
questionOrderIndex
==
null
)
questionOrderIndex
=
0L
;
lstQuestions
.
forEach
(
q
->
{
questionOrderIndex
+=
1
;
q
.
setOrderIndex
(
questionOrderIndex
);
...
...
@@ -466,7 +490,7 @@ public class ScenarioServiceImpl implements ScenarioService {
lstAnswerOfQuestion
.
forEach
(
a
->
{
answerIndex
+=
1
;
a
.
setOrderIndex
(
answerIndex
);
if
(
a
.
getImportQuestionIndex
()
==
q
.
getImportIndex
(
))
answers
.
add
(
a
);
if
(
a
.
getImportQuestionCode
().
equals
(
q
.
getImportCode
()
))
answers
.
add
(
a
);
});
q
.
setLstAnswers
(
answers
);
});
...
...
src/main/java/com/viettel/campaign/web/dto/ScenarioAnswerDTO.java
View file @
80a659bd
...
...
@@ -25,5 +25,6 @@ public class ScenarioAnswerDTO implements Serializable {
public
Date
deleteTime
;
public
Long
mappingQuestionId
;
public
Long
campaignId
;
public
Integer
importQuestionIndex
;
public
String
importQuestionCode
;
public
String
mappingQuestionCode
;
}
src/main/java/com/viettel/campaign/web/dto/ScenarioQuestionDTO.java
View file @
80a659bd
...
...
@@ -29,5 +29,5 @@ public class ScenarioQuestionDTO implements Serializable {
private
Short
isDefault
;
private
Short
answerIndex
;
private
List
<
ScenarioAnswerDTO
>
lstAnswers
;
private
Integer
importIndex
;
private
String
importCode
;
}
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
View file @
80a659bd
...
...
@@ -132,6 +132,9 @@ public class ScenarioController {
// .body(Files.readAllBytes(fileExport.toPath()));
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
ResultDTO
resultDTO
=
new
ResultDTO
();
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
}
...
...
src/main/resources/application.yml
View file @
80a659bd
server
:
port
:
1111
port
:
9999
spring
:
application
:
name
:
campaign
...
...
src/main/resources/i18n/language_en.properties
View file @
80a659bd
...
...
@@ -134,4 +134,5 @@ scenario.answer.required="Answer is required for SingleChoice or MultiChoice que
scenario.hashInput.required
=
"Has input is required"
scenario.required.required
=
"Require is required"
scenario.default.required
=
"Default is required"
scenario.mappingQuestion.invalid
=
"Mapping question invalid"
src/main/resources/i18n/language_vi.properties
View file @
80a659bd
...
...
@@ -136,6 +136,7 @@ scenario.answer.required="Câu trả lời cho câu hỏi SingleChoice, MultiCho
scenario.hashInput.required
=
"Trường Nhập text bắt buộc nhập"
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.mappingQuestion.invalid
=
"Câu hỏi liên kết không hợp lệ"
...
...
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