Commit 5e3ed78c authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd accept merge

parents 36905cb9 6476719d
...@@ -126,7 +126,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -126,7 +126,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sql.append(" CC2.COMPLETE_NAME AS surveyStatus, "); sql.append(" CC2.COMPLETE_NAME AS surveyStatus, ");
sql.append(" C.STATUS AS status, "); sql.append(" C.STATUS AS status, ");
sql.append(" CCR.STATUS AS recordStatus, "); sql.append(" CCR.STATUS AS recordStatus, ");
sql.append(" (( CCR.END_TIME - CCR.START_CALL ) * 24 * 60 * 60) AS callTime "); sql.append(" (( CCR.END_TIME - CCR.START_CALL ) * 24 * 60 * 60) AS callTime, ");
sql.append(" C.CAMPAIGN_ID AS campaignId, ");
sql.append(" CUS.CUSTOMER_ID AS customerId ");
sql.append("FROM CONTACT_CUST_RESULT CCR "); sql.append("FROM CONTACT_CUST_RESULT CCR ");
sql.append(" INNER JOIN CAMPAIGN C ON CCR.CAMPAIGN_ID = C.CAMPAIGN_ID "); sql.append(" INNER JOIN CAMPAIGN C ON CCR.CAMPAIGN_ID = C.CAMPAIGN_ID ");
sql.append(" INNER JOIN VSA_USERS VU ON CCR.AGENT_ID = VU.USER_ID "); sql.append(" INNER JOIN VSA_USERS VU ON CCR.AGENT_ID = VU.USER_ID ");
...@@ -293,6 +295,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -293,6 +295,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
item.setStatus(obj[10] == null ? 0 : ((BigDecimal) obj[10]).shortValueExact()); item.setStatus(obj[10] == null ? 0 : ((BigDecimal) obj[10]).shortValueExact());
item.setRecordStatus(obj[11] == null ? 0 : ((BigDecimal) obj[11]).shortValueExact()); item.setRecordStatus(obj[11] == null ? 0 : ((BigDecimal) obj[11]).shortValueExact());
item.setCallTime(obj[12] == null ? 0L : ((BigDecimal) obj[12]).longValueExact()); item.setCallTime(obj[12] == null ? 0L : ((BigDecimal) obj[12]).longValueExact());
item.setCampaignId(obj[13] == null ? 0L : ((BigDecimal) obj[13]).longValueExact());
item.setCustomerId(obj[14] == null ? 0L : ((BigDecimal) obj[14]).longValueExact());
list.add(item); list.add(item);
} }
......
...@@ -52,4 +52,6 @@ public interface CampaignExecuteService { ...@@ -52,4 +52,6 @@ public interface CampaignExecuteService {
ResultDTO createListContacQuestResult(List<ContactQuestResultDTO> dtoList); ResultDTO createListContacQuestResult(List<ContactQuestResultDTO> dtoList);
String getDialModeAtCurrent(Long campaignId, Long companySiteId); String getDialModeAtCurrent(Long campaignId, Long companySiteId);
ResultDTO getContactCustResultById(Long contactCustResultId);
} }
...@@ -38,9 +38,6 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -38,9 +38,6 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Autowired @Autowired
ModelMapper modelMapper; ModelMapper modelMapper;
@Autowired
ContactCustResultRepository ccResultRepository;
@Autowired @Autowired
ReceiveCustLogRepository custLogRepository; ReceiveCustLogRepository custLogRepository;
...@@ -68,6 +65,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -68,6 +65,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Autowired @Autowired
CampaignCustomerListColumnRepository campaignCustomerListColumnRepository; CampaignCustomerListColumnRepository campaignCustomerListColumnRepository;
@Autowired
ContactCustResultRepository ccResultRepository;
@Autowired @Autowired
ContactQuestResultRepository contactQuestResultRepository; ContactQuestResultRepository contactQuestResultRepository;
...@@ -226,9 +226,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -226,9 +226,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
++rowIndex; ++rowIndex;
++count; ++count;
} }
}catch (Exception e){ } catch (Exception e) {
}finally { } finally {
if (workbook != null) workbook.close(); if (workbook != null) workbook.close();
} }
...@@ -728,4 +728,19 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -728,4 +728,19 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
return "-1"; return "-1";
} }
@Override
public ResultDTO getContactCustResultById(Long contactCustResultId) {
ResultDTO resultDTO = new ResultDTO();
try {
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(ccResultRepository.findById(contactCustResultId));
} catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
} }
...@@ -2,9 +2,7 @@ package com.viettel.campaign.service.impl; ...@@ -2,9 +2,7 @@ package com.viettel.campaign.service.impl;
import com.viettel.campaign.config.DataSourceQualify; import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.*; import com.viettel.campaign.model.ccms_full.*;
//import com.viettel.campaign.model.UserActionLog;
import com.viettel.campaign.repository.ccms_full.*; import com.viettel.campaign.repository.ccms_full.*;
//import com.viettel.campaign.repository.UserActionLogRepository;
import com.viettel.campaign.service.CampaignService; import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.utils.BundleUtils; import com.viettel.campaign.utils.BundleUtils;
import com.viettel.campaign.utils.Constants; import com.viettel.campaign.utils.Constants;
...@@ -14,7 +12,9 @@ import com.viettel.campaign.web.dto.*; ...@@ -14,7 +12,9 @@ import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO; import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.modelmapper.ModelMapper; import org.modelmapper.ModelMapper;
...@@ -22,12 +22,11 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -22,12 +22,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*; import java.util.*;
//import com.viettel.campaign.model.UserActionLog;
//import com.viettel.campaign.repository.UserActionLogRepository;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class CampaignServiceImpl implements CampaignService { public class CampaignServiceImpl implements CampaignService {
...@@ -637,20 +636,26 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -637,20 +636,26 @@ public class CampaignServiceImpl implements CampaignService {
List<CustomerListDTO> listCustomerDto = dto.getLstCustomerCampaign(); List<CustomerListDTO> listCustomerDto = dto.getLstCustomerCampaign();
try { try {
// Thuc hien them giam khach hang // Thuc hien them giam khach hang
for (CustomerListDTO customerListDTO : listCustomerDto) { for (CustomerListDTO customerListDTO : listCustomerDto) { // Duyet tung customerList
if (customerListDTO.getTotalCusAddRemove() > 0) { // Them khach hang if (customerListDTO.getTotalCusAddRemove() > 0) { // Them khach hang
// Lay ra danh sach khach hang phu hop de them // Lay ra danh sach khach hang phu hop de them
List<Customer> listCustomerToAdd = customerRepository.findAllCutomerNotInCampagin(customerListDTO.getCustomerListId(), campaignId); List<Customer> listCustomerToAdd = customerRepository.findAllCutomerNotInCampagin(customerListDTO.getCustomerListId(), campaignId);
for (int i = 0; i < customerListDTO.getTotalCusAddRemove(); i++) { int numOfCusInList = listCustomerToAdd.size(); // Số khách hàng còn lại của chiến dịch chưa đc add vào campaign
CampaignCustomer campaignCustomerEntity = new CampaignCustomer(); for (int i = 0, j = 0; (i < customerListDTO.getTotalCusAddRemove() && j < numOfCusInList); j++) {
campaignCustomerEntity.setCampaignId(campaignId); if (campaignCustomerRepository.findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId(campaignId, companySiteId, listCustomerToAdd.get(j).getCustomerId()) != null) { // Khach hang đã đc chèn vào campaign theo individual
campaignCustomerEntity.setCustomerId(listCustomerToAdd.get(i).getCustomerId()); continue;
campaignCustomerEntity.setStatus((short) 0); } else {
campaignCustomerEntity.setRecallCount(0L); CampaignCustomer campaignCustomerEntity = new CampaignCustomer();
campaignCustomerEntity.setCustomerListId(customerListDTO.getCustomerListId()); campaignCustomerEntity.setCampaignId(campaignId);
campaignCustomerEntity.setCompanySiteId(companySiteId); campaignCustomerEntity.setCustomerId(listCustomerToAdd.get(j).getCustomerId());
campaignCustomerEntity.setInCampaignStatus((short) 1); campaignCustomerEntity.setStatus((short) 0);
campaignCustomerRepository.save(campaignCustomerEntity); campaignCustomerEntity.setRecallCount(0L);
campaignCustomerEntity.setCustomerListId(customerListDTO.getCustomerListId());
campaignCustomerEntity.setCompanySiteId(companySiteId);
campaignCustomerEntity.setInCampaignStatus((short) 1);
campaignCustomerRepository.save(campaignCustomerEntity);
i += 1;
}
} }
} else if (customerListDTO.getTotalCusAddRemove() < 0){ // Loai bo khach hang } else if (customerListDTO.getTotalCusAddRemove() < 0){ // Loai bo khach hang
long custToDel = Math.abs(customerListDTO.getTotalCusAddRemove()); long custToDel = Math.abs(customerListDTO.getTotalCusAddRemove());
......
...@@ -181,7 +181,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -181,7 +181,7 @@ public class CustomerServiceImpl implements CustomerService {
} }
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Order.desc(sort))); Pageable pageable = PageRequest.of(page, pageSize, Sort.by(Sort.Order.desc(sort)));
if (pageable != null) { if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize()); query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize()); query.setMaxResults(pageable.getPageSize());
} }
...@@ -195,7 +195,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -195,7 +195,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
if(session != null) session.close(); if (session != null) session.close();
} }
return resultDTO; return resultDTO;
...@@ -342,7 +342,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -342,7 +342,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
if(session != null) session.close(); if (session != null) session.close();
} }
return resultDTO; return resultDTO;
...@@ -498,7 +498,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -498,7 +498,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
if(session != null) session.close(); if (session != null) session.close();
} }
return resultDTO; return resultDTO;
...@@ -599,7 +599,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -599,7 +599,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
if(session != null) session.close(); if (session != null) session.close();
} }
return resultDTO; return resultDTO;
...@@ -871,7 +871,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -871,7 +871,7 @@ public class CustomerServiceImpl implements CustomerService {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
if(session != null) session.close(); if (session != null) session.close();
} }
return resultDTO; return resultDTO;
...@@ -941,7 +941,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -941,7 +941,7 @@ public class CustomerServiceImpl implements CustomerService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> dynamicHeader, UserSession userSession, Long customerListId) throws IOException{ public Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> dynamicHeader, UserSession userSession, Long customerListId) throws IOException {
LOGGER.info("------------READ AND VALIDATE--------------"); LOGGER.info("------------READ AND VALIDATE--------------");
Locale locale = new Locale("vi", "VN"); Locale locale = new Locale("vi", "VN");
DataFormatter dataFormat = new DataFormatter(); DataFormatter dataFormat = new DataFormatter();
...@@ -1267,7 +1267,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1267,7 +1267,7 @@ public class CustomerServiceImpl implements CustomerService {
LOGGER.info(e.getMessage()); LOGGER.info(e.getMessage());
result.put("message", "validate-error"); result.put("message", "validate-error");
return result; return result;
}finally { } finally {
if (workbook != null) workbook.close(); if (workbook != null) workbook.close();
} }
} }
...@@ -1414,10 +1414,10 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1414,10 +1414,10 @@ public class CustomerServiceImpl implements CustomerService {
//<editor-fold desc="Cho những trường tĩnh" defaultstate="collapsed"> //<editor-fold desc="Cho những trường tĩnh" defaultstate="collapsed">
DataValidationConstraint cusTypeConstraint = dataValidationHelper.createExplicitListConstraint(new String[]{BundleUtils.getLangString("customer.cusType.normal", locale), BundleUtils.getLangString("customer.cusType.vip", locale), BundleUtils.getLangString("customer.cusType.blacklist", locale)}); DataValidationConstraint cusTypeConstraint = dataValidationHelper.createExplicitListConstraint(new String[]{BundleUtils.getLangString("customer.cusType.normal", locale), BundleUtils.getLangString("customer.cusType.vip", locale), BundleUtils.getLangString("customer.cusType.blacklist", locale)});
DataValidationConstraint isAllowConstraint = dataValidationHelper.createExplicitListConstraint(new String[]{BundleUtils.getLangString("customer.yes", locale), BundleUtils.getLangString("customer.not", locale)}); DataValidationConstraint isAllowConstraint = dataValidationHelper.createExplicitListConstraint(new String[]{BundleUtils.getLangString("customer.yes", locale), BundleUtils.getLangString("customer.not", locale)});
CellRangeAddressList cusTypeCellRangeAddressList = new CellRangeAddressList(3, 9999, 6, 6); CellRangeAddressList cusTypeCellRangeAddressList = new CellRangeAddressList(4, 9999, 6, 6);
CellRangeAddressList callCellRangeAddressList = new CellRangeAddressList(3, 9999, 9, 9); CellRangeAddressList callCellRangeAddressList = new CellRangeAddressList(4, 9999, 9, 9);
CellRangeAddressList emailCellRangeAddressList = new CellRangeAddressList(3, 9999, 10, 10); CellRangeAddressList emailCellRangeAddressList = new CellRangeAddressList(4, 9999, 10, 10);
CellRangeAddressList smsCellRangeAddressList = new CellRangeAddressList(3, 9999, 11, 11); CellRangeAddressList smsCellRangeAddressList = new CellRangeAddressList(4, 9999, 11, 11);
DataValidation cusTypeValidation = dataValidationHelper.createValidation(cusTypeConstraint, cusTypeCellRangeAddressList); DataValidation cusTypeValidation = dataValidationHelper.createValidation(cusTypeConstraint, cusTypeCellRangeAddressList);
DataValidation callValidation = dataValidationHelper.createValidation(isAllowConstraint, callCellRangeAddressList); DataValidation callValidation = dataValidationHelper.createValidation(isAllowConstraint, callCellRangeAddressList);
DataValidation emailValidation = dataValidationHelper.createValidation(isAllowConstraint, emailCellRangeAddressList); DataValidation emailValidation = dataValidationHelper.createValidation(isAllowConstraint, emailCellRangeAddressList);
...@@ -1487,7 +1487,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1487,7 +1487,7 @@ public class CustomerServiceImpl implements CustomerService {
} catch (Exception e) { } catch (Exception e) {
LOGGER.error(e.getMessage()); LOGGER.error(e.getMessage());
return null; return null;
}finally { } finally {
if (workbook != null) workbook.close(); if (workbook != null) workbook.close();
} }
} }
...@@ -1823,7 +1823,29 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1823,7 +1823,29 @@ public class CustomerServiceImpl implements CustomerService {
return query; return query;
} }
// params.put('1', ["AND","AGE",">=","30"] )
// lst.push(params);
// StringBuilder sql = "Select ..... WHERE 1 = 1 "
// for(lst){
// String[] data = lst[i].value
// sql.append(data[0] + data[1] + data[2] + data[3]);
// }
// Map<String, String> params = new HashMap<>();
// public ResultDTO searchCustomize(List<CustomizeFields> customizeFields) {
// Map<String, CustomizeRequestDTo> hashCustomer = new HashMap<>();
// CustomizeRequestDTo customizeRequestDTo = new CustomizeRequestDTo();
// hashCustomer.put("1", customizeRequestDTo);
// hashCustomer.put("2", customizeRequestDTo);
// hashCustomer.put("3", customizeRequestDTo);
// StringBuilder sb = new StringBuilder();
// sb.append("");
// sb.append("");
// sb.append("");
// sb.append("");
@Override @Override
public ResultDTO listCustomizeFields(CustomizeFieldsDTO customizeFields) { public ResultDTO listCustomizeFields(CustomizeFieldsDTO customizeFields) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
...@@ -1866,111 +1888,130 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1866,111 +1888,130 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchCustomizeFields(CampaignCustomerDTO campaignCustomerDTO) { public ResultDTO searchCustomizeFields(CampaignCustomerDTO campaignCustomerDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
CustomerDTO customerDTO = new CustomerDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = sessionFactory.openSession();
session.beginTransaction(); 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.area_code");
requestCustomer.put("-12", "c.customer_type");
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 { try {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("select"); sb.append("select c.customer_id customerId,");
sb.append(" C.NAME name,"); sb.append(" C.NAME name,");
sb.append(" C.CUSTOMER_ID customerID,"); sb.append(" cc.contact mobileNumber,");
sb.append(" C.USERNAME username,"); sb.append(" cc2.contact email,");
sb.append(" C.GENDER gender,"); sb.append(" c.customer_type customerType,");
sb.append(" C.COMPANY_NAME companyName,");
sb.append(" C.DATE_OF_BIRTH dateOfBirth,");
sb.append(" C.CUSTOMER_TYPE customerType,");
sb.append(" C.COMPANY_NAME companyName,"); sb.append(" C.COMPANY_NAME companyName,");
sb.append(" C.PLACE_OF_BIRTH placeOfBirth,"); sb.append(" c.current_address currentAddress,");
sb.append(" C.EMAIL email,"); sb.append(" c.Description description");
sb.append(" C.MOBILE_NUMBER mobileNumber,");
sb.append(" C.STATUS status,");
sb.append(" C.SITE_ID siteId,");
sb.append(" CF.FUNCTION_CODE functionCode,");
sb.append(" CF.ACTIVE active,");
sb.append(" CFO.*");
sb.append(" FROM CUSTOMER C"); sb.append(" FROM CUSTOMER C");
sb.append(" INNER JOIN CUSTOMIZE_FIELD_OBJECT CFO ON C.CUSTOMER_ID = CFO.OBJECT_ID"); sb.append(" INNER JOIN CUSTOMER_contact cc ON (C.CUSTOMER_ID = Cc.customer_id " +
sb.append(" INNER JOIN CUSTOMIZE_FIELDS CF ON CF.CUSTOMIZE_FIELD_ID = CFO.CUSTOMIZE_FIELDS_ID\n" + "and cc.status = 1 and cc.contact_type = 5)");
" WHERE "); sb.append(" INNER JOIN CUSTOMER_contact Cc2 ON (C.CUSTOMER_ID = Cc2.customer_id and cc2.status = 1 and cc2.contact_type = 2)");
sb.append(" CFO.STATUS = 1"); sb.append("inner join customize_field_object cfo on c.customer_id = cfo.object_id and cfo.status = 1");
sb.append(" AND CF.ACTIVE = 1 "); sb.append(" AND C.STATUS = 1");
sb.append(" AND CF.FUNCTION_CODE = 'CUSTOMER' "); sb.append(" AND C.customer_id not in (select customer_id from campaign_customer where campaign_id = :p_campaign_id) ");
List<CustomerQueryDTO> customerDTOList = campaignCustomerDTO.getListQuery(); List<CustomerQueryDTO> customerDTOList = campaignCustomerDTO.getListQuery();
if (customerDTOList.get(0).getField() > 0) {
switch (customerDTOList.get(0).getType()) {
for (CustomerQueryDTO query : customerDTOList) { case "combobox":
if (query.getJoin() == null) { 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() + ")");
sb.append("AND ");
} else {
sb.append(query.getJoin() + " ");
// if ("like".equals(query.getOperator()) || "not like".equals(query.getOperator())) {
// sb.append("%"+ query.getCondition() + "% ");
// } else {
// sb.append(query.getCondition());
// }
}
switch (query.getField() + "") {
case "-1":
sb.append(" C.CUSTOMER_ID " + query.getOperator() + " '%" + query.getCondition() + "%' ");
break;
case "-2":
sb.append(" C.NAME " + query.getOperator() + " '%" + query.getCondition() + "%' ");
break;
case "-3":
sb.append(" C.COMPANY_NAME " + query.getOperator() + " '%" + query.getCondition() + "%' ");
break;
case "-4":
sb.append(" C.GENDER " + query.getOperator() + " '%" + query.getCondition() + "%' ");
break;
case "-5":
sb.append(" C.CURRENT_ADDRESS " + query.getOperator() + " '%" + query.getCondition() + "%' ");
break;
case "-6":
sb.append( " C.PLACE_OF_BIRTH " + query.getOperator() + "to_date(" + query.getCondition() + ", 'dd/mm/yyyy')");
break; break;
case "-7": case "text":
sb.append(" C.DATE_OF_BIRTH " + query.getOperator() + "to_date(" + query.getCondition() + ", 'dd/mm/yyyy')"); if ("like".equals(customerDTOList.get(0).getOperator()) || "not like".equals(customerDTOList.get(0).getOperator())) {
break; sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_text " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition() + "%')");
case "-8": } else {
sb.append(" C.MOBILE_NUMBER " + query.getOperator() + " '%" + query.getCondition() + "%' "); sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_text " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition() + ")");
}
break; break;
case "-9": case "date":
sb.append(" C.EMAIL " + query.getOperator() + " '%" + query.getCondition() + "%' "); sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_date " + customerDTOList.get(0).getOperator() + " to_date(" + customerDTOList.get(0).getCondition() + ", 'DD/MM/YYYY'))");
break; break;
case "-10": case "number":
sb.append(" C.USER_NAME " + query.getOperator() + " '%" + query.getCondition() + "%' "); sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_number " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition() + ")");
break; break;
case "-11": case "checkbox":
sb.append(" C.CUSTOMER_TYPE " + query.getOperator() + " '%" + query.getCondition() + "%' "); sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(0).getField() + " and cfo.value_checkbox " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition() + ")");
break; break;
} }
} else {
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 cfo.value_text " + customerDTOList.get(0).getOperator() + " '%" + customerDTOList.get(0).getCondition() + "%')");
} else {
sb.append("and " + requestCustomer.get(customerDTOList.get(0).getField().toString()) + " " + customerDTOList.get(0).getOperator() + " " + customerDTOList.get(0).getCondition());
}
}
for (int i = 1; i < campaignCustomerDTO.getListQuery().size(); i++) {
if (customerDTOList.get(i).getField() < 0) {
if ("like".equals(customerDTOList.get(i).getOperator()) || "not like".equals(customerDTOList.get(i).getOperator())) {
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.value_text " + customerDTOList.get(i).getOperator() + " '%" + customerDTOList.get(i).getCondition() + "%')");
sb.append(" " + customerDTOList.get(i).getJoin() + " "
+ requestCustomer.get(customerDTOList.get(i).getField().toString()) + " "
+ customerDTOList.get(i).getOperator() + " "
+ "'%"+customerDTOList.get(i).getCondition() + "%' ");
} else {
sb.append(" " + customerDTOList.get(i).getJoin() + " "
+ requestCustomer.get(customerDTOList.get(i).getField().toString()) + " "
+ customerDTOList.get(i).getOperator() + " "
+ customerDTOList.get(i).getCondition() + " ");
}
} else {
switch (customerDTOList.get(i).getType()) {
case "combobox":
sb.append("and (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":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.value_text " + customerDTOList.get(i).getOperator() + " %'" + customerDTOList.get(i).getCondition() + "%')");
break;
case "date":
sb.append("and (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.value_date " + customerDTOList.get(i).getOperator() + " " + customerDTOList.get(i).getCondition() + ")");
break;
case "number":
sb.append("and (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("and (cfo.customize_fields_id =" + customerDTOList.get(i).getField() + " and cfo.value_checkbox " + customerDTOList.get(i).getOperator() + " " + customerDTOList.get(i).getCondition() + ")");
break;
}
}
} }
SQLQuery query = session.createSQLQuery(sb.toString()); SQLQuery query = session.createSQLQuery(sb.toString());
query.addScalar("customerId", new LongType());
query.addScalar("name", new StringType()); query.addScalar("name", new StringType());
query.addScalar("userName", new StringType()); query.addScalar("customerId", new LongType());
query.addScalar("companyName", new StringType());
query.addScalar("customerType", new LongType());
query.addScalar("currentAddress", new StringType());
query.addScalar("mobileNumber", new StringType()); query.addScalar("mobileNumber", new StringType());
query.addScalar("email", new StringType()); query.addScalar("email", new StringType());
query.addScalar("placeOfBirth", new StringType()); query.addScalar("customerType", new LongType());
query.addScalar("dateOfBirth", new DateType()); query.addScalar("companyName", new StringType());
query.addScalar("status", new ShortType()); query.addScalar("currentAddress", new StringType());
query.addScalar("siteId", new LongType()); query.addScalar("description", new StringType());
query.addScalar("active", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CampaignCustomerDTO.class)); query.setParameter("p_campaign_id", campaignCustomerDTO.getCampaignId());
query.setResultTransformer(Transformers.aliasToBean(CustomerDTO.class));
int count = 0; int count = 0;
List<CampaignCustomerDTO> dtoList = query.list(); List<CustomerDTO> dtoList = query.list();
if (dtoList.size() > 0) { if (dtoList.size() > 0) {
count = query.list().size(); count = query.list().size();
} }
...@@ -1981,8 +2022,8 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1981,8 +2022,8 @@ public class CustomerServiceImpl implements CustomerService {
query.setMaxResults(pageable.getPageSize()); query.setMaxResults(pageable.getPageSize());
} }
List<CampaignCustomerDTO> data = query.list(); List<CustomerDTO>data = query.list();
Page<CampaignCustomerDTO> dataPage = new PageImpl<>(data, pageable, count); Page<CustomerDTO> dataPage = new PageImpl<>(data, pageable, count);
resultDTO.setData(dataPage); resultDTO.setData(dataPage);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
...@@ -1997,11 +2038,4 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1997,11 +2038,4 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO; return resultDTO;
} }
private String getCodition(String join, String operator, String codition) {
// if (operator.equalsIgnoreCase("LIKE") || operator.equalsIgnoreCase("NOT_LIKE")) {
// } else {
// return " " + join + " " + operator + " " + codition + " ";
// }
return null;
}
} }
package com.viettel.campaign.web.dto.request_dto; package com.viettel.campaign.web.dto.request_dto;
import com.viettel.campaign.web.dto.BaseDTO; import com.viettel.campaign.web.dto.BaseDTO;
import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
@Getter @Getter
@Setter @Setter
@AllArgsConstructor
@NoArgsConstructor
public class CustomerQueryDTO extends BaseDTO { public class CustomerQueryDTO extends BaseDTO {
String join ; String join ;
Long field; Long field;
String operator; String operator;
String condition; String condition;
String type;
} }
...@@ -180,4 +180,11 @@ public class CampaignExecuteController { ...@@ -180,4 +180,11 @@ public class CampaignExecuteController {
String result = campaignExecuteService.getDialModeAtCurrent(companySiteId, campaignId); String result = campaignExecuteService.getDialModeAtCurrent(companySiteId, campaignId);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping("/getContactCustResultById")
@ResponseBody
public ResponseEntity getContactCustResultById(@RequestParam("contactCustResultId") Long contactCustResultId) {
ResultDTO result = campaignExecuteService.getContactCustResultById(contactCustResultId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
} }
...@@ -316,7 +316,7 @@ public class CustomerController { ...@@ -316,7 +316,7 @@ public class CustomerController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK); return new ResponseEntity<>(resultDTO, HttpStatus.OK);
} }
@PostMapping("/searchCustomizeFields") @PostMapping("/searchIndividualCustomer")
@ResponseBody @ResponseBody
public ResponseEntity searchCustomizeFields(@RequestBody CampaignCustomerDTO campaignCustomerDTO ) { public ResponseEntity searchCustomizeFields(@RequestBody CampaignCustomerDTO campaignCustomerDTO ) {
ResultDTO result = customerService.searchCustomizeFields(campaignCustomerDTO); ResultDTO result = customerService.searchCustomizeFields(campaignCustomerDTO);
......
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