ソースを参照

树形渲染接口

lucky 3 ヶ月 前
コミット
21104eda71

+ 112 - 0
zkqy-business/src/main/java/com/zkqy/business/controller/DragTreeController.java

@@ -0,0 +1,112 @@
+package com.zkqy.business.controller;
+
+import com.zkqy.business.entity.DragTree;
+import com.zkqy.business.entity.vo.DragTreeVo;
+import com.zkqy.business.service.IDragTreeService;
+import com.zkqy.common.annotation.Anonymous;
+import com.zkqy.common.annotation.Log;
+import com.zkqy.common.core.controller.BaseController;
+import com.zkqy.common.core.domain.AjaxResult;
+import com.zkqy.common.core.page.TableDataInfo;
+import com.zkqy.common.enums.BusinessType;
+
+import com.zkqy.common.utils.poi.ExcelUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+
+/**
+ * 拖拽树结构Controller
+ * 
+ * @author hmc
+ * @date 2025-03-05
+ */
+@RestController
+@RequestMapping("/dragTree/tree")
+public class DragTreeController extends BaseController
+{
+
+    @Autowired
+    private IDragTreeService dragTreeService;
+
+    /**
+     * 查询拖拽树结构列表
+     */
+//    @PreAuthorize("@ss.hasPermi('dragTree:tree:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(DragTree dragTree)
+    {
+        startPage();
+        List<DragTree> list = dragTreeService.selectDragTreeList(dragTree);
+        return getDataTable(list);
+    }
+
+    @GetMapping("/recursionTree/treeTableKey/{treeTableKey}")
+    public AjaxResult recursionTree(@PathVariable String treeTableKey)
+    {
+        DragTreeVo list = dragTreeService.recursionTree(treeTableKey);
+        return AjaxResult.success(list);
+    }
+
+    /**
+     * 导出拖拽树结构列表
+     */
+//    @PreAuthorize("@ss.hasPermi('dragTree:tree:export')")
+    @Log(title = "拖拽树结构", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, DragTree dragTree)
+    {
+        List<DragTree> list = dragTreeService.selectDragTreeList(dragTree);
+        ExcelUtil<DragTree> util = new ExcelUtil<DragTree>(DragTree.class);
+        util.exportExcel(response, list, "拖拽树结构数据");
+    }
+
+
+    /**
+     * 获取拖拽树结构详细信息
+     */
+//    @PreAuthorize("@ss.hasPermi('dragTree:tree:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(dragTreeService.selectDragTreeById(id));
+    }
+
+    /**
+     * 新增拖拽树结构
+     */
+//    @PreAuthorize("@ss.hasPermi('dragTree:tree:add')")
+    @Anonymous
+    @Log(title = "拖拽树结构", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody DragTree dragTree)
+    {
+        return toAjax(dragTreeService.insertDragTree(dragTree));
+    }
+
+    /**
+     * 修改拖拽树结构
+     */
+//    @PreAuthorize("@ss.hasPermi('dragTree:tree:edit')")
+    @Log(title = "拖拽树结构", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody DragTree dragTree)
+    {
+        return toAjax(dragTreeService.updateDragTree(dragTree));
+    }
+
+
+    /**
+     * 删除拖拽树结构
+     */
+//    @PreAuthorize("@ss.hasPermi('dragTree:tree:remove')")
+    @Log(title = "拖拽树结构", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(dragTreeService.deleteDragTreeByIds(ids));
+    }
+}

+ 251 - 0
zkqy-business/src/main/java/com/zkqy/business/entity/DragTree.java

