21 changed files with 466 additions and 15 deletions
			
			
		@ -0,0 +1,26 @@ | 
				
			|||||
 | 
					package com.epmet.commons.tools.utils; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import lombok.Data; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.io.Serializable; | 
				
			||||
 | 
					import java.util.ArrayList; | 
				
			||||
 | 
					import java.util.List; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * 描述一下 | 
				
			||||
 | 
					 * | 
				
			||||
 | 
					 * @author yinzuomei@elink-cn.com | 
				
			||||
 | 
					 * @date 2021/2/4 20:49 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@Data | 
				
			||||
 | 
					public class AgencyNode<T> implements Serializable { | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    private String areaCode; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    private String parentAreaCode; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 子节点列表 | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    private List<T> subAgencyList = new ArrayList<>(); | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,73 @@ | 
				
			|||||
 | 
					package com.epmet.commons.tools.utils; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.validator.AssertUtils; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.util.ArrayList; | 
				
			||||
 | 
					import java.util.LinkedHashMap; | 
				
			||||
 | 
					import java.util.List; | 
				
			||||
 | 
					import java.util.Map; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * 描述一下 | 
				
			||||
 | 
					 * | 
				
			||||
 | 
					 * @author yinzuomei@elink-cn.com | 
				
			||||
 | 
					 * @date 2021/2/4 20:49 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					public class AgencyTreeUtils { | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 根据pid,构建树节点 | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public static <T extends AgencyNode> List<T> build(List<T> agencyNodes, String parentAreaCode) { | 
				
			||||
 | 
					        //pid不能为空
 | 
				
			||||
 | 
					        AssertUtils.isNull(parentAreaCode, "parentAreaCode"); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        List<T> treeList = new ArrayList<>(); | 
				
			||||
 | 
					        for (T agencyNode : agencyNodes) { | 
				
			||||
 | 
					            if (parentAreaCode.equals(agencyNode.getParentAreaCode())) { | 
				
			||||
 | 
					                treeList.add(findChildren(agencyNodes, agencyNode)); | 
				
			||||
 | 
					            } | 
				
			||||
 | 
					        } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        return treeList; | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 查找子节点 | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    private static <T extends AgencyNode> T findChildren(List<T> agencyNodes, T rootNode) { | 
				
			||||
 | 
					        for (T agencyNode : agencyNodes) { | 
				
			||||
 | 
					            if (rootNode.getAreaCode().equals(agencyNode.getParentAreaCode())) { | 
				
			||||
 | 
					                rootNode.getSubAgencyList().add(findChildren(agencyNodes, agencyNode)); | 
				
			||||
 | 
					            } | 
				
			||||
 | 
					        } | 
				
			||||
 | 
					        return rootNode; | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 构建树节点 | 
				
			||||
 | 
					     */ | 
				
			||||
 | 
					    public static <T extends AgencyNode> List<T> build(List<T> agencyNodes) { | 
				
			||||
 | 
					        List<T> result = new ArrayList<>(); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        //list转map
 | 
				
			||||
 | 
					        Map<String, T> nodeMap = new LinkedHashMap<>(agencyNodes.size()); | 
				
			||||
 | 
					        for (T agencyNode : agencyNodes) { | 
				
			||||
 | 
					            nodeMap.put(agencyNode.getAreaCode(), agencyNode); | 
				
			||||
 | 
					        } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        for (T node : nodeMap.values()) { | 
				
			||||
 | 
					            T parent = nodeMap.get(node.getParentAreaCode()); | 
				
			||||
 | 
					            if (parent != null && !(node.getAreaCode().equals(parent.getAreaCode()))) { | 
				
			||||
 | 
					                parent.getSubAgencyList().add(node); | 
				
			||||
 | 
					                continue; | 
				
			||||
 | 
					            } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					            result.add(node); | 
				
			||||
 | 
					        } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					        return result; | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,50 @@ | 
				
			|||||
 | 
					package com.epmet.dto.result.plugins; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.AgencyNode; | 
				
			||||
 | 
					import lombok.Data; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.io.Serializable; | 
				
			||||
 | 
					import java.util.ArrayList; | 
				
			||||
 | 
					import java.util.List; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * 008、当前用户的数据权限(多客户版本) 返参DTO | 
				
			||||
 | 
					 * | 
				
			||||
 | 
					 * @author yinzuomei@elink-cn.com | 
				
			||||
 | 
					 * @date 2021/2/3 20:33 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@Data | 
				
			||||
 | 
					public class AgencyNodeDTO extends AgencyNode<AgencyNodeDTO> implements Serializable { | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    private static final long serialVersionUID = -3745920378557792529L; | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 直属机关Id | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String agencyId; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 直属机关名称 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String agencyName; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 机关级别(社区级:community, 乡(镇、街道)级:street, 区县级: district, 市级: city 省级:province) | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String level; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 当前agencyId所属的客户id add02.03 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String customerId; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 直属机关直属网格列表 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private List<GridNodeDTO> gridList = new ArrayList<>(); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 直属机关直属部门列表 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private List<DeptNodeDTO> departmentList = new ArrayList<>(); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,36 @@ | 
				
			|||||
 | 
					package com.epmet.dto.result.plugins; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import lombok.Data; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.io.Serializable; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * @Description 部门信息 | 
				
			||||
 | 
					 * @ClassName ExtDeptResultDTO | 
				
			||||
 | 
					 * @Auth wangc | 
				
			||||
 | 
					 * @Date 2020-08-17 17:16 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@Data | 
				
			||||
 | 
					public class DeptNodeDTO implements Serializable { | 
				
			||||
 | 
					    private static final long serialVersionUID = 1792371558965832432L; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 部门Id | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String deptId; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 部门名称 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String deptName; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 当前deptId所属的customerId  add02.03 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String customerId; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 当前deptId对应的地区编码 add02.03 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String areaCode; | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,36 @@ | 
				
			|||||
 | 
					package com.epmet.dto.result.plugins; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import lombok.Data; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import java.io.Serializable; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * 008、当前用户的数据权限(多客户版本) 返参DTO | 
				
			||||
 | 
					 * | 
				
			||||
 | 
					 * @author yinzuomei@elink-cn.com | 
				
			||||
 | 
					 * @date 2021/2/3 20:33 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					@Data | 
				
			||||
 | 
					public class GridNodeDTO implements Serializable { | 
				
			||||
 | 
					    private static final long serialVersionUID = -4531574240525562587L; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 网格Id | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String gridId; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 网格名称 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String gridName; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 当前gridId所属的客户id add02.03 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String customerId; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * 当前gridId对应的地区编码 add02.03 | 
				
			||||
 | 
					     * */ | 
				
			||||
 | 
					    private String areaCode; | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,27 @@ | 
				
			|||||
 | 
					package com.epmet.feign; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.constant.ServiceConstant; | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.Result; | 
				
			||||
 | 
					import com.epmet.dto.result.plugins.AgencyNodeDTO; | 
				
			||||
 | 
					import com.epmet.feign.impl.DataReportOpenFeignClientFallBack; | 
				
			||||
 | 
					import org.springframework.cloud.openfeign.FeignClient; | 
				
			||||
 | 
					import org.springframework.web.bind.annotation.GetMapping; | 
				
			||||
 | 
					import org.springframework.web.bind.annotation.PathVariable; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * 本服务对外开放的API,其他服务通过引用此client调用该服务 | 
				
			||||
 | 
					 * | 
				
			||||
 | 
					 * @author yinzuomei@elink-cn.com | 
				
			||||
 | 
					 * @date 2021/2/3 22:05 | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					// @FeignClient(name = ServiceConstant.DATA_REPORT_SERVER, fallback = DataReportOpenFeignClientFallBack.class,url = "localhost:8109")
 | 
				
			||||
 | 
					@FeignClient(name = ServiceConstant.DATA_REPORT_SERVER, fallback = DataReportOpenFeignClientFallBack.class) | 
				
			||||
 | 
					public interface DataReportOpenFeignClient { | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * @param agencyId | 
				
			||||
 | 
					     * @description 查询当前组织及下级组织树 | 
				
			||||
 | 
					     * @Date 2021/2/3 22:05 | 
				
			||||
 | 
					     **/ | 
				
			||||
 | 
					    @GetMapping("/data/report/screen/agency/querystaffagencytree/{agencyId}") | 
				
			||||
 | 
					    Result<AgencyNodeDTO> queryStaffAgencyTree(@PathVariable("agencyId") String agencyId); | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,21 @@ | 
				
			|||||
 | 
					package com.epmet.feign.impl; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.constant.ServiceConstant; | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.ModuleUtils; | 
				
			||||
 | 
					import com.epmet.commons.tools.utils.Result; | 
				
			||||
 | 
					import com.epmet.dto.result.plugins.AgencyNodeDTO; | 
				
			||||
 | 
					import com.epmet.feign.DataReportOpenFeignClient; | 
				
			||||
 | 
					import org.springframework.stereotype.Component; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					@Component | 
				
			||||
 | 
					public class DataReportOpenFeignClientFallBack implements DataReportOpenFeignClient { | 
				
			||||
 | 
					    /** | 
				
			||||
 | 
					     * @param agencyId | 
				
			||||
 | 
					     * @description 查询当前组织及下级组织树 | 
				
			||||
 | 
					     * @Date 2021/2/3 22:05 | 
				
			||||
 | 
					     **/ | 
				
			||||
 | 
					    @Override | 
				
			||||
 | 
					    public Result<AgencyNodeDTO> queryStaffAgencyTree(String agencyId) { | 
				
			||||
 | 
					        return ModuleUtils.feignConError(ServiceConstant.DATA_REPORT_SERVER, "queryStaffAgencyTree",agencyId); | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue