|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author weaver_cl
|
|
|
|
* @Description: TODO
|
|
|
|
* @Date 2022/5/20
|
|
|
|
* @Version V1.0
|
|
|
|
**/
|
|
|
|
public class DepartmentServiceImpl extends Service implements DepartmentService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public PageInfo<SingleDeptTreeVO> getDeptListByPid(QuerySingleDeptListParam param) {
|
|
|
|
|
|
|
|
//1.查询分部下所有部门
|
|
|
|
PageUtil.start(param.getCurrent(), param.getPageSize());
|
|
|
|
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId(param.getParentComp());
|
|
|
|
PageInfo<DepartmentPO> pageInfo = new PageInfo<>(departmentPOS);
|
|
|
|
List<SingleDeptTreeVO> singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS);
|
|
|
|
PageInfo<SingleDeptTreeVO> pageInfos = new PageInfo<>(singleDeptTreeVOS,SingleDeptTreeVO.class);
|
|
|
|
pageInfos.setTotal(pageInfo.getTotal());
|
|
|
|
pageInfos.setPageNum(param.getCurrent());
|
|
|
|
pageInfos.setPageSize(param.getPageSize());
|
|
|
|
|
|
|
|
return pageInfos;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> listPage(DeptSearchParam param) {
|
|
|
|
Map<String, Object> datas = new HashMap<>();
|
|
|
|
PageUtil.start(param.getCurrent(), param.getPageSize());
|
|
|
|
List<DepartmentPO> parentList = getDepartmentMapper().listParent();
|
|
|
|
List<DepartmentPO> list = new ArrayList<>();
|
|
|
|
list.addAll(parentList);
|
|
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(parentList)) {
|
|
|
|
// 递归查询子数据
|
|
|
|
getChildPOs(parentList, list);
|
|
|
|
}
|
|
|
|
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, (long) user.getUID());
|
|
|
|
// 搜索条件过滤数据
|
|
|
|
List<DepartmentPO> filterList = filterListByParams(list, departmentPO);
|
|
|
|
|
|
|
|
List<DepartmentListDTO> departmentListDTOS = DepartmentBO.buildDeptDTOList(list, filterList);
|
|
|
|
PageInfo<DepartmentListDTO> pageInfos = new PageInfo<>(departmentListDTOS, DepartmentListDTO.class);
|
|
|
|
pageInfos.setTotal(pageInfos.getTotal());
|
|
|
|
pageInfos.setPageNum(param.getCurrent());
|
|
|
|
pageInfos.setPageSize(param.getPageSize());
|
|
|
|
|
|
|
|
OrganizationWeaTable<DepartmentListDTO> table = new OrganizationWeaTable<>(user, DepartmentListDTO.class);
|
|
|
|
List<Column> columns = pageInfos.getColumns();
|
|
|
|
List<WeaTableColumn> 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<DepartmentPO> filterListByParams(Collection<DepartmentPO> departmentPOS, DepartmentPO departmentPO) {
|
|
|
|
// 搜索后的数据
|
|
|
|
List<DepartmentPO> filterList = new ArrayList<>();
|
|
|
|
// 筛选数据
|
|
|
|
for (Iterator<DepartmentPO> 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<DepartmentPO> parentList, List<DepartmentPO> list) {
|
|
|
|
List<Long> ids = parentList.stream().map(DepartmentPO::getId).collect(Collectors.toList());
|
|
|
|
List<DepartmentPO> listChild = getDepartmentMapper().listChild(ids);
|
|
|
|
if (CollectionUtils.isNotEmpty(listChild)) {
|
|
|
|
list.addAll(listChild);
|
|
|
|
getChildPOs(listChild, list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|