Commit 662b775b authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd commi

parents 34f4766e ad5b82a9
[main] 27/08/2019 06:22:09 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
...@@ -42,69 +42,69 @@ public class CampaignJob { ...@@ -42,69 +42,69 @@ public class CampaignJob {
// @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 //write log
// saveLog(campaign, 1); saveLog(campaign, 1);
// }); });
//
// 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_END: case CRON_EXPRESSION_CHECK_END:
// // process // process
// if(isExecute){ if(isExecute){
// List<Long> status = new ArrayList<>(); List<Long> status = new ArrayList<>();
// status.add(2L); status.add(2L);
// status.add(3L); status.add(3L);
// List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status); List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
// campaigns.parallelStream().forEach(campaign -> { campaigns.parallelStream().forEach(campaign -> {
// log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId()); log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
// campaign.setStatus(4L); campaign.setStatus(4L);
// campaign.setCampaignEnd(new Date()); campaign.setCampaignEnd(new Date());
// campaignService.updateProcess(campaign); campaignService.updateProcess(campaign);
// //write log //write log
// saveLog(campaign, 2); saveLog(campaign, 2);
// }); });
//
// 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;
// default: default:
// // update last check time // update last check time
// } }
// }); });
} }
......
...@@ -32,7 +32,7 @@ public class ApParam implements Serializable { ...@@ -32,7 +32,7 @@ public class ApParam implements Serializable {
private String parCode; private String parCode;
@Column(name = "DESCRIPTION") @Column(name = "DESCRIPTION")
private Long description; private String description;
@Column(name = "IS_DELETE") @Column(name = "IS_DELETE")
private Long isDelete; private Long isDelete;
......
...@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.ApParam; ...@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.ApParam;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -23,4 +24,12 @@ public interface ApParamRepository extends JpaRepository<ApParam, Long> { ...@@ -23,4 +24,12 @@ public interface ApParamRepository extends JpaRepository<ApParam, Long> {
@Query(value = "FROM ApParam WHERE status = 1 AND parType = :parType") @Query(value = "FROM ApParam WHERE status = 1 AND parType = :parType")
List<ApParam> findAllParam(@Param("parType") String parType); List<ApParam> findAllParam(@Param("parType") String parType);
// ----------- sql lay so thu tu bang customer list ------------ //
@Query("select a from ApParam a where a.parType = 'CUSTOMER_LIST_SEQ'")
ApParam getCustomerListSeq();
@Modifying
@Query("update ApParam a set a.parValue = :p_par_value, a.description = :p_description where a.parType = 'CUSTOMER_LIST_SEQ'")
int updateCustomerListSeq(@Param("p_par_value") String p_par_value, @Param("p_description") String p_description);
} }
...@@ -7,20 +7,20 @@ import com.viettel.campaign.repository.ccms_full.TimeZoneDialModeRepository; ...@@ -7,20 +7,20 @@ import com.viettel.campaign.repository.ccms_full.TimeZoneDialModeRepository;
import com.viettel.campaign.utils.Constants; import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.DataUtil; import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.HibernateUtil; import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.*; 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.hibernate.SQLQuery; import org.hibernate.SQLQuery;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers; import org.hibernate.transform.Transformers;
import org.hibernate.type.*; import org.hibernate.type.DateType;
import org.hibernate.type.IntegerType;
import org.hibernate.type.LongType;
import org.hibernate.type.StringType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
...@@ -109,7 +109,6 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -109,7 +109,6 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
Session session = sessionFactory.openSession(); Session session = sessionFactory.openSession();
session.beginTransaction(); session.beginTransaction();
try { try {
// String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-execute-interactive");
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql.append("with campaign_type_list as ("); sql.append("with campaign_type_list as (");
...@@ -150,7 +149,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -150,7 +149,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sql.append(" f.complete_name surveyStatus,"); sql.append(" f.complete_name surveyStatus,");
sql.append(" g.status status,"); sql.append(" g.status status,");
sql.append(" a.status recordStatus,"); sql.append(" a.status recordStatus,");
sql.append(" (a.end_time - a.start_call)*24*60 callTime"); sql.append(" nvl((a.end_time - a.start_call)*24*60, 0) callTime");
sql.append(" from contact_cust_result a"); sql.append(" from contact_cust_result a");
sql.append(" left join campaign b on a.campaign_id = b.campaign_id"); sql.append(" left join campaign b on a.campaign_id = b.campaign_id");
sql.append(" left join vsa_users c on a.agent_id = c.user_id"); sql.append(" left join vsa_users c on a.agent_id = c.user_id");
...@@ -176,6 +175,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -176,6 +175,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sql.append(" select a.*, rownum row_ from data_temp a"); sql.append(" select a.*, rownum row_ from data_temp a");
sql.append(" where a.callTime >= :p_call_time_from"); sql.append(" where a.callTime >= :p_call_time_from");
sql.append(" and a.callTime <= :p_call_time_to"); sql.append(" and a.callTime <= :p_call_time_to");
sql.append(" order by a.createTime desc");
sql.append(" ),"); sql.append(" ),");
sql.append(" count_total as ("); sql.append(" count_total as (");
sql.append(" select count(*) totalRow from data"); sql.append(" select count(*) totalRow from data");
...@@ -196,8 +196,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -196,8 +196,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_call_time_to", dto.getCallTimeTo()); query.setParameter("p_call_time_to", dto.getCallTimeTo());
query.setParameter("p_list_campaign_code", dto.getCampaignCode()); query.setParameter("p_list_campaign_code", dto.getCampaignCode());
query.setParameter("p_phone_number", dto.getPhoneNumber()); query.setParameter("p_phone_number", dto.getPhoneNumber());
query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().toUpperCase()); query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().trim().toUpperCase());
query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().toUpperCase()); query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().trim().toUpperCase());
query.setParameter("p_page_number", dto.getPage()); query.setParameter("p_page_number", dto.getPage());
query.setParameter("p_page_size", dto.getPageSize()); query.setParameter("p_page_size", dto.getPageSize());
...@@ -343,8 +343,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -343,8 +343,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_call_time_to", dto.getCallTimeTo()); query.setParameter("p_call_time_to", dto.getCallTimeTo());
query.setParameter("p_list_campaign_code", dto.getCampaignCode()); query.setParameter("p_list_campaign_code", dto.getCampaignCode());
query.setParameter("p_phone_number", dto.getPhoneNumber()); query.setParameter("p_phone_number", dto.getPhoneNumber());
query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().toUpperCase()); query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().trim().toUpperCase());
query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().toUpperCase()); query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().trim().toUpperCase());
query.setParameter("p_page_number", dto.getPage()); query.setParameter("p_page_number", dto.getPage());
query.setParameter("p_page_size", dto.getPageSize()); query.setParameter("p_page_size", dto.getPageSize());
......
...@@ -309,7 +309,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -309,7 +309,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"ORDER BY START_TIME DESC"); "ORDER BY START_TIME DESC");
SQLQuery query = session.createSQLQuery(sb.toString()); SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", requestDto.getCompanySiteId()); query.setParameter("p_company_site_id", requestDto.getCompanySiteId());
query.setParameter("p_code", DataUtil.isNullOrEmpty(requestDto.getCampaignCode()) ? null : requestDto.getCampaignCode().toUpperCase()); query.setParameter("p_code", DataUtil.isNullOrEmpty(requestDto.getCampaignCode()) ? null : requestDto.getCampaignCode().trim().toUpperCase());
query.addScalar("campaignId", new LongType()); query.addScalar("campaignId", new LongType());
query.addScalar("campaignCode", new StringType()); query.addScalar("campaignCode", new StringType());
...@@ -742,8 +742,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -742,8 +742,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
SQLQuery query = session.createSQLQuery(sb.toString()); SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", dto.getCompanySiteId()); query.setParameter("p_company_site_id", dto.getCompanySiteId());
query.setParameter("p_campaign_id", dto.getCampaignId()); query.setParameter("p_campaign_id", dto.getCampaignId());
query.setParameter("p_cus_list_code", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCustListCode().toUpperCase()); query.setParameter("p_cus_list_code", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCustListCode().trim().toUpperCase());
query.setParameter("p_cus_list_name", DataUtil.isNullOrEmpty(dto.getCustListName()) ? null : dto.getCustListName().toUpperCase()); query.setParameter("p_cus_list_name", DataUtil.isNullOrEmpty(dto.getCustListName()) ? null : dto.getCustListName().trim().toUpperCase());
query.setParameter("p_to_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeTo()); query.setParameter("p_to_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeTo());
query.setParameter("p_from_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeFr()); query.setParameter("p_from_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeFr());
query.setParameter("p_page_number", dto.getPage()); query.setParameter("p_page_number", dto.getPage());
......
package com.viettel.campaign.service; package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.CampaignCustomerDTO; import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.ContactCustResultDTO;
import com.viettel.campaign.web.dto.ReceiveCustLogDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO; import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -36,10 +33,16 @@ public interface CampaignExecuteService { ...@@ -36,10 +33,16 @@ public interface CampaignExecuteService {
ResultDTO getCallLog(ReceiveCustLogDTO dto); ResultDTO getCallLog(ReceiveCustLogDTO dto);
ResultDTO getCallStatus(CampaignRequestDTO dto);
ResultDTO getAgentLogout(CampaignRequestDTO dto); ResultDTO getAgentLogout(CampaignRequestDTO dto);
ResultDTO callCustomer(ContactCustResultDTO dto); ResultDTO callCustomer(ContactCustResultDTO dto);
ResultDTO recallCustomer(ContactCustResultDTO dto);
ResultDTO callCustomerEnd(ContactCustResultDTO dto);
ResultDTO countRecallCustomer(Long companySiteId, Long agentId); ResultDTO countRecallCustomer(Long companySiteId, Long agentId);
ResultDTO getCustomerRecall(Long campaignId, Long customerId); ResultDTO getCustomerRecall(Long campaignId, Long customerId);
......
...@@ -34,9 +34,11 @@ public interface CustomerService { ...@@ -34,9 +34,11 @@ public interface CustomerService {
ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId); ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId);
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName); ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO); ResultDTO updateCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO); ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
......
...@@ -481,6 +481,24 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -481,6 +481,24 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
return result; return result;
} }
@Override
public ResultDTO getCallStatus(CampaignRequestDTO dto) {
ResultDTO result = new ResultDTO();
Random r = new Random();
String[] arr = {"ACCEPT", "REJECT", "MISSING"};
if (dto != null) {
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setData(arr[r.nextInt(arr.length)]);
} else {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
return result;
}
@Override @Override
public ResultDTO getAgentLogout(CampaignRequestDTO dto) { public ResultDTO getAgentLogout(CampaignRequestDTO dto) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
...@@ -519,6 +537,47 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -519,6 +537,47 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
return result; return result;
} }
@Override
public ResultDTO recallCustomer(ContactCustResultDTO dto) {
ResultDTO result = new ResultDTO();
try {
ccResultRepository.deleteById(dto.getContactCustResultId());
ContactCustResult ccr = ccResultRepository.save(modelMapper.map(dto, ContactCustResult.class));
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setData(ccr);
} catch (Exception e) {
e.printStackTrace();
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
return result;
}
@Override
public ResultDTO callCustomerEnd(ContactCustResultDTO dto) {
ResultDTO result = new ResultDTO();
ContactCustResult ccr = new ContactCustResult();
try {
ccr = ccResultRepository.getOne(dto.getContactCustResultId());
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setData(ccr);
} catch (Exception e) {
e.printStackTrace();
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
return result;
}
@Override @Override
public ResultDTO updateCustomerResult(ContactCustResultDTO dto) { public ResultDTO updateCustomerResult(ContactCustResultDTO dto) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
...@@ -564,8 +623,10 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -564,8 +623,10 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerRecall(Long campaignId, Long customerId) { public ResultDTO getCustomerRecall(Long campaignId, Long customerId) {
Long count = campaignCustomerRepository.getCustomerRecall(campaignId, customerId);
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
Long count = campaignCustomerRepository.getCustomerRecall(campaignId, customerId);
if (count != null) { if (count != null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
......
...@@ -48,6 +48,7 @@ import java.io.ByteArrayOutputStream; ...@@ -48,6 +48,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -94,6 +95,9 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -94,6 +95,9 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired @Autowired
CustomizeFieldOptionValueRepository customizeFieldOptionValueRepository; CustomizeFieldOptionValueRepository customizeFieldOptionValueRepository;
@Autowired
ApParamRepository apParamRepository;
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId) { public ResultDTO getAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId) {
...@@ -600,42 +604,61 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -600,42 +604,61 @@ public class CustomerServiceImpl implements CustomerService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName) { public ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName) {
ResultDTO resultDTO = new ResultDTO(); ApParam apParam = apParamRepository.getCustomerListSeq();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = new CustomerList(); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date currentDate = new Date(dateFormat.format(new Date()));
Date oldDate = new Date(apParam.getDescription());
Long newDay = (currentDate.getTime() - oldDate.getTime())/(1000*60*60*24);
String convertDate = dateFormat.format(new Date());
String[] dateArray = convertDate.split("/");
if (newDay == 0) {
apParamRepository.updateCustomerListSeq(String.valueOf(Integer.parseInt(apParam.getParValue()) + 1), apParam.getDescription());
customerListDTO.setCustomerListCode(dateArray[0]+dateArray[2]+dateArray[1]+"_"+(Integer.parseInt(apParam.getParValue()) + 1)+" "+customerListDTO.getCustomerListCode());
} else {
apParamRepository.updateCustomerListSeq("1", dateFormat.format(new Date()));
customerListDTO.setCustomerListCode(dateArray[0]+dateArray[2]+dateArray[1]+"_1"+" "+customerListDTO.getCustomerListCode());
}
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
ResultDTO resultDTO = new ResultDTO();
try { try {
if (customerListDTO != null) { CustomerList cl = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
// insert if (cl != null) {
CustomerList findCustomer = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (findCustomer == null) {
customerListDTO.setCreateBy(userName);
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription("Entity exists");
} return resultDTO;
} else { } else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); cl = new CustomerList();
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); cl.setCustomerListCode(customerListDTO.getCustomerListCode());
cl.setCustomerListName(customerListDTO.getCustomerListName());
cl.setStatus((short) 1);
cl.setCreateBy(userName);
cl.setCreateAt(new Date());
cl.setUpdateBy(null);
cl.setUpdateAt(null);
cl.setSource(null);
cl.setDeptCreate(null);
cl.setCompanySiteId(customerListDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(customerListRepository.save(cl));
return resultDTO;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOGGER.error(e.getMessage());
} resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription("Error");
return resultDTO; return resultDTO;
} }
}
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO updateCustomerList(CustomerListDTO customerListDTO) { public ResultDTO updateCustomerList(CustomerListDTO customerListDTO, String userName) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
try { try {
if (customerListDTO != null) { if (customerListDTO != null) {
...@@ -643,7 +666,19 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -643,7 +666,19 @@ public class CustomerServiceImpl implements CustomerService {
CustomerList customerList = customerListRepository.findByCustomerListIdAndCompanySiteId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId()); CustomerList customerList = customerListRepository.findByCustomerListIdAndCompanySiteId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
if (customerList != null) { if (customerList != null) {
customerList = customerListMapper.toPersistenceBean(customerListDTO); customerList.setCreateBy(customerListDTO.getCreateBy());
customerList.setCompanySiteId(customerListDTO.getCompanySiteId());
customerList.setCreateAt(customerListDTO.getCreateAt());
customerList.setCustomerListCode(customerListDTO.getCustomerListCode());
customerList.setCustomerListName(customerListDTO.getCustomerListName());
customerList.setDeptCreate(customerListDTO.getDeptCreate());
customerList.setStatus(customerList.getStatus());
customerList.setUpdateBy(userName);
customerList.setUpdateAt(new Date());
customerList.setSource(customerListDTO.getSource());
customerList.setCustomerListId(customerListDTO.getCustomerListId());
customerListRepository.save(customerList); customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
...@@ -738,21 +773,26 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -738,21 +773,26 @@ 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(" AND CREATE_AT BETWEEN to_date(:p_date_from, 'YYYYMMDD') AND to_date(:p_date_to, 'YYYYMMDD')"); sb.append(" AND CREATE_AT BETWEEN to_date(:p_date_from, 'YYYYMMDD') AND to_date(:p_date_to, 'YYYYMMDD')");
...@@ -763,6 +803,8 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -763,6 +803,8 @@ public class CustomerServiceImpl implements CustomerService {
sb.append(" AND CUSTOMER_LIST_NAME LIKE :p_list_name"); sb.append(" AND CUSTOMER_LIST_NAME LIKE :p_list_name");
} }
sb.append(" ORDER BY CREATE_AT DESC");
SQLQuery query = session.createSQLQuery(sb.toString()); SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId()); query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId());
...@@ -798,6 +840,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -798,6 +840,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.utils; package com.viettel.campaign.utils;
import com.viettel.security.PassTranformer;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.io.File; import java.io.File;
...@@ -60,7 +61,7 @@ public class Config { ...@@ -60,7 +61,7 @@ public class Config {
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(Config.class.getName()).error(ex.getMessage(), ex); Logger.getLogger(Config.class.getName()).error(ex.getMessage(), ex);
} }
// PassTranformer.setInputKey("Ipcc#987654321#@!"); PassTranformer.setInputKey("Ipcc#987654321#@!");
// rabbitConnection = properties.getProperty("rabbit_connection_string"); // rabbitConnection = properties.getProperty("rabbit_connection_string");
// fbGatewayUser = PassTranformer.decrypt(properties.getProperty("rabbit_user", "").trim()); // fbGatewayUser = PassTranformer.decrypt(properties.getProperty("rabbit_user", "").trim());
......
...@@ -12,7 +12,7 @@ public class ApParamDTO extends BaseDTO { ...@@ -12,7 +12,7 @@ public class ApParamDTO extends BaseDTO {
private String parName; private String parName;
private String parValue; private String parValue;
private String parCode; private String parCode;
private Long description; private String description;
private Long isDelete; private Long isDelete;
private Long isDefault; private Long isDefault;
private Long enableEdit; private Long enableEdit;
......
...@@ -41,16 +41,6 @@ public class CampaignController { ...@@ -41,16 +41,6 @@ public class CampaignController {
@Autowired @Autowired
CampaignService campaignService; CampaignService campaignService;
@Autowired
CampaignExecuteService campaignExecuteService;
@PostMapping("/callCustomer")
@ResponseBody
public ResponseEntity<ResultDTO> callCustomer(@RequestBody ContactCustResultDTO requestDto) {
ResultDTO result = campaignExecuteService.callCustomer(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/search", method = RequestMethod.POST) @RequestMapping(value = "/search", method = RequestMethod.POST)
public ResponseEntity<ResultDTO> search(@RequestBody CampaignRequestDTO requestDto) { public ResponseEntity<ResultDTO> search(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignService.search(requestDto); ResultDTO result = campaignService.search(requestDto);
...@@ -166,13 +156,6 @@ public class CampaignController { ...@@ -166,13 +156,6 @@ public class CampaignController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK); return new ResponseEntity<>(resultDTO, HttpStatus.OK);
} }
@GetMapping("/getCustomerRecall")
@ResponseBody
public ResponseEntity getCustomerRecall(@RequestParam("campaignId") Long campaignId, @RequestParam("customerId") Long customerId) {
ResultDTO result = campaignExecuteService.getCustomerRecall(campaignId, customerId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCampaignCustomerList") @PostMapping("/getCampaignCustomerList")
@ResponseBody @ResponseBody
public ResponseEntity getCampaignCustomerList(@RequestBody CampaignRequestDTO campaignRequestDTO) { public ResponseEntity getCampaignCustomerList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
...@@ -244,39 +227,4 @@ public class CampaignController { ...@@ -244,39 +227,4 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping("/getCustomerInfor")
@ResponseBody
public ResponseEntity getCustomerInfor(@RequestParam("companySiteId") Long companySiteId, @RequestParam("customerId") Long customerId, @RequestParam("campaignId") Long campaignId) {
ResultDTO result = campaignExecuteService.getCustomerInfor(companySiteId, customerId, campaignId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/import-file", method = RequestMethod.POST)
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestHeader("X-Auth-Token") String authToken) {
Locale locale = new Locale("vi", "VN");
try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(authToken);
if (file.isEmpty()) {
return new ResponseEntity<>(BundleUtils.getLangString("common.fileNotSelected"), HttpStatus.OK);
}
if (!Objects.equals(FilenameUtils.getExtension(file.getOriginalFilename()), Constants.FileType.xlsx)) {
return new ResponseEntity<>(BundleUtils.getLangString("common.fileInvalidFormat", locale), HttpStatus.OK);
}
//String path = saveUploadFile(file);
// List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
// Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, customerListId);
// File fileExport = (File) map.get("file");
// String message = (String) map.get("message");
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=template_import_customer.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
return new ResponseEntity<>(null, HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
} }
package com.viettel.campaign.web.rest; package com.viettel.campaign.web.rest;
import com.viettel.campaign.service.CampaignExecuteService; import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.web.dto.CampaignCustomerDTO; import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.ReceiveCustLogDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO; import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -67,6 +65,13 @@ public class CampaignExecuteController { ...@@ -67,6 +65,13 @@ public class CampaignExecuteController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@PostMapping("/getCallStatus")
@ResponseBody
public ResponseEntity<ResultDTO> getCallStatus(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignExecuteService.getCallStatus(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/countRecallCustomer") @GetMapping("/countRecallCustomer")
@ResponseBody @ResponseBody
public ResponseEntity countRecallCustomer(@RequestParam("companySiteId") Long companySiteId, @RequestParam("agentId") Long agentId) { public ResponseEntity countRecallCustomer(@RequestParam("companySiteId") Long companySiteId, @RequestParam("agentId") Long agentId) {
...@@ -126,4 +131,32 @@ public class CampaignExecuteController { ...@@ -126,4 +131,32 @@ public class CampaignExecuteController {
ResultDTO result = campaignExecuteService.getCustomerInfor(companySiteId, customerId, campaignId); ResultDTO result = campaignExecuteService.getCustomerInfor(companySiteId, customerId, campaignId);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@PostMapping("/callCustomer")
@ResponseBody
public ResponseEntity<ResultDTO> callCustomer(@RequestBody ContactCustResultDTO requestDto) {
ResultDTO result = campaignExecuteService.callCustomer(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/recallCustomer")
@ResponseBody
public ResponseEntity<ResultDTO> recallCustomer(@RequestBody ContactCustResultDTO requestDto) {
ResultDTO result = campaignExecuteService.recallCustomer(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/callCustomerEnd")
@ResponseBody
public ResponseEntity<ResultDTO> callCustomerEnd(@RequestBody ContactCustResultDTO requestDto) {
ResultDTO result = campaignExecuteService.callCustomerEnd(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/getCustomerRecall")
@ResponseBody
public ResponseEntity getCustomerRecall(@RequestParam("campaignId") Long campaignId, @RequestParam("customerId") Long customerId) {
ResultDTO result = campaignExecuteService.getCustomerRecall(campaignId, customerId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
} }
...@@ -109,21 +109,29 @@ public class CustomerController { ...@@ -109,21 +109,29 @@ public class CustomerController {
@PostMapping("/createCustomerList") @PostMapping("/createCustomerList")
@ResponseBody @ResponseBody
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) { public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
ResultDTO result = new ResultDTO(); // THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
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);
if (userSession == null) {
result = customerService.createCustomerList(customerListDTO, userSession.getUserName()); userSession = new UserSession();
return result; userSession.setSiteId(customerListDTO.getCompanySiteId());
userSession.setUserName("its4");
}
return customerService.createCustomerList(customerListDTO, userSession.getUserName());
} }
@PostMapping("/updateCustomerList") @PostMapping("/updateCustomerList")
@ResponseBody @ResponseBody
public ResultDTO updateCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) { public ResultDTO updateCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
ResultDTO result = new ResultDTO(); String xAuthToken = request.getHeader("X-Auth-Token");
result = customerService.updateCustomerList(customerListDTO); UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
return result; if (userSession == null) {
userSession = new UserSession();
userSession.setSiteId(customerListDTO.getCompanySiteId());
userSession.setUserName("its4");
}
return customerService.updateCustomerList(customerListDTO, userSession.getUserName());
} }
@PostMapping("/deleteCustomerList") @PostMapping("/deleteCustomerList")
......
server: server:
port: 9999 port: 1111
spring: spring:
application: application:
name: campaign name: campaign
......
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