Commit b684a288 authored by ='s avatar =

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/viettel/campaign/web/rest/CampaignController.java
parents 2110d1e0 1dff9662
......@@ -25,7 +25,7 @@ public class CorsFilter implements Filter {
HttpServletResponse response = (HttpServletResponse) resp;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "Origin, Authorization, X-Requested-With, Content-Type, Accept, token1, X-Auth-Token");
......
package com.viettel.campaign.repository.ccms_full;
import com.viettel.campaign.web.dto.ScenarioQuestionDTO;
/**
* @author anhvd_itsol
*/
......
package com.viettel.campaign.repository.ccms_full.impl;
import com.viettel.campaign.repository.ccms_full.ScenarioAnswerRepositoryCustom;
import com.viettel.campaign.web.dto.ScenarioQuestionDTO;
/**
* @author anhvd_itsol
*/
public class ScenarioAnswerRepositoryImpl {
public class ScenarioAnswerRepositoryImpl implements ScenarioAnswerRepositoryCustom {
}
......@@ -32,7 +32,6 @@ public class ScenarioQuestionRepositoryImpl implements ScenarioQuestionRepositor
try {
StringBuilder sb = new StringBuilder();
//SELECT COUNT(1) FROM ScenarioQuestion WHERE code = :code AND scenarioId = :scenarioId AND campaignId = :campaignId AND companySiteId = :companySiteId AND status = 1"
sb.append("SELECT COUNT(1) FROM SCENARIO_QUESTION WHERE 1 = 1 AND STATUS = 1 ");
if (questionDTO.getScenarioQuestionId() != null) {
sb.append(" AND SCENARIO_QUESTION_ID <> :p_question_id ");
......
......@@ -7,6 +7,7 @@ import com.viettel.campaign.model.ccms_full.CustomizeFields;
import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.econtact.filter.UserSession;
import java.util.Date;
import java.util.List;
......@@ -66,7 +67,7 @@ public interface CustomerService {
byte[] buildTemplate(Long companySiteId);
Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> headerDTOS, Long companySiteId);
Map<String, Object> readAndValidateCustomer(String path, List<CustomizeFields> headerDTOS, UserSession userSession, Long customerListId);
List<CustomizeFieldObject> getCustomizeField(Long customerId);
}
......@@ -233,27 +233,18 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
public ResultDTO update(ScenarioQuestionDTO scenarioQuestionDTO) {
ResultDTO resultDTO = new ResultDTO();
List<ScenarioAnswerDTO> lstAnswers = new ArrayList<>();
List<ScenarioAnswer> lstAnswersToInsert = new ArrayList<>();
if (scenarioQuestionDTO.getScenarioQuestionId() == null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
try {
//ScenarioQuestion scenarioQuestion = modelMapper.map(scenarioQuestionDTO, ScenarioQuestion.class);
ScenarioQuestion questionTmp = scenarioQuestionRepository.findScenarioQuestionByScenarioQuestionId(scenarioQuestionDTO.getScenarioQuestionId());
if (questionTmp != null) {
//questionTmp.setCode(scenarioQuestionDTO.getCode());
//questionTmp.setOrderIndex(scenarioQuestionDTO.getOrderIndex());
// questionTmp.setIsDefault(scenarioQuestionDTO.getIsDefault());
// questionTmp.setIsRequire(scenarioQuestionDTO.getIsRequire());
// questionTmp.setQuestion(scenarioQuestionDTO.getQuestion());
// questionTmp.setType(scenarioQuestionDTO.getType());
ScenarioQuestion scenarioQuestion = modelMapper.map(scenarioQuestionDTO, ScenarioQuestion.class);
scenarioQuestionRepository.save(questionTmp);
if (scenarioQuestion.getScenarioQuestionId() != null) {
scenarioQuestionRepository.save(scenarioQuestion);
CampaignLog campaignLog = new CampaignLog();
campaignLog.setCompanySiteId(questionTmp.getCompanySiteId());
campaignLog.setCompanySiteId(scenarioQuestion.getCompanySiteId());
campaignLog.setCreateTime(new Date());
campaignLog.setAgentId(null);
campaignLog.setTableName("SCENARIO_QUESTION");
......@@ -261,46 +252,46 @@ public class ScenarioQuestionServiceImpl implements ScenarioQuestionService {
campaignLog.setPreValue(null);
campaignLog.setPostValue(null);
campaignLog.setDescription("Chinh sua cau hoi rieng le");
campaignLog.setCampaignId(questionTmp.getCampaignId());
campaignLog.setCustomerId(questionTmp.getScenarioQuestionId());
campaignLog.setCampaignId(scenarioQuestion.getCampaignId());
campaignLog.setCustomerId(scenarioQuestion.getScenarioQuestionId());
campaignLogRepository.save(campaignLog);
// if (scenarioQuestionDTO.getLstAnswers().size() > 0) {
// lstAnswers = scenarioQuestionDTO.getLstAnswers();
//
// lstAnswers.forEach(item -> {
// CampaignLog campaignLogAnswer = new CampaignLog();
// campaignLogAnswer.setCompanySiteId(scenarioQuestion.getCompanySiteId());
// campaignLogAnswer.setCreateTime(new Date());
// campaignLogAnswer.setAgentId(null);
// campaignLogAnswer.setTableName("SCENARIO_ANSWER");
// campaignLogAnswer.setColumnName(null);
// campaignLogAnswer.setPreValue(null);
// campaignLogAnswer.setPostValue(null);
// campaignLogAnswer.setCampaignId(scenarioQuestion.getCampaignId());
//
// if (item.getScenarioAnswerId() != null) {
// ScenarioAnswer answer = modelMapper.map(item, ScenarioAnswer.class);
// scenarioAnswerRepository.save(answer);
// campaignLogAnswer.setCustomerId(answer.getScenarioAnswerId());
// campaignLogAnswer.setDescription("Chinh sua cau tra loi");
// campaignLogRepository.save(campaignLogAnswer);
// } else {
// item.setCode(scenarioQuestion.getScenarioQuestionId() + "_" + item.getOrderIndex());
// item.setScenarioQuestionId(scenarioQuestion.getScenarioQuestionId());
// item.setCreateTime(new Date());
// item.setStatus((short) 1);
// ScenarioAnswer answer = modelMapper.map(item, ScenarioAnswer.class);
// scenarioAnswerRepository.save(answer);
// campaignLogAnswer.setCustomerId(answer.getScenarioAnswerId());
// campaignLogAnswer.setDescription("Them moi cau tra loi");
// campaignLogRepository.save(campaignLogAnswer);
// }
// });
// }
if (scenarioQuestionDTO.getLstAnswers().size() > 0) {
lstAnswers = scenarioQuestionDTO.getLstAnswers();
lstAnswers.forEach(item -> {
CampaignLog campaignLogAnswer = new CampaignLog();
campaignLogAnswer.setCompanySiteId(scenarioQuestion.getCompanySiteId());
campaignLogAnswer.setCreateTime(new Date());
campaignLogAnswer.setAgentId(null);
campaignLogAnswer.setTableName("SCENARIO_ANSWER");
campaignLogAnswer.setColumnName(null);
campaignLogAnswer.setPreValue(null);
campaignLogAnswer.setPostValue(null);
campaignLogAnswer.setCampaignId(scenarioQuestion.getCampaignId());
if (item.getScenarioAnswerId() != null) {
ScenarioAnswer answer = modelMapper.map(item, ScenarioAnswer.class);
scenarioAnswerRepository.save(answer);
campaignLogAnswer.setCustomerId(answer.getScenarioAnswerId());
campaignLogAnswer.setDescription("Chinh sua cau tra loi");
campaignLogRepository.save(campaignLogAnswer);
} else {
item.setCode(scenarioQuestion.getScenarioQuestionId() + "_" + item.getOrderIndex());
item.setScenarioQuestionId(scenarioQuestion.getScenarioQuestionId());
item.setCreateTime(new Date());
item.setStatus((short) 1);
ScenarioAnswer answer = modelMapper.map(item, ScenarioAnswer.class);
scenarioAnswerRepository.save(answer);
campaignLogAnswer.setCustomerId(answer.getScenarioAnswerId());
campaignLogAnswer.setDescription("Them moi cau tra loi");
campaignLogRepository.save(campaignLogAnswer);
}
});
}
}
resultDTO.setData(questionTmp);
resultDTO.setData(scenarioQuestion);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception ex) {
......
......@@ -268,4 +268,10 @@ public class CampaignController {
ResultDTO resultDTO = campaignService.getCustomerChoosenList(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT)
public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) {
ResultDTO result = campaignService.renewCampaign(campaignDTO);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
......@@ -28,10 +28,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
@Controller
@RequestMapping("/ipcc/customer")
......@@ -187,20 +184,21 @@ public class CustomerController {
@PostMapping(value = "/importFile")
public ResponseEntity<?> importFile(@RequestParam("file") MultipartFile file,
@RequestParam("companySiteId") Long companySiteId,
@RequestParam("customerListId") Long customerListId,
@RequestHeader("X-Auth-Token") String authToken) {
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(authToken);
if (file.isEmpty()) {
return new ResponseEntity<>("Please select a file", HttpStatus.OK);
return new ResponseEntity<>(BundleUtils.getLangString("customer.fileNotSelected"), HttpStatus.OK);
}
if (!Objects.equals(FilenameUtils.getExtension(file.getOriginalFilename()), Constants.FileType.xlsx)) {
return new ResponseEntity<>("File khong dung dinh dang", HttpStatus.OK);
return new ResponseEntity<>(BundleUtils.getLangString("customer.invalidTemplate", locale), HttpStatus.OK);
}
String path = saveUploadFile(file);
List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(companySiteId);
Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, companySiteId);
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()
......
......@@ -67,3 +67,39 @@ IPCC_STATUS = IPCC_STATUS
EMAIL = EMAIL
CUSTOMER_TYPE = CUSTOMER_TYPE
AVATAR_LINK = AVATAR_LINK
#Customer Excel Header
customer.no = No
customer.fullname = Full Name#Required\nLetters only\nmaximum 1000 characters
customer.mainPhone = Main mobile phone#Number only\nmultiple numbers allowed\neach seperate by semicolon\nmaximum 50 characters
customer.secondPhone = Secondary phone#Number only\nmultiple numbers allowed\neach seperate by semicolon\nmaximum 50 characters
customer.email = Email#multiple emails allowed\neach seperate by semicolon\nmaximum 100 characters
customer.address = Address#maximum 500 characters
customer.cusType = Customer Type
customer.companyName = Company#maximum 100 characters
customer.description = Description#maximum 2000 characters
customer.callAllowed = Call Allowed
customer.emailAllowed = Email Allowed
customer.smsAllowed = Sms Allowed
customer.result = Result
customer.cusType.normal = Normal
customer.cusType.vip = VIP
customer.cusType.blacklist = Blacklist
customer.yes = Yes
customer.not = No
customer.invalidTemplate = Invalid Template
customer.noData = Template empty
customer.nameRequired = Full name required;
customer.emailMax50 = Email must less than 50 character;
customer.invalidCustomer = All 3 fields Main phone, second phone and email must not null;
customer.importSuccess = Import Successful
customer.importFailed = Import Failed
customer.errorValidate = Error while validating
customer.phoneMax50 = Mobile phone must less than 50 character;
customer.phoneExists = Mobile phone exists;
customer.notMatch = not match regexp validation
customer.notGreaterThan = not greater than
customer.notLessThan = not less than
customer.importCustomer = IMPORT CUSTOMER
customer.notice = Attention: A record is valid when Full Name is not null and one of three fields Main phone, secondary phone or email is not null
customer.fileNotSelected=Please select a file
......@@ -69,3 +69,39 @@ IPCC_STATUS = IPCC_STATUS
EMAIL = EMAIL
CUSTOMER_TYPE = CUSTOMER_TYPE
AVATAR_LINK = AVATAR_LINK
#Customer Excel Header
customer.no = STT
customer.fullname = Họ và tên#Bắt buộc\nĐịnh dạng chữ\ntối đa 1000 kí tự
customer.mainPhone = Số điện thoại chính#Định dạng số\ncho phép nhập nhiều số điện thoại chính\ncác số cách nhau bởi dấu chấm phấy\ntối đa 50 ký tự
customer.secondPhone = Số điện thoại phụ#Định dạng số\ncho phép nhập nhiều số điện thoại phụ\ncác số cách nhau bởi dấu chấm phấy hoặc dấu phẩy\ntối đa 50 ký tự
customer.email=Email#Cho phép nhập nhiều email\nmỗi email cách nhau bởi dấu \";\"\ntối đa 100 ký tự
customer.address = Địa chỉ#Tối đa 500 ký tự
customer.cusType = Loại khách hàng
customer.companyName = Công ty#Tối đa 100 ký tự
customer.description = Ghi chú#Tối đa 2000 ký tự
customer.callAllowed = Cho phép gọi ra
customer.emailAllowed = Cho phép gửi email
customer.smsAllowed = Cho phép gửi sms
customer.result = Kết quả
customer.cusType.normal = Thường
customer.cusType.vip = VIP
customer.cusType.blacklist = Blacklist
customer.yes =
customer.not = Không
customer.invalidTemplate = Template sai định dạng
customer.noData = Template không có dữ liệu
customer.nameRequired = Họ và tên không được để trống;
customer.emailMax50 = Email không được quá 50 kí tự;
customer.invalidCustomer = Cả 3 thông tin số điện thoại chính, số điện phụ và email không được để trống;
customer.importSuccess = Import dữ liệu thành công
customer.importFailed = Import dữ liệu thất bại
customer.errorValidate = Validate dữ liệu lỗi
customer.phoneMax50 = Số điện thoại không được quá 50 kí tự;
customer.phoneExists = Số điện thoại chính đã tồn tại;
customer.notMatch = không đúng định dạng
customer.notGreaterThan = không được lớn hơn
customer.notLessThan = không được nhỏ hơn
customer.importCustomer = IMPORT KHÁCH HÀNG
customer.notice = Chú ý: 1 bản ghi được coi là hợp lệ bắt buộc phải có thông tin Họ và Tên và 1 trong 3 thông tin liên lạc (số điện thoại chính, số điện thoại phụ hoặc email)
customer.fileNotSelected=Bạn chưa chọn 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