Commit 53925bbf authored by Tu Bach's avatar Tu Bach

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

# Conflicts:
#	src/main/java/com/viettel/campaign/repository/ccms_full/CampaignCustomerRepository.java
parents 43b6327c 21d7b924
......@@ -69,7 +69,7 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
List<CampaignCustomer> findCustomerNoContact(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId, @Param("customerListId") Long customerListId);
@Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " +
"WHERE CC.STATUS IN (SELECT COMPLETE_VALUE from CAMPAIGN_COMPLETE_CODE where STATUS = 1 and IS_FINISH = 0 and IS_RECALL = 0)" +
"WHERE CC.STATUS IN (SELECT COMPLETE_VALUE from CAMPAIGN_COMPLETE_CODE where STATUS = 1 and COMPLETE_TYPE=1)" +
"AND CC.CAMPAIGN_ID = :campaignId " +
"AND CC.COMPANY_SITE_ID = :companySiteId " +
"AND CC.CUSTOMER_LIST_ID = :customerListId", nativeQuery = true)
......@@ -88,6 +88,6 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
" and (status = 0 or status in (select * from status_customer))", nativeQuery = true)
List<CampaignCustomer> findListCustomerToDel(@Param("p_company_site_id") Long companySiteId, @Param("p_campaign_id") Long campaignId, @Param("p_cus_list_id") Long customerListId);
@Query(value = "SELECT COMPLETE_VALUE FROM CAMPAIGN_COMPLETE_CODE WHERE STATUS = 1 AND IS_FINISH = 0 AND IS_RECALL = 0", nativeQuery = true)
@Query(value = "select complete_value from campaign_complete_code where status = 1 and complete_type = 1", nativeQuery = true)
List<Short> getStatus();
}
......@@ -37,6 +37,8 @@ public interface CampaignRepositoryCustom {
ResultDTO getCustomerListInformation(CampaignRequestDTO dto);
ResultDTO getCountIndividualOnList(CampaignRequestDTO dto);
List<ApParamDTO> getConnectStatus(Long companySiteId);
//</editor-fold>
}
......@@ -12,7 +12,7 @@ public interface CampaignCfgService {
Map listCompleteCodeByName(int page, int pageSize, String sort, String name);
ResultDTO createCompleteCode(CampaignCfgDTO completeCodeDTO);
ResultDTO createCompleteCode(CampaignCfgDTO completeCodeDTO, Long userId);
ResultDTO updateCompleteCode(CampaignCfgDTO completeCodeDTO);
......
......@@ -70,6 +70,8 @@ public interface CampaignService {
ResultDTO getCustomerListInformation(CampaignRequestDTO dto);
ResultDTO getCountIndividualOnList(CampaignRequestDTO dto);
ResultDTO saveCustomerCampaign(CampaignRequestDTO dto);
ResultDTO getConnectStatus(Long companySiteId);
......
......@@ -5,6 +5,7 @@ import com.viettel.campaign.mapper.CampaignCompleteCodeMapper;
import com.viettel.campaign.model.ccms_full.CampaignCfg;
import com.viettel.campaign.repository.ccms_full.CampaignCfgRepository;
import com.viettel.campaign.repository.ccms_full.CampaignRepository;
import com.viettel.campaign.service.CampaignCfgService;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.DataUtil;
......@@ -157,7 +158,7 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO createCompleteCode(CampaignCfgDTO completeCodeDTO) {
public ResultDTO createCompleteCode(CampaignCfgDTO completeCodeDTO, Long userId) {
ResultDTO resultDTO = new ResultDTO();
CampaignCompleteCodeMapper compCodeMapper = new CampaignCompleteCodeMapper();
Date today = new Date();
......@@ -165,12 +166,37 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
try {
if (completeCodeDTO != null) {
// insert
compCode = compCodeMapper.toPersistenceBean(completeCodeDTO);
compCode = completeCodeRepository.save(compCode);
// compCode = compCodeMapper.toPersistenceBean(completeCodeDTO);
// compCode = completeCodeRepository.save(compCode);
//
// resultDTO.setErrorCode("0");
// resultDTO.setDescription("Complete Code: " + compCode.getCampaignCompleteCodeId() + " created!");
CampaignCfg cl = new CampaignCfg();
cl.setStatus((short) 1);
cl.setCreateBy(String.valueOf(userId));
cl.setCreateAt(new Date());
cl.setUpdateBy(null);
cl.setUpdateAt(null);
cl.setChanel(completeCodeDTO.getChanel());
cl.setCompleteName(completeCodeDTO.getCompleteName().trim());
cl.setCompleteValue(completeCodeDTO.getCompleteValue());
cl.setCampaignType(completeCodeDTO.getCampaignType());
cl.setDescription(completeCodeDTO.getDescription().trim());
cl.setCompleteType(completeCodeDTO.getCompleteType());
cl.setCompanySiteId(completeCodeDTO.getCompanySiteId());
cl.setCampaignCompleteCodeId(completeCodeDTO.getCampaignCompleteCodeId());
cl.setCampaignId(completeCodeDTO.getCampaignId());
cl.setDurationLock(completeCodeDTO.getDurationLock());
cl.setIsFinish(completeCodeDTO.getIsFinish());
cl.setIsLock(completeCodeDTO.getIsLock());
cl.setIsRecall(completeCodeDTO.getIsRecall());
resultDTO.setErrorCode("0");
resultDTO.setDescription("Complete Code: " + compCode.getCampaignCompleteCodeId() + " created!");
resultDTO.setData(completeCodeRepository.save(cl));
return resultDTO;
} else {
resultDTO.setErrorCode("-2");
resultDTO.setDescription("CompleteCodeDTO null");
......
......@@ -627,6 +627,12 @@ public class CampaignServiceImpl implements CampaignService {
return campaignRepositoryCustom.getCustomerListInformation(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCountIndividualOnList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCountIndividualOnList(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO saveCustomerCampaign(CampaignRequestDTO dto) {
......@@ -668,7 +674,12 @@ public class CampaignServiceImpl implements CampaignService {
// Lay ra danh sach khach hang can loai bo
List<CampaignCustomer> listCustomerToDelete = campaignCustomerRepository.findListCustomerToDel(companySiteId, campaignId, customerListDTO.getCustomerListId());
for (int j = 0; j < custToDel; j++) {
campaignCustomerRepository.delete(listCustomerToDelete.get(j));
if (listCustomerToDelete.get(j).getStatus() == 0) {
campaignCustomerRepository.delete(listCustomerToDelete.get(j));
} else {
listCustomerToDelete.get(j).setInCampaignStatus((short) 0);
campaignCustomerRepository.save(listCustomerToDelete.get(j));
}
}
}
}
......
......@@ -31,5 +31,5 @@ public class CampaignCustomerDTO extends BaseDTO{
private String lstCustomerId;
private List<CustomerQueryDTO> listQuery;
private Long field;
private Integer timezoneOffset;
}
......@@ -58,4 +58,5 @@ public class CampaignRequestDTO extends BaseDTO {
String customerListId;
String statuses;
String channels;
Integer timezoneOffset;
}
package com.viettel.campaign.web.rest;
import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.CampaignCfgDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.service.CampaignCfgService;
import com.viettel.campaign.web.dto.request_dto.CampaignCfgRequestDTO;
import com.viettel.econtact.filter.UserSession;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
......@@ -38,13 +41,16 @@ public class CampaignCfgController {
@PostMapping("/create")
@ResponseBody
public ResultDTO createCompleteCode(@RequestBody @Valid CampaignCfgDTO completeCodeDTO) {
public ResultDTO createCompleteCode(@RequestBody @Valid CampaignCfgDTO completeCodeDTO , HttpServletRequest httpServletRequest) {
String xAuthToken = httpServletRequest.getHeader("X-Auth-Token");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
ResultDTO result = new ResultDTO();
//LogUtil logUtil = new LogUtil();
//logUtil.initKpiLog("createCust")
try {
//LOGGER.info("Returning createCustomer: start");
result = completeCodeService.createCompleteCode(completeCodeDTO);
result = completeCodeService.createCompleteCode(completeCodeDTO, userSession.getUserId());
//LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) {
......
......@@ -15,6 +15,7 @@ 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;
......@@ -205,6 +206,13 @@ public class CampaignController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/getCountIndividualOnList")
@ResponseBody
public ResponseEntity getCountIndividualOnList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.getCountIndividualOnList(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/saveCustomerCampaign")
@ResponseBody
public ResponseEntity saveCustomerCampaign(@RequestBody CampaignRequestDTO campaignRequestDTO) {
......
......@@ -37,7 +37,7 @@ import java.util.Map;
@RequestMapping("/ipcc/customer")
@CrossOrigin(origins = "*")
public class CustomerController {
private CustomerQueryRepository customerQueryRepo;
private CustomerQueryRepository customerQueryRepo;
private static final Logger LOGGER = LoggerFactory.getLogger(CustomerController.class);
......@@ -198,11 +198,8 @@ public class CustomerController {
try {
UserSession userSession = (UserSession) RedisUtil.getInstance().get(request.getHeader("X-Auth-Token"));
if (file.isEmpty()) {
return new ResponseEntity<>("file-empty", HttpStatus.OK);
return new ResponseEntity<>("file-empty", HttpStatus.NO_CONTENT);
}
// if (!Objects.equals(FilenameUtils.getExtension(file.getOriginalFilename()), Constants.FileType.xlsx)) {
// return new ResponseEntity<>("template-invalid", HttpStatus.OK);
// }
String path = saveUploadFile(file);
List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, Long.parseLong(customerListId));
......@@ -265,18 +262,15 @@ public class CustomerController {
}
private String saveUploadFile(MultipartFile file) {
try {
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(Config.EXCEL_DIR);
if (!uploadFolder.exists()) {
uploadFolder.mkdir();
}
// Path path = Paths.get(BundleUtils.getGlobalConfig("import.uploadFolder"), fileName);
Path path = Paths.get(Config.EXCEL_DIR, fileName);
Files.write(path, content);
return path.toString();
......@@ -286,7 +280,7 @@ public class CustomerController {
return null;
}
// @GetMapping("/query")
// @GetMapping("/query")
// public ResponseEntity<List<Customer>> query(@RequestParam(value = "search") String query) {
// List<Customer> things = customerQueryRepo.findAll(query);
// if (things.isEmpty()) {
......@@ -294,16 +288,16 @@ public class CustomerController {
// }
// return ResponseEntity.ok(things);
// }
@GetMapping(path = "", produces = { MediaType.APPLICATION_JSON_VALUE })
@GetMapping(path = "", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<Customer>> query(@RequestParam(value = "search") String query) {
List<Customer> result = null;
try {
result= customerService.searchByQuery(query);
}catch (IllegalArgumentException iae){
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
result = customerService.searchByQuery(query);
} catch (IllegalArgumentException iae) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(result);
}
return ResponseEntity.status(HttpStatus.OK)
return ResponseEntity.status(HttpStatus.OK)
.body(result);
}
......@@ -316,7 +310,7 @@ public class CustomerController {
@PostMapping("/searchIndividualCustomer")
@ResponseBody
public ResponseEntity searchCustomizeFields(@RequestBody CampaignCustomerDTO campaignCustomerDTO ) {
public ResponseEntity searchCustomizeFields(@RequestBody CampaignCustomerDTO campaignCustomerDTO) {
ResultDTO result = customerService.searchCustomizeFields(campaignCustomerDTO);
return new ResponseEntity<>(result, HttpStatus.OK);
}
......
......@@ -89,7 +89,9 @@ customer.yes = Yes
customer.not = No
customer.noData = Template empty
customer.nameRequired = Full name required;
customer.emailMax50 = Email must less than 50 character;
customer.emailMax100=Email must less than 100 character;
customer.invalidRecord=Invalid Record, required one more contact information;
customer.onlyNumber=Phone contain number only;
customer.importSuccess = Import Successful
customer.importFailed = Import Failed
customer.errorValidate = Error while validating
......@@ -102,6 +104,7 @@ 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.emailInvalid=Invalid email;
customer.emailExists=Email exists;
customer.cusTypeInvalid=Customer type Invalid;
common.fileNotSelected=Please select a file
common.fileInvalidFormat=File invalid
......
......@@ -91,10 +91,9 @@ customer.yes = Có
customer.not = Khô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.mainPhoneRequired=Số điện thoại chính không được để trống
customer.secondPhoneRequired=Số điện thoại phụ không được để trống
customer.emailRequired=Số điện thoại email không được để trống
customer.emailMax100=Email không được quá 100 kí tự;
customer.invalidRecord=Bắt buộc nhập 1 trong 3 thông tin liên lạc(Số điện thoại chính, Số điện thoại phụ, Email);
customer.onlyNumber=Số điện thoại chỉ được nhập số;
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
......@@ -107,6 +106,7 @@ 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.emailInvalid=Email không đúng định dạng;
customer.emailExists=Email đã tồn tại;
customer.cusTypeInvalid=Loại khách hàng không hợp lệ;
common.fileNotSelected=Bạn chưa chọn file
common.fileInvalidFormat=File không hợp lệ
......
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