@@ -0,0 +1,251 @@
+package com.zkqy.business.entity;
+
+import com.zkqy.common.annotation.Excel;
+import com.zkqy.common.core.domain.BaseEntity;
+import lombok.Builder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+
+/**
+ * 拖拽树结构对象 drag_tree
+ * 
+ * @author hmc
+ * @date 2025-03-05
+ */
+
+public class DragTree extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    private String  treeShowLabel;
+
+    /** 唯一标识符,自增主键 */
+    private Long id;
+
+    private  String  treeTableKey;
+
+    public String getTreeTableKey() {
+        return treeTableKey;
+    }
+
+    public void setTreeTableKey(String treeTableKey) {
+        this.treeTableKey = treeTableKey;
+    }
+
+    /** $column.columnComment */
+    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+    private Long menuId;
+
+    private String tableId;
+
+    private  String tableNameDes;
+
+    public String getTableNameDes() {
+        return tableNameDes;
+    }
+
+    public void setTableNameDes(String tableNameDes) {
+        this.tableNameDes = tableNameDes;
+    }
+
+    /** 菜单名称 */
+    @Excel(name = "菜单名称")
+    private String menuName;
+
+    /** 树形描述 */
+    @Excel(name = "树形描述")
+    private String treeDesc;
+
+    /** 树形组件绑定的表格 */
+    @Excel(name = "树形组件绑定的表格")
+    private String treeTableName;
+
+    /** 树形表格组件绑定表格的主键 */
+    @Excel(name = "树形表格组件绑定表格的主键")
+    private String treeTablePrimaryKey;
+
+    /** 递归列 */
+    @Excel(name = "递归列")
+    private String treeTableDgl;
+
+    /** 查询条件选的是 label 还是 value */
+    @Excel(name = "查询条件选的是 label 还是 value")
+    private String treeTableCondition;
+
+    /** 关联右侧查询表的表名称 */
+    @Excel(name = "关联右侧查询表的表名称")
+    private String treeTableJoinTable;
+
+    /** 整体的json */
+    @Excel(name = "整体的json")
+    private String allJson;
+
+    /** 删除标志(0:否 2:是) */
+    private String delFlag;
+
+    /** 创建者id */
+    @Excel(name = "创建者id")
+    private Long createById;
+
+    /** 更新者id */
+    @Excel(name = "更新者id")
+    private Long updateById;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setMenuId(Long menuId) 
+    {
+        this.menuId = menuId;
+    }
+
+    public Long getMenuId() 
+    {
+        return menuId;
+    }
+    public void setMenuName(String menuName) 
+    {
+        this.menuName = menuName;
+    }
+
+    public String getMenuName() 
+    {
+        return menuName;
+    }
+    public void setTreeDesc(String treeDesc) 
+    {
+        this.treeDesc = treeDesc;
+    }
+
+    public String getTreeDesc() 
+    {
+        return treeDesc;
+    }
+    public void setTreeTableName(String treeTableName) 
+    {
+        this.treeTableName = treeTableName;
+    }
+
+    public String getTreeTableName() 
+    {
+        return treeTableName;
+    }
+    public void setTreeTablePrimaryKey(String treeTablePrimaryKey) 
+    {
+        this.treeTablePrimaryKey = treeTablePrimaryKey;
+    }
+
+    public String getTreeTablePrimaryKey() 
+    {
+        return treeTablePrimaryKey;
+    }
+    public void setTreeTableDgl(String treeTableDgl) 
+    {
+        this.treeTableDgl = treeTableDgl;
+    }
+
+    public String getTreeTableDgl() 
+    {
+        return treeTableDgl;
+    }
+    public void setTreeTableCondition(String treeTableCondition) 
+    {
+        this.treeTableCondition = treeTableCondition;
+    }
+
+    public String getTreeTableCondition() 
+    {
+        return treeTableCondition;
+    }
+    public void setTreeTableJoinTable(String treeTableJoinTable) 
+    {
+        this.treeTableJoinTable = treeTableJoinTable;
+    }
+
+    public String getTreeTableJoinTable() 
+    {
+        return treeTableJoinTable;
+    }
+    public void setAllJson(String allJson) 
+    {
+        this.allJson = allJson;
+    }
+
+    public String getAllJson() 
+    {
+        return allJson;
+    }
+    public void setDelFlag(String delFlag) 
+    {
+        this.delFlag = delFlag;
+    }
+
+    public String getDelFlag() 
+    {
+        return delFlag;
+    }
+    public void setCreateById(Long createById) 
+    {
+        this.createById = createById;
+    }
+
+    public Long getCreateById() 
+    {
+        return createById;
+    }
+    public void setUpdateById(Long updateById) 
+    {
+        this.updateById = updateById;
+    }
+
+    public Long getUpdateById() 
+    {
+        return updateById;
+    }
+
+    public String getTreeShowLabel() {
+        return treeShowLabel;
+    }
+
+    public void setTreeShowLabel(String treeShowLabel) {
+        this.treeShowLabel = treeShowLabel;
+    }
+
+    public String getTableId() {
+        return tableId;
+    }
+
+    public void setTableId(String tableId) {
+        this.tableId = tableId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("menuId", getMenuId())
+            .append("menuName", getMenuName())
+            .append("treeDesc", getTreeDesc())
+            .append("treeTableName", getTreeTableName())
+            .append("treeTablePrimaryKey", getTreeTablePrimaryKey())
+            .append("treeTableDgl", getTreeTableDgl())
+            .append("treeTableCondition", getTreeTableCondition())
+            .append("treeTableJoinTable", getTreeTableJoinTable())
+            .append("allJson", getAllJson())
+            .append("delFlag", getDelFlag())
+            .append("createBy", getCreateBy())
+            .append("createById", getCreateById())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateById", getUpdateById())
+            .append("updateTime", getUpdateTime())
+            .toString();
+    }
+}

