| | |
| | | import org.springblade.modules.jurisdiction.entity.Jurisdiction; |
| | | import org.springblade.modules.jurisdiction.service.JurisdictionService; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.mapper.DeptMapper; |
| | | import org.springblade.modules.system.node.TreeNode; |
| | | import org.springblade.modules.system.node.TreeNodes; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.vo.DeptVO; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | | import org.springblade.modules.system.wrapper.DeptWrapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | * @author Chill |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDeptService { |
| | | private static final String TENANT_ID = "tenantId"; |
| | | private static final String PARENT_ID = "parentId"; |
| | | |
| | | private final IInformationService iInformationService; |
| | | @Autowired |
| | | private IInformationService iInformationService; |
| | | |
| | | private final JurisdictionService jurisdictionService; |
| | | @Autowired |
| | | private JurisdictionService jurisdictionService; |
| | | |
| | | @Override |
| | | public List<DeptVO> lazyList(String tenantId, Long parentId, Map<String, Object> param) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<DeptVO> lazyTree(String tenantId, Long parentId) { |
| | | if (AuthUtil.isAdministrator()) { |
| | | tenantId = StringPool.EMPTY; |
| | | public List<DeptVO> lazyTree(String tenantId, Long parentId,String userId) { |
| | | // if (AuthUtil.isAdministrator()) { |
| | | // tenantId = StringPool.EMPTY; |
| | | // } |
| | | //获取用户信息,保安,民警 |
| | | if (null!=userId && !userId.equals("")) { |
| | | UserVO user = baseMapper.getUserInfoById(userId); |
| | | if (user.getRoleAlias().equals("公安管理员") || user.getRoleAlias().equals("民警")){ |
| | | //公安管理员又分,如果是派出所,只返回当前值 |
| | | if (user.getDeptName().contains("派出所")){ |
| | | return ForestNodeMerger.merge(baseMapper.lazyTreeCityOne(tenantId, parentId)); |
| | | }else { |
| | | //市局,区级 |
| | | Dept dept = this.getById(parentId); |
| | | if (null != dept) { |
| | | if (dept.getParentId().equals(1123598813738675201L)) { |
| | | return ForestNodeMerger.merge(baseMapper.lazyTreeCity(tenantId, parentId)); |
| | | } |
| | | if (dept.getParentId().equals(0L)){ |
| | | //南昌市公安局 |
| | | return ForestNodeMerger.merge(baseMapper.lazyTreeByJurisdiction()); |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | //保安公司 |
| | | return ForestNodeMerger.merge(baseMapper.securityLazyTree(null, parentId)); |
| | | } |
| | | } |
| | | return ForestNodeMerger.merge(baseMapper.lazyTree(tenantId, parentId)); |
| | | //admin |
| | | return ForestNodeMerger.merge(baseMapper.lazyTree(tenantId, parentId,null)); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeptVO> lazyTrees() { |
| | | return ForestNodeMerger.merge(baseMapper.lazyTrees()); |
| | |
| | | |
| | | @Override |
| | | public List<Map<Object,String>> selectCount(String name) { |
| | | return baseMapper.selectCount(name); |
| | | return baseMapper.getCount(name); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * 懒加载获取部门树形结构,不包含顶级管理员公安局 |
| | | */ |
| | | @Override |
| | | public List<DeptVO> securityLazyTree(String jurisdiction, Long parentId) { |
| | | public List<DeptVO> securityLazyTree(String jurisdiction, Long parentId,Long deptId) { |
| | | //如果传了deptId |
| | | if (null!=deptId){ |
| | | //递归查询 |
| | | // recursionDeptInfo(deptVOS, list); |
| | | //tree 组装并返回 |
| | | return ForestNodeMerger.merge(baseMapper.securityDeptUnitList(null,deptId)); |
| | | } |
| | | return ForestNodeMerger.merge(baseMapper.securityLazyTree(jurisdiction, parentId)); |
| | | } |
| | | |
| | | /** |
| | | * 递归查询子级菜单 |
| | | * @param deptVOS |
| | | * @param list |
| | | * @return |
| | | */ |
| | | private List<DeptVO> recursionDeptInfo(List<DeptVO> deptVOS,List<DeptVO> list) { |
| | | //如果有子级 |
| | | if (list.size()>0){ |
| | | deptVOS.addAll(list); |
| | | //遍历子级 |
| | | for (int i = 0; i < list.size(); i++) { |
| | | //查看是否有子级 |
| | | List<DeptVO> childList = baseMapper.securityDeptUnitList(list.get(i).getId(), null); |
| | | //如果有 |
| | | if (childList.size()>0){ |
| | | //递归 |
| | | recursionDeptInfo(deptVOS,childList); |
| | | } |
| | | } |
| | | } |
| | | return deptVOS; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<DeptVO> selectInfos() { |
| | | return baseMapper.selectInfos(); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeptVo> selDeptList() { |
| | | return baseMapper.selDeptList(); |
| | | } |
| | |
| | | public List<DeptVO> lazyTreeJurisdiction(String jurisdiction, Long parentId) { |
| | | return ForestNodeMerger.merge(baseMapper.lazyTreeJurisdiction(jurisdiction,parentId)); |
| | | } |
| | | |
| | | /** |
| | | * 懒加载获取单位树,电子围栏用 |
| | | * @param type 1:本单位 2:分公司 3:服务单位 |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DeptVO> lazyTreeRail(Integer type, Long deptId) { |
| | | //查询本单位 |
| | | if(type==1 || type==2){ |
| | | return ForestNodeMerger.merge(baseMapper.securityDeptUnitList(null,deptId)); |
| | | } |
| | | return ForestNodeMerger.merge(baseMapper.getDispatchUnitList(deptId)); |
| | | } |
| | | } |