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: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
......@@ -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$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:748)
>>>>>>> 5569a655cf439bfadfa12735a03e56f1c4aaceef
......@@ -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>
......
......@@ -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
}
});
}
......
......@@ -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 {
}
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<>();
......@@ -68,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();
}
......
......@@ -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()
......
......@@ -34,6 +34,8 @@ public interface CustomerService {
ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId);
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO);
......
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);
}
......@@ -421,6 +421,7 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerDetailById(Long companySiteId, Long customerListId, Long customerId) {
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
......@@ -599,35 +600,38 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO 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 resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = new CustomerList();
try {
if (customerListDTO != null) {
// insert
CustomerList findCustomer = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (findCustomer == null) {
customerListDTO.setCreateBy(userName);
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else {
CustomerList cl = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (cl != null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
resultDTO.setDescription("Entity exists");
return resultDTO;
} else {
cl = new CustomerList();
cl.setCustomerListCode(customerListDTO.getCustomerListCode());
cl.setCustomerListName(customerListDTO.getCustomerListName());
cl.setStatus((short) 1);
cl.setCreateBy(userName);
cl.setCreateAt(new Date());
cl.setUpdateBy(null);
cl.setUpdateAt(null);
cl.setSource(null);
cl.setDeptCreate(null);
cl.setCompanySiteId(customerListDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(customerListRepository.save(cl));
return resultDTO;
}
} catch (Exception e) {
e.printStackTrace();
LOGGER.error(e.getMessage());
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription("Error");
return resultDTO;
}
return resultDTO;
}
@Override
......@@ -880,6 +884,7 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<CustomizeFields> getDynamicHeader(Long companySiteId) {
LOGGER.info("------------------GET DYNAMIC HEADER-------------------");
List<CustomizeFields> headerList;
......@@ -893,10 +898,12 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> dynamicHeader, UserSession userSession, Long customerListId) {
LOGGER.info("------------READ AND VALIDATE--------------");
Locale locale = new Locale("vi", "VN");
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
DataFormatter dataFormat = new DataFormatter();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Map<String, Object> result = new HashMap<>();
StringBuilder sb = new StringBuilder();
boolean validateOk = false;
......@@ -972,14 +979,7 @@ public class CustomerServiceImpl implements CustomerService {
for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
Cell dataCell = dataRow.getCell(j);
if (dataCell != null) {
switch (dataCell.getCellTypeEnum()) {
case NUMERIC:
obj[j] = dataCell.getNumericCellValue();
break;
default:
obj[j] = dataCell.getStringCellValue();
break;
}
obj[j] = dataFormat.formatCellValue(dataCell);
} else {
Cell headerCell = row.getCell(j);
if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.cusType", locale))) {
......@@ -1016,9 +1016,12 @@ public class CustomerServiceImpl implements CustomerService {
&& !rawDataList.get(i)[4].toString().trim().equals("")) {
String str = validatePhone(rawDataList.get(i)[2].toString().trim(), locale);
str.concat(validateLength(BundleUtils.getLangString("customer.secondPhone", locale).split("#")[0], rawDataList.get(i)[3].toString(), 50, locale));
if (validateEmail(rawDataList.get(i)[4].toString().trim())) {
str.concat(BundleUtils.getLangString("customer.emailMax50", locale));
if (!validateEmail(rawDataList.get(i)[4].toString().trim())) {
str.concat(BundleUtils.getLangString("customer.emailInvalid", locale));
} else {
str.concat(validateDuplicateEmail(rawDataList.get(i)[4].toString().trim(), locale));
}
sb.append(validateLength(BundleUtils.getLangString("customer.email", locale).split("#")[0], rawDataList.get(i)[4].toString(), 50, locale));
sb.append(str);
} else {
sb.append(BundleUtils.getLangString("customer.invalidCustomer", locale));
......@@ -1032,17 +1035,17 @@ public class CustomerServiceImpl implements CustomerService {
if (rawDataList.get(i).length > 8 && rawDataList.get(i)[8] != null) {
sb.append(validateLength(BundleUtils.getLangString("customer.description", locale).split("#")[0], rawDataList.get(i)[8].toString(), 2000, locale));
}
for (int j = 12; j < header.size(); j++) {
if (rawDataList.get(i).length > j && rawDataList.get(i)[j] != null) {
if (header.get(j).getType().equals("text")) {
sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMinLength(), header.get(j).getMaxLength(), locale));
} else if (header.get(j).getType().equals("date")) {
sb.append(validateUsingRegexp(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getRegexpForValidation(), locale));
} else if (header.get(j).getType().equals("number")) {
sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMin(), header.get(j).getMax(), locale));
}
}
}
// for (int j = 12; j < header.size(); j++) {
// if (rawDataList.get(i).length > j && rawDataList.get(i)[j] != null) {
// if (header.get(j).getType().equals("text")) {
// sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMinLength(), header.get(j).getMaxLength(), locale));
// } else if (header.get(j).getType().equals("date")) {
// sb.append(validateUsingRegexp(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getRegexpForValidation(), locale));
// } else if (header.get(j).getType().equals("number")) {
// sb.append(validateDynamicLength(header.get(j).getTitle(), rawDataList.get(i)[j].toString(), header.get(j).getMin(), header.get(j).getMax(), locale));
// }
// }
// }
Row dataRow = sheet.getRow(4 + i);
Cell resultCell = dataRow.createCell(row.getPhysicalNumberOfCells() - 1);
if (sb.length() > 0) {
......@@ -1061,7 +1064,7 @@ public class CustomerServiceImpl implements CustomerService {
for (int i = 0; i < rawDataList.size(); i++) {
Customer c = new Customer();
c.setName(rawDataList.get(i)[1].toString());
c.setSiteId(userSession.getCompanySiteId());
c.setSiteId(userSession.getSiteId());
c.setCode(null);
c.setDescription(rawDataList.get(i)[8].toString());
c.setCompanyName(rawDataList.get(i)[7].toString());
......@@ -1107,11 +1110,12 @@ public class CustomerServiceImpl implements CustomerService {
}
c.setIpccStatus("active");
Customer saved = customerRepository.save(c);
CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId());
if (rawDataList.get(i).length > 2 && rawDataList.get(i)[2] != null) {
String[] mainPhone = rawDataList.get(i)[2].toString().split(";");
for (int j = 0; j < mainPhone.length; j++) {
CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId());
cc.setSiteId(userSession.getSiteId());
cc.setContactType((short) 5);
cc.setContact(mainPhone[j]);
cc.setIsDirectLine((short) 1);
......@@ -1126,6 +1130,9 @@ public class CustomerServiceImpl implements CustomerService {
if (rawDataList.get(i).length > 3 && rawDataList.get(i)[3] != null) {
String[] subPhone = rawDataList.get(i)[3].toString().split(";");
for (int j = 0; j < subPhone.length; j++) {
CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId());
cc.setSiteId(userSession.getSiteId());
cc.setContactType((short) 5);
cc.setContact(subPhone[j]);
cc.setIsDirectLine((short) 0);
......@@ -1138,8 +1145,11 @@ public class CustomerServiceImpl implements CustomerService {
}
}
if (rawDataList.get(i).length > 4 && rawDataList.get(i)[4] != null) {
String[] email = rawDataList.get(i)[3].toString().split(";");
String[] email = rawDataList.get(i)[4].toString().split(";");
for (int j = 0; j < email.length; j++) {
CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId());
cc.setSiteId(userSession.getSiteId());
cc.setContactType((short) 2);
cc.setContact(email[j]);
cc.setIsDirectLine((short) 1);
......@@ -1156,7 +1166,7 @@ public class CustomerServiceImpl implements CustomerService {
for (int j = 0; j < dynamicHeader.size(); j++) {
cfo.setCustomizeFieldId(dynamicHeader.get(j).getCustomizeFieldId());
if (rawDataList.get(i).length > (12 + j) && rawDataList.get(i)[12 + j] != null) {
switch (dynamicHeader.get(i).getType()) {
switch (dynamicHeader.get(j).getType()) {
case "combobox":
CustomizeFieldOptionValue cfov =
customizeFieldOptionValueRepository.findCustomizeFieldOptionValueByNameEqualsAndStatus(rawDataList.get(i)[12 + j].toString(), 1L);
......@@ -1221,7 +1231,7 @@ public class CustomerServiceImpl implements CustomerService {
if (str.length() > 50) {
result = BundleUtils.getLangString("customer.phoneMax50", locale);
}
for (int i = 0; i < str.length(); i++) {
for (int i = 0; i < arr.length; i++) {
CustomerContact cc = customerContactRepository.findCustomerContactByContactEquals(arr[i]);
if (cc != null) {
return result.concat(BundleUtils.getLangString("customer.phoneExists", locale));
......@@ -1230,6 +1240,18 @@ public class CustomerServiceImpl implements CustomerService {
return result;
}
private String validateDuplicateEmail(String str, Locale locale) {
String result = "";
String[] arr = str.split(";");
for (int i = 0; i < arr.length; i++) {
CustomerContact cc = customerContactRepository.findCustomerContactByContactEquals(arr[i]);
if (cc != null) {
return result.concat(BundleUtils.getLangString("customer.emailExists", locale));
}
}
return result;
}
private String validateUsingRegexp(String header, String data, String regexp, Locale locale) {
if (data.matches(regexp)) {
return header + " " + BundleUtils.getLangString("customer.notMatch", locale);
......@@ -1251,8 +1273,14 @@ public class CustomerServiceImpl implements CustomerService {
}
private boolean validateEmail(String str) {
String[] arr = str.split(";");
String regexp = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$";
return str.matches(regexp);
for (int i = 0; i < arr.length; i++) {
if (!arr[i].matches(regexp)) {
return false;
}
}
return true;
}
private boolean validateLetter(String str) {
......@@ -1262,6 +1290,7 @@ public class CustomerServiceImpl implements CustomerService {
//</editor-fold>
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public byte[] buildTemplate(Long companySiteId) {
LOGGER.info("-----------BUILD TEMPLATE-----------");
Locale locale = new Locale("vi", "VN");
......@@ -1414,6 +1443,7 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<CustomizeFieldObject> getCustomizeField(Long customerId) {
List<CustomizeFieldObject> customizeFieldDTOList;
try {
......@@ -1494,6 +1524,7 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO) {
List<CustomerDTO> customerList;
try {
......
......@@ -6,6 +6,7 @@ import com.viettel.campaign.repository.ccms_full.*;
import com.viettel.campaign.service.ScenarioService;
import com.viettel.campaign.utils.BundleUtils;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.WorkBookBuilder;
import com.viettel.campaign.web.dto.*;
import com.viettel.econtact.filter.UserSession;
......@@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -253,8 +255,9 @@ public class ScenarioServiceImpl implements ScenarioService {
FileInputStream fis = new FileInputStream(file);
XSSFWorkbook workbook = new XSSFWorkbook(fis);
Sheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(3);
Row row = sheet.getRow(2);
//<editor-fold desc="Tạo style cho cột kết quả" defaultstate="collapsed">
Font resultFont = workbook.createFont();
resultFont.setBold(true);
resultFont.setFontHeightInPoints((short) 11);
......@@ -264,14 +267,26 @@ public class ScenarioServiceImpl implements ScenarioService {
resultStyle.setBorderRight(BorderStyle.THIN);
resultStyle.setBorderBottom(BorderStyle.THIN);
resultStyle.setBorderTop(BorderStyle.THIN);
//</editor-fold>
//<editor-fold desc="Kiểm tra header của template" defaultstate="collapsed">
for (int i = 0; i < fileHeaderList.size(); i++) {
Cell cell = row.getCell(i);
if (!cell.getStringCellValue().equals(fileHeaderList.get(i).split("#")[0])) {
result.put("file", file);
result.put("message", BundleUtils.getLangString("common.invalidTemplate", locale));
return result;
}
}
//</editor-fold>
//kt file du lieu rong
if (sheet.getPhysicalNumberOfRows() == 3) {
if (sheet.getPhysicalNumberOfRows() == 2) {
result.put("message", BundleUtils.getLangString("customer.noData", locale));
result.put("file", file);
return result;
} else {
Cell resultCell = sheet.getRow(3).createCell(sheet.getRow(3).getPhysicalNumberOfCells());
Cell resultCell = sheet.getRow(2).createCell(sheet.getRow(2).getPhysicalNumberOfCells());
resultCell.setCellValue(BundleUtils.getLangString("customer.result", locale));
resultCell.setCellStyle(resultStyle);
}
......@@ -279,48 +294,114 @@ public class ScenarioServiceImpl implements ScenarioService {
List<Object[]> rawDataList = new ArrayList<>();
//validate row
for (int i = 4; i < sheet.getPhysicalNumberOfRows(); i++) {
for (int i = 3; i < sheet.getPhysicalNumberOfRows(); i++) {
Row dataRow = sheet.getRow(i);
if (dataRow != null) {
Object[] obj = new Object[row.getPhysicalNumberOfCells()];
for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
Cell dataCell = dataRow.getCell(j);
if (dataCell != null) {
// switch (dataCell.getCellTypeEnum()) {
// case NUMERIC:
// obj[j] = dataCell.getNumericCellValue();
// break;
// default:
// obj[j] = dataCell.getStringCellValue();
// break;
// }
} else {
// Cell headerCell = row.getCell(j);
// if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.cusType", locale))) {
// obj[j] = BundleUtils.getLangString("customer.cusType.normal", locale);
// } else if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.callAllowed", locale)) || headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.emailAllowed", locale))
// || headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.smsAllowed", locale))) {
// obj[j] = BundleUtils.getLangString("customer.yes", locale);
// break;
// } else {
// obj[j] = null;
// }
switch (dataCell.getCellTypeEnum()) {
case NUMERIC:
obj[j] = dataCell.getNumericCellValue();
break;
default:
obj[j] = dataCell.getStringCellValue();
break;
}
}
}
rawDataList.add(obj);
}
}
//<editor-fold desc="Validate dữ liệu" defaultstate="collapsed">
String selectedType = "";
for (int i = 0; i < rawDataList.size(); i++) {
if (rawDataList.get(i)[0] != null && !rawDataList.get(i)[0].toString().trim().equals(""))
selectedType = rawDataList.get(i)[1].toString().trim();
//validate question
if ((rawDataList.get(i)[0] != null && !rawDataList.get(i)[0].toString().trim().equals("")) ||
(rawDataList.get(i)[1] != null && !rawDataList.get(i)[1].toString().trim().equals("")) ||
(rawDataList.get(i)[2] != null && !rawDataList.get(i)[2].toString().trim().equals("")) ||
(rawDataList.get(i)[5] != null && !rawDataList.get(i)[5].toString().trim().equals("")) ||
(rawDataList.get(i)[6] != null && !rawDataList.get(i)[6].toString().trim().equals(""))) {
if (rawDataList.get(i)[0] == null || !DataUtil.isNumber(rawDataList.get(i)[0].toString())) {
sb.append(BundleUtils.getLangString("scenario.questionCode.required"));
}
if (rawDataList.get(i)[1] == null || rawDataList.get(i)[1].toString().trim().equals("")) {
sb.append(BundleUtils.getLangString("scenario.questionType.required"));
}
if (rawDataList.get(i)[2] == null || rawDataList.get(i)[2].toString().trim().equals("")) {
sb.append(BundleUtils.getLangString("scenario.question.required"));
}
if (rawDataList.get(i)[5] == null || rawDataList.get(i)[5].toString().trim().equals("")) {
sb.append(BundleUtils.getLangString("scenario.required.required"));
}
if (rawDataList.get(i)[6] == null || rawDataList.get(i)[6].toString().trim().equals("")) {
sb.append(BundleUtils.getLangString("scenario.default.required"));
}
}
//validate answer
if ((rawDataList.get(i)[3] != null && !rawDataList.get(i)[3].toString().trim().equals("")) ||
(rawDataList.get(i)[4] != null && !rawDataList.get(i)[4].toString().trim().equals("")) ||
(rawDataList.get(i)[7] != null && !rawDataList.get(i)[7].toString().trim().equals(""))) {
if ((rawDataList.get(i)[3] == null || rawDataList.get(i)[3].toString().trim().equals("")) && (!selectedType.equals(BundleUtils.getLangString("scenario.template.text")))) {
sb.append(BundleUtils.getLangString("scenario.answer.required"));
}
if(rawDataList.get(i)[4] == null && rawDataList.get(i)[4].toString().trim().equals("")) {
sb.append(BundleUtils.getLangString("scenario.hashInput.required"));
}
}
Row dataRow = sheet.getRow(3 + i);
Cell resultCell = dataRow.createCell(row.getPhysicalNumberOfCells() - 1);
if (sb.length() > 0) {
resultCell.setCellValue(sb.toString());
isValid = false;
} else {
isValid = true;
resultCell.setCellValue("Ok");
}
sb = new StringBuilder();
}
selectedType = "";
//</editor-fold>
//insert data
if (isValid) {
logger.info("----- Data valid, start import scenario question -----");
for (int i = 0; i < rawDataList.size(); i++) {
buildQuestionsLst(rawDataList);
}
}else {
FileOutputStream fos = new FileOutputStream(file);
workbook.write(fos);
result.put("file", file);
result.put("message", BundleUtils.getLangString("customer.importFailed", locale));
}
} catch (Exception ex) {
logger.info(ex.getMessage(), ex);
result.put("message", BundleUtils.getLangString("customer.errorValidate", locale));
}
logger.info("Import Questions result:" , result);
return result;
}
private boolean validateQuestionIndex(Object index) {
if (index != null && DataUtil.isLong(index.toString())) return true;
return false;
}
private List<ScenarioQuestionDTO> buildQuestionsLst(List<Object[]> rawDatas) {
List<ScenarioQuestionDTO> lstQuestions = new ArrayList<>();
ScenarioQuestionDTO questionDTO = null;
for(int i = 0; i < rawDatas.size(); i++) {
if(rawDatas.get(i)[0] != null && !rawDatas.get(i)[0].toString().trim().equals("")) {
questionDTO = new ScenarioQuestionDTO();
// questionDTO.setCampaignId();
}
}
return lstQuestions;
}
}
......@@ -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());
......
......@@ -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) {
......@@ -340,4 +251,32 @@ public class CampaignController {
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;
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.*;
......@@ -108,13 +109,16 @@ public class CustomerController {
@PostMapping("/createCustomerList")
@ResponseBody
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
ResultDTO result = new ResultDTO();
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
String xAuthToken = request.getHeader("X-Auth-Token");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
result = customerService.createCustomerList(customerListDTO, userSession.getUserName());
return result;
if (userSession == null) {
userSession = new UserSession();
userSession.setSiteId(customerListDTO.getCompanySiteId());
userSession.setUserName("its4");
}
return customerService.createCustomerList(customerListDTO, userSession.getUserName());
}
@PostMapping("/updateCustomerList")
......@@ -187,12 +191,17 @@ public class CustomerController {
@PostMapping(value = "/importFile")
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestParam("customerListId") Long customerListId,
@RequestHeader("X-Auth-Token") String authToken) {
@RequestParam("customerListId") String customerListId,
HttpServletRequest request) {
LOGGER.info("------------IMPORT FILE TEMPLATE--------------");
Locale locale = new Locale("vi", "VN");
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()) {
return new ResponseEntity<>(BundleUtils.getLangString("customer.fileNotSelected"), HttpStatus.OK);
}
......@@ -201,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()
......@@ -239,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) {
......
......@@ -122,7 +122,7 @@ public class ScenarioController {
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(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=import_scenario_result.xlsx")
.header("Message", message)
.body(Files.readAllBytes(fileExport.toPath()));
} catch (Exception e) {
......
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);
}
}
......@@ -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,6 +108,7 @@ 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
......@@ -125,3 +126,12 @@ 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,6 +110,7 @@ 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
......@@ -128,6 +129,14 @@ 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"
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