From d13dbdc42d2869dc2445a1df0f0e348512ea818b Mon Sep 17 00:00:00 2001 From: quyixiao <2621048238@qq.com> Date: Wed, 23 Sep 2020 11:22:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lz/modules/app/entity/StaffEntity.java | 9 +++++ .../com/lz/modules/flow/model/FlowDto.java | 2 +- .../service/impl/FlowManagerServiceImpl.java | 37 ++++++++++--------- src/main/resources/mapper/sys/SysUserDao.xml | 2 +- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/lz/modules/app/entity/StaffEntity.java b/src/main/java/com/lz/modules/app/entity/StaffEntity.java index c04b2820..3d22e43d 100644 --- a/src/main/java/com/lz/modules/app/entity/StaffEntity.java +++ b/src/main/java/com/lz/modules/app/entity/StaffEntity.java @@ -19,6 +19,15 @@ import lombok.Data; public class StaffEntity implements Serializable { private static final long serialVersionUID = 1L; + public StaffEntity() { + + } + + public StaffEntity(Long id,String name) { + this.id = id; + this.name = name; + } + /** * 自增主键 */ diff --git a/src/main/java/com/lz/modules/flow/model/FlowDto.java b/src/main/java/com/lz/modules/flow/model/FlowDto.java index e3ddba70..ed533cd1 100644 --- a/src/main/java/com/lz/modules/flow/model/FlowDto.java +++ b/src/main/java/com/lz/modules/flow/model/FlowDto.java @@ -24,7 +24,7 @@ public class FlowDto { * 组织架构名称/部门名称 */ private String departmentName; - + private Long staffId; private List list; } diff --git a/src/main/java/com/lz/modules/flow/service/impl/FlowManagerServiceImpl.java b/src/main/java/com/lz/modules/flow/service/impl/FlowManagerServiceImpl.java index 9dde4f6d..78a1baaa 100644 --- a/src/main/java/com/lz/modules/flow/service/impl/FlowManagerServiceImpl.java +++ b/src/main/java/com/lz/modules/flow/service/impl/FlowManagerServiceImpl.java @@ -137,10 +137,11 @@ public class FlowManagerServiceImpl extends ServiceImpl list = new ArrayList<>(); for (DepartmentsEntity d : parentDepartments) { - String realName = getRealName(departmentsStaffRelateEntityMap,staffMap,d.getDepartmentId(),singleRelateMap); - FlowDto entity = buildMenuEntity(d.getDepartmentId(),d.getDepartmentName() , "1", realName); + StaffEntity staff = getStaff(departmentsStaffRelateEntityMap,staffMap,d.getDepartmentId(),singleRelateMap); + FlowDto entity = buildMenuEntity(d.getDepartmentId(),d.getDepartmentName() , "1", staff.getName(),staff.getId()); List childList = getMenuList(tDepartments, entity,departmentsStaffRelateEntityMap,staffMap,singleRelateMap); entity.setList(childList); list.add(entity); @@ -149,46 +150,48 @@ public class FlowManagerServiceImpl extends ServiceImpl departmentsStaffRelateEntityMap, Map staffMap, String departmentId + public StaffEntity getStaff(Map departmentsStaffRelateEntityMap, Map staffMap, String departmentId , Map singleRelateMap) { FlowInfo flowInfo = departmentsStaffRelateEntityMap.get(departmentId); if (flowInfo != null) { - return doGetRealName(flowInfo.getParentDepartmentRelate(), staffMap); + return doGetStaff(flowInfo.getParentDepartmentRelate(), staffMap); } else { - return doGetRealName(singleRelateMap.get(departmentId), staffMap); + return doGetStaff(singleRelateMap.get(departmentId), staffMap); } } - public String doGetRealName(DepartmentsStaffRelateEntity departmentsStaffRelateEntity, Map staffMap) { + public StaffEntity doGetStaff(DepartmentsStaffRelateEntity departmentsStaffRelateEntity, Map staffMap) { if (departmentsStaffRelateEntity != null) { StaffEntity staffEntity = staffMap.get(departmentsStaffRelateEntity.getStaffId()); if (staffEntity != null) { - return staffEntity.getName(); + return staffEntity; } } - return ""; + return new StaffEntity(0l,""); } public List getMenuList(List tDepartments,FlowDto flowDto, - Map departmentsStaffRelateEntityMap, Map staffMap - ,Map singleRelateMap) { + Map departmentsStaffRelateEntityMap, Map staffMap + , Map singleRelateMap) { List flowDtos = new ArrayList<>(); - for(DepartmentsEntity child : tDepartments) { + for (DepartmentsEntity child : tDepartments) { if (child.getDepartmentParentId().equals(flowDto.getDepartmentId())) { + StaffEntity staff = getStaff(departmentsStaffRelateEntityMap, staffMap, child.getDepartmentId(), singleRelateMap); FlowDto entity = buildMenuEntity(child.getDepartmentId(), - child.getDepartmentName(), flowDto.getDepartmentId(), - getRealName(departmentsStaffRelateEntityMap, staffMap, child.getDepartmentId(),singleRelateMap)); - List list = getMenuList(tDepartments, entity, departmentsStaffRelateEntityMap, staffMap,singleRelateMap); + child.getDepartmentName(), flowDto.getDepartmentId(), staff.getName(),staff.getId()); + + List 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) { @@ -196,9 +199,9 @@ public class FlowManagerServiceImpl extends ServiceImpl