Commit e23ebd57 authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd accept merge

parents c0317239 0657308c
This diff is collapsed.
...@@ -18,14 +18,19 @@ public interface CampaignRepositoryCustom { ...@@ -18,14 +18,19 @@ public interface CampaignRepositoryCustom {
ResultDTO checkAllowStatusToPrepare(Long campaignId); ResultDTO checkAllowStatusToPrepare(Long campaignId);
//hungtt //<editor-fold: hungtt>
ResultDTO findCustomerListReallocation(CampaignRequestDTO dto); ResultDTO findCustomerListReallocation(CampaignRequestDTO dto);
//hungtt
ResultDTO reallocationCustomer(CampaignRequestDTO dto); ResultDTO reallocationCustomer(CampaignRequestDTO dto);
//hungtt
ResultDTO getListFieldsNotShow(CampaignRequestDTO dto); ResultDTO getListFieldsNotShow(CampaignRequestDTO dto);
//hungtt
ResultDTO getListFieldsToShow(CampaignRequestDTO dto); ResultDTO getListFieldsToShow(CampaignRequestDTO dto);
//hungtt
ResultDTO getCampaignCustomerList(CampaignRequestDTO dto); ResultDTO getCampaignCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerChoosenList(CampaignRequestDTO dto);
//</editor-fold>
} }
...@@ -56,6 +56,12 @@ public interface CampaignService { ...@@ -56,6 +56,12 @@ public interface CampaignService {
ResultDTO getListFieldsToShow(CampaignRequestDTO dto); ResultDTO getListFieldsToShow(CampaignRequestDTO dto);
ResultDTO getCampaignCustomerList(CampaignRequestDTO dto); ResultDTO getCampaignCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerChoosenList(CampaignRequestDTO dto);
ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto);
//</editor-fold> //</editor-fold>
} }
package com.viettel.campaign.service; package com.viettel.campaign.service;
import com.viettel.campaign.model.ccms_full.Scenario; import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.ScenarioAnswerDTO;
import com.viettel.campaign.web.dto.ScenarioDTO;
import com.viettel.campaign.web.dto.ScenarioQuestionDTO;
import java.util.List; import java.util.List;
...@@ -14,9 +11,12 @@ import java.util.List; ...@@ -14,9 +11,12 @@ import java.util.List;
public interface ScenarioService { public interface ScenarioService {
Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId); Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
ResultDTO update(ScenarioDTO scenario); ResultDTO update(ScenarioDTO scenario);
ResultDTO sortQuestionAndAnswer(ScenarioDTO scenarioDTO); ResultDTO sortQuestionAndAnswer(ScenarioDTO scenarioDTO);
Integer countDuplicateScenarioCode(Long companySiteId, String code, Long scenarioId); Integer countDuplicateScenarioCode(Long companySiteId, String code, Long scenarioId);
ResultDTO saveContacQuestResult(ContactQuestResultDTO dto);
} }
...@@ -245,7 +245,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -245,7 +245,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId())); //TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
if (agents.getUserStatus() != null && agents.getCampaignSystemStatus() != null) { if (agents.getUserStatus() != null && agents.getCampaignSystemStatus() != null) {
if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) { // tạm thời bỏ qua điều kiện này vì DB ACD không thực thi update được
// if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
if (agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0)) //if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0))
data.put("dialModeManual", "1"); data.put("dialModeManual", "1");
} }
...@@ -267,7 +269,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -267,7 +269,9 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
Agents agents = agentsRepository.findByAgentId(requestDto.getAgentId()); Agents agents = agentsRepository.findByAgentId(requestDto.getAgentId());
//TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId())); //TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId())); //TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) { // tạm thời bỏ qua điều kiện này vì DB ACD không thực thi update được
// if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) {
if (agents.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) {
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0)) //if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0))
// update acd_full.agents table // update acd_full.agents table
Agents a = new Agents(); Agents a = new Agents();
......
...@@ -61,6 +61,9 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -61,6 +61,9 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired @Autowired
ScenarioRepository scenarioRepository; ScenarioRepository scenarioRepository;
@Autowired
CampaignCustomerListRepository campaignCustomerListRepository;
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO search(CampaignRequestDTO requestDto) { public ResultDTO search(CampaignRequestDTO requestDto) {
...@@ -370,8 +373,8 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -370,8 +373,8 @@ public class CampaignServiceImpl implements CampaignService {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
List<TimeZoneDialModeDTO> lstTimeZone = dto.getLstTimeZone(); List<TimeZoneDialModeDTO> lstTimeZone = dto.getLstTimeZone();
List<TimeRangeDialModeDTO> lstTimeRange = dto.getLstTimeRange(); List<TimeRangeDialModeDTO> lstTimeRange = dto.getLstTimeRange();
Campaign campaignEntity = new Campaign(); Campaign campaignEntity = campaignRepository.findByCampaignId(dto.getCampaignId());
campaignEntity.setCampaignId(dto.getCampaignId()); campaignEntity.setCampaignName(dto.getCampaignName());
campaignEntity.setCampaignCode(dto.getCampaignCode()); campaignEntity.setCampaignCode(dto.getCampaignCode());
campaignEntity.setContent(dto.getContent()); campaignEntity.setContent(dto.getContent());
campaignEntity.setCustomerNumber(dto.getCustomerNumber()); campaignEntity.setCustomerNumber(dto.getCustomerNumber());
...@@ -487,6 +490,42 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -487,6 +490,42 @@ public class CampaignServiceImpl implements CampaignService {
return campaignRepositoryCustom.getCampaignCustomerList(dto); return campaignRepositoryCustom.getCampaignCustomerList(dto);
} }
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCustomerList(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerChoosenList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCustomerChoosenList(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
String[] lstCusListId = dto.getLstCustomerListId().split(",");
try {
for(String cusListId : lstCusListId) {
CampaignCustomerList entity = new CampaignCustomerList();
entity.setCampaignId(Long.parseLong(dto.getCampaignId()));
entity.setCompanySiteId(Long.parseLong(dto.getCompanySiteId()));
entity.setCustomerListId(Long.parseLong(cusListId));
campaignCustomerListRepository.save(entity);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
// hungtt // hungtt
private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) { private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) {
mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale)); mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale));
......
...@@ -527,23 +527,27 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -527,23 +527,27 @@ public class CustomerServiceImpl implements CustomerService {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("SELECT"); sb.append("SELECT");
sb.append(" CUSTOMER_LIST_ID customerListId,"); sb.append(" a.CUSTOMER_LIST_ID customerListId,");
sb.append(" COMPANY_SITE_ID companySiteId,"); sb.append(" a.COMPANY_SITE_ID companySiteId,");
sb.append(" CUSTOMER_LIST_CODE customerListCode,"); sb.append(" a.CUSTOMER_LIST_CODE customerListCode,");
sb.append(" CUSTOMER_LIST_NAME customerListName,"); sb.append(" a.CUSTOMER_LIST_NAME customerListName,");
sb.append(" STATUS status,"); sb.append(" a.STATUS status,");
sb.append(" CREATE_BY createBy,"); sb.append(" a.CREATE_BY createBy,");
sb.append(" CREATE_AT createAt,"); sb.append(" a.CREATE_AT createAt,");
sb.append(" UPDATE_BY updateBy,"); sb.append(" a.UPDATE_BY updateBy,");
sb.append(" UPDATE_AT updateAt,"); sb.append(" a.UPDATE_AT updateAt,");
sb.append(" SOURCE source,"); sb.append(" a.SOURCE source,");
sb.append(" DEPT_CREATE deptCreate"); sb.append(" a.DEPT_CREATE deptCreate,");
sb.append(" FROM CUSTOMER_LIST"); 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(" WHERE 1 = 1");
sb.append(" AND STATUS = 1"); sb.append(" AND a.STATUS = 1");
sb.append(" AND COMPANY_SITE_ID = :p_company_site_id"); sb.append(" AND a.COMPANY_SITE_ID = :p_company_site_id");
sb.append(" ORDER BY a.CREATE_AT DESC");
sb.append(" ORDER BY CREATE_AT DESC");
SQLQuery query = session.createSQLQuery(sb.toString()); SQLQuery query = session.createSQLQuery(sb.toString());
...@@ -560,6 +564,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -560,6 +564,7 @@ public class CustomerServiceImpl implements CustomerService {
query.addScalar("updateAt", new DateType()); query.addScalar("updateAt", new DateType());
query.addScalar("source", new StringType()); query.addScalar("source", new StringType());
query.addScalar("deptCreate", new StringType()); query.addScalar("deptCreate", new StringType());
query.addScalar("count", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class)); query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class));
int count = 0; int count = 0;
......
package com.viettel.campaign.service.impl; 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.ContactQuestResult;
import com.viettel.campaign.model.ccms_full.Scenario; import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.model.ccms_full.ScenarioAnswer; import com.viettel.campaign.model.ccms_full.ScenarioAnswer;
import com.viettel.campaign.model.ccms_full.ScenarioQuestion; import com.viettel.campaign.model.ccms_full.ScenarioQuestion;
import com.viettel.campaign.repository.ccms_full.ScenarioAnswerRepository; import com.viettel.campaign.repository.ccms_full.*;
import com.viettel.campaign.repository.ccms_full.ScenarioQuestionRepository;
import com.viettel.campaign.repository.ccms_full.ScenarioRepository;
import com.viettel.campaign.service.ScenarioService; import com.viettel.campaign.service.ScenarioService;
import com.viettel.campaign.utils.Constants; import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.ScenarioAnswerDTO; import org.apache.logging.log4j.LogManager;
import com.viettel.campaign.web.dto.ScenarioDTO; import org.apache.logging.log4j.Logger;
import com.viettel.campaign.web.dto.ScenarioQuestionDTO;
import org.modelmapper.ModelMapper; import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -46,6 +41,9 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -46,6 +41,9 @@ public class ScenarioServiceImpl implements ScenarioService {
@Autowired @Autowired
ModelMapper modelMapper; ModelMapper modelMapper;
@Autowired
ContactQuestResultRepository questResultRepository;
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId) { public Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId) {
...@@ -128,4 +126,19 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -128,4 +126,19 @@ public class ScenarioServiceImpl implements ScenarioService {
} }
return null; return null;
} }
public ResultDTO saveContacQuestResult(ContactQuestResultDTO dto) {
ResultDTO resultDTO = new ResultDTO();
if (dto != null) {
ContactQuestResult cqr = questResultRepository.save(modelMapper.map(dto, ContactQuestResult.class));
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(cqr);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
} }
...@@ -21,10 +21,17 @@ public class CustomerListDTO extends BaseDTO { ...@@ -21,10 +21,17 @@ public class CustomerListDTO extends BaseDTO {
private Date updateAt; private Date updateAt;
private String source; private String source;
private String deptCreate; private String deptCreate;
private String count;
private Long totalCusInList; private Long totalCusInList;
private Long totalCusInteract; private Long totalCusInteract;
private Long totalCusNotInteract; private Long totalCusNotInteract;
private Long totalCusList; private Long totalCusList;
private Long totalCusCampaign; private Long totalCusCampaign;
private Long totalCusCalled; private Long totalCusCalled;
private Long totalCusActive;
private Long totalCusLock;
private Long totalCusDnc;
private Long totalCusAddRemove;
private Long totalCusFilter;
private Integer totalRow;
} }
...@@ -46,5 +46,10 @@ public class CampaignRequestDTO extends BaseDTO { ...@@ -46,5 +46,10 @@ public class CampaignRequestDTO extends BaseDTO {
String roleUser; String roleUser;
String contactCustId; String contactCustId;
List<CustomerCustomDTO> customerCustomDTOList; List<CustomerCustomDTO> customerCustomDTOList;
String custListCode;
String custListName;
String createTimeTo;
String createTimeFr;
String lstCustomerListId;
} }
...@@ -255,6 +255,27 @@ public class CampaignController { ...@@ -255,6 +255,27 @@ public class CampaignController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK); return new ResponseEntity<>(resultDTO, HttpStatus.OK);
} }
@PostMapping("/getCustomerList")
@ResponseBody
public ResponseEntity getCustomerList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.getCustomerList(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/getCustomerChoosenList")
@ResponseBody
public ResponseEntity getCustomerChoosenList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.getCustomerChoosenList(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/addCustomerListToCampaign")
@ResponseBody
public ResponseEntity addCustomerListToCampaign(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.addCustomerListToCampaign(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT) @RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT)
public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) { public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) {
ResultDTO result = campaignService.renewCampaign(campaignDTO); ResultDTO result = campaignService.renewCampaign(campaignDTO);
......
...@@ -2,6 +2,7 @@ package com.viettel.campaign.web.rest; ...@@ -2,6 +2,7 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.Scenario; import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.service.ScenarioService; import com.viettel.campaign.service.ScenarioService;
import com.viettel.campaign.web.dto.ContactQuestResultDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.ScenarioDTO; import com.viettel.campaign.web.dto.ScenarioDTO;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -19,7 +20,9 @@ import org.springframework.web.bind.annotation.*; ...@@ -19,7 +20,9 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("/ipcc/campaign/scenario") @RequestMapping("/ipcc/campaign/scenario")
@CrossOrigin @CrossOrigin
public class ScenarioController { public class ScenarioController {
private static final Logger logger = LoggerFactory.getLogger(ScenarioController.class); private static final Logger logger = LoggerFactory.getLogger(ScenarioController.class);
@Autowired @Autowired
ScenarioService scenarioService; ScenarioService scenarioService;
...@@ -45,4 +48,10 @@ public class ScenarioController { ...@@ -45,4 +48,10 @@ public class ScenarioController {
Integer count = scenarioService.countDuplicateScenarioCode(companySiteId, code, scenarioId); Integer count = scenarioService.countDuplicateScenarioCode(companySiteId, code, scenarioId);
return new ResponseEntity<>(count, HttpStatus.OK); return new ResponseEntity<>(count, HttpStatus.OK);
} }
@RequestMapping(value = "/saveContactQuestResult", method = RequestMethod.POST)
ResponseEntity<ResultDTO> saveContactQuestResult(@RequestBody ContactQuestResultDTO dto) {
ResultDTO resultDTO = scenarioService.saveContacQuestResult(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
} }
with campaign_customer_id as (
select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl
where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id
),
customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1
group by a.customer_list_id
),
customer_active_table as (
select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'active'
group by a.customer_list_id
),
customer_lock_table as (
select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'locked'
group by a.customer_list_id
),
customer_dnc_table as (
select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.call_allowed = 0
group by a.customer_list_id
),
customer_filter_table as (
select count(a.customer_id) customerFilter, a.customer_list_id customerListId from campaign_customer a
where a.campaign_id = :p_campaign_id
group by a.customer_list_id
),
data_temp as (
select a.customer_list_id customerListId,
a.customer_list_code customerListCode,
a.customer_list_name customerListName,
nvl(b.totalCustomer, 0) totalCusList,
nvl(c.customerActive, 0) totalCusActive,
nvl(d.customerLock, 0) totalCusLock,
nvl(e.customerDnc, 0) totalCusDnc,
nvl(null, 0) totalCusAddRemove,
nvl(f.customerFilter, 0) totalCusFilter
from customer_list a
left join customer_table b on a.customer_list_id = b.customerListId
left join customer_active_table c on a.customer_list_id = c.customerListId
left join customer_lock_table d on a.customer_list_id = d.customerListId
left join customer_dnc_table e on a.customer_list_id = e.customerListId
left join customer_filter_table f on a.customer_list_id = f.customerListId
where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)
),
data as (
select a.*, rownum row_ from data_temp a
),
count_data as (
select count(*) totalRow from data_temp
)
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter, totalRow from data a, count_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)
with campaign_customer_id as (
select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl
where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id
),
customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1
group by a.customer_list_id
),
customer_active_table as (
select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'active'
group by a.customer_list_id
),
customer_lock_table as (
select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'locked'
group by a.customer_list_id
),
customer_dnc_table as (
select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.call_allowed = 0
group by a.customer_list_id
),
data_temp as (
select a.customer_list_id customerListId,
a.customer_list_code customerListCode,
a.customer_list_name customerListName,
nvl(b.totalCustomer, 0) totalCusList,
nvl(c.customerActive, 0) totalCusActive,
nvl(d.customerLock, 0) totalCusLock,
nvl(e.customerDnc, 0) totalCusDnc,
a.create_at createAt,
a.company_site_id companySiteId,
a.status status
from customer_list a
left join customer_table b on a.customer_list_id = b.customerListId
left join customer_active_table c on a.customer_list_id = c.customerListId
left join customer_lock_table d on a.customer_list_id = d.customerListId
left join customer_dnc_table e on a.customer_list_id = e.customerListId
where a.status = 1
and (:p_cus_list_code is null or upper(a.customer_list_code) like '%'||:p_cus_list_code||'%')
and (:p_cus_list_name is null or upper(a.customer_list_name) like '%'||:p_cus_list_name||'%')
and (a.create_at <= to_date(:p_to_date, 'DD/MM/YYYY'))
and (a.create_at >= to_date(:p_from_date, 'DD/MM/YYYY'))
and (a.company_site_id = :p_company_site_id)
and (a.customer_list_id not in (select CUSTOMER_LIST_ID from campaign_customer_id))
),
data as (
select a.*, rownum row_ from data_temp a
),
count_data as (
select count(*) totalRow from data_temp
)
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, totalRow from data a, count_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)
with customer_table as ( with campaign_customer_id as (
select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl
where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id
),
customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id left join customer b on a.customer_id = b.customer_id
where b.status = 1 where b.status = 1
...@@ -18,7 +22,8 @@ customer_not_interactive_table as ( ...@@ -18,7 +22,8 @@ customer_not_interactive_table as (
select count(a.customer_id) cusNotInteractive, a.customer_list_id customerListId, a.campaign_id from campaign_customer a select count(a.customer_id) cusNotInteractive, a.customer_list_id customerListId, a.campaign_id from campaign_customer a
where a.status = 0 and a.campaign_id = :p_campaign_id and a.in_campaign_status = 1 where a.status = 0 and a.campaign_id = :p_campaign_id and a.in_campaign_status = 1
group by a.customer_list_id, a.campaign_id group by a.customer_list_id, a.campaign_id
) ),
data_temp as (
select a.customer_list_id customerListId, select a.customer_list_id customerListId,
a.customer_list_code customerListCode, a.customer_list_code customerListCode,
a.customer_list_name customerListName, a.customer_list_name customerListName,
...@@ -31,3 +36,13 @@ left join customer_table b on a.customer_list_id = b.customerListId ...@@ -31,3 +36,13 @@ left join customer_table b on a.customer_list_id = b.customerListId
left join campaign_customer_table c on a.customer_list_id = c.customerListId left join campaign_customer_table c on a.customer_list_id = c.customerListId
left join customer_interactive_table d on a.customer_list_id = d.customerListId left join customer_interactive_table d on a.customer_list_id = d.customerListId
left join customer_not_interactive_table e on a.customer_list_id = e.customerListId left join customer_not_interactive_table e on a.customer_list_id = e.customerListId
where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)
),
data as (
select a.*, rownum row_ from data_temp a
),
count_data as (
select count(*) totalRow from data_temp
)
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusCampaign, a.totalCusCalled, a.totalCusNotInteract, totalRow from data a, count_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)
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