Xiajijian
2026-01-20 d34744aed7c451b4a8a67acc851708bd05c223e6
1. 增加获取巡检分组树列表接口。
2 files added
4 files modified
293 ■■■■■ changed files
ard-admin/src/main/java/com/ard/web/controller/inspection/ArdInspectionGroupController.java 15 ●●●●● patch | view | raw | blame | history
ard-admin/src/main/java/com/ard/web/controller/inspection/BigFileUploadController.java 17 ●●●●● patch | view | raw | blame | history
ard-inspection/src/main/java/com/ard/inspection/domain/ArdInspectionGroup.java 77 ●●●●● patch | view | raw | blame | history
ard-inspection/src/main/java/com/ard/inspection/domain/GroupTreeSelect.java 72 ●●●●● patch | view | raw | blame | history
ard-inspection/src/main/java/com/ard/inspection/service/IArdInspectionGroupService.java 13 ●●●●● patch | view | raw | blame | history
ard-inspection/src/main/java/com/ard/inspection/service/impl/ArdInspectionGroupServiceImpl.java 99 ●●●●● patch | view | raw | blame | history
ard-admin/src/main/java/com/ard/web/controller/inspection/ArdInspectionGroupController.java
@@ -1,14 +1,11 @@
package com.ard.web.controller.inspection;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ard.common.annotation.Log;
import com.ard.common.core.controller.BaseController;
import com.ard.common.core.domain.AjaxResult;
import com.ard.common.core.page.TableDataInfo;
import com.ard.common.enums.BusinessType;
import com.ard.common.utils.poi.ExcelUtil;
import com.ard.inspection.domain.ArdInspectionGroup;
import com.ard.inspection.service.IArdInspectionGroupService;
import io.swagger.annotations.Api;
@@ -68,7 +65,7 @@
    @Log(title = "精细化巡检分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArdInspectionGroup ardInspectionGroup) {
        if (ardInspectionGroupService.checkInspectionGroupNameUnique(ardInspectionGroup)){
        if (!ardInspectionGroupService.checkInspectionGroupNameUnique(ardInspectionGroup)){
            return error("新增分组'" + ardInspectionGroup.getGroupName() + "'失败,分组名称已存在");
        }
        ardInspectionGroup.setCreateBy(getUsername());
@@ -112,4 +109,14 @@
        return toAjax(ardInspectionGroupService.deleteArdInspectionGroupByGroupId(groupId));
    }
    /**
     * 获取巡检分组树列表
     */
    @ApiOperation("获取巡检分组树列表")
    @PreAuthorize("@ss.hasPermi('inspection:group:groupTree')")
    @GetMapping("/groupTree")
    public AjaxResult deptTree(ArdInspectionGroup ardInspectionGroup) {
        return success(ardInspectionGroupService.selectGroupTreeList(ardInspectionGroup));
    }
}
ard-admin/src/main/java/com/ard/web/controller/inspection/BigFileUploadController.java
New file
@@ -0,0 +1,17 @@
package com.ard.web.controller.inspection;
import io.lettuce.core.dynamic.annotation.Value;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "大文件上传")
@RestController
@RequestMapping("/inspection/bigfile")
public class BigFileUploadController {
    /** 若依文件上传根目录(从配置文件读取) */
    //@Value("${ruoyi.profile}")
    private String uploadRootDir;
}
ard-inspection/src/main/java/com/ard/inspection/domain/ArdInspectionGroup.java
@@ -1,8 +1,10 @@
package com.ard.inspection.domain;
import com.ard.common.annotation.Excel;
import com.ard.common.core.domain.BaseEntity;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
/**
 * 精细化巡检分组对象 ard_inspection_group
@@ -10,7 +12,6 @@
 * @author xia
 * @date 2026-01-15
 */
