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
cae4f155
Commit
cae4f155
authored
Aug 29, 2019
by
Phạm Duy Phi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.myitsol.com/hanv/service-campaign
parents
e9a9358f
3c9f41ef
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
384 additions
and
311 deletions
+384
-311
pom.xml
pom.xml
+14
-0
src/main/java/com/viettel/campaign/config/JobConfig.java
src/main/java/com/viettel/campaign/config/JobConfig.java
+27
-26
src/main/java/com/viettel/campaign/job/CampaignJob.java
src/main/java/com/viettel/campaign/job/CampaignJob.java
+1
-1
src/main/java/com/viettel/campaign/model/ccms_full/CustomerContact.java
...com/viettel/campaign/model/ccms_full/CustomerContact.java
+1
-1
src/main/java/com/viettel/campaign/model/ccms_full/CustomizeFields.java
...com/viettel/campaign/model/ccms_full/CustomizeFields.java
+4
-5
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
...pository/ccms_full/impl/CampaignExecuteRepositoryImp.java
+3
-3
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
...ign/repository/ccms_full/impl/CampaignRepositoryImpl.java
+17
-9
src/main/java/com/viettel/campaign/service/CampaignExecuteService.java
.../com/viettel/campaign/service/CampaignExecuteService.java
+2
-1
src/main/java/com/viettel/campaign/service/CustomerService.java
...in/java/com/viettel/campaign/service/CustomerService.java
+3
-2
src/main/java/com/viettel/campaign/service/ScenarioService.java
...in/java/com/viettel/campaign/service/ScenarioService.java
+3
-2
src/main/java/com/viettel/campaign/service/impl/AgentsServiceImpl.java
.../com/viettel/campaign/service/impl/AgentsServiceImpl.java
+21
-12
src/main/java/com/viettel/campaign/service/impl/CampaignCfgServiceImpl.java
...viettel/campaign/service/impl/CampaignCfgServiceImpl.java
+13
-10
src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
...ttel/campaign/service/impl/CampaignExecuteServiceImp.java
+109
-94
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
...om/viettel/campaign/service/impl/CampaignServiceImpl.java
+1
-1
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+94
-96
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
...om/viettel/campaign/service/impl/ScenarioServiceImpl.java
+43
-21
src/main/java/com/viettel/campaign/utils/BundleUtils.java
src/main/java/com/viettel/campaign/utils/BundleUtils.java
+1
-1
src/main/java/com/viettel/campaign/utils/Constants.java
src/main/java/com/viettel/campaign/utils/Constants.java
+7
-0
src/main/java/com/viettel/campaign/utils/DataUtil.java
src/main/java/com/viettel/campaign/utils/DataUtil.java
+2
-9
src/main/java/com/viettel/campaign/utils/RedisUtil.java
src/main/java/com/viettel/campaign/utils/RedisUtil.java
+2
-1
src/main/java/com/viettel/campaign/utils/WorkBookBuilder.java
...main/java/com/viettel/campaign/utils/WorkBookBuilder.java
+1
-1
src/main/java/com/viettel/campaign/web/dto/request_dto/CustomerQueryDTO.java
...iettel/campaign/web/dto/request_dto/CustomerQueryDTO.java
+1
-1
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
...ava/com/viettel/campaign/web/rest/CustomerController.java
+4
-2
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
...ava/com/viettel/campaign/web/rest/ScenarioController.java
+4
-11
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
+2
-0
src/main/resources/i18n/language_vi.properties
src/main/resources/i18n/language_vi.properties
+3
-0
No files found.
pom.xml
View file @
cae4f155
...
...
@@ -173,6 +173,20 @@
<!--<executable>true</executable>-->
<!--</configuration>-->
</plugin>
<!--<plugin>-->
<!--<groupId>org.sonarsource.scanner.maven</groupId>-->
<!--<artifactId>sonar-maven-plugin</artifactId>-->
<!--<version>3.3.0.603</version>-->
<!--<executions>-->
<!--<execution>-->
<!--<phase>verify</phase>-->
<!--<goals>-->
<!--<goal>sonar</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
</plugins>
</build>
<repositories>
...
...
src/main/java/com/viettel/campaign/config/JobConfig.java
View file @
cae4f155
...
...
@@ -48,33 +48,34 @@ public class JobConfig implements SchedulingConfigurer {
// taskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
// }
private
void
job1
(
TaskScheduler
scheduler
)
{
job1
=
scheduler
.
schedule
(()
->
{
log
.
info
(
"processing job1 ..."
);
log
.
info
(
Thread
.
currentThread
().
getName
()
+
" The Task1 executed at "
+
new
Date
());
try
{
Thread
.
sleep
(
10000
);
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
},
triggerContext
->
{
String
cronExp
=
"0/5 * * * * ?"
;
// Can be pulled from a db .
return
new
CronTrigger
(
cronExp
).
nextExecutionTime
(
triggerContext
);
});
}
private
void
job2
(
TaskScheduler
scheduler
)
{
job2
=
scheduler
.
schedule
(()
->
{
log
.
info
(
Thread
.
currentThread
().
getName
()
+
" The Job executed at "
+
new
Date
());
campaignJob
().
process
();
// private void job1(TaskScheduler scheduler) {
// job1 = scheduler.schedule(() -> {
// log.info("processing job1 ...");
// log.info(Thread.currentThread().getName() + " The Task1 executed at " + new Date());
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
//// e.printStackTrace();
// log.error("Interrupted! ...${}", e);
// }
// }, triggerContext -> {
//
// String cronExp = "0/5 * * * * ?";// Can be pulled from a db .
// return new CronTrigger(cronExp).nextExecutionTime(triggerContext);
// });
// }
},
triggerContext
->
{
String
cronExp
=
"0/1 * * * * ?"
;
// Can be pulled from a db . This will run every minute
return
new
CronTrigger
(
cronExp
).
nextExecutionTime
(
triggerContext
);
});
}
// private void job2(TaskScheduler scheduler) {
// job2 = scheduler.schedule(() -> {
// log.info(Thread.currentThread().getName() + " The Job executed at " + new Date());
// campaignJob().process();
//
// }, triggerContext -> {
// String cronExp = "0/1 * * * * ?";// Can be pulled from a db . This will run every minute
// return new CronTrigger(cronExp).nextExecutionTime(triggerContext);
// });
// }
...
...
src/main/java/com/viettel/campaign/job/CampaignJob.java
View file @
cae4f155
...
...
@@ -19,7 +19,7 @@ import java.util.List;
@Slf4j
public
class
CampaignJob
{
private
static
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd-MM-yyyy HH:mm:ss"
);
private
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd-MM-yyyy HH:mm:ss"
);
private
static
final
String
CUSTOMER_INACTIVE_DUARATION
=
"CUSTOMER_INACTIVE_DUARATION"
;
private
static
final
String
CRON_EXPRESSION_CHECK_START
=
"CRON_EXPRESSION_CHECK_START"
;
private
static
final
String
CRON_EXPRESSION_CHECK_END
=
"CRON_EXPRESSION_CHECK_END"
;
...
...
src/main/java/com/viettel/campaign/model/ccms_full/CustomerContact.java
View file @
cae4f155
...
...
@@ -15,7 +15,7 @@ import java.util.Date;
public
class
CustomerContact
implements
Serializable
{
@Id
@Basic
(
optional
=
false
)
@GeneratedValue
(
generator
=
"customer_contact_seq"
,
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
generator
=
"customer_contact_seq"
)
@SequenceGenerator
(
name
=
"customer_contact_seq"
,
sequenceName
=
"customer_contact_seq"
,
allocationSize
=
1
)
@NotNull
@Column
(
name
=
"CONTACT_ID"
)
...
...
src/main/java/com/viettel/campaign/model/ccms_full/CustomizeFields.java
View file @
cae4f155
package
com.viettel.campaign.model.ccms_full
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.*
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotNull
;
...
...
@@ -67,8 +64,10 @@ public class CustomizeFields implements Serializable {
@Column
(
name
=
"ACTIVE"
)
private
Long
active
;
public
CustomizeFields
(
String
type
,
String
title
)
{
public
CustomizeFields
(
@NotNull
String
type
,
@NotNull
String
title
)
{
this
.
type
=
type
;
this
.
title
=
title
;
}
}
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
View file @
cae4f155
...
...
@@ -301,9 +301,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
if
(!
"AGENT"
.
equals
(
dto
.
getRoleUser
()))
{
// ko phải nhân viên
ContactCustResultDTO
.
setEnableEdit
(
true
);
}
else
{
if
(
"2"
.
equals
(
ContactCustResultDTO
.
getRecordStatus
()
))
{
// là nhân viên thường
if
(
2
==
ContactCustResultDTO
.
getRecordStatus
(
))
{
// là nhân viên thường
ContactCustResultDTO
.
setEnableEdit
(
true
);
}
else
if
(
"1"
.
equals
(
ContactCustResultDTO
.
getRecordStatus
()
)
&&
isLower24Hour
(
ContactCustResultDTO
.
getCreateTime
()))
{
}
else
if
(
1
==
ContactCustResultDTO
.
getRecordStatus
(
)
&&
isLower24Hour
(
ContactCustResultDTO
.
getCreateTime
()))
{
ContactCustResultDTO
.
setEnableEdit
(
true
);
}
else
{
ContactCustResultDTO
.
setEnableEdit
(
false
);
...
...
@@ -439,8 +439,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
session
.
close
();
return
list
;
}
return
list
;
}
@Override
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
View file @
cae4f155
...
...
@@ -57,8 +57,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO
result
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCompanySiteId
()))
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -66,6 +65,9 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return
result
;
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
" SELECT"
);
...
...
@@ -256,7 +258,9 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
finally
{
session
.
close
();
if
(
null
!=
session
)
{
session
.
close
();
}
}
return
result
;
}
...
...
@@ -267,8 +271,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO
result
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCompanySiteId
()))
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -276,6 +279,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return
result
;
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
StringBuilder
sb
=
new
StringBuilder
();
// sb.append(" SELECT CAMPAIGN_ID campaignId, " +
// " CAMPAIGN_CODE campaignCode, " +
...
...
@@ -343,7 +348,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
result
;
}
...
...
@@ -353,9 +358,10 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
logger
.
info
(
"Start search max campaign code index::"
);
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
//StringBuilder sb = new StringBuilder();
//sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-max-campaign-code-index"));
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -373,6 +379,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
}
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
finally
{
if
(
session
!=
null
)
session
.
close
();
}
return
null
;
}
...
...
@@ -779,8 +787,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
return
resultDTO
;
}
return
resultDTO
;
}
@Override
...
...
src/main/java/com/viettel/campaign/service/CampaignExecuteService.java
View file @
cae4f155
...
...
@@ -6,6 +6,7 @@ import com.viettel.econtact.filter.UserSession;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.util.List
;
@Service
...
...
@@ -17,7 +18,7 @@ public interface CampaignExecuteService {
ResultDTO
searchInteractiveResult
(
CampaignRequestDTO
dto
);
XSSFWorkbook
exportInteractiveResult
(
CampaignRequestDTO
dto
);
XSSFWorkbook
exportInteractiveResult
(
CampaignRequestDTO
dto
)
throws
IOException
;
List
<
ContactCustResultDTO
>
getContactCustById
(
CampaignRequestDTO
dto
);
//</editor-fold>
...
...
src/main/java/com/viettel/campaign/service/CustomerService.java
View file @
cae4f155
...
...
@@ -11,6 +11,7 @@ import com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
import
com.viettel.econtact.filter.UserSession
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -76,9 +77,9 @@ public interface CustomerService {
List
<
CustomizeFields
>
getDynamicHeader
(
Long
companySiteId
);
byte
[]
buildTemplate
(
Long
companySiteId
);
byte
[]
buildTemplate
(
Long
companySiteId
)
throws
IOException
;
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
List
<
CustomizeFields
>
headerDTOS
,
UserSession
userSession
,
Long
customerListId
);
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
List
<
CustomizeFields
>
headerDTOS
,
UserSession
userSession
,
Long
customerListId
)
throws
IOException
;
List
<
CustomizeFieldObject
>
getCustomizeField
(
Long
customerId
);
...
...
src/main/java/com/viettel/campaign/service/ScenarioService.java
View file @
cae4f155
...
...
@@ -6,6 +6,7 @@ import com.viettel.econtact.filter.UserSession;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -24,7 +25,7 @@ public interface ScenarioService {
ResultDTO
saveContacQuestResult
(
ContactQuestResultDTO
dto
);
XSSFWorkbook
buildTemplate
();
XSSFWorkbook
buildTemplate
()
throws
IOException
;
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
);
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
Long
scenarioId
,
Long
campaignId
,
Long
companySiteId
)
throws
IOException
;
}
src/main/java/com/viettel/campaign/service/impl/AgentsServiceImpl.java
View file @
cae4f155
...
...
@@ -66,8 +66,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
companySiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -76,6 +75,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
...
...
@@ -136,7 +137,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
@@ -147,8 +148,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
companySiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -157,6 +157,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -214,7 +216,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
@@ -278,8 +280,7 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
companySiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -288,6 +289,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder
sqlStrBuilder
=
new
StringBuilder
();
...
...
@@ -372,7 +375,7 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
@@ -383,8 +386,10 @@ public class AgentsServiceImpl implements AgentsService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// Session session = sessionFactory.openSession();
// session.beginTransaction();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
companySiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -393,6 +398,8 @@ public class AgentsServiceImpl implements AgentsService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-agents-by-params"));
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -477,7 +484,9 @@ public class AgentsServiceImpl implements AgentsService {
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
null
!=
session
){
session
.
close
();
}
}
return
resultDTO
;
...
...
src/main/java/com/viettel/campaign/service/impl/CampaignCfgServiceImpl.java
View file @
cae4f155
...
...
@@ -44,8 +44,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
companySiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -54,6 +53,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "findAll-CampaignCompleteCode"));
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -132,7 +133,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
@@ -278,8 +279,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
completeCodeDTO
.
getCompanySiteId
()))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -288,6 +288,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "get-max-value-completevalue"));
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -323,9 +325,9 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
session
.
close
();
return
resultDTO
;
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
}
@Override
...
...
@@ -367,8 +369,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
campaignCompleteCodeId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -377,6 +378,8 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG,"findCampaignCodeById"));
...
...
@@ -437,7 +440,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
View file @
cae4f155
...
...
@@ -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
);
...
...
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
View file @
cae4f155
...
...
@@ -596,7 +596,7 @@ public class CampaignServiceImpl implements CampaignService {
// Cap nhat cac truong da co san
for
(
FieldsToShowDTO
fieldsToShowDTO
:
list
)
{
if
(
fieldsToShowDTO
.
getId
()
!=
null
)
{
listColumns
.
removeIf
(
p
->
p
.
getCampaignCusListColId
()
==
fieldsToShowDTO
.
getId
(
));
listColumns
.
removeIf
(
p
->
p
.
getCampaignCusListColId
()
.
equals
(
fieldsToShowDTO
.
getId
()
));
CampaignCustomerListColumn
entity
=
campaignCustomerListColumnRepository
.
findByCampaignCusListColId
(
fieldsToShowDTO
.
getId
());
entity
.
setOrderIndex
((
long
)
(
list
.
indexOf
(
fieldsToShowDTO
)
+
1
));
campaignCustomerListColumnRepository
.
save
(
entity
);
...
...
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
cae4f155
...
...
@@ -46,6 +46,7 @@ import javax.persistence.criteria.CriteriaQuery;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
...
...
@@ -103,8 +104,7 @@ public class CustomerServiceImpl implements CustomerService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
companySiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -113,6 +113,8 @@ public class CustomerServiceImpl implements CustomerService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params"));
...
...
@@ -179,7 +181,7 @@ public class CustomerServiceImpl implements CustomerService {
}
Pageable
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Order
.
desc
(
sort
)));
if
(
pageable
!=
null
)
{
if
(
pageable
!=
null
)
{
query
.
setFirstResult
(
pageable
.
getPageNumber
()
*
pageable
.
getPageSize
());
query
.
setMaxResults
(
pageable
.
getPageSize
());
}
...
...
@@ -193,7 +195,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
@@ -224,8 +226,7 @@ public class CustomerServiceImpl implements CustomerService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
companySiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -234,6 +235,8 @@ public class CustomerServiceImpl implements CustomerService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params"));
...
...
@@ -339,7 +342,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
@@ -429,8 +432,7 @@ public class CustomerServiceImpl implements CustomerService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
companySiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -439,6 +441,8 @@ public class CustomerServiceImpl implements CustomerService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-customer-detail-by-id"));
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -494,7 +498,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
@@ -522,8 +526,7 @@ public class CustomerServiceImpl implements CustomerService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrZero
(
companySiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -532,6 +535,8 @@ public class CustomerServiceImpl implements CustomerService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params"));
...
...
@@ -594,7 +599,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
@@ -759,8 +764,7 @@ public class CustomerServiceImpl implements CustomerService {
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
Session
session
=
null
;
if
(
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCompanySiteId
()))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
...
...
@@ -769,6 +773,8 @@ public class CustomerServiceImpl implements CustomerService {
}
try
{
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params"));
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -865,7 +871,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
if
(
session
!=
null
)
session
.
close
();
}
return
resultDTO
;
...
...
@@ -885,16 +891,11 @@ public class CustomerServiceImpl implements CustomerService {
try
{
List
<
CustomerContact
>
data
=
customerContactRepository
.
findByCustomerIdAndAndContactTypeAndContact
(
customer
.
getCustomerId
(),
customer
.
getContactType
(),
customer
.
getContact
(),
SQLBuilder
.
buildPageable
(
customer
));
if
(
customer
!=
null
)
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
"customer contact data"
);
result
.
setListData
(
data
);
result
.
setTotalRow
(
customerContactRepository
.
findByCustomerIdAndAndContactTypeAndContact
(
customer
.
getCustomerId
(),
customer
.
getContactType
(),
customer
.
getContact
(),
null
).
size
());
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
"customer contact data"
);
result
.
setListData
(
data
);
result
.
setTotalRow
(
customerContactRepository
.
findByCustomerIdAndAndContactTypeAndContact
(
customer
.
getCustomerId
(),
customer
.
getContactType
(),
customer
.
getContact
(),
null
).
size
());
}
else
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
"customer contact data null"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -940,7 +941,7 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
List
<
CustomizeFields
>
dynamicHeader
,
UserSession
userSession
,
Long
customerListId
)
{
public
Map
<
String
,
Object
>
readAndValidateCustomer
(
String
path
,
List
<
CustomizeFields
>
dynamicHeader
,
UserSession
userSession
,
Long
customerListId
)
throws
IOException
{
LOGGER
.
info
(
"------------READ AND VALIDATE--------------"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
DataFormatter
dataFormat
=
new
DataFormatter
();
...
...
@@ -948,6 +949,7 @@ public class CustomerServiceImpl implements CustomerService {
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
StringBuilder
sb
=
new
StringBuilder
();
int
failedCount
=
0
;
XSSFWorkbook
workbook
=
null
;
try
{
//<editor-fold desc="Khởi tạo mảng header tĩnh" defaultstate="collapsed">
...
...
@@ -971,7 +973,7 @@ public class CustomerServiceImpl implements CustomerService {
File
file
=
new
File
(
path
);
FileInputStream
fis
=
new
FileInputStream
(
file
);
XSSFWorkbook
workbook
=
new
XSSFWorkbook
(
fis
);
workbook
=
new
XSSFWorkbook
(
fis
);
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
();
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Row
row
=
sheet
.
getRow
(
3
);
...
...
@@ -1056,11 +1058,11 @@ public class CustomerServiceImpl implements CustomerService {
&&
rawDataList
.
get
(
i
)[
4
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
String
str
=
validatePhone
(
rawDataList
.
get
(
i
)[
2
].
toString
().
trim
(),
locale
);
str
.
concat
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.secondPhone"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
3
].
toString
(),
50
,
locale
));
str
+=
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.secondPhone"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
3
].
toString
(),
50
,
locale
));
if
(!
validateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
()))
{
str
.
concat
(
BundleUtils
.
getLangString
(
"customer.emailInvalid"
,
locale
));
str
+=
(
BundleUtils
.
getLangString
(
"customer.emailInvalid"
,
locale
));
}
else
{
str
.
concat
(
validateDuplicateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
(),
locale
));
str
+=
(
validateDuplicateEmail
(
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
(),
locale
));
}
sb
.
append
(
validateLength
(
BundleUtils
.
getLangString
(
"customer.email"
,
locale
).
split
(
"#"
)[
0
],
rawDataList
.
get
(
i
)[
4
].
toString
(),
50
,
locale
));
sb
.
append
(
str
);
...
...
@@ -1249,7 +1251,7 @@ public class CustomerServiceImpl implements CustomerService {
os
.
close
();
workbook
.
close
();
result
.
put
(
"content"
,
os
.
toByteArray
());
result
.
put
(
"message"
,
""
);
result
.
put
(
"message"
,
"
import-success
"
);
}
else
{
workbook
.
write
(
os
);
os
.
flush
();
...
...
@@ -1265,6 +1267,8 @@ public class CustomerServiceImpl implements CustomerService {
LOGGER
.
info
(
e
.
getMessage
());
result
.
put
(
"message"
,
"validate-error"
);
return
result
;
}
finally
{
if
(
workbook
!=
null
)
workbook
.
close
();
}
}
...
...
@@ -1335,11 +1339,12 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
byte
[]
buildTemplate
(
Long
companySiteId
)
{
public
byte
[]
buildTemplate
(
Long
companySiteId
)
throws
IOException
{
LOGGER
.
info
(
"-----------BUILD TEMPLATE-----------"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
XSSFWorkbook
workbook
=
null
;
try
{
XSSFWorkbook
workbook
=
new
XSSFWorkbook
();
workbook
=
new
XSSFWorkbook
();
CreationHelper
creationHelper
=
workbook
.
getCreationHelper
();
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
();
Sheet
sheet
=
workbook
.
createSheet
(
"IMPORT"
);
...
...
@@ -1478,11 +1483,12 @@ public class CustomerServiceImpl implements CustomerService {
workbook
.
write
(
os
);
os
.
flush
();
os
.
close
();
workbook
.
close
();
return
os
.
toByteArray
();
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
());
return
null
;
}
finally
{
if
(
workbook
!=
null
)
workbook
.
close
();
}
}
...
...
@@ -1818,70 +1824,32 @@ public class CustomerServiceImpl implements CustomerService {
@Override
public
ResultDTO
listCustomizeFields
(
CustomizeFieldsDTO
customizeFields
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
List
<
CustomizeFielObjectDTO
>
list
;
StringBuilder
stringBuilder
=
new
StringBuilder
();
try
{
List
<
CustomizeFields
>
lstCustomizeFields
=
customizeFieldsRepository
.
findByFunctionCodeAndActiveAndStatusAndSiteId
(
customizeFields
.
getFunctionCode
(),
customizeFields
.
getActive
(),
customizeFields
.
getStatus
()
,
customizeFields
.
getSiteId
());
List
<
CustomizeFields
>
lstCustomizeFields
=
customizeFieldsRepository
.
findByFunctionCodeAndActiveAndStatusAndSiteId
(
"CUSTOMER"
,
1L
,
1L
,
customizeFields
.
getSiteId
());
String
cf
[][]
=
{
{
"-1"
,
"Mã Khách Hàng"
,
"
number
"
},
{
"-1"
,
"Mã Khách Hàng"
,
"
text
"
},
{
"-2"
,
"Tên khách hàng"
,
"text"
},
{
"-3"
,
"Tên công ty"
,
"text"
},
{
"-4"
,
"Giới tính"
,
"
number
"
},
{
"-4"
,
"Giới tính"
,
"
combobox
"
},
{
"-5"
,
"Địa chỉ"
,
"text"
},
{
"-6"
,
"Nơi sinh"
,
"text"
},
{
"-7"
,
"Ngày sinh"
,
"date"
},
{
"-8"
,
"Số điện thoại"
,
"
number
"
},
{
"-8"
,
"Số điện thoại"
,
"
text
"
},
{
"-9"
,
"email"
,
"text"
},
{
"-10"
,
"Tên đăng nhập"
,
"text"
},
{
"-11"
,
"Loại Khách hàng"
,
"
number
"
},
{
"-11"
,
"Loại Khách hàng"
,
"
combobox
"
},
};
for
(
int
x
=
0
;
x
<
11
;
x
++)
{
CustomizeFields
datafill
=
new
CustomizeFields
();
datafill
.
setCustomizeFieldId
(
Long
.
parseLong
(
cf
[
x
][
0
]));
datafill
.
setTitle
(
cf
[
x
][
1
]);
datafill
.
setType
(
cf
[
x
][
2
]);
lstCustomizeFields
.
add
(
datafill
);
}
// try {
// stringBuilder.append(" with column_name_temp as (");
// stringBuilder.append(" select 'CUSTOMER_ID customerId' , from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'CUSTOMER_NAME customerName' , from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'CUSTOMER_TYPE customerType' , from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'NAME name' , from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'CURRENT_ADDRESS currentAddress', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'PLACE_OF_BIRTH placeOfBirth', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'DATE_OF_BIRTH dateOfBirth', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'MOBILE_NUMBER mobileNumber', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'EMAIL email', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'USERNAME username', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'CUSTOMER_TYPE customerType', from user_tab_columns, dual");
// stringBuilder.append(" where table_name = 'CUSTOMER'");
// stringBuilder.append(" )");
//
// stringBuilder.append(" select * from column_name_temp");
// stringBuilder.append(" union all");
// stringBuilder.append(" select title columnName, 0 isFix ");
// stringBuilder.append(" from customize_fields, dual");
// stringBuilder.append(" where function_code = 'CUSTOMER'");
// stringBuilder.append(" and site_id = :p_company_site_id");
// stringBuilder.append(" and STATUS = 1");
// stringBuilder.append(" and active = 1 ");
// params.put("p_company_site_id", customizeFields.getSiteId());
// params.put("p_customer_id", customizeFields.getCustomerId());
// LOGGER.info("SQL statement: " + stringBuilder);
// list = namedParameterJdbcTemplate.query(stringBuilder.toString(), params, BeanPropertyRowMapper.newInstance(CustomizeFielObjectDTO.class));
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
resultDTO
.
setListData
(
lstCustomizeFields
);
...
...
@@ -1934,9 +1902,9 @@ public class CustomerServiceImpl implements CustomerService {
sb
.
append
(
" INNER JOIN CUSTOMIZE_FIELD_OBJECT CFO ON C.CUSTOMER_ID = CFO.OBJECT_ID"
);
sb
.
append
(
" INNER JOIN CUSTOMIZE_FIELDS CF ON CF.CUSTOMIZE_FIELD_ID = CFO.CUSTOMIZE_FIELDS_ID\n"
+
" WHERE 1 = 1"
);
sb
.
append
(
"
and
CFO.STATUS = 1"
);
sb
.
append
(
"
and active
= 1 "
);
sb
.
append
(
"
and
CF.FUNCTION_CODE = 'CUSTOMER' "
);
sb
.
append
(
"
AND
CFO.STATUS = 1"
);
sb
.
append
(
"
AND ACTIVE
= 1 "
);
sb
.
append
(
"
AND
CF.FUNCTION_CODE = 'CUSTOMER' "
);
List
<
CustomerQueryDTO
>
customerDTOList
=
campaignCustomerDTO
.
getListQuery
();
// sb.append(
...
...
@@ -1949,17 +1917,42 @@ public class CustomerServiceImpl implements CustomerService {
// + campaignCustomerDTO.getListQuery().get(i).getOperator() + " "
// + campaignCustomerDTO.getListQuery().get(i).getCondition() + " ");
for
(
CustomerQueryDTO
query
:
customerDTOList
)
{
if
(
query
.
getJoin
()
==
null
)
{
sb
.
append
(
"AND "
);
}
else
{
sb
.
append
(
query
.
getJoin
()
+
" "
);
}
sb
.
append
(
query
.
getField
()
+
" "
);
sb
.
append
(
query
.
getOperator
()
+
" "
);
if
(
"like"
.
equals
(
query
.
getOperator
())
||
"not like"
.
equals
(
query
.
getOperator
()))
{
sb
.
append
(
"%"
+
query
.
getCondition
()
+
"% "
);
}
else
{
sb
.
append
(
query
.
getCondition
());
// if (query.getJoin() == null) {
// sb.append("AND ");
// } else {
// sb.append(query.getJoin() + " ");
// }
// sb.append(query.getField() + " ");
// sb.append(query.getOperator() + " ");
// if ("like".equals(query.getOperator()) || "not like".equals(query.getOperator())) {
// sb.append("%"+ query.getCondition() + "% ");
// } else {
// sb.append(query.getCondition());
// }
// LIKE NOT
if
(
query
.
getField
()
==
-
1
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.CUSTOMER_ID "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"% "
);
}
else
if
(
query
.
getField
()
==
-
2
)
{
sb
.
append
(
query
.
getJoin
()
+
"C.NAME "
+
query
.
getOperator
()
+
" '%"
+
query
.
getCondition
()
+
"% "
);
}
else
if
(
query
.
getField
()
==
-
3
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.COMPANY_NAME "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"% "
);
}
else
if
(
query
.
getField
()
==
-
4
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.GENDER "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"% "
);
}
else
if
(
query
.
getField
()
==
-
5
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.CURRENT_ADDRESS "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"% "
);
}
else
if
(
query
.
getField
()
==
-
6
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.PLACE_OF_BIRTH "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"% "
);
}
else
if
(
query
.
getField
()
==
-
7
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.DATE_OF_BIRTH "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"% "
);
}
else
if
(
query
.
getField
()
==
-
8
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.MOBILE_NUMBER "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"% "
);
}
else
if
(
query
.
getField
()
==
-
9
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.EMAIL "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"%' "
);
}
else
if
(
query
.
getField
()
==
-
10
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.USER_NAME "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"%' "
);
}
else
if
(
query
.
getField
()
==
-
11
)
{
sb
.
append
(
query
.
getJoin
()
+
" C.CUSTOMER_TYPE "
+
query
.
getOperator
()
+
" %"
+
query
.
getCondition
()
+
"% "
);
}
}
...
...
@@ -2006,8 +1999,13 @@ public class CustomerServiceImpl implements CustomerService {
}
return
resultDTO
;
}
private
String
getCodition
(
String
join
,
String
operator
,
String
codition
)
{
// if (operator.equalsIgnoreCase("LIKE") || operator.equalsIgnoreCase("NOT_LIKE")) {
// } else {
// return " " + join + " " + operator + " " + codition + " ";
// }
return
null
;
}
}
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
View file @
cae4f155
...
...
@@ -22,10 +22,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.*
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.nio.file.Files
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -160,12 +162,13 @@ public class ScenarioServiceImpl implements ScenarioService {
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
XSSFWorkbook
buildTemplate
()
{
public
XSSFWorkbook
buildTemplate
()
throws
IOException
{
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
XSSFWorkbook
workbook
=
null
;
try
{
XSSFWorkbook
workbook
=
new
XSSFWorkbook
();
Sheet
sheet
;
Sheet
sheet
;
workbook
=
new
XSSFWorkbook
();
CellStyle
styleTitle
=
WorkBookBuilder
.
buildDefaultStyleTitle
(
workbook
);
CellStyle
styleRowHeader
=
WorkBookBuilder
.
buildDefaultStyleRowHeader
(
workbook
);
CellStyle
styleRow
=
WorkBookBuilder
.
buildDefaultStyleRow
(
workbook
);
...
...
@@ -236,17 +239,20 @@ public class ScenarioServiceImpl implements ScenarioService {
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
return
null
;
}
finally
{
if
(
workbook
!=
null
)
workbook
.
close
();
}
}
@Override
@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"
);
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
StringBuilder
sb
=
new
StringBuilder
();
boolean
isValid
=
true
;
XSSFWorkbook
workbook
=
null
;
try
{
List
<
String
>
fileHeaderList
=
new
ArrayList
<>();
fileHeaderList
.
add
(
BundleUtils
.
getLangString
(
"scenario.template.questionCode"
,
locale
));
...
...
@@ -260,7 +266,9 @@ public class ScenarioServiceImpl implements ScenarioService {
File
file
=
new
File
(
path
);
FileInputStream
fis
=
new
FileInputStream
(
file
);
XSSFWorkbook
workbook
=
new
XSSFWorkbook
(
fis
);
workbook
=
new
XSSFWorkbook
(
fis
);
workbook
=
new
XSSFWorkbook
(
fis
);
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
();
Sheet
sheet
=
workbook
.
getSheetAt
(
0
);
Row
row
=
sheet
.
getRow
(
2
);
...
...
@@ -270,18 +278,26 @@ public class ScenarioServiceImpl implements ScenarioService {
resultFont
.
setFontHeightInPoints
((
short
)
11
);
CellStyle
resultStyle
=
workbook
.
createCellStyle
();
resultStyle
.
setFont
(
resultFont
);
resultStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
resultStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
resultStyle
.
setFillForegroundColor
(
IndexedColors
.
LIGHT_GREEN
.
getIndex
());
resultStyle
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
resultStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
resultStyle
.
setRightBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
resultStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
resultStyle
.
setBottomBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
resultStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
resultStyle
.
setLeftBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
resultStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
resultStyle
.
setTopBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
//</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
)
);
result
.
put
(
"
content"
,
Files
.
readAllBytes
(
file
.
toPath
())
);
result
.
put
(
"
code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
INVALID_FORMAT
);
return
result
;
}
}
...
...
@@ -289,8 +305,8 @@ public class ScenarioServiceImpl implements ScenarioService {
//kt file du lieu rong
if
(
sheet
.
getPhysicalNumberOfRows
()
==
2
)
{
result
.
put
(
"
message"
,
BundleUtils
.
getLangString
(
"customer.noData"
,
locale
));
result
.
put
(
"
file"
,
file
);
result
.
put
(
"
content"
,
Files
.
readAllBytes
(
file
.
toPath
()
));
result
.
put
(
"
code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
EMPTY
);
return
result
;
}
else
{
Cell
resultCell
=
sheet
.
getRow
(
2
).
createCell
(
sheet
.
getRow
(
2
).
getPhysicalNumberOfCells
());
...
...
@@ -385,7 +401,7 @@ public class ScenarioServiceImpl implements ScenarioService {
isValid
=
false
;
}
else
{
// isValid = true;
resultCell
.
setCellValue
(
"Ok"
);
resultCell
.
setCellValue
(
BundleUtils
.
getLangString
(
"ok"
)
);
}
sb
=
new
StringBuilder
();
}
...
...
@@ -397,26 +413,32 @@ public class ScenarioServiceImpl implements ScenarioService {
lstQuestion
.
forEach
(
question
->
{
questionService
.
add
(
question
);
});
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.importSuccess"
,
locale
));
workbook
.
write
(
os
);
os
.
flush
();
os
.
close
();
workbook
.
close
();
result
.
put
(
"content"
,
os
.
toByteArray
());
result
.
put
(
"code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
SUCCESS
);
}
else
{
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.importFailed"
,
locale
));
workbook
.
write
(
os
);
os
.
flush
();
os
.
close
();
workbook
.
close
();
result
.
put
(
"content"
,
os
.
toByteArray
());
result
.
put
(
"code"
,
Constants
.
FILE_UPLOAD_RESP_CODE
.
ERROR
);
}
}
catch
(
Exception
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
);
}
logger
.
info
(
"Import Questions result:"
,
result
);
return
result
;
}
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
().
filter
(
p
->
(
p
.
equals
(
mappingQuestion
)
&&
p
.
equals
(
currentQuestionCode
))).
...
...
src/main/java/com/viettel/campaign/utils/BundleUtils.java
View file @
cae4f155
...
...
@@ -12,7 +12,7 @@ import java.util.ResourceBundle;
*/
public
class
BundleUtils
{
protected
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BundleUtils
.
class
);
private
static
volatile
ResourceBundle
rsConfig
=
null
;
private
static
ResourceBundle
rsConfig
=
null
;
private
static
final
String
GLOBAL_CONFIG
=
"config/globalConfig"
;
public
static
String
getLangString
(
String
key
,
Locale
...
locale
)
{
...
...
src/main/java/com/viettel/campaign/utils/Constants.java
View file @
cae4f155
...
...
@@ -47,4 +47,11 @@ public class Constants {
public
interface
MIME_TYPE
{
String
EXCEL_XLSX
=
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
;
}
public
interface
FILE_UPLOAD_RESP_CODE
{
String
SUCCESS
=
"00"
;
String
ERROR
=
"01"
;
String
INVALID_FORMAT
=
"02"
;
String
EMPTY
=
"03"
;
}
}
src/main/java/com/viettel/campaign/utils/DataUtil.java
View file @
cae4f155
...
...
@@ -127,17 +127,10 @@ public class DataUtil {
}
public
static
boolean
safeEqual
(
Long
obj1
,
Long
obj2
)
{
if
(
obj1
==
obj2
)
{
if
(
obj1
.
equals
(
obj2
)
)
{
return
true
;
}
return
((
obj1
!=
null
)
&&
(
obj2
!=
null
)
&&
(
obj1
.
compareTo
(
obj2
)
==
0
));
}
public
static
boolean
safeEqual
(
String
obj1
,
String
obj2
)
{
if
(
obj1
==
obj2
)
{
return
true
;
}
return
((
obj1
!=
null
)
&&
(
obj2
!=
null
)
&&
obj1
.
equals
(
obj2
));
return
obj2
!=
null
&&
obj1
.
compareTo
(
obj2
)
==
0
;
}
public
static
String
convertDateToStringDDMMYYYYHHMISS
(
Date
datetime
)
{
...
...
src/main/java/com/viettel/campaign/utils/RedisUtil.java
View file @
cae4f155
...
...
@@ -16,7 +16,8 @@ public class RedisUtil {
private
static
final
Logger
logger
=
Logger
.
getLogger
(
RedisUtil
.
class
);
private
static
volatile
RedisUtil
INSTANCE
=
null
;
// private static volatile RedisUtil INSTANCE = null;
private
static
RedisUtil
INSTANCE
=
null
;
private
JedisCluster
jedisCluster
;
private
String
redisAddress
;
private
int
redisTimeout
;
...
...
src/main/java/com/viettel/campaign/utils/WorkBookBuilder.java
View file @
cae4f155
...
...
@@ -4,7 +4,7 @@ import org.apache.poi.ss.usermodel.*;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
/**
* @author anhvd_itsol
* @author anhvd_itsol
0ad5d5fb7aa141b4ac383bcb096e2ec3faba0b1b
*/
public
class
WorkBookBuilder
{
public
static
Font
buildDefaultFont
(
XSSFWorkbook
workbook
)
{
...
...
src/main/java/com/viettel/campaign/web/dto/request_dto/CustomerQueryDTO.java
View file @
cae4f155
...
...
@@ -8,7 +8,7 @@ import lombok.Setter;
@Setter
public
class
CustomerQueryDTO
extends
BaseDTO
{
String
join
;
Stri
ng
field
;
Lo
ng
field
;
String
operator
;
String
condition
;
...
...
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
View file @
cae4f155
...
...
@@ -30,7 +30,10 @@ import java.nio.file.Files;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
@Controller
@RequestMapping
(
"/ipcc/customer"
)
...
...
@@ -194,7 +197,6 @@ public class CustomerController {
@RequestPart
(
"customerListId"
)
String
customerListId
,
HttpServletRequest
request
)
{
LOGGER
.
info
(
"------------IMPORT FILE TEMPLATE--------------"
);
Locale
locale
=
new
Locale
(
"vi"
,
"VN"
);
try
{
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
request
.
getHeader
(
"X-Auth-Token"
));
if
(
file
.
isEmpty
())
{
...
...
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
View file @
cae4f155
...
...
@@ -119,18 +119,11 @@ public class ScenarioController {
}
String
path
=
saveUploadFile
(
file
);
Map
<
String
,
Object
>
map
=
scenarioService
.
readAndValidateCustomer
(
path
,
scenarioId
,
campaignId
,
userSession
.
getCompanySiteId
());
File
fileExport
=
(
File
)
map
.
get
(
"file"
);
String
message
=
(
String
)
map
.
get
(
"message"
);
ResultDTO
resultDTO
=
new
ResultDTO
();
resultDTO
.
setErrorCode
(
"00"
);
resultDTO
.
setDescription
(
message
);
resultDTO
.
setData
(
fileExport
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"Content-Type"
,
Constants
.
MIME_TYPE
.
EXCEL_XLSX
);
headers
.
add
(
"Message"
,
message
);
String
code
=
(
String
)
map
.
get
(
"code"
);
byte
[]
content
=
(
byte
[])
map
.
get
(
"content"
);
return
ResponseEntity
.
ok
()
.
header
s
(
headers
)
.
body
(
Files
.
readAllBytes
(
fileExport
.
toPath
())
);
.
header
(
"Message"
,
code
)
.
body
(
content
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
...
...
src/main/resources/application.yml
View file @
cae4f155
server
:
port
:
1111
port
:
9999
spring
:
application
:
name
:
campaign
...
...
src/main/resources/i18n/language_en.properties
View file @
cae4f155
...
...
@@ -134,3 +134,5 @@ scenario.required.required="Require is required"
scenario.default.required
=
"Default is required"
scenario.mappingQuestion.invalid
=
"Mapping question invalid"
ok
=
"Imported"
error
=
"Error"
src/main/resources/i18n/language_vi.properties
View file @
cae4f155
...
...
@@ -136,6 +136,9 @@ 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ệ"
ok
=
"Thành công"
error
=
"Thất bại"
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