提交修改
This commit is contained in:
parent
95ecea6fcc
commit
b4dc5b8210
@ -1,11 +1,13 @@
|
|||||||
package com.lz.modules.app.controller;
|
package com.lz.modules.app.controller;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.lz.common.utils.PageUtils;
|
import com.lz.common.utils.PageUtils;
|
||||||
import com.lz.common.utils.R;
|
import com.lz.common.utils.R;
|
||||||
import com.lz.modules.flow.entity.FlowManager;
|
import com.lz.modules.flow.entity.FlowManager;
|
||||||
|
import com.lz.modules.flow.model.FlowDto;
|
||||||
import com.lz.modules.flow.service.FlowManagerService;
|
import com.lz.modules.flow.service.FlowManagerService;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -40,6 +42,11 @@ public class FlowManagerController {
|
|||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/menu/list")
|
||||||
|
public List<FlowDto> menuList(){
|
||||||
|
List<FlowDto> flowDtoList = flowManagerService.getFowList();
|
||||||
|
return flowDtoList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信息
|
* 信息
|
||||||
|
|||||||
30
src/main/java/com/lz/modules/flow/model/FlowDto.java
Normal file
30
src/main/java/com/lz/modules/flow/model/FlowDto.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package com.lz.modules.flow.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FlowDto {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 飞书部门id
|
||||||
|
*/
|
||||||
|
private String departmentId;
|
||||||
|
/**
|
||||||
|
* 飞书上级部门id
|
||||||
|
*/
|
||||||
|
private String departmentParentId;
|
||||||
|
/**
|
||||||
|
* 飞书显示部门人数
|
||||||
|
*/
|
||||||
|
private String realName;
|
||||||
|
/**
|
||||||
|
* 组织架构名称/部门名称
|
||||||
|
*/
|
||||||
|
private String departmentName;
|
||||||
|
|
||||||
|
private List list;
|
||||||
|
|
||||||
|
}
|
||||||
14
src/main/java/com/lz/modules/flow/model/FlowInfo.java
Normal file
14
src/main/java/com/lz/modules/flow/model/FlowInfo.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.lz.modules.flow.model;
|
||||||
|
|
||||||
|
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FlowInfo {
|
||||||
|
private DepartmentsStaffRelateEntity parentDepartmentRelate;
|
||||||
|
|
||||||
|
private List<DepartmentsStaffRelateEntity> list;
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@ package com.lz.modules.flow.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.lz.common.utils.PageUtils;
|
import com.lz.common.utils.PageUtils;
|
||||||
import com.lz.modules.flow.entity.FlowManager;
|
import com.lz.modules.flow.entity.FlowManager;
|
||||||
|
import com.lz.modules.flow.model.FlowDto;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -37,4 +38,6 @@ public interface FlowManagerService extends IService<FlowManager> {
|
|||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
void deleteBatchIds(List<Long> asList);
|
void deleteBatchIds(List<Long> asList);
|
||||||
|
|
||||||
|
List<FlowDto> getFowList();
|
||||||
}
|
}
|
||||||
@ -3,14 +3,27 @@ package com.lz.modules.flow.service.impl;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.lz.common.utils.NumberUtil;
|
import com.lz.common.utils.NumberUtil;
|
||||||
import com.lz.common.utils.PageUtils;
|
import com.lz.common.utils.PageUtils;
|
||||||
|
import com.lz.modules.app.dao.DepartmentsDao;
|
||||||
|
import com.lz.modules.app.dao.StaffDao;
|
||||||
|
import com.lz.modules.app.entity.DepartmentsEntity;
|
||||||
|
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
|
||||||
|
import com.lz.modules.app.entity.StaffEntity;
|
||||||
|
import com.lz.modules.app.service.DepartmentsStaffRelateService;
|
||||||
import com.lz.modules.flow.dao.FlowManagerMapper;
|
import com.lz.modules.flow.dao.FlowManagerMapper;
|
||||||
import com.lz.modules.flow.entity.FlowManager;
|
import com.lz.modules.flow.entity.FlowManager;
|
||||||
|
import com.lz.modules.flow.model.FlowDto;
|
||||||
|
import com.lz.modules.flow.model.FlowInfo;
|
||||||
import com.lz.modules.flow.service.FlowManagerService;
|
import com.lz.modules.flow.service.FlowManagerService;
|
||||||
|
import com.lz.modules.flow.service.RecordRoleService;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -28,6 +41,18 @@ public class FlowManagerServiceImpl extends ServiceImpl<FlowManagerMapper, FlowM
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FlowManagerMapper flowManagerMapper;
|
private FlowManagerMapper flowManagerMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DepartmentsDao departmentsDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DepartmentsStaffRelateService departmentsStaffRelateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StaffDao staffDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RecordRoleService recordRoleService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,5 +105,110 @@ public class FlowManagerServiceImpl extends ServiceImpl<FlowManagerMapper, FlowM
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FlowDto> getFowList() {
|
||||||
|
List<DepartmentsEntity> tDepartments = departmentsDao.selectAll();
|
||||||
|
List<DepartmentsEntity> parentDepartments = tDepartments.stream()
|
||||||
|
//根据两个属性进行过滤
|
||||||
|
.filter(s -> s.getDepartmentParentId().equals("1"))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<DepartmentsStaffRelateEntity> departmentsStaffRelateEntities = departmentsStaffRelateService.selectAll();
|
||||||
|
Map<String, FlowInfo> departmentsStaffRelateEntityMap = new HashMap<>();
|
||||||
|
Map<String, DepartmentsStaffRelateEntity> singleRelateMap = new HashMap<>();
|
||||||
|
|
||||||
|
for(DepartmentsStaffRelateEntity d : departmentsStaffRelateEntities){
|
||||||
|
singleRelateMap.put(d.getDepartmentId(),d);
|
||||||
|
if(new Integer(1).equals(d.getIsLeader())){
|
||||||
|
FlowInfo flowInfo = new FlowInfo();
|
||||||
|
flowInfo.setParentDepartmentRelate(d);
|
||||||
|
List<DepartmentsStaffRelateEntity> list = new ArrayList<>();
|
||||||
|
for(DepartmentsStaffRelateEntity d2 : departmentsStaffRelateEntities){
|
||||||
|
if(d2.getDepartmentId().equals(d.getDepartmentId()) && new Integer(0).equals(d2.getIsLeader())){
|
||||||
|
list.add(d2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flowInfo.setList(list);
|
||||||
|
departmentsStaffRelateEntityMap.put(d.getDepartmentId(),flowInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<StaffEntity> staffEntities = staffDao.selectAll();
|
||||||
|
Map<Long ,StaffEntity> staffMap = new HashMap<>();
|
||||||
|
for(StaffEntity staffEntity : staffEntities){
|
||||||
|
staffMap.put(staffEntity.getId(),staffEntity);
|
||||||
|
}
|
||||||
|
List<FlowDto> list = new ArrayList<>();
|
||||||
|
for (DepartmentsEntity d : parentDepartments) {
|
||||||
|
String realName = getRealName(departmentsStaffRelateEntityMap,staffMap,d.getDepartmentId(),singleRelateMap);
|
||||||
|
FlowDto entity = buildMenuEntity(d.getDepartmentId(),d.getDepartmentName() , "1", realName);
|
||||||
|
List<FlowDto> childList = getMenuList(tDepartments, entity,departmentsStaffRelateEntityMap,staffMap,singleRelateMap);
|
||||||
|
entity.setList(childList);
|
||||||
|
list.add(entity);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public FlowDto buildMenuEntity(String departmentId, String departmentName, String parentId, String realName) {
|
||||||
|
FlowDto flowDto = new FlowDto();
|
||||||
|
flowDto.setDepartmentId(departmentId);
|
||||||
|
flowDto.setDepartmentName(departmentName);
|
||||||
|
flowDto.setDepartmentParentId(parentId);
|
||||||
|
flowDto.setRealName(realName);
|
||||||
|
return flowDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getRealName(Map<String, FlowInfo> departmentsStaffRelateEntityMap, Map<Long, StaffEntity> staffMap, String departmentId
|
||||||
|
, Map<String, DepartmentsStaffRelateEntity> singleRelateMap) {
|
||||||
|
FlowInfo flowInfo = departmentsStaffRelateEntityMap.get(departmentId);
|
||||||
|
if (flowInfo != null) {
|
||||||
|
return doGetRealName(flowInfo.getParentDepartmentRelate(), staffMap);
|
||||||
|
} else {
|
||||||
|
return doGetRealName(singleRelateMap.get(departmentId), staffMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String doGetRealName(DepartmentsStaffRelateEntity departmentsStaffRelateEntity, Map<Long, StaffEntity> staffMap) {
|
||||||
|
if (departmentsStaffRelateEntity != null) {
|
||||||
|
StaffEntity staffEntity = staffMap.get(departmentsStaffRelateEntity.getStaffId());
|
||||||
|
if (staffEntity != null) {
|
||||||
|
return staffEntity.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FlowDto> getMenuList(List<DepartmentsEntity> tDepartments,FlowDto flowDto,
|
||||||
|
Map<String,FlowInfo> departmentsStaffRelateEntityMap, Map<Long ,StaffEntity> staffMap
|
||||||
|
,Map<String, DepartmentsStaffRelateEntity> singleRelateMap) {
|
||||||
|
List<FlowDto> flowDtos = new ArrayList<>();
|
||||||
|
for(DepartmentsEntity child : tDepartments) {
|
||||||
|
if (child.getDepartmentParentId().equals(flowDto.getDepartmentId())) {
|
||||||
|
FlowDto entity = buildMenuEntity(child.getDepartmentId(),
|
||||||
|
child.getDepartmentName(), flowDto.getDepartmentId(),
|
||||||
|
getRealName(departmentsStaffRelateEntityMap, staffMap, child.getDepartmentId(),singleRelateMap));
|
||||||
|
List<FlowDto> list = getMenuList(tDepartments, entity, departmentsStaffRelateEntityMap, staffMap,singleRelateMap);
|
||||||
|
if (CollectionUtils.isEmpty(list) || list.size() == 0) {
|
||||||
|
FlowInfo flowInfo = departmentsStaffRelateEntityMap.get(child.getDepartmentId());
|
||||||
|
if (flowInfo != null && CollectionUtils.isNotEmpty(flowInfo.getList()) && flowInfo.getList().size() > 0) {
|
||||||
|
list = new ArrayList<>();
|
||||||
|
for (DepartmentsStaffRelateEntity dr : flowInfo.getList()) {
|
||||||
|
StaffEntity staffEntity = staffMap.get(dr.getStaffId());
|
||||||
|
FlowDto childEntiry = buildMenuEntity(dr.getDepartmentId() + "_" + dr.getStaffId(),
|
||||||
|
staffEntity != null ? staffEntity.getName() : "",
|
||||||
|
entity.getDepartmentId(),
|
||||||
|
"");
|
||||||
|
list.add(childEntiry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entity.setList(list);
|
||||||
|
flowDtos.add(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flowDtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user