mirror of
https://github.com/dataease/dataease.git
synced 2025-03-04 02:52:54 +08:00
commit
346667fb4e
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>dataease-server</artifactId>
|
||||
<groupId>io.dataease</groupId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@ -316,7 +316,7 @@
|
||||
<dependency>
|
||||
<groupId>io.dataease</groupId>
|
||||
<artifactId>dataease-plugin-interface</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -337,6 +337,11 @@
|
||||
<version>5.7.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-ldap</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
|
@ -4,6 +4,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.auth.api.dto.LoginDto;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -41,4 +42,8 @@ public interface AuthApi {
|
||||
@PostMapping("/validateName")
|
||||
Boolean validateName(Map<String, String> nameDto);
|
||||
|
||||
@ApiOperation("是否开启ldap")
|
||||
@PostMapping("/isOpenLdap")
|
||||
boolean isOpenLdap();
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,12 @@ public class LoginDto implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "密码", required = true)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 0: 默认登录
|
||||
* 1:ldap登录
|
||||
* 2:单点登录
|
||||
*/
|
||||
@ApiModelProperty(value = "登录方式", required = true, allowableValues = "0, 1, 2")
|
||||
private int loginType;
|
||||
}
|
||||
|
@ -14,9 +14,13 @@ import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.util.PluginUtils;
|
||||
import io.dataease.plugins.xpack.ldap.dto.request.LdapValidateRequest;
|
||||
import io.dataease.plugins.xpack.ldap.dto.response.ValidateResult;
|
||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
@ -35,10 +39,29 @@ public class AuthServer implements AuthApi {
|
||||
private AuthUserService authUserService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Object login(@RequestBody LoginDto loginDto) throws Exception {
|
||||
String username = loginDto.getUsername();
|
||||
String password = loginDto.getPassword();
|
||||
|
||||
|
||||
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, password);
|
||||
// 增加ldap登录方式
|
||||
Integer loginType = loginDto.getLoginType();
|
||||
boolean isSupportLdap = authUserService.supportLdap();
|
||||
if (loginType == 1 && isSupportLdap) {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
LdapValidateRequest request = LdapValidateRequest.builder().userName(username).password(pwd).build();
|
||||
ValidateResult validateResult = ldapXpackService.login(request);
|
||||
if (!validateResult.isSuccess()) {
|
||||
DataEaseException.throwException(validateResult.getMsg());
|
||||
}
|
||||
username = validateResult.getUserName();
|
||||
}
|
||||
// 增加ldap登录方式
|
||||
|
||||
SysUserEntity user = authUserService.getUserByName(username);
|
||||
|
||||
if (ObjectUtils.isEmpty(user)) {
|
||||
@ -48,14 +71,19 @@ public class AuthServer implements AuthApi {
|
||||
DataEaseException.throwException(Translator.get("i18n_id_or_pwd_error"));
|
||||
}
|
||||
String realPwd = user.getPassword();
|
||||
//私钥解密
|
||||
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, password);
|
||||
//md5加密
|
||||
pwd = CodingUtil.md5(pwd);
|
||||
|
||||
if (!StringUtils.equals(pwd, realPwd)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_id_or_pwd_error"));
|
||||
// 普通登录需要验证密码
|
||||
if (loginType == 0 || !isSupportLdap) {
|
||||
//私钥解密
|
||||
|
||||
//md5加密
|
||||
pwd = CodingUtil.md5(pwd);
|
||||
|
||||
if (!StringUtils.equals(pwd, realPwd)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_id_or_pwd_error"));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).build();
|
||||
String token = JWTUtils.sign(tokenInfo, realPwd);
|
||||
@ -108,6 +136,14 @@ public class AuthServer implements AuthApi {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenLdap() {
|
||||
Boolean licValid = PluginUtils.licValid();
|
||||
if(!licValid) return false;
|
||||
boolean open = authUserService.supportLdap();
|
||||
return open;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public Boolean isLogin() {
|
||||
return null;
|
||||
|
@ -21,6 +21,8 @@ public interface AuthUserService {
|
||||
|
||||
void clearCache(Long userId);
|
||||
|
||||
boolean supportLdap();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import io.dataease.base.mapper.ext.AuthMapper;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@ -102,4 +105,10 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
LogUtil.info("正在清除用户缓存【{}】",userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportLdap() {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
if(ObjectUtils.isEmpty(ldapXpackService)) return false;
|
||||
return ldapXpackService.isOpen();
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
filterChainDefinitionMap.put("/api/auth/login", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/logout", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/validateName", ANON);
|
||||
filterChainDefinitionMap.put("/api/auth/isOpenLdap", ANON);
|
||||
filterChainDefinitionMap.put("/unauth", ANON);
|
||||
filterChainDefinitionMap.put("/display/**", ANON);
|
||||
filterChainDefinitionMap.put("/tokenExpired", ANON);
|
||||
|
@ -1,31 +1,28 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ChartView implements Serializable {
|
||||
@ApiModelProperty("ID")
|
||||
private String id;
|
||||
@ApiModelProperty("名称")
|
||||
|
||||
private String name;
|
||||
@ApiModelProperty("场景ID")
|
||||
|
||||
private String sceneId;
|
||||
@ApiModelProperty("表ID")
|
||||
|
||||
private String tableId;
|
||||
@ApiModelProperty("类型")
|
||||
|
||||
private String type;
|
||||
@ApiModelProperty("标题")
|
||||
|
||||
private String title;
|
||||
@ApiModelProperty("创建者")
|
||||
|
||||
private String createBy;
|
||||
@ApiModelProperty("创建时间")
|
||||
|
||||
private Long createTime;
|
||||
@ApiModelProperty("更新时间")
|
||||
|
||||
private Long updateTime;
|
||||
@ApiModelProperty("样式优先级")
|
||||
|
||||
private String stylePriority;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -15,15 +15,17 @@ public class ChartViewWithBLOBs extends ChartView implements Serializable {
|
||||
private String xAxis;
|
||||
@ApiModelProperty("y轴")
|
||||
private String yAxis;
|
||||
@ApiModelProperty("副y轴")
|
||||
private String yAxisExt;
|
||||
@ApiModelProperty("堆叠")
|
||||
private String extStack;
|
||||
@ApiModelProperty("气泡")
|
||||
private String extBubble;
|
||||
@ApiModelProperty("客户端属性")
|
||||
@ApiModelProperty("图形属性")
|
||||
private String customAttr;
|
||||
@ApiModelProperty("客户端样式")
|
||||
@ApiModelProperty("组件样式")
|
||||
private String customStyle;
|
||||
@ApiModelProperty("客户端过滤条件")
|
||||
@ApiModelProperty("过滤条件")
|
||||
private String customFilter;
|
||||
@ApiModelProperty("下钻字段")
|
||||
private String drillFields;
|
||||
|
@ -1,59 +1,43 @@
|
||||
package io.dataease.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysUser implements Serializable {
|
||||
@ApiModelProperty(value = "用户ID" , allowEmptyValue = false, position = 0)
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "组织ID" , allowEmptyValue = false, position = 7)
|
||||
private Long deptId;
|
||||
|
||||
@ApiModelProperty(value = "账号" , required = true)
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "姓名" , required = true, position = 2)
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty(value = "性别" ,allowableValues = "男,女", allowEmptyValue = true, position = 5)
|
||||
private String gender;
|
||||
|
||||
@ApiModelProperty(value = "电话" , allowEmptyValue = true, position = 1)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "邮箱" , required = true, position = 3)
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "密码" , required = true, position = 4)
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Boolean isAdmin;
|
||||
|
||||
@ApiModelProperty(value = "状态" , allowableValues = "1,0", required = true, position = 6)
|
||||
private Long enabled;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long pwdResetTime;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long createTime;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Long updateTime;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String language;
|
||||
|
||||
private Integer from;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -1153,6 +1153,66 @@ public class SysUserExample {
|
||||
addCriterion("`language` not between", value1, value2, "language");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromIsNull() {
|
||||
addCriterion("`from` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromIsNotNull() {
|
||||
addCriterion("`from` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromEqualTo(Integer value) {
|
||||
addCriterion("`from` =", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromNotEqualTo(Integer value) {
|
||||
addCriterion("`from` <>", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromGreaterThan(Integer value) {
|
||||
addCriterion("`from` >", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("`from` >=", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromLessThan(Integer value) {
|
||||
addCriterion("`from` <", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("`from` <=", value, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromIn(List<Integer> values) {
|
||||
addCriterion("`from` in", values, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromNotIn(List<Integer> values) {
|
||||
addCriterion("`from` not in", values, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`from` between", value1, value2, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFromNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`from` not between", value1, value2, "from");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
@ -16,6 +16,7 @@
|
||||
<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="y_axis_ext" jdbcType="LONGVARCHAR" property="yAxisExt" />
|
||||
<result column="ext_stack" jdbcType="LONGVARCHAR" property="extStack" />
|
||||
<result column="ext_bubble" jdbcType="LONGVARCHAR" property="extBubble" />
|
||||
<result column="custom_attr" jdbcType="LONGVARCHAR" property="customAttr" />
|
||||
@ -87,7 +88,7 @@
|
||||
style_priority
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
x_axis, y_axis, ext_stack, ext_bubble, custom_attr, custom_style, custom_filter,
|
||||
x_axis, y_axis, y_axis_ext, ext_stack, ext_bubble, custom_attr, custom_style, custom_filter,
|
||||
drill_fields, snapshot
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.dataease.base.domain.ChartViewExample" resultMap="ResultMapWithBLOBs">
|
||||
@ -143,16 +144,16 @@
|
||||
table_id, `type`, title,
|
||||
create_by, create_time, update_time,
|
||||
style_priority, x_axis, y_axis,
|
||||
ext_stack, ext_bubble, custom_attr,
|
||||
custom_style, custom_filter, drill_fields,
|
||||
snapshot)
|
||||
y_axis_ext, ext_stack, ext_bubble,
|
||||
custom_attr, custom_style, custom_filter,
|
||||
drill_fields, snapshot)
|
||||
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},
|
||||
#{stylePriority,jdbcType=VARCHAR}, #{xAxis,jdbcType=LONGVARCHAR}, #{yAxis,jdbcType=LONGVARCHAR},
|
||||
#{extStack,jdbcType=LONGVARCHAR}, #{extBubble,jdbcType=LONGVARCHAR}, #{customAttr,jdbcType=LONGVARCHAR},
|
||||
#{customStyle,jdbcType=LONGVARCHAR}, #{customFilter,jdbcType=LONGVARCHAR}, #{drillFields,jdbcType=LONGVARCHAR},
|
||||
#{snapshot,jdbcType=LONGVARCHAR})
|
||||
#{yAxisExt,jdbcType=LONGVARCHAR}, #{extStack,jdbcType=LONGVARCHAR}, #{extBubble,jdbcType=LONGVARCHAR},
|
||||
#{customAttr,jdbcType=LONGVARCHAR}, #{customStyle,jdbcType=LONGVARCHAR}, #{customFilter,jdbcType=LONGVARCHAR},
|
||||
#{drillFields,jdbcType=LONGVARCHAR}, #{snapshot,jdbcType=LONGVARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.ChartViewWithBLOBs">
|
||||
insert into chart_view
|
||||
@ -193,6 +194,9 @@
|
||||
<if test="yAxis != null">
|
||||
y_axis,
|
||||
</if>
|
||||
<if test="yAxisExt != null">
|
||||
y_axis_ext,
|
||||
</if>
|
||||
<if test="extStack != null">
|
||||
ext_stack,
|
||||
</if>
|
||||
@ -252,6 +256,9 @@
|
||||
<if test="yAxis != null">
|
||||
#{yAxis,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="yAxisExt != null">
|
||||
#{yAxisExt,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="extStack != null">
|
||||
#{extStack,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@ -320,6 +327,9 @@
|
||||
<if test="record.yAxis != null">
|
||||
y_axis = #{record.yAxis,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="record.yAxisExt != null">
|
||||
y_axis_ext = #{record.yAxisExt,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="record.extStack != null">
|
||||
ext_stack = #{record.extStack,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@ -360,6 +370,7 @@
|
||||
style_priority = #{record.stylePriority,jdbcType=VARCHAR},
|
||||
x_axis = #{record.xAxis,jdbcType=LONGVARCHAR},
|
||||
y_axis = #{record.yAxis,jdbcType=LONGVARCHAR},
|
||||
y_axis_ext = #{record.yAxisExt,jdbcType=LONGVARCHAR},
|
||||
ext_stack = #{record.extStack,jdbcType=LONGVARCHAR},
|
||||
ext_bubble = #{record.extBubble,jdbcType=LONGVARCHAR},
|
||||
custom_attr = #{record.customAttr,jdbcType=LONGVARCHAR},
|
||||
@ -423,6 +434,9 @@
|
||||
<if test="yAxis != null">
|
||||
y_axis = #{yAxis,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="yAxisExt != null">
|
||||
y_axis_ext = #{yAxisExt,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="extStack != null">
|
||||
ext_stack = #{extStack,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
@ -460,6 +474,7 @@
|
||||
style_priority = #{stylePriority,jdbcType=VARCHAR},
|
||||
x_axis = #{xAxis,jdbcType=LONGVARCHAR},
|
||||
y_axis = #{yAxis,jdbcType=LONGVARCHAR},
|
||||
y_axis_ext = #{yAxisExt,jdbcType=LONGVARCHAR},
|
||||
ext_stack = #{extStack,jdbcType=LONGVARCHAR},
|
||||
ext_bubble = #{extBubble,jdbcType=LONGVARCHAR},
|
||||
custom_attr = #{customAttr,jdbcType=LONGVARCHAR},
|
||||
|
@ -18,6 +18,7 @@
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="language" jdbcType="VARCHAR" property="language" />
|
||||
<result column="from" jdbcType="INTEGER" property="from" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
@ -79,7 +80,8 @@
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
user_id, dept_id, username, nick_name, gender, phone, email, `password`, is_admin,
|
||||
enabled, create_by, update_by, pwd_reset_time, create_time, update_time, `language`
|
||||
enabled, create_by, update_by, pwd_reset_time, create_time, update_time, `language`,
|
||||
`from`
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.dataease.base.domain.SysUserExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -117,13 +119,13 @@
|
||||
email, `password`, is_admin,
|
||||
enabled, create_by, update_by,
|
||||
pwd_reset_time, create_time, update_time,
|
||||
`language`)
|
||||
`language`, `from`)
|
||||
values (#{userId,jdbcType=BIGINT}, #{deptId,jdbcType=BIGINT}, #{username,jdbcType=VARCHAR},
|
||||
#{nickName,jdbcType=VARCHAR}, #{gender,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
|
||||
#{email,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{isAdmin,jdbcType=BIT},
|
||||
#{enabled,jdbcType=BIGINT}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR},
|
||||
#{pwdResetTime,jdbcType=BIGINT}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
|
||||
#{language,jdbcType=VARCHAR})
|
||||
#{language,jdbcType=VARCHAR}, #{from,jdbcType=INTEGER})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.dataease.base.domain.SysUser">
|
||||
insert into sys_user
|
||||
@ -176,6 +178,9 @@
|
||||
<if test="language != null">
|
||||
`language`,
|
||||
</if>
|
||||
<if test="from != null">
|
||||
`from`,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">
|
||||
@ -226,6 +231,9 @@
|
||||
<if test="language != null">
|
||||
#{language,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="from != null">
|
||||
#{from,jdbcType=INTEGER},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.dataease.base.domain.SysUserExample" resultType="java.lang.Long">
|
||||
@ -285,6 +293,9 @@
|
||||
<if test="record.language != null">
|
||||
`language` = #{record.language,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.from != null">
|
||||
`from` = #{record.from,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
@ -307,7 +318,8 @@
|
||||
pwd_reset_time = #{record.pwdResetTime,jdbcType=BIGINT},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
`language` = #{record.language,jdbcType=VARCHAR}
|
||||
`language` = #{record.language,jdbcType=VARCHAR},
|
||||
`from` = #{record.from,jdbcType=INTEGER}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@ -360,6 +372,9 @@
|
||||
<if test="language != null">
|
||||
`language` = #{language,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="from != null">
|
||||
`from` = #{from,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where user_id = #{userId,jdbcType=BIGINT}
|
||||
</update>
|
||||
@ -379,7 +394,8 @@
|
||||
pwd_reset_time = #{pwdResetTime,jdbcType=BIGINT},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
`language` = #{language,jdbcType=VARCHAR}
|
||||
`language` = #{language,jdbcType=VARCHAR},
|
||||
`from` = #{from,jdbcType=INTEGER}
|
||||
where user_id = #{userId,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
@ -7,4 +7,6 @@ import java.util.List;
|
||||
|
||||
public interface ExtSysUserMapper {
|
||||
List<SysUserGridResponse> query(GridExample example);
|
||||
|
||||
List<String> ldapUserNames(Integer from);
|
||||
}
|
||||
|
@ -62,4 +62,8 @@
|
||||
left join sys_role r on r.role_id = sur.role_id
|
||||
where sur.user_id = #{user_id}
|
||||
</select>
|
||||
|
||||
<select id="ldapUserNames" resultType="java.lang.String" parameterType="java.lang.Integer">
|
||||
select username from sys_user u where u.from = #{from}
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -10,6 +10,7 @@ import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.LdapAddRequest;
|
||||
import io.dataease.controller.sys.request.SysUserCreateRequest;
|
||||
import io.dataease.controller.sys.request.SysUserPwdRequest;
|
||||
import io.dataease.controller.sys.request.SysUserStateRequest;
|
||||
@ -127,4 +128,18 @@ public class SysUserController {
|
||||
Pager<List<SysRole>> listPager = PageUtils.setPageInfo(page, sysRoleService.query(request));
|
||||
return listPager;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("同步用户")
|
||||
@PostMapping("/sync")
|
||||
public void importLdap(@RequestBody LdapAddRequest request) {
|
||||
sysUserService.saveLdapUsers(request);
|
||||
}
|
||||
|
||||
@ApiOperation("已同步用户")
|
||||
@PostMapping("/existLdapUsers")
|
||||
public List<String> getExistLdapUsers() {
|
||||
return sysUserService.ldapUserNames();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class LdapAddRequest implements Serializable {
|
||||
|
||||
private Long deptId;
|
||||
|
||||
private List<Long> roleIds;
|
||||
|
||||
private Long enabled;
|
||||
|
||||
private List<XpackLdapUserEntity> users;
|
||||
}
|
@ -6,7 +6,8 @@ public enum DatasourceTypes {
|
||||
pg("pg", "pg", "org.postgresql.Driver", "\"", "\"", "\"", "\""),
|
||||
sqlServer("sqlServer", "sqlServer", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
|
||||
doris("doris", "doris", "com.mysql.jdbc.Driver", "`", "`", "", ""),
|
||||
oracle("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\"");
|
||||
oracle("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),
|
||||
es("es", "es", "", "\"", "\"", "\"", "\"");
|
||||
|
||||
private String feature;
|
||||
private String desc;
|
||||
|
@ -0,0 +1,14 @@
|
||||
package io.dataease.datasource.dto;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class EsConfigDTO {
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
private String dataSourceType = "es";
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package io.dataease.datasource.dto.es;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class EsReponse {
|
||||
private List<Column>columns = new ArrayList<>();
|
||||
private List<String[]>rows = new ArrayList<>();
|
||||
private String cursor;
|
||||
private Integer status;
|
||||
private Error error;
|
||||
|
||||
@Data
|
||||
public class Error{
|
||||
private String type;
|
||||
private String reason;
|
||||
}
|
||||
|
||||
@Data
|
||||
public class Column {
|
||||
private String name;
|
||||
private String type;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package io.dataease.datasource.dto.es;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Requst {
|
||||
private String query;
|
||||
private Integer fetch_size = 10000;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package io.dataease.datasource.dto.es;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RequstWithCursor extends Requst{
|
||||
private String cursor;
|
||||
}
|
@ -0,0 +1,221 @@
|
||||
package io.dataease.datasource.provider;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
import io.dataease.commons.utils.HttpClientConfig;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.datasource.dto.*;
|
||||
import io.dataease.datasource.dto.es.EsReponse;
|
||||
import io.dataease.datasource.dto.es.Requst;
|
||||
import io.dataease.datasource.dto.es.RequstWithCursor;
|
||||
import io.dataease.datasource.request.DatasourceRequest;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.provider.es.EsQueryProvider;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
@Service("es")
|
||||
public class EsProvider extends DatasourceProvider {
|
||||
|
||||
private static Map<String, ComboPooledDataSource> jdbcConnection = new HashMap<>();
|
||||
private static int initPoolSize = 5;
|
||||
private static int maxConnections = 200;
|
||||
|
||||
/**
|
||||
* 增加缓存机制 key 由 'provider_sql_' dsr.datasource.id dsr.table dsr.query共4部分组成,命中则使用缓存直接返回不再执行sql逻辑
|
||||
* @param dsr
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
/**
|
||||
* 这里使用声明式缓存不是很妥当
|
||||
* 改为chartViewService中使用编程式缓存
|
||||
@Cacheable(
|
||||
value = JdbcConstants.JDBC_PROVIDER_KEY,
|
||||
key = "'provider_sql_' + #dsr.datasource.id + '_' + #dsr.table + '_' + #dsr.query",
|
||||
condition = "#dsr.pageSize == null || #dsr.pageSize == 0L"
|
||||
)
|
||||
*/
|
||||
@Override
|
||||
public List<String[]> getData(DatasourceRequest dsr) throws Exception {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
try {
|
||||
EsConfigDTO esConfigDTO = new Gson().fromJson(dsr.getDatasource().getConfiguration(), EsConfigDTO.class);
|
||||
|
||||
HttpClientConfig httpClientConfig = new HttpClientConfig();
|
||||
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
|
||||
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
|
||||
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
|
||||
Requst requst = new Requst();
|
||||
requst.setQuery(dsr.getQuery());
|
||||
requst.setFetch_size(dsr.getFetchSize());
|
||||
String url = esConfigDTO.getUrl().endsWith("/") ? esConfigDTO.getUrl() + "_sql?format=json" : esConfigDTO.getUrl() + "/" + "_sql?format=json";
|
||||
String response = HttpClientUtil.post(url, new Gson().toJson(requst), httpClientConfig);
|
||||
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
|
||||
list.addAll(fetchResult(esReponse));
|
||||
if(dsr.isPageable()){
|
||||
Integer realSize = dsr.getPage() * dsr.getPageSize() < list.size() ? dsr.getPage() * dsr.getPageSize(): list.size();
|
||||
list = list.subList((dsr.getPage() - 1) * dsr.getPageSize(), realSize);
|
||||
}
|
||||
if(!dsr.isPreviewData()){
|
||||
while (StringUtils.isNotEmpty(esReponse.getCursor())) {
|
||||
RequstWithCursor requstWithCursor = new RequstWithCursor();
|
||||
requstWithCursor.setQuery(dsr.getQuery());
|
||||
requstWithCursor.setFetch_size(dsr.getFetchSize());
|
||||
requstWithCursor.setCursor(esReponse.getCursor());
|
||||
response = HttpClientUtil.post(url, new Gson().toJson(requstWithCursor), httpClientConfig);
|
||||
esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
list.addAll(fetchResult(esReponse));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String[]> fetchResult(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "_sql?format=json");
|
||||
list = fetchResult(response);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String[]> fetchResult(String response) throws Exception {
|
||||
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
return fetchResult(esReponse);
|
||||
}
|
||||
|
||||
private List<String[]> fetchResult(EsReponse esReponse) throws Exception {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
if(esReponse.getError() != null){
|
||||
throw new Exception(esReponse.getError().getReason());
|
||||
}
|
||||
list.addAll(esReponse.getRows());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableFiled> fetchResultField(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<TableFiled> tableFileds = new ArrayList<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "_sql?format=json");
|
||||
tableFileds = fetchResultField(response);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return tableFileds;
|
||||
}
|
||||
|
||||
private List<TableFiled> fetchResultField(String response) throws Exception {
|
||||
List<TableFiled> fieldList = new ArrayList<>();
|
||||
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
if(esReponse.getError() != null){
|
||||
throw new Exception(esReponse.getError().getReason());
|
||||
}
|
||||
|
||||
for (String[] row : esReponse.getRows()) {
|
||||
TableFiled field = new TableFiled();
|
||||
field.setFieldName(row[0]);
|
||||
field.setRemarks(row[0]);
|
||||
field.setFieldType(row[2]);
|
||||
field.setFieldSize(EsQueryProvider.transFieldTypeSize(row[2]));
|
||||
fieldList.add(field);
|
||||
}
|
||||
return fieldList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception {
|
||||
Map<String, List> result = new HashMap<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, datasourceRequest.getQuery(), "_sql?format=json");
|
||||
result.put("dataList", fetchResult(response));
|
||||
result.put("fieldList", fetchResultField(response));
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDatasource(DatasourceRequest datasourceRequest, String type) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTables(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<String> tables = new ArrayList<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, "show tables", "_sql?format=json");
|
||||
tables = fetchTables(response);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return tables;
|
||||
}
|
||||
|
||||
private List<String> fetchTables(String response) throws Exception {
|
||||
List<String> tables = new ArrayList<>();
|
||||
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
if(esReponse.getError() != null){
|
||||
throw new Exception(esReponse.getError().getReason());
|
||||
}
|
||||
|
||||
for (String[] row : esReponse.getRows()) {
|
||||
if(row.length == 3 && row[1].equalsIgnoreCase("TABLE") && row[2].equalsIgnoreCase("INDEX")){
|
||||
tables.add(row[0]);
|
||||
}
|
||||
}
|
||||
return tables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSchema(DatasourceRequest datasourceRequest) throws Exception {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableFiled> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<TableFiled> tableFileds = new ArrayList<>();
|
||||
try {
|
||||
String response = exexQuery(datasourceRequest, "desc " + datasourceRequest.getTable(), "_sql?format=json");
|
||||
tableFileds = fetchResultField(response);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return tableFileds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkStatus(DatasourceRequest datasourceRequest) throws Exception {
|
||||
getTables(datasourceRequest);
|
||||
}
|
||||
|
||||
private String exexQuery(DatasourceRequest datasourceRequest, String sql, String uri){
|
||||
EsConfigDTO esConfigDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), EsConfigDTO.class);
|
||||
|
||||
HttpClientConfig httpClientConfig = new HttpClientConfig();
|
||||
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
|
||||
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
|
||||
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
|
||||
|
||||
Requst requst = new Requst();
|
||||
requst.setQuery(sql);
|
||||
requst.setFetch_size(datasourceRequest.getFetchSize());
|
||||
String url = esConfigDTO.getUrl().endsWith("/") ? esConfigDTO.getUrl() + uri : esConfigDTO.getUrl() + "/" + uri;
|
||||
String response = HttpClientUtil.post(url, new Gson().toJson(requst), httpClientConfig);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
@ -30,6 +30,8 @@ public class ProviderFactory implements ApplicationContextAware {
|
||||
return context.getBean("jdbc", DatasourceProvider.class);
|
||||
case pg:
|
||||
return context.getBean("jdbc", DatasourceProvider.class);
|
||||
case es:
|
||||
return context.getBean("es", DatasourceProvider.class);
|
||||
default:
|
||||
return context.getBean("jdbc", DatasourceProvider.class);
|
||||
}
|
||||
@ -48,6 +50,8 @@ public class ProviderFactory implements ApplicationContextAware {
|
||||
return context.getBean("pgQuery", QueryProvider.class);
|
||||
case oracle:
|
||||
return context.getBean("oracleQuery", QueryProvider.class);
|
||||
case es:
|
||||
return context.getBean("esQuery", QueryProvider.class);
|
||||
default:
|
||||
return context.getBean("mysqlQuery", QueryProvider.class);
|
||||
}
|
||||
|
@ -11,8 +11,12 @@ public class DatasourceRequest {
|
||||
protected String query;
|
||||
protected String table;
|
||||
protected Datasource datasource;
|
||||
private Long pageSize;
|
||||
private Long startPage;
|
||||
private Integer pageSize;
|
||||
private Integer page;
|
||||
private Integer realSize;
|
||||
private Integer fetchSize = 10000;
|
||||
private boolean pageable = false;
|
||||
private boolean previewData = false;
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.ldap.dto.response.LdapInfo;
|
||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("/api/ldap")
|
||||
@RestController
|
||||
public class XLdapServer {
|
||||
|
||||
|
||||
@GetMapping("/info")
|
||||
public LdapInfo getLdapInfo() {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
return ldapXpackService.info();
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
public void save(@RequestBody List<SysSettingDto> settings) {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
ldapXpackService.save(settings);
|
||||
}
|
||||
|
||||
@PostMapping("/testConn")
|
||||
public void testConn() {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
ldapXpackService.testConn();
|
||||
}
|
||||
|
||||
@PostMapping("/users")
|
||||
public List<XpackLdapUserEntity> users() {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
return ldapXpackService.users();
|
||||
}
|
||||
}
|
@ -46,6 +46,16 @@ public class PluginUtils {
|
||||
return f2CLicenseResponse;
|
||||
}
|
||||
|
||||
public static Boolean licValid() {
|
||||
try{
|
||||
F2CLicenseResponse f2CLicenseResponse = PluginUtils.currentLic();
|
||||
if (f2CLicenseResponse.getStatus() != F2CLicenseResponse.Status.valid) return false;
|
||||
}catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -38,6 +38,10 @@ public abstract class QueryProvider {
|
||||
|
||||
public abstract String getSQLAsTmp(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList);
|
||||
|
||||
public abstract String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds);
|
||||
|
||||
public abstract String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds);
|
||||
|
||||
public abstract String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds);
|
||||
|
||||
public abstract String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack);
|
||||
|
@ -281,6 +281,83 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
} else {
|
||||
originField = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(DorisConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
return getSQL("(" + sql + ")", xAxis, yAxis, customFilter, extFilterRequestList, null);
|
||||
|
@ -0,0 +1,933 @@
|
||||
package io.dataease.provider.es;
|
||||
|
||||
import io.dataease.base.domain.DatasetTableField;
|
||||
import io.dataease.base.domain.DatasetTableFieldExample;
|
||||
import io.dataease.base.domain.Datasource;
|
||||
import io.dataease.base.mapper.DatasetTableFieldMapper;
|
||||
import io.dataease.commons.constants.DeTypeConstants;
|
||||
import io.dataease.controller.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
||||
import io.dataease.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.dto.sqlObj.SQLObj;
|
||||
import io.dataease.provider.QueryProvider;
|
||||
import io.dataease.provider.SQLConstants;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.stringtemplate.v4.ST;
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
import org.stringtemplate.v4.STGroupFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static io.dataease.provider.SQLConstants.TABLE_ALIAS_PREFIX;
|
||||
|
||||
@Service("esQuery")
|
||||
public class EsQueryProvider extends QueryProvider {
|
||||
@Resource
|
||||
private DatasetTableFieldMapper datasetTableFieldMapper;
|
||||
|
||||
@Override
|
||||
public Integer transFieldType(String field) {
|
||||
switch (field) {
|
||||
case "keyword":
|
||||
case "text":
|
||||
case "binary":
|
||||
case "object":
|
||||
case "nested":
|
||||
case "null":
|
||||
case "ip":
|
||||
case "unsupported":
|
||||
return DeTypeConstants.DE_STRING;
|
||||
case "boolean":
|
||||
case "byte":
|
||||
case "short":
|
||||
case "integer":
|
||||
case "long":
|
||||
return DeTypeConstants.DE_INT;
|
||||
case "double":
|
||||
case "float":
|
||||
case "half_float":
|
||||
case "scaled_float":
|
||||
return DeTypeConstants.DE_FLOAT;
|
||||
case "datetime":
|
||||
return DeTypeConstants.DE_TIME;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer transFieldTypeSize(String field) {
|
||||
switch (field) {
|
||||
case "null":
|
||||
return 1;
|
||||
case "boolean":
|
||||
return 1;
|
||||
case "byte":
|
||||
return 3;
|
||||
case "short":
|
||||
return 5;
|
||||
case "integer":
|
||||
return 10;
|
||||
case "long":
|
||||
return 19;
|
||||
case "double":
|
||||
case "float":
|
||||
case "half_float":
|
||||
case "scaled_float":
|
||||
return 15;
|
||||
case "keyword":
|
||||
case "text":
|
||||
case "binary":
|
||||
case "object":
|
||||
case "nested":
|
||||
return 65532;
|
||||
case "datetime":
|
||||
return 50;
|
||||
case "ip":
|
||||
return 50;
|
||||
case "unsupported":
|
||||
return 50;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createSQLPreview(String sql, String orderBy) {
|
||||
return "SELECT * FROM (" + sqlFix(sql) + ") AS tmp ORDER BY null " + " LIMIT 1000";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(fields)) {
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
DatasetTableField f = fields.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(f.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
String fieldName = "";
|
||||
// 处理横轴字段
|
||||
if (f.getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
if (f.getDeType() == DeTypeConstants.DE_INT || f.getDeType() == DeTypeConstants.DE_FLOAT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "bigint");
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
} else if (f.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
||||
if (f.getDeType() == DeTypeConstants.DE_INT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "bigint");
|
||||
} else if (f.getDeType() == DeTypeConstants.DE_FLOAT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "double");
|
||||
} else if (f.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
} else {
|
||||
if (f.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
|
||||
} else if (f.getDeType() == DeTypeConstants.DE_INT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
}
|
||||
xFields.add(SQLObj.builder()
|
||||
.fieldName(fieldName)
|
||||
.fieldAlias(fieldAlias)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
return st_sql.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds) {
|
||||
return createQuerySQL(table, fields, isGroup, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmpWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
List<SQLObj> yWheres = new ArrayList<>();
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(yAxis)) {
|
||||
for (int i = 0; i < yAxis.size(); i++) {
|
||||
ChartViewFieldDTO y = yAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
yFields.add(getYFields(y, originField, fieldAlias));
|
||||
// 处理纵轴过滤
|
||||
yWheres.addAll(getYWheres(y, originField, fieldAlias));
|
||||
// 处理纵轴排序
|
||||
if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) {
|
||||
yOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(y.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<SQLObj> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(EsSqlLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
List<ChartViewFieldDTO> xList = new ArrayList<>();
|
||||
xList.addAll(xAxis);
|
||||
xList.addAll(extStack);
|
||||
if (CollectionUtils.isNotEmpty(xList)) {
|
||||
for (int i = 0; i < xList.size(); i++) {
|
||||
ChartViewFieldDTO x = xList.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
List<SQLObj> yWheres = new ArrayList<>();
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(yAxis)) {
|
||||
for (int i = 0; i < yAxis.size(); i++) {
|
||||
ChartViewFieldDTO y = yAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
yFields.add(getYFields(y, originField, fieldAlias));
|
||||
// 处理纵轴过滤
|
||||
yWheres.addAll(getYWheres(y, originField, fieldAlias));
|
||||
// 处理纵轴排序
|
||||
if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) {
|
||||
yOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(y.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<SQLObj> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(EsSqlLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, customFilter, extFilterRequestList, extStack, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
List<SQLObj> yWheres = new ArrayList<>();
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
List<ChartViewFieldDTO> yList = new ArrayList<>();
|
||||
yList.addAll(yAxis);
|
||||
yList.addAll(extBubble);
|
||||
if (CollectionUtils.isNotEmpty(yList)) {
|
||||
for (int i = 0; i < yList.size(); i++) {
|
||||
ChartViewFieldDTO y = yList.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
yFields.add(getYFields(y, originField, fieldAlias));
|
||||
// 处理纵轴过滤
|
||||
yWheres.addAll(getYWheres(y, originField, fieldAlias));
|
||||
// 处理纵轴排序
|
||||
if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) {
|
||||
yOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(y.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<SQLObj> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(EsSqlLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, customFilter, extFilterRequestList, extBubble, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
List<SQLObj> yWheres = new ArrayList<>();
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(yAxis)) {
|
||||
for (int i = 0; i < yAxis.size(); i++) {
|
||||
ChartViewFieldDTO y = yAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == 1) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
|
||||
// 处理纵轴字段
|
||||
yFields.add(getYFields(y, originField, fieldAlias));
|
||||
// 处理纵轴过滤
|
||||
yWheres.addAll(getYWheres(y, originField, fieldAlias));
|
||||
// 处理纵轴排序
|
||||
if (StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) {
|
||||
yOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(y.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(yFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(yOrders);
|
||||
List<SQLObj> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(EsSqlLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, customFilter, extFilterRequestList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String wrapSql(String sql) {
|
||||
sql = sql.trim();
|
||||
if (sql.lastIndexOf(";") == (sql.length() - 1)) {
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
}
|
||||
String tmpSql = "SELECT * FROM (" + sql + ") AS tmp " + " LIMIT 0";
|
||||
return tmpSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createRawQuerySQL(String table, List<DatasetTableField> fields, Datasource ds) {
|
||||
String[] array = fields.stream().map(f -> {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("\"").append(f.getOriginName()).append("\" AS ").append(f.getDataeaseName());
|
||||
return stringBuilder.toString();
|
||||
}).toArray(String[]::new);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ORDER BY null", StringUtils.join(array, ","), table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createRawQuerySQLAsTmp(String sql, List<DatasetTableField> fields) {
|
||||
return createRawQuerySQL(" (" + sqlFix(sql) + ") AS tmp ", fields, null);
|
||||
}
|
||||
|
||||
public String transMysqlFilterTerm(String term) {
|
||||
switch (term) {
|
||||
case "eq":
|
||||
return " = ";
|
||||
case "not_eq":
|
||||
return " <> ";
|
||||
case "lt":
|
||||
return " < ";
|
||||
case "le":
|
||||
return " <= ";
|
||||
case "gt":
|
||||
return " > ";
|
||||
case "ge":
|
||||
return " >= ";
|
||||
case "in":
|
||||
return " IN ";
|
||||
case "not in":
|
||||
return " NOT IN ";
|
||||
case "like":
|
||||
return " LIKE ";
|
||||
case "not like":
|
||||
return " NOT LIKE ";
|
||||
case "null":
|
||||
return " IN ";
|
||||
case "not_null":
|
||||
return " IS NOT NULL AND %s <> ''";
|
||||
case "between":
|
||||
return " BETWEEN ";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public List<SQLObj> transCustomFilterList(SQLObj tableObj, List<ChartCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
}
|
||||
List<SQLObj> list = new ArrayList<>();
|
||||
for (ChartCustomFilterDTO request : requestList) {
|
||||
DatasetTableField field = request.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
continue;
|
||||
}
|
||||
String value = request.getValue();
|
||||
String whereName = "";
|
||||
String whereTerm = transMysqlFilterTerm(request.getTerm());
|
||||
String whereValue = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(EsSqlLConstants.CAST, originName, "timestamp");
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_BOOL) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originName, "timestamp");
|
||||
whereName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(request.getTerm(), "null")) {
|
||||
whereValue = EsSqlLConstants.WHERE_VALUE_NULL;
|
||||
} else if (StringUtils.equalsIgnoreCase(request.getTerm(), "not_null")) {
|
||||
whereTerm = String.format(whereTerm, originName);
|
||||
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "in")) {
|
||||
whereValue = "('" + StringUtils.join(value, "','") + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<SQLObj> transExtFilterList(SQLObj tableObj, List<ChartExtFilterRequest> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
}
|
||||
List<SQLObj> list = new ArrayList<>();
|
||||
for (ChartExtFilterRequest request : requestList) {
|
||||
List<String> value = request.getValue();
|
||||
DatasetTableField field = request.getDatasetTableField();
|
||||
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
|
||||
continue;
|
||||
}
|
||||
String whereName = "";
|
||||
String whereTerm = transMysqlFilterTerm(request.getOperator());
|
||||
String whereValue = "";
|
||||
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(EsSqlLConstants.CAST, originName, "timestamp");
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originName, "timestamp");
|
||||
whereName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
|
||||
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
|
||||
whereValue = "('" + StringUtils.join(value, "','") + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
whereValue = "'%" + value.get(0) + "%'";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == 1) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String startTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(0))));
|
||||
String endTime = simpleDateFormat.format(new Date(Long.parseLong(value.get(1))));
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_BETWEEN, startTime, endTime);
|
||||
} else {
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_BETWEEN, value.get(0), value.get(1));
|
||||
}
|
||||
} else {
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_VALUE_VALUE, value.get(0));
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String sqlFix(String sql) {
|
||||
if (sql.lastIndexOf(";") == (sql.length() - 1)) {
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private String transDateFormat(String dateStyle, String datePattern) {
|
||||
String split = "-";
|
||||
if (StringUtils.equalsIgnoreCase(datePattern, "date_sub")) {
|
||||
split = "-";
|
||||
} else if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
|
||||
split = "/";
|
||||
}
|
||||
|
||||
switch (dateStyle) {
|
||||
case "y":
|
||||
return "YYYY";
|
||||
case "y_M":
|
||||
return "YYYY" + split + "MM";
|
||||
case "y_M_d":
|
||||
return "YYYY" + split + "MM" + split + "dd";
|
||||
case "H_m_s":
|
||||
return "HH:mm:ss";
|
||||
case "y_M_d_H_m":
|
||||
return "YYYY" + split + "MM" + split + "dd" + " HH:mm";
|
||||
case "y_M_d_H_m_s":
|
||||
return "YYYY" + split + "MM" + split + "dd" + " HH:mm:ss";
|
||||
default:
|
||||
return "YYYY-MM-dd HH:mm:ss";
|
||||
}
|
||||
}
|
||||
|
||||
private SQLObj getXFields(ChartViewFieldDTO x, String originField, String fieldAlias) {
|
||||
String fieldName = "";
|
||||
if (x.getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
if (x.getDeType() == DeTypeConstants.DE_INT || x.getDeType() == DeTypeConstants.DE_FLOAT) {
|
||||
fieldName = String.format(EsSqlLConstants.CAST, originField, "bigint");
|
||||
} else if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, originField, format);
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
} else {
|
||||
if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
if (x.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, format);
|
||||
} else {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, "timestamp");
|
||||
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, format);
|
||||
}
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
}
|
||||
return SQLObj.builder()
|
||||
.fieldName(fieldName)
|
||||
.fieldAlias(fieldAlias)
|
||||
.build();
|
||||
}
|
||||
|
||||
private SQLObj getYFields(ChartViewFieldDTO y, String originField, String fieldAlias) {
|
||||
String fieldName = "";
|
||||
if (StringUtils.equalsIgnoreCase(y.getOriginName(), "*")) {
|
||||
fieldName = EsSqlLConstants.AGG_COUNT;
|
||||
} else if (SQLConstants.DIMENSION_TYPE.contains(y.getDeType())) {
|
||||
fieldName = String.format(EsSqlLConstants.AGG_FIELD, y.getSummary(), originField);
|
||||
} else {
|
||||
if (StringUtils.equalsIgnoreCase(y.getSummary(), "avg") || StringUtils.containsIgnoreCase(y.getSummary(), "pop")) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? "bigint" : "double");
|
||||
String agg = String.format(EsSqlLConstants.AGG_FIELD, y.getSummary(), cast);
|
||||
fieldName = String.format(EsSqlLConstants.CAST, agg, EsSqlLConstants.DEFAULT_FLOAT_FORMAT);
|
||||
} else {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originField, y.getDeType() == DeTypeConstants.DE_INT ? "bigint" : "double");
|
||||
fieldName = String.format(EsSqlLConstants.AGG_FIELD, y.getSummary(), cast);
|
||||
}
|
||||
}
|
||||
return SQLObj.builder()
|
||||
.fieldName(fieldName)
|
||||
.fieldAlias(fieldAlias)
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<SQLObj> getYWheres(ChartViewFieldDTO y, String originField, String fieldAlias) {
|
||||
List<SQLObj> list = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(y.getFilter()) && y.getFilter().size() > 0) {
|
||||
y.getFilter().forEach(f -> {
|
||||
String whereTerm = transMysqlFilterTerm(f.getTerm());
|
||||
String whereValue = "";
|
||||
// 原始类型不是时间,在de中被转成时间的字段做处理
|
||||
if (StringUtils.equalsIgnoreCase(f.getTerm(), "null")) {
|
||||
whereValue = EsSqlLConstants.WHERE_VALUE_NULL;
|
||||
} else if (StringUtils.equalsIgnoreCase(f.getTerm(), "not_null")) {
|
||||
whereTerm = String.format(whereTerm, originField);
|
||||
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "in")) {
|
||||
whereValue = "('" + StringUtils.join(f.getValue(), "','") + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) {
|
||||
whereValue = "'%" + f.getValue() + "%'";
|
||||
} else {
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_VALUE_VALUE, f.getValue());
|
||||
}
|
||||
list.add(SQLObj.builder()
|
||||
.whereField(fieldAlias)
|
||||
.whereAlias(fieldAlias)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build());
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package io.dataease.provider.es;
|
||||
|
||||
import io.dataease.provider.SQLConstants;
|
||||
|
||||
import static io.dataease.datasource.constants.DatasourceTypes.es;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
* @Date 2021/7/8 7:22 下午
|
||||
*/
|
||||
public class EsSqlLConstants extends SQLConstants {
|
||||
public static final String KEYWORD_TABLE = es.getKeywordPrefix() + "%s" + es.getKeywordSuffix();
|
||||
|
||||
public static final String KEYWORD_FIX = "%s." + es.getKeywordPrefix() + "%s" + es.getKeywordSuffix();
|
||||
|
||||
public static final String UNIX_TIMESTAMP = "UNIX_TIMESTAMP(%s)";
|
||||
|
||||
public static final String DATETIME_FORMAT = "DATETIME_FORMAT(%s,'%s')";
|
||||
|
||||
public static final String CAST = "CAST(%s AS %s)";
|
||||
|
||||
public static final String DEFAULT_DATE_FORMAT = "YYYY-MM-dd HH:mm:ss";
|
||||
|
||||
public static final String DEFAULT_INT_FORMAT = "DECIMAL(20,0)";
|
||||
|
||||
public static final String DEFAULT_FLOAT_FORMAT = "DECIMAL(20,2)";
|
||||
|
||||
public static final String WHERE_VALUE_NULL = "(NULL,'')";
|
||||
|
||||
public static final String WHERE_VALUE_VALUE = "'%s'";
|
||||
|
||||
public static final String AGG_COUNT = "COUNT(*)";
|
||||
|
||||
public static final String AGG_FIELD = "%s(%s)";
|
||||
|
||||
public static final String WHERE_BETWEEN = "'%s' AND '%s'";
|
||||
|
||||
public static final String BRACKETS = "(%s)";
|
||||
}
|
@ -270,6 +270,83 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(MySQLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
|
@ -304,6 +304,83 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(OracleConstants.ALIAS_FIX, String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i));
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(OracleConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, customFilter, extFilterRequestList, null);
|
||||
|
@ -293,6 +293,84 @@ public class PgQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(PgConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
|
@ -13,7 +13,6 @@ import io.dataease.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.dto.sqlObj.SQLObj;
|
||||
import io.dataease.provider.QueryProvider;
|
||||
import io.dataease.provider.SQLConstants;
|
||||
import io.dataease.provider.mysql.MySQLConstants;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -259,6 +258,76 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xWheres = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴过滤
|
||||
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
List<SQLObj> customWheres = transCustomFilterList(tableObj, customFilter);
|
||||
// 处理仪表板字段过滤
|
||||
List<SQLObj> extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
List<SQLObj> wheres = new ArrayList<>();
|
||||
wheres.addAll(xWheres);
|
||||
if (customWheres != null) wheres.addAll(customWheres);
|
||||
if (extWheres != null) wheres.addAll(extWheres);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("previewSql");
|
||||
st_sql.add("isGroup", false);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("previewSql");
|
||||
st.add("isGroup", false);
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(SqlServerSQLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, customFilter, extFilterRequestList, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList) {
|
||||
|
@ -184,6 +184,11 @@ public class ChartViewService {
|
||||
}.getType());
|
||||
List<ChartViewFieldDTO> yAxis = new Gson().fromJson(view.getYAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
if (StringUtils.equalsIgnoreCase(view.getType(), "chart-mix")) {
|
||||
List<ChartViewFieldDTO> yAxisExt = new Gson().fromJson(view.getYAxisExt(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
yAxis.addAll(yAxisExt);
|
||||
}
|
||||
List<ChartViewFieldDTO> extStack = new Gson().fromJson(view.getExtStack(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
List<ChartViewFieldDTO> extBubble = new Gson().fromJson(view.getExtBubble(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
@ -210,6 +215,13 @@ public class ChartViewService {
|
||||
BeanUtils.copyBean(dto, view);
|
||||
return dto;
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
yAxis = new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(xAxis)) {
|
||||
ChartViewDTO dto = new ChartViewDTO();
|
||||
BeanUtils.copyBean(dto, view);
|
||||
return dto;
|
||||
}
|
||||
} else {
|
||||
if (CollectionUtils.isEmpty(xAxis) && CollectionUtils.isEmpty(yAxis)) {
|
||||
ChartViewDTO dto = new ChartViewDTO();
|
||||
@ -321,6 +333,8 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLStack(dataTableInfoDTO.getTable(), xAxis, yAxis, customFilter, extFilterList, extStack, ds));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "scatter")) {
|
||||
datasourceRequest.setQuery(qp.getSQLScatter(dataTableInfoDTO.getTable(), xAxis, yAxis, customFilter, extFilterList, extBubble, ds));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLTableInfo(dataTableInfoDTO.getTable(), xAxis, customFilter, extFilterList, ds));
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQL(dataTableInfoDTO.getTable(), xAxis, yAxis, customFilter, extFilterList, ds));
|
||||
}
|
||||
@ -331,6 +345,8 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpStack(dataTableInfoDTO.getSql(), xAxis, yAxis, customFilter, extFilterList, extStack));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "scatter")) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpScatter(dataTableInfoDTO.getSql(), xAxis, yAxis, customFilter, extFilterList, extBubble));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpTableInfo(dataTableInfoDTO.getSql(), xAxis, customFilter, extFilterList, ds));
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmp(dataTableInfoDTO.getSql(), xAxis, yAxis, customFilter, extFilterList));
|
||||
}
|
||||
@ -344,6 +360,8 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpStack(sql, xAxis, yAxis, customFilter, extFilterList, extStack));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "scatter")) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpScatter(sql, xAxis, yAxis, customFilter, extFilterList, extBubble));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpTableInfo(sql, xAxis, customFilter, extFilterList, ds));
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmp(sql, xAxis, yAxis, customFilter, extFilterList));
|
||||
}
|
||||
@ -374,6 +392,8 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLStack(tableName, xAxis, yAxis, customFilter, extFilterList, extStack, ds));
|
||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "scatter")) {
|
||||
datasourceRequest.setQuery(qp.getSQLScatter(tableName, xAxis, yAxis, customFilter, extFilterList, extBubble, ds));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLTableInfo(tableName, xAxis, customFilter, extFilterList, ds));
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQL(tableName, xAxis, yAxis, customFilter, extFilterList, ds));
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.service.dataset;
|
||||
|
||||
|
||||
import com.fit2cloud.quartz.anno.QuartzScheduled;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.base.domain.*;
|
||||
import io.dataease.base.mapper.*;
|
||||
@ -115,9 +114,9 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveExcel(DataSetTableRequest datasetTable)throws Exception {
|
||||
public void saveExcel(DataSetTableRequest datasetTable) throws Exception {
|
||||
if (StringUtils.isEmpty(datasetTable.getId())) {
|
||||
if(datasetTable.isMergeSheet()){
|
||||
if (datasetTable.isMergeSheet()) {
|
||||
Map<String, List<ExcelSheetData>> map = datasetTable.getSheets().stream().collect(Collectors.groupingBy(ExcelSheetData::getFieldsMd5));
|
||||
for (String s : map.keySet()) {
|
||||
DataSetTableRequest sheetTable = new DataSetTableRequest();
|
||||
@ -147,7 +146,7 @@ public class DataSetTableService {
|
||||
});
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
for (ExcelSheetData sheet : datasetTable.getSheets()) {
|
||||
String[] fieldArray = sheet.getFields().stream().map(TableFiled::getFieldName).toArray(String[]::new);
|
||||
if (checkIsRepeat(fieldArray)) {
|
||||
@ -183,7 +182,7 @@ public class DataSetTableService {
|
||||
List<String> oldFields = datasetTable.getSheets().get(0).getFields().stream().map(TableFiled::getRemarks).collect(Collectors.toList());
|
||||
for (ExcelSheetData sheet : datasetTable.getSheets()) {
|
||||
//替换时,
|
||||
if(datasetTable.getEditType() == 0){
|
||||
if (datasetTable.getEditType() == 0) {
|
||||
List<String> newFields = sheet.getFields().stream().map(TableFiled::getRemarks).collect(Collectors.toList());
|
||||
if (!oldFields.equals(newFields)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_colume_change"));
|
||||
@ -240,7 +239,7 @@ public class DataSetTableService {
|
||||
if (datasetTable.getIsRename() == null || !datasetTable.getIsRename()) {
|
||||
// 更新数据和字段
|
||||
if (update == 1) {
|
||||
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql") || StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom") ) {
|
||||
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "sql") || StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) {
|
||||
// 删除所有字段,重新抽象
|
||||
dataSetTableFieldsService.deleteByTableId(datasetTable.getId());
|
||||
saveTableField(datasetTable);
|
||||
@ -251,7 +250,7 @@ public class DataSetTableService {
|
||||
return datasetTable;
|
||||
}
|
||||
|
||||
public void alter(DataSetTableRequest request)throws Exception {
|
||||
public void alter(DataSetTableRequest request) throws Exception {
|
||||
checkName(request);
|
||||
datasetTableMapper.updateByPrimaryKeySelective(request);
|
||||
}
|
||||
@ -470,14 +469,22 @@ public class DataSetTableService {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
|
||||
map.put("sql", datasourceRequest.getQuery());
|
||||
datasourceRequest.setPage(page);
|
||||
datasourceRequest.setFetchSize(Integer.parseInt(dataSetTableRequest.getRow()));
|
||||
datasourceRequest.setPageSize(pageSize);
|
||||
datasourceRequest.setRealSize(realSize);
|
||||
datasourceRequest.setPreviewData(true);
|
||||
try {
|
||||
datasourceRequest.setPageable(true);
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
DEException.throwException(e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields, Integer.valueOf(dataSetTableRequest.getRow()), false, ds));
|
||||
datasourceRequest.setPageable(false);
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -804,6 +811,9 @@ public class DataSetTableService {
|
||||
if (StringUtils.equals(dto.getTargetTableId(), dataTableInfoCustomUnion.getTableId())) {
|
||||
DatasetTableField sourceField = dataSetTableFieldsService.get(dto.getSourceTableFieldId());
|
||||
DatasetTableField targetField = dataSetTableFieldsService.get(dto.getTargetTableFieldId());
|
||||
if (ObjectUtils.isEmpty(sourceField) || ObjectUtils.isEmpty(targetField)) {
|
||||
DEException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
}
|
||||
join.append(convertUnionTypeToSQL(dto.getSourceUnionRelation()))
|
||||
.append(DorisTableUtils.dorisName(dto.getTargetTableId()))
|
||||
.append(" ON ")
|
||||
@ -861,6 +871,9 @@ public class DataSetTableService {
|
||||
if (StringUtils.equals(dto.getTargetTableId(), dataTableInfoCustomUnion.getTableId())) {
|
||||
DatasetTableField sourceField = dataSetTableFieldsService.get(dto.getSourceTableFieldId());
|
||||
DatasetTableField targetField = dataSetTableFieldsService.get(dto.getTargetTableFieldId());
|
||||
if (ObjectUtils.isEmpty(sourceField) || ObjectUtils.isEmpty(targetField)) {
|
||||
DEException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
}
|
||||
DatasetTable sourceTable = datasetTableMapper.selectByPrimaryKey(dto.getSourceTableId());
|
||||
String sourceTableName = new Gson().fromJson(sourceTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
DatasetTable targetTable = datasetTableMapper.selectByPrimaryKey(dto.getTargetTableId());
|
||||
@ -901,7 +914,7 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<DatasetTableField> saveExcelTableField(String datasetTableId, List<TableFiled> fields, boolean insert){
|
||||
public List<DatasetTableField> saveExcelTableField(String datasetTableId, List<TableFiled> fields, boolean insert) {
|
||||
List<DatasetTableField> datasetTableFields = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(fields)) {
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
@ -920,7 +933,7 @@ public class DataSetTableService {
|
||||
datasetTableField.setLastSyncTime(System.currentTimeMillis());
|
||||
datasetTableField.setExtField(0);
|
||||
datasetTableField.setGroupType(datasetTableField.getDeType() < 2 ? "d" : "q");
|
||||
if(insert){
|
||||
if (insert) {
|
||||
dataSetTableFieldsService.save(datasetTableField);
|
||||
}
|
||||
datasetTableFields.add(datasetTableField);
|
||||
@ -1120,11 +1133,11 @@ public class DataSetTableService {
|
||||
.replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString());
|
||||
datasourceRequest.setQuery(qp.wrapSql(sql));
|
||||
List<String> sqlFileds = new ArrayList<>();
|
||||
try{
|
||||
try {
|
||||
datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableFiled::getFieldName).forEach(filed -> {
|
||||
sqlFileds.add(filed);
|
||||
});
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(Translator.get("i18n_check_sql_error") + e.getMessage());
|
||||
}
|
||||
|
||||
@ -1137,11 +1150,11 @@ public class DataSetTableService {
|
||||
.replace(currentUpdateTime, Long.valueOf(System.currentTimeMillis()).toString());
|
||||
datasourceRequest.setQuery(qp.wrapSql(sql));
|
||||
List<String> sqlFileds = new ArrayList<>();
|
||||
try{
|
||||
try {
|
||||
datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableFiled::getFieldName).forEach(filed -> {
|
||||
sqlFileds.add(filed);
|
||||
});
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(Translator.get("i18n_check_sql_error") + e.getMessage());
|
||||
}
|
||||
|
||||
@ -1186,7 +1199,7 @@ public class DataSetTableService {
|
||||
List<ExcelSheetData> excelSheetDataList = parseExcel2(filename, file.getInputStream(), true);
|
||||
List<ExcelSheetData> retrunSheetDataList = new ArrayList<>();
|
||||
|
||||
if (StringUtils.isNotEmpty(tableId) && editType == 1 ) {
|
||||
if (StringUtils.isNotEmpty(tableId) && editType == 1) {
|
||||
List<DatasetTableField> datasetTableFields = dataSetTableFieldsService.getFieldsByTableId(tableId);
|
||||
datasetTableFields.stream().filter(datasetTableField -> datasetTableField.getExtField() == 0).collect(Collectors.toList());
|
||||
datasetTableFields.sort((o1, o2) -> {
|
||||
@ -1210,7 +1223,7 @@ public class DataSetTableService {
|
||||
if (retrunSheetDataList.size() == 0) {
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_colume_change"));
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
retrunSheetDataList = excelSheetDataList;
|
||||
}
|
||||
|
||||
@ -1223,12 +1236,12 @@ public class DataSetTableService {
|
||||
excelFileData.setPath(filePath);
|
||||
|
||||
filename = filename.substring(0, filename.lastIndexOf('.'));
|
||||
if(retrunSheetDataList.size() == 1){
|
||||
if (retrunSheetDataList.size() == 1) {
|
||||
retrunSheetDataList.get(0).setDatasetName(filename);
|
||||
retrunSheetDataList.get(0).setSheetExcelId(excelId);
|
||||
retrunSheetDataList.get(0).setId(UUID.randomUUID().toString());
|
||||
retrunSheetDataList.get(0).setPath(filePath);
|
||||
}else {
|
||||
} else {
|
||||
for (ExcelSheetData excelSheetData : retrunSheetDataList) {
|
||||
excelSheetData.setDatasetName(filename + "-" + excelSheetData.getExcelLable());
|
||||
excelSheetData.setSheetExcelId(excelId);
|
||||
|
@ -14,12 +14,14 @@ import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.LdapAddRequest;
|
||||
import io.dataease.controller.sys.request.SysUserCreateRequest;
|
||||
import io.dataease.controller.sys.request.SysUserPwdRequest;
|
||||
import io.dataease.controller.sys.request.SysUserStateRequest;
|
||||
import io.dataease.controller.sys.response.SysUserGridResponse;
|
||||
import io.dataease.controller.sys.response.SysUserRole;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -85,6 +87,7 @@ public class SysUserService {
|
||||
user.setCreateTime(now);
|
||||
user.setUpdateTime(now);
|
||||
user.setIsAdmin(false);
|
||||
user.setFrom(0);
|
||||
if (ObjectUtils.isEmpty(user.getPassword()) || StringUtils.equals(user.getPassword(), DEFAULT_PWD)) {
|
||||
user.setPassword(CodingUtil.md5(DEFAULT_PWD));
|
||||
} else {
|
||||
@ -99,6 +102,39 @@ public class SysUserService {
|
||||
return insert;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveLdapUsers(LdapAddRequest request) {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
List<XpackLdapUserEntity> users = request.getUsers();
|
||||
List<SysUser> sysUsers = users.stream().map(user -> {
|
||||
SysUser sysUser = BeanUtils.copyBean(new SysUser(), user);
|
||||
sysUser.setUsername(user.getUserName());
|
||||
sysUser.setDeptId(request.getDeptId());
|
||||
sysUser.setPassword(CodingUtil.md5(DEFAULT_PWD));
|
||||
sysUser.setCreateTime(now);
|
||||
sysUser.setUpdateTime(now);
|
||||
sysUser.setEnabled(request.getEnabled());
|
||||
sysUser.setFrom(1);
|
||||
return sysUser;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
sysUsers.forEach(sysUser -> {
|
||||
sysUserMapper.insert(sysUser);
|
||||
SysUser dbUser = findOne(sysUser);
|
||||
if (null != dbUser && null != dbUser.getUserId()) {
|
||||
saveUserRoles( dbUser.getUserId(), request.getRoleIds());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<String> ldapUserNames() {
|
||||
|
||||
List<String> usernames = extSysUserMapper.ldapUserNames(1);
|
||||
return usernames;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户密码清楚缓存
|
||||
*
|
||||
|
@ -6,36 +6,6 @@ INSERT INTO `sys_msg_type` VALUES (7, 0, 'i18n_msg_type_ds_invalid', 'datasource
|
||||
INSERT INTO `sys_msg_type` VALUES (8, 7, 'i18n_msg_type_ds_invalid', 'datasource', 'to-msg-ds');
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for system_parameter
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `system_parameter`;
|
||||
CREATE TABLE `system_parameter` (
|
||||
`param_key` varchar(64) NOT NULL COMMENT 'Parameter name',
|
||||
`param_value` varchar(255) DEFAULT NULL COMMENT 'Parameter value',
|
||||
`type` varchar(100) NOT NULL DEFAULT 'text' COMMENT 'Parameter type',
|
||||
`sort` int(5) DEFAULT NULL COMMENT 'Sort',
|
||||
PRIMARY KEY (`param_key`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of system_parameter
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `system_parameter` VALUES ('', NULL, 'text', NULL);
|
||||
INSERT INTO `system_parameter` VALUES ('default.language', 'zh_CN', 'text', -1);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.favicon', NULL, 'file', -1);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.loginImage', NULL, 'file', 4);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.loginLogo', NULL, 'file', 5);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.loginTitle', NULL, 'text', 3);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.logo', NULL, 'file', 6);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.theme', NULL, 'text', 2);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.title', NULL, 'text', 1);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.topMenuActiveColor', NULL, 'text', 8);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.topMenuColor', NULL, 'text', 7);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.topMenuTextActiveColor', NULL, 'text', 10);
|
||||
INSERT INTO `system_parameter` VALUES ('ui.topMenuTextColor', NULL, 'text', 9);
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for panel_pdf_template
|
||||
@ -51,3 +21,11 @@ CREATE TABLE `panel_pdf_template` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `chart_view` ADD COLUMN `y_axis_ext` LONGTEXT COMMENT '副轴' AFTER `y_axis`;
|
||||
UPDATE `chart_view` SET `y_axis_ext` = '[]';
|
||||
|
||||
|
||||
ALTER TABLE `sys_user` ADD COLUMN `from` int(4) NOT NULL COMMENT '来源' AFTER `language`;
|
||||
|
||||
INSERT INTO `sys_menu` VALUES (60, 1, 0, 1, '导入LDAP用户', 'system-user-import', 'system/user/imp-ldap', 11, NULL, 'user-ldap', b'0', b'0', b'1', 'user:import', NULL, NULL, NULL, NULL);
|
||||
|
||||
|
@ -64,7 +64,9 @@
|
||||
|
||||
<!--要生成的数据库表 -->
|
||||
|
||||
<table tableName="panel_pdf_template"/>
|
||||
|
||||
<table tableName="chart_view"/>
|
||||
|
||||
<!-- <table tableName="sys_dict_item"/>-->
|
||||
<!-- <table tableName="dataset_table_field"/>-->
|
||||
<!-- <table tableName="v_chart">-->
|
||||
|
@ -283,3 +283,4 @@ i18n_change_task_status_error=Suspension is not allowed. The task status is:
|
||||
i18n_Stopped=END
|
||||
i18n_Exec=Running
|
||||
i18n_no_trigger=The current setting does not trigger task generation.
|
||||
i18n_dataset_field_delete=Union field deleted,please set again and redo.
|
||||
|
@ -282,4 +282,5 @@ i18n_change_task_status_error=不允许暂停,任务状态为:
|
||||
i18n_Stopped=执行结束
|
||||
i18n_Exec=运行中
|
||||
i18n_no_trigger=当前设置没有触发任务生成
|
||||
i18n_dataset_field_delete=该自定义数据集有关联字段被删除,请重新确认关联关系并重做该数据集
|
||||
|
||||
|
@ -285,3 +285,4 @@ i18n_change_task_status_error=不允許暫停,任務狀態為:
|
||||
i18n_Stopped=執行結束
|
||||
i18n_Exec=運行中
|
||||
i18n_no_trigger=当前设置没有触发任务生成 當前設置沒有觸發任務生成.
|
||||
i18n_dataset_field_delete=該自定義數據集有關聯字段被刪除,請重新確認關聯關系並重做該數據集
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>dataease-server</artifactId>
|
||||
<groupId>io.dataease</groupId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -98,4 +98,29 @@ export function roleGrid(pageIndex, pageSize, data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { editPassword, delUser, editUser, addUser, userLists, editStatus, persionInfo, updatePerson, updatePersonPwd, allRoles, roleGrid }
|
||||
export function ldapUsers(data) {
|
||||
return request({
|
||||
url: '/api/ldap/users',
|
||||
method: 'post',
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
|
||||
export function saveLdapUser(data) {
|
||||
return request({
|
||||
url: '/api/user/sync',
|
||||
method: 'post',
|
||||
loading: true,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function existLdapUsers() {
|
||||
return request({
|
||||
url: '/api/user/existLdapUsers',
|
||||
method: 'post',
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
export default { editPassword, delUser, editUser, addUser, userLists, editStatus, persionInfo, updatePerson, updatePersonPwd, allRoles, roleGrid, ldapUsers, saveLdapUser, existLdapUsers }
|
||||
|
@ -50,3 +50,10 @@ export function languageApi(language) {
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
export function ldapStatus() {
|
||||
return request({
|
||||
url: '/api/auth/isOpenLdap',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<chart-component v-if="httpRequest.status &&chart.type && !chart.type.includes('table') && !chart.type.includes('text')" :ref="element.propValue.id" class="chart-class" :chart="chart" :track-menu="trackMenu" @onChartClick="chartClick" />
|
||||
<!-- <chart-component :ref="element.propValue.id" class="chart-class" :chart="chart" :track-menu="trackMenu" @onChartClick="chartClick" />-->
|
||||
<table-normal v-if="httpRequest.status &&chart.type && chart.type.includes('table')" :ref="element.propValue.id" :chart="chart" class="table-class" />
|
||||
<table-normal v-if="httpRequest.status &&chart.type && chart.type.includes('table')" :ref="element.propValue.id" :show-summary="chart.type === 'table-normal'" :chart="chart" class="table-class" />
|
||||
<label-normal v-if="httpRequest.status && chart.type && chart.type.includes('text')" :ref="element.propValue.id" :chart="chart" class="table-class" />
|
||||
<div style="position: absolute;left: 20px;bottom:14px;">
|
||||
<drill-path :drill-filters="drillFilters" @onDrillJump="drillJump" />
|
||||
|
1
frontend/src/icons/svg/table-info.svg
Normal file
1
frontend/src/icons/svg/table-info.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg t="1630896296862" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2121" width="200" height="200"><path d="M85.333333 170.666667h853.333334v170.666666H85.333333z" p-id="2122"></path><path d="M85.333333 384h256v128H85.333333zM384 384h256v128H384zM682.666667 384h256v128H682.666667zM85.333333 725.333333h256v128H85.333333zM384 725.333333h256v128H384zM682.666667 725.333333h256v128H682.666667z" opacity=".6" p-id="2123"></path><path d="M85.333333 554.666667h256v128H85.333333zM384 554.666667h256v128H384zM682.666667 554.666667h256v128H682.666667z" p-id="2124"></path></svg>
|
After Width: | Height: | Size: 619 B |
@ -1 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1619335647805" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="859" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M975.920762 0H72.46019C45.884952 0 24.380952 24.576 24.380952 54.979048v889.660952C24.380952 975.043048 45.884952 999.619048 72.46019 999.619048h903.460572C1002.496 999.619048 1024 975.043048 1024 944.64V54.979048C1024 24.576 1002.496 0 975.920762 0zM338.066286 925.988571H89.965714v-194.243047h248.100572v194.218666z m0-258.925714H89.965714v-194.243047h248.100572v194.218666z m0-258.925714H89.965714V213.991619h248.100572v194.096762z m310.174476 517.851428H400.14019v-194.243047h248.100572v194.218666z m0-258.925714H400.14019v-194.243047h248.100572v194.218666z m0-258.925714H400.14019V213.991619h248.100572v194.096762zM958.415238 925.988571H710.314667v-194.243047H958.415238v194.218666z m0-258.925714H710.314667v-194.243047H958.415238v194.218666z m0-258.925714H710.314667V213.991619H958.415238v194.096762z" p-id="860"></path></svg>
|
||||
<svg t="1630896178915" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1969" width="200" height="200"><path d="M85.333333 170.666667h853.333334v170.666666H85.333333zM85.333333 384h170.666667v469.333333H85.333333z" p-id="1970"></path><path d="M298.666667 384h640v128H298.666667z" opacity=".6" p-id="1971"></path><path d="M298.666667 554.666667h298.666666v128H298.666667zM640 554.666667h298.666667v128H640z" p-id="1972"></path><path d="M298.666667 725.333333h298.666666v128H298.666667zM640 725.333333h298.666667v128H640z" opacity=".6" p-id="1973"></path></svg>
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 603 B |
@ -746,7 +746,8 @@ export default {
|
||||
filter_condition: 'Filter Condition',
|
||||
filter_field_can_null: 'Filter field must choose',
|
||||
preview_100_data: 'Preview 100 rows',
|
||||
chart_table_normal: 'Detail Table',
|
||||
chart_table_normal: 'Summary Table',
|
||||
chart_table_info: 'Detail Table',
|
||||
chart_card: 'KPI Card',
|
||||
chart_bar: 'Base Bar',
|
||||
chart_bar_stack: 'Stack Bar',
|
||||
@ -854,7 +855,14 @@ export default {
|
||||
axis_value_min: 'Min',
|
||||
axis_value_max: 'Max',
|
||||
axis_value_split: 'Split',
|
||||
axis_auto: 'Auto'
|
||||
axis_auto: 'Auto',
|
||||
table_info_switch: 'Switch detail table will clear dimensions',
|
||||
drag_block_value_axis_main: 'Main Axis Value',
|
||||
drag_block_value_axis_ext: 'Ext Axis Value',
|
||||
yAxis_main: 'Main Vertical Axis',
|
||||
yAxis_ext: 'Ext Vertical Axis',
|
||||
total: 'Total',
|
||||
items: 'Items'
|
||||
},
|
||||
dataset: {
|
||||
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',
|
||||
@ -1044,6 +1052,7 @@ export default {
|
||||
please_input_user_name: 'Please enter user name',
|
||||
please_input_password: 'Please enter Password',
|
||||
please_input_host: 'Please enter host',
|
||||
please_input_url: 'Please enter url adress',
|
||||
please_input_port: 'Please enter port',
|
||||
modify: 'Edit data Source',
|
||||
validate_success: 'Verification successful',
|
||||
|
@ -745,7 +745,8 @@ export default {
|
||||
filter_condition: '過濾條件',
|
||||
filter_field_can_null: '過濾字段必填',
|
||||
preview_100_data: '預覽前100條記錄',
|
||||
chart_table_normal: '明細表',
|
||||
chart_table_normal: '匯總表',
|
||||
chart_table_info: '明細表',
|
||||
chart_card: '指標卡',
|
||||
chart_bar: '基礎柱狀圖',
|
||||
chart_bar_stack: '堆疊柱狀圖',
|
||||
@ -853,7 +854,14 @@ export default {
|
||||
axis_value_min: '最小值',
|
||||
axis_value_max: '最大值',
|
||||
axis_value_split: '間隔',
|
||||
axis_auto: '自動'
|
||||
axis_auto: '自動',
|
||||
table_info_switch: '明細表切換將清空維度',
|
||||
drag_block_value_axis_main: '主軸值',
|
||||
drag_block_value_axis_ext: '副軸值',
|
||||
yAxis_main: '主縱軸',
|
||||
yAxis_ext: '副縱軸',
|
||||
total: '共',
|
||||
items: '條數據'
|
||||
},
|
||||
dataset: {
|
||||
sheet_warn: '有多個sheet頁面,默認抽取第一個',
|
||||
@ -1043,6 +1051,7 @@ export default {
|
||||
please_input_user_name: '請輸入用戶名',
|
||||
please_input_password: '請輸入密碼',
|
||||
please_input_host: '請輸入主機',
|
||||
please_input_url: '請輸入URL地址',
|
||||
please_input_port: '請輸入',
|
||||
modify: '編輯數據源',
|
||||
validate_success: '校驗成功',
|
||||
|
@ -482,6 +482,7 @@ export default {
|
||||
input_password: '请输入密码',
|
||||
input_phone: '请输入电话号码',
|
||||
input_roles: '请选择角色',
|
||||
select_users: '请选择用户',
|
||||
special_characters_are_not_supported: '不支持特殊字符',
|
||||
mobile_number_format_is_incorrect: '手机号码格式不正确',
|
||||
email_format_is_incorrect: '邮箱格式不正确',
|
||||
@ -496,7 +497,38 @@ export default {
|
||||
new_passwd: '新密码',
|
||||
confirm_passwd: '确认密码',
|
||||
change_password: '修改密码',
|
||||
search_by_name: '按姓名搜索'
|
||||
search_by_name: '按姓名搜索',
|
||||
import_ldap: '导入LDAP用户'
|
||||
},
|
||||
ldap: {
|
||||
url: 'LDAP地址',
|
||||
dn: '绑定DN',
|
||||
password: '密码',
|
||||
ou: '用户OU',
|
||||
filter: '用户过滤器',
|
||||
mapping: 'LDAP属性映射',
|
||||
open: '启用LDAP认证',
|
||||
input_url: '请输入LDAP地址',
|
||||
input_dn: '请输入DN',
|
||||
input_password: '请输入密码',
|
||||
input_ou: '请输入用户OU',
|
||||
input_filter: '请输入用户过滤器',
|
||||
input_mapping: '请输入LDAP属性映射',
|
||||
input_username: '请输入用户名',
|
||||
input_url_placeholder: '请输入LDAP地址 (如 ldap://localhost:389)',
|
||||
input_ou_placeholder: '输入用户OU (使用|分隔各OU)',
|
||||
input_filter_placeholder: '输入过滤器 [可能的选项是cn或uid或sAMAccountName={0}, 如:(uid={0})]',
|
||||
input_mapping_placeholder: '如:{"username":"uid","name":"sn","email":"mail"}, username映射的选项可能是cn或uid或sAMAccountName',
|
||||
test_connect: '测试连接',
|
||||
test_login: '测试登录',
|
||||
edit: '编辑',
|
||||
login_success: '登录成功',
|
||||
url_cannot_be_empty: 'LDAP 地址不能为空',
|
||||
dn_cannot_be_empty: 'LDAP DN不能为空',
|
||||
ou_cannot_be_empty: 'LDAP OU不能为空',
|
||||
filter_cannot_be_empty: 'LDAP 用户过滤器不能为空',
|
||||
mapping_cannot_be_empty: 'LDAP 用户属性映射不能为空',
|
||||
password_cannot_be_empty: 'LDAP 密码不能为空'
|
||||
},
|
||||
role: {
|
||||
menu_authorization: '菜单授权',
|
||||
@ -745,7 +777,8 @@ export default {
|
||||
filter_condition: '过滤条件',
|
||||
filter_field_can_null: '过滤字段必填',
|
||||
preview_100_data: '预览前100条记录',
|
||||
chart_table_normal: '明细表',
|
||||
chart_table_normal: '汇总表',
|
||||
chart_table_info: '明细表',
|
||||
chart_card: '指标卡',
|
||||
chart_bar: '基础柱状图',
|
||||
chart_bar_stack: '堆叠柱状图',
|
||||
@ -853,7 +886,14 @@ export default {
|
||||
axis_value_min: '最小值',
|
||||
axis_value_max: '最大值',
|
||||
axis_value_split: '间隔',
|
||||
axis_auto: '自动'
|
||||
axis_auto: '自动',
|
||||
table_info_switch: '明细表切换将清空维度',
|
||||
drag_block_value_axis_main: '主轴值',
|
||||
drag_block_value_axis_ext: '副轴值',
|
||||
yAxis_main: '主纵轴',
|
||||
yAxis_ext: '副纵轴',
|
||||
total: '共',
|
||||
items: '条数据'
|
||||
},
|
||||
dataset: {
|
||||
sheet_warn: '有多个 Sheet 页,默认抽取第一个',
|
||||
@ -1044,6 +1084,7 @@ export default {
|
||||
please_input_user_name: '请输入用户名',
|
||||
please_input_password: '请输入密码',
|
||||
please_input_host: '请输入主机',
|
||||
please_input_url: '请输入URL地址',
|
||||
please_input_port: '请输入端口',
|
||||
modify: '编辑数据源',
|
||||
validate_success: '校验成功',
|
||||
|
@ -71,9 +71,9 @@ const mutations = {
|
||||
const actions = {
|
||||
// user login
|
||||
login({ commit }, userInfo) {
|
||||
const { username, password } = userInfo
|
||||
const { username, password, loginType } = userInfo
|
||||
return new Promise((resolve, reject) => {
|
||||
login({ username: username.trim(), password: password }).then(response => {
|
||||
login({ username: username.trim(), password: password, loginType: loginType }).then(response => {
|
||||
const { data } = response
|
||||
commit('SET_TOKEN', data.token)
|
||||
commit('SET_LOGIN_MSG', null)
|
||||
|
@ -145,6 +145,36 @@ export const DEFAULT_YAXIS_STYLE = {
|
||||
split: null
|
||||
}
|
||||
}
|
||||
export const DEFAULT_YAXIS_EXT_STYLE = {
|
||||
show: true,
|
||||
position: 'right',
|
||||
name: '',
|
||||
nameTextStyle: {
|
||||
color: '#333333',
|
||||
fontSize: 12
|
||||
},
|
||||
axisLabel: {
|
||||
show: true,
|
||||
color: '#333333',
|
||||
fontSize: '12',
|
||||
rotate: 0,
|
||||
formatter: '{value}'
|
||||
},
|
||||
splitLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: '#cccccc',
|
||||
width: 1,
|
||||
style: 'solid'
|
||||
}
|
||||
},
|
||||
axisValue: {
|
||||
auto: true,
|
||||
min: null,
|
||||
max: null,
|
||||
split: null
|
||||
}
|
||||
}
|
||||
export const DEFAULT_BACKGROUND_COLOR = {
|
||||
color: '#ffffff',
|
||||
alpha: 0
|
||||
@ -586,6 +616,7 @@ export const BASE_CHART_STRING = {
|
||||
legend: DEFAULT_LEGEND_STYLE,
|
||||
xAxis: DEFAULT_XAXIS_STYLE,
|
||||
yAxis: DEFAULT_YAXIS_STYLE,
|
||||
yAxisExt: DEFAULT_YAXIS_EXT_STYLE,
|
||||
background: DEFAULT_BACKGROUND_COLOR
|
||||
}),
|
||||
customFilter: '[]'
|
||||
@ -609,6 +640,7 @@ export const BASE_CHART = {
|
||||
legend: DEFAULT_LEGEND_STYLE,
|
||||
xAxis: DEFAULT_XAXIS_STYLE,
|
||||
yAxis: DEFAULT_YAXIS_STYLE,
|
||||
yAxisExt: DEFAULT_YAXIS_EXT_STYLE,
|
||||
background: DEFAULT_BACKGROUND_COLOR
|
||||
},
|
||||
customFilter: []
|
||||
@ -771,9 +803,14 @@ export const BASE_MIX = {
|
||||
xAxis: {
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value'
|
||||
},
|
||||
{
|
||||
type: 'value'
|
||||
}
|
||||
],
|
||||
series: [],
|
||||
dataZoom: [
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { hexColorToRGBA } from '@/views/chart/chart/util'
|
||||
import { DEFAULT_YAXIS_EXT_STYLE } from '@/views/chart/chart/chart'
|
||||
|
||||
export function componentStyle(chart_option, chart) {
|
||||
const padding = '8px'
|
||||
@ -50,6 +51,9 @@ export function componentStyle(chart_option, chart) {
|
||||
chart_option.legend.orient = customStyle.legend.orient
|
||||
chart_option.legend.icon = customStyle.legend.icon
|
||||
chart_option.legend.textStyle = customStyle.legend.textStyle
|
||||
if (chart.type === 'treemap') {
|
||||
chart_option.legend.show = false
|
||||
}
|
||||
}
|
||||
if (customStyle.xAxis && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter') || chart.type === 'chart-mix')) {
|
||||
chart_option.xAxis.show = customStyle.xAxis.show
|
||||
@ -78,7 +82,7 @@ export function componentStyle(chart_option, chart) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (customStyle.yAxis && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter') || chart.type === 'chart-mix')) {
|
||||
if (customStyle.yAxis && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter'))) {
|
||||
chart_option.yAxis.show = customStyle.yAxis.show
|
||||
chart_option.yAxis.position = customStyle.yAxis.position
|
||||
chart_option.yAxis.name = customStyle.yAxis.name
|
||||
@ -105,6 +109,61 @@ export function componentStyle(chart_option, chart) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (customStyle.yAxis && chart.type === 'chart-mix') {
|
||||
chart_option.yAxis[0].show = customStyle.yAxis.show
|
||||
chart_option.yAxis[0].position = customStyle.yAxis.position
|
||||
chart_option.yAxis[0].name = customStyle.yAxis.name
|
||||
chart_option.yAxis[0].axisLabel = customStyle.yAxis.axisLabel
|
||||
chart_option.yAxis[0].splitLine = customStyle.yAxis.splitLine
|
||||
chart_option.yAxis[0].nameTextStyle = customStyle.yAxis.nameTextStyle
|
||||
|
||||
chart_option.yAxis[0].axisLabel.showMaxLabel = true
|
||||
chart_option.yAxis[0].axisLabel.showMinLabel = true
|
||||
|
||||
if (!customStyle.yAxis.show) {
|
||||
chart_option.yAxis[0].axisLabel.show = false
|
||||
}
|
||||
|
||||
// 轴值设置
|
||||
delete chart_option.yAxis[0].min
|
||||
delete chart_option.yAxis[0].max
|
||||
delete chart_option.yAxis[0].split
|
||||
if (!chart.type.includes('horizontal')) {
|
||||
if (customStyle.yAxis.axisValue && !customStyle.yAxis.axisValue.auto) {
|
||||
customStyle.yAxis.axisValue.min && (chart_option.yAxis[0].min = parseFloat(customStyle.yAxis.axisValue.min))
|
||||
customStyle.yAxis.axisValue.max && (chart_option.yAxis[0].max = parseFloat(customStyle.yAxis.axisValue.max))
|
||||
customStyle.yAxis.axisValue.split && (chart_option.yAxis[0].interval = parseFloat(customStyle.yAxis.axisValue.split))
|
||||
}
|
||||
}
|
||||
|
||||
// axis ext
|
||||
!customStyle.yAxisExt && (customStyle.yAxisExt = JSON.parse(JSON.stringify(DEFAULT_YAXIS_EXT_STYLE)))
|
||||
chart_option.yAxis[1].show = customStyle.yAxisExt.show
|
||||
chart_option.yAxis[1].position = customStyle.yAxisExt.position
|
||||
chart_option.yAxis[1].name = customStyle.yAxisExt.name
|
||||
chart_option.yAxis[1].axisLabel = customStyle.yAxisExt.axisLabel
|
||||
chart_option.yAxis[1].splitLine = customStyle.yAxisExt.splitLine
|
||||
chart_option.yAxis[1].nameTextStyle = customStyle.yAxisExt.nameTextStyle
|
||||
|
||||
chart_option.yAxis[1].axisLabel.showMaxLabel = true
|
||||
chart_option.yAxis[1].axisLabel.showMinLabel = true
|
||||
|
||||
if (!customStyle.yAxisExt.show) {
|
||||
chart_option.yAxis[1].axisLabel.show = false
|
||||
}
|
||||
|
||||
// 轴值设置
|
||||
delete chart_option.yAxis[1].min
|
||||
delete chart_option.yAxis[1].max
|
||||
delete chart_option.yAxis[1].split
|
||||
if (!chart.type.includes('horizontal')) {
|
||||
if (customStyle.yAxisExt.axisValue && !customStyle.yAxisExt.axisValue.auto) {
|
||||
customStyle.yAxisExt.axisValue.min && (chart_option.yAxis[1].min = parseFloat(customStyle.yAxisExt.axisValue.min))
|
||||
customStyle.yAxisExt.axisValue.max && (chart_option.yAxis[1].max = parseFloat(customStyle.yAxisExt.axisValue.max))
|
||||
customStyle.yAxisExt.axisValue.split && (chart_option.yAxis[1].interval = parseFloat(customStyle.yAxisExt.axisValue.split))
|
||||
}
|
||||
}
|
||||
}
|
||||
if (customStyle.split && chart.type.includes('radar')) {
|
||||
chart_option.radar.name = customStyle.split.name
|
||||
chart_option.radar.splitNumber = customStyle.split.splitNumber
|
||||
|
@ -4,6 +4,7 @@ import { componentStyle } from '../common/common'
|
||||
export function baseMixOption(chart_option, chart) {
|
||||
// 处理shape attr
|
||||
let customAttr = {}
|
||||
const yAxis = JSON.parse(chart.yaxis)
|
||||
if (chart.customAttr) {
|
||||
customAttr = JSON.parse(chart.customAttr)
|
||||
if (customAttr.color) {
|
||||
@ -68,6 +69,7 @@ export function baseMixOption(chart_option, chart) {
|
||||
y.label = customAttr.label
|
||||
}
|
||||
chart_option.legend.data.push(y.name)
|
||||
i >= yAxis.length ? (y.yAxisIndex = 1) : (y.yAxisIndex = 0)
|
||||
chart_option.series.push(y)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,220 @@
|
||||
<template>
|
||||
<div style="width: 100%">
|
||||
<el-col>
|
||||
<el-form ref="axisForm" :model="axisForm" label-width="80px" size="mini" :disabled="!hasDataPermission('manage',param.privileges)">
|
||||
<el-form-item :label="$t('chart.show')" class="form-item">
|
||||
<el-checkbox v-model="axisForm.show" @change="changeYAxisStyle">{{ $t('chart.show') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
<div v-show="axisForm.show">
|
||||
<el-form-item :label="$t('chart.position')" class="form-item">
|
||||
<el-radio-group v-model="axisForm.position" size="mini" @change="changeYAxisStyle">
|
||||
<el-radio-button label="left">{{ $t('chart.text_pos_left') }}</el-radio-button>
|
||||
<el-radio-button label="right">{{ $t('chart.text_pos_right') }}</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.name')" class="form-item">
|
||||
<el-input v-model="axisForm.name" size="mini" @blur="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.axis_name_color')" class="form-item">
|
||||
<el-color-picker v-model="axisForm.nameTextStyle.color" class="color-picker-style" @change="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.axis_name_fontsize')" class="form-item">
|
||||
<el-select v-model="axisForm.nameTextStyle.fontSize" :placeholder="$t('chart.axis_name_fontsize')" @change="changeYAxisStyle">
|
||||
<el-option v-for="option in fontSize" :key="option.value" :label="option.name" :value="option.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<span v-show="chart.type && !chart.type.includes('horizontal')">
|
||||
<el-divider />
|
||||
<el-form-item class="form-item">
|
||||
<span slot="label">
|
||||
<span class="span-box">
|
||||
<span>{{ $t('chart.axis_value') }}</span>
|
||||
<el-tooltip class="item" effect="dark" placement="bottom">
|
||||
<div slot="content">
|
||||
最小值、最大值、间隔均为数值类型;若不填,则该项视为自动。
|
||||
<br>
|
||||
请确保填写数值能正确计算,否则将无法正常显示轴值。
|
||||
</div>
|
||||
<i class="el-icon-info" style="cursor: pointer;" />
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</span>
|
||||
<el-checkbox v-model="axisForm.axisValue.auto" @change="changeYAxisStyle">{{ $t('chart.axis_auto') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
<span v-show="!axisForm.axisValue.auto">
|
||||
<el-form-item :label="$t('chart.axis_value_min')" class="form-item">
|
||||
<el-input v-model="axisForm.axisValue.min" @blur="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.axis_value_max')" class="form-item">
|
||||
<el-input v-model="axisForm.axisValue.max" @blur="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.axis_value_split')" class="form-item">
|
||||
<el-input v-model="axisForm.axisValue.split" @blur="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
</span>
|
||||
</span>
|
||||
<el-divider />
|
||||
<el-form-item :label="$t('chart.axis_show')" class="form-item">
|
||||
<el-checkbox v-model="axisForm.splitLine.show" @change="changeYAxisStyle">{{ $t('chart.axis_show') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
<span v-show="axisForm.splitLine.show">
|
||||
<el-form-item :label="$t('chart.axis_color')" class="form-item">
|
||||
<el-color-picker v-model="axisForm.splitLine.lineStyle.color" class="el-color-picker" @change="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.axis_width')" class="form-item form-item-slider">
|
||||
<el-slider v-model="axisForm.splitLine.lineStyle.width" :min="1" :max="10" show-input :show-input-controls="false" input-size="mini" @change="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.axis_type')" class="form-item">
|
||||
<el-radio-group v-model="axisForm.splitLine.lineStyle.type" size="mini" @change="changeYAxisStyle">
|
||||
<el-radio-button label="solid">{{ $t('chart.axis_type_solid') }}</el-radio-button>
|
||||
<el-radio-button label="dashed">{{ $t('chart.axis_type_dashed') }}</el-radio-button>
|
||||
<el-radio-button label="dotted">{{ $t('chart.axis_type_dotted') }}</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</span>
|
||||
<el-divider />
|
||||
<el-form-item :label="$t('chart.axis_label_show')" class="form-item">
|
||||
<el-checkbox v-model="axisForm.axisLabel.show" @change="changeYAxisStyle">{{ $t('chart.axis_label_show') }}</el-checkbox>
|
||||
</el-form-item>
|
||||
<span v-show="axisForm.axisLabel.show">
|
||||
<el-form-item :label="$t('chart.axis_label_color')" class="form-item">
|
||||
<el-color-picker v-model="axisForm.axisLabel.color" class="el-color-picker" @change="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.axis_label_rotate')" class="form-item form-item-slider">
|
||||
<el-slider v-model="axisForm.axisLabel.rotate" show-input :show-input-controls="false" :min="-90" :max="90" input-size="mini" @change="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.axis_label_fontsize')" class="form-item">
|
||||
<el-select v-model="axisForm.axisLabel.fontSize" :placeholder="$t('chart.axis_label_fontsize')" @change="changeYAxisStyle">
|
||||
<el-option v-for="option in fontSize" :key="option.value" :label="option.name" :value="option.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</span>
|
||||
<el-divider />
|
||||
<el-form-item :label="$t('chart.content_formatter')" class="form-item">
|
||||
<el-input v-model="axisForm.axisLabel.formatter" type="textarea" :autosize="{ minRows: 4, maxRows: 4}" @blur="changeYAxisStyle" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { DEFAULT_YAXIS_EXT_STYLE } from '../../chart/chart'
|
||||
|
||||
export default {
|
||||
name: 'YAxisExtSelector',
|
||||
props: {
|
||||
param: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
chart: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
axisForm: JSON.parse(JSON.stringify(DEFAULT_YAXIS_EXT_STYLE)),
|
||||
isSetting: false,
|
||||
fontSize: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'chart': {
|
||||
handler: function() {
|
||||
this.initData()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
this.initData()
|
||||
},
|
||||
methods: {
|
||||
initData() {
|
||||
const chart = JSON.parse(JSON.stringify(this.chart))
|
||||
if (chart.customStyle) {
|
||||
// if (!chart.customStyle.yAxisExt) {
|
||||
// chart.customStyle.yAxisExt = JSON.parse(JSON.stringify(DEFAULT_YAXIS_EXT_STYLE))
|
||||
// }
|
||||
let customStyle = null
|
||||
if (Object.prototype.toString.call(chart.customStyle) === '[object Object]') {
|
||||
customStyle = JSON.parse(JSON.stringify(chart.customStyle))
|
||||
} else {
|
||||
customStyle = JSON.parse(chart.customStyle)
|
||||
}
|
||||
if (customStyle.yAxisExt) {
|
||||
this.axisForm = customStyle.yAxisExt
|
||||
if (!this.axisForm.splitLine) {
|
||||
this.axisForm.splitLine = JSON.parse(JSON.stringify(DEFAULT_YAXIS_EXT_STYLE.splitLine))
|
||||
}
|
||||
if (!this.axisForm.nameTextStyle) {
|
||||
this.axisForm.nameTextStyle = JSON.parse(JSON.stringify(DEFAULT_YAXIS_EXT_STYLE.nameTextStyle))
|
||||
}
|
||||
if (!this.axisForm.axisValue) {
|
||||
this.axisForm.axisValue = JSON.parse(JSON.stringify(DEFAULT_YAXIS_EXT_STYLE.axisValue))
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
init() {
|
||||
const arr = []
|
||||
for (let i = 6; i <= 40; i = i + 2) {
|
||||
arr.push({
|
||||
name: i + '',
|
||||
value: i + ''
|
||||
})
|
||||
}
|
||||
this.fontSize = arr
|
||||
},
|
||||
changeYAxisStyle() {
|
||||
if (!this.axisForm.show) {
|
||||
this.isSetting = false
|
||||
}
|
||||
this.$emit('onChangeYAxisForm', this.axisForm)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-divider--horizontal {
|
||||
margin: 10px 0
|
||||
}
|
||||
.shape-item{
|
||||
padding: 6px;
|
||||
border: none;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.form-item-slider>>>.el-form-item__label{
|
||||
font-size: 12px;
|
||||
line-height: 38px;
|
||||
}
|
||||
.form-item>>>.el-form-item__label{
|
||||
font-size: 12px;
|
||||
}
|
||||
.el-select-dropdown__item{
|
||||
padding: 0 20px;
|
||||
}
|
||||
span{
|
||||
font-size: 12px
|
||||
}
|
||||
.el-form-item{
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.switch-style{
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
margin-top: -4px;
|
||||
}
|
||||
.color-picker-style{
|
||||
cursor: pointer;
|
||||
z-index: 1003;
|
||||
}
|
||||
</style>
|
284
frontend/src/views/chart/components/drag-item/QuotaExtItem.vue
Normal file
284
frontend/src/views/chart/components/drag-item/QuotaExtItem.vue
Normal file
@ -0,0 +1,284 @@
|
||||
<template>
|
||||
<span>
|
||||
<el-tag v-if="!hasDataPermission('manage',param.privileges)" size="small" class="item-axis" :type="item.groupType === 'q'?'success':''">
|
||||
<span style="float: left">
|
||||
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
|
||||
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
|
||||
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
|
||||
<svg-icon v-if="item.deType === 5" icon-class="field_location" class="field-icon-location" />
|
||||
<svg-icon v-if="chart.type ==='chart-mix' && item.chartType === 'bar'" icon-class="bar" class-name="field-icon-sort" />
|
||||
<svg-icon v-if="chart.type ==='chart-mix' && item.chartType === 'line'" icon-class="line" class-name="field-icon-sort" />
|
||||
<svg-icon v-if="chart.type ==='chart-mix' && item.chartType === 'scatter'" icon-class="scatter" class-name="field-icon-sort" />
|
||||
<svg-icon v-if="item.sort === 'asc'" icon-class="sort-asc" class-name="field-icon-sort" />
|
||||
<svg-icon v-if="item.sort === 'desc'" icon-class="sort-desc" class-name="field-icon-sort" />
|
||||
</span>
|
||||
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
|
||||
<span v-if="chart.type !== 'table-info' && item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span>
|
||||
</el-tag>
|
||||
<el-dropdown v-else trigger="click" size="mini" @command="clickItem">
|
||||
<span class="el-dropdown-link">
|
||||
<el-tag size="small" class="item-axis" :type="item.groupType === 'q'?'success':''">
|
||||
<span style="float: left">
|
||||
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
|
||||
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
|
||||
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
|
||||
<svg-icon v-if="item.deType === 5" icon-class="field_location" class="field-icon-location" />
|
||||
<svg-icon v-if="chart.type ==='chart-mix' && item.chartType === 'bar'" icon-class="bar" class-name="field-icon-sort" />
|
||||
<svg-icon v-if="chart.type ==='chart-mix' && item.chartType === 'line'" icon-class="line" class-name="field-icon-sort" />
|
||||
<svg-icon v-if="chart.type ==='chart-mix' && item.chartType === 'scatter'" icon-class="scatter" class-name="field-icon-sort" />
|
||||
<svg-icon v-if="item.sort === 'asc'" icon-class="sort-asc" class-name="field-icon-sort" />
|
||||
<svg-icon v-if="item.sort === 'desc'" icon-class="sort-desc" class-name="field-icon-sort" />
|
||||
</span>
|
||||
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
|
||||
<span v-if="chart.type !== 'table-info' && item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span>
|
||||
<i class="el-icon-arrow-down el-icon--right" style="position: absolute;top: 6px;right: 10px;" />
|
||||
</el-tag>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item v-show="chart.type ==='chart-mix'">
|
||||
<el-dropdown placement="right-start" size="mini" style="width: 100%" @command="switchChartType">
|
||||
<span class="el-dropdown-link inner-dropdown-menu">
|
||||
<span>
|
||||
<i class="el-icon-s-data" />
|
||||
<span>{{ $t('chart.chart_type') }}</span>
|
||||
</span>
|
||||
<i class="el-icon-arrow-right el-icon--right" />
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="beforeSwitch('bar')">{{ $t('chart.chart_bar') }}</el-dropdown-item>
|
||||
<el-dropdown-item :command="beforeSwitch('line')">{{ $t('chart.chart_line') }}</el-dropdown-item>
|
||||
<el-dropdown-item :command="beforeSwitch('scatter')">{{ $t('chart.chart_scatter') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-show="chart.type !== 'table-info'" :divided="chart.type === 'chart-mix'">
|
||||
<el-dropdown placement="right-start" size="mini" style="width: 100%" @command="summary">
|
||||
<span class="el-dropdown-link inner-dropdown-menu">
|
||||
<span>
|
||||
<i class="el-icon-notebook-2" />
|
||||
<span>{{ $t('chart.summary') }}</span>
|
||||
<span class="summary-span-item">({{ $t('chart.'+item.summary) }})</span>
|
||||
</span>
|
||||
<i class="el-icon-arrow-right el-icon--right" />
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item v-if="item.id === 'count' || item.deType === 0 || item.deType === 1" :command="beforeSummary('count')">{{ $t('chart.count') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="item.id !== 'count' && item.deType !== 0 && item.deType !== 1" :command="beforeSummary('sum')">{{ $t('chart.sum') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="item.id !== 'count' && item.deType !== 0 && item.deType !== 1" :command="beforeSummary('avg')">{{ $t('chart.avg') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="item.id !== 'count' && item.deType !== 0 && item.deType !== 1" :command="beforeSummary('max')">{{ $t('chart.max') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="item.id !== 'count' && item.deType !== 0 && item.deType !== 1" :command="beforeSummary('min')">{{ $t('chart.min') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="item.id !== 'count' && item.deType !== 0 && item.deType !== 1" :command="beforeSummary('stddev_pop')">{{ $t('chart.stddev_pop') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="item.id !== 'count' && item.deType !== 0 && item.deType !== 1" :command="beforeSummary('var_pop')">{{ $t('chart.var_pop') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</el-dropdown-item>
|
||||
<!-- 快速计算先隐藏-->
|
||||
<!-- <el-dropdown-item v-if="item.id !== 'count'">-->
|
||||
<!-- <el-dropdown placement="right-start" size="mini" style="width: 100%" @command="quickCalc">-->
|
||||
<!-- <span class="el-dropdown-link inner-dropdown-menu">-->
|
||||
<!-- <span>-->
|
||||
<!-- <i class="el-icon-s-grid" />-->
|
||||
<!-- <span>{{ $t('chart.quick_calc') }}</span>-->
|
||||
<!-- <span class="summary-span-item">(无)</span>-->
|
||||
<!-- </span>-->
|
||||
<!-- <i class="el-icon-arrow-right el-icon--right" />-->
|
||||
<!-- </span>-->
|
||||
<!-- <el-dropdown-menu slot="dropdown">-->
|
||||
<!-- <el-dropdown-item :command="beforeQuickCalc('none')">无</el-dropdown-item>-->
|
||||
<!-- </el-dropdown-menu>-->
|
||||
<!-- </el-dropdown>-->
|
||||
<!-- </el-dropdown-item>-->
|
||||
<el-dropdown-item :divided="chart.type !== 'table-info'">
|
||||
<el-dropdown placement="right-start" size="mini" style="width: 100%" @command="sort">
|
||||
<span class="el-dropdown-link inner-dropdown-menu">
|
||||
<span>
|
||||
<i class="el-icon-sort" />
|
||||
<span>{{ $t('chart.sort') }}</span>
|
||||
<span class="summary-span-item">({{ $t('chart.'+item.sort) }})</span>
|
||||
</span>
|
||||
<i class="el-icon-arrow-right el-icon--right" />
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="beforeSort('none')">{{ $t('chart.none') }}</el-dropdown-item>
|
||||
<el-dropdown-item :command="beforeSort('asc')">{{ $t('chart.asc') }}</el-dropdown-item>
|
||||
<el-dropdown-item :command="beforeSort('desc')">{{ $t('chart.desc') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-files" :command="beforeClickItem('filter')">
|
||||
<span>{{ $t('chart.filter') }}...</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-edit-outline" divided :command="beforeClickItem('rename')">
|
||||
<span>{{ $t('chart.show_name_set') }}</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-delete" divided :command="beforeClickItem('remove')">
|
||||
<span>{{ $t('chart.delete') }}</span>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</span>
|
||||
</el-dropdown>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'QuotaExtItem',
|
||||
props: {
|
||||
param: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
item: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
chart: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
clickItem(param) {
|
||||
if (!param) {
|
||||
return
|
||||
}
|
||||
switch (param.type) {
|
||||
case 'rename':
|
||||
this.showRename()
|
||||
break
|
||||
case 'remove':
|
||||
this.removeItem()
|
||||
break
|
||||
case 'filter':
|
||||
this.editFilter()
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
},
|
||||
beforeClickItem(type) {
|
||||
return {
|
||||
type: type
|
||||
}
|
||||
},
|
||||
|
||||
summary(param) {
|
||||
// console.log(param)
|
||||
this.item.summary = param.type
|
||||
this.$emit('onQuotaItemChange', this.item)
|
||||
},
|
||||
beforeSummary(type) {
|
||||
return {
|
||||
type: type
|
||||
}
|
||||
},
|
||||
|
||||
switchChartType(param) {
|
||||
// console.log(param)
|
||||
this.item.chartType = param.type
|
||||
this.$emit('onQuotaItemChange', this.item)
|
||||
},
|
||||
beforeSwitch(type) {
|
||||
return {
|
||||
type: type
|
||||
}
|
||||
},
|
||||
|
||||
quickCalc(param) {
|
||||
|
||||
},
|
||||
beforeQuickCalc(type) {
|
||||
return {
|
||||
type: type
|
||||
}
|
||||
},
|
||||
|
||||
sort(param) {
|
||||
// console.log(param)
|
||||
this.item.sort = param.type
|
||||
this.$emit('onQuotaItemChange', this.item)
|
||||
},
|
||||
beforeSort(type) {
|
||||
return {
|
||||
type: type
|
||||
}
|
||||
},
|
||||
showRename() {
|
||||
this.item.index = this.index
|
||||
this.item.renameType = 'quotaExt'
|
||||
this.$emit('onNameEdit', this.item)
|
||||
},
|
||||
removeItem() {
|
||||
this.item.index = this.index
|
||||
this.item.removeType = 'quotaExt'
|
||||
this.$emit('onQuotaItemRemove', this.item)
|
||||
},
|
||||
editFilter() {
|
||||
this.item.index = this.index
|
||||
this.item.filterType = 'quotaExt'
|
||||
this.$emit('editItemFilter', this.item)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.item-axis {
|
||||
padding: 1px 6px;
|
||||
margin: 0 3px 2px 3px;
|
||||
text-align: left;
|
||||
height: 24px;
|
||||
line-height: 22px;
|
||||
display: flex;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
white-space: nowrap;
|
||||
width: 159px;
|
||||
}
|
||||
|
||||
.item-axis:hover {
|
||||
background-color: #fdfdfd;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.summary-span-item{
|
||||
margin-left: 4px;
|
||||
color: #878d9f;
|
||||
}
|
||||
|
||||
.summary-span{
|
||||
margin-left: 4px;
|
||||
color: #878d9f;
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
}
|
||||
|
||||
.inner-dropdown-menu{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
.item-span-style{
|
||||
display: inline-block;
|
||||
width: 70px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
@ -13,7 +13,7 @@
|
||||
<svg-icon v-if="item.sort === 'desc'" icon-class="sort-desc" class-name="field-icon-sort" />
|
||||
</span>
|
||||
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
|
||||
<span v-if="item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span>
|
||||
<span v-if="chart.type !== 'table-info' && item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span>
|
||||
</el-tag>
|
||||
<el-dropdown v-else trigger="click" size="mini" @command="clickItem">
|
||||
<span class="el-dropdown-link">
|
||||
@ -30,7 +30,7 @@
|
||||
<svg-icon v-if="item.sort === 'desc'" icon-class="sort-desc" class-name="field-icon-sort" />
|
||||
</span>
|
||||
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
|
||||
<span v-if="item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span>
|
||||
<span v-if="chart.type !== 'table-info' && item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span>
|
||||
<i class="el-icon-arrow-down el-icon--right" style="position: absolute;top: 6px;right: 10px;" />
|
||||
</el-tag>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
@ -50,7 +50,7 @@
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item divided>
|
||||
<el-dropdown-item v-show="chart.type !== 'table-info'" :divided="chart.type === 'chart-mix'">
|
||||
<el-dropdown placement="right-start" size="mini" style="width: 100%" @command="summary">
|
||||
<span class="el-dropdown-link inner-dropdown-menu">
|
||||
<span>
|
||||
@ -87,7 +87,7 @@
|
||||
<!-- </el-dropdown-menu>-->
|
||||
<!-- </el-dropdown>-->
|
||||
<!-- </el-dropdown-item>-->
|
||||
<el-dropdown-item divided>
|
||||
<el-dropdown-item :divided="chart.type !== 'table-info'">
|
||||
<el-dropdown placement="right-start" size="mini" style="width: 100%" @command="sort">
|
||||
<span class="el-dropdown-link inner-dropdown-menu">
|
||||
<span>
|
||||
@ -220,10 +220,12 @@ export default {
|
||||
},
|
||||
removeItem() {
|
||||
this.item.index = this.index
|
||||
this.item.removeType = 'quota'
|
||||
this.$emit('onQuotaItemRemove', this.item)
|
||||
},
|
||||
editFilter() {
|
||||
this.item.index = this.index
|
||||
this.item.filterType = 'quota'
|
||||
this.$emit('editItemFilter', this.item)
|
||||
}
|
||||
}
|
||||
|
@ -94,10 +94,10 @@
|
||||
<el-option v-for="option in fontSize" :key="option.value" :label="option.name" :value="option.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.table_title_height')" class="form-item">
|
||||
<el-form-item :label="$t('chart.table_title_height')" class="form-item form-item-slider">
|
||||
<el-slider v-model="sizeForm.tableTitleHeight" :min="36" :max="100" show-input :show-input-controls="false" input-size="mini" @change="changeBarSizeCase" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('chart.table_item_height')" class="form-item">
|
||||
<el-form-item :label="$t('chart.table_item_height')" class="form-item form-item-slider">
|
||||
<el-slider v-model="sizeForm.tableItemHeight" :min="36" :max="100" show-input :show-input-controls="false" input-size="mini" @change="changeBarSizeCase" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
@ -1,33 +1,55 @@
|
||||
<template>
|
||||
<div ref="tableContainer" :style="bg_class" style="padding: 8px;width: 100%;height: 100%;overflow: hidden;">
|
||||
<p v-show="title_show" ref="title" :style="title_class">{{ chart.title }}</p>
|
||||
<ux-grid
|
||||
ref="plxTable"
|
||||
size="mini"
|
||||
style="width: 100%;"
|
||||
:height="height"
|
||||
:checkbox-config="{highlight: true}"
|
||||
:width-resize="true"
|
||||
:header-row-style="table_header_class"
|
||||
:row-style="getRowStyle"
|
||||
class="table-class"
|
||||
:class="chart.id"
|
||||
:show-summary="showSummary"
|
||||
:summary-method="summaryMethod"
|
||||
>
|
||||
<ux-table-column
|
||||
v-for="field in fields"
|
||||
:key="field.dataeaseName"
|
||||
:field="field.dataeaseName"
|
||||
:resizable="true"
|
||||
sortable
|
||||
:title="field.name"
|
||||
<el-row style="height: 100%;">
|
||||
<p v-show="title_show" ref="title" :style="title_class">{{ chart.title }}</p>
|
||||
<ux-grid
|
||||
ref="plxTable"
|
||||
size="mini"
|
||||
style="width: 100%;"
|
||||
:height="height"
|
||||
:checkbox-config="{highlight: true}"
|
||||
:width-resize="true"
|
||||
:header-row-style="table_header_class"
|
||||
:row-style="getRowStyle"
|
||||
class="table-class"
|
||||
:class="chart.id"
|
||||
:show-summary="showSummary"
|
||||
:summary-method="summaryMethod"
|
||||
>
|
||||
<!-- <template slot="header">-->
|
||||
<!-- <span>{{ field.name }}</span>-->
|
||||
<!-- </template>-->
|
||||
</ux-table-column>
|
||||
</ux-grid>
|
||||
<ux-table-column
|
||||
v-for="field in fields"
|
||||
:key="Math.random()"
|
||||
:field="field.dataeaseName"
|
||||
:resizable="true"
|
||||
sortable
|
||||
:title="field.name"
|
||||
>
|
||||
<!-- <template slot="header">-->
|
||||
<!-- <span>{{ field.name }}</span>-->
|
||||
<!-- </template>-->
|
||||
</ux-table-column>
|
||||
</ux-grid>
|
||||
|
||||
<el-row v-show="chart.type === 'table-info'" class="table-page">
|
||||
<span class="total-style">
|
||||
{{ $t('chart.total') }}
|
||||
<span>{{ chart.data.tableRow.length }}</span>
|
||||
{{ $t('chart.items') }}
|
||||
</span>
|
||||
<el-pagination
|
||||
small
|
||||
:current-page="currentPage.page"
|
||||
:page-sizes="[10,20,50,100]"
|
||||
:page-size="currentPage.pageSize"
|
||||
:pager-count="5"
|
||||
layout="sizes, prev, pager, next"
|
||||
:total="currentPage.show"
|
||||
class="page-style"
|
||||
@current-change="pageClick"
|
||||
@size-change="pageChange"
|
||||
/>
|
||||
</el-row>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -91,7 +113,12 @@ export default {
|
||||
height: '36px'
|
||||
},
|
||||
title_show: true,
|
||||
borderRadius: '0px'
|
||||
borderRadius: '0px',
|
||||
currentPage: {
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
show: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -137,9 +164,17 @@ export default {
|
||||
if (this.chart.data) {
|
||||
this.fields = JSON.parse(JSON.stringify(this.chart.data.fields))
|
||||
datas = JSON.parse(JSON.stringify(this.chart.data.tableRow))
|
||||
if (this.chart.type === 'table-info') {
|
||||
// 计算分页
|
||||
this.currentPage.show = datas.length
|
||||
const pageStart = (this.currentPage.page - 1) * this.currentPage.pageSize
|
||||
const pageEnd = pageStart + this.currentPage.pageSize
|
||||
datas = datas.slice(pageStart, pageEnd)
|
||||
}
|
||||
} else {
|
||||
this.fields = []
|
||||
datas = []
|
||||
this.resetPage()
|
||||
}
|
||||
this.$refs.plxTable.reloadData(datas)
|
||||
this.$nextTick(() => {
|
||||
@ -152,11 +187,19 @@ export default {
|
||||
calcHeightRightNow() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.tableContainer) {
|
||||
let pageHeight = 0
|
||||
if (this.chart.type === 'table-info') {
|
||||
pageHeight = 36
|
||||
}
|
||||
const currentHeight = this.$refs.tableContainer.offsetHeight
|
||||
const tableMaxHeight = currentHeight - this.$refs.title.offsetHeight - 16
|
||||
const tableMaxHeight = currentHeight - this.$refs.title.offsetHeight - 16 - pageHeight
|
||||
let tableHeight
|
||||
if (this.chart.data) {
|
||||
tableHeight = (this.chart.data.tableRow.length + 2) * 36
|
||||
if (this.chart.type === 'table-info') {
|
||||
tableHeight = (this.currentPage.pageSize + 2) * 36 - pageHeight
|
||||
} else {
|
||||
tableHeight = (this.chart.data.tableRow.length + 2) * 36 - pageHeight
|
||||
}
|
||||
} else {
|
||||
tableHeight = 0
|
||||
}
|
||||
@ -279,6 +322,24 @@ export default {
|
||||
|
||||
resetHeight() {
|
||||
this.height = 100
|
||||
},
|
||||
|
||||
pageChange(val) {
|
||||
this.currentPage.pageSize = val
|
||||
this.init()
|
||||
},
|
||||
|
||||
pageClick(val) {
|
||||
this.currentPage.page = val
|
||||
this.init()
|
||||
},
|
||||
|
||||
resetPage() {
|
||||
this.currentPage = {
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
show: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -292,4 +353,25 @@ export default {
|
||||
max-height: none!important;
|
||||
line-height: normal!important;
|
||||
}
|
||||
.table-page{
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.page-style{
|
||||
margin-right: auto;
|
||||
}
|
||||
.total-style{
|
||||
flex: 1;
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
white-space:nowrap;
|
||||
}
|
||||
.page-style >>> .el-input__inner{
|
||||
height: 24px;
|
||||
}
|
||||
</style>
|
||||
|
@ -327,6 +327,7 @@ import {
|
||||
DEFAULT_TOOLTIP,
|
||||
DEFAULT_XAXIS_STYLE,
|
||||
DEFAULT_YAXIS_STYLE,
|
||||
DEFAULT_YAXIS_EXT_STYLE,
|
||||
DEFAULT_BACKGROUND_COLOR,
|
||||
DEFAULT_SPLIT
|
||||
} from '../chart/chart'
|
||||
@ -739,11 +740,13 @@ export default {
|
||||
legend: DEFAULT_LEGEND_STYLE,
|
||||
xAxis: DEFAULT_XAXIS_STYLE,
|
||||
yAxis: DEFAULT_YAXIS_STYLE,
|
||||
yAxisExt: DEFAULT_YAXIS_EXT_STYLE,
|
||||
background: DEFAULT_BACKGROUND_COLOR,
|
||||
split: DEFAULT_SPLIT
|
||||
})
|
||||
view.xaxis = JSON.stringify([])
|
||||
view.yaxis = JSON.stringify([])
|
||||
view.yaxisExt = JSON.stringify([])
|
||||
view.extStack = JSON.stringify([])
|
||||
view.customFilter = JSON.stringify([])
|
||||
view.drillFields = JSON.stringify([])
|
||||
|
@ -77,7 +77,7 @@
|
||||
@add="moveToQuota"
|
||||
>
|
||||
<transition-group>
|
||||
<span v-for="item in quotaData" :key="item.id" class="item-quota" :title="item.name">
|
||||
<span v-for="item in quotaData" v-show="chart.type && (chart.type !== 'table-info' || (chart.type === 'table-info' && item.id !=='count'))" :key="item.id" class="item-quota" :title="item.name">
|
||||
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
|
||||
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
|
||||
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
|
||||
@ -117,7 +117,7 @@
|
||||
v-model="view.type"
|
||||
style="width: 100%"
|
||||
:disabled="!hasDataPermission('manage',param.privileges)"
|
||||
@change="save(true,'chart',true)"
|
||||
@change="save(true,'chart',true,true)"
|
||||
>
|
||||
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
|
||||
<el-radio value="table-normal" label="table-normal">
|
||||
@ -125,6 +125,11 @@
|
||||
<svg-icon icon-class="table-normal" class="chart-icon" />
|
||||
</span>
|
||||
</el-radio>
|
||||
<el-radio value="table-info" label="table-info">
|
||||
<span :title="$t('chart.chart_table_info')">
|
||||
<svg-icon icon-class="table-info" class="chart-icon" />
|
||||
</span>
|
||||
</el-radio>
|
||||
<el-radio value="text" label="text">
|
||||
<span :title="$t('chart.chart_card')">
|
||||
<svg-icon icon-class="text" class="chart-icon" />
|
||||
@ -140,13 +145,13 @@
|
||||
<svg-icon icon-class="bar-stack" class="chart-icon" />
|
||||
</span>
|
||||
</el-radio>
|
||||
</div>
|
||||
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
|
||||
<el-radio value="bar-horizontal" label="bar-horizontal">
|
||||
<span :title="$t('chart.chart_bar_horizontal')">
|
||||
<svg-icon icon-class="bar-horizontal" class="chart-icon" />
|
||||
</span>
|
||||
</el-radio>
|
||||
</div>
|
||||
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
|
||||
<el-radio value="bar-stack-horizontal" label="bar-stack-horizontal">
|
||||
<span :title="$t('chart.chart_bar_stack_horizontal')">
|
||||
<svg-icon icon-class="bar-stack-horizontal" class="chart-icon" />
|
||||
@ -167,13 +172,13 @@
|
||||
<svg-icon icon-class="scatter" class="chart-icon" />
|
||||
</span>
|
||||
</el-radio>
|
||||
</div>
|
||||
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
|
||||
<el-radio value="chart-mix" label="chart-mix">
|
||||
<span :title="$t('chart.chart_mix')">
|
||||
<svg-icon icon-class="chart-mix" class="chart-icon" />
|
||||
</span>
|
||||
</el-radio>
|
||||
</div>
|
||||
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
|
||||
<el-radio value="map" label="map">
|
||||
<span :title="$t('chart.chart_map')">
|
||||
<svg-icon icon-class="map" class="chart-icon" />
|
||||
@ -194,13 +199,13 @@
|
||||
<svg-icon icon-class="pie" class="chart-icon" />
|
||||
</span>
|
||||
</el-radio>
|
||||
</div>
|
||||
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
|
||||
<el-radio value="pie-rose" label="pie-rose">
|
||||
<span :title="$t('chart.chart_pie_rose')">
|
||||
<svg-icon icon-class="pie-rose" class="chart-icon" />
|
||||
</span>
|
||||
</el-radio>
|
||||
</div>
|
||||
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
|
||||
<el-radio value="funnel" label="funnel">
|
||||
<span :title="$t('chart.chart_funnel')">
|
||||
<svg-icon icon-class="funnel" class="chart-icon" />
|
||||
@ -213,7 +218,6 @@
|
||||
</el-radio>
|
||||
<el-radio value="" label="" disabled class="disabled-none-cursor"><svg-icon icon-class="" class="chart-icon" /></el-radio>
|
||||
<el-radio value="" label="" disabled class="disabled-none-cursor"><svg-icon icon-class="" class="chart-icon" /></el-radio>
|
||||
<el-radio value="" label="" disabled class="disabled-none-cursor"><svg-icon icon-class="" class="chart-icon" /></el-radio>
|
||||
</div>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
@ -280,10 +284,10 @@
|
||||
<span class="drag-placeholder-style-span">{{ $t('chart.placeholder_field') }}</span>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-row class="padding-lr" style="margin-top: 6px;">
|
||||
<el-row v-if="view.type !=='table-info'" class="padding-lr" style="margin-top: 6px;">
|
||||
<span style="width: 80px;text-align: right;">
|
||||
<span v-if="view.type && view.type.includes('table')">{{ $t('chart.drag_block_table_data_column') }}</span>
|
||||
<span v-else-if="view.type && (view.type.includes('bar') || view.type.includes('line') || view.type.includes('scatter') || view.type === 'chart-mix')">{{ $t('chart.drag_block_value_axis') }}</span>
|
||||
<span v-else-if="view.type && (view.type.includes('bar') || view.type.includes('line') || view.type.includes('scatter'))">{{ $t('chart.drag_block_value_axis') }}</span>
|
||||
<span v-else-if="view.type && view.type.includes('pie')">{{ $t('chart.drag_block_pie_angel') }}</span>
|
||||
<span v-else-if="view.type && view.type.includes('funnel')">{{ $t('chart.drag_block_funnel_width') }}</span>
|
||||
<span v-else-if="view.type && view.type.includes('radar')">{{ $t('chart.drag_block_radar_length') }}</span>
|
||||
@ -291,6 +295,7 @@
|
||||
<span v-else-if="view.type && view.type.includes('text')">{{ $t('chart.drag_block_label_value') }}</span>
|
||||
<span v-else-if="view.type && view.type === 'map'">{{ $t('chart.chart_data') }}</span>
|
||||
<span v-else-if="view.type && view.type.includes('tree')">{{ $t('chart.drag_block_treemap_size') }}</span>
|
||||
<span v-else-if="view.type && view.type === 'chart-mix'">{{ $t('chart.drag_block_value_axis_main') }}</span>
|
||||
/
|
||||
<span>{{ $t('chart.quota') }}</span>
|
||||
</span>
|
||||
@ -312,6 +317,30 @@
|
||||
<span class="drag-placeholder-style-span">{{ $t('chart.placeholder_field') }}</span>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-row v-if="view.type && view.type === 'chart-mix'" class="padding-lr" style="margin-top: 6px;">
|
||||
<span style="width: 80px;text-align: right;">
|
||||
<span>{{ $t('chart.drag_block_value_axis_ext') }}</span>
|
||||
/
|
||||
<span>{{ $t('chart.quota') }}</span>
|
||||
</span>
|
||||
<draggable
|
||||
v-model="view.yaxisExt"
|
||||
:disabled="!hasDataPermission('manage',param.privileges)"
|
||||
group="drag"
|
||||
animation="300"
|
||||
:move="onMove"
|
||||
class="drag-block-style"
|
||||
@add="addYaxisExt"
|
||||
@update="save(true)"
|
||||
>
|
||||
<transition-group class="draggable-group">
|
||||
<quota-ext-item v-for="(item,index) in view.yaxisExt" :key="item.id" :param="param" :index="index" :item="item" :chart="chart" @onQuotaItemChange="quotaItemChange" @onQuotaItemRemove="quotaItemRemove" @editItemFilter="showQuotaEditFilter" @onNameEdit="showRename" />
|
||||
</transition-group>
|
||||
</draggable>
|
||||
<div v-if="!view.yaxisExt || view.yaxisExt.length === 0" class="drag-placeholder-style">
|
||||
<span class="drag-placeholder-style-span">{{ $t('chart.placeholder_field') }}</span>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-row v-if="view.type && view.type.includes('stack')" class="padding-lr" style="margin-top: 6px;">
|
||||
<span style="width: 80px;text-align: right;">
|
||||
<span>{{ $t('chart.stack_item') }}</span>
|
||||
@ -446,12 +475,6 @@
|
||||
<tooltip-selector :param="param" class="attr-selector" :chart="chart" @onTooltipChange="onTooltipChange" />
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
<!-- <el-row>-->
|
||||
<!-- <color-selector :param="param" class="attr-selector" :chart="chart" @onColorChange="onColorChange" />-->
|
||||
<!-- <size-selector v-show="chart.type !== 'map'" :param="param" class="attr-selector" :chart="chart" @onSizeChange="onSizeChange" />-->
|
||||
<!-- <label-selector v-show="!view.type.includes('table') && !view.type.includes('text')" :param="param" class="attr-selector" :chart="chart" @onLabelChange="onLabelChange" />-->
|
||||
<!-- <tooltip-selector v-show="!view.type.includes('table') && !view.type.includes('text')" :param="param" class="attr-selector" :chart="chart" @onTooltipChange="onTooltipChange" />-->
|
||||
<!-- </el-row>-->
|
||||
</el-row>
|
||||
<el-row>
|
||||
<span class="padding-lr">{{ $t('chart.module_style') }}</span>
|
||||
@ -459,9 +482,12 @@
|
||||
<el-collapse-item v-show="view.type && (view.type.includes('bar') || view.type.includes('line') || view.type.includes('scatter') || view.type === 'chart-mix')" name="xAxis" :title="$t('chart.xAxis')">
|
||||
<x-axis-selector :param="param" class="attr-selector" :chart="chart" @onChangeXAxisForm="onChangeXAxisForm" />
|
||||
</el-collapse-item>
|
||||
<el-collapse-item v-show="view.type && (view.type.includes('bar') || view.type.includes('line') || view.type.includes('scatter') || view.type === 'chart-mix')" name="yAxis" :title="$t('chart.yAxis')">
|
||||
<el-collapse-item v-show="view.type && (view.type.includes('bar') || view.type.includes('line') || view.type.includes('scatter') || view.type === 'chart-mix')" name="yAxis" :title="view.type === 'chart-mix' ? $t('chart.yAxis_main') : $t('chart.yAxis')">
|
||||
<y-axis-selector :param="param" class="attr-selector" :chart="chart" @onChangeYAxisForm="onChangeYAxisForm" />
|
||||
</el-collapse-item>
|
||||
<el-collapse-item v-show="view.type && view.type === 'chart-mix'" name="yAxisExt" :title="$t('chart.yAxis_ext')">
|
||||
<y-axis-ext-selector :param="param" class="attr-selector" :chart="chart" @onChangeYAxisForm="onChangeYAxisExtForm" />
|
||||
</el-collapse-item>
|
||||
<el-collapse-item v-show="view.type && view.type.includes('radar')" name="split" :title="$t('chart.split')">
|
||||
<split-selector :param="param" class="attr-selector" :chart="chart" @onChangeSplitForm="onChangeSplitForm" />
|
||||
</el-collapse-item>
|
||||
@ -475,14 +501,6 @@
|
||||
<background-color-selector :param="param" class="attr-selector" :chart="chart" @onChangeBackgroundForm="onChangeBackgroundForm" />
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
<!-- <el-row>-->
|
||||
<!-- <x-axis-selector v-show="view.type && (view.type.includes('bar') || view.type.includes('line'))" :param="param" class="attr-selector" :chart="chart" @onChangeXAxisForm="onChangeXAxisForm" />-->
|
||||
<!-- <y-axis-selector v-show="view.type && (view.type.includes('bar') || view.type.includes('line'))" :param="param" class="attr-selector" :chart="chart" @onChangeYAxisForm="onChangeYAxisForm" />-->
|
||||
<!-- <split-selector v-show="view.type && view.type.includes('radar')" :param="param" class="attr-selector" :chart="chart" @onChangeSplitForm="onChangeSplitForm" />-->
|
||||
<!-- <title-selector :param="param" class="attr-selector" :chart="chart" @onTextChange="onTextChange" />-->
|
||||
<!-- <legend-selector v-show="view.type && !view.type.includes('map') && !view.type.includes('table') && !view.type.includes('text')" :param="param" class="attr-selector" :chart="chart" @onLegendChange="onLegendChange" />-->
|
||||
<!-- <background-color-selector :param="param" class="attr-selector" :chart="chart" @onChangeBackgroundForm="onChangeBackgroundForm" />-->
|
||||
<!-- </el-row>-->
|
||||
</el-row>
|
||||
</div>
|
||||
</el-row>
|
||||
@ -493,7 +511,7 @@
|
||||
<el-row style="width: 100%;height: 100%;" class="padding-lr">
|
||||
<div ref="imageWrapper" style="height: 100%">
|
||||
<chart-component v-if="httpRequest.status && chart.type && !chart.type.includes('table') && !chart.type.includes('text')" ref="dynamicChart" :chart-id="chart.id" :chart="chart" class="chart-class" @onChartClick="chartClick" />
|
||||
<table-normal v-if="httpRequest.status && chart.type && chart.type.includes('table')" :chart="chart" class="table-class" />
|
||||
<table-normal v-if="httpRequest.status && chart.type && chart.type.includes('table')" :show-summary="chart.type === 'table-normal'" :chart="chart" class="table-class" />
|
||||
<label-normal v-if="httpRequest.status && chart.type && chart.type.includes('text')" :chart="chart" class="table-class" />
|
||||
<div v-if="!httpRequest.status" class="chart-error-class">
|
||||
<div style="font-size: 12px; color: #9ea6b2;height: 100%;display: flex;align-items: center;justify-content: center;">
|
||||
@ -629,7 +647,8 @@ import {
|
||||
DEFAULT_TOOLTIP,
|
||||
DEFAULT_XAXIS_STYLE,
|
||||
DEFAULT_YAXIS_STYLE,
|
||||
DEFAULT_SPLIT
|
||||
DEFAULT_SPLIT,
|
||||
DEFAULT_YAXIS_EXT_STYLE
|
||||
} from '../chart/chart'
|
||||
import ColorSelector from '../components/shape-attr/ColorSelector'
|
||||
import SizeSelector from '../components/shape-attr/SizeSelector'
|
||||
@ -649,9 +668,13 @@ import LabelNormal from '../components/normal/LabelNormal'
|
||||
import TableSelector from './TableSelector'
|
||||
import FieldEdit from '../../dataset/data/FieldEdit'
|
||||
import { areaMapping } from '@/api/map/map'
|
||||
import QuotaExtItem from '@/views/chart/components/drag-item/QuotaExtItem'
|
||||
import YAxisExtSelector from '@/views/chart/components/component-style/YAxisExtSelector'
|
||||
export default {
|
||||
name: 'ChartEdit',
|
||||
components: {
|
||||
YAxisExtSelector,
|
||||
QuotaExtItem,
|
||||
FilterItem,
|
||||
FieldEdit,
|
||||
SplitSelector,
|
||||
@ -696,6 +719,7 @@ export default {
|
||||
view: {
|
||||
xaxis: [],
|
||||
yaxis: [],
|
||||
yaxisExt: [],
|
||||
extStack: [],
|
||||
drillFields: [],
|
||||
extBubble: [],
|
||||
@ -713,6 +737,7 @@ export default {
|
||||
legend: DEFAULT_LEGEND_STYLE,
|
||||
xAxis: DEFAULT_XAXIS_STYLE,
|
||||
yAxis: DEFAULT_YAXIS_STYLE,
|
||||
yAxisExt: DEFAULT_YAXIS_EXT_STYLE,
|
||||
background: DEFAULT_BACKGROUND_COLOR,
|
||||
split: DEFAULT_SPLIT
|
||||
},
|
||||
@ -829,7 +854,15 @@ export default {
|
||||
this.resetDatasetField()
|
||||
}
|
||||
},
|
||||
save(getData, trigger, needRefreshGroup = false) {
|
||||
save(getData, trigger, needRefreshGroup = false, switchType = false) {
|
||||
if (switchType && (this.view.type === 'table-info' || this.chart.type === 'table-info') && this.view.xaxis.length > 0) {
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: this.$t('chart.table_info_switch'),
|
||||
type: 'warning'
|
||||
})
|
||||
this.view.xaxis = []
|
||||
}
|
||||
const view = JSON.parse(JSON.stringify(this.view))
|
||||
view.id = this.view.id
|
||||
view.sceneId = this.view.sceneId
|
||||
@ -880,6 +913,26 @@ export default {
|
||||
ele.filter = []
|
||||
}
|
||||
})
|
||||
if (view.type === 'chart-mix') {
|
||||
view.yaxisExt.forEach(function(ele) {
|
||||
if (!ele.chartType) {
|
||||
ele.chartType = 'bar'
|
||||
}
|
||||
if (!ele.summary || ele.summary === '') {
|
||||
if (ele.id === 'count' || ele.deType === 0 || ele.deType === 1) {
|
||||
ele.summary = 'count'
|
||||
} else {
|
||||
ele.summary = 'sum'
|
||||
}
|
||||
}
|
||||
if (!ele.sort || ele.sort === '') {
|
||||
ele.sort = 'none'
|
||||
}
|
||||
if (!ele.filter) {
|
||||
ele.filter = []
|
||||
}
|
||||
})
|
||||
}
|
||||
view.extStack.forEach(function(ele) {
|
||||
if (!ele.sort || ele.sort === '') {
|
||||
ele.sort = 'none'
|
||||
@ -926,6 +979,7 @@ export default {
|
||||
})
|
||||
view.xaxis = JSON.stringify(view.xaxis)
|
||||
view.yaxis = JSON.stringify(view.yaxis)
|
||||
view.yaxisExt = JSON.stringify(view.yaxisExt)
|
||||
view.customAttr = JSON.stringify(view.customAttr)
|
||||
view.customStyle = JSON.stringify(view.customStyle)
|
||||
view.customFilter = JSON.stringify(view.customFilter)
|
||||
@ -972,6 +1026,7 @@ export default {
|
||||
this.view = JSON.parse(JSON.stringify(response.data))
|
||||
this.view.xaxis = this.view.xaxis ? JSON.parse(this.view.xaxis) : []
|
||||
this.view.yaxis = this.view.yaxis ? JSON.parse(this.view.yaxis) : []
|
||||
this.view.yaxisExt = this.view.yaxisExt ? JSON.parse(this.view.yaxisExt) : []
|
||||
this.view.extStack = this.view.extStack ? JSON.parse(this.view.extStack) : []
|
||||
this.view.drillFields = this.view.drillFields ? JSON.parse(this.view.drillFields) : []
|
||||
this.view.extBubble = this.view.extBubble ? JSON.parse(this.view.extBubble) : []
|
||||
@ -1011,6 +1066,7 @@ export default {
|
||||
this.view = JSON.parse(JSON.stringify(response.data))
|
||||
this.view.xaxis = this.view.xaxis ? JSON.parse(this.view.xaxis) : []
|
||||
this.view.yaxis = this.view.yaxis ? JSON.parse(this.view.yaxis) : []
|
||||
this.view.yaxisExt = this.view.yaxisExt ? JSON.parse(this.view.yaxisExt) : []
|
||||
this.view.extStack = this.view.extStack ? JSON.parse(this.view.extStack) : []
|
||||
this.view.drillFields = this.view.drillFields ? JSON.parse(this.view.drillFields) : []
|
||||
this.view.extBubble = this.view.extBubble ? JSON.parse(this.view.extBubble) : []
|
||||
@ -1060,7 +1116,11 @@ export default {
|
||||
},
|
||||
|
||||
quotaItemRemove(item) {
|
||||
this.view.yaxis.splice(item.index, 1)
|
||||
if (item.removeType === 'quota') {
|
||||
this.view.yaxis.splice(item.index, 1)
|
||||
} else if (item.removeType === 'quotaExt') {
|
||||
this.view.yaxisExt.splice(item.index, 1)
|
||||
}
|
||||
this.save(true)
|
||||
},
|
||||
|
||||
@ -1105,6 +1165,11 @@ export default {
|
||||
this.save()
|
||||
},
|
||||
|
||||
onChangeYAxisExtForm(val) {
|
||||
this.view.customStyle.yAxisExt = val
|
||||
this.save()
|
||||
},
|
||||
|
||||
onChangeBackgroundForm(val) {
|
||||
this.view.customStyle.background = val
|
||||
this.save()
|
||||
@ -1158,7 +1223,11 @@ export default {
|
||||
return
|
||||
}
|
||||
}
|
||||
this.view.yaxis[this.quotaItem.index].filter = this.quotaItem.filter
|
||||
if (this.quotaItem.filterType === 'quota') {
|
||||
this.view.yaxis[this.quotaItem.index].filter = this.quotaItem.filter
|
||||
} else if (this.quotaItem.filterType === 'quotaExt') {
|
||||
this.view.yaxisExt[this.quotaItem.index].filter = this.quotaItem.filter
|
||||
}
|
||||
this.save(true)
|
||||
this.closeQuotaFilter()
|
||||
},
|
||||
@ -1203,6 +1272,8 @@ export default {
|
||||
this.view.yaxis[this.itemForm.index].name = this.itemForm.name
|
||||
} else if (this.itemForm.renameType === 'dimension') {
|
||||
this.view.xaxis[this.itemForm.index].name = this.itemForm.name
|
||||
} else if (this.itemForm.renameType === 'quotaExt') {
|
||||
this.view.yaxisExt[this.itemForm.index].name = this.itemForm.name
|
||||
}
|
||||
this.save(true)
|
||||
this.closeRename()
|
||||
@ -1313,7 +1384,9 @@ export default {
|
||||
if (this.view.type === 'map' && this.view.xaxis.length > 1) {
|
||||
this.view.xaxis = [this.view.xaxis[0]]
|
||||
}
|
||||
this.dragCheckType(this.view.xaxis, 'd')
|
||||
if (this.view.type !== 'table-info') {
|
||||
this.dragCheckType(this.view.xaxis, 'd')
|
||||
}
|
||||
this.dragMoveDuplicate(this.view.xaxis, e)
|
||||
this.save(true)
|
||||
},
|
||||
@ -1325,6 +1398,14 @@ export default {
|
||||
this.dragMoveDuplicate(this.view.yaxis, e)
|
||||
this.save(true)
|
||||
},
|
||||
addYaxisExt(e) {
|
||||
if (this.view.type === 'map' && this.view.yaxisExt.length > 1) {
|
||||
this.view.yaxisExt = [this.view.yaxisExt[0]]
|
||||
}
|
||||
this.dragCheckType(this.view.yaxisExt, 'q')
|
||||
this.dragMoveDuplicate(this.view.yaxisExt, e)
|
||||
this.save(true)
|
||||
},
|
||||
moveToDimension(e) {
|
||||
this.dragCheckType(this.dimensionData, 'd')
|
||||
this.dragMoveDuplicate(this.dimensionData, e)
|
||||
@ -1697,7 +1778,6 @@ export default {
|
||||
}
|
||||
.table-class{
|
||||
height: calc(100% - 20px);
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.dialog-css>>>.el-dialog__title {
|
||||
|
@ -15,6 +15,13 @@
|
||||
{{ $t('login.welcome') + (uiInfo && uiInfo['ui.title'] && uiInfo['ui.title'].paramValue || ' DataEase') }}
|
||||
</div>
|
||||
<div class="login-form">
|
||||
<el-form-item>
|
||||
<el-radio-group v-model="loginForm.loginType">
|
||||
<el-radio v-if="openLdap" :label="0" size="mini">普通登录</el-radio>
|
||||
<el-radio v-if="openLdap" :label="1" size="mini">LDAP</el-radio>
|
||||
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item prop="username">
|
||||
<el-input v-model="loginForm.username" placeholder="ID" autofocus />
|
||||
</el-form-item>
|
||||
@ -55,7 +62,7 @@
|
||||
<script>
|
||||
|
||||
import { encrypt } from '@/utils/rsaEncrypt'
|
||||
// import { validateUserName } from '@/api/user'
|
||||
import { ldapStatus } from '@/api/user'
|
||||
import { getSysUI } from '@/utils/auth'
|
||||
export default {
|
||||
name: 'Login',
|
||||
@ -86,6 +93,7 @@ export default {
|
||||
// }
|
||||
return {
|
||||
loginForm: {
|
||||
loginType: 0,
|
||||
username: '',
|
||||
password: ''
|
||||
},
|
||||
@ -99,7 +107,8 @@ export default {
|
||||
uiInfo: null,
|
||||
loginImageUrl: null,
|
||||
loginLogoUrl: null,
|
||||
axiosFinished: false
|
||||
axiosFinished: false,
|
||||
openLdap: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -115,6 +124,11 @@ export default {
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
ldapStatus().then(res => {
|
||||
this.openLdap = res.success && res.data
|
||||
})
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('user/getUI').then(() => {
|
||||
// const uiLists = this.$store.state.user.uiInfo
|
||||
@ -141,7 +155,8 @@ export default {
|
||||
this.loading = true
|
||||
const user = {
|
||||
username: this.loginForm.username,
|
||||
password: this.loginForm.password
|
||||
password: this.loginForm.password,
|
||||
loginType: this.loginForm.loginType
|
||||
}
|
||||
user.password = encrypt(user.password)
|
||||
this.$store.dispatch('user/login', user).then(() => {
|
||||
|
@ -42,7 +42,8 @@ export default {
|
||||
varsInfo: {
|
||||
panelName: this.panelName,
|
||||
snapshot: this.snapshot,
|
||||
userName: this.$store.state.user.user.name
|
||||
userName: this.$store.state.user.user.userName,
|
||||
nickName: this.$store.state.user.user.nickName
|
||||
},
|
||||
timeInfo: [
|
||||
'yyyy-MM-dd',
|
||||
@ -85,7 +86,7 @@ export default {
|
||||
const contentWidth = canvas.width
|
||||
const contentHeight = canvas.height
|
||||
const pageData = canvas.toDataURL('image/jpeg', 1.0)
|
||||
const PDF = new JsPDF('p', 'pt', [contentWidth, contentHeight])
|
||||
const PDF = new JsPDF('l', 'px', [contentWidth, contentHeight])
|
||||
PDF.addImage(pageData, 'JPEG', 0, 0, contentWidth, contentHeight)
|
||||
PDF.save(_this.panelName + '.pdf')
|
||||
}
|
||||
@ -103,7 +104,7 @@ export default {
|
||||
}
|
||||
.export_body_class{
|
||||
border: 1px solid #dcdfe6 ;
|
||||
height: 500px;
|
||||
height: 65vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,8 @@
|
||||
v-if="pdfExportShow"
|
||||
:title="'['+panelInfo.name+']'+'PDF导出'"
|
||||
:visible.sync="pdfExportShow"
|
||||
width="70%"
|
||||
width="80%"
|
||||
:top="'8vh'"
|
||||
:destroy-on-close="true"
|
||||
class="dialog-css2"
|
||||
>
|
||||
|
@ -27,6 +27,9 @@
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.host')" prop="configuration.host">
|
||||
<el-input v-model="form.configuration.host" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='es'" :label="$t('datasource.url')" prop="configuration.url">
|
||||
<el-input v-model="form.configuration.url" placeholder="请输入 Elasticsearch 地址,如: http://es_host:es_port" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.data_base')" prop="configuration.dataBase">
|
||||
<el-input v-model="form.configuration.dataBase" autocomplete="off" />
|
||||
</el-form-item>
|
||||
@ -36,10 +39,10 @@
|
||||
<el-radio v-model="form.configuration.connectionType" label="serviceName">{{ $t('datasource.oracle_service_name') }}</el-radio>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.user_name')" prop="configuration.username">
|
||||
<el-form-item :label="$t('datasource.user_name')" prop="configuration.username">
|
||||
<el-input v-model="form.configuration.username" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.password')" prop="configuration.password">
|
||||
<el-form-item :label="$t('datasource.password')" prop="configuration.password">
|
||||
<el-input v-model="form.configuration.password" autocomplete="off" show-password />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.port')" prop="configuration.port">
|
||||
@ -61,25 +64,25 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-collapse>
|
||||
<el-collapse v-if="form.configuration.dataSourceType=='jdbc'">
|
||||
<el-collapse-item :title="$t('datasource.priority')" name="1">
|
||||
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.initial_pool_size')" prop="configuration.initialPoolSize">
|
||||
<el-form-item :label="$t('datasource.initial_pool_size')" prop="configuration.initialPoolSize">
|
||||
<el-input v-model="form.configuration.initialPoolSize" autocomplete="off" type="number" min="0" size="small" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.min_pool_size')" prop="configuration.minPoolSize">
|
||||
<el-form-item :label="$t('datasource.min_pool_size')" prop="configuration.minPoolSize">
|
||||
<el-input v-model="form.configuration.minPoolSize" autocomplete="off" type="number" min="0" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.max_pool_size')" prop="configuration.maxPoolSize">
|
||||
<el-form-item :label="$t('datasource.max_pool_size')" prop="configuration.maxPoolSize">
|
||||
<el-input v-model="form.configuration.maxPoolSize" autocomplete="off" type="number" min="0" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.max_idle_time')" prop="configuration.maxIdleTime">
|
||||
<el-form-item :label="$t('datasource.max_idle_time')" prop="configuration.maxIdleTime">
|
||||
<el-input v-model="form.configuration.maxIdleTime" autocomplete="off" type="number" min="0" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.acquire_increment')" prop="configuration.acquireIncrement">
|
||||
<el-form-item :label="$t('datasource.acquire_increment')" prop="configuration.acquireIncrement">
|
||||
<el-input v-model="form.configuration.acquireIncrement" autocomplete="off" type="number" min="0" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.connect_timeout')" prop="configuration.connectTimeout">
|
||||
<el-form-item :label="$t('datasource.connect_timeout')" prop="configuration.connectTimeout">
|
||||
<el-input v-model="form.configuration.connectTimeout" autocomplete="off" type="number" min="0" />
|
||||
</el-form-item>
|
||||
|
||||
@ -135,6 +138,7 @@ export default {
|
||||
'configuration.username': [{ required: true, message: this.$t('datasource.please_input_user_name'), trigger: 'blur' }],
|
||||
'configuration.password': [{ required: true, message: this.$t('datasource.please_input_password'), trigger: 'change' }],
|
||||
'configuration.host': [{ required: true, message: this.$t('datasource.please_input_host'), trigger: 'change' }],
|
||||
'configuration.url': [{ required: true, message: this.$t('datasource.please_input_url'), trigger: 'change' }],
|
||||
'configuration.port': [{ required: true, message: this.$t('datasource.please_input_port'), trigger: 'change' }],
|
||||
'configuration.initialPoolSize': [{ required: true, message: this.$t('datasource.please_input_initial_pool_size'), trigger: 'change' }],
|
||||
'configuration.minPoolSize': [{ required: true, message: this.$t('datasource.please_input_min_pool_size'), trigger: 'change' }],
|
||||
@ -146,7 +150,8 @@ export default {
|
||||
allTypes: [{ name: 'mysql', label: 'MySQL', type: 'jdbc' },
|
||||
{ name: 'oracle', label: 'Oracle', type: 'jdbc' },
|
||||
{ name: 'sqlServer', label: 'SQL Server', type: 'jdbc' },
|
||||
{ name: 'pg', label: 'PostgreSQL', type: 'jdbc' }],
|
||||
{ name: 'pg', label: 'PostgreSQL', type: 'jdbc' },
|
||||
{ name: 'es', label: 'Elasticsearch', type: 'es' }],
|
||||
schemas: [],
|
||||
canEdit: false,
|
||||
originConfiguration: {}
|
||||
|
21
frontend/src/views/system/settings/index.vue
Normal file
21
frontend/src/views/system/settings/index.vue
Normal file
@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default ({
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('app/toggleSideBarHide', false)
|
||||
},
|
||||
method: {
|
||||
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
21
frontend/src/views/system/settings/sso/index.vue
Normal file
21
frontend/src/views/system/settings/sso/index.vue
Normal file
@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<h2>this is sso page</h2>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default ({
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('app/toggleSideBarHide', false)
|
||||
},
|
||||
method: {
|
||||
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
10
frontend/src/views/system/settings/theme/index.vue
Normal file
10
frontend/src/views/system/settings/theme/index.vue
Normal file
@ -0,0 +1,10 @@
|
||||
<template>
|
||||
<h2>
|
||||
this is display settings page
|
||||
</h2>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
|
||||
}
|
||||
</script>
|
267
frontend/src/views/system/user/imp-ldap.vue
Normal file
267
frontend/src/views/system/user/imp-ldap.vue
Normal file
@ -0,0 +1,267 @@
|
||||
<template>
|
||||
<layout-content :header="$t('user.import_ldap') " back-name="system-user">
|
||||
<el-form ref="importUserForm" :model="form" :rules="rule" size="small" label-width="auto" label-position="right">
|
||||
|
||||
<el-form-item :label="$t('commons.user')" prop="userIds">
|
||||
<el-select
|
||||
ref="userSelect"
|
||||
v-model="form.userIds"
|
||||
filterable
|
||||
style="width: 100%"
|
||||
multiple
|
||||
:placeholder="$t('commons.please_select')"
|
||||
@change="changeUser"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in users"
|
||||
:key="item.userName"
|
||||
:disabled="item.disabled"
|
||||
:label="item.nickName"
|
||||
:value="item.userName"
|
||||
>
|
||||
<span>{{ item.nickName + (item.disabled ? '(已存在)':'') }}</span>
|
||||
<!-- <span><el-checkbox v-model="item.checked">{{ item.nickName }}</el-checkbox></span> -->
|
||||
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('commons.organization')" prop="deptId">
|
||||
<treeselect
|
||||
ref="deptTreeSelect"
|
||||
v-model="form.deptId"
|
||||
:options="depts"
|
||||
:load-options="loadDepts"
|
||||
:auto-load-root-options="false"
|
||||
:placeholder="$t('user.choose_org')"
|
||||
@open="filterData"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.role')" prop="roleIds">
|
||||
<el-select
|
||||
ref="roleSelect"
|
||||
v-model="form.roleIds"
|
||||
filterable
|
||||
style="width: 100%"
|
||||
multiple
|
||||
:placeholder="$t('commons.please_select')"
|
||||
@remove-tag="deleteTag"
|
||||
@change="changeRole"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in roles"
|
||||
:key="item.name"
|
||||
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('commons.status')" prop="enabled">
|
||||
<el-radio-group v-model="form.enabled" style="width: 140px">
|
||||
<el-radio :label="1">{{ $t('commons.enable') }}</el-radio>
|
||||
<el-radio :label="0">{{ $t('commons.disable') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">{{ $t('commons.confirm') }}</el-button>
|
||||
<el-button @click="cancel">{{ $t('commons.cancel') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</layout-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import { getDeptTree, treeByDeptId } from '@/api/system/dept'
|
||||
import { allRoles, ldapUsers, saveLdapUser, existLdapUsers } from '@/api/system/user'
|
||||
export default {
|
||||
|
||||
components: { LayoutContent },
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
roles: [{
|
||||
id: ''
|
||||
}]
|
||||
},
|
||||
rule: {
|
||||
userIds: [{ required: true, message: this.$t('user.select_users'), trigger: 'change' }],
|
||||
roleIds: [{ required: true, message: this.$t('user.input_roles'), trigger: 'change' }],
|
||||
deptId: [],
|
||||
enable: []
|
||||
|
||||
},
|
||||
defaultForm: { deptId: null, enabled: 1, roleIds: [2] },
|
||||
depts: null,
|
||||
roles: [],
|
||||
roleDatas: [],
|
||||
userRoles: [],
|
||||
users: [],
|
||||
exitsUsers: []
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
this.initRoles()
|
||||
this.remoteMethod()
|
||||
this.getExistUsers()
|
||||
this.create()
|
||||
},
|
||||
mounted() {
|
||||
this.bindKey()
|
||||
},
|
||||
destroyed() {
|
||||
this.unBindKey()
|
||||
},
|
||||
methods: {
|
||||
entryKey(event) {
|
||||
const keyCode = event.keyCode
|
||||
if (keyCode === 13) {
|
||||
this.save()
|
||||
}
|
||||
},
|
||||
bindKey() {
|
||||
document.addEventListener('keypress', this.entryKey)
|
||||
},
|
||||
unBindKey() {
|
||||
document.removeEventListener('keypress', this.entryKey)
|
||||
},
|
||||
|
||||
create() {
|
||||
this.depts = null
|
||||
this.form = Object.assign({}, this.defaultForm)
|
||||
},
|
||||
|
||||
initRoles() {
|
||||
allRoles().then(res => {
|
||||
this.roles = res.data
|
||||
})
|
||||
},
|
||||
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === 'LOAD_ROOT_OPTIONS' && !this.form.deptId) {
|
||||
const _self = this
|
||||
treeByDeptId(0).then(res => {
|
||||
const results = res.data.map(node => {
|
||||
if (node.hasChildren && !node.children) {
|
||||
node.children = null
|
||||
}
|
||||
return node
|
||||
})
|
||||
_self.depts = results
|
||||
callback()
|
||||
})
|
||||
}
|
||||
|
||||
if (action === 'LOAD_CHILDREN_OPTIONS') {
|
||||
const _self = this
|
||||
getDeptTree(parentNode.id).then(res => {
|
||||
parentNode.children = res.data.map(function(obj) {
|
||||
return _self.normalizer(obj)
|
||||
})
|
||||
callback()
|
||||
})
|
||||
}
|
||||
},
|
||||
normalizer(node) {
|
||||
if (node.hasChildren) {
|
||||
node.children = null
|
||||
}
|
||||
return {
|
||||
id: node.deptId,
|
||||
label: node.name,
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
deleteTag(value) {
|
||||
this.userRoles.forEach(function(data, index) {
|
||||
if (data.id === value) {
|
||||
this.userRoles.splice(index, value)
|
||||
}
|
||||
}.bind(this))
|
||||
},
|
||||
changeRole(value) {
|
||||
this.userRoles = []
|
||||
value.forEach(function(data, index) {
|
||||
const role = { id: data }
|
||||
this.userRoles.push(role)
|
||||
}.bind(this))
|
||||
},
|
||||
cancel() {
|
||||
this.$refs.importUserForm.resetFields()
|
||||
},
|
||||
save() {
|
||||
this.$refs.importUserForm.validate(valid => {
|
||||
if (valid) {
|
||||
const checkedUsers = this.users.filter(user => user.checked)
|
||||
const param = {
|
||||
users: checkedUsers,
|
||||
deptId: this.form.deptId,
|
||||
roleIds: this.form.roleIds,
|
||||
enabled: this.form.enabled
|
||||
}
|
||||
const method = saveLdapUser
|
||||
method(param).then(res => {
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.backToList()
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
backToList() {
|
||||
this.$router.push({ name: 'system-user' })
|
||||
},
|
||||
filterData(instanceId) {
|
||||
this.$refs.roleSelect && this.$refs.roleSelect.blur && this.$refs.roleSelect.blur()
|
||||
if (!this.depts) {
|
||||
return
|
||||
}
|
||||
const results = this.depts.map(node => {
|
||||
if (node.hasChildren) {
|
||||
node.children = null
|
||||
}
|
||||
return node
|
||||
})
|
||||
this.depts = results
|
||||
},
|
||||
remoteMethod() {
|
||||
this.users = []
|
||||
existLdapUsers().then(resout => {
|
||||
this.exitsUsers = resout.data
|
||||
ldapUsers().then(res => {
|
||||
if (res && res.data) {
|
||||
this.users = res.data.map(item => {
|
||||
if (this.exitsUsers.some(existUser => existUser === item.userName)) {
|
||||
item.disabled = true
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
changeUser(values) {
|
||||
this.users.forEach(user => {
|
||||
user.checked = false
|
||||
if (values.includes(user.userName)) {
|
||||
user.checked = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getExistUsers() {
|
||||
/* existLdapUsers().then(res => {
|
||||
this.exitsUsers = res.data
|
||||
}) */
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
@ -12,11 +12,19 @@
|
||||
>
|
||||
<template #toolbar>
|
||||
<el-button v-permission="['user:add']" icon="el-icon-circle-plus-outline" @click="create">{{ $t('user.create') }}</el-button>
|
||||
|
||||
<!-- <el-button v-permission="['user:import']" icon="el-icon-download" @click="importLdap">{{ $t('user.import_ldap') }}</el-button> -->
|
||||
<el-button v-if="openLdap" v-permission="['user:import']" icon="el-icon-download" @click="importLdap">{{ $t('user.import_ldap') }}</el-button>
|
||||
</template>
|
||||
|
||||
<el-table-column prop="username" label="ID" />
|
||||
<el-table-column :show-overflow-tooltip="true" prop="nickName" sortable="custom" :label="$t('commons.nick_name')" />
|
||||
<el-table-column prop="gender" :label="$t('commons.gender')" width="60" />
|
||||
<!-- <el-table-column prop="gender" :label="$t('commons.gender')" width="60" /> -->
|
||||
<el-table-column prop="from" :label="$t('user.source')" width="80">
|
||||
<template slot-scope="scope">
|
||||
<div>{{ scope.row.from === 0 ? 'LOCAL' : 'LDAP' }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :show-overflow-tooltip="true" prop="email" :label="$t('commons.email')" />
|
||||
<el-table-column :show-overflow-tooltip="true" prop="dept" sortable="custom" :label="$t('commons.organization')">
|
||||
@ -166,7 +174,7 @@ import { PHONE_REGEX } from '@/utils/validate'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
|
||||
import { ldapStatus } from '@/api/user'
|
||||
import { userLists, addUser, editUser, delUser, editPassword, editStatus, allRoles } from '@/api/system/user'
|
||||
import { getDeptTree, treeByDeptId } from '@/api/system/dept'
|
||||
|
||||
@ -297,14 +305,19 @@ export default {
|
||||
editPwd: ['user:editPwd']
|
||||
},
|
||||
orderConditions: [],
|
||||
last_condition: null
|
||||
last_condition: null,
|
||||
openLdap: false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.allRoles()
|
||||
this.search()
|
||||
},
|
||||
|
||||
beforeCreate() {
|
||||
ldapStatus().then(res => {
|
||||
this.openLdap = res.success && res.data
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
sortChange({ column, prop, order }) {
|
||||
this.orderConditions = []
|
||||
@ -479,6 +492,9 @@ export default {
|
||||
},
|
||||
btnDisabled(row) {
|
||||
return row.userId === 1
|
||||
},
|
||||
importLdap() {
|
||||
this.$router.push({ name: 'system-user-import' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user