Commit 5e96376d authored by Tu Bach's avatar Tu Bach

Merge branch 'master' of https://git.myitsol.com/hanv/service-campaign

# Conflicts:
#	src/main/java/com/viettel/campaign/repository/CampaignCompleteCodeRepository.java
#	src/main/java/com/viettel/campaign/service/impl/CampaignCompleteCodeServiceImpl.java
parents 34095a7a 9e99b655
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;
public class MavenWrapperDownloader {
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
...@@ -25,13 +25,19 @@ public interface CampaignCompleteCodeRepository extends JpaRepository<CampaignCo ...@@ -25,13 +25,19 @@ public interface CampaignCompleteCodeRepository extends JpaRepository<CampaignCo
List<CampaignCompleteCode> findByCompleteNameContains(String name, Pageable pageable); List<CampaignCompleteCode> findByCompleteNameContains(String name, Pageable pageable);
@Modifying @Modifying
@Query("delete from CampaignCompleteCode c where c.campaignCompleteCodeId in (:ids)") @Query("update CampaignCompleteCode c set c.status = 0 where c.campaignCompleteCodeId in (:ids)")
int deleteds(@Param("ids") List<Long> ids); int deleteds(@Param("ids") List<Long> ids);
// @Query(value="SELECT max(completeValue) FROM CampaignCompleteCode WHERE companySiteId = :companySiteId GROUP BY companySiteId") // @Query(value="SELECT max(completeValue) FROM CampaignCompleteCode WHERE companySiteId = :companySiteId GROUP BY companySiteId")
// Short findByMaxCompanySiteId(Long companySiteId); // Short findByMaxCompanySiteId(Long companySiteId);
List<CampaignCompleteCode> findCampaignCompleteCodesByCompanySiteId(Long companySiteId); List<CampaignCompleteCode> findCampaignCompleteCodesByCompanySiteId(Long companySiteId);
@Query(value="SELECT max(completeValue) FROM CampaignCompleteCode WHERE companySiteId = :companySiteId GROUP BY companySiteId")
Short findByMaxCompanySiteId(Long companySiteId);
// List<CampaignCompleteCode> findCampaignCompleteCodesByCompanySiteId(Long companySiteId);
// List<CampaignCompleteCode> findByCampaignIdContainsAndChanel(Long campaignId, String chanel); // List<CampaignCompleteCode> findByCampaignIdContainsAndChanel(Long campaignId, String chanel);
@Query(value = "FROM CampaignCompleteCode WHERE status = 1 AND completeValue = :completeValue AND completeType = :completeType AND companySiteId = :companySiteId") @Query(value = "FROM CampaignCompleteCode WHERE status = 1 AND completeValue = :completeValue AND completeType = :completeType AND companySiteId = :companySiteId")
......
...@@ -8,4 +8,5 @@ public interface CampaignCompleteCodeRepositoryCustom { ...@@ -8,4 +8,5 @@ public interface CampaignCompleteCodeRepositoryCustom {
// CampaignCompleteCode findMaxValueCampaignType(Long companySiteId); // CampaignCompleteCode findMaxValueCampaignType(Long companySiteId);
} }
package com.viettel.campaign.repository; package com.viettel.campaign.repository;
import com.viettel.campaign.model.CustomerList; import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.web.dto.ResultDTO;
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.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
...@@ -21,4 +22,7 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long ...@@ -21,4 +22,7 @@ public interface CustomerListRepository extends JpaRepository<CustomerList, Long
@Modifying @Modifying
@Query("update CustomerList c set c.status = 0 where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id") @Query("update CustomerList c set c.status = 0 where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id")
int deleteCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id); int deleteCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
@Query(value = "SELECT * FROM (SELECT *, MAX(CREATE_AT) OVER() AS LATEST_CREATED FROM CUSTOMER_LIST) WHERE CREATE_AT = LATEST_CREATED", nativeQuery = true)
CustomerList latestCreated();
} }
...@@ -43,12 +43,11 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -43,12 +43,11 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
public List<ApParamDTO> getComboBoxStatus(String companySiteId, String completeType) { public List<ApParamDTO> getComboBoxStatus(String companySiteId, String completeType) {
List<ApParamDTO> list = new ArrayList<>(); List<ApParamDTO> list = new ArrayList<>();
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-combo-connect-status"); String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-combo-status");
try { try {
params.put("p_company_site_id", companySiteId); params.put("p_company_site_id", companySiteId);
params.put("p_complete_type", completeType); params.put("p_complete_type", completeType);
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(ApParamDTO.class)); list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(ApParamDTO.class));
// list = namedParameterJdbcTemplate.getJdbcTemplate().query(sql, (PreparedStatementSetter) params, BeanPropertyRowMapper.newInstance(ComboBoxDTO.class));
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} }
...@@ -82,37 +81,69 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -82,37 +81,69 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-execute-interactive"); String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-execute-interactive");
sqlBuilder.append(sql); sqlBuilder.append(sql);
sqlBuilder.append(" and to_char(a.customer_id) like :p_customer_id");
sqlBuilder.append(" and to_char(a.contact_status) in (:p_list_contact_status)");
sqlBuilder.append(" and to_char(a.call_status) in (:p_list_survey_status)");
sqlBuilder.append(" and to_char(a.status) in (:p_list_record_status)");
if (!DataUtil.isNullOrEmpty(dto.getPhoneNumber())) {
sqlBuilder.append(" and a.phone_number like :p_phone_number");
}
if (!DataUtil.isNullOrEmpty(dto.getCampaignId())) {
sqlBuilder.append(" and b.campaign_code in (:p_list_campaign_id) ");
}
if (!DataUtil.isNullOrEmpty(dto.getCampaignName())) { if (!DataUtil.isNullOrEmpty(dto.getCampaignName())) {
sqlBuilder.append(" and upper(campaignName) like upper(:p_campaign_name)"); sqlBuilder.append(" and upper(b.campaign_name) like :p_campaign_name");
} }
if (!DataUtil.isNullOrEmpty(dto.getAgentId())) { if (!DataUtil.isNullOrEmpty(dto.getAgentId())) {
sqlBuilder.append(" and upper(userName) like upper(:p_user_name)"); sqlBuilder.append(" and upper(c.user_name) like :p_user_name");
} }
SQLQuery query = session.createSQLQuery(sqlBuilder.toString()); SQLQuery query = session.createSQLQuery(sqlBuilder.toString());
query.setParameterList("p_list_campaign_id", dto.getCampaignId().split(",")); query.setParameter("p_company_site_id", dto.getCompanySiteId());
query.setParameter("p_customer_id", dto.getCustomerId()); query.setParameter("p_customer_id", "%" + dto.getCustomerId()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
query.setParameter("p_date_from", dto.getFromDate()); query.setParameter("p_date_from", dto.getFromDate());
query.setParameter("p_date_to", dto.getToDate()); query.setParameter("p_date_to", dto.getToDate());
query.setParameterList("p_list_contact_status", dto.getContactStatus().split(",")); query.setParameterList("p_list_contact_status", dto.getContactStatus().split(","));
query.setParameterList("p_list_survey_status", dto.getSurveyStatus().split(",")); query.setParameterList("p_list_survey_status", dto.getSurveyStatus().split(","));
query.setParameterList("p_list_record_status", dto.getRecordStatus().split(",")); query.setParameterList("p_list_record_status", dto.getRecordStatus().split(","));
query.setParameter("p_phone_number", dto.getPhoneNumber());
query.setParameter("p_call_time_from", dto.getCallTimeFrom()); query.setParameter("p_call_time_from", dto.getCallTimeFrom());
query.setParameter("p_call_time_to", dto.getCallTimeTo()); query.setParameter("p_call_time_to", dto.getCallTimeTo());
if (!DataUtil.isNullOrEmpty(dto.getCampaignId())) {
query.setParameterList("p_list_campaign_id", dto.getCampaignId().split(","));
}
if (!DataUtil.isNullOrEmpty(dto.getPhoneNumber())) {
query.setParameter("p_phone_number", "%" + dto.getPhoneNumber()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(dto.getCampaignName())) { if (!DataUtil.isNullOrEmpty(dto.getCampaignName())) {
query.setParameter("p_campaign_name", dto.getCampaignName().trim()); query.setParameter("p_campaign_name", "%" + dto.getCampaignName().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
} }
if (!DataUtil.isNullOrEmpty(dto.getAgentId())) { if (!DataUtil.isNullOrEmpty(dto.getAgentId())) {
query.setParameter("p_user_name", dto.getAgentId().trim()); query.setParameter("p_user_name", "%" + dto.getAgentId().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
} }
query.addScalar("campaignCode", new StringType()); query.addScalar("campaignCode", new StringType());
query.addScalar("campaignName", new StringType()); query.addScalar("campaignName", new StringType());
query.addScalar("userName", new StringType()); query.addScalar("userName", new StringType());
query.addScalar("phoneNumber", new LongType()); query.addScalar("phoneNumber", new StringType());
query.addScalar("customerName", new StringType()); query.addScalar("customerName", new StringType());
query.addScalar("createTime", new DateType()); query.addScalar("createTime", new DateType());
query.addScalar("contactStatus", new StringType()); query.addScalar("contactStatus", new StringType());
...@@ -156,8 +187,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -156,8 +187,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} finally { } finally {
session.close(); session.close();
return resultDTO;
} }
return resultDTO;
} }
@Override @Override
...@@ -172,37 +203,69 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -172,37 +203,69 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-execute-interactive"); String sql = SQLBuilder.getSqlQueryById(Constants.SQL_MODULES.MODULE_EXECUTE, "get-execute-interactive");
sqlBuilder.append(sql); sqlBuilder.append(sql);
sqlBuilder.append(" and to_char(a.customer_id) like :p_customer_id");
sqlBuilder.append(" and to_char(a.contact_status) in (:p_list_contact_status)");
sqlBuilder.append(" and to_char(a.call_status) in (:p_list_survey_status)");
sqlBuilder.append(" and to_char(a.status) in (:p_list_record_status)");
if (!DataUtil.isNullOrEmpty(dto.getPhoneNumber())) {
sqlBuilder.append(" and a.phone_number like :p_phone_number");
}
if (!DataUtil.isNullOrEmpty(dto.getCampaignId())) {
sqlBuilder.append(" and b.campaign_code in (:p_list_campaign_id) ");
}
if (!DataUtil.isNullOrEmpty(dto.getCampaignName())) { if (!DataUtil.isNullOrEmpty(dto.getCampaignName())) {
sqlBuilder.append(" and upper(campaignName) like upper(:p_campaign_name)"); sqlBuilder.append(" and upper(b.campaign_name) like :p_campaign_name");
} }
if (!DataUtil.isNullOrEmpty(dto.getAgentId())) { if (!DataUtil.isNullOrEmpty(dto.getAgentId())) {
sqlBuilder.append(" and upper(userName) like upper(:p_user_name)"); sqlBuilder.append(" and upper(c.user_name) like :p_user_name");
} }
SQLQuery query = session.createSQLQuery(sqlBuilder.toString()); SQLQuery query = session.createSQLQuery(sqlBuilder.toString());
query.setParameterList("p_list_campaign_id", dto.getCampaignId().split(",")); query.setParameter("p_company_site_id", dto.getCompanySiteId());
query.setParameter("p_customer_id", dto.getCustomerId()); query.setParameter("p_customer_id", "%" + dto.getCustomerId()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
query.setParameter("p_date_from", dto.getFromDate()); query.setParameter("p_date_from", dto.getFromDate());
query.setParameter("p_date_to", dto.getToDate()); query.setParameter("p_date_to", dto.getToDate());
query.setParameterList("p_list_contact_status", dto.getContactStatus().split(",")); query.setParameterList("p_list_contact_status", dto.getContactStatus().split(","));
query.setParameterList("p_list_survey_status", dto.getSurveyStatus().split(",")); query.setParameterList("p_list_survey_status", dto.getSurveyStatus().split(","));
query.setParameterList("p_list_record_status", dto.getRecordStatus().split(",")); query.setParameterList("p_list_record_status", dto.getRecordStatus().split(","));
query.setParameter("p_phone_number", dto.getPhoneNumber());
query.setParameter("p_call_time_from", dto.getCallTimeFrom()); query.setParameter("p_call_time_from", dto.getCallTimeFrom());
query.setParameter("p_call_time_to", dto.getCallTimeTo()); query.setParameter("p_call_time_to", dto.getCallTimeTo());
if (!DataUtil.isNullOrEmpty(dto.getCampaignId())) {
query.setParameterList("p_list_campaign_id", dto.getCampaignId().split(","));
}
if (!DataUtil.isNullOrEmpty(dto.getPhoneNumber())) {
query.setParameter("p_phone_number", "%" + dto.getPhoneNumber()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(dto.getCampaignName())) { if (!DataUtil.isNullOrEmpty(dto.getCampaignName())) {
query.setParameter("p_campaign_name", dto.getCampaignName().trim()); query.setParameter("p_campaign_name", "%" + dto.getCampaignName().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
} }
if (!DataUtil.isNullOrEmpty(dto.getAgentId())) { if (!DataUtil.isNullOrEmpty(dto.getAgentId())) {
query.setParameter("p_user_name", dto.getAgentId().trim()); query.setParameter("p_user_name", "%" + dto.getAgentId().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
} }
query.addScalar("campaignCode", new StringType()); query.addScalar("campaignCode", new StringType());
query.addScalar("campaignName", new StringType()); query.addScalar("campaignName", new StringType());
query.addScalar("userName", new StringType()); query.addScalar("userName", new StringType());
query.addScalar("phoneNumber", new LongType()); query.addScalar("phoneNumber", new StringType());
query.addScalar("customerName", new StringType()); query.addScalar("customerName", new StringType());
query.addScalar("createTime", new DateType()); query.addScalar("createTime", new DateType());
query.addScalar("contactStatus", new StringType()); query.addScalar("contactStatus", new StringType());
......
package com.viettel.campaign.service; package com.viettel.campaign.service;
import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.web.dto.CustomerContactDTO; import com.viettel.campaign.web.dto.CustomerContactDTO;
import com.viettel.campaign.web.dto.CustomerDTO; import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO; import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
public interface CustomerService { public interface CustomerService {
...@@ -35,10 +36,17 @@ public interface CustomerService { ...@@ -35,10 +36,17 @@ public interface CustomerService {
ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO); ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO);
CustomerList getLatestCreated();
// ------------ customer contact ------------ // // ------------ customer contact ------------ //
ResultDTO getCustomerContact(CustomerContactDTO customer); ResultDTO getCustomerContact(CustomerContactDTO customer);
// danh sach khach hang cua chien dich //
ResultDTO searchCustomerListInfoFromCustomerList(int page, int pageSize, String sort, Long campaignId, Long companySiteId);
// ------------ customer ------------ // // ------------ customer ------------ //
ResultDTO getCustomerRecall(Long campaignId, Long customerId); ResultDTO getCustomerRecall(Long campaignId, Long customerId);
......
...@@ -5,8 +5,17 @@ import com.viettel.campaign.model.CampaignCompleteCode; ...@@ -5,8 +5,17 @@ import com.viettel.campaign.model.CampaignCompleteCode;
import com.viettel.campaign.repository.CampaignCompleteCodeRepository; import com.viettel.campaign.repository.CampaignCompleteCodeRepository;
import com.viettel.campaign.service.CampaignCompleteCodeService; import com.viettel.campaign.service.CampaignCompleteCodeService;
import com.viettel.campaign.utils.Constants; 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.CampaignCompleteCodeDTO; import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.transform.Transformers;
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;
...@@ -163,28 +172,83 @@ public class CampaignCompleteCodeServiceImpl implements CampaignCompleteCodeServ ...@@ -163,28 +172,83 @@ public class CampaignCompleteCodeServiceImpl implements CampaignCompleteCodeServ
return result; return result;
} }
// @Override
// public ResultDTO findMaxValueCampaignCompleteCode(CampaignCompleteCodeDTO completeCodeDTO) {
// ResultDTO resultDTO = new ResultDTO();
// CampaignCompleteCodeMapper campaignCompleteCodeMapper = new CampaignCompleteCodeMapper();
// try {
// short maxValue = 0;
//// List<CampaignCompleteCode> list = completeCodeRepository.findCampaignCompleteCodesByCompanySiteId(completeCodeDTO.getCompanySiteId());
//// for (int i = 0; i<list.size();i++) {
//// if (list.get(i).getCompleteValue() != null && !list.get(i).getCompleteValue().equals("")) {
//// if (maxValue < Short.parseShort(list.get(i).getCompleteValue())) {
//// maxValue = Short.parseShort(list.get(i).getCompleteValue());
//// }
//// }
//// }
// maxValue = completeCodeRepository.findByMaxCompanySiteId(completeCodeDTO.getCompanySiteId());
// if (maxValue < 4) {
// maxValue = 4;
// }
// maxValue+= 1;
// resultDTO.setData(maxValue);
// resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
// resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
// } catch (Exception e) {
// resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
// resultDTO.setDescription(e.getMessage());
// logger.error(e.getMessage(), e);
// }
// return resultDTO;
// }
@Override @Override
public ResultDTO findMaxValueCampaignCompleteCode(CampaignCompleteCodeDTO completeCodeDTO) { public ResultDTO findMaxValueCampaignCompleteCode(CampaignCompleteCodeDTO completeCodeDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
if (DataUtil.isNullOrZero(completeCodeDTO.getCompanySiteId())) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
try { try {
short maxValue = 0; StringBuilder sqlStrBuilder = new StringBuilder();
List<CampaignCompleteCode> list = completeCodeRepository.findCampaignCompleteCodesByCompanySiteId(completeCodeDTO.getCompanySiteId()); sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_STATUS_MNG, "get-max-value-completevalue"));
for (int i = 0; i<list.size();i++) {
if (list.get(i).getCompleteValue() != null && !list.get(i).getCompleteValue().equals("")) { SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
if (maxValue < Short.parseShort(list.get(i).getCompleteValue())) { query.setParameter("p_site_id", completeCodeDTO.getCompanySiteId());
maxValue = Short.parseShort(list.get(i).getCompleteValue());
} query.addScalar("completeValue", new StringType());
query.addScalar("companySiteId", new LongType());
query.setResultTransformer(Transformers.aliasToBean(CampaignCompleteCodeDTO.class));
List<CampaignCompleteCodeDTO> data = query.list();
if (data != null && data.size() > 0) {
int tmp = 4;
String completeValue = data.get(0).getCompleteValue();
if (completeValue != null && !completeValue.trim().equals("")) {
tmp = Integer.parseInt(completeValue) + 1;
} }
resultDTO.setData(tmp);
} else {
resultDTO.setData(null);
} }
maxValue+= 1;
resultDTO.setData(maxValue);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) { } catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(e.getMessage()); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
logger.error(e.getMessage(), e);
} finally {
session.close();
return resultDTO;
} }
return resultDTO;
} }
@Override @Override
...@@ -241,4 +305,5 @@ public class CampaignCompleteCodeServiceImpl implements CampaignCompleteCodeServ ...@@ -241,4 +305,5 @@ public class CampaignCompleteCodeServiceImpl implements CampaignCompleteCodeServ
// result.setErrorCode("0"); // result.setErrorCode("0");
// return result; // return result;
// } // }
} }
...@@ -157,9 +157,15 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -157,9 +157,15 @@ public class CustomerServiceImpl implements CustomerService {
StringBuilder sqlStrBuilder = new StringBuilder(); StringBuilder sqlStrBuilder = new StringBuilder();
sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params")); sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params"));
sqlStrBuilder.append(" AND "); if (!DataUtil.isNullOrEmpty(name)) {
sqlStrBuilder.append(" ORDER BY name DESC"); sqlStrBuilder.append(" AND b.NAME LIKE :p_name");
sqlStrBuilder.append(" ORDER BY name DESC"); }
if (!DataUtil.isNullOrEmpty(mobileNumber)) {
sqlStrBuilder.append(" AND c.MOBILE LIKE :p_mobile_number");
}
if (!DataUtil.isNullOrEmpty(email)) {
sqlStrBuilder.append(" AND d.EMAIL LIKE :p_email");
}
sqlStrBuilder.append(" ORDER BY name DESC"); sqlStrBuilder.append(" ORDER BY name DESC");
SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString()); SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
...@@ -167,6 +173,30 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -167,6 +173,30 @@ public class CustomerServiceImpl implements CustomerService {
query.setParameter("p_company_site_id", companySiteId); query.setParameter("p_company_site_id", companySiteId);
query.setParameter("p_customer_list_id", customerListId); query.setParameter("p_customer_list_id", customerListId);
if (!DataUtil.isNullOrEmpty(name)) {
query.setParameter("p_name", "%" +
name.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(mobileNumber)) {
query.setParameter("p_mobile_number", "%" +
mobileNumber.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
if (!DataUtil.isNullOrEmpty(email)) {
query.setParameter("p_email", "%" +
email.replace("\\", "\\\\")
.replaceAll("%", "\\%")
.replaceAll("_", "\\_")
+ "%");
}
query.addScalar("customerListMappingId", new LongType()); query.addScalar("customerListMappingId", new LongType());
query.addScalar("companySiteId", new LongType()); query.addScalar("companySiteId", new LongType());
query.addScalar("customerListId", new LongType()); query.addScalar("customerListId", new LongType());
...@@ -571,6 +601,11 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -571,6 +601,11 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO; return resultDTO;
} }
@Override
public CustomerList getLatestCreated() {
return customerListRepository.latestCreated();
}
@Override @Override
public ResultDTO getCustomerContact(CustomerContactDTO customer) { public ResultDTO getCustomerContact(CustomerContactDTO customer) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
...@@ -615,4 +650,22 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -615,4 +650,22 @@ public class CustomerServiceImpl implements CustomerService {
} }
return result; return result;
} }
@Override
public ResultDTO searchCustomerListInfoFromCustomerList(int page, int pageSize, String sort, Long campaignId, Long companySiteId) {
ResultDTO resultDTO = new ResultDTO();
try {
String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-customer-list-info-from-customer-list");
Query query = entityManager.createNativeQuery(sql);
query.setParameter("p_campaign_id", campaignId);
query.setParameter("p_company_site_id", companySiteId);
resultDTO.setListData(query.getResultList());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(e.getMessage());
}
return resultDTO;
}
} }
...@@ -23,7 +23,7 @@ public class ContactCustResultDTO extends BaseDTO{ ...@@ -23,7 +23,7 @@ public class ContactCustResultDTO extends BaseDTO{
private Long agentId; private Long agentId;
private Long campaignId; private Long campaignId;
private String campaignName; private String campaignName;
private Long phoneNumber; private String phoneNumber;
private String customerName; private String customerName;
private Long customerId; private Long customerId;
private String contactStatus; private String contactStatus;
......
...@@ -61,6 +61,7 @@ public class CampaignCompleteCodeController { ...@@ -61,6 +61,7 @@ public class CampaignCompleteCodeController {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
try { try {
result = completeCodeService.updateCompleteCode(completeCodeDTO); result = completeCodeService.updateCompleteCode(completeCodeDTO);
} catch (Exception e) { } catch (Exception e) {
result.setErrorCode("-1"); result.setErrorCode("-1");
LOGGER.error(e); LOGGER.error(e);
...@@ -94,7 +95,7 @@ public class CampaignCompleteCodeController { ...@@ -94,7 +95,7 @@ public class CampaignCompleteCodeController {
@PostMapping("/getMaxValue") @PostMapping("/getMaxValue")
@ResponseBody @ResponseBody
public ResultDTO findMaxValueCampaignType(@RequestBody CampaignCompleteCodeDTO completeCodeDTO){ public ResultDTO findMaxValueCampaignType(@RequestBody CampaignCompleteCodeDTO completeCodeDTO){
return completeCodeService.findMaxValueCampaignCompleteCode(completeCodeDTO); return completeCodeService.findMaxValueCampaignCompleteCode(completeCodeDTO);
} }
@GetMapping("/getListStatus") @GetMapping("/getListStatus")
......
...@@ -164,6 +164,14 @@ public class CustomerController { ...@@ -164,6 +164,14 @@ public class CustomerController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping("/latestCreated")
@ResponseBody
public ResponseEntity getLatestCreated() {
ResultDTO result = new ResultDTO();
result.setData(customerService.getLatestCreated());
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/findCustomerContact") @PostMapping("/findCustomerContact")
@ResponseBody @ResponseBody
public ResponseEntity<ResultDTO> findAllCustomerContact(@RequestBody CustomerContactDTO customerContactDTO) { public ResponseEntity<ResultDTO> findAllCustomerContact(@RequestBody CustomerContactDTO customerContactDTO) {
...@@ -233,4 +241,13 @@ public class CustomerController { ...@@ -233,4 +241,13 @@ public class CustomerController {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
} }
} }
@RequestMapping(value = "/searchCustomerListInfoFromCustomerList", method = RequestMethod.GET)
public ResultDTO searchCustomerListInfoFromCustomerList(@RequestParam("page") int page,
@RequestParam("pageSize") int pageSize,
@RequestParam("sort") String sort,
@RequestParam("campaignId") Long campaignId,
@RequestParam("companySiteId") Long companySiteId) {
return customerService.searchCustomerListInfoFromCustomerList(page, pageSize, sort, campaignId, companySiteId);
}
} }
#Common #Common
detail = Chi ti?t detail = Detail
stt = STT stt = No
#Campaign Execute Interactive #Campaign Execute Interactive
campaign.execute.interactive.title = Chi ti?t k?t qu? t??ng tc campaign.execute.interactive.title = Chi tiết kết quả tương tác
campaign.execute.interactive.campaignCode = M chi?n d?ch campaign.execute.interactive.campaignCode = Campaign code
campaign.execute.interactive.campaignName = Tn chi?n d?ch campaign.execute.interactive.campaignName = Campaign name
campaign.execute.interactive.agentId = M t? v?n vin campaign.execute.interactive.agentId = Agent id
campaign.execute.interactive.phoneNumber = S? ?i?n tho?i campaign.execute.interactive.phoneNumber = Phone number
campaign.execute.interactive.customerId = M khch hng campaign.execute.interactive.customerId = Customer id
campaign.execute.interactive.customerName = Tn khch hng campaign.execute.interactive.customerName = Customer name
campaign.execute.interactive.callTime = Th?i gian lin l?c campaign.execute.interactive.createTime = Create time
campaign.execute.interactive.contactStatus = Tr?ng thi k?t n?i campaign.execute.interactive.contactStatus = Contact status
campaign.execute.interactive.surveyStatus = Tr?ng thi kh?o st campaign.execute.interactive.surveyStatus = Trạng thái khảo sát
campaign.execute.interactive.status = Tr?ng thi chi?n d?ch campaign.execute.interactive.status = Trạng thái chiến dịch
campaign.execute.interactive.recordStatus = Tr?ng thi b?n ghi campaign.execute.interactive.recordStatus = Trạng thái bản ghi
select AP_PARAM_ID apParamId, select PAR_VALUE apParamId,
PAR_NAME parName PAR_NAME parName
from AP_PARAM from AP_PARAM
where PAR_TYPE = 'CAMPAIGN_TYPE' and COMPANY_SITE_ID = :p_company_site_id where PAR_TYPE = 'CAMPAIGN_TYPE' and COMPANY_SITE_ID = :p_company_site_id
...@@ -14,15 +14,10 @@ from contact_cust_result a ...@@ -14,15 +14,10 @@ from contact_cust_result a
left join customer d on a.customer_id = d.customer_id left join customer d on a.customer_id = d.customer_id
left join campaign_complete_code e on a.contact_status = e.complete_value left join campaign_complete_code e on a.contact_status = e.complete_value
left join campaign_complete_code f on a.call_status = e.complete_value left join campaign_complete_code f on a.call_status = e.complete_value
left join campaign g on a.campaign_id = b.campaign_id left join campaign g on a.campaign_id = g.campaign_id
where a.status <> 0 where a.status <> 0
and a.campaign_id in (:p_list_campaign_id) and a.company_site_id = :p_company_site_id
and a.customer_id like '%'||:p_customer_id||'%'
and a.create_time >= to_date(:p_date_from, 'DD/MM/YYYY') and a.create_time >= to_date(:p_date_from, 'DD/MM/YYYY')
and a.create_time <= to_date(:p_date_to, 'DD/MM/YYYY') and a.create_time <= to_date(:p_date_to, 'DD/MM/YYYY')
and a.contact_status in (:p_list_contact_status)
and a.call_status in (:p_list_survey_status)
and a.status in (:p_list_record_status)
and a.phone_number like '%'||:p_phone_number||'%'
and a.duration_call >= :p_call_time_from and a.duration_call >= :p_call_time_from
and a.duration_call <= :p_call_time_to and a.duration_call <= :p_call_time_to
...@@ -12,4 +12,5 @@ SELECT ...@@ -12,4 +12,5 @@ SELECT
DEPT_CREATE deptCreate DEPT_CREATE deptCreate
FROM CUSTOMER_LIST FROM CUSTOMER_LIST
WHERE 1 = 1 WHERE 1 = 1
AND STATUS = 1
AND COMPANY_SITE_ID = :p_company_site_id AND COMPANY_SITE_ID = :p_company_site_id
with totalCustomer as (
select clm.customer_list_id,
clm.company_site_id,
count(clm.customer_id) total
from customer_list_mapping clm
inner join customer c on clm.customer_id = c.customer_id
where c.status = 1
group by clm.customer_list_id,clm.company_site_id
), customerInteractive as (
select customer_list_id,
company_site_id,
count(customer_id) tt
from campaign_customer where campaign_id = :p_campaign_id and status <> 0
group by customer_list_id, company_site_id
), customerNotInteractive as (
select customer_list_id,
company_site_id,
count(customer_id) ktt
from campaign_customer where campaign_id = :p_campaign_id and status = 0
and in_campaign_status = 1
group by customer_list_id, company_site_id
)
select customer_list_code ma,
customer_list_name ten,
cl.company_site_id,
nvl(total, 0) tong,
nvl(tt, 0) tongtt,
nvl(ktt, 0) tongktt
from customer_list cl
left join totalCustomer tc on (cl.customer_list_id = tc.customer_list_id and cl.company_site_id = tc.company_site_id)
left join customerInteractive ci on (cl.customer_list_id = ci.customer_list_id and cl.company_site_id = ci.company_site_id)
left join customerNotInteractive cni on (cl.customer_list_id = cni.customer_list_id and cl.company_site_id = cni.company_site_id)
where cl.company_site_id = :p_company_site_id
order by customer_list_code
\ No newline at end of file
SELECT max(COMPLETE_VALUE) completeValue, COMPANY_SITE_ID companySiteId from CAMPAIGN_COMPLETE_CODE where COMPANY_SITE_ID = :p_site_id GROUP BY COMPANY_SITE_ID
...@@ -12,7 +12,8 @@ SELECT ...@@ -12,7 +12,8 @@ SELECT
FROM CAMPAIGN_COMPLETE_CODE a FROM CAMPAIGN_COMPLETE_CODE a
LEFT JOIN CAMPAIGN b ON a.CAMPAIGN_ID = b.CAMPAIGN_ID LEFT JOIN CAMPAIGN b ON a.CAMPAIGN_ID = b.CAMPAIGN_ID
LEFT JOIN AP_PARAM c ON a.CAMPAIGN_TYPE = to_char(c.AP_PARAM_ID); LEFT JOIN AP_PARAM c ON a.CAMPAIGN_TYPE = to_char(c.AP_PARAM_ID);
SELECT max(COMPLETE_VALUE) ,COMPANY_SITE_ID from CAMPAIGN_COMPLETE_CODE where COMPANY_SITE_ID = : p_site_id GROUP BY COMPANY_SITE_ID
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