feat(视图): 视图编辑保存,横纵维度指标,EChart展示

This commit is contained in:
junjie
2021-03-01 18:03:11 +08:00
parent 8fca61aeb0
commit b6117d658a
22 changed files with 1965 additions and 164 deletions

View File

@@ -0,0 +1,27 @@
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class ChartView implements Serializable {
private String id;
private String name;
private String sceneId;
private String tableId;
private String type;
private String title;
private String createBy;
private Long createTime;
private Long updateTime;
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,810 @@
package io.dataease.base.domain;
import java.util.ArrayList;
import java.util.List;
public class ChartViewExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public ChartViewExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("`name` is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("`name` is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("`name` =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("`name` <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("`name` >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("`name` >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("`name` <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("`name` <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("`name` like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("`name` not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("`name` not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("`name` between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("`name` not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andSceneIdIsNull() {
addCriterion("scene_id is null");
return (Criteria) this;
}
public Criteria andSceneIdIsNotNull() {
addCriterion("scene_id is not null");
return (Criteria) this;
}
public Criteria andSceneIdEqualTo(String value) {
addCriterion("scene_id =", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdNotEqualTo(String value) {
addCriterion("scene_id <>", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdGreaterThan(String value) {
addCriterion("scene_id >", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdGreaterThanOrEqualTo(String value) {
addCriterion("scene_id >=", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdLessThan(String value) {
addCriterion("scene_id <", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdLessThanOrEqualTo(String value) {
addCriterion("scene_id <=", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdLike(String value) {
addCriterion("scene_id like", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdNotLike(String value) {
addCriterion("scene_id not like", value, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdIn(List<String> values) {
addCriterion("scene_id in", values, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdNotIn(List<String> values) {
addCriterion("scene_id not in", values, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdBetween(String value1, String value2) {
addCriterion("scene_id between", value1, value2, "sceneId");
return (Criteria) this;
}
public Criteria andSceneIdNotBetween(String value1, String value2) {
addCriterion("scene_id not between", value1, value2, "sceneId");
return (Criteria) this;
}
public Criteria andTableIdIsNull() {
addCriterion("table_id is null");
return (Criteria) this;
}
public Criteria andTableIdIsNotNull() {
addCriterion("table_id is not null");
return (Criteria) this;
}
public Criteria andTableIdEqualTo(String value) {
addCriterion("table_id =", value, "tableId");
return (Criteria) this;
}
public Criteria andTableIdNotEqualTo(String value) {
addCriterion("table_id <>", value, "tableId");
return (Criteria) this;
}
public Criteria andTableIdGreaterThan(String value) {
addCriterion("table_id >", value, "tableId");
return (Criteria) this;
}
public Criteria andTableIdGreaterThanOrEqualTo(String value) {
addCriterion("table_id >=", value, "tableId");
return (Criteria) this;
}
public Criteria andTableIdLessThan(String value) {
addCriterion("table_id <", value, "tableId");
return (Criteria) this;
}
public Criteria andTableIdLessThanOrEqualTo(String value) {
addCriterion("table_id <=", value, "tableId");
return (Criteria) this;
}
public Criteria andTableIdLike(String value) {
addCriterion("table_id like", value, "tableId");
return (Criteria) this;
}
public Criteria andTableIdNotLike(String value) {
addCriterion("table_id not like", value, "tableId");
return (Criteria) this;
}
public Criteria andTableIdIn(List<String> values) {
addCriterion("table_id in", values, "tableId");
return (Criteria) this;
}
public Criteria andTableIdNotIn(List<String> values) {
addCriterion("table_id not in", values, "tableId");
return (Criteria) this;
}
public Criteria andTableIdBetween(String value1, String value2) {
addCriterion("table_id between", value1, value2, "tableId");
return (Criteria) this;
}
public Criteria andTableIdNotBetween(String value1, String value2) {
addCriterion("table_id not between", value1, value2, "tableId");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("`type` like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("`type` not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTitleIsNull() {
addCriterion("title is null");
return (Criteria) this;
}
public Criteria andTitleIsNotNull() {
addCriterion("title is not null");
return (Criteria) this;
}
public Criteria andTitleEqualTo(String value) {
addCriterion("title =", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotEqualTo(String value) {
addCriterion("title <>", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThan(String value) {
addCriterion("title >", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThanOrEqualTo(String value) {
addCriterion("title >=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThan(String value) {
addCriterion("title <", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThanOrEqualTo(String value) {
addCriterion("title <=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLike(String value) {
addCriterion("title like", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotLike(String value) {
addCriterion("title not like", value, "title");
return (Criteria) this;
}
public Criteria andTitleIn(List<String> values) {
addCriterion("title in", values, "title");
return (Criteria) this;
}
public Criteria andTitleNotIn(List<String> values) {
addCriterion("title not in", values, "title");
return (Criteria) this;
}
public Criteria andTitleBetween(String value1, String value2) {
addCriterion("title between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andTitleNotBetween(String value1, String value2) {
addCriterion("title not between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andCreateByIsNull() {
addCriterion("create_by is null");
return (Criteria) this;
}
public Criteria andCreateByIsNotNull() {
addCriterion("create_by is not null");
return (Criteria) this;
}
public Criteria andCreateByEqualTo(String value) {
addCriterion("create_by =", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotEqualTo(String value) {
addCriterion("create_by <>", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByGreaterThan(String value) {
addCriterion("create_by >", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByGreaterThanOrEqualTo(String value) {
addCriterion("create_by >=", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLessThan(String value) {
addCriterion("create_by <", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLessThanOrEqualTo(String value) {
addCriterion("create_by <=", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByLike(String value) {
addCriterion("create_by like", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotLike(String value) {
addCriterion("create_by not like", value, "createBy");
return (Criteria) this;
}
public Criteria andCreateByIn(List<String> values) {
addCriterion("create_by in", values, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotIn(List<String> values) {
addCriterion("create_by not in", values, "createBy");
return (Criteria) this;
}
public Criteria andCreateByBetween(String value1, String value2) {
addCriterion("create_by between", value1, value2, "createBy");
return (Criteria) this;
}
public Criteria andCreateByNotBetween(String value1, String value2) {
addCriterion("create_by not between", value1, value2, "createBy");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Long value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Long value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Long value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Long value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@@ -0,0 +1,23 @@
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ChartViewWithBLOBs extends ChartView implements Serializable {
private String xAxis;
private String yAxis;
private String customAttr;
private String customStyle;
private String customFilter;
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,37 @@
package io.dataease.base.mapper;
import io.dataease.base.domain.ChartView;
import io.dataease.base.domain.ChartViewExample;
import io.dataease.base.domain.ChartViewWithBLOBs;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ChartViewMapper {
long countByExample(ChartViewExample example);
int deleteByExample(ChartViewExample example);
int deleteByPrimaryKey(String id);
int insert(ChartViewWithBLOBs record);
int insertSelective(ChartViewWithBLOBs record);
List<ChartViewWithBLOBs> selectByExampleWithBLOBs(ChartViewExample example);
List<ChartView> selectByExample(ChartViewExample example);
ChartViewWithBLOBs selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") ChartViewWithBLOBs record, @Param("example") ChartViewExample example);
int updateByExampleWithBLOBs(@Param("record") ChartViewWithBLOBs record, @Param("example") ChartViewExample example);
int updateByExample(@Param("record") ChartView record, @Param("example") ChartViewExample example);
int updateByPrimaryKeySelective(ChartViewWithBLOBs record);
int updateByPrimaryKeyWithBLOBs(ChartViewWithBLOBs record);
int updateByPrimaryKey(ChartView record);
}

View File

@@ -0,0 +1,402 @@
<?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="io.dataease.base.mapper.ChartViewMapper">
<resultMap id="BaseResultMap" type="io.dataease.base.domain.ChartView">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="scene_id" jdbcType="VARCHAR" property="sceneId" />
<result column="table_id" jdbcType="VARCHAR" property="tableId" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.dataease.base.domain.ChartViewWithBLOBs">
<result column="x_axis" jdbcType="LONGVARCHAR" property="xAxis" />
<result column="y_axis" jdbcType="LONGVARCHAR" property="yAxis" />
<result column="custom_attr" jdbcType="LONGVARCHAR" property="customAttr" />
<result column="custom_style" jdbcType="LONGVARCHAR" property="customStyle" />
<result column="custom_filter" jdbcType="LONGVARCHAR" property="customFilter" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time
</sql>
<sql id="Blob_Column_List">
x_axis, y_axis, custom_attr, custom_style, custom_filter
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.dataease.base.domain.ChartViewExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from chart_view
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.dataease.base.domain.ChartViewExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from chart_view
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from chart_view
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from chart_view
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.dataease.base.domain.ChartViewExample">
delete from chart_view
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.ChartViewWithBLOBs">
insert into chart_view (id, `name`, scene_id,
table_id, `type`, title,
create_by, create_time, update_time,
x_axis, y_axis, custom_attr,
custom_style, custom_filter)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{sceneId,jdbcType=VARCHAR},
#{tableId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{xAxis,jdbcType=LONGVARCHAR}, #{yAxis,jdbcType=LONGVARCHAR}, #{customAttr,jdbcType=LONGVARCHAR},
#{customStyle,jdbcType=LONGVARCHAR}, #{customFilter,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.ChartViewWithBLOBs">
insert into chart_view
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
`name`,
</if>
<if test="sceneId != null">
scene_id,
</if>
<if test="tableId != null">
table_id,
</if>
<if test="type != null">
`type`,
</if>
<if test="title != null">
title,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="xAxis != null">
x_axis,
</if>
<if test="yAxis != null">
y_axis,
</if>
<if test="customAttr != null">
custom_attr,
</if>
<if test="customStyle != null">
custom_style,
</if>
<if test="customFilter != null">
custom_filter,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="sceneId != null">
#{sceneId,jdbcType=VARCHAR},
</if>
<if test="tableId != null">
#{tableId,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="xAxis != null">
#{xAxis,jdbcType=LONGVARCHAR},
</if>
<if test="yAxis != null">
#{yAxis,jdbcType=LONGVARCHAR},
</if>
<if test="customAttr != null">
#{customAttr,jdbcType=LONGVARCHAR},
</if>
<if test="customStyle != null">
#{customStyle,jdbcType=LONGVARCHAR},
</if>
<if test="customFilter != null">
#{customFilter,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.dataease.base.domain.ChartViewExample" resultType="java.lang.Long">
select count(*) from chart_view
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update chart_view
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.sceneId != null">
scene_id = #{record.sceneId,jdbcType=VARCHAR},
</if>
<if test="record.tableId != null">
table_id = #{record.tableId,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.title != null">
title = #{record.title,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
<if test="record.xAxis != null">
x_axis = #{record.xAxis,jdbcType=LONGVARCHAR},
</if>
<if test="record.yAxis != null">
y_axis = #{record.yAxis,jdbcType=LONGVARCHAR},
</if>
<if test="record.customAttr != null">
custom_attr = #{record.customAttr,jdbcType=LONGVARCHAR},
</if>
<if test="record.customStyle != null">
custom_style = #{record.customStyle,jdbcType=LONGVARCHAR},
</if>
<if test="record.customFilter != null">
custom_filter = #{record.customFilter,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update chart_view
set id = #{record.id,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
scene_id = #{record.sceneId,jdbcType=VARCHAR},
table_id = #{record.tableId,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
title = #{record.title,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
x_axis = #{record.xAxis,jdbcType=LONGVARCHAR},
y_axis = #{record.yAxis,jdbcType=LONGVARCHAR},
custom_attr = #{record.customAttr,jdbcType=LONGVARCHAR},
custom_style = #{record.customStyle,jdbcType=LONGVARCHAR},
custom_filter = #{record.customFilter,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update chart_view
set id = #{record.id,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
scene_id = #{record.sceneId,jdbcType=VARCHAR},
table_id = #{record.tableId,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=VARCHAR},
title = #{record.title,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.ChartViewWithBLOBs">
update chart_view
<set>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="sceneId != null">
scene_id = #{sceneId,jdbcType=VARCHAR},
</if>
<if test="tableId != null">
table_id = #{tableId,jdbcType=VARCHAR},
</if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="xAxis != null">
x_axis = #{xAxis,jdbcType=LONGVARCHAR},
</if>
<if test="yAxis != null">
y_axis = #{yAxis,jdbcType=LONGVARCHAR},
</if>
<if test="customAttr != null">
custom_attr = #{customAttr,jdbcType=LONGVARCHAR},
</if>
<if test="customStyle != null">
custom_style = #{customStyle,jdbcType=LONGVARCHAR},
</if>
<if test="customFilter != null">
custom_filter = #{customFilter,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.dataease.base.domain.ChartViewWithBLOBs">
update chart_view
set `name` = #{name,jdbcType=VARCHAR},
scene_id = #{sceneId,jdbcType=VARCHAR},
table_id = #{tableId,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
title = #{title,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
x_axis = #{xAxis,jdbcType=LONGVARCHAR},
y_axis = #{yAxis,jdbcType=LONGVARCHAR},
custom_attr = #{customAttr,jdbcType=LONGVARCHAR},
custom_style = #{customStyle,jdbcType=LONGVARCHAR},
custom_filter = #{customFilter,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.ChartView">
update chart_view
set `name` = #{name,jdbcType=VARCHAR},
scene_id = #{sceneId,jdbcType=VARCHAR},
table_id = #{tableId,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
title = #{title,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@@ -0,0 +1,47 @@
package io.dataease.controller.chart;
import io.dataease.base.domain.ChartViewWithBLOBs;
import io.dataease.controller.request.chart.ChartViewRequest;
import io.dataease.dto.chart.ChartViewDTO;
import io.dataease.service.chart.ChartViewService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* @Author gin
* @Date 2021/3/1 1:17 下午
*/
@RestController
@RequestMapping("/chart/view")
public class ChartViewController {
@Resource
private ChartViewService chartViewService;
@PostMapping("/save")
public ChartViewWithBLOBs save(@RequestBody ChartViewWithBLOBs chartViewWithBLOBs) {
return chartViewService.save(chartViewWithBLOBs);
}
@PostMapping("/list")
public List<ChartViewWithBLOBs> list(@RequestBody ChartViewRequest chartViewRequest) {
return chartViewService.list(chartViewRequest);
}
@PostMapping("/get/{id}")
public ChartViewWithBLOBs get(@PathVariable String id) {
return chartViewService.get(id);
}
@PostMapping("/delete/{id}")
public void delete(@PathVariable String id) {
chartViewService.delete(id);
}
@PostMapping("/getData/{id}")
public ChartViewDTO getData(@PathVariable String id) throws Exception {
return chartViewService.getData(id);
}
}

View File

@@ -1,6 +1,7 @@
package io.dataease.controller.dataset;
import io.dataease.base.domain.DatasetTable;
import io.dataease.base.domain.DatasetTableField;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.datasource.dto.TableFiled;
import io.dataease.service.dataset.DataSetTableService;
@@ -50,6 +51,11 @@ public class DataSetTableController {
return dataSetTableService.getFields(dataSetTableRequest);
}
@PostMapping("getFieldsFromDE")
public Map<String, List<DatasetTableField>> getFieldsFromDE(@RequestBody DataSetTableRequest dataSetTableRequest) throws Exception {
return dataSetTableService.getFieldsFromDE(dataSetTableRequest);
}
@PostMapping("getData")
public List<String[]> getData(@RequestBody DataSetTableRequest dataSetTableRequest) throws Exception {
return dataSetTableService.getData(dataSetTableRequest);

View File

@@ -0,0 +1,15 @@
package io.dataease.controller.request.chart;
import io.dataease.base.domain.ChartViewWithBLOBs;
import lombok.Getter;
import lombok.Setter;
/**
* @Author gin
* @Date 2021/3/1 1:32 下午
*/
@Setter
@Getter
public class ChartViewRequest extends ChartViewWithBLOBs {
private String sort;
}

View File

@@ -74,4 +74,8 @@ public class DatasourceService {
return datasourceProvider.getTables(datasourceRequest);
}
public Datasource get(String id) {
return datasourceMapper.selectByPrimaryKey(id);
}
}

View File

@@ -0,0 +1,17 @@
package io.dataease.dto.chart;
import io.dataease.base.domain.ChartViewWithBLOBs;
import lombok.Getter;
import lombok.Setter;
import java.util.Map;
/**
* @Author gin
* @Date 2021/3/1 4:19 下午
*/
@Setter
@Getter
public class ChartViewDTO extends ChartViewWithBLOBs {
private Map<String, Object> data;
}

View File

@@ -0,0 +1,19 @@
package io.dataease.dto.chart;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.util.List;
/**
* @Author gin
* @Date 2021/3/1 3:51 下午
*/
@Getter
@Setter
public class Series {
private String name;
private String type;
private List<BigDecimal> data;
}

View File

@@ -0,0 +1,159 @@
package io.dataease.service.chart;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import io.dataease.base.domain.*;
import io.dataease.base.mapper.ChartViewMapper;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.controller.request.chart.ChartViewRequest;
import io.dataease.datasource.constants.DatasourceTypes;
import io.dataease.datasource.provider.DatasourceProvider;
import io.dataease.datasource.provider.ProviderFactory;
import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.datasource.service.DatasourceService;
import io.dataease.dto.chart.ChartViewDTO;
import io.dataease.dto.chart.Series;
import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.service.dataset.DataSetTableFieldsService;
import io.dataease.service.dataset.DataSetTableService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author gin
* @Date 2021/3/1 12:34 下午
*/
@Service
public class ChartViewService {
@Resource
private ChartViewMapper chartViewMapper;
@Resource
private DataSetTableService dataSetTableService;
@Resource
private DatasourceService datasourceService;
@Resource
private DataSetTableFieldsService dataSetTableFieldsService;
public ChartViewWithBLOBs save(ChartViewWithBLOBs chartView) {
long timestamp = System.currentTimeMillis();
chartView.setUpdateTime(timestamp);
int i = chartViewMapper.updateByPrimaryKeyWithBLOBs(chartView);
if (i == 0) {
chartView.setId(UUID.randomUUID().toString());
chartView.setCreateTime(timestamp);
chartView.setUpdateTime(timestamp);
chartViewMapper.insert(chartView);
}
return chartView;
}
public List<ChartViewWithBLOBs> list(ChartViewRequest chartViewRequest) {
ChartViewExample chartViewExample = new ChartViewExample();
ChartViewExample.Criteria criteria = chartViewExample.createCriteria();
if (StringUtils.isNotEmpty(chartViewRequest.getSceneId())) {
criteria.andSceneIdEqualTo(chartViewRequest.getSceneId());
}
if (StringUtils.isNotEmpty(chartViewRequest.getSort())) {
chartViewExample.setOrderByClause(chartViewRequest.getSort());
}
return chartViewMapper.selectByExampleWithBLOBs(chartViewExample);
}
public ChartViewWithBLOBs get(String id) {
return chartViewMapper.selectByPrimaryKey(id);
}
public void delete(String id) {
chartViewMapper.deleteByPrimaryKey(id);
}
public ChartViewDTO getData(String id) throws Exception {
ChartViewWithBLOBs view = chartViewMapper.selectByPrimaryKey(id);
List<DatasetTableField> xAxis = new Gson().fromJson(view.getXAxis(), new TypeToken<List<DatasetTableField>>() {
}.getType());
List<DatasetTableField> yAxis = new Gson().fromJson(view.getYAxis(), new TypeToken<List<DatasetTableField>>() {
}.getType());
List<String> x = new ArrayList<>();
List<Series> series = new ArrayList<>();
if (CollectionUtils.isEmpty(xAxis) || CollectionUtils.isEmpty(yAxis)) {
ChartViewDTO dto = new ChartViewDTO();
BeanUtils.copyBean(dto, view);
return dto;
}
List<String> xIds = xAxis.stream().map(DatasetTableField::getId).collect(Collectors.toList());
List<String> yIds = yAxis.stream().map(DatasetTableField::getId).collect(Collectors.toList());
List<DatasetTableField> xList = dataSetTableFieldsService.getListByIds(xIds);
List<DatasetTableField> yList = dataSetTableFieldsService.getListByIds(yIds);
// 获取数据源
DatasetTable table = dataSetTableService.get(view.getTableId());
Datasource ds = datasourceService.get(table.getDataSourceId());
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(ds);
DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(table.getInfo(), DataTableInfoDTO.class);
datasourceRequest.setTable(dataTableInfoDTO.getTable());
datasourceRequest.setQuery(getSQL(ds.getType(), dataTableInfoDTO.getTable(), xList, yList));
List<String[]> data = datasourceProvider.getData(datasourceRequest);
// todo 处理结果,目前做一个单系列图表,后期图表组件再扩展
for (DatasetTableField y : yList) {
Series series1 = new Series();
series1.setName(y.getName());
series1.setType(view.getType());
series1.setData(new ArrayList<>());
series.add(series1);
}
for (String[] d : data) {
StringBuilder a = new StringBuilder();
BigDecimal b = new BigDecimal("0");
for (int i = 0; i < xList.size(); i++) {
if (i == xList.size() - 1) {
a.append(d[i]);
} else {
a.append(d[i]).append("\n");
}
}
x.add(a.toString());
for (int i = xList.size(); i < xList.size() + yList.size(); i++) {
int j = i - xList.size();
series.get(j).getData().add(new BigDecimal(d[i]));
}
}
Map<String, Object> map = new HashMap<>();
map.put("x", x);
map.put("series", series);
ChartViewDTO dto = new ChartViewDTO();
BeanUtils.copyBean(dto, view);
dto.setData(map);
return dto;
}
public String getSQL(String type, String table, List<DatasetTableField> xAxis, List<DatasetTableField> yAxis) {
DatasourceTypes datasourceType = DatasourceTypes.valueOf(type);
switch (datasourceType) {
case mysql:
return transMysqlSQL(table, xAxis, yAxis);
case sqlServer:
default:
return "";
}
}
public String transMysqlSQL(String table, List<DatasetTableField> xAxis, List<DatasetTableField> yAxis) {
// TODO 此处sum后期由用户前端传入
String[] field = yAxis.stream().map(y -> "sum(" + y.getOriginName() + ")").toArray(String[]::new);
String[] group = xAxis.stream().map(DatasetTableField::getOriginName).toArray(String[]::new);
return MessageFormat.format("SELECT {0},{1} FROM {2} GROUP BY {3}", StringUtils.join(group, ","), StringUtils.join(field, ","), table, StringUtils.join(group, ","));
}
}

View File

@@ -54,4 +54,10 @@ public class DataSetTableFieldsService {
datasetTableFieldExample.createCriteria().andTableIdEqualTo(tableId);
datasetTableFieldMapper.deleteByExample(datasetTableFieldExample);
}
public List<DatasetTableField> getListByIds(List<String> ids) {
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
datasetTableFieldExample.createCriteria().andIdIn(ids);
return datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
}
}

View File

@@ -91,6 +91,29 @@ public class DataSetTableService {
return datasourceProvider.getTableFileds(datasourceRequest);
}
public Map<String, List<DatasetTableField>> getFieldsFromDE(DataSetTableRequest dataSetTableRequest) throws Exception {
DatasetTableField datasetTableField = new DatasetTableField();
datasetTableField.setTableId(dataSetTableRequest.getId());
datasetTableField.setChecked(Boolean.TRUE);
List<DatasetTableField> fields = dataSetTableFieldsService.list(datasetTableField);
List<DatasetTableField> dimension = new ArrayList<>();
List<DatasetTableField> quota = new ArrayList<>();
fields.forEach(field -> {
if (field.getDeType() == 2) {
quota.add(field);
} else {
dimension.add(field);
}
});
Map<String, List<DatasetTableField>> map = new HashMap<>();
map.put("dimension", dimension);
map.put("quota", quota);
return map;
}
public List<String[]> getData(DataSetTableRequest dataSetTableRequest) throws Exception {
Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId());
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());