客户资源后台新增和个人更新

master
river 4 years ago
parent 185433e307
commit 4242aade43
  1. 21
      dq-financial-api/src/main/java/com/daqing/financial/crms/CustomerControllerApi.java
  2. 6
      dq-financial-api/src/main/java/com/daqing/financial/hrms/DeptControllerApi.java
  3. 4
      dq-financial-api/src/main/java/com/daqing/financial/hrms/EmployeeControllerApi.java
  4. 45
      dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java
  5. 2
      dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CompanyCustomerDao.java
  6. 4
      dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java
  7. 4
      dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/PersonalCustomerDao.java
  8. 1
      dq-financial-crms/src/main/java/com/daqing/financial/crms/feign/HrmsFeignService.java
  9. 8
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/CustomerService.java
  10. 151
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java
  11. 7
      dq-financial-crms/src/main/resources/mapper/crms/CompanyCustomerDao.xml
  12. 14
      dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml
  13. 21
      dq-financial-crms/src/main/resources/mapper/crms/PersonalCustomerDao.xml
  14. 10
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/DeptController.java
  15. 5
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/DeptDao.java
  16. 3
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/EmployeeDao.java
  17. 3
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/DeptService.java
  18. 34
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/DeptServiceImpl.java
  19. 6
      dq-financial-hrms/src/main/resources/mapper/hrms/DeptDao.xml
  20. 11
      dq-financial-hrms/src/main/resources/mapper/hrms/EmployeeDao.xml
  21. 26
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/ext/CustomerCompanyTO.java
  22. 4
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/ext/CustomerCompanyVO.java
  23. 27
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/ext/CustomerPersonalTO.java
  24. 4
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/ext/CustomerPersonalVO.java
  25. 55
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/DepartmentVO.java
  26. 25
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/ext/EmployeeVO.java

@ -1,5 +1,9 @@
package com.daqing.financial.crms;
import com.daqing.framework.domain.crms.CustomerEntity;
import com.daqing.framework.domain.crms.PersonalCustomerEntity;
import com.daqing.framework.domain.crms.ext.CustomerCompanyTO;
import com.daqing.framework.domain.crms.ext.CustomerPersonalTO;
import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
@ -37,4 +41,21 @@ public interface CustomerControllerApi {
@ApiOperation(value = "删除所选客户", notes = "删除所选客户")
ResponseResult deleteCustomer(Long[] ids);
/**
* 插入个人类型客户信息
*/
@ApiOperation(value = "插入个人类型客户信息", notes = "插入个人类型客户信息")
ResponseResult savePersonal(CustomerPersonalTO customerPersonalTO);
/**
* 插入企业类型客户信息
*/
@ApiOperation(value = "插入企业类型客户信息", notes = "插入企业类型客户信息")
ResponseResult saveCompany(CustomerCompanyTO customerCompanyTO);
/**
* 更新个人类型客户信息
*/
@ApiOperation(value = "更新个人类型客户信息", notes = "更新个人类型客户信息")
ResponseResult updatePersonal(CustomerPersonalTO customerPersonalTO);
}

@ -50,4 +50,10 @@ public interface DeptControllerApi {
*/
@ApiOperation(value = "根据id数组批量删除部门信息", notes = "根据id数组批量删除部门信息")
ResponseResult delete(Long[] ids);
/**
* 查询所有部门及部门下的员工信息
*/
@ApiOperation(value = "查询所有部门及部门下的员工信息", notes = "查询所有部门及部门下的员工信息")
ResponseResult trees();
}

