Commit 8890ea24 authored by Tu Bach's avatar Tu Bach

Merge branch 'master' into tubn

parents 7a345766 0193956c
...@@ -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
// } }
// }); });
} }
......
...@@ -149,7 +149,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -149,7 +149,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sql.append(" f.complete_name surveyStatus,"); sql.append(" f.complete_name surveyStatus,");
sql.append(" g.status status,"); sql.append(" g.status status,");
sql.append(" a.status recordStatus,"); sql.append(" a.status recordStatus,");
sql.append(" (a.end_time - a.start_call)*24*60 callTime"); sql.append(" nvl((a.end_time - a.start_call)*24*60, 0) callTime");
sql.append(" from contact_cust_result a"); sql.append(" from contact_cust_result a");
sql.append(" left join campaign b on a.campaign_id = b.campaign_id"); sql.append(" left join campaign b on a.campaign_id = b.campaign_id");
sql.append(" left join vsa_users c on a.agent_id = c.user_id"); sql.append(" left join vsa_users c on a.agent_id = c.user_id");
...@@ -175,6 +175,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -175,6 +175,7 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
sql.append(" select a.*, rownum row_ from data_temp a"); sql.append(" select a.*, rownum row_ from data_temp a");
sql.append(" where a.callTime >= :p_call_time_from"); sql.append(" where a.callTime >= :p_call_time_from");
sql.append(" and a.callTime <= :p_call_time_to"); sql.append(" and a.callTime <= :p_call_time_to");
sql.append(" order by a.createTime desc");
sql.append(" ),"); sql.append(" ),");
sql.append(" count_total as ("); sql.append(" count_total as (");
sql.append(" select count(*) totalRow from data"); sql.append(" select count(*) totalRow from data");
...@@ -195,8 +196,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -195,8 +196,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_call_time_to", dto.getCallTimeTo()); query.setParameter("p_call_time_to", dto.getCallTimeTo());
query.setParameter("p_list_campaign_code", dto.getCampaignCode()); query.setParameter("p_list_campaign_code", dto.getCampaignCode());
query.setParameter("p_phone_number", dto.getPhoneNumber()); query.setParameter("p_phone_number", dto.getPhoneNumber());
query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().toUpperCase()); query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().trim().toUpperCase());
query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().toUpperCase()); query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().trim().toUpperCase());
query.setParameter("p_page_number", dto.getPage()); query.setParameter("p_page_number", dto.getPage());
query.setParameter("p_page_size", dto.getPageSize()); query.setParameter("p_page_size", dto.getPageSize());
...@@ -342,8 +343,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository { ...@@ -342,8 +343,8 @@ public class CampaignExecuteRepositoryImp implements CampaignExecuteRepository {
query.setParameter("p_call_time_to", dto.getCallTimeTo()); query.setParameter("p_call_time_to", dto.getCallTimeTo());
query.setParameter("p_list_campaign_code", dto.getCampaignCode()); query.setParameter("p_list_campaign_code", dto.getCampaignCode());
query.setParameter("p_phone_number", dto.getPhoneNumber()); query.setParameter("p_phone_number", dto.getPhoneNumber());
query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().toUpperCase()); query.setParameter("p_campaign_name", DataUtil.isNullOrEmpty(dto.getCampaignName()) ? null : dto.getCampaignName().trim().toUpperCase());
query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().toUpperCase()); query.setParameter("p_user_name", DataUtil.isNullOrEmpty(dto.getAgentId()) ? null : dto.getAgentId().trim().toUpperCase());
query.setParameter("p_page_number", dto.getPage()); query.setParameter("p_page_number", dto.getPage());
query.setParameter("p_page_size", dto.getPageSize()); query.setParameter("p_page_size", dto.getPageSize());
......
...@@ -309,7 +309,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -309,7 +309,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"ORDER BY START_TIME DESC"); "ORDER BY START_TIME DESC");
SQLQuery query = session.createSQLQuery(sb.toString()); SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", requestDto.getCompanySiteId()); query.setParameter("p_company_site_id", requestDto.getCompanySiteId());
query.setParameter("p_code", DataUtil.isNullOrEmpty(requestDto.getCampaignCode()) ? null : requestDto.getCampaignCode().toUpperCase()); query.setParameter("p_code", DataUtil.isNullOrEmpty(requestDto.getCampaignCode()) ? null : requestDto.getCampaignCode().trim().toUpperCase());
query.addScalar("campaignId", new LongType()); query.addScalar("campaignId", new LongType());
query.addScalar("campaignCode", new StringType()); query.addScalar("campaignCode", new StringType());
...@@ -742,8 +742,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -742,8 +742,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
SQLQuery query = session.createSQLQuery(sb.toString()); SQLQuery query = session.createSQLQuery(sb.toString());
query.setParameter("p_company_site_id", dto.getCompanySiteId()); query.setParameter("p_company_site_id", dto.getCompanySiteId());
query.setParameter("p_campaign_id", dto.getCampaignId()); query.setParameter("p_campaign_id", dto.getCampaignId());
query.setParameter("p_cus_list_code", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCustListCode().toUpperCase()); query.setParameter("p_cus_list_code", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCustListCode().trim().toUpperCase());
query.setParameter("p_cus_list_name", DataUtil.isNullOrEmpty(dto.getCustListName()) ? null : dto.getCustListName().toUpperCase()); query.setParameter("p_cus_list_name", DataUtil.isNullOrEmpty(dto.getCustListName()) ? null : dto.getCustListName().trim().toUpperCase());
query.setParameter("p_to_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeTo()); query.setParameter("p_to_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeTo());
query.setParameter("p_from_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeFr()); query.setParameter("p_from_date", DataUtil.isNullOrEmpty(dto.getCustListCode()) ? null : dto.getCreateTimeFr());
query.setParameter("p_page_number", dto.getPage()); query.setParameter("p_page_number", dto.getPage());
......
...@@ -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);
......
...@@ -421,6 +421,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -421,6 +421,7 @@ public class CustomerServiceImpl implements CustomerService {
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCustomerDetailById(Long companySiteId, Long customerListId, Long customerId) { public ResultDTO getCustomerDetailById(Long companySiteId, Long customerListId, Long customerId) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
...@@ -599,35 +600,38 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -599,35 +600,38 @@ public class CustomerServiceImpl implements CustomerService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName) { 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(); ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = new CustomerList();
try { try {
if (customerListDTO != null) { CustomerList cl = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
// insert if (cl != null) {
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 {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); 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) { } catch (Exception e) {
e.printStackTrace(); LOGGER.error(e.getMessage());
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription("Error");
return resultDTO;
} }
return resultDTO;
} }
@Override @Override
...@@ -880,6 +884,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -880,6 +884,7 @@ public class CustomerServiceImpl implements CustomerService {
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<CustomizeFields> getDynamicHeader(Long companySiteId) { public List<CustomizeFields> getDynamicHeader(Long companySiteId) {
LOGGER.info("------------------GET DYNAMIC HEADER-------------------"); LOGGER.info("------------------GET DYNAMIC HEADER-------------------");
List<CustomizeFields> headerList; List<CustomizeFields> headerList;
...@@ -893,10 +898,12 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -893,10 +898,12 @@ public class CustomerServiceImpl implements CustomerService {
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL)
public Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> dynamicHeader, UserSession userSession, Long customerListId) { public Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> dynamicHeader, UserSession userSession, Long customerListId) {
LOGGER.info("------------READ AND VALIDATE--------------"); LOGGER.info("------------READ AND VALIDATE--------------");
Locale locale = new Locale("vi", "VN"); 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<>(); Map<String, Object> result = new HashMap<>();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
boolean validateOk = false; boolean validateOk = false;
...@@ -972,14 +979,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -972,14 +979,7 @@ public class CustomerServiceImpl implements CustomerService {
for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) { for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
Cell dataCell = dataRow.getCell(j); Cell dataCell = dataRow.getCell(j);
if (dataCell != null) { if (dataCell != null) {
switch (dataCell.getCellTypeEnum()) { obj[j] = dataFormat.formatCellValue(dataCell);
case NUMERIC:
obj[j] = dataCell.getNumericCellValue();
break;
default:
obj[j] = dataCell.getStringCellValue();
break;
}
} else { } else {
Cell headerCell = row.getCell(j); Cell headerCell = row.getCell(j);
if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.cusType", locale))) { if (headerCell.getStringCellValue().equals(BundleUtils.getLangString("customer.cusType", locale))) {
...@@ -1016,9 +1016,12 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1016,9 +1016,12 @@ public class CustomerServiceImpl implements CustomerService {
&& !rawDataList.get(i)[4].toString().trim().equals("")) { && !rawDataList.get(i)[4].toString().trim().equals("")) {
String str = validatePhone(rawDataList.get(i)[2].toString().trim(), locale); 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)); 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())) { if (!validateEmail(rawDataList.get(i)[4].toString().trim())) {
str.concat(BundleUtils.getLangString("customer.emailMax50", locale)); 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); sb.append(str);
} else { } else {
sb.append(BundleUtils.getLangString("customer.invalidCustomer", locale)); sb.append(BundleUtils.getLangString("customer.invalidCustomer", locale));
...@@ -1032,17 +1035,17 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1032,17 +1035,17 @@ public class CustomerServiceImpl implements CustomerService {
if (rawDataList.get(i).length > 8 && rawDataList.get(i)[8] != null) { 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)); 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++) { // for (int j = 12; j < header.size(); j++) {
if (rawDataList.get(i).length > j && rawDataList.get(i)[j] != null) { // if (rawDataList.get(i).length > j && rawDataList.get(i)[j] != null) {
if (header.get(j).getType().equals("text")) { // 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)); // 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")) { // } 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)); // 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")) { // } 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)); // 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); Row dataRow = sheet.getRow(4 + i);
Cell resultCell = dataRow.createCell(row.getPhysicalNumberOfCells() - 1); Cell resultCell = dataRow.createCell(row.getPhysicalNumberOfCells() - 1);
if (sb.length() > 0) { if (sb.length() > 0) {
...@@ -1061,7 +1064,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1061,7 +1064,7 @@ public class CustomerServiceImpl implements CustomerService {
for (int i = 0; i < rawDataList.size(); i++) { for (int i = 0; i < rawDataList.size(); i++) {
Customer c = new Customer(); Customer c = new Customer();
c.setName(rawDataList.get(i)[1].toString()); c.setName(rawDataList.get(i)[1].toString());
c.setSiteId(userSession.getCompanySiteId()); c.setSiteId(userSession.getSiteId());
c.setCode(null); c.setCode(null);
c.setDescription(rawDataList.get(i)[8].toString()); c.setDescription(rawDataList.get(i)[8].toString());
c.setCompanyName(rawDataList.get(i)[7].toString()); c.setCompanyName(rawDataList.get(i)[7].toString());
...@@ -1107,11 +1110,12 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1107,11 +1110,12 @@ public class CustomerServiceImpl implements CustomerService {
} }
c.setIpccStatus("active"); c.setIpccStatus("active");
Customer saved = customerRepository.save(c); Customer saved = customerRepository.save(c);
CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId());
if (rawDataList.get(i).length > 2 && rawDataList.get(i)[2] != null) { if (rawDataList.get(i).length > 2 && rawDataList.get(i)[2] != null) {
String[] mainPhone = rawDataList.get(i)[2].toString().split(";"); String[] mainPhone = rawDataList.get(i)[2].toString().split(";");
for (int j = 0; j < mainPhone.length; j++) { 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.setContactType((short) 5);
cc.setContact(mainPhone[j]); cc.setContact(mainPhone[j]);
cc.setIsDirectLine((short) 1); cc.setIsDirectLine((short) 1);
...@@ -1126,6 +1130,9 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1126,6 +1130,9 @@ public class CustomerServiceImpl implements CustomerService {
if (rawDataList.get(i).length > 3 && rawDataList.get(i)[3] != null) { if (rawDataList.get(i).length > 3 && rawDataList.get(i)[3] != null) {
String[] subPhone = rawDataList.get(i)[3].toString().split(";"); String[] subPhone = rawDataList.get(i)[3].toString().split(";");
for (int j = 0; j < subPhone.length; j++) { 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.setContactType((short) 5);
cc.setContact(subPhone[j]); cc.setContact(subPhone[j]);
cc.setIsDirectLine((short) 0); cc.setIsDirectLine((short) 0);
...@@ -1138,8 +1145,11 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1138,8 +1145,11 @@ public class CustomerServiceImpl implements CustomerService {
} }
} }
if (rawDataList.get(i).length > 4 && rawDataList.get(i)[4] != null) { 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++) { 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.setContactType((short) 2);
cc.setContact(email[j]); cc.setContact(email[j]);
cc.setIsDirectLine((short) 1); cc.setIsDirectLine((short) 1);
...@@ -1156,7 +1166,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1156,7 +1166,7 @@ public class CustomerServiceImpl implements CustomerService {
for (int j = 0; j < dynamicHeader.size(); j++) { for (int j = 0; j < dynamicHeader.size(); j++) {
cfo.setCustomizeFieldId(dynamicHeader.get(j).getCustomizeFieldId()); cfo.setCustomizeFieldId(dynamicHeader.get(j).getCustomizeFieldId());
if (rawDataList.get(i).length > (12 + j) && rawDataList.get(i)[12 + j] != null) { 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": case "combobox":
CustomizeFieldOptionValue cfov = CustomizeFieldOptionValue cfov =
customizeFieldOptionValueRepository.findCustomizeFieldOptionValueByNameEqualsAndStatus(rawDataList.get(i)[12 + j].toString(), 1L); customizeFieldOptionValueRepository.findCustomizeFieldOptionValueByNameEqualsAndStatus(rawDataList.get(i)[12 + j].toString(), 1L);
...@@ -1221,7 +1231,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1221,7 +1231,7 @@ public class CustomerServiceImpl implements CustomerService {
if (str.length() > 50) { if (str.length() > 50) {
result = BundleUtils.getLangString("customer.phoneMax50", locale); 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]); CustomerContact cc = customerContactRepository.findCustomerContactByContactEquals(arr[i]);
if (cc != null) { if (cc != null) {
return result.concat(BundleUtils.getLangString("customer.phoneExists", locale)); return result.concat(BundleUtils.getLangString("customer.phoneExists", locale));
...@@ -1230,6 +1240,18 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1230,6 +1240,18 @@ public class CustomerServiceImpl implements CustomerService {
return result; 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) { private String validateUsingRegexp(String header, String data, String regexp, Locale locale) {
if (data.matches(regexp)) { if (data.matches(regexp)) {
return header + " " + BundleUtils.getLangString("customer.notMatch", locale); return header + " " + BundleUtils.getLangString("customer.notMatch", locale);
...@@ -1251,8 +1273,14 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1251,8 +1273,14 @@ public class CustomerServiceImpl implements CustomerService {
} }
private boolean validateEmail(String str) { private boolean validateEmail(String str) {
String[] arr = str.split(";");
String regexp = "^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$"; 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) { private boolean validateLetter(String str) {
...@@ -1262,6 +1290,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1262,6 +1290,7 @@ public class CustomerServiceImpl implements CustomerService {
//</editor-fold> //</editor-fold>
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL)
public byte[] buildTemplate(Long companySiteId) { public byte[] buildTemplate(Long companySiteId) {
LOGGER.info("-----------BUILD TEMPLATE-----------"); LOGGER.info("-----------BUILD TEMPLATE-----------");
Locale locale = new Locale("vi", "VN"); Locale locale = new Locale("vi", "VN");
...@@ -1414,6 +1443,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1414,6 +1443,7 @@ public class CustomerServiceImpl implements CustomerService {
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<CustomizeFieldObject> getCustomizeField(Long customerId) { public List<CustomizeFieldObject> getCustomizeField(Long customerId) {
List<CustomizeFieldObject> customizeFieldDTOList; List<CustomizeFieldObject> customizeFieldDTOList;
try { try {
...@@ -1494,6 +1524,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1494,6 +1524,7 @@ public class CustomerServiceImpl implements CustomerService {
} }
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO) { public List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO) {
List<CustomerDTO> customerList; List<CustomerDTO> customerList;
try { try {
......
...@@ -6,6 +6,7 @@ import com.viettel.campaign.repository.ccms_full.*; ...@@ -6,6 +6,7 @@ import com.viettel.campaign.repository.ccms_full.*;
import com.viettel.campaign.service.ScenarioService; import com.viettel.campaign.service.ScenarioService;
import com.viettel.campaign.utils.BundleUtils; import com.viettel.campaign.utils.BundleUtils;
import com.viettel.campaign.utils.Constants; import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.WorkBookBuilder; import com.viettel.campaign.utils.WorkBookBuilder;
import com.viettel.campaign.web.dto.*; import com.viettel.campaign.web.dto.*;
import com.viettel.econtact.filter.UserSession; import com.viettel.econtact.filter.UserSession;
...@@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -253,8 +255,9 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -253,8 +255,9 @@ public class ScenarioServiceImpl implements ScenarioService {
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
XSSFWorkbook workbook = new XSSFWorkbook(fis); XSSFWorkbook workbook = new XSSFWorkbook(fis);
Sheet sheet = workbook.getSheetAt(0); 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(); Font resultFont = workbook.createFont();
resultFont.setBold(true); resultFont.setBold(true);
resultFont.setFontHeightInPoints((short) 11); resultFont.setFontHeightInPoints((short) 11);
...@@ -264,14 +267,26 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -264,14 +267,26 @@ public class ScenarioServiceImpl implements ScenarioService {
resultStyle.setBorderRight(BorderStyle.THIN); resultStyle.setBorderRight(BorderStyle.THIN);
resultStyle.setBorderBottom(BorderStyle.THIN); resultStyle.setBorderBottom(BorderStyle.THIN);
resultStyle.setBorderTop(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 //kt file du lieu rong
if (sheet.getPhysicalNumberOfRows() == 3) { if (sheet.getPhysicalNumberOfRows() == 2) {
result.put("message", BundleUtils.getLangString("customer.noData", locale)); result.put("message", BundleUtils.getLangString("customer.noData", locale));
result.put("file", file); result.put("file", file);
return result; return result;
} else { } 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.setCellValue(BundleUtils.getLangString("customer.result", locale));
resultCell.setCellStyle(resultStyle); resultCell.setCellStyle(resultStyle);
} }
...@@ -279,48 +294,114 @@ public class ScenarioServiceImpl implements ScenarioService { ...@@ -279,48 +294,114 @@ public class ScenarioServiceImpl implements ScenarioService {
List<Object[]> rawDataList = new ArrayList<>(); List<Object[]> rawDataList = new ArrayList<>();
//validate row //validate row
for (int i = 4; i < sheet.getPhysicalNumberOfRows(); i++) { for (int i = 3; i < sheet.getPhysicalNumberOfRows(); i++) {
Row dataRow = sheet.getRow(i); Row dataRow = sheet.getRow(i);
if (dataRow != null) { if (dataRow != null) {
Object[] obj = new Object[row.getPhysicalNumberOfCells()]; Object[] obj = new Object[row.getPhysicalNumberOfCells()];
for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) { for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) {
Cell dataCell = dataRow.getCell(j); Cell dataCell = dataRow.getCell(j);
if (dataCell != null) { if (dataCell != null) {
// switch (dataCell.getCellTypeEnum()) { switch (dataCell.getCellTypeEnum()) {
// case NUMERIC: case NUMERIC:
// obj[j] = dataCell.getNumericCellValue(); obj[j] = dataCell.getNumericCellValue();
// break; break;
// default: default:
// obj[j] = dataCell.getStringCellValue(); obj[j] = dataCell.getStringCellValue();
// break; 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;
// }
} }
} }
rawDataList.add(obj); 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 //insert data
if (isValid) { if (isValid) {
logger.info("----- Data valid, start import scenario question -----");
for (int i = 0; i < rawDataList.size(); i++) { 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) { } catch (Exception ex) {
logger.info(ex.getMessage(), ex); logger.info(ex.getMessage(), ex);
result.put("message", BundleUtils.getLangString("customer.errorValidate", locale)); result.put("message", BundleUtils.getLangString("customer.errorValidate", locale));
} }
logger.info("Import Questions result:" , result);
return 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;
}
} }
...@@ -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());
......
...@@ -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) {
......
...@@ -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