|
|
@ -27,16 +27,14 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.CustomerAgencyConstant; |
|
|
|
import com.epmet.constant.CustomerGridConstant; |
|
|
|
import com.epmet.dao.CustomerAgencyDao; |
|
|
|
import com.epmet.dao.CustomerGridDao; |
|
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
|
import com.epmet.dto.CustomerDTO; |
|
|
|
import com.epmet.dao.*; |
|
|
|
import com.epmet.dto.*; |
|
|
|
import com.epmet.dto.form.CustomerFormDTO; |
|
|
|
import com.epmet.dto.form.StaffOrgFormDTO; |
|
|
|
import com.epmet.dto.result.AgencyGridResultDTO; |
|
|
|
import com.epmet.dto.result.StaffOrgsResultDTO; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.CustomerAgencyEntity; |
|
|
|
import com.epmet.entity.CustomerGridEntity; |
|
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.feign.OperCrmFeignClient; |
|
|
|
import com.epmet.redis.CustomerAgencyRedis; |
|
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
@ -47,9 +45,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 机关单位信息表 |
|
|
@ -67,6 +64,17 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
|
private OperCrmFeignClient operCrmFeignClient; |
|
|
|
@Autowired |
|
|
|
private CustomerGridDao customerGridDao; |
|
|
|
@Autowired |
|
|
|
private CustomerStaffAgencyDao customerStaffAgencyDao; |
|
|
|
@Autowired |
|
|
|
private CustomerDepartmentDao customerDepartmentDao; |
|
|
|
@Autowired |
|
|
|
private CustomerStaffDepartmentDao customerStaffDepartmentDao; |
|
|
|
@Autowired |
|
|
|
private CustomerStaffGridDao customerStaffGridDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<CustomerAgencyDTO> page(Map<String, Object> params) { |
|
|
|
IPage<CustomerAgencyEntity> page = baseDao.selectPage( |
|
|
@ -167,4 +175,127 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
|
return agencyGridResultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param agencyId |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 查询组织下人员,组织下部门人员,组织下网格人员列表信息 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public DepartmentStaffListResultDTO departmentStaffList(String agencyId) { |
|
|
|
//根据组织Id查询该组织的工作人员列表;该组织的部门列表、部门下人员(带部门领导角色)列表;该组织的网格列表、网格下人员(带网格长角色)列表。人员都不做去重处理。
|
|
|
|
DepartmentStaffListResultDTO resultDTO = new DepartmentStaffListResultDTO(); |
|
|
|
//1:根据组织Id查询该组织下工作人员列表
|
|
|
|
List<StaffListResultDTO> agencyStaffList = customerStaffAgencyDao.selectAgencyStaffList(agencyId); |
|
|
|
//2:根据组织Id查询该组织下部门、人员列表
|
|
|
|
//2.1:查询组织下部门列表
|
|
|
|
List<DepartmentListResultDTO> listDept = customerDepartmentDao.selectDepartmentList(agencyId); |
|
|
|
List<DeptListResultDTO> departmentList = ConvertUtils.sourceToTarget(listDept, DeptListResultDTO.class); |
|
|
|
//2.2:查询每一个部门下人员列表
|
|
|
|
List<String> deptIdList = departmentList.stream().map(DeptListResultDTO::getDepartmentId).collect(Collectors.toList()); |
|
|
|
List<CustomerStaffDepartmentDTO> deptStaffs = customerStaffDepartmentDao.selectDeptStaffs(deptIdList); |
|
|
|
departmentList.forEach(dept->{ |
|
|
|
List<StaffListResultDTO> departmentStaffList = new ArrayList<>(); |
|
|
|
deptStaffs.forEach(ds->{ |
|
|
|
if(dept.getDepartmentId().equals(ds.getDepartmentId())){ |
|
|
|
StaffListResultDTO sf = new StaffListResultDTO(); |
|
|
|
sf.setStaffId(ds.getUserId()); |
|
|
|
departmentStaffList.add(sf); |
|
|
|
} |
|
|
|
}); |
|
|
|
dept.setDepartmentStaffList(departmentStaffList); |
|
|
|
}); |
|
|
|
//3:根据组织Id查询该组织下网格、人员列表
|
|
|
|
//3.1:查询组织下网格列表
|
|
|
|
List<GridListResultDTO> gridList = customerGridDao.selectGridList(agencyId); |
|
|
|
//3.2:查询每一个网格下人员列表
|
|
|
|
List<String> gridIdList = gridList.stream().map(GridListResultDTO::getGridId).collect(Collectors.toList()); |
|
|
|
List<CustomerStaffGridDTO> gridStaffs = customerStaffGridDao.selectGridStaffs(gridIdList); |
|
|
|
gridList.forEach(grid->{ |
|
|
|
List<StaffListResultDTO> gridStaffList = new ArrayList<>(); |
|
|
|
gridStaffs.forEach(gs->{ |
|
|
|
if(grid.getGridId().equals(gs.getGridId())){ |
|
|
|
StaffListResultDTO sf = new StaffListResultDTO(); |
|
|
|
sf.setStaffId(gs.getUserId()); |
|
|
|
gridStaffList.add(sf); |
|
|
|
} |
|
|
|
}); |
|
|
|
grid.setGridStaffList(gridStaffList); |
|
|
|
}); |
|
|
|
//4:汇总组织下人员、组织下部门下人员、组织下网格下人员Id集合,调用epmet-user服务查询工作人员基本信息
|
|
|
|
List<String> staffIdList1 = agencyStaffList.stream().map(StaffListResultDTO::getStaffId).collect(Collectors.toList()); |
|
|
|
List<String> staffIdList2 = deptStaffs.stream().map(CustomerStaffDepartmentDTO::getUserId).collect(Collectors.toList()); |
|
|
|
List<String> staffIdList3 = gridStaffs.stream().map(CustomerStaffGridDTO::getUserId).collect(Collectors.toList()); |
|
|
|
List<String> staffIdList = new ArrayList<>(); |
|
|
|
staffIdList.addAll(staffIdList1); staffIdList.addAll(staffIdList2); staffIdList.addAll(staffIdList3); |
|
|
|
staffIdList = new ArrayList<String>(new LinkedHashSet<>(staffIdList)); |
|
|
|
Result<CustomerStaffListResultDTO> userList = epmetUserFeignClient.getCustomerStaffList(staffIdList); |
|
|
|
//5:循环数据,将人员数据放到对应数据结构下
|
|
|
|
CustomerStaffListResultDTO dto = userList.getData(); |
|
|
|
List<StaffListResultDTO> staffList = dto.getStaffList(); |
|
|
|
List<CustomerStaffRoleResultDTO> roleList = dto.getRoleList(); |
|
|
|
//有时间再优化成jdk8的遍历方式
|
|
|
|
//5.1装载组织下人员数据
|
|
|
|
for(StaffListResultDTO sf : agencyStaffList){ |
|
|
|
//人员信息
|
|
|
|
for(StaffListResultDTO stf : staffList){ |
|
|
|
if(sf.getStaffId().equals(stf.getStaffId())){ |
|
|
|
sf = ConvertUtils.sourceToTarget(stf, StaffListResultDTO.class); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//人员角色信息
|
|
|
|
for(CustomerStaffRoleResultDTO role : roleList){ |
|
|
|
if(sf.getStaffId().equals(role.getStaffId())&&CustomerAgencyConstant.AGENCY_LEADER.equals(role.getRoleKey())){ |
|
|
|
sf.setRoleName(role.getRoleName()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//5.2装载组织下部门下人员数据
|
|
|
|
for(DeptListResultDTO dept : departmentList){ |
|
|
|
List<StaffListResultDTO> departmentStaffList = dept.getDepartmentStaffList(); |
|
|
|
for(StaffListResultDTO ds : departmentStaffList){ |
|
|
|
//人员信息
|
|
|
|
for(StaffListResultDTO stf : staffList){ |
|
|
|
if(ds.getStaffId().equals(stf.getStaffId())){ |
|
|
|
ds = ConvertUtils.sourceToTarget(stf, StaffListResultDTO.class); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//人员角色信息
|
|
|
|
for(CustomerStaffRoleResultDTO role : roleList){ |
|
|
|
if(ds.getStaffId().equals(role.getStaffId())&&CustomerAgencyConstant.DEPT_LEADER.equals(role.getRoleKey())){ |
|
|
|
ds.setRoleName(role.getRoleName()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//5.3装载组织下网格下人员数据
|
|
|
|
for(GridListResultDTO grid : gridList){ |
|
|
|
List<StaffListResultDTO> gridStaffList = grid.getGridStaffList(); |
|
|
|
for(StaffListResultDTO gs : gridStaffList){ |
|
|
|
//人员信息
|
|
|
|
for(StaffListResultDTO stf : staffList){ |
|
|
|
if(gs.getStaffId().equals(stf.getStaffId())){ |
|
|
|
gs = ConvertUtils.sourceToTarget(stf, StaffListResultDTO.class); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//人员角色信息
|
|
|
|
for(CustomerStaffRoleResultDTO role : roleList){ |
|
|
|
if(gs.getStaffId().equals(role.getStaffId())&&CustomerAgencyConstant.GRID_MANAGER.equals(role.getRoleKey())){ |
|
|
|
gs.setRoleName(role.getRoleName()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
resultDTO.setAgencyStaffList(agencyStaffList); |
|
|
|
resultDTO.setDepartmentList(departmentList); |
|
|
|
resultDTO.setGridList(gridList); |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
} |