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
b2e6cdb5
Commit
b2e6cdb5
authored
Aug 17, 2019
by
=
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hungtt-commit reallocation customer
parent
9ed37467
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
229 deletions
+104
-229
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
...pository/ccms_full/impl/CampaignExecuteRepositoryImp.java
+39
-205
src/main/resources/sql/campaign-execute/get-execute-interactive.sql
...esources/sql/campaign-execute/get-execute-interactive.sql
+65
-24
No files found.
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
View file @
b2e6cdb5
...
...
@@ -6,27 +6,16 @@ import com.viettel.campaign.repository.ccms_full.TimeRangeDialModeRepository;
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.utils.SQLBuilder
;
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.LongType
;
import
org.hibernate.type.ShortType
;
import
org.hibernate.type.StringType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
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
;
...
...
@@ -100,124 +89,35 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
public
ResultDTO
getInteractiveResult
(
CampaignRequestDTO
dto
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
List
<
ContactCustResultDTO
>
list
=
new
ArrayList
<>();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
StringBuilder
sqlBuilder
=
new
StringBuilder
();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
try
{
String
sql
=
SQLBuilder
.
getSqlQueryById
(
Constants
.
SQL_MODULES
.
MODULE_EXECUTE
,
"get-execute-interactive"
);
sqlBuilder
.
append
(
sql
);
sqlBuilder
.
append
(
" and b.campaign_type in (:p_list_compaign_type)"
);
sqlBuilder
.
append
(
" and to_char(a.customer_id) like :p_customer_id"
);
sqlBuilder
.
append
(
" and to_char(a.contact_status) in (:p_list_contact_status)"
);
sqlBuilder
.
append
(
" and to_char(a.call_status) in (:p_list_survey_status)"
);
sqlBuilder
.
append
(
" and to_char(a.status) in (:p_list_record_status)"
);
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getPhoneNumber
()))
{
sqlBuilder
.
append
(
" and a.phone_number like :p_phone_number"
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignId
()))
{
sqlBuilder
.
append
(
" and b.campaign_code in (:p_list_campaign_id) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignName
()))
{
sqlBuilder
.
append
(
" and upper(b.campaign_name) like :p_campaign_name"
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getAgentId
()))
{
sqlBuilder
.
append
(
" and upper(c.user_name) like :p_user_name"
);
}
SQLQuery
query
=
session
.
createSQLQuery
(
sqlBuilder
.
toString
());
query
.
setParameter
(
"p_company_site_id"
,
dto
.
getCompanySiteId
());
query
.
setParameter
(
"p_customer_id"
,
"%"
+
dto
.
getCustomerId
()
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"_"
,
"\\_"
)
+
"%"
);
query
.
setParameter
(
"p_date_from"
,
dto
.
getFromDate
());
query
.
setParameter
(
"p_date_to"
,
dto
.
getToDate
());
query
.
setParameterList
(
"p_list_compaign_type"
,
dto
.
getCampaignType
().
split
(
","
));
query
.
setParameterList
(
"p_list_contact_status"
,
dto
.
getContactStatus
().
split
(
","
));
query
.
setParameterList
(
"p_list_survey_status"
,
dto
.
getSurveyStatus
().
split
(
","
));
query
.
setParameterList
(
"p_list_record_status"
,
dto
.
getRecordStatus
().
split
(
","
));
query
.
setParameter
(
"p_call_time_from"
,
dto
.
getCallTimeFrom
());
query
.
setParameter
(
"p_call_time_to"
,
dto
.
getCallTimeTo
());
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignId
()))
{
query
.
setParameterList
(
"p_list_campaign_id"
,
dto
.
getCampaignId
().
split
(
","
));
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getPhoneNumber
()))
{
query
.
setParameter
(
"p_phone_number"
,
"%"
+
dto
.
getPhoneNumber
()
.
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
.
addScalar
(
"campaignCode"
,
new
StringType
());
query
.
addScalar
(
"campaignName"
,
new
StringType
());
query
.
addScalar
(
"userName"
,
new
StringType
());
query
.
addScalar
(
"phoneNumber"
,
new
StringType
());
query
.
addScalar
(
"customerName"
,
new
StringType
());
query
.
addScalar
(
"createTime"
,
new
DateType
());
query
.
addScalar
(
"contactStatus"
,
new
StringType
());
query
.
addScalar
(
"surveyStatus"
,
new
StringType
());
query
.
addScalar
(
"status"
,
new
ShortType
());
query
.
addScalar
(
"recordStatus"
,
new
ShortType
());
query
.
addScalar
(
"callTime"
,
new
LongType
());
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
ContactCustResultDTO
.
class
));
int
count
=
0
;
list
=
query
.
list
();
if
(
list
.
size
()
>
0
)
{
count
=
list
.
size
();
}
Pageable
pageable
=
SQLBuilder
.
buildPageable
(
dto
);
if
(
pageable
!=
null
)
{
query
.
setFirstResult
(
pageable
.
getPageNumber
()
*
pageable
.
getPageSize
());
query
.
setMaxResults
(
pageable
.
getPageSize
());
}
List
<
ContactCustResultDTO
>
data
=
query
.
list
();
for
(
ContactCustResultDTO
contactCustResultDTO
:
data
)
{
if
(!
"AGENT"
.
equals
(
dto
.
getRoleUser
()))
{
contactCustResultDTO
.
setEnableEdit
(
true
);
}
else
{
if
(
contactCustResultDTO
.
getRecordStatus
()
==
2
)
{
contactCustResultDTO
.
setEnableEdit
(
true
);
}
else
if
(
contactCustResultDTO
.
getRecordStatus
()
==
1
&&
isLower24Hour
(
contactCustResultDTO
.
getCreateTime
()))
{
contactCustResultDTO
.
setEnableEdit
(
true
);
}
else
{
contactCustResultDTO
.
setEnableEdit
(
false
);
}
}
}
Page
<
ContactCustResultDTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
resultDTO
.
setData
(
dataPage
);
params
.
put
(
"p_company_site_id"
,
dto
.
getCompanySiteId
());
params
.
put
(
"p_customer_id"
,
dto
.
getCustomerId
());
params
.
put
(
"p_date_from"
,
dto
.
getFromDate
());
params
.
put
(
"p_date_to"
,
dto
.
getToDate
());
params
.
put
(
"p_list_compaign_type"
,
dto
.
getCampaignType
());
params
.
put
(
"p_list_contact_status"
,
dto
.
getContactStatus
());
params
.
put
(
"p_list_survey_status"
,
dto
.
getSurveyStatus
());
params
.
put
(
"p_list_record_status"
,
dto
.
getRecordStatus
());
params
.
put
(
"p_call_time_from"
,
dto
.
getCallTimeFrom
());
params
.
put
(
"p_list_campaign_id"
,
dto
.
getCallTimeTo
());
params
.
put
(
"p_phone_number"
,
dto
.
getPhoneNumber
());
params
.
put
(
"p_campaign_name"
,
dto
.
getCampaignName
().
toUpperCase
());
params
.
put
(
"p_user_name"
,
dto
.
getAgentId
().
toUpperCase
());
params
.
put
(
"p_page_number"
,
dto
.
getPage
().
toString
());
params
.
put
(
"p_page_size"
,
dto
.
getPageSize
().
toString
());
list
=
namedParameterJdbcTemplate
.
query
(
sql
,
params
,
BeanPropertyRowMapper
.
newInstance
(
ContactCustResultDTO
.
class
));
resultDTO
.
setListData
(
list
);
resultDTO
.
setTotalRow
(
list
.
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
);
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
session
.
close
();
return
resultDTO
;
}
}
...
...
@@ -225,95 +125,29 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
@Override
public
List
<
ContactCustResultDTO
>
getExcelInteractiveResult
(
CampaignRequestDTO
dto
)
{
List
<
ContactCustResultDTO
>
list
=
new
ArrayList
<>();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
StringBuilder
sqlBuilder
=
new
StringBuilder
();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
try
{
String
sql
=
SQLBuilder
.
getSqlQueryById
(
Constants
.
SQL_MODULES
.
MODULE_EXECUTE
,
"get-execute-interactive"
);
sqlBuilder
.
append
(
sql
);
sqlBuilder
.
append
(
" and b.campaign_type in (:p_list_compaign_type)"
);
sqlBuilder
.
append
(
" and to_char(a.customer_id) like :p_customer_id"
);
sqlBuilder
.
append
(
" and to_char(a.contact_status) in (:p_list_contact_status)"
);
sqlBuilder
.
append
(
" and to_char(a.call_status) in (:p_list_survey_status)"
);
sqlBuilder
.
append
(
" and to_char(a.status) in (:p_list_record_status)"
);
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getPhoneNumber
()))
{
sqlBuilder
.
append
(
" and a.phone_number like :p_phone_number"
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignId
()))
{
sqlBuilder
.
append
(
" and b.campaign_code in (:p_list_campaign_id) "
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignName
()))
{
sqlBuilder
.
append
(
" and upper(b.campaign_name) like :p_campaign_name"
);
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getAgentId
()))
{
sqlBuilder
.
append
(
" and upper(c.user_name) like :p_user_name"
);
}
SQLQuery
query
=
session
.
createSQLQuery
(
sqlBuilder
.
toString
());
query
.
setParameter
(
"p_company_site_id"
,
dto
.
getCompanySiteId
());
query
.
setParameter
(
"p_customer_id"
,
"%"
+
dto
.
getCustomerId
()
.
replace
(
"\\"
,
"\\\\"
)
.
replaceAll
(
"%"
,
"\\%"
)
.
replaceAll
(
"_"
,
"\\_"
)
+
"%"
);
query
.
setParameter
(
"p_date_from"
,
dto
.
getFromDate
());
query
.
setParameter
(
"p_date_to"
,
dto
.
getToDate
());
query
.
setParameterList
(
"p_list_compaign_type"
,
dto
.
getCampaignType
().
split
(
","
));
query
.
setParameterList
(
"p_list_contact_status"
,
dto
.
getContactStatus
().
split
(
","
));
query
.
setParameterList
(
"p_list_survey_status"
,
dto
.
getSurveyStatus
().
split
(
","
));
query
.
setParameterList
(
"p_list_record_status"
,
dto
.
getRecordStatus
().
split
(
","
));
query
.
setParameter
(
"p_call_time_from"
,
dto
.
getCallTimeFrom
());
query
.
setParameter
(
"p_call_time_to"
,
dto
.
getCallTimeTo
());
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getCampaignId
()))
{
query
.
setParameterList
(
"p_list_campaign_id"
,
dto
.
getCampaignId
().
split
(
","
));
}
if
(!
DataUtil
.
isNullOrEmpty
(
dto
.
getPhoneNumber
()))
{
query
.
setParameter
(
"p_phone_number"
,
"%"
+
dto
.
getPhoneNumber
()
.
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
.
addScalar
(
"campaignCode"
,
new
StringType
());
query
.
addScalar
(
"campaignName"
,
new
StringType
());
query
.
addScalar
(
"userName"
,
new
StringType
());
query
.
addScalar
(
"phoneNumber"
,
new
StringType
());
query
.
addScalar
(
"customerName"
,
new
StringType
());
query
.
addScalar
(
"createTime"
,
new
DateType
());
query
.
addScalar
(
"contactStatus"
,
new
StringType
());
query
.
addScalar
(
"surveyStatus"
,
new
StringType
());
query
.
addScalar
(
"status"
,
new
ShortType
());
query
.
addScalar
(
"recordStatus"
,
new
ShortType
());
query
.
addScalar
(
"callTime"
,
new
LongType
());
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
ContactCustResultDTO
.
class
));
list
=
query
.
list
();
params
.
put
(
"p_company_site_id"
,
dto
.
getCompanySiteId
());
params
.
put
(
"p_customer_id"
,
dto
.
getCustomerId
());
params
.
put
(
"p_date_from"
,
dto
.
getFromDate
());
params
.
put
(
"p_date_to"
,
dto
.
getToDate
());
params
.
put
(
"p_list_compaign_type"
,
dto
.
getCampaignType
());
params
.
put
(
"p_list_contact_status"
,
dto
.
getContactStatus
());
params
.
put
(
"p_list_survey_status"
,
dto
.
getSurveyStatus
());
params
.
put
(
"p_list_record_status"
,
dto
.
getRecordStatus
());
params
.
put
(
"p_call_time_from"
,
dto
.
getCallTimeFrom
());
params
.
put
(
"p_list_campaign_id"
,
dto
.
getCallTimeTo
());
params
.
put
(
"p_phone_number"
,
dto
.
getPhoneNumber
());
params
.
put
(
"p_campaign_name"
,
dto
.
getCampaignName
().
toUpperCase
());
params
.
put
(
"p_user_name"
,
dto
.
getAgentId
().
toUpperCase
());
params
.
put
(
"p_page_number"
,
dto
.
getPage
().
toString
());
params
.
put
(
"p_page_size"
,
"0"
);
list
=
namedParameterJdbcTemplate
.
query
(
sql
,
params
,
BeanPropertyRowMapper
.
newInstance
(
ContactCustResultDTO
.
class
));
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
session
.
close
();
return
list
;
}
}
...
...
src/main/resources/sql/campaign-execute/get-execute-interactive.sql
View file @
b2e6cdb5
select
b
.
campaign_code
campaignCode
,
with
campaign_type_list
as
(
select
trim
(
regexp_substr
(:
p_list_compaign_type
,
'[^,]+'
,
1
,
level
))
campaign_type
from
dual
connect
by
level
<=
regexp_count
(:
p_list_compaign_type
,
','
)
+
1
),
contact_status_list
as
(
select
trim
(
regexp_substr
(:
p_list_contact_status
,
'[^,]+'
,
1
,
level
))
contact_status
from
dual
connect
by
level
<=
regexp_count
(:
p_list_contact_status
,
','
)
+
1
),
survey_status_list
as
(
select
trim
(
regexp_substr
(:
p_list_survey_status
,
'[^,]+'
,
1
,
level
))
survey_status
from
dual
connect
by
level
<=
regexp_count
(:
p_list_survey_status
,
','
)
+
1
),
record_status_list
as
(
select
trim
(
regexp_substr
(:
p_list_record_status
,
'[^,]+'
,
1
,
level
))
record_status
from
dual
connect
by
level
<=
regexp_count
(:
p_list_record_status
,
','
)
+
1
),
campaign_id_list
as
(
select
trim
(
regexp_substr
(:
p_list_campaign_id
,
'[^,]+'
,
1
,
level
))
campaign_id
from
dual
connect
by
level
<=
regexp_count
(:
p_list_campaign_id
,
','
)
+
1
),
data_temp
as
(
select
b
.
campaign_code
campaignCode
,
b
.
campaign_name
campaignName
,
c
.
user_name
userName
,
a
.
phone_number
phoneNumber
,
...
...
@@ -9,16 +35,31 @@ select b.campaign_code campaignCode,
g
.
status
status
,
a
.
status
recordStatus
,
(
a
.
end_time
-
a
.
start_call
)
*
24
*
60
callTime
from
contact_cust_result
a
from
contact_cust_result
a
left
join
campaign
b
on
a
.
campaign_id
=
b
.
campaign_id
left
join
vsa_users
c
on
a
.
agent_id
=
c
.
user_id
left
join
customer
d
on
a
.
customer_id
=
d
.
customer_id
left
join
campaign_complete_code
e
on
a
.
contact_status
=
e
.
complete_value
left
join
campaign_complete_code
f
on
a
.
call_status
=
e
.
complete_value
left
join
campaign
g
on
a
.
campaign_id
=
g
.
campaign_id
where
a
.
status
<>
0
where
a
.
status
<>
0
and
a
.
company_site_id
=
:
p_company_site_id
and
a
.
create_time
>=
to_date
(:
p_date_from
,
'DD/MM/YYYY'
)
and
a
.
create_time
<=
to_date
(:
p_date_to
,
'DD/MM/YYYY'
)
and
a
.
duration_call
>=
:
p_call_time_from
and
a
.
duration_call
<=
:
p_call_time_to
and
to_char
(
a
.
customer_id
)
like
'%'
||
:
p_customer_id
||
'%'
and
b
.
campaign_type
in
(
select
campaign_type
from
campaign_type_list
)
and
to_char
(
a
.
contact_status
)
in
(
select
contact_status
from
contact_status_list
)
and
to_char
(
a
.
call_status
)
in
(
select
survey_status
from
survey_status_list
)
and
to_char
(
a
.
status
)
in
(
select
record_status
from
record_status_list
)
and
(:
p_phone_number
is
null
or
to_char
(
a
.
phone_number
)
like
'%'
||
:
p_phone_number
||
'%'
)
and
(:
p_list_campaign_id
is
null
or
b
.
campaign_code
in
(
select
campaign_id
from
campaign_id_list
))
and
(:
p_campaign_name
is
null
or
upper
(
b
.
campaign_name
)
like
'%'
||
:
p_campaign_name
||
'%'
)
and
(:
p_user_name
is
null
or
upper
(
c
.
user_name
)
like
'%'
||
:
p_user_name
||
'%'
)
),
data
as
(
select
a
.
*
,
rownum
row_
from
data_temp
a
)
select
*
from
data
where
:
p_page_size
=
0
or
(
row_
>=
((:
p_page_number
-
1
)
*
:
p_page_size
+
1
)
and
row_
<
(:
p_page_number
*
:
p_page_size
+
1
))
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