Commit 156c41ab authored by đinh thị đầm's avatar đinh thị đầm

Merge branch 'master' of http://git.myitsol.com/hanv/service-campaign

 Conflicts:
	src/main/java/com/viettel/campaign/service/impl/CustomerServiceImpl.java
parents 338033d7 d99b493b
......@@ -32,25 +32,25 @@ public class CorsFilter implements Filter {
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.");
// }
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
......
......@@ -18,9 +18,9 @@ public interface CampaignExecuteRepository {
List<ApParamDTO> getComboCampaignType(String companySiteId);
ResultDTO getInteractiveResult(CampaignRequestDTO dto);
List<ContactCustResultDTO> getInteractiveResult(CampaignRequestDTO dto, Pageable pageable);
List<ContactCusResDTO> getExcelInteractiveResult(CampaignRequestDTO dto);
List<ContactCustResultDTO> getExcelInteractiveResult(CampaignRequestDTO dto);
List<ContactCustResultDTO> getContactCustById(CampaignRequestDTO dto);
//</editor-fold: hungtt>
......
......@@ -2,6 +2,7 @@ package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
......@@ -37,7 +38,7 @@ public interface CampaignExecuteService {
ResultDTO getAgentLogout(CampaignRequestDTO dto);
ResultDTO callCustomer(ContactCustResultDTO dto);
ResultDTO callCustomer(ContactCustResultDTO dto, UserSession userSession);
ResultDTO recallCustomer(ContactCustResultDTO dto);
......
......@@ -61,6 +61,10 @@ public interface CustomerService {
ResultDTO deleteCustomerFromCampaign(CampaignCustomerDTO campaignCustomerDTO);
ResultDTO searchCampaignInformation(CampaignCustomerDTO campaignCustomerDTO);
ResultDTO addCustomerToCampaign(CampaignCustomerDTO campaignCustomerDTO);
// ------------ customer ------------ //
......
......@@ -20,6 +20,7 @@ import org.modelmapper.ModelMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -100,11 +101,19 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchInteractiveResult(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
try {
resultDTO = campaignExecuteRepository.getInteractiveResult(dto);
List<ContactCustResultDTO> list = campaignExecuteRepository.getInteractiveResult(dto, SQLBuilder.buildPageable(dto));
resultDTO.setListData(list);
resultDTO.setTotalRow(campaignExecuteRepository.getInteractiveResult(dto, null).size());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
logger.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
......@@ -112,7 +121,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
@Transactional(DataSourceQualify.CCMS_FULL)
public XSSFWorkbook exportInteractiveResult(CampaignRequestDTO dto) {
Locale locale = Locale.forLanguageTag("vi");
List<ContactCusResDTO> list = campaignExecuteRepository.getExcelInteractiveResult(dto);
List<ContactCustResultDTO> list = campaignExecuteRepository.getExcelInteractiveResult(dto);
XSSFWorkbook workbook = new XSSFWorkbook();
Sheet sheet;
......@@ -519,7 +528,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
}
@Override
public ResultDTO callCustomer(ContactCustResultDTO dto) {
public ResultDTO callCustomer(ContactCustResultDTO dto, UserSession userSession) {
ResultDTO result = new ResultDTO();
try {
......
......@@ -1661,6 +1661,85 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchCampaignInformation(CampaignCustomerDTO campaignCustomerDTO) {
ResultDTO resultDTO = new ResultDTO();
List<CampaignInformationDTO> list = new ArrayList<>();
Map<String, Object> params = new HashMap<>();
try {
StringBuilder sb = new StringBuilder();
sb.append(" with status_customer as (\n" +
"select complete_value\n" +
"from campaign_complete_code\n" +
"where complete_value <> 4\n" +
" and is_finish <> 1\n" +
" and campaign_type = 1\n" +
" and company_site_id = :p_company_site_id\n" +
"),\n" +
"count_customer as (\n" +
"select campaign_id campaignId,\n" +
" sum(case\n" +
" when customer_list_id is null then 1\n" +
" else 0\n" +
" end) totalIndividual,\n" +
" sum(case\n" +
" when customer_list_id is not null then 1\n" +
" else 0\n" +
" end) totalCusInList\n" +
"from campaign_customer\n" +
"group by campaign_id\n" +
")\n" +
"select a.*, b.customer_number campaignCustomer\n" +
"from count_customer a\n" +
"left join campaign b on a.campaignId = b.campaign_id\n" +
"where a.campaignId = :p_campaign_id");
params.put("p_campaign_id", campaignCustomerDTO.getCampaignId());
params.put("p_company_site_id", campaignCustomerDTO.getCompanySiteId());
list = namedParameterJdbcTemplate.query(sb.toString(), params, BeanPropertyRowMapper.newInstance(CampaignInformationDTO.class));
if (list.size() > 0) {
resultDTO.setData(list.get(0));
} else {
resultDTO.setData(null);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO addCustomerToCampaign(CampaignCustomerDTO campaignCustomerDTO) {
ResultDTO resultDTO = new ResultDTO();
Long companySiteId = campaignCustomerDTO.getCompanySiteId();
Long campaignId = campaignCustomerDTO.getCampaignId();
String[] lstCusId = campaignCustomerDTO.getLstCustomerId().split(",");
try {
for (String cusId: lstCusId) {
CampaignCustomer entity = new CampaignCustomer();
entity.setCompanySiteId(companySiteId);
entity.setStatus((short) 0);
entity.setCampaignId(campaignId);
entity.setCustomerId(Long.parseLong(cusId));
entity.setRecallCount(0L);
entity.setInCampaignStatus((short) 1);
campaignCustomerRepository.save(entity);
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
......@@ -1761,6 +1840,44 @@ public class CustomerServiceImpl implements CustomerService {
lstCustomizeFields.add(datafill);
}
// try {
// stringBuilder.append(" with column_name_temp as (");
// stringBuilder.append(" select 'CUSTOMER_ID customerId' , from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'CUSTOMER_NAME customerName' , from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'CUSTOMER_TYPE customerType' , from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'NAME name' , from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'CURRENT_ADDRESS currentAddress', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'PLACE_OF_BIRTH placeOfBirth', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'DATE_OF_BIRTH dateOfBirth', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'MOBILE_NUMBER mobileNumber', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'EMAIL email', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'USERNAME username', from user_tab_columns, dual");
// stringBuilder.append(" union all");
// stringBuilder.append(" select 'CUSTOMER_TYPE customerType', from user_tab_columns, dual");
// stringBuilder.append(" where table_name = 'CUSTOMER'");
// stringBuilder.append(" )");
//
// stringBuilder.append(" select * from column_name_temp");
// stringBuilder.append(" union all");
// stringBuilder.append(" select title columnName, 0 isFix ");
// stringBuilder.append(" from customize_fields, dual");
// stringBuilder.append(" where function_code = 'CUSTOMER'");
// stringBuilder.append(" and site_id = :p_company_site_id");
// stringBuilder.append(" and STATUS = 1");
// stringBuilder.append(" and active = 1 ");
// params.put("p_company_site_id", customizeFields.getSiteId());
// params.put("p_customer_id", customizeFields.getCustomerId());
// LOGGER.info("SQL statement: " + stringBuilder);
// list = namedParameterJdbcTemplate.query(stringBuilder.toString(), params, BeanPropertyRowMapper.newInstance(CustomizeFielObjectDTO.class));
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setListData(lstCustomizeFields);
......@@ -1774,7 +1891,6 @@ public class CustomerServiceImpl implements CustomerService {
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO searchCustomizeFields(CampaignCustomerDTO campaignCustomerDTO) {
......@@ -1784,11 +1900,11 @@ public class CustomerServiceImpl implements CustomerService {
Session session = sessionFactory.openSession();
session.beginTransaction();
// if (DataUtil.isNullOrZero(customizeFieldsDTO.getSiteId())) {
// resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
// resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
// return resultDTO;
// }
if (DataUtil.isNullOrZero(SiteId)) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
try {
......
......@@ -239,6 +239,8 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
return resultDTO;
}
try {
scenarioQuestionDTO.setCode(scenarioQuestionDTO.getCode().trim());
scenarioQuestionDTO.setQuestion(scenarioQuestionDTO.getQuestion().trim());
ScenarioQuestion scenarioQuestion = modelMapper.map(scenarioQuestionDTO, ScenarioQuestion.class);
if (scenarioQuestion.getScenarioQuestionId() != null) {
......@@ -271,6 +273,8 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
campaignLogAnswer.setCampaignId(scenarioQuestion.getCampaignId());
if (item.getScenarioAnswerId() != null) {
item.setCode(item.getCode().trim());
item.setAnswer(item.getAnswer().trim());
ScenarioAnswer answer = modelMapper.map(item, ScenarioAnswer.class);
scenarioAnswerRepository.save(answer);
campaignLogAnswer.setCustomerId(answer.getScenarioAnswerId());
......@@ -281,6 +285,7 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
item.setScenarioQuestionId(scenarioQuestion.getScenarioQuestionId());
item.setCreateTime(new Date());
item.setStatus((short) 1);
item.setAnswer(item.getAnswer().trim());
ScenarioAnswer answer = modelMapper.map(item, ScenarioAnswer.class);
scenarioAnswerRepository.save(answer);
campaignLogAnswer.setCustomerId(answer.getScenarioAnswerId());
......
......@@ -72,6 +72,9 @@ public class ScenarioServiceImpl implements ScenarioService {
public ResultDTO update(ScenarioDTO scenarioDTO) {
ResultDTO resultDTO = new ResultDTO();
try {
scenarioDTO.setCode(scenarioDTO.getCode().trim());
if (scenarioDTO.getDescription() != null) scenarioDTO.setDescription(scenarioDTO.getDescription().trim());
else scenarioDTO.setDescription("");
scenarioDTO.setUpdateBy(null);
scenarioDTO.setUpdateTime(new Date());
......@@ -368,8 +371,8 @@ public class ScenarioServiceImpl implements ScenarioService {
if (rawDataList.get(i)[4] == null && rawDataList.get(i)[4].toString().trim().equals("")) {
sb.append(BundleUtils.getLangString("scenario.hashInput.required"));
}
if((rawDataList.get(i)[7] != null && !rawDataList.get(i)[7].toString().trim().equals(""))) {
if((rawDataList.get(i)[7].toString().trim().equals(tmpCurrentQuestionCode)) ||
if ((rawDataList.get(i)[7] != null && !rawDataList.get(i)[7].toString().trim().equals(""))) {
if ((rawDataList.get(i)[7].toString().trim().equals(tmpCurrentQuestionCode)) ||
validateMappingQuestion(rawDataList.get(i)[7].toString().trim(), tmpCurrentQuestionCode, lstImportQuestionCodes))
sb.append(BundleUtils.getLangString("scenario.mappingQuestion.invalid"));
}
......@@ -415,12 +418,12 @@ public class ScenarioServiceImpl implements ScenarioService {
}
private boolean validateMappingQuestion(String mappingQuestion, String currentQuestionCode, List<String> lstQuestionCode) {
if(mappingQuestion == currentQuestionCode) return false;
if (mappingQuestion == currentQuestionCode) return false;
String duplicateCode = lstQuestionCode.stream().
filter(p -> (p.equals(mappingQuestion) && p.equals(currentQuestionCode))).
findAny().orElse(null);
if(duplicateCode == null) return false;
if (duplicateCode == null) return false;
// String notMappedCode = lstQuestionCode.stream().filter(p -> (!p.equals(mappingQuestion))).findAny().orElse(null);
// if(notMappedCode != null) return false;
......
......@@ -16,4 +16,5 @@ public class CampaignInformationDTO {
private Long totalNotCall;
private Long campaignCustomer;
private Long customerListId;
private Long totalCusInList;
}
package com.viettel.campaign.web.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
//import java.io.Serializable;
import java.util.Date;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ContactCusResDTO {
private Long contactCustResultId;
private String campaignCode;
private String campaignName;
private String userName;
private String phoneNumber;
private String customerName;
private Date startCall;
private Date createTime;
private String contactStatus;
private String surveyStatus;
private String status;
private String recordStatus;
private Long callTime;
private Boolean enableEdit;
private Integer totalRow;
}
......@@ -14,7 +14,7 @@ public class ContactCustResultDTO extends BaseDTO {
private Long contactCustResultId;
private Long companySiteId;
private Short callStatus;
private Short contactStatus;
private String contactStatus;
private Short status;
private Integer satisfaction;
private String description;
......@@ -53,4 +53,6 @@ public class ContactCustResultDTO extends BaseDTO {
private String userName;
private String surveyStatus;
private Boolean enableEdit;
private Integer totalRow;
}
package com.viettel.campaign.web.rest;
import com.viettel.campaign.service.CampaignExecuteService;
import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -134,8 +136,10 @@ public class CampaignExecuteController {
@PostMapping("/callCustomer")
@ResponseBody
public ResponseEntity<ResultDTO> callCustomer(@RequestBody ContactCustResultDTO requestDto) {
ResultDTO result = campaignExecuteService.callCustomer(requestDto);
public ResponseEntity<ResultDTO> callCustomer(@RequestBody ContactCustResultDTO requestDto, HttpServletRequest request) {
String xAuthToken = request.getHeader("X-Auth-Token");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
ResultDTO result = campaignExecuteService.callCustomer(requestDto, userSession);
return new ResponseEntity<>(result, HttpStatus.OK);
}
......
......@@ -261,6 +261,20 @@ public class CustomerController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/searchCampaignInformation")
@ResponseBody
public ResponseEntity<?> searchCampaignInformation(@RequestBody CampaignCustomerDTO dto) {
ResultDTO resultDTO = customerService.searchCampaignInformation(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/addCustomerToCampaign")
@ResponseBody
public ResponseEntity<?> addCustomerToCampaign(@RequestBody CampaignCustomerDTO dto) {
ResultDTO resultDTO = customerService.addCustomerToCampaign(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
private String saveUploadFile(MultipartFile file) {
......
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