Commit 2f4944a3 authored by Tu Bach's avatar Tu Bach

Merge branch 'master' into tubn

# Conflicts:
#	src/main/java/com/viettel/campaign/service/impl/CampaignExecuteServiceImp.java
parents bc6c4f74 ba5f20e1
......@@ -11,23 +11,16 @@ import java.util.List;
public interface CustomerListMappingRepository extends JpaRepository<CustomerListMapping, Long> {
// ----------- customer ------------ //
@Query("select c from CustomerListMapping c where c.customerId in (:p_ids) and c.customerListId =:p_customer_list_id and c.companySiteId=:p_company_site_id")
List<CustomerListMapping> findAllCustomerListMapping(@Param("p_ids") List<Long> p_ids, @Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@Query("delete from CustomerListMapping c where c.customerId=:p_customer_id and c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerId(@Param("p_customer_id") Long p_customer_id, @Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@Query("delete from CustomerListMapping c where c.customerId in (:p_ids) and c.customerListId =:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerIds(@Param("p_ids") List<Long> p_ids, @Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
// ----------- customer list --------------- //
@Modifying
@Query("delete from CustomerListMapping c where c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerListId(@Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@Query("delete from CustomerListMapping c where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
......
......@@ -8,7 +8,7 @@ import org.springframework.data.repository.query.Param;
import java.util.List;
public interface CustomerListRepository extends JpaRepository<CustomerList, Long> {
public interface CustomerListRepository extends JpaRepository<CustomerList, Long>, CustomerListRepositoryCustom {
CustomerList findByCustomerListIdAndCompanySiteId(long customerListId, long companySiteId);
......@@ -17,14 +17,7 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long
@Query("select c from CustomerList c where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id and c.status = 1")
List<CustomerList> findAllCustomerList(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@Query("update CustomerList c set c.status = 0 where c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteCustomerList(@Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@Query("update CustomerList c set c.status = 0 where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id")
int deleteCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
@Query(value = "SELECT * FROM (SELECT c.*, MAX(c.CREATE_AT) OVER() AS LATEST_CREATED FROM CUSTOMER_LIST c) WHERE CREATE_AT = LATEST_CREATED AND COMPANY_SITE_ID =:p_company_site_id", nativeQuery = true)
CustomerList latestCreated(@Param("p_company_site_id") Long p_company_site_id);
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerListRequestDTO;
import org.springframework.data.domain.Pageable;
import java.util.List;
public interface CustomerListRepositoryCustom {
List<CustomerListDTO> getAllCustomerListByParams(SearchCustomerListRequestDTO searchCustomerListRequestDTO, Pageable pageable);
}
......@@ -15,7 +15,7 @@ import java.util.Date;
import java.util.List;
@Repository
public interface CustomerRepository extends JpaRepository<Customer, Long> {
public interface CustomerRepository extends JpaRepository<Customer, Long>, CustomerRepositoryCustom {
Page<Customer> findAll(Pageable pageable);
......
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerDetailRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.springframework.data.domain.Pageable;
import java.util.List;
public interface CustomerRepositoryCustom {
List<CustomerDetailRequestDTO> getCustomerDetailById(Long companySiteId, Long customerListId, Long customerId);
List<CustomerCustomDTO> getAllCustomerByParams(SearchCustomerRequestDTO searchCustomerRequestDTO, Pageable pageable);
List<CampaignInformationDTO> getCampaignInformation(CampaignCustomerDTO campaignCustomerDTO);
List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO);
List<CustomerListDTO> getCustomerListInfo(CampaignCustomerDTO campaignCustomerDTO);
List<CustomerDTO> getCustomizeFields(CampaignCustomerDTO campaignCustomerDTO, UserSession userSession, Pageable pageable);
}
......@@ -195,8 +195,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_customer_id", "%" +
dto.getCustomerId().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
......@@ -229,8 +229,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_phone_number", "%" +
dto.getPhoneNumber().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
......@@ -238,8 +238,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_campaign_name", "%" +
dto.getCampaignName().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
......@@ -247,8 +247,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_user_name", "%" +
dto.getAgentId().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
......@@ -526,8 +526,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("pCampaignName", "%" +
campaignRequestDto.getCampaignName().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
......
package com.viettel.campaign.repository.ccms_full.impl;
import com.viettel.campaign.repository.ccms_full.CustomerListRepositoryCustom;
import com.viettel.campaign.utils.*;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerListRequestDTO;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.hibernate.type.DateType;
import org.hibernate.type.LongType;
import org.hibernate.type.ShortType;
import org.hibernate.type.StringType;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
import java.util.TimeZone;
@Repository
public class CustomerListRepositoryImpl implements CustomerListRepositoryCustom {
@Override
public List<CustomerListDTO> getAllCustomerListByParams(SearchCustomerListRequestDTO searchCustomerListRequestDTO, Pageable pageable) {
TimeZone tzClient = TimeZoneUtils.getZoneMinutes(searchCustomerListRequestDTO.getTimezoneOffset());
List<CustomerListDTO> listData = new ArrayList<>();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = null;
try {
session = sessionFactory.openSession();
session.beginTransaction();
StringBuilder sb = new StringBuilder();
sb.append("SELECT");
sb.append(" a.CUSTOMER_LIST_ID customerListId,");
sb.append(" a.COMPANY_SITE_ID companySiteId,");
sb.append(" a.CUSTOMER_LIST_CODE customerListCode,");
sb.append(" a.CUSTOMER_LIST_NAME customerListName,");
sb.append(" a.STATUS status,");
sb.append(" a.CREATE_BY createBy,");
sb.append(" a.CREATE_AT createAt,");
sb.append(" a.UPDATE_BY updateBy,");
sb.append(" a.UPDATE_AT updateAt,");
sb.append(" a.SOURCE source,");
sb.append(" a.DEPT_CREATE deptCreate,");
sb.append(" b.count count");
sb.append(" FROM CUSTOMER_LIST a");
sb.append(" LEFT JOIN (SELECT COUNT(CAMPAIGN_ID) as count, CUSTOMER_LIST_ID");
sb.append(" FROM CAMPAIGN_CUSTOMERLIST");
sb.append(" GROUP BY CUSTOMER_LIST_ID) b");
sb.append(" ON a.CUSTOMER_LIST_ID = b.CUSTOMER_LIST_ID");
sb.append(" WHERE 1 = 1");
sb.append(" AND a.STATUS = 1");
sb.append(" AND a.COMPANY_SITE_ID = :p_company_site_id");
sb.append(" AND to_date(CREATE_AT, 'DD/MM/RR') >= to_date(:p_date_from, 'DD/MM/YYYY HH24:MI:SS') AND to_date(CREATE_AT, 'DD/MM/RR') <= to_date(:p_date_to, 'DD/MM/YYYY HH24:MI:SS')");
if (!DataUtil.isNullOrEmpty(searchCustomerListRequestDTO.getCustomerListCode())) {
sb.append(" AND UPPER(CUSTOMER_LIST_CODE) LIKE UPPER(:p_list_code)");
}
if (!DataUtil.isNullOrEmpty(searchCustomerListRequestDTO.getCustomerListName())) {
sb.append(" AND UPPER(CUSTOMER_LIST_NAME) LIKE UPPER(:p_list_name)");
}
sb.append(" ORDER BY CREATE_AT DESC");
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", searchCustomerListRequestDTO.getCompanySiteId());
query.setParameter("p_date_from", TimeZoneUtils.toDateStringWithTimeZone(DateTimeUtil.parseDate("YYYYMMdd", searchCustomerListRequestDTO.getConvertedDateFrom()), tzClient));
query.setParameter("p_date_to", TimeZoneUtils.toDateStringWithTimeZone(DateTimeUtil.parseDate("YYYYMMdd", searchCustomerListRequestDTO.getConvertedDateTo()), tzClient));
if (!DataUtil.isNullOrEmpty(searchCustomerListRequestDTO.getCustomerListCode())) {
query.setParameter("p_list_code", "%" +
searchCustomerListRequestDTO.getCustomerListCode().trim()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(searchCustomerListRequestDTO.getCustomerListName())) {
query.setParameter("p_list_name", "%" +
searchCustomerListRequestDTO.getCustomerListName().trim()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
query.addScalar("customerListId", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListCode", new StringType());
query.addScalar("customerListName", new StringType());
query.addScalar("status", new ShortType());
query.addScalar("createBy", new StringType());
query.addScalar("createAt", new DateType());
query.addScalar("updateBy", new StringType());
query.addScalar("updateAt", new DateType());
query.addScalar("source", new StringType());
query.addScalar("deptCreate", new StringType());
query.addScalar("count", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class));
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
listData = query.list();
listData.forEach(item -> {
item.setCreateAt(DateTimeUtil.parseDate("dd/MM/yyyy HH:mm:ss",TimeZoneUtils.toDateStringWithTimeZone(item.getCreateAt(),tzClient)));
if (item.getUpdateAt() != null) {
item.setUpdateAt(DateTimeUtil.parseDate("dd/MM/yyyy HH:mm:ss",TimeZoneUtils.toDateStringWithTimeZone(item.getUpdateAt(),tzClient)));
}
});
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) session.close();
}
return listData;
}
}
package com.viettel.campaign.repository.ccms_full.impl;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.repository.ccms_full.CustomerRepositoryCustom;
import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerDetailRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerQueryDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.hibernate.type.DateType;
import org.hibernate.type.LongType;
import org.hibernate.type.ShortType;
import org.hibernate.type.StringType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.*;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Repository
public class CustomerRepositoryImpl implements CustomerRepositoryCustom {
@Autowired
@Qualifier(DataSourceQualify.NAMED_JDBC_PARAMETER_TEMPLATE_CCMS_FULL)
NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Override
public List<CustomerDetailRequestDTO> getCustomerDetailById(Long companySiteId, Long customerListId, Long customerId) {
List<CustomerDetailRequestDTO> data = new ArrayList<>();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = null;
try {
session = sessionFactory.openSession();
session.beginTransaction();
StringBuilder sb = new StringBuilder();
sb.append("select");
sb.append(" a.COMPANY_SITE_ID companySiteId,");
sb.append(" a.CUSTOMER_LIST_ID customerListId,");
sb.append(" a.CUSTOMER_ID customerId,");
sb.append(" e.TITLE title,");
sb.append(" f.TYPE type,");
sb.append(" h.VALUE_COMBOBOX valueCombobox,");
sb.append(" e.VALUE_CHECKBOX valueCheckbox,");
sb.append(" e.VALUE_DATE valueDate,");
sb.append(" e.VALUE_NUMBER valueNumber,");
sb.append(" e.VALUE_TEXT valueText");
sb.append(" from CUSTOMER_LIST_MAPPING a");
sb.append(" left join CUSTOMIZE_FIELD_OBJECT e on a.CUSTOMER_ID = e.OBJECT_ID");
sb.append(" left join CUSTOMIZE_FIELDS f on e.CUSTOMIZE_FIELDS_ID = f.CUSTOMIZE_FIELD_ID");
sb.append(" left join (SELECT FIELD_OPTION_VALUE_ID, NAME AS VALUE_COMBOBOX");
sb.append(" FROM CUSTOMIZE_FIELD_OPTION_VALUE) h on h.FIELD_OPTION_VALUE_ID = ");
sb.append(" e.FIELD_OPTION_VALUE_ID");
sb.append(" where 1 = 1");
sb.append(" and a.COMPANY_SITE_ID = :p_company_site_id");
sb.append(" and a.CUSTOMER_LIST_ID = :p_customer_list_id");
sb.append(" and a.CUSTOMER_ID = :p_customer_id");
sb.append(" AND e.FUNCTION_CODE = 'CUSTOMER'");
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", companySiteId);
query.setParameter("p_customer_list_id", customerListId);
query.setParameter("p_customer_id", customerId);
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListId", new LongType());
query.addScalar("customerId", new LongType());
query.addScalar("title", new StringType());
query.addScalar("type", new StringType());
query.addScalar("valueCombobox", new StringType());
query.addScalar("valueCheckbox", new ShortType());
query.addScalar("valueDate", new DateType());
query.addScalar("valueNumber", new LongType());
query.addScalar("valueText", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerDetailRequestDTO.class));
data = query.list();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) session.close();
}
return data;
}
@Override
public List<CustomerCustomDTO> getAllCustomerByParams(SearchCustomerRequestDTO searchCustomerRequestDTO, Pageable pageable) {
List<CustomerCustomDTO> data = new ArrayList<>();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = null;
try {
session = sessionFactory.openSession();
session.beginTransaction();
StringBuilder sb = new StringBuilder();
sb.append("select");
sb.append(" a.CUSTOMER_LIST_MAPPING_ID customerListMappingId,");
sb.append(" a.COMPANY_SITE_ID companySiteId,");
sb.append(" a.CUSTOMER_LIST_ID customerListId,");
sb.append(" a.CUSTOMER_ID customerId,");
sb.append(" b.NAME name,");
sb.append(" b.DESCRIPTION description,");
sb.append(" b.COMPANY_NAME companyName,");
sb.append(" b.CUSTOMER_TYPE customerType,");
sb.append(" b.CURRENT_ADDRESS currentAddress,");
sb.append(" b.CALL_ALLOWED callAllowed,");
sb.append(" b.EMAIL_ALLOWED emailAllowed,");
sb.append(" b.SMS_ALLOWED smsAllowed,");
sb.append(" b.IPCC_STATUS ipccStatus,");
sb.append(" c.MOBILE mobileNumber,");
sb.append(" d.EMAIL email");
sb.append(" from CUSTOMER_LIST_MAPPING a");
sb.append(" join CUSTOMER b on a.CUSTOMER_ID = b.CUSTOMER_ID");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS MOBILE");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 5 AND STATUS = 1 GROUP BY CUSTOMER_ID) c on b.CUSTOMER_ID = c.CUSTOMER_ID");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS EMAIL");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 2 AND STATUS = 1 GROUP BY CUSTOMER_ID) d on b.CUSTOMER_ID = d.CUSTOMER_ID");
sb.append(" where 1 = 1");
sb.append(" and a.COMPANY_SITE_ID = :p_company_site_id");
sb.append(" and a.CUSTOMER_LIST_ID = :p_customer_list_id");
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getName())) {
sb.append(" AND UPPER(b.NAME) LIKE UPPER(:p_name)");
}
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getMobileNumber())) {
sb.append(" AND UPPER(c.MOBILE) LIKE UPPER(:p_mobile_number)");
}
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getEmail())) {
sb.append(" AND UPPER(d.EMAIL) LIKE UPPER(:p_email)");
}
sb.append(" ORDER BY name DESC");
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId());
query.setParameter("p_customer_list_id", searchCustomerRequestDTO.getCustomerListId());
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getName())) {
query.setParameter("p_name", "%" +
searchCustomerRequestDTO.getName().trim().replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getMobileNumber())) {
query.setParameter("p_mobile_number", "%" +
searchCustomerRequestDTO.getMobileNumber().trim().replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getEmail())) {
query.setParameter("p_email", "%" +
searchCustomerRequestDTO.getEmail().trim().replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
query.addScalar("customerListMappingId", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListId", new LongType());
query.addScalar("customerId", new LongType());
query.addScalar("name", new StringType());
query.addScalar("description", new StringType());
query.addScalar("companyName", new StringType());
query.addScalar("customerType", new StringType());
query.addScalar("currentAddress", new StringType());
query.addScalar("mobileNumber", new StringType());
query.addScalar("email", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerCustomDTO.class));
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
data = query.list();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) session.close();
}
return data;
}
@Override
public List<CampaignInformationDTO> getCampaignInformation(CampaignCustomerDTO campaignCustomerDTO) {
List<CampaignInformationDTO> list = new ArrayList<>();
Map<String, Object> params = new HashMap<>();
try {
StringBuilder sb = new StringBuilder();
sb.append(" with count_customer as (");
sb.append(" select campaign_id campaignId,");
sb.append(" sum(case");
sb.append(" when customer_list_id is null then 1");
sb.append(" else 0");
sb.append(" end) totalIndividual,");
sb.append(" sum(case");
sb.append(" when customer_list_id is not null then 1");
sb.append(" else 0");
sb.append(" end) totalCusInList");
sb.append(" from campaign_customer");
sb.append(" group by campaign_id");
sb.append(" )");
sb.append(" select b.campaign_id campaignId, nvl(totalIndividual, 0) totalIndividual, nvl(totalCusInList, 0) totalCusInList, b.customer_number campaignCustomer");
sb.append(" from campaign b");
sb.append(" left join count_customer a on a.campaignId = b.campaign_id");
sb.append(" where b.campaign_id = :p_campaign_id");
params.put("p_campaign_id", campaignCustomerDTO.getCampaignId());
params.put("p_company_site_id", campaignCustomerDTO.getCompanySiteId());
list = namedParameterJdbcTemplate.query(sb.toString(), params, BeanPropertyRowMapper.newInstance(CampaignInformationDTO.class));
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
@Override
public List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO) {
List<CustomerDTO> customerList = new ArrayList<>();
try {
//String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-individual-customer");
// BuildMyString.com generated code. Please enjoy your string responsibly.
StringBuilder sb = new StringBuilder();
sb.append("with cusPhone as (");
sb.append(" select customer_id cusId,");
sb.append(" listagg(contact, ', ') within group (order by create_date desc) phone");
sb.append(" from customer_contact cc");
sb.append(" where cc.contact_type = 5");
sb.append(" and status = 1 ");
sb.append(" group by customer_id");
sb.append(" ), cusEmail as (");
sb.append(" select customer_id cusId,");
sb.append(" listagg(contact , ', ') within group(order by create_date desc) email");
sb.append(" from customer_contact cc");
sb.append(" where cc.contact_type = 2");
sb.append(" and status = 1 ");
sb.append(" group by customer_id");
sb.append(" )," +
"cusInCampaign as (" +
"select * from campaign_customer " +
"where campaign_id = :p_campaign_id " +
"and company_site_id = :p_company_site_id " +
"and customer_list_id is null " +
"and in_campaign_status = 1");
sb.append(" ), datas as (");
sb.append(" select c.customer_id customerId,");
sb.append(" c.name,");
sb.append(" cP.phone mobileNumber,");
sb.append(" cE.email,");
sb.append(" c.customer_type customerType,");
sb.append(" c.company_name companyName,");
sb.append(" c.current_address currentAddress,");
sb.append(" c.description,");
sb.append(" c.ipcc_status ipccStatus,");
sb.append(" c.call_allowed customerDnc");
sb.append(" from customer c");
sb.append(" inner join cusInCampaign cc on c.customer_id = cc.customer_id");
sb.append(" left join cusPhone cP on c.customer_id = cP.cusId");
sb.append(" left join cusEmail cE on c.customer_id = cE.cusId");
sb.append(" )");
sb.append(" select * from");
sb.append(" (");
sb.append(" select a.*, rownum r__");
sb.append(" from");
sb.append(" (");
sb.append(" select * from datas");
sb.append(" order by UPPER(datas.name)");
sb.append(" ) a");
sb.append(" where rownum < ((:p_page_number * :p_page_size) + 1 )");
sb.append(" )");
sb.append(" where r__ >= (((:p_page_number-1) * :p_page_size) + 1)");
Map<String, Object> param = new HashMap<>();
param.put("p_page_number", campaignCustomerDTO.getPage());
param.put("p_page_size", campaignCustomerDTO.getPageSize());
param.put("p_campaign_id", campaignCustomerDTO.getCampaignId());
param.put("p_company_site_id", campaignCustomerDTO.getCompanySiteId());
customerList = namedParameterJdbcTemplate.query(sb.toString(), param, new BeanPropertyRowMapper<>(CustomerDTO.class));
} catch (Exception e) {
e.printStackTrace();
}
return customerList;
}
@Override
public List<CustomerListDTO> getCustomerListInfo(CampaignCustomerDTO campaignCustomerDTO) {
List<CustomerListDTO> customerList = new ArrayList<>();
try {
//String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-customer-list-info-from-customer-list");
// BuildMyString.com generated code. Please enjoy your string responsibly.
StringBuilder sb = new StringBuilder();
sb.append(" with totalCustomer as (");
sb.append(" select clm.customer_list_id,");
sb.append(" clm.company_site_id,");
sb.append(" count(clm.customer_id) total");
sb.append(" from customer_list_mapping clm");
sb.append(" inner join customer c on clm.customer_id = c.customer_id");
sb.append(" where c.status = 1");
sb.append(" group by clm.customer_list_id,clm.company_site_id");
sb.append(" ), customerInteractive as (");
sb.append(" select customer_list_id,");
sb.append(" company_site_id,");
sb.append(" count(customer_id) tt");
sb.append(" from campaign_customer where campaign_id = :p_campaign_id and status <> 0");
sb.append(" group by customer_list_id, company_site_id");
sb.append(" ), customerNotInteractive as (");
sb.append(" select customer_list_id,");
sb.append(" company_site_id,");
sb.append(" count(customer_id) ktt");
sb.append(" from campaign_customer where campaign_id = :p_campaign_id and status = 0");
sb.append(" and in_campaign_status = 1");
sb.append(" group by customer_list_id, company_site_id");
sb.append(" ), datas as (");
sb.append(" select customer_list_code customerListCode,");
sb.append(" customer_list_name customerListName,");
sb.append(" nvl(total, 0) totalCusInList,");
sb.append(" nvl(tt, 0) totalCusInteract,");
sb.append(" nvl(ktt, 0) totalCusNotInteract");
sb.append(" from customer_list cl");
sb.append(" left join totalCustomer tc on (cl.customer_list_id = tc.customer_list_id and cl.company_site_id = tc.company_site_id)");
sb.append(" left join customerInteractive ci on (cl.customer_list_id = ci.customer_list_id and cl.company_site_id = ci.company_site_id)");
sb.append(" left join customerNotInteractive cni on (cl.customer_list_id = cni.customer_list_id and cl.company_site_id = cni.company_site_id)");
sb.append(" where cl.company_site_id = :p_company_site_id");
sb.append(" )");
sb.append(" select * from");
sb.append(" (");
sb.append(" select a.*, rownum r__");
sb.append(" from");
sb.append(" (");
sb.append(" select * from datas");
sb.append(" order by customerListCode");
sb.append(" ) a");
sb.append(" where rownum < ((:p_page_number * :p_page_size) + 1 )");
sb.append(" )");
sb.append(" where r__ >= (((:p_page_number-1) * :p_page_size) + 1)");
Map<String, Object> param = new HashMap<>();
param.put("p_campaign_id", campaignCustomerDTO.getCampaignId());
param.put("p_company_site_id", campaignCustomerDTO.getCompanySiteId());
param.put("p_page_number", campaignCustomerDTO.getPage());
param.put("p_page_size", campaignCustomerDTO.getPageSize());
customerList = namedParameterJdbcTemplate.query(sb.toString(), param, new BeanPropertyRowMapper<>(CustomerListDTO.class));
} catch (Exception e) {
e.printStackTrace();
}
return customerList;
}
@Override
public List<CustomerDTO> getCustomizeFields(CampaignCustomerDTO campaignCustomerDTO, UserSession userSession, Pageable pageable) {
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
List<CustomerDTO> data = new ArrayList<>();
Session session = sessionFactory.openSession();
session.beginTransaction();
Map<String, String> requestCustomer = new HashMap<>();
requestCustomer.put("-1", "c.code");
requestCustomer.put("-2", "c.name");
requestCustomer.put("-3", "c.company_name");
requestCustomer.put("-4", "c.gender");
requestCustomer.put("-5", "c.current_address");
requestCustomer.put("-6", "c.place_of_birth");
requestCustomer.put("-7", "c.date_of_birth");
requestCustomer.put("-8", "cc.contact");
requestCustomer.put("-9", "cc2.contact");
requestCustomer.put("-10", "c.username");
requestCustomer.put("-11", "c.customer_type");
requestCustomer.put("-12", "c.area_code");
requestCustomer.put("-13", "c.call_allowed");
requestCustomer.put("-14", "c.email_allowed");
requestCustomer.put("-15", "c.sms_allowed");
requestCustomer.put("-16", "c.ipcc_status");
try {
StringBuilder sb = new StringBuilder();
sb.append("select distinct c.customer_id customerId,");
sb.append(" C.NAME name,");
sb.append(" cc.CONTACT mobileNumber,");
sb.append(" cc2.CONTACT email,");
sb.append(" c.customer_type customerType,");
sb.append(" C.COMPANY_NAME companyName,");
sb.append(" c.current_address currentAddress,");
sb.append(" c.Description description");
sb.append(" FROM CUSTOMER C");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY ");
sb.append(" NULL) AS CONTACT");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 5 AND STATUS = 1 GROUP BY ");
sb.append(" CUSTOMER_ID) cc on c.CUSTOMER_ID = cc.CUSTOMER_ID");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY ");
sb.append(" NULL) AS CONTACT");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 2 AND STATUS = 1 GROUP BY ");
sb.append(" CUSTOMER_ID) cc2 on cc2.CUSTOMER_ID = c.CUSTOMER_ID ");
sb.append(" left join customize_field_object cfo on c.customer_id = cfo.object_id and cfo.status = 1");
sb.append(" AND C.STATUS = 1");
sb.append(" AND C.customer_id not in (select customer_id from campaign_customer where campaign_id = :p_campaign_id) ");
sb.append(" where 1 = 1 AND C.STATUS = 1 AND C.SITE_ID = :p_site_id ");
List<CustomerQueryDTO> customerDTOList = campaignCustomerDTO.getListQuery();
if (customerDTOList.get(0).getField() > 0) {// field dong
switch (customerDTOList.get(0).getType()) {
case "combobox":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.field_option_value_id " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition() + ")");
break;
case "text":
if ("like".equals(customerDTOList.get(0).getOperator()) || "not like".equals(customerDTOList.get(0).getOperator())) {
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and upper(cfo.value_text) " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%'");
} else {
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_text " + customerDTOList.get(0).getOperator() + " '" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "'");
}
if ("not like".equals(customerDTOList.get(0).getOperator()) || "<>".equals(customerDTOList.get(0).getOperator())) {
sb.append(" or cfo.value_text is null");
}
sb.append(" )");
break;
case "date":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and (cfo.value_date +" + campaignCustomerDTO.getTimezoneOffset() + "/24)" + customerDTOList.get(0).getOperator() + " to_date('" + customerDTOList.get(0).getCondition().trim() + "', 'DD/MM/YYYY'))");
break;
case "number":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_number " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition() + ")");
break;
case "checkbox":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_checkbox " + customerDTOList.get(0).getOperator() + " " + ("true".equals(customerDTOList.get(0).getCondition()) ? "1" : "0") + ")");
break;
}
} else {// field tinh
if ("like".equals(customerDTOList.get(0).getOperator()) || "not like".equals(customerDTOList.get(0).getOperator())) {
sb.append("and (upper(" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + ") " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%'");
} else if (customerDTOList.get(0).getField() == -8 || customerDTOList.get(0).getField() == -9) {
sb.append("and (" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + " " + ("=".equals(customerDTOList.get(0).getOperator()) ? "like " : "not like") + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "%'");
} else if ("text".equals(customerDTOList.get(0).getType())) {
if ("=".equals(customerDTOList.get(0).getOperator()) || "<>".equals(customerDTOList.get(0).getOperator())) {
sb.append("and (" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + " " + customerDTOList.get(0).getOperator() + " '" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "'");
} else {
sb.append("and (upper(" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + ") " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%'");
}
} else {
sb.append("and (" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + " " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition());
}
if ("<>".equals(customerDTOList.get(0).getOperator()) || "not like".equals(customerDTOList.get(0).getOperator())) {
sb.append(" or " + requestCustomer.get(customerDTOList.get(0).getField().toString()) + " is null ");
}
sb.append(" )");
}
for (int i = 1; i < campaignCustomerDTO.getListQuery().size(); i++) {
if (customerDTOList.get(i).getField() < 0) { //Field tinh
if ("like".equals(customerDTOList.get(i).getOperator()) || "not like".equals(customerDTOList.get(i).getOperator())) {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ "upper(" + requestCustomer.get(customerDTOList.get(i).getField().toString()) + ") "
+ customerDTOList.get(i).getOperator() + " "
+ "'%" + customerDTOList.get(i).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%' ");
} else if (customerDTOList.get(i).getField() == -8 || customerDTOList.get(i).getField() == -9) {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ requestCustomer.get(customerDTOList.get(i).getField().toString()) + " "
+ ("=".equals(customerDTOList.get(i).getOperator()) ? "like" : "not like") + " '%"
+ customerDTOList.get(i).getCondition().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%' ");
} else if ("text".equals(customerDTOList.get(i).getType())) {
if ("=".equals(customerDTOList.get(i).getOperator()) || "<>".equals(customerDTOList.get(i).getOperator())) {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ requestCustomer.get(customerDTOList.get(i).getField().toString()) + " "
+ customerDTOList.get(i).getOperator() + " '"
+ customerDTOList.get(i).getCondition().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "' ");
} else {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ "upper(" + requestCustomer.get(customerDTOList.get(i).getField().toString()) + ") "
+ customerDTOList.get(i).getOperator() + " '%"
+ customerDTOList.get(i).getCondition().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%' ");
}
} else {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ requestCustomer.get(customerDTOList.get(i).getField().toString()) + " "
+ customerDTOList.get(i).getOperator() + " "
+ customerDTOList.get(i).getCondition());
}
if ("not like".equals(customerDTOList.get(i).getOperator()) || "<>".equals(customerDTOList.get(i).getOperator())) {
sb.append(" or " + requestCustomer.get(customerDTOList.get(i).getField().toString()) + " is null");
}
sb.append(" )");
} else { // Field dong
switch (customerDTOList.get(i).getType()) {
case "combobox":
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.field_option_value_id " + customerDTOList.get(i).getOperator() + " " + customerDTOList.get(i).getCondition() + ")");
break;
case "text":
if ("like".equals(customerDTOList.get(i).getOperator()) || "not like".equals(customerDTOList.get(i).getOperator())) {
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and upper(cfo.value_text) " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%'");
} else {
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_text " + customerDTOList.get(0).getOperator() + " '" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "'");
}
if ("not like".equals(customerDTOList.get(i).getOperator()) || "<>".equals(customerDTOList.get(i).getOperator())) {
sb.append(" or cfo.value_text is null ");
}
sb.append(" )");
break;
case "date":
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and (cfo.value_date + " + campaignCustomerDTO.getTimezoneOffset() + "/24)" + customerDTOList.get(i).getOperator() + " to_date('" + customerDTOList.get(i).getCondition().trim() + "', 'DD/MM/YYYY'))");
break;
case "number":
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.value_number " + customerDTOList.get(i).getOperator() + " " + customerDTOList.get(i).getCondition() + ")");
break;
case "checkbox":
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.value_checkbox " + customerDTOList.get(i).getOperator() + " " + ("true".equals(customerDTOList.get(i).getCondition()) ? "1" : "0") + ")");
break;
}
}
}
SQLQuery query = session.createSQLQuery(sb.toString());
query.addScalar("name", new StringType());
query.addScalar("customerId", new LongType());
query.addScalar("mobileNumber", new StringType());
query.addScalar("email", new StringType());
query.addScalar("customerType", new LongType());
query.addScalar("companyName", new StringType());
query.addScalar("currentAddress", new StringType());
query.addScalar("description", new StringType());
query.setParameter("p_campaign_id", campaignCustomerDTO.getCampaignId());
query.setParameter("p_site_id", userSession.getSiteId());
query.setResultTransformer(Transformers.aliasToBean(CustomerDTO.class));
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
data = query.list();
} catch (Exception e) {
e.printStackTrace();
} finally {
session.close();
}
return data;
}
}
......@@ -6,6 +6,7 @@ import com.viettel.campaign.model.ccms_full.CustomizeFieldObject;
import com.viettel.campaign.model.ccms_full.CustomizeFields;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerListRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession;
......@@ -16,37 +17,27 @@ import java.util.Map;
public interface CustomerService {
ResultDTO getAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId);
ResultDTO getCustomerId(Long customerId);
ResultDTO searchAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId, String name, String mobileNumber, String email);
ResultDTO searchAllCustomer(SearchCustomerRequestDTO searchCustomerRequestDTO);
ResultDTO createCustomer(CustomerDTO customerDTO);
ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO);
ResultDTO deleteIds(CustomerRequestDTO customerRequestDTO);
ResultDTO getCustomerDetailById(Long companySiteId, Long customerListId, Long customerId);
// ------------ customer list ------------ //
ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId);
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteCustomerListIds(CustomerRequestDTO customerRequestDTO);
ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO);
CustomerList getLatestCreated(Long companySiteId);
ResultDTO searchCustomerList(SearchCustomerListRequestDTO searchCustomerListRequestDTO);
// ------------ customer contact ------------ //
......
......@@ -28,7 +28,7 @@ public interface ScenarioService {
XSSFWorkbook buildTemplate() throws IOException;
Map<String, Object> readAndValidateCustomer(String path, Long scenarioId, Long campaignId, Long companySiteId) throws IOException;
Map<String, Object> readAndValidateScenario(String path, Long scenarioId, Long campaignId, Long companySiteId) throws IOException;
List<ContactQuestResult> getContactQuestResult(Long companySiteId, Long campaignId, Long customerId);
}
......@@ -149,110 +149,104 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Transactional(DataSourceQualify.CCMS_FULL)
public XSSFWorkbook exportInteractiveResult(CampaignRequestDTO dto) throws IOException {
Locale locale = Locale.forLanguageTag("vi");
List<ContactCustResultDTO> list = campaignExecuteRepository.getExcelInteractiveResult(dto);
List<ContactCustResultDTO> list = campaignExecuteRepository.getInteractiveResult(dto, null);
XSSFWorkbook workbook = null;
XSSFWorkbook workbook = new XSSFWorkbook();
Sheet sheet;
try {
// create font style
workbook = new XSSFWorkbook();
Font defaultFont = workbook.createFont();
defaultFont.setFontHeightInPoints((short) 13);
defaultFont.setFontName("Times New Roman");
defaultFont.setColor(IndexedColors.BLACK.getIndex());
Font titleFont = workbook.createFont();
titleFont.setFontHeightInPoints((short) 18);
titleFont.setFontName("Times New Roman");
titleFont.setColor(IndexedColors.BLACK.getIndex());
titleFont.setBold(true);
Font headerFont = workbook.createFont();
headerFont.setFontHeightInPoints((short) 13);
headerFont.setFontName("Times New Roman");
headerFont.setColor(IndexedColors.BLACK.getIndex());
headerFont.setBold(true);
CellStyle styleTitle = workbook.createCellStyle();
styleTitle.setFont(titleFont);
styleTitle.setAlignment(HorizontalAlignment.CENTER);
CellStyle styleRowHeader = workbook.createCellStyle();
styleRowHeader.setFont(headerFont);
styleRowHeader.setAlignment(HorizontalAlignment.CENTER);
styleRowHeader.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
styleRowHeader.setFillPattern(FillPatternType.SOLID_FOREGROUND);
styleRowHeader.setBorderRight(BorderStyle.THIN);
styleRowHeader.setRightBorderColor(IndexedColors.BLACK.getIndex());
styleRowHeader.setBorderBottom(BorderStyle.THIN);
styleRowHeader.setBottomBorderColor(IndexedColors.BLACK.getIndex());
styleRowHeader.setBorderLeft(BorderStyle.THIN);
styleRowHeader.setLeftBorderColor(IndexedColors.BLACK.getIndex());
styleRowHeader.setBorderTop(BorderStyle.THIN);
styleRowHeader.setTopBorderColor(IndexedColors.BLACK.getIndex());
CellStyle styleRow = workbook.createCellStyle();
styleRow.setFont(defaultFont);
// list header
List<String> headerList = new ArrayList<>();
headerList.add(BundleUtils.getLangString("stt", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.campaignCode", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.campaignName", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.agentId", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.phoneNumber", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.customerId", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.customerName", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.createTime", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.contactStatus", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.surveyStatus", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.status", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.recordStatus", locale));
//
String sheetName = BundleUtils.getLangString("detail", locale);
sheet = workbook.createSheet(sheetName);
// Title
String title = BundleUtils.getLangString("campaign.execute.interactive.title", locale);
int rowTitleStart = 3;
Row rowTitle = sheet.createRow(rowTitleStart);
rowTitle.setHeight((short) 800);
writeCellContent(rowTitle, styleTitle, 3, title);
sheet.addMergedRegion(new CellRangeAddress(rowTitleStart, rowTitleStart, 3, 8));
// Header
int startRowTable = 5;
int count = 1;
Row rowHeader = sheet.createRow(startRowTable);
for (int i = 0; i < headerList.size(); i++) {
writeCellContent(rowHeader, styleRowHeader, i, headerList.get(i));
}
// Content
for (int i = 0, rowIndex = 1; i < list.size(); i++) {
Row row = sheet.createRow(startRowTable + count);
int col = 0;
writeCellContent(row, styleRow, col++, rowIndex);
writeCellContent(row, styleRow, col++, list.get(i).getCampaignCode());
writeCellContent(row, styleRow, col++, list.get(i).getCampaignName());
writeCellContent(row, styleRow, col++, list.get(i).getUserName());
writeCellContent(row, styleRow, col++, list.get(i).getPhoneNumber());
writeCellContent(row, styleRow, col++, list.get(i).getCustomerName());
writeCellContent(row, styleRow, col++, list.get(i).getCustomerName());
writeCellContent(row, styleRow, col++, formatter.format(list.get(i).getCreateTime()));
writeCellContent(row, styleRow, col++, list.get(i).getContactStatus());
writeCellContent(row, styleRow, col++, list.get(i).getSurveyStatus());
writeCellContent(row, styleRow, col++, list.get(i).getStatus());
writeCellContent(row, styleRow, col++, list.get(i).getRecordStatus());
++rowIndex;
++count;
}
} catch (Exception e) {
logger.error(e.getMessage());
} finally {
if (workbook != null) workbook.close();
// create font style
Font defaultFont = workbook.createFont();
defaultFont.setFontHeightInPoints((short) 13);
defaultFont.setFontName("Times New Roman");
defaultFont.setColor(IndexedColors.BLACK.getIndex());
Font titleFont = workbook.createFont();
titleFont.setFontHeightInPoints((short) 18);
titleFont.setFontName("Times New Roman");
titleFont.setColor(IndexedColors.BLACK.getIndex());
titleFont.setBold(true);
Font headerFont = workbook.createFont();
headerFont.setFontHeightInPoints((short) 13);
headerFont.setFontName("Times New Roman");
headerFont.setColor(IndexedColors.BLACK.getIndex());
headerFont.setBold(true);
CellStyle styleTitle = workbook.createCellStyle();
styleTitle.setFont(titleFont);
styleTitle.setAlignment(HorizontalAlignment.CENTER);
CellStyle styleRowHeader = workbook.createCellStyle();
styleRowHeader.setFont(headerFont);
styleRowHeader.setAlignment(HorizontalAlignment.CENTER);
styleRowHeader.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
styleRowHeader.setFillPattern(FillPatternType.SOLID_FOREGROUND);
styleRowHeader.setBorderRight(BorderStyle.THIN);
styleRowHeader.setRightBorderColor(IndexedColors.BLACK.getIndex());
styleRowHeader.setBorderBottom(BorderStyle.THIN);
styleRowHeader.setBottomBorderColor(IndexedColors.BLACK.getIndex());
styleRowHeader.setBorderLeft(BorderStyle.THIN);
styleRowHeader.setLeftBorderColor(IndexedColors.BLACK.getIndex());
styleRowHeader.setBorderTop(BorderStyle.THIN);
styleRowHeader.setTopBorderColor(IndexedColors.BLACK.getIndex());
CellStyle styleRow = workbook.createCellStyle();
styleRow.setFont(defaultFont);
// list header
List<String> headerList = new ArrayList<>();
headerList.add(BundleUtils.getLangString("stt", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.campaignCode", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.campaignName", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.agentId", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.phoneNumber", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.customerName", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.createTime", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.contactStatus", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.surveyStatus", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.status", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.recordStatus", locale));
headerList.add(BundleUtils.getLangString("campaign.execute.interactive.callTime", locale));
//
String sheetName = BundleUtils.getLangString("detail", locale);
sheet = workbook.createSheet(sheetName);
// Title
String title = BundleUtils.getLangString("campaign.execute.interactive.title", locale);
int rowTitleStart = 3;
Row rowTitle = sheet.createRow(rowTitleStart);
rowTitle.setHeight((short) 800);
writeCellContent(rowTitle, styleTitle, 3, title);
sheet.addMergedRegion(new CellRangeAddress(rowTitleStart, rowTitleStart, 3, 8));
// Header
int startRowTable = 5;
int count = 1;
Row rowHeader = sheet.createRow(startRowTable);
for (int i = 0; i < headerList.size(); i++) {
writeCellContent(rowHeader, styleRowHeader, i, headerList.get(i));
}
// Content
for (int i = 0, rowIndex = 1; i < list.size(); i++) {
Row row = sheet.createRow(startRowTable + count);
int col = 0;
writeCellContent(row, styleRow, col++, rowIndex);
writeCellContent(row, styleRow, col++, list.get(i).getCampaignCode());
writeCellContent(row, styleRow, col++, list.get(i).getCampaignName());
writeCellContent(row, styleRow, col++, list.get(i).getUserName());
writeCellContent(row, styleRow, col++, list.get(i).getPhoneNumber());
writeCellContent(row, styleRow, col++, list.get(i).getCustomerName());
writeCellContent(row, styleRow, col++, formatter.format(list.get(i).getCreateTime()));
writeCellContent(row, styleRow, col++, list.get(i).getConnectStatus());
writeCellContent(row, styleRow, col++, list.get(i).getSurveyStatus());
writeCellContent(row, styleRow, col++, list.get(i).getStatus());
writeCellContent(row, styleRow, col++, list.get(i).getRecordStatus());
writeCellContent(row, styleRow, col++, list.get(i).getCallTime());
++rowIndex;
++count;
}
return workbook;
}
private void writeCellContent(Row row, CellStyle rowStyle, int colNo, Object content) {
......
......@@ -9,9 +9,9 @@ import com.viettel.campaign.repository.ccms_full.*;
import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.utils.*;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerDetailRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerQueryDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerListRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession;
import cz.jirutka.rsql.parser.RSQLParser;
......@@ -26,7 +26,6 @@ import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.hibernate.type.DateType;
import org.hibernate.type.LongType;
import org.hibernate.type.ShortType;
import org.hibernate.type.StringType;
......@@ -103,109 +102,6 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired
ApParamRepository apParamRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId) {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params"));
//sqlStrBuilder.append(" ORDER BY b.NAME ASC");
StringBuilder sb = new StringBuilder();
sb.append("select");
sb.append(" a.CUSTOMER_LIST_MAPPING_ID customerListMappingId,");
sb.append(" a.COMPANY_SITE_ID companySiteId,");
sb.append(" a.CUSTOMER_LIST_ID customerListId,");
sb.append(" a.CUSTOMER_ID customerId,");
sb.append(" b.NAME name,");
sb.append(" b.DESCRIPTION description,");
sb.append(" b.COMPANY_NAME companyName,");
sb.append(" b.CUSTOMER_TYPE customerType,");
sb.append(" b.CURRENT_ADDRESS currentAddress,");
sb.append(" b.CALL_ALLOWED callAllowed,");
sb.append(" b.EMAIL_ALLOWED emailAllowed,");
sb.append(" b.SMS_ALLOWED smsAllowed,");
sb.append(" b.IPCC_STATUS ipccStatus,");
sb.append(" c.MOBILE mobileNumber,");
sb.append(" d.EMAIL email");
sb.append(" from CUSTOMER_LIST_MAPPING a");
sb.append(" join CUSTOMER b on a.CUSTOMER_ID = b.CUSTOMER_ID");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY ");
sb.append(" NULL) AS MOBILE");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 5 AND STATUS = 1 GROUP BY ");
sb.append(" CUSTOMER_ID) c on b.CUSTOMER_ID = c.CUSTOMER_ID");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY ");
sb.append(" NULL) AS EMAIL");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 2 AND STATUS = 1 GROUP BY ");
sb.append(" CUSTOMER_ID) d on b.CUSTOMER_ID = d.CUSTOMER_ID ");
sb.append(" where 1 = 1");
sb.append(" and a.COMPANY_SITE_ID = :p_company_site_id");
sb.append(" and a.CUSTOMER_LIST_ID = :p_customer_list_id");
sb.append(" ORDER BY b.NAME ASC");
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", companySiteId);
query.setParameter("p_customer_list_id", customerListId);
query.addScalar("customerListMappingId", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListId", new LongType());
query.addScalar("customerId", new LongType());
query.addScalar("name", new StringType());
query.addScalar("description", new StringType());
query.addScalar("companyName", new StringType());
query.addScalar("customerType", 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("email", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerCustomDTO.class));
int count = 0;
List<CustomerCustomDTO> dtoList = query.list();
if (dtoList.size() > 0) {
count = query.list().size();
}
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Order.desc(sort)));
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
List<CustomerCustomDTO> data = query.list();
Page<CustomerCustomDTO> dataPage = new PageImpl<>(data, pageable, count);
resultDTO.setData(dataPage);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
if (session != null) session.close();
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerId(Long customerId) {
......@@ -227,129 +123,27 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId, String name, String mobileNumber, String email) {
public ResultDTO searchAllCustomer(SearchCustomerRequestDTO searchCustomerRequestDTO) {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
if (DataUtil.isNullOrZero(searchCustomerRequestDTO.getCompanySiteId())) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params"));
StringBuilder sb = new StringBuilder();
int count = customerRepository.getAllCustomerByParams(searchCustomerRequestDTO, null).size();
sb.append("select");
sb.append(" a.CUSTOMER_LIST_MAPPING_ID customerListMappingId,");
sb.append(" a.COMPANY_SITE_ID companySiteId,");
sb.append(" a.CUSTOMER_LIST_ID customerListId,");
sb.append(" a.CUSTOMER_ID customerId,");
sb.append(" b.NAME name,");
sb.append(" b.DESCRIPTION description,");
sb.append(" b.COMPANY_NAME companyName,");
sb.append(" b.CUSTOMER_TYPE customerType,");
sb.append(" b.CURRENT_ADDRESS currentAddress,");
sb.append(" b.CALL_ALLOWED callAllowed,");
sb.append(" b.EMAIL_ALLOWED emailAllowed,");
sb.append(" b.SMS_ALLOWED smsAllowed,");
sb.append(" b.IPCC_STATUS ipccStatus,");
sb.append(" c.MOBILE mobileNumber,");
sb.append(" d.EMAIL email");
sb.append(" from CUSTOMER_LIST_MAPPING a");
sb.append(" join CUSTOMER b on a.CUSTOMER_ID = b.CUSTOMER_ID");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS MOBILE");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 5 AND STATUS = 1 GROUP BY CUSTOMER_ID) c on b.CUSTOMER_ID = c.CUSTOMER_ID");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS EMAIL");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 2 AND STATUS = 1 GROUP BY CUSTOMER_ID) d on b.CUSTOMER_ID = d.CUSTOMER_ID");
sb.append(" where 1 = 1");
sb.append(" and a.COMPANY_SITE_ID = :p_company_site_id");
sb.append(" and a.CUSTOMER_LIST_ID = :p_customer_list_id");
if (!DataUtil.isNullOrEmpty(name)) {
sb.append(" AND UPPER(b.NAME) LIKE UPPER(:p_name)");
}
if (!DataUtil.isNullOrEmpty(mobileNumber)) {
sb.append(" AND UPPER(c.MOBILE) LIKE UPPER(:p_mobile_number)");
}
if (!DataUtil.isNullOrEmpty(email)) {
sb.append(" AND UPPER(d.EMAIL) LIKE UPPER(:p_email)");
}
sb.append(" ORDER BY name DESC");
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", companySiteId);
query.setParameter("p_customer_list_id", customerListId);
if (!DataUtil.isNullOrEmpty(name)) {
query.setParameter("p_name", "%" +
name.trim().replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(mobileNumber)) {
query.setParameter("p_mobile_number", "%" +
mobileNumber.trim().replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(email)) {
query.setParameter("p_email", "%" +
email.trim().replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
query.addScalar("customerListMappingId", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListId", new LongType());
query.addScalar("customerId", new LongType());
query.addScalar("name", new StringType());
query.addScalar("description", new StringType());
query.addScalar("companyName", new StringType());
query.addScalar("customerType", new StringType());
query.addScalar("currentAddress", new StringType());
query.addScalar("mobileNumber", new StringType());
query.addScalar("email", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerCustomDTO.class));
int count = 0;
List<CustomerCustomDTO> dtoList = query.list();
if (dtoList.size() > 0) {
count = query.list().size();
}
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Order.desc(sort)));
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
List<CustomerCustomDTO> data = query.list();
Page<CustomerCustomDTO> dataPage = new PageImpl<>(data, pageable, count);
resultDTO.setData(dataPage);
resultDTO.setTotalRow(count);
List<CustomerCustomDTO> data = customerRepository.getAllCustomerByParams(searchCustomerRequestDTO, SQLBuilder.buildPageable(searchCustomerRequestDTO));
resultDTO.setListData(data);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
if (session != null) session.close();
}
return resultDTO;
}
......@@ -388,36 +182,6 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO();
List<Long> listId = new ArrayList<>();
try {
if (customerRequestDTO != null) {
listId.add(customerRequestDTO.getCustomerId());
if (customerListMappingRepository.findAllCustomerListMapping(listId, customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId()).size() > 0) {
// delete
// customerRepository.deleteById(customerDTO.getCustomerId());
customerListMappingRepository.deleteMappingByCustomerId(customerRequestDTO.getCustomerId(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.DELETE_ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.DELETE_ERROR);
}
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
// e.printStackTrace();
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteIds(CustomerRequestDTO customerRequestDTO) {
......@@ -447,77 +211,20 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerDetailById(Long companySiteId, Long customerListId, Long customerId) {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sqlStrBuilder = new StringBuilder();
// sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-customer-detail-by-id"));
StringBuilder sb = new StringBuilder();
sb.append("select");
sb.append(" a.COMPANY_SITE_ID companySiteId,");
sb.append(" a.CUSTOMER_LIST_ID customerListId,");
sb.append(" a.CUSTOMER_ID customerId,");
sb.append(" e.TITLE title,");
sb.append(" f.TYPE type,");
sb.append(" h.VALUE_COMBOBOX valueCombobox,");
sb.append(" e.VALUE_CHECKBOX valueCheckbox,");
sb.append(" e.VALUE_DATE valueDate,");
sb.append(" e.VALUE_NUMBER valueNumber,");
sb.append(" e.VALUE_TEXT valueText");
sb.append(" from CUSTOMER_LIST_MAPPING a");
sb.append(" left join CUSTOMIZE_FIELD_OBJECT e on a.CUSTOMER_ID = e.OBJECT_ID");
sb.append(" left join CUSTOMIZE_FIELDS f on e.CUSTOMIZE_FIELDS_ID = f.CUSTOMIZE_FIELD_ID");
sb.append(" left join (SELECT FIELD_OPTION_VALUE_ID, NAME AS VALUE_COMBOBOX");
sb.append(" FROM CUSTOMIZE_FIELD_OPTION_VALUE) h on h.FIELD_OPTION_VALUE_ID = ");
sb.append(" e.FIELD_OPTION_VALUE_ID");
sb.append(" where 1 = 1");
sb.append(" and a.COMPANY_SITE_ID = :p_company_site_id");
sb.append(" and a.CUSTOMER_LIST_ID = :p_customer_list_id");
sb.append(" and a.CUSTOMER_ID = :p_customer_id");
sb.append(" AND e.FUNCTION_CODE = 'CUSTOMER'");
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", companySiteId);
query.setParameter("p_customer_list_id", customerListId);
query.setParameter("p_customer_id", customerId);
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListId", new LongType());
query.addScalar("customerId", new LongType());
query.addScalar("title", new StringType());
query.addScalar("type", new StringType());
query.addScalar("valueCombobox", new StringType());
query.addScalar("valueCheckbox", new ShortType());
query.addScalar("valueDate", new DateType());
query.addScalar("valueNumber", new LongType());
query.addScalar("valueText", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerDetailRequestDTO.class));
List<CustomerDetailRequestDTO> data = query.list();
resultDTO.setData(data);
resultDTO.setData(customerRepository.getCustomerDetailById(companySiteId, customerListId, customerId));
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
if (session != null) session.close();
}
return resultDTO;
}
......@@ -536,92 +243,6 @@ public class CustomerServiceImpl implements CustomerService {
}
// ------------- customer list ----------------- //
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId) {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = null;
if (DataUtil.isNullOrZero(companySiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params"));
StringBuilder sb = new StringBuilder();
sb.append("SELECT");
sb.append(" CUSTOMER_LIST_ID customerListId,");
sb.append(" COMPANY_SITE_ID companySiteId,");
sb.append(" CUSTOMER_LIST_CODE customerListCode,");
sb.append(" CUSTOMER_LIST_NAME customerListName,");
sb.append(" STATUS status,");
sb.append(" CREATE_BY createBy,");
sb.append(" CREATE_AT createAt,");
sb.append(" UPDATE_BY updateBy,");
sb.append(" UPDATE_AT updateAt,");
sb.append(" SOURCE source,");
sb.append(" DEPT_CREATE deptCreate");
sb.append(" FROM CUSTOMER_LIST");
sb.append(" WHERE 1 = 1");
sb.append(" AND STATUS = 1");
sb.append(" AND COMPANY_SITE_ID = :p_company_site_id");
sb.append(" ORDER BY CREATE_AT DESC");
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", companySiteId);
query.addScalar("customerListId", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListCode", new StringType());
query.addScalar("customerListName", new StringType());
query.addScalar("status", new ShortType());
query.addScalar("createBy", new StringType());
query.addScalar("createAt", new DateType());
query.addScalar("updateBy", new StringType());
query.addScalar("updateAt", new DateType());
query.addScalar("source", new StringType());
query.addScalar("deptCreate", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class));
int count = 0;
List<CustomerListDTO> dtoList = query.list();
if (dtoList.size() > 0) {
count = query.list().size();
}
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Order.desc(sort)));
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
List<CustomerListDTO> data = query.list();
Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count);
resultDTO.setData(dataPage);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
if (session != null) session.close();
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName) {
......@@ -721,39 +342,6 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
List<Long> ids = new ArrayList<>();
ids.add(customerListDTO.getCustomerListId());
try {
// delete
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) {
if (customerListRepository.findAllCustomerList(ids, customerListDTO.getCompanySiteId()).size() > 0) {
customerListRepository.deleteCustomerList(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
customerListMappingRepository.deleteMappingByCustomerListId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.DELETE_ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.DELETE_ERROR);
}
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
// e.printStackTrace();
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCustomerListIds(CustomerRequestDTO customerRequestDTO) {
......@@ -788,139 +376,34 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO) {
public ResultDTO searchCustomerList(SearchCustomerListRequestDTO searchCustomerListRequestDTO) {
LOGGER.info("=== Start search customer list::");
TimeZone tzClient = TimeZoneUtils.getZoneMinutes((long) searchCustomerRequestDTO.getTimezoneOffset());
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = null;
if (DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCompanySiteId())) {
if (DataUtil.isNullOrEmpty(searchCustomerListRequestDTO.getCompanySiteId())) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
int count = customerListRepository.getAllCustomerListByParams(searchCustomerListRequestDTO, null).size();
try {
session = sessionFactory.openSession();
session.beginTransaction();
// StringBuilder sb = new StringBuilder();
// sb.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params"));
StringBuilder sb = new StringBuilder();
sb.append("SELECT");
sb.append(" a.CUSTOMER_LIST_ID customerListId,");
sb.append(" a.COMPANY_SITE_ID companySiteId,");
sb.append(" a.CUSTOMER_LIST_CODE customerListCode,");
sb.append(" a.CUSTOMER_LIST_NAME customerListName,");
sb.append(" a.STATUS status,");
sb.append(" a.CREATE_BY createBy,");
sb.append(" a.CREATE_AT createAt,");
sb.append(" a.UPDATE_BY updateBy,");
sb.append(" a.UPDATE_AT updateAt,");
sb.append(" a.SOURCE source,");
sb.append(" a.DEPT_CREATE deptCreate,");
sb.append(" b.count count");
sb.append(" FROM CUSTOMER_LIST a");
sb.append(" LEFT JOIN (SELECT COUNT(CAMPAIGN_ID) as count, CUSTOMER_LIST_ID");
sb.append(" FROM CAMPAIGN_CUSTOMERLIST");
sb.append(" GROUP BY CUSTOMER_LIST_ID) b");
sb.append(" ON a.CUSTOMER_LIST_ID = b.CUSTOMER_LIST_ID");
sb.append(" WHERE 1 = 1");
sb.append(" AND a.STATUS = 1");
sb.append(" AND a.COMPANY_SITE_ID = :p_company_site_id");
sb.append(" AND to_date(CREATE_AT, 'DD/MM/RR') >= to_date(:p_date_from, 'DD/MM/YYYY HH24:MI:SS') AND to_date(CREATE_AT, 'DD/MM/RR') <= to_date(:p_date_to, 'DD/MM/YYYY HH24:MI:SS')");
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
sb.append(" AND UPPER(CUSTOMER_LIST_CODE) LIKE UPPER(:p_list_code)");
}
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListName())) {
sb.append(" AND UPPER(CUSTOMER_LIST_NAME) LIKE UPPER(:p_list_name)");
}
sb.append(" ORDER BY CREATE_AT DESC");
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId());
query.setParameter("p_date_from", TimeZoneUtils.toDateStringWithTimeZone(DateTimeUtil.parseDate("YYYYMMdd",searchCustomerRequestDTO.getConvertedDateFrom()), tzClient));
query.setParameter("p_date_to", TimeZoneUtils.toDateStringWithTimeZone(DateTimeUtil.parseDate("YYYYMMdd",searchCustomerRequestDTO.getConvertedDateTo()), tzClient));
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
query.setParameter("p_list_code", "%" +
searchCustomerRequestDTO.getCustomerListCode().trim()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListName())) {
query.setParameter("p_list_name", "%" +
searchCustomerRequestDTO.getCustomerListName().trim()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
query.addScalar("customerListId", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListCode", new StringType());
query.addScalar("customerListName", new StringType());
query.addScalar("status", new ShortType());
query.addScalar("createBy", new StringType());
query.addScalar("createAt", new DateType());
query.addScalar("updateBy", new StringType());
query.addScalar("updateAt", new DateType());
query.addScalar("source", new StringType());
query.addScalar("deptCreate", new StringType());
query.addScalar("count", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class));
int count = 0;
List<CustomerListDTO> dtoList = query.list();
if (dtoList.size() > 0) {
count = query.list().size();
}
if (count > 0) {
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setTotalRow(count);
List<CustomerListDTO> customerList = customerListRepository.getAllCustomerListByParams(searchCustomerListRequestDTO, SQLBuilder.buildPageable(searchCustomerListRequestDTO));
resultDTO.setListData(customerList);
Pageable pageable = PageRequest.of(searchCustomerRequestDTO.getPage(), searchCustomerRequestDTO.getPageSize(), Sort.by(searchCustomerRequestDTO.getSort()).descending());
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
List<CustomerListDTO> data = query.list();
Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count);
dataPage.forEach(item -> {
item.setCreateAt(DateTimeUtil.parseDate("dd/MM/yyyy HH:mm:ss",TimeZoneUtils.toDateStringWithTimeZone(item.getCreateAt(),tzClient)));
if (item.getUpdateAt() != null) {
item.setUpdateAt(DateTimeUtil.parseDate("dd/MM/yyyy HH:mm:ss",TimeZoneUtils.toDateStringWithTimeZone(item.getUpdateAt(),tzClient)));
}
});
resultDTO.setData(dataPage);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
e.printStackTrace();
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
LOGGER.error(e.getMessage(), e);
} finally {
if (session != null) session.close();
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public CustomerList getLatestCreated(Long companySiteId) {
return customerListRepository.latestCreated(companySiteId);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerContact(CustomerContactDTO customer) {
......@@ -1110,10 +593,9 @@ public class CustomerServiceImpl implements CustomerService {
isMainPhoneNull = true;
} else {
String str = validateLength(BundleUtils.getLangString("customer.mainPhone", locale).split("#")[0], rawDataList.get(i)[headerMap.get(BundleUtils.getLangString("customer.mainPhone", locale).split("#")[0])].toString(), 50, locale);
if(!str.equals("")){
if (!str.equals("")) {
sb.append(str);
}
else if(validateNumberOnly(rawDataList.get(i)[headerMap.get(BundleUtils.getLangString("customer.mainPhone", locale).split("#")[0])].toString().trim())) {
} else if (validateNumberOnly(rawDataList.get(i)[headerMap.get(BundleUtils.getLangString("customer.mainPhone", locale).split("#")[0])].toString().trim())) {
sb.append(validateExistPhone(rawDataList.get(i)[headerMap.get(BundleUtils.getLangString("customer.mainPhone", locale).split("#")[0])].toString().trim(), locale, true));
} else {
sb.append(BundleUtils.getLangString("customer.onlyNumber", locale));
......@@ -1123,10 +605,9 @@ public class CustomerServiceImpl implements CustomerService {
isSecondPhoneNull = true;
} else {
String str = validateLength(BundleUtils.getLangString("customer.secondPhone", locale).split("#")[0], rawDataList.get(i)[headerMap.get(BundleUtils.getLangString("customer.secondPhone", locale).split("#")[0])].toString(), 50, locale);
if(!str.equals("")){
if (!str.equals("")) {
sb.append(str);
}
else if (validateNumberOnly(rawDataList.get(i)[headerMap.get(BundleUtils.getLangString("customer.secondPhone", locale).split("#")[0])].toString().trim())) {
} else if (validateNumberOnly(rawDataList.get(i)[headerMap.get(BundleUtils.getLangString("customer.secondPhone", locale).split("#")[0])].toString().trim())) {
sb.append(validateExistPhone(rawDataList.get(i)[headerMap.get(BundleUtils.getLangString("customer.secondPhone", locale).split("#")[0])].toString(), locale, false));
} else {
sb.append(BundleUtils.getLangString("customer.onlyNumber", locale));
......@@ -1901,63 +1382,7 @@ public class CustomerServiceImpl implements CustomerService {
public List<CustomerListDTO> getCustomerListInfo(CampaignCustomerDTO campaignCustomerDTO) {
List<CustomerListDTO> customerList;
try {
//String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-customer-list-info-from-customer-list");
// BuildMyString.com generated code. Please enjoy your string responsibly.
StringBuilder sb = new StringBuilder();
sb.append(" with totalCustomer as (");
sb.append(" select clm.customer_list_id,");
sb.append(" clm.company_site_id,");
sb.append(" count(clm.customer_id) total");
sb.append(" from customer_list_mapping clm");
sb.append(" inner join customer c on clm.customer_id = c.customer_id");
sb.append(" where c.status = 1");
sb.append(" group by clm.customer_list_id,clm.company_site_id");
sb.append(" ), customerInteractive as (");
sb.append(" select customer_list_id,");
sb.append(" company_site_id,");
sb.append(" count(customer_id) tt");
sb.append(" from campaign_customer where campaign_id = :p_campaign_id and status <> 0");
sb.append(" group by customer_list_id, company_site_id");
sb.append(" ), customerNotInteractive as (");
sb.append(" select customer_list_id,");
sb.append(" company_site_id,");
sb.append(" count(customer_id) ktt");
sb.append(" from campaign_customer where campaign_id = :p_campaign_id and status = 0");
sb.append(" and in_campaign_status = 1");
sb.append(" group by customer_list_id, company_site_id");
sb.append(" ), datas as (");
sb.append(" select customer_list_code customerListCode,");
sb.append(" customer_list_name customerListName,");
sb.append(" nvl(total, 0) totalCusInList,");
sb.append(" nvl(tt, 0) totalCusInteract,");
sb.append(" nvl(ktt, 0) totalCusNotInteract");
sb.append(" from customer_list cl");
sb.append(" left join totalCustomer tc on (cl.customer_list_id = tc.customer_list_id and cl.company_site_id = tc.company_site_id)");
sb.append(" left join customerInteractive ci on (cl.customer_list_id = ci.customer_list_id and cl.company_site_id = ci.company_site_id)");
sb.append(" left join customerNotInteractive cni on (cl.customer_list_id = cni.customer_list_id and cl.company_site_id = cni.company_site_id)");
sb.append(" where cl.company_site_id = :p_company_site_id");
sb.append(" )");
sb.append(" select * from");
sb.append(" (");
sb.append(" select a.*, rownum r__");
sb.append(" from");
sb.append(" (");
sb.append(" select * from datas");
sb.append(" order by customerListCode");
sb.append(" ) a");
sb.append(" where rownum < ((:p_page_number * :p_page_size) + 1 )");
sb.append(" )");
sb.append(" where r__ >= (((:p_page_number-1) * :p_page_size) + 1)");
Map<String, Object> param = new HashMap<>();
param.put("p_campaign_id", campaignCustomerDTO.getCampaignId());
param.put("p_company_site_id", campaignCustomerDTO.getCompanySiteId());
param.put("p_page_number", campaignCustomerDTO.getPage());
param.put("p_page_size", campaignCustomerDTO.getPageSize());
customerList = namedParameterJdbcTemplate.query(sb.toString(), param, new BeanPropertyRowMapper<>(CustomerListDTO.class));
customerList = customerRepository.getCustomerListInfo(campaignCustomerDTO);
} catch (Exception e) {
return null;
}
......@@ -1967,69 +1392,9 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO) {
List<CustomerDTO> customerList;
List<CustomerDTO> customerList = new ArrayList<>();
try {
//String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-individual-customer");
// BuildMyString.com generated code. Please enjoy your string responsibly.
StringBuilder sb = new StringBuilder();
sb.append("with cusPhone as (");
sb.append(" select customer_id cusId,");
sb.append(" listagg(contact, ', ') within group (order by create_date desc) phone");
sb.append(" from customer_contact cc");
sb.append(" where cc.contact_type = 5");
sb.append(" and status = 1 ");
sb.append(" group by customer_id");
sb.append(" ), cusEmail as (");
sb.append(" select customer_id cusId,");
sb.append(" listagg(contact , ', ') within group(order by create_date desc) email");
sb.append(" from customer_contact cc");
sb.append(" where cc.contact_type = 2");
sb.append(" and status = 1 ");
sb.append(" group by customer_id");
sb.append(" )," +
"cusInCampaign as (" +
"select * from campaign_customer " +
"where campaign_id = :p_campaign_id " +
"and company_site_id = :p_company_site_id " +
"and customer_list_id is null " +
"and in_campaign_status = 1");
sb.append(" ), datas as (");
sb.append(" select c.customer_id customerId,");
sb.append(" c.name,");
sb.append(" cP.phone mobileNumber,");
sb.append(" cE.email,");
sb.append(" c.customer_type customerType,");
sb.append(" c.company_name companyName,");
sb.append(" c.current_address currentAddress,");
sb.append(" c.description,");
sb.append(" c.ipcc_status ipccStatus,");
sb.append(" c.call_allowed customerDnc");
sb.append(" from customer c");
sb.append(" inner join cusInCampaign cc on c.customer_id = cc.customer_id");
sb.append(" left join cusPhone cP on c.customer_id = cP.cusId");
sb.append(" left join cusEmail cE on c.customer_id = cE.cusId");
sb.append(" )");
sb.append(" select * from");
sb.append(" (");
sb.append(" select a.*, rownum r__");
sb.append(" from");
sb.append(" (");
sb.append(" select * from datas");
sb.append(" order by UPPER(datas.name)");
sb.append(" ) a");
sb.append(" where rownum < ((:p_page_number * :p_page_size) + 1 )");
sb.append(" )");
sb.append(" where r__ >= (((:p_page_number-1) * :p_page_size) + 1)");
Map<String, Object> param = new HashMap<>();
param.put("p_page_number", campaignCustomerDTO.getPage());
param.put("p_page_size", campaignCustomerDTO.getPageSize());
param.put("p_campaign_id", campaignCustomerDTO.getCampaignId());
param.put("p_company_site_id", campaignCustomerDTO.getCompanySiteId());
customerList = namedParameterJdbcTemplate.query(sb.toString(), param, new BeanPropertyRowMapper<>(CustomerDTO.class));
customerList = customerRepository.getIndividualCustomerInfo(campaignCustomerDTO);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
return null;
......@@ -2071,30 +1436,8 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchCampaignInformation(CampaignCustomerDTO campaignCustomerDTO) {
ResultDTO resultDTO = new ResultDTO();
List<CampaignInformationDTO> list = new ArrayList<>();
Map<String, Object> params = new HashMap<>();
List<CampaignInformationDTO> list = customerRepository.getCampaignInformation(campaignCustomerDTO);
try {
StringBuilder sb = new StringBuilder();
sb.append(" with count_customer as (");
sb.append(" select campaign_id campaignId,");
sb.append(" sum(case");
sb.append(" when customer_list_id is null then 1");
sb.append(" else 0");
sb.append(" end) totalIndividual,");
sb.append(" sum(case");
sb.append(" when customer_list_id is not null then 1");
sb.append(" else 0");
sb.append(" end) totalCusInList");
sb.append(" from campaign_customer");
sb.append(" group by campaign_id");
sb.append(" )");
sb.append(" select b.campaign_id campaignId, nvl(totalIndividual, 0) totalIndividual, nvl(totalCusInList, 0) totalCusInList, b.customer_number campaignCustomer");
sb.append(" from campaign b");
sb.append(" left join count_customer a on a.campaignId = b.campaign_id");
sb.append(" where b.campaign_id = :p_campaign_id");
params.put("p_campaign_id", campaignCustomerDTO.getCampaignId());
params.put("p_company_site_id", campaignCustomerDTO.getCompanySiteId());
list = namedParameterJdbcTemplate.query(sb.toString(), params, BeanPropertyRowMapper.newInstance(CampaignInformationDTO.class));
if (list.size() > 0) {
resultDTO.setData(list.get(0));
} else {
......@@ -2277,195 +1620,10 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchCustomizeFields(CampaignCustomerDTO campaignCustomerDTO, UserSession userSession) {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Map<String, String> requestCustomer = new HashMap<>();
requestCustomer.put("-1", "c.code");
requestCustomer.put("-2", "c.name");
requestCustomer.put("-3", "c.company_name");
requestCustomer.put("-4", "c.gender");
requestCustomer.put("-5", "c.current_address");
requestCustomer.put("-6", "c.place_of_birth");
requestCustomer.put("-7", "c.date_of_birth");
requestCustomer.put("-8", "cc.contact");
requestCustomer.put("-9", "cc2.contact");
requestCustomer.put("-10", "c.username");
requestCustomer.put("-11", "c.customer_type");
requestCustomer.put("-12", "c.area_code");
requestCustomer.put("-13", "c.call_allowed");
requestCustomer.put("-14", "c.email_allowed");
requestCustomer.put("-15", "c.sms_allowed");
requestCustomer.put("-16", "c.ipcc_status");
try {
StringBuilder sb = new StringBuilder();
sb.append("select distinct c.customer_id customerId,");
sb.append(" C.NAME name,");
sb.append(" cc.CONTACT mobileNumber,");
sb.append(" cc2.CONTACT email,");
sb.append(" c.customer_type customerType,");
sb.append(" C.COMPANY_NAME companyName,");
sb.append(" c.current_address currentAddress,");
sb.append(" c.Description description");
sb.append(" FROM CUSTOMER C");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY ");
sb.append(" NULL) AS CONTACT");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 5 AND STATUS = 1 GROUP BY ");
sb.append(" CUSTOMER_ID) cc on c.CUSTOMER_ID = cc.CUSTOMER_ID");
sb.append(" left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY ");
sb.append(" NULL) AS CONTACT");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 2 AND STATUS = 1 GROUP BY ");
sb.append(" CUSTOMER_ID) cc2 on cc2.CUSTOMER_ID = c.CUSTOMER_ID ");
sb.append(" left join customize_field_object cfo on c.customer_id = cfo.object_id and cfo.status = 1");
sb.append(" AND C.STATUS = 1");
sb.append(" AND C.customer_id not in (select customer_id from campaign_customer where campaign_id = :p_campaign_id) ");
sb.append(" where 1 = 1 AND C.STATUS = 1 AND C.SITE_ID = :p_site_id ");
List<CustomerQueryDTO> customerDTOList = campaignCustomerDTO.getListQuery();
if (customerDTOList.get(0).getField() > 0) {// field dong
switch (customerDTOList.get(0).getType()) {
case "combobox":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.field_option_value_id " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition() + ")");
break;
case "text":
if ("like".equals(customerDTOList.get(0).getOperator()) || "not like".equals(customerDTOList.get(0).getOperator())) {
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and upper(cfo.value_text) " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%'");
} else {
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_text " + customerDTOList.get(0).getOperator() + " '" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "'");
}
if ("not like".equals(customerDTOList.get(0).getOperator()) || "<>".equals(customerDTOList.get(0).getOperator())) {
sb.append(" or cfo.value_text is null");
}
sb.append(" )");
break;
case "date":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and (cfo.value_date +" + campaignCustomerDTO.getTimezoneOffset() + "/24)" + customerDTOList.get(0).getOperator() + " to_date('" + customerDTOList.get(0).getCondition().trim() + "', 'DD/MM/YYYY'))");
break;
case "number":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_number " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition() + ")");
break;
case "checkbox":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_checkbox " + customerDTOList.get(0).getOperator() + " " + ("true".equals(customerDTOList.get(0).getCondition()) ? "1" : "0") + ")");
break;
}
} else {// field tinh
if ("like".equals(customerDTOList.get(0).getOperator()) || "not like".equals(customerDTOList.get(0).getOperator())) {
sb.append("and (upper(" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + ") " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%'");
} else if (customerDTOList.get(0).getField() == -8 || customerDTOList.get(0).getField() == -9) {
sb.append("and (" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + " " + ("=".equals(customerDTOList.get(0).getOperator()) ? "like " : "not like") + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "%'");
} else if ("text".equals(customerDTOList.get(0).getType())) {
if ("=".equals(customerDTOList.get(0).getOperator()) || "<>".equals(customerDTOList.get(0).getOperator())) {
sb.append("and (" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + " " + customerDTOList.get(0).getOperator() + " '" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "'");
} else {
sb.append("and (upper(" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + ") " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%'");
}
} else{
sb.append("and (" + requestCustomer.get(customerDTOList.get(0).getField().toString()) + " " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition());
}
if ("<>".equals(customerDTOList.get(0).getOperator()) || "not like".equals(customerDTOList.get(0).getOperator())) {
sb.append(" or " + requestCustomer.get(customerDTOList.get(0).getField().toString()) + " is null ");
}
sb.append(" )");
}
for (int i = 1; i < campaignCustomerDTO.getListQuery().size(); i++) {
if (customerDTOList.get(i).getField() < 0) { //Field tinh
if ("like".equals(customerDTOList.get(i).getOperator()) || "not like".equals(customerDTOList.get(i).getOperator())) {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ "upper(" + requestCustomer.get(customerDTOList.get(i).getField().toString()) + ") "
+ customerDTOList.get(i).getOperator() + " "
+ "'%" + customerDTOList.get(i).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%' ");
} else if (customerDTOList.get(i).getField() == -8 || customerDTOList.get(i).getField() == -9) {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ requestCustomer.get(customerDTOList.get(i).getField().toString()) + " "
+ ("=".equals(customerDTOList.get(i).getOperator()) ? "like" : "not like") + " '%"
+ customerDTOList.get(i).getCondition().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%' ");
} else if ("text".equals(customerDTOList.get(i).getType())) {
if ("=".equals(customerDTOList.get(i).getOperator()) || "<>".equals(customerDTOList.get(i).getOperator())) {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ requestCustomer.get(customerDTOList.get(i).getField().toString()) + " "
+ customerDTOList.get(i).getOperator() + " '"
+ customerDTOList.get(i).getCondition().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "' ");
} else {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ "upper(" + requestCustomer.get(customerDTOList.get(i).getField().toString()) + ") "
+ customerDTOList.get(i).getOperator() + " '%"
+ customerDTOList.get(i).getCondition().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%' ");
}
} else {
sb.append(" " + customerDTOList.get(i).getJoin() + " ("
+ requestCustomer.get(customerDTOList.get(i).getField().toString()) + " "
+ customerDTOList.get(i).getOperator() + " "
+ customerDTOList.get(i).getCondition());
}
if ("not like".equals(customerDTOList.get(i).getOperator()) || "<>".equals(customerDTOList.get(i).getOperator())) {
sb.append(" or " + requestCustomer.get(customerDTOList.get(i).getField().toString()) + " is null");
}
sb.append(" )");
} else { // Field dong
switch (customerDTOList.get(i).getType()) {
case "combobox":
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.field_option_value_id " + customerDTOList.get(i).getOperator() + " " + customerDTOList.get(i).getCondition() + ")");
break;
case "text":
if ("like".equals(customerDTOList.get(i).getOperator()) || "not like".equals(customerDTOList.get(i).getOperator())) {
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and upper(cfo.value_text) " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_").toUpperCase() + "%'");
} else {
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_text " + customerDTOList.get(0).getOperator() + " '" + customerDTOList.get(0).getCondition().trim().replace("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_") + "'");
}
if ("not like".equals(customerDTOList.get(i).getOperator()) || "<>".equals(customerDTOList.get(i).getOperator())) {
sb.append(" or cfo.value_text is null ");
}
sb.append(" )");
break;
case "date":
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and (cfo.value_date + " + campaignCustomerDTO.getTimezoneOffset() + "/24)" + customerDTOList.get(i).getOperator() + " to_date('" + customerDTOList.get(i).getCondition().trim() + "', 'DD/MM/YYYY'))");
break;
case "number":
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.value_number " + customerDTOList.get(i).getOperator() + " " + customerDTOList.get(i).getCondition() + ")");
break;
case "checkbox":
sb.append(customerDTOList.get(i).getJoin() + " (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.value_checkbox " + customerDTOList.get(i).getOperator() + " " + ("true".equals(customerDTOList.get(i).getCondition()) ? "1" : "0") + ")");
break;
}
}
}
SQLQuery query = session.createSQLQuery(sb.toString());
query.addScalar("name", new StringType());
query.addScalar("customerId", new LongType());
query.addScalar("mobileNumber", new StringType());
query.addScalar("email", new StringType());
query.addScalar("customerType", new LongType());
query.addScalar("companyName", new StringType());
query.addScalar("currentAddress", new StringType());
query.addScalar("description", new StringType());
query.setParameter("p_campaign_id", campaignCustomerDTO.getCampaignId());
query.setParameter("p_site_id", userSession.getSiteId());
query.setResultTransformer(Transformers.aliasToBean(CustomerDTO.class));
int count = 0;
List<CustomerDTO> dtoList = query.list();
if (dtoList.size() > 0) {
count = query.list().size();
}
Pageable pageable = PageRequest.of(campaignCustomerDTO.getPage(), campaignCustomerDTO.getPageSize());
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
List<CustomerDTO> data = query.list();
Page<CustomerDTO> dataPage = new PageImpl<>(data, pageable, count);
resultDTO.setData(dataPage);
int count = customerRepository.getCustomizeFields(campaignCustomerDTO, userSession, null).size();
List<CustomerDTO> data = customerRepository.getCustomizeFields(campaignCustomerDTO, userSession, SQLBuilder.buildPageable(campaignCustomerDTO));
resultDTO.setListData(data);
resultDTO.setTotalRow(count);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
......@@ -2473,10 +1631,7 @@ public class CustomerServiceImpl implements CustomerService {
LOGGER.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
}
return resultDTO;
}
......
......@@ -80,7 +80,6 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
if (scenarioQuestionDTO.getLstAnswers().size() > 0) {
lstAnswers = scenarioQuestionDTO.getLstAnswers();
lstAnswers.forEach(item -> {
item.setCode(scenarioQuestion.getCode() + "_" + item.getOrderIndex());
item.setScenarioQuestionId(scenarioQuestion.getScenarioQuestionId());
item.setCreateTime(new Date());
item.setStatus((short) 1);
......
......@@ -254,7 +254,7 @@ public class ScenarioServiceImpl implements ScenarioService {
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Map<String, Object> readAndValidateCustomer (String path, Long scenarioId, Long campaignId, Long companySiteId) throws IOException{
public Map<String, Object> readAndValidateScenario (String path, Long scenarioId, Long campaignId, Long companySiteId) throws IOException{
Locale locale = new Locale("vi", "VN");
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Map<String, Object> result = new HashMap<>();
......@@ -551,6 +551,7 @@ public class ScenarioServiceImpl implements ScenarioService {
lstQuestions.forEach(q2 -> {
List<ScenarioAnswerDTO> lstAnswers = q2.getLstAnswers();
lstAnswers.forEach(a2 -> {
a2.setCode(q2.getCode() + "_" + a2.getOrderIndex());
ScenarioQuestionDTO mappingQuestion = lstQuestions.stream().filter(mq -> mq.getImportCode().equals(a2.getMappingQuestionCode())).findFirst().orElse(null);
if (mappingQuestion != null) {
a2.setMappingQuestionCode(mappingQuestion.getCode());
......
......@@ -8,7 +8,6 @@ import java.util.List;
@Getter
@Setter
public class CustomerRequestDTO {
Long customerId;
Long customerListId;
List<Long> ids;
Long companySiteId;
......
package com.viettel.campaign.web.dto.request_dto;
import com.viettel.campaign.web.dto.BaseDTO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SearchCustomerListRequestDTO extends BaseDTO {
String customerListCode;
String customerListName;
String convertedDateFrom;
String convertedDateTo;
String companySiteId;
Long timezoneOffset;
}
......@@ -7,10 +7,9 @@ import lombok.Setter;
@Getter
@Setter
public class SearchCustomerRequestDTO extends BaseDTO {
String customerListCode;
String customerListName;
String convertedDateFrom;
String convertedDateTo;
String companySiteId;
Integer timezoneOffset;
Long companySiteId;
Long customerListId;
String name;
String mobileNumber;
String email;
}
......@@ -24,7 +24,7 @@ import java.util.List;
@RestController
@RequestMapping("/ipcc/campaign/execute")
//@CrossOrigin
@CrossOrigin(origins = "*")
public class CampaignExecuteController {
private static final Logger logger = LoggerFactory.getLogger(CampaignController.class);
......
......@@ -9,6 +9,7 @@ import com.viettel.campaign.utils.Config;
import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerListRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.apache.commons.io.FilenameUtils;
......@@ -44,13 +45,6 @@ public class CustomerController {
@Autowired(required = true)
CustomerService customerService;
@GetMapping("/findAll")
@ResponseBody
public ResponseEntity findAllCustomer(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("customerListId") long customerListId, @RequestParam("companySiteId") long companySiteId) {
ResultDTO result = customerService.getAllCustomer(page, pageSize, sort, customerListId, companySiteId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/findCustomerId")
@ResponseBody
public ResponseEntity<ResultDTO> findAllCustomerName(@RequestParam("customerId") Long customerId) {
......@@ -58,10 +52,10 @@ public class CustomerController {
return new ResponseEntity(result, HttpStatus.OK);
}
@GetMapping("/searchAllCustomerByParams")
@PostMapping("/searchAllCustomerByParams")
@ResponseBody
public ResponseEntity findAllCustomerByParams(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("customerListId") Long customerListId, @RequestParam("companySiteId") Long companySiteId, @RequestParam("name") String name, @RequestParam("mobileNumber") String mobileNumber, @RequestParam("email") String email) {
ResultDTO result = customerService.searchAllCustomer(page, pageSize, sort, customerListId, companySiteId, name, mobileNumber, email);
public ResponseEntity findAllCustomerByParams(@RequestBody SearchCustomerRequestDTO searchCustomerRequestDTO) {
ResultDTO result = customerService.searchAllCustomer(searchCustomerRequestDTO);
return new ResponseEntity(result, HttpStatus.OK);
}
......@@ -73,14 +67,6 @@ public class CustomerController {
return result;
}
@PostMapping("/delete")
@ResponseBody
public ResultDTO deleteCustomer(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO();
resultDTO = customerService.deleteCustomer(customerRequestDTO);
return resultDTO;
}
@PostMapping("/deleteIds")
@ResponseBody
public ResultDTO deleteIds(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
......@@ -98,14 +84,6 @@ public class CustomerController {
// --------------- customer list table ----------------- //
@GetMapping("/findAlls")
@ResponseBody
public ResponseEntity findAllCustomerList(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("companySiteId") Long companySiteId) {
ResultDTO result = customerService.getAllCustomerList(page, pageSize, sort, companySiteId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/createCustomerList")
@ResponseBody
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
......@@ -129,14 +107,6 @@ public class CustomerController {
return customerService.updateCustomerList(customerListDTO, userSession.getUserName());
}
@PostMapping("/deleteCustomerList")
@ResponseBody
public ResultDTO deleteCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO();
result = customerService.deleteCustomerList(customerListDTO);
return result;
}
@PostMapping("/deleteCustomerListIds")
@ResponseBody
public ResultDTO deleteCustomerListIds(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
......@@ -146,16 +116,8 @@ public class CustomerController {
}
@RequestMapping(value = "/searchCustomerList", method = RequestMethod.POST)
public ResponseEntity searchCustomerList(@RequestBody SearchCustomerRequestDTO searchCustomerRequestDTO) {
ResultDTO result = customerService.searchCustomerList(searchCustomerRequestDTO);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/latestCreated")
@ResponseBody
public ResponseEntity getLatestCreated(@RequestParam("companySiteId") Long companySiteId) {
ResultDTO result = new ResultDTO();
result.setData(customerService.getLatestCreated(companySiteId));
public ResponseEntity searchCustomerList(@RequestBody SearchCustomerListRequestDTO searchCustomerListRequestDTO) {
ResultDTO result = customerService.searchCustomerList(searchCustomerListRequestDTO);
return new ResponseEntity<>(result, HttpStatus.OK);
}
......
......@@ -118,7 +118,7 @@ public class ScenarioController {
return new ResponseEntity<>(BundleUtils.getLangString("common.fileInvalidFormat", locale), HttpStatus.OK);
}
String path = saveUploadFile(file);
Map<String, Object> map = scenarioService.readAndValidateCustomer(path, scenarioId, campaignId, userSession.getCompanySiteId());
Map<String, Object> map = scenarioService.readAndValidateScenario(path, scenarioId, campaignId, userSession.getCompanySiteId());
String code = (String) map.get("code");
byte[] content = (byte[]) map.get("content");
return ResponseEntity.ok()
......
......@@ -14,6 +14,7 @@ campaign.execute.interactive.contactStatus = Contact status
campaign.execute.interactive.surveyStatus = Trạng thái khảo sát
campaign.execute.interactive.status = Trạng thái chiến dịch
campaign.execute.interactive.recordStatus = Trạng thái bản ghi
campaign.execute.interactive.callTime = Thời lượng cuộc gọi
#Campaign
campaign = Campaigns
......
......@@ -14,6 +14,7 @@ campaign.execute.interactive.contactStatus = Trạng thái kết nối
campaign.execute.interactive.surveyStatus = Trạng thái khảo sát
campaign.execute.interactive.status = Trạng thái chiến dịch
campaign.execute.interactive.recordStatus = Trạng thái bản ghi
campaign.execute.interactive.callTime = Thời lượng cuộc gọi
#Campaigns
......
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