@Data
public class ArdInspectionGroup extends BaseEntity {
    private static final long serialVersionUID = 1L;
@@ -19,19 +20,79 @@
    private Long groupId;
    /** 分组父部门id */
    @Excel(name = "分组父部门id")
    private Long groupParentId;
    /** 祖级列表 */
    @Excel(name = "祖级列表")
    private String ancestors;
    /** 分组名称 */
    @Excel(name = "分组名称")
    private String groupName;
    /** 显示顺序 */
    @Excel(name = "显示顺序")
    private Long orderNum;
    private Integer orderNum;
    /** 父部门名称 */
    private String parentName;
    /** 子部门 */
    private List<ArdInspectionGroup> children = new ArrayList<ArdInspectionGroup>();
    public Long getGroupId() {
        return groupId;
    }
    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }
    public Long getGroupParentId() {
        return groupParentId;
    }
    public void setGroupParentId(Long groupParentId) {
        this.groupParentId = groupParentId;
    }
    public String getAncestors() {
        return ancestors;
    }
    public void setAncestors(String ancestors) {
        this.ancestors = ancestors;
    }
    @NotBlank(message = "分组名称不能为空")
    @Size(min = 0, max = 30, message = "分组名称长度不能超过30个字符")
    public String getGroupName() {
        return groupName;
    }
    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }
    public Integer getOrderNum() {
        return orderNum;
    }
    public void setOrderNum(Integer orderNum) {
        this.orderNum = orderNum;
    }
    public String getParentName() {
        return parentName;
    }
    public void setParentName(String parentName) {
        this.parentName = parentName;
    }
    public List<ArdInspectionGroup> getChildren() {
        return children;
    }
    public void setChildren(List<ArdInspectionGroup> children) {
        this.children = children;
    }
}
ard-inspection/src/main/java/com/ard/inspection/domain/GroupTreeSelect.java
New file
@@ -0,0 +1,72 @@
package com.ard.inspection.domain;
import com.ard.common.core.domain.entity.SysMenu;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
public class GroupTreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;
    /** 节点ID */
    private Long id;
    /** 节点名称 */
    private String label;
    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<GroupTreeSelect> children;
    public GroupTreeSelect()
    {
    }
    public GroupTreeSelect(ArdInspectionGroup group)
    {
        this.id = group.getGroupId();
        this.label = group.getGroupName();
        this.children = group.getChildren().stream().map(GroupTreeSelect::new).collect(Collectors.toList());
    }
    public GroupTreeSelect(SysMenu menu)
    {
        this.id = menu.getMenuId();
        this.label = menu.getMenuName();
        this.children = menu.getChildren().stream().map(GroupTreeSelect::new).collect(Collectors.toList());
    }
    public Long getId()
    {
        return id;
    }
    public void setId(Long id)
    {
        this.id = id;
    }
    public String getLabel()
    {
        return label;
    }
    public void setLabel(String label)
    {
        this.label = label;
    }
    public List<GroupTreeSelect> getChildren()
    {
        return children;
    }
    public void setChildren(List<GroupTreeSelect> children)
    {
        this.children = children;
    }
}
ard-inspection/src/main/java/com/ard/inspection/service/IArdInspectionGroupService.java
@@ -1,6 +1,7 @@
package com.ard.inspection.service;
import com.ard.inspection.domain.ArdInspectionGroup;
import com.ard.inspection.domain.GroupTreeSelect;
import java.util.List;
@@ -83,4 +84,16 @@
     */
    public boolean checkInspectionGroupExistUser(Long groupId);
    /**
     * 查询分组树结构信息
     *
     * @param ardInspectionGroup 精细化巡检分组
     * @return 分组树信息集合
     */
    public List<GroupTreeSelect> selectGroupTreeList(ArdInspectionGroup ardInspectionGroup);
    public List<GroupTreeSelect> buildGroupTreeSelect(List<ArdInspectionGroup> groups);
    public List<ArdInspectionGroup> buildGroupTree(List<ArdInspectionGroup> groups);
}
ard-inspection/src/main/java/com/ard/inspection/service/impl/ArdInspectionGroupServiceImpl.java
@@ -1,8 +1,10 @@
package com.ard.inspection.service.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import com.ard.common.annotation.DataScope;
import com.ard.common.constant.UserConstants;
import com.ard.common.core.domain.entity.SysUser;
import com.ard.common.exception.ServiceException;
@@ -11,6 +13,7 @@
import com.ard.common.utils.StringUtils;
import com.ard.common.utils.spring.SpringUtils;
import com.ard.inspection.domain.ArdInspectionGroup;
import com.ard.inspection.domain.GroupTreeSelect;
import com.ard.inspection.mapper.ArdInspectionGroupMapper;
import com.ard.inspection.service.IArdInspectionGroupService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -170,4 +173,98 @@
        return result > 0;
    }
    /**
     * 查询分组树结构信息
     *
     * @param ardInspectionGroup 精细化巡检分组
     * @return 分组树信息集合
     */
    @Override
    public List<GroupTreeSelect> selectGroupTreeList(ArdInspectionGroup ardInspectionGroup)
    {
        List<ArdInspectionGroup> groups = selectArdInspectionGroupList(ardInspectionGroup);
        return buildGroupTreeSelect(groups);
    }
    /**
     * 构建前端所需要下拉树结构
     *
     * @param groups 分组列表
     * @return 下拉树结构列表
     */
    @Override
    public List<GroupTreeSelect> buildGroupTreeSelect(List<ArdInspectionGroup> groups){
        List<ArdInspectionGroup> groupTrees = buildGroupTree(groups);
        return groupTrees.stream().map(GroupTreeSelect::new).collect(Collectors.toList());
    }
    /**
     * 构建前端所需要树结构
     *
     * @param groups 分组列表
     * @return 树结构列表
     */
    @Override
    public List<ArdInspectionGroup> buildGroupTree(List<ArdInspectionGroup> groups){
        List<ArdInspectionGroup> returnList = new ArrayList<ArdInspectionGroup>();
        List<Long> tempList = groups.stream().map(ArdInspectionGroup::getGroupId).collect(Collectors.toList());
        for (ArdInspectionGroup group : groups)
        {
            // 如果是顶级节点, 遍历该父节点的所有子节点
            if (!tempList.contains(group.getGroupParentId()))
            {
                recursionFn(groups, group);
                returnList.add(group);
            }
        }
        if (returnList.isEmpty())
        {
            returnList = groups;
        }
        return returnList;
    }
    /**
     * 递归列表
     */
    private void recursionFn(List<ArdInspectionGroup> list, ArdInspectionGroup t)
    {
        // 得到子节点列表
        List<ArdInspectionGroup> childList = getChildList(list, t);
        t.setChildren(childList);
        for (ArdInspectionGroup tChild : childList)
        {
            if (hasChild(list, tChild))
            {
                recursionFn(list, tChild);
            }
        }
    }
    /**
     * 得到子节点列表
     */
    private List<ArdInspectionGroup> getChildList(List<ArdInspectionGroup> list, ArdInspectionGroup t)
    {
        List<ArdInspectionGroup> tlist = new ArrayList<ArdInspectionGroup>();
        Iterator<ArdInspectionGroup> it = list.iterator();
        while (it.hasNext())
        {
            ArdInspectionGroup n = (ArdInspectionGroup) it.next();
            if (StringUtils.isNotNull(n.getGroupParentId()) && n.getGroupParentId().longValue() == t.getGroupId().longValue())
            {
                tlist.add(n);
            }
        }
        return tlist;
    }
    /**
     * 判断是否有子节点
     */
    private boolean hasChild(List<ArdInspectionGroup> list, ArdInspectionGroup t)
    {
        return getChildList(list, t).size() > 0;
    }
}