Commit 5562315e 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/CampaignCompleteCodeServiceImpl.java
parents 0cad1285 8fcc4f8f
package com.viettel.campaign.mapper;
import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.web.dto.CustomerListDTO;
public class CustomerListMapper extends BaseMapper<CustomerList, CustomerListDTO> {
@Override
public CustomerListDTO toDtoBean(CustomerList customerList) {
CustomerListDTO obj = new CustomerListDTO();
if (customerList != null) {
obj.setCreateAt(customerList.getCreateAt());
obj.setCreateBy(customerList.getCreateBy());
obj.setCustomerListCode(customerList.getCustomerListCode());
obj.setCustomerListId(customerList.getCustomerListId());
obj.setCustomerSiteId(customerList.getCustomerSiteId());
obj.setCustomerListName(customerList.getCustomerListName());
obj.setDeptCreate(customerList.getDeptCreate());
obj.setSource(customerList.getSource());
obj.setStatus(customerList.getStatus());
obj.setUpdateAt(customerList.getUpdateAt());
obj.setUpdateBy(customerList.getUpdateBy());
}
return obj;
}
@Override
public CustomerList toPersistenceBean(CustomerListDTO dtoBean) {
CustomerList obj = new CustomerList();
if (dtoBean != null) {
obj.setCreateAt(dtoBean.getCreateAt());
obj.setCreateBy(dtoBean.getCreateBy());
obj.setCustomerListCode(dtoBean.getCustomerListCode());
obj.setCustomerListId(dtoBean.getCustomerListId());
obj.setCustomerListName(dtoBean.getCustomerListName());
obj.setCustomerSiteId(dtoBean.getCustomerSiteId());
obj.setDeptCreate(dtoBean.getDeptCreate());
obj.setSource(dtoBean.getSource());
obj.setStatus(dtoBean.getStatus());
obj.setUpdateAt(dtoBean.getUpdateAt());
obj.setUpdateBy(dtoBean.getUpdateBy());
}
return obj;
}
}
......@@ -6,9 +6,11 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ApParamRepository extends JpaRepository<ApParam, Long>, ApParamRepositoryCustom {
Page<ApParam> findAll(Pageable pageable);
......
package com.viettel.campaign.repository;
import com.viettel.campaign.model.ApParam;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ApParamRepositoryCustom {
}
......@@ -7,9 +7,11 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CampaignCompleteCodeRepository extends JpaRepository<CampaignCompleteCode, Long> {
Page<CampaignCompleteCode> findAll(Pageable pageable);
......
......@@ -4,10 +4,13 @@ import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CampaignRepositoryCustom {
List<CampaignDTO> searchCampaignExecute(String agentId, Pageable pageable);
ResultDTO search(CampaignRequestDTO requestDto);
}
package com.viettel.campaign.repository;
import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.web.dto.ResultDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
public interface CustomerListRepository extends JpaRepository<CustomerList, Long> {
CustomerList findCustomerListByCustomerListId(long customerListId);
CustomerList findByCustomerListCode(String customerListCode);
@Modifying
@Query("delete from CustomerList c where c.customerListId in (:ids)")
int deleteIds(@Param("ids") List<Long> ids);
}
......@@ -5,9 +5,11 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CustomerRepository extends JpaRepository<Customer, Long> {
Page<Customer> findAll(Pageable pageable);
......@@ -17,4 +19,5 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
@Query("SELECT COUNT(0) FROM Customer t WHERE t.mobileNumber = ?1 and t.siteId = ?2 and t.status = 1 ")
Long findByMobileNumberAndSiteId(String mobileNumber, Long siteId);
}
package com.viettel.campaign.repository;
package com.viettel.campaign.repository.impl;
import com.viettel.campaign.model.ApParam;
import com.viettel.campaign.repository.ApParamRepositoryCustom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
......
package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
......@@ -8,5 +7,6 @@ import java.util.Map;
public interface CampaignService {
Map searchCampaignExecute(int page, int pageSize, String sort, String agentId);
ResultDTO search(CampaignRequestDTO requestDto);
}
package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import java.util.List;
import java.util.Map;
public interface CustomerListService {
Map getCustomerList(int page, int pageSize, String sort);
ResultDTO createCustomerList(CustomerListDTO customerListDTO);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteIds(List<Long> ids);
}
package com.viettel.campaign.service;
import com.viettel.campaign.mapper.CustomerListMapper;
import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.repository.CustomerListRepository;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.util.*;
@Service
public class CustomerListServiceImpl implements CustomerListService {
@Autowired
EntityManager entityManager;
@Autowired
CustomerListRepository customerListRepository;
@Override
public Map getCustomerList(int page, int pageSize, String sort) {
Map result = new HashMap();
List<CustomerList> list = new ArrayList<>();
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
Page<CustomerList> pc = customerListRepository.findAll(pageable);
result.put("totalItem", pc.getTotalElements());
result.put("customerList", pc.iterator());
return result;
}
@Override
public ResultDTO createCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
Date today = new Date();
CustomerList customerList = new CustomerList();
try {
if (customerListDTO != null) {
// insert
CustomerList findCustomer = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (findCustomer == null) {
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.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultDTO;
}
@Override
public ResultDTO updateCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
Date today = new Date();
CustomerList customerList = customerListRepository.findCustomerListByCustomerListId(customerListDTO.getCustomerListId());
try {
if (customerListDTO != null) {
// update
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerList = customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultDTO;
}
@Override
public ResultDTO deleteCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
Date today = new Date();
CustomerList customerList = new CustomerList();
try {
if (customerListDTO != null) {
// delete
customerListRepository.deleteById(customerListDTO.getCustomerListId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultDTO;
}
@Transactional
@Override
public ResultDTO deleteIds(List<Long> ids) {
ResultDTO resultDTO = new ResultDTO();
try {
if (ids != null) {
customerListRepository.deleteIds(ids);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultDTO;
}
}
package com.viettel.campaign.service;
package com.viettel.campaign.service.impl;
import com.viettel.campaign.service.ApParamService;
import com.viettel.campaign.web.dto.ApParamDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.mapper.ApParamMapper;
......
package com.viettel.campaign.service;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.mapper.CampaignCompleteCodeMapper;
import com.viettel.campaign.model.CampaignCompleteCode;
import com.viettel.campaign.repository.CampaignCompleteCodeRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@Service
@ComponentScan
public class CampaignCompleteCodeServiceImpl implements CampaignCompleteCodeService {
@Autowired
CampaignCompleteCodeRepository completeCodeRepository;
private Logger log = LoggerFactory.getLogger(CampaignCompleteCodeServiceImpl.class);
@Override
public Map listAllCompleteCode(int page, int pageSize, String sort) {
Map result = new HashMap();
......
package com.viettel.campaign.service.impl;
import com.viettel.campaign.repository.CampaignRepository;
import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.service.CampaignService;
import com.viettel.campaign.web.dto.CampaignDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -21,18 +18,18 @@ import java.util.Map;
@Service
public class CampaignServiceImpl implements CampaignService {
@Autowired(required=true)
@Autowired
CampaignRepository campaignRepository;
@Override
public Map searchCampaignExecute(int page, int pageSize, String sort, String agentId) {
Map result = new HashMap();
List<CampaignDTO> lst = new ArrayList<>();
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
lst = campaignRepository.searchCampaignExecute(agentId, pageable);
List<CampaignDTO> lst = campaignRepository.searchCampaignExecute(agentId, pageable);
List<CampaignDTO> count = campaignRepository.searchCampaignExecute(agentId, null);
result.put("totalItem", lst.size());
result.put("totalItem", count.size());
result.put("data", lst);
return result;
......
package com.viettel.campaign.service;
package com.viettel.campaign.service.impl;
import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.mapper.CustomerMapper;
......
......@@ -14,11 +14,11 @@ public class CampaignDTO extends BaseDTO {
private BigDecimal companySiteId;
private String campaignCode;
private String campaignName;
private BigDecimal chanel;
private Short chanel;
private String content;
private BigDecimal customerNumber;
private String target;
private BigDecimal status;
private Short status;
private Date startTime;
private Date endTime;
private Integer maxRecall;
......
......@@ -3,20 +3,22 @@ package com.viettel.campaign.web.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class CustomerListDTO extends BaseDTO {
private String customerListId;
private String customerListPK;
private String customerSiteId;
private long customerListId;
// private String customerListPK;
private long customerSiteId;
private String customerListCode;
private String customerListName;
private String status;
private short status;
private String createBy;
private String createAt;
private Date createAt;
private String updateBy;
private String updateAt;
private Date updateAt;
private String source;
private String deptCreate;
}
......@@ -17,10 +17,10 @@ public class CampaignRequestDTO extends BaseDTO {
String campaignCode;
String campaignName;
Short status;
Date fromDateFr;
Date fromDateTo;
Date toDateTo;
Date toDateFr;
String fromDateFr;
String fromDateTo;
String toDateTo;
String toDateFr;
Long numOfCusFr;
Long numOfCusTo;
Short type;
......
......@@ -15,6 +15,7 @@ import java.util.Map;
@Controller
@RequestMapping("/ipcc/customer")
@CrossOrigin("*")
public class CustomerController {
private static final Logger LOGGER = Logger.getLogger(CustomerController.class);
......
package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.service.CustomerListService;
import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(path = "/ipcc/customerlist")
@CrossOrigin(origins = "*")
public class CustomerListController {
@Autowired(required=true)
CustomerListService customerListService;
@GetMapping("/findAll")
@ResponseBody
public ResponseEntity findAllCustomerList(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) {
Map result = customerListService.getCustomerList(page, pageSize, sort);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@PostMapping("/create")
@ResponseBody
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO();
//LogUtil logUtil = new LogUtil();
//logUtil.initKpiLog("createCust")
try {
//LOGGER.info("Returning createCustomer: start");
result = customerListService.createCustomerList(customerListDTO);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) {
result.setErrorCode("-1");
// LOGGER.error(e);
//logUtil.endKpiLog(customerDTO, 1, result.getErrorCode(), e.getMessage(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
}
return result;
// return new ResponseEntity<>("", HttpStatus.OK);
}
@PutMapping("/update")
@ResponseBody
public ResultDTO updateCompleteCode(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO();
//LogUtil logUtil = new LogUtil();
//logUtil.initKpiLog("createCust");
try {
//LOGGER.info("Returning createCustomer: start");
result = customerListService.updateCustomerList(customerListDTO);
//LOGGER.info("Returning createCustomer:" + result.getErrorCode());
//logUtil.endKpiLog(customerDTO, 0, result.getErrorCode(), result.getDetail(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
} catch (Exception e) {
result.setErrorCode("-1");
// LOGGER.error(e);
//logUtil.endKpiLog(customerDTO, 1, result.getErrorCode(), e.getMessage(), CustomerController.class, customerDTO.getAgentProcess(), this.serverPort);
}
return result;
}
@PostMapping("/delete")
@ResponseBody
public ResultDTO deleteCompleteCode(@RequestBody @Valid CustomerListDTO customerListDTO) {
ResultDTO result = new ResultDTO();
result = customerListService.deleteCustomerList(customerListDTO);
return result;
}
@PostMapping("/ids")
@ResponseBody
public ResultDTO deleteIds(@RequestBody @Valid List<Long> ids) {
ResultDTO result = new ResultDTO();
result = customerListService.deleteIds(ids);
return result;
}
}
......@@ -7,10 +7,7 @@ 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.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.data.domain.Page;
import java.util.Map;
......@@ -31,7 +28,7 @@ public class CampaignController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "/search",method = RequestMethod.POST)
@RequestMapping(value = "/search", method = RequestMethod.POST)
public ResponseEntity<ResultDTO> search(@RequestBody CampaignRequestDTO requestDto) {
ResultDTO result = campaignService.search(requestDto);
return new ResponseEntity<>(result, HttpStatus.OK);
......
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