Commit 7752154f authored by 廖旭伟's avatar 廖旭伟

员工管理花名册功能修改查询当前部门以及子部门员工

parent a421a91f
......@@ -36,5 +36,8 @@ public interface DeptDao extends ICRUDDao<DeptEntity,Long>{
* */
DeptEntity queryDeptParient(String parentCode);
/**
* 查询包含本部门所有下级部门
* */
List<DeptEntity> getAllChildrenDept(Long deptId);
}
......@@ -37,7 +37,10 @@ public class DeptDaoImpl extends BaseCRUDDaoMybatis<DeptEntity,Long> implements
return getSqlSession().selectOne(getSqlId("queryDeptParient"),parentCode);
}
@Override
public List<DeptEntity> getAllChildrenDept(Long deptId) {
return getSqlSession().selectList(getSqlId("getAllChildrenDept"), deptId);
}
}
package com.mortals.xhx.module.dept.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.dept.dao.DeptDao;
......@@ -64,5 +65,10 @@ public interface DeptService extends ICRUDService<DeptEntity, Long> {
*/
Rest<Void> updateDeptNum(Context context);
/**
* 查询包含本部门所有下级部门
* */
List<DeptEntity> getAllChildrenDept(Long deptId) throws AppException;
}
\ No newline at end of file
......@@ -255,5 +255,10 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
return Rest.ok();
}
@Override
public List<DeptEntity> getAllChildrenDept(Long deptId) throws AppException {
return dao.getAllChildrenDept(deptId);
}
}
......@@ -32,4 +32,6 @@ public class StaffVo extends BaseEntityLong {
private List<StaffInfoVo>staffInfoVos;
private List <Long> deptIdList;
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.SecurityUtil;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
......@@ -33,14 +34,12 @@ import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.model.vo.StaffInfoVo;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -263,4 +262,20 @@ public class StaffServiceImpl extends AbstractCRUDCacheServiceImpl<StaffDao, Sta
System.out.println("1" + StrUtil.padPre("125", 7, "0"));
}
@Override
protected StaffEntity findBefore(StaffEntity params, PageInfo pageInfo, Context context) throws AppException {
if(params.getDeptId()!=null){
List<DeptEntity> deptList = deptService.getAllChildrenDept(params.getDeptId());
if(CollectionUtils.isNotEmpty(deptList)){
List<Long> deptIdList = new ArrayList<>();
deptList.forEach(item -> {
deptIdList.add(item.getId());
});
params.setDeptId(null);
params.setDeptIdList(deptIdList);
}
}
return params;
}
}
\ No newline at end of file
......@@ -12,4 +12,20 @@
<select id="queryDeptParentId" resultType="integer">
select parentId from mortals_xhx_dept where deptId = #{deptId}
</select>
<!--查询所有子部门-->
<select id="getAllChildrenDept" resultType="com.mortals.xhx.module.dept.model.DeptEntity">
SELECT * FROM (
SELECT id, parentId, deptName,deptCode,deptStatus FROM mortals_xhx_dept WHERE id = #{deptId}
UNION ALL
SELECT i.id, i.parentId, i.deptName,i.deptCode,i.deptStatus
FROM mortals_xhx_dept i
INNER JOIN (
SELECT * FROM (
SELECT id, parentId, deptName,deptCode,deptStatus FROM mortals_xhx_dept WHERE id = #{deptId}
UNION ALL
SELECT id, parentId, deptName,deptCode,deptStatus FROM mortals_xhx_dept WHERE parentId = #{deptId}
) t1
) t2 ON i.parentId = t2.id
) t3
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment