diff --git a/src/com/engine/organization/entity/department/bo/DepartmentBO.java b/src/com/engine/organization/entity/department/bo/DepartmentBO.java index da7bae34..df1d5b60 100644 --- a/src/com/engine/organization/entity/department/bo/DepartmentBO.java +++ b/src/com/engine/organization/entity/department/bo/DepartmentBO.java @@ -1,5 +1,7 @@ package com.engine.organization.entity.department.bo; +import com.engine.organization.entity.department.dto.DepartmentListDTO; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import com.engine.organization.mapper.department.DepartmentMapper; @@ -7,8 +9,7 @@ import com.engine.organization.mapper.employee.EmployeeMapper; import com.engine.organization.util.db.MapperProxyFactory; import org.apache.commons.collections.CollectionUtils; -import java.util.Collections; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -19,7 +20,62 @@ import java.util.stream.Collectors; **/ public class DepartmentBO { - public static List buildSingleDeptTreeVOS(List departmentPOs) { + public static List buildDeptDTOList(Collection list, List filterList) { + // 搜索结果为空,直接返回空 + if (CollectionUtils.isEmpty(filterList)) { + return Collections.emptyList(); + } + // 递归添加父级数据 + Map poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item)); + List addedList = new ArrayList<>(); + for (DepartmentPO po : filterList) { + dealParentData(addedList, po, poMaps); + } + + List dtoList = addedList.stream().map(e -> DepartmentListDTO.builder() + .id(e.getId()) + .deptNo(e.getDeptNo()) + .deptName(e.getDeptName()) + .deptNameShort(e.getDeptNameShort()) + .parentComp(e.getParentComp() + "")// 命名 + .parentDept(e.getParentDept()) + .parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept()).getDeptName()) + .deptPrincipal(getEmployeeNameById((long) e.getDeptPrincipal())) + .showOrder(e.getShowOrder()) + .forbiddenTag(e.getForbiddenTag()) + .build() + ).collect(Collectors.toList()); + Map> collects = dtoList.stream().filter(item -> null != item.getParentDept() && 0 != item.getParentDept()).collect(Collectors.groupingBy(DepartmentListDTO::getParentDept)); + System.out.println(collects); + return dtoList.stream().map(e -> { + System.out.println(e.getId()); + System.out.println(collects.get(e.getId())); + e.setChildren(collects.get(e.getId())); + return e; + }).filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).collect(Collectors.toList()); + } + + public static DepartmentPO convertParamsToPO(DeptSearchParam param, Long employeeId) { + if (null == param) { + return null; + } + return DepartmentPO.builder() + .id(param.getId() == null ? 0 : param.getId()) + .deptNo(param.getDeptNo()) + .deptName(param.getDeptName()) + .deptNameShort(param.getDeptNameShort()) + .parentComp(param.getParentComp()) + .parentDept(param.getParentDept()) + .deptPrincipal(param.getDeptPrincipal()) + .showOrder(param.getShowOrder()) + .forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1) + .deleteType(0) + .createTime(new Date()) + .updateTime(new Date()) + .creator(employeeId).build(); + } + + public static List buildSingleDeptTreeVOS(List departmentPOs) { if (CollectionUtils.isEmpty(departmentPOs)) { return Collections.emptyList(); @@ -29,7 +85,7 @@ public class DepartmentBO { List singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder() .id(e.getId()) .deptName(e.getDeptName()) - .parentDeptName(getDeptNameById(e.getParentDept())) + .parentDeptName(getDeptNameById(e.getParentDept().intValue())) .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) .children(recursiveData(e.getId())) .build() @@ -40,8 +96,8 @@ public class DepartmentBO { } - public static String getDeptNameById(int id) { - return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(id); + public static String getDeptNameById(Integer id) { + return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(id); } public static String getEmployeeNameById(Long id) { @@ -49,8 +105,26 @@ public class DepartmentBO { } + /** + * 递归获取查询后数据的父级数据 + * + * @param addedList + * @param po + * @param poMaps + */ + private static void dealParentData(List addedList, DepartmentPO po, Map poMaps) { + if (!addedList.contains(po)) { + addedList.add(po); + } + DepartmentPO parentPO = poMaps.get(po.getParentDept()); + if (null != parentPO) { + dealParentData(addedList, parentPO, poMaps); + } + } + /** * 递归获取 + * * @param parentDeptId * @return */ @@ -61,17 +135,16 @@ public class DepartmentBO { } List singleDeptTreeVOS = departmentPOS.stream().map(e -> SingleDeptTreeVO.builder() - .id(e.getId()) - .deptName(e.getDeptName()) - .parentDeptName(getDeptNameById(e.getParentDept())) - .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) - .children(recursiveData(e.getId())) - .build() - ).collect(Collectors.toList()); + .id(e.getId()) + .deptName(e.getDeptName()) + .parentDeptName(getDeptNameById(e.getParentDept().intValue())) + .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())) + .children(recursiveData(e.getId())) + .build() + ).collect(Collectors.toList()); return singleDeptTreeVOS; } - } diff --git a/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java b/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java new file mode 100644 index 00000000..1731a5da --- /dev/null +++ b/src/com/engine/organization/entity/department/dto/DepartmentListDTO.java @@ -0,0 +1,98 @@ +package com.engine.organization.entity.department.dto; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.organization.annotation.OrganizationTable; +import com.engine.organization.annotation.OrganizationTableOperate; +import com.engine.organization.annotation.TableTitle; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @Author weaver_cl + * @Description: TODO + * @Date 2022/5/19 + * @Version V1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@OrganizationTable(pageId = "96f2bb0d-da73-11ec-a0da-00ffcbed7508", + tableType = WeaTableType.NONE, + operates = { + @OrganizationTableOperate(index = "0", text = "编辑"), + @OrganizationTableOperate(index = "1", text = "删除"), + @OrganizationTableOperate(index = "2", text = "合并"), + @OrganizationTableOperate(index = "3", text = "转移"), + @OrganizationTableOperate(index = "4", text = "联查岗位"), + @OrganizationTableOperate(index = "4", text = "联查人员") + }) +public class DepartmentListDTO { + + private Long id; + + /** + * 编号 + */ + @TableTitle(title = "编号", dataIndex = "deptNo", key = "deptNo") + private String deptNo; + + /** + * 名称 + */ + @TableTitle(title = "名称", dataIndex = "deptName", key = "deptName") + private String deptName; + + /** + * 简称 + */ + @TableTitle(title = "简称", dataIndex = "deptNameShort", key = "deptNameShort") + private String deptNameShort; + + /** + * 所属分部 + */ + @TableTitle(title = "所属分部", dataIndex = "parentComp", key = "parentComp") + private String parentComp; + + /** + * 上级部门 + */ + @TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName") + private String parentDeptName; + + private Long parentDept; + + /** + * 部门负责人 + */ + @TableTitle(title = "部门负责人", dataIndex = "deptPrincipal", key = "deptPrincipal") + private String deptPrincipal; + + /** + * 显示顺序 + */ + @TableTitle(title = "显示顺序", dataIndex = "showOrder", key = "showOrder") + private int showOrder; + + /** + * 说明 + */ + @TableTitle(title = "说明", dataIndex = "description", key = "description") + private String description; + + /** + * 禁用标记 + */ + @TableTitle(title = "禁用标记", dataIndex = "forbiddenTag", key = "forbiddenTag") + private int forbiddenTag; + + /** + * 子节点 + */ + private List children; +} diff --git a/src/com/engine/organization/entity/department/param/DeptSearchParam.java b/src/com/engine/organization/entity/department/param/DeptSearchParam.java new file mode 100644 index 00000000..75004134 --- /dev/null +++ b/src/com/engine/organization/entity/department/param/DeptSearchParam.java @@ -0,0 +1,37 @@ +package com.engine.organization.entity.department.param; + +import com.engine.organization.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/23 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DeptSearchParam extends BaseQueryParam { + private Long id; + + private String deptNo; + + private String deptName; + + private String deptNameShort; + + private Long parentComp; + + private Long parentDept; + + private Integer deptPrincipal; + + private Integer showOrder; + + private Boolean forbiddenTag; +} diff --git a/src/com/engine/organization/entity/department/po/DepartmentPO.java b/src/com/engine/organization/entity/department/po/DepartmentPO.java index e06c1a0b..512b0367 100644 --- a/src/com/engine/organization/entity/department/po/DepartmentPO.java +++ b/src/com/engine/organization/entity/department/po/DepartmentPO.java @@ -27,17 +27,17 @@ public class DepartmentPO { private String deptNameShort; - private int parentComp; + private Long parentComp; - private int parentDept; + private Long parentDept; - private int deptPrincipal; //部门负责人 + private Integer deptPrincipal; //部门负责人 - private int showOrder; + private Integer showOrder; private String description; - private int forbiddenTag; + private Integer forbiddenTag; private Long creator; diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.java b/src/com/engine/organization/mapper/department/DepartmentMapper.java index cbf2912b..f11d7f57 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.java +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.java @@ -3,6 +3,7 @@ package com.engine.organization.mapper.department; import com.engine.organization.entity.department.po.DepartmentPO; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; /** @@ -15,7 +16,26 @@ public interface DepartmentMapper { List getDeptListByCompId(@Param("parentComp") int parentComp); - List getDeptListByPId(@Param("PId")Long PId); + List getDeptListByPId(@Param("PId") Long PId); - String getDeptNameById(@Param("id")int id); + List getDeptList(DepartmentPO departmentPO); + + /** + * 获取顶级数据 + * + * @return + */ + List listParent(); + + /** + * 获取子层级数据 + * + * @param ids + * @return + */ + List listChild(@Param("ids") Collection ids); + + DepartmentPO getDeptById(@Param("id") int id); + + String getDeptNameById(@Param("id") int id); } diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.xml b/src/com/engine/organization/mapper/department/DepartmentMapper.xml index 49ecedaa..9b022ad2 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.xml +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.xml @@ -1,20 +1,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + and t.dept_no like CONCAT('%',#{deptNo},'%') + + + and t.dept_name like CONCAT('%',#{deptName},'%') + + + and t.dept_name_short like CONCAT('%',#{deptNameShort},'%') + + + + + + and t.dept_no like '%'||#{deptNo}||'%' + + + and t.dept_name like '%'||#{deptName}||'%' + + + and t.dept_name_short like '%'||#{deptNameShort}||'%' + + + + + + and t.dept_no like '%'+#{deptNo}+'%' + + + and t.dept_name like '%'+#{deptName}+'%' + + + and t.dept_name_short like '%'+#{deptNameShort}+'%' + + + + + and ifnull(parent_dept,'0')='0' + + + + and isnull(parent_dept,'0')='0' + + + + and NVL(parent_dept,'0')='0' + \ No newline at end of file diff --git a/src/com/engine/organization/service/DepartmentService.java b/src/com/engine/organization/service/DepartmentService.java index 0a32073b..13cc9d5a 100644 --- a/src/com/engine/organization/service/DepartmentService.java +++ b/src/com/engine/organization/service/DepartmentService.java @@ -1,9 +1,12 @@ package com.engine.organization.service; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.param.QuerySingleDeptListParam; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import com.engine.organization.util.page.PageInfo; +import java.util.Map; + /** * @Author weaver_cl * @Description: TODO @@ -15,8 +18,19 @@ public interface DepartmentService { /** * 根据分部id获取部门tree * 联查部门 + * * @param param * @return */ PageInfo getDeptListByPid(QuerySingleDeptListParam param); + + /** + * 列表数据展示 + * + * @param param + * @return + */ + public Map listPage(DeptSearchParam param); + + } diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 78d72c6c..18186055 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -91,8 +91,10 @@ public class CompServiceImpl extends Service implements CompService { List list = new ArrayList<>(); list.addAll(parentList); - // 递归查询子数据 - getChildPOs(parentList, list); + if (CollectionUtils.isNotEmpty(parentList)) { + // 递归查询子数据 + getChildPOs(parentList, list); + } CompPO compPO = CompBO.convertParamToPO(params, (long) user.getUID()); // 搜索条件过滤数据 diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index 3fdfca59..f6b4ffe8 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -1,17 +1,26 @@ package com.engine.organization.service.impl; +import com.cloudstore.eccom.pc.table.WeaTableColumn; +import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; +import com.engine.organization.component.OrganizationWeaTable; import com.engine.organization.entity.department.bo.DepartmentBO; +import com.engine.organization.entity.department.dto.DepartmentListDTO; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.param.QuerySingleDeptListParam; import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.service.DepartmentService; import com.engine.organization.util.db.MapperProxyFactory; +import com.engine.organization.util.page.Column; import com.engine.organization.util.page.PageInfo; import com.engine.organization.util.page.PageUtil; +import org.apache.commons.collections4.CollectionUtils; +import weaver.general.StringUtil; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * @Author weaver_cl @@ -20,20 +29,106 @@ import java.util.List; * @Version V1.0 **/ public class DepartmentServiceImpl extends Service implements DepartmentService { - + private DepartmentMapper getDepartmentMapper() { + return MapperProxyFactory.getProxy(DepartmentMapper.class); + } @Override public PageInfo getDeptListByPid(QuerySingleDeptListParam param) { //1.查询分部下所有部门 - PageUtil.start(param.getCurrent(),param.getPageSize()); + PageUtil.start(param.getCurrent(), param.getPageSize()); List departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId(param.getParentComp()); List singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS); - PageInfo pageInfos = new PageInfo<>(singleDeptTreeVOS,SingleDeptTreeVO.class); + PageInfo pageInfos = new PageInfo<>(singleDeptTreeVOS, SingleDeptTreeVO.class); pageInfos.setTotal(departmentPOS.size()); pageInfos.setPageNum(param.getCurrent()); pageInfos.setPageSize(param.getPageSize()); return pageInfos; } + + @Override + public Map listPage(DeptSearchParam param) { + Map datas = new HashMap<>(); + PageUtil.start(param.getCurrent(), param.getPageSize()); + List parentList = getDepartmentMapper().listParent(); + List list = new ArrayList<>(); + list.addAll(parentList); + + if(CollectionUtils.isNotEmpty(parentList)) { + // 递归查询子数据 + getChildPOs(parentList, list); + } + DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, (long) user.getUID()); + // 搜索条件过滤数据 + List filterList = filterListByParams(list, departmentPO); + + List departmentListDTOS = DepartmentBO.buildDeptDTOList(list, filterList); + PageInfo pageInfos = new PageInfo<>(departmentListDTOS, DepartmentListDTO.class); + pageInfos.setTotal(pageInfos.getTotal()); + pageInfos.setPageNum(param.getCurrent()); + pageInfos.setPageSize(param.getPageSize()); + + OrganizationWeaTable table = new OrganizationWeaTable<>(user, DepartmentListDTO.class); + List columns = pageInfos.getColumns(); + List weaTableColumn = columns.stream().map(v -> new WeaTableColumn("100", v.getTitle(), v.getKey())).collect(Collectors.toList()); + + + table.setColumns(weaTableColumn); + + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + + + datas.put("pageInfo", pageInfos); + datas.put("dataKey", result.getResultMap()); + return datas; + } + + /** + * 通过搜索条件过滤list数据 + * + * @param departmentPOS + * @param departmentPO + * @return + */ + private List filterListByParams(Collection departmentPOS, DepartmentPO departmentPO) { + // 搜索后的数据 + List filterList = new ArrayList<>(); + // 筛选数据 + for (Iterator iterator = departmentPOS.iterator(); iterator.hasNext(); ) { + DepartmentPO next = iterator.next(); + boolean isAdd = (StringUtil.isEmpty(departmentPO.getDeptName()) || next.getDeptName().contains(departmentPO.getDeptName())) // 名称 + && (StringUtil.isEmpty(departmentPO.getDeptNo()) || next.getDeptNo().contains(departmentPO.getDeptNo()))//编号 + && (StringUtil.isEmpty(departmentPO.getDeptNameShort()) || next.getDeptNameShort().contains(departmentPO.getDeptNameShort()))//简称 + && (null == departmentPO.getParentComp() || next.getParentComp().equals(departmentPO.getParentComp()))//所属分部 + && (null == departmentPO.getParentDept() || next.getParentDept().equals(departmentPO.getParentDept()))//上级部门 + && (null == departmentPO.getDeptPrincipal() || next.getDeptPrincipal().equals(departmentPO.getDeptPrincipal()))//部门负责人 + && (null == departmentPO.getShowOrder() || next.getShowOrder().equals(departmentPO.getShowOrder()))//显示顺序 + && (null == departmentPO.getForbiddenTag() || next.getForbiddenTag().equals(departmentPO.getForbiddenTag()));//禁用标记 + + if (isAdd) { + filterList.add(next); + } + + } + return filterList; + } + + /** + * 递归获取子级数据 + * + * @param parentList + * @param list + */ + private void getChildPOs(List parentList, List list) { + List ids = parentList.stream().map(DepartmentPO::getId).collect(Collectors.toList()); + List listChild = getDepartmentMapper().listChild(ids); + if (CollectionUtils.isNotEmpty(listChild)) { + list.addAll(listChild); + getChildPOs(listChild, list); + } + } } diff --git a/src/com/engine/organization/web/DepartmentController.java b/src/com/engine/organization/web/DepartmentController.java index d8b05372..3edd5bc3 100644 --- a/src/com/engine/organization/web/DepartmentController.java +++ b/src/com/engine/organization/web/DepartmentController.java @@ -1,6 +1,7 @@ package com.engine.organization.web; import com.engine.common.util.ServiceUtil; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.param.QuerySingleDeptListParam; import com.engine.organization.util.response.ReturnResult; import com.engine.organization.wrapper.DepartmentWrapper; @@ -25,20 +26,40 @@ import javax.ws.rs.core.MediaType; public class DepartmentController { private DepartmentWrapper getDepartmentWrapper(User user) { - return ServiceUtil.getService(DepartmentWrapper.class,user); + return ServiceUtil.getService(DepartmentWrapper.class, user); } @POST @Path("/getDeptListByPid") @Produces(MediaType.APPLICATION_JSON) - public ReturnResult getDeptListByPid(@Context HttpServletRequest request, @Context HttpServletResponse response, - @RequestBody QuerySingleDeptListParam querySingleDeptListParam) { + public ReturnResult getDeptListByPid(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody QuerySingleDeptListParam querySingleDeptListParam) { try { User user = HrmUserVarify.getUser(request, response); return getDepartmentWrapper(user).getDeptListByPid(querySingleDeptListParam); - }catch (Exception e) { + } catch (Exception e) { return ReturnResult.exceptionHandle(e.getMessage()); } } + + /** + * 获取list列表 + * + * @param request + * @param response + * @param params + * @return + */ + @POST + @Path("/listDept") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult listDept(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DeptSearchParam params) { + try { + User user = HrmUserVarify.getUser(request, response); + return ReturnResult.successed(getDepartmentWrapper(user).listPage(params)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + } diff --git a/src/com/engine/organization/webservice/CustomBrowserService.java b/src/com/engine/organization/webservice/CustomBrowserService.java new file mode 100644 index 00000000..d6086e7f --- /dev/null +++ b/src/com/engine/organization/webservice/CustomBrowserService.java @@ -0,0 +1,30 @@ +package com.engine.organization.webservice; + +import com.engine.organization.entity.comp.po.CompPO; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import java.util.List; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/23 + * @version: 1.0 + */ +@WebService +public interface CustomBrowserService { + + + /** + * 公司/分部 树形列表 + * 只获取未删除且启用的数据 + * + * @return + */ + @WebMethod( + operationName = "getCompTreeList", + action = "com.engine.organization.webservice.CustomBrowserService.getCompTreeList" + ) + List getCompTreeList(); +} diff --git a/src/com/engine/organization/webservice/CustomBrowserServiceImpl.java b/src/com/engine/organization/webservice/CustomBrowserServiceImpl.java new file mode 100644 index 00000000..94c0d1e1 --- /dev/null +++ b/src/com/engine/organization/webservice/CustomBrowserServiceImpl.java @@ -0,0 +1,53 @@ +package com.engine.organization.webservice; + +import com.engine.organization.entity.comp.po.CompPO; +import com.engine.organization.mapper.comp.CompMapper; +import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/05/23 + * @version: 1.0 + */ +public class CustomBrowserServiceImpl implements CustomBrowserService { + private CompMapper getCompMapper() { + return MapperProxyFactory.getProxy(CompMapper.class); + } + + @Override + public List getCompTreeList() { + // 获取所有启用数据 + List allList = getCompMapper().list().stream().filter(item -> 0 == item.getForbiddenTag()).collect(Collectors.toList()); + + List parentList = allList.stream().filter(item -> (null == item.getParentCompany() || 0 == item.getParentCompany())).collect(Collectors.toList()); + Map> compMap = allList.stream().filter(item -> (null != item.getParentCompany() && 0 != item.getParentCompany())).collect(Collectors.groupingBy(CompPO::getParentCompany)); + List returnList = new ArrayList<>(); + dealChildren(parentList, returnList, compMap); + + return returnList; + } + + /** + * 处理分部子节点 + * + * @param parentList + * @param returnList + * @param compMap + */ + private void dealChildren(List parentList, List returnList, Map> compMap) { + if (CollectionUtils.isEmpty(parentList)) { + return; + } + for (CompPO compPO : parentList) { + returnList.add(compPO); + dealChildren(compMap.get(compPO.getId()), returnList, compMap); + } + } +} diff --git a/src/com/engine/organization/wrapper/DepartmentWrapper.java b/src/com/engine/organization/wrapper/DepartmentWrapper.java index 114d5c50..5167cbd1 100644 --- a/src/com/engine/organization/wrapper/DepartmentWrapper.java +++ b/src/com/engine/organization/wrapper/DepartmentWrapper.java @@ -2,6 +2,7 @@ package com.engine.organization.wrapper; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.organization.entity.department.param.DeptSearchParam; import com.engine.organization.entity.department.param.QuerySingleDeptListParam; import com.engine.organization.service.DepartmentService; import com.engine.organization.service.impl.DepartmentServiceImpl; @@ -10,6 +11,8 @@ import com.engine.organization.util.response.ReturnResult; import com.engine.organization.entity.department.vo.SingleDeptTreeVO; import weaver.hrm.User; +import java.util.Map; + /** * @Author weaver_cl * @Description: TODO @@ -19,11 +22,21 @@ import weaver.hrm.User; public class DepartmentWrapper extends Service { public DepartmentService getDepartmentService(User user) { - return ServiceUtil.getService(DepartmentServiceImpl.class,user); + return ServiceUtil.getService(DepartmentServiceImpl.class, user); } public ReturnResult getDeptListByPid(QuerySingleDeptListParam param) { PageInfo singleDeptTreeVOS = getDepartmentService(user).getDeptListByPid(param); return ReturnResult.successed(singleDeptTreeVOS); } + + /** + * 列表数据展示 + * + * @param param + * @return + */ + public Map listPage(DeptSearchParam param) { + return getDepartmentService(user).listPage(param); + } }