Commit 79e56468 authored by Phạm Duy Phi's avatar Phạm Duy Phi

phipd accept merge

parents 64346ecc bad14c05
No preview for this file type
......@@ -5,3 +5,4 @@ out/
/campaign.iml
/lib
/log
/etc
This diff is collapsed.
......@@ -49,8 +49,8 @@
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath>
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath>-->
<version>1.0</version>
</dependency>
<dependency>
......@@ -151,6 +151,16 @@
<version>3.4</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.github.tennaito</groupId>
<artifactId>rsql-jpa</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>cz.jirutka.rsql</groupId>
<artifactId>rsql-parser</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
......
......@@ -15,7 +15,6 @@ public class ServiceCampaignApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceCampaignApplication.class, args);
RedisUtil redis = new RedisUtil(Config.redisAddress,Config.redisTimeout);
redis.setup();
}
......
......@@ -2,7 +2,6 @@ package com.viettel.campaign.filter;
import com.viettel.campaign.utils.RedisUtil;
import com.viettel.econtact.filter.UserSession;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import javax.servlet.*;
......@@ -31,27 +30,27 @@ public class CorsFilter implements Filter {
HttpServletRequest request = (HttpServletRequest) req;
chain.doFilter(req, resp);
// if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
// chain.doFilter(req, resp);
// return;
// }
// if ("/".equals(request.getRequestURI())) {
// chain.doFilter(req, resp);
// return;
// }
// String xAuthToken = request.getHeader("X-Auth-Token");
// if (xAuthToken == null || "".equals(xAuthToken)) {
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null.");
// return;
// }
// Object obj = RedisUtil.getInstance().get(xAuthToken);
// if (obj instanceof UserSession) {
// chain.doFilter(req, resp);
// } else {
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid.");
// }
// chain.doFilter(req, response);
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
chain.doFilter(req, resp);
return;
}
if ("/".equals(request.getRequestURI())) {
chain.doFilter(req, resp);
return;
}
String xAuthToken = request.getHeader("X-Auth-Token");
if (xAuthToken == null || "".equals(xAuthToken)) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null.");
return;
}
Object obj = RedisUtil.getInstance().get(xAuthToken);
if (obj instanceof UserSession) {
chain.doFilter(req, resp);
} else {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid.");
}
}
@Override
......
......@@ -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
}
});
}
......
package com.viettel.campaign.model.ccms_full;
public class CustomizeField {
}
......@@ -11,7 +11,7 @@ import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ApParamRepository extends JpaRepository<ApParam, Long>, ApParamRepositoryCustom {
public interface ApParamRepository extends JpaRepository<ApParam, Long> {
Page<ApParam> findAll(Pageable pageable);
......
package com.viettel.campaign.repository.ccms_full;
import org.springframework.stereotype.Repository;
@Repository
public interface ApParamRepositoryCustom {
}
......@@ -14,7 +14,7 @@ import java.util.List;
@Repository
public interface CampaignCfgRepository extends JpaRepository<CampaignCfg, Long>{
@Query(" select u FROM CampaignCfg u WHERE u.status = 1")
@Query("FROM CampaignCfg u WHERE u.status = 1 AND u.completeValue NOT IN (1,2,3,4)")
Page<CampaignCfg> findAll(Pageable pageable);
......
......@@ -10,7 +10,7 @@ import java.util.List;
@Repository
@Transactional(DataSourceQualify.CCMS_FULL)
public interface CampaignCustomerListColumnRepository extends JpaRepository<CampaignCustomerListColumn, Long> {
public interface CampaignCustomerListColumnRepository extends JpaRepository<CampaignCustomerListColumn, Long>, CampaignCustomerListColumnRepositoryCustom {
List<CampaignCustomerListColumn> findByCampaignIdAndCompanySiteId(Long campaignId, Long companaySiteId);
......
......@@ -36,6 +36,31 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
CampaignCustomer findCampaignCustomerByCampaignCustomerId(Long id);
@Query(value = "select C.NAME, " +
"C.EMAIL, " +
"C.PLACE_OF_BIRTH, " +
"C.AREA_CODE, " +
"C.COMPANY_NAME, " +
"C.CURRENT_ADDRESS, " +
"C.CUSTOMER_TYPE, " +
"C.DATE_OF_BIRTH, " +
"C.CUSTOMER_ID,"+
"C.USERNAME,"+
"C.GENDER, CF.TITLE " +
// " from CAMPAIGN_COMPLETE_CODE cm " +
"from CUSTOMER C " +
"left join CUSTOMIZE_FIELDS CF " +
"on C.CUSTOMER_ID = CF.CUSTOMIZE_FIELD_ID "+
"where CF.FUNCTION_CODE = 'CUSTORMER' and c.STATUS =1 and CF.ACTIVE =1 and CF.SITE_ID =?"
, nativeQuery = true)
Long searchCustomer(@Param("site_id") Long pSiteId);
@Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " +
"WHERE CC.STATUS = 0 " +
"AND CC.CAMPAIGN_ID = :campaignId " +
......@@ -50,5 +75,17 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
"AND CC.CUSTOMER_LIST_ID = :customerListId", nativeQuery = true)
List<CampaignCustomer> findCustomerContacted(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId, @Param("customerListId") Long customerListId);
@Query(value = "with status_customer as (\n" +
"select complete_value \n" +
"from campaign_complete_code\n" +
"where complete_value <> 4\n" +
" and is_finish <> 1\n" +
" and campaign_type = 1\n" +
" and company_site_id = :p_company_site_id\n" +
")\n" +
"select * from campaign_customer\n" +
"where campaign_id = :p_campaign_id\n" +
" and customer_list_id = :p_cus_list_id\n" +
" and (status = 0 or status in (select * from status_customer))", nativeQuery = true)
List<CampaignCustomer> findListCustomerToDel(@Param("p_company_site_id") Long companySiteId, @Param("p_campaign_id") Long campaignId, @Param("p_cus_list_id") Long customerListId);
}
......@@ -32,5 +32,9 @@ public interface CampaignRepositoryCustom {
ResultDTO getCustomerList(CampaignRequestDTO dto);
ResultDTO getCustomerChoosenList(CampaignRequestDTO dto);
ResultDTO getCampaignCustomerInformation(CampaignRequestDTO dto);
ResultDTO getCustomerListInformation(CampaignRequestDTO dto);
//</editor-fold>
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.model.ccms_full.Customer;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
......@@ -32,4 +34,11 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
@Query("select c from Customer c left join com.viettel.campaign.model.ccms_full.CustomerTime ct on c.customerId = ct.customerId " +
"where c.ipccStatus = 'locked' and c.siteId =?1 and ct.endTime <= ?2")
List<Customer> findAllByCondition(Long siteId, Date endTime);
@Query(value = "select * from customer a\n" +
"left join customer_list_mapping b on a.customer_id = b.customer_id\n" +
"where b.customer_list_id = :p_customer_list_id\n" +
" and a.customer_id not in (select cc.customer_id from campaign_customer cc where cc.campaign_id = :p_campaign_id and cc.customer_list_id = :p_customer_list_id)", nativeQuery = true)
List<Customer> findAllCutomerNotInCampagin(@Param("p_customer_list_id") Long customerListId, @Param("p_campaign_id") Long campaignId);
}
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.Ticket;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
@Transactional(DataSourceQualify.CCMS_FULL)
public interface TicketRepository extends BaseRepository<Ticket>, TicketRepositoryCustom {
}
package com.viettel.campaign.repository.ccms_full.impl;
import com.viettel.campaign.repository.ccms_full.ApParamRepositoryCustom;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
@Transactional
public class AppParamRepositoryImpl implements ApParamRepositoryCustom {
}
......@@ -22,7 +22,6 @@ import java.util.List;
public class CampaignCustomerListColumnRepositoryImpl implements CampaignCustomerListColumnRepositoryCustom {
@Override
public List<CampaignCustomerListColumnRequestDTO> getCustomerInfor(Long companySiteId, Long customerId, Long campaignId) {
ResultDTO result = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
List<CampaignCustomerListColumnRequestDTO> data = new ArrayList<>();
......@@ -41,12 +40,9 @@ public class CampaignCustomerListColumnRepositoryImpl implements CampaignCustome
sb.append(" c.TYPE type,");
sb.append(" d.NAME valueCombobox");
sb.append(" FROM CAMPAIGN_CUSTOMERLIST_COLUMN a");
sb.append(" JOIN CUSTOMIZE_FIELD_OBJECT b");
sb.append(" ON a.CUSTOMIZE_FIELD_ID = b.CUSTOMIZE_FIELDS_ID");
sb.append(" JOIN CUSTOMIZE_FIELDS c");
sb.append(" ON a.CUSTOMIZE_FIELD_ID = c.CUSTOMIZE_FIELD_ID");
sb.append(" LEFT JOIN CUSTOMIZE_FIELD_OPTION_VALUE d");
sb.append(" ON b.FIELD_OPTION_VALUE_ID = d.FIELD_OPTION_VALUE_ID");
sb.append(" JOIN CUSTOMIZE_FIELD_OBJECT b ON a.CUSTOMIZE_FIELD_ID = b.CUSTOMIZE_FIELDS_ID");
sb.append(" JOIN CUSTOMIZE_FIELDS c ON a.CUSTOMIZE_FIELD_ID = c.CUSTOMIZE_FIELD_ID");
sb.append(" LEFT JOIN CUSTOMIZE_FIELD_OPTION_VALUE d ON b.FIELD_OPTION_VALUE_ID = d.FIELD_OPTION_VALUE_ID");
sb.append(" WHERE 1 = 1");
sb.append(" AND b.FUNCTION_CODE = 'CUSTOMER'");
sb.append(" AND a.COMPANY_SITE_ID = :p_company_site_id");
......@@ -71,8 +67,7 @@ public class CampaignCustomerListColumnRepositoryImpl implements CampaignCustome
data = query.list();
} catch (Exception e) {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
e.printStackTrace();
} finally {
session.close();
}
......
......@@ -132,10 +132,10 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sql.append(" from dual");
sql.append(" connect by level <= regexp_count(:p_list_record_status, ',') +1");
sql.append(" ),");
sql.append(" campaign_id_list as (");
sql.append(" select trim (regexp_substr(:p_list_campaign_id, '[^,]+', 1, level)) campaign_id");
sql.append(" campaign_code_list as (");
sql.append(" select trim (regexp_substr(:p_list_campaign_code, '[^,]+', 1, level)) campaign_code");
sql.append(" from dual");
sql.append(" connect by level <= regexp_count(:p_list_campaign_id, ',') +1");
sql.append(" connect by level <= regexp_count(:p_list_campaign_code, ',') +1");
sql.append(" ),");
sql.append(" data_temp as (");
sql.append(" select a.contact_cust_result_id contactCustResultId,");
......@@ -168,7 +168,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sql.append(" and to_char(a.call_status) in (select survey_status from survey_status_list)");
sql.append(" and to_char(a.status) in (select record_status from record_status_list)");
sql.append(" and (:p_phone_number is null or to_char(a.phone_number) like '%'||:p_phone_number||'%')");
sql.append(" and (:p_list_campaign_id is null or b.campaign_code in (select campaign_id from campaign_id_list))");
sql.append(" and (:p_list_campaign_code is null or b.campaign_code in (select campaign_code from campaign_code_list))");
sql.append(" and (:p_campaign_name is null or upper(b.campaign_name) like '%'||:p_campaign_name||'%')");
sql.append(" and (:p_user_name is null or upper(c.user_name) like '%'||:p_user_name||'%')");
sql.append(" ),");
......@@ -194,7 +194,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_list_record_status", dto.getRecordStatus());
query.setParameter("p_call_time_from", dto.getCallTimeFrom());
query.setParameter("p_call_time_to", dto.getCallTimeTo());
query.setParameter("p_list_campaign_id", dto.getCampaignId());
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());
......@@ -223,10 +223,10 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
total = list.get(0).getTotalRow();
}
for (ContactCusResDTO contactCusResDTO : list) {
if (!"AGENT".equals(dto.getRoleUser())) {
if (!"AGENT".equals(dto.getRoleUser())) { // ko phải nhân viên
contactCusResDTO.setEnableEdit(true);
} else {
if ("2".equals(contactCusResDTO.getRecordStatus())) {
if ("2".equals(contactCusResDTO.getRecordStatus())) {// là nhân viên thường
contactCusResDTO.setEnableEdit(true);
} else if ("1".equals(contactCusResDTO.getRecordStatus()) && isLower24Hour(contactCusResDTO.getCreateTime())) {
contactCusResDTO.setEnableEdit(true);
......@@ -282,10 +282,10 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sb.append(" from dual");
sb.append(" connect by level <= regexp_count(:p_list_record_status, ',') +1");
sb.append(" ),");
sb.append(" campaign_id_list as (");
sb.append(" select trim (regexp_substr(:p_list_campaign_id, '[^,]+', 1, level)) campaign_id");
sb.append(" campaign_code_list as (");
sb.append(" select trim (regexp_substr(:p_list_campaign_code, '[^,]+', 1, level)) campaign_code");
sb.append(" from dual");
sb.append(" connect by level <= regexp_count(:p_list_campaign_id, ',') +1");
sb.append(" connect by level <= regexp_count(:p_list_campaign_code, ',') +1");
sb.append(" ),");
sb.append(" data_temp as (");
sb.append(" select a.contact_cust_result_id contactCustResultId,");
......@@ -318,7 +318,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sb.append(" and to_char(a.call_status) in (select survey_status from survey_status_list)");
sb.append(" and to_char(a.status) in (select record_status from record_status_list)");
sb.append(" and (:p_phone_number is null or to_char(a.phone_number) like '%'||:p_phone_number||'%')");
sb.append(" and (:p_list_campaign_id is null or b.campaign_code in (select campaign_id from campaign_id_list))");
sb.append(" and (:p_list_campaign_code is null or b.campaign_code in (select campaign_code from campaign_code_list))");
sb.append(" and (:p_campaign_name is null or upper(b.campaign_name) like '%'||:p_campaign_name||'%')");
sb.append(" and (:p_user_name is null or upper(c.user_name) like '%'||:p_user_name||'%')");
sb.append(" ),");
......@@ -330,24 +330,6 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sb.append(" select campaignCode, createTime, campaignName, userName, phoneNumber, customerName, startCall, contactStatus, surveyStatus, status, recordStatus, callTime from data");
sb.append(" where :p_page_size = 0 or (row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1))");
// params.put("p_company_site_id", dto.getCompanySiteId());
// params.put("p_customer_id", dto.getCustomerId());
// params.put("p_date_from", dto.getFromDate());
// params.put("p_date_to", dto.getToDate());
// params.put("p_list_compaign_type", dto.getCampaignType());
// params.put("p_list_contact_status", dto.getContactStatus());
// params.put("p_list_survey_status", dto.getSurveyStatus());
// params.put("p_list_record_status", dto.getRecordStatus());
// params.put("p_call_time_from", dto.getCallTimeFrom());
// params.put("p_call_time_to", dto.getCallTimeTo());
// params.put("p_list_campaign_id", dto.getCampaignId());
// params.put("p_phone_number", dto.getPhoneNumber());
// params.put("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().toUpperCase());
// params.put("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().toUpperCase());
// params.put("p_page_number", dto.getPage().toString());
// params.put("p_page_size", "0");
//
// list = namedParameterJdbcTemplate.query(sb.toString(), params, BeanPropertyRowMapper.newInstance(ContactCusResDTO.class));
SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", dto.getCompanySiteId());
query.setParameter("p_customer_id", dto.getCustomerId());
......@@ -359,7 +341,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_list_record_status", dto.getRecordStatus());
query.setParameter("p_call_time_from", dto.getCallTimeFrom());
query.setParameter("p_call_time_to", dto.getCallTimeTo());
query.setParameter("p_list_campaign_id", dto.getCampaignId());
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());
......
......@@ -20,7 +20,6 @@ public class TicketRepositoryImpl implements TicketRepositoryCustom {
@PersistenceContext( unitName= DataSourceQualify.JPA_UNIT_NAME_CCMS_FULL)
EntityManager entityManager;
@Override
public List<TicketDTO> getHistory(String customerId, Pageable pageable) {
List<TicketDTO> lst = new ArrayList<>();
String expression = new StringBuilder()
......
......@@ -66,6 +66,12 @@ public interface CampaignService {
ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto);
ResultDTO saveFieldCustomer(CampaignRequestDTO dto);
ResultDTO getCampaignCustomerInformation(CampaignRequestDTO dto);
ResultDTO getCustomerListInformation(CampaignRequestDTO dto);
ResultDTO saveCustomerCampaign(CampaignRequestDTO dto);
//</editor-fold>
}
......@@ -6,6 +6,7 @@ import com.viettel.campaign.model.ccms_full.CustomizeFieldObject;
import com.viettel.campaign.model.ccms_full.CustomizeFields;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession;
......@@ -33,7 +34,9 @@ public interface CustomerService {
ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId);
CustomerList createCustomerList(CustomerListDTO customerListDTO, String userName);
// 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);
......@@ -70,4 +73,9 @@ public interface CustomerService {
Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> headerDTOS, UserSession userSession, Long customerListId);
List<CustomizeFieldObject> getCustomizeField(Long customerId);
List<Customer> searchByQuery(String queryString);
Long countByQuery(String queryString);
// Map<String, CustomizeRequestDTo> searchCustomer();
//// List<CustomizeFields> searchCustomize();
ResultDTO searchCustomizeFields(CustomizeRequestDTo customizeFields);
}
......@@ -2,8 +2,11 @@ package com.viettel.campaign.service;
import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.web.dto.*;
import com.viettel.econtact.filter.UserSession;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.List;
import java.util.Map;
/**
* @author anhvd_itsol
......@@ -19,4 +22,8 @@ public interface ScenarioService {
Integer countDuplicateScenarioCode(Long companySiteId, String code, Long scenarioId);
ResultDTO saveContacQuestResult(ContactQuestResultDTO dto);
XSSFWorkbook buildTemplate();
Map<String, Object> readAndValidateCustomer(String path, UserSession userSession);
}
package com.viettel.campaign.service;
import java.util.Map;
import com.viettel.campaign.web.dto.ResultDTO;
public interface TicketService {
Map getHistory(int page, int pageSize, String sort, String customerId);
ResultDTO getHistory(int page, int pageSize, String sort, String customerId);
}
......@@ -81,6 +81,9 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
sb.append(" where 1 = 1");
sb.append(" AND STATUS = 1");
sb.append(" and COMPANY_SITE_ID = :p_company_site_id");
sb.append(" and COMPLETE_VALUE not in (1,2,3,4)");
sb.append("ORDER BY to_number(COMPLETE_VALUE) ");
SQLQuery query = session.createSQLQuery(sb.toString());
......@@ -290,7 +293,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
sb.append("SELECT max(to_number(COMPLETE_VALUE)) completeValue, COMPANY_SITE_ID ");
sb.append(" companySiteId from CAMPAIGN_COMPLETE_CODE where COMPANY_SITE_ID = :p_site_id ");
sb.append(" GROUP BY COMPANY_SITE_ID");
sb.append(" GROUP BY COMPANY_SITE_ID ");
SQLQuery query = session.createSQLQuery(sb.toString());
......
......@@ -63,7 +63,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
TimeRangeDialModeRepository rangeDialModeRepository;
@Autowired
CampaignCustomerListColumnRepositoryCustom campaignCustomerListColumnRepositoryCustom;
CampaignCustomerListColumnRepository campaignCustomerListColumnRepository;
//<editor-fold: hungtt>
@Override
......@@ -277,6 +277,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
a.setAgentId(requestDto.getAgentId());
a.setCampaignSystemStatus("AVAILABLE");
a.setCurrentCampaignId(Long.parseLong(requestDto.getCampaignId()));
a.setUpdateDate(new Date());
agentsRepository.save(a);
// update ccms_full.campaign_agent table
campaignAgentRepository.updateCampaignAgentSetStatus(Long.parseLong(requestDto.getAgentId()), Long.parseLong(requestDto.getCampaignId()), 1);
......@@ -589,7 +590,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
}
try {
List<CampaignCustomerListColumnRequestDTO> data = campaignCustomerListColumnRepositoryCustom.getCustomerInfor(companySiteId, customerId, campaignId);
List<CampaignCustomerListColumnRequestDTO> data = campaignCustomerListColumnRepository.getCustomerInfor(companySiteId, customerId, campaignId);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(data);
......
......@@ -12,7 +12,6 @@ import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.WorkBookBuilder;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import oracle.jdbc.driver.Const;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.usermodel.*;
......@@ -70,6 +69,9 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired
CampaignCustomerListColumnRepository campaignCustomerListColumnRepository;
@Autowired
CustomerRepository customerRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO search(CampaignRequestDTO requestDto) {
......@@ -613,6 +615,61 @@ public class CampaignServiceImpl implements CampaignService {
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCampaignCustomerInformation(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCampaignCustomerInformation(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerListInformation(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCustomerListInformation(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO saveCustomerCampaign(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
long campaignId = Long.parseLong(dto.getCampaignId());
long companySiteId = Long.parseLong(dto.getCompanySiteId());
List<CustomerListDTO> listCustomerDto = dto.getLstCustomerCampaign();
try {
// Thuc hien them giam khach hang
for (CustomerListDTO customerListDTO : listCustomerDto) {
if (customerListDTO.getTotalCusAddRemove() > 0) { // Them khach hang
// Lay ra danh sach khach hang phu hop de them
List<Customer> listCustomerToAdd = customerRepository.findAllCutomerNotInCampagin(customerListDTO.getCustomerListId(), campaignId);
for (int i = 0; i < customerListDTO.getTotalCusAddRemove(); i++) {
CampaignCustomer campaignCustomerEntity = new CampaignCustomer();
campaignCustomerEntity.setCampaignId(campaignId);
campaignCustomerEntity.setCustomerId(listCustomerToAdd.get(i).getCustomerId());
campaignCustomerEntity.setStatus((short) 0);
campaignCustomerEntity.setRecallCount(0L);
campaignCustomerEntity.setCustomerListId(customerListDTO.getCustomerListId());
campaignCustomerEntity.setCompanySiteId(companySiteId);
campaignCustomerEntity.setInCampaignStatus((short) 1);
campaignCustomerRepository.save(campaignCustomerEntity);
}
} else if (customerListDTO.getTotalCusAddRemove() < 0){ // Loai bo khach hang
long custToDel = Math.abs(customerListDTO.getTotalCusAddRemove());
// Lay ra danh sach khach hang can loai bo
List<CampaignCustomer> listCustomerToDelete = campaignCustomerRepository.findListCustomerToDel(companySiteId, campaignId, customerListDTO.getCustomerListId());
for (int j = 0; j < custToDel; j++) {
campaignCustomerRepository.delete(listCustomerToDelete.get(j));
}
}
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
// hungtt
private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) {
mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale));
......
......@@ -3,6 +3,8 @@ package com.viettel.campaign.service.impl;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.repository.ccms_full.TicketRepository;
import com.viettel.campaign.service.TicketService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.TicketDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
......@@ -11,9 +13,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class TicketServiceImpl implements TicketService {
......@@ -21,16 +21,29 @@ public class TicketServiceImpl implements TicketService {
@Autowired
TicketRepository ticketRepository;
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Map getHistory(int page, int pageSize, String sort, String customerId) {
Map result = new HashMap();
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getHistory(int page, int pageSize, String sort, String customerId) {
ResultDTO result = new ResultDTO();
List<TicketDTO> lst = new ArrayList<>();
lst = ticketRepository.getHistory(customerId, PageRequest.of(page, pageSize, Sort.by(sort)));
result.put("totalItem", lst.size());
result.put("tickets", lst);
try {
Integer c = ticketRepository.getHistory(customerId, null).size();
if (c > 0) {
lst = ticketRepository.getHistory(customerId, PageRequest.of(page, pageSize, Sort.by(sort)));
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setListData(lst);
result.setTotalRow(c);
} else {
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setTotalRow(0);
}
} catch (Exception e) {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
}
return result;
}
......
......@@ -16,6 +16,7 @@ public class Config {
public static final String APP_CONF_FILE_PATH = System.getProperty("user.dir") + File.separator + "etc" + File.separator + "app.conf";
public static final String LOG_CONF_FILE_PATH = System.getProperty("user.dir") + File.separator + "etc" + File.separator + "log.conf";
public static final String EXCEL_DIR = System.getProperty("user.dir") + File.separator + "etc";
public static String amcd_xmlrpc_url;
public static int num_client_amcd_xmlprc;
......@@ -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());
......
package com.viettel.campaign.utils;
public enum SearchOperation {
EQUALITY, NEGATION, GREATER_THAN, LESS_THAN, LIKE, STARTS_WITH, ENDS_WITH, CONTAINS;
public static final String[] SIMPLE_OPERATION_SET = { ":", "!", ">", "<", "~" };
public static final String OR_PREDICATE_FLAG = "'";
public static final String ZERO_OR_MORE_REGEX = "*";
public static final String OR_OPERATOR = "OR";
public static final String AND_OPERATOR = "AND";
public static final String LEFT_PARANTHESIS = "(";
public static final String RIGHT_PARANTHESIS = ")";
public static SearchOperation getSimpleOperation(final char input) {
switch (input) {
case ':':
return EQUALITY;
case '!':
return NEGATION;
case '>':
return GREATER_THAN;
case '<':
return LESS_THAN;
case '~':
return LIKE;
default:
return null;
}
}
}
package com.viettel.campaign.web.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CampaignInformationDTO {
private Long campaignId;
private Long totalIndividual;
private Long totalNotInteractive;
private Long totalNotCall;
private Long campaignCustomer;
private Long customerListId;
}
package com.viettel.campaign.web.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CustomizeFielObjectDTO {
private Long customerId;
private String name;
private String companyName;
private String customerImg;
private String status;
private Long siteId;
private Short gender;
private String currentAddress;
private String placeOfBirth;
private Date dateOfBirth;
private String mobileNumber;
private String email;
private String userName;
private Long customerType;
private Long customizeFieldObjectId;
private Long objectId;
private Long customizeFieldId;
private String valueText;
private Long valueNumber;
private Date valueDate;
private Long valueCheckbox;
private Date createBy;
private Date createDate;
private String updateBy;
private Date updateDate;
private Long fieldOptionValueId;
private String title;
private String functionCode;
}
......@@ -2,6 +2,7 @@ package com.viettel.campaign.web.dto.request_dto;
import com.viettel.campaign.web.dto.BaseDTO;
import com.viettel.campaign.web.dto.CustomerCustomDTO;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.FieldsToShowDTO;
import lombok.Getter;
import lombok.Setter;
......@@ -53,4 +54,6 @@ public class CampaignRequestDTO extends BaseDTO {
String createTimeFr;
String lstCustomerListId;
List<FieldsToShowDTO> lstFiedCustomer;
List<CustomerListDTO> lstCustomerCampaign;
String customerListId;
}
package com.viettel.campaign.web.dto.request_dto;
import com.viettel.campaign.web.dto.BaseDTO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CustomizeRequestDTo extends BaseDTO {
String operatorLogic;
String filterCustomer;
String compare;
String valueCustomer;
String companySiteId;
String customerId;
}
......@@ -16,7 +16,7 @@ import java.util.Map;
@RestController
@RequestMapping("/ipcc/completeCode")
@CrossOrigin(origins = "*")
public class CampaignCfg {
public class CampaignCfgController {
private static final Logger LOGGER = Logger.getLogger(CustomerController.class);
@Autowired
......@@ -127,4 +127,5 @@ public class CampaignCfg {
return new ResponseEntity(result, HttpStatus.OK);
}
}
......@@ -44,42 +44,6 @@ public class CampaignController {
@Autowired
CampaignExecuteService campaignExecuteService;
@PostMapping("/searchCampaignExecute")
@ResponseBody
public ResponseEntity<ResultDTO> searchCampaignExecute(@RequestBody CampaignRequestDTO requestDto, HttpServletRequest request) {
String xAuthToken = request.getHeader("X-Auth-Token");
ResultDTO result = campaignExecuteService.searchCampaignExecute(requestDto, xAuthToken);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getExecuteCampaign")
@ResponseBody
public ResponseEntity<ResultDTO> getExecuteCampaign(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignExecuteService.getExecuteCampaign(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCustomer")
@ResponseBody
public ResponseEntity<ResultDTO> getCustomer(@RequestBody CampaignCustomerDTO requestDto) {
ResultDTO result = campaignExecuteService.getCustomer(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCustomerComplete")
@ResponseBody
public ResponseEntity<ResultDTO> getCustomerComplete(@RequestBody ReceiveCustLogDTO requestDto) {
ResultDTO result = campaignExecuteService.getCustomerComplete(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCallLog")
@ResponseBody
public ResponseEntity<ResultDTO> getCallLog(@RequestBody ReceiveCustLogDTO requestDto) {
ResultDTO result = campaignExecuteService.getCallLog(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/callCustomer")
@ResponseBody
public ResponseEntity<ResultDTO> callCustomer(@RequestBody ContactCustResultDTO requestDto) {
......@@ -87,13 +51,6 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getAgentLogout")
@ResponseBody
public ResponseEntity<ResultDTO> getAgentLogout(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignExecuteService.getAgentLogout(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);
......@@ -131,45 +88,6 @@ public class CampaignController {
return new ResponseEntity<>(list, HttpStatus.OK);
}
@PostMapping("/searchInteractiveResult")
@ResponseBody
public ResponseEntity<ResultDTO> searchInteractiveResult(@RequestBody CampaignRequestDTO dto) throws Exception {
ResultDTO result = campaignExecuteService.searchInteractiveResult(dto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/exportInteractiveResult")
@ResponseBody
public ResponseEntity<?> exportInteractiveResult(HttpServletResponse response, @RequestBody CampaignRequestDTO dto) {
XSSFWorkbook workbook = null;
byte[] contentReturn = null;
try {
String fileName = "report_campaign_exec_interactive_result.xlsx";
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
OutputStream outputStream;
workbook = campaignExecuteService.exportInteractiveResult(dto);
outputStream = response.getOutputStream();
workbook.write(outputStream);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
workbook.write(byteArrayOutputStream);
contentReturn = byteArrayOutputStream.toByteArray();
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ResponseEntity<byte[]>(null, null, HttpStatus.BAD_REQUEST);
} finally {
if (workbook != null) {
try {
workbook.close();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/vnd.ms-excel"));
return new ResponseEntity<byte[]>(contentReturn, headers, HttpStatus.OK);
}
@RequestMapping(value = "/changeCampaignStatus", method = RequestMethod.POST)
public ResultDTO changeCampaignStatus(@RequestBody CampaignDTO dto, HttpServletRequest request) {
dto.setSessionId(request.getSession().getId());
......@@ -248,13 +166,6 @@ public class CampaignController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@GetMapping("/countRecallCustomer")
@ResponseBody
public ResponseEntity countRecallCustomer(@RequestParam("companySiteId") Long companySiteId, @RequestParam("agentId") Long agentId) {
ResultDTO result = campaignExecuteService.countRecallCustomer(companySiteId, agentId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/getCustomerRecall")
@ResponseBody
public ResponseEntity getCustomerRecall(@RequestParam("campaignId") Long campaignId, @RequestParam("customerId") Long customerId) {
......@@ -305,6 +216,28 @@ public class CampaignController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/getCampaignCustomerInformation")
@ResponseBody
public ResponseEntity getCampaignCustomerInformation(@RequestBody CampaignRequestDTO campaignRequestDTO) {
campaignRequestDTO.setCustomerListId(null);
ResultDTO resultDTO = campaignService.getCampaignCustomerInformation(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/getCustomerListInformation")
@ResponseBody
public ResponseEntity getCustomerListInformation(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.getCustomerListInformation(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/saveCustomerCampaign")
@ResponseBody
public ResponseEntity saveCustomerCampaign(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.saveCustomerCampaign(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT)
public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) {
ResultDTO result = campaignService.renewCampaign(campaignDTO);
......
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.request_dto.CampaignRequestDTO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@RestController
@RequestMapping("/ipcc/campaign/execute")
@CrossOrigin
public class CampaignExecuteController {
private static final Logger logger = LoggerFactory.getLogger(CampaignController.class);
@Autowired
CampaignExecuteService campaignExecuteService;
@PostMapping("/searchCampaignExecute")
@ResponseBody
public ResponseEntity<ResultDTO> searchCampaignExecute(@RequestBody CampaignRequestDTO requestDto, HttpServletRequest request) {
String xAuthToken = request.getHeader("X-Auth-Token");
ResultDTO result = campaignExecuteService.searchCampaignExecute(requestDto, xAuthToken);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getExecuteCampaign")
@ResponseBody
public ResponseEntity<ResultDTO> getExecuteCampaign(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignExecuteService.getExecuteCampaign(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCustomer")
@ResponseBody
public ResponseEntity<ResultDTO> getCustomer(@RequestBody CampaignCustomerDTO requestDto) {
ResultDTO result = campaignExecuteService.getCustomer(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCustomerComplete")
@ResponseBody
public ResponseEntity<ResultDTO> getCustomerComplete(@RequestBody ReceiveCustLogDTO requestDto) {
ResultDTO result = campaignExecuteService.getCustomerComplete(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getCallLog")
@ResponseBody
public ResponseEntity<ResultDTO> getCallLog(@RequestBody ReceiveCustLogDTO requestDto) {
ResultDTO result = campaignExecuteService.getCallLog(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/countRecallCustomer")
@ResponseBody
public ResponseEntity countRecallCustomer(@RequestParam("companySiteId") Long companySiteId, @RequestParam("agentId") Long agentId) {
ResultDTO result = campaignExecuteService.countRecallCustomer(companySiteId, agentId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/getAgentLogout")
@ResponseBody
public ResponseEntity<ResultDTO> getAgentLogout(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignExecuteService.getAgentLogout(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/searchInteractiveResult")
@ResponseBody
public ResponseEntity<ResultDTO> searchInteractiveResult(@RequestBody CampaignRequestDTO dto) throws Exception {
ResultDTO result = campaignExecuteService.searchInteractiveResult(dto);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/exportInteractiveResult")
@ResponseBody
public ResponseEntity<?> exportInteractiveResult(HttpServletResponse response, @RequestBody CampaignRequestDTO dto) {
XSSFWorkbook workbook = null;
byte[] contentReturn = null;
try {
String fileName = "report_campaign_exec_interactive_result.xlsx";
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
OutputStream outputStream;
workbook = campaignExecuteService.exportInteractiveResult(dto);
outputStream = response.getOutputStream();
workbook.write(outputStream);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
workbook.write(byteArrayOutputStream);
contentReturn = byteArrayOutputStream.toByteArray();
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ResponseEntity<byte[]>(null, null, HttpStatus.BAD_REQUEST);
} finally {
if (workbook != null) {
try {
workbook.close();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/vnd.ms-excel"));
return new ResponseEntity<byte[]>(contentReturn, headers, 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);
}
}
package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.CustomerList;
import com.viettel.campaign.model.ccms_full.Customer;
import com.viettel.campaign.model.ccms_full.CustomizeFieldObject;
import com.viettel.campaign.model.ccms_full.CustomizeFields;
import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.utils.BundleUtils;
import com.viettel.campaign.utils.Config;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.CustomizeRequestDTo;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.apache.commons.io.FilenameUtils;
......@@ -17,6 +19,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
......@@ -105,15 +108,17 @@ public class CustomerController {
@PostMapping("/createCustomerList")
@ResponseBody
public ResponseEntity<?> createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
// 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);
CustomerList cl = customerService.createCustomerList(customerListDTO, userSession.getUserName());
if (cl == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
if (userSession == null) {
userSession = new UserSession();
userSession.setSiteId(customerListDTO.getCompanySiteId());
userSession.setUserName("its4");
}
return new ResponseEntity<>(cl, HttpStatus.OK);
return customerService.createCustomerList(customerListDTO, userSession.getUserName());
}
@PostMapping("/updateCustomerList")
......@@ -186,12 +191,17 @@ public class CustomerController {
@PostMapping(value = "/importFile")
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestParam("customerListId") Long customerListId,
@RequestParam("customerListId") String customerListId,
HttpServletRequest request) {
LOGGER.info("------------IMPORT FILE TEMPLATE--------------");
Locale locale = new Locale("vi", "VN");
try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(request.getHeader("X-Auth-Token"));
if (userSession == null) {
userSession = new UserSession();
userSession.setSiteId(662691L);
userSession.setUserName("its3");
}
if (file.isEmpty()) {
return new ResponseEntity<>(BundleUtils.getLangString("customer.fileNotSelected"), HttpStatus.OK);
}
......@@ -200,7 +210,7 @@ public class CustomerController {
}
String path = saveUploadFile(file);
List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, customerListId);
Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, Long.parseLong(customerListId));
File fileExport = (File) map.get("file");
String message = (String) map.get("message");
return ResponseEntity.ok()
......@@ -238,11 +248,13 @@ public class CustomerController {
String currentTime = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss").format(new Date());
String fileName = FilenameUtils.getBaseName(file.getOriginalFilename()) + "_" + currentTime + "." + FilenameUtils.getExtension(file.getOriginalFilename());
byte[] content = file.getBytes();
File uploadFolder = new File(BundleUtils.getGlobalConfig("import.uploadFolder"));
// File uploadFolder = new File(BundleUtils.getGlobalConfig("import.uploadFolder"));
File uploadFolder = new File(Config.EXCEL_DIR);
if (!uploadFolder.exists()) {
uploadFolder.mkdir();
}
Path path = Paths.get(BundleUtils.getGlobalConfig("import.uploadFolder"), fileName);
// Path path = Paths.get(BundleUtils.getGlobalConfig("import.uploadFolder"), fileName);
Path path = Paths.get(Config.EXCEL_DIR, fileName);
Files.write(path, content);
return path.toString();
} catch (Exception e) {
......@@ -250,4 +262,22 @@ public class CustomerController {
}
return null;
}
@GetMapping(path = "", produces = { MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<List<Customer>> query(@RequestParam(value = "search") String query) {
List<Customer> result = null;
try {
result= customerService.searchByQuery(query);
}catch (IllegalArgumentException iae){
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(result);
}
return ResponseEntity.status(HttpStatus.OK)
.body(result);
}
@PostMapping("/getCustomizeFields")
@ResponseBody
public ResponseEntity<?> getListFieldsToShow(@RequestBody CustomizeRequestDTo customizeRequestDTo) {
ResultDTO resultDTO = customerService.searchCustomizeFields(customizeRequestDTo);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
}
......@@ -2,15 +2,32 @@ package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.Scenario;
import com.viettel.campaign.service.ScenarioService;
import com.viettel.campaign.utils.BundleUtils;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.ContactQuestResultDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.ScenarioDTO;
import com.viettel.econtact.filter.UserSession;
import org.apache.commons.io.FilenameUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author anhvd_itsol
......@@ -54,4 +71,82 @@ public class ScenarioController {
ResultDTO resultDTO = scenarioService.saveContacQuestResult(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/download-file-template", method = RequestMethod.GET)
public ResponseEntity<?> downloadFileTemplate(HttpServletResponse response) {
XSSFWorkbook workbook = null;
byte[] contentReturn = null;
try {
String fileName = "import_scenario_template.xlsx";
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
OutputStream outputStream;
workbook = scenarioService.buildTemplate();
outputStream = response.getOutputStream();
workbook.write(outputStream);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
workbook.write(byteArrayOutputStream);
contentReturn = byteArrayOutputStream.toByteArray();
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
return new ResponseEntity<byte[]>(null, null, HttpStatus.BAD_REQUEST);
} finally {
if (workbook != null) {
try {
workbook.close();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/vnd.ms-excel"));
return new ResponseEntity<byte[]>(contentReturn, headers, HttpStatus.OK);
}
@RequestMapping(value = "/import-file", method = RequestMethod.POST)
public ResponseEntity<?> importFile(@RequestParam MultipartFile file) {
logger.info("------------IMPORT FILE TEMPLATE--------------");
Locale locale = new Locale("vi", "VN");
try {
UserSession userSession = new UserSession();
// 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);
Map<String, Object> map = scenarioService.readAndValidateCustomer(path, userSession);
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=import_scenario_result.xlsx")
.header("Message", message)
.body(Files.readAllBytes(fileExport.toPath()));
} catch (Exception e) {
logger.error(e.getMessage());
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
private String saveUploadFile(MultipartFile file) {
try {
String currentTime = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss").format(new Date());
String fileName = FilenameUtils.getBaseName(file.getOriginalFilename()) + "_" + currentTime + "." + FilenameUtils.getExtension(file.getOriginalFilename());
byte[] content = file.getBytes();
File uploadFolder = new File(System.getProperty("user.dir") + File.separator + "etc" + File.separator + "upload");
if (!uploadFolder.exists()) {
uploadFolder.mkdir();
}
Path path = Paths.get(System.getProperty("user.dir") + File.separator + "etc", fileName);
Files.write(path, content);
return path.toString();
} catch (Exception e) {
logger.error(e.getMessage());
}
return null;
}
}
package com.viettel.campaign.web.rest;
import com.viettel.campaign.service.TicketService;
import com.viettel.campaign.web.dto.ResultDTO;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
......@@ -22,7 +23,7 @@ public class TicketController {
@GetMapping("/getHistory")
@ResponseBody
public ResponseEntity searchCampaignExecute(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("customerId") String customerId) {
Map result = ticketService.getHistory(page, pageSize, sort, customerId);
ResultDTO result = ticketService.getHistory(page, pageSize, sort, customerId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
server:
port: 1111
port: 9999
spring:
application:
name: campaign
......@@ -11,6 +11,11 @@ spring:
ddl-auto: none
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
servlet:
multipart:
enabled: true
max-file-size: 3MB
max-request-size: 3MB
# kafka:
# consumer:
# bootstrap-servers: 192.168.1.201:9092
......@@ -40,4 +45,3 @@ datasource-property:
......@@ -108,3 +108,30 @@ customer.emailExists=Email exists;
common.fileNotSelected=Please select a file
common.fileInvalidFormat=File invalid
common.invalidTemplate = Template invalid format
#IMPORT SCENARIO TEMPLATE
scenario.template.title=IMPORT QUESTIONS
scenario.template.questionCode=Question code
scenario.template.questionType=Question type
scenario.template.question=Question
scenario.template.answer=Answer
scenario.template.hashInput=Hash input?
scenario.template.required=Required?
scenario.template.default=Default?
scenario.template.mappingQuestion=Mapping question
scenario.template.yes=Yes
scenario.template.no=No
scenario.template.result=Result
scenario.template.singleChoice=SingleChoice
scenario.template.multiChoice=MultiChoice
scenario.template.text=Text
scenario.questionCode.required="Question index is required"
scenario.questionType.required="Question type is required"
scenario.question.required="Question content is required"
scenario.answer.required="Answer is required for SingleChoice or MultiChoice question"
scenario.hashInput.required="Has input is required"
scenario.required.required="Require is required"
scenario.default.required="Default is required"
......@@ -110,3 +110,33 @@ customer.emailExists=Email đã tồn tại;
common.fileNotSelected=Bạn chưa chọn file
common.fileInvalidFormat=File không hợp lệ
common.invalidTemplate = Template sai định dạng
#IMPORT SCENARIO TEMPLATE
scenario.template.title=IMPORT CÂU HỎI
scenario.template.questionCode=Mã câu hỏi
scenario.template.questionType=Loại câu hỏi
scenario.template.question=Câu hỏi
scenario.template.answer=Câu trả lời
scenario.template.hashInput=Nhập text?
scenario.template.required=Bắt buộc?
scenario.template.default=Mặc định?
scenario.template.mappingQuestion=Câu hỏi liên kết
scenario.template.yes=
scenario.template.no=Không
scenario.template.result=Kết quả
scenario.template.singleChoice=SingleChoice
scenario.template.multiChoice=MultiChoice
scenario.template.text=Text
scenario.questionCode.required="Mã câu hỏi bắt buộc nhập"
scenario.questionType.required="Loại câu hỏi bắt buộc nhập"
scenario.question.required="Câu hỏi bắt buộc nhập"
scenario.answer.required="Câu trả lời cho câu hỏi SingleChoice, MultiChoice bắt buộc nhập"
scenario.hashInput.required="Trường Nhập text bắt buộc nhập"
scenario.required.required="Trường Bắt buộc bắt buộc nhập"
scenario.default.required="Trường Mặc định bắt buộc nhập"
......@@ -60,6 +60,9 @@ where a.status <> 0
),
data as (
select a.*, rownum row_ from data_temp a
),
count_data as (
select count(*) totalRow from data_temp
)
select * from data
select campaignCode, campaignName, userName, phoneNumber, customerName, startCall, contactStatus, surveyStatus, status, recordStatus, callTime, totalRow from data, count_data
where :p_page_size = 0 or (row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1))
with status_customer as (
select complete_value
from campaign_complete_code
where complete_value <> 4
and is_finish <> 1
and campaign_type = 1
and company_site_id = :p_company_site_id
),
count_customer as (
select campaign_id campaignId,
sum(case
when customer_list_id is null then 1
else 0
end) totalIndividual,
sum(case
when status = 0 then 1
else 0
end) totalNotInteractive,
sum(case
when status in (select * from status_customer) then 1
else 0
end) totalNotCall
from campaign_customer
where :p_cus_list_id is null or customer_list_id = :p_cus_list_id
group by campaign_id
)
select a.*, b.customer_number campaignCustomer
from count_customer a
left join campaign b on a.campaignId = b.campaign_id
where a.campaignId = :p_campaign_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