Commit 6f785531 authored by đinh thị đầm's avatar đinh thị đầm
parents 1da529f9 6d5f50f1
...@@ -14,6 +14,14 @@ import java.util.List; ...@@ -14,6 +14,14 @@ import java.util.List;
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public interface CampaignCustomerRepository extends JpaRepository<CampaignCustomer, Long>, CampaignCustomerRepositoryCustom { public interface CampaignCustomerRepository extends JpaRepository<CampaignCustomer, Long>, CampaignCustomerRepositoryCustom {
CampaignCustomer findCampaignCustomerByCampaignCustomerId(Long id);
CampaignCustomer findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId(Long campaignId, Long companySiteId, Long customerId);
List<CampaignCustomer> findCampaignCustomersByCampaignIdAndCompanySiteIdAndCustomerIdAndInCampaignStatus(Long campaignId, Long companySiteId, Long customerId, Short inCampaingStatus);
CampaignCustomer findCampaignCustomersByCampaignIdAndCustomerId(Long campaignId, Long customerId);
@Query(value = "SELECT COUNT(*) " + @Query(value = "SELECT COUNT(*) " +
" FROM CAMPAIGN_CUSTOMER CC " + " FROM CAMPAIGN_CUSTOMER CC " +
" JOIN CAMPAIGN C ON CC.CAMPAIGN_ID = C.CAMPAIGN_ID " + " JOIN CAMPAIGN C ON CC.CAMPAIGN_ID = C.CAMPAIGN_ID " +
...@@ -34,10 +42,6 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom ...@@ -34,10 +42,6 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
"AND CCC.STATUS = 1 ", nativeQuery = true) "AND CCC.STATUS = 1 ", nativeQuery = true)
Long getCustomerRecall(@Param("campaignId") Long campaignId, @Param("customerId") Long customerId); Long getCustomerRecall(@Param("campaignId") Long campaignId, @Param("customerId") Long customerId);
CampaignCustomer findCampaignCustomerByCampaignCustomerId(Long id);
@Query(value = "select C.NAME, " + @Query(value = "select C.NAME, " +
"C.EMAIL, " + "C.EMAIL, " +
"C.PLACE_OF_BIRTH, " + "C.PLACE_OF_BIRTH, " +
...@@ -57,10 +61,6 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom ...@@ -57,10 +61,6 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
, nativeQuery = true) , nativeQuery = true)
Long searchCustomer(@Param("site_id") Long pSiteId); Long searchCustomer(@Param("site_id") Long pSiteId);
@Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " + @Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " +
"WHERE CC.STATUS = 0 " + "WHERE CC.STATUS = 0 " +
"AND CC.CAMPAIGN_ID = :campaignId " + "AND CC.CAMPAIGN_ID = :campaignId " +
...@@ -88,10 +88,6 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom ...@@ -88,10 +88,6 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
" and (status = 0 or status in (select * from status_customer))", nativeQuery = true) " 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); List<CampaignCustomer> findListCustomerToDel(@Param("p_company_site_id") Long companySiteId, @Param("p_campaign_id") Long campaignId, @Param("p_cus_list_id") Long customerListId);
CampaignCustomer findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId(Long campaignId, Long companySiteId, Long customerId);
List<CampaignCustomer> findCampaignCustomersByCampaignIdAndCompanySiteIdAndCustomerIdAndInCampaignStatus(Long campaignId, Long companySiteId, Long customerId, Short inCampaingStatus);
@Query(value = "select complete_value from campaign_complete_code where status = 1 and complete_type = 1", nativeQuery = true) @Query(value = "select complete_value from campaign_complete_code where status = 1 and complete_type = 1", nativeQuery = true)
List<Short> getStatus(); List<Short> getStatus();
} }
...@@ -21,4 +21,6 @@ public interface CampaignExecuteRepository { ...@@ -21,4 +21,6 @@ public interface CampaignExecuteRepository {
List<ContactCustResultDTO> getInteractiveResult(CampaignRequestDTO dto, Pageable pageable); List<ContactCustResultDTO> getInteractiveResult(CampaignRequestDTO dto, Pageable pageable);
List<ContactCustResultDTO> getExcelInteractiveResult(CampaignRequestDTO dto); List<ContactCustResultDTO> getExcelInteractiveResult(CampaignRequestDTO dto);
List<ContactQuestResultDTO> createListContacQuestResult(List<ContactQuestResultDTO> dtoList);
} }
...@@ -2,8 +2,15 @@ package com.viettel.campaign.repository.ccms_full; ...@@ -2,8 +2,15 @@ package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.model.ccms_full.ContactCustResult; import com.viettel.campaign.model.ccms_full.ContactCustResult;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.sql.Date;
@Repository @Repository
public interface ContactCustResultRepository extends JpaRepository<ContactCustResult, Long> { public interface ContactCustResultRepository extends JpaRepository<ContactCustResult, Long> {
@Query(value = "SELECT MAX(createTime) FROM ContactCustResult WHERE campaignId = :campaignId AND agentId = :agentId AND status = 1")
Date getMaxCreateTime(@Param("campaignId") Long campaignId, @Param("agentId") Long agentId);
} }
...@@ -2,15 +2,13 @@ package com.viettel.campaign.repository.ccms_full.impl; ...@@ -2,15 +2,13 @@ package com.viettel.campaign.repository.ccms_full.impl;
import com.viettel.campaign.config.DataSourceQualify; import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.repository.ccms_full.CampaignExecuteRepository; import com.viettel.campaign.repository.ccms_full.CampaignExecuteRepository;
import com.viettel.campaign.repository.ccms_full.ContactQuestResultRepository;
import com.viettel.campaign.repository.ccms_full.TimeRangeDialModeRepository; import com.viettel.campaign.repository.ccms_full.TimeRangeDialModeRepository;
import com.viettel.campaign.repository.ccms_full.TimeZoneDialModeRepository; import com.viettel.campaign.repository.ccms_full.TimeZoneDialModeRepository;
import com.viettel.campaign.utils.Constants; import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.DataUtil; import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.HibernateUtil; import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.web.dto.ApParamDTO; import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ContactCustResultDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO; import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.hibernate.SQLQuery; import org.hibernate.SQLQuery;
import org.hibernate.Session; import org.hibernate.Session;
...@@ -57,6 +55,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -57,6 +55,9 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
@Autowired @Autowired
TimeRangeDialModeRepository rangeDialModeRepository; TimeRangeDialModeRepository rangeDialModeRepository;
@Autowired
ContactQuestResultRepository contactQuestResultRepository;
@Override @Override
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<>();
...@@ -584,4 +585,28 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -584,4 +585,28 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
return result; return result;
} }
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<ContactQuestResultDTO> createListContacQuestResult(List<ContactQuestResultDTO> dtoList) {
ResultDTO resultDTO = new ResultDTO();
List<ContactQuestResultDTO> list = new ArrayList<>();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
// list = contactQuestResultRepository.saveAll(dtoList);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
}
return list;
}
} }
...@@ -800,74 +800,74 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -800,74 +800,74 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
// StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
try { try {
// String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-customer-list-choosen"); // String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-customer-list-choosen");
String sql = "with campaign_customer_id as (\n" + sb.append(" with campaign_customer_id as (");
" select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl\n" + sb.append(" select ccl.CUSTOMER_LIST_ID from campaign_customerlist ccl");
" where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id\n" + sb.append(" where ccl.campaign_id = :p_campaign_id and ccl.company_site_id = :p_company_site_id");
"),\n" + sb.append(" ),");
"customer_table as (\n" + sb.append(" customer_table as (");
" select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a\n" + sb.append(" select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a");
" left join customer b on a.customer_id = b.customer_id\n" + sb.append(" left join customer b on a.customer_id = b.customer_id");
" where b.status = 1\n" + sb.append(" where b.status = 1");
" group by a.customer_list_id\n" + sb.append(" group by a.customer_list_id");
"),\n" + sb.append(" ),");
"customer_active_table as (\n" + sb.append(" customer_active_table as (");
" select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a\n" + sb.append(" select count(a.customer_id) customerActive, a.customer_list_id customerListId from customer_list_mapping a");
" left join customer b on a.customer_id = b.customer_id\n" + sb.append(" left join customer b on a.customer_id = b.customer_id");
" where b.status = 1 and b.ipcc_status = 'active'\n" + sb.append(" where b.status = 1 and b.ipcc_status = 'active'");
" group by a.customer_list_id\n" + sb.append(" group by a.customer_list_id");
"),\n" + sb.append(" ),");
"customer_lock_table as (\n" + sb.append(" customer_lock_table as (");
" select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a\n" + sb.append(" select count(a.customer_id) customerLock, a.customer_list_id customerListId from customer_list_mapping a");
" left join customer b on a.customer_id = b.customer_id\n" + sb.append(" left join customer b on a.customer_id = b.customer_id");
" where b.status = 1 and b.ipcc_status = 'locked'\n" + sb.append(" where b.status = 1 and b.ipcc_status = 'locked'");
" group by a.customer_list_id\n" + sb.append(" group by a.customer_list_id");
"),\n" + sb.append(" ),");
"customer_dnc_table as (\n" + sb.append(" customer_dnc_table as (");
" select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a\n" + sb.append(" select count(a.customer_id) customerDnc, a.customer_list_id customerListId from customer_list_mapping a");
" left join customer b on a.customer_id = b.customer_id\n" + sb.append(" left join customer b on a.customer_id = b.customer_id");
" where b.status = 1 and b.call_allowed = 0\n" + sb.append(" where b.status = 1 and b.call_allowed = 0");
" group by a.customer_list_id\n" + sb.append(" group by a.customer_list_id");
"),\n" + sb.append(" ),");
"customer_filter_table as (\n" + sb.append(" customer_filter_table as (");
" select count(a.customer_id) customerFilter, a.customer_list_id customerListId from campaign_customer a\n" + sb.append(" select count(a.customer_id) customerFilter, a.customer_list_id customerListId from campaign_customer a");
" where a.campaign_id = :p_campaign_id and a.in_campaign_status = 1\n" + sb.append(" where a.campaign_id = :p_campaign_id and a.in_campaign_status = 1");
" group by a.customer_list_id\n" + sb.append(" group by a.customer_list_id");
"),\n" + sb.append(" ),");
"data_temp as (\n" + sb.append(" data_temp as (");
"select a.customer_list_id customerListId,\n" + sb.append(" select a.customer_list_id customerListId,");
" a.customer_list_code customerListCode,\n" + sb.append(" a.customer_list_code customerListCode,");
" a.customer_list_name customerListName,\n" + sb.append(" a.customer_list_name customerListName,");
" nvl(b.totalCustomer, 0) totalCusList,\n" + sb.append(" nvl(b.totalCustomer, 0) totalCusList,");
" nvl(c.customerActive, 0) totalCusActive,\n" + sb.append(" nvl(c.customerActive, 0) totalCusActive,");
" nvl(d.customerLock, 0) totalCusLock,\n" + sb.append(" nvl(d.customerLock, 0) totalCusLock,");
" nvl(e.customerDnc, 0) totalCusDnc,\n" + sb.append(" nvl(e.customerDnc, 0) totalCusDnc,");
" nvl(null, 0) totalCusAddRemove,\n" + sb.append(" nvl(null, 0) totalCusAddRemove,");
" nvl(f.customerFilter, 0) totalCusFilter\n" + sb.append(" nvl(f.customerFilter, 0) totalCusFilter");
"from customer_list a\n" + sb.append(" from customer_list a");
"left join customer_table b on a.customer_list_id = b.customerListId\n" + sb.append(" left join customer_table b on a.customer_list_id = b.customerListId");
"left join customer_active_table c on a.customer_list_id = c.customerListId\n" + sb.append(" left join customer_active_table c on a.customer_list_id = c.customerListId");
"left join customer_lock_table d on a.customer_list_id = d.customerListId\n" + sb.append(" left join customer_lock_table d on a.customer_list_id = d.customerListId");
"left join customer_dnc_table e on a.customer_list_id = e.customerListId\n" + sb.append(" left join customer_dnc_table e on a.customer_list_id = e.customerListId");
"left join customer_filter_table f on a.customer_list_id = f.customerListId\n" + sb.append(" left join customer_filter_table f on a.customer_list_id = f.customerListId");
"where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)\n" + sb.append(" where a.customer_list_id in (select CUSTOMER_LIST_ID from campaign_customer_id)");
"),\n" + sb.append(" ),");
"data as (\n" + sb.append(" data as (");
"select a.*, rownum row_ from data_temp a\n" + sb.append(" select a.*, rownum row_ from data_temp a");
"),\n" + sb.append(" ),");
"count_data as (\n" + sb.append(" count_data as (");
"select count(*) totalRow from data_temp\n" + sb.append(" select count(*) totalRow from data_temp");
")\n" + sb.append(" )");
"select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter, totalRow from data a, count_data\n" + sb.append(" select a.customerListId, a.customerListCode, a.customerListName, a.totalCusList, a.totalCusActive, a.totalCusLock, a.totalCusDnc, a.totalCusAddRemove, a.totalCusFilter, totalRow from data a, count_data");
"where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)\n" + sb.append(" where row_ >= ((:p_page_number - 1) * :p_page_size + 1) and row_ < (:p_page_number * :p_page_size + 1)");
"order by a.customerListName"; sb.append(" order by a.customerListName");
params.put("p_campaign_id", dto.getCampaignId()); params.put("p_campaign_id", dto.getCampaignId());
params.put("p_company_site_id", dto.getCompanySiteId()); params.put("p_company_site_id", dto.getCompanySiteId());
params.put("p_page_number", dto.getPage().toString()); params.put("p_page_number", dto.getPage().toString());
params.put("p_page_size", dto.getPageSize().toString()); params.put("p_page_size", dto.getPageSize().toString());
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(CustomerListDTO.class)); list = namedParameterJdbcTemplate.query(sb.toString(), params, BeanPropertyRowMapper.newInstance(CustomerListDTO.class));
int total = 0; int total = 0;
if (list.size() > 0) { if (list.size() > 0) {
total = list.get(0).getTotalRow(); total = list.get(0).getTotalRow();
......
...@@ -10,7 +10,6 @@ import org.springframework.stereotype.Service; ...@@ -10,7 +10,6 @@ import org.springframework.stereotype.Service;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@Service
public interface CampaignExecuteService { public interface CampaignExecuteService {
//<editor-fold: hungtt> //<editor-fold: hungtt>
ResultDTO getComboBoxStatus(String companySiteId, String completeType); ResultDTO getComboBoxStatus(String companySiteId, String completeType);
...@@ -37,7 +36,7 @@ public interface CampaignExecuteService { ...@@ -37,7 +36,7 @@ public interface CampaignExecuteService {
ResultDTO getAgentLogout(CampaignRequestDTO dto); ResultDTO getAgentLogout(CampaignRequestDTO dto);
ResultDTO callCustomer(ContactCustResultDTO dto, UserSession userSession); ResultDTO updateContactCustResult(ContactCustResultDTO dto, UserSession userSession);
ResultDTO recallCustomer(ContactCustResultDTO dto); ResultDTO recallCustomer(ContactCustResultDTO dto);
......
...@@ -538,11 +538,36 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -538,11 +538,36 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
} }
@Override @Override
public ResultDTO callCustomer(ContactCustResultDTO dto, UserSession userSession) { public ResultDTO updateContactCustResult(ContactCustResultDTO dto, UserSession userSession) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
ContactCustResult ccr = new ContactCustResult();
try { try {
ContactCustResult ccr = ccResultRepository.save(modelMapper.map(dto, ContactCustResult.class)); if (dto.getEventCall().equalsIgnoreCase("call")) {
ccr = ccResultRepository.save(modelMapper.map(dto, ContactCustResult.class));
} else if (dto.getContactCustResultId() != null) {
ccr = ccResultRepository.getOne(dto.getContactCustResultId());
if (dto.getEventCall().equalsIgnoreCase("ringing")) {
ccr.setCallId(dto.getCallId());
ccr.setUpdateBy(userSession.getUserId());
ccr.setUpdateTime(new Date());
ccr = ccResultRepository.save(ccr);
} else if (dto.getEventCall().equalsIgnoreCase("ended")) {
ccr.setDurationCall(dto.getDurationCall());
ccr.setStartCall(dto.getStartCall());
ccr.setReceiveTime(dto.getReceiveTime()); //
ccr.setPreEndTime(ccResultRepository.getMaxCreateTime(dto.getCampaignId(), dto.getAgentId()));
ccr.setEndTime(dto.getEndTime());
ccr.setWaitTime(dto.getWaitTime());
ccr = ccResultRepository.save(ccr);
CampaignCustomer cc = campaignCustomerRepository.findCampaignCustomersByCampaignIdAndCustomerId(dto.getCampaignId(), dto.getCustomerId());
cc.setCallTime(dto.getStartCall());
cc = campaignCustomerRepository.save(cc);
Agents ag = agentsRepository.findByAgentId(dto.getAgentId().toString());
ag.setSystemStatus("AVAILABLE");
ag = agentsRepository.save(ag);
}
}
result.setErrorCode(Constants.ApiErrorCode.SUCCESS); result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS); result.setDescription(Constants.ApiErrorDesc.SUCCESS);
...@@ -682,7 +707,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -682,7 +707,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
} }
@Override @Override
@Transactional @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO createListContacQuestResult(List<ContactQuestResultDTO> dtoList) { public ResultDTO createListContacQuestResult(List<ContactQuestResultDTO> dtoList) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
List<ContactQuestResult> lstContactQuestResult = new ArrayList<>(); List<ContactQuestResult> lstContactQuestResult = new ArrayList<>();
...@@ -692,7 +717,8 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService { ...@@ -692,7 +717,8 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
} }
try { try {
List<ContactQuestResult> dataReturn = contactQuestResultRepository.saveAll(lstContactQuestResult); List<ContactQuestResult> dataReturn = new ArrayList<>();
dataReturn = contactQuestResultRepository.saveAll(lstContactQuestResult);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setListData(dataReturn); resultDTO.setListData(dataReturn);
......
...@@ -55,4 +55,5 @@ public class ContactCustResultDTO extends BaseDTO { ...@@ -55,4 +55,5 @@ public class ContactCustResultDTO extends BaseDTO {
private Boolean enableEdit; private Boolean enableEdit;
private Integer totalRow; private Integer totalRow;
private String eventCall;
} }
package com.viettel.campaign.web.rest; package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.ContactQuestResult;
import com.viettel.campaign.service.CampaignExecuteService; import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.utils.RedisUtil; import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.*; import com.viettel.campaign.web.dto.*;
...@@ -25,7 +24,7 @@ import java.util.List; ...@@ -25,7 +24,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/ipcc/campaign/execute") @RequestMapping("/ipcc/campaign/execute")
@CrossOrigin //@CrossOrigin
public class CampaignExecuteController { public class CampaignExecuteController {
private static final Logger logger = LoggerFactory.getLogger(CampaignController.class); private static final Logger logger = LoggerFactory.getLogger(CampaignController.class);
...@@ -136,12 +135,12 @@ public class CampaignExecuteController { ...@@ -136,12 +135,12 @@ public class CampaignExecuteController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@PostMapping("/callCustomer") @PostMapping("/updateContactCustResult")
@ResponseBody @ResponseBody
public ResponseEntity<ResultDTO> callCustomer(@RequestBody ContactCustResultDTO requestDto, HttpServletRequest request) { public ResponseEntity<ResultDTO> updateContactCustResult(@RequestBody ContactCustResultDTO requestDto, HttpServletRequest request) {
String xAuthToken = request.getHeader("X-Auth-Token"); String xAuthToken = request.getHeader("X-Auth-Token");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken); UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
ResultDTO result = campaignExecuteService.callCustomer(requestDto, userSession); ResultDTO result = campaignExecuteService.updateContactCustResult(requestDto, userSession);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
...@@ -166,7 +165,7 @@ public class CampaignExecuteController { ...@@ -166,7 +165,7 @@ public class CampaignExecuteController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@PostMapping("/createListContactQuestResult") @PutMapping("/createListContactQuestResult")
@ResponseBody @ResponseBody
public ResponseEntity<ResultDTO> createListContactQuestResult(@RequestBody List<ContactQuestResultDTO> dtoList) { public ResponseEntity<ResultDTO> createListContactQuestResult(@RequestBody List<ContactQuestResultDTO> dtoList) {
ResultDTO result = null; ResultDTO result = null;
......
...@@ -198,20 +198,16 @@ public class CustomerController { ...@@ -198,20 +198,16 @@ public class CustomerController {
try { try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(request.getHeader("X-Auth-Token")); UserSession userSession = (UserSession) RedisUtil.getInstance().get(request.getHeader("X-Auth-Token"));
if (file.isEmpty()) { if (file.isEmpty()) {
return new ResponseEntity<>("file-empty", HttpStatus.BAD_REQUEST); return new ResponseEntity<>("file-empty", HttpStatus.NO_CONTENT);
} }
String path = saveUploadFile(file); String path = saveUploadFile(file);
List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId()); List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, Long.parseLong(customerListId)); Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, Long.parseLong(customerListId));
String message = (String) map.get("message"); String message = (String) map.get("message");
byte[] content = (byte[]) map.get("content"); byte[] content = (byte[]) map.get("content");
if (message.equals("import-success")) {
return ResponseEntity.ok() return ResponseEntity.ok()
.header("Message", message) .header("Message", message)
.body(content); .body(content);
} else {
return ResponseEntity.badRequest().header("Message", message).body(content);
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.error(e.getMessage()); LOGGER.error(e.getMessage());
return new ResponseEntity<>(HttpStatus.BAD_REQUEST); return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
...@@ -266,18 +262,15 @@ public class CustomerController { ...@@ -266,18 +262,15 @@ public class CustomerController {
} }
private String saveUploadFile(MultipartFile file) { private String saveUploadFile(MultipartFile file) {
try { try {
String currentTime = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss").format(new Date()); String currentTime = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss").format(new Date());
String fileName = FilenameUtils.getBaseName(file.getOriginalFilename()) + "_" + currentTime + "." + FilenameUtils.getExtension(file.getOriginalFilename()); String fileName = FilenameUtils.getBaseName(file.getOriginalFilename()) + "_" + currentTime + "." + FilenameUtils.getExtension(file.getOriginalFilename());
byte[] content = file.getBytes(); byte[] content = file.getBytes();
// File uploadFolder = new File(BundleUtils.getGlobalConfig("import.uploadFolder"));
File uploadFolder = new File(Config.EXCEL_DIR); File uploadFolder = new File(Config.EXCEL_DIR);
if (!uploadFolder.exists()) { if (!uploadFolder.exists()) {
uploadFolder.mkdir(); uploadFolder.mkdir();
} }
// Path path = Paths.get(BundleUtils.getGlobalConfig("import.uploadFolder"), fileName);
Path path = Paths.get(Config.EXCEL_DIR, fileName); Path path = Paths.get(Config.EXCEL_DIR, fileName);
Files.write(path, content); Files.write(path, content);
return path.toString(); return path.toString();
...@@ -287,7 +280,7 @@ public class CustomerController { ...@@ -287,7 +280,7 @@ public class CustomerController {
return null; return null;
} }
// @GetMapping("/query") // @GetMapping("/query")
// public ResponseEntity<List<Customer>> query(@RequestParam(value = "search") String query) { // public ResponseEntity<List<Customer>> query(@RequestParam(value = "search") String query) {
// List<Customer> things = customerQueryRepo.findAll(query); // List<Customer> things = customerQueryRepo.findAll(query);
// if (things.isEmpty()) { // if (things.isEmpty()) {
...@@ -295,12 +288,12 @@ public class CustomerController { ...@@ -295,12 +288,12 @@ public class CustomerController {
// } // }
// return ResponseEntity.ok(things); // return ResponseEntity.ok(things);
// } // }
@GetMapping(path = "", produces = { MediaType.APPLICATION_JSON_VALUE }) @GetMapping(path = "", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<Customer>> query(@RequestParam(value = "search") String query) { public ResponseEntity<List<Customer>> query(@RequestParam(value = "search") String query) {
List<Customer> result = null; List<Customer> result = null;
try { try {
result= customerService.searchByQuery(query); result = customerService.searchByQuery(query);
}catch (IllegalArgumentException iae){ } catch (IllegalArgumentException iae) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST) return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(result); .body(result);
} }
...@@ -317,7 +310,7 @@ public class CustomerController { ...@@ -317,7 +310,7 @@ public class CustomerController {
@PostMapping("/searchIndividualCustomer") @PostMapping("/searchIndividualCustomer")
@ResponseBody @ResponseBody
public ResponseEntity searchCustomizeFields(@RequestBody CampaignCustomerDTO campaignCustomerDTO ) { public ResponseEntity searchCustomizeFields(@RequestBody CampaignCustomerDTO campaignCustomerDTO) {
ResultDTO result = customerService.searchCustomizeFields(campaignCustomerDTO); ResultDTO result = customerService.searchCustomizeFields(campaignCustomerDTO);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
......
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