|
|
|
@ -4,13 +4,20 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.daqing.financial.crms.dao.CompanyCustomerDao; |
|
|
|
|
import com.daqing.financial.crms.dao.CustomerDao; |
|
|
|
|
import com.daqing.financial.crms.dao.PersonalCustomerDao; |
|
|
|
|
import com.daqing.financial.crms.feign.HrmsFeignService; |
|
|
|
|
import com.daqing.financial.crms.service.CustomerService; |
|
|
|
|
import com.daqing.framework.domain.crms.CompanyCustomerEntity; |
|
|
|
|
import com.daqing.framework.domain.crms.CustomerEntity; |
|
|
|
|
import com.daqing.framework.domain.crms.PersonalCustomerEntity; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CrmsConstant; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CustomerTO; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CustomerVOCompany; |
|
|
|
|
import com.daqing.framework.domain.crms.ext.CustomerVOPersonal; |
|
|
|
|
import com.daqing.framework.domain.crms.request.CustomerRequest; |
|
|
|
|
import com.daqing.framework.domain.hrms.EmployeeEntity; |
|
|
|
|
import com.daqing.framework.domain.hrms.ext.EmployeeTO; |
|
|
|
|
import com.daqing.framework.model.response.ResponseResult; |
|
|
|
|
import com.daqing.framework.utils.PageUtils; |
|
|
|
@ -18,6 +25,7 @@ import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
@ -28,6 +36,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
@Autowired |
|
|
|
|
private CustomerDao customerDao; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private PersonalCustomerDao personalCustomerDao; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private CompanyCustomerDao companyCustomerDao; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private HrmsFeignService hrmsFeignService; |
|
|
|
|
|
|
|
|
@ -42,12 +56,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
@Override |
|
|
|
|
public PageUtils queryList(Integer page, Integer size, CustomerRequest customerRequest) { |
|
|
|
|
|
|
|
|
|
// 选择某段时间内客户信息的时间参数校验
|
|
|
|
|
timeCheckout(customerRequest.getCreateTime(),customerRequest.getStartTime(),customerRequest.getEndTime(),customerRequest); |
|
|
|
|
// 时间参数校验
|
|
|
|
|
this.timeCheckout(customerRequest.getCreateTime(), customerRequest.getStartTime(), customerRequest.getEndTime(), customerRequest); |
|
|
|
|
|
|
|
|
|
//分页参数校验
|
|
|
|
|
Page<Object> pages = pageCheckout(page, size); |
|
|
|
|
//查询所有客户的基本信息
|
|
|
|
|
// 分页参数校验
|
|
|
|
|
Page<Object> pages = this.pageCheckout(page, size); |
|
|
|
|
// 查询所有客户的基本信息
|
|
|
|
|
IPage<CustomerEntity> customerEntityIPage = customerDao.queryList(pages, customerRequest); |
|
|
|
|
|
|
|
|
|
// 获取所有的客户基本信息
|
|
|
|
@ -55,33 +69,88 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
// 获取所有的客户经理id
|
|
|
|
|
Long[] ids = customers.stream().map(CustomerEntity::getId).toArray(Long[]::new); |
|
|
|
|
|
|
|
|
|
//TODO 远程调用查询客户经理信息的接口
|
|
|
|
|
ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids); |
|
|
|
|
List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData(); |
|
|
|
|
if (ids != null && ids.length != 0) { |
|
|
|
|
//TODO 远程调用查询客户经理信息的接口
|
|
|
|
|
ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids); |
|
|
|
|
List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData(); |
|
|
|
|
|
|
|
|
|
// 将客户信息和客户经理及部门信息拼装起来
|
|
|
|
|
List<CustomerTO> customerTOS = jointCustomerEmployee(customers, employeeTO); |
|
|
|
|
// 将客户信息和客户经理及部门信息拼装起来
|
|
|
|
|
List<CustomerTO> customerTOS = this.jointCustomerEmployee(customers, employeeTO); |
|
|
|
|
|
|
|
|
|
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
|
|
|
|
|
IPage<CustomerTO> iPage = new Page<>(); |
|
|
|
|
BeanUtils.copyProperties(customerEntityIPage, iPage); |
|
|
|
|
iPage.setRecords(customerTOS); |
|
|
|
|
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
|
|
|
|
|
IPage<CustomerTO> iPage = new Page<>(); |
|
|
|
|
BeanUtils.copyProperties(customerEntityIPage, iPage); |
|
|
|
|
iPage.setRecords(customerTOS); |
|
|
|
|
return new PageUtils(iPage); |
|
|
|
|
} else { |
|
|
|
|
return new PageUtils(customerEntityIPage); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据id查询客户的信息 |
|
|
|
|
* |
|
|
|
|
* @param id 客户id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public ResponseResult queryCustomerById(Long id) { |
|
|
|
|
|
|
|
|
|
return new PageUtils(iPage); |
|
|
|
|
// 员工基本信息
|
|
|
|
|
CustomerEntity customer = customerDao.queryCustomerById(id); |
|
|
|
|
if (customer == null) { |
|
|
|
|
return new ResponseResult<CustomerEntity>().SUCCESS(null); |
|
|
|
|
} |
|
|
|
|
// 客户经理姓名
|
|
|
|
|
String name = hrmsFeignService.getEmployeeById(customer.getManager()).getData().getName(); |
|
|
|
|
// 判断该客户的类型
|
|
|
|
|
if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType())) { |
|
|
|
|
PersonalCustomerEntity personalCustomerEntity = personalCustomerDao.queryPersonalCustomerById(id); |
|
|
|
|
//封装个人类型客户信息
|
|
|
|
|
CustomerVOPersonal customerVOPersonal = this.setPersonal(customer, name, personalCustomerEntity); |
|
|
|
|
return new ResponseResult<CustomerVOPersonal>().SUCCESS(customerVOPersonal); |
|
|
|
|
} else { |
|
|
|
|
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id); |
|
|
|
|
//封装企业类型客户信息
|
|
|
|
|
CustomerVOCompany customerVOCompany = this.setCompany(customer, name, companyCustomerEntity); |
|
|
|
|
return new ResponseResult<CustomerVOCompany>().SUCCESS(customerVOCompany); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据id更新是否删除字段 |
|
|
|
|
* |
|
|
|
|
* @param ids 客户id集合 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<String> updateCustomerById(Long[] ids) { |
|
|
|
|
|
|
|
|
|
//TODO 远程调用审批模块判断所选客户是否在审批,返回正在审批的客户的id集合Long[] idArray
|
|
|
|
|
List<Long> idArray = new ArrayList<>();// 假设为返回的正在审批的客户id集合
|
|
|
|
|
if (idArray.size() == 0 || idArray == null) { |
|
|
|
|
customerDao.updateCustomerById(Arrays.asList(ids)); |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} else { |
|
|
|
|
return customerDao.queryCustomerNameById(idArray); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 选择某段时间内客户信息的时间参数校验 |
|
|
|
|
* |
|
|
|
|
* @param createTime 创建时间 |
|
|
|
|
* @param startTime 起始时间 |
|
|
|
|
* @param endTime 结束时间 |
|
|
|
|
* @param endTime 结束时间 |
|
|
|
|
*/ |
|
|
|
|
private void timeCheckout(Integer createTime, String startTime, String endTime, CustomerRequest customerRequest){ |
|
|
|
|
private void timeCheckout(Integer createTime, String startTime, String endTime, CustomerRequest customerRequest) { |
|
|
|
|
// 没有选择自定义时间且选择了固定的"3个月内、6个月内、9个月内...."时间
|
|
|
|
|
if (startTime == null && endTime == null && createTime != null) { |
|
|
|
|
if (createTime != 0) { |
|
|
|
|
String pastTime = pastTime(createTime); |
|
|
|
|
if (createTime == 3 || createTime == 6 || createTime == 9 || createTime == 12) { |
|
|
|
|
String pastTime = this.pastTime(createTime); |
|
|
|
|
customerRequest.setStartTime(pastTime); |
|
|
|
|
} else { |
|
|
|
|
customerRequest.setStartTime(null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 选择了自定义时间且选择了固定时间则固定时间无效
|
|
|
|
@ -107,10 +176,11 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页参数校验 |
|
|
|
|
* |
|
|
|
|
* @param page 当前页 |
|
|
|
|
* @param size 每页条数 |
|
|
|
|
*/ |
|
|
|
|
private Page<Object> pageCheckout(Integer page, Integer size){ |
|
|
|
|
private Page<Object> pageCheckout(Integer page, Integer size) { |
|
|
|
|
Integer count = this.count(new QueryWrapper<CustomerEntity>().eq("del_or_not", CrmsConstant.NOT_DELETE));//查询客户有效总条数
|
|
|
|
|
if (size == null || size < 1) { |
|
|
|
|
size = 10; |
|
|
|
@ -128,11 +198,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 拼接客户及其对应的客户经理及部门信息 |
|
|
|
|
* @param customers 客户基本信息集合 |
|
|
|
|
* |
|
|
|
|
* @param customers 客户基本信息集合 |
|
|
|
|
* @param employeeTO 员工及部门信息集合 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<CustomerTO> jointCustomerEmployee(List<CustomerEntity> customers, List<EmployeeTO> employeeTO){ |
|
|
|
|
private List<CustomerTO> jointCustomerEmployee(List<CustomerEntity> customers, List<EmployeeTO> employeeTO) { |
|
|
|
|
List<CustomerTO> customerTOS = new ArrayList<>();// 用于拼装客户信息和员工及部门信息的集合
|
|
|
|
|
CustomerTO customerTO; |
|
|
|
|
|
|
|
|
@ -163,4 +234,67 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
} |
|
|
|
|
return customerTOS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 封装个人类型的客户信息 |
|
|
|
|
* |
|
|
|
|
* @param customer 客户基本信息 |
|
|
|
|
* @param name 客户经理姓名 |
|
|
|
|
* @param personal 个人类型信息 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private CustomerVOPersonal setPersonal(CustomerEntity customer, String name, PersonalCustomerEntity personal) { |
|
|
|
|
//BeanUtils能批量封装相同字段名称和类型的属性的值
|
|
|
|
|
CustomerVOPersonal customerVOPersonal = new CustomerVOPersonal(); |
|
|
|
|
customerVOPersonal.setCode(customer.getCode()); |
|
|
|
|
customerVOPersonal.setType(customer.getType()); |
|
|
|
|
customerVOPersonal.setManager(name); |
|
|
|
|
customerVOPersonal.setName(customer.getName()); |
|
|
|
|
customerVOPersonal.setAddress(customer.getAddr()); |
|
|
|
|
customerVOPersonal.setPhone(customer.getPhone()); |
|
|
|
|
customerVOPersonal.setIdCard(personal.getIdCard()); |
|
|
|
|
customerVOPersonal.setAge(personal.getAge()); |
|
|
|
|
customerVOPersonal.setGender(personal.getGender()); |
|
|
|
|
customerVOPersonal.setMaritalStatus(personal.getMaritalStatus()); |
|
|
|
|
customerVOPersonal.setEducation(personal.getEducation()); |
|
|
|
|
customerVOPersonal.setEmployer(personal.getEmployer()); |
|
|
|
|
customerVOPersonal.setPosition(personal.getPosition()); |
|
|
|
|
customerVOPersonal.setWorkingYears(personal.getWorkingYears()); |
|
|
|
|
customerVOPersonal.setSocialSecurityNum(personal.getSocialSecurityNum()); |
|
|
|
|
customerVOPersonal.setLivingSituation(personal.getLivingSituation()); |
|
|
|
|
customerVOPersonal.setResidenceAddr(personal.getResidenceAddr()); |
|
|
|
|
customerVOPersonal.setBusinessSource(personal.getBusinessSource()); |
|
|
|
|
customerVOPersonal.setEmergencyLinkman(personal.getEmergencyLinkman()); |
|
|
|
|
customerVOPersonal.setEmergencyLinkmanRelationship(personal.getEmergencyLinkmanRelationship()); |
|
|
|
|
customerVOPersonal.setEmergencyLinkmanPhone(personal.getEmergencyLinkmanPhone()); |
|
|
|
|
return customerVOPersonal; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 封装企业类型的客户信息 |
|
|
|
|
* |
|
|
|
|
* @param customer 客户基本信息 |
|
|
|
|
* @param name 客户经理姓名 |
|
|
|
|
* @param company 企业类型信息 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private CustomerVOCompany setCompany(CustomerEntity customer, String name, CompanyCustomerEntity company) { |
|
|
|
|
CustomerVOCompany customerVOCompany = new CustomerVOCompany(); |
|
|
|
|
customerVOCompany.setCode(customer.getCode()); |
|
|
|
|
customerVOCompany.setType(customer.getType()); |
|
|
|
|
customerVOCompany.setManager(name); |
|
|
|
|
customerVOCompany.setName(customer.getName()); |
|
|
|
|
customerVOCompany.setAddress(customer.getAddr()); |
|
|
|
|
customerVOCompany.setPhone(customer.getPhone()); |
|
|
|
|
customerVOCompany.setRegisteredCapital(company.getRegisteredCapital()); |
|
|
|
|
customerVOCompany.setIndustry(company.getIndustry()); |
|
|
|
|
customerVOCompany.setYears(company.getYears()); |
|
|
|
|
customerVOCompany.setRegion(company.getRegion()); |
|
|
|
|
customerVOCompany.setShareholder(company.getShareholder()); |
|
|
|
|
customerVOCompany.setAffiliatedCompany(company.getAffiliatedCompany()); |
|
|
|
|
customerVOCompany.setEmployeeNumber(company.getEmpNum()); |
|
|
|
|
customerVOCompany.setLinkman(company.getLinkman()); |
|
|
|
|
customerVOCompany.setBusinessSource(company.getBusinessSource()); |
|
|
|
|
return customerVOCompany; |
|
|
|
|
} |
|
|
|
|
} |