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
9ae7b537
Commit
9ae7b537
authored
Aug 16, 2019
by
=
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hungtt-commit reallocation customer
parent
6753a6d6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
163 additions
and
5 deletions
+163
-5
src/main/java/com/viettel/campaign/repository/ccms_full/CampaignRepositoryCustom.java
...mpaign/repository/ccms_full/CampaignRepositoryCustom.java
+5
-0
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
...pository/ccms_full/impl/CampaignExecuteRepositoryImp.java
+10
-2
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
...ign/repository/ccms_full/impl/CampaignRepositoryImpl.java
+58
-3
src/main/java/com/viettel/campaign/service/CampaignService.java
...in/java/com/viettel/campaign/service/CampaignService.java
+6
-0
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
...om/viettel/campaign/service/impl/CampaignServiceImpl.java
+14
-0
src/main/java/com/viettel/campaign/web/dto/CustomerCustomDTO.java
.../java/com/viettel/campaign/web/dto/CustomerCustomDTO.java
+4
-0
src/main/java/com/viettel/campaign/web/dto/request_dto/CampaignRequestDTO.java
...ttel/campaign/web/dto/request_dto/CampaignRequestDTO.java
+4
-0
src/main/java/com/viettel/campaign/web/rest/ApParamController.java
...java/com/viettel/campaign/web/rest/ApParamController.java
+4
-0
src/main/java/com/viettel/campaign/web/rest/CampaignController.java
...ava/com/viettel/campaign/web/rest/CampaignController.java
+14
-0
src/main/resources/sql/campaign-mng/get-list-customer-reallocation.sql
...urces/sql/campaign-mng/get-list-customer-reallocation.sql
+44
-0
No files found.
src/main/java/com/viettel/campaign/repository/ccms_full/CampaignRepositoryCustom.java
View file @
9ae7b537
...
...
@@ -17,4 +17,9 @@ public interface CampaignRepositoryCustom {
String
getMaxCampaignIndex
();
ResultDTO
checkAllowStatusToPrepare
(
Long
campaignId
);
//hungtt
ResultDTO
findCustomerList
(
CampaignRequestDTO
dto
);
//hungtt
ResultDTO
reallocationCustomer
(
CampaignRequestDTO
dto
);
}
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
View file @
9ae7b537
...
...
@@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit;
public
class
CampaignExecuteRepositoryImp
implements
CampaignExecuteRepository
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CampaignExecuteRepositoryImp
.
class
);
private
static
final
String
CONNECT_STATUS_TYPE_RE
=
"3"
;
@Autowired
@Qualifier
(
DataSourceQualify
.
NAMED_JDBC_PARAMETER_TEMPLATE_CCMS_FULL
)
...
...
@@ -64,10 +65,17 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
List
<
ApParamDTO
>
list
=
new
ArrayList
<>();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
String
sql
=
SQLBuilder
.
getSqlQueryById
(
Constants
.
SQL_MODULES
.
MODULE_EXECUTE
,
"get-combo-status"
);
StringBuilder
stringBuilder
=
new
StringBuilder
();
stringBuilder
.
append
(
sql
);
try
{
params
.
put
(
"p_company_site_id"
,
companySiteId
);
params
.
put
(
"p_complete_type"
,
completeType
);
list
=
namedParameterJdbcTemplate
.
query
(
sql
,
params
,
BeanPropertyRowMapper
.
newInstance
(
ApParamDTO
.
class
));
if
(
CONNECT_STATUS_TYPE_RE
.
equals
(
completeType
))
{
params
.
put
(
"p_complete_type"
,
"1"
);
stringBuilder
.
append
(
" and COMPLETE_VALUE <> 1"
);
}
else
{
params
.
put
(
"p_complete_type"
,
completeType
);
}
list
=
namedParameterJdbcTemplate
.
query
(
stringBuilder
.
toString
(),
params
,
BeanPropertyRowMapper
.
newInstance
(
ApParamDTO
.
class
));
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
View file @
9ae7b537
package
com.viettel.campaign.repository.ccms_full.impl
;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.model.ccms_full.CampaignCustomer
;
import
com.viettel.campaign.repository.ccms_full.CampaignRepositoryCustom
;
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.CampaignDTO
;
import
com.viettel.campaign.web.dto.CustomerCustomDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -17,16 +19,18 @@ import org.hibernate.SessionFactory;
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.jdbc.core.BeanPropertyRowMapper
;
import
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
;
import
org.springframework.stereotype.Repository
;
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.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.*
;
@Repository
public
class
CampaignRepositoryImpl
implements
CampaignRepositoryCustom
{
...
...
@@ -37,6 +41,10 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
@PersistenceContext
(
unitName
=
DataSourceQualify
.
JPA_UNIT_NAME_CCMS_FULL
)
EntityManager
entityManager
;
@Autowired
@Qualifier
(
DataSourceQualify
.
NAMED_JDBC_PARAMETER_TEMPLATE_CCMS_FULL
)
NamedParameterJdbcTemplate
namedParameterJdbcTemplate
;
@Override
public
ResultDTO
search
(
CampaignRequestDTO
requestDto
)
{
logger
.
info
(
"Start search campaign::"
);
...
...
@@ -322,4 +330,51 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return
result
;
}
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
findCustomerList
(
CampaignRequestDTO
dto
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
List
<
CustomerCustomDTO
>
list
=
new
ArrayList
<>();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
try
{
String
sql
=
SQLBuilder
.
getSqlQueryById
(
SQLBuilder
.
SQL_MODULE_CAMPAIGN_MNG
,
"get-list-customer-reallocation"
);
params
.
put
(
"p_company_site_id"
,
dto
.
getCompanySiteId
());
params
.
put
(
"p_campaign_id"
,
dto
.
getCampaignId
());
params
.
put
(
"p_list_connect_status"
,
dto
.
getConnectStatus
());
params
.
put
(
"p_page_size"
,
dto
.
getPageSize
().
toString
());
params
.
put
(
"p_page_number"
,
dto
.
getPage
().
toString
());
list
=
namedParameterJdbcTemplate
.
query
(
sql
,
params
,
BeanPropertyRowMapper
.
newInstance
(
CustomerCustomDTO
.
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
);
}
return
resultDTO
;
}
@Override
public
ResultDTO
reallocationCustomer
(
CampaignRequestDTO
dto
)
{
ResultDTO
resultDTO
=
new
ResultDTO
();
try
{
List
<
CustomerCustomDTO
>
list
=
dto
.
getCustomerCustomDTOList
();
for
(
CustomerCustomDTO
customerCustomDTO:
list
)
{
CampaignCustomer
campaignCustomer
=
entityManager
.
find
(
CampaignCustomer
.
class
,
customerCustomDTO
.
getCampaignCustomerId
());
campaignCustomer
.
setStatus
((
short
)
0
);
campaignCustomer
.
setCallStatus
(
null
);
campaignCustomer
.
setRedistribute
((
short
)
1
);
}
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
;
}
}
src/main/java/com/viettel/campaign/service/CampaignService.java
View file @
9ae7b537
...
...
@@ -47,4 +47,10 @@ public interface CampaignService {
ResultDTO
renewCampaign
(
CampaignDTO
campaignDTO
);
ResultDTO
updateCampaign
(
CampaignDTO
dto
);
//<editor-fold: hungtt>
ResultDTO
findCustomerList
(
CampaignRequestDTO
dto
);
ResultDTO
reallocationCustomer
(
CampaignRequestDTO
dto
);
//</editor-fold>
}
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
View file @
9ae7b537
...
...
@@ -436,6 +436,20 @@ public class CampaignServiceImpl implements CampaignService {
return
resultDTO
;
}
// hungtt
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
findCustomerList
(
CampaignRequestDTO
dto
)
{
return
campaignRepositoryCustom
.
findCustomerList
(
dto
);
}
// hungtt
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
reallocationCustomer
(
CampaignRequestDTO
dto
)
{
return
campaignRepositoryCustom
.
reallocationCustomer
(
dto
);
}
private
String
generateCampaignCode
(
String
campaignType
,
Short
chanel
)
{
int
year
=
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
);
String
maxIndexStr
=
campaignRepositoryCustom
.
getMaxCampaignIndex
();
...
...
src/main/java/com/viettel/campaign/web/dto/CustomerCustomDTO.java
View file @
9ae7b537
...
...
@@ -23,4 +23,8 @@ public class CustomerCustomDTO {
String
ipccStatus
;
String
mobileNumber
;
String
email
;
String
connectStatus
;
String
connectTime
;
String
customerName
;
Long
campaignCustomerId
;
}
src/main/java/com/viettel/campaign/web/dto/request_dto/CampaignRequestDTO.java
View file @
9ae7b537
package
com.viettel.campaign.web.dto.request_dto
;
import
com.viettel.campaign.web.dto.BaseDTO
;
import
com.viettel.campaign.web.dto.CustomerCustomDTO
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.List
;
/**
* @author anhvd_itsol
*/
...
...
@@ -42,4 +45,5 @@ public class CampaignRequestDTO extends BaseDTO {
String
surveyStatus
;
String
roleUser
;
String
contactCustId
;
List
<
CustomerCustomDTO
>
customerCustomDTOList
;
}
src/main/java/com/viettel/campaign/web/rest/ApParamController.java
View file @
9ae7b537
...
...
@@ -21,6 +21,8 @@ public class ApParamController {
private
static
final
String
CONNECT_STATUS
=
"CONNECT_STATUS"
;
private
static
final
String
CONNECT_STATUS_TYPE
=
"1"
;
private
static
final
String
CONNECT_STATUS_RE
=
"CONNECT_STATUS_RE"
;
private
static
final
String
CONNECT_STATUS_TYPE_RE
=
"3"
;
private
static
final
String
SURVEY_STATUS
=
"SURVEY_STATUS"
;
private
static
final
String
SURVEY_STATUS_TYPE
=
"2"
;
private
static
final
String
CAMPAIGN_TYPE
=
"CAMPAIGN_TYPE"
;
...
...
@@ -74,6 +76,8 @@ public class ApParamController {
return
new
ResponseEntity
<>(
campaignExecuteService
.
getComboBoxStatus
(
companySiteId
,
CONNECT_STATUS_TYPE
),
HttpStatus
.
OK
);
}
else
if
(
SURVEY_STATUS
.
equals
(
parType
)){
return
new
ResponseEntity
<>(
campaignExecuteService
.
getComboBoxStatus
(
companySiteId
,
SURVEY_STATUS_TYPE
),
HttpStatus
.
OK
);
}
else
if
(
CONNECT_STATUS_RE
.
equals
(
parType
))
{
return
new
ResponseEntity
<>(
campaignExecuteService
.
getComboBoxStatus
(
companySiteId
,
CONNECT_STATUS_TYPE_RE
),
HttpStatus
.
OK
);
}
else
{
return
new
ResponseEntity
<>(
campaignExecuteService
.
getComboCampaignType
(
companySiteId
),
HttpStatus
.
OK
);
}
...
...
src/main/java/com/viettel/campaign/web/rest/CampaignController.java
View file @
9ae7b537
...
...
@@ -192,4 +192,18 @@ public class CampaignController {
ResultDTO
resultDTO
=
campaignService
.
updateCampaign
(
dto
);
return
new
ResponseEntity
<>(
resultDTO
,
HttpStatus
.
OK
);
}
@PostMapping
(
"/findCustomerList"
)
@ResponseBody
public
ResponseEntity
<?>
findCustomerList
(
@RequestBody
CampaignRequestDTO
dto
)
{
ResultDTO
result
=
campaignService
.
findCustomerList
(
dto
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@PostMapping
(
"/reallocationCustomer"
)
@ResponseBody
public
ResponseEntity
<?>
reallocationCustomer
(
@RequestBody
CampaignRequestDTO
dto
)
{
ResultDTO
result
=
campaignService
.
reallocationCustomer
(
dto
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
src/main/resources/sql/campaign-mng/get-list-customer-reallocation.sql
0 → 100644
View file @
9ae7b537
with
contact
as
(
select
customer_id
,
contact
from
(
select
*
from
customer_contact
where
status
=
1
and
contact_type
=
5
and
is_direct_line
=
1
order
by
create_date
desc
)
where
rownum
=
1
),
connect_status
as
(
select
complete_value
,
complete_name
from
campaign_complete_code
where
company_site_id
=
:
p_company_site_id
and
complete_type
=
1
and
complete_value
<>
1
),
connect_status_list
as
(
select
trim
(
regexp_substr
(:
p_list_connect_status
,
'[^,]+'
,
1
,
level
))
connect_status
from
dual
connect
by
level
<=
regexp_count
(:
p_list_connect_status
,
','
)
+
1
),
data
as
(
select
a
.
campaign_customer_id
campaignCustomerId
,
b
.
name
customerName
,
c
.
contact
mobileNumber
,
to_char
(
a
.
call_time
,
'DD/MM/YYYY HH24:MI:SS'
)
connectTime
,
d
.
complete_name
connectStatus
from
campaign_customer
a
left
join
customer
b
on
a
.
customer_id
=
b
.
customer_id
left
join
contact
c
on
a
.
customer_id
=
c
.
customer_id
left
join
connect_status
d
on
d
.
complete_value
=
a
.
status
where
a
.
campaign_id
=
:
p_campaign_id
and
a
.
in_campaign_status
=
1
and
a
.
status
in
(
select
connect_status
from
connect_status_list
)
order
by
customerName
),
final_data
as
(
select
a
.
*
,
rownum
row_
from
data
a
)
select
*
from
final_data
where
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