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
801ae339
Commit
801ae339
authored
Sep 12, 2019
by
đinh thị đầm
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
a8ec62a6
784e68cb
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
305 additions
and
65 deletions
+305
-65
pom.xml
pom.xml
+12
-0
src/main/java/com/viettel/campaign/job/CampaignJob.java
src/main/java/com/viettel/campaign/job/CampaignJob.java
+2
-0
src/main/java/com/viettel/campaign/repository/ccms_full/CampaignAgentRepository.java
...ampaign/repository/ccms_full/CampaignAgentRepository.java
+3
-1
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
...pository/ccms_full/impl/CampaignExecuteRepositoryImp.java
+15
-7
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
...ign/repository/ccms_full/impl/CampaignRepositoryImpl.java
+19
-16
src/main/java/com/viettel/campaign/service/CampaignExecuteService.java
.../com/viettel/campaign/service/CampaignExecuteService.java
+4
-2
src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
...ttel/campaign/service/impl/CampaignExecuteServiceImp.java
+69
-31
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
...om/viettel/campaign/service/impl/CampaignServiceImpl.java
+2
-2
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
...om/viettel/campaign/service/impl/CustomerServiceImpl.java
+8
-3
src/main/java/com/viettel/campaign/service/impl/ScenarioQuestionServiceImpl.java
...el/campaign/service/impl/ScenarioQuestionServiceImpl.java
+1
-0
src/main/java/com/viettel/campaign/utils/TimeZoneUtils.java
src/main/java/com/viettel/campaign/utils/TimeZoneUtils.java
+157
-0
src/main/java/com/viettel/campaign/web/dto/CampaignDTO.java
src/main/java/com/viettel/campaign/web/dto/CampaignDTO.java
+3
-0
src/main/java/com/viettel/campaign/web/dto/request_dto/SearchCustomerRequestDTO.java
...ampaign/web/dto/request_dto/SearchCustomerRequestDTO.java
+1
-0
src/main/java/com/viettel/campaign/web/rest/CampaignExecuteController.java
.../viettel/campaign/web/rest/CampaignExecuteController.java
+9
-3
No files found.
pom.xml
View file @
801ae339
...
@@ -162,6 +162,18 @@
...
@@ -162,6 +162,18 @@
<version>
2.1.0
</version>
<version>
2.1.0
</version>
</dependency>
</dependency>
<dependency>
<groupId>
net.javacrumbs.shedlock
</groupId>
<artifactId>
shedlock-spring
</artifactId>
<version>
2.2.0
</version>
</dependency>
<dependency>
<groupId>
net.javacrumbs.shedlock
</groupId>
<artifactId>
shedlock-provider-redis-spring
</artifactId>
<version>
2.2.0
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
src/main/java/com/viettel/campaign/job/CampaignJob.java
View file @
801ae339
...
@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.*;
...
@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.*;
import
com.viettel.campaign.service.*
;
import
com.viettel.campaign.service.*
;
import
com.viettel.campaign.utils.DateTimeUtil
;
import
com.viettel.campaign.utils.DateTimeUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.javacrumbs.shedlock.core.SchedulerLock
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -41,6 +42,7 @@ public class CampaignJob {
...
@@ -41,6 +42,7 @@ public class CampaignJob {
// @Scheduled(fixedRate = 5000)
// @Scheduled(fixedRate = 5000)
// @Transactional( propagation = Propagation.REQUIRED)
// @Transactional( propagation = Propagation.REQUIRED)
@SchedulerLock
(
name
=
"testTimer"
,
lockAtMostFor
=
20
*
1000
,
lockAtLeastFor
=
20
*
1000
)
public
void
process
()
{
public
void
process
()
{
log
.
info
(
Thread
.
currentThread
().
getName
()
+
" The Task executed at "
+
dateFormat
.
format
(
new
Date
()));
log
.
info
(
Thread
.
currentThread
().
getName
()
+
" The Task executed at "
+
dateFormat
.
format
(
new
Date
()));
List
<
ProcessConfig
>
list
=
processConfigService
.
findAll
();
List
<
ProcessConfig
>
list
=
processConfigService
.
findAll
();
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/CampaignAgentRepository.java
View file @
801ae339
...
@@ -18,7 +18,9 @@ public interface CampaignAgentRepository extends JpaRepository<CampaignAgent, Lo
...
@@ -18,7 +18,9 @@ public interface CampaignAgentRepository extends JpaRepository<CampaignAgent, Lo
@Query
(
value
=
"SELECT campaign_agent_seq.nextval FROM DUAL"
,
nativeQuery
=
true
)
@Query
(
value
=
"SELECT campaign_agent_seq.nextval FROM DUAL"
,
nativeQuery
=
true
)
Long
getNextSeqId
();
Long
getNextSeqId
();
List
<
CampaignAgent
>
findByCampaignIdAndAgentId
(
Long
campaignId
,
Long
agentId
);
CampaignAgent
findByCampaignIdAndAgentId
(
Long
campaignId
,
Long
agentId
);
List
<
CampaignAgent
>
findByAgentId
(
Long
agentId
);
@Modifying
@Modifying
@Query
(
"delete from CampaignAgent c where c.campaignAgentId in (:p_campaign_agent_id)"
)
@Query
(
"delete from CampaignAgent c where c.campaignAgentId in (:p_campaign_agent_id)"
)
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignExecuteRepositoryImp.java
View file @
801ae339
...
@@ -460,6 +460,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
...
@@ -460,6 +460,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
List
<
CampaignDTO
>
searchCampaignExecute
(
CampaignRequestDTO
campaignRequestDto
,
Pageable
pageable
)
{
public
List
<
CampaignDTO
>
searchCampaignExecute
(
CampaignRequestDTO
campaignRequestDto
,
Pageable
pageable
)
{
List
<
CampaignDTO
>
result
=
new
ArrayList
<>();
List
<
CampaignDTO
>
result
=
new
ArrayList
<>();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
Session
session
=
null
;
StringBuilder
expression
=
new
StringBuilder
()
StringBuilder
expression
=
new
StringBuilder
()
.
append
(
" SELECT C.CAMPAIGN_CODE, C.CAMPAIGN_NAME, C.CONTENT, C.START_TIME, C.END_TIME, C.STATUS, CA.STATUS AS AGENT_STATUS, C.CAMPAIGN_ID "
)
.
append
(
" SELECT C.CAMPAIGN_CODE, C.CAMPAIGN_NAME, C.CONTENT, C.START_TIME, C.END_TIME, C.STATUS, CA.STATUS AS AGENT_STATUS, C.CAMPAIGN_ID "
)
.
append
(
" FROM CAMPAIGN C INNER JOIN CAMPAIGN_AGENT CA ON C.CAMPAIGN_ID = CA.CAMPAIGN_ID "
)
.
append
(
" FROM CAMPAIGN C INNER JOIN CAMPAIGN_AGENT CA ON C.CAMPAIGN_ID = CA.CAMPAIGN_ID "
)
...
@@ -506,12 +509,15 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
...
@@ -506,12 +509,15 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
}
}
try
{
try
{
Query
query
=
entityManager
.
createNativeQuery
(
expression
.
toString
());
session
=
sessionFactory
.
openSession
();
session
.
beginTransaction
();
SQLQuery
query
=
session
.
createSQLQuery
(
expression
.
toString
());
query
.
setParameter
(
"pAgentId"
,
Long
.
parseLong
(
campaignRequestDto
.
getAgentId
()));
query
.
setParameter
(
"pAgentId"
,
Long
.
parseLong
(
campaignRequestDto
.
getAgentId
()));
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getCampaignCode
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getCampaignCode
())
&&
!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getCampaignCode
().
trim
())
)
{
String
[]
lstCode
=
campaignRequestDto
.
getCampaignCode
().
split
(
","
);
String
[]
lstCode
=
campaignRequestDto
.
getCampaignCode
().
split
(
","
);
query
.
setParameter
(
"pCampaignCode"
,
lstCode
);
query
.
setParameter
List
(
"pCampaignCode"
,
lstCode
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getCampaignName
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
campaignRequestDto
.
getCampaignName
()))
{
...
@@ -557,9 +563,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
...
@@ -557,9 +563,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query
.
setMaxResults
(
pageable
.
getPageSize
());
query
.
setMaxResults
(
pageable
.
getPageSize
());
}
}
List
<
Object
[]>
data
=
query
.
getResultList
();
List
<
Object
[]>
data
=
query
.
list
();
//TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(campaignRequestDto.getCampaignId()), Long.parseLong(campaignRequestDto.getCompanySiteId()));
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(campaignRequestDto.getCampaignId()), Long.parseLong(campaignRequestDto.getCompanySiteId()));
for
(
Object
[]
obj
:
data
)
{
for
(
Object
[]
obj
:
data
)
{
CampaignDTO
item
=
new
CampaignDTO
();
CampaignDTO
item
=
new
CampaignDTO
();
...
@@ -580,7 +584,11 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
...
@@ -580,7 +584,11 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
return
result
;
return
result
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// e.printStackTrace();
e
.
printStackTrace
();
}
finally
{
if
(
null
!=
session
)
{
session
.
close
();
}
}
}
return
result
;
return
result
;
...
...
src/main/java/com/viettel/campaign/repository/ccms_full/impl/CampaignRepositoryImpl.java
View file @
801ae339
...
@@ -4,10 +4,7 @@ import com.viettel.campaign.config.DataSourceQualify;
...
@@ -4,10 +4,7 @@ import com.viettel.campaign.config.DataSourceQualify;
import
com.viettel.campaign.model.ccms_full.CampaignCustomer
;
import
com.viettel.campaign.model.ccms_full.CampaignCustomer
;
import
com.viettel.campaign.repository.ccms_full.CampaignCustomerRepository
;
import
com.viettel.campaign.repository.ccms_full.CampaignCustomerRepository
;
import
com.viettel.campaign.repository.ccms_full.CampaignRepositoryCustom
;
import
com.viettel.campaign.repository.ccms_full.CampaignRepositoryCustom
;
import
com.viettel.campaign.utils.Constants
;
import
com.viettel.campaign.utils.*
;
import
com.viettel.campaign.utils.DataUtil
;
import
com.viettel.campaign.utils.HibernateUtil
;
import
com.viettel.campaign.utils.SQLBuilder
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.*
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
...
@@ -29,10 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -29,10 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.persistence.EntityManager
;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.PersistenceContext
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Repository
@Repository
public
class
CampaignRepositoryImpl
implements
CampaignRepositoryCustom
{
public
class
CampaignRepositoryImpl
implements
CampaignRepositoryCustom
{
...
@@ -52,6 +46,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -52,6 +46,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
@Override
@Override
public
ResultDTO
search
(
CampaignRequestDTO
requestDto
)
{
public
ResultDTO
search
(
CampaignRequestDTO
requestDto
)
{
TimeZone
tzClient
=
TimeZoneUtils
.
getZoneMinutes
((
long
)
requestDto
.
getTimezoneOffset
());
logger
.
info
(
"Start search campaign::"
);
logger
.
info
(
"Start search campaign::"
);
ResultDTO
result
=
new
ResultDTO
();
ResultDTO
result
=
new
ResultDTO
();
...
@@ -131,16 +126,16 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -131,16 +126,16 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
sb
.
append
(
" AND a.STATUS IN (:p_statuses) "
);
sb
.
append
(
" AND a.STATUS IN (:p_statuses) "
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
sb
.
append
(
" AND
TO_DATE(a.START_TIME, 'DD-MM-RR') >= TO_DATE(:p_frDateFr, 'YYYYMMDD
')"
);
sb
.
append
(
" AND
a.START_TIME >= TO_DATE(:p_frDateFr, 'DD/MM/YYYY HH24:MI:SS
')"
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateFr
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateFr
()))
{
sb
.
append
(
" AND
TO_DATE(a.START_TIME, 'DD-MM-RR') <= TO_DATE(:p_toDateFr, 'YYYYMMDD
')"
);
sb
.
append
(
" AND
a.START_TIME <= TO_DATE(:p_toDateFr, 'DD/MM/YYYY HH24:MI:SS
')"
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateTo
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateTo
()))
{
sb
.
append
(
" AND
TO_DATE(a.END_TIME, 'DD-MM-RR') >= TO_DATE(:p_frDateTo, 'YYYYMMDD
')"
);
sb
.
append
(
" AND
a.END_TIME >= TO_DATE(:p_frDateTo, 'DD/MM/YYYY HH24:MI:SS
')"
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateTo
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateTo
()))
{
sb
.
append
(
" AND
TO_DATE(a.END_TIME, 'DD-MM-RR') <= TO_DATE(:p_toDateTo, 'YYYYMMDD
')"
);
sb
.
append
(
" AND
a.END_TIME <= TO_DATE(:p_toDateTo, 'DD/MM/YYYY HH24:MI:SS
')"
);
}
}
if
(!
DataUtil
.
isNullOrZero
(
requestDto
.
getNumOfCusFr
()))
{
if
(!
DataUtil
.
isNullOrZero
(
requestDto
.
getNumOfCusFr
()))
{
sb
.
append
(
" AND a.CUSTOMER_NUMBER >= :p_cusNumFr"
);
sb
.
append
(
" AND a.CUSTOMER_NUMBER >= :p_cusNumFr"
);
...
@@ -185,16 +180,16 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -185,16 +180,16 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
query
.
setParameterList
(
"p_statuses"
,
statuses
);
query
.
setParameterList
(
"p_statuses"
,
statuses
);
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateFr
()))
{
query
.
setParameter
(
"p_frDateFr"
,
requestDto
.
getFromDateFr
(
));
query
.
setParameter
(
"p_frDateFr"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
DateTimeUtil
.
parseDate
(
"YYYYMMdd"
,
requestDto
.
getFromDateFr
()),
tzClient
));
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateTo
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getFromDateTo
()))
{
query
.
setParameter
(
"p_frDateTo"
,
requestDto
.
getFromDateTo
(
));
query
.
setParameter
(
"p_frDateTo"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
DateTimeUtil
.
parseDate
(
"YYYYMMdd"
,
requestDto
.
getFromDateTo
()),
tzClient
));
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateFr
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateFr
()))
{
query
.
setParameter
(
"p_toDateFr"
,
requestDto
.
getToDateFr
(
));
query
.
setParameter
(
"p_toDateFr"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
DateTimeUtil
.
parseDate
(
"YYYYMMdd"
,
requestDto
.
getToDateFr
()),
tzClient
));
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateTo
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getToDateTo
()))
{
query
.
setParameter
(
"p_toDateTo"
,
requestDto
.
getToDateTo
(
));
query
.
setParameter
(
"p_toDateTo"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
DateTimeUtil
.
parseDate
(
"YYYYMMdd"
,
requestDto
.
getToDateTo
()),
tzClient
));
}
}
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getTypes
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
requestDto
.
getTypes
()))
{
String
[]
types
=
requestDto
.
getTypes
().
split
(
","
);
String
[]
types
=
requestDto
.
getTypes
().
split
(
","
);
...
@@ -247,10 +242,18 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
...
@@ -247,10 +242,18 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
query
.
setMaxResults
(
pageable
.
getPageSize
());
query
.
setMaxResults
(
pageable
.
getPageSize
());
}
}
List
<
CampaignDTO
>
data
=
query
.
list
();
List
<
CampaignDTO
>
data
=
query
.
list
();
data
.
forEach
(
item
->
{
item
.
setStartTime
(
DateTimeUtil
.
parseDate
(
"dd/MM/yyyy HH:mm:ss"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
item
.
getStartTime
(),
tzClient
)));
item
.
setEndTime
(
DateTimeUtil
.
parseDate
(
"dd/MM/yyyy HH:mm:ss"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
item
.
getEndTime
(),
tzClient
)));
});
Page
<
CampaignDTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
Page
<
CampaignDTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
result
.
setData
(
dataPage
);
result
.
setData
(
dataPage
);
}
else
{
}
else
{
List
<
CampaignDTO
>
dataExport
=
query
.
list
();
List
<
CampaignDTO
>
dataExport
=
query
.
list
();
dataExport
.
forEach
(
item
->
{
item
.
setStartTime
(
DateTimeUtil
.
parseDate
(
"dd/MM/yyyy HH:mm:ss"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
item
.
getStartTime
(),
tzClient
)));
item
.
setEndTime
(
DateTimeUtil
.
parseDate
(
"dd/MM/yyyy HH:mm:ss"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
item
.
getEndTime
(),
tzClient
)));
});
result
.
setData
(
dataExport
);
result
.
setData
(
dataExport
);
}
}
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
...
...
src/main/java/com/viettel/campaign/service/CampaignExecuteService.java
View file @
801ae339
...
@@ -20,7 +20,7 @@ public interface CampaignExecuteService {
...
@@ -20,7 +20,7 @@ public interface CampaignExecuteService {
XSSFWorkbook
exportInteractiveResult
(
CampaignRequestDTO
dto
)
throws
IOException
;
XSSFWorkbook
exportInteractiveResult
(
CampaignRequestDTO
dto
)
throws
IOException
;
ResultDTO
searchCampaignExecute
(
CampaignRequestDTO
requestDto
,
String
xAuthToken
);
ResultDTO
searchCampaignExecute
(
CampaignRequestDTO
requestDto
);
ResultDTO
checkExecuteCampaign
(
CampaignRequestDTO
requestDto
);
ResultDTO
checkExecuteCampaign
(
CampaignRequestDTO
requestDto
);
...
@@ -36,6 +36,8 @@ public interface CampaignExecuteService {
...
@@ -36,6 +36,8 @@ public interface CampaignExecuteService {
ResultDTO
getAgentLogout
(
CampaignRequestDTO
dto
);
ResultDTO
getAgentLogout
(
CampaignRequestDTO
dto
);
ResultDTO
getLogoutContactResult
(
ReceiveCustLogDTO
dto
);
ResultDTO
updateContactCustResult
(
ContactCustResultDTO
dto
,
UserSession
userSession
);
ResultDTO
updateContactCustResult
(
ContactCustResultDTO
dto
,
UserSession
userSession
);
ResultDTO
draftAtTen
(
ContactCustResultDTO
dto
,
UserSession
userSession
);
ResultDTO
draftAtTen
(
ContactCustResultDTO
dto
,
UserSession
userSession
);
...
@@ -54,7 +56,7 @@ public interface CampaignExecuteService {
...
@@ -54,7 +56,7 @@ public interface CampaignExecuteService {
ResultDTO
updateListContactQuestResult
(
ContactQuestResultDTO
dto
);
ResultDTO
updateListContactQuestResult
(
ContactQuestResultDTO
dto
);
String
getDialModeAtCurrent
(
Long
c
ampaignId
,
Long
companySite
Id
);
String
getDialModeAtCurrent
(
Long
c
ompanySiteId
,
Long
campaign
Id
);
ResultDTO
getContactCustResultById
(
Long
contactCustResultId
);
ResultDTO
getContactCustResultById
(
Long
contactCustResultId
);
...
...
src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
View file @
801ae339
...
@@ -261,31 +261,43 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
...
@@ -261,31 +261,43 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
//</editor-fold: hungtt>
//</editor-fold: hungtt>
@Override
@Override
public
ResultDTO
searchCampaignExecute
(
CampaignRequestDTO
requestDto
,
String
xAuthToken
)
{
public
ResultDTO
searchCampaignExecute
(
CampaignRequestDTO
requestDto
)
{
ResultDTO
result
=
new
ResultDTO
();
ResultDTO
result
=
new
ResultDTO
();
Map
data
=
new
HashMap
();
Map
data
=
new
HashMap
();
UserSession
userSession
=
(
UserSession
)
RedisUtil
.
getInstance
().
get
(
xAuthToken
);
String
campaignSystemStatus
=
""
;
String
campaignExecuting
=
""
;
Integer
count
=
campaignExecuteRepository
.
searchCampaignExecute
(
requestDto
,
null
).
size
();
try
{
Integer
count
=
campaignExecuteRepository
.
searchCampaignExecute
(
requestDto
,
null
).
size
();
if
(
count
>
0
)
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
result
.
setTotalRow
(
count
);
result
.
setListData
(
campaignExecuteRepository
.
searchCampaignExecute
(
requestDto
,
SQLBuilder
.
buildPageable
(
requestDto
)));
Agents
agents
=
agentsRepository
.
findByAgentId
(
requestDto
.
getAgentId
());
//TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
if
(
agents
.
getUserStatus
()
!=
null
&&
agents
.
getCampaignSystemStatus
()
!=
null
)
{
if
(
count
>
0
)
{
if
(
agents
.
getUserStatus
().
equalsIgnoreCase
(
"CALLOUT"
)
&&
agents
.
getCampaignSystemStatus
().
equalsIgnoreCase
(
"AVAILABLE"
))
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0))
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
data
.
put
(
"dialModeManual"
,
"1"
);
result
.
setTotalRow
(
count
);
List
<
CampaignDTO
>
campaignList
=
campaignExecuteRepository
.
searchCampaignExecute
(
requestDto
,
SQLBuilder
.
buildPageable
(
requestDto
));
result
.
setListData
(
campaignList
);
Agents
agents
=
agentsRepository
.
findByAgentId
(
requestDto
.
getAgentId
());
if
(
agents
.
getCampaignSystemStatus
()
!=
null
&&
agents
.
getCampaignSystemStatus
().
equalsIgnoreCase
(
"AVAILABLE"
))
{
campaignSystemStatus
=
"1"
;
for
(
CampaignDTO
item
:
campaignList
)
{
if
(
item
.
getStatus
()
==
2
&&
item
.
getAgentStatus
()
==
1
)
{
campaignExecuting
=
item
.
getCampaignId
().
toString
();
break
;
}
}
}
}
data
.
put
(
"campaignSystemStatus"
,
campaignSystemStatus
);
data
.
put
(
"campaignExecuting"
,
campaignExecuting
);
result
.
setData
(
data
);
}
else
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
data
.
put
(
"dialModeManual"
,
campaignSystemStatus
);
data
.
put
(
"campaignExecuting"
,
campaignExecuting
);
result
.
setData
(
data
);
}
}
result
.
setData
(
data
);
}
catch
(
Exception
e
)
{
}
else
{
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
}
...
@@ -298,7 +310,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
...
@@ -298,7 +310,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
ResultDTO
result
=
new
ResultDTO
();
ResultDTO
result
=
new
ResultDTO
();
try
{
try
{
String
dialMode
=
getDialModeAtCurrent
(
Long
.
parseLong
(
requestDto
.
getC
ampaignId
()),
Long
.
parseLong
(
requestDto
.
getCompanySite
Id
()));
String
dialMode
=
getDialModeAtCurrent
(
Long
.
parseLong
(
requestDto
.
getC
ompanySiteId
()),
Long
.
parseLong
(
requestDto
.
getCampaign
Id
()));
VSAUsers
vsa
=
vsaUsersRepository
.
findByUserId
(
Long
.
parseLong
(
requestDto
.
getAgentId
()));
VSAUsers
vsa
=
vsaUsersRepository
.
findByUserId
(
Long
.
parseLong
(
requestDto
.
getAgentId
()));
AgentStatusStat
ass
=
agentStatusStatRepository
.
findByKzUserIdAndCurrentStatusNotIn
(
vsa
.
getUserKazooId
(),
Arrays
.
asList
(
"logged_out"
,
"campaign"
));
AgentStatusStat
ass
=
agentStatusStatRepository
.
findByKzUserIdAndCurrentStatusNotIn
(
vsa
.
getUserKazooId
(),
Arrays
.
asList
(
"logged_out"
,
"campaign"
));
if
(
ass
!=
null
)
{
if
(
ass
!=
null
)
{
...
@@ -325,6 +337,14 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
...
@@ -325,6 +337,14 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
ResultDTO
result
=
new
ResultDTO
();
ResultDTO
result
=
new
ResultDTO
();
try
{
try
{
if
(
requestDto
.
getType
()
==
2
)
{
List
<
CampaignAgent
>
ca
=
campaignAgentRepository
.
findByAgentId
(
Long
.
parseLong
(
requestDto
.
getAgentId
()));
for
(
CampaignAgent
item:
ca
)
{
item
.
setStatus
(
0
);
}
ca
=
campaignAgentRepository
.
saveAll
(
ca
);
}
// update acd_full.agents table
// update acd_full.agents table
Agents
agents
=
agentsRepository
.
findByAgentId
(
requestDto
.
getAgentId
());
Agents
agents
=
agentsRepository
.
findByAgentId
(
requestDto
.
getAgentId
());
agents
.
setAgentId
(
requestDto
.
getAgentId
());
agents
.
setAgentId
(
requestDto
.
getAgentId
());
...
@@ -334,11 +354,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
...
@@ -334,11 +354,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
Agents
a1
=
agentsRepository
.
save
(
agents
);
Agents
a1
=
agentsRepository
.
save
(
agents
);
// update ccms_full.campaign_agent table
// update ccms_full.campaign_agent table
List
<
CampaignAgent
>
ca
=
campaignAgentRepository
.
findByCampaignIdAndAgentId
(
Long
.
parseLong
(
requestDto
.
getCampaignId
()),
Long
.
parseLong
(
requestDto
.
getAgentId
()));
CampaignAgent
ca
=
campaignAgentRepository
.
findByCampaignIdAndAgentId
(
Long
.
parseLong
(
requestDto
.
getCampaignId
()),
Long
.
parseLong
(
requestDto
.
getAgentId
()));
for
(
CampaignAgent
item
:
ca
)
{
ca
.
setStatus
(
1
);
item
.
setStatus
(
1
);
ca
=
campaignAgentRepository
.
save
(
ca
);
}
List
<
CampaignAgent
>
ca1
=
campaignAgentRepository
.
saveAll
(
ca
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
...
@@ -542,11 +560,31 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
...
@@ -542,11 +560,31 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
try
{
try
{
agentsRepository
.
updateAgentLogoutFromCampaign
(
dto
.
getAgentId
(),
"LOGOUT"
);
agentsRepository
.
updateAgentLogoutFromCampaign
(
dto
.
getAgentId
(),
"LOGOUT"
);
// update ccms_full.campaign_agent table
// update ccms_full.campaign_agent table
List
<
CampaignAgent
>
ca
=
campaignAgentRepository
.
findByCampaignIdAndAgentId
(
Long
.
parseLong
(
dto
.
getCampaignId
()),
Long
.
parseLong
(
dto
.
getAgentId
()));
CampaignAgent
ca
=
campaignAgentRepository
.
findByCampaignIdAndAgentId
(
Long
.
parseLong
(
dto
.
getCampaignId
()),
Long
.
parseLong
(
dto
.
getAgentId
()));
for
(
CampaignAgent
item
:
ca
)
{
ca
.
setStatus
(
0
);
item
.
setStatus
(
1
);
ca
=
campaignAgentRepository
.
save
(
ca
);
}
List
<
CampaignAgent
>
ca1
=
campaignAgentRepository
.
saveAll
(
ca
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
}
catch
(
Exception
e
)
{
// e.printStackTrace();
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
ERROR
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
ERROR
);
}
return
result
;
}
@Override
public
ResultDTO
getLogoutContactResult
(
ReceiveCustLogDTO
dto
)
{
ResultDTO
result
=
new
ResultDTO
();
try
{
agentsRepository
.
updateAgentLogoutFromCampaign
(
dto
.
getAgentId
().
toString
(),
"AVAILABLE"
);
// update receive customer log
ReceiveCustLog
rcl
=
custLogRepository
.
getOne
(
dto
.
getReceiveCustLogId
());
rcl
.
setEndTime
(
new
Date
());
rcl
=
custLogRepository
.
save
(
rcl
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
result
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
...
@@ -840,7 +878,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
...
@@ -840,7 +878,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
}
}
@Override
@Override
public
String
getDialModeAtCurrent
(
Long
c
ampaignId
,
Long
companySite
Id
)
{
public
String
getDialModeAtCurrent
(
Long
c
ompanySiteId
,
Long
campaign
Id
)
{
// 0: manual, 1- Preview, 2-Progressive, 3-Super Progressive, 4- Predictive
// 0: manual, 1- Preview, 2-Progressive, 3-Super Progressive, 4- Predictive
try
{
try
{
TimeRangeDialMode
lstTimeRange
=
rangeDialModeRepository
.
findDialModeAtCurrent
(
companySiteId
,
campaignId
);
TimeRangeDialMode
lstTimeRange
=
rangeDialModeRepository
.
findDialModeAtCurrent
(
companySiteId
,
campaignId
);
...
...
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
View file @
801ae339
...
@@ -357,7 +357,7 @@ public class CampaignServiceImpl implements CampaignService {
...
@@ -357,7 +357,7 @@ public class CampaignServiceImpl implements CampaignService {
entity
.
setUpdateBy
(
campaignDTO
.
getUpdateBy
());
entity
.
setUpdateBy
(
campaignDTO
.
getUpdateBy
());
entity
.
setEndTime
(
campaignDTO
.
getEndTime
());
entity
.
setEndTime
(
campaignDTO
.
getEndTime
());
campaignRepository
.
save
(
entity
);
//
campaignRepository.save(entity);
UserActionLogDTO
userActionLog
=
new
UserActionLogDTO
();
UserActionLogDTO
userActionLog
=
new
UserActionLogDTO
();
userActionLog
.
setAgentId
(
null
);
userActionLog
.
setAgentId
(
null
);
...
@@ -368,7 +368,7 @@ public class CampaignServiceImpl implements CampaignService {
...
@@ -368,7 +368,7 @@ public class CampaignServiceImpl implements CampaignService {
userActionLog
.
setEndTime
(
null
);
userActionLog
.
setEndTime
(
null
);
userActionLog
.
setObjectId
(
entity
.
getCampaignId
());
userActionLog
.
setObjectId
(
entity
.
getCampaignId
());
userActionLog
.
setActionType
((
short
)
6
);
userActionLog
.
setActionType
((
short
)
6
);
userActionLogRepository
.
insertToUserActionLog
(
userActionLog
);
//
userActionLogRepository.insertToUserActionLog(userActionLog);
resultDTO
.
setData
(
entity
);
resultDTO
.
setData
(
entity
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
...
...
src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
View file @
801ae339
...
@@ -774,6 +774,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -774,6 +774,7 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Override
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
@Transactional
(
DataSourceQualify
.
CCMS_FULL
)
public
ResultDTO
searchCustomerList
(
SearchCustomerRequestDTO
searchCustomerRequestDTO
)
{
public
ResultDTO
searchCustomerList
(
SearchCustomerRequestDTO
searchCustomerRequestDTO
)
{
TimeZone
tzClient
=
TimeZoneUtils
.
getZoneMinutes
((
long
)
searchCustomerRequestDTO
.
getTimezoneOffset
());
ResultDTO
resultDTO
=
new
ResultDTO
();
ResultDTO
resultDTO
=
new
ResultDTO
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
SessionFactory
sessionFactory
=
HibernateUtil
.
getSessionFactory
();
...
@@ -814,7 +815,7 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -814,7 +815,7 @@ public class CustomerServiceImpl implements CustomerService {
sb
.
append
(
" AND a.STATUS = 1"
);
sb
.
append
(
" AND a.STATUS = 1"
);
sb
.
append
(
" AND a.COMPANY_SITE_ID = :p_company_site_id"
);
sb
.
append
(
" AND a.COMPANY_SITE_ID = :p_company_site_id"
);
sb
.
append
(
" AND
to_date(CREATE_AT, 'DD-MM-RR') >= to_date(:p_date_from, 'YYYYMMDD') AND to_date(CREATE_AT, 'DD-MM-RR') <= to_date(:p_date_to, 'YYYYMMDD
')"
);
sb
.
append
(
" AND
CREATE_AT >= to_date(:p_date_from, 'DD/MM/YYYY HH24:MI:SS') AND CREATE_AT <= to_date(:p_date_to, 'DD/MM/YYYY HH24:MI:SS
')"
);
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListCode
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListCode
()))
{
sb
.
append
(
" AND UPPER(CUSTOMER_LIST_CODE) LIKE UPPER(:p_list_code)"
);
sb
.
append
(
" AND UPPER(CUSTOMER_LIST_CODE) LIKE UPPER(:p_list_code)"
);
...
@@ -828,8 +829,8 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -828,8 +829,8 @@ public class CustomerServiceImpl implements CustomerService {
SQLQuery
query
=
session
.
createSQLQuery
(
sb
.
toString
());
SQLQuery
query
=
session
.
createSQLQuery
(
sb
.
toString
());
query
.
setParameter
(
"p_company_site_id"
,
searchCustomerRequestDTO
.
getCompanySiteId
());
query
.
setParameter
(
"p_company_site_id"
,
searchCustomerRequestDTO
.
getCompanySiteId
());
query
.
setParameter
(
"p_date_from"
,
searchCustomerRequestDTO
.
getConvertedDateFrom
(
));
query
.
setParameter
(
"p_date_from"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
DateTimeUtil
.
parseDate
(
"YYYYMMdd"
,
searchCustomerRequestDTO
.
getConvertedDateFrom
()),
tzClient
));
query
.
setParameter
(
"p_date_to"
,
searchCustomerRequestDTO
.
getConvertedDateTo
(
));
query
.
setParameter
(
"p_date_to"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
DateTimeUtil
.
parseDate
(
"YYYYMMdd"
,
searchCustomerRequestDTO
.
getConvertedDateTo
()),
tzClient
));
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListCode
()))
{
if
(!
DataUtil
.
isNullOrEmpty
(
searchCustomerRequestDTO
.
getCustomerListCode
()))
{
query
.
setParameter
(
"p_list_code"
,
"%"
+
query
.
setParameter
(
"p_list_code"
,
"%"
+
...
@@ -877,6 +878,10 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -877,6 +878,10 @@ public class CustomerServiceImpl implements CustomerService {
List
<
CustomerListDTO
>
data
=
query
.
list
();
List
<
CustomerListDTO
>
data
=
query
.
list
();
Page
<
CustomerListDTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
Page
<
CustomerListDTO
>
dataPage
=
new
PageImpl
<>(
data
,
pageable
,
count
);
dataPage
.
forEach
(
item
->
{
item
.
setCreateAt
(
DateTimeUtil
.
parseDate
(
"dd/MM/yyyy HH:mm:ss"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
item
.
getCreateAt
(),
tzClient
)));
item
.
setUpdateAt
(
DateTimeUtil
.
parseDate
(
"dd/MM/yyyy HH:mm:ss"
,
TimeZoneUtils
.
toDateStringWithTimeZone
(
item
.
getUpdateAt
(),
tzClient
)));
});
resultDTO
.
setData
(
dataPage
);
resultDTO
.
setData
(
dataPage
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setErrorCode
(
Constants
.
ApiErrorCode
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
resultDTO
.
setDescription
(
Constants
.
ApiErrorDesc
.
SUCCESS
);
...
...
src/main/java/com/viettel/campaign/service/impl/ScenarioQuestionServiceImpl.java
View file @
801ae339
...
@@ -69,6 +69,7 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
...
@@ -69,6 +69,7 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
ResultDTO
resultDTO
=
new
ResultDTO
();
ResultDTO
resultDTO
=
new
ResultDTO
();
List
<
ScenarioAnswerDTO
>
lstAnswers
=
new
ArrayList
<>();
List
<
ScenarioAnswerDTO
>
lstAnswers
=
new
ArrayList
<>();
List
<
ScenarioAnswer
>
lstAnswersToInsert
=
new
ArrayList
<>();
List
<
ScenarioAnswer
>
lstAnswersToInsert
=
new
ArrayList
<>();
scenarioQuestionDTO
.
setQuestion
(
scenarioQuestionDTO
.
getQuestion
().
trim
());
try
{
try
{
ScenarioQuestion
scenarioQuestion
=
modelMapper
.
map
(
scenarioQuestionDTO
,
ScenarioQuestion
.
class
);
ScenarioQuestion
scenarioQuestion
=
modelMapper
.
map
(
scenarioQuestionDTO
,
ScenarioQuestion
.
class
);
...
...
src/main/java/com/viettel/campaign/utils/TimeZoneUtils.java
0 → 100644
View file @
801ae339
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
com.viettel.campaign.utils
;
import
org.apache.log4j.Logger
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.TimeZone
;
import
java.util.concurrent.TimeUnit
;
import
java.util.logging.Level
;
/**
*
* @author phamky
*/
public
class
TimeZoneUtils
{
private
static
Long
getTimeZone
(
TimeZone
tz
)
{
return
TimeUnit
.
MILLISECONDS
.
toHours
(
tz
.
getRawOffset
());
}
private
static
Long
getTimeZoneToMinutes
(
TimeZone
tz
)
{
return
TimeUnit
.
MILLISECONDS
.
toMinutes
(
tz
.
getRawOffset
());
}
public
static
String
toQueryTimeZoneZero
(
Date
date
){
String
dateStr
=
toDateStringWithTimeZoneZero
(
date
);
return
"to_date( '"
+
dateStr
+
"', 'DD/MM/YYYY HH24:MI:SS')"
;
}
public
static
String
changeTimeZoneString
(
String
dateStr
,
TimeZone
tz
){
try
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
Date
date
=
sdf
.
parse
(
dateStr
);
sdf
.
setTimeZone
(
tz
);
return
sdf
.
format
(
date
);
}
catch
(
ParseException
ex
)
{
}
return
""
;
}
public
static
String
changeTimeZoneStringPattern
(
String
dateStr
,
TimeZone
tz
,
String
pattern
){
try
{
SimpleDateFormat
sdf1
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
Date
date
=
sdf1
.
parse
(
dateStr
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
sdf
.
setTimeZone
(
tz
);
return
sdf
.
format
(
date
);
}
catch
(
ParseException
ex
)
{
}
return
""
;
}
public
static
String
toDateStringWithTimeZoneZero
(
Date
date
){
TimeZone
tz
=
getZone
(
0
l
);
return
toDateStringWithTimeZone
(
date
,
tz
);
}
public
static
String
toDateStringWithTimeZonePattern
(
Date
date
,
long
tz
,
String
pattern
){
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
sdf
.
setTimeZone
(
getZone
(
tz
));
return
sdf
.
format
(
date
);
}
// public static String toHourStringWithTimeZonePattern(Long hour, long tz){
// SimpleDateFormat sdf = new SimpleDateFormat(pattern);
// sdf.setTimeZone(getZone(tz));
// return sdf.format(date);
// }
public
static
String
toDateStringWithTimeZonePattern
(
Date
date
,
TimeZone
tz
,
String
pattern
){
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
sdf
.
setTimeZone
(
tz
);
return
sdf
.
format
(
date
);
}
public
static
String
toDateStringWithTimeZone
(
Date
date
,
TimeZone
tz
){
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"dd/MM/yyyy HH:mm:ss"
);
sdf
.
setTimeZone
(
tz
);
return
sdf
.
format
(
date
);
}
public
static
TimeZone
getZone
(
Long
timeZone
){
if
(
timeZone
==
null
){
//timezone is null, return default
return
TimeZone
.
getDefault
();
}
String
[]
ids
=
TimeZone
.
getAvailableIDs
();
for
(
String
id
:
ids
)
{
TimeZone
tz
=
TimeZone
.
getTimeZone
(
id
);
if
(
getTimeZone
(
tz
).
equals
(
timeZone
)){
//zone need change
return
tz
;
}
}
return
TimeZone
.
getDefault
();
}
public
static
TimeZone
getZoneMinutes
(
Long
timeZone
){
if
(
timeZone
==
null
){
//timezone is null, return default
return
TimeZone
.
getDefault
();
}
String
[]
ids
=
TimeZone
.
getAvailableIDs
();
for
(
String
id
:
ids
)
{
TimeZone
tz
=
TimeZone
.
getTimeZone
(
id
);
if
(
getTimeZoneToMinutes
(
tz
).
equals
(
timeZone
)){
//zone need change
return
tz
;
}
}
return
TimeZone
.
getDefault
();
}
public
static
Date
changeTimeZone
(
Date
date
,
Long
timeZone
){
if
(
timeZone
==
null
){
//timezone is null, do not change timezone
return
date
;
}
String
[]
ids
=
TimeZone
.
getAvailableIDs
();
for
(
String
id
:
ids
)
{
TimeZone
tz
=
TimeZone
.
getTimeZone
(
id
);
if
(
getTimeZone
(
tz
).
equals
(
timeZone
)){
//zone need change
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
df
.
setTimeZone
(
tz
);
try
{
SimpleDateFormat
df2
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
newDate
=
df2
.
parse
(
df
.
format
(
date
));
System
.
out
.
println
(
df2
.
format
(
newDate
));
return
newDate
;
}
catch
(
ParseException
ex
)
{
}
}
}
return
date
;
}
public
static
void
main
(
String
args
[]){
Date
date
=
new
Date
();
System
.
out
.
println
(
changeTimeZone
(
date
,
-
6
l
));
System
.
out
.
println
(
changeTimeZone
(
date
,
0
l
));
System
.
out
.
println
(
getZone
(
0
l
));
}
}
src/main/java/com/viettel/campaign/web/dto/CampaignDTO.java
View file @
801ae339
...
@@ -66,4 +66,7 @@ public class CampaignDTO extends BaseDTO {
...
@@ -66,4 +66,7 @@ public class CampaignDTO extends BaseDTO {
private
String
sessionId
;
private
String
sessionId
;
private
Long
numOfInteractedCus
;
private
Long
numOfInteractedCus
;
private
Long
numOfNotInteractedCus
;
private
Long
numOfNotInteractedCus
;
//timezone to get true date
private
Double
timezone
;
}
}
src/main/java/com/viettel/campaign/web/dto/request_dto/SearchCustomerRequestDTO.java
View file @
801ae339
...
@@ -12,4 +12,5 @@ public class SearchCustomerRequestDTO extends BaseDTO {
...
@@ -12,4 +12,5 @@ public class SearchCustomerRequestDTO extends BaseDTO {
String
convertedDateFrom
;
String
convertedDateFrom
;
String
convertedDateTo
;
String
convertedDateTo
;
String
companySiteId
;
String
companySiteId
;
Integer
timezoneOffset
;
}
}
src/main/java/com/viettel/campaign/web/rest/CampaignExecuteController.java
View file @
801ae339
...
@@ -34,9 +34,8 @@ public class CampaignExecuteController {
...
@@ -34,9 +34,8 @@ public class CampaignExecuteController {
@PostMapping
(
"/searchCampaignExecute"
)
@PostMapping
(
"/searchCampaignExecute"
)
@ResponseBody
@ResponseBody
public
ResponseEntity
<
ResultDTO
>
searchCampaignExecute
(
@RequestBody
CampaignRequestDTO
requestDto
,
HttpServletRequest
request
)
{
public
ResponseEntity
<
ResultDTO
>
searchCampaignExecute
(
@RequestBody
CampaignRequestDTO
requestDto
)
{
String
xAuthToken
=
request
.
getHeader
(
"X-Auth-Token"
);
ResultDTO
result
=
campaignExecuteService
.
searchCampaignExecute
(
requestDto
);
ResultDTO
result
=
campaignExecuteService
.
searchCampaignExecute
(
requestDto
,
xAuthToken
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
...
@@ -89,6 +88,13 @@ public class CampaignExecuteController {
...
@@ -89,6 +88,13 @@ public class CampaignExecuteController {
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
@PostMapping
(
"/getLogoutContactResult"
)
@ResponseBody
public
ResponseEntity
<
ResultDTO
>
getLogoutContactResult
(
@RequestBody
ReceiveCustLogDTO
requestDto
)
{
ResultDTO
result
=
campaignExecuteService
.
getLogoutContactResult
(
requestDto
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@PostMapping
(
"/searchInteractiveResult"
)
@PostMapping
(
"/searchInteractiveResult"
)
@ResponseBody
@ResponseBody
public
ResponseEntity
<
ResultDTO
>
searchInteractiveResult
(
@RequestBody
CampaignRequestDTO
dto
)
throws
Exception
{
public
ResponseEntity
<
ResultDTO
>
searchInteractiveResult
(
@RequestBody
CampaignRequestDTO
dto
)
throws
Exception
{
...
...
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