Commit 77af9bb2 authored by Phạm Duy Phi's avatar Phạm Duy Phi
parents 2dd144f3 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>
......
...@@ -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();
......
package com.viettel.campaign.model.ccms_full;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Entity
@Table(name = "AGENT_STATUS_STAT")
@Getter
@Setter
public class AgentStatusStat {
@Id
@NotNull
@GeneratedValue(generator = "AGENT_STATUS_STAT_SEQ")
@SequenceGenerator(name = "AGENT_STATUS_STAT_SEQ", sequenceName = "AGENT_STATUS_STAT_SEQ", allocationSize = 1)
@Basic(optional = false)
@Column(name = "KZ_ACCOUNT_ID")
@NotNull
private String kzAccountId;
@Column(name = "KZ_USER_ID")
@NotNull
private String kzUserId;
@Column(name = "CURRENT_STATUS")
@NotNull
private String currentStatus;
@Column(name = "TIMESTAMP")
@NotNull
private String timestamp;
@Column(name = "PREVIOUS_STATUS")
private String previousStatus;
@Column(name = "PREVIOUS_STATUS_DURATION")
private Long previousStatusDuration;
@Column(name = "ID")
@NotNull
private Long id;
@Column(name = "CHANNEL")
@NotNull
private String channel;
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.AgentStatusStat;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Repository
@Transactional(DataSourceQualify.CCMS_FULL)
public interface AgentStatusStatRepository extends JpaRepository<AgentStatusStat, Long> {
AgentStatusStat findByKzUserIdAndCurrentStatusNotIn(String kzUserId, List<String> currentStatus);
}
...@@ -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)")
......
...@@ -13,6 +13,9 @@ import java.util.List; ...@@ -13,6 +13,9 @@ import java.util.List;
@Repository @Repository
public interface CampaignCfgRepository extends JpaRepository<CampaignCfg, Long> { public interface CampaignCfgRepository extends JpaRepository<CampaignCfg, Long> {
@Query("select c from CampaignCfg c where c.companySiteId=:p_company_site_id and c.status = 1")
List<CampaignCfg> findByCampaignCompleteCodeId( @Param("p_company_site_id") Long p_company_site_id);
@Query("select c from CampaignCfg c where c.campaignCompleteCodeId in (:p_ids) and c.companySiteId=:p_company_site_id and c.status = 1") @Query("select c from CampaignCfg c where c.campaignCompleteCodeId in (:p_ids) and c.companySiteId=:p_company_site_id and c.status = 1")
List<CampaignCfg> findAllCampaignCfg(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id); List<CampaignCfg> findAllCampaignCfg(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
......
...@@ -21,13 +21,13 @@ public interface TimeRangeDialModeRepository extends JpaRepository<TimeRangeDial ...@@ -21,13 +21,13 @@ public interface TimeRangeDialModeRepository extends JpaRepository<TimeRangeDial
List<TimeRangeDialMode> findTimeRangeDialModeByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId); List<TimeRangeDialMode> findTimeRangeDialModeByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
@Query(value = "SELECT * " + @Query(value = "SELECT * " +
"FROM (SELECT Z.* " + "FROM (SELECT R.* " +
" FROM TIME_ZONE_DIAL_MODE Z INNER JOIN CAMPAIGN C ON Z.CAMPAIGN_ID = C.CAMPAIGN_ID " + " FROM TIME_RANGE_DIAL_MODE R INNER JOIN CAMPAIGN C ON R.CAMPAIGN_ID = C.CAMPAIGN_ID" +
" WHERE Z.COMPANY_SITE_ID = :companySiteId " + " WHERE R.COMPANY_SITE_ID = :companySiteId " +
" AND Z.CAMPAIGN_ID = :campaignId " + " AND R.CAMPAIGN_ID = :campaignId " +
" AND TO_DATE(START_TIME, 'YYYY/MM/DD') <= TO_DATE(SYSDATE, 'YYYY/MM/DD') " + " AND C.START_TIME <= SYSDATE " +
" AND TO_DATE((to_char(SYSDATE, 'YYYY/MM/DD') || ' ' || Z.HOUR || ':' || Z.MINUTE || ':00'), 'YYYY/MM/DD HH24:MI:SS') <= SYSDATE " + " AND R.START_TIME <= SYSDATE " +
" ORDER BY TO_DATE((to_char(SYSDATE, 'YYYY/MM/DD') || ' ' || Z.HOUR || ':' || Z.MINUTE || ':00'), 'YYYY/MM/DD HH24:MI:SS') DESC " + " ORDER BY R.START_TIME DESC " +
" ) WHERE ROWNUM = 1", nativeQuery = true) " ) WHERE ROWNUM = 1", nativeQuery = true)
TimeRangeDialMode findDialModeAtCurrent(@Param("companySiteId") Long companySiteId, @Param("campaignId") Long campaignId); TimeRangeDialMode findDialModeAtCurrent(@Param("companySiteId") Long companySiteId, @Param("campaignId") Long campaignId);
......
...@@ -21,14 +21,15 @@ public interface TimeZoneDialModeRepository extends JpaRepository<TimeZoneDialMo ...@@ -21,14 +21,15 @@ public interface TimeZoneDialModeRepository extends JpaRepository<TimeZoneDialMo
List<TimeZoneDialMode> findTimeZoneDialModeByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId); List<TimeZoneDialMode> findTimeZoneDialModeByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
@Query(value = "SELECT * " + @Query(value = "SELECT * " +
"FROM (SELECT R.* " + "FROM (SELECT Z.* " +
" FROM TIME_RANGE_DIAL_MODE R " + " FROM TIME_ZONE_DIAL_MODE Z INNER JOIN CAMPAIGN C ON Z.CAMPAIGN_ID = C.CAMPAIGN_ID " +
" WHERE R.CAMPAIGN_ID = 11 " + " WHERE Z.COMPANY_SITE_ID = :companySiteId " +
" AND R.COMPANY_SITE_ID = 662691 " + " AND Z.CAMPAIGN_ID = :campaignId " +
" AND TO_DATE(R.START_TIME, 'YYYY/MM/DD HH24:MI:SS') <= TO_DATE(SYSDATE, 'YYYY/MM/DD HH24:MI:SS') " + " AND TO_CHAR(C.START_TIME, 'YYYY/MM/DD') <= TO_CHAR(SYSDATE, 'YYYY/MM/DD') " +
" ORDER BY R.START_TIME DESC " + " AND TO_DATE((TO_CHAR(SYSDATE, 'YYYY/MM/DD') || ' ' || Z.HOUR || ':' || Z.MINUTE || ':00'), 'YYYY/MM/DD HH24:MI:SS') <= SYSDATE " +
" ORDER BY TO_DATE((TO_CHAR(SYSDATE, 'YYYY/MM/DD') || ' ' || Z.HOUR || ':' || Z.MINUTE || ':00'), 'YYYY/MM/DD HH24:MI:SS') DESC " +
" ) WHERE ROWNUM = 1", nativeQuery = true) " ) WHERE ROWNUM = 1", nativeQuery = true)
TimeZoneDialMode findDialModeAtCurrent(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId); TimeZoneDialMode findDialModeAtCurrent(@Param("companySiteId") Long companySiteId, @Param("campaignId") Long campaignId);
void deleteAllByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId); void deleteAllByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
} }
...@@ -6,5 +6,8 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -6,5 +6,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List; import java.util.List;
public interface VSAUsersRepository extends JpaRepository<VSAUsers, Long> { public interface VSAUsersRepository extends JpaRepository<VSAUsers, Long> {
List<VSAUsers> findAllByCompanySiteId(Long companySiteId); List<VSAUsers> findAllByCompanySiteId(Long companySiteId);
VSAUsers findByUserId(Long userId);
} }
...@@ -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.setParameterList("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;
......
...@@ -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);
...@@ -543,7 +546,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -543,7 +546,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
sb.append(" select column_name columnName, null customizeFieldId, 1 isFix from user_tab_columns, dual"); sb.append(" select column_name columnName, null customizeFieldId, 1 isFix from user_tab_columns, dual");
sb.append(" where table_name = 'CUSTOMER'"); sb.append(" where table_name = 'CUSTOMER'");
sb.append(" )"); sb.append(" )");
sb.append(" select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)"); sb.append(" select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where campaign_id = :p_campaign_id and column_name is not null)");
sb.append(" union all"); sb.append(" union all");
sb.append(" select title columnName, customize_field_id customizeFieldId, 0 isFix from customize_fields, dual"); sb.append(" select title columnName, customize_field_id customizeFieldId, 0 isFix from customize_fields, dual");
sb.append(" where function_code = 'CUSTOMER'"); sb.append(" where function_code = 'CUSTOMER'");
......
...@@ -20,7 +20,7 @@ public interface CampaignCfgService { ...@@ -20,7 +20,7 @@ public interface CampaignCfgService {
ResultDTO deleteList(CampaignCfgRequestDTO campaignCfgRequestDTO); ResultDTO deleteList(CampaignCfgRequestDTO campaignCfgRequestDTO);
ResultDTO deleteById(Long id); ResultDTO deleteById(CampaignCfgRequestDTO campaignCfgRequestDTO);
ResultDTO findMaxValueCampaignCompleteCode(CampaignCfgDTO completeCodeDTO); ResultDTO findMaxValueCampaignCompleteCode(CampaignCfgDTO completeCodeDTO);
......
...@@ -20,7 +20,9 @@ public interface CampaignExecuteService { ...@@ -20,7 +20,9 @@ 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 getExecuteCampaign(CampaignRequestDTO requestDto); ResultDTO getExecuteCampaign(CampaignRequestDTO requestDto);
...@@ -34,6 +36,8 @@ public interface CampaignExecuteService { ...@@ -34,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);
...@@ -52,7 +56,7 @@ public interface CampaignExecuteService { ...@@ -52,7 +56,7 @@ public interface CampaignExecuteService {
ResultDTO updateListContactQuestResult(ContactQuestResultDTO dto); ResultDTO updateListContactQuestResult(ContactQuestResultDTO dto);
String getDialModeAtCurrent(Long campaignId, Long companySiteId); String getDialModeAtCurrent(Long companySiteId, Long campaignId);
ResultDTO getContactCustResultById(Long contactCustResultId); ResultDTO getContactCustResultById(Long contactCustResultId);
......
...@@ -241,10 +241,14 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -241,10 +241,14 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCompleteCode(CampaignCfgRequestDTO completeCodeDTO) { public ResultDTO deleteCompleteCode(CampaignCfgRequestDTO completeCodeDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
List<Long> listId = new ArrayList<>();
listId.add(completeCodeDTO.getCampaignCompleteCodeID());
try { try {
// delete // delete
if (completeCodeDTO != null) { if (completeCodeDTO != null) {
// completeCodeRepository.deleteCampaignCompleteCodeBy(completeCodeDTO.getCampaignCompleteCodeID(), completeCodeDTO.getCompanySiteId());
if (completeCodeRepository.findAllCampaignCfg(listId, completeCodeDTO.getCompanySiteId()).size() > 0) {
completeCodeRepository.deleteCampaignCompleteCodeBy(completeCodeDTO.getCampaignCompleteCodeID(), completeCodeDTO.getCompanySiteId()); completeCodeRepository.deleteCampaignCompleteCodeBy(completeCodeDTO.getCampaignCompleteCodeID(), completeCodeDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
...@@ -254,8 +258,14 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -254,8 +258,14 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} }
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
logger.error(e.getMessage(), e);
} }
return resultDTO; return resultDTO;
...@@ -284,25 +294,35 @@ public class CampaignCfgServiceImpl implements CampaignCfgService { ...@@ -284,25 +294,35 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
} }
} catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
logger.error(e.getMessage(), e);
} }
return resultDTO; return resultDTO;
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteById(Long id) { public ResultDTO deleteById(CampaignCfgRequestDTO completeCodeDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
try { try {
completeCodeRepository.deleteById(id); if (completeCodeDTO != null) {
result.setErrorCode(Constants.Status.ACTIVE_STR); if (completeCodeRepository.findAllCampaignCfg(completeCodeDTO.getListId(), completeCodeDTO.getCompanySiteId()).size() > 0) {
result.setDescription(Constants.Status.ACTIVE_STR); completeCodeRepository.deletedList(completeCodeDTO.getListId(), completeCodeDTO.getCompanySiteId());
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) { } catch (Exception e) {
result.setErrorCode("-1"); // e.printStackTrace();
return result; logger.error(e.getMessage(), e);
} }
result.setErrorCode("0");
return result; return result;
} }
......
...@@ -79,6 +79,12 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -79,6 +79,12 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Autowired @Autowired
CustomerRepository customerRepository; CustomerRepository customerRepository;
@Autowired
AgentStatusStatRepository agentStatusStatRepository;
@Autowired
VSAUsersRepository vsaUsersRepository;
public CampaignExecuteServiceImp() throws NoSuchAlgorithmException { public CampaignExecuteServiceImp() throws NoSuchAlgorithmException {
} }
...@@ -255,31 +261,43 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -255,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 = "";
try {
Integer count = campaignExecuteRepository.searchCampaignExecute(requestDto, null).size(); Integer count = campaignExecuteRepository.searchCampaignExecute(requestDto, null).size();
if (count > 0) { if (count > 0) {
result.setErrorCode(Constants.ApiErrorCode.SUCCESS); result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS); result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setTotalRow(count); result.setTotalRow(count);
result.setListData(campaignExecuteRepository.searchCampaignExecute(requestDto, SQLBuilder.buildPageable(requestDto))); List<CampaignDTO> campaignList = campaignExecuteRepository.searchCampaignExecute(requestDto, SQLBuilder.buildPageable(requestDto));
result.setListData(campaignList);
Agents agents = agentsRepository.findByAgentId(requestDto.getAgentId()); Agents agents = agentsRepository.findByAgentId(requestDto.getAgentId());
//TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId())); if (agents.getCampaignSystemStatus() != null && agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId())); campaignSystemStatus = "1";
for (CampaignDTO item : campaignList) {
if (agents.getUserStatus() != null && agents.getCampaignSystemStatus() != null) { if (item.getStatus() == 2 && item.getAgentStatus() == 1) {
if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) { campaignExecuting = item.getCampaignId().toString();
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0)) break;
data.put("dialModeManual", "1"); }
} }
} }
data.put("campaignSystemStatus", campaignSystemStatus);
data.put("campaignExecuting", campaignExecuting);
result.setData(data); result.setData(data);
} else { } else {
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
data.put("dialModeManual", campaignSystemStatus);
data.put("campaignExecuting", campaignExecuting);
result.setData(data);
}
} catch (Exception e) {
result.setErrorCode(Constants.ApiErrorCode.ERROR); result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR); result.setDescription(Constants.ApiErrorDesc.ERROR);
} }
...@@ -288,11 +306,45 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -288,11 +306,45 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
} }
@Override @Override
public ResultDTO getExecuteCampaign(CampaignRequestDTO requestDto) { public ResultDTO checkExecuteCampaign(CampaignRequestDTO requestDto) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
try {
String dialMode = getDialModeAtCurrent(Long.parseLong(requestDto.getCompanySiteId()), Long.parseLong(requestDto.getCampaignId())); String dialMode = getDialModeAtCurrent(Long.parseLong(requestDto.getCompanySiteId()), Long.parseLong(requestDto.getCampaignId()));
VSAUsers vsa = vsaUsersRepository.findByUserId(Long.parseLong(requestDto.getAgentId()));
AgentStatusStat ass = agentStatusStatRepository.findByKzUserIdAndCurrentStatusNotIn(vsa.getUserKazooId(), Arrays.asList("logged_out", "campaign"));
if (ass != null) {
result.setErrorCode("02");
result.setDescription("campaign-agents-err-callout");
} else if (dialMode.equalsIgnoreCase("-1")) {
result.setErrorCode("03");
result.setDescription("campaign-agents-err-dial-mode");
} else {
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 getExecuteCampaign(CampaignRequestDTO requestDto) {
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());
...@@ -302,11 +354,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -302,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);
...@@ -510,11 +560,31 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -510,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);
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;
} }
List<CampaignAgent> ca1 = campaignAgentRepository.saveAll(ca);
@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);
...@@ -808,15 +878,15 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -808,15 +878,15 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
} }
@Override @Override
public String getDialModeAtCurrent(Long campaignId, Long companySiteId) { public String getDialModeAtCurrent(Long companySiteId, Long campaignId) {
// 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);
TimeZoneDialMode lstTimeZone = zoneDialModeRepository.findDialModeAtCurrent(companySiteId, campaignId); TimeZoneDialMode lstTimeZone = zoneDialModeRepository.findDialModeAtCurrent(companySiteId, campaignId);
if (lstTimeRange.getTimeRangeDialModeId() != null) { if (lstTimeRange != null) {
return lstTimeRange.getDialMode().toString(); return lstTimeRange.getDialMode().toString();
} else if (lstTimeZone.getTimeZoneDialModeId() != null) { } else if (lstTimeZone != null) {
return lstTimeZone.getDialMode().toString(); return lstTimeZone.getDialMode().toString();
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -130,6 +130,8 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -130,6 +130,8 @@ public class CampaignServiceImpl implements CampaignService {
public ResultDTO addNewCampaign(CampaignDTO campaignDTO) { public ResultDTO addNewCampaign(CampaignDTO campaignDTO) {
logger.info("=== Start add new campaign "); logger.info("=== Start add new campaign ");
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
campaignDTO.setCampaignName(campaignDTO.getCampaignName().trim());
campaignDTO.setContent(campaignDTO.getContent().trim());
Campaign campaign = modelMapper.map(campaignDTO, Campaign.class); Campaign campaign = modelMapper.map(campaignDTO, Campaign.class);
Long campaignId; Long campaignId;
List<TimeZoneDialModeDTO> timeZoneDialModes = new ArrayList<>(); List<TimeZoneDialModeDTO> timeZoneDialModes = new ArrayList<>();
...@@ -355,7 +357,7 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -355,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);
...@@ -366,7 +368,7 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -366,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);
......
...@@ -789,6 +789,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -789,6 +789,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();
...@@ -829,7 +830,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -829,7 +830,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)");
...@@ -843,8 +844,8 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -843,8 +844,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", "%" +
...@@ -892,6 +893,10 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -892,6 +893,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);
......
...@@ -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);
...@@ -83,6 +84,7 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService { ...@@ -83,6 +84,7 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
item.setScenarioQuestionId(scenarioQuestion.getScenarioQuestionId()); item.setScenarioQuestionId(scenarioQuestion.getScenarioQuestionId());
item.setCreateTime(new Date()); item.setCreateTime(new Date());
item.setStatus((short) 1); item.setStatus((short) 1);
item.setAnswer(item.getAnswer().trim());
ScenarioAnswer answer = modelMapper.map(item, ScenarioAnswer.class); ScenarioAnswer answer = modelMapper.map(item, ScenarioAnswer.class);
lstAnswersToInsert.add(answer); lstAnswersToInsert.add(answer);
}); });
......
/*
* 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(0l);
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, -6l));
System.out.println(changeTimeZone(date, 0l));
System.out.println(getZone(0l));
}
}
...@@ -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;
} }
...@@ -10,5 +10,5 @@ public class CampaignCfgRequestDTO { ...@@ -10,5 +10,5 @@ public class CampaignCfgRequestDTO {
List<Long> listId; List<Long> listId;
Long companySiteId; Long companySiteId;
Long campaignCompleteCodeID; Long campaignCompleteCodeID;
String completeValue;
} }
...@@ -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;
} }
...@@ -106,9 +106,9 @@ public class CampaignCfgController { ...@@ -106,9 +106,9 @@ public class CampaignCfgController {
@PostMapping("/deleteById") @PostMapping("/deleteById")
@ResponseBody @ResponseBody
public ResultDTO deleteById(@RequestParam("id") Long id){ public ResultDTO deleteById(@RequestBody @Valid CampaignCfgRequestDTO campaignCfgRequestDTO){
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
resultDTO = completeCodeService.deleteById(id); resultDTO = completeCodeService.deleteById(campaignCfgRequestDTO);
return resultDTO; return resultDTO;
} }
......
...@@ -34,9 +34,15 @@ public class CampaignExecuteController { ...@@ -34,9 +34,15 @@ 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);
}
@PostMapping("/checkExecuteCampaign")
@ResponseBody
public ResponseEntity<ResultDTO> checkExecuteCampaign(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignExecuteService.checkExecuteCampaign(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
...@@ -82,6 +88,13 @@ public class CampaignExecuteController { ...@@ -82,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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment