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
681da34f
Commit
681da34f
authored
Aug 09, 2019
by
=
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
1d0dd0ba
b18de655
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
312 additions
and
30 deletions
+312
-30
pom.xml
pom.xml
+11
-0
src/main/java/com/viettel/campaign/config/JobConfig.java
src/main/java/com/viettel/campaign/config/JobConfig.java
+27
-19
src/main/java/com/viettel/campaign/model/ProcessConfig.java
src/main/java/com/viettel/campaign/model/ProcessConfig.java
+42
-0
src/main/java/com/viettel/campaign/repository/CampaignRepository.java
...a/com/viettel/campaign/repository/CampaignRepository.java
+12
-0
src/main/java/com/viettel/campaign/repository/CampaignRepositoryCustom.java
...viettel/campaign/repository/CampaignRepositoryCustom.java
+2
-0
src/main/java/com/viettel/campaign/repository/ProcessConfigRepository.java
.../viettel/campaign/repository/ProcessConfigRepository.java
+19
-0
src/main/java/com/viettel/campaign/repository/impl/CampaignRepositoryImpl.java
...ttel/campaign/repository/impl/CampaignRepositoryImpl.java
+42
-2
src/main/java/com/viettel/campaign/service/CampaignService.java
...in/java/com/viettel/campaign/service/CampaignService.java
+14
-0
src/main/java/com/viettel/campaign/service/CustomerService.java
...in/java/com/viettel/campaign/service/CustomerService.java
+0
-4
src/main/java/com/viettel/campaign/service/ProcessConfigService.java
...va/com/viettel/campaign/service/ProcessConfigService.java
+38
-0
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
...om/viettel/campaign/service/impl/CampaignServiceImpl.java
+39
-1
src/main/java/com/viettel/campaign/utils/DateTimeUtil.java
src/main/java/com/viettel/campaign/utils/DateTimeUtil.java
+36
-0
src/main/java/com/viettel/campaign/web/rest/CampaignController.java
...ava/com/viettel/campaign/web/rest/CampaignController.java
+5
-3
src/main/resources/sql/campaign-mng/check-allow-campaign-status-to-prepare.sql
...l/campaign-mng/check-allow-campaign-status-to-prepare.sql
+16
-0
src/main/resources/sql/campaign-mng/search-campaign-by-params.sql
.../resources/sql/campaign-mng/search-campaign-by-params.sql
+9
-1
No files found.
pom.xml
View file @
681da34f
...
@@ -201,6 +201,17 @@
...
@@ -201,6 +201,17 @@
<artifactId>
poi-ooxml
</artifactId>
<artifactId>
poi-ooxml
</artifactId>
<version>
3.17
</version>
<version>
3.17
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.cronutils
</groupId>
<artifactId>
cron-utils
</artifactId>
<version>
9.0.1
</version>
</dependency>
<dependency>
<groupId>
org.quartz-scheduler
</groupId>
<artifactId>
quartz
</artifactId>
<version>
2.3.0
</version>
</dependency>
</dependencies>
</dependencies>
<dependencyManagement>
<dependencyManagement>
...
...
src/main/java/com/viettel/campaign/config/JobConfig.java
View file @
681da34f
...
@@ -7,6 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -7,6 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.TaskScheduler
;
import
org.springframework.scheduling.TaskScheduler
;
import
org.springframework.scheduling.Trigger
;
import
org.springframework.scheduling.TriggerContext
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.SchedulingConfigurer
;
import
org.springframework.scheduling.annotation.SchedulingConfigurer
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
...
@@ -26,9 +28,6 @@ import java.util.concurrent.ScheduledFuture;
...
@@ -26,9 +28,6 @@ import java.util.concurrent.ScheduledFuture;
@Configuration
@Configuration
public
class
JobConfig
implements
SchedulingConfigurer
{
public
class
JobConfig
implements
SchedulingConfigurer
{
@Autowired
private
ApParamService
apParamService
;
TaskScheduler
taskScheduler
;
TaskScheduler
taskScheduler
;
private
ScheduledFuture
<?>
job1
;
private
ScheduledFuture
<?>
job1
;
private
ScheduledFuture
<?>
job2
;
private
ScheduledFuture
<?>
job2
;
...
@@ -38,18 +37,18 @@ public class JobConfig implements SchedulingConfigurer {
...
@@ -38,18 +37,18 @@ public class JobConfig implements SchedulingConfigurer {
return
new
CampaignJob
();
return
new
CampaignJob
();
}
}
@Override
//
@Override
public
void
configureTasks
(
ScheduledTaskRegistrar
taskRegistrar
)
{
//
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
//
ThreadPoolTaskScheduler
threadPoolTaskScheduler
=
new
ThreadPoolTaskScheduler
();
//
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler
.
setPoolSize
(
10
);
//
threadPoolTaskScheduler.setPoolSize(10);
threadPoolTaskScheduler
.
setThreadNamePrefix
(
"scheduler-thread"
);
//
threadPoolTaskScheduler.setThreadNamePrefix("scheduler-thread");
threadPoolTaskScheduler
.
initialize
();
//
threadPoolTaskScheduler.initialize();
job1
(
threadPoolTaskScheduler
);
//
job1(threadPoolTaskScheduler);
job2
(
threadPoolTaskScheduler
);
//
job2(threadPoolTaskScheduler);
this
.
taskScheduler
=
threadPoolTaskScheduler
;
//
this.taskScheduler = threadPoolTaskScheduler;
taskRegistrar
.
setTaskScheduler
(
threadPoolTaskScheduler
);
//
taskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
}
//
}
private
void
job1
(
TaskScheduler
scheduler
)
{
private
void
job1
(
TaskScheduler
scheduler
)
{
job1
=
scheduler
.
schedule
(()
->
{
job1
=
scheduler
.
schedule
(()
->
{
...
@@ -82,8 +81,17 @@ public class JobConfig implements SchedulingConfigurer {
...
@@ -82,8 +81,17 @@ public class JobConfig implements SchedulingConfigurer {
// @Override
@Override
// public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
public
void
configureTasks
(
ScheduledTaskRegistrar
scheduledTaskRegistrar
)
{
//// scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process2(), (TriggerContext triggerContext) -> yourService.getCron());
ThreadPoolTaskScheduler
threadPoolTaskScheduler
=
new
ThreadPoolTaskScheduler
();
// }
threadPoolTaskScheduler
.
setPoolSize
(
10
);
threadPoolTaskScheduler
.
setThreadNamePrefix
(
"scheduler-thread"
);
threadPoolTaskScheduler
.
initialize
();
scheduledTaskRegistrar
.
setTaskScheduler
(
threadPoolTaskScheduler
);
// scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process(), (TriggerContext triggerContext) -> yourService.getCron());
scheduledTaskRegistrar
.
addTriggerTask
(()
->
campaignJob
().
process
(),
triggerContext
->
{
CronTrigger
trigger
=
new
CronTrigger
(
"0/5 * * * * ?"
);
return
trigger
.
nextExecutionTime
(
triggerContext
);
});
}
}
}
src/main/java/com/viettel/campaign/model/ProcessConfig.java
0 → 100644
View file @
681da34f
package
com.viettel.campaign.model
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @author hanv_itsol
* @project campaign
*/
@Entity
@Table
(
name
=
"PROCESS_CONFIG"
)
@Data
public
class
ProcessConfig
implements
Serializable
{
@Id
@NotNull
@Column
(
name
=
"CONFIG_ID"
)
private
Long
configId
;
@Column
(
name
=
"CONFIG_NAME"
)
private
String
configName
;
@Column
(
name
=
"CONFIG_CODE"
)
private
String
configCode
;
@Column
(
name
=
"CONFIG_VALUE"
)
private
String
configValue
;
@Column
(
name
=
"LAST_PROCESS"
)
private
Date
lastProcess
;
@Column
(
name
=
"COMPANY_SITE_ID"
)
private
Long
siteId
;
}
src/main/java/com/viettel/campaign/repository/CampaignRepository.java
View file @
681da34f
...
@@ -8,9 +8,21 @@ import org.springframework.data.jpa.repository.Query;
...
@@ -8,9 +8,21 @@ import org.springframework.data.jpa.repository.Query;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
@Repository
@Repository
public
interface
CampaignRepository
extends
JpaRepository
<
Campaign
,
Long
>,
CampaignRepositoryCustom
{
public
interface
CampaignRepository
extends
JpaRepository
<
Campaign
,
Long
>,
CampaignRepositoryCustom
{
List
<
Campaign
>
findAllByCompanySiteId
(
Long
companyId
);
List
<
Campaign
>
findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn
(
Long
siteId
,
Date
startTime
,
List
<
Long
>
status
);
List
<
Campaign
>
findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn
(
Long
siteId
,
Date
endTime
,
List
<
Long
>
status
);
@Query
(
"SELECT COUNT(c.campaignId) "
+
@Query
(
"SELECT COUNT(c.campaignId) "
+
" FROM Campaign c JOIN CampaignCustomer cc ON c.campaignId = cc.campaignId "
+
" FROM Campaign c JOIN CampaignCustomer cc ON c.campaignId = cc.campaignId "
+
" WHERE cc.companySiteId = :pCompanySiteId "
+
" WHERE cc.companySiteId = :pCompanySiteId "
+
...
...
src/main/java/com/viettel/campaign/repository/CampaignRepositoryCustom.java
View file @
681da34f
...
@@ -13,4 +13,6 @@ public interface CampaignRepositoryCustom {
...
@@ -13,4 +13,6 @@ public interface CampaignRepositoryCustom {
ResultDTO
findByCampaignCode
(
CampaignRequestDTO
requestDTO
);
ResultDTO
findByCampaignCode
(
CampaignRequestDTO
requestDTO
);
String
getMaxCampaignIndex
();
String
getMaxCampaignIndex
();
ResultDTO
checkAllowStatusToPrepare
(
Long
campaignId
);
}
}
src/main/java/com/viettel/campaign/repository/ProcessConfigRepository.java
0 → 100644
View file @
681da34f
package
com.viettel.campaign.repository
;
import
com.viettel.campaign.model.ProcessConfig
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
* @author hanv_itsol
* @project campaign
*/
@Repository
public
interface
ProcessConfigRepository
extends
JpaRepository
<
ProcessConfig
,
Long
>
{
List
<
ProcessConfig
>
findAllByConfigCode
(
String
configCode
);
}
src/main/java/com/viettel/campaign/repository/impl/CampaignRepositoryImpl.java
View file @
681da34f
...
@@ -192,7 +192,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -192,7 +192,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCampaignName
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getCampaignName
()))
{
sqlStr
.
append
(
" AND UPPER(a.CAMPAIGN_NAME) LIKE :p_name"
);
sqlStr
.
append
(
" AND UPPER(a.CAMPAIGN_NAME) LIKE :p_name"
);
}
}
if
(
requestDto
.
getStatus
()
!=
null
&&
requestDto
.
getStatus
()
>
0
)
{
if
(
requestDto
.
getStatus
()
!=
null
&&
requestDto
.
getStatus
()
>
=
0
)
{
sqlStr
.
append
(
" AND a.STATUS = :p_status"
);
sqlStr
.
append
(
" AND a.STATUS = :p_status"
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
...
@@ -245,7 +245,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -245,7 +245,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
query
.
setParameter
(
"p_company_site_id"
,
requestDto
.
getCompanySiteId
());
query
.
setParameter
(
"p_company_site_id"
,
requestDto
.
getCompanySiteId
());
if
(
requestDto
.
getStatus
()
!=
null
&&
requestDto
.
getStatus
()
>
0
)
{
if
(
requestDto
.
getStatus
()
!=
null
&&
requestDto
.
getStatus
()
>
=
0
)
{
query
.
setParameter
(
"p_status"
,
requestDto
.
getStatus
());
query
.
setParameter
(
"p_status"
,
requestDto
.
getStatus
());
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
...
@@ -287,6 +287,14 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -287,6 +287,14 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
query
.
addScalar
(
"numOfJoinedCus"
,
new
LongType
());
query
.
addScalar
(
"numOfJoinedCus"
,
new
LongType
());
query
.
addScalar
(
"numOfNotJoinedCus"
,
new
LongType
());
query
.
addScalar
(
"numOfNotJoinedCus"
,
new
LongType
());
query
.
addScalar
(
"numOfLockCus"
,
new
LongType
());
query
.
addScalar
(
"numOfLockCus"
,
new
LongType
());
query
.
addScalar
(
"companySiteId"
,
new
LongType
());
query
.
addScalar
(
"content"
,
new
StringType
());
query
.
addScalar
(
"maxRecall"
,
new
IntegerType
());
query
.
addScalar
(
"recallType"
,
new
IntegerType
());
query
.
addScalar
(
"recallDuration"
,
new
IntegerType
());
query
.
addScalar
(
"currentTimeMode"
,
new
LongType
());
query
.
addScalar
(
"wrapupTimeConnect"
,
new
LongType
());
query
.
addScalar
(
"wrapupTimeDisconnect"
,
new
LongType
());
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
CampaignDTO
.
class
));
query
.
setResultTransformer
(
Transformers
.
aliasToBean
(
CampaignDTO
.
class
));
int
count
=
0
;
int
count
=
0
;
...
@@ -407,4 +415,36 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -407,4 +415,36 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return
null
;
return
null
;
}
}
@Override
public
ResultDTO
checkAllowStatusToPrepare
(
Long
campaignId
)
{
logger
.
info
(
"Start check allow campaign status to prepare::"
);
ResultDTO
result
=
new
ResultDTO
();
if
(
DataUtil
.
isNullOrZero
(
campaignId
))
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
return
result
;
}
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
sessionFactory
.
openSession
();
try
{
StringBuilder
sqlStr
=
new
StringBuilder
();
sqlStr
.
append
(
SQLBuilder
.
getSqlQueryById
(
SQLBuilder
.
SQL_MODULE_CAMPAIGN_MNG
,
"check-allow-campaign-status-to-prepare"
));
SQLQuery
query
=
session
.
createSQLQuery
(
sqlStr
.
toString
());
query
.
setParameter
(
"p_campaignId"
,
campaignId
);
List
<
Object
[]>
list
=
query
.
list
();
if
(
list
.
size
()
>
0
)
{
result
.
setData
(
list
.
get
(
0
));
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
}
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
finally
{
session
.
close
();
}
return
result
;
}
}
}
src/main/java/com/viettel/campaign/service/CampaignService.java
View file @
681da34f
package
com.viettel.campaign.service
;
package
com.viettel.campaign.service
;
import
com.viettel.campaign.model.Campaign
;
import
com.viettel.campaign.web.dto.CampaignDTO
;
import
com.viettel.campaign.web.dto.CampaignDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.ResultDTO
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
public
interface
CampaignService
{
public
interface
CampaignService
{
...
@@ -13,6 +17,14 @@ public interface CampaignService {
...
@@ -13,6 +17,14 @@ public interface CampaignService {
ResultDTO
findByCampaignCode
(
CampaignRequestDTO
requestDTO
);
ResultDTO
findByCampaignCode
(
CampaignRequestDTO
requestDTO
);
List
<
Campaign
>
findAllCondition
(
Long
companySiteId
);
List
<
Campaign
>
findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn
(
Long
siteId
,
Date
startTime
,
List
<
Long
>
status
);
List
<
Campaign
>
findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn
(
Long
siteId
,
Date
startTime
,
List
<
Long
>
status
);
Campaign
updateProcess
(
Campaign
c
);
ResultDTO
findByCampaignId
(
Long
campaignId
);
ResultDTO
findByCampaignId
(
Long
campaignId
);
ResultDTO
addNewCampaign
(
CampaignDTO
campaignDTO
);
ResultDTO
addNewCampaign
(
CampaignDTO
campaignDTO
);
...
@@ -22,4 +34,6 @@ public interface CampaignService {
...
@@ -22,4 +34,6 @@ public interface CampaignService {
ResultDTO
findCampaignById
(
Long
campaignId
);
ResultDTO
findCampaignById
(
Long
campaignId
);
ResultDTO
changeCampaignStatus
(
CampaignDTO
dto
);
ResultDTO
changeCampaignStatus
(
CampaignDTO
dto
);
ResultDTO
checkAllowStatusToPrepare
(
Long
campaignId
);
}
}
src/main/java/com/viettel/campaign/service/CustomerService.java
View file @
681da34f
...
@@ -40,11 +40,7 @@ public interface CustomerService {
...
@@ -40,11 +40,7 @@ public interface CustomerService {
// ------------ customer contact ------------ //
// ------------ customer contact ------------ //
<<<<<<<
HEAD
=======
ResultDTO
getCustomerContact
(
CustomerContactDTO
customer
);
ResultDTO
getCustomerContact
(
CustomerContactDTO
customer
);
>>>>>>>
1
e6b797350a4aab62031bb2ede27d0beb4dc3bb3
// 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
);
ResultDTO
searchCustomerListInfoFromCustomerList
(
int
page
,
int
pageSize
,
String
sort
,
Long
campaignId
,
Long
companySiteId
);
...
...
src/main/java/com/viettel/campaign/service/ProcessConfigService.java
0 → 100644
View file @
681da34f
package
com.viettel.campaign.service
;
import
com.viettel.campaign.model.ProcessConfig
;
import
com.viettel.campaign.repository.ProcessConfigRepository
;
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
ProcessConfigService
{
@Autowired
private
ProcessConfigRepository
processConfigRepository
;
@Transactional
(
readOnly
=
true
)
public
List
<
ProcessConfig
>
findAll
(){
return
processConfigRepository
.
findAll
();
}
@Transactional
(
readOnly
=
true
)
public
List
<
ProcessConfig
>
findAllByCode
(
String
configCode
){
return
processConfigRepository
.
findAllByConfigCode
(
configCode
);
}
public
void
update
(
ProcessConfig
pc
){
processConfigRepository
.
save
(
pc
);
}
}
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
View file @
681da34f
...
@@ -21,6 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -21,6 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.*
;
@Service
@Service
...
@@ -58,6 +63,26 @@ public class CampaignServiceImpl implements CampaignService {
...
@@ -58,6 +63,26 @@ public class CampaignServiceImpl implements CampaignService {
return
campaignRepository
.
findByCampaignCode
(
requestDTO
);
return
campaignRepository
.
findByCampaignCode
(
requestDTO
);
}
}
@Override
public
List
<
Campaign
>
findAllCondition
(
Long
companySiteId
)
{
return
campaignRepository
.
findAllByCompanySiteId
(
companySiteId
);
}
@Override
public
List
<
Campaign
>
findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn
(
Long
siteId
,
Date
startTime
,
List
<
Long
>
status
)
{
return
campaignRepository
.
findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn
(
siteId
,
startTime
,
status
);
}
@Override
public
List
<
Campaign
>
findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn
(
Long
siteId
,
Date
endTime
,
List
<
Long
>
status
)
{
return
campaignRepository
.
findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn
(
siteId
,
endTime
,
status
);
}
@Override
public
Campaign
updateProcess
(
Campaign
c
)
{
return
campaignRepository
.
save
(
c
);
}
@Override
@Override
public
ResultDTO
findByCampaignId
(
Long
campaignId
)
{
public
ResultDTO
findByCampaignId
(
Long
campaignId
)
{
ResultDTO
result
=
new
ResultDTO
();
ResultDTO
result
=
new
ResultDTO
();
...
@@ -179,6 +204,14 @@ public class CampaignServiceImpl implements CampaignService {
...
@@ -179,6 +204,14 @@ public class CampaignServiceImpl implements CampaignService {
userActionLog
.
setObjectId
(
entity
.
getCampaignId
());
userActionLog
.
setObjectId
(
entity
.
getCampaignId
());
if
(
dto
.
getStatus
().
equals
((
short
)
-
1
))
{
if
(
dto
.
getStatus
().
equals
((
short
)
-
1
))
{
userActionLog
.
setActionType
((
short
)
2
);
userActionLog
.
setActionType
((
short
)
2
);
}
else
if
(
dto
.
getStatus
().
equals
((
short
)
4
))
{
userActionLog
.
setActionType
((
short
)
7
);
}
else
if
(
dto
.
getStatus
().
equals
((
short
)
3
))
{
userActionLog
.
setActionType
((
short
)
4
);
}
else
if
(
dto
.
getStatus
().
equals
((
short
)
2
))
{
}
else
if
(
dto
.
getStatus
().
equals
((
short
)
5
))
{
}
else
if
(
dto
.
getStatus
().
equals
((
short
)
5
))
{
userActionLog
.
setActionType
((
short
)
7
);
userActionLog
.
setActionType
((
short
)
7
);
}
else
if
(
dto
.
getStatus
().
equals
((
short
)
4
))
{
}
else
if
(
dto
.
getStatus
().
equals
((
short
)
4
))
{
...
@@ -203,12 +236,17 @@ public class CampaignServiceImpl implements CampaignService {
...
@@ -203,12 +236,17 @@ public class CampaignServiceImpl implements CampaignService {
return
result
;
return
result
;
}
}
@Override
public
ResultDTO
checkAllowStatusToPrepare
(
Long
campaignId
)
{
return
campaignRepository
.
checkAllowStatusToPrepare
(
campaignId
);
}
private
String
generateCampaignCode
(
String
campaignType
,
Short
chanel
)
{
private
String
generateCampaignCode
(
String
campaignType
,
Short
chanel
)
{
int
year
=
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
);
int
year
=
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
);
String
maxIndexStr
=
campaignRepository
.
getMaxCampaignIndex
();
String
maxIndexStr
=
campaignRepository
.
getMaxCampaignIndex
();
if
(
maxIndexStr
!=
null
)
{
if
(
maxIndexStr
!=
null
)
{
Long
maxIndex
=
Long
.
valueOf
(
maxIndexStr
)
+
1
;
Long
maxIndex
=
Long
.
valueOf
(
maxIndexStr
)
+
1
;
String
result
=
campaignType
+
"_"
+
String
.
valueOf
(
chanel
)
+
"_"
+
String
.
valueOf
(
year
)
+
"_"
+
maxIndex
.
toString
();
String
result
=
campaignType
+
"_"
+
chanel
+
"_"
+
year
+
"_"
+
maxIndex
.
toString
();
return
result
;
return
result
;
}
}
return
null
;
return
null
;
...
...
src/main/java/com/viettel/campaign/utils/DateTimeUtil.java
View file @
681da34f
package
com.viettel.campaign.utils
;
package
com.viettel.campaign.utils
;
import
com.cronutils.model.definition.CronDefinition
;
import
com.cronutils.model.definition.CronDefinitionBuilder
;
import
com.cronutils.model.time.ExecutionTime
;
import
com.cronutils.parser.CronParser
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.logging.log4j.util.Strings
;
import
org.apache.logging.log4j.util.Strings
;
import
org.joda.time.DateTime
;
import
org.joda.time.format.DateTimeFormat
;
import
org.joda.time.format.DateTimeFormat
;
import
org.quartz.CronExpression
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.Duration
;
import
java.time.ZonedDateTime
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.Optional
;
import
java.util.TimeZone
;
import
java.util.TimeZone
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.concurrent.atomic.AtomicReference
;
import
static
com
.
cronutils
.
model
.
CronType
.
QUARTZ
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
MILLISECONDS
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
MILLISECONDS
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
NANOSECONDS
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
NANOSECONDS
;
/**
/**
* @author anhvd_itsol
* @author anhvd_itsol
*/
*/
@Slf4j
public
final
class
DateTimeUtil
{
public
final
class
DateTimeUtil
{
public
static
final
long
DAY_IN_MILLIS
=
86400000L
;
public
static
final
long
DAY_IN_MILLIS
=
86400000L
;
public
static
interface
DateTimeProvider
{
long
now
();
}
public
static
interface
DateTimeProvider
{
long
now
();
}
...
@@ -84,4 +98,26 @@ public final class DateTimeUtil {
...
@@ -84,4 +98,26 @@ public final class DateTimeUtil {
/**
/**
*
*
*/
*/
public
static
boolean
isRun
(
String
cron
,
Date
lastCheck
){
boolean
isOk
=
false
;
String
format
=
"dd-MMM-YYYY hh:mm:ss"
;
// String cronExpression="* * 12 ? * FRI *";
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
format
);
CronExpression
expression
=
null
;
try
{
expression
=
new
CronExpression
(
cron
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
Date
currentDate
=
new
Date
();
assert
expression
!=
null
;
Date
lastDate
=
expression
.
getNextValidTimeAfter
(
lastCheck
);
long
interval
=
lastDate
.
getTime
()
-
currentDate
.
getTime
();
if
(
interval
<=
0
){
isOk
=
true
;
}
return
isOk
;
}
}
}
src/main/java/com/viettel/campaign/web/rest/CampaignController.java
View file @
681da34f
...
@@ -9,10 +9,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
...
@@ -9,10 +9,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
<<<<<<<
HEAD:
src
/
main
/
java
/
com
/
viettel
/
campaign
/
web
/
rest
/
controller
/
CampaignController
.
java
import
org.springframework.cloud.sleuth.instrument.reactor.ReactorSleuth
;
import
org.springframework.cloud.sleuth.instrument.reactor.ReactorSleuth
;
=======
>>>>>>>
1
e6b797350a4aab62031bb2ede27d0beb4dc3bb3:
src
/
main
/
java
/
com
/
viettel
/
campaign
/
web
/
rest
/
CampaignController
.
java
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
;
...
@@ -119,4 +116,9 @@ public class CampaignController {
...
@@ -119,4 +116,9 @@ public class CampaignController {
dto
.
setSessionId
(
request
.
getSession
().
getId
());
dto
.
setSessionId
(
request
.
getSession
().
getId
());
return
campaignService
.
changeCampaignStatus
(
dto
);
return
campaignService
.
changeCampaignStatus
(
dto
);
}
}
@RequestMapping
(
value
=
"/check-allow-status-to-prepare"
,
method
=
RequestMethod
.
GET
)
public
ResultDTO
checkAllowStatusToPrepare
(
@RequestParam
(
"campaignId"
)
Long
campaignId
)
{
return
campaignService
.
checkAllowStatusToPrepare
(
campaignId
);
}
}
}
src/main/resources/sql/campaign-mng/check-allow-campaign-status-to-prepare.sql
0 → 100644
View file @
681da34f
WITH
COUNT_LIST
AS
(
SELECT
(
SELECT
COUNT
(
1
)
FROM
CAMPAIGN_CUSTOMER
WHERE
CAMPAIGN_ID
=
:
p_campaignId
)
countCamp
,
(
SELECT
COUNT
(
1
)
FROM
CAMPAIGN_AGENT
WHERE
CAMPAIGN_ID
=
:
p_campaignId
)
countAgent
,
(
select
COUNT
(
1
)
FROM
SCENARIO
s
INNER
JOIN
SCENARIO_QUESTION
sq
ON
s
.
SCENARIO_ID
=
sq
.
SCENARIO_ID
INNER
JOIN
SCENARIO_ANSWER
sa
ON
sq
.
SCENARIO_QUESTION_ID
=
sa
.
SCENARIO_QUESTION_ID
WHERE
s
.
CAMPAIGN_ID
=
:
p_campaignId
)
countScenario
FROM
DUAL
)
SELECT
c
.
countCamp
countCamp
,
c
.
countAgent
countAgent
,
c
.
countScenario
countScenario
,
CASE
WHEN
(
c
.
countCamp
IS
NOT
NULL
AND
c
.
countAgent
IS
NOT
NULL
AND
c
.
countScenario
IS
NOT
NULL
)
THEN
'00'
ELSE
'01'
END
as
code
FROM
COUNT_LIST
c
src/main/resources/sql/campaign-mng/search-campaign-by-params.sql
View file @
681da34f
...
@@ -12,7 +12,15 @@ SELECT
...
@@ -12,7 +12,15 @@ SELECT
a
.
CUSTOMER_NUMBER
cusNum
,
a
.
CUSTOMER_NUMBER
cusNum
,
b
.
SLKHThamgiaCD
numOfJoinedCus
,
b
.
SLKHThamgiaCD
numOfJoinedCus
,
c
.
SLKHChuaTuongTac
numOfNotJoinedCus
,
c
.
SLKHChuaTuongTac
numOfNotJoinedCus
,
d
.
SLKHDoNotCall_Khoa
numOfLockCus
d
.
SLKHDoNotCall_Khoa
numOfLockCus
,
a
.
COMPANY_SITE_ID
companySiteId
,
a
.
CONTENT
content
,
a
.
MAX_RECALL
maxRecall
,
a
.
RECALL_TYPE
recallType
,
a
.
RECALL_DURATION
recallDuration
,
a
.
CURRENT_TIME_MODE
currentTimeMode
,
a
.
WRAPUP_TIME_CONNECT
wrapupTimeConnect
,
a
.
WRAPUP_TIME_DISCONNECT
wrapupTimeDisconnect
FROM
CAMPAIGN
a
FROM
CAMPAIGN
a
LEFT
JOIN
(
SELECT
campaign_id
,
COUNT
(
*
)
AS
SLKHThamgiaCD
LEFT
JOIN
(
SELECT
campaign_id
,
COUNT
(
*
)
AS
SLKHThamgiaCD
FROM
campaign_customer
cc
INNER
JOIN
CUSTOMER
cus
ON
cc
.
CUSTOMER_ID
=
cus
.
CUSTOMER_ID
FROM
campaign_customer
cc
INNER
JOIN
CUSTOMER
cus
ON
cc
.
CUSTOMER_ID
=
cus
.
CUSTOMER_ID
...
...
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