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
07ab5f64
Commit
07ab5f64
authored
Aug 29, 2019
by
Nguyen Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sonar
parent
2e0e6f96
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
...om/viettel/campaign/service/impl/ScenarioServiceImpl.java
+15
-6
No files found.
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
View file @
07ab5f64
...
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.*
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
...
@@ -161,12 +162,13 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -161,12 +162,13 @@ public class ScenarioServiceImpl implements ScenarioService {
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
XSSFWorkbook
buildTemplate
()
{
public
XSSFWorkbook
buildTemplate
()
throws
IOException
{
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
XSSFWorkbook
workbook
=
null
;
try
{
try
{
XSSFWorkbook
workbook
=
new
XSSFWorkbook
();
Sheet
sheet
;
Sheet
sheet
;
workbook
=
new
XSSFWorkbook
();
CellStyle
styleTitle
=
WorkBookBuilder
.
buildDefaultStyleTitle
(
workbook
);
CellStyle
styleTitle
=
WorkBookBuilder
.
buildDefaultStyleTitle
(
workbook
);
CellStyle
styleRowHeader
=
WorkBookBuilder
.
buildDefaultStyleRowHeader
(
workbook
);
CellStyle
styleRowHeader
=
WorkBookBuilder
.
buildDefaultStyleRowHeader
(
workbook
);
CellStyle
styleRow
=
WorkBookBuilder
.
buildDefaultStyleRow
(
workbook
);
CellStyle
styleRow
=
WorkBookBuilder
.
buildDefaultStyleRow
(
workbook
);
...
@@ -237,17 +239,20 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -237,17 +239,20 @@ public class ScenarioServiceImpl implements ScenarioService {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
());
return
null
;
return
null
;
}
finally
{
if
(
workbook
!=
null
)
workbook
.
close
();
}
}
}
}
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
)
{
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
)
throws
IOException
{
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
boolean
isValid
=
true
;
boolean
isValid
=
true
;
XSSFWorkbook
workbook
=
null
;
try
{
try
{
List
<
String
>
fileHeaderList
=
new
ArrayList
<>();
List
<
String
>
fileHeaderList
=
new
ArrayList
<>();
fileHeaderList
.
add
(
BundleUtils
.
getLangString
(
"scenario.template.questionCode"
,
locale
));
fileHeaderList
.
add
(
BundleUtils
.
getLangString
(
"scenario.template.questionCode"
,
locale
));
...
@@ -261,7 +266,8 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -261,7 +266,8 @@ public class ScenarioServiceImpl implements ScenarioService {
File
file
=
new
File
(
path
);
File
file
=
new
File
(
path
);
FileInputStream
fis
=
new
FileInputStream
(
file
);
FileInputStream
fis
=
new
FileInputStream
(
file
);
XSSFWorkbook
workbook
=
new
XSSFWorkbook
(
fis
);
workbook
=
new
XSSFWorkbook
(
fis
);
workbook
=
new
XSSFWorkbook
(
fis
);
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
();
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Row
row
=
sheet
.
getRow
(
2
);
Row
row
=
sheet
.
getRow
(
2
);
...
@@ -423,13 +429,16 @@ public class ScenarioServiceImpl implements ScenarioService {
...
@@ -423,13 +429,16 @@ public class ScenarioServiceImpl implements ScenarioService {
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
logger
.
info
(
ex
.
getMessage
(),
ex
);
logger
.
info
(
ex
.
getMessage
(),
ex
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.errorValidate"
,
locale
));
}
finally
{
if
(
workbook
!=
null
)
workbook
.
close
();
result
.
put
(
"code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
ERROR
);
result
.
put
(
"code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
ERROR
);
}
}
return
result
;
return
result
;
}
}
private
boolean
validateMappingQuestion
(
String
mappingQuestion
,
String
currentQuestionCode
,
List
<
String
>
lstQuestionCode
)
{
private
boolean
validateMappingQuestion
(
String
mappingQuestion
,
String
currentQuestionCode
,
List
<
String
>
lstQuestionCode
)
{
if
(
mappingQuestion
==
currentQuestionCode
)
return
false
;
if
(
mappingQuestion
!=
null
&&
mappingQuestion
.
equals
(
currentQuestionCode
)
)
return
false
;
String
duplicateCode
=
lstQuestionCode
.
stream
().
String
duplicateCode
=
lstQuestionCode
.
stream
().
filter
(
p
->
(
p
.
equals
(
mappingQuestion
)
&&
p
.
equals
(
currentQuestionCode
))).
filter
(
p
->
(
p
.
equals
(
mappingQuestion
)
&&
p
.
equals
(
currentQuestionCode
))).
...
...
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