Commit 918d6a03 authored by ='s avatar =

Merge remote-tracking branch 'origin/master'

parents 4ec3f526 79e56468
<<<<<<< HEAD
[main] 26/08/2019 09:46:33 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 26/08/2019 10:25:08 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 26/08/2019 10:29:12 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 26/08/2019 10:31:57 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 26/08/2019 10:36:03 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 26/08/2019 10:39:17 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 26/08/2019 10:42:36 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 26/08/2019 10:44:03 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
=======
[main] 26/08/2019 09:11:22 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016 [main] 26/08/2019 09:11:22 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 26/08/2019 09:27:36 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016 [main] 26/08/2019 09:27:36 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
[main] 26/08/2019 09:39:31 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016 [main] 26/08/2019 09:39:31 INFO RedisUtil: (38) : Start connect Redis: 10.60.156.82:8011,10.60.156.82:8012,10.60.156.82:8013,10.60.156.82:8014,10.60.156.82:8015,10.60.156.82:8016
...@@ -216,3 +226,4 @@ java.lang.NullPointerException ...@@ -216,3 +226,4 @@ java.lang.NullPointerException
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:748) at java.lang.Thread.run(Thread.java:748)
>>>>>>> 5569a655cf439bfadfa12735a03e56f1c4aaceef
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
<dependency> <dependency>
<groupId>com.oracle</groupId> <groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId> <artifactId>ojdbc7</artifactId>
<scope>system</scope> <!-- <scope>system</scope>-->
<systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath> <!-- <systemPath>${project.basedir}/lib/ojdbc7.jar</systemPath>-->
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -2,7 +2,6 @@ package com.viettel.campaign.filter; ...@@ -2,7 +2,6 @@ package com.viettel.campaign.filter;
import com.viettel.campaign.utils.RedisUtil; import com.viettel.campaign.utils.RedisUtil;
import com.viettel.econtact.filter.UserSession; import com.viettel.econtact.filter.UserSession;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.servlet.*; import javax.servlet.*;
...@@ -31,27 +30,27 @@ public class CorsFilter implements Filter { ...@@ -31,27 +30,27 @@ public class CorsFilter implements Filter {
HttpServletRequest request = (HttpServletRequest) req; HttpServletRequest request = (HttpServletRequest) req;
chain.doFilter(req, resp); // chain.doFilter(req, response);
// if ("OPTIONS".equalsIgnoreCase(request.getMethod())) { if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
// chain.doFilter(req, resp); chain.doFilter(req, resp);
// return; return;
// } }
// if ("/".equals(request.getRequestURI())) { if ("/".equals(request.getRequestURI())) {
// chain.doFilter(req, resp); chain.doFilter(req, resp);
// return; return;
// } }
// String xAuthToken = request.getHeader("X-Auth-Token"); String xAuthToken = request.getHeader("X-Auth-Token");
// if (xAuthToken == null || "".equals(xAuthToken)) { if (xAuthToken == null || "".equals(xAuthToken)) {
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null."); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is null.");
// return; return;
// } }
// Object obj = RedisUtil.getInstance().get(xAuthToken); Object obj = RedisUtil.getInstance().get(xAuthToken);
// if (obj instanceof UserSession) { if (obj instanceof UserSession) {
// chain.doFilter(req, resp); chain.doFilter(req, resp);
// } else { } else {
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid."); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "The token is invalid.");
// } }
} }
@Override @Override
......
...@@ -42,69 +42,69 @@ public class CampaignJob { ...@@ -42,69 +42,69 @@ public class CampaignJob {
// @Scheduled(fixedRate = 5000) // @Scheduled(fixedRate = 5000)
// @Transactional( propagation = Propagation.REQUIRED) // @Transactional( propagation = Propagation.REQUIRED)
public void process() { public void process() {
// log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date())); log.info(Thread.currentThread().getName() + " The Task executed at " + dateFormat.format(new Date()));
// List<ProcessConfig> list = processConfigService.findAll(); List<ProcessConfig> list = processConfigService.findAll();
//
// list.parallelStream().forEach(p -> { list.parallelStream().forEach(p -> {
// boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess()); boolean isExecute = DateTimeUtil.isRun(p.getConfigValue(), p.getLastProcess());
// switch (p.getConfigCode()){ switch (p.getConfigCode()){
// case CUSTOMER_INACTIVE_DUARATION: case CUSTOMER_INACTIVE_DUARATION:
// if(isExecute){ if(isExecute){
// List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date()); List<Customer> customers = customerService.findAllByCondition(p.getSiteId(), new Date());
// updateCustomer(customers); updateCustomer(customers);
// updateCustomerTime(customers); updateCustomerTime(customers);
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId()); log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date()); p.setLastProcess(new Date());
// processConfigService.update(p); processConfigService.update(p);
// } }
// break; break;
// case CRON_EXPRESSION_CHECK_START: case CRON_EXPRESSION_CHECK_START:
// // process // process
// if(isExecute){ if(isExecute){
// List<Long> status = new ArrayList<>(); List<Long> status = new ArrayList<>();
// status.add(1L); status.add(1L);
// status.add(1L); status.add(1L);
// List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status); List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndStartTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
// campaigns.parallelStream().forEach(campaign -> { campaigns.parallelStream().forEach(campaign -> {
// log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId()); log.info("Chuyen trang thai chien dich ... #{} ... tu Du thao sang Trien khai", campaign.getCampaignId());
// campaign.setProcessStatus(1); campaign.setProcessStatus(1);
// campaign.setStatus(2L); campaign.setStatus(2L);
// campaign.setCampaignStart(new Date()); campaign.setCampaignStart(new Date());
// campaignService.updateProcess(campaign); campaignService.updateProcess(campaign);
// //write log //write log
// saveLog(campaign, 1); saveLog(campaign, 1);
// }); });
//
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId()); log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date()); p.setLastProcess(new Date());
// processConfigService.update(p); processConfigService.update(p);
// } }
// break; break;
// case CRON_EXPRESSION_CHECK_END: case CRON_EXPRESSION_CHECK_END:
// // process // process
// if(isExecute){ if(isExecute){
// List<Long> status = new ArrayList<>(); List<Long> status = new ArrayList<>();
// status.add(2L); status.add(2L);
// status.add(3L); status.add(3L);
// List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status); List<Campaign> campaigns = campaignService.findCampaignByCompanySiteIdAndEndTimeIsLessThanEqualAndStatusIn(p.getSiteId(), new Date(), status);
// campaigns.parallelStream().forEach(campaign -> { campaigns.parallelStream().forEach(campaign -> {
// log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId()); log.info("Chuyen trang thai chien dich ... #{} ... sang Ket thuc", campaign.getCampaignId());
// campaign.setStatus(4L); campaign.setStatus(4L);
// campaign.setCampaignEnd(new Date()); campaign.setCampaignEnd(new Date());
// campaignService.updateProcess(campaign); campaignService.updateProcess(campaign);
// //write log //write log
// saveLog(campaign, 2); saveLog(campaign, 2);
// }); });
//
// log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId()); log.info("Cap nhat thoi gian thuc hien tien trinh cho siteId ... #{}", p.getSiteId());
// p.setLastProcess(new Date()); p.setLastProcess(new Date());
// processConfigService.update(p); processConfigService.update(p);
// } }
// break; break;
// default: default:
// // update last check time // update last check time
// } }
// }); });
} }
......
...@@ -11,7 +11,7 @@ import org.springframework.stereotype.Repository; ...@@ -11,7 +11,7 @@ import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@Repository @Repository
public interface ApParamRepository extends JpaRepository<ApParam, Long>, ApParamRepositoryCustom { public interface ApParamRepository extends JpaRepository<ApParam, Long> {
Page<ApParam> findAll(Pageable pageable); Page<ApParam> findAll(Pageable pageable);
......
package com.viettel.campaign.repository.ccms_full;
import org.springframework.stereotype.Repository;
@Repository
public interface ApParamRepositoryCustom {
}
package com.viettel.campaign.repository.ccms_full; package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.model.ccms_full.Ticket; 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 { 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; ...@@ -22,7 +22,6 @@ import java.util.List;
public class CampaignCustomerListColumnRepositoryImpl implements CampaignCustomerListColumnRepositoryCustom { public class CampaignCustomerListColumnRepositoryImpl implements CampaignCustomerListColumnRepositoryCustom {
@Override @Override
public List<CampaignCustomerListColumnRequestDTO> getCustomerInfor(Long companySiteId, Long customerId, Long campaignId) { public List<CampaignCustomerListColumnRequestDTO> getCustomerInfor(Long companySiteId, Long customerId, Long campaignId) {
ResultDTO result = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
List<CampaignCustomerListColumnRequestDTO> data = new ArrayList<>(); List<CampaignCustomerListColumnRequestDTO> data = new ArrayList<>();
...@@ -68,8 +67,7 @@ public class CampaignCustomerListColumnRepositoryImpl implements CampaignCustome ...@@ -68,8 +67,7 @@ public class CampaignCustomerListColumnRepositoryImpl implements CampaignCustome
data = query.list(); data = query.list();
} catch (Exception e) { } catch (Exception e) {
result.setErrorCode(Constants.ApiErrorCode.ERROR); e.printStackTrace();
result.setDescription(Constants.ApiErrorDesc.ERROR);
} finally { } finally {
session.close(); session.close();
} }
......
...@@ -20,7 +20,6 @@ public class TicketRepositoryImpl implements TicketRepositoryCustom { ...@@ -20,7 +20,6 @@ public class TicketRepositoryImpl implements TicketRepositoryCustom {
@PersistenceContext( unitName= DataSourceQualify.JPA_UNIT_NAME_CCMS_FULL) @PersistenceContext( unitName= DataSourceQualify.JPA_UNIT_NAME_CCMS_FULL)
EntityManager entityManager; EntityManager entityManager;
@Override
public List<TicketDTO> getHistory(String customerId, Pageable pageable) { public List<TicketDTO> getHistory(String customerId, Pageable pageable) {
List<TicketDTO> lst = new ArrayList<>(); List<TicketDTO> lst = new ArrayList<>();
String expression = new StringBuilder() String expression = new StringBuilder()
......
...@@ -34,6 +34,8 @@ public interface CustomerService { ...@@ -34,6 +34,8 @@ public interface CustomerService {
ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId); ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId);
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName); ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO); ResultDTO updateCustomerList(CustomerListDTO customerListDTO);
......
package com.viettel.campaign.service; package com.viettel.campaign.service;
import java.util.Map; import com.viettel.campaign.web.dto.ResultDTO;
public interface TicketService { public interface TicketService {
Map getHistory(int page, int pageSize, String sort, String customerId); ResultDTO getHistory(int page, int pageSize, String sort, String customerId);
} }
...@@ -3,6 +3,8 @@ package com.viettel.campaign.service.impl; ...@@ -3,6 +3,8 @@ package com.viettel.campaign.service.impl;
import com.viettel.campaign.config.DataSourceQualify; import com.viettel.campaign.config.DataSourceQualify;
import com.viettel.campaign.repository.ccms_full.TicketRepository; import com.viettel.campaign.repository.ccms_full.TicketRepository;
import com.viettel.campaign.service.TicketService; 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 com.viettel.campaign.web.dto.TicketDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
...@@ -11,9 +13,7 @@ import org.springframework.stereotype.Service; ...@@ -11,9 +13,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Service @Service
public class TicketServiceImpl implements TicketService { public class TicketServiceImpl implements TicketService {
...@@ -21,16 +21,29 @@ public class TicketServiceImpl implements TicketService { ...@@ -21,16 +21,29 @@ public class TicketServiceImpl implements TicketService {
@Autowired @Autowired
TicketRepository ticketRepository; TicketRepository ticketRepository;
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public Map getHistory(int page, int pageSize, String sort, String customerId) { public ResultDTO getHistory(int page, int pageSize, String sort, String customerId) {
Map result = new HashMap(); ResultDTO result = new ResultDTO();
List<TicketDTO> lst = new ArrayList<>(); List<TicketDTO> lst = new ArrayList<>();
lst = ticketRepository.getHistory(customerId, PageRequest.of(page, pageSize, Sort.by(sort))); try {
Integer c = ticketRepository.getHistory(customerId, null).size();
result.put("totalItem", lst.size()); if (c > 0) {
result.put("tickets", lst); 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; return result;
} }
......
...@@ -16,6 +16,7 @@ public class Config { ...@@ -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 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 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 String amcd_xmlrpc_url;
public static int num_client_amcd_xmlprc; public static int num_client_amcd_xmlprc;
...@@ -60,7 +61,7 @@ public class Config { ...@@ -60,7 +61,7 @@ public class Config {
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(Config.class.getName()).error(ex.getMessage(), ex); Logger.getLogger(Config.class.getName()).error(ex.getMessage(), ex);
} }
// PassTranformer.setInputKey("Ipcc#987654321#@!"); PassTranformer.setInputKey("Ipcc#987654321#@!");
// rabbitConnection = properties.getProperty("rabbit_connection_string"); // rabbitConnection = properties.getProperty("rabbit_connection_string");
// fbGatewayUser = PassTranformer.decrypt(properties.getProperty("rabbit_user", "").trim()); // fbGatewayUser = PassTranformer.decrypt(properties.getProperty("rabbit_user", "").trim());
......
...@@ -44,42 +44,6 @@ public class CampaignController { ...@@ -44,42 +44,6 @@ public class CampaignController {
@Autowired @Autowired
CampaignExecuteService campaignExecuteService; 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") @PostMapping("/callCustomer")
@ResponseBody @ResponseBody
public ResponseEntity<ResultDTO> callCustomer(@RequestBody ContactCustResultDTO requestDto) { public ResponseEntity<ResultDTO> callCustomer(@RequestBody ContactCustResultDTO requestDto) {
...@@ -87,13 +51,6 @@ public class CampaignController { ...@@ -87,13 +51,6 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK); 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) @RequestMapping(value = "/search", method = RequestMethod.POST)
public ResponseEntity<ResultDTO> search(@RequestBody CampaignRequestDTO requestDto) { public ResponseEntity<ResultDTO> search(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignService.search(requestDto); ResultDTO result = campaignService.search(requestDto);
...@@ -131,45 +88,6 @@ public class CampaignController { ...@@ -131,45 +88,6 @@ public class CampaignController {
return new ResponseEntity<>(list, HttpStatus.OK); 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) @RequestMapping(value = "/changeCampaignStatus", method = RequestMethod.POST)
public ResultDTO changeCampaignStatus(@RequestBody CampaignDTO dto, HttpServletRequest request) { public ResultDTO changeCampaignStatus(@RequestBody CampaignDTO dto, HttpServletRequest request) {
dto.setSessionId(request.getSession().getId()); dto.setSessionId(request.getSession().getId());
...@@ -248,13 +166,6 @@ public class CampaignController { ...@@ -248,13 +166,6 @@ public class CampaignController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK); 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") @GetMapping("/getCustomerRecall")
@ResponseBody @ResponseBody
public ResponseEntity getCustomerRecall(@RequestParam("campaignId") Long campaignId, @RequestParam("customerId") Long customerId) { public ResponseEntity getCustomerRecall(@RequestParam("campaignId") Long campaignId, @RequestParam("customerId") Long customerId) {
...@@ -340,4 +251,32 @@ public class CampaignController { ...@@ -340,4 +251,32 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@RequestMapping(value = "/import-file", method = RequestMethod.POST)
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestHeader("X-Auth-Token") String authToken) {
Locale locale = new Locale("vi", "VN");
try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(authToken);
if (file.isEmpty()) {
return new ResponseEntity<>(BundleUtils.getLangString("common.fileNotSelected"), HttpStatus.OK);
}
if (!Objects.equals(FilenameUtils.getExtension(file.getOriginalFilename()), Constants.FileType.xlsx)) {
return new ResponseEntity<>(BundleUtils.getLangString("common.fileInvalidFormat", locale), HttpStatus.OK);
}
//String path = saveUploadFile(file);
// List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
// Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, customerListId);
// File fileExport = (File) map.get("file");
// String message = (String) map.get("message");
// return ResponseEntity.ok()
// .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=template_import_customer.xlsx")
// .header("Message", message)
// .body(Files.readAllBytes(fileExport.toPath()));
return new ResponseEntity<>(null, HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
} }
package com.viettel.campaign.web.rest;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.web.dto.CampaignCustomerDTO;
import com.viettel.campaign.web.dto.ReceiveCustLogDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.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);
}
}
...@@ -5,6 +5,7 @@ import com.viettel.campaign.model.ccms_full.CustomizeFieldObject; ...@@ -5,6 +5,7 @@ import com.viettel.campaign.model.ccms_full.CustomizeFieldObject;
import com.viettel.campaign.model.ccms_full.CustomizeFields; import com.viettel.campaign.model.ccms_full.CustomizeFields;
import com.viettel.campaign.service.CustomerService; import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.utils.BundleUtils; import com.viettel.campaign.utils.BundleUtils;
import com.viettel.campaign.utils.Config;
import com.viettel.campaign.utils.Constants; import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.RedisUtil; import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.*; import com.viettel.campaign.web.dto.*;
...@@ -108,13 +109,16 @@ public class CustomerController { ...@@ -108,13 +109,16 @@ public class CustomerController {
@PostMapping("/createCustomerList") @PostMapping("/createCustomerList")
@ResponseBody @ResponseBody
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) { public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
ResultDTO result = new ResultDTO(); // THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
String xAuthToken = request.getHeader("X-Auth-Token"); String xAuthToken = request.getHeader("X-Auth-Token");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken); UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
if (userSession == null) {
result = customerService.createCustomerList(customerListDTO, userSession.getUserName()); userSession = new UserSession();
return result; userSession.setSiteId(customerListDTO.getCompanySiteId());
userSession.setUserName("its4");
}
return customerService.createCustomerList(customerListDTO, userSession.getUserName());
} }
@PostMapping("/updateCustomerList") @PostMapping("/updateCustomerList")
...@@ -187,12 +191,17 @@ public class CustomerController { ...@@ -187,12 +191,17 @@ public class CustomerController {
@PostMapping(value = "/importFile") @PostMapping(value = "/importFile")
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file, public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestParam("customerListId") Long customerListId, @RequestParam("customerListId") String customerListId,
@RequestHeader("X-Auth-Token") String authToken) { HttpServletRequest request) {
LOGGER.info("------------IMPORT FILE TEMPLATE--------------"); LOGGER.info("------------IMPORT FILE TEMPLATE--------------");
Locale locale = new Locale("vi", "VN"); Locale locale = new Locale("vi", "VN");
try { try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(authToken); 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()) { if (file.isEmpty()) {
return new ResponseEntity<>(BundleUtils.getLangString("customer.fileNotSelected"), HttpStatus.OK); return new ResponseEntity<>(BundleUtils.getLangString("customer.fileNotSelected"), HttpStatus.OK);
} }
...@@ -201,7 +210,7 @@ public class CustomerController { ...@@ -201,7 +210,7 @@ public class CustomerController {
} }
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, customerListId); Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, Long.parseLong(customerListId));
File fileExport = (File) map.get("file"); File fileExport = (File) map.get("file");
String message = (String) map.get("message"); String message = (String) map.get("message");
return ResponseEntity.ok() return ResponseEntity.ok()
...@@ -239,11 +248,13 @@ public class CustomerController { ...@@ -239,11 +248,13 @@ public class CustomerController {
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(BundleUtils.getGlobalConfig("import.uploadFolder"));
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(BundleUtils.getGlobalConfig("import.uploadFolder"), fileName);
Path path = Paths.get(Config.EXCEL_DIR, fileName);
Files.write(path, content); Files.write(path, content);
return path.toString(); return path.toString();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -122,7 +122,7 @@ public class ScenarioController { ...@@ -122,7 +122,7 @@ public class ScenarioController {
String message = (String) map.get("message"); String message = (String) map.get("message");
return ResponseEntity.ok() return ResponseEntity.ok()
.header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX) .header("Content-Type", Constants.MIME_TYPE.EXCEL_XLSX)
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=template_import_customer.xlsx") .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=import_scenario_result.xlsx")
.header("Message", message) .header("Message", message)
.body(Files.readAllBytes(fileExport.toPath())); .body(Files.readAllBytes(fileExport.toPath()));
} catch (Exception e) { } catch (Exception e) {
......
package com.viettel.campaign.web.rest; package com.viettel.campaign.web.rest;
import com.viettel.campaign.service.TicketService; import com.viettel.campaign.service.TicketService;
import com.viettel.campaign.web.dto.ResultDTO;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -22,7 +23,7 @@ public class TicketController { ...@@ -22,7 +23,7 @@ public class TicketController {
@GetMapping("/getHistory") @GetMapping("/getHistory")
@ResponseBody @ResponseBody
public ResponseEntity searchCampaignExecute(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("customerId") String customerId) { 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); return new ResponseEntity<>(result, HttpStatus.OK);
} }
} }
...@@ -11,6 +11,11 @@ spring: ...@@ -11,6 +11,11 @@ spring:
ddl-auto: none ddl-auto: none
naming: naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
servlet:
multipart:
enabled: true
max-file-size: 3MB
max-request-size: 3MB
# kafka: # kafka:
# consumer: # consumer:
# bootstrap-servers: 192.168.1.201:9092 # bootstrap-servers: 192.168.1.201:9092
...@@ -40,4 +45,3 @@ datasource-property: ...@@ -40,4 +45,3 @@ datasource-property:
...@@ -108,6 +108,7 @@ customer.emailExists=Email exists; ...@@ -108,6 +108,7 @@ customer.emailExists=Email exists;
common.fileNotSelected=Please select a file common.fileNotSelected=Please select a file
common.fileInvalidFormat=File invalid common.fileInvalidFormat=File invalid
common.invalidTemplate = Template invalid format
#IMPORT SCENARIO TEMPLATE #IMPORT SCENARIO TEMPLATE
scenario.template.title=IMPORT QUESTIONS scenario.template.title=IMPORT QUESTIONS
...@@ -125,3 +126,12 @@ scenario.template.result=Result ...@@ -125,3 +126,12 @@ scenario.template.result=Result
scenario.template.singleChoice=SingleChoice scenario.template.singleChoice=SingleChoice
scenario.template.multiChoice=MultiChoice scenario.template.multiChoice=MultiChoice
scenario.template.text=Text 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,6 +110,7 @@ customer.emailExists=Email đã tồn tại; ...@@ -110,6 +110,7 @@ customer.emailExists=Email đã tồn tại;
common.fileNotSelected=Bạn chưa chọn file common.fileNotSelected=Bạn chưa chọn file
common.fileInvalidFormat=File không hợp lệ common.fileInvalidFormat=File không hợp lệ
common.invalidTemplate = Template sai định dạng
#IMPORT SCENARIO TEMPLATE #IMPORT SCENARIO TEMPLATE
scenario.template.title=IMPORT CÂU HỎI scenario.template.title=IMPORT CÂU HỎI
...@@ -128,6 +129,14 @@ scenario.template.singleChoice=SingleChoice ...@@ -128,6 +129,14 @@ scenario.template.singleChoice=SingleChoice
scenario.template.multiChoice=MultiChoice scenario.template.multiChoice=MultiChoice
scenario.template.text=Text 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"
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