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
c4788ff1
Commit
c4788ff1
authored
Aug 29, 2019
by
Đào Nhật Quang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
aa60b869
3ec149b9
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
425 additions
and
251 deletions
+425
-251
src/main/java/com/viettel/campaign/filter/CorsFilter.java
src/main/java/com/viettel/campaign/filter/CorsFilter.java
+19
-19
src/main/java/com/viettel/campaign/repository/ccms_full/CampaignExecuteRepository.java
...paign/repository/ccms_full/CampaignExecuteRepository.java
+2
-2
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
...pository/ccms_full/impl/CampaignExecuteRepositoryImp.java
+183
-111
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
...ign/repository/ccms_full/impl/CampaignRepositoryImpl.java
+8
-5
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
+5
-1
src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
...ttel/campaign/service/impl/CampaignExecuteServiceImp.java
+12
-3
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+128
-56
src/main/java/com/viettel/campaign/service/impl/ScenarioQuestionServiceImpl.java
...el/campaign/service/impl/ScenarioQuestionServiceImpl.java
+5
-0
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
...om/viettel/campaign/service/impl/ScenarioServiceImpl.java
+9
-8
src/main/java/com/viettel/campaign/web/dto/CampaignCustomerDTO.java
...ava/com/viettel/campaign/web/dto/CampaignCustomerDTO.java
+5
-0
src/main/java/com/viettel/campaign/web/dto/CampaignInformationDTO.java
.../com/viettel/campaign/web/dto/CampaignInformationDTO.java
+1
-0
src/main/java/com/viettel/campaign/web/dto/ContactCusResDTO.java
...n/java/com/viettel/campaign/web/dto/ContactCusResDTO.java
+0
-31
src/main/java/com/viettel/campaign/web/dto/ContactCustResultDTO.java
...va/com/viettel/campaign/web/dto/ContactCustResultDTO.java
+3
-1
src/main/java/com/viettel/campaign/web/dto/CustomizeFieldsDTO.java
...java/com/viettel/campaign/web/dto/CustomizeFieldsDTO.java
+3
-0
src/main/java/com/viettel/campaign/web/dto/request_dto/CustomerQueryDTO.java
...iettel/campaign/web/dto/request_dto/CustomerQueryDTO.java
+1
-0
src/main/java/com/viettel/campaign/web/rest/CampaignExecuteController.java
.../viettel/campaign/web/rest/CampaignExecuteController.java
+6
-2
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
...ava/com/viettel/campaign/web/rest/CustomerController.java
+24
-0
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
...ava/com/viettel/campaign/web/rest/ScenarioController.java
+9
-11
No files found.
src/main/java/com/viettel/campaign/filter/CorsFilter.java
View file @
c4788ff1
...
...
@@ -32,25 +32,25 @@ public class CorsFilter implements Filter {
chain
.
doFilter
(
req
,
response
);
//
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
//
chain.doFilter(req, resp);
//
return;
//
}
//
if ("/".equals(request.getRequestURI())) {
//
chain.doFilter(req, resp);
//
return;
//
}
//
String xAuthToken = request.getHeader("X-Auth-Token");
//
if (xAuthToken == null || "".equals(xAuthToken)) {
//
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null.");
//
return;
//
}
//
Object obj = RedisUtil.getInstance().get(xAuthToken);
//
if (obj instanceof UserSession) {
//
chain.doFilter(req, resp);
//
} else {
//
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid.");
//
}
if
(
"OPTIONS"
.
equalsIgnoreCase
(
request
.
getMethod
()))
{
chain
.
doFilter
(
req
,
resp
);
return
;
}
if
(
"/"
.
equals
(
request
.
getRequestURI
()))
{
chain
.
doFilter
(
req
,
resp
);
return
;
}
String
xAuthToken
=
request
.
getHeader
(
"X-Auth-Token"
);
if
(
xAuthToken
==
null
||
""
.
equals
(
xAuthToken
))
{
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
"The token is null."
);
return
;
}
Object
obj
=
RedisUtil
.
getInstance
().
get
(
xAuthToken
);
if
(
obj
instanceof
UserSession
)
{
chain
.
doFilter
(
req
,
resp
);
}
else
{
response
.
sendError
(
HttpServletResponse
.
SC_UNAUTHORIZED
,
"The token is invalid."
);
}
}
@Override
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/CampaignExecuteRepository.java
View file @
c4788ff1
...
...
@@ -18,9 +18,9 @@ public interface CampaignExecuteRepository {
List
<
ApParamDTO
>
getComboCampaignType
(
String
companySiteId
);
ResultDTO
getInteractiveResult
(
CampaignRequestDTO
dto
);
List
<
ContactCustResultDTO
>
getInteractiveResult
(
CampaignRequestDTO
dto
,
Pageable
pageable
);
List
<
ContactCus
Res
DTO
>
getExcelInteractiveResult
(
CampaignRequestDTO
dto
);
List
<
ContactCus
tResult
DTO
>
getExcelInteractiveResult
(
CampaignRequestDTO
dto
);
List
<
ContactCustResultDTO
>
getContactCustById
(
CampaignRequestDTO
dto
);
//</editor-fold: hungtt>
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
View file @
c4788ff1
...
...
@@ -7,15 +7,18 @@ import com.viettel.campaign.repository.ccms_full.TimeZoneDialModeRepository;
import
com.viettel.campaign.utils.Constants
;
import
com.viettel.campaign.utils.DataUtil
;
import
com.viettel.campaign.utils.HibernateUtil
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.ApParamDTO
;
import
com.viettel.campaign.web.dto.CampaignDTO
;
import
com.viettel.campaign.web.dto.ContactCustResultDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
org.hibernate.SQLQuery
;
import
org.hibernate.Session
;
import
org.hibernate.SessionFactory
;
import
org.hibernate.transform.Transformers
;
import
org.hibernate.type.DateType
;
import
org.hibernate.type.IntegerType
;
import
org.hibernate.type.LongType
;
import
org.hibernate.type.ShortType
;
import
org.hibernate.type.StringType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -100,108 +103,156 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
getInteractiveResult
(
CampaignRequestDTO
dto
)
{
public
List
<
ContactCustResultDTO
>
getInteractiveResult
(
CampaignRequestDTO
dto
,
Pageable
pageable
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
List
<
ContactCus
Res
DTO
>
list
=
new
ArrayList
<>();
List
<
ContactCus
tResult
DTO
>
list
=
new
ArrayList
<>();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
try
{
StringBuilder
sql
=
new
StringBuilder
();
sql
.
append
(
"with campaign_type_list as ("
);
sql
.
append
(
" select trim (regexp_substr(:p_list_compaign_type, '[^,]+', 1, level)) campaign_type"
);
sql
.
append
(
" from dual"
);
sql
.
append
(
" connect by level <= regexp_count(:p_list_compaign_type, ',') +1"
);
sql
.
append
(
" ),"
);
sql
.
append
(
" contact_status_list as ("
);
sql
.
append
(
" select trim (regexp_substr(:p_list_contact_status, '[^,]+', 1, level)) contact_status"
);
sql
.
append
(
" from dual"
);
sql
.
append
(
" connect by level <= regexp_count(:p_list_contact_status, ',') +1"
);
sql
.
append
(
" ),"
);
sql
.
append
(
" survey_status_list as ("
);
sql
.
append
(
" select trim (regexp_substr(:p_list_survey_status, '[^,]+', 1, level)) survey_status"
);
sql
.
append
(
" from dual"
);
sql
.
append
(
" connect by level <= regexp_count(:p_list_survey_status, ',') +1"
);
sql
.
append
(
" ),"
);
sql
.
append
(
" record_status_list as ("
);
sql
.
append
(
" select trim (regexp_substr(:p_list_record_status, '[^,]+', 1, level)) record_status"
);
sql
.
append
(
" from dual"
);
sql
.
append
(
" connect by level <= regexp_count(:p_list_record_status, ',') +1"
);
sql
.
append
(
" ),"
);
sql
.
append
(
" campaign_code_list as ("
);
sql
.
append
(
" select trim (regexp_substr(:p_list_campaign_code, '[^,]+', 1, level)) campaign_code"
);
sql
.
append
(
" from dual"
);
sql
.
append
(
" connect by level <= regexp_count(:p_list_campaign_code, ',') +1"
);
sql
.
append
(
" ),"
);
sql
.
append
(
" data_temp as ("
);
sql
.
append
(
" select a.contact_cust_result_id contactCustResultId,"
);
sql
.
append
(
" a.create_time createTime,"
);
sql
.
append
(
" b.campaign_code campaignCode,"
);
sql
.
append
(
" b.campaign_name campaignName,"
);
sql
.
append
(
" c.user_name userName,"
);
sql
.
append
(
" a.phone_number phoneNumber,"
);
sql
.
append
(
" d.name customerName,"
);
sql
.
append
(
" a.start_call startCall,"
);
sql
.
append
(
" e.complete_name contactStatus,"
);
sql
.
append
(
" f.complete_name surveyStatus,"
);
sql
.
append
(
" g.status status,"
);
sql
.
append
(
" a.status recordStatus,"
);
sql
.
append
(
" nvl((a.end_time - a.start_call)*24*60, 0) callTime"
);
sql
.
append
(
" from contact_cust_result a"
);
sql
.
append
(
" left join campaign b on a.campaign_id = b.campaign_id"
);
sql
.
append
(
" left join vsa_users c on a.agent_id = c.user_id"
);
sql
.
append
(
" left join customer d on a.customer_id = d.customer_id"
);
sql
.
append
(
" left join campaign_complete_code e on a.contact_status = e.complete_value"
);
sql
.
append
(
" left join campaign_complete_code f on a.call_status = e.complete_value"
);
sql
.
append
(
" left join campaign g on a.campaign_id = g.campaign_id"
);
sql
.
append
(
" where a.status <> 0"
);
sql
.
append
(
" and a.company_site_id = :p_company_site_id"
);
sql
.
append
(
" and a.create_time >= to_date(:p_date_from, 'DD/MM/YYYY')"
);
sql
.
append
(
" and a.create_time <= to_date(:p_date_to, 'DD/MM/YYYY')"
);
sql
.
append
(
" and to_char(a.customer_id) like '%'||:p_customer_id||'%'"
);
sql
.
append
(
" and b.campaign_type in (select campaign_type from campaign_type_list)"
);
sql
.
append
(
" and to_char(a.contact_status) in (select contact_status from contact_status_list)"
);
sql
.
append
(
" and to_char(a.call_status) in (select survey_status from survey_status_list)"
);
sql
.
append
(
" and to_char(a.status) in (select record_status from record_status_list)"
);
sql
.
append
(
" and (:p_phone_number is null or to_char(a.phone_number) like '%'||:p_phone_number||'%')"
);
sql
.
append
(
" and (:p_list_campaign_code is null or b.campaign_code in (select campaign_code from campaign_code_list))"
);
sql
.
append
(
" and (:p_campaign_name is null or upper(b.campaign_name) like '%'||:p_campaign_name||'%')"
);
sql
.
append
(
" and (:p_user_name is null or upper(c.user_name) like '%'||:p_user_name||'%')"
);
sql
.
append
(
" ),"
);
sql
.
append
(
" data as ("
);
sql
.
append
(
" select a.*, rownum row_ from data_temp a"
);
sql
.
append
(
" where a.callTime >= :p_call_time_from"
);
sql
.
append
(
" and a.callTime <= :p_call_time_to"
);
sql
.
append
(
" order by a.createTime desc"
);
sql
.
append
(
" ),"
);
sql
.
append
(
" count_total as ("
);
sql
.
append
(
" select count(*) totalRow from data"
);
sql
.
append
(
" )"
);
sql
.
append
(
" select contactCustResultId, createTime, campaignCode, campaignName, userName, phoneNumber, customerName, startCall, contactStatus, surveyStatus, status, recordStatus, callTime, totalRow from data, count_total"
);
sql
.
append
(
" where :p_page_size = 0 or (row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1))"
);
sql
.
append
(
"SELECT CCR.CONTACT_CUST_RESULT_ID AS contactCustResultId, "
);
sql
.
append
(
" CCR.CREATE_TIME AS createTime, "
);
sql
.
append
(
" C.CAMPAIGN_CODE AS campaignCode, "
);
sql
.
append
(
" C.CAMPAIGN_NAME AS campaignName, "
);
sql
.
append
(
" VU.USER_NAME AS userName, "
);
sql
.
append
(
" CCR.PHONE_NUMBER AS phoneNumber, "
);
sql
.
append
(
" CUS.NAME AS customerName, "
);
sql
.
append
(
" CCR.START_CALL AS startCall, "
);
sql
.
append
(
" CC1.COMPLETE_NAME AS contactStatus, "
);
sql
.
append
(
" CC2.COMPLETE_NAME AS surveyStatus, "
);
sql
.
append
(
" C.STATUS AS status, "
);
sql
.
append
(
" CCR.STATUS AS recordStatus, "
);
sql
.
append
(
" (( CCR.END_TIME - CCR.START_CALL ) * 24 * 60 * 60) AS callTime "
);
sql
.
append
(
"FROM CONTACT_CUST_RESULT CCR "
);
sql
.
append
(
" INNER JOIN CAMPAIGN C ON CCR.CAMPAIGN_ID = C.CAMPAIGN_ID "
);
sql
.
append
(
" INNER JOIN VSA_USERS VU ON CCR.AGENT_ID = VU.USER_ID "
);
sql
.
append
(
" INNER JOIN CUSTOMER CUS ON CCR.CUSTOMER_ID = CUS.CUSTOMER_ID "
);
sql
.
append
(
" INNER JOIN CAMPAIGN_COMPLETE_CODE CC1 ON CCR.CONTACT_STATUS = CC1.COMPLETE_VALUE "
);
sql
.
append
(
" LEFT JOIN CAMPAIGN_COMPLETE_CODE CC2 ON CCR.CALL_STATUS = CC2.COMPLETE_VALUE "
);
sql
.
append
(
"WHERE CCR.STATUS <> 0 "
);
sql
.
append
(
" AND CCR.COMPANY_SITE_ID = :p_company_site_id "
);
sql
.
append
(
" AND to_date(CCR.CREATE_TIME, 'DD/MM/RR') >= to_date(:p_date_from, 'DD/MM/RR') "
);
sql
.
append
(
" AND to_date(CCR.CREATE_TIME, 'DD/MM/RR') <= to_date(:p_date_to, 'DD/MM/RR') "
);
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCustomerId
()))
{
sql
.
append
(
" AND CCR.CUSTOMER_ID LIKE (:p_customer_id) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignType
()))
{
sql
.
append
(
" AND C.CAMPAIGN_TYPE IN (:p_list_compaign_type) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getContactStatus
()))
{
sql
.
append
(
" AND CCR.CONTACT_STATUS IN (:p_list_contact_status) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getSurveyStatus
()))
{
sql
.
append
(
" AND CCR.CALL_STATUS IN (:p_list_survey_status) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getRecordStatus
()))
{
sql
.
append
(
" AND CCR.STATUS IN (:p_list_record_status) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignCode
()))
{
sql
.
append
(
" AND C.CAMPAIGN_CODE IN (:p_list_campaign_code) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getPhoneNumber
()))
{
sql
.
append
(
" AND CCR.PHONE_NUMBER LIKE (:p_phone_number) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignName
()))
{
sql
.
append
(
" AND UPPER(C.CAMPAIGN_NAME) LIKE (:p_campaign_name) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getAgentId
()))
{
sql
.
append
(
" AND UPPER(VU.USER_NAME) LIKE (:p_user_name) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCallTimeFrom
()))
{
sql
.
append
(
" AND (( CCR.END_TIME - CCR.START_CALL ) * 24 * 60 * 60) >= (:p_call_time_from) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCallTimeTo
()))
{
sql
.
append
(
" AND (( CCR.END_TIME - CCR.START_CALL ) * 24 * 60 * 60) <= (:p_call_time_to) "
);
}
SQLQuery
query
=
session
.
createSQLQuery
(
sql
.
toString
());
query
.
setParameter
(
"p_company_site_id"
,
dto
.
getCompanySiteId
());
query
.
setParameter
(
"p_customer_id"
,
dto
.
getCustomerId
());
query
.
setParameter
(
"p_date_from"
,
dto
.
getFromDate
());
query
.
setParameter
(
"p_date_to"
,
dto
.
getToDate
());
query
.
setParameter
(
"p_list_compaign_type"
,
dto
.
getCampaignType
());
query
.
setParameter
(
"p_list_contact_status"
,
dto
.
getContactStatus
());
query
.
setParameter
(
"p_list_survey_status"
,
dto
.
getSurveyStatus
());
query
.
setParameter
(
"p_list_record_status"
,
dto
.
getRecordStatus
());
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCustomerId
()))
{
query
.
setParameter
(
"p_customer_id"
,
"%"
+
dto
.
getCustomerId
().
toUpperCase
()
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\\\%"
)
.
replaceAll
(
"_"
,
"\\\\_"
)
+
"%"
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignType
()))
{
String
[]
lstCode
=
dto
.
getCampaignType
().
split
(
","
);
query
.
setParameterList
(
"p_list_compaign_type"
,
lstCode
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getContactStatus
()))
{
String
[]
lstCode
=
dto
.
getContactStatus
().
split
(
","
);
query
.
setParameterList
(
"p_list_contact_status"
,
lstCode
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getSurveyStatus
()))
{
String
[]
lstCode
=
dto
.
getSurveyStatus
().
split
(
","
);
query
.
setParameterList
(
"p_list_survey_status"
,
lstCode
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getRecordStatus
()))
{
String
[]
lstCode
=
dto
.
getRecordStatus
().
split
(
","
);
query
.
setParameterList
(
"p_list_record_status"
,
lstCode
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignCode
()))
{
String
[]
lstCode
=
dto
.
getCampaignCode
().
split
(
","
);
query
.
setParameterList
(
"p_list_campaign_code"
,
lstCode
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getPhoneNumber
()))
{
query
.
setParameter
(
"p_phone_number"
,
"%"
+
dto
.
getPhoneNumber
().
toUpperCase
()
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\\\%"
)
.
replaceAll
(
"_"
,
"\\\\_"
)
+
"%"
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignName
()))
{
query
.
setParameter
(
"p_campaign_name"
,
"%"
+
dto
.
getCampaignName
().
toUpperCase
()
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\\\%"
)
.
replaceAll
(
"_"
,
"\\\\_"
)
+
"%"
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getAgentId
()))
{
query
.
setParameter
(
"p_user_name"
,
"%"
+
dto
.
getAgentId
().
toUpperCase
()
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\\\%"
)
.
replaceAll
(
"_"
,
"\\\\_"
)
+
"%"
);
}
query
.
setParameter
(
"p_call_time_from"
,
dto
.
getCallTimeFrom
());
query
.
setParameter
(
"p_call_time_to"
,
dto
.
getCallTimeTo
());
query
.
setParameter
(
"p_list_campaign_code"
,
dto
.
getCampaignCode
());
query
.
setParameter
(
"p_phone_number"
,
dto
.
getPhoneNumber
());
query
.
setParameter
(
"p_campaign_name"
,
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignName
())
?
null
:
dto
.
getCampaignName
().
trim
().
toUpperCase
());
query
.
setParameter
(
"p_user_name"
,
DataUtil
.
isNullOrEmpty
(
dto
.
getAgentId
())
?
null
:
dto
.
getAgentId
().
trim
().
toUpperCase
());
query
.
setParameter
(
"p_page_number"
,
dto
.
getPage
());
query
.
setParameter
(
"p_page_size"
,
dto
.
getPageSize
());
query
.
addScalar
(
"contactCustResultId"
,
new
LongType
());
// add data to parameter
/*query.addScalar("contactCustResultId", new LongType());
query.addScalar("createTime", new DateType());
query.addScalar("campaignCode", new StringType());
query.addScalar("campaignName", new StringType());
...
...
@@ -211,49 +262,70 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.addScalar("startCall", new DateType());
query.addScalar("contactStatus", new StringType());
query.addScalar("surveyStatus", new StringType());
query
.
addScalar
(
"status"
,
new
S
tring
Type
());
query
.
addScalar
(
"
callTime"
,
new
Long
Type
());
query
.
addScalar
(
"
totalRow"
,
new
IntegerType
());
query.addScalar("status", new S
hort
Type());
query.addScalar("
recordStatus", new Short
Type());
query.addScalar("
callTime", new LongType());*/
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
ContactCusResDTO
.
class
));
int
total
=
0
;
list
=
query
.
list
();
if
(
list
.
size
()
>
0
)
{
total
=
list
.
get
(
0
).
getTotalRow
();
if
(
pageable
!=
null
)
{
query
.
setFirstResult
(
pageable
.
getPageNumber
()
*
pageable
.
getPageSize
());
query
.
setMaxResults
(
pageable
.
getPageSize
());
}
for
(
ContactCusResDTO
contactCusResDTO
:
list
)
{
List
<
Object
[]>
data
=
query
.
list
();
//query.setResultTransformer(Transformers.aliasToBean(ContactCustResultDTO.class));
//list = query.list();
for
(
Object
[]
obj
:
data
)
{
ContactCustResultDTO
item
=
new
ContactCustResultDTO
();
item
.
setPage
(
dto
.
getPage
());
item
.
setPageSize
(
dto
.
getPageSize
());
item
.
setSort
(
dto
.
getSort
());
item
.
setContactCustResultId
(((
BigDecimal
)
obj
[
0
]).
longValueExact
());
item
.
setCreateTime
((
Date
)
obj
[
1
]);
item
.
setCampaignCode
((
String
)
obj
[
2
]);
item
.
setCampaignName
((
String
)
obj
[
3
]);
item
.
setUserName
((
String
)
obj
[
4
]);
item
.
setPhoneNumber
((
String
)
obj
[
5
]);
item
.
setCustomerName
((
String
)
obj
[
6
]);
item
.
setStartCall
(
obj
[
7
]
==
null
?
null
:
(
Date
)
obj
[
7
]);
item
.
setContactStatus
((
String
)
obj
[
8
]);
item
.
setSurveyStatus
((
String
)
obj
[
9
]);
item
.
setStatus
(
obj
[
10
]
==
null
?
0
:
((
BigDecimal
)
obj
[
10
]).
shortValueExact
());
item
.
setRecordStatus
(
obj
[
11
]
==
null
?
0
:
((
BigDecimal
)
obj
[
11
]).
shortValueExact
());
item
.
setCallTime
(
obj
[
12
]
==
null
?
0L
:
((
BigDecimal
)
obj
[
12
]).
longValueExact
());
list
.
add
(
item
);
}
for
(
ContactCustResultDTO
ContactCustResultDTO
:
list
)
{
if
(!
"AGENT"
.
equals
(
dto
.
getRoleUser
()))
{
// ko phải nhân viên
contactCusRes
DTO
.
setEnableEdit
(
true
);
ContactCustResult
DTO
.
setEnableEdit
(
true
);
}
else
{
if
(
"2"
.
equals
(
contactCusRes
DTO
.
getRecordStatus
()))
{
// là nhân viên thường
contactCusRes
DTO
.
setEnableEdit
(
true
);
}
else
if
(
"1"
.
equals
(
contactCusResDTO
.
getRecordStatus
())
&&
isLower24Hour
(
contactCusRes
DTO
.
getCreateTime
()))
{
contactCusRes
DTO
.
setEnableEdit
(
true
);
if
(
"2"
.
equals
(
ContactCustResult
DTO
.
getRecordStatus
()))
{
// là nhân viên thường
ContactCustResult
DTO
.
setEnableEdit
(
true
);
}
else
if
(
"1"
.
equals
(
ContactCustResultDTO
.
getRecordStatus
())
&&
isLower24Hour
(
ContactCustResult
DTO
.
getCreateTime
()))
{
ContactCustResult
DTO
.
setEnableEdit
(
true
);
}
else
{
contactCusRes
DTO
.
setEnableEdit
(
false
);
ContactCustResult
DTO
.
setEnableEdit
(
false
);
}
}
}
resultDTO
.
setListData
(
list
);
resultDTO
.
setTotalRow
(
total
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
return
resultDTO
;
}
return
list
;
}
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
List
<
ContactCus
Res
DTO
>
getExcelInteractiveResult
(
CampaignRequestDTO
dto
)
{
List
<
ContactCus
Res
DTO
>
list
=
new
ArrayList
<>();
public
List
<
ContactCus
tResult
DTO
>
getExcelInteractiveResult
(
CampaignRequestDTO
dto
)
{
List
<
ContactCus
tResult
DTO
>
list
=
new
ArrayList
<>();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
...
...
@@ -360,7 +432,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query
.
addScalar
(
"status"
,
new
StringType
());
query
.
addScalar
(
"callTime"
,
new
LongType
());
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
ContactCus
Res
DTO
.
class
));
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
ContactCus
tResult
DTO
.
class
));
list
=
query
.
list
();
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
View file @
c4788ff1
...
...
@@ -19,7 +19,9 @@ import org.hibernate.transform.Transformers;
import
org.hibernate.type.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.jdbc.core.BeanPropertyRowMapper
;
import
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
;
import
org.springframework.stereotype.Repository
;
...
...
@@ -27,9 +29,10 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.Query
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Repository
public
class
CampaignRepositoryImpl
implements
CampaignRepositoryCustom
{
...
...
@@ -638,7 +641,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"),\n"
+
"data as (\n"
+
"select a.*, rownum row_ from data_temp a\n"
+
"where a.totalCus
List
> 0"
+
"where a.totalCus
Campaign
> 0"
+
"),\n"
+
"count_data as (\n"
+
"select count(*) totalRow from data_temp\n"
+
...
...
src/main/java/com/viettel/campaign/service/CampaignExecuteService.java
View file @
c4788ff1
...
...
@@ -2,6 +2,7 @@ package com.viettel.campaign.service;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
com.viettel.econtact.filter.UserSession
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.stereotype.Service
;
...
...
@@ -37,7 +38,7 @@ public interface CampaignExecuteService {
ResultDTO
getAgentLogout
(
CampaignRequestDTO
dto
);
ResultDTO
callCustomer
(
ContactCustResultDTO
dto
);
ResultDTO
callCustomer
(
ContactCustResultDTO
dto
,
UserSession
userSession
);
ResultDTO
recallCustomer
(
ContactCustResultDTO
dto
);
...
...
src/main/java/com/viettel/campaign/service/CustomerService.java
View file @
c4788ff1
...
...
@@ -61,6 +61,10 @@ public interface CustomerService {
ResultDTO
deleteCustomerFromCampaign
(
CampaignCustomerDTO
campaignCustomerDTO
);
ResultDTO
searchCampaignInformation
(
CampaignCustomerDTO
campaignCustomerDTO
);
ResultDTO
addCustomerToCampaign
(
CampaignCustomerDTO
campaignCustomerDTO
);
// ------------ customer ------------ //
...
...
@@ -86,6 +90,6 @@ public interface CustomerService {
//// List<CustomizeFields> searchCustomize();
ResultDTO
listCustomizeFields
(
CustomizeFieldsDTO
customizeFields
);
ResultDTO
searchCustomizeFields
(
int
page
,
int
pageSize
,
long
companySiteId
,
long
campaignId
,
CustomerQueryDTO
customerQuery
DTO
);
ResultDTO
searchCustomizeFields
(
CampaignCustomerDTO
campaignCustomer
DTO
);
}
src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
View file @
c4788ff1
...
...
@@ -20,6 +20,7 @@ import org.modelmapper.ModelMapper;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -100,11 +101,19 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
searchInteractiveResult
(
CampaignRequestDTO
dto
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
try
{
resultDTO
=
campaignExecuteRepository
.
getInteractiveResult
(
dto
);
List
<
ContactCustResultDTO
>
list
=
campaignExecuteRepository
.
getInteractiveResult
(
dto
,
SQLBuilder
.
buildPageable
(
dto
));
resultDTO
.
setListData
(
list
);
resultDTO
.
setTotalRow
(
campaignExecuteRepository
.
getInteractiveResult
(
dto
,
null
).
size
());
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
return
resultDTO
;
}
...
...
@@ -112,7 +121,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
XSSFWorkbook
exportInteractiveResult
(
CampaignRequestDTO
dto
)
{
Locale
locale
=
Locale
.
forLanguageTag
(
"vi"
);
List
<
ContactCus
Res
DTO
>
list
=
campaignExecuteRepository
.
getExcelInteractiveResult
(
dto
);
List
<
ContactCus
tResult
DTO
>
list
=
campaignExecuteRepository
.
getExcelInteractiveResult
(
dto
);
XSSFWorkbook
workbook
=
new
XSSFWorkbook
();
Sheet
sheet
;
...
...
@@ -519,7 +528,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
}
@Override
public
ResultDTO
callCustomer
(
ContactCustResultDTO
dto
)
{
public
ResultDTO
callCustomer
(
ContactCustResultDTO
dto
,
UserSession
userSession
)
{
ResultDTO
result
=
new
ResultDTO
();
try
{
...
...
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
c4788ff1
...
...
@@ -1664,6 +1664,85 @@ public class CustomerServiceImpl implements CustomerService {
return
resultDTO
;
}
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
searchCampaignInformation
(
CampaignCustomerDTO
campaignCustomerDTO
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
List
<
CampaignInformationDTO
>
list
=
new
ArrayList
<>();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
try
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
" with status_customer as (\n"
+
"select complete_value\n"
+
"from campaign_complete_code\n"
+
"where complete_value <> 4\n"
+
" and is_finish <> 1\n"
+
" and campaign_type = 1\n"
+
" and company_site_id = :p_company_site_id\n"
+
"),\n"
+
"count_customer as (\n"
+
"select campaign_id campaignId,\n"
+
" sum(case\n"
+
" when customer_list_id is null then 1\n"
+
" else 0\n"
+
" end) totalIndividual,\n"
+
" sum(case\n"
+
" when customer_list_id is not null then 1\n"
+
" else 0\n"
+
" end) totalCusInList\n"
+
"from campaign_customer\n"
+
"group by campaign_id\n"
+
")\n"
+
"select a.*, b.customer_number campaignCustomer\n"
+
"from count_customer a\n"
+
"left join campaign b on a.campaignId = b.campaign_id\n"
+
"where a.campaignId = :p_campaign_id"
);
params
.
put
(
"p_campaign_id"
,
campaignCustomerDTO
.
getCampaignId
());
params
.
put
(
"p_company_site_id"
,
campaignCustomerDTO
.
getCompanySiteId
());
list
=
namedParameterJdbcTemplate
.
query
(
sb
.
toString
(),
params
,
BeanPropertyRowMapper
.
newInstance
(
CampaignInformationDTO
.
class
));
if
(
list
.
size
()
>
0
)
{
resultDTO
.
setData
(
list
.
get
(
0
));
}
else
{
resultDTO
.
setData
(
null
);
}
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
return
resultDTO
;
}
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
addCustomerToCampaign
(
CampaignCustomerDTO
campaignCustomerDTO
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
Long
companySiteId
=
campaignCustomerDTO
.
getCompanySiteId
();
Long
campaignId
=
campaignCustomerDTO
.
getCampaignId
();
String
[]
lstCusId
=
campaignCustomerDTO
.
getLstCustomerId
().
split
(
","
);
try
{
for
(
String
cusId
:
lstCusId
)
{
CampaignCustomer
entity
=
new
CampaignCustomer
();
entity
.
setCompanySiteId
(
companySiteId
);
entity
.
setStatus
((
short
)
0
);
entity
.
setCampaignId
(
campaignId
);
entity
.
setCustomerId
(
Long
.
parseLong
(
cusId
));
entity
.
setRecallCount
(
0L
);
entity
.
setInCampaignStatus
((
short
)
1
);
campaignCustomerRepository
.
save
(
entity
);
}
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
return
resultDTO
;
}
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
...
...
@@ -1816,18 +1895,19 @@ public class CustomerServiceImpl implements CustomerService {
@Override
public
ResultDTO
searchCustomizeFields
(
int
page
,
int
pageSize
,
long
SiteId
,
long
campaignId
,
CustomerQueryDTO
customerQueryDTO
)
{
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
searchCustomizeFields
(
CampaignCustomerDTO
campaignCustomerDTO
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
if
(
DataUtil
.
isNullOrZero
(
SiteId
))
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
return
resultDTO
;
}
//
if (DataUtil.isNullOrZero(SiteId)) {
//
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
//
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
//
return resultDTO;
//
}
try
{
...
...
@@ -1844,90 +1924,82 @@ public class CustomerServiceImpl implements CustomerService {
sb
.
append
(
" C.CUSTOMER_TYPE customerType,"
);
sb
.
append
(
" C.COMPANY_NAME companyName,"
);
sb
.
append
(
" C.PLACE_OF_BIRTH placeOfBirth,"
);
sb
.
append
(
" C.CUSTOMER_TYPE customerType,"
);
sb
.
append
(
" C.EMAIL email,"
);
sb
.
append
(
" C.USERNAME username,"
);
sb
.
append
(
" C.NAME name,"
);
sb
.
append
(
" C.MOBILE_NUMBER mobileNumber,"
);
sb
.
append
(
" C.STATUS status,"
);
sb
.
append
(
" C.SITE_ID siteId,"
);
sb
.
append
(
" CF.FUNCTION_CODE functionCode,"
);
sb
.
append
(
" CF
O
.ACTIVE active,"
);
sb
.
append
(
" CF.ACTIVE active,"
);
sb
.
append
(
" CFO.*"
);
sb
.
append
(
"FROM CUSTOMER C"
);
sb
.
append
(
"
FROM CUSTOMER C"
);
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"
);
"
WHERE 1 = 1"
);
sb
.
append
(
" and CFO.STATUS = 1"
);
sb
.
append
(
" and active = 1 "
);
sb
.
append
(
" and CF.FUNCTION_CODE = 'CUSTOMER' "
);
List
<
CustomerQueryDTO
>
queryCustomer
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
queryCustomer
.
size
();
i
++)
{
sb
.
append
(
queryCustomer
.
get
(
i
).
getJoin
()
+
" "
+
queryCustomer
.
get
(
i
).
getOperator
()
+
" "
+
queryCustomer
.
get
(
i
).
getField
()
+
" "
+
queryCustomer
.
get
(
i
).
getCondition
());
List
<
CustomerQueryDTO
>
customerDTOList
=
campaignCustomerDTO
.
getListQuery
();
// sb.append(
// customerDTOList.get(0).getField() + " "
// + customerDTOList.get(0).getOperator() + " "
// + customerDTOList.get(0).getCondition() + " ");
// for (int i = 1; i < campaignCustomerDTO.getListQuery().size(); i++) {
// sb.append(campaignCustomerDTO.getListQuery().get(i).getJoin() + " "
// + campaignCustomerDTO.getListQuery().get(i).getField() + " "
// + 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
());
}
}
SQLQuery
query
=
session
.
createSQLQuery
(
sb
.
toString
());
// query.setParameter("p_company_site_id", companySiteId);
// query.setParameter("p_customer_list_id", customerListId);
//
// if (!DataUtil.isNullOrEmpty(name)) {
// query.setParameter("p_name", "%" +
// name.replace("\\", "\\\\")
// .replaceAll("%", "\\%")
// .replaceAll("_", "\\_")
// + "%");
// }
//
// if (!DataUtil.isNullOrEmpty(mobileNumber)) {
// query.setParameter("p_mobile_number", "%" +
// mobileNumber.replace("\\", "\\\\")
// .replaceAll("%", "\\%")
// .replaceAll("_", "\\_")
// + "%");
// }
//
// if (!DataUtil.isNullOrEmpty(email)) {
// query.setParameter("p_email", "%" +
// email.replace("\\", "\\\\")
// .replaceAll("%", "\\%")
// .replaceAll("_", "\\_")
// + "%");
// }
query
.
addScalar
(
"customerID"
,
new
LongType
());
query
.
addScalar
(
"name"
,
new
StringType
());
query
.
addScalar
(
"username"
,
new
StringType
());
query
.
addScalar
(
"customerId"
,
new
LongType
());
query
.
addScalar
(
"name"
,
new
StringType
());
query
.
addScalar
(
"
description
"
,
new
StringType
());
query
.
addScalar
(
"
userName
"
,
new
StringType
());
query
.
addScalar
(
"companyName"
,
new
StringType
());
query
.
addScalar
(
"customerType"
,
new
Stri
ngType
());
query
.
addScalar
(
"customerType"
,
new
Lo
ngType
());
query
.
addScalar
(
"currentAddress"
,
new
StringType
());
query
.
addScalar
(
"mobileNumber"
,
new
StringType
());
query
.
addScalar
(
"email"
,
new
StringType
());
query
.
addScalar
(
"placeOfBirth"
,
new
StringType
());
query
.
addScalar
(
"dateOfBirth"
,
new
DateType
());
query
.
addScalar
(
"status"
,
new
ShortType
());
query
.
addScalar
(
"siteId"
,
new
LongType
());
query
.
addScalar
(
"active"
,
new
StringType
());
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
CampaignCustomerDTO
.
class
));
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
CustomizeRequestDTo
.
class
));
int
count
=
0
;
List
<
C
ustomerCustom
DTO
>
dtoList
=
query
.
list
();
List
<
C
ampaignCustomer
DTO
>
dtoList
=
query
.
list
();
if
(
dtoList
.
size
()
>
0
)
{
count
=
query
.
list
().
size
();
}
Pageable
pageable
=
PageRequest
.
of
(
page
,
pageSize
);
Pageable
pageable
=
PageRequest
.
of
(
campaignCustomerDTO
.
getPage
(),
campaignCustomerDTO
.
getPageSize
()
);
if
(
pageable
!=
null
)
{
query
.
setFirstResult
(
pageable
.
getPageNumber
()
*
pageable
.
getPageSize
());
query
.
setMaxResults
(
pageable
.
getPageSize
());
}
List
<
C
ustomerCustom
DTO
>
data
=
query
.
list
();
Page
<
C
ustomerCustom
DTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
List
<
C
ampaignCustomer
DTO
>
data
=
query
.
list
();
Page
<
C
ampaignCustomer
DTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
resultDTO
.
setData
(
dataPage
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
...
...
src/main/java/com/viettel/campaign/service/impl/ScenarioQuestionServiceImpl.java
View file @
c4788ff1
...
...
@@ -239,6 +239,8 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
return
resultDTO
;
}
try
{
scenarioQuestionDTO
.
setCode
(
scenarioQuestionDTO
.
getCode
().
trim
());
scenarioQuestionDTO
.
setQuestion
(
scenarioQuestionDTO
.
getQuestion
().
trim
());
ScenarioQuestion
scenarioQuestion
=
modelMapper
.
map
(
scenarioQuestionDTO
,
ScenarioQuestion
.
class
);
if
(
scenarioQuestion
.
getScenarioQuestionId
()
!=
null
)
{
...
...
@@ -271,6 +273,8 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
campaignLogAnswer
.
setCampaignId
(
scenarioQuestion
.
getCampaignId
());
if
(
item
.
getScenarioAnswerId
()
!=
null
)
{
item
.
setCode
(
item
.
getCode
().
trim
());
item
.
setAnswer
(
item
.
getAnswer
().
trim
());
ScenarioAnswer
answer
=
modelMapper
.
map
(
item
,
ScenarioAnswer
.
class
);
scenarioAnswerRepository
.
save
(
answer
);
campaignLogAnswer
.
setCustomerId
(
answer
.
getScenarioAnswerId
());
...
...
@@ -281,6 +285,7 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
item
.
setScenarioQuestionId
(
scenarioQuestion
.
getScenarioQuestionId
());
item
.
setCreateTime
(
new
Date
());
item
.
setStatus
((
short
)
1
);
item
.
setAnswer
(
item
.
getAnswer
().
trim
());
ScenarioAnswer
answer
=
modelMapper
.
map
(
item
,
ScenarioAnswer
.
class
);
scenarioAnswerRepository
.
save
(
answer
);
campaignLogAnswer
.
setCustomerId
(
answer
.
getScenarioAnswerId
());
...
...
src/main/java/com/viettel/campaign/service/impl/ScenarioServiceImpl.java
View file @
c4788ff1
...
...
@@ -72,6 +72,9 @@ public class ScenarioServiceImpl implements ScenarioService {
public
ResultDTO
update
(
ScenarioDTO
scenarioDTO
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
try
{
scenarioDTO
.
setCode
(
scenarioDTO
.
getCode
().
trim
());
if
(
scenarioDTO
.
getDescription
()
!=
null
)
scenarioDTO
.
setDescription
(
scenarioDTO
.
getDescription
().
trim
());
else
scenarioDTO
.
setDescription
(
""
);
scenarioDTO
.
setUpdateBy
(
null
);
scenarioDTO
.
setUpdateTime
(
new
Date
());
...
...
@@ -368,8 +371,8 @@ public class ScenarioServiceImpl implements ScenarioService {
if
(
rawDataList
.
get
(
i
)[
4
]
==
null
&&
rawDataList
.
get
(
i
)[
4
].
toString
().
trim
().
equals
(
""
))
{
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.hashInput.required"
));
}
if
((
rawDataList
.
get
(
i
)[
7
]
!=
null
&&
!
rawDataList
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
""
)))
{
if
((
rawDataList
.
get
(
i
)[
7
].
toString
().
trim
().
equals
(
tmpCurrentQuestionCode
))
||
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
))
sb
.
append
(
BundleUtils
.
getLangString
(
"scenario.mappingQuestion.invalid"
));
}
...
...
@@ -390,17 +393,15 @@ public class ScenarioServiceImpl implements ScenarioService {
//insert data
if
(
isValid
)
{
logger
.
info
(
"----- Data valid, start import scenario question -----"
);
List
<
ScenarioQuestionDTO
>
lstQuestion
=
buildQuestionsLst
(
rawDataList
,
scenarioId
,
campaignId
,
companySiteId
);
lstQuestion
.
forEach
(
question
->
{
//
questionService.add(question);
questionService
.
add
(
question
);
});
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
result
.
put
(
"message"
,
BundleUtils
.
getLangString
(
"customer.importSuccess"
,
locale
));
}
else
{
logger
.
info
(
"----- Data invalid, can't import scenario question -----"
);
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
workbook
.
write
(
fos
);
result
.
put
(
"file"
,
file
);
...
...
@@ -415,12 +416,12 @@ public class ScenarioServiceImpl implements ScenarioService {
}
private
boolean
validateMappingQuestion
(
String
mappingQuestion
,
String
currentQuestionCode
,
List
<
String
>
lstQuestionCode
)
{
if
(
mappingQuestion
==
currentQuestionCode
)
return
false
;
if
(
mappingQuestion
==
currentQuestionCode
)
return
false
;
String
duplicateCode
=
lstQuestionCode
.
stream
().
filter
(
p
->
(
p
.
equals
(
mappingQuestion
)
&&
p
.
equals
(
currentQuestionCode
))).
findAny
().
orElse
(
null
);
if
(
duplicateCode
==
null
)
return
false
;
if
(
duplicateCode
==
null
)
return
false
;
// String notMappedCode = lstQuestionCode.stream().filter(p -> (!p.equals(mappingQuestion))).findAny().orElse(null);
// if(notMappedCode != null) return false;
...
...
src/main/java/com/viettel/campaign/web/dto/CampaignCustomerDTO.java
View file @
c4788ff1
package
com.viettel.campaign.web.dto
;
import
com.viettel.campaign.web.dto.request_dto.CustomerQueryDTO
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.Date
;
import
java.util.List
;
@Getter
@Setter
...
...
@@ -27,4 +29,7 @@ public class CampaignCustomerDTO extends BaseDTO{
private
Long
companySiteId
;
private
Long
complainId
;
private
String
lstCustomerId
;
private
List
<
CustomerQueryDTO
>
listQuery
;
}
src/main/java/com/viettel/campaign/web/dto/CampaignInformationDTO.java
View file @
c4788ff1
...
...
@@ -16,4 +16,5 @@ public class CampaignInformationDTO {
private
Long
totalNotCall
;
private
Long
campaignCustomer
;
private
Long
customerListId
;
private
Long
totalCusInList
;
}
src/main/java/com/viettel/campaign/web/dto/ContactCusResDTO.java
deleted
100644 → 0
View file @
aa60b869
package
com.viettel.campaign.web.dto
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
//import java.io.Serializable;
import
java.util.Date
;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public
class
ContactCusResDTO
{
private
Long
contactCustResultId
;
private
String
campaignCode
;
private
String
campaignName
;
private
String
userName
;
private
String
phoneNumber
;
private
String
customerName
;
private
Date
startCall
;
private
Date
createTime
;
private
String
contactStatus
;
private
String
surveyStatus
;
private
String
status
;
private
String
recordStatus
;
private
Long
callTime
;
private
Boolean
enableEdit
;
private
Integer
totalRow
;
}
src/main/java/com/viettel/campaign/web/dto/ContactCustResultDTO.java
View file @
c4788ff1
...
...
@@ -14,7 +14,7 @@ public class ContactCustResultDTO extends BaseDTO {
private
Long
contactCustResultId
;
private
Long
companySiteId
;
private
Short
callStatus
;
private
S
hort
contactStatus
;
private
S
tring
contactStatus
;
private
Short
status
;
private
Integer
satisfaction
;
private
String
description
;
...
...
@@ -53,4 +53,6 @@ public class ContactCustResultDTO extends BaseDTO {
private
String
userName
;
private
String
surveyStatus
;
private
Boolean
enableEdit
;
private
Integer
totalRow
;
}
src/main/java/com/viettel/campaign/web/dto/CustomizeFieldsDTO.java
View file @
c4788ff1
package
com.viettel.campaign.web.dto
;
import
com.viettel.campaign.web.dto.request_dto.CustomerQueryDTO
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.Date
;
import
java.util.List
;
@Getter
@Setter
...
...
@@ -29,4 +31,5 @@ public class CustomizeFieldsDTO extends BaseDTO {
private
Long
min
;
private
Long
max
;
private
Long
active
;
}
src/main/java/com/viettel/campaign/web/dto/request_dto/CustomerQueryDTO.java
View file @
c4788ff1
...
...
@@ -11,4 +11,5 @@ public class CustomerQueryDTO extends BaseDTO {
String
field
;
String
operator
;
String
condition
;
}
src/main/java/com/viettel/campaign/web/rest/CampaignExecuteController.java
View file @
c4788ff1
package
com.viettel.campaign.web.rest
;
import
com.viettel.campaign.service.CampaignExecuteService
;
import
com.viettel.campaign.utils.RedisUtil
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
com.viettel.econtact.filter.UserSession
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -134,8 +136,10 @@ public class CampaignExecuteController {
@PostMapping
(
"/callCustomer"
)
@ResponseBody
public
ResponseEntity
<
ResultDTO
>
callCustomer
(
@RequestBody
ContactCustResultDTO
requestDto
)
{
ResultDTO
result
=
campaignExecuteService
.
callCustomer
(
requestDto
);
public
ResponseEntity
<
ResultDTO
>
callCustomer
(
@RequestBody
ContactCustResultDTO
requestDto
,
HttpServletRequest
request
)
{
String
xAuthToken
=
request
.
getHeader
(
"X-Auth-Token"
);
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
xAuthToken
);
ResultDTO
result
=
campaignExecuteService
.
callCustomer
(
requestDto
,
userSession
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
...
...
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
View file @
c4788ff1
...
...
@@ -10,6 +10,7 @@ import com.viettel.campaign.utils.Config;
import
com.viettel.campaign.utils.Constants
;
import
com.viettel.campaign.utils.RedisUtil
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.request_dto.CustomerQueryDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo
;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
...
...
@@ -245,6 +246,20 @@ public class CustomerController {
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
}
@PostMapping
(
"/searchCampaignInformation"
)
@ResponseBody
public
ResponseEntity
<?>
searchCampaignInformation
(
@RequestBody
CampaignCustomerDTO
dto
)
{
ResultDTO
resultDTO
=
customerService
.
searchCampaignInformation
(
dto
);
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
}
@PostMapping
(
"/addCustomerToCampaign"
)
@ResponseBody
public
ResponseEntity
<?>
addCustomerToCampaign
(
@RequestBody
CampaignCustomerDTO
dto
)
{
ResultDTO
resultDTO
=
customerService
.
addCustomerToCampaign
(
dto
);
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
}
private
String
saveUploadFile
(
MultipartFile
file
)
{
...
...
@@ -293,4 +308,13 @@ public class CustomerController {
ResultDTO
resultDTO
=
customerService
.
listCustomizeFields
(
customizeRequestDTo
);
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
}
@PostMapping
(
"/searchCustomizeFields"
)
@ResponseBody
public
ResponseEntity
searchCustomizeFields
(
@RequestBody
CampaignCustomerDTO
campaignCustomerDTO
)
{
ResultDTO
result
=
customerService
.
searchCustomizeFields
(
campaignCustomerDTO
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
src/main/java/com/viettel/campaign/web/rest/ScenarioController.java
View file @
c4788ff1
...
...
@@ -121,20 +121,18 @@ public class ScenarioController {
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
(
Constants
.
ApiErrorCode
.
SUCCESS
);
ResultDTO
resultDTO
=
new
ResultDTO
();
resultDTO
.
setErrorCode
(
"00"
);
resultDTO
.
setDescription
(
message
);
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=import_scenario_result.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
resultDTO
.
setData
(
fileExport
);
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"Content-Type"
,
Constants
.
MIME_TYPE
.
EXCEL_XLSX
);
headers
.
add
(
"Message"
,
message
);
return
ResponseEntity
.
ok
()
.
headers
(
headers
)
.
body
(
Files
.
readAllBytes
(
fileExport
.
toPath
()));
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
ResultDTO
resultDTO
=
new
ResultDTO
();
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
}
...
...
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