Commit 09b75382 authored by ='s avatar =

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/viettel/campaign/web/rest/CampaignController.java
#	src/main/java/com/viettel/campaign/web/rest/CustomerController.java
parents 80a0a4ad 35578fa2
...@@ -71,9 +71,8 @@ public class JobConfig implements SchedulingConfigurer { ...@@ -71,9 +71,8 @@ public class JobConfig implements SchedulingConfigurer {
private void job2(TaskScheduler scheduler) { private void job2(TaskScheduler scheduler) {
job2 = scheduler.schedule(() -> { job2 = scheduler.schedule(() -> {
// log.info("processing job2 ..."); log.info(Thread.currentThread().getName() + " The Job executed at " + new Date());
// log.info(Thread.currentThread().getName() + " The Task2 executed at " + new Date()); campaignJob().process();
// campaignJob().process();
}, triggerContext -> { }, triggerContext -> {
String cronExp = "0/1 * * * * ?";// Can be pulled from a db . This will run every minute String cronExp = "0/1 * * * * ?";// Can be pulled from a db . This will run every minute
...@@ -85,15 +84,15 @@ public class JobConfig implements SchedulingConfigurer { ...@@ -85,15 +84,15 @@ public class JobConfig implements SchedulingConfigurer {
@Override @Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
// ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
// threadPoolTaskScheduler.setPoolSize(10); threadPoolTaskScheduler.setPoolSize(10);
// threadPoolTaskScheduler.setThreadNamePrefix("scheduler-thread"); threadPoolTaskScheduler.setThreadNamePrefix("scheduler-thread");
// threadPoolTaskScheduler.initialize(); threadPoolTaskScheduler.initialize();
// scheduledTaskRegistrar.setTaskScheduler(threadPoolTaskScheduler); scheduledTaskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
//// scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process(), (TriggerContext triggerContext) -> yourService.getCron()); // scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process(), (TriggerContext triggerContext) -> yourService.getCron());
// scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process(), triggerContext -> { scheduledTaskRegistrar.addTriggerTask(() -> campaignJob().process(), triggerContext -> {
// CronTrigger trigger = new CronTrigger("0/5 * * * * ?"); CronTrigger trigger = new CronTrigger("0/5 * * * * ?");
// return trigger.nextExecutionTime(triggerContext); return trigger.nextExecutionTime(triggerContext);
// }); });
} }
} }
package com.viettel.campaign.job; package com.viettel.campaign.job;
import com.viettel.campaign.model.ccms_full.Campaign; import com.viettel.campaign.model.ccms_full.Campaign;
import com.viettel.campaign.model.ccms_full.Customer;
import com.viettel.campaign.model.ccms_full.CustomerTime;
import com.viettel.campaign.model.ccms_full.ProcessConfig; import com.viettel.campaign.model.ccms_full.ProcessConfig;
import com.viettel.campaign.service.CampaignService; import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.service.CustomerTimeService;
import com.viettel.campaign.service.ProcessConfigService; import com.viettel.campaign.service.ProcessConfigService;
import com.viettel.campaign.utils.DateTimeUtil; import com.viettel.campaign.utils.DateTimeUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -34,8 +36,14 @@ public class CampaignJob { ...@@ -34,8 +36,14 @@ public class CampaignJob {
@Autowired @Autowired
private CampaignService campaignService; private CampaignService campaignService;
@Autowired
private CustomerTimeService customerTimeService;
@Autowired
private CustomerService customerService;
// @Scheduled(fixedRate = 5000) // @Scheduled(fixedRate = 5000)
@Transactional( propagation = Propagation.REQUIRED) // @Transactional( propagation = Propagation.REQUIRED)
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();
...@@ -45,26 +53,30 @@ public class CampaignJob { ...@@ -45,26 +53,30 @@ public class CampaignJob {
switch (p.getConfigCode()){ switch (p.getConfigCode()){
case CUSTOMER_INACTIVE_DUARATION: case CUSTOMER_INACTIVE_DUARATION:
if(isExecute){ if(isExecute){
List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
updateCustomer(customers);
updateCustomerTime(customers);
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
} }
break; break;
case CRON_EXPRESSION_CHECK_START: case CRON_EXPRESSION_CHECK_START:
// process // process
if(isExecute){ if(isExecute){
// chuyen trang thai Du thao sang Trien khai
log.info("thay doi trang thai");
List<Long> status = new ArrayList<>(); List<Long> status = new ArrayList<>();
status.add(1L); status.add(1L);
status.add(1L); status.add(1L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status); List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> { campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
campaign.setProcessStatus(1); campaign.setProcessStatus(1);
campaign.setStatus(2L); campaign.setStatus(2L);
campaign.setCampaignStart(new Date()); campaign.setCampaignStart(new Date());
campaignService.updateProcess(campaign); campaignService.updateProcess(campaign);
}); });
// update last check log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date()); p.setLastProcess(new Date());
processConfigService.update(p); processConfigService.update(p);
} }
...@@ -72,25 +84,50 @@ public class CampaignJob { ...@@ -72,25 +84,50 @@ public class CampaignJob {
case CRON_EXPRESSION_CHECK_END: case CRON_EXPRESSION_CHECK_END:
// process // process
if(isExecute){ if(isExecute){
// chuyen trang thai sang ket thuc
List<Long> status = new ArrayList<>(); List<Long> status = new ArrayList<>();
status.add(2L); status.add(2L);
status.add(3L); status.add(3L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status); List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> { campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
campaign.setStatus(4L); campaign.setStatus(4L);
campaign.setCampaignEnd(new Date()); campaign.setCampaignEnd(new Date());
campaignService.updateProcess(campaign); campaignService.updateProcess(campaign);
}); });
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
} }
break; break;
default: default:
// update last check time
} }
}); });
} }
private void updateCustomer(List<Customer> customers){
customers.parallelStream().forEach(c -> {
log.info("Cap nhat trang thai khoa cua KH ... #{}", c.getCustomerId());
c.setIpccStatus("active");
customerService.update(c);
});
}
private void updateCustomerTime(List<Customer> customers){
customers.parallelStream().forEach(customer -> {
// find all customer_time by customerId
List<CustomerTime> customerTimes = customerTimeService.findByCustomerId(customer.getCustomerId());
customerTimes.parallelStream().forEach(customerTime -> {
log.info("Cap nhat Customer time cua KH ... #{}", customerTime.getCustomerId());
customerTime.setStatus(2);
customerTime.setUpdateTime(new Date());
customerTimeService.update(customerTime);
});
});
}
} }
package com.viettel.campaign.model.acd_full;
/**
* @author anhvd_itsol
*/
public class modeltest {
}
package com.viettel.campaign.model.ccms_full;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* @author hanv_itsol
* @project campaign
*/
@Entity
@Table(name = "CUSTOMER_TIME")
@Getter
@Setter
public class CustomerTime {
@Id
@NotNull
@Column(name = "CUSTOMER_TIME_ID")
private Long customerTimeId;
@Column(name = "COMPANY_SITE_ID")
private String companySiteId;
@Column(name = "CUSTOMER_ID")
private String customerId;
@Column(name = "START_TIME")
private Date startTime;
@Column(name = "END_TIME")
private Date endTime;
@Column(name = "STATUS")
private Integer status;
@Column(name = "CREATE_TIME")
private Date createTime;
@Column(name = "UPDATE_TIME")
private Date updateTime;
@Column(name = "CREATE_BY")
private String createBy;
@Column(name = "UPDATE_BY")
private String updateBy;
@Column(name = "CONTACT_CUST_RESULT_ID")
private Long contactCustResultId;
}
package com.viettel.campaign.repository.acd_full;
/**
* @author anhvd_itsol
*/
public class acdrepotest {
}
...@@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query; ...@@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List; import java.util.List;
@Repository @Repository
...@@ -27,4 +28,8 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> { ...@@ -27,4 +28,8 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
@Modifying @Modifying
@Query("delete from Customer c where c.customerId in (:ids)") @Query("delete from Customer c where c.customerId in (:ids)")
int deleteIds(@Param("ids") List<Long> ids); int deleteIds(@Param("ids") List<Long> ids);
@Query("select c from Customer c left join com.viettel.campaign.model.ccms_full.CustomerTime ct on c.customerId = ct.customerId " +
"where c.ipccStatus = 'locked' and c.siteId =?1 and ct.endTime <= ?2")
List<Customer> findAllByCondition(Long siteId, Date endTime);
} }
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.model.ccms_full.CustomerTime;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author hanv_itsol
* @project campaign
*/
@Repository
public interface CustomerTimeRepository extends JpaRepository<CustomerTime, Long> {
List<CustomerTime> findByCustomerId(Long customerId);
}
...@@ -4,10 +4,13 @@ import com.viettel.campaign.model.ccms_full.TimeRangeDialMode; ...@@ -4,10 +4,13 @@ import com.viettel.campaign.model.ccms_full.TimeRangeDialMode;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* @author anhvd_itsol * @author anhvd_itsol
*/ */
@Repository @Repository
public interface TimeRangeDialModeRepository extends JpaRepository<TimeRangeDialMode, Long> { public interface TimeRangeDialModeRepository extends JpaRepository<TimeRangeDialMode, Long> {
List<TimeRangeDialMode> findTimeRangeDialModeByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
} }
...@@ -4,10 +4,13 @@ import com.viettel.campaign.model.ccms_full.TimeZoneDialMode; ...@@ -4,10 +4,13 @@ import com.viettel.campaign.model.ccms_full.TimeZoneDialMode;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* @author anhvd_itsol * @author anhvd_itsol
*/ */
@Repository @Repository
public interface TimeZoneDialModeRepository extends JpaRepository<TimeZoneDialMode, Long> { public interface TimeZoneDialModeRepository extends JpaRepository<TimeZoneDialMode, Long> {
List<TimeZoneDialMode> findTimeZoneDialModeByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
} }
package com.viettel.campaign.service; package com.viettel.campaign.service;
import com.viettel.campaign.model.ccms_full.Campaign; import com.viettel.campaign.model.ccms_full.Campaign;
import com.viettel.campaign.model.ccms_full.TimeRangeDialMode;
import com.viettel.campaign.model.ccms_full.TimeZoneDialMode;
import com.viettel.campaign.web.dto.CampaignDTO; import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO; import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
...@@ -38,4 +40,8 @@ public interface CampaignService { ...@@ -38,4 +40,8 @@ public interface CampaignService {
ResultDTO checkAllowStatusToPrepare(Long campaignId); ResultDTO checkAllowStatusToPrepare(Long campaignId);
XSSFWorkbook exportCampaigns(CampaignRequestDTO dto); XSSFWorkbook exportCampaigns(CampaignRequestDTO dto);
List<TimeRangeDialMode> getCampaignTimeRangeMode (Long campaignId, Long companySiteId);
List<TimeZoneDialMode> getCampaignTimeZoneMode (Long campaignId, Long companySiteId);
} }
package com.viettel.campaign.service; package com.viettel.campaign.service;
import com.viettel.campaign.model.ccms_full.Customer;
import com.viettel.campaign.model.ccms_full.CustomerList; import com.viettel.campaign.model.ccms_full.CustomerList;
import com.viettel.campaign.web.dto.CustomerContactDTO; import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import java.util.Date;
import java.util.List;
import java.util.List;
public interface CustomerService { public interface CustomerService {
ResultDTO getAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId); ResultDTO getAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId);
...@@ -44,12 +47,18 @@ public interface CustomerService { ...@@ -44,12 +47,18 @@ public interface CustomerService {
// danh sach khach hang cua chien dich // // danh sach khach hang cua chien dich //
ResultDTO searchCustomerListInfoFromCustomerList(int page, int pageSize, String sort, Long campaignId, Long companySiteId); List<CustomerListDTO> getCustomerListInfo(CampaignCustomerDTO campaignCustomerDTO);
List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO);
// ------------ customer ------------ // // ------------ customer ------------ //
ResultDTO getCustomerRecall(Long campaignId, Long customerId); ResultDTO getCustomerRecall(Long campaignId, Long customerId);
List<Customer> findAllByCondition(Long siteId, Date endTime);
Customer update(Customer c);
} }
package com.viettel.campaign.service;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.CustomerTime;
import com.viettel.campaign.repository.ccms_full.CustomerTimeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author hanv_itsol
* @project campaign
*/
@Service
@Transactional
public class CustomerTimeService {
@Autowired
private CustomerTimeRepository customerTimeRepository;
@Transactional(DataSourceQualify.CCMS_FULL)
public CustomerTime update(CustomerTime customerTime){
return customerTimeRepository.save(customerTime);
}
@Transactional(DataSourceQualify.CCMS_FULL)
public List<CustomerTime> findByCustomerId(Long customerId){
return customerTimeRepository.findByCustomerId(customerId);
}
}
package com.viettel.campaign.service; package com.viettel.campaign.service;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.ProcessConfig; import com.viettel.campaign.model.ccms_full.ProcessConfig;
import com.viettel.campaign.repository.ccms_full.ProcessConfigRepository; import com.viettel.campaign.repository.ccms_full.ProcessConfigRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -20,17 +21,18 @@ public class ProcessConfigService { ...@@ -20,17 +21,18 @@ public class ProcessConfigService {
@Autowired @Autowired
private ProcessConfigRepository processConfigRepository; private ProcessConfigRepository processConfigRepository;
@Transactional(readOnly = true) @Transactional(DataSourceQualify.CCMS_FULL)
public List<ProcessConfig> findAll(){ public List<ProcessConfig> findAll(){
return processConfigRepository.findAll(); return processConfigRepository.findAll();
} }
@Transactional(readOnly = true) @Transactional(DataSourceQualify.CCMS_FULL)
public List<ProcessConfig> findAllByCode(String configCode){ public List<ProcessConfig> findAllByCode(String configCode){
return processConfigRepository.findAllByConfigCode(configCode); return processConfigRepository.findAllByConfigCode(configCode);
} }
@Transactional(DataSourceQualify.CCMS_FULL)
public void update(ProcessConfig pc){ public void update(ProcessConfig pc){
processConfigRepository.save(pc); processConfigRepository.save(pc);
} }
......
...@@ -338,6 +338,16 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -338,6 +338,16 @@ public class CampaignServiceImpl implements CampaignService {
return workbook; return workbook;
} }
@Override
public List<TimeRangeDialMode> getCampaignTimeRangeMode(Long campaignId, Long companySiteId) {
return timeRangeDialModeRepository.findTimeRangeDialModeByCampaignIdAndCompanySiteId(campaignId, companySiteId);
}
@Override
public List<TimeZoneDialMode> getCampaignTimeZoneMode(Long campaignId, Long companySiteId) {
return timeZoneDialModeRepository.findTimeZoneDialModeByCampaignIdAndCompanySiteId(campaignId, companySiteId);
}
private String generateCampaignCode(String campaignType, Short chanel) { private String generateCampaignCode(String campaignType, Short chanel) {
int year = Calendar.getInstance().get(Calendar.YEAR); int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepositoryCustom.getMaxCampaignIndex(); String maxIndexStr = campaignRepositoryCustom.getMaxCampaignIndex();
......
package com.viettel.campaign.service.impl; package com.viettel.campaign.service.impl;
import com.viettel.campaign.config.CCMSFullDatasourceConfig;
import com.viettel.campaign.config.DataSourceQualify; import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.mapper.CustomerListMapper; import com.viettel.campaign.mapper.CustomerListMapper;
import com.viettel.campaign.mapper.CustomerMapper; import com.viettel.campaign.mapper.CustomerMapper;
...@@ -24,15 +25,20 @@ import org.hibernate.type.LongType; ...@@ -24,15 +25,20 @@ import org.hibernate.type.LongType;
import org.hibernate.type.ShortType; import org.hibernate.type.ShortType;
import org.hibernate.type.StringType; import org.hibernate.type.StringType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.*; import org.springframework.data.domain.*;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import javax.persistence.Query; import javax.persistence.Query;
import java.util.Date; import javax.sql.DataSource;
import java.util.List; import java.util.*;
@Service @Service
public class CustomerServiceImpl implements CustomerService { public class CustomerServiceImpl implements CustomerService {
...@@ -59,6 +65,10 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -59,6 +65,10 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired @Autowired
CustomerListMappingRepository customerListMappingRepository; CustomerListMappingRepository customerListMappingRepository;
@Autowired
@Qualifier(DataSourceQualify.NAMED_JDBC_PARAMETER_TEMPLATE_CCMS_FULL)
NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId) { public ResultDTO getAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId) {
...@@ -94,6 +104,10 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -94,6 +104,10 @@ public class CustomerServiceImpl implements CustomerService {
query.addScalar("companyName", new StringType()); query.addScalar("companyName", new StringType());
query.addScalar("customerType", new StringType()); query.addScalar("customerType", new StringType());
query.addScalar("currentAddress", new StringType()); query.addScalar("currentAddress", new StringType());
query.addScalar("callAllowed", new ShortType());
query.addScalar("emailAllowed", new ShortType());
query.addScalar("smsAllowed", new ShortType());
query.addScalar("ipccStatus", new StringType());
query.addScalar("mobileNumber", new StringType()); query.addScalar("mobileNumber", new StringType());
query.addScalar("email", new StringType()); query.addScalar("email", new StringType());
...@@ -666,20 +680,46 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -666,20 +680,46 @@ public class CustomerServiceImpl implements CustomerService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchCustomerListInfoFromCustomerList(int page, int pageSize, String sort, Long campaignId, Long companySiteId) { public List<CustomerListDTO> getCustomerListInfo(CampaignCustomerDTO campaignCustomerDTO) {
ResultDTO resultDTO = new ResultDTO(); List<CustomerListDTO> customerList;
try { try {
String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-customer-list-info-from-customer-list"); String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-customer-list-info-from-customer-list");
Query query = entityManager.createNativeQuery(sql); Map<String, Object> param = new HashMap<>();
query.setParameter("p_campaign_id", campaignId); param.put("p_campaign_id", campaignCustomerDTO.getCampaignId());
query.setParameter("p_company_site_id", companySiteId); param.put("p_company_site_id", campaignCustomerDTO.getCompanySiteId());
resultDTO.setListData(query.getResultList()); param.put("p_page_number", campaignCustomerDTO.getPage());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); param.put("p_page_size", campaignCustomerDTO.getPageSize());
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); customerList = namedParameterJdbcTemplate.query(sql, param, new BeanPropertyRowMapper<>(CustomerListDTO.class));
} catch (Exception e) { } catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); return null;
resultDTO.setDescription(e.getMessage());
} }
return resultDTO; return customerList;
}
@Override
public List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO) {
List<CustomerDTO> customerList;
try {
String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-individual-customer");
Map<String, Object> param = new HashMap<>();
param.put("p_page_number", campaignCustomerDTO.getPage());
param.put("p_page_size", campaignCustomerDTO.getPageSize());
customerList = namedParameterJdbcTemplate.query(sql, param, new BeanPropertyRowMapper<>(CustomerDTO.class));
} catch (Exception e) {
return null;
}
return customerList;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<Customer> findAllByCondition(Long siteId, Date endTime) {
return customerRepository.findAllByCondition(siteId, endTime);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Customer update(Customer c) {
return customerRepository.save(c);
} }
} }
...@@ -7,7 +7,7 @@ import java.util.Date; ...@@ -7,7 +7,7 @@ import java.util.Date;
@Getter @Getter
@Setter @Setter
public class CampaignCustomerDTO { public class CampaignCustomerDTO extends BaseDTO{
private Long campaignCustomerListId; private Long campaignCustomerListId;
private Long campaignId; private Long campaignId;
private Long customerId; private Long customerId;
......
...@@ -15,6 +15,10 @@ public class CustomerCustomDTO { ...@@ -15,6 +15,10 @@ public class CustomerCustomDTO {
String companyName; String companyName;
String customerType; String customerType;
String currentAddress; String currentAddress;
Short callAllowed;
Short emailAllowed;
Short smsAllowed;
String ipccStatus;
String mobileNumber; String mobileNumber;
String email; String email;
} }
...@@ -21,4 +21,7 @@ public class CustomerListDTO extends BaseDTO { ...@@ -21,4 +21,7 @@ public class CustomerListDTO extends BaseDTO {
private Date updateAt; private Date updateAt;
private String source; private String source;
private String deptCreate; private String deptCreate;
private Long totalCusInList;
private Long totalCusInteract;
private Long totalCusNotInteract;
} }
...@@ -3,13 +3,13 @@ package com.viettel.campaign.web.rest; ...@@ -3,13 +3,13 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.service.CampaignExecuteService; import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.service.CampaignService; import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.web.dto.CampaignDTO; import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ContactCustResultDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO; import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.instrument.reactor.ReactorSleuth;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -21,7 +21,6 @@ import javax.servlet.http.HttpServletResponse; ...@@ -21,7 +21,6 @@ import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.List;
import java.util.Map; import java.util.Map;
@RestController @RestController
...@@ -37,7 +36,7 @@ public class CampaignController { ...@@ -37,7 +36,7 @@ public class CampaignController {
@Autowired @Autowired
CampaignExecuteService campaignExecuteService; CampaignExecuteService campaignExecuteService;
@RequestMapping("/searchCampaignExecute") @PostMapping("/searchCampaignExecute")
@ResponseBody @ResponseBody
public ResponseEntity<ResultDTO> searchCampaignExecute(@RequestBody CampaignRequestDTO requestDto) { public ResponseEntity<ResultDTO> searchCampaignExecute(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignService.searchCampaignExecute(requestDto); ResultDTO result = campaignService.searchCampaignExecute(requestDto);
...@@ -73,6 +72,7 @@ public class CampaignController { ...@@ -73,6 +72,7 @@ public class CampaignController {
ResultDTO result = campaignService.findByCampaignId(campaignId); ResultDTO result = campaignService.findByCampaignId(campaignId);
return new ResponseEntity<>(result, HttpStatus.OK); 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 {
...@@ -112,13 +112,6 @@ public class CampaignController { ...@@ -112,13 +112,6 @@ public class CampaignController {
return new ResponseEntity<byte[]>(contentReturn, headers, HttpStatus.OK); return new ResponseEntity<byte[]>(contentReturn, headers, HttpStatus.OK);
} }
@PostMapping("/getContactCustById")
@ResponseBody
public ResponseEntity<?> getContactCustById(@RequestBody CampaignRequestDTO campaignRequestDTO) {
List<ContactCustResultDTO> list = campaignExecuteService.getContactCustById(campaignRequestDTO);
return new ResponseEntity<>(null, null, HttpStatus.OK);
}
@RequestMapping(value = "/changeCampaignStatus", method = RequestMethod.PUT) @RequestMapping(value = "/changeCampaignStatus", method = RequestMethod.PUT)
public ResultDTO changeCampaignStatus(@RequestBody CampaignDTO dto, HttpServletRequest request) { public ResultDTO changeCampaignStatus(@RequestBody CampaignDTO dto, HttpServletRequest request) {
dto.setSessionId(request.getSession().getId()); dto.setSessionId(request.getSession().getId());
......
...@@ -243,7 +243,6 @@ public class CustomerController { ...@@ -243,7 +243,6 @@ public class CustomerController {
} }
@RequestMapping(value = "/searchCustomerListInfoFromCustomerList", method = RequestMethod.GET) @RequestMapping(value = "/searchCustomerListInfoFromCustomerList", method = RequestMethod.GET)
@ResponseBody
public ResultDTO searchCustomerListInfoFromCustomerList(@RequestParam("page") int page, public ResultDTO searchCustomerListInfoFromCustomerList(@RequestParam("page") int page,
@RequestParam("pageSize") int pageSize, @RequestParam("pageSize") int pageSize,
@RequestParam("sort") String sort, @RequestParam("sort") String sort,
......
...@@ -12,8 +12,8 @@ spring: ...@@ -12,8 +12,8 @@ spring:
datasource2: datasource2:
driver-class-name: oracle.jdbc.driver.OracleDriver driver-class-name: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@10.60.157.135:1521:vt url: jdbc:oracle:thin:@10.60.157.135:1521:vt
username: CCMS_FULL username: ACD_FULL
password: CCMS_FULL#123 password: ACD_FULL#123
max_pool_size: 32 max_pool_size: 32
jpa: jpa:
database-platform: org.hibernate.dialect.Oracle10gDialect database-platform: org.hibernate.dialect.Oracle10gDialect
......
...@@ -8,6 +8,10 @@ select ...@@ -8,6 +8,10 @@ select
b.COMPANY_NAME companyName, b.COMPANY_NAME companyName,
b.CUSTOMER_TYPE customerType, b.CUSTOMER_TYPE customerType,
b.CURRENT_ADDRESS currentAddress, b.CURRENT_ADDRESS currentAddress,
b.CALL_ALLOWED callAllowed,
b.EMAIL_ALLOWED emailAllowed,
b.SMS_ALLOWED smsAllowed,
b.IPCC_STATUS ipccStatus,
c.MOBILE mobileNumber, c.MOBILE mobileNumber,
d.EMAIL email d.EMAIL email
from CUSTOMER_LIST_MAPPING a from CUSTOMER_LIST_MAPPING a
......
...@@ -19,16 +19,26 @@ count(customer_id) ktt ...@@ -19,16 +19,26 @@ count(customer_id) ktt
from campaign_customer where campaign_id = :p_campaign_id and status = 0 from campaign_customer where campaign_id = :p_campaign_id and status = 0
and in_campaign_status = 1 and in_campaign_status = 1
group by customer_list_id, company_site_id group by customer_list_id, company_site_id
) ), datas as (
select customer_list_code ma, select customer_list_code customerListCode,
customer_list_name ten, customer_list_name customerListName,
cl.company_site_id, nvl(total, 0) totalCusInList,
nvl(total, 0) tong, nvl(tt, 0) totalCusInteract,
nvl(tt, 0) tongtt, nvl(ktt, 0) totalCusNotInteract
nvl(ktt, 0) tongktt
from customer_list cl from customer_list cl
left join totalCustomer tc on (cl.customer_list_id = tc.customer_list_id and cl.company_site_id = tc.company_site_id) left join totalCustomer tc on (cl.customer_list_id = tc.customer_list_id and cl.company_site_id = tc.company_site_id)
left join customerInteractive ci on (cl.customer_list_id = ci.customer_list_id and cl.company_site_id = ci.company_site_id) left join customerInteractive ci on (cl.customer_list_id = ci.customer_list_id and cl.company_site_id = ci.company_site_id)
left join customerNotInteractive cni on (cl.customer_list_id = cni.customer_list_id and cl.company_site_id = cni.company_site_id) left join customerNotInteractive cni on (cl.customer_list_id = cni.customer_list_id and cl.company_site_id = cni.company_site_id)
where cl.company_site_id = :p_company_site_id where cl.company_site_id = :p_company_site_id
order by customer_list_code )
\ No newline at end of file select * from
(
select a.*, rownum r__
from
(
select * from datas
order by customerListCode
) a
where rownum < ((:p_page_number * :p_page_size) + 1 )
)
where r__ >= (((:p_page_number-1) * :p_page_size) + 1)
\ No newline at end of file
with cusPhone as (
select customer_id cusId,
contact phone
from customer_contact cc
where cc.contact_type = 5
and status = 1
), cusEmail as (
select customer_id cusId,
contact email
from customer_contact cc
where cc.contact_type = 2
and status = 1
), datas as (
select c.name,
cP.phone,
cE.email,
c.customer_type cusType,
c.company_name compName,
c.current_address currentAddress,
c.description
from customer c
left join cusPhone cP on c.customer_id = cP.cusId
left join cusEmail cE on c.customer_id = cE.cusId
)
select * from
(
select a.*, rownum r__
from
(
select * from datas
order by datas.name
) a
where rownum < ((:p_page_number * :p_page_size) + 1 )
)
where r__ >= (((:p_page_number-1) * :p_page_size) + 1)
\ No newline at end of file
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