Commit b3b96cc4 authored by Phạm Duy Phi's avatar Phạm Duy Phi

phipd commit merge

parent bc43ea80
No preview for this file type
...@@ -4,3 +4,4 @@ logs/ ...@@ -4,3 +4,4 @@ logs/
out/ out/
/campaign.iml /campaign.iml
/lib /lib
/log
package com.viettel.campaign.job; package com.viettel.campaign.job;
import com.viettel.campaign.model.ccms_full.Campaign; import com.viettel.campaign.model.ccms_full.*;
import com.viettel.campaign.model.ccms_full.Customer; import com.viettel.campaign.service.*;
import com.viettel.campaign.model.ccms_full.CustomerTime;
import com.viettel.campaign.model.ccms_full.ProcessConfig;
import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.service.CustomerTimeService;
import com.viettel.campaign.service.ProcessConfigService;
import com.viettel.campaign.utils.DateTimeUtil; import com.viettel.campaign.utils.DateTimeUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -42,68 +36,75 @@ public class CampaignJob { ...@@ -42,68 +36,75 @@ public class CampaignJob {
@Autowired @Autowired
private CustomerService customerService; private CustomerService customerService;
@Autowired
private UserActionLogService userActionLogService;
// @Scheduled(fixedRate = 5000) // @Scheduled(fixedRate = 5000)
// @Transactional( propagation = Propagation.REQUIRED) // @Transactional( propagation = Propagation.REQUIRED)
public void process() { public void process() {
log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date())); // log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
List<ProcessConfig> list = processConfigService.findAll(); // List<ProcessConfig> list = processConfigService.findAll();
//
list.parallelStream().forEach(p -> { // list.parallelStream().forEach(p -> {
boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess()); // boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
switch (p.getConfigCode()){ // switch (p.getConfigCode()){
case CUSTOMER_INACTIVE_DUARATION: // case CUSTOMER_INACTIVE_DUARATION:
if(isExecute){ // if(isExecute){
List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date()); // List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
updateCustomer(customers); // updateCustomer(customers);
updateCustomerTime(customers); // updateCustomerTime(customers);
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId()); // log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date()); // p.setLastProcess(new Date());
processConfigService.update(p); // processConfigService.update(p);
} // }
break; // break;
case CRON_EXPRESSION_CHECK_START: // case CRON_EXPRESSION_CHECK_START:
// process // // process
if(isExecute){ // if(isExecute){
List<Long> status = new ArrayList<>(); // List<Long> status = new ArrayList<>();
status.add(1L); // status.add(1L);
status.add(1L); // status.add(1L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status); // List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> { // campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId()); // log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
campaign.setProcessStatus(1); // campaign.setProcessStatus(1);
campaign.setStatus(2L); // campaign.setStatus(2L);
campaign.setCampaignStart(new Date()); // campaign.setCampaignStart(new Date());
campaignService.updateProcess(campaign); // campaignService.updateProcess(campaign);
}); // //write log
// saveLog(campaign, 1);
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId()); // });
p.setLastProcess(new Date()); //
processConfigService.update(p); // log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
} // p.setLastProcess(new Date());
break; // processConfigService.update(p);
case CRON_EXPRESSION_CHECK_END: // }
// process // break;
if(isExecute){ // case CRON_EXPRESSION_CHECK_END:
List<Long> status = new ArrayList<>(); // // process
status.add(2L); // if(isExecute){
status.add(3L); // List<Long> status = new ArrayList<>();
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status); // status.add(2L);
campaigns.parallelStream().forEach(campaign -> { // status.add(3L);
log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId()); // List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaign.setStatus(4L); // campaigns.parallelStream().forEach(campaign -> {
campaign.setCampaignEnd(new Date()); // log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
campaignService.updateProcess(campaign); // campaign.setStatus(4L);
}); // campaign.setCampaignEnd(new Date());
// campaignService.updateProcess(campaign);
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId()); // //write log
p.setLastProcess(new Date()); // saveLog(campaign, 2);
processConfigService.update(p); // });
} //
break; // log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
default: // p.setLastProcess(new Date());
// update last check time // processConfigService.update(p);
} // }
}); // break;
// default:
// // update last check time
// }
// });
} }
...@@ -129,5 +130,16 @@ public class CampaignJob { ...@@ -129,5 +130,16 @@ public class CampaignJob {
}); });
} }
private void saveLog(Campaign c, int t){
UserActionLog log = new UserActionLog();
log.setAgentId(1L);
log.setSessionId("-1");
log.setStartTime(new Date());
log.setActionType(t == 1 ? 13L : 14L);
log.setObjectId(c.getCampaignId());
log.setCompanySiteId(c.getCompanySiteId());
userActionLogService.save(log);
}
} }
...@@ -5,15 +5,18 @@ import lombok.Setter; ...@@ -5,15 +5,18 @@ import lombok.Setter;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
@Entity @Entity
@Table(name = "CUSTOMER_CONTACT") @Table(name = "CUSTOMER_CONTACT")
@Getter @Getter
@Setter @Setter
public class CustomerContact { public class CustomerContact implements Serializable {
@Id @Id
@Basic(optional = false) @Basic(optional = false)
@GeneratedValue(generator = "customer_contact_seq", strategy = GenerationType.IDENTITY)
@SequenceGenerator(name = "customer_contact_seq", sequenceName = "customer_contact_seq", allocationSize = 1)
@NotNull @NotNull
@Column(name = "CONTACT_ID") @Column(name = "CONTACT_ID")
private Long contactId; private Long contactId;
......
package com.viettel.campaign.model.ccms_full;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @author hanv_itsol
* @project campaign
*/
@Entity
@Table(name = "USER_ACTION_LOG")
@Data
public class UserActionLog implements Serializable {
@Id
@NotNull
@Column(name = "AGENT_ID")
private Long agentId;
@Column(name = "COMPANY_SITE_ID")
private Long companySiteId;
@Column(name = "SESSION_ID")
private String sessionId;
@Column(name = "START_TIME")
private Date startTime;
@Column(name = "END_TIME")
private Date endTime;
@Column(name = "ACTION_TYPE")
private Long actionType;
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "OBJECT_ID")
private Long objectId;
}
...@@ -17,5 +17,5 @@ public interface AgentsRepository extends JpaRepository<Agents, String> { ...@@ -17,5 +17,5 @@ public interface AgentsRepository extends JpaRepository<Agents, String> {
@Modifying @Modifying
@Query(value = "UPDATE Agents SET campaignSystemStatus = :campaignSystemStatus WHERE agentId = :agentId") @Query(value = "UPDATE Agents SET campaignSystemStatus = :campaignSystemStatus WHERE agentId = :agentId")
void updateAgentLogoutFromCampaign(@Param("agentId") Long agentId, @Param("campaignSystemStatus") String campaignSystemStatus); void updateAgentLogoutFromCampaign(@Param("agentId") String agentId, @Param("campaignSystemStatus") String campaignSystemStatus);
} }
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.CampaignCustomerListColumn;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Repository
@Transactional(DataSourceQualify.CCMS_FULL)
public interface CampaignCustomerListColumnRepository extends JpaRepository<CampaignCustomerListColumn, Long> {
List<CampaignCustomerListColumn> findByCampaignIdAndCompanySiteId(Long campaignId, Long companaySiteId);
CampaignCustomerListColumn findByCampaignCusListColId(Long campaignCusListColId);
}
...@@ -14,4 +14,6 @@ public interface CampaignCustomerListRepository extends JpaRepository<CampaignCu ...@@ -14,4 +14,6 @@ public interface CampaignCustomerListRepository extends JpaRepository<CampaignCu
@Query("select count (c.campaignId) from CampaignCustomerList c where c.customerListId in (:ids)") @Query("select count (c.campaignId) from CampaignCustomerList c where c.customerListId in (:ids)")
Long campaignIdsCount(@Param("ids") List<Long> ids); Long campaignIdsCount(@Param("ids") List<Long> ids);
void deleteCampaignCustomerListByCampaignIdAndCustomerListIdAndCompanySiteId(Long campaignId, Long customerListId, Long companySiteId);
} }
...@@ -35,4 +35,20 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom ...@@ -35,4 +35,20 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
Long getCustomerRecall(@Param("campaignId") Long campaignId, @Param("customerId") Long customerId); Long getCustomerRecall(@Param("campaignId") Long campaignId, @Param("customerId") Long customerId);
CampaignCustomer findCampaignCustomerByCampaignCustomerId(Long id); CampaignCustomer findCampaignCustomerByCampaignCustomerId(Long id);
@Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " +
"WHERE CC.STATUS = 0 " +
"AND CC.CAMPAIGN_ID = :campaignId " +
"AND CC.COMPANY_SITE_ID = :companySiteId " +
"AND CC.CUSTOMER_LIST_ID = :customerListId", nativeQuery = true)
List<CampaignCustomer> findCustomerNoContact(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId, @Param("customerListId") Long customerListId);
@Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " +
"WHERE CC.STATUS IN (SELECT COMPLETE_VALUE from CAMPAIGN_COMPLETE_CODE where STATUS = 1 and IS_FINISH = 0 and IS_RECALL = 0)" +
"AND CC.CAMPAIGN_ID = :campaignId " +
"AND CC.COMPANY_SITE_ID = :companySiteId " +
"AND CC.CUSTOMER_LIST_ID = :customerListId", nativeQuery = true)
List<CampaignCustomer> findCustomerContacted(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId, @Param("customerListId") Long customerListId);
} }
...@@ -18,14 +18,19 @@ public interface CampaignRepositoryCustom { ...@@ -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>
} }
...@@ -12,5 +12,5 @@ public interface CustomerContactRepository extends JpaRepository<CustomerContact ...@@ -12,5 +12,5 @@ public interface CustomerContactRepository extends JpaRepository<CustomerContact
@Query("FROM CustomerContact WHERE status = 1 AND customerId = :customerId AND contactType = :contactType AND (contact IS NULL OR UPPER(contact) LIKE UPPER(concat('%', :contact, '%')))") @Query("FROM CustomerContact WHERE status = 1 AND customerId = :customerId AND contactType = :contactType AND (contact IS NULL OR UPPER(contact) LIKE UPPER(concat('%', :contact, '%')))")
List<CustomerContact> findByCustomerIdAndAndContactTypeAndContact(@Param("customerId") Long customerId, @Param("contactType") Short contactType, @Param("contact") String contact, Pageable pageable); List<CustomerContact> findByCustomerIdAndAndContactTypeAndContact(@Param("customerId") Long customerId, @Param("contactType") Short contactType, @Param("contact") String contact, Pageable pageable);
CustomerContact findCustomerContactByContactTypeAndContactAndIsDirectLine(Short contactType, String contact, Short isDirectLine); CustomerContact findCustomerContactByContactEquals(String contact);
} }
...@@ -24,4 +24,7 @@ public interface ScenarioAnswerRepository extends JpaRepository<ScenarioAnswer, ...@@ -24,4 +24,7 @@ public interface ScenarioAnswerRepository extends JpaRepository<ScenarioAnswer,
Integer deleteScenarioAnswersByScenarioQuestionId(Long scenarioQuestionId); Integer deleteScenarioAnswersByScenarioQuestionId(Long scenarioQuestionId);
ScenarioAnswer findScenarioAnswerByScenarioAnswerId(Long scenarioAnswerId); ScenarioAnswer findScenarioAnswerByScenarioAnswerId(Long scenarioAnswerId);
@Query(value = "SELECT COUNT(1) FROM ScenarioAnswer WHERE 1 = 1 AND code = :code AND scenarioQuestionId = :scenarioQuestionId AND scenarioAnswerId <> :scenarioAnswerId")
Integer countDuplicateScenarioCode(@Param("code") String code, @Param("scenarioQuestionId") Long scenarioQuestionId, @Param("scenarioAnswerId") Long scenarioAnswerId);
} }
...@@ -9,4 +9,6 @@ import com.viettel.campaign.web.dto.ScenarioQuestionDTO; ...@@ -9,4 +9,6 @@ import com.viettel.campaign.web.dto.ScenarioQuestionDTO;
public interface ScenarioQuestionRepositoryCustom { public interface ScenarioQuestionRepositoryCustom {
Integer countDuplicateQuestionCode(ScenarioQuestionDTO questionDTO); Integer countDuplicateQuestionCode(ScenarioQuestionDTO questionDTO);
Integer countDuplicateOrderIndex(ScenarioQuestionDTO questionDTO);
} }
...@@ -2,7 +2,9 @@ package com.viettel.campaign.repository.ccms_full; ...@@ -2,7 +2,9 @@ package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.model.ccms_full.Scenario; import com.viettel.campaign.model.ccms_full.Scenario;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.data.repository.query.Param;
/** /**
* @author anhvd_itsol * @author anhvd_itsol
...@@ -11,4 +13,7 @@ import org.springframework.stereotype.Repository; ...@@ -11,4 +13,7 @@ import org.springframework.stereotype.Repository;
@Repository @Repository
public interface ScenarioRepository extends JpaRepository<Scenario, Long> { public interface ScenarioRepository extends JpaRepository<Scenario, Long> {
Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId); Scenario findScenarioByCampaignIdAndCompanySiteId(Long campaignId, Long companySiteId);
@Query(value = "SELECT COUNT(1) FROM Scenario WHERE 1 = 1 AND companySiteId = :companySiteId AND code = :code AND scenarioId <> :scenarioId")
Integer countDuplicateScenarioCode(@Param("companySiteId") Long companySiteId, @Param("code") String code, @Param("scenarioId") Long scenarioId);
} }
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.model.ccms_full.UserActionLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* @author hanv_itsol
* @project campaign
*/
@Repository
public interface UserActionLogRepository extends JpaRepository<UserActionLog, Long> {
//
}
...@@ -68,6 +68,61 @@ public class ScenarioQuestionRepositoryImpl implements ScenarioQuestionRepositor ...@@ -68,6 +68,61 @@ public class ScenarioQuestionRepositoryImpl implements ScenarioQuestionRepositor
} }
} catch (Exception ex) { } catch (Exception ex) {
logger.error(ex.getMessage(), ex); logger.error(ex.getMessage(), ex);
} finally {
session.close();
}
return count;
}
@Override
public Integer countDuplicateOrderIndex(ScenarioQuestionDTO questionDTO) {
logger.info("Start search duplicate order index::");
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
Integer count = null;
try {
StringBuilder sb = new StringBuilder();
sb.append("SELECT COUNT(1) FROM SCENARIO_QUESTION WHERE 1 = 1 AND STATUS = 1 ");
if (questionDTO.getScenarioQuestionId() != null) {
sb.append(" AND SCENARIO_QUESTION_ID <> :p_question_id ");
}
if (questionDTO.getOrderIndex() != null) {
sb.append(" AND ORDER_INDEX = :p_orderIndex ");
}
if (questionDTO.getCampaignId() != null) {
sb.append(" AND CAMPAIGN_ID = :p_campaign_id");
}
if (questionDTO.getCompanySiteId() != null) {
sb.append(" AND COMPANY_SITE_ID = :p_site_id");
}
SQLQuery query = session.createSQLQuery(sb.toString());
if (questionDTO.getScenarioQuestionId() != null) {
query.setParameter("p_question_id", questionDTO.getScenarioQuestionId());
}
if (questionDTO.getOrderIndex() != null) {
query.setParameter("p_orderIndex", questionDTO.getOrderIndex());
}
if (questionDTO.getCampaignId() != null) {
query.setParameter("p_campaign_id", questionDTO.getCampaignId());
}
if (questionDTO.getCompanySiteId() != null) {
query.setParameter("p_site_id", questionDTO.getCompanySiteId());
}
final List<BigDecimal> obj = query.list();
for (BigDecimal i : obj) {
if (i != null) {
count = i.intValue();
}
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
} finally {
session.close();
} }
return count; return count;
} }
......
...@@ -56,6 +56,16 @@ public interface CampaignService { ...@@ -56,6 +56,16 @@ 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);
ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto);
ResultDTO saveFieldCustomer(CampaignRequestDTO dto);
//</editor-fold> //</editor-fold>
} }
...@@ -33,7 +33,7 @@ public interface CustomerService { ...@@ -33,7 +33,7 @@ public interface CustomerService {
ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId); ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId);
ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName); CustomerList createCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO); ResultDTO updateCustomerList(CustomerListDTO customerListDTO);
......
...@@ -13,4 +13,6 @@ public interface ScenarioAnswerService { ...@@ -13,4 +13,6 @@ public interface ScenarioAnswerService {
Long getMaxAnswerOrderId(Long scenarioQuestionId, Long companySiteId); Long getMaxAnswerOrderId(Long scenarioQuestionId, Long companySiteId);
ResultDTO delete(ScenarioAnswerDTO scenarioAnswerDTO); ResultDTO delete(ScenarioAnswerDTO scenarioAnswerDTO);
Integer countDuplicateScenarioCode(String code, Long scenarioQuestionId, Long scenarioAnswerId);
} }
...@@ -20,4 +20,6 @@ public interface ScenarioQuestionService { ...@@ -20,4 +20,6 @@ public interface ScenarioQuestionService {
ResultDTO update(ScenarioQuestionDTO scenarioQuestionDTO); ResultDTO update(ScenarioQuestionDTO scenarioQuestionDTO);
Integer countDuplicateOrderIndex(ScenarioQuestionDTO questionDTO);
} }
...@@ -16,5 +16,7 @@ public interface ScenarioService { ...@@ -16,5 +16,7 @@ public interface ScenarioService {
ResultDTO sortQuestionAndAnswer(ScenarioDTO scenarioDTO); ResultDTO sortQuestionAndAnswer(ScenarioDTO scenarioDTO);
Integer countDuplicateScenarioCode(Long companySiteId, String code, Long scenarioId);
ResultDTO saveContacQuestResult(ContactQuestResultDTO dto); ResultDTO saveContacQuestResult(ContactQuestResultDTO dto);
} }
package com.viettel.campaign.service; package com.viettel.campaign.service;
import com.viettel.campaign.model.ccms_full.UserActionLog;
/** /**
* @author anhvd_itsol * @author hanv_itsol
* @project campaign
*/ */
public interface UserActionLogService { public interface UserActionLogService {
void save(UserActionLog log);
} }
...@@ -61,6 +61,15 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -61,6 +61,15 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired @Autowired
ScenarioRepository scenarioRepository; ScenarioRepository scenarioRepository;
@Autowired
CampaignCustomerListRepository campaignCustomerListRepository;
@Autowired
CampaignCustomerRepository campaignCustomerRepository;
@Autowired
CampaignCustomerListColumnRepository campaignCustomerListColumnRepository;
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO search(CampaignRequestDTO requestDto) { public ResultDTO search(CampaignRequestDTO requestDto) {
...@@ -364,14 +373,15 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -364,14 +373,15 @@ public class CampaignServiceImpl implements CampaignService {
return resultDTO; return resultDTO;
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO updateCampaign(CampaignDTO dto) { public ResultDTO updateCampaign(CampaignDTO dto) {
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 +497,122 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -487,6 +497,122 @@ 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;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
String[] lstCusListId = dto.getLstCustomerListId().split(",");
long campaignId = Long.parseLong(dto.getCampaignId());
long companySiteId = Long.parseLong(dto.getCompanySiteId());
try {
for(String cusListId : lstCusListId) {
// Xoa danh sach khach hang khoi campaign_customerList
campaignCustomerListRepository.deleteCampaignCustomerListByCampaignIdAndCustomerListIdAndCompanySiteId(campaignId, Long.parseLong(cusListId), companySiteId);
// Thuc hien xoa cac khach hang chua lien lac tai bang campaign_customer
List<CampaignCustomer> listCampaignCustomer = campaignCustomerRepository.findCustomerNoContact(campaignId, companySiteId, Long.parseLong(cusListId));
for (CampaignCustomer entity : listCampaignCustomer) {
campaignCustomerRepository.delete(entity);
}
// Thuc hien update cac khach hang da lien lac
List<CampaignCustomer> list = campaignCustomerRepository.findCustomerContacted(campaignId, companySiteId, Long.parseLong(cusListId));
for (CampaignCustomer campaignCustomer: list) {
campaignCustomer.setInCampaignStatus((short) 0);
}
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO saveFieldCustomer(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
List<FieldsToShowDTO> list = dto.getLstFiedCustomer();
long campaignId = Long.parseLong(dto.getCampaignId());
long companySiteId = Long.parseLong(dto.getCompanySiteId());
List<CampaignCustomerListColumn> listColumns = campaignCustomerListColumnRepository.findByCampaignIdAndCompanySiteId(campaignId, companySiteId);
try {
// Them moi cac truong hien thi
for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getId() == null) {
CampaignCustomerListColumn entity = new CampaignCustomerListColumn();
entity.setCampaignId(campaignId);
entity.setCompanySiteId(companySiteId);
if (fieldsToShowDTO.getIsFix()) {
entity.setColumnName(fieldsToShowDTO.getColumnName());
} else {
entity.setCustomizeFieldId(fieldsToShowDTO.getCustomizeFieldId());
entity.setCustomizeFieldTitle(fieldsToShowDTO.getColumnTitle());
}
entity.setOrderIndex((long) (list.indexOf(fieldsToShowDTO) + 1));
campaignCustomerListColumnRepository.save(entity);
}
}
// Cap nhat cac truong da co san
for (FieldsToShowDTO fieldsToShowDTO : list) {
if (fieldsToShowDTO.getId() != null) {
listColumns.removeIf(p -> p.getCampaignCusListColId() == fieldsToShowDTO.getId());
CampaignCustomerListColumn entity = campaignCustomerListColumnRepository.findByCampaignCusListColId(fieldsToShowDTO.getId());
entity.setOrderIndex((long) (list.indexOf(fieldsToShowDTO) + 1));
campaignCustomerListColumnRepository.save(entity);
}
}
// Xoa cac truong khong con hien thi nua
for (CampaignCustomerListColumn entity : listColumns) {
campaignCustomerListColumnRepository.delete(entity);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
// hungtt // 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));
......
...@@ -113,4 +113,15 @@ public class ScenarioAnswerServiceImpl implements ScenarioAnswerService { ...@@ -113,4 +113,15 @@ public class ScenarioAnswerServiceImpl implements ScenarioAnswerService {
} }
return resultDTO; return resultDTO;
} }
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Integer countDuplicateScenarioCode(String code, Long scenarioQuestionId, Long scenarioAnswerId) {
try {
return scenarioAnswerRepository.countDuplicateScenarioCode(code, scenarioQuestionId, scenarioAnswerId);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
} }
...@@ -302,4 +302,15 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService { ...@@ -302,4 +302,15 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
return resultDTO; return resultDTO;
} }
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Integer countDuplicateOrderIndex(ScenarioQuestionDTO questionDTO) {
try {
return questionRepositoryCustom.countDuplicateOrderIndex(questionDTO);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
} }
...@@ -117,6 +117,16 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -117,6 +117,16 @@ public class ScenarioServiceImpl implements ScenarioService {
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Integer countDuplicateScenarioCode(Long companySiteId, String code, Long scenarioId) {
try {
return scenarioRepository.countDuplicateScenarioCode(companySiteId, code, scenarioId);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
return null;
}
public ResultDTO saveContacQuestResult(ContactQuestResultDTO dto) { public ResultDTO saveContacQuestResult(ContactQuestResultDTO dto) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
......
package com.viettel.campaign.service.impl; package com.viettel.campaign.service.impl;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.UserActionLog;
import com.viettel.campaign.repository.ccms_full.UserActionLogRepository;
import com.viettel.campaign.service.UserActionLogService; import com.viettel.campaign.service.UserActionLogService;
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;
...@@ -11,4 +15,13 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -11,4 +15,13 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class UserActionLogServiceImpl implements UserActionLogService { public class UserActionLogServiceImpl implements UserActionLogService {
@Autowired
UserActionLogRepository userActionLogRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public void save(UserActionLog log) {
userActionLogRepository.save(log);
}
} }
...@@ -10,7 +10,7 @@ import java.util.Date; ...@@ -10,7 +10,7 @@ import java.util.Date;
@Getter @Getter
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
public class ContactCustResultDTO extends BaseDTO{ public class ContactCustResultDTO extends BaseDTO {
private Long contactCustResultId; private Long contactCustResultId;
private Long companySiteId; private Long companySiteId;
private Short callStatus; private Short callStatus;
......
...@@ -28,4 +28,10 @@ public class CustomerListDTO extends BaseDTO { ...@@ -28,4 +28,10 @@ public class CustomerListDTO extends BaseDTO {
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;
} }
...@@ -13,21 +13,13 @@ import java.io.Serializable; ...@@ -13,21 +13,13 @@ import java.io.Serializable;
@AllArgsConstructor @AllArgsConstructor
public class FieldsToShowDTO implements Serializable { public class FieldsToShowDTO implements Serializable {
// private Long campaignCusListColId; private Long id;
// private Long companySiteId;
// private Long campaignId;
private String columnName; private String columnName;
private String columnTitle; private String columnTitle;
// private Long orderIndex;
// private Long customizeFieldId;
// private String customizeFieldTitle;
private Boolean isFix; private Boolean isFix;
private Long customizeFieldId;
} }
...@@ -2,6 +2,7 @@ package com.viettel.campaign.web.dto.request_dto; ...@@ -2,6 +2,7 @@ package com.viettel.campaign.web.dto.request_dto;
import com.viettel.campaign.web.dto.BaseDTO; import com.viettel.campaign.web.dto.BaseDTO;
import com.viettel.campaign.web.dto.CustomerCustomDTO; import com.viettel.campaign.web.dto.CustomerCustomDTO;
import com.viettel.campaign.web.dto.FieldsToShowDTO;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
package com.viettel.campaign.web.rest; package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.CustomerList;
import com.viettel.campaign.model.ccms_full.CustomizeFieldObject; import com.viettel.campaign.model.ccms_full.CustomizeFieldObject;
import com.viettel.campaign.model.ccms_full.CustomizeFields; import com.viettel.campaign.model.ccms_full.CustomizeFields;
import com.viettel.campaign.service.CustomerService; import com.viettel.campaign.service.CustomerService;
...@@ -103,15 +104,15 @@ public class CustomerController { ...@@ -103,15 +104,15 @@ public class CustomerController {
} }
@PostMapping("/createCustomerList") @PostMapping("/createCustomerList")
@ResponseBody public ResponseEntity<?> createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
ResultDTO result = new ResultDTO();
String xAuthToken = request.getHeader("X-Auth-Token"); String xAuthToken = request.getHeader("X-Auth-Token");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken); UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
result = customerService.createCustomerList(customerListDTO, userSession.getUserName()); CustomerList cl = customerService.createCustomerList(customerListDTO, userSession.getUserName());
return result; if (cl == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(cl, HttpStatus.OK);
} }
@PostMapping("/updateCustomerList") @PostMapping("/updateCustomerList")
...@@ -185,11 +186,11 @@ public class CustomerController { ...@@ -185,11 +186,11 @@ public class CustomerController {
@PostMapping(value = "/importFile") @PostMapping(value = "/importFile")
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file, public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestParam("customerListId") Long customerListId, @RequestParam("customerListId") Long customerListId,
@RequestHeader("X-Auth-Token") String authToken) { HttpServletRequest request) {
LOGGER.info("------------IMPORT FILE TEMPLATE--------------"); LOGGER.info("------------IMPORT FILE TEMPLATE--------------");
Locale locale = new Locale("vi", "VN"); Locale locale = new Locale("vi", "VN");
try { try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(authToken); UserSession userSession = (UserSession) RedisUtil.getInstance().get(request.getHeader("X-Auth-Token"));
if (file.isEmpty()) { if (file.isEmpty()) {
return new ResponseEntity<>(BundleUtils.getLangString("customer.fileNotSelected"), HttpStatus.OK); return new ResponseEntity<>(BundleUtils.getLangString("customer.fileNotSelected"), HttpStatus.OK);
} }
......
...@@ -37,4 +37,10 @@ public class ScenarioAnswerController { ...@@ -37,4 +37,10 @@ public class ScenarioAnswerController {
ResultDTO resultDTO = scenarioAnswerService.delete(answerDTO); ResultDTO resultDTO = scenarioAnswerService.delete(answerDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK); return new ResponseEntity<>(resultDTO, HttpStatus.OK);
} }
@RequestMapping(value = "/count-duplicate-code", method = RequestMethod.GET)
ResponseEntity<Integer> countDuplicateCode(@RequestParam String code, @RequestParam Long scenarioQuestionId, @RequestParam Long scenarioAnswerId) {
Integer count = scenarioAnswerService.countDuplicateScenarioCode(code, scenarioQuestionId, scenarioAnswerId);
return new ResponseEntity<>(count, HttpStatus.OK);
}
} }
...@@ -43,6 +43,12 @@ public class ScenarioController { ...@@ -43,6 +43,12 @@ public class ScenarioController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK); return new ResponseEntity<>(resultDTO, HttpStatus.OK);
} }
@RequestMapping(value = "/count-duplicate-code", method = RequestMethod.GET)
ResponseEntity<Integer> countDuplicateCode(@RequestParam String code, @RequestParam Long scenarioId, @RequestParam Long companySiteId) {
Integer count = scenarioService.countDuplicateScenarioCode(companySiteId, code, scenarioId);
return new ResponseEntity<>(count, HttpStatus.OK);
}
@RequestMapping(value = "/saveContactQuestResult", method = RequestMethod.POST) @RequestMapping(value = "/saveContactQuestResult", method = RequestMethod.POST)
ResponseEntity<ResultDTO> saveContactQuestResult(@RequestBody ContactQuestResultDTO dto) { ResponseEntity<ResultDTO> saveContactQuestResult(@RequestBody ContactQuestResultDTO dto) {
ResultDTO resultDTO = scenarioService.saveContacQuestResult(dto); ResultDTO resultDTO = scenarioService.saveContacQuestResult(dto);
......
...@@ -56,4 +56,9 @@ public class ScenarioQuestionController { ...@@ -56,4 +56,9 @@ public class ScenarioQuestionController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK); return new ResponseEntity<>(resultDTO, HttpStatus.OK);
} }
@RequestMapping(value = "/count-duplicate-order-index", method = RequestMethod.POST)
public Integer countDuplicateOrderIndex(@RequestBody ScenarioQuestionDTO questionDTO) {
return scenarioQuestionService.countDuplicateOrderIndex(questionDTO);
}
} }
server: server:
port: 9999 port: 1111
spring: spring:
application: application:
name: campaign name: campaign
......
...@@ -103,3 +103,8 @@ customer.notLessThan = not less than ...@@ -103,3 +103,8 @@ customer.notLessThan = not less than
customer.importCustomer = IMPORT CUSTOMER customer.importCustomer = IMPORT CUSTOMER
customer.notice = Attention: A record is valid when Full Name is not null and one of three fields Main phone, secondary phone or email is not null customer.notice = Attention: A record is valid when Full Name is not null and one of three fields Main phone, secondary phone or email is not null
customer.fileNotSelected=Please select a file customer.fileNotSelected=Please select a file
customer.emailInvalid=Invalid email;
customer.emailExists=Email exists;
common.fileNotSelected=Please select a file
common.fileInvalidFormat=File invalid
...@@ -105,3 +105,8 @@ customer.notLessThan = không được nhỏ hơn ...@@ -105,3 +105,8 @@ customer.notLessThan = không được nhỏ hơn
customer.importCustomer = IMPORT KHÁCH HÀNG customer.importCustomer = IMPORT KHÁCH HÀNG
customer.notice = Chú ý: 1 bản ghi được coi là hợp lệ bắt buộc phải có thông tin Họ và Tên và 1 trong 3 thông tin liên lạc (số điện thoại chính, số điện thoại phụ hoặc email) customer.notice = Chú ý: 1 bản ghi được coi là hợp lệ bắt buộc phải có thông tin Họ và Tên và 1 trong 3 thông tin liên lạc (số điện thoại chính, số điện thoại phụ hoặc email)
customer.fileNotSelected=Bạn chưa chọn file customer.fileNotSelected=Bạn chưa chọn file
customer.emailInvalid=Email không đúng định dạng;
customer.emailExists=Email đã tồn tại;
common.fileNotSelected=Bạn chưa chọn file
common.fileInvalidFormat=File không hợp lệ
with campaign_customer_id as (
select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl
where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id
),
customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1
group by a.customer_list_id
),
customer_active_table as (
select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'active'
group by a.customer_list_id
),
customer_lock_table as (
select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'locked'
group by a.customer_list_id
),
customer_dnc_table as (
select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.call_allowed = 0
group by a.customer_list_id
),
customer_filter_table as (
select count(a.customer_id) customerFilter, a.customer_list_id customerListId from campaign_customer a
where a.campaign_id = :p_campaign_id
group by a.customer_list_id
),
data_temp as (
select a.customer_list_id customerListId,
a.customer_list_code customerListCode,
a.customer_list_name customerListName,
nvl(b.totalCustomer, 0) totalCusList,
nvl(c.customerActive, 0) totalCusActive,
nvl(d.customerLock, 0) totalCusLock,
nvl(e.customerDnc, 0) totalCusDnc,
nvl(null, 0) totalCusAddRemove,
nvl(f.customerFilter, 0) totalCusFilter
from customer_list a
left join customer_table b on a.customer_list_id = b.customerListId
left join customer_active_table c on a.customer_list_id = c.customerListId
left join customer_lock_table d on a.customer_list_id = d.customerListId
left join customer_dnc_table e on a.customer_list_id = e.customerListId
left join customer_filter_table f on a.customer_list_id = f.customerListId
where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)
),
data as (
select a.*, rownum row_ from data_temp a
),
count_data as (
select count(*) totalRow from data_temp
)
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter, totalRow from data a, count_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)
with campaign_customer_id as (
select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl
where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id
),
customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1
group by a.customer_list_id
),
customer_active_table as (
select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'active'
group by a.customer_list_id
),
customer_lock_table as (
select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.ipcc_status = 'locked'
group by a.customer_list_id
),
customer_dnc_table as (
select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1 and b.call_allowed = 0
group by a.customer_list_id
),
data_temp as (
select a.customer_list_id customerListId,
a.customer_list_code customerListCode,
a.customer_list_name customerListName,
nvl(b.totalCustomer, 0) totalCusList,
nvl(c.customerActive, 0) totalCusActive,
nvl(d.customerLock, 0) totalCusLock,
nvl(e.customerDnc, 0) totalCusDnc,
a.create_at createAt,
a.company_site_id companySiteId,
a.status status
from customer_list a
left join customer_table b on a.customer_list_id = b.customerListId
left join customer_active_table c on a.customer_list_id = c.customerListId
left join customer_lock_table d on a.customer_list_id = d.customerListId
left join customer_dnc_table e on a.customer_list_id = e.customerListId
where a.status = 1
and (:p_cus_list_code is null or upper(a.customer_list_code) like '%'||:p_cus_list_code||'%')
and (:p_cus_list_name is null or upper(a.customer_list_name) like '%'||:p_cus_list_name||'%')
and (a.create_at <= to_date(:p_to_date, 'DD/MM/YYYY'))
and (a.create_at >= to_date(:p_from_date, 'DD/MM/YYYY'))
and (a.company_site_id = :p_company_site_id)
and (a.customer_list_id not in (select CUSTOMER_LIST_ID from campaign_customer_id))
),
data as (
select a.*, rownum row_ from data_temp a
),
count_data as (
select count(*) totalRow from data_temp
)
select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, totalRow from data a, count_data
where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)
with customer_table as ( with campaign_customer_id as (
select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl
where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id
),
customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a 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)
with column_name_temp as ( with column_name_temp as (
select column_name columnName, 1 isFix from user_tab_columns, dual select column_name columnName, null customizeFieldId, 1 isFix from user_tab_columns, dual
where table_name = 'CUSTOMER' where table_name = 'CUSTOMER'
) )
select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null) select * from column_name_temp where columnName not in (select column_name from campaign_customerlist_column where column_name is not null)
union all union all
select title columnName, 0 isFix from customize_fields, dual select title columnName, customize_field_id customizeFieldId, 0 isFix from customize_fields, dual
where function_code = 'CUSTOMER' where function_code = 'CUSTOMER'
and site_id = :p_company_site_id and site_id = :p_company_site_id
and customize_field_id not in (select customize_field_id from campaign_customerlist_column where campaign_customerlist_column.campaign_id = :p_campaign_id) and customize_field_id not in (select customize_field_id from campaign_customerlist_column where campaign_customerlist_column.campaign_id = :p_campaign_id)
select to_char(column_name) columnName, 1 isFix from campaign_customerlist_column, dual where campaign_id = :p_campaign_id and column_name is not null with field_name as (
select a.campaign_cus_list_column_id id, to_char(a.column_name) columnName, a.order_index, a.customize_field_id customizeFieldId, 1 isFix
from campaign_customerlist_column a, dual
where a.campaign_id = :p_campaign_id
and a.company_site_id = :p_company_site_id
and column_name is not null
union all union all
select customize_field_title columnName, 0 isFix from campaign_customerlist_column where campaign_id = :p_campaign_id select a.campaign_cus_list_column_id id, a.customize_field_title columnName, a.order_index, a.customize_field_id customizeFieldId, 0 isFix
from campaign_customerlist_column a
where a.campaign_id = :p_campaign_id
and a.company_site_id = :p_company_site_id
)
select id, columnName, customizeFieldId, isFix from field_name where columnName is not null order by order_index
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment