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
4f98a848
Commit
4f98a848
authored
Aug 12, 2019
by
Đào Nhật Quang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quangdn
parent
2db2c01b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
38 deletions
+112
-38
src/main/java/com/viettel/campaign/service/CustomerService.java
...in/java/com/viettel/campaign/service/CustomerService.java
+6
-5
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+37
-13
src/main/java/com/viettel/campaign/web/dto/CampaignCustomerDTO.java
...ava/com/viettel/campaign/web/dto/CampaignCustomerDTO.java
+1
-1
src/main/java/com/viettel/campaign/web/dto/CustomerListDTO.java
...in/java/com/viettel/campaign/web/dto/CustomerListDTO.java
+3
-0
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
...ava/com/viettel/campaign/web/rest/CustomerController.java
+12
-11
src/main/resources/sql/campaign-mng/search-customer-list-info-from-customer-list.sql
...aign-mng/search-customer-list-info-from-customer-list.sql
+18
-8
src/main/resources/sql/campaign-mng/search-individual-customer.sql
...resources/sql/campaign-mng/search-individual-customer.sql
+35
-0
No files found.
src/main/java/com/viettel/campaign/service/CustomerService.java
View file @
4f98a848
package
com.viettel.campaign.service
;
package
com.viettel.campaign.service
;
import
com.viettel.campaign.model.ccms_full.CustomerList
;
import
com.viettel.campaign.model.ccms_full.CustomerList
;
import
com.viettel.campaign.web.dto.CustomerContactDTO
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.CustomerDTO
;
import
com.viettel.campaign.web.dto.CustomerListDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
import
java.util.List
;
public
interface
CustomerService
{
public
interface
CustomerService
{
ResultDTO
getAllCustomer
(
int
page
,
int
pageSize
,
String
sort
,
long
customerListId
,
long
companySiteId
);
ResultDTO
getAllCustomer
(
int
page
,
int
pageSize
,
String
sort
,
long
customerListId
,
long
companySiteId
);
...
@@ -44,7 +43,9 @@ public interface CustomerService {
...
@@ -44,7 +43,9 @@ public interface CustomerService {
// danh sach khach hang cua chien dich //
// danh sach khach hang cua chien dich //
ResultDTO
searchCustomerListInfoFromCustomerList
(
int
page
,
int
pageSize
,
String
sort
,
Long
campaignId
,
Long
companySiteId
);
List
<
CustomerListDTO
>
getCustomerListInfo
(
CampaignCustomerDTO
campaignCustomerDTO
);
List
<
CustomerDTO
>
getIndividualCustomerInfo
(
CampaignCustomerDTO
campaignCustomerDTO
);
// ------------ customer ------------ //
// ------------ customer ------------ //
...
...
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
4f98a848
package
com.viettel.campaign.service.impl
;
package
com.viettel.campaign.service.impl
;
import
com.viettel.campaign.config.CCMSFullDatasourceConfig
;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.mapper.CustomerListMapper
;
import
com.viettel.campaign.mapper.CustomerListMapper
;
import
com.viettel.campaign.mapper.CustomerMapper
;
import
com.viettel.campaign.mapper.CustomerMapper
;
...
@@ -24,15 +25,20 @@ import org.hibernate.type.LongType;
...
@@ -24,15 +25,20 @@ import org.hibernate.type.LongType;
import
org.hibernate.type.ShortType
;
import
org.hibernate.type.ShortType
;
import
org.hibernate.type.StringType
;
import
org.hibernate.type.StringType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.domain.*
;
import
org.springframework.jdbc.core.BeanPropertyRowMapper
;
import
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.EntityManager
;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.Query
;
import
javax.persistence.Query
;
import
java
.util.Dat
e
;
import
java
x.sql.DataSourc
e
;
import
java.util.
List
;
import
java.util.
*
;
@Service
@Service
public
class
CustomerServiceImpl
implements
CustomerService
{
public
class
CustomerServiceImpl
implements
CustomerService
{
...
@@ -59,6 +65,10 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -59,6 +65,10 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired
@Autowired
CustomerListMappingRepository
customerListMappingRepository
;
CustomerListMappingRepository
customerListMappingRepository
;
@Autowired
@Qualifier
(
DataSourceQualify
.
NAMED_JDBC_PARAMETER_TEMPLATE_CCMS_FULL
)
NamedParameterJdbcTemplate
namedParameterJdbcTemplate
;
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
getAllCustomer
(
int
page
,
int
pageSize
,
String
sort
,
long
customerListId
,
long
companySiteId
)
{
public
ResultDTO
getAllCustomer
(
int
page
,
int
pageSize
,
String
sort
,
long
customerListId
,
long
companySiteId
)
{
...
@@ -670,20 +680,34 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -670,20 +680,34 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
searchCustomerListInfoFromCustomerList
(
int
page
,
int
pageSize
,
String
sort
,
Long
campaignId
,
Long
companySiteId
)
{
public
List
<
CustomerListDTO
>
getCustomerListInfo
(
CampaignCustomerDTO
campaignCustomerDTO
)
{
ResultDTO
resultDTO
=
new
ResultDTO
()
;
List
<
CustomerListDTO
>
customerList
;
try
{
try
{
String
sql
=
SQLBuilder
.
getSqlQueryById
(
SQLBuilder
.
SQL_MODULE_CAMPAIGN_MNG
,
"search-customer-list-info-from-customer-list"
);
String
sql
=
SQLBuilder
.
getSqlQueryById
(
SQLBuilder
.
SQL_MODULE_CAMPAIGN_MNG
,
"search-customer-list-info-from-customer-list"
);
Query
query
=
entityManager
.
createNativeQuery
(
sql
);
Map
<
String
,
Object
>
param
=
new
HashMap
<>(
);
query
.
setParameter
(
"p_campaign_id"
,
campaignId
);
param
.
put
(
"p_campaign_id"
,
campaignCustomerDTO
.
getCampaignId
()
);
query
.
setParameter
(
"p_company_site_id"
,
companySiteId
);
param
.
put
(
"p_company_site_id"
,
campaignCustomerDTO
.
getCompanySiteId
()
);
resultDTO
.
setListData
(
query
.
getResultList
());
param
.
put
(
"p_page_number"
,
campaignCustomerDTO
.
getPage
());
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
param
.
put
(
"p_page_size"
,
campaignCustomerDTO
.
getPageSize
()
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
customerList
=
namedParameterJdbcTemplate
.
query
(
sql
,
param
,
new
BeanPropertyRowMapper
<>(
CustomerListDTO
.
class
)
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
return
null
;
resultDTO
.
setDescription
(
e
.
getMessage
());
}
}
return
resultDTO
;
return
customerList
;
}
@Override
public
List
<
CustomerDTO
>
getIndividualCustomerInfo
(
CampaignCustomerDTO
campaignCustomerDTO
)
{
List
<
CustomerDTO
>
customerList
;
try
{
String
sql
=
SQLBuilder
.
getSqlQueryById
(
SQLBuilder
.
SQL_MODULE_CAMPAIGN_MNG
,
"search-individual-customer"
);
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"p_page_number"
,
campaignCustomerDTO
.
getPage
());
param
.
put
(
"p_page_size"
,
campaignCustomerDTO
.
getPageSize
());
customerList
=
namedParameterJdbcTemplate
.
query
(
sql
,
param
,
new
BeanPropertyRowMapper
<>(
CustomerDTO
.
class
));
}
catch
(
Exception
e
)
{
return
null
;
}
return
customerList
;
}
}
}
}
src/main/java/com/viettel/campaign/web/dto/CampaignCustomerDTO.java
View file @
4f98a848
...
@@ -7,7 +7,7 @@ import java.util.Date;
...
@@ -7,7 +7,7 @@ import java.util.Date;
@Getter
@Getter
@Setter
@Setter
public
class
CampaignCustomerDTO
{
public
class
CampaignCustomerDTO
extends
BaseDTO
{
private
Long
campaignCustomerListId
;
private
Long
campaignCustomerListId
;
private
Long
campaignId
;
private
Long
campaignId
;
private
Long
customerId
;
private
Long
customerId
;
...
...
src/main/java/com/viettel/campaign/web/dto/CustomerListDTO.java
View file @
4f98a848
...
@@ -21,4 +21,7 @@ public class CustomerListDTO extends BaseDTO {
...
@@ -21,4 +21,7 @@ public class CustomerListDTO extends BaseDTO {
private
Date
updateAt
;
private
Date
updateAt
;
private
String
source
;
private
String
source
;
private
String
deptCreate
;
private
String
deptCreate
;
private
Long
totalCusInList
;
private
Long
totalCusInteract
;
private
Long
totalCusNotInteract
;
}
}
src/main/java/com/viettel/campaign/web/rest/CustomerController.java
View file @
4f98a848
package
com.viettel.campaign.web.rest
;
package
com.viettel.campaign.web.rest
;
import
com.viettel.campaign.web.dto.CustomerContactDTO
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.CustomerDTO
;
import
com.viettel.campaign.web.dto.CustomerListDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
...
@@ -12,6 +9,7 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
...
@@ -12,6 +9,7 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
...
@@ -242,12 +240,15 @@ public class CustomerController {
...
@@ -242,12 +240,15 @@ public class CustomerController {
}
}
}
}
@RequestMapping
(
value
=
"/searchCustomerListInfoFromCustomerList"
,
method
=
RequestMethod
.
GET
)
@PostMapping
(
"/getCustomerListInfo"
)
public
ResultDTO
searchCustomerListInfoFromCustomerList
(
@RequestParam
(
"page"
)
int
page
,
public
ResponseEntity
<?>
getCustomerListInfo
(
@RequestBody
CampaignCustomerDTO
campaignCustomerDTO
)
{
@RequestParam
(
"pageSize"
)
int
pageSize
,
List
<
CustomerListDTO
>
data
=
customerService
.
getCustomerListInfo
(
campaignCustomerDTO
);
@RequestParam
(
"sort"
)
String
sort
,
return
new
ResponseEntity
<>(
data
,
HttpStatus
.
OK
);
@RequestParam
(
"campaignId"
)
Long
campaignId
,
}
@RequestParam
(
"companySiteId"
)
Long
companySiteId
)
{
return
customerService
.
searchCustomerListInfoFromCustomerList
(
page
,
pageSize
,
sort
,
campaignId
,
companySiteId
);
@PostMapping
(
"/getIndividualCustomerInfo"
)
public
ResponseEntity
<?>
getIndividualCustomerInfo
(
@RequestBody
CampaignCustomerDTO
dto
)
{
List
<
CustomerDTO
>
data
=
customerService
.
getIndividualCustomerInfo
(
dto
);
return
new
ResponseEntity
<>(
data
,
HttpStatus
.
OK
);
}
}
}
}
src/main/resources/sql/campaign-mng/search-customer-list-info-from-customer-list.sql
View file @
4f98a848
...
@@ -19,16 +19,26 @@ count(customer_id) ktt
...
@@ -19,16 +19,26 @@ count(customer_id) ktt
from
campaign_customer
where
campaign_id
=
:
p_campaign_id
and
status
=
0
from
campaign_customer
where
campaign_id
=
:
p_campaign_id
and
status
=
0
and
in_campaign_status
=
1
and
in_campaign_status
=
1
group
by
customer_list_id
,
company_site_id
group
by
customer_list_id
,
company_site_id
)
),
datas
as
(
select
customer_list_code
ma
,
select
customer_list_code
customerListCode
,
customer_list_name
ten
,
customer_list_name
customerListName
,
cl
.
company_site_id
,
nvl
(
total
,
0
)
totalCusInList
,
nvl
(
total
,
0
)
tong
,
nvl
(
tt
,
0
)
totalCusInteract
,
nvl
(
tt
,
0
)
tongtt
,
nvl
(
ktt
,
0
)
totalCusNotInteract
nvl
(
ktt
,
0
)
tongktt
from
customer_list
cl
from
customer_list
cl
left
join
totalCustomer
tc
on
(
cl
.
customer_list_id
=
tc
.
customer_list_id
and
cl
.
company_site_id
=
tc
.
company_site_id
)
left
join
totalCustomer
tc
on
(
cl
.
customer_list_id
=
tc
.
customer_list_id
and
cl
.
company_site_id
=
tc
.
company_site_id
)
left
join
customerInteractive
ci
on
(
cl
.
customer_list_id
=
ci
.
customer_list_id
and
cl
.
company_site_id
=
ci
.
company_site_id
)
left
join
customerInteractive
ci
on
(
cl
.
customer_list_id
=
ci
.
customer_list_id
and
cl
.
company_site_id
=
ci
.
company_site_id
)
left
join
customerNotInteractive
cni
on
(
cl
.
customer_list_id
=
cni
.
customer_list_id
and
cl
.
company_site_id
=
cni
.
company_site_id
)
left
join
customerNotInteractive
cni
on
(
cl
.
customer_list_id
=
cni
.
customer_list_id
and
cl
.
company_site_id
=
cni
.
company_site_id
)
where
cl
.
company_site_id
=
:
p_company_site_id
where
cl
.
company_site_id
=
:
p_company_site_id
order
by
customer_list_code
)
\ No newline at end of file
select
*
from
(
select
a
.
*
,
rownum
r__
from
(
select
*
from
datas
order
by
customerListCode
)
a
where
rownum
<
((:
p_page_number
*
:
p_page_size
)
+
1
)
)
where
r__
>=
(((:
p_page_number
-
1
)
*
:
p_page_size
)
+
1
)
\ No newline at end of file
src/main/resources/sql/campaign-mng/search-individual-customer.sql
0 → 100644
View file @
4f98a848
with
cusPhone
as
(
select
customer_id
cusId
,
contact
phone
from
customer_contact
cc
where
cc
.
contact_type
=
5
and
status
=
1
),
cusEmail
as
(
select
customer_id
cusId
,
contact
email
from
customer_contact
cc
where
cc
.
contact_type
=
2
and
status
=
1
),
datas
as
(
select
c
.
name
,
cP
.
phone
,
cE
.
email
,
c
.
customer_type
cusType
,
c
.
company_name
compName
,
c
.
current_address
currentAddress
,
c
.
description
from
customer
c
left
join
cusPhone
cP
on
c
.
customer_id
=
cP
.
cusId
left
join
cusEmail
cE
on
c
.
customer_id
=
cE
.
cusId
)
select
*
from
(
select
a
.
*
,
rownum
r__
from
(
select
*
from
datas
order
by
datas
.
name
)
a
where
rownum
<
((:
p_page_number
*
:
p_page_size
)
+
1
)
)
where
r__
>=
(((:
p_page_number
-
1
)
*
:
p_page_size
)
+
1
)
\ No newline at end of file
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