Browse Source

feat:动态表格数据统计接口

xuezizhuo 1 year ago
parent
commit
1e7960e170

+ 152 - 0
ruoyi-system/src/main/java/com/ruoyi/system/entity/DragTableStatistic.java

@@ -0,0 +1,152 @@
+package com.ruoyi.system.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 动态格统计对象 drag_table_statistic
+ * 
+ * @author ruoyi
+ * @date 2023-10-27
+ */
+public class DragTableStatistic extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 编号 */
+    private Long id;
+
+    /** 统计标题 */
+    @Excel(name = "统计标题")
+    private String statisticTitle;
+
+    /** 表格key */
+    @Excel(name = "表格key")
+    private String tableKey;
+
+    /** 统计描述 */
+    @Excel(name = "统计描述")
+    private String statisticDescription;
+
+    /** 统计类型 */
+    @Excel(name = "统计类型")
+    private Long statisticType;
+
+    /** 统计字段 */
+    @Excel(name = "统计字段")
+    private String statisticField;
+
+    /** 统计对象 */
+    @Excel(name = "统计对象")
+    private String statisticObject;
+
+    /** 执行sql */
+    @Excel(name = "执行sql")
+    private String executeSql;
+
+    /** 删除标志(0:否;2:是) */
+    private String delFlag;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setStatisticTitle(String statisticTitle) 
+    {
+        this.statisticTitle = statisticTitle;
+    }
+
+    public String getStatisticTitle() 
+    {
+        return statisticTitle;
+    }
+    public void setTableKey(String tableKey) 
+    {
+        this.tableKey = tableKey;
+    }
+
+    public String getTableKey() 
+    {
+        return tableKey;
+    }
+    public void setStatisticDescription(String statisticDescription) 
+    {
+        this.statisticDescription = statisticDescription;
+    }
+
+    public String getStatisticDescription() 
+    {
+        return statisticDescription;
+    }
+    public void setStatisticType(Long statisticType) 
+    {
+        this.statisticType = statisticType;
+    }
+
+    public Long getStatisticType() 
+    {
+        return statisticType;
+    }
+    public void setStatisticField(String statisticField) 
+    {
+        this.statisticField = statisticField;
+    }
+
+    public String getStatisticField() 
+    {
+        return statisticField;
+    }
+    public void setStatisticObject(String statisticObject) 
+    {
+        this.statisticObject = statisticObject;
+    }
+
+    public String getStatisticObject() 
+    {
+        return statisticObject;
+    }
+    public void setExecuteSql(String executeSql) 
+    {
+        this.executeSql = executeSql;
+    }
+
+    public String getExecuteSql() 
+    {
+        return executeSql;
+    }
+    public void setDelFlag(String delFlag) 
+    {
+        this.delFlag = delFlag;
+    }
+
+    public String getDelFlag() 
+    {
+        return delFlag;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("statisticTitle", getStatisticTitle())
+            .append("tableKey", getTableKey())
+            .append("statisticDescription", getStatisticDescription())
+            .append("statisticType", getStatisticType())
+            .append("statisticField", getStatisticField())
+            .append("statisticObject", getStatisticObject())
+            .append("executeSql", getExecuteSql())
+            .append("delFlag", getDelFlag())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .toString();
+    }
+}

+ 39 - 25
ruoyi-system/src/main/java/com/ruoyi/system/entity/vo/DragTableVo.java

