|
|
@ -82,27 +82,34 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
// 获取所有的客户基本信息
|
|
|
|
// 获取所有的客户基本信息
|
|
|
|
List<CustomerEntity> customers = customerEntityIPage.getRecords(); |
|
|
|
List<CustomerEntity> customers = customerEntityIPage.getRecords(); |
|
|
|
// 获取所有的客户经理id
|
|
|
|
// 获取所有的客户经理id
|
|
|
|
Long[] managerIds = customers.stream().map(CustomerEntity::getManager).toArray(Long[]::new); |
|
|
|
Long[] managerIds = new Long[customers.size()]; |
|
|
|
|
|
|
|
for (int i = 0; i < customers.size(); i++) { |
|
|
|
if (managerIds.length != 0) { |
|
|
|
if (customers.get(i).getManager() != null) { |
|
|
|
//TODO 远程调用查询客户经理信息的接口
|
|
|
|
managerIds[i] = customers.get(i).getManager(); |
|
|
|
ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(managerIds); |
|
|
|
} else { |
|
|
|
List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData(); |
|
|
|
managerIds[i] = 0L; |
|
|
|
if (employeeTO != null){ |
|
|
|
} |
|
|
|
// 将客户信息和客户经理及部门信息拼装起来
|
|
|
|
} |
|
|
|
List<CustomerTO> customerTOS = this.jointCustomerEmployee(customers, employeeTO); |
|
|
|
|
|
|
|
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
|
|
|
|
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
|
|
|
|
IPage<CustomerTO> iPage = new Page<>(); |
|
|
|
IPage<CustomerTO> iPage = new Page<>(); |
|
|
|
BeanUtils.copyProperties(customerEntityIPage, iPage); |
|
|
|
BeanUtils.copyProperties(customerEntityIPage, iPage); |
|
|
|
iPage.setRecords(customerTOS); |
|
|
|
List<CustomerTO> listResponse = new ArrayList<>(); |
|
|
|
return new PageUtils(iPage); |
|
|
|
// 获取所有的客户经理名称和部门名称
|
|
|
|
}else { |
|
|
|
ResponseResult<List<EmployeeTO>> responseResult = hrmsFeignService.getEmployeeAndDeptById(managerIds); |
|
|
|
return new PageUtils(customerEntityIPage); |
|
|
|
List<EmployeeTO> employeeTO = responseResult.getData(); |
|
|
|
} |
|
|
|
if (employeeTO != null) { |
|
|
|
|
|
|
|
// 将客户信息和客户经理及部门信息拼装起来
|
|
|
|
|
|
|
|
listResponse = this.jointCustomerEmployee(customers, employeeTO); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return new PageUtils(customerEntityIPage); |
|
|
|
for (CustomerEntity customer : customers) { |
|
|
|
|
|
|
|
CustomerTO customerTO = new CustomerTO(); |
|
|
|
|
|
|
|
BeanUtils.copyProperties(customer, customerTO); |
|
|
|
|
|
|
|
listResponse.add(customerTO); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
iPage.setRecords(listResponse); |
|
|
|
|
|
|
|
return new PageUtils(iPage); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 根据id查询客户的信息 |
|
|
|
* 根据id查询客户的信息 |
|
|
@ -113,7 +120,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ResponseResult queryCustomerById(Long id) { |
|
|
|
public ResponseResult queryCustomerById(Long id) { |
|
|
|
|
|
|
|
|
|
|
|
if (id == null){ |
|
|
|
if (id == null) { |
|
|
|
return new ResponseResult(CommonCode.INVALID_PARAM); |
|
|
|
return new ResponseResult(CommonCode.INVALID_PARAM); |
|
|
|
} |
|
|
|
} |
|
|
|
// 员工基本信息
|
|
|
|
// 员工基本信息
|
|
|
@ -125,16 +132,16 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType())) { |
|
|
|
if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType())) { |
|
|
|
PersonalCustomerEntity personalCustomerEntity = personalCustomerDao.queryPersonalCustomerById(id); |
|
|
|
PersonalCustomerEntity personalCustomerEntity = personalCustomerDao.queryPersonalCustomerById(id); |
|
|
|
// 封装个人类型客户信息
|
|
|
|
// 封装个人类型客户信息
|
|
|
|
CustomerPersonalDTO customerPersonalDTO = this.setPersonal(customer,personalCustomerEntity); |
|
|
|
CustomerPersonalDTO customerPersonalDTO = this.setPersonal(customer, personalCustomerEntity); |
|
|
|
return new ResponseResult<CustomerPersonalDTO>().SUCCESS(customerPersonalDTO); |
|
|
|
return new ResponseResult<CustomerPersonalDTO>().SUCCESS(customerPersonalDTO); |
|
|
|
} else if (Objects.equals(customer.getType(),CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType())){ |
|
|
|
} else if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType())) { |
|
|
|
// CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id);
|
|
|
|
// CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id);
|
|
|
|
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.selectOne(new QueryWrapper<CompanyCustomerEntity>() |
|
|
|
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.selectOne(new QueryWrapper<CompanyCustomerEntity>() |
|
|
|
.eq("customer_id",id)); |
|
|
|
.eq("customer_id", id)); |
|
|
|
// 封装企业类型客户信息
|
|
|
|
// 封装企业类型客户信息
|
|
|
|
CustomerCompanyDTO customerCompanyDTO = this.setCompany(customer, companyCustomerEntity); |
|
|
|
CustomerCompanyDTO customerCompanyDTO = this.setCompany(customer, companyCustomerEntity); |
|
|
|
return new ResponseResult<CustomerCompanyDTO>().SUCCESS(customerCompanyDTO); |
|
|
|
return new ResponseResult<CustomerCompanyDTO>().SUCCESS(customerCompanyDTO); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
return new ResponseResult(CommonCode.INEXISTENCE); |
|
|
|
return new ResponseResult(CommonCode.INEXISTENCE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -144,7 +151,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ResponseResult getCustomerById(Long id) { |
|
|
|
public ResponseResult getCustomerById(Long id) { |
|
|
|
|
|
|
|
|
|
|
|
if (id == null){ |
|
|
|
if (id == null) { |
|
|
|
return new ResponseResult(CommonCode.INVALID_PARAM); |
|
|
|
return new ResponseResult(CommonCode.INVALID_PARAM); |
|
|
|
} |
|
|
|
} |
|
|
|
// 员工基本信息
|
|
|
|
// 员工基本信息
|
|
|
@ -153,9 +160,9 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
return new ResponseResult(CommonCode.INEXISTENCE); |
|
|
|
return new ResponseResult(CommonCode.INEXISTENCE); |
|
|
|
} |
|
|
|
} |
|
|
|
String name = PromptSuccess.NOT_BEING; |
|
|
|
String name = PromptSuccess.NOT_BEING; |
|
|
|
if (customer.getManager() != null){ |
|
|
|
if (customer.getManager() != null) { |
|
|
|
ResponseResult<EmployeeEntity> employee = hrmsFeignService.getEmployeeById(customer.getManager()); |
|
|
|
ResponseResult<EmployeeEntity> employee = hrmsFeignService.getEmployeeById(customer.getManager()); |
|
|
|
if (employee.getData() != null){ |
|
|
|
if (employee.getData() != null) { |
|
|
|
// 客户经理姓名
|
|
|
|
// 客户经理姓名
|
|
|
|
name = hrmsFeignService.getEmployeeById(customer.getManager()).getData().getName(); |
|
|
|
name = hrmsFeignService.getEmployeeById(customer.getManager()).getData().getName(); |
|
|
|
} |
|
|
|
} |
|
|
@ -166,12 +173,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
// 封装个人类型客户信息
|
|
|
|
// 封装个人类型客户信息
|
|
|
|
CustomerPersonalVO customerPersonalVO = this.setPersonal(customer, name, personalCustomerEntity); |
|
|
|
CustomerPersonalVO customerPersonalVO = this.setPersonal(customer, name, personalCustomerEntity); |
|
|
|
return new ResponseResult<CustomerPersonalVO>().SUCCESS(customerPersonalVO); |
|
|
|
return new ResponseResult<CustomerPersonalVO>().SUCCESS(customerPersonalVO); |
|
|
|
} else if (Objects.equals(customer.getType(),CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType())){ |
|
|
|
} else if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType())) { |
|
|
|
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id); |
|
|
|
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id); |
|
|
|
// 封装企业类型客户信息
|
|
|
|
// 封装企业类型客户信息
|
|
|
|
CustomerCompanyVO customerCompanyVO = this.setCompany(customer, name, companyCustomerEntity); |
|
|
|
CustomerCompanyVO customerCompanyVO = this.setCompany(customer, name, companyCustomerEntity); |
|
|
|
return new ResponseResult<CustomerCompanyVO>().SUCCESS(customerCompanyVO); |
|
|
|
return new ResponseResult<CustomerCompanyVO>().SUCCESS(customerCompanyVO); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
return new ResponseResult(CommonCode.INEXISTENCE); |
|
|
|
return new ResponseResult(CommonCode.INEXISTENCE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -184,7 +191,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<String> updateCustomerById(Long[] ids) { |
|
|
|
public List<String> updateCustomerById(Long[] ids) { |
|
|
|
if (ids == null || ids.length == 0){ |
|
|
|
if (ids == null || ids.length == 0) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
//TODO 远程调用审批模块判断所选客户是否在审批,返回正在审批的客户的id集合Long[] idArray
|
|
|
|
//TODO 远程调用审批模块判断所选客户是否在审批,返回正在审批的客户的id集合Long[] idArray
|
|
|
@ -209,10 +216,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
public boolean saveCustomerPersonal(CustomerPersonalTOI customerPersonalTOI) { |
|
|
|
public boolean saveCustomerPersonal(CustomerPersonalTOI customerPersonalTOI) { |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); |
|
|
|
PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); |
|
|
|
BeanUtils.copyProperties(customerPersonalTOI,customerEntity); |
|
|
|
BeanUtils.copyProperties(customerPersonalTOI, customerEntity); |
|
|
|
BeanUtils.copyProperties(customerPersonalTOI,personalCustomerEntity); |
|
|
|
BeanUtils.copyProperties(customerPersonalTOI, personalCustomerEntity); |
|
|
|
//TODO 设置客户编号
|
|
|
|
//TODO 设置客户编号
|
|
|
|
customerEntity.setCode(((int)(Math.random()*100+1))+""); |
|
|
|
customerEntity.setCode(((int) (Math.random() * 100 + 1)) + ""); |
|
|
|
customerEntity.setCreateTime(new Date()); |
|
|
|
customerEntity.setCreateTime(new Date()); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setType(CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType()); |
|
|
|
customerEntity.setType(CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType()); |
|
|
@ -232,10 +239,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
public boolean saveCustomerCompany(CustomerCompanyTOI customerCompanyTOI) { |
|
|
|
public boolean saveCustomerCompany(CustomerCompanyTOI customerCompanyTOI) { |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
|
|
|
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
|
|
|
BeanUtils.copyProperties(customerCompanyTOI,customerEntity); |
|
|
|
BeanUtils.copyProperties(customerCompanyTOI, customerEntity); |
|
|
|
BeanUtils.copyProperties(customerCompanyTOI,companyCustomerEntity); |
|
|
|
BeanUtils.copyProperties(customerCompanyTOI, companyCustomerEntity); |
|
|
|
//TODO 设置客户编号
|
|
|
|
//TODO 设置客户编号
|
|
|
|
customerEntity.setCode(((int)(Math.random()*100+1))+""); |
|
|
|
customerEntity.setCode(((int) (Math.random() * 100 + 1)) + ""); |
|
|
|
customerEntity.setCreateTime(new Date()); |
|
|
|
customerEntity.setCreateTime(new Date()); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setType(CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType()); |
|
|
|
customerEntity.setType(CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType()); |
|
|
@ -254,9 +261,9 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
public boolean updateCustomerPersonal(CustomerPersonalTOU customerPersonalTOU) { |
|
|
|
public boolean updateCustomerPersonal(CustomerPersonalTOU customerPersonalTOU) { |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); |
|
|
|
PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); |
|
|
|
BeanUtils.copyProperties(customerPersonalTOU,customerEntity); |
|
|
|
BeanUtils.copyProperties(customerPersonalTOU, customerEntity); |
|
|
|
BeanUtils.copyProperties(customerPersonalTOU,personalCustomerEntity); |
|
|
|
BeanUtils.copyProperties(customerPersonalTOU, personalCustomerEntity); |
|
|
|
if (customerEntity.getId() == null){ |
|
|
|
if (customerEntity.getId() == null) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
@ -274,8 +281,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
public boolean updateCustomerCompany(CustomerCompanyTOU customerCompanyTOU) { |
|
|
|
public boolean updateCustomerCompany(CustomerCompanyTOU customerCompanyTOU) { |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
|
|
|
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
|
|
|
BeanUtils.copyProperties(customerCompanyTOU,customerEntity); |
|
|
|
BeanUtils.copyProperties(customerCompanyTOU, customerEntity); |
|
|
|
BeanUtils.copyProperties(customerCompanyTOU,companyCustomerEntity); |
|
|
|
BeanUtils.copyProperties(customerCompanyTOU, companyCustomerEntity); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
boolean customer = customerDao.updateCustomer(customerEntity); |
|
|
|
boolean customer = customerDao.updateCustomer(customerEntity); |
|
|
|
companyCustomerEntity.setCustomerId(customerEntity.getId()); |
|
|
|
companyCustomerEntity.setCustomerId(customerEntity.getId()); |
|
|
@ -285,30 +292,31 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 导出数据到excel |
|
|
|
* 导出数据到excel |
|
|
|
|
|
|
|
* |
|
|
|
* @param response 响应 |
|
|
|
* @param response 响应 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Transactional |
|
|
|
@Transactional |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void excelExportCustomer(HttpServletResponse response){ |
|
|
|
public void excelExportCustomer(HttpServletResponse response) { |
|
|
|
//TODO 查询所有的客户详细信息,并按照类型封装,后续有待优化,消耗时间太长
|
|
|
|
//TODO 查询所有的客户详细信息,并按照类型封装,后续有待优化,消耗时间太长
|
|
|
|
try { |
|
|
|
try { |
|
|
|
List<CustomerCompanyVO> companyList = new ArrayList<>(); |
|
|
|
List<CustomerCompanyVO> companyList = new ArrayList<>(); |
|
|
|
List<CustomerPersonalVO> personalList = new ArrayList<>(); |
|
|
|
List<CustomerPersonalVO> personalList = new ArrayList<>(); |
|
|
|
List<Long> longList = customerDao.listCustomerId(); |
|
|
|
List<Long> longList = customerDao.listCustomerId(); |
|
|
|
if (longList != null){ |
|
|
|
if (longList != null) { |
|
|
|
for (Long id : longList) { |
|
|
|
for (Long id : longList) { |
|
|
|
ResponseResult responseResult = this.getCustomerById(id); |
|
|
|
ResponseResult responseResult = this.getCustomerById(id); |
|
|
|
if ((responseResult.getData()).getClass() == CustomerCompanyVO.class){ |
|
|
|
if ((responseResult.getData()).getClass() == CustomerCompanyVO.class) { |
|
|
|
companyList.add((CustomerCompanyVO) responseResult.getData()); |
|
|
|
companyList.add((CustomerCompanyVO) responseResult.getData()); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
personalList.add((CustomerPersonalVO) responseResult.getData()); |
|
|
|
personalList.add((CustomerPersonalVO) responseResult.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelUtil.writeExcelWithSheets(response,personalList,"客户资源信息一览表","个人类型",new CustomerPersonalVO()) |
|
|
|
ExcelUtil.writeExcelWithSheets(response, personalList, "客户资源信息一览表", "个人类型", new CustomerPersonalVO()) |
|
|
|
.write(companyList,"企业类型",new CustomerCompanyVO()) |
|
|
|
.write(companyList, "企业类型", new CustomerCompanyVO()) |
|
|
|
.finish(); |
|
|
|
.finish(); |
|
|
|
}catch (Exception e){ |
|
|
|
} catch (Exception e) { |
|
|
|
ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORT_EXSIT); |
|
|
|
ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORT_EXSIT); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -321,27 +329,28 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
try { |
|
|
|
try { |
|
|
|
List<CompanyTemplate> companyTemplates = new ArrayList<>(); |
|
|
|
List<CompanyTemplate> companyTemplates = new ArrayList<>(); |
|
|
|
List<PersonalTemplate> personalTemplates = new ArrayList<>(); |
|
|
|
List<PersonalTemplate> personalTemplates = new ArrayList<>(); |
|
|
|
ExcelUtil.writeExcelWithSheets(response,personalTemplates,"客户资源信息表模板","个人类型",new PersonalTemplate()) |
|
|
|
ExcelUtil.writeExcelWithSheets(response, personalTemplates, "客户资源信息表模板", "个人类型", new PersonalTemplate()) |
|
|
|
.write(companyTemplates,"企业类型",new CompanyTemplate()) |
|
|
|
.write(companyTemplates, "企业类型", new CompanyTemplate()) |
|
|
|
.finish(); |
|
|
|
.finish(); |
|
|
|
}catch (Exception e){ |
|
|
|
} catch (Exception e) { |
|
|
|
ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORTTEMPLATE_EXSIT); |
|
|
|
ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORTTEMPLATE_EXSIT); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 导入excel数据 |
|
|
|
* 导入excel数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param excel |
|
|
|
* @param excel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Transactional |
|
|
|
@Transactional |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ResponseResult excelImportCustomer(MultipartFile excel) { |
|
|
|
public ResponseResult excelImportCustomer(MultipartFile excel) { |
|
|
|
//TODO 导入excel数据到数据库,思路耗时太长,有待优化
|
|
|
|
//TODO 导入excel数据到数据库,思路耗时太长,有待优化
|
|
|
|
if (excel.isEmpty()){ |
|
|
|
if (excel.isEmpty()) { |
|
|
|
ExceptionCast.cast(CrmsCode.NOT_NULL); |
|
|
|
ExceptionCast.cast(CrmsCode.NOT_NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
List<Object> personalList = ExcelUtil.readExcel(excel,new PersonalTemplate(), 1); |
|
|
|
List<Object> personalList = ExcelUtil.readExcel(excel, new PersonalTemplate(), 1); |
|
|
|
List<Object> companyList = ExcelUtil.readExcel(excel, new CompanyTemplate(), 2); |
|
|
|
List<Object> companyList = ExcelUtil.readExcel(excel, new CompanyTemplate(), 2); |
|
|
|
List<EmployeeVO> nameList = hrmsFeignService.listEmployeeName().getData(); |
|
|
|
List<EmployeeVO> nameList = hrmsFeignService.listEmployeeName().getData(); |
|
|
|
CustomerPersonalTOI customerPersonalTOI; |
|
|
|
CustomerPersonalTOI customerPersonalTOI; |
|
|
@ -350,44 +359,44 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
for (Object personal : personalList) { |
|
|
|
for (Object personal : personalList) { |
|
|
|
customerPersonalTOI = new CustomerPersonalTOI(); |
|
|
|
customerPersonalTOI = new CustomerPersonalTOI(); |
|
|
|
customerPersonalTOI.setType(0); |
|
|
|
customerPersonalTOI.setType(0); |
|
|
|
BeanUtils.copyProperties(personal,customerPersonalTOI); |
|
|
|
BeanUtils.copyProperties(personal, customerPersonalTOI); |
|
|
|
manager = new ManagerName(); |
|
|
|
manager = new ManagerName(); |
|
|
|
BeanUtils.copyProperties(personal,manager); |
|
|
|
BeanUtils.copyProperties(personal, manager); |
|
|
|
// 根据客户经理名称找到对应的员工id
|
|
|
|
// 根据客户经理名称找到对应的员工id
|
|
|
|
if (nameList != null && manager.getManager() != null){ |
|
|
|
if (nameList != null && manager.getManager() != null) { |
|
|
|
for (EmployeeVO employeeVO : nameList){ |
|
|
|
for (EmployeeVO employeeVO : nameList) { |
|
|
|
if (Objects.equals(manager.getManager(),employeeVO.getName())){ |
|
|
|
if (Objects.equals(manager.getManager(), employeeVO.getName())) { |
|
|
|
customerPersonalTOI.setManager(employeeVO.getId()); |
|
|
|
customerPersonalTOI.setManager(employeeVO.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (customerPersonalTOI.getManager() == null){ |
|
|
|
if (customerPersonalTOI.getManager() == null) { |
|
|
|
return new ResponseResult<String>().SUCCESS("导入数据失败,员工"+manager.getManager()+"不存在"); |
|
|
|
return new ResponseResult<String>().SUCCESS("导入数据失败,员工" + manager.getManager() + "不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.saveCustomerPersonal(customerPersonalTOI); |
|
|
|
this.saveCustomerPersonal(customerPersonalTOI); |
|
|
|
} |
|
|
|
} |
|
|
|
// 企业类型
|
|
|
|
// 企业类型
|
|
|
|
for (Object company : companyList){ |
|
|
|
for (Object company : companyList) { |
|
|
|
CustomerCompanyTOI customerCompanyTOI = new CustomerCompanyTOI(); |
|
|
|
CustomerCompanyTOI customerCompanyTOI = new CustomerCompanyTOI(); |
|
|
|
manager = new ManagerName(); |
|
|
|
manager = new ManagerName(); |
|
|
|
customerCompanyTOI.setType(1); |
|
|
|
customerCompanyTOI.setType(1); |
|
|
|
BeanUtils.copyProperties(company,customerCompanyTOI); |
|
|
|
BeanUtils.copyProperties(company, customerCompanyTOI); |
|
|
|
BeanUtils.copyProperties(company,manager); |
|
|
|
BeanUtils.copyProperties(company, manager); |
|
|
|
// 根据客户经理名称找到对应的员工id
|
|
|
|
// 根据客户经理名称找到对应的员工id
|
|
|
|
if (nameList != null && manager.getManager() != null){ |
|
|
|
if (nameList != null && manager.getManager() != null) { |
|
|
|
for (EmployeeVO employeeVO : nameList){ |
|
|
|
for (EmployeeVO employeeVO : nameList) { |
|
|
|
if (Objects.equals(manager.getManager(),employeeVO.getName())){ |
|
|
|
if (Objects.equals(manager.getManager(), employeeVO.getName())) { |
|
|
|
customerCompanyTOI.setManager(employeeVO.getId()); |
|
|
|
customerCompanyTOI.setManager(employeeVO.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (customerCompanyTOI.getManager() == null){ |
|
|
|
if (customerCompanyTOI.getManager() == null) { |
|
|
|
return new ResponseResult<String>().SUCCESS("导入数据失败,员工"+manager.getManager()+"不存在"); |
|
|
|
return new ResponseResult<String>().SUCCESS("导入数据失败,员工" + manager.getManager() + "不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.saveCustomerCompany(customerCompanyTOI); |
|
|
|
this.saveCustomerCompany(customerCompanyTOI); |
|
|
|
} |
|
|
|
} |
|
|
|
return ResponseResult.SUCCESS(); |
|
|
|
return ResponseResult.SUCCESS(); |
|
|
|
}catch (Exception e){ |
|
|
|
} catch (Exception e) { |
|
|
|
return new ResponseResult<String>().SUCCESS("导入数据失败,请检查文件和数据格式或稍后再试"); |
|
|
|
return new ResponseResult<String>().SUCCESS("导入数据失败,请检查文件和数据格式或稍后再试"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -410,7 +419,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 选择了自定义时间且选择了固定时间则固定时间无效
|
|
|
|
// 选择了自定义时间且选择了固定时间则固定时间无效
|
|
|
|
if (createTime != null && ((startTime != null && startTime.length() !=0) || (endTime != null && endTime.length() != 0))) { |
|
|
|
if (createTime != null && ((startTime != null && startTime.length() != 0) || (endTime != null && endTime.length() != 0))) { |
|
|
|
customerRequest.setCreateTime(null); |
|
|
|
customerRequest.setCreateTime(null); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -467,24 +476,19 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
for (CustomerEntity customer : customers) { |
|
|
|
for (CustomerEntity customer : customers) { |
|
|
|
// 每一个客户对应一个不同的对象
|
|
|
|
// 每一个客户对应一个不同的对象
|
|
|
|
customerTO = new CustomerTO(); |
|
|
|
customerTO = new CustomerTO(); |
|
|
|
for (EmployeeTO anEmployeeTO : employeeTO) { |
|
|
|
for (EmployeeTO employee : employeeTO) { |
|
|
|
if (Objects.equals(customer.getManager(), anEmployeeTO.getId())) { |
|
|
|
if (Objects.equals(customer.getManager(), employee.getId())) { |
|
|
|
BeanUtils.copyProperties(customer,customerTO); |
|
|
|
customerTO.setManager(employee.getEmpName()); |
|
|
|
customerTO.setManager(anEmployeeTO.getEmpName()); |
|
|
|
customerTO.setDepartments(employee.getDeptNames()); |
|
|
|
customerTO.setDepartments(anEmployeeTO.getDeptNames()); |
|
|
|
|
|
|
|
customerTOS.add(customerTO); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!Objects.equals(customerTO.getId(), customer.getId())) { |
|
|
|
BeanUtils.copyProperties(customer, customerTO); |
|
|
|
BeanUtils.copyProperties(customer,customerTO); |
|
|
|
|
|
|
|
customerTOS.add(customerTO); |
|
|
|
customerTOS.add(customerTO); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return customerTOS; |
|
|
|
return customerTOS; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 封装个人类型的客户信息 |
|
|
|
* 封装个人类型的客户信息 |
|
|
|
* |
|
|
|
* |
|
|
@ -495,8 +499,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
private CustomerPersonalDTO setPersonal(CustomerEntity customer, PersonalCustomerEntity personal) { |
|
|
|
private CustomerPersonalDTO setPersonal(CustomerEntity customer, PersonalCustomerEntity personal) { |
|
|
|
//BeanUtils能批量封装相同字段名称和类型的属性的值
|
|
|
|
//BeanUtils能批量封装相同字段名称和类型的属性的值
|
|
|
|
CustomerPersonalDTO personalDTO = new CustomerPersonalDTO(); |
|
|
|
CustomerPersonalDTO personalDTO = new CustomerPersonalDTO(); |
|
|
|
BeanUtils.copyProperties(customer,personalDTO); |
|
|
|
BeanUtils.copyProperties(customer, personalDTO); |
|
|
|
BeanUtils.copyProperties(personal,personalDTO); |
|
|
|
BeanUtils.copyProperties(personal, personalDTO); |
|
|
|
return personalDTO; |
|
|
|
return personalDTO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -509,8 +513,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private CustomerCompanyDTO setCompany(CustomerEntity customer, CompanyCustomerEntity company) { |
|
|
|
private CustomerCompanyDTO setCompany(CustomerEntity customer, CompanyCustomerEntity company) { |
|
|
|
CustomerCompanyDTO companyDTO = new CustomerCompanyDTO(); |
|
|
|
CustomerCompanyDTO companyDTO = new CustomerCompanyDTO(); |
|
|
|
BeanUtils.copyProperties(customer,companyDTO); |
|
|
|
BeanUtils.copyProperties(customer, companyDTO); |
|
|
|
BeanUtils.copyProperties(company,companyDTO); |
|
|
|
BeanUtils.copyProperties(company, companyDTO); |
|
|
|
return companyDTO; |
|
|
|
return companyDTO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -519,8 +523,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private CustomerCompanyVO setCompany(CustomerEntity customer, String name, CompanyCustomerEntity company) { |
|
|
|
private CustomerCompanyVO setCompany(CustomerEntity customer, String name, CompanyCustomerEntity company) { |
|
|
|
CustomerCompanyVO customerCompanyVO = new CustomerCompanyVO(); |
|
|
|
CustomerCompanyVO customerCompanyVO = new CustomerCompanyVO(); |
|
|
|
BeanUtils.copyProperties(customer,customerCompanyVO); |
|
|
|
BeanUtils.copyProperties(customer, customerCompanyVO); |
|
|
|
BeanUtils.copyProperties(company,customerCompanyVO); |
|
|
|
BeanUtils.copyProperties(company, customerCompanyVO); |
|
|
|
customerCompanyVO.setManager(name); |
|
|
|
customerCompanyVO.setManager(name); |
|
|
|
return customerCompanyVO; |
|
|
|
return customerCompanyVO; |
|
|
|
} |
|
|
|
} |
|
|
@ -531,8 +535,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
private CustomerPersonalVO setPersonal(CustomerEntity customer, String name, PersonalCustomerEntity personal) { |
|
|
|
private CustomerPersonalVO setPersonal(CustomerEntity customer, String name, PersonalCustomerEntity personal) { |
|
|
|
//BeanUtils能批量封装相同字段名称和类型的属性的值
|
|
|
|
//BeanUtils能批量封装相同字段名称和类型的属性的值
|
|
|
|
CustomerPersonalVO customerPersonalVO = new CustomerPersonalVO(); |
|
|
|
CustomerPersonalVO customerPersonalVO = new CustomerPersonalVO(); |
|
|
|
BeanUtils.copyProperties(customer,customerPersonalVO); |
|
|
|
BeanUtils.copyProperties(customer, customerPersonalVO); |
|
|
|
BeanUtils.copyProperties(personal,customerPersonalVO); |
|
|
|
BeanUtils.copyProperties(personal, customerPersonalVO); |
|
|
|
customerPersonalVO.setManager(name); |
|
|
|
customerPersonalVO.setManager(name); |
|
|
|
return customerPersonalVO; |
|
|
|
return customerPersonalVO; |
|
|
|
} |
|
|
|
} |
|
|
@ -544,7 +548,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<CustomerEntity> queryCompanyCodeAndName(int type) { |
|
|
|
public List<CustomerEntity> queryCompanyCodeAndName(int type) { |
|
|
|
List<CustomerEntity>list = customerDao.queryCompanyCodeAndName(type); |
|
|
|
List<CustomerEntity> list = customerDao.queryCompanyCodeAndName(type); |
|
|
|
return list; |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -555,10 +559,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
public boolean insertCompany(CompanyCustomerRequest companyCustomerReq) { |
|
|
|
public boolean insertCompany(CompanyCustomerRequest companyCustomerReq) { |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
|
|
|
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
|
|
|
BeanUtils.copyProperties(companyCustomerReq,customerEntity); |
|
|
|
BeanUtils.copyProperties(companyCustomerReq, customerEntity); |
|
|
|
BeanUtils.copyProperties(companyCustomerReq,companyCustomerEntity); |
|
|
|
BeanUtils.copyProperties(companyCustomerReq, companyCustomerEntity); |
|
|
|
//TODO 设置客户编号
|
|
|
|
//TODO 设置客户编号
|
|
|
|
customerEntity.setCode(((int)(Math.random()*100+1))+""); |
|
|
|
customerEntity.setCode(((int) (Math.random() * 100 + 1)) + ""); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setCreateTime(new Date()); |
|
|
|
customerEntity.setCreateTime(new Date()); |
|
|
|
customerEntity.setManager(companyCustomerReq.getManager()); |
|
|
|
customerEntity.setManager(companyCustomerReq.getManager()); |
|
|
@ -570,7 +574,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
List<CrmsCustomerRelated> relatedList = new ArrayList<>(); |
|
|
|
List<CrmsCustomerRelated> relatedList = new ArrayList<>(); |
|
|
|
List<Integer> intList = companyCustomerReq.getRelatedId(); |
|
|
|
List<Integer> intList = companyCustomerReq.getRelatedId(); |
|
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<intList.size();i++){ |
|
|
|
for (int i = 0; i < intList.size(); i++) { |
|
|
|
CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); |
|
|
|
CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); |
|
|
|
Integer integer = intList.get(i); |
|
|
|
Integer integer = intList.get(i); |
|
|
|
crmsCustomerRelated.setCustomerId(companyCustomerEntity.getId().intValue());//企业id
|
|
|
|
crmsCustomerRelated.setCustomerId(companyCustomerEntity.getId().intValue());//企业id
|
|
|
@ -579,7 +583,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
} |
|
|
|
} |
|
|
|
crmsCustomerRelatedService.insertCustomerRelated(relatedList); |
|
|
|
crmsCustomerRelatedService.insertCustomerRelated(relatedList); |
|
|
|
|
|
|
|
|
|
|
|
if(customer==true && company>0){ |
|
|
|
if (customer == true && company > 0) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -592,34 +596,34 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity |
|
|
|
public boolean updateCompanyNew(CompanyCustomerRequest companyCustomerReq) { |
|
|
|
public boolean updateCompanyNew(CompanyCustomerRequest companyCustomerReq) { |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CustomerEntity customerEntity = new CustomerEntity(); |
|
|
|
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
|
|
|
CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); |
|
|
|
BeanUtils.copyProperties(companyCustomerReq,customerEntity); |
|
|
|
BeanUtils.copyProperties(companyCustomerReq, customerEntity); |
|
|
|
BeanUtils.copyProperties(companyCustomerReq,companyCustomerEntity); |
|
|
|
BeanUtils.copyProperties(companyCustomerReq, companyCustomerEntity); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setMotifyTime(new Date()); |
|
|
|
customerEntity.setManager(companyCustomerReq.getManager()); |
|
|
|
customerEntity.setManager(companyCustomerReq.getManager()); |
|
|
|
boolean customer = customerDao.updateCustomer(customerEntity); |
|
|
|
boolean customer = customerDao.updateCustomer(customerEntity); |
|
|
|
companyCustomerEntity.setCustomerId(customerEntity.getId()); |
|
|
|
companyCustomerEntity.setCustomerId(customerEntity.getId()); |
|
|
|
int company = companyCustomerDao.update(companyCustomerEntity, new QueryWrapper<CompanyCustomerEntity>() |
|
|
|
int company = companyCustomerDao.update(companyCustomerEntity, new QueryWrapper<CompanyCustomerEntity>() |
|
|
|
.eq("customer_id",companyCustomerEntity.getCustomerId())); |
|
|
|
.eq("customer_id", companyCustomerEntity.getCustomerId())); |
|
|
|
|
|
|
|
|
|
|
|
//根据企业id删除关联关系
|
|
|
|
//根据企业id删除关联关系
|
|
|
|
crmsCustomerRelatedMapper.delete(new QueryWrapper<CrmsCustomerRelated>().eq("customer_id",companyCustomerEntity.getId())); |
|
|
|
crmsCustomerRelatedMapper.delete(new QueryWrapper<CrmsCustomerRelated>().eq("customer_id", companyCustomerEntity.getId())); |
|
|
|
|
|
|
|
|
|
|
|
//绑定关联关系
|
|
|
|
//绑定关联关系
|
|
|
|
List<CrmsCustomerRelated> relatedList = new ArrayList<>(); |
|
|
|
List<CrmsCustomerRelated> relatedList = new ArrayList<>(); |
|
|
|
List<Integer> intList = companyCustomerReq.getRelatedId(); |
|
|
|
List<Integer> intList = companyCustomerReq.getRelatedId(); |
|
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<intList.size();i++){ |
|
|
|
for (int i = 0; i < intList.size(); i++) { |
|
|
|
CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); |
|
|
|
CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); |
|
|
|
Integer integer = intList.get(i); |
|
|
|
Integer integer = intList.get(i); |
|
|
|
crmsCustomerRelated.setCustomerId(companyCustomerEntity.getId().intValue());//企业id
|
|
|
|
crmsCustomerRelated.setCustomerId(companyCustomerEntity.getId().intValue());//企业id
|
|
|
|
crmsCustomerRelated.setRelatedId(integer);//关联人/企业id
|
|
|
|
crmsCustomerRelated.setRelatedId(integer);//关联人/企业id
|
|
|
|
relatedList.add(crmsCustomerRelated); |
|
|
|
relatedList.add(crmsCustomerRelated); |
|
|
|
} |
|
|
|
} |
|
|
|
if(relatedList.size()>0){ |
|
|
|
if (relatedList.size() > 0) { |
|
|
|
crmsCustomerRelatedService.insertCustomerRelated(relatedList); |
|
|
|
crmsCustomerRelatedService.insertCustomerRelated(relatedList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(customer==true && company>0){ |
|
|
|
if (customer == true && company > 0) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|