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 {
// @Scheduled(fixedRate = 5000)
// @Transactional( propagation = Propagation.REQUIRED)
public void process() {
// log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
// List<ProcessConfig> list = processConfigService.findAll();
//
// list.parallelStream().forEach(p -> {
// boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
// switch (p.getConfigCode()){
// case CUSTOMER_INACTIVE_DUARATION:
// if(isExecute){
// List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
// updateCustomer(customers);
// updateCustomerTime(customers);
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date());
// processConfigService.update(p);
// }
// break;
// case CRON_EXPRESSION_CHECK_START:
// // process
// if(isExecute){
// List<Long> status = new ArrayList<>();
// status.add(1L);
// status.add(1L);
// List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
// campaigns.parallelStream().forEach(campaign -> {
// log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
// campaign.setProcessStatus(1);
// campaign.setStatus(2L);
// campaign.setCampaignStart(new Date());
// 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);
// }
// break;
// case CRON_EXPRESSION_CHECK_END:
// // process
// if(isExecute){
// List<Long> status = new ArrayList<>();
// status.add(2L);
// status.add(3L);
// List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
// campaigns.parallelStream().forEach(campaign -> {
// log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
// campaign.setStatus(4L);
// campaign.setCampaignEnd(new Date());
// campaignService.updateProcess(campaign);
// //write log
// saveLog(campaign, 2);
// });
//
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date());
// processConfigService.update(p);
// }
// break;
// default:
// // update last check time
// }
// });
log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
List<ProcessConfig> list = processConfigService.findAll();
list.parallelStream().forEach(p -> {
boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
switch (p.getConfigCode()){
case CUSTOMER_INACTIVE_DUARATION:
if(isExecute){
List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
updateCustomer(customers);
updateCustomerTime(customers);
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
}
break;
case CRON_EXPRESSION_CHECK_START:
// process
if(isExecute){
List<Long> status = new ArrayList<>();
status.add(1L);
status.add(1L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
campaign.setProcessStatus(1);
campaign.setStatus(2L);
campaign.setCampaignStart(new Date());
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);
}
break;
case CRON_EXPRESSION_CHECK_END:
// process
if(isExecute){
List<Long> status = new ArrayList<>();
status.add(2L);
status.add(3L);
List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
campaigns.parallelStream().forEach(campaign -> {
log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
campaign.setStatus(4L);
campaign.setCampaignEnd(new Date());
campaignService.updateProcess(campaign);
//write log
saveLog(campaign, 2);
});
log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
p.setLastProcess(new Date());
processConfigService.update(p);
}
break;
default:
// update last check time
}
});
}
......
......@@ -32,7 +32,7 @@ public class ApParam implements Serializable {
private String parCode;
@Column(name = "DESCRIPTION")
private Long description;
private String description;
@Column(name = "IS_DELETE")
private Long isDelete;
......
......@@ -4,6 +4,7 @@ import com.viettel.campaign.model.ccms_full.ApParam;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.repository.query.Param;
import org.springframework.stereotype.Repository;
......@@ -23,4 +24,12 @@ public interface ApParamRepository extends JpaRepository<ApParam, Long> {
@Query(value = "FROM ApParam WHERE status = 1 AND parType = :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;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
import org.hibernate.type.*;
import org.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.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
......@@ -109,7 +109,6 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
// String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-execute-interactive");
StringBuilder sql = new StringBuilder();
sql.append("with campaign_type_list as (");
......@@ -150,7 +149,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sql.append(" f.complete_name surveyStatus,");
sql.append(" g.status status,");
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(" 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");
......@@ -176,6 +175,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sql.append(" select a.*, rownum row_ from data_temp a");
sql.append(" where a.callTime >= :p_call_time_from");
sql.append(" and a.callTime <= :p_call_time_to");
sql.append(" order by a.createTime desc");
sql.append(" ),");
sql.append(" count_total as (");
sql.append(" select count(*) totalRow from data");
......@@ -196,8 +196,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_call_time_to", dto.getCallTimeTo());
query.setParameter("p_list_campaign_code", dto.getCampaignCode());
query.setParameter("p_phone_number", dto.getPhoneNumber());
query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().toUpperCase());
query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().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().trim().toUpperCase());
query.setParameter("p_page_number", dto.getPage());
query.setParameter("p_page_size", dto.getPageSize());
......@@ -343,8 +343,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_call_time_to", dto.getCallTimeTo());
query.setParameter("p_list_campaign_code", dto.getCampaignCode());
query.setParameter("p_phone_number", dto.getPhoneNumber());
query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().toUpperCase());
query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().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().trim().toUpperCase());
query.setParameter("p_page_number", dto.getPage());
query.setParameter("p_page_size", dto.getPageSize());
......
......@@ -309,7 +309,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"ORDER BY START_TIME DESC");
SQLQuery query = session.createSQLQuery(sb.toString());
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("campaignCode", new StringType());
......@@ -742,8 +742,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", dto.getCompanySiteId());
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_name", DataUtil.isNullOrEmpty(dto.getCustListName()) ? null : dto.getCustListName().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().trim().toUpperCase());
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_page_number", dto.getPage());
......
package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.CampaignCustomerDTO;
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.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
......@@ -36,10 +33,16 @@ public interface CampaignExecuteService {
ResultDTO getCallLog(ReceiveCustLogDTO dto);
ResultDTO getCallStatus(CampaignRequestDTO dto);
ResultDTO getAgentLogout(CampaignRequestDTO dto);
ResultDTO callCustomer(ContactCustResultDTO dto);
ResultDTO recallCustomer(ContactCustResultDTO dto);
ResultDTO callCustomerEnd(ContactCustResultDTO dto);
ResultDTO countRecallCustomer(Long companySiteId, Long agentId);
ResultDTO getCustomerRecall(Long campaignId, Long customerId);
......
......@@ -34,9 +34,11 @@ public interface CustomerService {
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 updateCustomerList(CustomerListDTO customerListDTO);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
......
......@@ -247,7 +247,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
if (agents.getUserStatus() != null && agents.getCampaignSystemStatus() != null) {
if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("AVAILABLE")) {
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0))
data.put("dialModeManual", "1");
}
......@@ -269,7 +269,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
Agents agents = agentsRepository.findByAgentId(requestDto.getAgentId());
//TimeZoneDialMode zoneDialMode = zoneDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
//TimeRangeDialMode rangeDialMode = rangeDialModeRepository.findDialModeAtCurrent(Long.parseLong(requestDto.getCampaignId()), Long.parseLong(requestDto.getCompanySiteId()));
if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) {
if (agents.getUserStatus().equalsIgnoreCase("CALLOUT") && agents.getCampaignSystemStatus().equalsIgnoreCase("LOGOUT")) {
//if (zoneDialMode != null && zoneDialMode.getDialMode().equals(0) || rangeDialMode != null && rangeDialMode.getDialMode().equals(0))
// update acd_full.agents table
Agents a = new Agents();
......@@ -481,6 +481,24 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
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
public ResultDTO getAgentLogout(CampaignRequestDTO dto) {
ResultDTO result = new ResultDTO();
......@@ -519,6 +537,47 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
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
public ResultDTO updateCustomerResult(ContactCustResultDTO dto) {
ResultDTO result = new ResultDTO();
......@@ -564,8 +623,10 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerRecall(Long campaignId, Long customerId) {
Long count = campaignCustomerRepository.getCustomerRecall(campaignId, customerId);
ResultDTO resultDTO = new ResultDTO();
Long count = campaignCustomerRepository.getCustomerRecall(campaignId, customerId);
if (count != null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
......
......@@ -48,6 +48,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -94,6 +95,9 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired
CustomizeFieldOptionValueRepository customizeFieldOptionValueRepository;
@Autowired
ApParamRepository apParamRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId) {
......@@ -600,42 +604,61 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = new CustomerList();
ApParam apParam = apParamRepository.getCustomerListSeq();
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 {
if (customerListDTO != null) {
// insert
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.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else {
CustomerList cl = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (cl != null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
resultDTO.setDescription("Entity exists");
return resultDTO;
} else {
cl = new CustomerList();
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) {
e.printStackTrace();
LOGGER.error(e.getMessage());
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription("Error");
return resultDTO;
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO updateCustomerList(CustomerListDTO customerListDTO) {
public ResultDTO updateCustomerList(CustomerListDTO customerListDTO, String userName) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
try {
if (customerListDTO != null) {
......@@ -643,7 +666,19 @@ public class CustomerServiceImpl implements CustomerService {
CustomerList customerList = customerListRepository.findByCustomerListIdAndCompanySiteId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
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);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
......@@ -738,21 +773,26 @@ public class CustomerServiceImpl implements CustomerService {
StringBuilder sb = new StringBuilder();
sb.append("SELECT");
sb.append(" CUSTOMER_LIST_ID customerListId,");
sb.append(" COMPANY_SITE_ID companySiteId,");
sb.append(" CUSTOMER_LIST_CODE customerListCode,");
sb.append(" CUSTOMER_LIST_NAME customerListName,");
sb.append(" STATUS status,");
sb.append(" CREATE_BY createBy,");
sb.append(" CREATE_AT createAt,");
sb.append(" UPDATE_BY updateBy,");
sb.append(" UPDATE_AT updateAt,");
sb.append(" SOURCE source,");
sb.append(" DEPT_CREATE deptCreate");
sb.append(" FROM CUSTOMER_LIST");
sb.append(" a.CUSTOMER_LIST_ID customerListId,");
sb.append(" a.COMPANY_SITE_ID companySiteId,");
sb.append(" a.CUSTOMER_LIST_CODE customerListCode,");
sb.append(" a.CUSTOMER_LIST_NAME customerListName,");
sb.append(" a.STATUS status,");
sb.append(" a.CREATE_BY createBy,");
sb.append(" a.CREATE_AT createAt,");
sb.append(" a.UPDATE_BY updateBy,");
sb.append(" a.UPDATE_AT updateAt,");
sb.append(" a.SOURCE source,");
sb.append(" a.DEPT_CREATE deptCreate,");
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(" AND STATUS = 1");
sb.append(" AND COMPANY_SITE_ID = :p_company_site_id");
sb.append(" AND a.STATUS = 1");
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')");
......@@ -763,6 +803,8 @@ public class CustomerServiceImpl implements CustomerService {
sb.append(" AND CUSTOMER_LIST_NAME LIKE :p_list_name");
}
sb.append(" ORDER BY CREATE_AT DESC");
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId());
......@@ -798,6 +840,7 @@ public class CustomerServiceImpl implements CustomerService {
query.addScalar("updateAt", new DateType());
query.addScalar("source", new StringType());
query.addScalar("deptCreate", new StringType());
query.addScalar("count", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class));
int count = 0;
......
package com.viettel.campaign.utils;
import com.viettel.security.PassTranformer;
import org.apache.log4j.Logger;
import java.io.File;
......@@ -60,7 +61,7 @@ public class Config {
} catch (IOException ex) {
Logger.getLogger(Config.class.getName()).error(ex.getMessage(), ex);
}
// PassTranformer.setInputKey("Ipcc#987654321#@!");
PassTranformer.setInputKey("Ipcc#987654321#@!");
// rabbitConnection = properties.getProperty("rabbit_connection_string");
// fbGatewayUser = PassTranformer.decrypt(properties.getProperty("rabbit_user", "").trim());
......
......@@ -12,7 +12,7 @@ public class ApParamDTO extends BaseDTO {
private String parName;
private String parValue;
private String parCode;
private Long description;
private String description;
private Long isDelete;
private Long isDefault;
private Long enableEdit;
......
......@@ -41,16 +41,6 @@ public class CampaignController {
@Autowired
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)
public ResponseEntity<ResultDTO> search(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignService.search(requestDto);
......@@ -166,13 +156,6 @@ public class CampaignController {
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")
@ResponseBody
public ResponseEntity getCampaignCustomerList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
......@@ -244,39 +227,4 @@ public class CampaignController {
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;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.web.dto.CampaignCustomerDTO;
import com.viettel.campaign.web.dto.ReceiveCustLogDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
......@@ -67,6 +65,13 @@ public class CampaignExecuteController {
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")
@ResponseBody
public ResponseEntity countRecallCustomer(@RequestParam("companySiteId") Long companySiteId, @RequestParam("agentId") Long agentId) {
......@@ -126,4 +131,32 @@ public class CampaignExecuteController {
ResultDTO result = campaignExecuteService.getCustomerInfor(companySiteId, customerId, campaignId);
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 {
@PostMapping("/createCustomerList")
@ResponseBody
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");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
result = customerService.createCustomerList(customerListDTO, userSession.getUserName());
return result;
if (userSession == null) {
userSession = new UserSession();
userSession.setSiteId(customerListDTO.getCompanySiteId());
userSession.setUserName("its4");
}
return customerService.createCustomerList(customerListDTO, userSession.getUserName());
}
@PostMapping("/updateCustomerList")
@ResponseBody
public ResultDTO updateCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO();
result = customerService.updateCustomerList(customerListDTO);
return result;
public ResultDTO updateCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
String xAuthToken = request.getHeader("X-Auth-Token");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
if (userSession == null) {
userSession = new UserSession();
userSession.setSiteId(customerListDTO.getCompanySiteId());
userSession.setUserName("its4");
}
return customerService.updateCustomerList(customerListDTO, userSession.getUserName());
}
@PostMapping("/deleteCustomerList")
......
server:
port: 9999
port: 1111
spring:
application:
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