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
5ad1ac01
Commit
5ad1ac01
authored
Aug 12, 2019
by
Nguyen Ha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add job
parent
e3d1e236
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
176 additions
and
8 deletions
+176
-8
src/main/java/com/viettel/campaign/job/CampaignJob.java
src/main/java/com/viettel/campaign/job/CampaignJob.java
+45
-8
src/main/java/com/viettel/campaign/model/ccms_full/CustomerTime.java
...va/com/viettel/campaign/model/ccms_full/CustomerTime.java
+55
-0
src/main/java/com/viettel/campaign/repository/ccms_full/CustomerRepository.java
...tel/campaign/repository/ccms_full/CustomerRepository.java
+5
-0
src/main/java/com/viettel/campaign/repository/ccms_full/CustomerTimeRepository.java
...campaign/repository/ccms_full/CustomerTimeRepository.java
+18
-0
src/main/java/com/viettel/campaign/service/CustomerService.java
...in/java/com/viettel/campaign/service/CustomerService.java
+8
-0
src/main/java/com/viettel/campaign/service/CustomerTimeService.java
...ava/com/viettel/campaign/service/CustomerTimeService.java
+33
-0
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+12
-0
No files found.
src/main/java/com/viettel/campaign/job/CampaignJob.java
View file @
5ad1ac01
package
com.viettel.campaign.job
;
import
com.viettel.campaign.model.ccms_full.Campaign
;
import
com.viettel.campaign.model.ccms_full.Customer
;
import
com.viettel.campaign.model.ccms_full.CustomerTime
;
import
com.viettel.campaign.model.ccms_full.ProcessConfig
;
import
com.viettel.campaign.service.CampaignService
;
import
com.viettel.campaign.service.CustomerService
;
import
com.viettel.campaign.service.CustomerTimeService
;
import
com.viettel.campaign.service.ProcessConfigService
;
import
com.viettel.campaign.utils.DateTimeUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
...
...
@@ -34,6 +36,12 @@ public class CampaignJob {
@Autowired
private
CampaignService
campaignService
;
@Autowired
private
CustomerTimeService
customerTimeService
;
@Autowired
private
CustomerService
customerService
;
// @Scheduled(fixedRate = 5000)
// @Transactional( propagation = Propagation.REQUIRED)
public
void
process
()
{
...
...
@@ -45,26 +53,30 @@ public class CampaignJob {
switch
(
p
.
getConfigCode
()){
case
CUSTOMER_INACTIVE_DUARATION:
if
(
isExecute
){
List
<
Customer
>
customers
=
customerService
.
findAllByCondition
(
p
.
getSiteId
(),
new
Date
());
updateCustomer
(
customers
);
updateCustomerTime
(
customers
);
log
.
info
(
"Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}"
,
p
.
getSiteId
());
p
.
setLastProcess
(
new
Date
());
processConfigService
.
update
(
p
);
}
break
;
case
CRON_EXPRESSION_CHECK_START:
// process
if
(
isExecute
){
// chuyen trang thai Du thao sang Trien khai
log
.
info
(
"thay doi trang thai"
);
List
<
Long
>
status
=
new
ArrayList
<>();
status
.
add
(
1L
);
status
.
add
(
1L
);
List
<
Campaign
>
campaigns
=
campaignService
.
findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn
(
p
.
getSiteId
(),
new
Date
(),
status
);
campaigns
.
parallelStream
().
forEach
(
campaign
->
{
log
.
info
(
"Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai"
,
campaign
.
getCampaignId
());
campaign
.
setProcessStatus
(
1
);
campaign
.
setStatus
(
2L
);
campaign
.
setCampaignStart
(
new
Date
());
campaignService
.
updateProcess
(
campaign
);
});
// update last check
log
.
info
(
"Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}"
,
p
.
getSiteId
());
p
.
setLastProcess
(
new
Date
());
processConfigService
.
update
(
p
);
}
...
...
@@ -72,25 +84,50 @@ public class CampaignJob {
case
CRON_EXPRESSION_CHECK_END:
// process
if
(
isExecute
){
// chuyen trang thai sang ket thuc
List
<
Long
>
status
=
new
ArrayList
<>();
status
.
add
(
2L
);
status
.
add
(
3L
);
List
<
Campaign
>
campaigns
=
campaignService
.
findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn
(
p
.
getSiteId
(),
new
Date
(),
status
);
campaigns
.
parallelStream
().
forEach
(
campaign
->
{
log
.
info
(
"Chuyen trang thai chien dich ... #{} ... sang Ket thuc"
,
campaign
.
getCampaignId
());
campaign
.
setStatus
(
4L
);
campaign
.
setCampaignEnd
(
new
Date
());
campaignService
.
updateProcess
(
campaign
);
});
log
.
info
(
"Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}"
,
p
.
getSiteId
());
p
.
setLastProcess
(
new
Date
());
processConfigService
.
update
(
p
);
}
break
;
default
:
// update last check time
}
});
}
private
void
updateCustomer
(
List
<
Customer
>
customers
){
customers
.
parallelStream
().
forEach
(
c
->
{
log
.
info
(
"Cap nhat trang thai khoa cua KH ... #{}"
,
c
.
getCustomerId
());
c
.
setIpccStatus
(
"active"
);
customerService
.
update
(
c
);
});
}
private
void
updateCustomerTime
(
List
<
Customer
>
customers
){
customers
.
parallelStream
().
forEach
(
customer
->
{
// find all customer_time by customerId
List
<
CustomerTime
>
customerTimes
=
customerTimeService
.
findByCustomerId
(
customer
.
getCustomerId
());
customerTimes
.
parallelStream
().
forEach
(
customerTime
->
{
log
.
info
(
"Cap nhat Customer time cua KH ... #{}"
,
customerTime
.
getCustomerId
());
customerTime
.
setStatus
(
2
);
customerTime
.
setUpdateTime
(
new
Date
());
customerTimeService
.
update
(
customerTime
);
});
});
}
}
src/main/java/com/viettel/campaign/model/ccms_full/CustomerTime.java
0 → 100644
View file @
5ad1ac01
package
com.viettel.campaign.model.ccms_full
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
/**
* @author hanv_itsol
* @project campaign
*/
@Entity
@Table
(
name
=
"CUSTOMER_TIME"
)
@Getter
@Setter
public
class
CustomerTime
{
@Id
@NotNull
@Column
(
name
=
"CUSTOMER_TIME_ID"
)
private
Long
customerTimeId
;
@Column
(
name
=
"COMPANY_SITE_ID"
)
private
String
companySiteId
;
@Column
(
name
=
"CUSTOMER_ID"
)
private
String
customerId
;
@Column
(
name
=
"START_TIME"
)
private
Date
startTime
;
@Column
(
name
=
"END_TIME"
)
private
Date
endTime
;
@Column
(
name
=
"STATUS"
)
private
Integer
status
;
@Column
(
name
=
"CREATE_TIME"
)
private
Date
createTime
;
@Column
(
name
=
"UPDATE_TIME"
)
private
Date
updateTime
;
@Column
(
name
=
"CREATE_BY"
)
private
String
createBy
;
@Column
(
name
=
"UPDATE_BY"
)
private
String
updateBy
;
@Column
(
name
=
"CONTACT_CUST_RESULT_ID"
)
private
Long
contactCustResultId
;
}
src/main/java/com/viettel/campaign/repository/ccms_full/CustomerRepository.java
View file @
5ad1ac01
...
...
@@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.Date
;
import
java.util.List
;
@Repository
...
...
@@ -27,4 +28,8 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
@Modifying
@Query
(
"delete from Customer c where c.customerId in (:ids)"
)
int
deleteIds
(
@Param
(
"ids"
)
List
<
Long
>
ids
);
@Query
(
"select c from Customer c left join com.viettel.campaign.model.ccms_full.CustomerTime ct on c.customerId = ct.customerId "
+
"where c.ipccStatus = 'locked' and c.siteId =?1 and ct.endTime <= ?2"
)
List
<
Customer
>
findAllByCondition
(
Long
siteId
,
Date
endTime
);
}
src/main/java/com/viettel/campaign/repository/ccms_full/CustomerTimeRepository.java
0 → 100644
View file @
5ad1ac01
package
com.viettel.campaign.repository.ccms_full
;
import
com.viettel.campaign.model.ccms_full.CustomerTime
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
* @author hanv_itsol
* @project campaign
*/
@Repository
public
interface
CustomerTimeRepository
extends
JpaRepository
<
CustomerTime
,
Long
>
{
List
<
CustomerTime
>
findByCustomerId
(
Long
customerId
);
}
src/main/java/com/viettel/campaign/service/CustomerService.java
View file @
5ad1ac01
package
com.viettel.campaign.service
;
import
com.viettel.campaign.model.ccms_full.Customer
;
import
com.viettel.campaign.model.ccms_full.CustomerList
;
import
com.viettel.campaign.web.dto.CustomerContactDTO
;
import
com.viettel.campaign.web.dto.CustomerDTO
;
...
...
@@ -8,6 +9,9 @@ import com.viettel.campaign.web.dto.ResultDTO;
import
com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO
;
import
java.util.Date
;
import
java.util.List
;
public
interface
CustomerService
{
ResultDTO
getAllCustomer
(
int
page
,
int
pageSize
,
String
sort
,
long
customerListId
,
long
companySiteId
);
...
...
@@ -51,5 +55,9 @@ public interface CustomerService {
ResultDTO
getCustomerRecall
(
Long
campaignId
,
Long
customerId
);
List
<
Customer
>
findAllByCondition
(
Long
siteId
,
Date
endTime
);
Customer
update
(
Customer
c
);
}
src/main/java/com/viettel/campaign/service/CustomerTimeService.java
0 → 100644
View file @
5ad1ac01
package
com.viettel.campaign.service
;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.model.ccms_full.CustomerTime
;
import
com.viettel.campaign.repository.ccms_full.CustomerTimeRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
* @author hanv_itsol
* @project campaign
*/
@Service
@Transactional
public
class
CustomerTimeService
{
@Autowired
private
CustomerTimeRepository
customerTimeRepository
;
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
CustomerTime
update
(
CustomerTime
customerTime
){
return
customerTimeRepository
.
save
(
customerTime
);
}
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
List
<
CustomerTime
>
findByCustomerId
(
Long
customerId
){
return
customerTimeRepository
.
findByCustomerId
(
customerId
);
}
}
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
5ad1ac01
...
...
@@ -682,4 +682,16 @@ public class CustomerServiceImpl implements CustomerService {
}
return
resultDTO
;
}
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
List
<
Customer
>
findAllByCondition
(
Long
siteId
,
Date
endTime
)
{
return
customerRepository
.
findAllByCondition
(
siteId
,
endTime
);
}
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
Customer
update
(
Customer
c
)
{
return
customerRepository
.
save
(
c
);
}
}
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