Commit 2acfee33 authored by đinh thị đầm's avatar đinh thị đầm
parents 96aa09ed 95438a14
This diff is collapsed.
......@@ -189,6 +189,18 @@
<artifactId>modelmapper</artifactId>
<version>2.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
<dependencyManagement>
......
......@@ -16,6 +16,8 @@ public class Campaign implements Serializable {
@Id
@NotNull
@GeneratedValue(generator = "campaign_seq")
@SequenceGenerator(name = "campaign_seq", sequenceName = "campaign_seq", allocationSize = 1)
@Basic(optional = false)
@Column(name = "CAMPAIGN_ID")
private Long campaignId;
......
package com.viettel.campaign.model;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Entity
@Table(name = "CUSTOMER_CONTACT")
@Getter
@Setter
public class CustomerContact {
@Id
@Basic(optional = false)
@NotNull
@Column(name = "CONTACT_ID")
private Long contactId;
@Column(name = "CUSTOMER_ID")
private Long customerId;
@Column(name = "CONTACT_TYPE")
private Short contactType;
@Column(name = "CONTACT")
private String contact;
@Column(name = "IS_DIRECT_LINE")
private Short isDirectLine;
@Column(name = "STATUS")
private Short status;
@Column(name = "CREATE_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date createDate;
@Column(name = "UPDATE_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date updateDate;
@Column(name = "CREATE_BY")
private String createBy;
@Column(name = "UPDATE_BY")
private String updateBy;
@Column(name = "START_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date startDate;
@Column(name = "END_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date endDate;
}
......@@ -18,6 +18,8 @@ import java.util.Date;
public class TimeRangeDialMode implements Serializable {
@Id
@NotNull
@GeneratedValue(generator = "TIME_RANGE_DIAL_MODE_SEQ")
@SequenceGenerator(name = "TIME_RANGE_DIAL_MODE_SEQ", sequenceName = "TIME_RANGE_DIAL_MODE_SEQ", allocationSize = 1)
@Basic(optional = false)
@Column(name = "TIME_RANGE_DIAL_MODE_ID")
private Long timeRangeDialModeId;
......
......@@ -19,9 +19,11 @@ import java.io.Serializable;
public class TimeZoneDialMode implements Serializable{
@Id
@NotNull
@GeneratedValue(generator = "TIME_ZONE_DIAL_MODE_SEQ")
@SequenceGenerator(name = "TIME_ZONE_DIAL_MODE_SEQ", sequenceName = "TIME_ZONE_DIAL_MODE_SEQ", allocationSize = 1)
@Basic(optional = false)
@Column(name = "TIME_ZONE_DIAL_MODE_ID")
private Long timeRangeDialModeId;
private Long timeZoneDialModeId;
@Column(name = "COMPANY_SITE_ID")
private Long companySiteId;
......
......@@ -25,3 +25,4 @@ public interface ApParamRepository extends JpaRepository<ApParam, Long>, ApParam
List<ApParam> findAllParam();
}
package com.viettel.campaign.repository;
import com.viettel.campaign.model.ApParam;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ApParamRepositoryCustom {
......
package com.viettel.campaign.repository;
import com.viettel.campaign.web.dto.ApParamDTO;
import com.viettel.campaign.web.dto.ContactCustResultDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CampaignExecuteRepository {
//<editor-fold: hungtt>
List<ApParamDTO> getComboBoxStatus(String companySiteId, String completeType);
List<ApParamDTO> getComboCampaignType(String companySiteId);
ResultDTO getInteractiveResult(CampaignRequestDTO dto);
//</editor-fold: hungtt>
}
package com.viettel.campaign.repository;
import com.viettel.campaign.model.Campaign;
import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
......@@ -16,4 +18,6 @@ public interface CampaignRepository extends JpaRepository<Campaign, Long>, Campa
" AND cc.recallTime <= sysdate " +
" AND cc.agentId = :pAgentId")
Long countRecallCustomer(@Param("pCompanySiteId") Long pCompanySiteId, @Param("pAgentId") Long pAgentId);
Campaign findCampaignByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
}
......@@ -11,4 +11,6 @@ public interface CampaignRepositoryCustom {
ResultDTO search(CampaignRequestDTO requestDto);
ResultDTO findByCampaignCode(CampaignRequestDTO requestDTO);
String getMaxCampaignIndex();
}
package com.viettel.campaign.repository;
import com.viettel.campaign.model.CustomerContact;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface CustomerContactRepository extends JpaRepository<CustomerContact, Long> {
List<CustomerContact> findByCustomerIdAndAndContactTypeAndContact(Long customerId, Short contactType, String contact);
}
......@@ -6,9 +6,27 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
public interface CustomerListMappingRepository extends JpaRepository<CustomerListMapping, Long> {
// ----------- customer ------------ //
@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=:customerListId")
int deleteMappingByCustomerListId(@Param("customerListId") Long customerListId);
@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);
}
......@@ -10,11 +10,15 @@ import java.util.List;
public interface CustomerListRepository extends JpaRepository<CustomerList, Long> {
CustomerList findCustomerListByCustomerListId(long customerListId);
CustomerList findByCustomerListIdAndCompanySiteId(long customerListId, long companySiteId);
CustomerList findByCustomerListCode(String customerListCode);
@Modifying
@Query("delete from CustomerList c where c.customerListId in (:ids)")
int deleteCustomerListIds(@Param("ids") List<Long> ids);
@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);
}
......@@ -16,6 +16,8 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
Page<Customer> findAll(Pageable pageable);
List<Customer> findByCustomerId(Long customerId);
@Query("FROM Customer WHERE name = ?1")
List<Customer> findByName(String firstName, Pageable pageable);
......
package com.viettel.campaign.repository.impl;
import com.viettel.campaign.model.ApParam;
import com.viettel.campaign.repository.ApParamRepositoryCustom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.List;
@Repository
@Transactional
public class AppParamRepositoryImpl implements ApParamRepositoryCustom {
@Autowired
EntityManager entityManager;
public AppParamRepositoryImpl() {
}
}
package com.viettel.campaign.repository.impl;
import com.viettel.campaign.repository.CampaignExecuteRepository;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.ApParamDTO;
import com.viettel.campaign.web.dto.ContactCustResultDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.hibernate.type.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Repository
public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
private static final Logger logger = LoggerFactory.getLogger(CampaignRepositoryImpl.class);
@Autowired
NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Autowired
EntityManager entityManager;
@Override
public List<ApParamDTO> getComboBoxStatus(String companySiteId, String completeType) {
List<ApParamDTO> list = new ArrayList<>();
Map<String, String> params = new HashMap<>();
String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-combo-connect-status");
try {
params.put("p_company_site_id", companySiteId);
params.put("p_complete_type", completeType);
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(ApParamDTO.class));
// list = namedParameterJdbcTemplate.getJdbcTemplate().query(sql, (PreparedStatementSetter) params, BeanPropertyRowMapper.newInstance(ComboBoxDTO.class));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return list;
}
@Override
public List<ApParamDTO> getComboCampaignType(String companySiteId) {
List<ApParamDTO> list = new ArrayList<>();
Map<String, String> params = new HashMap<>();
String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-combo-campaign-type");
try {
params.put("p_company_site_id", companySiteId);
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(ApParamDTO.class));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return list;
}
@Override
public ResultDTO getInteractiveResult(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
List<ContactCustResultDTO> list = new ArrayList<>();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
StringBuilder sqlBuilder = new StringBuilder();
try {
String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-execute-interactive");
sqlBuilder.append(sql);
if (!DataUtil.isNullOrEmpty(dto.getCampaignName().trim())) {
sqlBuilder.append(" and upper(campaignName) like upper(:p_campaign_name)");
}
if (!DataUtil.isNullOrEmpty(dto.getAgentId().trim())) {
sqlBuilder.append(" and upper(userName) like upper(:p_user_name)");
}
SQLQuery query = session.createSQLQuery(sqlBuilder.toString());
query.setParameterList("p_list_campaign_id", dto.getCampaignId().trim().split(","));
query.setParameter("p_customer_id", dto.getCustomerId().trim());
query.setParameter("p_date_from", dto.getFromDate().trim());
query.setParameter("p_date_to", dto.getToDate().trim());
query.setParameterList("p_list_contact_status", dto.getContactStatus().trim().split(","));
query.setParameterList("p_list_survey_status", dto.getSurveyStatus().trim().split(","));
query.setParameterList("p_list_record_status", dto.getRecordStatus().trim().split(","));
query.setParameter("p_phone_number", dto.getPhoneNumber().trim());
query.setParameter("p_call_time_from", dto.getCallTimeFrom().trim());
query.setParameter("p_call_time_to", dto.getCallTimeTo().trim());
if (!DataUtil.isNullOrEmpty(dto.getCampaignName().trim())) {
query.setParameter("p_campaign_name", dto.getCampaignName().trim());
}
if (!DataUtil.isNullOrEmpty(dto.getAgentId().trim())) {
query.setParameter("p_user_name", dto.getAgentId().trim());
}
query.addScalar("campaignCode", new StringType());
query.addScalar("campaignName", new StringType());
query.addScalar("userName", new StringType());
query.addScalar("phoneNumber", new LongType());
query.addScalar("customerName", new StringType());
query.addScalar("createTime", new DateType());
query.addScalar("contactStatus", new StringType());
query.addScalar("surveyStatus", new StringType());
query.addScalar("status", new ShortType());
query.addScalar("recordStatus", new ShortType());
query.setResultTransformer(Transformers.aliasToBean(ContactCustResultDTO.class));
int count = 0;
list = query.list();
if (list.size() > 0) {
count = list.size();
}
Pageable pageable = SQLBuilder.buildPageable(dto);
if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize());
}
List<ContactCustResultDTO> data = query.list();
for (ContactCustResultDTO contactCustResultDTO: data) {
if (!"AGENT".equals(dto.getRoleUser())) {
contactCustResultDTO.setEnableEdit(true);
} else {
if (contactCustResultDTO.getRecordStatus() == 2) {
contactCustResultDTO.setEnableEdit(true);
} else if (contactCustResultDTO.getRecordStatus() == 1){
/**
* Hoi chi linh xac dinh thoi gian 24h ke tu khi da luu kieu gi??????
*/
} else {
contactCustResultDTO.setEnableEdit(false);
}
}
}
Page<ContactCustResultDTO> 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);
logger.error(e.getMessage(), e);
} finally {
session.close();
}
return resultDTO;
}
}
......@@ -21,12 +21,14 @@ import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Repository
public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
private static final Logger logger = LogManager.getLogger(CampaignRepositoryImpl.class);
@Autowired
......@@ -37,18 +39,17 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO result = new ResultDTO();
List<CampaignDTO> lst = new ArrayList<>();
StringBuilder expression = new StringBuilder()
.append(" SELECT C.CAMPAIGN_CODE, C.CAMPAIGN_NAME, C.CONTENT, C.START_TIME, C.END_TIME, C.STATUS ")
.append(" SELECT C.CAMPAIGN_CODE, C.CAMPAIGN_NAME, C.CONTENT, C.START_TIME, C.END_TIME, C.STATUS, CA.STATUS AS AGENT_STATUS ")
.append(" FROM CAMPAIGN C INNER JOIN CAMPAIGN_AGENT CA ON C.CAMPAIGN_ID = CA.CAMPAIGN_ID ")
.append(" WHERE 1 = 1 ")
.append(" WHERE 1 = 1 ");
//.append(" AND CA.AGENT_ID = :pAgentId ")
.append(" AND C.STATUS IN (2,3) ");
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignCode())) {
expression.append(" AND C.CAMPAIGN_ID IN (:pCampaingId) ");
expression.append(" AND C.CAMPAIGN_CODE IN (:pCampaignCode) ");
}
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignName())) {
expression.append(" AND UPPER(C.CAMPAIGN_NAME) LIKE CONCAT('%',:pCampaignName,'%') ");
expression.append(" AND UPPER(C.CAMPAIGN_NAME) LIKE :pCampaignName ");
}
if (!DataUtil.isNullOrZero(campaignRequestDto.getStatus().longValue())) {
......@@ -88,40 +89,45 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignCode())) {
String[] lstCode = campaignRequestDto.getCampaignCode().split(",");
query.setParameter(":pCampaingId", lstCode);
query.setParameter("pCampaignCode", lstCode);
}
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignName())) {
query.setParameter(":pCampaignName", campaignRequestDto.getCampaignName().toUpperCase());
query.setParameter("pCampaignName", "%" +
campaignRequestDto.getCampaignName().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
+ "%");
}
if (!DataUtil.isNullOrZero(campaignRequestDto.getStatus().longValue())) {
if (campaignRequestDto.getStatus() != 0)
query.setParameter(":pStatus", campaignRequestDto.getStatus());
query.setParameter("pStatus", campaignRequestDto.getStatus());
}
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getFromDateFr())) {
query.setParameter(":pStartTimeFr", campaignRequestDto.getFromDateFr());
query.setParameter("pStartTimeFr", campaignRequestDto.getFromDateFr());
}
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getFromDateTo())) {
query.setParameter(":pStartTimeTo", campaignRequestDto.getFromDateTo());
query.setParameter("pStartTimeTo", campaignRequestDto.getFromDateTo());
}
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getToDateFr())) {
query.setParameter(":pEndTimeFr", campaignRequestDto.getToDateFr());
query.setParameter("pEndTimeFr", campaignRequestDto.getToDateFr());
}
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getToDateTo())) {
query.setParameter(":pEndTimeTo", campaignRequestDto.getToDateTo());
query.setParameter("pEndTimeTo", campaignRequestDto.getToDateTo());
}
if (!DataUtil.isNullOrZero(campaignRequestDto.getNumOfCusFr())) {
query.setParameter(":pCustNumFr", campaignRequestDto.getNumOfCusFr());
query.setParameter("pCustNumFr", campaignRequestDto.getNumOfCusFr());
}
if (!DataUtil.isNullOrZero(campaignRequestDto.getNumOfCusTo())) {
query.setParameter(":pCustNumTo", campaignRequestDto.getNumOfCusTo());
query.setParameter("pCustNumTo", campaignRequestDto.getNumOfCusTo());
}
result.setTotalRow(query.getResultList().size());
......@@ -144,7 +150,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
item.setContent((String) obj[2]);
item.setStartTime((Date) obj[3]);
item.setEndTime((Date) obj[4]);
item.setStatus(((Short) obj[5]));
item.setStatus(((BigDecimal) obj[5]).shortValueExact());
item.setAgentStatus(((BigDecimal) obj[6]).shortValueExact());
lst.add(item);
}
......@@ -368,9 +375,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
result.setData(dataPage);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
session.close();
return result;
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
result.setErrorCode(Constants.ApiErrorCode.ERROR);
......@@ -381,4 +386,25 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return result;
}
@Override
public String getMaxCampaignIndex() {
logger.info("Start search max campaign code index::");
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
StringBuilder sqlStr = new StringBuilder();
sqlStr.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-max-campaign-code-index"));
SQLQuery query = session.createSQLQuery(sqlStr.toString());
List<String> list = query.list();
if(list.size() > 0) {
return list.get(0);
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
}
......@@ -17,4 +17,6 @@ public interface ApParamService {
ResultDTO findParamByParType(String parType);
List<ApParam>findAllParam();
}
package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.springframework.stereotype.Service;
@Service
public interface CampaignExecuteService {
//<editor-fold: hungtt>
ResultDTO getComboBoxStatus(String companySiteId, String completeType);
ResultDTO getComboCampaignType(String companySiteId);
ResultDTO searchInteractiveResult(CampaignRequestDTO dto);
//</editor-fold>
}
......@@ -16,4 +16,8 @@ public interface CampaignService {
ResultDTO addNewCampaign(CampaignDTO campaignDTO);
Map countRecallCustomer(Long companySiteId, Long agentId);
ResultDTO findCampaignById(Long campaignId);
ResultDTO changeCampaignStatus(CampaignDTO dto);
}
......@@ -3,22 +3,24 @@ package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import java.util.Date;
import java.util.List;
import java.util.Map;
public interface CustomerService {
Map listAllCustomer(int page, int pageSize, String sort);
ResultDTO listAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId);
ResultDTO getCustomerId(Long customerId);
Map listCustByName(int page, int pageSize, String sort, String name);
ResultDTO createCustomer(CustomerDTO customerDTO);
ResultDTO deleteCustomer(CustomerDTO customerDTO);
ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO);
ResultDTO deleteIds(List<Long> ids);
ResultDTO deleteIds(CustomerRequestDTO customerRequestDTO);
// ------------ customer list ------------ //
......@@ -30,7 +32,11 @@ public interface CustomerService {
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteCustomerListIds(List<Long> ids);
ResultDTO deleteCustomerListIds(CustomerRequestDTO customerRequestDTO);
ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO);
// ------------ customer contact ------------ //
ResultDTO searchCustomerList(String customerListCode, String customerListName, Date dateFrom, Date dateTo, int page, int pageSize, String sort);
ResultDTO getCustomerContact(Long customerId, Short contactType, String contact);
}
......@@ -25,8 +25,6 @@ public class ApParamServiceImpl implements ApParamService {
private static final Logger logger = LogManager.getLogger(ApParamServiceImpl.class);
@Override
public Iterable<ApParam> getAllParams(int page, int pageSize, String sort) {
return apParamRepository.findAll(PageRequest.of(page, pageSize, Sort.by(sort)));
......
package com.viettel.campaign.service;
package com.viettel.campaign.service.impl;
import com.viettel.campaign.service.CampaignCompleteCodeService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO;
......
package com.viettel.campaign.service.impl;
import com.viettel.campaign.repository.CampaignExecuteRepository;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.ApParamDTO;
import com.viettel.campaign.web.dto.ContactCustResultDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CampaignExecuteServiceImp implements CampaignExecuteService {
private static final Logger logger = LoggerFactory.getLogger(CampaignExecuteServiceImp.class);
@Autowired
CampaignExecuteRepository campaignExecuteRepository;
//<editor-fold: hungtt>
@Override
public ResultDTO getComboBoxStatus(String companySiteId, String completeType) {
ResultDTO resultDTO = new ResultDTO();
try {
List<ApParamDTO> lst = campaignExecuteRepository.getComboBoxStatus(companySiteId, completeType);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(lst);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return resultDTO;
}
@Override
public ResultDTO getComboCampaignType(String companySiteId) {
ResultDTO resultDTO = new ResultDTO();
try {
List<ApParamDTO> lst = campaignExecuteRepository.getComboCampaignType(companySiteId);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(lst);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return resultDTO;
}
@Override
public ResultDTO searchInteractiveResult(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
try {
resultDTO = campaignExecuteRepository.getInteractiveResult(dto);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return resultDTO;
}
//</editor-fold: hungtt>
}
package com.viettel.campaign.service.impl;
import com.viettel.campaign.model.Campaign;
import com.viettel.campaign.model.TimeRangeDialMode;
import com.viettel.campaign.model.TimeZoneDialMode;
import com.viettel.campaign.repository.CampaignRepository;
import com.viettel.campaign.repository.TimeRangeDialModeRepository;
import com.viettel.campaign.repository.TimeZoneDialModeRepository;
import com.viettel.campaign.repository.impl.CampaignRepositoryImpl;
import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.TimeRangeDialModeDTO;
import com.viettel.campaign.web.dto.TimeZoneDialModeDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -18,8 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
@Service
@Transactional(rollbackFor = Exception.class)
......@@ -32,6 +35,9 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired
TimeZoneDialModeRepository timeZoneDialModeRepository;
@Autowired
TimeRangeDialModeRepository timeRangeDialModeRepository;
@Autowired
ModelMapper modelMapper;
......@@ -52,29 +58,45 @@ public class CampaignServiceImpl implements CampaignService {
@Override
public ResultDTO addNewCampaign(CampaignDTO campaignDTO) {
logger.info("=== Start add new campaign ");
ResultDTO resultDTO = new ResultDTO();
Campaign campaign = modelMapper.map(campaignDTO, Campaign.class);
TimeZoneDialMode timeZoneDialMode = new TimeZoneDialMode();
Long campaignId;
List<TimeZoneDialModeDTO> timeZoneDialModes = new ArrayList<>();
List<TimeRangeDialModeDTO> timeRangeDialModes = new ArrayList<>();
List<TimeRangeDialMode> lstTimeRangeModeToInsert = new ArrayList<>();
List<TimeZoneDialMode> lstTimeZoneModeToInser = new ArrayList<>();
try {
campaign = campaignRepository.save(campaign);
String campaignCode = generateCampaignCode(campaignDTO.getCampaignType(), campaignDTO.getChanel());
campaign.setCampaignCode(campaignCode);
Campaign campaignResult = campaignRepository.save(campaign);
campaignId = campaign.getCampaignId();
//insert sub tables
if(campaignDTO.getCurrentTimeMode().equals(1)){
timeZoneDialMode.setCompanySiteId(campaignDTO.getCompanySiteId());
timeZoneDialMode.setCampaignId(campaign.getCampaignId());
// timeZoneDialMode.setHour(campaignDTO.getT);
timeZoneDialModeRepository.save(timeZoneDialMode);
if(campaignDTO.getLstTimeRange().size() > 0) {
timeRangeDialModes = campaignDTO.getLstTimeRange();
timeRangeDialModes.forEach(item -> {
item.setCampaignId(campaignId);
TimeRangeDialMode timeRangeDialMode = modelMapper.map(item, TimeRangeDialMode.class);
lstTimeRangeModeToInsert.add(timeRangeDialMode);
});
timeRangeDialModeRepository.saveAll(lstTimeRangeModeToInsert);
}
if(campaignDTO.getCurrentTimeMode().equals(2)) {
if(campaignDTO.getLstTimeZone().size() > 0) {
timeZoneDialModes = campaignDTO.getLstTimeZone();
timeZoneDialModes.forEach(item -> {
item.setCampaignId(campaignId);
TimeZoneDialMode timeZoneDialMode = modelMapper.map(item, TimeZoneDialMode.class);
lstTimeZoneModeToInser.add(timeZoneDialMode);
});
timeZoneDialModeRepository.saveAll(lstTimeZoneModeToInser);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setErrorCode(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(campaign);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(campaignResult);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setErrorCode(Constants.ApiErrorDesc.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
......@@ -97,4 +119,59 @@ public class CampaignServiceImpl implements CampaignService {
return result;
}
@Override
public ResultDTO findCampaignById(Long campaignId) {
logger.info("=== Start find campaign by id: " + campaignId);
ResultDTO resultDTO = new ResultDTO();
try {
Campaign campaign = campaignRepository.findById(campaignId).orElse(null);
if (campaign != null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(campaign);
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override
public ResultDTO changeCampaignStatus(CampaignDTO dto) {
ResultDTO result = new ResultDTO();
try {
Campaign entity = campaignRepository.findCampaignByCampaignIdAndCompanySiteId(dto.getCampaignId(), dto.getCompanySiteId());
if (entity != null) {
entity.setStatus(dto.getStatus().longValue());
entity.setUpdateTime(new Date());
entity.setUpdateBy(dto.getUpdateBy());
campaignRepository.save(entity);
result.setData(entity);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
} else {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription("Entity not found");
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(e.getMessage());
}
return result;
}
private String generateCampaignCode(String campaignType, Short chanel) {
int year = Calendar.getInstance().get(Calendar.YEAR);
String maxIndexStr = campaignRepository.getMaxCampaignIndex();
if(maxIndexStr != null) {
Long maxIndex = Long.valueOf(maxIndexStr) + 1;
String result = campaignType + "_" + String.valueOf(chanel) + "_" + String.valueOf(year) + "_" + maxIndex.toString();
return result;
}
return null;
}
}
......@@ -31,4 +31,8 @@ public class Constants {
String ACTIVE_STR = "Trạng thái kêt nối(Không thành công)";
String INACTIVE_STR = "Trạng thái khảo sát";
}
public interface SQL_MODULES {
String MODULE_EXECUTE = "campaign-execute";
}
}
......@@ -5,7 +5,6 @@ import java.nio.file.Paths;
import java.io.IOException;
import com.viettel.campaign.web.dto.BaseDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
......@@ -17,7 +16,6 @@ import org.springframework.data.domain.Sort;
public class SQLBuilder {
public static final String SQL_MODULE_CAMPAIGN_MNG = "campaign-mng";
public static final String SQL_MODULE_CAMPAIGN_STATUS_MNG = "campaign-status-mng";
public static final String SQL_MODULE_CAMPAIGN_CUSTOMER = "campaign-customer";
public static String getSqlQueryById(String module,
String queryId) {
......
......@@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter;
import java.util.Date;
import java.util.List;
@Getter
@Setter
......@@ -57,6 +58,10 @@ public class CampaignDTO extends BaseDTO {
private Long numOfNotJoinedCus;
private Long numOfLockCus;
private String campaignTypeName;
private Date timeRangeStartTime;
private String timeZoneHour;
private String timeZoneMinute;
private List<TimeRangeDialModeDTO> lstTimeRange;
private List<TimeZoneDialModeDTO> lstTimeZone;
private Short agentStatus;
}
package com.viettel.campaign.web.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ContactCustResultDTO extends BaseDTO{
private Long contacCustResultId;
private Long companySiteId;
private Short callStatus;
private Short recordStatus;
private String description;
private Date createTime;
private String callTime;
private Long agentId;
private Long campaignId;
private String campaignName;
private Long phoneNumber;
private String customerName;
private Long customerId;
private String contactStatus;
private String campaignCode;
private String userName;
private String surveyStatus;
private Short status;
private Boolean enableEdit;
}
package com.viettel.campaign.web.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class CustomerContactDTO {
private Long contactId;
private Long customerId;
private Short contactType;
private String contact;
private Short isDirectLine;
private Short status;
private Date createDate;
private Date updateDate;
private String createBy;
private String updateBy;
private Date startDate;
private Date endDate;
}
package com.viettel.campaign.web.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CustomerCustomDTO {
Long customerListMappingId;
Long companySiteId;
Long customerListId;
Long customerId;
String name;
String description;
String companyName;
String customerType;
String currentAddress;
String mobileNumber;
String email;
}
......@@ -10,7 +10,7 @@ import lombok.Setter;
@Getter
@Setter
public class TimeZoneDialModeDTO {
private Long timeRangeDialModeId;
private Long timeZoneDialModeId;
private Long companySiteId;
private String hour;
private String minute;
......
......@@ -25,4 +25,20 @@ public class CampaignRequestDTO extends BaseDTO {
String companySiteId;
String agentId;
String types;
String phoneNumber;
String contactStatus;
String campaignStatus;
String customerId;
String customerName;
String callTimeTo;
String callTimeFrom;
String recordStatus;
String connectStatus;
String toDate;
String fromDate;
String campaignType;
String agentName;
String campaignId;
String surveyStatus;
String roleUser;
}
package com.viettel.campaign.web.dto.request_dto;
import lombok.Getter;
import lombok.Setter;
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 SearchCustomerRequestDTO extends BaseDTO {
String customerListCode;
String customerListName;
String convertedDateFrom;
String convertedDateTo;
String companySiteId;
}
......@@ -2,6 +2,7 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ApParam;
import com.viettel.campaign.service.ApParamService;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.web.rest.controller.CustomerController;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -19,9 +20,18 @@ public class ApParamController {
private static final Logger LOGGER = Logger.getLogger(CustomerController.class);
private static final String CONNECT_STATUS = "CONNECT_STATUS";
private static final String CONNECT_STATUS_TYPE = "1";
private static final String SURVEY_STATUS = "SURVEY_STATUS";
private static final String SURVEY_STATUS_TYPE = "2";
private static final String CAMPAIGN_TYPE = "CAMPAIGN_TYPE";
@Autowired(required = true)
ApParamService apParamService;
@Autowired
CampaignExecuteService campaignExecuteService;
@GetMapping(path = "/findAlls")
@ResponseBody
public ResponseEntity listAllCustomer(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) {
......@@ -56,5 +66,20 @@ public class ApParamController {
}
return new ResponseEntity(findAll, HttpStatus.OK);
}
//<editor-fold: hungtt>
@GetMapping("/getDataComboBox")
@ResponseBody
public ResponseEntity getComboBox(@RequestParam("parType") String parType, @RequestParam("companySiteId") String companySiteId) {
if (CONNECT_STATUS.equals(parType)) {
return new ResponseEntity<>(campaignExecuteService.getComboBoxStatus(companySiteId, CONNECT_STATUS_TYPE), HttpStatus.OK);
} else if (SURVEY_STATUS.equals(parType)){
return new ResponseEntity<>(campaignExecuteService.getComboBoxStatus(companySiteId, SURVEY_STATUS_TYPE), HttpStatus.OK);
} else {
return new ResponseEntity<>(campaignExecuteService.getComboCampaignType(companySiteId), HttpStatus.OK);
}
}
//</editor-fold: hungtt>
}
package com.viettel.campaign.web.rest.controller;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.log4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -16,11 +19,14 @@ import java.util.Map;
@CrossOrigin
public class CampaignController {
private static final Logger LOGGER = Logger.getLogger(CampaignController.class);
private static final Logger logger = LoggerFactory.getLogger(CampaignController.class);
@Autowired
CampaignService campaignService;
@Autowired
CampaignExecuteService campaignExecuteService;
@RequestMapping("/searchCampaignExecute")
@ResponseBody
public ResponseEntity<ResultDTO> searchCampaignExecute(@RequestBody CampaignRequestDTO requestDto) {
......@@ -34,14 +40,14 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/findByCampaignCode", method = RequestMethod.POST)
@RequestMapping(value = "/find-by-campaign-code", method = RequestMethod.POST)
public ResultDTO findByCampaignCode(@RequestBody CampaignRequestDTO dto) {
return campaignService.findByCampaignCode(dto);
}
@RequestMapping(method = RequestMethod.POST)
public ResultDTO addNewCampaign(@RequestBody CampaignRequestDTO dto) {
return campaignService.findByCampaignCode(dto);
public ResultDTO addNewCampaign(@RequestBody CampaignDTO dto) {
return campaignService.addNewCampaign(dto);
}
@GetMapping("/countRecallCustomer")
......@@ -50,4 +56,22 @@ public class CampaignController {
Map result = campaignService.countRecallCustomer(companySiteId, agentId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/searchInteractiveResult")
@ResponseBody
public ResponseEntity<ResultDTO> searchInteractiveResult(@RequestBody CampaignRequestDTO dto) {
ResultDTO result = campaignExecuteService.searchInteractiveResult(dto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/find-campaign-by-id/{campaignId}", method = RequestMethod.GET)
public ResponseEntity<ResultDTO> findCampaignById(@PathVariable Long campaignId) {
ResultDTO resultDTO = campaignService.findCampaignById(campaignId);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/changeCampaignStatus")
public ResultDTO changeCampaignStatus(@RequestBody CampaignDTO dto) {
return campaignService.changeCampaignStatus(dto);
}
}
......@@ -4,21 +4,32 @@ import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import org.apache.log4j.Logger;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.util.Date;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/ipcc/customer")
@CrossOrigin("*")
@CrossOrigin(origins = "*")
public class CustomerController {
private static final Logger LOGGER = Logger.getLogger(CustomerController.class);
......@@ -28,11 +39,18 @@ public class CustomerController {
@GetMapping("/findAll")
@ResponseBody
public ResponseEntity findAllCustomer(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) {
Map result = customerService.listAllCustomer(page, pageSize, sort);
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.listAllCustomer(page, pageSize, sort, customerListId, companySiteId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/findCustomerId")
@ResponseBody
public ResponseEntity<ResultDTO> findAllCustomerName(@RequestParam("customerId") Long customerId) {
ResultDTO result = customerService.getCustomerId(customerId);
return new ResponseEntity(result, HttpStatus.OK);
}
@GetMapping("/findCustomerByName")
@ResponseBody
public ResponseEntity findAllCustomerName(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("name") String name) {
......@@ -61,17 +79,17 @@ public class CustomerController {
@PostMapping("/delete")
@ResponseBody
public ResultDTO deleteCustomer(@RequestBody @Valid CustomerDTO customerDTO) {
public ResultDTO deleteCustomer(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO();
result = customerService.deleteCustomer(customerDTO);
result = customerService.deleteCustomer(customerRequestDTO);
return result;
}
@PostMapping("/deleteIds")
@ResponseBody
public ResultDTO deleteIds(@RequestBody @Valid List<Long> ids) {
public ResultDTO deleteIds(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO();
result = customerService.deleteIds(ids);
result = customerService.deleteIds(customerRequestDTO);
return result;
}
......@@ -134,16 +152,78 @@ public class CustomerController {
@PostMapping("/deleteCustomerListIds")
@ResponseBody
public ResultDTO deleteCustomerListIds(@RequestBody @Valid List<Long> ids) {
public ResultDTO deleteCustomerListIds(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO();
result = customerService.deleteCustomerListIds(ids);
result = customerService.deleteCustomerListIds(customerRequestDTO);
return result;
}
@GetMapping("/searchCustomerList")
@ResponseBody
public ResponseEntity searchCustomerList(@RequestParam("customerListCode") String customerListCode, @RequestParam("customerListName") String customerListName, @RequestParam("dateFrom") Date dateFrom, @RequestParam("dateTo") Date dateTo, @RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) {
ResultDTO result = customerService.searchCustomerList(customerListCode, customerListName, dateFrom, dateTo, page, pageSize, sort);
@RequestMapping(value = "/searchCustomerList", method = RequestMethod.POST)
public ResponseEntity searchCustomerList(@RequestBody SearchCustomerRequestDTO searchCustomerRequestDTO) {
ResultDTO result = customerService.searchCustomerList(searchCustomerRequestDTO);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/findCustomerContact")
@ResponseBody
public ResponseEntity<ResultDTO> findAllCustomerContact(@RequestParam("customerId") Long customerId, @RequestParam("contactType") Short contactType, @RequestParam("contact") String contact) {
ResultDTO result = customerService.getCustomerContact(customerId, contactType, contact);
return new ResponseEntity(result, HttpStatus.OK);
}
@GetMapping(value = "/downloadFileTemplate")
public ResponseEntity<byte[]> downloadFileTemplate() {
LOGGER.debug("--------DOWNLOAD FILE TEMPLATE---------");
try {
File file = ResourceUtils.getFile("classpath:templates/test_download.xlsx");
byte[] content = Files.readAllBytes(file.toPath());
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + file.getName())
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(content);
} catch (Exception e) {
LOGGER.error(e.getMessage());
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
@PostMapping(value = "/importFile")
public ResponseEntity<byte[]> importFile(@RequestParam("file") MultipartFile file) {
LOGGER.debug("--------IMPORT FILE TEMPLATE---------");
try {
List<CustomerDTO> listCustomer = new ArrayList<>();
XSSFWorkbook workbook = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheet = workbook.getSheetAt(0);
for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) {
CustomerDTO customer = new CustomerDTO();
XSSFRow row = sheet.getRow(i);
customer.setCustomerId(Double.valueOf(row.getCell(0).getNumericCellValue()).longValue());
customer.setCreateDate(row.getCell(1).getDateCellValue());
customer.setName(row.getCell(2).getStringCellValue());
listCustomer.add(customer);
}
// for (int i = 0; i < listCustomer.size(); i++) {
// validate du lieu
// }
// if (okay) {
// for (int i = 0; i < listCustomer.size(); i++) {
// customerService.createCustomer(listCustomer.get(i));
// }
// return ResponseEntity.ok()
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + file.getName())
// .contentType(MediaType.APPLICATION_OCTET_STREAM)
// .body(file.getBytes());
// } else {
// return ResponseEntity.ok()
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + file.getName())
// .header("Message", "Validate failed!")
// .contentType(MediaType.APPLICATION_OCTET_STREAM)
// .body(file.getBytes());
// }
return null;
} catch (Exception e) {
LOGGER.error(e.getMessage());
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
}
select AP_PARAM_ID apParamId,
PAR_NAME parName
from AP_PARAM
where PAR_TYPE = 'CAMPAIGN_TYPE' and COMPANY_SITE_ID = :p_company_site_id
select COMPLETE_VALUE apParamId,
COMPLETE_NAME parName
from CAMPAIGN_COMPLETE_CODE
where to_char(COMPLETE_TYPE) = :p_complete_type and STATUS = 1 and COMPANY_SITE_ID = :p_company_site_id
select b.campaign_code campaignCode,
b.campaign_name campaignName,
c.user_name userName,
a.phone_number phoneNumber,
d.name customerName,
a.create_time createTime,
e.complete_name contactStatus,
f.complete_name surveyStatus,
g.status status,
a.status recordStatus
from contact_cust_result a
left join campaign b on a.campaign_id = b.campaign_id
left join vsa_users c on a.agent_id = c.user_id
left join customer d on a.customer_id = d.customer_id
left join campaign_complete_code e on a.contact_status = e.complete_value
left join campaign_complete_code f on a.call_status = e.complete_value
left join campaign g on a.campaign_id = b.campaign_id
where a.campaign_id in (:p_list_campaign_id)
and a.customer_id like '%'||:p_customer_id||'%'
and a.create_time >= to_date(:p_date_from, 'DD/MM/YYYY')
and a.create_time <= to_date(:p_date_to, 'DD/MM/YYYY')
and a.contact_status in (:p_list_contact_status)
and a.call_status in (:p_list_survey_status)
and a.status in (:p_list_record_status)
and a.phone_number like '%'||:p_phone_number||'%'
and a.duration_call >= :p_call_time_from
and a.duration_call <= :p_call_time_to
select
a.CUSTOMER_LIST_MAPPING_ID customerListMappingId,
a.COMPANY_SITE_ID companySiteId,
a.CUSTOMER_LIST_ID customerListId,
a.CUSTOMER_ID customerId,
b.NAME name,
b.DESCRIPTION description,
b.COMPANY_NAME companyName,
b.CUSTOMER_TYPE customerType,
b.CURRENT_ADDRESS currentAddress,
c.MOBILE mobileNumber,
d.EMAIL email
from CUSTOMER_LIST_MAPPING a
join CUSTOMER b on a.CUSTOMER_ID = b.CUSTOMER_ID
left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS MOBILE
FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 5 GROUP BY CUSTOMER_ID) c on b.CUSTOMER_ID = c.CUSTOMER_ID
left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS EMAIL
FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 2 GROUP BY CUSTOMER_ID) d on b.CUSTOMER_ID = d.CUSTOMER_ID
where 1 = 1
and COMPANY_SITE_ID = :p_company_site_id
and CUSTOMER_LIST_ID = :p_customer_list_id
SELECT CASE WHEN
(SELECT COUNT(1) FROM CAMPAIGN) > 0
THEN (SELECT SUBSTR((SELECT CAMPAIGN_CODE FROM CAMPAIGN WHERE CAMPAIGN_ID = (SELECT MAX(CAMPAIGN_ID) FROM CAMPAIGN)),
INSTR((SELECT CAMPAIGN_CODE FROM CAMPAIGN WHERE CAMPAIGN_ID = (SELECT MAX(CAMPAIGN_ID) FROM CAMPAIGN)), '_', -1, 1 )+1) FROM DUAL)
ELSE '0'
END FROM DUAL
SELECT
CUSTOMER_LIST_ID,
COMPANY_SITE_ID,
CUSTOMER_LIST_CODE,
CUSTOMER_LIST_NAME,
STATUS,
CREATE_BY,
CREATE_AT,
UPDATE_BY,
UPDATE_AT,
SOURCE,
DEPT_CREATE
CUSTOMER_LIST_ID customerListId,
COMPANY_SITE_ID companySiteId,
CUSTOMER_LIST_CODE customerListCode,
CUSTOMER_LIST_NAME customerListName,
STATUS status,
CREATE_BY createBy,
CREATE_AT createAt,
UPDATE_BY updateBy,
UPDATE_AT updateAt,
SOURCE source,
DEPT_CREATE deptCreate
FROM CUSTOMER_LIST
WHERE 1 = 1
AND CREATE_AT BETWEEN :p_date_from AND :p_date_to
AND CREATE_AT BETWEEN to_date(:p_date_from, 'YYYYMMDD') AND to_date(:p_date_to, 'YYYYMMDD')
AND COMPANY_SITE_ID = :p_company_site_id
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