@@ -2,6 +2,7 @@ package com.ruoyi.system.entity.vo;
 
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
+import com.ruoyi.system.entity.DragTableStatistic;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
@@ -109,30 +110,8 @@ public class DragTableVo {
      */
     private String sortOrder;
 
-    @Override
-    public String toString() {
-        return "DragTableVo{" +
-                "tId=" + tId +
-                ", dtName='" + dtName + '\'' +
-                ", dtNickname='" + dtNickname + '\'' +
-                ", tableKey='" + tableKey + '\'' +
-                ", sqlKey='" + sqlKey + '\'' +
-                ", dtTableName='" + dtTableName + '\'' +
-                ", dtColumnName=" + dtColumnName +
-                ", dtColumnNameEcho='" + dtColumnNameEcho + '\'' +
-                ", timeFormat='" + timeFormat + '\'' +
-                ", isSelection='" + isSelection + '\'' +
-                ", searchFieldList=" + searchFieldList +
-                ", tableSql='" + tableSql + '\'' +
-                ", tableExportField=" + tableExportField +
-                ", tableExportFieldEcho=" + tableExportFieldEcho +
-                ", echoData='" + echoData + '\'' +
-                ", menuId=" + menuId +
-                ", primaryKey='" + primaryKey + '\'' +
-                ", orderByColumn='" + orderByColumn + '\'' +
-                ", sortOrder='" + sortOrder + '\'' +
-                '}';
-    }
+    /** 表格统计 */
+    private List<DragTableStatistic> dragTableStatisticList;
 
     public Long gettId() {
         return tId;
@@ -286,10 +265,18 @@ public class DragTableVo {
         this.sortOrder = sortOrder;
     }
 
+    public List<DragTableStatistic> getDragTableStatisticList() {
+        return dragTableStatisticList;
+    }
+
+    public void setDragTableStatisticList(List<DragTableStatistic> dragTableStatisticList) {
+        this.dragTableStatisticList = dragTableStatisticList;
+    }
+
     public DragTableVo() {
     }
 
-    public DragTableVo(Long tId, String dtName, String dtNickname, String tableKey, String sqlKey, String dtTableName, Object dtColumnName, String dtColumnNameEcho, String timeFormat, String isSelection, List<String> searchFieldList, String tableSql, Object tableExportField, String tableExportFieldEcho, String echoData, Long menuId, String primaryKey, String orderByColumn, String sortOrder) {
+    public DragTableVo(Long tId, String dtName, String dtNickname, String tableKey, String sqlKey, String dtTableName, Object dtColumnName, String dtColumnNameEcho, String timeFormat, String isSelection, List<String> searchFieldList, String tableSql, Object tableExportField, String tableExportFieldEcho, String echoData, Long menuId, String primaryKey, String orderByColumn, String sortOrder, List<DragTableStatistic> dragTableStatisticList) {
         this.tId = tId;
         this.dtName = dtName;
         this.dtNickname = dtNickname;
@@ -309,5 +296,32 @@ public class DragTableVo {
         this.primaryKey = primaryKey;
         this.orderByColumn = orderByColumn;
         this.sortOrder = sortOrder;
+        this.dragTableStatisticList = dragTableStatisticList;
+    }
+
+    @Override
+    public String toString() {
+        return "DragTableVo{" +
+                "tId=" + tId +
+                ", dtName='" + dtName + '\'' +
+                ", dtNickname='" + dtNickname + '\'' +
+                ", tableKey='" + tableKey + '\'' +
+                ", sqlKey='" + sqlKey + '\'' +
+                ", dtTableName='" + dtTableName + '\'' +
+                ", dtColumnName=" + dtColumnName +
+                ", dtColumnNameEcho='" + dtColumnNameEcho + '\'' +
+                ", timeFormat='" + timeFormat + '\'' +
+                ", isSelection='" + isSelection + '\'' +
+                ", searchFieldList=" + searchFieldList +
+                ", tableSql='" + tableSql + '\'' +
+                ", tableExportField=" + tableExportField +
+                ", tableExportFieldEcho='" + tableExportFieldEcho + '\'' +
+                ", echoData='" + echoData + '\'' +
+                ", menuId=" + menuId +
+                ", primaryKey='" + primaryKey + '\'' +
+                ", orderByColumn='" + orderByColumn + '\'' +
+                ", sortOrder='" + sortOrder + '\'' +
+                ", dragTableStatisticList=" + dragTableStatisticList +
+                '}';
     }
 }

+ 63 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/DragTableStatisticMapper.java

@@ -0,0 +1,63 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.entity.DragTableStatistic;
+
+import java.util.List;
+
+/**
+ * 动态格统计Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2023-10-27
+ */
+public interface DragTableStatisticMapper 
+{
+    /**
+     * 查询动态格统计
+     * 
+     * @param id 动态格统计主键
+     * @return 动态格统计
+     */
+    DragTableStatistic selectDragTableStatisticById(Long id);
+
+    /**
+     * 查询动态格统计列表
+     * 
+     * @param dragTableStatistic 动态格统计
+     * @return 动态格统计集合
+     */
+    List<DragTableStatistic> selectDragTableStatisticList(DragTableStatistic dragTableStatistic);
+
+    /**
+     * 新增动态格统计
+     * 
+     * @param dragTableStatisticList 动态格统计
+     * @return 结果
+     */
+    int batchInsertDragTableStatistic(List<DragTableStatistic> dragTableStatisticList);
+
+    /**
+     * 修改动态格统计
+     * 
+     * @param dragTableStatistic 动态格统计
+     * @return 结果
+     */
+    int updateDragTableStatistic(DragTableStatistic dragTableStatistic);
+
+    /**
+     * 删除动态格统计
+     * 
+     * @param id 动态格统计主键
+     * @return 结果
+     */
+    int deleteDragTableStatisticById(Long id);
+
+    /**
+     * 批量删除动态格统计
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteDragTableStatisticByIds(Long[] ids);
+
+}

+ 9 - 9
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DragTableServiceImpl.java

@@ -16,14 +16,11 @@ import com.ruoyi.system.entity.DragTable;
 import com.ruoyi.system.entity.DragTableCondition;
 import com.ruoyi.system.entity.TableSql;
 import com.ruoyi.system.entity.vo.DragTableVo;
-import com.ruoyi.system.mapper.CommonMapper;
-import com.ruoyi.system.mapper.DragTableConditionMapper;
-import com.ruoyi.system.mapper.TableSqlMapper;
+import com.ruoyi.system.mapper.*;
 import org.apache.ibatis.jdbc.SQL;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.system.mapper.DragTableMapper;
 import com.ruoyi.system.service.IDragTableService;
 import org.springframework.transaction.TransactionStatus;
 import org.springframework.transaction.annotation.Propagation;
@@ -56,6 +53,9 @@ public class DragTableServiceImpl implements IDragTableService {
     @Resource
     private TransactionTemplate transactionTemplate;
 
+    @Resource
+    private DragTableStatisticMapper dragTableStatisticMapper;
+
     /**
      * 查询动态表格
      *
@@ -162,14 +162,9 @@ public class DragTableServiceImpl implements IDragTableService {
     @Override
     public void addDragTable(DragTableVo dragTableVo) {
         String SQL = "";
-        //生成dtNickname表格别名
-        String dtNickname = IdUtils.fastSimpleUUID();
-        //生成sqlKey唯一标识
-//        String sqlKey = IdUtils.fastSimpleUUID();
         //add drag_table
         DragTable dragTable = new DragTable();
         BeanUtils.copyProperties(dragTableVo, dragTable);
-        //dragTable.setDtTableName(dtNickname);
         dragTable.setDtColumnName(JSON.toJSONString(dragTableVo.getDtColumnName()));
         dragTable.setPrimaryKey(dragTableVo.getPrimaryKey());
         dragTable.setMenuId(dragTableVo.getMenuId());
@@ -219,6 +214,11 @@ public class DragTableServiceImpl implements IDragTableService {
             });
             dragTableConditionMapper.insertDragTableConditionByList(dragTableConditionList);
         }
+        //add drag_table_statistic
+//        if(dragTableVo.getDragTableStatisticList().size() > 0){
+//            dragTableStatisticMapper.batchInsertDragTableStatistic(dragTableVo.getDragTableStatisticList());
+//        }
+
     }
 
     @Override

+ 77 - 0
ruoyi-system/src/main/resources/mapper/dragmapper/DragTableStatisticMapper.xml

@@ -0,0 +1,77 @@
+<?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.ruoyi.system.mapper.DragTableStatisticMapper">
+    
+    <resultMap type="com.ruoyi.system.entity.DragTableStatistic" id="DragTableStatisticResult">
+        <result property="id"    column="id"    />
+        <result property="statisticTitle"    column="statistic_title"    />
+        <result property="tableKey"    column="table_key"    />
+        <result property="statisticDescription"    column="statistic_description"    />
+        <result property="statisticType"    column="statistic_type"    />
+        <result property="statisticField"    column="statistic_field"    />
+        <result property="statisticObject"    column="statistic_object"    />
+        <result property="executeSql"    column="execute_sql"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectDragTableStatisticVo">
+        select id, statistic_title, table_key, statistic_description, statistic_type, statistic_field, statistic_object, execute_sql, del_flag, create_by, create_time, update_by, update_time from drag_table_statistic
+    </sql>
+
+    <select id="selectDragTableStatisticList" parameterType="com.ruoyi.system.entity.DragTableStatistic" resultMap="DragTableStatisticResult">
+        <include refid="selectDragTableStatisticVo"/>
+        where  del_flag = '0'
+            <if test="statisticTitle != null  and statisticTitle != ''"> and statistic_title = #{statisticTitle}</if>
+            <if test="tableKey != null  and tableKey != ''"> and table_key = #{tableKey}</if>
+            <if test="statisticDescription != null  and statisticDescription != ''"> and statistic_description = #{statisticDescription}</if>
+            <if test="statisticType != null "> and statistic_type = #{statisticType}</if>
+            <if test="statisticField != null  and statisticField != ''"> and statistic_field = #{statisticField}</if>
+            <if test="statisticObject != null  and statisticObject != ''"> and statistic_object = #{statisticObject}</if>
+            <if test="executeSql != null  and executeSql != ''"> and execute_sql = #{executeSql}</if>
+    </select>
+
+    <select id="selectDragTableStatisticById" parameterType="Long" resultMap="DragTableStatisticResult">
+        <include refid="selectDragTableStatisticVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="batchInsertDragTableStatistic" parameterType="com.ruoyi.system.entity.DragTableStatistic" useGeneratedKeys="true" keyProperty="id">
+        insert into drag_table_statistic
+            (statistic_title,table_key,statistic_description,statistic_type,statistic_field,statistic_object,execute_sql,create_by,create_time,del_flag)
+            values
+            (#{statisticTitle},#{tableKey},#{statisticDescription},#{statisticType},#{statisticField},#{statisticObject},#{executeSql},#{createBy},#{createTime},'0')
+    </insert>
+
+    <update id="updateDragTableStatistic" parameterType="com.ruoyi.system.entity.DragTableStatistic">
+        update drag_table_statistic
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="statisticTitle != null">statistic_title = #{statisticTitle},</if>
+            <if test="tableKey != null">table_key = #{tableKey},</if>
+            <if test="statisticDescription != null">statistic_description = #{statisticDescription},</if>
+            <if test="statisticType != null">statistic_type = #{statisticType},</if>
+            <if test="statisticField != null">statistic_field = #{statisticField},</if>
+            <if test="statisticObject != null">statistic_object = #{statisticObject},</if>
+            <if test="executeSql != null">execute_sql = #{executeSql},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <update id="deleteDragTableStatisticById" parameterType="Long">
+        update drag_table_statistic set del_flag = '2' where id = #{id}
+    </update>
+
+    <delete id="deleteDragTableStatisticByIds" parameterType="String">
+        update drag_table_statistic set del_flag = '2' where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>