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
74441932
Commit
74441932
authored
Sep 11, 2019
by
Tu Bach
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into tubn
parents
5c592e18
c14699bb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
130 additions
and
17 deletions
+130
-17
pom.xml
pom.xml
+2
-2
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
...ign/repository/ccms_full/impl/CampaignRepositoryImpl.java
+16
-3
src/main/java/com/viettel/campaign/service/impl/CampaignCfgServiceImpl.java
...viettel/campaign/service/impl/CampaignCfgServiceImpl.java
+6
-4
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+45
-3
src/main/java/com/viettel/campaign/service/impl/ScenarioQuestionServiceImpl.java
...el/campaign/service/impl/ScenarioQuestionServiceImpl.java
+2
-0
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
...om/viettel/campaign/service/impl/ScenarioServiceImpl.java
+50
-5
src/main/resources/i18n/language_en.properties
src/main/resources/i18n/language_en.properties
+5
-0
src/main/resources/i18n/language_vi.properties
src/main/resources/i18n/language_vi.properties
+4
-0
No files found.
pom.xml
View file @
74441932
...
...
@@ -119,7 +119,7 @@
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
3.17
</version>
<version>
4.0.1
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
...
...
@@ -131,7 +131,7 @@
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
3.17
</version>
<version>
4.0.1
</version>
</dependency>
<dependency>
<groupId>
org.quartz-scheduler
</groupId>
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
View file @
74441932
...
...
@@ -122,7 +122,11 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCampaignCode
())
&&
!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCampaignCode
().
trim
()))
{
sb
.
append
(
" AND a.CAMPAIGN_CODE IN (:p_code) "
);
if
(
requestDto
.
getCampaignCode
().
split
(
","
).
length
>
1
)
{
sb
.
append
(
" AND a.CAMPAIGN_CODE IN (:p_code) "
);
}
else
{
sb
.
append
(
" AND a.CAMPAIGN_CODE LIKE :p_code "
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCampaignName
()))
{
sb
.
append
(
" AND UPPER(a.CAMPAIGN_NAME) LIKE :p_name"
);
...
...
@@ -165,8 +169,17 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
SQLQuery
query
=
session
.
createSQLQuery
(
sb
.
toString
());
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCampaignCode
())
&&
!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCampaignCode
().
trim
()))
{
String
[]
lstCode
=
requestDto
.
getCampaignCode
().
trim
().
split
(
","
);
query
.
setParameterList
(
"p_code"
,
lstCode
);
if
(
requestDto
.
getCampaignCode
().
split
(
","
).
length
>
1
)
{
String
[]
lstCode
=
requestDto
.
getCampaignCode
().
trim
().
split
(
","
);
query
.
setParameterList
(
"p_code"
,
lstCode
);
}
else
{
query
.
setParameter
(
"p_code"
,
"%"
+
requestDto
.
getCampaignCode
().
trim
().
toUpperCase
()
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"_"
,
"\\_"
)
+
"%"
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCampaignName
()))
{
...
...
src/main/java/com/viettel/campaign/service/impl/CampaignCfgServiceImpl.java
View file @
74441932
...
...
@@ -220,16 +220,18 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
if
(
completeCodeDTO
!=
null
)
{
// update
compCode
=
compCodeMapper
.
toPersistenceBean
(
completeCodeDTO
);
comp
Code
=
comp
leteCodeRepository
.
save
(
compCode
);
completeCodeRepository
.
save
(
compCode
);
resultDTO
.
setErrorCode
(
"0"
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
"Complete Code: "
+
compCode
.
getCampaignCompleteCodeId
()
+
" updated!"
);
}
else
{
resultDTO
.
setErrorCode
(
"-2"
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
"CompleteCodeDTO null"
);
}
}
catch
(
Exception
e
)
{
// e.printStackTrace();
logger
.
error
(
e
.
getMessage
(),
e
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
return
resultDTO
;
...
...
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
74441932
...
...
@@ -20,6 +20,7 @@ import cz.jirutka.rsql.parser.ast.RSQLVisitor;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.ss.util.CellRangeAddressList
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.hibernate.SQLQuery
;
import
org.hibernate.Session
;
...
...
@@ -980,7 +981,7 @@ public class CustomerServiceImpl implements CustomerService {
FileInputStream
fis
=
new
FileInputStream
(
file
);
workbook
=
new
XSSFWorkbook
(
fis
);
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
();
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
XSSF
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Row
row
=
sheet
.
getRow
(
3
);
//<editor-fold desc="Tạo style cho cột kết quả" defaultstate="collapsed">
...
...
@@ -993,10 +994,31 @@ public class CustomerServiceImpl implements CustomerService {
resultStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
resultStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
resultStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
resultStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
resultStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
//</editor-fold>
//<editor-fold desc="Kiểm tra header của template" defaultstate="collapsed">
if
(
row
.
getPhysicalNumberOfCells
()
!=
header
.
size
())
{
if
(
row
.
getPhysicalNumberOfCells
()
>
header
.
size
())
{
for
(
int
i
=
0
;
i
<
row
.
getPhysicalNumberOfCells
();
i
++)
{
if
(
sheet
.
isColumnHidden
(
i
))
{
sheet
.
setColumnHidden
(
i
,
false
);
}
if
(
isColumnNullOrBlank
(
sheet
,
i
))
{
sheet
.
shiftColumns
(
i
+
1
,
i
+
1
,
-
1
);
sheet
.
removeMergedRegion
(
0
);
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
0
,
1
,
0
,
13
));
}
}
for
(
int
i
=
0
;
i
<
header
.
size
();
i
++)
{
Cell
cell
=
row
.
getCell
(
i
);
if
(!
cell
.
getStringCellValue
().
equals
(
header
.
get
(
i
).
getTitle
().
split
(
"#"
)[
0
]))
{
result
.
put
(
"content"
,
Files
.
readAllBytes
(
file
.
toPath
()));
result
.
put
(
"message"
,
"template-invalid"
);
return
result
;
}
}
}
else
if
(
row
.
getPhysicalNumberOfCells
()
<
header
.
size
())
{
result
.
put
(
"content"
,
Files
.
readAllBytes
(
file
.
toPath
()));
result
.
put
(
"message"
,
"template-invalid"
);
return
result
;
...
...
@@ -1020,7 +1042,10 @@ public class CustomerServiceImpl implements CustomerService {
result
.
put
(
"content"
,
Files
.
readAllBytes
(
file
.
toPath
()));
return
result
;
}
else
{
Cell
resultCell
=
sheet
.
getRow
(
3
).
createCell
(
sheet
.
getRow
(
3
).
getPhysicalNumberOfCells
());
Cell
resultCell
=
sheet
.
getRow
(
3
).
getCell
(
header
.
size
());
if
(
resultCell
==
null
)
{
resultCell
=
sheet
.
getRow
(
3
).
createCell
(
header
.
size
());
}
resultCell
.
setCellValue
(
BundleUtils
.
getLangString
(
"customer.result"
,
locale
));
resultCell
.
setCellStyle
(
resultStyle
);
}
...
...
@@ -1396,6 +1421,18 @@ public class CustomerServiceImpl implements CustomerService {
String
regexp
=
"@\"^\\p{L}+$\""
;
return
str
.
matches
(
regexp
);
}
private
boolean
isColumnNullOrBlank
(
Sheet
sheet
,
int
columnIndex
)
{
for
(
Row
row
:
sheet
)
{
if
(
row
.
getRowNum
()
<
3
)
continue
;
Cell
cell
=
row
.
getCell
(
columnIndex
,
Row
.
MissingCellPolicy
.
RETURN_BLANK_AS_NULL
);
if
(
cell
!=
null
)
{
return
false
;
}
}
return
true
;
}
//</editor-fold>
@Override
...
...
@@ -1436,10 +1473,14 @@ public class CustomerServiceImpl implements CustomerService {
headerFont
.
setBold
(
true
);
CellStyle
headerStyle
=
workbook
.
createCellStyle
();
CellStyle
importantStyle
=
workbook
.
createCellStyle
();
CellStyle
columnStyle
=
workbook
.
createCellStyle
();
importantStyle
.
setFont
(
importantFont
);
headerStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
headerStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
headerStyle
.
setFont
(
headerFont
);
columnStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
columnStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
columnStyle
.
setWrapText
(
true
);
//</editor-fold>
//<editor-fold desc="Thêm combobox" defaultstate="collapsed">
...
...
@@ -1512,6 +1553,7 @@ public class CustomerServiceImpl implements CustomerService {
cell2
.
setCellStyle
(
importantStyle
);
cell2
.
setCellValue
(
BundleUtils
.
getLangString
(
"customer.notice"
,
locale
));
for
(
int
i
=
0
;
i
<
header
.
size
();
i
++)
{
sheet
.
setDefaultColumnStyle
(
i
,
columnStyle
);
Cell
headerCell
=
row3
.
createCell
(
i
);
headerCell
.
setCellValue
(
header
.
get
(
i
).
getTitle
().
split
(
"#"
)[
0
]);
headerStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
...
...
src/main/java/com/viettel/campaign/service/impl/ScenarioQuestionServiceImpl.java
View file @
74441932
...
...
@@ -70,6 +70,8 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
List
<
ScenarioAnswerDTO
>
lstAnswers
=
new
ArrayList
<>();
List
<
ScenarioAnswer
>
lstAnswersToInsert
=
new
ArrayList
<>();
try
{
if
(
scenarioQuestionDTO
.
getQuestion
()
!=
null
&&
scenarioQuestionDTO
.
getQuestion
()
!=
""
)
scenarioQuestionDTO
.
setQuestion
(
scenarioQuestionDTO
.
getQuestion
().
trim
());
ScenarioQuestion
scenarioQuestion
=
modelMapper
.
map
(
scenarioQuestionDTO
,
ScenarioQuestion
.
class
);
scenarioQuestion
.
setCreateTime
(
new
Date
());
...
...
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
View file @
74441932
...
...
@@ -247,14 +247,14 @@ public class ScenarioServiceImpl implements ScenarioService {
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
return
null
;
}
finally
{
}
finally
{
//if (workbook != null) workbook.close();
}
}
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
)
throws
IOException
{
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
)
throws
IOException
{
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
...
...
@@ -371,18 +371,52 @@ public class ScenarioServiceImpl implements ScenarioService {
if
(
rawDataList
.
get
(
i
)[
0
]
==
null
||
!
DataUtil
.
isNumber
(
rawDataList
.
get
(
i
)[
0
].
toString
()))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.questionCode.required"
));
}
//question type
if
(
rawDataList
.
get
(
i
)[
1
]
==
null
||
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.questionType.required"
));
}
if
(
rawDataList
.
get
(
i
)[
1
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
""
))
{
if
(
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.singleChoice"
))
||
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.multiChoice"
))
||
rawDataList
.
get
(
i
)[
1
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.text"
))
)
{
sb
=
sb
;
}
else
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.questionType.invalid"
));
}
}
//
if
(
rawDataList
.
get
(
i
)[
2
]
==
null
||
rawDataList
.
get
(
i
)[
2
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.question.required"
));
}
//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
)[
5
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
5
].
toString
().
trim
().
equals
(
""
))
{
if
(
rawDataList
.
get
(
i
)[
5
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.yes"
))
||
rawDataList
.
get
(
i
)[
5
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.no"
))
)
{
sb
=
sb
;
}
else
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.required.invalid"
));
}
}
//
//default
if
(
rawDataList
.
get
(
i
)[
6
]
==
null
||
rawDataList
.
get
(
i
)[
6
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.default.required"
));
}
if
(
rawDataList
.
get
(
i
)[
6
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
6
].
toString
().
trim
().
equals
(
""
))
{
if
(
rawDataList
.
get
(
i
)[
6
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.yes"
))
||
rawDataList
.
get
(
i
)[
6
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.no"
))
)
{
sb
=
sb
;
}
else
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.default.invalid"
));
}
}
//
}
//validate answer
...
...
@@ -392,9 +426,20 @@ 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"
))))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.answer.required"
));
}
//hash input
if
(
rawDataList
.
get
(
i
)[
4
]
==
null
&&
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.hashInput.required"
));
}
if
(
rawDataList
.
get
(
i
)[
4
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
if
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.yes"
))
||
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
BundleUtils
.
getLangString
(
"scenario.template.no"
))
)
{
sb
=
sb
;
}
else
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.hashInput.invalid"
));
}
}
//
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
))
...
...
@@ -429,7 +474,7 @@ public class ScenarioServiceImpl implements ScenarioService {
ScenarioQuestion
question
=
questionRepository
.
findScenarioQuestionByCodeAndCompanySiteId
(
item
.
getMappingQuestionCode
(),
item
.
getCompanySiteId
());
if
(
question
!=
null
)
{
ScenarioAnswer
answerForUpdate
=
answerRepository
.
findScenarioAnswerByCode
(
item
.
getCode
());
if
(
answerForUpdate
!=
null
)
{
if
(
answerForUpdate
!=
null
)
{
answerForUpdate
.
setMappingQuestionId
(
question
.
getScenarioQuestionId
());
answerRepository
.
save
(
answerForUpdate
);
}
...
...
@@ -454,9 +499,9 @@ public class ScenarioServiceImpl implements ScenarioService {
}
catch
(
Exception
ex
)
{
logger
.
info
(
ex
.
getMessage
(),
ex
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.errorValidate"
,
locale
));
}
finally
{
}
finally
{
if
(
workbook
!=
null
)
workbook
.
close
();
if
(
fis
!=
null
)
fis
.
close
();
if
(
fis
!=
null
)
fis
.
close
();
}
return
result
;
}
...
...
src/main/resources/i18n/language_en.properties
View file @
74441932
...
...
@@ -138,3 +138,8 @@ scenario.mappingQuestion.invalid="Mapping question invalid"
ok
=
"Imported"
error
=
"Error"
scenario.questionType.invalid
=
"Question type invalid"
scenario.required.invalid
=
"Required field invalid"
scenario.default.invalid
=
"Default field invalid"
scenario.hashInput.invalid
=
"Has input field invalid"
src/main/resources/i18n/language_vi.properties
View file @
74441932
...
...
@@ -141,6 +141,10 @@ 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"
scenario.questionType.invalid
=
"Loại câu hỏi không hợp lệ"
scenario.required.invalid
=
"Giá trị rường bắt buộc không hợp lệ"
scenario.default.invalid
=
"Giá trị trường mặc định không hợp lệ"
scenario.hashInput.invalid
=
"Giá trị nhập text 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