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
5a1269c3
Commit
5a1269c3
authored
Aug 26, 2019
by
Vu Duy Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
anhvd commit import scenario
parent
7819a484
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
120 additions
and
16 deletions
+120
-16
log/campaign.log
log/campaign.log
+6
-0
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
...om/viettel/campaign/service/impl/ScenarioServiceImpl.java
+95
-16
src/main/resources/i18n/language_en.properties
src/main/resources/i18n/language_en.properties
+10
-0
src/main/resources/i18n/language_vi.properties
src/main/resources/i18n/language_vi.properties
+9
-0
No files found.
log/campaign.log
View file @
5a1269c3
...
...
@@ -209,3 +209,9 @@ java.lang.NullPointerException
[main] 25/08/2019 15:42:34 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 25/08/2019 15:44:03 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 25/08/2019 17:15:28 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 25/08/2019 20:31:50 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 25/08/2019 20:38:26 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 25/08/2019 20:40:13 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 25/08/2019 20:43:31 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 25/08/2019 20:55:21 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 25/08/2019 22:31:03 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
View file @
5a1269c3
...
...
@@ -6,6 +6,7 @@ import com.viettel.campaign.repository.ccms_full.*;
import
com.viettel.campaign.service.ScenarioService
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.Constants
;
import
com.viettel.campaign.utils.DataUtil
;
import
com.viettel.campaign.utils.WorkBookBuilder
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.econtact.filter.UserSession
;
...
...
@@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -253,8 +255,9 @@ public class ScenarioServiceImpl implements ScenarioService {
FileInputStream
fis
=
new
FileInputStream
(
file
);
XSSFWorkbook
workbook
=
new
XSSFWorkbook
(
fis
);
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Row
row
=
sheet
.
getRow
(
3
);
Row
row
=
sheet
.
getRow
(
2
);
//<editor-fold desc="Tạo style cho cột kết quả" defaultstate="collapsed">
Font
resultFont
=
workbook
.
createFont
();
resultFont
.
setBold
(
true
);
resultFont
.
setFontHeightInPoints
((
short
)
11
);
...
...
@@ -264,14 +267,26 @@ public class ScenarioServiceImpl implements ScenarioService {
resultStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
resultStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
resultStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
//</editor-fold>
//<editor-fold desc="Kiểm tra header của template" defaultstate="collapsed">
for
(
int
i
=
0
;
i
<
fileHeaderList
.
size
();
i
++)
{
Cell
cell
=
row
.
getCell
(
i
);
if
(!
cell
.
getStringCellValue
().
equals
(
fileHeaderList
.
get
(
i
).
split
(
"#"
)[
0
]))
{
result
.
put
(
"file"
,
file
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"common.invalidTemplate"
,
locale
));
return
result
;
}
}
//</editor-fold>
//kt file du lieu rong
if
(
sheet
.
getPhysicalNumberOfRows
()
==
3
)
{
if
(
sheet
.
getPhysicalNumberOfRows
()
==
2
)
{
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.noData"
,
locale
));
result
.
put
(
"file"
,
file
);
return
result
;
}
else
{
Cell
resultCell
=
sheet
.
getRow
(
3
).
createCell
(
sheet
.
getRow
(
3
).
getPhysicalNumberOfCells
());
Cell
resultCell
=
sheet
.
getRow
(
2
).
createCell
(
sheet
.
getRow
(
2
).
getPhysicalNumberOfCells
());
resultCell
.
setCellValue
(
BundleUtils
.
getLangString
(
"customer.result"
,
locale
));
resultCell
.
setCellStyle
(
resultStyle
);
}
...
...
@@ -279,27 +294,28 @@ public class ScenarioServiceImpl implements ScenarioService {
List
<
Object
[]>
rawDataList
=
new
ArrayList
<>();
//validate row
for
(
int
i
=
4
;
i
<
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
for
(
int
i
=
3
;
i
<
sheet
.
getPhysicalNumberOfRows
();
i
++)
{
Row
dataRow
=
sheet
.
getRow
(
i
);
if
(
dataRow
!=
null
)
{
Object
[]
obj
=
new
Object
[
row
.
getPhysicalNumberOfCells
()];
for
(
int
j
=
0
;
j
<
row
.
getPhysicalNumberOfCells
();
j
++)
{
Cell
dataCell
=
dataRow
.
getCell
(
j
);
if
(
dataCell
!=
null
)
{
//
switch (dataCell.getCellTypeEnum()) {
//
case NUMERIC:
//
obj[j] = dataCell.getNumericCellValue();
//
break;
//
default:
//
obj[j] = dataCell.getStringCellValue();
//
break;
//
}
switch
(
dataCell
.
getCellTypeEnum
())
{
case
NUMERIC:
obj
[
j
]
=
dataCell
.
getNumericCellValue
();
break
;
default
:
obj
[
j
]
=
dataCell
.
getStringCellValue
();
break
;
}
}
else
{
//
Cell headerCell = row.getCell(j);
// if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("
customer.cus
Type", locale))) {
Cell
headerCell
=
row
.
getCell
(
j
);
// if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("
scenario.template.question
Type", locale))) {
// obj[j] = BundleUtils.getLangString("customer.cusType.normal", locale);
// } else if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.callAllowed", locale)) || headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.emailAllowed", locale))
// || headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.smsAllowed", locale))) {
// } else if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.callAllowed", locale)) ||
// headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.emailAllowed", locale)) ||
// headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.smsAllowed", locale))) {
// obj[j] = BundleUtils.getLangString("customer.yes", locale);
// break;
// } else {
...
...
@@ -311,11 +327,69 @@ public class ScenarioServiceImpl implements ScenarioService {
}
}
//<editor-fold desc="Validate dữ liệu" defaultstate="collapsed">
String
selectedType
=
""
;
for
(
int
i
=
0
;
i
<
rawDataList
.
size
();
i
++)
{
if
(
rawDataList
.
get
(
i
)[
0
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
0
].
toString
().
trim
().
equals
(
""
))
selectedType
=
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
(
""
))
||
(
rawDataList
.
get
(
i
)[
2
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
2
].
toString
().
trim
().
equals
(
""
))
||
(
rawDataList
.
get
(
i
)[
5
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
5
].
toString
().
trim
().
equals
(
""
))
||
(
rawDataList
.
get
(
i
)[
6
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
6
].
toString
().
trim
().
equals
(
""
)))
{
if
(
rawDataList
.
get
(
i
)[
0
]
==
null
||
!
DataUtil
.
isLong
(
rawDataList
.
get
(
i
)[
0
].
toString
()))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.questionCode.required"
));
}
if
(
rawDataList
.
get
(
i
)[
1
]
==
null
||
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.questionType.required"
));
}
if
(
rawDataList
.
get
(
i
)[
2
]
==
null
||
rawDataList
.
get
(
i
)[
2
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.question.required"
));
}
if
(
rawDataList
.
get
(
i
)[
5
]
==
null
||
rawDataList
.
get
(
i
)[
5
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.required.required"
));
}
if
(
rawDataList
.
get
(
i
)[
6
]
==
null
||
rawDataList
.
get
(
i
)[
6
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.default.required"
));
}
}
//validate answer
if
((
rawDataList
.
get
(
i
)[
3
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
3
].
toString
().
trim
().
equals
(
""
))
||
(
rawDataList
.
get
(
i
)[
4
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
||
(
rawDataList
.
get
(
i
)[
7
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
""
)))
{
if
((
rawDataList
.
get
(
i
)[
3
]
==
null
||
!
DataUtil
.
isLong
(
rawDataList
.
get
(
i
)[
3
].
toString
()))
&&
(!
selectedType
.
equals
(
BundleUtils
.
getLangString
(
"scenario.template.text"
))))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.answer.required"
));
}
if
(
rawDataList
.
get
(
i
)[
4
]
==
null
&&
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.hashInput.required"
));
}
}
Row
dataRow
=
sheet
.
getRow
(
3
+
i
);
Cell
resultCell
=
dataRow
.
createCell
(
row
.
getPhysicalNumberOfCells
()
-
1
);
if
(
sb
.
length
()
>
0
)
{
resultCell
.
setCellValue
(
sb
.
toString
());
isValid
=
false
;
}
else
{
isValid
=
true
;
resultCell
.
setCellValue
(
"Ok"
);
}
sb
=
new
StringBuilder
();
}
selectedType
=
""
;
//</editor-fold>
//insert data
if
(
isValid
)
{
for
(
int
i
=
0
;
i
<
rawDataList
.
size
();
i
++)
{
}
}
else
{
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.importFailed"
,
locale
));
}
}
catch
(
Exception
ex
)
{
logger
.
info
(
ex
.
getMessage
(),
ex
);
...
...
@@ -323,4 +397,9 @@ public class ScenarioServiceImpl implements ScenarioService {
}
return
result
;
}
private
boolean
validateQuestionIndex
(
Object
index
)
{
if
(
index
!=
null
&&
DataUtil
.
isLong
(
index
.
toString
()))
return
true
;
return
false
;
}
}
src/main/resources/i18n/language_en.properties
View file @
5a1269c3
...
...
@@ -108,6 +108,7 @@ customer.emailExists=Email exists;
common.fileNotSelected
=
Please select a file
common.fileInvalidFormat
=
File invalid
common.invalidTemplate
=
Template invalid format
#IMPORT SCENARIO TEMPLATE
scenario.template.title
=
IMPORT QUESTIONS
...
...
@@ -125,3 +126,12 @@ scenario.template.result=Result
scenario.template.singleChoice
=
SingleChoice
scenario.template.multiChoice
=
MultiChoice
scenario.template.text
=
Text
scenario.questionCode.required
=
"Question index is required"
scenario.questionType.required
=
"Question type is required"
scenario.question.required
=
"Question content is required"
scenario.answer.required
=
"Answer is required for SingleChoice or MultiChoice question"
scenario.hashInput.required
=
"Has input is required"
scenario.required.required
=
"Require is required"
scenario.default.required
=
"Default is required"
src/main/resources/i18n/language_vi.properties
View file @
5a1269c3
...
...
@@ -110,6 +110,7 @@ customer.emailExists=Email đã tồn tại;
common.fileNotSelected
=
Bạn chưa chọn file
common.fileInvalidFormat
=
File không hợp lệ
common.invalidTemplate
=
Template sai định dạng
#IMPORT SCENARIO TEMPLATE
scenario.template.title
=
IMPORT CÂU HỎI
...
...
@@ -128,6 +129,14 @@ scenario.template.singleChoice=SingleChoice
scenario.template.multiChoice
=
MultiChoice
scenario.template.text
=
Text
scenario.questionCode.required
=
"Mã câu hỏi bắt buộc nhập"
scenario.questionType.required
=
"Loại câu hỏi bắt buộc nhập"
scenario.question.required
=
"Câu hỏi bắt buộc nhập"
scenario.answer.required
=
"Câu trả lời cho câu hỏi SingleChoice, MultiChoice bắt buộc nhập"
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"
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