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
63ddc8fc
Commit
63ddc8fc
authored
Aug 29, 2019
by
Nguyen Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sonar
parent
adbc0add
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
94 deletions
+109
-94
src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
...ttel/campaign/service/impl/CampaignExecuteServiceImp.java
+109
-94
No files found.
src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
View file @
63ddc8fc
...
...
@@ -24,6 +24,9 @@ import org.springframework.data.domain.PageRequest;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.IOException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -33,6 +36,8 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CampaignExecuteServiceImp
.
class
);
private
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
Constants
.
DATE_FORMAT
.
FOMART_DATE_TYPE_1
);
private
Random
rand
=
SecureRandom
.
getInstanceStrong
();
@Autowired
ModelMapper
modelMapper
;
...
...
@@ -66,6 +71,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Autowired
CampaignCustomerListColumnRepository
campaignCustomerListColumnRepository
;
public
CampaignExecuteServiceImp
()
throws
NoSuchAlgorithmException
{
}
//<editor-fold: hungtt>
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
...
...
@@ -119,104 +127,111 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
XSSFWorkbook
exportInteractiveResult
(
CampaignRequestDTO
dto
)
{
public
XSSFWorkbook
exportInteractiveResult
(
CampaignRequestDTO
dto
)
throws
IOException
{
Locale
locale
=
Locale
.
forLanguageTag
(
"vi"
);
List
<
ContactCustResultDTO
>
list
=
campaignExecuteRepository
.
getExcelInteractiveResult
(
dto
);
XSSFWorkbook
workbook
=
n
ew
XSSFWorkbook
()
;
XSSFWorkbook
workbook
=
n
ull
;
Sheet
sheet
;
try
{
// create font style
workbook
=
new
XSSFWorkbook
();
Font
defaultFont
=
workbook
.
createFont
();
defaultFont
.
setFontHeightInPoints
((
short
)
13
);
defaultFont
.
setFontName
(
"Times New Roman"
);
defaultFont
.
setColor
(
IndexedColors
.
BLACK
.
getIndex
());
Font
titleFont
=
workbook
.
createFont
();
titleFont
.
setFontHeightInPoints
((
short
)
18
);
titleFont
.
setFontName
(
"Times New Roman"
);
titleFont
.
setColor
(
IndexedColors
.
BLACK
.
getIndex
());
titleFont
.
setBold
(
true
);
Font
headerFont
=
workbook
.
createFont
();
headerFont
.
setFontHeightInPoints
((
short
)
13
);
headerFont
.
setFontName
(
"Times New Roman"
);
headerFont
.
setColor
(
IndexedColors
.
BLACK
.
getIndex
());
headerFont
.
setBold
(
true
);
CellStyle
styleTitle
=
workbook
.
createCellStyle
();
styleTitle
.
setFont
(
titleFont
);
styleTitle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
CellStyle
styleRowHeader
=
workbook
.
createCellStyle
();
styleRowHeader
.
setFont
(
headerFont
);
styleRowHeader
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
styleRowHeader
.
setFillForegroundColor
(
IndexedColors
.
LIGHT_GREEN
.
getIndex
());
styleRowHeader
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
styleRowHeader
.
setBorderRight
(
BorderStyle
.
THIN
);
styleRowHeader
.
setRightBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
styleRowHeader
.
setBorderBottom
(
BorderStyle
.
THIN
);
styleRowHeader
.
setBottomBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
styleRowHeader
.
setBorderLeft
(
BorderStyle
.
THIN
);
styleRowHeader
.
setLeftBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
styleRowHeader
.
setBorderTop
(
BorderStyle
.
THIN
);
styleRowHeader
.
setTopBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
CellStyle
styleRow
=
workbook
.
createCellStyle
();
styleRow
.
setFont
(
defaultFont
);
// list header
List
<
String
>
headerList
=
new
ArrayList
<>();
headerList
.
add
(
BundleUtils
.
getLangString
(
"stt"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.campaignCode"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.campaignName"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.agentId"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.phoneNumber"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.customerId"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.customerName"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.createTime"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.contactStatus"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.surveyStatus"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.status"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.recordStatus"
,
locale
));
//
String
sheetName
=
BundleUtils
.
getLangString
(
"detail"
,
locale
);
sheet
=
workbook
.
createSheet
(
sheetName
);
// Title
String
title
=
BundleUtils
.
getLangString
(
"campaign.execute.interactive.title"
,
locale
);
int
rowTitleStart
=
3
;
Row
rowTitle
=
sheet
.
createRow
(
rowTitleStart
);
rowTitle
.
setHeight
((
short
)
800
);
writeCellContent
(
rowTitle
,
styleTitle
,
3
,
title
);
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
rowTitleStart
,
rowTitleStart
,
3
,
8
));
// Header
int
startRowTable
=
5
;
int
count
=
1
;
Row
rowHeader
=
sheet
.
createRow
(
startRowTable
);
for
(
int
i
=
0
;
i
<
headerList
.
size
();
i
++)
{
writeCellContent
(
rowHeader
,
styleRowHeader
,
i
,
headerList
.
get
(
i
));
}
// Content
for
(
int
i
=
0
,
rowIndex
=
1
;
i
<
list
.
size
();
i
++)
{
Row
row
=
sheet
.
createRow
(
startRowTable
+
count
);
int
col
=
0
;
writeCellContent
(
row
,
styleRow
,
col
++,
rowIndex
);
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getCampaignCode
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getCampaignName
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getUserName
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getPhoneNumber
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getCustomerName
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getCustomerName
());
writeCellContent
(
row
,
styleRow
,
col
++,
formatter
.
format
(
list
.
get
(
i
).
getCreateTime
()));
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getContactStatus
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getSurveyStatus
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getStatus
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getRecordStatus
());
++
rowIndex
;
++
count
;
}
}
catch
(
Exception
e
){
// create font style
Font
defaultFont
=
workbook
.
createFont
();
defaultFont
.
setFontHeightInPoints
((
short
)
13
);
defaultFont
.
setFontName
(
"Times New Roman"
);
defaultFont
.
setColor
(
IndexedColors
.
BLACK
.
getIndex
());
Font
titleFont
=
workbook
.
createFont
();
titleFont
.
setFontHeightInPoints
((
short
)
18
);
titleFont
.
setFontName
(
"Times New Roman"
);
titleFont
.
setColor
(
IndexedColors
.
BLACK
.
getIndex
());
titleFont
.
setBold
(
true
);
Font
headerFont
=
workbook
.
createFont
();
headerFont
.
setFontHeightInPoints
((
short
)
13
);
headerFont
.
setFontName
(
"Times New Roman"
);
headerFont
.
setColor
(
IndexedColors
.
BLACK
.
getIndex
());
headerFont
.
setBold
(
true
);
CellStyle
styleTitle
=
workbook
.
createCellStyle
();
styleTitle
.
setFont
(
titleFont
);
styleTitle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
CellStyle
styleRowHeader
=
workbook
.
createCellStyle
();
styleRowHeader
.
setFont
(
headerFont
);
styleRowHeader
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
styleRowHeader
.
setFillForegroundColor
(
IndexedColors
.
LIGHT_GREEN
.
getIndex
());
styleRowHeader
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
styleRowHeader
.
setBorderRight
(
BorderStyle
.
THIN
);
styleRowHeader
.
setRightBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
styleRowHeader
.
setBorderBottom
(
BorderStyle
.
THIN
);
styleRowHeader
.
setBottomBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
styleRowHeader
.
setBorderLeft
(
BorderStyle
.
THIN
);
styleRowHeader
.
setLeftBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
styleRowHeader
.
setBorderTop
(
BorderStyle
.
THIN
);
styleRowHeader
.
setTopBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
CellStyle
styleRow
=
workbook
.
createCellStyle
();
styleRow
.
setFont
(
defaultFont
);
// list header
List
<
String
>
headerList
=
new
ArrayList
<>();
headerList
.
add
(
BundleUtils
.
getLangString
(
"stt"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.campaignCode"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.campaignName"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.agentId"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.phoneNumber"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.customerId"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.customerName"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.createTime"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.contactStatus"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.surveyStatus"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.status"
,
locale
));
headerList
.
add
(
BundleUtils
.
getLangString
(
"campaign.execute.interactive.recordStatus"
,
locale
));
//
String
sheetName
=
BundleUtils
.
getLangString
(
"detail"
,
locale
);
sheet
=
workbook
.
createSheet
(
sheetName
);
// Title
String
title
=
BundleUtils
.
getLangString
(
"campaign.execute.interactive.title"
,
locale
);
int
rowTitleStart
=
3
;
Row
rowTitle
=
sheet
.
createRow
(
rowTitleStart
);
rowTitle
.
setHeight
((
short
)
800
);
writeCellContent
(
rowTitle
,
styleTitle
,
3
,
title
);
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
rowTitleStart
,
rowTitleStart
,
3
,
8
));
// Header
int
startRowTable
=
5
;
int
count
=
1
;
Row
rowHeader
=
sheet
.
createRow
(
startRowTable
);
for
(
int
i
=
0
;
i
<
headerList
.
size
();
i
++)
{
writeCellContent
(
rowHeader
,
styleRowHeader
,
i
,
headerList
.
get
(
i
));
}
// Content
for
(
int
i
=
0
,
rowIndex
=
1
;
i
<
list
.
size
();
i
++)
{
Row
row
=
sheet
.
createRow
(
startRowTable
+
count
);
int
col
=
0
;
writeCellContent
(
row
,
styleRow
,
col
++,
rowIndex
);
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getCampaignCode
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getCampaignName
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getUserName
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getPhoneNumber
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getCustomerName
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getCustomerName
());
writeCellContent
(
row
,
styleRow
,
col
++,
formatter
.
format
(
list
.
get
(
i
).
getCreateTime
()));
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getContactStatus
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getSurveyStatus
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getStatus
());
writeCellContent
(
row
,
styleRow
,
col
++,
list
.
get
(
i
).
getRecordStatus
());
++
rowIndex
;
++
count
;
}
finally
{
if
(
workbook
!=
null
)
workbook
.
close
();
}
return
workbook
;
}
...
...
@@ -493,13 +508,13 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Override
public
ResultDTO
getCallStatus
(
CampaignRequestDTO
dto
)
{
ResultDTO
result
=
new
ResultDTO
();
Random
r
=
new
Random
();
//
Random r = new Random();
String
[]
arr
=
{
"ACCEPT"
,
"REJECT"
,
"MISSING"
};
if
(
dto
!=
null
)
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
result
.
setData
(
arr
[
r
.
nextInt
(
arr
.
length
)]);
result
.
setData
(
arr
[
this
.
rand
.
nextInt
(
arr
.
length
)]);
}
else
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
...
...
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