@ -12,12 +12,10 @@ import io.swagger.annotations.ApiOperation;
@Api(value = "员工管理相关操作", tags = "提供员工信息增删改查等相关方法")
public interface EmployeeControllerApi {
/**
* 根据id查询员工的基本信息和部门信息
*/
@ApiOperation(value = "根据id查询员工的基本信息和部门信息", notes = "根据id查询员工的基本信息和部门信息")
ResponseResult getEmployeeAndDeptById(Long[] ids);
@ApiOperation(value = "根据id查询员工姓名", notes = "根据id查询员工姓名")
ResponseResult getEmployeeById(Long id);
/**

@ -2,6 +2,8 @@ package com.daqing.financial.crms.controller;
import com.daqing.financial.crms.CustomerControllerApi;
import com.daqing.financial.crms.service.CustomerService;
import com.daqing.framework.domain.crms.ext.CustomerCompanyTO;
import com.daqing.framework.domain.crms.ext.CustomerPersonalTO;
import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils;
@ -25,6 +27,19 @@ public class CustomerController implements CustomerControllerApi {
@Autowired
private CustomerService customerService;
/*@Autowired
private HrmsFeignService hrmsFeignService;*/
/**
* 列表
*/
/*@GetMapping("/hrms_list")*/
//@RequiresPermissions("hrms:dept:list")
/* public ResponseResult hrmsList() {
Map<String, Object> params = new HashMap<>();
return hrmsFeignService.list(params);
}*/
/**
* 查询客户列表(所有)根据创建时间筛选根据客户类型筛选根据客户编号或者名称搜索
*/
@ -52,4 +67,34 @@ public class CustomerController implements CustomerControllerApi {
return new ResponseResult<List<String>>().SUCCESS(customerService.updateCustomerById(ids));
}
/**
* 保存个人类型客户信息
*/
@PostMapping("/savePersonal")
@Override
public ResponseResult savePersonal(@RequestBody CustomerPersonalTO customerPersonalTO) {
boolean result = customerService.saveCustomerPersonal(customerPersonalTO.getCustomerEntity(), customerPersonalTO.getPersonalCustomerEntity());
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/**
* 保存企业类型客户信息
*/
@PostMapping("/saveCompany")
@Override
public ResponseResult saveCompany(@RequestBody CustomerCompanyTO customerCompanyTO) {
boolean result = customerService.saveCustomerCompany(customerCompanyTO.getCustomerEntity(), customerCompanyTO.getCompanyCustomerEntity());
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/**
* 更新个人类型客户信息
*/
@PostMapping("/updatePersonal")
@Override
public ResponseResult updatePersonal(@RequestBody CustomerPersonalTO customerPersonalTO) {
boolean result = customerService.updateCustomerPersonal(customerPersonalTO.getCustomerEntity(), customerPersonalTO.getPersonalCustomerEntity());
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
}

@ -15,4 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
public interface CompanyCustomerDao extends BaseMapper<CompanyCustomerEntity> {
CompanyCustomerEntity queryCompanyCustomerById(Long id);
boolean saveCompanyCustomer(CompanyCustomerEntity companyCustomerEntity);
}

@ -28,4 +28,8 @@ public interface CustomerDao extends BaseMapper<CustomerEntity> {
void updateCustomerById(@Param("ids") List<Long> ids);
List<String> queryCustomerNameById(@Param("ids") List<Long> ids);
boolean saveCustomer(CustomerEntity customerEntity);
boolean updateCustomer(CustomerEntity customerEntity);
}

@ -15,4 +15,8 @@ import org.apache.ibatis.annotations.Mapper;
public interface PersonalCustomerDao extends BaseMapper<PersonalCustomerEntity> {
PersonalCustomerEntity queryPersonalCustomerById(Long id);
boolean savePersonalCustomer(PersonalCustomerEntity personalCustomerEntity);
boolean updatePersonalCustomer(PersonalCustomerEntity personalCustomerEntity);
}

@ -24,4 +24,5 @@ public interface HrmsFeignService {
@GetMapping("/hrms/employee/getEmployeeById")
ResponseResult<EmployeeEntity> getEmployeeById(@RequestParam("id") Long id);
}

@ -1,6 +1,8 @@
package com.daqing.financial.crms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.crms.CompanyCustomerEntity;
import com.daqing.framework.domain.crms.PersonalCustomerEntity;
import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils;
@ -23,5 +25,11 @@ public interface CustomerService extends IService<CustomerEntity> {
ResponseResult queryCustomerById(Long id);
List<String> updateCustomerById(Long[] ids);
boolean saveCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity);
boolean saveCustomerCompany(CustomerEntity customerEntity, CompanyCustomerEntity companyCustomerEntity);
boolean updateCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity);
}

@ -14,18 +14,18 @@ import com.daqing.framework.domain.crms.CustomerEntity;
import com.daqing.framework.domain.crms.PersonalCustomerEntity;
import com.daqing.framework.domain.crms.ext.CrmsConstant;
import com.daqing.framework.domain.crms.ext.CustomerTO;
import com.daqing.framework.domain.crms.ext.CustomerVOCompany;
import com.daqing.framework.domain.crms.ext.CustomerVOPersonal;
import com.daqing.framework.domain.crms.ext.CustomerCompanyVO;
import com.daqing.framework.domain.crms.ext.CustomerPersonalVO;
import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.ext.EmployeeTO;
import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils;
import com.daqing.framework.utils.SnowflakeIdUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
@ -107,13 +107,13 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
if (Objects.equals(customer.getType(), CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType())) {
PersonalCustomerEntity personalCustomerEntity = personalCustomerDao.queryPersonalCustomerById(id);
//封装个人类型客户信息
CustomerVOPersonal customerVOPersonal = this.setPersonal(customer, name, personalCustomerEntity);
return new ResponseResult<CustomerVOPersonal>().SUCCESS(customerVOPersonal);
CustomerPersonalVO customerPersonalVO = this.setPersonal(customer, name, personalCustomerEntity);
return new ResponseResult<CustomerPersonalVO>().SUCCESS(customerPersonalVO);
} else {
CompanyCustomerEntity companyCustomerEntity = companyCustomerDao.queryCompanyCustomerById(id);
//封装企业类型客户信息
CustomerVOCompany customerVOCompany = this.setCompany(customer, name, companyCustomerEntity);
return new ResponseResult<CustomerVOCompany>().SUCCESS(customerVOCompany);
CustomerCompanyVO customerCompanyVO = this.setCompany(customer, name, companyCustomerEntity);
return new ResponseResult<CustomerCompanyVO>().SUCCESS(customerCompanyVO);
}
}
@ -136,6 +136,57 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
}
}
/**
* 插入个人类型客户信息
* @param customerEntity 客户基本信息
* @param personalCustomerEntity 个人类型信息
* @return
*/
@Transactional
@Override
public boolean saveCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity) {
customerEntity.setId(SnowflakeIdUtils.getRandomid());
//TODO 设置客户编号
customerEntity.setCode(((int)(Math.random()*100+1))+"");
customerEntity.setCreateTime(new Date());
customerEntity.setMotifyTime(new Date());
personalCustomerEntity.setId(SnowflakeIdUtils.getRandomid());
personalCustomerEntity.setCustomerId(customerEntity.getId());
return customerDao.saveCustomer(customerEntity) && personalCustomerDao.savePersonalCustomer(personalCustomerEntity);
}
/**
* 插入企业类型客户信息
* @param customerEntity 客户基本信息
* @param companyCustomerEntity 企业类型信息
* @return
*/
@Transactional
@Override
public boolean saveCustomerCompany(CustomerEntity customerEntity, CompanyCustomerEntity companyCustomerEntity) {
customerEntity.setId(SnowflakeIdUtils.getRandomid());
//TODO 设置客户编号
customerEntity.setCode(((int)(Math.random()*100+1))+"");
customerEntity.setCreateTime(new Date());
customerEntity.setMotifyTime(new Date());
companyCustomerEntity.setId(SnowflakeIdUtils.getRandomid());
companyCustomerEntity.setCustomerId(customerEntity.getId());
return customerDao.saveCustomer(customerEntity) && companyCustomerDao.saveCompanyCustomer(companyCustomerEntity);
}
/**
* 更新个人类型客户信息
* @param customerEntity 客户基本信息
* @param personalCustomerEntity 企业类型信息
* @return
*/
@Override
public boolean updateCustomerPersonal(CustomerEntity customerEntity, PersonalCustomerEntity personalCustomerEntity) {
customerEntity.setMotifyTime(new Date());
personalCustomerEntity.setCustomerId(customerEntity.getId());
return customerDao.updateCustomer(customerEntity) && personalCustomerDao.updatePersonalCustomer(personalCustomerEntity);
}
/**
* 选择某段时间内客户信息的时间参数校验
*
@ -243,31 +294,31 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
* @param personal 个人类型信息
* @return
*/
private CustomerVOPersonal setPersonal(CustomerEntity customer, String name, PersonalCustomerEntity personal) {
private CustomerPersonalVO setPersonal(CustomerEntity customer, String name, PersonalCustomerEntity personal) {
//BeanUtils能批量封装相同字段名称和类型的属性的值
CustomerVOPersonal customerVOPersonal = new CustomerVOPersonal();
customerVOPersonal.setCode(customer.getCode());
customerVOPersonal.setType(customer.getType());
customerVOPersonal.setManager(name);
customerVOPersonal.setName(customer.getName());
customerVOPersonal.setAddress(customer.getAddr());
customerVOPersonal.setPhone(customer.getPhone());
customerVOPersonal.setIdCard(personal.getIdCard());
customerVOPersonal.setAge(personal.getAge());
customerVOPersonal.setGender(personal.getGender());
customerVOPersonal.setMaritalStatus(personal.getMaritalStatus());
customerVOPersonal.setEducation(personal.getEducation());
customerVOPersonal.setEmployer(personal.getEmployer());
customerVOPersonal.setPosition(personal.getPosition());
customerVOPersonal.setWorkingYears(personal.getWorkingYears());
customerVOPersonal.setSocialSecurityNum(personal.getSocialSecurityNum());
customerVOPersonal.setLivingSituation(personal.getLivingSituation());
customerVOPersonal.setResidenceAddr(personal.getResidenceAddr());
customerVOPersonal.setBusinessSource(personal.getBusinessSource());
customerVOPersonal.setEmergencyLinkman(personal.getEmergencyLinkman());
customerVOPersonal.setEmergencyLinkmanRelationship(personal.getEmergencyLinkmanRelationship());
customerVOPersonal.setEmergencyLinkmanPhone(personal.getEmergencyLinkmanPhone());
return customerVOPersonal;
CustomerPersonalVO customerPersonalVO = new CustomerPersonalVO();
customerPersonalVO.setCode(customer.getCode());
customerPersonalVO.setType(customer.getType());
customerPersonalVO.setManager(name);
customerPersonalVO.setName(customer.getName());
customerPersonalVO.setAddress(customer.getAddr());
customerPersonalVO.setPhone(customer.getPhone());
customerPersonalVO.setIdCard(personal.getIdCard());
customerPersonalVO.setAge(personal.getAge());
customerPersonalVO.setGender(personal.getGender());
customerPersonalVO.setMaritalStatus(personal.getMaritalStatus());
customerPersonalVO.setEducation(personal.getEducation());
customerPersonalVO.setEmployer(personal.getEmployer());
customerPersonalVO.setPosition(personal.getPosition());
customerPersonalVO.setWorkingYears(personal.getWorkingYears());
customerPersonalVO.setSocialSecurityNum(personal.getSocialSecurityNum());
customerPersonalVO.setLivingSituation(personal.getLivingSituation());
customerPersonalVO.setResidenceAddr(personal.getResidenceAddr());
customerPersonalVO.setBusinessSource(personal.getBusinessSource());
customerPersonalVO.setEmergencyLinkman(personal.getEmergencyLinkman());
customerPersonalVO.setEmergencyLinkmanRelationship(personal.getEmergencyLinkmanRelationship());
customerPersonalVO.setEmergencyLinkmanPhone(personal.getEmergencyLinkmanPhone());
return customerPersonalVO;
}
/**
@ -278,23 +329,23 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
* @param company 企业类型信息
* @return
*/
private CustomerVOCompany setCompany(CustomerEntity customer, String name, CompanyCustomerEntity company) {
CustomerVOCompany customerVOCompany = new CustomerVOCompany();
customerVOCompany.setCode(customer.getCode());
customerVOCompany.setType(customer.getType());
customerVOCompany.setManager(name);
customerVOCompany.setName(customer.getName());
customerVOCompany.setAddress(customer.getAddr());
customerVOCompany.setPhone(customer.getPhone());
customerVOCompany.setRegisteredCapital(company.getRegisteredCapital());
customerVOCompany.setIndustry(company.getIndustry());
customerVOCompany.setYears(company.getYears());
customerVOCompany.setRegion(company.getRegion());
customerVOCompany.setShareholder(company.getShareholder());
customerVOCompany.setAffiliatedCompany(company.getAffiliatedCompany());
customerVOCompany.setEmployeeNumber(company.getEmpNum());
customerVOCompany.setLinkman(company.getLinkman());
customerVOCompany.setBusinessSource(company.getBusinessSource());
return customerVOCompany;
private CustomerCompanyVO setCompany(CustomerEntity customer, String name, CompanyCustomerEntity company) {
CustomerCompanyVO customerCompanyVO = new CustomerCompanyVO();
customerCompanyVO.setCode(customer.getCode());
customerCompanyVO.setType(customer.getType());
customerCompanyVO.setManager(name);
customerCompanyVO.setName(customer.getName());
customerCompanyVO.setAddress(customer.getAddr());
customerCompanyVO.setPhone(customer.getPhone());
customerCompanyVO.setRegisteredCapital(company.getRegisteredCapital());
customerCompanyVO.setIndustry(company.getIndustry());
customerCompanyVO.setYears(company.getYears());
customerCompanyVO.setRegion(company.getRegion());
customerCompanyVO.setShareholder(company.getShareholder());
customerCompanyVO.setAffiliatedCompany(company.getAffiliatedCompany());
customerCompanyVO.setEmployeeNumber(company.getEmpNum());
customerCompanyVO.setLinkman(company.getLinkman());
customerCompanyVO.setBusinessSource(company.getBusinessSource());
return customerCompanyVO;
}
}

@ -25,5 +25,12 @@
WHERE customer_id = #{id}
</select>
<!-- 插入企业类型客户信息 -->
<insert id="saveCompanyCustomer" parameterType="com.daqing.framework.domain.crms.CompanyCustomerEntity">
INSERT INTO crms_company_customer
(id,registered_capital,industry,years,region,shareholder,affiliated_company,emp_num,linkman,business_source,customer_id)
values (#{id},#{registeredCapital},#{industry},#{years},#{region},#{shareholder},#{affiliatedCompany},#{empNum},#{linkman},
#{businessSource},#{customerId});
</insert>
</mapper>

@ -69,4 +69,18 @@
</foreach>
</select>
<!-- 插入客户基本信息 -->
<insert id="saveCustomer" parameterType="com.daqing.framework.domain.crms.CustomerEntity">
INSERT INTO crms_customer
(id,code,type,manager,name,addr,phone,del_or_not,status,create_time,motify_time)
VALUES (#{id},#{code},#{type},#{manager},#{name},#{addr},#{phone},0,0,#{createTime},#{motifyTime})
</insert>
<!-- 更新客户基本信息 -->
<update id="updateCustomer" parameterType="com.daqing.framework.domain.crms.CustomerEntity">
UPDATE crms_customer
SET manager=#{manager},name=#{name},addr=#{addr},phone=#{phone},motify_time=#{motifyTime}
WHERE id = #{id}
</update>
</mapper>

@ -33,4 +33,25 @@
WHERE customer_id = #{id}
</select>
<!-- 插入个人类型的客户信息 -->
<insert id="savePersonalCustomer" parameterType="com.daqing.framework.domain.crms.PersonalCustomerEntity">
INSERT INTO crms_personal_customer
(id,customer_id,id_card,age,gender,marital_status,education,employer,position,working_years,social_security_num,living_situation
,residence_addr,business_source,emergency_linkman,emergency_linkman_relationship,emergency_linkman_phone)
VALUES (#{id},#{customerId},#{idCard},#{age},#{gender},#{maritalStatus},#{education},#{employer},#{position},#{workingYears},
#{socialSecurityNum},#{livingSituation},#{residenceAddr},#{businessSource},#{emergencyLinkman},#{emergencyLinkmanRelationship},
#{emergencyLinkmanPhone});
</insert>
<!-- 更新个人类型的客户信息 -->
<update id="updatePersonalCustomer" parameterType="com.daqing.framework.domain.crms.PersonalCustomerEntity">
UPDATE crms_personal_customer
SET id_card=#{idCard},age=#{age},gender=#{gender},marital_status=#{maritalStatus},education=#{education},
employer=#{employer},position=#{position},working_years=#{workingYears},social_security_num=#{socialSecurityNum},
living_situation=#{livingSituation},residence_addr=#{residenceAddr},business_source=#{businessSource},
emergency_linkman=#{emergencyLinkman},emergency_linkman_relationship=#{emergencyLinkmanRelationship},
emergency_linkman_phone=#{emergencyLinkmanPhone}
WHERE customer_id = #{customer_id}
</update>
</mapper>

@ -2,6 +2,7 @@ package com.daqing.financial.hrms.controller;
import com.daqing.financial.hrms.DeptControllerApi;
import com.daqing.financial.hrms.service.DeptService;
import com.daqing.framework.domain.hrms.DepartmentVO;
import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.request.DeptAddRequest;
import com.daqing.framework.model.response.ResponseResult;
@ -95,4 +96,13 @@ public class DeptController implements DeptControllerApi {
boolean result = deptService.deleteByIds(ids);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/**
*所有部门及员工
*/
@Override
@GetMapping("/trees")
public ResponseResult trees() {
return new ResponseResult<List<DepartmentVO>>().SUCCESS(deptService.listDepartmentAndEmployeeTree());
}
}

@ -1,6 +1,7 @@
package com.daqing.financial.hrms.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daqing.framework.domain.hrms.DepartmentVO;
import com.daqing.framework.domain.hrms.DeptEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -20,5 +21,9 @@ public interface DeptDao extends BaseMapper<DeptEntity> {
Integer getEmpDeptCount(@Param("deptId") Long deptId);
<<<<<<< Updated upstream
List<DeptEntity> getByPositionId(@Param("positionId") Long positionId);
=======
List<DepartmentVO> listDepartment();
>>>>>>> Stashed changes
}

@ -3,6 +3,7 @@ package com.daqing.financial.hrms.dao;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daqing.framework.domain.hrms.ext.EmployeeTO;
import com.daqing.framework.domain.hrms.ext.EmployeeVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -21,4 +22,6 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
List<EmployeeTO> getEmployeeAndDeptById(@Param("ids") List<Long> ids);
EmployeeEntity getEmployeeById(Long id);
List<EmployeeVO> listEmployeeByDeptId(Long id);
}

@ -1,6 +1,7 @@
package com.daqing.financial.hrms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.DepartmentVO;
import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.request.DeptAddRequest;
@ -22,5 +23,7 @@ public interface DeptService extends IService<DeptEntity> {
boolean updateDept(DeptEntity dept);
boolean deleteByIds(Long[] ids);
List<DepartmentVO> listDepartmentAndEmployeeTree();
}

@ -3,7 +3,9 @@ package com.daqing.financial.hrms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daqing.financial.hrms.dao.DeptDao;
import com.daqing.financial.hrms.dao.EmployeeDao;
import com.daqing.financial.hrms.service.DeptService;
import com.daqing.framework.domain.hrms.DepartmentVO;
import com.daqing.framework.domain.hrms.DeptEntity;
import com.daqing.framework.domain.hrms.request.DeptAddRequest;
import com.daqing.framework.domain.hrms.response.HrmsCode;
@ -11,6 +13,7 @@ import com.daqing.framework.exception.ExceptionCast;
import com.daqing.framework.utils.SnowflakeIdUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
@ -23,6 +26,12 @@ import java.util.stream.Collectors;
@Service("deptService")
public class DeptServiceImpl extends ServiceImpl<DeptDao, DeptEntity> implements DeptService {
@Autowired
private DeptDao deptDao;
@Autowired
private EmployeeDao employeeDao;
/**
* 保存一条部门信息
*
@ -100,7 +109,10 @@ public class DeptServiceImpl extends ServiceImpl<DeptDao, DeptEntity> implements
private List<DeptEntity> getDeptTreeList(List<DeptEntity> list, Long parentId) {
return list.stream()
.filter(dept -> parentId.equals(dept.getParentId()))
.peek(dept -> dept.setChildren(getDeptTreeList(list, dept.getId())))
.peek(dept -> {
dept.setChildren(getDeptTreeList(list, dept.getId()));
})
.sorted(Comparator.comparingInt(menu -> (menu.getSort() == null ? 0 : menu.getSort())))
.collect(Collectors.toList());
}
@ -137,4 +149,24 @@ public class DeptServiceImpl extends ServiceImpl<DeptDao, DeptEntity> implements
});
return this.removeByIds(list);
}
/**
* 获取所有的部门及部门下的员工信息
* @return
*/
@Override
public List<DepartmentVO> listDepartmentAndEmployeeTree() {
return this.getListDepartmentAndEmployeeTree(deptDao.listDepartment(), 0L);
}
private List<DepartmentVO> getListDepartmentAndEmployeeTree(List<DepartmentVO> list, Long parentId){
return list.stream()
.filter(dept -> parentId.equals(dept.getParentId())) // 过滤出部门id为所选id的部门信息(也为递归的结果条件,找不到所对应的部门id)
.peek(dept -> {
dept.setChildren(getListDepartmentAndEmployeeTree(list, dept.getId())); // 设置该部门的子部门:递归调用
dept.setEmployee(employeeDao.listEmployeeByDeptId(dept.getId())); // 设置该部门下面的所有员工
})
.sorted(Comparator.comparingInt(menu -> (menu.getSort() == null ? 0 : menu.getSort()))) // 根据所选排序信息进行排序
.collect(Collectors.toList());
}
}

@ -13,6 +13,7 @@
<result property="createTime" column="create_time"/>
<result property="motifyTime" column="motify_time"/>
</resultMap>
<!-- 部门树及各级部门下的员工 -->
<select id="getMaxSort" parameterType="java.lang.Long" resultType="java.lang.Integer">
SELECT MAX(sort) FROM hrms_dept WHERE parent_id = #{parentId}
</select>
@ -30,4 +31,9 @@
dp.position_id = #{positionId}
</select>
<select id="listDepartment" resultType="com.daqing.framework.domain.hrms.DepartmentVO">
SELECT id,name,parent_id,sort
FROM hrms_dept
</select>
</mapper>

@ -46,4 +46,15 @@
<select id="getEmployeeById" parameterType="long" resultType="com.daqing.framework.domain.hrms.EmployeeEntity">
SELECT name FROM hrms_employee WHERE id = #{id}
</select>
<!-- 根据部门id获取该部门下面所有的员工 -->
<select id="listEmployeeByDeptId" parameterType="long" resultType="com.daqing.framework.domain.hrms.ext.EmployeeVO">
SELECT e.id,e.name
FROM hrms_employee e
LEFT JOIN hrms_employee_dept ed
ON e.id = ed.employee_id
LEFT JOIN hrms_dept d
ON ed.dept_id = d.id
WHERE d.id = #{id}
</select>
</mapper>

@ -0,0 +1,26 @@
package com.daqing.framework.domain.crms.ext;
import com.daqing.framework.domain.crms.CompanyCustomerEntity;
import com.daqing.framework.domain.crms.CustomerEntity;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
/**
* @auther River
* @date 2020/9/15 20:20
*/
@Data
@ToString
public class CustomerCompanyTO implements Serializable {
/**
* 客户基本信息
*/
private CustomerEntity customerEntity;
/**
* 企业类型信息
*/
private CompanyCustomerEntity companyCustomerEntity;
}

@ -6,12 +6,14 @@ import lombok.ToString;
import java.io.Serializable;
/**
* 企业类型客户返回信息包装类
*
* @auther River
* @date 2020/9/14 10:48
*/
@Data
@ToString
public class CustomerVOCompany implements Serializable {
public class CustomerCompanyVO implements Serializable {
/**
* 客户编号

@ -0,0 +1,27 @@
package com.daqing.framework.domain.crms.ext;
import com.daqing.framework.domain.crms.CustomerEntity;
import com.daqing.framework.domain.crms.PersonalCustomerEntity;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
/**
* @auther River
* @date 2020/9/15 19:57
*/
@Data
@ToString
public class CustomerPersonalTO implements Serializable {
/**
* 客户基本信息
*/
private CustomerEntity customerEntity;
/**
* 客户个人信息
*/
private PersonalCustomerEntity personalCustomerEntity;
}

@ -6,12 +6,14 @@ import lombok.ToString;
import java.io.Serializable;
/**
* 个人类型返回信息包装类
*
* @auther River
* @date 2020/9/11 17:28
*/
@Data
@ToString
public class CustomerVOPersonal implements Serializable {
public class CustomerPersonalVO implements Serializable {
/**
* 客户编号

@ -0,0 +1,55 @@
package com.daqing.framework.domain.hrms;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.daqing.framework.domain.hrms.ext.EmployeeVO;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 封装所有部门及部门下所有员工的包装类
*
* @auther River
* @date 2020/9/15 9:44
*/
@Data
@ToString
public class DepartmentVO implements Serializable{
/**
* 主键
*/
@TableId(value = "id", type = IdType.INPUT)
private Long id;
/**
* 部门名称
*/
private String name;
/**
* 上级部门id
*/
private Long parentId;
/**
* 排序
*/
private Integer sort;
/**
* 子部门
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@TableField(exist = false)
private List<DepartmentVO> children;
/**
* 该级部门下面的员工
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@TableField(exist = false)
private List<EmployeeVO> employee;
}

@ -0,0 +1,25 @@
package com.daqing.framework.domain.hrms.ext;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
/**
* @auther River
* @date 2020/9/15 16:46
*/
@Data
@ToString
public class EmployeeVO implements Serializable{
/**
* id
*/
private Long id;
/**
* 员工姓名
*/
private String name;
}
Loading…
Cancel
Save