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

master
river 4 years ago
parent c471f516c1
commit a03f2e92ff
  1. 198
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java
  2. 54
      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. 93
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/EmployeeServiceImpl.java

@ -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;

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

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

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

Loading…
Cancel
Save