修复前后台客户列表客户经理名称和部门显示问题

master
river 4 years ago
parent c471f516c1
commit a03f2e92ff
  1. 208
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java
  2. 60
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerWorkbenchServiceImpl.java
  3. 15
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgWorkConferenceConsiderServiceImpl.java
  4. 109
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/EmployeeServiceImpl.java

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

@ -62,40 +62,44 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
IPage<CustomerEntityResponse> customerEntityIPage = this.getBaseMapper().queryList(new Page(page, size), cwr);
List<CustomerEntityResponse> customers = customerEntityIPage.getRecords();
// 获取所有的客户经理id
Long[] managerIds = customers.stream().map(CustomerEntityResponse::getManager).toArray(Long[]::new);
Long[] managerIds = new Long[customers.size()];
for (int i = 0; i < customers.size(); i++) {
if (customers.get(i).getManager() != null) {
managerIds[i] = customers.get(i).getManager();
} else {
managerIds[i] = 0L;
}
}
// 获取所有的客户id
Long[] customerIds = customers.stream().map(CustomerEntityResponse::getId).toArray(Long[]::new);
// 返回列表实体类集合
List<CustomerWorkbenchListVO> customerWorkbenchListVOS = new ArrayList<>();
for (int i = 0; i < customers.size(); i++) {
CustomerWorkbenchListVO customerWorkbenchListVO = new CustomerWorkbenchListVO();
BeanUtils.copyProperties(customers.get(i), customerWorkbenchListVO);
customerWorkbenchListVOS.add(customerWorkbenchListVO);
}
System.out.println(customerWorkbenchListVOS);
if (managerIds.length != 0) {
// 远程调用查询客户对应的客户经理信息
ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(managerIds);
List<EmployeeTO> employeeTOs = (List<EmployeeTO>) responseResult.getData();
if (employeeTOs != null) {
customerWorkbenchListVOS = this.jointCustomerEmployee(customers, employeeTOs);
List<CustomerWorkbenchListVO> listResponse = new ArrayList<>();
// 远程调用查询客户对应的客户经理信息
ResponseResult<List<EmployeeTO>> responseResult = hrmsFeignService.getEmployeeAndDeptById(managerIds);
List<EmployeeTO> employeeTOs = responseResult.getData();
if (employeeTOs != null) {
listResponse = this.jointCustomerEmployee(customers, employeeTOs);
} else {
for (CustomerEntityResponse customer : customers) {
CustomerWorkbenchListVO workbenchListVO = new CustomerWorkbenchListVO();
BeanUtils.copyProperties(customer, workbenchListVO);
listResponse.add(workbenchListVO);
}
}
if (customerIds.length != 0) {
// TODO:远程调用担保服务查询每个客户的审批状态
for (CustomerWorkbenchListVO customerWorkbenchListVO : customerWorkbenchListVOS) {
for (CustomerWorkbenchListVO customerWorkbenchListVO : listResponse) {
customerWorkbenchListVO.setStatus(2);
}
if (cwr.getStatus() != null && (cwr.getStatus() == 0 || cwr.getStatus() == 1 || cwr.getStatus() == 2)) {
// 筛选状态
customerWorkbenchListVOS.removeIf(customerWorkbenchListVO -> !Objects.equals(customerWorkbenchListVO.getStatus(), cwr.getStatus()));
listResponse.removeIf(customerWorkbenchListVO -> !Objects.equals(customerWorkbenchListVO.getStatus(), cwr.getStatus()));
}
}
System.out.println(customerWorkbenchListVOS);
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
IPage<CustomerWorkbenchListVO> iPage = new Page<>();
BeanUtils.copyProperties(customerEntityIPage, iPage);
iPage.setRecords(customerWorkbenchListVOS);
iPage.setRecords(listResponse);
return new PageUtils(iPage);
}
@ -252,26 +256,22 @@ public class CustomerWorkbenchServiceImpl extends ServiceImpl<CustomerWorkbenchD
* 拼接客户及其对应的客户经理及部门信息
*/
private List<CustomerWorkbenchListVO> jointCustomerEmployee(List<CustomerEntityResponse> customers, List<EmployeeTO> employeeTO) {
List<CustomerWorkbenchListVO> customerWorkbenchListVOS = new ArrayList<>();// 用于拼装客户信息和员工及部门信息的集合
List<CustomerWorkbenchListVO> listResponse = new ArrayList<>();// 用于拼装客户信息和员工及部门信息的集合
CustomerWorkbenchListVO customerWorkbenchListVO;
// 将客户信息和客户经理及部门信息拼装起来
for (CustomerEntityResponse customer : customers) {
// 每一个客户对应一个不同的对象
customerWorkbenchListVO = new CustomerWorkbenchListVO();
for (EmployeeTO anEmployeeTO : employeeTO) {
if (Objects.equals(customer.getManager(), anEmployeeTO.getId())) {
BeanUtils.copyProperties(customer, customerWorkbenchListVO);
customerWorkbenchListVO.setManager(anEmployeeTO.getEmpName());
customerWorkbenchListVO.setDepartments(anEmployeeTO.getDeptNames());
customerWorkbenchListVOS.add(customerWorkbenchListVO);
for (int i = 0; i < employeeTO.size(); i++) {
if (customer.getManager() != null && customer.getManager().equals(employeeTO.get(i).getId())) {
customerWorkbenchListVO.setManager(employeeTO.get(i).getEmpName());
customerWorkbenchListVO.setDepartments(employeeTO.get(i).getDeptNames());
}
}
if (!Objects.equals(customerWorkbenchListVO.getId(), customer.getId())) {
BeanUtils.copyProperties(customer, customerWorkbenchListVO);
customerWorkbenchListVOS.add(customerWorkbenchListVO);
}
BeanUtils.copyProperties(customer, customerWorkbenchListVO);
listResponse.add(customerWorkbenchListVO);
}
return customerWorkbenchListVOS;
return listResponse;
}
/**

@ -107,20 +107,21 @@ public class DgWorkConferenceConsiderServiceImpl extends ServiceImpl<DgWorkConfe
// 根据userId获取对应的员工姓名
ResponseResult<List<EmployeeVO>> responseResult = hrmsFeignService.listEmpNameByUserId(userIds);
System.out.println(responseResult.getData());
List<DgWorkConferenceResponse> workConferenceResponses = new ArrayList<>();
List<DgWorkConferenceResponse> listResponse = new ArrayList<>();
if (responseResult.getData() != null) {
// 将对应的userId转换为name
workConferenceResponses = this.transitionUserName(dgWorkConferencePOS, responseResult.getData());
listResponse = this.transitionUserName(dgWorkConferencePOS, responseResult.getData());
} else {
for (int i = 0; i < dgWorkConferencePOS.size(); i++) {
DgWorkConferenceResponse workConferenceResponse = new DgWorkConferenceResponse();
BeanUtils.copyProperties(dgWorkConferencePOS.get(i), workConferenceResponse);
workConferenceResponses.add(workConferenceResponse);
for (DgWorkConferencePO workConferencePO : dgWorkConferencePOS) {
DgWorkConferenceResponse workConference = new DgWorkConferenceResponse();
BeanUtils.copyProperties(workConferencePO, workConference);
listResponse.add(workConference);
}
}
// 分页属性复制并返回
IPage<DgWorkConferenceResponse> iPage = new Page<>();
BeanUtils.copyProperties(list, iPage);
iPage.setRecords(workConferenceResponses);
iPage.setRecords(listResponse);
return new PageUtils(iPage);
}

@ -56,7 +56,7 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
@Override
public PageUtils queryPage(Integer page, Integer size, EmployeeRequest employeeRequest) {
//分页参数参数校验,后续优化为自定义选择每页条数和跳转到第几页
if (page == null || size == null){
if (page == null || size == null) {
page = 1;
size = 10;
}
@ -91,7 +91,7 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
@Transactional
@Override
public Boolean start(Long id) {
if (id == null){
if (id == null) {
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
Long userId = this.getBaseMapper().getUserId(id);
@ -108,25 +108,25 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
@Override
public Boolean stop(EmployeeDisableRequest employeeDisableRequest) {
UserEntity user = new UserEntity();
BeanUtils.copyProperties(employeeDisableRequest,user);
BeanUtils.copyProperties(employeeDisableRequest, user);
if (employeeDisableRequest.getEmployeeId() == null || user.getDisableStartTime() == null
|| user.getDisableEndTime() == null || user.getDisableCause() == null){
|| user.getDisableEndTime() == null || user.getDisableCause() == null) {
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
if (user.getDisableStartTime().getTime() >= user.getDisableEndTime().getTime()){
if (user.getDisableStartTime().getTime() >= user.getDisableEndTime().getTime()) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_DISABLE_TIME_ERROR);
}
Long userId = this.getBaseMapper().getUserId(employeeDisableRequest.getEmployeeId());
if (user.getDisableStartTime().getTime() <= (new Date()).getTime()
&& (new Date()).getTime() <= user.getDisableEndTime().getTime()){
&& (new Date()).getTime() <= user.getDisableEndTime().getTime()) {
user.setId(userId);
user.setStatus(PromptSuccess.STOP_STATUS);
return this.getBaseMapper().startOrStop(user);
}else if (user.getDisableStartTime().getTime() > (new Date()).getTime()){
} else if (user.getDisableStartTime().getTime() > (new Date()).getTime()) {
user.setId(userId);
user.setStatus(PromptSuccess.UPCOMING_STOP_STATUS);
return this.getBaseMapper().startOrStop(user);
}else {
} else {
return false;
}
}
@ -136,7 +136,7 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
*/
@Override
public UserEntity forbidInfo(Long id) {
if (id == null){
if (id == null) {
ExceptionCast.cast(CommonCode.INVALID_PARAM);
}
Long userId = this.getBaseMapper().getUserId(id);
@ -150,16 +150,16 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
@Override
public void disableDetection() {
List<UserEntity> users = this.getBaseMapper().listDisableTime();
if (users.size() != 0){
if (users.size() != 0) {
for (UserEntity user : users) {
if (user.getDisableStartTime().getTime() <= (new Date()).getTime()
&& (new Date()).getTime() <= user.getDisableEndTime().getTime()){
&& (new Date()).getTime() <= user.getDisableEndTime().getTime()) {
user.setStatus(PromptSuccess.STOP_STATUS);
this.getBaseMapper().startOrStop(user);
}else if ((new Date()).getTime() < user.getDisableStartTime().getTime()){
} else if ((new Date()).getTime() < user.getDisableStartTime().getTime()) {
user.setStatus(PromptSuccess.UPCOMING_STOP_STATUS);
this.getBaseMapper().startOrStop(user);
}else if ((new Date()).getTime() > user.getDisableEndTime().getTime()){
} else if ((new Date()).getTime() > user.getDisableEndTime().getTime()) {
user.setStatus(PromptSuccess.START_STATUS);
user.setDisableStartTime(null);
user.setDisableEndTime(null);
@ -206,9 +206,9 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
List<RolePermissionResponse> list = permissionDao.listPermissionByRoleIds(roleIds);
if (list.size() != 0) {
// 去重
Map<Long,RolePermissionResponse> map = new HashMap<>();
Map<Long, RolePermissionResponse> map = new HashMap<>();
for (RolePermissionResponse rolePermissionResponse : list) {
map.put(rolePermissionResponse.getPermissionId(),rolePermissionResponse);
map.put(rolePermissionResponse.getPermissionId(), rolePermissionResponse);
}
list.clear();
for (Long key : map.keySet()) {
@ -233,15 +233,15 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
}
List<RolePermissionResponse> list = permissionDao.listPermissionByRoleIds(ids);
if (list.size() != 0) {
// 去重
Map<Long,RolePermissionResponse> map = new HashMap<>();
for (RolePermissionResponse rolePermissionResponse : list) {
map.put(rolePermissionResponse.getPermissionId(),rolePermissionResponse);
}
list.clear();
for (Long key : map.keySet()) {
list.add(map.get(key));
}
// 去重
Map<Long, RolePermissionResponse> map = new HashMap<>();
for (RolePermissionResponse rolePermissionResponse : list) {
map.put(rolePermissionResponse.getPermissionId(), rolePermissionResponse);
}
list.clear();
for (Long key : map.keySet()) {
list.add(map.get(key));
}
return this.getRolePermissionTreeList(list, 0L);
} else {
return null;
@ -267,43 +267,43 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
ExceptionCast.cast(HrmsCode.ROLE_NOT_NULL);
}
Long userId = this.getBaseMapper().getUserId(employeeInfoVO.getId());
if (userId == null){
if (userId == null) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_USER_IS_NULL);
}
if (employeeInfoVO.getName().length() == 0
|| employeeInfoVO.getAccount().length() == 0
|| employeeInfoVO.getCompanyMail().length() == 0
|| employeeInfoVO.getJobNumber().length() == 0
|| employeeInfoVO.getPhone().length() == 0){
|| employeeInfoVO.getPhone().length() == 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_INFO_NOT_NULL);
}
// 工号判重,修改判重先要判断是否与原来相同
EmployeeRepetition employeeRepetition = this.getBaseMapper().getEmployeeRepetitionByEmpId(employeeInfoVO.getId());
if (employeeRepetition != null && !Objects.equals(employeeInfoVO.getJobNumber(),employeeRepetition.getJobNumber())){
if (employeeRepetition != null && !Objects.equals(employeeInfoVO.getJobNumber(), employeeRepetition.getJobNumber())) {
Integer numberCount = this.getBaseMapper().employeeJobNumberCount(employeeInfoVO.getJobNumber());
if (numberCount > 0){
if (numberCount > 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_JOB_NUMBER_EXIST);
}
}
// 账号判重
if (employeeRepetition != null && !Objects.equals(employeeInfoVO.getAccount(),employeeRepetition.getAccount())){
if (employeeRepetition != null && !Objects.equals(employeeInfoVO.getAccount(), employeeRepetition.getAccount())) {
Integer accountCount = this.getBaseMapper().userAccountCount(employeeInfoVO.getAccount());
if (accountCount > 0){
if (accountCount > 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_USER_ACCOUNT_EXIST);
}
}
// 姓名判重,如果重复,自动在后面加字母"A、B、C、D、E"
if (employeeRepetition != null && !Objects.equals(employeeInfoVO.getName(),employeeRepetition.getName())){
if (employeeRepetition != null && !Objects.equals(employeeInfoVO.getName(), employeeRepetition.getName())) {
String name = employeeInfoVO.getName();
for (int i = 0;i < PromptSuccess.LETTERS.length;i++){
for (int i = 0; i < PromptSuccess.LETTERS.length; i++) {
Integer nameCount = this.getBaseMapper().employeeNameCount(name);
if (nameCount > 0){
if (nameCount > 0) {
name = employeeInfoVO.getName() + PromptSuccess.LETTERS[i];
}else {
} else {
employeeInfoVO.setName(name);
break;
}
if (i == PromptSuccess.LETTERS.length - 1){
if (i == PromptSuccess.LETTERS.length - 1) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_REPETITION_EXCEED);
}
}
@ -342,28 +342,28 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
|| employeeInfoVO.getAccount().length() == 0
|| employeeInfoVO.getCompanyMail().length() == 0
|| employeeInfoVO.getJobNumber().length() == 0
|| employeeInfoVO.getPhone().length() == 0){
|| employeeInfoVO.getPhone().length() == 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_INFO_NOT_NULL);
}
// 判重
Integer numberCount = this.getBaseMapper().employeeJobNumberCount(employeeInfoVO.getJobNumber());
if (numberCount > 0){
if (numberCount > 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_JOB_NUMBER_EXIST);
}
Integer accountCount = this.getBaseMapper().userAccountCount(employeeInfoVO.getAccount());
if (accountCount > 0){
if (accountCount > 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_USER_ACCOUNT_EXIST);
}
String name = employeeInfoVO.getName();
for (int i = 0;i < PromptSuccess.LETTERS.length;i++){
for (int i = 0; i < PromptSuccess.LETTERS.length; i++) {
Integer nameCount = this.getBaseMapper().employeeNameCount(name);
if (nameCount > 0){
if (nameCount > 0) {
name = employeeInfoVO.getName() + PromptSuccess.LETTERS[i];
}else {
} else {
employeeInfoVO.setName(name);
break;
}
if (i == PromptSuccess.LETTERS.length - 1){
if (i == PromptSuccess.LETTERS.length - 1) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_REPETITION_EXCEED);
}
}
@ -430,7 +430,7 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
@Transactional
@Override
public Boolean excelImport(MultipartFile file) {
if (file == null || file.isEmpty()){
if (file == null || file.isEmpty()) {
ExceptionCast.cast(CrmsCode.NOT_NULL);
}
EmployeeExcelImport employeeExcelImport = new EmployeeExcelImport();
@ -450,7 +450,7 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
for (Object e : employees) {
// 判空
BeanUtils.copyProperties(e, employeeExcelImport);
if (employeeExcelImport.getName() == null || employeeExcelImport.getName().length() == 0) {
if (employeeExcelImport.getName() == null || employeeExcelImport.getName().length() == 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_NAME_IS_NULL);
}
if (employeeExcelImport.getAccount() == null || employeeExcelImport.getAccount().length() == 0) {
@ -461,23 +461,23 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
}
// 判重
Integer jobNumberCount = this.getBaseMapper().employeeJobNumberCount(employeeExcelImport.getJobNumber());
if (jobNumberCount > 0){
if (jobNumberCount > 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_JOB_NUMBER_EXIST);
}
Integer accountCount = this.getBaseMapper().userAccountCount(employeeExcelImport.getAccount());
if (accountCount > 0){
if (accountCount > 0) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_USER_ACCOUNT_EXIST);
}
String name = employeeExcelImport.getName();
for (int i = 0;i < PromptSuccess.LETTERS.length;i++){
for (int i = 0; i < PromptSuccess.LETTERS.length; i++) {
Integer nameCount = this.getBaseMapper().employeeNameCount(name);
if (nameCount > 0){
if (nameCount > 0) {
name = employeeExcelImport.getName() + PromptSuccess.LETTERS[i];
}else {
} else {
employeeExcelImport.setName(name);
break;
}
if (i == PromptSuccess.LETTERS.length - 1){
if (i == PromptSuccess.LETTERS.length - 1) {
ExceptionCast.cast(HrmsCode.EMPLOYEE_REPETITION_EXCEED);
}
}
@ -486,7 +486,7 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
user.setMotifyTime(new Date());
this.getBaseMapper().insertUser(user);
// 根据新增的user主键id新增初始密码
this.getBaseMapper().updatePassword(user.getId(),Md5Util.md5(PromptSuccess.RESET_PASSWORD+user.getId()));
this.getBaseMapper().updatePassword(user.getId(), Md5Util.md5(PromptSuccess.RESET_PASSWORD + user.getId()));
BeanUtils.copyProperties(e, employee);
employee.setUserId(user.getId());
// 此处员工姓名可能重复,所以要如下设置
@ -580,11 +580,13 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
*/
@Override
public List<EmployeeTO> getEmployeeAndDeptById(List<Long> ids) {
return this.getBaseMapper().getEmployeeAndDeptById(ids);
}
/**
* 根据userId查询员工的头像
*
* @return
*/
@Override
@ -599,11 +601,10 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
@Override
public boolean insertUserRole(Long userId, Long roleId) {
return this.getBaseMapper().insertUserRole(userId,roleId);
return this.getBaseMapper().insertUserRole(userId, roleId);
}
@Override
public boolean insertUsrRole(List<DgGuaranteePO> list) {
return this.getBaseMapper().insertUsrRole(list);
@ -615,7 +616,7 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
@Override
public Boolean saveUserRole(Long userId, Long roleId) {
int i = this.getBaseMapper().saveUserRole(userId, roleId);
if (i > 0){
if (i > 0) {
return true;
}

Loading…
Cancel
Save