Commit 19861c0d authored by đinh thị đầm's avatar đinh thị đầm

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/viettel/campaign/repository/ccms_full/CampaignCustomerListRepository.java
#	src/main/java/com/viettel/campaign/repository/ccms_full/CampaignCustomerRepository.java
#	src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
#	src/main/java/com/viettel/campaign/web/rest/CustomerController.java
parents 359bb2c1 19b464e1
No preview for this file type
......@@ -4,3 +4,4 @@ logs/
out/
/campaign.iml
/lib
/log
File mode changed from 100755 to 100644
[main] 19/08/2019 17:50:53 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 19/08/2019 17:53:34 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
package com.viettel.campaign.job;
import com.viettel.campaign.model.ccms_full.Campaign;
import com.viettel.campaign.model.ccms_full.Customer;
import com.viettel.campaign.model.ccms_full.CustomerTime;
import com.viettel.campaign.model.ccms_full.ProcessConfig;
import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.service.CustomerTimeService;
import com.viettel.campaign.service.ProcessConfigService;
import com.viettel.campaign.model.ccms_full.*;
import com.viettel.campaign.service.*;
import com.viettel.campaign.utils.DateTimeUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -42,68 +36,75 @@ public class CampaignJob {
@Autowired
private CustomerService customerService;
@Autowired
private UserActionLogService userActionLogService;
// @Scheduled(fixedRate = 5000)
// @Transactional( propagation = Propagation.REQUIRED)
public void process() {
log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
List<ProcessConfig> list = processConfigService.findAll();
list.parallelStream().forEach(p -> {
boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
switch (p.getConfigCode()){
case CUSTOMER_INACTIVE_DUARATION:
if(isExecute){
List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
updateCustomer(customers);
updateCustomerTime(customers);
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
}
break;
case CRON_EXPRESSION_CHECK_START:
// process
if(isExecute){
List<Long> status = new ArrayList<>();
status.add(1L);
status.add(1L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
campaign.setProcessStatus(1);
campaign.setStatus(2L);
campaign.setCampaignStart(new Date());
campaignService.updateProcess(campaign);
});
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
}
break;
case CRON_EXPRESSION_CHECK_END:
// process
if(isExecute){
List<Long> status = new ArrayList<>();
status.add(2L);
status.add(3L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
campaign.setStatus(4L);
campaign.setCampaignEnd(new Date());
campaignService.updateProcess(campaign);
});
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
}
break;
default:
// update last check time
}
});
// log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
// List<ProcessConfig> list = processConfigService.findAll();
//
// list.parallelStream().forEach(p -> {
// boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
// switch (p.getConfigCode()){
// case CUSTOMER_INACTIVE_DUARATION:
// if(isExecute){
// List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
// updateCustomer(customers);
// updateCustomerTime(customers);
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date());
// processConfigService.update(p);
// }
// break;
// case CRON_EXPRESSION_CHECK_START:
// // process
// if(isExecute){
// List<Long> status = new ArrayList<>();
// status.add(1L);
// status.add(1L);
// List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
// campaigns.parallelStream().forEach(campaign -> {
// log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
// campaign.setProcessStatus(1);
// campaign.setStatus(2L);
// campaign.setCampaignStart(new Date());
// campaignService.updateProcess(campaign);
// //write log
// saveLog(campaign, 1);
// });
//
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date());
// processConfigService.update(p);
// }
// break;
// case CRON_EXPRESSION_CHECK_END:
// // process
// if(isExecute){
// List<Long> status = new ArrayList<>();
// status.add(2L);
// status.add(3L);
// List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
// campaigns.parallelStream().forEach(campaign -> {
// log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
// campaign.setStatus(4L);
// campaign.setCampaignEnd(new Date());
// campaignService.updateProcess(campaign);
// //write log
// saveLog(campaign, 2);
// });
//
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date());
// processConfigService.update(p);
// }
// break;
// default:
// // update last check time
// }
// });
}
......@@ -129,5 +130,16 @@ public class CampaignJob {
});
}
private void saveLog(Campaign c, int t){
UserActionLog log = new UserActionLog();
log.setAgentId(1L);
log.setSessionId("-1");
log.setStartTime(new Date());
log.setActionType(t == 1 ? 13L : 14L);
log.setObjectId(c.getCampaignId());
log.setCompanySiteId(c.getCompanySiteId());
userActionLogService.save(log);
}
}
......@@ -5,15 +5,18 @@ import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "CUSTOMER_CONTACT")
@Getter
@Setter
public class CustomerContact {
public class CustomerContact implements Serializable {
@Id
@Basic(optional = false)
@GeneratedValue(generator = "customer_contact_seq", strategy = GenerationType.IDENTITY)
@SequenceGenerator(name = "customer_contact_seq", sequenceName = "customer_contact_seq", allocationSize = 1)
@NotNull
@Column(name = "CONTACT_ID")
private Long contactId;
......
package com.viettel.campaign.model.ccms_full;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @author hanv_itsol
* @project campaign
*/
@Entity
@Table(name = "USER_ACTION_LOG")
@Data
public class UserActionLog implements Serializable {
@Id
@NotNull
@Column(name = "AGENT_ID")
private Long agentId;
@Column(name = "COMPANY_SITE_ID")
private Long companySiteId;
@Column(name = "SESSION_ID")
private String sessionId;
@Column(name = "START_TIME")
private Date startTime;
@Column(name = "END_TIME")
private Date endTime;
@Column(name = "ACTION_TYPE")
private Long actionType;
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "OBJECT_ID")
private Long objectId;
}
......@@ -17,5 +17,5 @@ public interface AgentsRepository extends JpaRepository<Agents, String> {
@Modifying
@Query(value = "UPDATE Agents SET campaignSystemStatus = :campaignSystemStatus WHERE agentId = :agentId")
void updateAgentLogoutFromCampaign(@Param("agentId") Long agentId, @Param("campaignSystemStatus") String campaignSystemStatus);
void updateAgentLogoutFromCampaign(@Param("agentId") String agentId, @Param("campaignSystemStatus") String campaignSystemStatus);
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.CampaignCustomerListColumn;
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 CampaignCustomerListColumnRepository extends JpaRepository<CampaignCustomerListColumn, Long> {
List<CampaignCustomerListColumn> findByCampaignIdAndCompanySiteId(Long campaignId, Long companaySiteId);
CampaignCustomerListColumn findByCampaignCusListColId(Long campaignCusListColId);
}
......@@ -15,4 +15,5 @@ public interface CampaignCustomerListRepository extends JpaRepository<CampaignCu
@Query("select count (c.campaignId) from CampaignCustomerList c where c.customerListId in (:ids)")
Long campaignIdsCount(@Param("ids") List<Long> ids);
void deleteCampaignCustomerListByCampaignIdAndCustomerListIdAndCompanySiteId(Long campaignId, Long customerListId, Long companySiteId);
}
......@@ -2,7 +2,6 @@ package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.CampaignCustomer;
import com.viettel.campaign.model.ccms_full.Customer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
......@@ -11,7 +10,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Repository
@Transactional(DataSourceQualify.CCMS_FULL)
public interface CampaignCustomerRepository extends JpaRepository<CampaignCustomer, Long>, CampaignCustomerRepositoryCustom {
......@@ -62,4 +60,20 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
@Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " +
"WHERE CC.STATUS = 0 " +
"AND CC.CAMPAIGN_ID = :campaignId " +
"AND CC.COMPANY_SITE_ID = :companySiteId " +
"AND CC.CUSTOMER_LIST_ID = :customerListId", nativeQuery = true)
List<CampaignCustomer> findCustomerNoContact(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId, @Param("customerListId") Long customerListId);
@Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " +
"WHERE CC.STATUS IN (SELECT COMPLETE_VALUE from CAMPAIGN_COMPLETE_CODE where STATUS = 1 and IS_FINISH = 0 and IS_RECALL = 0)" +
"AND CC.CAMPAIGN_ID = :campaignId " +
"AND CC.COMPANY_SITE_ID = :companySiteId " +
"AND CC.CUSTOMER_LIST_ID = :customerListId", nativeQuery = true)
List<CampaignCustomer> findCustomerContacted(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId, @Param("customerListId") Long customerListId);
}
......@@ -18,14 +18,19 @@ public interface CampaignRepositoryCustom {
ResultDTO checkAllowStatusToPrepare(Long campaignId);
//hungtt
//<editor-fold: hungtt>
ResultDTO findCustomerListReallocation(CampaignRequestDTO dto);
//hungtt
ResultDTO reallocationCustomer(CampaignRequestDTO dto);
//hungtt
ResultDTO getListFieldsNotShow(CampaignRequestDTO dto);
//hungtt
ResultDTO getListFieldsToShow(CampaignRequestDTO dto);
//hungtt
ResultDTO getCampaignCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerChoosenList(CampaignRequestDTO dto);
//</editor-fold>
}
......@@ -12,5 +12,5 @@ public interface CustomerContactRepository extends JpaRepository<CustomerContact
@Query("FROM CustomerContact WHERE status = 1 AND customerId = :customerId AND contactType = :contactType AND (contact IS NULL OR UPPER(contact) LIKE UPPER(concat('%', :contact, '%')))")
List<CustomerContact> findByCustomerIdAndAndContactTypeAndContact(@Param("customerId") Long customerId, @Param("contactType") Short contactType, @Param("contact") String contact, Pageable pageable);
CustomerContact findCustomerContactByContactTypeAndContactAndIsDirectLine(Short contactType, String contact, Short isDirectLine);
CustomerContact findCustomerContactByContactEquals(String contact);
}
......@@ -24,4 +24,7 @@ public interface ScenarioAnswerRepository extends JpaRepository<ScenarioAnswer,
Integer deleteScenarioAnswersByScenarioQuestionId(Long scenarioQuestionId);
ScenarioAnswer findScenarioAnswerByScenarioAnswerId(Long scenarioAnswerId);
@Query(value = "SELECT COUNT(1) FROM ScenarioAnswer WHERE 1 = 1 AND code = :code AND scenarioQuestionId = :scenarioQuestionId AND scenarioAnswerId <> :scenarioAnswerId")
Integer countDuplicateScenarioCode(@Param("code") String code, @Param("scenarioQuestionId") Long scenarioQuestionId, @Param("scenarioAnswerId") Long scenarioAnswerId);
}
......@@ -9,4 +9,6 @@ import com.viettel.campaign.web.dto.ScenarioQuestionDTO;
public interface ScenarioQuestionRepositoryCustom {
Integer countDuplicateQuestionCode(ScenarioQuestionDTO questionDTO);
Integer countDuplicateOrderIndex(ScenarioQuestionDTO questionDTO);
}
......@@ -2,7 +2,9 @@ package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.model.ccms_full.Scenario;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.data.repository.query.Param;
/**
* @author anhvd_itsol
......@@ -11,4 +13,7 @@ import org.springframework.stereotype.Repository;
@Repository
public interface ScenarioRepository extends JpaRepository<Scenario, Long> {
Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
@Query(value = "SELECT COUNT(1) FROM Scenario WHERE 1 = 1 AND companySiteId = :companySiteId AND code = :code AND scenarioId <> :scenarioId")
Integer countDuplicateScenarioCode(@Param("companySiteId") Long companySiteId, @Param("code") String code, @Param("scenarioId") Long scenarioId);
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.model.ccms_full.UserActionLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* @author hanv_itsol
* @project campaign
*/
@Repository
public interface UserActionLogRepository extends JpaRepository<UserActionLog, Long> {
//
}
......@@ -92,7 +92,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
sb.append(" FROM CAMPAIGN a");
sb.append(" LEFT JOIN (SELECT campaign_id, COUNT (*) AS SLKHThamgiaCD");
sb.append(" FROM campaign_customer cc INNER JOIN CUSTOMER cus ON cc.CUSTOMER_ID = cus.CUSTOMER_ID");
sb.append(" WHERE 1 = 1 AND cc.IN_CAMPAIGN_STATUS = 1 AND cus.STATUS = 1");
sb.append(" WHERE 1 = 1 AND cus.STATUS = 1");
sb.append(" group by campaign_id) b");
sb.append(" ON a.CAMPAIGN_ID = b.CAMPAIGN_ID");
sb.append(" LEFT JOIN (SELECT campaign_id, COUNT (*) AS SLKHChuaTuongTac");
......@@ -511,23 +511,19 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
StringBuilder stringBuilder = new StringBuilder();
try {
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-fields-not-show");
stringBuilder.append(" with column_name_temp as (");
stringBuilder.append(" select column_name columnName, 1 isFix from user_tab_columns, dual");
stringBuilder.append(" where table_name = 'CUSTOMER'");
stringBuilder.append(" )");
stringBuilder.append(" select * from column_name_temp");
stringBuilder.append(" where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)");
stringBuilder.append(" union all");
stringBuilder.append(" select title columnName, 0 isFix ");
stringBuilder.append(" from customize_fields, dual");
stringBuilder.append(" where function_code = 'CUSTOMER'");
stringBuilder.append(" and site_id = :p_company_site_id");
stringBuilder.append(" and customize_field_id not in (select customize_field_id");
stringBuilder.append(" from campaign_customerlist_column");
stringBuilder.append(" where campaign_customerlist_column.campaign_id = :p_campaign_id)");
String sql = "with column_name_temp as (\n" +
" select column_name columnName, null customizeFieldId, 1 isFix from user_tab_columns, dual\n" +
" where table_name = 'CUSTOMER'\n" +
")\n" +
"select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)\n" +
"union all\n" +
"select title columnName, customize_field_id customizeFieldId, 0 isFix from customize_fields, dual\n" +
"where function_code = 'CUSTOMER'\n" +
" and site_id = :p_company_site_id\n" +
" and customize_field_id not in (select customize_field_id from campaign_customerlist_column where campaign_customerlist_column.campaign_id = :p_campaign_id)\n";
params.put("p_company_site_id", dto.getCompanySiteId());
params.put("p_campaign_id", dto.getCampaignId());
list = namedParameterJdbcTemplate.query(stringBuilder.toString(), params, BeanPropertyRowMapper.newInstance(FieldsToShowDTO.class));
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(FieldsToShowDTO.class));
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setListData(list);
......@@ -548,15 +544,22 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
StringBuilder sqlBuilder = new StringBuilder();
try {
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-fields-to-show");
sqlBuilder.append(" select to_char(column_name) columnName, 1 isFix");
sqlBuilder.append(" from campaign_customerlist_column, dual");
sqlBuilder.append(" where campaign_id = :p_campaign_id and column_name is not null");
sqlBuilder.append(" union all");
sqlBuilder.append(" select customize_field_title columnName, 0 isFix");
sqlBuilder.append(" from campaign_customerlist_column");
sqlBuilder.append(" where campaign_id = :p_campaign_id");
String sql = "with field_name as (\n" +
"select a.campaign_cus_list_column_id id, to_char(a.column_name) columnName, a.order_index, a.customize_field_id customizeFieldId, 1 isFix\n" +
"from campaign_customerlist_column a, dual\n" +
"where a.campaign_id = :p_campaign_id\n" +
" and a.company_site_id = :p_company_site_id\n" +
" and column_name is not null\n" +
"union all\n" +
"select a.campaign_cus_list_column_id id, a.customize_field_title columnName, a.order_index, a.customize_field_id customizeFieldId, 0 isFix\n" +
"from campaign_customerlist_column a\n" +
"where a.campaign_id = :p_campaign_id\n" +
" and a.company_site_id = :p_company_site_id\n" +
")\n" +
"select id, columnName, customizeFieldId, isFix from field_name where columnName is not null order by order_index\n";
params.put("p_campaign_id", dto.getCampaignId());
list = namedParameterJdbcTemplate.query(sqlBuilder.toString(), params, BeanPropertyRowMapper.newInstance(FieldsToShowDTO.class));
params.put("p_company_site_id", dto.getCompanySiteId());
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(FieldsToShowDTO.class));
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setListData(list);
......@@ -577,10 +580,280 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
// StringBuilder sb = new StringBuilder();
try {
String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-campaign-customer");
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-campaign-customer");
String sql = "with campaign_customer_id as (\n" +
" select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl\n" +
" where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id\n" +
"),\n" +
"customer_table as (\n" +
" select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a\n" +
" left join customer b on a.customer_id = b.customer_id\n" +
" where b.status = 1\n" +
" group by a.customer_list_id\n" +
"),\n" +
"campaign_customer_table as (\n" +
" select count(a.customer_id) campaignCustomer, a.customer_list_id customerListId, a.campaign_id from campaign_customer a\n" +
" where a.campaign_id = :p_campaign_id\n" +
" group by a.customer_list_id, a.campaign_id\n" +
"),\n" +
"customer_interactive_table as (\n" +
" select count(a.customer_id) campaignCustomerCalled, a.customer_list_id customerListId, a.campaign_id from campaign_customer a\n" +
" where a.status <> 0 and a.campaign_id = :p_campaign_id\n" +
" group by a.customer_list_id, a.campaign_id\n" +
"),\n" +
"customer_not_interactive_table as (\n" +
" select count(a.customer_id) cusNotInteractive, a.customer_list_id customerListId, a.campaign_id from campaign_customer a\n" +
" where a.status = 0 and a.campaign_id = :p_campaign_id and a.in_campaign_status = 1\n" +
" group by a.customer_list_id, a.campaign_id\n" +
"),\n" +
"data_temp as (\n" +
"select a.customer_list_id customerListId,\n" +
" a.customer_list_code customerListCode,\n" +
" a.customer_list_name customerListName,\n" +
" nvl(b.totalCustomer, 0) totalCusList,\n" +
" nvl(c.campaignCustomer, 0) totalCusCampaign,\n" +
" nvl(d.campaignCustomerCalled, 0) totalCusCalled,\n" +
" nvl(e.cusNotInteractive, 0) totalCusNotInteract\n" +
"from customer_list a\n" +
"left join customer_table b on a.customer_list_id = b.customerListId\n" +
"left join campaign_customer_table c on a.customer_list_id = c.customerListId\n" +
"left join customer_interactive_table d on a.customer_list_id = d.customerListId\n" +
"left join customer_not_interactive_table e on a.customer_list_id = e.customerListId\n" +
"where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)\n" +
"),\n" +
"data as (\n" +
"select a.*, rownum row_ from data_temp a\n" +
"),\n" +
"count_data as (\n" +
"select count(*) totalRow from data_temp\n" +
")\n" +
"select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusCampaign, a.totalCusCalled, a.totalCusNotInteract, totalRow from data a, count_data\n" +
"where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)\n";
params.put("p_campaign_id", dto.getCampaignId());
params.put("p_company_site_id", dto.getCompanySiteId());
params.put("p_page_number", dto.getPage().toString());
params.put("p_page_size", dto.getPageSize().toString());
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(CustomerListDTO.class));
int total = 0;
if (list.size() > 0) {
total = list.get(0).getTotalRow();
}
resultDTO.setListData(list);
resultDTO.setTotalRow(total);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerList(CampaignRequestDTO dto) {
List<CustomerListDTO> list = new ArrayList();
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
// Map<String, String> params = new HashMap<>();
StringBuilder sb = new StringBuilder();
try {
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-customer-list");
sb.append(" with campaign_customer_id as (");
sb.append(" select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl");
sb.append(" where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id");
sb.append(" ),");
sb.append(" customer_table as (");
sb.append(" select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a");
sb.append(" left join customer b on a.customer_id = b.customer_id");
sb.append(" where b.status = 1");
sb.append(" group by a.customer_list_id");
sb.append(" ),");
sb.append(" customer_active_table as (");
sb.append(" select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a");
sb.append(" left join customer b on a.customer_id = b.customer_id");
sb.append(" where b.status = 1 and b.ipcc_status = 'active'");
sb.append(" group by a.customer_list_id");
sb.append(" ),");
sb.append(" customer_lock_table as (");
sb.append(" select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a");
sb.append(" left join customer b on a.customer_id = b.customer_id");
sb.append(" where b.status = 1 and b.ipcc_status = 'locked'");
sb.append(" group by a.customer_list_id");
sb.append(" ),");
sb.append(" customer_dnc_table as (");
sb.append(" select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a");
sb.append(" left join customer b on a.customer_id = b.customer_id");
sb.append(" where b.status = 1 and b.call_allowed = 0");
sb.append(" group by a.customer_list_id");
sb.append(" ),");
sb.append(" data_temp as (");
sb.append(" select a.customer_list_id customerListId,");
sb.append(" a.customer_list_code customerListCode,");
sb.append(" a.customer_list_name customerListName,");
sb.append(" nvl(b.totalCustomer, 0) totalCusList,");
sb.append(" nvl(c.customerActive, 0) totalCusActive,");
sb.append(" nvl(d.customerLock, 0) totalCusLock,");
sb.append(" nvl(e.customerDnc, 0) totalCusDnc,");
sb.append(" a.create_at createAt,");
sb.append(" a.company_site_id companySiteId,");
sb.append(" a.status status");
sb.append(" from customer_list a");
sb.append(" left join customer_table b on a.customer_list_id = b.customerListId");
sb.append(" left join customer_active_table c on a.customer_list_id = c.customerListId");
sb.append(" left join customer_lock_table d on a.customer_list_id = d.customerListId");
sb.append(" left join customer_dnc_table e on a.customer_list_id = e.customerListId");
sb.append(" where a.status = 1");
sb.append(" and (:p_cus_list_code is null or upper(a.customer_list_code) like '%'||:p_cus_list_code||'%')");
sb.append(" and (:p_cus_list_name is null or upper(a.customer_list_name) like '%'||:p_cus_list_name||'%')");
sb.append(" and (a.create_at <= to_date(:p_to_date, 'DD/MM/YYYY'))");
sb.append(" and (a.create_at >= to_date(:p_from_date, 'DD/MM/YYYY'))");
sb.append(" and (a.company_site_id = :p_company_site_id)");
sb.append(" and (a.customer_list_id not in (select CUSTOMER_LIST_ID from campaign_customer_id))");
sb.append(" ),");
sb.append(" data as (");
sb.append(" select a.*, rownum row_ from data_temp a");
sb.append(" ),");
sb.append(" count_data as (");
sb.append(" select count(*) totalRow from data_temp");
sb.append(" )");
sb.append(" select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, totalRow from data a, count_data");
sb.append(" where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)");
// params.put("p_campaign_id", dto.getCampaignId());
// params.put("p_cus_list_code", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCustListCode().toUpperCase());
// params.put("p_cus_list_name", DataUtil.isNullOrEmpty(dto.getCustListName()) ? null : dto.getCustListName().toUpperCase());
// params.put("p_to_date", dto.getCreateTimeTo());
// params.put("p_from_date", dto.getCreateTimeFr());
// params.put("p_company_site_id", dto.getCompanySiteId());
// params.put("p_page_number", dto.getPage().toString());
// params.put("p_page_size", dto.getPageSize().toString());
//
// list = namedParameterJdbcTemplate.query(sb.toString(), params, BeanPropertyRowMapper.newInstance(CustomerListDTO.class));
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", dto.getCompanySiteId());
query.setParameter("p_campaign_id", dto.getCampaignId());
query.setParameter("p_cus_list_code", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCustListCode().toUpperCase());
query.setParameter("p_cus_list_name", DataUtil.isNullOrEmpty(dto.getCustListName()) ? null : dto.getCustListName().toUpperCase());
query.setParameter("p_to_date", dto.getCreateTimeTo());
query.setParameter("p_from_date", dto.getCreateTimeFr());
query.setParameter("p_page_number", dto.getPage());
query.setParameter("p_page_size", dto.getPageSize());
query.addScalar("customerListId", new LongType());
query.addScalar("customerListCode", new StringType());
query.addScalar("customerListName", new StringType());
query.addScalar("totalCusList", new LongType());
query.addScalar("totalCusActive", new LongType());
query.addScalar("totalCusLock", new LongType());
query.addScalar("totalCusDnc", new LongType());
query.addScalar("totalRow", new IntegerType());
query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class));
int total = 0;
list = query.list();
if (list.size() > 0) {
total = list.get(0).getTotalRow();
}
resultDTO.setListData(list);
resultDTO.setTotalRow(total);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
return resultDTO;
}
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerChoosenList(CampaignRequestDTO dto) {
List<CustomerListDTO> list = new ArrayList();
ResultDTO resultDTO = new ResultDTO();
Map<String, String> params = new HashMap<>();
// StringBuilder sb = new StringBuilder();
try {
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-customer-list-choosen");
String sql = "with campaign_customer_id as (\n" +
" select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl\n" +
" where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id\n" +
"),\n" +
"customer_table as (\n" +
" select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a\n" +
" left join customer b on a.customer_id = b.customer_id\n" +
" where b.status = 1\n" +
" group by a.customer_list_id\n" +
"),\n" +
"customer_active_table as (\n" +
" select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a\n" +
" left join customer b on a.customer_id = b.customer_id\n" +
" where b.status = 1 and b.ipcc_status = 'active'\n" +
" group by a.customer_list_id\n" +
"),\n" +
"customer_lock_table as (\n" +
" select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a\n" +
" left join customer b on a.customer_id = b.customer_id\n" +
" where b.status = 1 and b.ipcc_status = 'locked'\n" +
" group by a.customer_list_id\n" +
"),\n" +
"customer_dnc_table as (\n" +
" select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a\n" +
" left join customer b on a.customer_id = b.customer_id\n" +
" where b.status = 1 and b.call_allowed = 0\n" +
" group by a.customer_list_id\n" +
"),\n" +
"customer_filter_table as (\n" +
" select count(a.customer_id) customerFilter, a.customer_list_id customerListId from campaign_customer a\n" +
" where a.campaign_id = :p_campaign_id\n" +
" group by a.customer_list_id\n" +
"),\n" +
"data_temp as (\n" +
"select a.customer_list_id customerListId,\n" +
" a.customer_list_code customerListCode,\n" +
" a.customer_list_name customerListName,\n" +
" nvl(b.totalCustomer, 0) totalCusList,\n" +
" nvl(c.customerActive, 0) totalCusActive,\n" +
" nvl(d.customerLock, 0) totalCusLock,\n" +
" nvl(e.customerDnc, 0) totalCusDnc,\n" +
" nvl(null, 0) totalCusAddRemove,\n" +
" nvl(f.customerFilter, 0) totalCusFilter\n" +
"from customer_list a\n" +
"left join customer_table b on a.customer_list_id = b.customerListId\n" +
"left join customer_active_table c on a.customer_list_id = c.customerListId\n" +
"left join customer_lock_table d on a.customer_list_id = d.customerListId\n" +
"left join customer_dnc_table e on a.customer_list_id = e.customerListId\n" +
"left join customer_filter_table f on a.customer_list_id = f.customerListId\n" +
"where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)\n" +
"),\n" +
"data as (\n" +
"select a.*, rownum row_ from data_temp a\n" +
"),\n" +
"count_data as (\n" +
"select count(*) totalRow from data_temp\n" +
")\n" +
"select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter, totalRow from data a, count_data\n" +
"where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)\n";
params.put("p_campaign_id", dto.getCampaignId());
params.put("p_company_site_id", dto.getCompanySiteId());
params.put("p_page_number", dto.getPage().toString());
params.put("p_page_size", dto.getPageSize().toString());
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(CustomerListDTO.class));
int total = 0;
if (list.size() > 0) {
total = list.get(0).getTotalRow();
}
resultDTO.setListData(list);
resultDTO.setTotalRow(total);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
......
......@@ -68,6 +68,61 @@ public class ScenarioQuestionRepositoryImpl implements ScenarioQuestionRepositor
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
} finally {
session.close();
}
return count;
}
@Override
public Integer countDuplicateOrderIndex(ScenarioQuestionDTO questionDTO) {
logger.info("Start search duplicate order index::");
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Integer count = null;
try {
StringBuilder sb = new StringBuilder();
sb.append("SELECT COUNT(1) FROM SCENARIO_QUESTION WHERE 1 = 1 AND STATUS = 1 ");
if (questionDTO.getScenarioQuestionId() != null) {
sb.append(" AND SCENARIO_QUESTION_ID <> :p_question_id ");
}
if (questionDTO.getOrderIndex() != null) {
sb.append(" AND ORDER_INDEX = :p_orderIndex ");
}
if (questionDTO.getCampaignId() != null) {
sb.append(" AND CAMPAIGN_ID = :p_campaign_id");
}
if (questionDTO.getCompanySiteId() != null) {
sb.append(" AND COMPANY_SITE_ID = :p_site_id");
}
SQLQuery query = session.createSQLQuery(sb.toString());
if (questionDTO.getScenarioQuestionId() != null) {
query.setParameter("p_question_id", questionDTO.getScenarioQuestionId());
}
if (questionDTO.getOrderIndex() != null) {
query.setParameter("p_orderIndex", questionDTO.getOrderIndex());
}
if (questionDTO.getCampaignId() != null) {
query.setParameter("p_campaign_id", questionDTO.getCampaignId());
}
if (questionDTO.getCompanySiteId() != null) {
query.setParameter("p_site_id", questionDTO.getCompanySiteId());
}
final List<BigDecimal> obj = query.list();
for (BigDecimal i : obj) {
if (i != null) {
count = i.intValue();
}
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
} finally {
session.close();
}
return count;
}
......
......@@ -28,7 +28,11 @@ public interface CampaignExecuteService {
ResultDTO getExecuteCampaign(CampaignRequestDTO requestDto);
ResultDTO getCall(CampaignCustomerDTO dto);
ResultDTO getCustomer(CampaignCustomerDTO dto);
ResultDTO updateCustomerResult(ContactCustResultDTO dto);
ResultDTO getCustomerComplete(ReceiveCustLogDTO dto);
ResultDTO getCallLog(ReceiveCustLogDTO dto);
......
......@@ -56,6 +56,16 @@ public interface CampaignService {
ResultDTO getListFieldsToShow(CampaignRequestDTO dto);
ResultDTO getCampaignCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerChoosenList(CampaignRequestDTO dto);
ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto);
ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto);
ResultDTO saveFieldCustomer(CampaignRequestDTO dto);
//</editor-fold>
}
......@@ -34,7 +34,7 @@ public interface CustomerService {
ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId);
ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName);
CustomerList createCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO);
......
......@@ -13,4 +13,6 @@ public interface ScenarioAnswerService {
Long getMaxAnswerOrderId(Long scenarioQuestionId, Long companySiteId);
ResultDTO delete(ScenarioAnswerDTO scenarioAnswerDTO);
Integer countDuplicateScenarioCode(String code, Long scenarioQuestionId, Long scenarioAnswerId);
}
......@@ -20,4 +20,6 @@ public interface ScenarioQuestionService {
ResultDTO update(ScenarioQuestionDTO scenarioQuestionDTO);
Integer countDuplicateOrderIndex(ScenarioQuestionDTO questionDTO);
}
package com.viettel.campaign.service;
import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.ScenarioAnswerDTO;
import com.viettel.campaign.web.dto.ScenarioDTO;
import com.viettel.campaign.web.dto.ScenarioQuestionDTO;
import com.viettel.campaign.web.dto.*;
import java.util.List;
......@@ -14,7 +11,12 @@ import java.util.List;
public interface ScenarioService {
Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
ResultDTO update(ScenarioDTO scenario);
ResultDTO sortQuestionAndAnswer(ScenarioDTO scenarioDTO);
Integer countDuplicateScenarioCode(Long companySiteId, String code, Long scenarioId);
ResultDTO saveContacQuestResult(ContactQuestResultDTO dto);
}
package com.viettel.campaign.service;
import com.viettel.campaign.model.ccms_full.UserActionLog;
/**
* @author anhvd_itsol
* @author hanv_itsol
* @project campaign
*/
public interface UserActionLogService {
void save(UserActionLog log);
}
......@@ -4,6 +4,7 @@ import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.acd_full.Agents;
import com.viettel.campaign.model.ccms_full.CampaignCustomer;
import com.viettel.campaign.model.ccms_full.ContactCustResult;
import com.viettel.campaign.model.ccms_full.ReceiveCustLog;
import com.viettel.campaign.repository.acd_full.AgentsRepository;
import com.viettel.campaign.repository.ccms_full.*;
import com.viettel.campaign.service.CampaignExecuteService;
......@@ -288,7 +289,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
}
@Override
public ResultDTO getCall(CampaignCustomerDTO dto) {
public ResultDTO getCustomer(CampaignCustomerDTO dto) {
ResultDTO result = new ResultDTO();
//Agents agents = agentsRepository.findByAgentId(dto.getAgentId());
......@@ -438,6 +439,26 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
return result;
}
@Override
public ResultDTO getCustomerComplete(ReceiveCustLogDTO dto) {
ResultDTO result = new ResultDTO();
try {
ReceiveCustLog rclResult = custLogRepository.save(modelMapper.map(dto, ReceiveCustLog.class));
agentsRepository.updateAgentLogoutFromCampaign(dto.getAgentId().toString(), "NOT AVAILABLE");
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setData(rclResult);
} catch (Exception e) {
e.printStackTrace();
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
return result;
}
@Override
public ResultDTO getCallLog(ReceiveCustLogDTO dto) {
ResultDTO result = new ResultDTO();
......@@ -463,7 +484,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
ResultDTO result = new ResultDTO();
try {
agentsRepository.updateAgentLogoutFromCampaign(Long.parseLong(dto.getAgentId()), "LOGOUT");
agentsRepository.updateAgentLogoutFromCampaign(dto.getAgentId(), "LOGOUT");
campaignAgentRepository.updateCampaignAgentSetStatus(Long.parseLong(dto.getAgentId()), Long.parseLong(dto.getCampaignId()), 0);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
......@@ -496,6 +517,32 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
return result;
}
@Override
public ResultDTO updateCustomerResult(ContactCustResultDTO dto) {
ResultDTO result = new ResultDTO();
try {
ContactCustResult ccr = ccResultRepository.getOne(dto.getContactCustResultId());
ccr.setDurationCall(0L);
ccr.setStartCall(new Date());
ccr.setReceiveTime(new Date());
ccr.setPreEndTime(new Date());
ccr.setEndTime(new Date());
ccr.setWaitTime(0L);
ContactCustResult resultUpdate = ccResultRepository.save(ccr);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setData(resultUpdate);
} catch (Exception e) {
e.printStackTrace();
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
return result;
}
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO countRecallCustomer(Long companySiteId, Long agentId) {
Long count = campaignCustomerRepository.countRecallCustomer(companySiteId, agentId);
......
......@@ -60,6 +60,15 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired
ScenarioRepository scenarioRepository;
@Autowired
CampaignCustomerListRepository campaignCustomerListRepository;
@Autowired
CampaignCustomerRepository campaignCustomerRepository;
@Autowired
CampaignCustomerListColumnRepository campaignCustomerListColumnRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO search(CampaignRequestDTO requestDto) {
......@@ -363,14 +372,15 @@ public class CampaignServiceImpl implements CampaignService {
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO updateCampaign(CampaignDTO dto) {
ResultDTO resultDTO = new ResultDTO();
List<TimeZoneDialModeDTO> lstTimeZone = dto.getLstTimeZone();
List<TimeRangeDialModeDTO> lstTimeRange = dto.getLstTimeRange();
Campaign campaignEntity = new Campaign();
campaignEntity.setCampaignId(dto.getCampaignId());
Campaign campaignEntity = campaignRepository.findByCampaignId(dto.getCampaignId());
campaignEntity.setCampaignName(dto.getCampaignName());
campaignEntity.setCampaignCode(dto.getCampaignCode());
campaignEntity.setContent(dto.getContent());
campaignEntity.setCustomerNumber(dto.getCustomerNumber());
......@@ -486,6 +496,122 @@ public class CampaignServiceImpl implements CampaignService {
return campaignRepositoryCustom.getCampaignCustomerList(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCustomerList(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerChoosenList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCustomerChoosenList(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
String[] lstCusListId = dto.getLstCustomerListId().split(",");
try {
for(String cusListId : lstCusListId) {
CampaignCustomerList entity = new CampaignCustomerList();
entity.setCampaignId(Long.parseLong(dto.getCampaignId()));
entity.setCompanySiteId(Long.parseLong(dto.getCompanySiteId()));
entity.setCustomerListId(Long.parseLong(cusListId));
campaignCustomerListRepository.save(entity);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
String[] lstCusListId = dto.getLstCustomerListId().split(",");
long campaignId = Long.parseLong(dto.getCampaignId());
long companySiteId = Long.parseLong(dto.getCompanySiteId());
try {
for(String cusListId : lstCusListId) {
// Xoa danh sach khach hang khoi campaign_customerList
campaignCustomerListRepository.deleteCampaignCustomerListByCampaignIdAndCustomerListIdAndCompanySiteId(campaignId, Long.parseLong(cusListId), companySiteId);
// Thuc hien xoa cac khach hang chua lien lac tai bang campaign_customer
List<CampaignCustomer> listCampaignCustomer = campaignCustomerRepository.findCustomerNoContact(campaignId, companySiteId, Long.parseLong(cusListId));
for (CampaignCustomer entity : listCampaignCustomer) {
campaignCustomerRepository.delete(entity);
}
// Thuc hien update cac khach hang da lien lac
List<CampaignCustomer> list = campaignCustomerRepository.findCustomerContacted(campaignId, companySiteId, Long.parseLong(cusListId));
for (CampaignCustomer campaignCustomer: list) {
campaignCustomer.setInCampaignStatus((short) 0);
}
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO saveFieldCustomer(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
List<FieldsToShowDTO> list = dto.getLstFiedCustomer();
long campaignId = Long.parseLong(dto.getCampaignId());
long companySiteId = Long.parseLong(dto.getCompanySiteId());
List<CampaignCustomerListColumn> listColumns = campaignCustomerListColumnRepository.findByCampaignIdAndCompanySiteId(campaignId, companySiteId);
try {
// Them moi cac truong hien thi
for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getId() == null) {
CampaignCustomerListColumn entity = new CampaignCustomerListColumn();
entity.setCampaignId(campaignId);
entity.setCompanySiteId(companySiteId);
if (fieldsToShowDTO.getIsFix()) {
entity.setColumnName(fieldsToShowDTO.getColumnName());
} else {
entity.setCustomizeFieldId(fieldsToShowDTO.getCustomizeFieldId());
entity.setCustomizeFieldTitle(fieldsToShowDTO.getColumnTitle());
}
entity.setOrderIndex((long) (list.indexOf(fieldsToShowDTO) + 1));
campaignCustomerListColumnRepository.save(entity);
}
}
// Cap nhat cac truong da co san
for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getId() != null) {
listColumns.removeIf(p -> p.getCampaignCusListColId() == fieldsToShowDTO.getId());
CampaignCustomerListColumn entity = campaignCustomerListColumnRepository.findByCampaignCusListColId(fieldsToShowDTO.getId());
entity.setOrderIndex((long) (list.indexOf(fieldsToShowDTO) + 1));
campaignCustomerListColumnRepository.save(entity);
}
}
// Xoa cac truong khong con hien thi nua
for (CampaignCustomerListColumn entity : listColumns) {
campaignCustomerListColumnRepository.delete(entity);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
// hungtt
private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) {
mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale));
......
......@@ -113,4 +113,15 @@ public class ScenarioAnswerServiceImpl implements ScenarioAnswerService {
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Integer countDuplicateScenarioCode(String code, Long scenarioQuestionId, Long scenarioAnswerId) {
try {
return scenarioAnswerRepository.countDuplicateScenarioCode(code, scenarioQuestionId, scenarioAnswerId);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
}
......@@ -302,4 +302,15 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Integer countDuplicateOrderIndex(ScenarioQuestionDTO questionDTO) {
try {
return questionRepositoryCustom.countDuplicateOrderIndex(questionDTO);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
}
package com.viettel.campaign.service.impl;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.ContactQuestResult;
import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.model.ccms_full.ScenarioAnswer;
import com.viettel.campaign.model.ccms_full.ScenarioQuestion;
import com.viettel.campaign.repository.ccms_full.ScenarioAnswerRepository;
import com.viettel.campaign.repository.ccms_full.ScenarioQuestionRepository;
import com.viettel.campaign.repository.ccms_full.ScenarioRepository;
import com.viettel.campaign.repository.ccms_full.*;
import com.viettel.campaign.service.ScenarioService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.ScenarioAnswerDTO;
import com.viettel.campaign.web.dto.ScenarioDTO;
import com.viettel.campaign.web.dto.ScenarioQuestionDTO;
import com.viettel.campaign.web.dto.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.Date;
......@@ -46,6 +41,9 @@ public class ScenarioServiceImpl implements ScenarioService {
@Autowired
ModelMapper modelMapper;
@Autowired
ContactQuestResultRepository questResultRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId) {
......@@ -117,4 +115,31 @@ public class ScenarioServiceImpl implements ScenarioService {
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Integer countDuplicateScenarioCode(Long companySiteId, String code, Long scenarioId) {
try {
return scenarioRepository.countDuplicateScenarioCode(companySiteId, code, scenarioId);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
public ResultDTO saveContacQuestResult(ContactQuestResultDTO dto) {
ResultDTO resultDTO = new ResultDTO();
if (dto != null) {
ContactQuestResult cqr = questResultRepository.save(modelMapper.map(dto, ContactQuestResult.class));
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(cqr);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
}
package com.viettel.campaign.service.impl;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.UserActionLog;
import com.viettel.campaign.repository.ccms_full.UserActionLogRepository;
import com.viettel.campaign.service.UserActionLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -11,4 +15,13 @@ import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(rollbackFor = Exception.class)
public class UserActionLogServiceImpl implements UserActionLogService {
@Autowired
UserActionLogRepository userActionLogRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public void save(UserActionLog log) {
userActionLogRepository.save(log);
}
}
......@@ -10,7 +10,7 @@ import java.util.Date;
@Getter
@Setter
@NoArgsConstructor
public class ContactCustResultDTO extends BaseDTO{
public class ContactCustResultDTO extends BaseDTO {
private Long contactCustResultId;
private Long companySiteId;
private Short callStatus;
......
......@@ -21,10 +21,17 @@ public class CustomerListDTO extends BaseDTO {
private Date updateAt;
private String source;
private String deptCreate;
private String count;
private Long totalCusInList;
private Long totalCusInteract;
private Long totalCusNotInteract;
private Long totalCusList;
private Long totalCusCampaign;
private Long totalCusCalled;
private Long totalCusActive;
private Long totalCusLock;
private Long totalCusDnc;
private Long totalCusAddRemove;
private Long totalCusFilter;
private Integer totalRow;
}
......@@ -13,21 +13,13 @@ import java.io.Serializable;
@AllArgsConstructor
public class FieldsToShowDTO implements Serializable {
// private Long campaignCusListColId;
// private Long companySiteId;
// private Long campaignId;
private Long id;
private String columnName;
private String columnTitle;
// private Long orderIndex;
// private Long customizeFieldId;
// private String customizeFieldTitle;
private Boolean isFix;
private Long customizeFieldId;
}
......@@ -2,6 +2,7 @@ package com.viettel.campaign.web.dto.request_dto;
import com.viettel.campaign.web.dto.BaseDTO;
import com.viettel.campaign.web.dto.CustomerCustomDTO;
import com.viettel.campaign.web.dto.FieldsToShowDTO;
import lombok.Getter;
import lombok.Setter;
......@@ -46,5 +47,10 @@ public class CampaignRequestDTO extends BaseDTO {
String roleUser;
String contactCustId;
List<CustomerCustomDTO> customerCustomDTOList;
String custListCode;
String custListName;
String createTimeTo;
String createTimeFr;
String lstCustomerListId;
List<FieldsToShowDTO> lstFiedCustomer;
}
......@@ -4,8 +4,13 @@ import com.viettel.campaign.model.ccms_full.TimeRangeDialMode;
import com.viettel.campaign.model.ccms_full.TimeZoneDialMode;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.utils.BundleUtils;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -15,6 +20,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -22,7 +28,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import java.util.Locale;
import java.util.Objects;
@RestController
@RequestMapping("/ipcc/campaign")
......@@ -52,10 +59,17 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCall")
@PostMapping("/getCustomer")
@ResponseBody
public ResponseEntity<ResultDTO> getCall(@RequestBody CampaignCustomerDTO requestDto) {
ResultDTO result = campaignExecuteService.getCall(requestDto);
public ResponseEntity<ResultDTO> getCustomer(@RequestBody CampaignCustomerDTO requestDto) {
ResultDTO result = campaignExecuteService.getCustomer(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCustomerComplete")
@ResponseBody
public ResponseEntity<ResultDTO> getCustomerComplete(@RequestBody ReceiveCustLogDTO requestDto) {
ResultDTO result = campaignExecuteService.getCustomerComplete(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
......@@ -255,9 +269,74 @@ public class CampaignController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/getCustomerList")
@ResponseBody
public ResponseEntity getCustomerList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.getCustomerList(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/getCustomerChoosenList")
@ResponseBody
public ResponseEntity getCustomerChoosenList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.getCustomerChoosenList(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/addCustomerListToCampaign")
@ResponseBody
public ResponseEntity addCustomerListToCampaign(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.addCustomerListToCampaign(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/deleteCustomerListFromCampaign")
@ResponseBody
public ResponseEntity deleteCustomerListFromCampaign(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.deleteCustomerListFromCampaign(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/saveFieldCustomer")
@ResponseBody
public ResponseEntity saveFieldCustomer(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.saveFieldCustomer(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT)
public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) {
ResultDTO result = campaignService.renewCampaign(campaignDTO);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/import-file", method = RequestMethod.POST)
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestHeader("X-Auth-Token") String authToken) {
Locale locale = new Locale("vi", "VN");
try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(authToken);
if (file.isEmpty()) {
return new ResponseEntity<>(BundleUtils.getLangString("common.fileNotSelected"), HttpStatus.OK);
}
if (!Objects.equals(FilenameUtils.getExtension(file.getOriginalFilename()), Constants.FileType.xlsx)) {
return new ResponseEntity<>(BundleUtils.getLangString("common.fileInvalidFormat", locale), HttpStatus.OK);
}
//String path = saveUploadFile(file);
// List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
// Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, customerListId);
// File fileExport = (File) map.get("file");
// String message = (String) map.get("message");
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=template_import_customer.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
return new ResponseEntity<>(null, HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
}
......@@ -37,4 +37,10 @@ public class ScenarioAnswerController {
ResultDTO resultDTO = scenarioAnswerService.delete(answerDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/count-duplicate-code", method = RequestMethod.GET)
ResponseEntity<Integer> countDuplicateCode(@RequestParam String code, @RequestParam Long scenarioQuestionId, @RequestParam Long scenarioAnswerId) {
Integer count = scenarioAnswerService.countDuplicateScenarioCode(code, scenarioQuestionId, scenarioAnswerId);
return new ResponseEntity<>(count, HttpStatus.OK);
}
}
......@@ -2,6 +2,7 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.service.ScenarioService;
import com.viettel.campaign.web.dto.ContactQuestResultDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.ScenarioDTO;
import org.slf4j.Logger;
......@@ -19,11 +20,13 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("/ipcc/campaign/scenario")
@CrossOrigin
public class ScenarioController {
private static final Logger logger = LoggerFactory.getLogger(ScenarioController.class);
@Autowired
ScenarioService scenarioService;
@RequestMapping(value="/findOneByCampaignIdAndCompanyId", method = RequestMethod.GET)
@RequestMapping(value = "/findOneByCampaignIdAndCompanyId", method = RequestMethod.GET)
Scenario findOneByCampaignIdAndCompanyId(@RequestParam Long campaignId, @RequestParam Long companySiteId) {
return scenarioService.findScenarioByCampaignIdAndCompanySiteId(campaignId, companySiteId);
}
......@@ -39,4 +42,16 @@ public class ScenarioController {
ResultDTO resultDTO = scenarioService.sortQuestionAndAnswer(scenarioDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/count-duplicate-code", method = RequestMethod.GET)
ResponseEntity<Integer> countDuplicateCode(@RequestParam String code, @RequestParam Long scenarioId, @RequestParam Long companySiteId) {
Integer count = scenarioService.countDuplicateScenarioCode(companySiteId, code, scenarioId);
return new ResponseEntity<>(count, HttpStatus.OK);
}
@RequestMapping(value = "/saveContactQuestResult", method = RequestMethod.POST)
ResponseEntity<ResultDTO> saveContactQuestResult(@RequestBody ContactQuestResultDTO dto) {
ResultDTO resultDTO = scenarioService.saveContacQuestResult(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
}
......@@ -56,4 +56,9 @@ public class ScenarioQuestionController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/count-duplicate-order-index", method = RequestMethod.POST)
public Integer countDuplicateOrderIndex(@RequestBody ScenarioQuestionDTO questionDTO) {
return scenarioQuestionService.countDuplicateOrderIndex(questionDTO);
}
}
server:
port: 9999
port: 1111
spring:
application:
name: campaign
......
......@@ -103,3 +103,8 @@ customer.notLessThan = not less than
customer.importCustomer = IMPORT CUSTOMER
customer.notice = Attention: A record is valid when Full Name is not null and one of three fields Main phone, secondary phone or email is not null
customer.fileNotSelected=Please select a file
customer.emailInvalid=Invalid email;
customer.emailExists=Email exists;
common.fileNotSelected=Please select a file
common.fileInvalidFormat=File invalid
......@@ -105,3 +105,8 @@ customer.notLessThan = không được nhỏ hơn
customer.importCustomer = IMPORT KHÁCH HÀNG
customer.notice = Chú ý: 1 bản ghi được coi là hợp lệ bắt buộc phải có thông tin Họ và Tên và 1 trong 3 thông tin liên lạc (số điện thoại chính, số điện thoại phụ hoặc email)
customer.fileNotSelected=Bạn chưa chọn file
customer.emailInvalid=Email không đúng định dạng;
customer.emailExists=Email đã tồn tại;
common.fileNotSelected=Bạn chưa chọn file
common.fileInvalidFormat=File không hợp lệ
with campaign_customer_id as (
select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl
where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id
),
customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1
group by a.customer_list_id
),
customer_active_table as (
select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'active'
group by a.customer_list_id
),
customer_lock_table as (
select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'locked'
group by a.customer_list_id
),
customer_dnc_table as (
select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.call_allowed = 0
group by a.customer_list_id
),
customer_filter_table as (
select count(a.customer_id) customerFilter, a.customer_list_id customerListId from campaign_customer a
where a.campaign_id = :p_campaign_id
group by a.customer_list_id
),
data_temp as (
select a.customer_list_id customerListId,
a.customer_list_code customerListCode,
a.customer_list_name customerListName,
nvl(b.totalCustomer, 0) totalCusList,
nvl(c.customerActive, 0) totalCusActive,
nvl(d.customerLock, 0) totalCusLock,
nvl(e.customerDnc, 0) totalCusDnc,
nvl(null, 0) totalCusAddRemove,
nvl(f.customerFilter, 0) totalCusFilter
from customer_list a
left join customer_table b on a.customer_list_id = b.customerListId
left join customer_active_table c on a.customer_list_id = c.customerListId
left join customer_lock_table d on a.customer_list_id = d.customerListId
left join customer_dnc_table e on a.customer_list_id = e.customerListId
left join customer_filter_table f on a.customer_list_id = f.customerListId
where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)
),
data as (
select a.*, rownum row_ from data_temp a
),
count_data as (
select count(*) totalRow from data_temp
)
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter, totalRow from data a, count_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)
with campaign_customer_id as (
select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl
where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id
),
customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1
group by a.customer_list_id
),
customer_active_table as (
select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'active'
group by a.customer_list_id
),
customer_lock_table as (
select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'locked'
group by a.customer_list_id
),
customer_dnc_table as (
select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.call_allowed = 0
group by a.customer_list_id
),
data_temp as (
select a.customer_list_id customerListId,
a.customer_list_code customerListCode,
a.customer_list_name customerListName,
nvl(b.totalCustomer, 0) totalCusList,
nvl(c.customerActive, 0) totalCusActive,
nvl(d.customerLock, 0) totalCusLock,
nvl(e.customerDnc, 0) totalCusDnc,
a.create_at createAt,
a.company_site_id companySiteId,
a.status status
from customer_list a
left join customer_table b on a.customer_list_id = b.customerListId
left join customer_active_table c on a.customer_list_id = c.customerListId
left join customer_lock_table d on a.customer_list_id = d.customerListId
left join customer_dnc_table e on a.customer_list_id = e.customerListId
where a.status = 1
and (:p_cus_list_code is null or upper(a.customer_list_code) like '%'||:p_cus_list_code||'%')
and (:p_cus_list_name is null or upper(a.customer_list_name) like '%'||:p_cus_list_name||'%')
and (a.create_at <= to_date(:p_to_date, 'DD/MM/YYYY'))
and (a.create_at >= to_date(:p_from_date, 'DD/MM/YYYY'))
and (a.company_site_id = :p_company_site_id)
and (a.customer_list_id not in (select CUSTOMER_LIST_ID from campaign_customer_id))
),
data as (
select a.*, rownum row_ from data_temp a
),
count_data as (
select count(*) totalRow from data_temp
)
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, totalRow from data a, count_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)
with customer_table as (
with campaign_customer_id as (
select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl
where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id
),
customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1
......@@ -18,7 +22,8 @@ customer_not_interactive_table as (
select count(a.customer_id) cusNotInteractive, a.customer_list_id customerListId, a.campaign_id from campaign_customer a
where a.status = 0 and a.campaign_id = :p_campaign_id and a.in_campaign_status = 1
group by a.customer_list_id, a.campaign_id
)
),
data_temp as (
select a.customer_list_id customerListId,
a.customer_list_code customerListCode,
a.customer_list_name customerListName,
......@@ -31,3 +36,13 @@ left join customer_table b on a.customer_list_id = b.customerListId
left join campaign_customer_table c on a.customer_list_id = c.customerListId
left join customer_interactive_table d on a.customer_list_id = d.customerListId
left join customer_not_interactive_table e on a.customer_list_id = e.customerListId
where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)
),
data as (
select a.*, rownum row_ from data_temp a
),
count_data as (
select count(*) totalRow from data_temp
)
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusCampaign, a.totalCusCalled, a.totalCusNotInteract, totalRow from data a, count_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)
with column_name_temp as (
select column_name columnName, 1 isFix from user_tab_columns, dual
select column_name columnName, null customizeFieldId, 1 isFix from user_tab_columns, dual
where table_name = 'CUSTOMER'
)
select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)
union all
select title columnName, 0 isFix from customize_fields, dual
select title columnName, customize_field_id customizeFieldId, 0 isFix from customize_fields, dual
where function_code = 'CUSTOMER'
and site_id = :p_company_site_id
and customize_field_id not in (select customize_field_id from campaign_customerlist_column where campaign_customerlist_column.campaign_id = :p_campaign_id)
select to_char(column_name) columnName, 1 isFix from campaign_customerlist_column, dual where campaign_id = :p_campaign_id and column_name is not null
with field_name as (
select a.campaign_cus_list_column_id id, to_char(a.column_name) columnName, a.order_index, a.customize_field_id customizeFieldId, 1 isFix
from campaign_customerlist_column a, dual
where a.campaign_id = :p_campaign_id
and a.company_site_id = :p_company_site_id
and column_name is not null
union all
select customize_field_title columnName, 0 isFix from campaign_customerlist_column where campaign_id = :p_campaign_id
select a.campaign_cus_list_column_id id, a.customize_field_title columnName, a.order_index, a.customize_field_id customizeFieldId, 0 isFix
from campaign_customerlist_column a
where a.campaign_id = :p_campaign_id
and a.company_site_id = :p_company_site_id
)
select id, columnName, customizeFieldId, isFix from field_name where columnName is not null order by order_index
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