+ 26 - 0
zkqy-business/src/main/java/com/zkqy/business/entity/vo/DragTreeVo.java

@@ -0,0 +1,26 @@
+package com.zkqy.business.entity.vo;
+
+import lombok.Builder;
+
+@Builder
+public class DragTreeVo {
+    private  String template;
+
+    private  String data;
+
+    public String getTemplate() {
+        return template;
+    }
+
+    public void setTemplate(String template) {
+        this.template = template;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+}

+ 91 - 0
zkqy-business/src/main/java/com/zkqy/business/mapper/DragTreeMapper.java

@@ -0,0 +1,91 @@
+package com.zkqy.business.mapper;
+
+
+
+import com.zkqy.business.entity.DragTree;
+import com.zkqy.execution.produce.dispersed.entity.CommonEntity;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 拖拽树结构Mapper接口
+ * 
+ * @author hmc
+ * @date 2025-03-05
+ */
+public interface DragTreeMapper 
+{
+    /**
+     * 查询拖拽树结构
+     * 
+     * @param id 拖拽树结构主键
+     * @return 拖拽树结构
+     */
+    public DragTree selectDragTreeById(Long id);
+
+
+    /**
+     * 查询拖拽树结构
+     *
+     * @param treeTableKey 拖拽树结构主键
+     * @return 拖拽树结构
+     */
+    public DragTree selectDragTreeByTreeTableKey(String treeTableKey);
+
+    /**
+     * 根据表名查询所有字段名称
+     * @param tableName
+     * @return
+     */
+    public  List<String> allTabColumns(@Param("tableName") String tableName,@Param("dbname") String dbname);
+
+    /**
+     * 查询列表
+     */
+    List<Map<String, String>> selectList(@Param("executeSql") String executeSql);
+
+
+
+    /**
+     * 查询拖拽树结构列表
+     * 
+     * @param dragTree 拖拽树结构
+     * @return 拖拽树结构集合
+     */
+    public List<DragTree> selectDragTreeList(DragTree dragTree);
+
+    /**
+     * 新增拖拽树结构
+     * 
+     * @param dragTree 拖拽树结构
+     * @return 结果
+     */
+    public int insertDragTree(DragTree dragTree);
+
+    /**
+     * 修改拖拽树结构
+     * 
+     * @param dragTree 拖拽树结构
+     * @return 结果
+     */
+    public int updateDragTree(DragTree dragTree);
+
+    /**
+     * 删除拖拽树结构
+     * 
+     * @param id 拖拽树结构主键
+     * @return 结果
+     */
+    public int deleteDragTreeById(Long id);
+
+    /**
+     * 批量删除拖拽树结构
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteDragTreeByIds(Long[] ids);
+}

+ 73 - 0
zkqy-business/src/main/java/com/zkqy/business/service/IDragTreeService.java

@@ -0,0 +1,73 @@
+package com.zkqy.business.service;
+
+
+
+import com.zkqy.business.entity.DragTree;
+import com.zkqy.business.entity.vo.DragTreeVo;
+
+import java.util.List;
+
+
+/**
+ * 拖拽树结构Service接口
+ * 
+ * @author hmc
+ * @date 2025-03-05
+ */
+public interface IDragTreeService 
+{
+    /**
+     * 查询拖拽树结构
+     * 
+     * @param id 拖拽树结构主键
+     * @return 拖拽树结构
+     */
+    public DragTree selectDragTreeById(Long id);
+
+    /**
+     * 查询拖拽树结构列表
+     * 
+     * @param dragTree 拖拽树结构
+     * @return 拖拽树结构集合
+     */
+    public List<DragTree> selectDragTreeList(DragTree dragTree);
+
+    /**
+     * 新增拖拽树结构
+     * 
+     * @param dragTree 拖拽树结构
+     * @return 结果
+     */
+    public int insertDragTree(DragTree dragTree);
+
+    /**
+     * 修改拖拽树结构
+     * 
+     * @param dragTree 拖拽树结构
+     * @return 结果
+     */
+    public int updateDragTree(DragTree dragTree);
+
+    /**
+     * 批量删除拖拽树结构
+     * 
+     * @param ids 需要删除的拖拽树结构主键集合
+     * @return 结果
+     */
+    public int deleteDragTreeByIds(Long[] ids);
+
+    /**
+     * 删除拖拽树结构信息
+     * 
+     * @param id 拖拽树结构主键
+     * @return 结果
+     */
+    public int deleteDragTreeById(Long id);
+
+    /**
+     * 根据treeTableKey递归出树结构,并返回对应的逻辑数据
+     * @param treeTableKey
+     * @return
+     */
+    DragTreeVo recursionTree(String treeTableKey);
+}

+ 162 - 0
zkqy-business/src/main/java/com/zkqy/business/service/impl/DragTreeServiceImpl.java

@@ -0,0 +1,162 @@
+package com.zkqy.business.service.impl;
+
+import com.alibaba.fastjson2.JSON;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import com.zkqy.business.entity.DragTree;
+import com.zkqy.business.entity.vo.DragTreeVo;
+import com.zkqy.business.mapper.DragTreeMapper;
+import com.zkqy.business.service.IDragTreeService;
+import com.zkqy.business.utils.ProcessingSelectSqlUtil;
+import com.zkqy.business.utils.TreeBuilder;
+import com.zkqy.common.exception.base.BaseException;
+import com.zkqy.common.utils.DateUtils;
+import com.zkqy.common.utils.SecurityUtils;
+import com.zkqy.execution.produce.dispersed.entity.CommonEntity;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 拖拽树结构Service业务层处理
+ * 
+ * @author hmc
+ * @date 2025-03-05
+ */
+@Service
+@Slf4j
+public class DragTreeServiceImpl implements IDragTreeService
+{
+    @Autowired
+    private DragTreeMapper dragTreeMapper;
+
+    /**
+     * 查询拖拽树结构
+     * 
+     * @param id 拖拽树结构主键
+     * @return 拖拽树结构
+     */
+    @Override
+    public DragTree selectDragTreeById(Long id)
+    {
+        return dragTreeMapper.selectDragTreeById(id);
+    }
+
+    /**
+     * 查询拖拽树结构列表
+     * 
+     * @param dragTree 拖拽树结构
+     * @return 拖拽树结构
+     */
+    @Override
+    public List<DragTree> selectDragTreeList(DragTree dragTree)
+    {
+        return dragTreeMapper.selectDragTreeList(dragTree);
+    }
+
+    /**
+     * 新增拖拽树结构
+     * 
+     * @param dragTree 拖拽树结构
+     * @return 结果
+     */
+    @Override
+    public int insertDragTree(DragTree dragTree)
+    {
+        dragTree.setCreateTime(DateUtils.getNowDate());
+        return dragTreeMapper.insertDragTree(dragTree);
+    }
+
+    /**
+     * 修改拖拽树结构
+     * 
+     * @param dragTree 拖拽树结构
+     * @return 结果
+     */
+    @Override
+    public int updateDragTree(DragTree dragTree)
+    {
+        dragTree.setUpdateTime(DateUtils.getNowDate());
+        return dragTreeMapper.updateDragTree(dragTree);
+    }
+
+    /**
+     * 批量删除拖拽树结构
+     * 
+     * @param ids 需要删除的拖拽树结构主键
+     * @return 结果
+     */
+    @Override
+    public int deleteDragTreeByIds(Long[] ids)
+    {
+        return dragTreeMapper.deleteDragTreeByIds(ids);
+    }
+
+    /**
+     * 删除拖拽树结构信息
+     * 
+     * @param id 拖拽树结构主键
+     * @return 结果
+     */
+    @Override
+    public int deleteDragTreeById(Long id)
+    {
+        return dragTreeMapper.deleteDragTreeById(id);
+    }
+
+    /***
+     * 19	11448	0314-cs	0314-csmc	ammunition_plan_information_intermediate_table	id	id	id	warehouse	72	yx	0	huaxian
+     * 2025-03-14 11:01:32	huaxian		2025-03-14 11:01:32	48e90c10-147f-4bfa-a1a0-f702ba93b5c8
+     * @param treeTableKey
+     * @return
+     */
+    @Override
+    public DragTreeVo recursionTree(String treeTableKey) {
+        treeTableKey="48e90c10-147f-4bfa-a1a0-f702ba93b5c8";
+        // 首先通过tableKey查询模版数据
+        DragTree dragTree = dragTreeMapper.selectDragTreeByTreeTableKey(treeTableKey);
+        // 数据表名称 ammunition_plan_information_intermediate_table
+        String treeTableName = dragTree.getTreeTableName();
+        // 表格主键(value)
+        String tableId = dragTree.getTreeTablePrimaryKey();
+        // 递归列
+        String treeTableDgl = dragTree.getTreeTableDgl();
+        // 展示字段(label)
+        String treeShowLabel = dragTree.getTreeShowLabel();
+        // 当前表字段的所有列名
+        String databaseName = SecurityUtils.getDatabaseName();
+        log.error(databaseName);
+        List<String> allTabColumns = dragTreeMapper.allTabColumns(treeTableName,databaseName);
+        if(treeTableDgl.equals("")||treeTableDgl==null){
+            BaseException.builder().code("500").defaultMessage("该表指定的递归不符合树形结构,请从新配置");
+        }
+        if(treeTableDgl.equals(tableId)){
+            BaseException.builder().code("500").defaultMessage("递归列不能主键列相同");
+        }
+        // 得到查询字符串
+        ProcessingSelectSqlUtil processingSqlUtils = ProcessingSelectSqlUtil.builder().valueColumn(tableId).labelColumn(treeShowLabel)
+                .columns(allTabColumns).tableName(treeTableName).build();
+        //执行的是label+value 的查询拼接
+        String s1 = processingSqlUtils.buildFullLabelValueQuery();
+        //复数对象
+        List<Map<String, String>> mapList = dragTreeMapper.selectList(s1);
+        //递归树形数据
+        List<Map<String, ?>> treeMapData = TreeBuilder.buildTree(mapList,"0",tableId,treeTableDgl);
+
+        //规则数据转json
+        String dragTreeJSon = JSON.toJSONString(dragTree);
+        //递归树形数据转json
+        String treeMapDataJson = JSON.toJSONString(treeMapData);
+        //封装返回值
+        DragTreeVo dragTreeVo = DragTreeVo.builder().template(dragTreeJSon).data(treeMapDataJson.toString()).build();
+
+//        ProcessingSelectSqlUtil build = ProcessingSelectSqlUtil.builder().tableName(treeTableName).build();
+//        String s2 = build.buildFullAllQuery();
+//        log.info(s1);
+//        log.info(s2);
+        //查询对应的表格信息
+        return dragTreeVo;
+    }
+}

+ 88 - 0
zkqy-business/src/main/java/com/zkqy/business/utils/ProcessingSelectSqlUtil.java

@@ -0,0 +1,88 @@
+package com.zkqy.business.utils;
+
+import lombok.Builder;
+import lombok.Data;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+@Data
+public class ProcessingSelectSqlUtil {
+
+    private List<String> columns; //所有的列名
+
+    private String labelColumn; //label列
+    private String valueColumn; //value列
+    private String tableName;   //表名
+
+
+    @Builder
+    public ProcessingSelectSqlUtil(List<String> columns, String labelColumn, String valueColumn, String tableName) {
+        this.columns = columns;
+        this.labelColumn = labelColumn;
+        this.valueColumn = valueColumn;
+        this.tableName = tableName;
+    }
+
+    /**
+     * 处理 label  和  value 中间拼接
+     * @return
+     */
+    public   String getSelectLabelValue(){
+        return columns.stream().map(
+                column -> {
+                    if (column.equals(valueColumn)) {
+                        System.out.println("Matched valueColumn: " + column);
+                        return column+","+ column + " as value";
+                    }
+                    if (column.equals(labelColumn)) {
+                        System.out.println("Matched labelColumn: " + column);
+                        return column+","+ column + " as label";
+                    }
+                    return column;
+                }
+        ).collect(Collectors.joining(","));
+    };
+
+
+    /**
+     * 处理别名拼接
+     * @return
+     */
+    public   String getSelectAll(){
+        return columns.stream().map(
+                column -> new StringBuilder(column).append(" as ")
+                        .append(tableName).append("_").append(column).toString()
+        ).collect(Collectors.joining(","));
+    };
+
+
+    /**
+     * 构建完整的SQL查询
+     * @return 完整的 SQL 查询字符串
+     */
+    public String buildFullLabelValueQuery() {
+        String selectPart = getSelectLabelValue();
+        return new StringBuilder("SELECT ")
+                .append(selectPart)
+                .append(" FROM ")
+                .append("{DBNAME}.")
+                .append(tableName)
+                .toString();
+    }
+
+    /**
+     * 构建完整的SQL查询
+     * @return 完整的 SQL 查询字符串
+     */
+    public String buildFullAllQuery() {
+        String selectPart = getSelectAll();
+        return new StringBuilder("SELECT ")
+                .append(selectPart)
+                .append(" FROM ")
+                .append(tableName)
+                .toString();
+    }
+
+}

+ 93 - 0
zkqy-business/src/main/java/com/zkqy/business/utils/TreeBuilder.java

@@ -0,0 +1,93 @@
+package com.zkqy.business.utils;
+
+import com.alibaba.fastjson2.JSON;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class TreeBuilder {
+
+    // 递归地找到所有子节点并构建树形结构
+    public static List<Map<String, ?>> buildTree(List<Map<String, String>> allNodes, String parentId,String tableId,String treeTableDgl) {
+        return allNodes.stream()
+                .filter(node ->Objects.equals(convertToString(parentId), convertToString(node.get(treeTableDgl))))
+                .map(parentNode -> {
+                     // 确保 tableId 对应的值被正确地转换为字符串
+                    Object tableIdObj = parentNode.get(tableId);
+                    String tableIdStr = convertToString(tableIdObj);
+                    System.out.println(tableIdStr);
+                    List<Map<String, ?>> children = buildTree(allNodes, tableIdStr, tableId,treeTableDgl);
+                    if (!children.isEmpty()) {
+                        // 将子节点列表添加到当前节点
+                        Map<String, Object> enrichedParentNode = new HashMap<>(parentNode);
+                        enrichedParentNode.put("children", children);
+                        return enrichedParentNode;
+                    }
+                    return parentNode;
+                })
+                .collect(Collectors.toList());
+    }
+
+    private static String convertToString(Object obj) {
+        if (obj instanceof Integer) {
+            return ((Integer) obj).toString();
+        } else if (obj instanceof Long) {
+            return ((Long) obj).toString();
+        } else if (obj instanceof String) {
+            return (String) obj;
+        } else {
+            throw new IllegalArgumentException("Unsupported type: " + obj.getClass().getName());
+        }
+    }
+
+
+    public static void main(String[] args) {
+        // 示例数据: 假设这是从数据库获取的数据
+        // 示例数据: 假设这是从数据库获取的数据
+        List<Map<String, String>> mapList = Arrays.asList(
+                new HashMap<String, String>() {{
+                    put("id", "1");
+                    put("name", "根节点");
+                    put("parentId", null); // 根节点
+                }},
+                new HashMap<String, String>() {{
+                    put("id", "2");
+                    put("name", "二级节点");
+                    put("parentId", "1"); // 子节点
+                }},
+                new HashMap<String, String>() {{
+                    put("id", "3");
+                    put("name", "二级节点");
+                    put("parentId", "1"); // 子节点
+                }},
+                new HashMap<String, String>() {{
+                    put("id", "4");
+                    put("name", "三级节点");
+                    put("parentId", "2"); // 子节点的子节点
+                }});
+
+        // 构建树形结构
+        List<Map<String, ?>> tree = buildTree(mapList, null,"id","parentId");
+        String jsonString = JSON.toJSONString(tree);
+        System.out.println(jsonString);
+        // 打印结果
+//        printTree(tree);
+    }
+
+    private static void printTree(List<Map<String, ?>> tree) {
+        for (Map<String, ?> node : tree) {
+            System.out.println(node.get("id")+"---"+node.get("name"));
+            if (node.containsKey("children")) {
+                //noinspection unchecked
+                printTree((List<Map<String, ?>>) node.get("children"));
+            }
+        }
+        Integer a=new Integer(1);
+        String string = a.toString();
+
+    }
+
+    /**
+     * [{"name":"根节点","id":"1","children":[{"name":"二级节点","id":"2","children":[{"name":"三级节点","id":"4","parentId":"2"}],"parentId":"1"},{"name":"二级节点","id":"3","parentId":"1"}]}]
+     */
+}

+ 160 - 0
zkqy-business/src/main/resources/mapper/dragmapper/DragTreeMapper.xml

@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zkqy.business.mapper.DragTreeMapper">
+
+    <resultMap type="com.zkqy.business.entity.DragTree" id="DragTreeResult">
+        <result property="id"    column="id"    />
+        <result property="menuId"    column="menu_id"    />
+        <result property="menuName"    column="menu_name"    />
+        <result property="treeDesc"    column="tree_desc"    />
+        <result property="treeTableName"    column="tree_table_name"    />
+        <result property="treeTablePrimaryKey"    column="tree_table_primary_key"    />
+        <result property="treeTableDgl"    column="tree_table_dgl"    />
+        <result property="treeTableCondition"    column="tree_table_condition"    />
+        <result property="treeTableJoinTable"    column="tree_table_join_table"    />
+        <result property="allJson"    column="all_json"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createById"    column="create_by_id"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateById"    column="update_by_id"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="tableId" column="table_id"/>
+        <result property="tableNameDes" column="table_name_des"/>
+        <result property="treeTableKey" column="tree_table_key"/>
+        <result property="treeShowLabel" column="tree_show_label"/>
+    </resultMap>
+
+    <sql id="selectDragTreeVo">
+        select id, menu_id, menu_name, tree_desc, tree_table_name, tree_table_primary_key, tree_table_dgl, tree_table_condition, tree_table_join_table, table_name_des, del_flag, create_by, create_by_id, create_time, update_by, update_by_id, update_time,table_id,tree_table_key,tree_show_label from {DBNAME}.drag_tree
+    </sql>
+
+    <select id="selectDragTreeList" parameterType="com.zkqy.business.entity.DragTree" resultMap="DragTreeResult">
+        <include refid="selectDragTreeVo"/>
+        <where>
+            <if test="menuId != null "> and menu_id = #{menuId}</if>
+            <if test="menuName != null  and menuName != ''"> and menu_name like concat('%', #{menuName}, '%')</if>
+            <if test="treeDesc != null  and treeDesc != ''"> and tree_desc = #{treeDesc}</if>
+            <if test="treeTableName != null  and treeTableName != ''"> and tree_table_name like concat('%', #{treeTableName}, '%')</if>
+            <if test="treeTablePrimaryKey != null  and treeTablePrimaryKey != ''"> and tree_table_primary_key = #{treeTablePrimaryKey}</if>
+            <if test="treeTableDgl != null  and treeTableDgl != ''"> and tree_table_dgl = #{treeTableDgl}</if>
+            <if test="treeTableCondition != null  and treeTableCondition != ''"> and tree_table_condition = #{treeTableCondition}</if>
+            <if test="treeTableJoinTable != null  and treeTableJoinTable != ''"> and tree_table_join_table = #{treeTableJoinTable}</if>
+            <if test="tableNameDes != null  and tableNameDes != ''"> and table_name_des = #{tableNameDes}</if>
+            <if test="createById != null "> and create_by_id = #{createById}</if>
+            <if test="updateById != null "> and update_by_id = #{updateById}</if>
+            <if test="tableId != null">and table_id=#{tableId},</if>
+            <if test="treeTableKey!=null">and tree_table_key=#{treeTableKey}</if>
+        </where>
+    </select>
+
+    <select id="selectDragTreeById" parameterType="Long" resultMap="DragTreeResult">
+        <include refid="selectDragTreeVo"/>
+        where id = #{id}
+    </select>
+
+    <select id="selectDragTreeByTreeTableKey" resultType="com.zkqy.business.entity.DragTree">
+        <include refid="selectDragTreeVo"/>
+        where tree_table_key = #{id}
+    </select>
+
+
+
+    <select id="selectList" resultType="java.util.HashMap">
+        ${executeSql}
+    </select>
+
+    <select id="allTabColumns" resultType="java.lang.String">
+        SELECT COLUMN_NAME
+        FROM INFORMATION_SCHEMA.COLUMNS
+        WHERE TABLE_SCHEMA = #{dbname}
+          AND TABLE_NAME = #{tableName}
+    </select>
+
+
+
+
+    <insert id="insertDragTree" parameterType="com.zkqy.business.entity.DragTree" useGeneratedKeys="true" keyProperty="id">
+        insert into {DBNAME}.drag_tree
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="menuId != null">menu_id,</if>
+            <if test="menuName != null and menuName != ''">menu_name,</if>
+            <if test="treeDesc != null and treeDesc != ''">tree_desc,</if>
+            <if test="treeTableName != null and treeTableName != ''">tree_table_name,</if>
+            <if test="treeTablePrimaryKey != null">tree_table_primary_key,</if>
+            <if test="treeTableDgl != null">tree_table_dgl,</if>
+            <if test="treeTableCondition != null">tree_table_condition,</if>
+            <if test="treeTableJoinTable != null">tree_table_join_table,</if>
+            <if test="tableNameDes != null">`table_name_des`,</if>
+            <if test="delFlag != null">del_flag,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createById != null">create_by_id,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateById != null">update_by_id,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="tableId != null">table_id,</if>
+            <if test="treeTableKey!=null">tree_table_key,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="menuId != null">#{menuId},</if>
+            <if test="menuName != null and menuName != ''">#{menuName},</if>
+            <if test="treeDesc != null and treeDesc != ''">#{treeDesc},</if>
+            <if test="treeTableName != null and treeTableName != ''">#{treeTableName},</if>
+            <if test="treeTablePrimaryKey != null">#{treeTablePrimaryKey},</if>
+            <if test="treeTableDgl != null">#{treeTableDgl},</if>
+            <if test="treeTableCondition != null">#{treeTableCondition},</if>
+            <if test="treeTableJoinTable != null">#{treeTableJoinTable},</if>
+            <if test="tableNameDes != null">#{tableNameDes},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createById != null">#{createById},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateById != null">#{updateById},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="tableId != null">#{tableId},</if>
+            <if test="treeTableKey!=null">#{treeTableKey}</if>
+        </trim>
+    </insert>
+
+    <update id="updateDragTree" parameterType="com.zkqy.business.entity.DragTree">
+        update {DBNAME}.drag_tree
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="menuId != null">menu_id = #{menuId},</if>
+            <if test="menuName != null and menuName != ''">menu_name = #{menuName},</if>
+            <if test="treeDesc != null and treeDesc != ''">tree_desc = #{treeDesc},</if>
+            <if test="treeTableName != null and treeTableName != ''">tree_table_name = #{treeTableName},</if>
+            <if test="treeTablePrimaryKey != null">tree_table_primary_key = #{treeTablePrimaryKey},</if>
+            <if test="treeTableDgl != null">tree_table_dgl = #{treeTableDgl},</if>
+            <if test="treeTableCondition != null">tree_table_condition = #{treeTableCondition},</if>
+            <if test="treeTableJoinTable != null">tree_table_join_table = #{treeTableJoinTable},</if>
+            <if test="tableNameDes != null">`table_name_des`= #{tableNameDes},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createById != null">create_by_id = #{createById},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateById != null">update_by_id = #{updateById},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="tableId != null">table_id=#{tableId},</if>
+            <if test="treeTableKey!=null">tree_table_key=#{treeTableKey}</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteDragTreeById" parameterType="Long">
+        delete from {DBNAME}.drag_tree where id = #{id}
+    </delete>
+
+    <delete id="deleteDragTreeByIds" parameterType="String">
+        delete from {DBNAME}.drag_tree where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+</mapper>

+ 4 - 0
zkqy-common/src/main/java/com/zkqy/common/exception/base/BaseException.java

@@ -2,12 +2,14 @@ package com.zkqy.common.exception.base;
 
 import com.zkqy.common.utils.MessageUtils;
 import com.zkqy.common.utils.StringUtils;
+import lombok.Builder;
 
 /**
  * 基础异常
  * 
  * @author ruoyi
  */
+@Builder
 public class BaseException extends RuntimeException
 {
     private static final long serialVersionUID = 1L;
@@ -60,6 +62,8 @@ public class BaseException extends RuntimeException
         this(null, null, null, defaultMessage);
     }
 
+
+
     @Override
     public String getMessage()
     {

+ 1 - 0
zkqy-process-execution/src/main/java/com/zkqy/execution/produce/dispersed/entity/CommonEntity.java

@@ -94,6 +94,7 @@ public class CommonEntity extends BaseEntity implements Serializable,Cloneable {
     public CommonEntity clone() throws CloneNotSupportedException {
         return (CommonEntity) super.clone();
     }
+
     public CommonEntity(Map<String, Object> basicMap, Map<String, Object> queryMap, Map<String, Object> conditionMap, Map<String, Object> resultMap, Map<String, Object> commMap, List<Map<String, String>> addListMap, String execlMap, Map<String, Object> btnParametersMap) {
         this.basicMap = basicMap;
         this.queryMap = queryMap;