Procházet zdrojové kódy

改成 树结构

master
PoffyZhang před 1 rokem
rodič
revize
69e7ebeb92
4 změnil soubory, kde provedl 93 přidání a 25 odebrání
  1. +18
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java
  2. +2
    -5
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/NdKqZzsfwMenuController.java
  3. +41
    -0
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/entity/vo/TreeVO.java
  4. +32
    -20
      kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java

+ 18
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/constants/ZzsfwMenuConstant.java Zobrazit soubor

@@ -0,0 +1,18 @@
package com.ningdatech.kqapi.zzsfw.constants;

/**
* @Classname ZzsfwMenuConstant
* @Description
* @Date 2023/10/30 10:41
* @Author PoffyZhang
*/
public class ZzsfwMenuConstant {
public static final String MENU_TYPE_ZONE = "zone";

public static final String MENU_TYPE_WINDOW = "window";

public static final String MENU_TYPE_DEPARTMENT = "department";

public static final String MENU_TYPE_MATTER = "matter";
}

+ 2
- 5
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/controller/NdKqZzsfwMenuController.java Zobrazit soubor

@@ -2,8 +2,7 @@ package com.ningdatech.kqapi.zzsfw.controller;


import com.ningdatech.basic.model.ApiResponse;
import com.ningdatech.kqapi.zzsfw.entity.vo.MattersVO;
import com.ningdatech.kqapi.zzsfw.entity.vo.ZoneVO;
import com.ningdatech.kqapi.zzsfw.entity.vo.TreeVO;
import com.ningdatech.kqapi.zzsfw.manage.MatterManage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -12,8 +11,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@@ -37,7 +34,7 @@ public class NdKqZzsfwMenuController {

@ApiOperation(value = "获取政务事项数据列表", notes = "获取政务事项数据列表")
@GetMapping("/matters")
public ApiResponse<List<ZoneVO>> getMatters() {
public ApiResponse<List<TreeVO>> getMatters() {
return ApiResponse.ofSuccess(matterManage.getMatters());
}
}

+ 41
- 0
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/entity/vo/TreeVO.java Zobrazit soubor

@@ -0,0 +1,41 @@
package com.ningdatech.kqapi.zzsfw.entity.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
* <p>
* 树结构
* </p>
*
* @author ZPF
* @since 2023-10-25
*/
@Data
@ApiModel(value = "TreeVO", description = "树结构")
public class TreeVO implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("rowid")
private String id;

@ApiModelProperty("名称")
private String name;

@ApiModelProperty("类型")
private String type;

@ApiModelProperty("链接")
private String url;

@ApiModelProperty("链接")
private Integer sort;

@ApiModelProperty("子级")
private List<TreeVO> chilren;
}

+ 32
- 20
kqapi/src/main/java/com/ningdatech/kqapi/zzsfw/manage/MatterManage.java Zobrazit soubor

@@ -1,19 +1,16 @@
package com.ningdatech.kqapi.zzsfw.manage;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.StopWatch;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.kqapi.common.enumeration.CommonEnum;
import com.ningdatech.kqapi.zzsfw.constants.ZzsfwMenuConstant;
import com.ningdatech.kqapi.zzsfw.entity.entity.NdKqZzsfwMenu;
import com.ningdatech.kqapi.zzsfw.entity.vo.MattersVO;
import com.ningdatech.kqapi.zzsfw.entity.vo.WindowVO;
import com.ningdatech.kqapi.zzsfw.entity.vo.ZoneVO;
import com.ningdatech.kqapi.zzsfw.entity.vo.TreeVO;
import com.ningdatech.kqapi.zzsfw.service.INdKqZzsfwMenuService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -33,7 +30,7 @@ public class MatterManage {

private final INdKqZzsfwMenuService menuService;

public List<ZoneVO> getMatters() {
public List<TreeVO> getMatters() {
List<NdKqZzsfwMenu> matters = menuService.list(Wrappers.lambdaQuery(NdKqZzsfwMenu.class)
.eq(NdKqZzsfwMenu::getHasUrl, CommonEnum.YES.getCode())
.orderByAsc(NdKqZzsfwMenu::getSort));
@@ -42,34 +39,49 @@ public class MatterManage {
}

Set<String> zoneSet = new HashSet<>();
List<ZoneVO> res = matters.stream().filter(m -> zoneSet.add(m.getZoneName())).map(m -> {
ZoneVO zone = new ZoneVO();
zone.setZoneName(m.getZoneName());
zone.setWindows(generateWindows(m, matters));
List<TreeVO> res = matters.stream().filter(m -> zoneSet.add(m.getZoneName())).map(m -> {
TreeVO zone = new TreeVO();
zone.setName(m.getZoneName());
zone.setChilren(generateWindows(m, matters));
zone.setType(ZzsfwMenuConstant.MENU_TYPE_ZONE);
return zone;
}).collect(Collectors.toList());
return res;
}

private List<WindowVO> generateWindows(NdKqZzsfwMenu menu, List<NdKqZzsfwMenu> matters) {
private List<TreeVO> generateWindows(NdKqZzsfwMenu menu, List<NdKqZzsfwMenu> matters) {
Set<String> windowSet = new HashSet<>();
return matters.stream().filter(m -> windowSet.add(m.getWindow()) && StringUtils.isNotBlank(m.getZoneName()) && m.getZoneName().equals(menu.getZoneName()))
.map(m -> {
WindowVO window = new WindowVO();
window.setWindowName(m.getWindow());
window.setMatters(generateMatters(m,matters));
TreeVO window = new TreeVO();
window.setName(m.getWindow());
window.setChilren(generateDepartment(m,matters));
window.setType(ZzsfwMenuConstant.MENU_TYPE_WINDOW);
return window;
}).collect(Collectors.toList());
}

private List<MattersVO> generateMatters(NdKqZzsfwMenu menu, List<NdKqZzsfwMenu> matters) {
return matters.stream().filter(m -> StringUtils.isNotBlank(m.getWindow()) && m.getWindow().equals(menu.getWindow()))
private List<TreeVO> generateDepartment(NdKqZzsfwMenu menu, List<NdKqZzsfwMenu> matters) {
Set<String> departmentSet = new HashSet<>();
return matters.stream().filter(m -> departmentSet.add(m.getDepartment()) && StringUtils.isNotBlank(m.getWindow()) && m.getWindow().equals(menu.getWindow()))
.map(m -> {
TreeVO department = new TreeVO();
department.setName(m.getDepartment());
department.setChilren(generateMatters(m,matters));
department.setType(ZzsfwMenuConstant.MENU_TYPE_DEPARTMENT);
return department;
}).collect(Collectors.toList());
}

private List<TreeVO> generateMatters(NdKqZzsfwMenu menu, List<NdKqZzsfwMenu> matters) {
return matters.stream().filter(m -> StringUtils.isNotBlank(m.getDepartment()) && m.getDepartment().equals(menu.getDepartment()))
.map(m -> {
MattersVO matter = new MattersVO();
matter.setMatterName(m.getItemName());
matter.setWebapplyurl(m.getWebapplyurl());
matter.setRowguid(m.getItemRowid());
TreeVO matter = new TreeVO();
matter.setName(m.getItemName());
matter.setUrl(m.getWebapplyurl());
matter.setId(m.getItemRowid());
matter.setSort(m.getSort());
matter.setType(ZzsfwMenuConstant.MENU_TYPE_MATTER);
return matter;
}).collect(Collectors.toList());
}


Načítá se…
Zrušit
Uložit