Merge branch 'dev' into pr@dev@feat_xpack定时报告自测版本
This commit is contained in:
commit
cdf75963b6
@ -8,6 +8,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@EnableCaching
|
||||
@SpringBootApplication(exclude = {
|
||||
QuartzAutoConfiguration.class,
|
||||
|
||||
@ -20,6 +20,8 @@ import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@ -44,9 +46,9 @@ public class F2CRealm extends AuthorizingRealm {
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
|
||||
Long userId = JWTUtils.tokenInfoByToken(principals.toString()).getUserId();
|
||||
SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();
|
||||
Set<String> role = authUserService.roles(userId).stream().collect(Collectors.toSet());
|
||||
Set<String> role = new HashSet<>(authUserService.roles(userId));
|
||||
simpleAuthorizationInfo.addRoles(role);
|
||||
Set<String> permission = authUserService.permissions(userId).stream().collect(Collectors.toSet());
|
||||
Set<String> permission = new HashSet<>(authUserService.permissions(userId));
|
||||
simpleAuthorizationInfo.addStringPermissions(permission);
|
||||
return simpleAuthorizationInfo;
|
||||
}
|
||||
@ -79,8 +81,8 @@ public class F2CRealm extends AuthorizingRealm {
|
||||
throw new AuthenticationException("license error");
|
||||
}
|
||||
|
||||
TokenInfo tokenInfo = null;
|
||||
String token = null;
|
||||
TokenInfo tokenInfo;
|
||||
String token;
|
||||
try {
|
||||
token = (String) auth.getCredentials();
|
||||
// 解密获得username,用于和数据库进行对比
|
||||
|
||||
@ -20,9 +20,6 @@ import org.springframework.context.annotation.DependsOn;
|
||||
@Configuration
|
||||
public class ShiroConfig {
|
||||
|
||||
|
||||
|
||||
|
||||
@Bean("securityManager")
|
||||
public DefaultWebSecurityManager getManager(F2CRealm f2cRealm) {
|
||||
DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
|
||||
|
||||
@ -3,6 +3,7 @@ package io.dataease.auth.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
|
||||
@ -13,7 +13,7 @@ public class TokenInfo implements Serializable {
|
||||
|
||||
private Long userId;
|
||||
|
||||
public String format(){
|
||||
return username + "," +userId;
|
||||
public String format() {
|
||||
return username + "," + userId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,32 +4,28 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.interfaces.Claim;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import io.dataease.auth.config.RsaProperties;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.auth.util.LinkUtil;
|
||||
import io.dataease.auth.util.RsaUtil;
|
||||
import io.dataease.base.domain.PanelLink;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.web.filter.authc.AnonymousFilter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class F2CLinkFilter extends AnonymousFilter {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(F2CLogoutFilter.class);
|
||||
|
||||
private static final String LINK_TOKEN_KEY = "LINK-PWD-TOKEN";
|
||||
|
||||
@Override
|
||||
protected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) {
|
||||
try{
|
||||
try {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
String link_token = req.getHeader(LINK_TOKEN_KEY);
|
||||
DecodedJWT jwt = JWT.decode(link_token);
|
||||
String linkToken = req.getHeader(LINK_TOKEN_KEY);
|
||||
DecodedJWT jwt = JWT.decode(linkToken);
|
||||
Claim resourceId = jwt.getClaim("resourceId");
|
||||
String id = resourceId.asString();
|
||||
PanelLink panelLink = LinkUtil.queryLink(id);
|
||||
@ -38,11 +34,11 @@ public class F2CLinkFilter extends AnonymousFilter {
|
||||
if (!panelLink.getEnablePwd()) {
|
||||
panelLink.setPwd("dataease");
|
||||
pwd = panelLink.getPwd();
|
||||
}else {
|
||||
} else {
|
||||
pwd = panelLink.getPwd();
|
||||
}
|
||||
return JWTUtils.verifyLink(link_token, id, pwd);
|
||||
}catch (Exception e) {
|
||||
return JWTUtils.verifyLink(linkToken, id, pwd);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
return false;
|
||||
@ -50,6 +46,4 @@ public class F2CLinkFilter extends AnonymousFilter {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.web.filter.authc.LogoutFilter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
@ -18,7 +19,7 @@ public class F2CLogoutFilter extends LogoutFilter {
|
||||
try {
|
||||
subject.logout();
|
||||
} catch (Exception ex) {
|
||||
logger.error("退出登录错误",ex);
|
||||
logger.error("退出登录错误", ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -27,7 +28,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
|
||||
|
||||
private Logger LOGGER = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public final static String expireMessage = "Login token is expire.";
|
||||
@ -65,10 +65,10 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
return false;
|
||||
}
|
||||
// 当没有出现登录超时 且需要刷新token 则执行刷新token
|
||||
if (JWTUtils.loginExpire(authorization)){
|
||||
if (JWTUtils.loginExpire(authorization)) {
|
||||
throw new AuthenticationException(expireMessage);
|
||||
}
|
||||
if (JWTUtils.needRefresh(authorization)){
|
||||
if (JWTUtils.needRefresh(authorization)) {
|
||||
authorization = refreshToken(request, response);
|
||||
}
|
||||
JWTToken token = new JWTToken(authorization);
|
||||
@ -79,8 +79,8 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
|
||||
@ -93,9 +93,9 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
return loginSuccess;
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
if (e instanceof AuthenticationException && StringUtils.equals(e.getMessage(), expireMessage)){
|
||||
if (e instanceof AuthenticationException && StringUtils.equals(e.getMessage(), expireMessage)) {
|
||||
responseExpire(request, response, e);
|
||||
}else {
|
||||
} else {
|
||||
tokenError(request, response, e);
|
||||
}
|
||||
}
|
||||
@ -104,16 +104,14 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private String refreshToken(ServletRequest request, ServletResponse response) throws Exception{
|
||||
private String refreshToken(ServletRequest request, ServletResponse response) throws Exception {
|
||||
// 获取AccessToken(Shiro中getAuthzHeader方法已经实现)
|
||||
String token = this.getAuthzHeader(request);
|
||||
// 获取当前Token的帐号信息
|
||||
TokenInfo tokenInfo = JWTUtils.tokenInfoByToken(token);
|
||||
AuthUserService authUserService = CommonBeanFactory.getBean(AuthUserService.class);
|
||||
SysUserEntity user = authUserService.getUserById(tokenInfo.getUserId());
|
||||
if(user == null){
|
||||
if (user == null) {
|
||||
DataEaseException.throwException(Translator.get("i18n_not_find_user"));
|
||||
}
|
||||
String password = user.getPassword();
|
||||
|
||||
@ -16,7 +16,6 @@ public class ApiKeyHandler {
|
||||
|
||||
public static final String API_SIGNATURE = "signature";
|
||||
|
||||
|
||||
public static String random = UUID.randomUUID().toString() + UUID.randomUUID().toString();
|
||||
|
||||
public static Long getUser(HttpServletRequest request) {
|
||||
|
||||
@ -43,16 +43,12 @@ public class AuthServer implements AuthApi {
|
||||
@Autowired
|
||||
private AuthUserService authUserService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Object login(@RequestBody LoginDto loginDto) throws Exception {
|
||||
String username = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, loginDto.getUsername());;
|
||||
String username = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, loginDto.getUsername());
|
||||
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, loginDto.getPassword());
|
||||
|
||||
// 增加ldap登录方式
|
||||
@ -67,15 +63,19 @@ public class AuthServer implements AuthApi {
|
||||
}
|
||||
XpackLdapUserEntity ldapUserEntity = validateResult.getData();
|
||||
SysUserEntity user = authUserService.getLdapUserByName(username);
|
||||
if(ObjectUtils.isEmpty(user) || ObjectUtils.isEmpty(user.getUserId())) {
|
||||
if (ObjectUtils.isEmpty(user) || ObjectUtils.isEmpty(user.getUserId())) {
|
||||
LdapAddRequest ldapAddRequest = new LdapAddRequest();
|
||||
ldapAddRequest.setUsers(new ArrayList<XpackLdapUserEntity>(){{add(ldapUserEntity);}});
|
||||
ldapAddRequest.setUsers(new ArrayList<XpackLdapUserEntity>() {{
|
||||
add(ldapUserEntity);
|
||||
}});
|
||||
ldapAddRequest.setEnabled(1L);
|
||||
ldapAddRequest.setRoleIds(new ArrayList<Long>(){{add(2L);}});
|
||||
ldapAddRequest.setRoleIds(new ArrayList<Long>() {{
|
||||
add(2L);
|
||||
}});
|
||||
sysUserService.validateExistUser(ldapUserEntity.getUsername(), ldapUserEntity.getNickname(), ldapUserEntity.getEmail());
|
||||
sysUserService.saveLdapUsers(ldapAddRequest);
|
||||
}
|
||||
|
||||
|
||||
username = validateResult.getData().getUsername();
|
||||
}
|
||||
// 增加ldap登录方式
|
||||
@ -131,7 +131,7 @@ public class AuthServer implements AuthApi {
|
||||
@Override
|
||||
public String logout() {
|
||||
String token = ServletUtils.getToken();
|
||||
|
||||
|
||||
if (isOpenOidc()) {
|
||||
HttpServletRequest request = ServletUtils.request();
|
||||
String idToken = request.getHeader("IdToken");
|
||||
@ -139,15 +139,15 @@ public class AuthServer implements AuthApi {
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
oidcXpackService.logout(idToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (StringUtils.isEmpty(token) || StringUtils.equals("null", token) || StringUtils.equals("undefined", token)) {
|
||||
return "success";
|
||||
}
|
||||
try{
|
||||
try {
|
||||
Long userId = JWTUtils.tokenInfoByToken(token).getUserId();
|
||||
authUserService.clearCache(userId);
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
return "fail";
|
||||
}
|
||||
@ -160,29 +160,27 @@ public class AuthServer implements AuthApi {
|
||||
String userName = nameDto.get("userName");
|
||||
if (StringUtils.isEmpty(userName)) return false;
|
||||
SysUserEntity userEntity = authUserService.getUserByName(userName);
|
||||
if (ObjectUtils.isEmpty(userEntity)) return false;
|
||||
return true;
|
||||
return !ObjectUtils.isEmpty(userEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenLdap() {
|
||||
Boolean licValid = PluginUtils.licValid();
|
||||
if(!licValid) return false;
|
||||
boolean open = authUserService.supportLdap();
|
||||
return open;
|
||||
if (!licValid) return false;
|
||||
return authUserService.supportLdap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenOidc() {
|
||||
Boolean licValid = PluginUtils.licValid();
|
||||
if(!licValid) return false;
|
||||
if (!licValid) return false;
|
||||
return authUserService.supportOidc();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginLoaded() {
|
||||
Boolean licValid = PluginUtils.licValid();
|
||||
if(!licValid) return false;
|
||||
if (!licValid) return false;
|
||||
return authUserService.pluginLoaded();
|
||||
}
|
||||
|
||||
@ -190,7 +188,7 @@ public class AuthServer implements AuthApi {
|
||||
@Override
|
||||
public String getPublicKey() {
|
||||
return RsaProperties.publicKey;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import io.dataease.auth.api.dto.DynamicMenuDto;
|
||||
import io.dataease.auth.service.DynamicMenuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
||||
@ -8,7 +8,6 @@ import java.util.List;
|
||||
public interface AuthUserService {
|
||||
|
||||
|
||||
|
||||
SysUserEntity getUserById(Long userId);
|
||||
|
||||
SysUserEntity getUserByName(String username);
|
||||
@ -32,5 +31,4 @@ public interface AuthUserService {
|
||||
Boolean pluginLoaded();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ public interface ShiroService {
|
||||
* 初始化权限 -> 拿全部权限
|
||||
*
|
||||
* @param :
|
||||
* @return: java.util.Map<java.lang.String,java.lang.String>
|
||||
* @return: java.util.Map<java.lang.String, java.lang.String>
|
||||
*/
|
||||
Map<String, String> loadFilterChainDefinitionMap();
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -39,12 +40,13 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
|
||||
/**
|
||||
* 此处需被F2CRealm登录认证调用 也就是说每次请求都会被调用 所以最好加上缓存
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(value = AuthConstants.USER_CACHE_NAME, key = "'user' + #userId" )
|
||||
@Cacheable(value = AuthConstants.USER_CACHE_NAME, key = "'user' + #userId")
|
||||
@Override
|
||||
public SysUserEntity getUserById(Long userId){
|
||||
public SysUserEntity getUserById(Long userId) {
|
||||
return authMapper.findUser(userId);
|
||||
}
|
||||
|
||||
@ -69,30 +71,31 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> roles(Long userId){
|
||||
public List<String> roles(Long userId) {
|
||||
return authMapper.roleCodes(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 此处需被F2CRealm登录认证调用 也就是说每次请求都会被调用 所以最好加上缓存
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(value = AuthConstants.USER_PERMISSION_CACHE_NAME, key = "'user' + #userId" )
|
||||
@Cacheable(value = AuthConstants.USER_PERMISSION_CACHE_NAME, key = "'user' + #userId")
|
||||
@Override
|
||||
public List<String> permissions(Long userId){
|
||||
public List<String> permissions(Long userId) {
|
||||
try {
|
||||
// 用户登录获取菜单权限时同时更新插件菜单表
|
||||
dynamicMenuService.syncPluginMenu();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
//ignore
|
||||
}
|
||||
List<String> permissions;
|
||||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(userId);
|
||||
if(sysUser.getIsAdmin()!=null&&sysUser.getIsAdmin()){
|
||||
if (sysUser.getIsAdmin() != null && sysUser.getIsAdmin()) {
|
||||
permissions = authMapper.permissionsAll();
|
||||
}else{
|
||||
} else {
|
||||
permissions = authMapper.permissions(userId);
|
||||
}
|
||||
return Optional.ofNullable(permissions).orElse(new ArrayList<>()).stream().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
||||
@ -100,10 +103,11 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
|
||||
/**
|
||||
* 此处需被F2CRealm登录认证调用 也就是说每次请求都会被调用 所以最好加上缓存
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(value = AuthConstants.USER_ROLE_CACHE_NAME, key = "'user' + #userId" )
|
||||
@Cacheable(value = AuthConstants.USER_ROLE_CACHE_NAME, key = "'user' + #userId")
|
||||
@Override
|
||||
public List<CurrentRoleDto> roleInfos(Long userId) {
|
||||
return authMapper.roles(userId);
|
||||
@ -112,6 +116,7 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
|
||||
/**
|
||||
* 一波清除3个缓存
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@ -121,37 +126,35 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
})
|
||||
@Override
|
||||
public void clearCache(Long userId) {
|
||||
LogUtil.info("正在清除用户缓存【{}】",userId);
|
||||
LogUtil.info("正在清除用户缓存【{}】", userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportLdap() {
|
||||
Map<String, LdapXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((LdapXpackService.class));
|
||||
if(beansOfType.keySet().size() == 0) return false;
|
||||
if (beansOfType.keySet().size() == 0) return false;
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
if(ObjectUtils.isEmpty(ldapXpackService)) return false;
|
||||
if (ObjectUtils.isEmpty(ldapXpackService)) return false;
|
||||
return ldapXpackService.isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean supportOidc() {
|
||||
Map<String, OidcXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((OidcXpackService.class));
|
||||
if(beansOfType.keySet().size() == 0) return false;
|
||||
if (beansOfType.keySet().size() == 0) return false;
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
if(ObjectUtils.isEmpty(oidcXpackService)) return false;
|
||||
if (ObjectUtils.isEmpty(oidcXpackService)) return false;
|
||||
return oidcXpackService.isSuuportOIDC();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean pluginLoaded() {
|
||||
Map<String, PluginCommonService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((PluginCommonService.class));
|
||||
if(beansOfType.keySet().size() == 0) return false;
|
||||
if (beansOfType.keySet().size() == 0) return false;
|
||||
PluginCommonService pluginCommonService = SpringContextUtil.getBean(PluginCommonService.class);
|
||||
if(ObjectUtils.isEmpty(pluginCommonService)) return false;
|
||||
if (ObjectUtils.isEmpty(pluginCommonService)) return false;
|
||||
return pluginCommonService.isPluginLoaded();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@ -38,22 +39,21 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
List<DynamicMenuDto> dynamicMenuDtos = sysMenus.stream().map(this::convert).collect(Collectors.toList());
|
||||
//增加插件中的菜单
|
||||
List<PluginSysMenu> pluginSysMenus = PluginUtils.pluginMenus();
|
||||
if (CollectionUtils.isNotEmpty(pluginSysMenus) ) {
|
||||
if (CollectionUtils.isNotEmpty(pluginSysMenus)) {
|
||||
pluginSysMenus = pluginSysMenus.stream().filter(menu -> menu.getType() <= 1).collect(Collectors.toList());
|
||||
List<DynamicMenuDto> pluginDtos = pluginSysMenus.stream().map(this::convert).collect(Collectors.toList());
|
||||
dynamicMenuDtos.addAll(pluginDtos);
|
||||
}
|
||||
dynamicMenuDtos = dynamicMenuDtos.stream().sorted((s1, s2) -> {
|
||||
int sortIndex1 = null == s1.getMenuSort() ? 999: s1.getMenuSort();
|
||||
int sortIndex2 = null == s2.getMenuSort() ? 999: s2.getMenuSort();
|
||||
int sortIndex1 = null == s1.getMenuSort() ? 999 : s1.getMenuSort();
|
||||
int sortIndex2 = null == s2.getMenuSort() ? 999 : s2.getMenuSort();
|
||||
return sortIndex1 - sortIndex2;
|
||||
}).collect(Collectors.toList());
|
||||
dynamicMenuDtos.sort((s1, s2) -> s1.getHidden().compareTo(s2.getHidden()));
|
||||
List<DynamicMenuDto> result = buildTree(dynamicMenuDtos);
|
||||
return result;
|
||||
return buildTree(dynamicMenuDtos);
|
||||
}
|
||||
|
||||
private DynamicMenuDto convert(SysMenu sysMenu){
|
||||
private DynamicMenuDto convert(SysMenu sysMenu) {
|
||||
DynamicMenuDto dynamicMenuDto = new DynamicMenuDto();
|
||||
dynamicMenuDto.setId(sysMenu.getMenuId());
|
||||
dynamicMenuDto.setPid(sysMenu.getPid());
|
||||
@ -72,7 +72,8 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
dynamicMenuDto.setIsPlugin(false);
|
||||
return dynamicMenuDto;
|
||||
}
|
||||
private DynamicMenuDto convert(PluginSysMenu sysMenu){
|
||||
|
||||
private DynamicMenuDto convert(PluginSysMenu sysMenu) {
|
||||
DynamicMenuDto dynamicMenuDto = new DynamicMenuDto();
|
||||
dynamicMenuDto.setId(sysMenu.getMenuId());
|
||||
dynamicMenuDto.setPid(sysMenu.getPid());
|
||||
@ -93,17 +94,17 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
return dynamicMenuDto;
|
||||
}
|
||||
|
||||
private List<DynamicMenuDto> buildTree(List<DynamicMenuDto> lists){
|
||||
private List<DynamicMenuDto> buildTree(List<DynamicMenuDto> lists) {
|
||||
List<DynamicMenuDto> rootNodes = new ArrayList<>();
|
||||
lists.forEach(node -> {
|
||||
if (isParent(node.getPid())) {
|
||||
rootNodes.add(node);
|
||||
}
|
||||
lists.forEach(tNode -> {
|
||||
if (tNode.getPid() == node.getId()) {
|
||||
if (tNode.getPid().equals(node.getId())) {
|
||||
if (node.getChildren() == null) {
|
||||
node.setChildren(new ArrayList<DynamicMenuDto>());
|
||||
node.setRedirect(node.getPath()+"/"+tNode.getPath());//第一个子节点的path
|
||||
node.setRedirect(node.getPath() + "/" + tNode.getPath());//第一个子节点的path
|
||||
}
|
||||
node.getChildren().add(tNode);
|
||||
}
|
||||
@ -113,8 +114,8 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
|
||||
}
|
||||
|
||||
private Boolean isParent(Long pid){
|
||||
return null == pid || pid==0L;
|
||||
private Boolean isParent(Long pid) {
|
||||
return null == pid || pid == 0L;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -123,7 +124,7 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
List<PluginSysMenu> pluginSysMenuList = PluginUtils.pluginMenus();
|
||||
Set<PluginSysMenu> pluginSysMenuSet = new HashSet<>(pluginSysMenuList);
|
||||
pluginSysMenuList = new ArrayList<>(pluginSysMenuSet);
|
||||
if(CollectionUtils.isNotEmpty(pluginSysMenuList)){
|
||||
if (CollectionUtils.isNotEmpty(pluginSysMenuList)) {
|
||||
extPluginSysMenuMapper.savePluginMenu(pluginSysMenuList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import io.dataease.base.mapper.ext.ExtAuthMapper;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -19,8 +20,6 @@ public class ExtAuthServiceImpl implements ExtAuthService {
|
||||
@Resource
|
||||
private ExtAuthMapper extAuthMapper;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Set<Long> userIdsByRD(AuthURD request) {
|
||||
Set<Long> result = new HashSet<>();
|
||||
|
||||
@ -3,14 +3,14 @@ package io.dataease.auth.service.impl;
|
||||
import io.dataease.auth.service.ShiroService;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class ShiroServiceImpl implements ShiroService {
|
||||
|
||||
private final static String ANON = "anon";
|
||||
|
||||
private final static String ANON = "anon";
|
||||
|
||||
|
||||
@Override
|
||||
@ -20,15 +20,15 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
// 配置过滤:不会被拦截的链接 -> 放行 start ----------------------------------------------------------
|
||||
// 放行Swagger2页面,需要放行这些
|
||||
|
||||
filterChainDefinitionMap.put("/doc.html**","doc");
|
||||
filterChainDefinitionMap.put("/deApi**",ANON);
|
||||
filterChainDefinitionMap.put("/swagger-ui.html",ANON);
|
||||
filterChainDefinitionMap.put("/swagger-ui/**",ANON);
|
||||
filterChainDefinitionMap.put("/swagger/**",ANON);
|
||||
filterChainDefinitionMap.put("/doc.html**", "doc");
|
||||
filterChainDefinitionMap.put("/deApi**", ANON);
|
||||
filterChainDefinitionMap.put("/swagger-ui.html", ANON);
|
||||
filterChainDefinitionMap.put("/swagger-ui/**", ANON);
|
||||
filterChainDefinitionMap.put("/swagger/**", ANON);
|
||||
filterChainDefinitionMap.put("/webjars/**", ANON);
|
||||
filterChainDefinitionMap.put("/swagger-resources/**",ANON);
|
||||
filterChainDefinitionMap.put("/v2/**",ANON);
|
||||
filterChainDefinitionMap.put("/v3/**",ANON);
|
||||
filterChainDefinitionMap.put("/swagger-resources/**", ANON);
|
||||
filterChainDefinitionMap.put("/v2/**", ANON);
|
||||
filterChainDefinitionMap.put("/v3/**", ANON);
|
||||
|
||||
filterChainDefinitionMap.put("/static/**", ANON);
|
||||
filterChainDefinitionMap.put("/css/**", ANON);
|
||||
@ -90,8 +90,7 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
|
||||
return filterChainDefinitionMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updatePermission(ShiroFilterFactoryBean shiroFilterFactoryBean, Integer roleId, Boolean isRemoveSession) {
|
||||
|
||||
@ -14,6 +14,7 @@ import io.dataease.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@ -21,16 +22,15 @@ public class JWTUtils {
|
||||
|
||||
|
||||
// token过期时间1min (过期会自动刷新续命 目的是避免一直都是同一个token )
|
||||
private static final long EXPIRE_TIME = 1*60*1000;
|
||||
private static final long EXPIRE_TIME = 1 * 60 * 1000;
|
||||
// 登录间隔时间10min 超过这个时间强制重新登录
|
||||
private static long Login_Interval;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 校验token是否正确
|
||||
* @param token 密钥
|
||||
*
|
||||
* @param token 密钥
|
||||
* @param secret 用户的密码
|
||||
* @return 是否正确
|
||||
*/
|
||||
@ -39,41 +39,42 @@ public class JWTUtils {
|
||||
Verification verification = JWT.require(algorithm)
|
||||
.withClaim("username", tokenInfo.getUsername())
|
||||
.withClaim("userId", tokenInfo.getUserId());
|
||||
JWTVerifier verifier = verification.build();
|
||||
JWTVerifier verifier = verification.build();
|
||||
verifier.verify(token);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得token中的信息无需secret解密也能获得
|
||||
*
|
||||
* @return token中包含的用户名
|
||||
*/
|
||||
public static TokenInfo tokenInfoByToken(String token) {
|
||||
DecodedJWT jwt = JWT.decode(token);
|
||||
String username = jwt.getClaim("username").asString();
|
||||
Long userId = jwt.getClaim("userId").asLong();
|
||||
if (StringUtils.isEmpty(username) || ObjectUtils.isEmpty(userId) ){
|
||||
if (StringUtils.isEmpty(username) || ObjectUtils.isEmpty(userId)) {
|
||||
DataEaseException.throwException("token格式错误!");
|
||||
}
|
||||
TokenInfoBuilder tokenInfoBuilder = TokenInfo.builder().username(username).userId(userId);
|
||||
TokenInfo tokenInfo = tokenInfoBuilder.build();
|
||||
return tokenInfo;
|
||||
return tokenInfoBuilder.build();
|
||||
}
|
||||
|
||||
public static boolean needRefresh(String token){
|
||||
public static boolean needRefresh(String token) {
|
||||
Date exp = JWTUtils.getExp(token);
|
||||
return new Date().getTime() >= exp.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前token是否登录超时
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static boolean loginExpire(String token){
|
||||
if (Login_Interval==0) {
|
||||
public static boolean loginExpire(String token) {
|
||||
if (Login_Interval == 0) {
|
||||
// 默认超时时间是8h
|
||||
int minute = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout", Integer.class, 8*60);
|
||||
int minute = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout", Integer.class, 8 * 60);
|
||||
// 分钟换算成毫秒
|
||||
Login_Interval = minute * 1000 * 60;
|
||||
}
|
||||
@ -98,19 +99,20 @@ public class JWTUtils {
|
||||
|
||||
/**
|
||||
* 生成签名,5min后过期
|
||||
*
|
||||
* @param tokenInfo 用户信息
|
||||
* @param secret 用户的密码
|
||||
* @param secret 用户的密码
|
||||
* @return 加密的token
|
||||
*/
|
||||
public static String sign(TokenInfo tokenInfo, String secret) {
|
||||
try {
|
||||
Date date = new Date(System.currentTimeMillis()+EXPIRE_TIME);
|
||||
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
Builder builder = JWT.create()
|
||||
.withClaim("username", tokenInfo.getUsername())
|
||||
.withClaim("userId", tokenInfo.getUserId());
|
||||
return builder.withExpiresAt(date).sign(algorithm);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
@ -121,7 +123,7 @@ public class JWTUtils {
|
||||
return JWT.create().withClaim("resourceId", resourceId).sign(algorithm);
|
||||
}
|
||||
|
||||
public static boolean verifyLink(String token,String resourceId, String secret) {
|
||||
public static boolean verifyLink(String token, String resourceId, String secret) {
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
JWTVerifier verifier = JWT.require(algorithm)
|
||||
.withClaim("resourceId", resourceId)
|
||||
@ -129,17 +131,18 @@ public class JWTUtils {
|
||||
try {
|
||||
verifier.verify(token);
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前token上次操作时间
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static Long tokenLastOperateTime(String token){
|
||||
public static Long tokenLastOperateTime(String token) {
|
||||
DecodedJWT jwt = JWT.decode(token);
|
||||
Date expiresAt = jwt.getExpiresAt();
|
||||
return expiresAt.getTime();
|
||||
|
||||
@ -16,7 +16,7 @@ public class RsaUtil {
|
||||
* 私钥解密
|
||||
*
|
||||
* @param privateKeyText 私钥
|
||||
* @param text 待解密的文本
|
||||
* @param text 待解密的文本
|
||||
* @return /
|
||||
* @throws Exception /
|
||||
*/
|
||||
@ -30,7 +30,7 @@ public class RsaUtil {
|
||||
byte[] result = null;
|
||||
byte[] b = Base64.decodeBase64(text);
|
||||
for (int i = 0; i < b.length; i += 64) {
|
||||
byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(b, i,i + 64));
|
||||
byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(b, i, i + 64));
|
||||
result = ArrayUtils.addAll(result, doFinal);
|
||||
}
|
||||
return new String(result);
|
||||
@ -40,7 +40,7 @@ public class RsaUtil {
|
||||
* 公钥加密
|
||||
*
|
||||
* @param publicKeyText 公钥
|
||||
* @param text 待加密的文本
|
||||
* @param text 待加密的文本
|
||||
* @return /
|
||||
*/
|
||||
public static String encryptByPublicKey(String publicKeyText, String text) throws Exception {
|
||||
@ -53,7 +53,7 @@ public class RsaUtil {
|
||||
byte[] result = null;
|
||||
byte[] b = text.getBytes("utf-8");
|
||||
for (int i = 0; i < b.length; i += 50) {
|
||||
byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(b, i,i + 50));
|
||||
byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(b, i, i + 50));
|
||||
result = ArrayUtils.addAll(result, doFinal);
|
||||
}
|
||||
return Base64.encodeBase64String(result);
|
||||
|
||||
@ -9,7 +9,6 @@ import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
|
||||
|
||||
|
||||
public class LicStatusCondition implements Condition {
|
||||
|
||||
@Override
|
||||
|
||||
@ -7,22 +7,21 @@ package io.dataease.commons.constants;
|
||||
*/
|
||||
public class SystemConstants {
|
||||
|
||||
public static final class WITH_EXTEND{
|
||||
public static final class WITH_EXTEND {
|
||||
public final static String NOW = "now";
|
||||
public final static String PARENT = "parent";
|
||||
public final static String CHILDREN = "children";
|
||||
}
|
||||
|
||||
|
||||
public static final class PRIVILEGE_VALUE{
|
||||
public static final class PRIVILEGE_VALUE {
|
||||
public final static Integer ON = 1;
|
||||
public final static Integer OFF = 0;
|
||||
}
|
||||
|
||||
public static final class AUTH_SOURCE{
|
||||
public static final class AUTH_SOURCE {
|
||||
public final static String MENU = "menu";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package io.dataease.commons.filter;
|
||||
import io.dataease.commons.holder.ThreadLocalContextHolder;
|
||||
import io.dataease.commons.wrapper.XssAndSqlHttpServletRequestWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -12,8 +13,6 @@ import java.io.*;
|
||||
public class SqlFilter implements Filter {
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// TODO Auto-generated method stub
|
||||
@ -31,7 +30,7 @@ public class SqlFilter implements Filter {
|
||||
}
|
||||
|
||||
String method = "GET";
|
||||
String param = "";
|
||||
String param;
|
||||
XssAndSqlHttpServletRequestWrapper xssRequest = null;
|
||||
if (request instanceof HttpServletRequest) {
|
||||
method = ((HttpServletRequest) request).getMethod();
|
||||
@ -39,8 +38,8 @@ public class SqlFilter implements Filter {
|
||||
}
|
||||
if ("POST".equalsIgnoreCase(method)) {
|
||||
param = this.getBodyString(xssRequest.getReader());
|
||||
if(StringUtils.isNotBlank(param)){
|
||||
if(xssRequest.checkXSSAndSql(param)){
|
||||
if (StringUtils.isNotBlank(param)) {
|
||||
if (xssRequest.checkXSSAndSql(param)) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
@ -5,8 +5,8 @@ import io.dataease.base.domain.License;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@ -17,46 +17,44 @@ import java.util.List;
|
||||
public class DefaultLicenseService {
|
||||
@Resource
|
||||
private InnerLicenseService innerLicenseService;
|
||||
@Value("${spring.application.name:null}")
|
||||
private String moduleId;
|
||||
|
||||
private static final String LICENSE_ID = "fit2cloud_license";
|
||||
private static final String validatorUtil = "/usr/bin/validator";
|
||||
private static final String product = "DataEase";
|
||||
|
||||
public F2CLicenseResponse validateLicense(String product, String licenseKey){
|
||||
public F2CLicenseResponse validateLicense(String product, String licenseKey) {
|
||||
List<String> command = new ArrayList<String>();
|
||||
StringBuilder result = new StringBuilder();
|
||||
command.add(validatorUtil);
|
||||
command.add(licenseKey);
|
||||
try{
|
||||
try {
|
||||
execCommand(result, command);
|
||||
LogUtil.info("read lic content is : " + result.toString());
|
||||
F2CLicenseResponse f2CLicenseResponse = new Gson().fromJson(result.toString(), F2CLicenseResponse.class);
|
||||
if(f2CLicenseResponse.getStatus() != F2CLicenseResponse.Status.valid){
|
||||
if (f2CLicenseResponse.getStatus() != F2CLicenseResponse.Status.valid) {
|
||||
return f2CLicenseResponse;
|
||||
}
|
||||
if(!StringUtils.equals(f2CLicenseResponse.getLicense().getProduct(), product)){
|
||||
if (!StringUtils.equals(f2CLicenseResponse.getLicense().getProduct(), product)) {
|
||||
f2CLicenseResponse.setStatus(F2CLicenseResponse.Status.invalid);
|
||||
f2CLicenseResponse.setLicense(null);
|
||||
f2CLicenseResponse.setMessage("The license is unavailable for this product.");
|
||||
return f2CLicenseResponse;
|
||||
}
|
||||
return f2CLicenseResponse;
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage());
|
||||
return F2CLicenseResponse.noRecord();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static int execCommand(StringBuilder result, List<String> command) throws Exception{
|
||||
private static int execCommand(StringBuilder result, List<String> command) throws Exception {
|
||||
ProcessBuilder builder = new ProcessBuilder();
|
||||
builder.command(command);
|
||||
Process process = builder.start();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line = null;
|
||||
while ((line=bufferedReader.readLine()) != null){
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line).append("\n");
|
||||
}
|
||||
int exitCode = process.waitFor();
|
||||
@ -66,7 +64,7 @@ public class DefaultLicenseService {
|
||||
|
||||
public F2CLicenseResponse validateLicense() {
|
||||
try {
|
||||
License license = readLicense();
|
||||
License license = readLicense();
|
||||
return validateLicense(product, license.getLicense());
|
||||
} catch (Exception e) {
|
||||
return F2CLicenseResponse.noRecord();
|
||||
|
||||
@ -30,11 +30,11 @@ public class F2CLicenseResponse {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public static enum Status {
|
||||
public enum Status {
|
||||
no_record,
|
||||
valid,
|
||||
invalid,
|
||||
expired;
|
||||
expired
|
||||
}
|
||||
|
||||
public static F2CLicenseResponse invalid(String a) {
|
||||
|
||||
@ -22,7 +22,6 @@ class InnerLicenseService {
|
||||
|
||||
License getLicense(String key) {
|
||||
License license = licenseMapper.selectByPrimaryKey(key);
|
||||
if (license == null) return null;
|
||||
return license;
|
||||
}
|
||||
|
||||
|
||||
@ -20,8 +20,8 @@ public class AuthUtils {
|
||||
AuthUtils.extAuthService = extAuthService;
|
||||
}
|
||||
|
||||
public static CurrentUserDto getUser(){
|
||||
CurrentUserDto userDto = (CurrentUserDto)SecurityUtils.getSubject().getPrincipal();
|
||||
public static CurrentUserDto getUser() {
|
||||
CurrentUserDto userDto = (CurrentUserDto) SecurityUtils.getSubject().getPrincipal();
|
||||
return userDto;
|
||||
}
|
||||
|
||||
|
||||
@ -154,7 +154,6 @@ public class CodingUtil {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String secretKey() {
|
||||
try {
|
||||
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
|
||||
|
||||
@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class FilterConfig {
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean registration(){
|
||||
public FilterRegistrationBean registration() {
|
||||
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
|
||||
filterRegistrationBean.setFilter(new SqlFilter());//实例化Filter类
|
||||
filterRegistrationBean.addUrlPatterns("/*");//设置匹配模式,这里设置为所有,可以按需求设置为"/hello"等等
|
||||
|
||||
@ -17,7 +17,6 @@ import java.util.List;
|
||||
public class ChartController {
|
||||
|
||||
|
||||
|
||||
@ApiOperation("查询")
|
||||
@PostMapping("list")
|
||||
public List<JSON> list(@RequestBody DataSetTableRequest dataSetTableRequest) {
|
||||
|
||||
@ -16,7 +16,6 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
@ -110,7 +109,7 @@ public class ChartViewController {
|
||||
|
||||
@ApiOperation("验证视图是否使用相同数据集")
|
||||
@GetMapping("/checkSameDataSet/{viewIdSource}/{viewIdTarget}")
|
||||
public String checkSameDataSet(@PathVariable String viewIdSource,@PathVariable String viewIdTarget) throws Exception {
|
||||
return chartViewService.checkSameDataSet(viewIdSource,viewIdTarget);
|
||||
public String checkSameDataSet(@PathVariable String viewIdSource, @PathVariable String viewIdTarget) throws Exception {
|
||||
return chartViewService.checkSameDataSet(viewIdSource, viewIdTarget);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,9 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
@ -65,6 +63,7 @@ public class DataSetTableFieldController {
|
||||
public DatasetTableField save(@RequestBody DatasetTableField datasetTableField) {
|
||||
return dataSetTableFieldsService.save(datasetTableField);
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@PostMapping("delete/{id}")
|
||||
public void delete(@PathVariable String id) {
|
||||
|
||||
@ -55,7 +55,7 @@ public class ResultResponseBodyAdvice implements ResponseBodyAdvice<Object> {
|
||||
|
||||
// i18n
|
||||
private Object translate(Object obj, String type) {
|
||||
return Translator.translateObject(obj);
|
||||
return Translator.translateObject(obj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,22 +2,16 @@ package io.dataease.controller.panel;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.base.domain.DatasetTableField;
|
||||
import io.dataease.commons.model.BaseRspModel;
|
||||
import io.dataease.controller.request.panel.PanelLinkageRequest;
|
||||
import io.dataease.controller.request.panel.PanelSubjectRequest;
|
||||
import io.dataease.dto.panel.linkJump.PanelLinkJumpBaseRequest;
|
||||
import io.dataease.dto.panel.linkJump.PanelLinkJumpBaseResponse;
|
||||
import io.dataease.dto.panel.linkJump.PanelLinkJumpDTO;
|
||||
import io.dataease.dto.panel.linkJump.PanelLinkJumpInfoDTO;
|
||||
import io.dataease.service.panel.PanelLinkJumpService;
|
||||
import io.dataease.service.panel.PanelViewLinkageService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Author: wangjiahao
|
||||
@ -35,32 +29,32 @@ public class PanelLinkJumpController {
|
||||
|
||||
@ApiOperation("根据视图ID获取对应表字段信息")
|
||||
@GetMapping("/getTableFieldWithViewId/{viewId}")
|
||||
public List<DatasetTableField> getTableFieldWithViewId(@PathVariable String viewId){
|
||||
public List<DatasetTableField> getTableFieldWithViewId(@PathVariable String viewId) {
|
||||
return panelLinkJumpService.getViewFields(viewId);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("根据仪表板ID和视图ID获取跳转信息")
|
||||
@GetMapping("/queryWithViewId/{panelId}/{viewId}")
|
||||
public PanelLinkJumpDTO queryWithViewId(@PathVariable String panelId, @PathVariable String viewId){
|
||||
return panelLinkJumpService.queryWithView(panelId,viewId);
|
||||
public PanelLinkJumpDTO queryWithViewId(@PathVariable String panelId, @PathVariable String viewId) {
|
||||
return panelLinkJumpService.queryWithView(panelId, viewId);
|
||||
}
|
||||
|
||||
@ApiOperation("根据仪表板ID获取跳转信息")
|
||||
@GetMapping("/queryPanelJumpInfo/{panelId}")
|
||||
public PanelLinkJumpBaseResponse queryPanelJumpInfo(@PathVariable String panelId){
|
||||
public PanelLinkJumpBaseResponse queryPanelJumpInfo(@PathVariable String panelId) {
|
||||
return panelLinkJumpService.queryPanelJumpInfo(panelId);
|
||||
}
|
||||
|
||||
@ApiOperation("更新跳转信息")
|
||||
@PostMapping("/updateJumpSet")
|
||||
public void updateJumpSet(@RequestBody PanelLinkJumpDTO jumpDTO){
|
||||
public void updateJumpSet(@RequestBody PanelLinkJumpDTO jumpDTO) {
|
||||
panelLinkJumpService.updateJumpSet(jumpDTO);
|
||||
}
|
||||
|
||||
@ApiOperation("获取仪表板目标仪表板跳转联动信息")
|
||||
@PostMapping("/queryTargetPanelJumpInfo")
|
||||
public PanelLinkJumpBaseResponse queryTargetPanelJumpInfo(@RequestBody PanelLinkJumpBaseRequest request){
|
||||
public PanelLinkJumpBaseResponse queryTargetPanelJumpInfo(@RequestBody PanelLinkJumpBaseRequest request) {
|
||||
return panelLinkJumpService.queryTargetPanelJumpInfo(request);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public class PanelPdfTemplateController {
|
||||
|
||||
@GetMapping("queryAll")
|
||||
@ApiOperation("查询所有仪表板模板")
|
||||
public List<PanelPdfTemplate> queryAll(){
|
||||
public List<PanelPdfTemplate> queryAll() {
|
||||
return panelPdfTemplateService.queryAll();
|
||||
}
|
||||
|
||||
|
||||
@ -29,22 +29,20 @@ public class PanelViewLinkageController {
|
||||
|
||||
@ApiOperation("获取仪表板所有视图联动信息")
|
||||
@PostMapping("/getViewLinkageGather")
|
||||
public Map getViewLinkageGather(@RequestBody PanelLinkageRequest request){
|
||||
public Map getViewLinkageGather(@RequestBody PanelLinkageRequest request) {
|
||||
return panelViewLinkageService.getViewLinkageGather(request);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("保存仪表板视图联动信息")
|
||||
@PostMapping("/saveLinkage")
|
||||
public BaseRspModel saveLinkage(@RequestBody PanelLinkageRequest request){
|
||||
public BaseRspModel saveLinkage(@RequestBody PanelLinkageRequest request) {
|
||||
panelViewLinkageService.saveLinkage(request);
|
||||
return new BaseRspModel();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("获取当前仪表板所有联动信息")
|
||||
@GetMapping("/getPanelAllLinkageInfo/{panelId}")
|
||||
public Map<String, List<String>> getPanelAllLinkageInfo(@PathVariable String panelId){
|
||||
public Map<String, List<String>> getPanelAllLinkageInfo(@PathVariable String panelId) {
|
||||
return panelViewLinkageService.getPanelAllLinkageInfo(panelId);
|
||||
}
|
||||
|
||||
|
||||
@ -7,15 +7,15 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
public class EsReponse {
|
||||
private List<Column>columns = new ArrayList<>();
|
||||
private List<String[]>rows = new ArrayList<>();
|
||||
private List<Column> columns = new ArrayList<>();
|
||||
private List<String[]> rows = new ArrayList<>();
|
||||
private String cursor;
|
||||
private Integer status;
|
||||
private Error error;
|
||||
private String version;
|
||||
|
||||
@Data
|
||||
public class Error{
|
||||
public class Error {
|
||||
private String type;
|
||||
private String reason;
|
||||
}
|
||||
|
||||
@ -27,4 +27,6 @@ public abstract class DatasourceProvider {
|
||||
abstract public void handleDatasource(DatasourceRequest datasourceRequest, String type) throws Exception;
|
||||
|
||||
abstract public List<String> getSchema(DatasourceRequest datasourceRequest) throws Exception;
|
||||
|
||||
public abstract List<TableFiled> getTableFileds(DatasourceRequest datasourceRequest) throws Exception;
|
||||
}
|
||||
|
||||
@ -12,6 +12,8 @@ import io.dataease.dto.datasource.EsConfiguration;
|
||||
import io.dataease.dto.datasource.TableFiled;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.provider.query.QueryProvider;
|
||||
import io.dataease.provider.query.es.EsQueryProvider;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -94,6 +96,13 @@ public class EsProvider extends DatasourceProvider {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableFiled> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(datasourceRequest.getDatasource().getType());
|
||||
datasourceRequest.setQuery(qp.convertTableToSql(datasourceRequest.getTable(), datasourceRequest.getDatasource()));
|
||||
return fetchResultField(datasourceRequest);
|
||||
}
|
||||
|
||||
private List<String[]> fetchResult(String response) throws Exception {
|
||||
EsReponse esReponse = new Gson().fromJson(response, EsReponse.class);
|
||||
return fetchResult(esReponse);
|
||||
|
||||
@ -72,8 +72,8 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
|
||||
list = fetchResult(rs);
|
||||
|
||||
if(dsr.isPageable() && dsr.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.sqlServer.name())){
|
||||
Integer realSize = dsr.getPage() * dsr.getPageSize() < list.size() ? dsr.getPage() * dsr.getPageSize(): list.size();
|
||||
if (dsr.isPageable() && dsr.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.sqlServer.name())) {
|
||||
Integer realSize = dsr.getPage() * dsr.getPageSize() < list.size() ? dsr.getPage() * dsr.getPageSize() : list.size();
|
||||
list = list.subList((dsr.getPage() - 1) * dsr.getPageSize(), realSize);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
}
|
||||
|
||||
public void exec(DatasourceRequest datasourceRequest) throws Exception {
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest); Statement stat = connection.createStatement()){
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest); Statement stat = connection.createStatement()) {
|
||||
Boolean result = stat.execute(datasourceRequest.getQuery());
|
||||
} catch (SQLException e) {
|
||||
DataEaseException.throwException(e);
|
||||
@ -97,7 +97,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
|
||||
@Override
|
||||
public List<String[]> fetchResult(DatasourceRequest datasourceRequest) throws Exception {
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest); Statement stat = connection.createStatement(); ResultSet rs = stat.executeQuery(rebuildSqlWithFragment(datasourceRequest.getQuery()))){
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest); Statement stat = connection.createStatement(); ResultSet rs = stat.executeQuery(rebuildSqlWithFragment(datasourceRequest.getQuery()))) {
|
||||
return fetchResult(rs);
|
||||
} catch (SQLException e) {
|
||||
DataEaseException.throwException(e);
|
||||
@ -117,7 +117,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
int columType = metaData.getColumnType(j + 1);
|
||||
switch (columType) {
|
||||
case Types.DATE:
|
||||
if(rs.getDate(j + 1) != null){
|
||||
if (rs.getDate(j + 1) != null) {
|
||||
row[j] = rs.getDate(j + 1).toString();
|
||||
}
|
||||
break;
|
||||
@ -131,9 +131,95 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableFiled> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<TableFiled> list = new LinkedList<>();
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest)) {
|
||||
DatabaseMetaData databaseMetaData = connection.getMetaData();
|
||||
ResultSet resultSet = databaseMetaData.getColumns(null, "%", datasourceRequest.getTable(), "%");
|
||||
while (resultSet.next()) {
|
||||
String tableName = resultSet.getString("TABLE_NAME");
|
||||
String database;
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())) {
|
||||
database = resultSet.getString("TABLE_SCHEM");
|
||||
} else {
|
||||
database = resultSet.getString("TABLE_CAT");
|
||||
}
|
||||
if (database != null) {
|
||||
if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDatabase(datasourceRequest))) {
|
||||
TableFiled tableFiled = getTableFiled(resultSet, datasourceRequest);
|
||||
list.add(tableFiled);
|
||||
}
|
||||
} else {
|
||||
if (tableName.equals(datasourceRequest.getTable())) {
|
||||
TableFiled tableFiled = getTableFiled(resultSet, datasourceRequest);
|
||||
list.add(tableFiled);
|
||||
}
|
||||
}
|
||||
}
|
||||
resultSet.close();
|
||||
} catch (SQLException e) {
|
||||
DataEaseException.throwException(e);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(Translator.get("i18n_datasource_connect_error") + e.getMessage());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private TableFiled getTableFiled(ResultSet resultSet, DatasourceRequest datasourceRequest) throws SQLException {
|
||||
TableFiled tableFiled = new TableFiled();
|
||||
String colName = resultSet.getString("COLUMN_NAME");
|
||||
tableFiled.setFieldName(colName);
|
||||
String remarks = resultSet.getString("REMARKS");
|
||||
if (remarks == null || remarks.equals("")) {
|
||||
remarks = colName;
|
||||
}
|
||||
tableFiled.setRemarks(remarks);
|
||||
String dbType = resultSet.getString("TYPE_NAME").toUpperCase();
|
||||
tableFiled.setFieldType(dbType);
|
||||
if(dbType.equalsIgnoreCase("LONG")){tableFiled.setFieldSize(65533);}
|
||||
if(StringUtils.isNotEmpty(dbType) && dbType.toLowerCase().contains("date") && tableFiled.getFieldSize() < 50 ){
|
||||
tableFiled.setFieldSize(50);
|
||||
}
|
||||
|
||||
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())){
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(datasourceRequest.getDatasource().getType());
|
||||
tableFiled.setFieldSize(qp.transFieldSize(dbType));
|
||||
}else {
|
||||
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.hive.name()) && tableFiled.getFieldType().equalsIgnoreCase("BOOLEAN")){
|
||||
tableFiled.setFieldSize(1);
|
||||
}else {
|
||||
tableFiled.setFieldSize(Integer.valueOf(resultSet.getString("COLUMN_SIZE")));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return tableFiled;
|
||||
}
|
||||
|
||||
private String getDatabase(DatasourceRequest datasourceRequest) {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasourceRequest.getDatasource().getType());
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
case de_doris:
|
||||
case ds_doris:
|
||||
case mariadb:
|
||||
MysqlConfiguration mysqlConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MysqlConfiguration.class);
|
||||
return mysqlConfiguration.getDataBase();
|
||||
case sqlServer:
|
||||
SqlServerConfiguration sqlServerConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfiguration.class);
|
||||
return sqlServerConfiguration.getDataBase();
|
||||
case pg:
|
||||
PgConfiguration pgConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), PgConfiguration.class);
|
||||
return pgConfiguration.getDataBase();
|
||||
default:
|
||||
JdbcConfiguration jdbcConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), JdbcConfiguration.class);
|
||||
return jdbcConfiguration.getDataBase();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public List<TableFiled> fetchResultField(DatasourceRequest datasourceRequest) throws Exception {
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest); Statement stat = connection.createStatement(); ResultSet rs = stat.executeQuery(rebuildSqlWithFragment(datasourceRequest.getQuery()))){
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest); Statement stat = connection.createStatement(); ResultSet rs = stat.executeQuery(rebuildSqlWithFragment(datasourceRequest.getQuery()))) {
|
||||
return fetchResultField(rs, datasourceRequest);
|
||||
} catch (SQLException e) {
|
||||
DataEaseException.throwException(e);
|
||||
@ -146,9 +232,9 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
@Override
|
||||
public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception {
|
||||
Map<String, List> result = new HashMap<>();
|
||||
List<String[]> dataList = new LinkedList<>();
|
||||
List<TableFiled> fieldList = new ArrayList<>();
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest); Statement stat = connection.createStatement(); ResultSet rs = stat.executeQuery(rebuildSqlWithFragment(datasourceRequest.getQuery()))){
|
||||
List<String[]> dataList;
|
||||
List<TableFiled> fieldList;
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest); Statement stat = connection.createStatement(); ResultSet rs = stat.executeQuery(rebuildSqlWithFragment(datasourceRequest.getQuery()))) {
|
||||
dataList = fetchResult(rs);
|
||||
fieldList = fetchResultField(rs, datasourceRequest);
|
||||
result.put("dataList", dataList);
|
||||
@ -170,7 +256,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
String f = metaData.getColumnName(j + 1);
|
||||
String l = StringUtils.isNotEmpty(metaData.getColumnLabel(j + 1)) ? metaData.getColumnLabel(j + 1) : f;
|
||||
String t = metaData.getColumnTypeName(j + 1);
|
||||
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.hive.name())){
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.hive.name())) {
|
||||
l = l.split("\\.")[1];
|
||||
}
|
||||
TableFiled field = new TableFiled();
|
||||
@ -178,14 +264,16 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
field.setRemarks(l);
|
||||
field.setFieldType(t);
|
||||
|
||||
if(datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())){
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())) {
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(datasourceRequest.getDatasource().getType());
|
||||
field.setFieldSize(qp.transFieldSize(t));
|
||||
}else {
|
||||
} else {
|
||||
field.setFieldSize(metaData.getColumnDisplaySize(j + 1));
|
||||
}
|
||||
if(t.equalsIgnoreCase("LONG")){field.setFieldSize(65533);} //oracle LONG
|
||||
if(StringUtils.isNotEmpty(t) && t.toLowerCase().contains("date") && field.getFieldSize() < 50 ){
|
||||
if (t.equalsIgnoreCase("LONG")) {
|
||||
field.setFieldSize(65533);
|
||||
} //oracle LONG
|
||||
if (StringUtils.isNotEmpty(t) && t.toLowerCase().contains("date") && field.getFieldSize() < 50) {
|
||||
field.setFieldSize(50);
|
||||
}
|
||||
fieldList.add(field);
|
||||
@ -197,7 +285,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
public List<String> getTables(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<String> tables = new ArrayList<>();
|
||||
String queryStr = getTablesSql(datasourceRequest);
|
||||
try (Connection con = getConnectionFromPool(datasourceRequest); Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(queryStr)){
|
||||
try (Connection con = getConnectionFromPool(datasourceRequest); Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(queryStr)) {
|
||||
while (resultSet.next()) {
|
||||
tables.add(resultSet.getString(1));
|
||||
}
|
||||
@ -206,8 +294,8 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
}
|
||||
|
||||
String queryView = getViewSql(datasourceRequest);
|
||||
if(queryView != null){
|
||||
try (Connection con = getConnectionFromPool(datasourceRequest); Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(queryView)){
|
||||
if (queryView != null) {
|
||||
try (Connection con = getConnectionFromPool(datasourceRequest); Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(queryView)) {
|
||||
while (resultSet.next()) {
|
||||
tables.add(resultSet.getString(1));
|
||||
}
|
||||
@ -223,7 +311,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
public List<String> getSchema(DatasourceRequest datasourceRequest) throws Exception {
|
||||
List<String> schemas = new ArrayList<>();
|
||||
String queryStr = getSchemaSql(datasourceRequest);
|
||||
try (Connection con = getConnection(datasourceRequest); Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(queryStr)){
|
||||
try (Connection con = getConnection(datasourceRequest); Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(queryStr)) {
|
||||
while (resultSet.next()) {
|
||||
schemas.add(resultSet.getString(1));
|
||||
}
|
||||
@ -237,7 +325,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
@Override
|
||||
public void checkStatus(DatasourceRequest datasourceRequest) throws Exception {
|
||||
String queryStr = getTablesSql(datasourceRequest);
|
||||
try (Connection con = getConnection(datasourceRequest); Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(queryStr)){
|
||||
try (Connection con = getConnection(datasourceRequest); Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(queryStr)) {
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -248,7 +336,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
@Override
|
||||
public void handleDatasource(DatasourceRequest datasourceRequest, String type) throws Exception {
|
||||
DruidDataSource dataSource = null;
|
||||
switch (type){
|
||||
switch (type) {
|
||||
case "add":
|
||||
checkStatus(datasourceRequest);
|
||||
dataSource = jdbcConnection.get(datasourceRequest.getDatasource().getId());
|
||||
@ -316,7 +404,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
password = oracleConfiguration.getPassword();
|
||||
driver = oracleConfiguration.getDriver();
|
||||
jdbcurl = oracleConfiguration.getJdbc();
|
||||
props.put( "oracle.net.CONNECT_TIMEOUT" , "5000") ;
|
||||
props.put("oracle.net.CONNECT_TIMEOUT", "5000");
|
||||
break;
|
||||
case pg:
|
||||
PgConfiguration pgConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), PgConfiguration.class);
|
||||
@ -376,7 +464,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
druidDataSource.setInitialSize(jdbcConfiguration.getInitialPoolSize());// 初始连接数
|
||||
druidDataSource.setMinIdle(jdbcConfiguration.getMinPoolSize()); // 最小连接数
|
||||
druidDataSource.setMaxActive(jdbcConfiguration.getMaxPoolSize()); // 最大连接数
|
||||
if(datasourceRequest.getDatasource().getType().equals(DatasourceTypes.mongo.name()) || datasourceRequest.getDatasource().getType().equals(DatasourceTypes.hive.name())){
|
||||
if (datasourceRequest.getDatasource().getType().equals(DatasourceTypes.mongo.name()) || datasourceRequest.getDatasource().getType().equals(DatasourceTypes.hive.name())) {
|
||||
WallFilter wallFilter = new WallFilter();
|
||||
wallFilter.setDbType(DatasourceTypes.mysql.name());
|
||||
druidDataSource.setProxyFilters(Arrays.asList(new Filter[]{wallFilter}));
|
||||
@ -467,7 +555,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
return "show tables";
|
||||
case sqlServer:
|
||||
SqlServerConfiguration sqlServerConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfiguration.class);
|
||||
if(StringUtils.isEmpty(sqlServerConfiguration.getSchema())){
|
||||
if (StringUtils.isEmpty(sqlServerConfiguration.getSchema())) {
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT TABLE_NAME FROM DATABASE.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'DS_SCHEMA' ;"
|
||||
@ -475,13 +563,13 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
.replace("DS_SCHEMA", sqlServerConfiguration.getSchema());
|
||||
case oracle:
|
||||
OracleConfiguration oracleConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), OracleConfiguration.class);
|
||||
if(StringUtils.isEmpty(oracleConfiguration.getSchema())){
|
||||
if (StringUtils.isEmpty(oracleConfiguration.getSchema())) {
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "select table_name, owner from all_tables where owner='" + oracleConfiguration.getSchema() + "'";
|
||||
case pg:
|
||||
PgConfiguration pgConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), PgConfiguration.class);
|
||||
if(StringUtils.isEmpty(pgConfiguration.getSchema())){
|
||||
if (StringUtils.isEmpty(pgConfiguration.getSchema())) {
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT tablename FROM pg_tables WHERE schemaname='SCHEMA' ;".replace("SCHEMA", pgConfiguration.getSchema());
|
||||
@ -490,7 +578,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
return "SELECT name FROM system.tables where database='DATABASE';".replace("DATABASE", chConfiguration.getDataBase());
|
||||
case redshift:
|
||||
RedshiftConfigration redshiftConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), RedshiftConfigration.class);
|
||||
if(StringUtils.isEmpty(redshiftConfigration.getSchema())){
|
||||
if (StringUtils.isEmpty(redshiftConfigration.getSchema())) {
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT tablename FROM pg_tables WHERE schemaname='SCHEMA' ;".replace("SCHEMA", redshiftConfigration.getSchema());
|
||||
@ -510,7 +598,7 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
return null;
|
||||
case sqlServer:
|
||||
SqlServerConfiguration sqlServerConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfiguration.class);
|
||||
if(StringUtils.isEmpty(sqlServerConfiguration.getSchema())){
|
||||
if (StringUtils.isEmpty(sqlServerConfiguration.getSchema())) {
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT TABLE_NAME FROM DATABASE.INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'DS_SCHEMA' ;"
|
||||
@ -518,19 +606,19 @@ public class JdbcProvider extends DatasourceProvider {
|
||||
.replace("DS_SCHEMA", sqlServerConfiguration.getSchema());
|
||||
case oracle:
|
||||
OracleConfiguration oracleConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), OracleConfiguration.class);
|
||||
if(StringUtils.isEmpty(oracleConfiguration.getSchema())){
|
||||
if (StringUtils.isEmpty(oracleConfiguration.getSchema())) {
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "select VIEW_NAME from all_views where owner='" + oracleConfiguration.getSchema() + "'";
|
||||
case pg:
|
||||
PgConfiguration pgConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), PgConfiguration.class);
|
||||
if(StringUtils.isEmpty(pgConfiguration.getSchema())){
|
||||
if (StringUtils.isEmpty(pgConfiguration.getSchema())) {
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT viewname FROM pg_views WHERE schemaname='SCHEMA' ;".replace("SCHEMA", pgConfiguration.getSchema());
|
||||
case redshift:
|
||||
RedshiftConfigration redshiftConfigration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), RedshiftConfigration.class);
|
||||
if(StringUtils.isEmpty(redshiftConfigration.getSchema())){
|
||||
if (StringUtils.isEmpty(redshiftConfigration.getSchema())) {
|
||||
throw new Exception(Translator.get("i18n_schema_is_empty"));
|
||||
}
|
||||
return "SELECT viewname FROM pg_views WHERE schemaname='SCHEMA' ;".replace("SCHEMA", redshiftConfigration.getSchema());
|
||||
|
||||
@ -59,8 +59,6 @@ public abstract class QueryProvider {
|
||||
return 50;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 单指标汇总
|
||||
*
|
||||
|
||||
@ -49,6 +49,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
case "date":
|
||||
return 1;// 时间
|
||||
case "tinyint":
|
||||
case "smallint":
|
||||
case "int":
|
||||
case "bigint":
|
||||
return 2;// 整型
|
||||
|
||||
@ -38,11 +38,11 @@ import static io.dataease.provider.query.SQLConstants.TABLE_ALIAS_PREFIX;
|
||||
@Service("oracleQuery")
|
||||
public class OracleQueryProvider extends QueryProvider {
|
||||
|
||||
private static Integer STRING = 0;
|
||||
private static Integer TIME = 1;
|
||||
private static Integer INT = 2;
|
||||
private static Integer FLOAT = 3;
|
||||
private static Integer BOOLEAN = 4;
|
||||
private static final Integer STRING = 0;
|
||||
private static final Integer TIME = 1;
|
||||
private static final Integer INT = 2;
|
||||
private static final Integer FLOAT = 3;
|
||||
private static final Integer BOOLEAN = 4;
|
||||
|
||||
@Resource
|
||||
private DatasetTableFieldMapper datasetTableFieldMapper;
|
||||
|
||||
@ -108,7 +108,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
String fieldName = "";
|
||||
String fieldName;
|
||||
// 处理横轴字段
|
||||
if (f.getDeExtractType() == DeTypeConstants.DE_TIME) { // 时间 转为 数值
|
||||
if (f.getDeType() == DeTypeConstants.DE_INT || f.getDeType() == DeTypeConstants.DE_FLOAT) {
|
||||
|
||||
@ -11,6 +11,7 @@ import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
@ -27,11 +28,11 @@ public class AboutService {
|
||||
public F2CLicenseResponse updateLicense(String licenseKey) {
|
||||
F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.updateLicense(product, licenseKey);
|
||||
Optional.ofNullable(f2CLicenseResponse).ifPresent(resp -> {
|
||||
if (resp.getStatus() == F2CLicenseResponse.Status.valid){
|
||||
if (resp.getStatus() == F2CLicenseResponse.Status.valid) {
|
||||
String dateStr = f2CLicenseResponse.getLicense().getExpired();
|
||||
LogUtil.info("update valid lic, expired date is {}", dateStr);
|
||||
try {
|
||||
Date date = DateUtils.getDate(dateStr);
|
||||
Date date = DateUtils.getDate(dateStr);
|
||||
CacheUtils.updateLicCache(date);
|
||||
CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME);
|
||||
CacheUtils.removeAll(AuthConstants.USER_ROLE_CACHE_NAME);
|
||||
@ -62,8 +63,7 @@ public class AboutService {
|
||||
}
|
||||
}
|
||||
String property = CommonBeanFactory.getBean(Environment.class).getProperty("cmp.version");
|
||||
String result = Optional.ofNullable(property).orElse("V1.0");
|
||||
return result;
|
||||
return Optional.ofNullable(property).orElse("V1.0");
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("failed to get build version.", e);
|
||||
}
|
||||
|
||||
@ -11,14 +11,13 @@ import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class CommonFilesService {
|
||||
public final static String VIEW_DEFAULT_IMAGE="VIEW_DEFAULT_IMAGE";
|
||||
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
|
||||
|
||||
public ResponseEntity<byte[]> getImageById(String imageId,String defaultImage) {
|
||||
byte[] bytes = null;
|
||||
byte[] bytes;
|
||||
MediaType contentType = MediaType.parseMediaType("application/octet-stream");
|
||||
FileMetadata fileMetadata = fileService.copyFile(imageId);
|
||||
if (fileMetadata == null&& StringUtils.isNotEmpty(defaultImage)) {
|
||||
|
||||
@ -21,9 +21,9 @@ public class FileService {
|
||||
private FileMetadataMapper fileMetadataMapper;
|
||||
@Resource
|
||||
private FileContentMapper fileContentMapper;
|
||||
|
||||
public byte[] loadFileAsBytes(String id) {
|
||||
FileContent fileContent = fileContentMapper.selectByPrimaryKey(id);
|
||||
|
||||
return fileContent.getFile();
|
||||
}
|
||||
|
||||
@ -38,42 +38,19 @@ public class FileService {
|
||||
FileMetadataExample example = new FileMetadataExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
fileMetadataMapper.deleteByExample(example);
|
||||
|
||||
FileContentExample example2 = new FileContentExample();
|
||||
example2.createCriteria().andFileIdIn(ids);
|
||||
fileContentMapper.deleteByExample(example2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void deleteFileRelatedByIds(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
FileMetadataExample example = new FileMetadataExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
fileMetadataMapper.deleteByExample(example);
|
||||
|
||||
FileContentExample example2 = new FileContentExample();
|
||||
example2.createCriteria().andFileIdIn(ids);
|
||||
fileContentMapper.deleteByExample(example2);
|
||||
}
|
||||
|
||||
public FileMetadata saveFile(MultipartFile file) {
|
||||
return saveFile(file,file.getOriginalFilename());
|
||||
return saveFile(file, file.getOriginalFilename());
|
||||
}
|
||||
|
||||
public FileMetadata saveFile(MultipartFile file,String fileName) {
|
||||
public FileMetadata saveFile(MultipartFile file, String fileName) {
|
||||
final FileMetadata fileMetadata = new FileMetadata();
|
||||
fileMetadata.setId(UUID.randomUUID().toString());
|
||||
fileMetadata.setName(fileName);
|
||||
fileMetadata.setSize(file.getSize());
|
||||
fileMetadata.setCreateTime(System.currentTimeMillis());
|
||||
fileMetadata.setUpdateTime(System.currentTimeMillis());
|
||||
FileType fileType = getFileType(fileMetadata.getName());
|
||||
fileMetadata.setType(fileType.name());
|
||||
setFileMetadataProperties(fileMetadata, file.getSize(), fileName);
|
||||
fileMetadataMapper.insert(fileMetadata);
|
||||
|
||||
FileContent fileContent = new FileContent();
|
||||
fileContent.setFileId(fileMetadata.getId());
|
||||
try {
|
||||
@ -86,22 +63,24 @@ public class FileService {
|
||||
return fileMetadata;
|
||||
}
|
||||
|
||||
public FileMetadata saveFile(byte[] fileByte,String fileName,Long fileSize) {
|
||||
final FileMetadata fileMetadata = new FileMetadata();
|
||||
private void setFileMetadataProperties(FileMetadata fileMetadata, long size, String fileName){
|
||||
fileMetadata.setId(UUID.randomUUID().toString());
|
||||
fileMetadata.setName(fileName);
|
||||
fileMetadata.setSize(fileSize);
|
||||
fileMetadata.setSize(size);
|
||||
fileMetadata.setCreateTime(System.currentTimeMillis());
|
||||
fileMetadata.setUpdateTime(System.currentTimeMillis());
|
||||
FileType fileType = getFileType(fileMetadata.getName());
|
||||
fileMetadata.setType(fileType.name());
|
||||
fileMetadataMapper.insert(fileMetadata);
|
||||
}
|
||||
|
||||
public FileMetadata saveFile(byte[] fileByte, String fileName, Long fileSize) {
|
||||
final FileMetadata fileMetadata = new FileMetadata();
|
||||
setFileMetadataProperties(fileMetadata, fileSize, fileName);
|
||||
fileMetadataMapper.insert(fileMetadata);
|
||||
FileContent fileContent = new FileContent();
|
||||
fileContent.setFileId(fileMetadata.getId());
|
||||
fileContent.setFile(fileByte);
|
||||
fileContentMapper.insert(fileContent);
|
||||
|
||||
return fileMetadata;
|
||||
}
|
||||
|
||||
|
||||
@ -59,20 +59,21 @@ public class ScheduleService {
|
||||
scheduleManager.removeJob(new JobKey(datasetTableTask.getId(), datasetTableTask.getTableId()), new TriggerKey(datasetTableTask.getId(), datasetTableTask.getTableId()));
|
||||
}
|
||||
|
||||
public void fireNow(DatasetTableTask datasetTableTask) throws Exception{
|
||||
public void fireNow(DatasetTableTask datasetTableTask) throws Exception {
|
||||
scheduleManager.fireNow(datasetTableTask.getId(), datasetTableTask.getTableId());
|
||||
}
|
||||
|
||||
public void addSchedule(GlobalTaskEntity task) throws Exception{
|
||||
public void addSchedule(GlobalTaskEntity task) throws Exception {
|
||||
TaskHandler taskHandler = TaskStrategyFactory.getInvokeStrategy(task.getTaskType());
|
||||
taskHandler.addTask(scheduleManager, task);
|
||||
}
|
||||
|
||||
public void deleteSchedule(GlobalTaskEntity task) {
|
||||
TaskHandler taskHandler = TaskStrategyFactory.getInvokeStrategy(task.getTaskType());
|
||||
taskHandler.removeTask(scheduleManager, task);
|
||||
}
|
||||
|
||||
public void fireNow(GlobalTaskEntity task) throws Exception{
|
||||
public void fireNow(GlobalTaskEntity task) throws Exception {
|
||||
TaskHandler taskHandler = TaskStrategyFactory.getInvokeStrategy(task.getTaskType());
|
||||
taskHandler.executeTask(scheduleManager, task);
|
||||
}
|
||||
|
||||
@ -90,8 +90,7 @@ public class ChartGroupService {
|
||||
chartGroup.setPid(null);
|
||||
chartGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
List<ChartGroupDTO> treeInfo = extChartGroupMapper.search(chartGroup);
|
||||
List<ChartGroupDTO> result = TreeUtils.mergeTree(treeInfo);
|
||||
return result;
|
||||
return TreeUtils.mergeTree(treeInfo);
|
||||
}
|
||||
|
||||
public List<ChartGroupDTO> treeNode(ChartGroupRequest chartGroup) {
|
||||
@ -100,8 +99,7 @@ public class ChartGroupService {
|
||||
chartGroup.setType("group");
|
||||
chartGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
List<ChartGroupDTO> treeInfo = extChartGroupMapper.search(chartGroup);
|
||||
List<ChartGroupDTO> result = TreeUtils.mergeTree(treeInfo);
|
||||
return result;
|
||||
return TreeUtils.mergeTree(treeInfo);
|
||||
}
|
||||
|
||||
public List<String> getAllId(List<ChartGroupDTO> list, List<String> ids) {
|
||||
|
||||
@ -99,8 +99,7 @@ public class DataSetGroupService {
|
||||
datasetGroup.setType("group");
|
||||
datasetGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
List<DataSetGroupDTO> treeInfo = extDataSetGroupMapper.search(datasetGroup);
|
||||
List<DataSetGroupDTO> result = TreeUtils.mergeTree(treeInfo);
|
||||
return result;
|
||||
return TreeUtils.mergeTree(treeInfo);
|
||||
}
|
||||
|
||||
public List<DataSetGroupDTO> tree(DataSetGroupRequest datasetGroup) {
|
||||
@ -108,8 +107,7 @@ public class DataSetGroupService {
|
||||
datasetGroup.setPid(null);
|
||||
datasetGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
List<DataSetGroupDTO> treeInfo = extDataSetGroupMapper.search(datasetGroup);
|
||||
List<DataSetGroupDTO> result = TreeUtils.mergeTree(treeInfo);
|
||||
return result;
|
||||
return TreeUtils.mergeTree(treeInfo);
|
||||
}
|
||||
|
||||
public List<String> getAllId(List<DataSetGroupDTO> list, List<String> ids) {
|
||||
|
||||
@ -77,9 +77,7 @@ public class DataSetTableFieldsService {
|
||||
public List<DatasetTableField> getListByIdsEach(List<String> ids) {
|
||||
List<DatasetTableField> list = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
ids.forEach(id -> {
|
||||
list.add(datasetTableFieldMapper.selectByPrimaryKey(id));
|
||||
});
|
||||
ids.forEach(id -> list.add(datasetTableFieldMapper.selectByPrimaryKey(id)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -80,8 +80,6 @@ public class DataSetTableService {
|
||||
@Resource
|
||||
private DataSetTableUnionService dataSetTableUnionService;
|
||||
@Resource
|
||||
private DataSetTableTaskLogService dataSetTableTaskLogService;
|
||||
@Resource
|
||||
private QrtzSchedulerStateMapper qrtzSchedulerStateMapper;
|
||||
@Resource
|
||||
private DatasetTableTaskLogMapper datasetTableTaskLogMapper;
|
||||
@ -89,8 +87,8 @@ public class DataSetTableService {
|
||||
private ExtDataSetGroupMapper extDataSetGroupMapper;
|
||||
@Resource
|
||||
private DatasetTableFieldMapper datasetTableFieldMapper;
|
||||
private static String lastUpdateTime = "${__last_update_time__}";
|
||||
private static String currentUpdateTime = "${__current_update_time__}";
|
||||
private static final String lastUpdateTime = "${__last_update_time__}";
|
||||
private static final String currentUpdateTime = "${__current_update_time__}";
|
||||
|
||||
@Value("${upload.file.path}")
|
||||
private String path;
|
||||
@ -144,9 +142,7 @@ public class DataSetTableService {
|
||||
int insert = datasetTableMapper.insert(sheetTable);
|
||||
if (insert == 1) {
|
||||
saveExcelTableField(sheetTable.getId(), excelSheetDataList.get(0).getFields(), true);
|
||||
commonThreadPool.addTask(() -> {
|
||||
extractDataService.extractExcelData(sheetTable.getId(), "all_scope", "初始导入", null);
|
||||
});
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(sheetTable.getId(), "all_scope", "初始导入", null));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -172,9 +168,7 @@ public class DataSetTableService {
|
||||
int insert = datasetTableMapper.insert(sheetTable);
|
||||
if (insert == 1) {
|
||||
saveExcelTableField(sheetTable.getId(), sheet.getFields(), true);
|
||||
commonThreadPool.addTask(() -> {
|
||||
extractDataService.extractExcelData(sheetTable.getId(), "all_scope", "初始导入", null);
|
||||
});
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(sheetTable.getId(), "all_scope", "初始导入", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,7 +182,7 @@ public class DataSetTableService {
|
||||
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_inconsistent"));
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_column_inconsistent"));
|
||||
}
|
||||
oldFields = newFields;
|
||||
}
|
||||
@ -209,13 +203,9 @@ public class DataSetTableService {
|
||||
|
||||
if (update == 1) {
|
||||
if (datasetTable.getEditType() == 0) {
|
||||
commonThreadPool.addTask(() -> {
|
||||
extractDataService.extractExcelData(datasetTable.getId(), "all_scope", "替换", saveExcelTableField(datasetTable.getId(), datasetTable.getSheets().get(0).getFields(), false));
|
||||
});
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetTable.getId(), "all_scope", "替换", saveExcelTableField(datasetTable.getId(), datasetTable.getSheets().get(0).getFields(), false)));
|
||||
} else if (datasetTable.getEditType() == 1) {
|
||||
commonThreadPool.addTask(() -> {
|
||||
extractDataService.extractExcelData(datasetTable.getId(), "add_scope", "追加", null);
|
||||
});
|
||||
commonThreadPool.addTask(() -> extractDataService.extractExcelData(datasetTable.getId(), "add_scope", "追加", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -388,9 +378,8 @@ public class DataSetTableService {
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(qp.convertTableToSql(new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable(), ds));
|
||||
return datasourceProvider.fetchResultField(datasourceRequest);
|
||||
datasourceRequest.setTable(new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable());
|
||||
return datasourceProvider.getTableFileds(datasourceRequest);
|
||||
}
|
||||
|
||||
public Map<String, List<DatasetTableField>> getFieldsFromDE(DataSetTableRequest dataSetTableRequest) throws Exception {
|
||||
@ -771,9 +760,7 @@ public class DataSetTableService {
|
||||
|
||||
// 获取每个字段在当前de数据库中的name,作为sql查询后的remarks返回前端展示
|
||||
List<DatasetTableField> checkedFieldList = new ArrayList<>();
|
||||
dataTableInfoDTO.getList().forEach(ele -> {
|
||||
checkedFieldList.addAll(dataSetTableFieldsService.getListByIds(ele.getCheckedFields()));
|
||||
});
|
||||
dataTableInfoDTO.getList().forEach(ele -> checkedFieldList.addAll(dataSetTableFieldsService.getListByIds(ele.getCheckedFields())));
|
||||
for (DatasetTableField datasetTableField : checkedFieldList) {
|
||||
for (TableFiled tableFiled : fields) {
|
||||
if (StringUtils.equalsIgnoreCase(tableFiled.getFieldName(), DorisTableUtils.dorisFieldName(datasetTableField.getTableId() + "_" + datasetTableField.getDataeaseName()))
|
||||
@ -984,9 +971,7 @@ public class DataSetTableService {
|
||||
List<DatasetTableField> fieldList = new ArrayList<>();
|
||||
list.forEach(ele -> {
|
||||
List<DatasetTableField> listByIds = dataSetTableFieldsService.getListByIdsEach(ele.getCheckedFields());
|
||||
listByIds.forEach(f -> {
|
||||
f.setDataeaseName(DorisTableUtils.dorisFieldName(ele.getTableId() + "_" + f.getDataeaseName()));
|
||||
});
|
||||
listByIds.forEach(f -> f.setDataeaseName(DorisTableUtils.dorisFieldName(ele.getTableId() + "_" + f.getDataeaseName())));
|
||||
fieldList.addAll(listByIds);
|
||||
});
|
||||
for (int i = 0; i < fieldList.size(); i++) {
|
||||
@ -1187,9 +1172,7 @@ public class DataSetTableService {
|
||||
datasourceRequest.setQuery(qp.wrapSql(sql));
|
||||
List<String> sqlFileds = new ArrayList<>();
|
||||
try {
|
||||
datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableFiled::getFieldName).forEach(filed -> {
|
||||
sqlFileds.add(filed);
|
||||
});
|
||||
datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableFiled::getFieldName).forEach(filed -> sqlFileds.add(filed));
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(Translator.get("i18n_check_sql_error") + e.getMessage());
|
||||
}
|
||||
@ -1257,7 +1240,7 @@ public class DataSetTableService {
|
||||
}
|
||||
|
||||
if (retrunSheetDataList.size() == 0) {
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_colume_change"));
|
||||
DataEaseException.throwException(Translator.get("i18n_excel_column_change"));
|
||||
}
|
||||
} else {
|
||||
retrunSheetDataList = excelSheetDataList;
|
||||
|
||||
@ -26,10 +26,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
@ -55,11 +52,11 @@ public class DataSetTableTaskService {
|
||||
public DatasetTableTask save(DataSetTaskRequest dataSetTaskRequest) throws Exception {
|
||||
checkName(dataSetTaskRequest);
|
||||
DatasetTableTask datasetTableTask = dataSetTaskRequest.getDatasetTableTask();
|
||||
if(datasetTableTask.getType().equalsIgnoreCase("add_scope")){
|
||||
if (datasetTableTask.getType().equalsIgnoreCase("add_scope")) {
|
||||
dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig());
|
||||
}
|
||||
// check
|
||||
if (!StringUtils.equalsIgnoreCase(datasetTableTask.getRate(), ScheduleType.SIMPLE.toString())){
|
||||
if (!StringUtils.equalsIgnoreCase(datasetTableTask.getRate(), ScheduleType.SIMPLE.toString())) {
|
||||
if (StringUtils.isNotEmpty(datasetTableTask.getCron())) {
|
||||
if (!CronExpression.isValidExpression(datasetTableTask.getCron())) {
|
||||
throw new RuntimeException(Translator.get("i18n_cron_expression_error"));
|
||||
@ -79,9 +76,9 @@ public class DataSetTableTaskService {
|
||||
if (StringUtils.isEmpty(datasetTableTask.getId())) {
|
||||
datasetTableTask.setId(UUID.randomUUID().toString());
|
||||
datasetTableTask.setCreateTime(System.currentTimeMillis());
|
||||
if (StringUtils.equalsIgnoreCase(datasetTableTask.getRate(), ScheduleType.SIMPLE.toString())){
|
||||
if (StringUtils.equalsIgnoreCase(datasetTableTask.getRate(), ScheduleType.SIMPLE.toString())) {
|
||||
datasetTableTask.setStatus(TaskStatus.Exec.name());
|
||||
}else {
|
||||
} else {
|
||||
datasetTableTask.setStatus(TaskStatus.Underway.name());
|
||||
}
|
||||
datasetTableTaskMapper.insert(datasetTableTask);
|
||||
@ -97,7 +94,7 @@ public class DataSetTableTaskService {
|
||||
// simple
|
||||
if (datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())) { // SIMPLE 类型,提前占位
|
||||
execNow(datasetTableTask);
|
||||
}else {
|
||||
} else {
|
||||
checkTaskIsStopped(datasetTableTask);
|
||||
}
|
||||
|
||||
@ -116,13 +113,13 @@ public class DataSetTableTaskService {
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized boolean existSyncTask(DatasetTable datasetTable, DatasetTableTask datasetTableTask) {
|
||||
private synchronized boolean existSyncTask(DatasetTable datasetTable, DatasetTableTask datasetTableTask) {
|
||||
datasetTable.setSyncStatus(JobStatus.Underway.name());
|
||||
DatasetTableExample example = new DatasetTableExample();
|
||||
example.createCriteria().andIdEqualTo(datasetTable.getId()).andSyncStatusNotEqualTo(JobStatus.Underway.name());
|
||||
example.or(example.createCriteria().andIdEqualTo(datasetTable.getId()).andSyncStatusIsNull());
|
||||
Boolean existSyncTask = datasetTableMapper.updateByExampleSelective(datasetTable, example) == 0;
|
||||
if(!existSyncTask){
|
||||
if (!existSyncTask) {
|
||||
Long startTime = System.currentTimeMillis();
|
||||
datasetTableTask.setLastExecTime(startTime);
|
||||
datasetTableTask.setLastExecStatus(JobStatus.Underway.name());
|
||||
@ -165,64 +162,65 @@ public class DataSetTableTaskService {
|
||||
}
|
||||
|
||||
public void updateTaskStatus(List<String> taskIds, JobStatus lastExecStatus) {
|
||||
if (CollectionUtils.isEmpty(taskIds)){
|
||||
if (CollectionUtils.isEmpty(taskIds)) {
|
||||
return;
|
||||
}
|
||||
DatasetTableTaskExample example = new DatasetTableTaskExample();
|
||||
example.createCriteria().andIdIn(taskIds);
|
||||
List<DatasetTableTask> datasetTableTasks = datasetTableTaskMapper.selectByExample(example);
|
||||
List<DatasetTableTask> datasetTableTasks = datasetTableTaskMapper.selectByExample(example);
|
||||
for (DatasetTableTask tableTask : datasetTableTasks) {
|
||||
updateTaskStatus(tableTask, lastExecStatus);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkTaskIsStopped(DatasetTableTask datasetTableTask){
|
||||
if(StringUtils.isNotEmpty(datasetTableTask.getEnd()) && datasetTableTask.getEnd().equalsIgnoreCase("1")){
|
||||
public void checkTaskIsStopped(DatasetTableTask datasetTableTask) {
|
||||
if (StringUtils.isNotEmpty(datasetTableTask.getEnd()) && datasetTableTask.getEnd().equalsIgnoreCase("1")) {
|
||||
BaseGridRequest request = new BaseGridRequest();
|
||||
ConditionEntity conditionEntity = new ConditionEntity();
|
||||
conditionEntity.setField("dataset_table_task.id");
|
||||
conditionEntity.setOperator("eq");
|
||||
conditionEntity.setValue(datasetTableTask.getId());
|
||||
request.setConditions(Arrays.asList(conditionEntity));
|
||||
request.setConditions(Collections.singletonList(conditionEntity));
|
||||
List<DataSetTaskDTO> dataSetTaskDTOS = taskWithTriggers(request);
|
||||
if(CollectionUtils.isEmpty(dataSetTaskDTOS)){
|
||||
if (CollectionUtils.isEmpty(dataSetTaskDTOS)) {
|
||||
return;
|
||||
}
|
||||
if(dataSetTaskDTOS.get(0).getNextExecTime() == null || dataSetTaskDTOS.get(0).getNextExecTime() <= 0){
|
||||
if (dataSetTaskDTOS.get(0).getNextExecTime() == null || dataSetTaskDTOS.get(0).getNextExecTime() <= 0) {
|
||||
datasetTableTask.setStatus(TaskStatus.Stopped.name());
|
||||
update(datasetTableTask);
|
||||
return;
|
||||
}
|
||||
if(dataSetTaskDTOS.get(0).getNextExecTime() > datasetTableTask.getEndTime()){
|
||||
if (dataSetTaskDTOS.get(0).getNextExecTime() > datasetTableTask.getEndTime()) {
|
||||
datasetTableTask.setStatus(TaskStatus.Stopped.name());
|
||||
update(datasetTableTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void updateTaskStatus(DatasetTableTask datasetTableTask, JobStatus lastExecStatus){
|
||||
|
||||
public void updateTaskStatus(DatasetTableTask datasetTableTask, JobStatus lastExecStatus) {
|
||||
datasetTableTask.setLastExecStatus(lastExecStatus.name());
|
||||
if(datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.name())){
|
||||
if (datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.name())) {
|
||||
datasetTableTask.setStatus(TaskStatus.Stopped.name());
|
||||
}else {
|
||||
} else {
|
||||
datasetTableTask = datasetTableTaskMapper.selectByPrimaryKey(datasetTableTask.getId());
|
||||
datasetTableTask.setLastExecStatus(lastExecStatus.name());
|
||||
if(StringUtils.isNotEmpty(datasetTableTask.getEnd()) && datasetTableTask.getEnd().equalsIgnoreCase("1")){
|
||||
if (StringUtils.isNotEmpty(datasetTableTask.getEnd()) && datasetTableTask.getEnd().equalsIgnoreCase("1")) {
|
||||
BaseGridRequest request = new BaseGridRequest();
|
||||
ConditionEntity conditionEntity = new ConditionEntity();
|
||||
conditionEntity.setField("dataset_table_task.id");
|
||||
conditionEntity.setOperator("eq");
|
||||
conditionEntity.setValue(datasetTableTask.getId());
|
||||
request.setConditions(Arrays.asList(conditionEntity));
|
||||
request.setConditions(Collections.singletonList(conditionEntity));
|
||||
List<DataSetTaskDTO> dataSetTaskDTOS = taskWithTriggers(request);
|
||||
if(CollectionUtils.isEmpty(dataSetTaskDTOS)){
|
||||
if (CollectionUtils.isEmpty(dataSetTaskDTOS)) {
|
||||
return;
|
||||
}
|
||||
if(dataSetTaskDTOS.get(0).getNextExecTime() == null || dataSetTaskDTOS.get(0).getNextExecTime() <= 0){
|
||||
if (dataSetTaskDTOS.get(0).getNextExecTime() == null || dataSetTaskDTOS.get(0).getNextExecTime() <= 0) {
|
||||
datasetTableTask.setStatus(TaskStatus.Stopped.name());
|
||||
}else {
|
||||
} else {
|
||||
datasetTableTask.setStatus(TaskStatus.Underway.name());
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
datasetTableTask.setStatus(TaskStatus.Underway.name());
|
||||
}
|
||||
}
|
||||
@ -244,7 +242,7 @@ public class DataSetTableTaskService {
|
||||
}
|
||||
|
||||
public List<DataSetTaskDTO> taskList4User(BaseGridRequest request) {
|
||||
List<ConditionEntity> conditionEntities = request.getConditions() == null ? new ArrayList<>() : new ArrayList(request.getConditions());;
|
||||
List<ConditionEntity> conditionEntities = request.getConditions() == null ? new ArrayList<>() : new ArrayList(request.getConditions());
|
||||
ConditionEntity entity = new ConditionEntity();
|
||||
entity.setField("1");
|
||||
entity.setOperator("eq");
|
||||
@ -253,19 +251,16 @@ public class DataSetTableTaskService {
|
||||
request.setConditions(conditionEntities);
|
||||
GridExample gridExample = request.convertExample();
|
||||
gridExample.setExtendCondition(AuthUtils.getUser().getUserId().toString());
|
||||
if(AuthUtils.getUser().getIsAdmin()){
|
||||
List<DataSetTaskDTO> dataSetTaskDTOS = extDataSetTaskMapper.taskList(gridExample);
|
||||
return dataSetTaskDTOS;
|
||||
}else {
|
||||
List<DataSetTaskDTO> dataSetTaskDTOS = extDataSetTaskMapper.userTaskList(gridExample);
|
||||
return dataSetTaskDTOS;
|
||||
if (AuthUtils.getUser().getIsAdmin()) {
|
||||
return extDataSetTaskMapper.taskList(gridExample);
|
||||
} else {
|
||||
return extDataSetTaskMapper.userTaskList(gridExample);
|
||||
}
|
||||
}
|
||||
|
||||
public List<DataSetTaskDTO> taskWithTriggers(BaseGridRequest request) {
|
||||
GridExample gridExample = request.convertExample();
|
||||
List<DataSetTaskDTO> dataSetTaskDTOS = extDataSetTaskMapper.taskWithTriggers(gridExample);
|
||||
return dataSetTaskDTOS;
|
||||
return extDataSetTaskMapper.taskWithTriggers(gridExample);
|
||||
}
|
||||
|
||||
private void checkName(DataSetTaskRequest dataSetTaskRequest) {
|
||||
@ -286,10 +281,10 @@ public class DataSetTableTaskService {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDatasetTableTaskStatus(DatasetTableTask datasetTableTask)throws Exception{
|
||||
public void updateDatasetTableTaskStatus(DatasetTableTask datasetTableTask) throws Exception {
|
||||
|
||||
DatasetTableTask dbDatasetTableTask = datasetTableTaskMapper.selectByPrimaryKey(datasetTableTask.getId());
|
||||
if(dbDatasetTableTask.getStatus().equalsIgnoreCase(TaskStatus.Exec.name()) || dbDatasetTableTask.getStatus().equals(TaskStatus.Stopped.name())){
|
||||
if (dbDatasetTableTask.getStatus().equalsIgnoreCase(TaskStatus.Exec.name()) || dbDatasetTableTask.getStatus().equals(TaskStatus.Stopped.name())) {
|
||||
throw new Exception(Translator.get("i18n_change_task_status_error") + Translator.get("i18n_" + dbDatasetTableTask.getStatus()));
|
||||
}
|
||||
|
||||
@ -301,9 +296,9 @@ public class DataSetTableTaskService {
|
||||
datasetTableTaskMapper.updateByExampleSelective(record, datasetTableTaskExample);
|
||||
}
|
||||
|
||||
public void execTask(DatasetTableTask datasetTableTask) throws Exception{
|
||||
public void execTask(DatasetTableTask datasetTableTask) throws Exception {
|
||||
execNow(datasetTableTask);
|
||||
if(!datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())){
|
||||
if (!datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())) {
|
||||
scheduleService.fireNow(datasetTableTask);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,11 +93,11 @@ public class ExtractDataService {
|
||||
@Resource
|
||||
private ExtChartViewMapper extChartViewMapper;
|
||||
|
||||
private static String lastUpdateTime = "${__last_update_time__}";
|
||||
private static String currentUpdateTime = "${__current_update_time__}";
|
||||
private static String separator = "|DE|";
|
||||
private static String extention = "txt";
|
||||
private static String root_path = "/opt/dataease/data/kettle/";
|
||||
private static final String lastUpdateTime = "${__last_update_time__}";
|
||||
private static final String currentUpdateTime = "${__current_update_time__}";
|
||||
private static final String separator = "|DE|";
|
||||
private static final String extention = "txt";
|
||||
private static final String root_path = "/opt/dataease/data/kettle/";
|
||||
|
||||
@Value("${kettle.files.keep:false}")
|
||||
private boolean kettleFilesKeep;
|
||||
@ -109,14 +109,14 @@ public class ExtractDataService {
|
||||
private String user;
|
||||
@Value("${carte.passwd:cluster}")
|
||||
private String passwd;
|
||||
private static String creatTableSql = "CREATE TABLE IF NOT EXISTS `TABLE_NAME`" +
|
||||
private static final String creatTableSql = "CREATE TABLE IF NOT EXISTS `TABLE_NAME`" +
|
||||
"Column_Fields" +
|
||||
"UNIQUE KEY(dataease_uuid)\n" +
|
||||
"DISTRIBUTED BY HASH(dataease_uuid) BUCKETS 10\n" +
|
||||
"PROPERTIES(\"replication_num\" = \"1\");";
|
||||
|
||||
private static String dropTableSql = "DROP TABLE IF EXISTS TABLE_NAME;";
|
||||
private static String shellScript = "result=`curl --location-trusted -u %s:%s -H \"label:%s\" -H \"column_separator:%s\" -H \"columns:%s\" -H \"merge_type: %s\" -T %s -XPUT http://%s:%s/api/%s/%s/_stream_load`\n" +
|
||||
private static final String dropTableSql = "DROP TABLE IF EXISTS TABLE_NAME;";
|
||||
private static final String shellScript = "result=`curl --location-trusted -u %s:%s -H \"label:%s\" -H \"column_separator:%s\" -H \"columns:%s\" -H \"merge_type: %s\" -T %s -XPUT http://%s:%s/api/%s/%s/_stream_load`\n" +
|
||||
"if [ $? == 0 ] ; then\n" +
|
||||
" failstatus=$(echo $result | grep '\"Status\": \"Fail\"')\n" +
|
||||
" if [[ \"$failstatus\" != \"\" ]]; then\n" +
|
||||
@ -133,17 +133,14 @@ public class ExtractDataService {
|
||||
DatasetTableExample example = new DatasetTableExample();
|
||||
example.createCriteria().andIdEqualTo(datasetTable.getId()).andSyncStatusNotEqualTo(JobStatus.Underway.name());
|
||||
example.or(example.createCriteria().andIdEqualTo(datasetTable.getId()).andSyncStatusIsNull());
|
||||
Boolean existSyncTask = datasetTableMapper.updateByExampleSelective(datasetTable, example) == 0;
|
||||
boolean existSyncTask = datasetTableMapper.updateByExampleSelective(datasetTable, example) == 0;
|
||||
if (existSyncTask) {
|
||||
DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog();
|
||||
datasetTableTaskLog.setTaskId(datasetTableTask.getId());
|
||||
datasetTableTaskLog.setTableId(datasetTable.getId());
|
||||
datasetTableTaskLog.setStatus(JobStatus.Underway.name());
|
||||
List<DatasetTableTaskLog> datasetTableTaskLogs = dataSetTableTaskLogService.select(datasetTableTaskLog);
|
||||
if (CollectionUtils.isNotEmpty(datasetTableTaskLogs) && datasetTableTaskLogs.get(0).getTriggerType().equalsIgnoreCase(TriggerType.Custom.name())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !CollectionUtils.isNotEmpty(datasetTableTaskLogs) || !datasetTableTaskLogs.get(0).getTriggerType().equalsIgnoreCase(TriggerType.Custom.name());
|
||||
} else {
|
||||
datasetTableTask.setLastExecTime(startTime);
|
||||
datasetTableTask.setLastExecStatus(JobStatus.Underway.name());
|
||||
@ -162,7 +159,7 @@ public class ExtractDataService {
|
||||
return;
|
||||
}
|
||||
UpdateType updateType = UpdateType.valueOf(type);
|
||||
DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog();
|
||||
DatasetTableTaskLog datasetTableTaskLog;
|
||||
if(datasetTableFields == null){
|
||||
datasetTableFields = dataSetTableFieldsService.list(DatasetTableField.builder().tableId(datasetTable.getId()).build());
|
||||
}
|
||||
@ -176,25 +173,23 @@ public class ExtractDataService {
|
||||
}
|
||||
return o1.getColumnIndex().compareTo(o2.getColumnIndex());
|
||||
});
|
||||
String dorisTablColumnSql = createDorisTablColumnSql(datasetTableFields);
|
||||
String dorisTableColumnSql = createDorisTableColumnSql(datasetTableFields);
|
||||
switch (updateType) {
|
||||
case all_scope: // 全量更新
|
||||
try {
|
||||
datasetTableTaskLog = writeDatasetTableTaskLog(datasetTableId, ops);
|
||||
createDorisTable(DorisTableUtils.dorisName(datasetTableId), dorisTablColumnSql);
|
||||
createDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId)), dorisTablColumnSql);
|
||||
createDorisTable(DorisTableUtils.dorisName(datasetTableId), dorisTableColumnSql);
|
||||
createDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId)), dorisTableColumnSql);
|
||||
generateTransFile("all_scope", datasetTable, datasource, datasetTableFields, null);
|
||||
generateJobFile("all_scope", datasetTable, String.join(",", datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.toList())));
|
||||
generateJobFile("all_scope", datasetTable, datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.joining(",")));
|
||||
Long execTime = System.currentTimeMillis();
|
||||
extractData(datasetTable, "all_scope");
|
||||
replaceTable(DorisTableUtils.dorisName(datasetTableId));
|
||||
saveSucessLog(datasetTableTaskLog);
|
||||
saveSuccessLog(datasetTableTaskLog);
|
||||
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime);
|
||||
if(ops.equalsIgnoreCase("替换")){
|
||||
dataSetTableFieldsService.deleteByTableId(datasetTable.getId());
|
||||
datasetTableFields.forEach(datasetTableField -> {
|
||||
dataSetTableFieldsService.save(datasetTableField);
|
||||
});
|
||||
datasetTableFields.forEach(datasetTableField -> dataSetTableFieldsService.save(datasetTableField));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
saveErrorLog(datasetTableId, null, e);
|
||||
@ -212,10 +207,10 @@ public class ExtractDataService {
|
||||
try {
|
||||
datasetTableTaskLog = writeDatasetTableTaskLog(datasetTableId, ops);
|
||||
generateTransFile("incremental_add", datasetTable, datasource, datasetTableFields, null);
|
||||
generateJobFile("incremental_add", datasetTable, String.join(",", datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.toList())));
|
||||
generateJobFile("incremental_add", datasetTable, datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.joining(",")));
|
||||
Long execTime = System.currentTimeMillis();
|
||||
extractData(datasetTable, "incremental_add");
|
||||
saveSucessLog(datasetTableTaskLog);
|
||||
saveSuccessLog(datasetTableTaskLog);
|
||||
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, execTime);
|
||||
} catch (Exception e) {
|
||||
saveErrorLog(datasetTableId, null, e);
|
||||
@ -232,9 +227,7 @@ public class ExtractDataService {
|
||||
//侵入式清除下属视图缓存
|
||||
List<String> viewIds = extChartViewMapper.allViewIds(datasetTableId);
|
||||
if (CollectionUtils.isNotEmpty(viewIds)) {
|
||||
viewIds.forEach(viewId -> {
|
||||
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, viewId);
|
||||
});
|
||||
viewIds.forEach(viewId -> CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, viewId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,7 +249,7 @@ public class ExtractDataService {
|
||||
|
||||
Long startTime = System.currentTimeMillis();
|
||||
if (existSyncTask(datasetTable, datasetTableTask, startTime)) {
|
||||
LogUtil.info("Skip synchronization task for dataset due to exist other synctask, dataset ID : " + datasetTableId);
|
||||
LogUtil.info("Skip synchronization task for dataset due to exist others, dataset ID : " + datasetTableId);
|
||||
return;
|
||||
}
|
||||
DatasetTableTaskLog datasetTableTaskLog = getDatasetTableTaskLog(datasetTableId, taskId, startTime);
|
||||
@ -282,7 +275,7 @@ public class ExtractDataService {
|
||||
}
|
||||
return o1.getColumnIndex().compareTo(o2.getColumnIndex());
|
||||
});
|
||||
String dorisTablColumnSql = createDorisTablColumnSql(datasetTableFields);
|
||||
String dorisTableColumnSql = createDorisTableColumnSql(datasetTableFields);
|
||||
|
||||
boolean msg = false;
|
||||
JobStatus lastExecStatus = JobStatus.Completed;
|
||||
@ -290,21 +283,14 @@ public class ExtractDataService {
|
||||
switch (updateType) {
|
||||
case all_scope: // 全量更新
|
||||
try {
|
||||
if (datasetTableTask == null ) {
|
||||
datasetTableTaskLog = writeDatasetTableTaskLog(datasetTableId, taskId);
|
||||
}
|
||||
createDorisTable(DorisTableUtils.dorisName(datasetTableId), dorisTablColumnSql);
|
||||
createDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId)), dorisTablColumnSql);
|
||||
createDorisTable(DorisTableUtils.dorisName(datasetTableId), dorisTableColumnSql);
|
||||
createDorisTable(DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTableId)), dorisTableColumnSql);
|
||||
generateTransFile("all_scope", datasetTable, datasource, datasetTableFields, null);
|
||||
if (datasetTable.getType().equalsIgnoreCase("sql")) {
|
||||
generateJobFile("all_scope", datasetTable, String.join(",", datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.toList())));
|
||||
} else {
|
||||
generateJobFile("all_scope", datasetTable, String.join(",", datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.toList())));
|
||||
}
|
||||
generateJobFile("all_scope", datasetTable, datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.joining(",")));
|
||||
execTime = System.currentTimeMillis();
|
||||
extractData(datasetTable, "all_scope");
|
||||
replaceTable(DorisTableUtils.dorisName(datasetTableId));
|
||||
saveSucessLog(datasetTableTaskLog);
|
||||
saveSuccessLog(datasetTableTaskLog);
|
||||
msg = true;
|
||||
lastExecStatus = JobStatus.Completed;
|
||||
} catch (Exception e) {
|
||||
@ -331,11 +317,6 @@ public class ExtractDataService {
|
||||
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (datasetTableTask == null ) {
|
||||
datasetTableTaskLog = writeDatasetTableTaskLog(datasetTableId, taskId);
|
||||
}
|
||||
|
||||
if (datasetTable.getLastUpdateTime() == null || datasetTable.getLastUpdateTime() == 0) {
|
||||
updateTableStatus(datasetTableId, datasetTable, JobStatus.Completed, null);
|
||||
saveErrorLog(datasetTableId, taskId, new Exception("未进行全量同步"));
|
||||
@ -359,7 +340,7 @@ public class ExtractDataService {
|
||||
generateJobFile("incremental_delete", datasetTable, fetchSqlField(sql, datasource));
|
||||
extractData(datasetTable, "incremental_delete");
|
||||
}
|
||||
saveSucessLog(datasetTableTaskLog);
|
||||
saveSuccessLog(datasetTableTaskLog);
|
||||
|
||||
msg = true;
|
||||
lastExecStatus = JobStatus.Completed;
|
||||
@ -379,9 +360,7 @@ public class ExtractDataService {
|
||||
//侵入式清除下属视图缓存
|
||||
List<String> viewIds = extChartViewMapper.allViewIds(datasetTableId);
|
||||
if (CollectionUtils.isNotEmpty(viewIds)) {
|
||||
viewIds.forEach(viewId -> {
|
||||
CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, viewId);
|
||||
});
|
||||
viewIds.forEach(viewId -> CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, viewId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -423,7 +402,7 @@ public class ExtractDataService {
|
||||
datasetTableMapper.updateByExampleSelective(datasetTable, example);
|
||||
}
|
||||
|
||||
private void saveSucessLog(DatasetTableTaskLog datasetTableTaskLog) {
|
||||
private void saveSuccessLog(DatasetTableTaskLog datasetTableTaskLog) {
|
||||
datasetTableTaskLog.setStatus(JobStatus.Completed.name());
|
||||
datasetTableTaskLog.setEndTime(System.currentTimeMillis());
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
@ -448,48 +427,48 @@ public class ExtractDataService {
|
||||
|
||||
}
|
||||
|
||||
private String createDorisTablColumnSql(final List<DatasetTableField> datasetTableFields) {
|
||||
String Column_Fields = "dataease_uuid varchar(50), `";
|
||||
private String createDorisTableColumnSql(final List<DatasetTableField> datasetTableFields) {
|
||||
StringBuilder Column_Fields = new StringBuilder("dataease_uuid varchar(50), `");
|
||||
for (DatasetTableField datasetTableField : datasetTableFields) {
|
||||
Column_Fields = Column_Fields + datasetTableField.getDataeaseName() + "` ";
|
||||
Column_Fields.append(datasetTableField.getDataeaseName()).append("` ");
|
||||
Integer size = datasetTableField.getSize() * 3;
|
||||
if (datasetTableField.getSize() == 0 || datasetTableField.getSize() > 65533 || datasetTableField.getSize() * 3 > 65533) {
|
||||
size = 65533;
|
||||
}
|
||||
switch (datasetTableField.getDeExtractType()) {
|
||||
case 0:
|
||||
Column_Fields = Column_Fields + "varchar(lenth)".replace("lenth", String.valueOf(size)) + ",`";
|
||||
Column_Fields.append("varchar(length)".replace("length", String.valueOf(size))).append(",`");
|
||||
break;
|
||||
case 1:
|
||||
size = size < 50? 50 : size;
|
||||
Column_Fields = Column_Fields + "varchar(lenth)".replace("lenth", String.valueOf(size)) + ",`";
|
||||
Column_Fields.append("varchar(length)".replace("length", String.valueOf(size))).append(",`");
|
||||
break;
|
||||
case 2:
|
||||
Column_Fields = Column_Fields + "bigint" + ",`";
|
||||
Column_Fields.append("bigint").append(",`");
|
||||
break;
|
||||
case 3:
|
||||
Column_Fields = Column_Fields + "DOUBLE" + ",`";
|
||||
Column_Fields.append("DOUBLE").append(",`");
|
||||
break;
|
||||
case 4:
|
||||
Column_Fields = Column_Fields + "TINYINT(lenth)".replace("lenth", String.valueOf(size)) + ",`";
|
||||
Column_Fields.append("TINYINT(length)".replace("length", String.valueOf(size))).append(",`");
|
||||
break;
|
||||
default:
|
||||
Column_Fields = Column_Fields + "varchar(lenth)".replace("lenth", String.valueOf(size)) + ",`";
|
||||
Column_Fields.append("varchar(length)".replace("length", String.valueOf(size))).append(",`");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Column_Fields = Column_Fields.substring(0, Column_Fields.length() - 2);
|
||||
Column_Fields = "(" + Column_Fields + ")\n";
|
||||
return Column_Fields;
|
||||
Column_Fields = new StringBuilder(Column_Fields.substring(0, Column_Fields.length() - 2));
|
||||
Column_Fields = new StringBuilder("(" + Column_Fields + ")\n");
|
||||
return Column_Fields.toString();
|
||||
}
|
||||
|
||||
private void createDorisTable(String dorisTableName, String dorisTablColumnSql) throws Exception {
|
||||
private void createDorisTable(String dorisTableName, String dorisTableColumnSql) throws Exception {
|
||||
Datasource dorisDatasource = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
|
||||
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(dorisDatasource);
|
||||
datasourceRequest.setQuery(creatTableSql.replace("TABLE_NAME", dorisTableName).replace("Column_Fields", dorisTablColumnSql));
|
||||
datasourceRequest.setQuery(creatTableSql.replace("TABLE_NAME", dorisTableName).replace("Column_Fields", dorisTableColumnSql));
|
||||
jdbcProvider.exec(datasourceRequest);
|
||||
}
|
||||
|
||||
@ -508,7 +487,6 @@ public class ExtractDataService {
|
||||
private void replaceTable(String dorisTableName) throws Exception {
|
||||
Datasource dorisDatasource = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
|
||||
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
|
||||
;
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(dorisDatasource);
|
||||
datasourceRequest.setQuery("ALTER TABLE DORIS_TABLE REPLACE WITH TABLE DORIS_TMP_TABLE PROPERTIES('swap' = 'false');".replace("DORIS_TABLE", dorisTableName).replace("DORIS_TMP_TABLE", DorisTableUtils.dorisTmpName(dorisTableName)));
|
||||
@ -644,31 +622,27 @@ public class ExtractDataService {
|
||||
return remoteSlaveServer;
|
||||
}
|
||||
|
||||
private void generateJobFile(String extractType, DatasetTable datasetTable, String columnFeilds) throws Exception {
|
||||
String outFile = null;
|
||||
private void generateJobFile(String extractType, DatasetTable datasetTable, String columnFields) throws Exception {
|
||||
String outFile;
|
||||
String jobName = null;
|
||||
String script = null;
|
||||
Datasource dorisDatasource = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
|
||||
DorisConfiguration dorisConfiguration = new Gson().fromJson(dorisDatasource.getConfiguration(), DorisConfiguration.class);
|
||||
String columns = columnFeilds + ",dataease_uuid";
|
||||
String transName = null;
|
||||
String columns = columnFields + ",dataease_uuid";
|
||||
switch (extractType) {
|
||||
case "all_scope":
|
||||
transName = "trans_" + DorisTableUtils.dorisName(datasetTable.getId());
|
||||
outFile = DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTable.getId()));
|
||||
jobName = "job_" + DorisTableUtils.dorisName(datasetTable.getId());
|
||||
script = String.format(shellScript, dorisConfiguration.getUsername(), dorisConfiguration.getPassword(), String.valueOf(System.currentTimeMillis()), separator, columns, "APPEND", root_path + outFile + "." + extention, dorisConfiguration.getHost(), dorisConfiguration.getHttpPort(), dorisConfiguration.getDataBase(), DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTable.getId())), root_path + outFile + "." + extention);
|
||||
script = String.format(shellScript, dorisConfiguration.getUsername(), dorisConfiguration.getPassword(), System.currentTimeMillis(), separator, columns, "APPEND", root_path + outFile + "." + extention, dorisConfiguration.getHost(), dorisConfiguration.getHttpPort(), dorisConfiguration.getDataBase(), DorisTableUtils.dorisTmpName(DorisTableUtils.dorisName(datasetTable.getId())), root_path + outFile + "." + extention);
|
||||
break;
|
||||
case "incremental_add":
|
||||
transName = "trans_add_" + DorisTableUtils.dorisName(datasetTable.getId());
|
||||
outFile = DorisTableUtils.dorisAddName(datasetTable.getId());
|
||||
jobName = "job_add_" + DorisTableUtils.dorisName(datasetTable.getId());
|
||||
script = String.format(shellScript, dorisConfiguration.getUsername(), dorisConfiguration.getPassword(), String.valueOf(System.currentTimeMillis()), separator, columns, "APPEND", root_path + outFile + "." + extention, dorisConfiguration.getHost(), dorisConfiguration.getHttpPort(), dorisConfiguration.getDataBase(), DorisTableUtils.dorisName(datasetTable.getId()), root_path + outFile + "." + extention);
|
||||
script = String.format(shellScript, dorisConfiguration.getUsername(), dorisConfiguration.getPassword(), System.currentTimeMillis(), separator, columns, "APPEND", root_path + outFile + "." + extention, dorisConfiguration.getHost(), dorisConfiguration.getHttpPort(), dorisConfiguration.getDataBase(), DorisTableUtils.dorisName(datasetTable.getId()), root_path + outFile + "." + extention);
|
||||
break;
|
||||
case "incremental_delete":
|
||||
transName = "trans_delete_" + DorisTableUtils.dorisName(datasetTable.getId());
|
||||
outFile = DorisTableUtils.dorisDeleteName(DorisTableUtils.dorisName(datasetTable.getId()));
|
||||
script = String.format(shellScript, dorisConfiguration.getUsername(), dorisConfiguration.getPassword(), String.valueOf(System.currentTimeMillis()), separator, columns, "DELETE", root_path + outFile + "." + extention, dorisConfiguration.getHost(), dorisConfiguration.getHttpPort(), dorisConfiguration.getDataBase(), DorisTableUtils.dorisName(datasetTable.getId()), root_path + outFile + "." + extention);
|
||||
script = String.format(shellScript, dorisConfiguration.getUsername(), dorisConfiguration.getPassword(), System.currentTimeMillis(), separator, columns, "DELETE", root_path + outFile + "." + extention, dorisConfiguration.getHost(), dorisConfiguration.getHttpPort(), dorisConfiguration.getDataBase(), DorisTableUtils.dorisName(datasetTable.getId()), root_path + outFile + "." + extention);
|
||||
jobName = "job_delete_" + DorisTableUtils.dorisName(datasetTable.getId());
|
||||
break;
|
||||
default:
|
||||
@ -725,23 +699,23 @@ public class ExtractDataService {
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
datasourceRequest.setQuery(qp.wrapSql(sql));
|
||||
List<String> dorisFileds = new ArrayList<>();
|
||||
List<String> dorisFields = new ArrayList<>();
|
||||
datasourceProvider.fetchResultField(datasourceRequest).stream().map(TableFiled::getFieldName).forEach(filed -> {
|
||||
dorisFileds.add(DorisTableUtils.columnName(filed));
|
||||
dorisFields.add(DorisTableUtils.columnName(filed));
|
||||
});
|
||||
return String.join(",", dorisFileds);
|
||||
return String.join(",", dorisFields);
|
||||
}
|
||||
|
||||
private void generateTransFile(String extractType, DatasetTable datasetTable, Datasource datasource, List<DatasetTableField> datasetTableFields, String selectSQL) throws Exception {
|
||||
TransMeta transMeta = new TransMeta();
|
||||
String outFile = null;
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasource.getType());
|
||||
DatabaseMeta dataMeta = null;
|
||||
DatabaseMeta dataMeta;
|
||||
StepMeta inputStep = null;
|
||||
StepMeta outputStep = null;
|
||||
StepMeta outputStep;
|
||||
StepMeta udjcStep = null;
|
||||
TransHopMeta hi1 = null;
|
||||
TransHopMeta hi2 = null;
|
||||
TransHopMeta hi1;
|
||||
TransHopMeta hi2;
|
||||
String transName = null;
|
||||
|
||||
switch (datasourceType) {
|
||||
@ -945,7 +919,7 @@ public class ExtractDataService {
|
||||
for(int i=0;i< datasetTableFields.size();i++){
|
||||
TextFileField textFileField = new TextFileField();
|
||||
textFileField.setName(datasetTableFields.get(i).getDataeaseName());
|
||||
if (datasetTableFields.get(i).getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
if (datasetTableFields.get(i).getDeExtractType().equals(DeTypeConstants.DE_TIME)) {
|
||||
textFileField.setType("String");
|
||||
textFileField.setFormat("yyyy-MM-dd HH:mm:ss");
|
||||
} else {
|
||||
@ -965,7 +939,7 @@ public class ExtractDataService {
|
||||
for(int i=0;i< datasetTableFields.size();i++){
|
||||
TextFileField textFileField = new TextFileField();
|
||||
textFileField.setName(datasetTableFields.get(i).getDataeaseName());
|
||||
if (datasetTableFields.get(i).getDeExtractType() == DeTypeConstants.DE_INT) {
|
||||
if (datasetTableFields.get(i).getDeExtractType().equals(DeTypeConstants.DE_INT)) {
|
||||
textFileField.setType("Integer");
|
||||
textFileField.setFormat("0");
|
||||
} else {
|
||||
@ -991,12 +965,12 @@ public class ExtractDataService {
|
||||
}
|
||||
|
||||
private StepMeta udjc(List<DatasetTableField> datasetTableFields, DatasourceTypes datasourceType) {
|
||||
String handleBinaryTypeCode = "";
|
||||
StringBuilder handleBinaryTypeCode = new StringBuilder();
|
||||
String excelCompletion = "";
|
||||
|
||||
for (DatasetTableField datasetTableField : datasetTableFields) {
|
||||
if(datasetTableField.getDeExtractType() == DeTypeConstants.DE_BINARY){
|
||||
handleBinaryTypeCode = handleBinaryTypeCode + "\n" + this.handleBinaryType.replace("FEILD", datasetTableField.getDataeaseName());
|
||||
if(datasetTableField.getDeExtractType().equals(DeTypeConstants.DE_BINARY)){
|
||||
handleBinaryTypeCode.append("\n").append(handleBinaryType.replace("FIELD", datasetTableField.getDataeaseName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1005,14 +979,14 @@ public class ExtractDataService {
|
||||
UserDefinedJavaClassMeta.FieldInfo fieldInfo = new UserDefinedJavaClassMeta.FieldInfo("dataease_uuid", ValueMetaInterface.TYPE_STRING, -1, -1);
|
||||
fields.add(fieldInfo);
|
||||
userDefinedJavaClassMeta.setFieldInfo(fields);
|
||||
List<UserDefinedJavaClassDef> definitions = new ArrayList<UserDefinedJavaClassDef>();
|
||||
String tmp_code = code.replace("handleWraps", handleWraps).replace("handleBinaryType", handleBinaryTypeCode);
|
||||
List<UserDefinedJavaClassDef> definitions = new ArrayList<>();
|
||||
String tmp_code = code.replace("handleWraps", handleWraps).replace("handleBinaryType", handleBinaryTypeCode.toString());
|
||||
|
||||
String Column_Fields = "";
|
||||
String Column_Fields;
|
||||
if (datasourceType.equals(DatasourceTypes.oracle)) {
|
||||
Column_Fields = String.join(",", datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList()));
|
||||
Column_Fields = datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.joining(","));
|
||||
} else {
|
||||
Column_Fields = String.join(",", datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.toList()));
|
||||
Column_Fields = datasetTableFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
if (datasourceType.equals(DatasourceTypes.excel)) {
|
||||
@ -1020,7 +994,7 @@ public class ExtractDataService {
|
||||
.replace("ExcelCompletion", excelCompletion);
|
||||
} else {
|
||||
tmp_code = tmp_code.replace("handleExcelIntColumn", "").replace("Column_Fields", Column_Fields)
|
||||
.replace("ExcelCompletion", "");;
|
||||
.replace("ExcelCompletion", "");
|
||||
}
|
||||
|
||||
UserDefinedJavaClassDef userDefinedJavaClassDef = new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "Processor", tmp_code);
|
||||
@ -1104,7 +1078,7 @@ public class ExtractDataService {
|
||||
}
|
||||
}
|
||||
|
||||
private final static String handleBinaryType = " \t\tif(\"FEILD\".equalsIgnoreCase(filed)){\n" +
|
||||
private final static String handleBinaryType = " \t\tif(\"FIELD\".equalsIgnoreCase(filed)){\n" +
|
||||
" get(Fields.Out, filed).setValue(r, \"\");\n" +
|
||||
" get(Fields.Out, filed).getValueMeta().setType(2);\n" +
|
||||
" \t}";
|
||||
@ -1124,11 +1098,6 @@ public class ExtractDataService {
|
||||
" get(Fields.Out, filed).setValue(r, tmp);\n" +
|
||||
" } \n";
|
||||
|
||||
private final static String excelCompletion = "\t\tif(tmp == null){\n" +
|
||||
" \t\t\ttmp = \"\";\n" +
|
||||
"\t\t\tget(Fields.Out, filed).setValue(r, tmp);\n" +
|
||||
"\t\t}";
|
||||
|
||||
private final static String code = "import org.pentaho.di.core.row.ValueMetaInterface;\n" +
|
||||
"import java.util.List;\n" +
|
||||
"import java.io.File;\n" +
|
||||
|
||||
@ -34,13 +34,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -67,7 +61,6 @@ public class DatasourceService {
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
datasourceMapper.insertSelective(datasource);
|
||||
handleConnectionPool(datasource, "add");
|
||||
|
||||
return datasource;
|
||||
}
|
||||
|
||||
@ -126,7 +119,7 @@ public class DatasourceService {
|
||||
conditionEntity.setField("1");
|
||||
conditionEntity.setOperator("eq");
|
||||
conditionEntity.setValue("1");
|
||||
request.setConditions(Arrays.asList(conditionEntity));
|
||||
request.setConditions(Collections.singletonList(conditionEntity));
|
||||
}
|
||||
GridExample gridExample = request.convertExample();
|
||||
gridExample.setExtendCondition(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
@ -263,9 +256,7 @@ public class DatasourceService {
|
||||
|
||||
public void updateDatasourceStatus(){
|
||||
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
|
||||
datasources.forEach(datasource -> {
|
||||
checkAndUpdateDatasourceStatus(datasource, true);
|
||||
});
|
||||
datasources.forEach(datasource -> checkAndUpdateDatasourceStatus(datasource, true));
|
||||
}
|
||||
|
||||
private void checkAndUpdateDatasourceStatus(Datasource datasource){
|
||||
@ -299,9 +290,7 @@ public class DatasourceService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void sendWebMsg(Datasource datasource) {
|
||||
|
||||
String id = datasource.getId();
|
||||
AuthURD authURD = AuthUtils.authURDR(id);
|
||||
Set<Long> userIds = AuthUtils.userIdsByURD(authURD);
|
||||
@ -311,10 +300,7 @@ public class DatasourceService {
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("id", id);
|
||||
param.put("name", datasource.getName());
|
||||
|
||||
|
||||
String content = "数据源【" + datasource.getName() + "】无效";
|
||||
|
||||
DeMsgutil.sendMsg(userId, typeId, content, gson.toJson(param));
|
||||
});
|
||||
}
|
||||
|
||||
@ -7,8 +7,6 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class DeMsgutil {
|
||||
|
||||
|
||||
|
||||
private static SysMsgService sysMsgService;
|
||||
|
||||
@Autowired
|
||||
@ -16,8 +14,6 @@ public class DeMsgutil {
|
||||
DeMsgutil.sysMsgService = sysMsgService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void sendMsg(Long userId, Long typeId, String content, String param) {
|
||||
|
||||
sysMsgService.sendMsg(userId, typeId, content, param);
|
||||
|
||||
@ -42,11 +42,9 @@ public class SysMsgService {
|
||||
@Resource
|
||||
private ExtSysMsgMapper extSysMsgMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
private SysMsgTypeMapper sysMsgTypeMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
private SysMsgChannelMapper sysMsgChannelMapper;
|
||||
|
||||
@ -79,8 +77,7 @@ public class SysMsgService {
|
||||
criteria.andCreateTimeGreaterThanOrEqualTo(startTime);
|
||||
|
||||
example.setOrderByClause(orderClause);
|
||||
List<MsgGridDto> msgGridDtos = extSysMsgMapper.queryGrid(example);
|
||||
return msgGridDtos;
|
||||
return extSysMsgMapper.queryGrid(example);
|
||||
}
|
||||
|
||||
public Long queryCount(Long userId) {
|
||||
@ -121,8 +118,7 @@ public class SysMsgService {
|
||||
@Cacheable(SysMsgConstants.SYS_MSG_TYPE)
|
||||
public List<SysMsgType> queryMsgTypes() {
|
||||
SysMsgTypeExample example = new SysMsgTypeExample();
|
||||
List<SysMsgType> sysMsgTypes = sysMsgTypeMapper.selectByExample(example);
|
||||
return sysMsgTypes;
|
||||
return sysMsgTypeMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
private List<SettingTreeNode> buildTree(List<SysMsgType> lists){
|
||||
@ -133,9 +129,9 @@ public class SysMsgService {
|
||||
rootNodes.add(settingTreeNode);
|
||||
}
|
||||
lists.forEach(tNode -> {
|
||||
if (tNode.getPid() == settingTreeNode.getId()) {
|
||||
if (tNode.getPid().equals(settingTreeNode.getId())) {
|
||||
if (settingTreeNode.getChildren() == null) {
|
||||
settingTreeNode.setChildren(new ArrayList<SettingTreeNode>());
|
||||
settingTreeNode.setChildren(new ArrayList<>());
|
||||
}
|
||||
settingTreeNode.getChildren().add(convert(tNode));
|
||||
}
|
||||
@ -246,7 +242,7 @@ public class SysMsgService {
|
||||
List<SubscribeNode> subscribes = subscribes(userId);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(subscribes)) {
|
||||
subscribes.stream().filter(item -> item.getTypeId() == typeId).forEach(sub -> {
|
||||
subscribes.stream().filter(item -> item.getTypeId().equals(typeId)).forEach(sub -> {
|
||||
SendService sendService = serviceByChannel(sub.getChannelId());
|
||||
sendService.sendMsg(userId, typeId, content, param);
|
||||
});
|
||||
@ -273,13 +269,12 @@ public class SysMsgService {
|
||||
// 添加默认订阅
|
||||
sysMsgSettings = addDefault(sysMsgSettings);
|
||||
sysMsgSettings = sysMsgSettings.stream().filter(SysMsgSetting::getEnable).collect(Collectors.toList());
|
||||
List<SubscribeNode> resultLists = sysMsgSettings.stream().map(item -> {
|
||||
return sysMsgSettings.stream().map(item -> {
|
||||
SubscribeNode subscribeNode = new SubscribeNode();
|
||||
subscribeNode.setTypeId(item.getTypeId());
|
||||
subscribeNode.setChannelId(item.getChannelId());
|
||||
return subscribeNode;
|
||||
}).collect(Collectors.toList());
|
||||
return resultLists;
|
||||
}
|
||||
|
||||
public List<SysMsgSetting> addDefault(List<SysMsgSetting> sourceLists) {
|
||||
@ -301,7 +296,6 @@ public class SysMsgService {
|
||||
sysMsgMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
|
||||
public Long overTime() {
|
||||
String msgTimeOut = systemParameterService.basicInfo().getMsgTimeOut();
|
||||
if(StringUtils.isNotBlank(msgTimeOut)) {
|
||||
|
||||
@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -36,7 +37,7 @@ import java.util.UUID;
|
||||
@Service
|
||||
public class PanelGroupService {
|
||||
|
||||
private Logger LOGGER = LoggerFactory.getLogger(this.getClass());
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource
|
||||
private PanelGroupMapper panelGroupMapper;
|
||||
@ -64,25 +65,23 @@ public class PanelGroupService {
|
||||
String userId = String.valueOf(AuthUtils.getUser().getUserId());
|
||||
panelGroupRequest.setUserId(userId);
|
||||
List<PanelGroupDTO> panelGroupDTOList = extPanelGroupMapper.panelGroupList(panelGroupRequest);
|
||||
List<PanelGroupDTO> result = TreeUtils.mergeTree(panelGroupDTOList,"panel_list");
|
||||
return result;
|
||||
return TreeUtils.mergeTree(panelGroupDTOList, "panel_list");
|
||||
}
|
||||
|
||||
public List<PanelGroupDTO> defaultTree(PanelGroupRequest panelGroupRequest) {
|
||||
String userId = String.valueOf(AuthUtils.getUser().getUserId());
|
||||
panelGroupRequest.setUserId(userId);
|
||||
List<PanelGroupDTO> panelGroupDTOList = extPanelGroupMapper.panelGroupListDefault(panelGroupRequest);
|
||||
List<PanelGroupDTO> result = TreeUtils.mergeTree(panelGroupDTOList,"default_panel");
|
||||
return result;
|
||||
return TreeUtils.mergeTree(panelGroupDTOList, "default_panel");
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PanelGroup saveOrUpdate(PanelGroupRequest request) {
|
||||
try{
|
||||
try {
|
||||
panelViewService.syncPanelViews(request);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("更新panelView出错panelId:{}" ,request.getId());
|
||||
LOGGER.error("更新panelView出错panelId:{}", request.getId());
|
||||
}
|
||||
String panelId = request.getId();
|
||||
if (StringUtils.isEmpty(panelId)) {
|
||||
@ -107,7 +106,7 @@ public class PanelGroupService {
|
||||
newDefaultPanel.setCreateBy(AuthUtils.getUser().getUsername());
|
||||
checkPanelName(newDefaultPanel.getName(), newDefaultPanel.getPid(), PanelConstants.OPT_TYPE_INSERT, newDefaultPanel.getId());
|
||||
panelGroupMapper.insertSelective(newDefaultPanel);
|
||||
} else if ("copy".equals(request.getOptType())) {
|
||||
} else if ("copy".equals(request.getOptType())) {
|
||||
panelId = UUID.randomUUID().toString();
|
||||
// 复制模板
|
||||
PanelGroupWithBLOBs newPanel = panelGroupMapper.selectByPrimaryKey(request.getId());
|
||||
@ -120,15 +119,15 @@ public class PanelGroupService {
|
||||
newPanel.setCreateBy(AuthUtils.getUser().getUsername());
|
||||
panelGroupMapper.insertSelective(newPanel);
|
||||
|
||||
try{
|
||||
try {
|
||||
panelViewService.syncPanelViews(newPanel);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("更新panelView出错panelId:{}" ,request.getId());
|
||||
} }
|
||||
else if ("move".equals(request.getOptType())) {
|
||||
LOGGER.error("更新panelView出错panelId:{}", request.getId());
|
||||
}
|
||||
} else if ("move".equals(request.getOptType())) {
|
||||
PanelGroupWithBLOBs panelInfo = panelGroupMapper.selectByPrimaryKey(request.getId());
|
||||
if(panelInfo.getPid().equalsIgnoreCase(request.getPid())){
|
||||
if (panelInfo.getPid().equalsIgnoreCase(request.getPid())) {
|
||||
DataEaseException.throwException(Translator.get("i18n_select_diff_folder"));
|
||||
}
|
||||
// 移动校验
|
||||
@ -141,7 +140,7 @@ public class PanelGroupService {
|
||||
record.setPid(request.getPid());
|
||||
panelGroupMapper.updateByPrimaryKeySelective(record);
|
||||
|
||||
}else {
|
||||
} else {
|
||||
// 更新
|
||||
if (StringUtils.isNotEmpty(request.getName())) {
|
||||
checkPanelName(request.getName(), request.getPid(), PanelConstants.OPT_TYPE_UPDATE, request.getId());
|
||||
@ -149,16 +148,14 @@ public class PanelGroupService {
|
||||
panelGroupMapper.updateByPrimaryKeySelective(request);
|
||||
}
|
||||
|
||||
|
||||
//带有权限的返回
|
||||
PanelGroupRequest authRequest = new PanelGroupRequest();
|
||||
authRequest.setId(panelId);
|
||||
authRequest.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
List<PanelGroupDTO> panelGroupDTOList = extPanelGroupMapper.panelGroupList(authRequest);
|
||||
if(!CollectionUtils.isNotEmpty(panelGroupDTOList)){
|
||||
if (!CollectionUtils.isNotEmpty(panelGroupDTOList)) {
|
||||
DataEaseException.throwException("未查询到用户对应的资源权限,请尝试刷新重新保存");
|
||||
}
|
||||
|
||||
return panelGroupDTOList.get(0);
|
||||
}
|
||||
|
||||
@ -180,7 +177,7 @@ public class PanelGroupService {
|
||||
|
||||
public void deleteCircle(String id) {
|
||||
Assert.notNull(id, "id cannot be null");
|
||||
sysAuthService.checkTreeNoManageCount("panel",id);
|
||||
sysAuthService.checkTreeNoManageCount("panel", id);
|
||||
// 同时会删除对应默认仪表盘
|
||||
extPanelGroupMapper.deleteCircle(id);
|
||||
storeService.removeByPanelId(id);
|
||||
@ -196,17 +193,17 @@ public class PanelGroupService {
|
||||
|
||||
public PanelGroupWithBLOBs findOne(String panelId) {
|
||||
PanelGroupWithBLOBs panelGroupWithBLOBs = panelGroupMapper.selectByPrimaryKey(panelId);
|
||||
if(panelGroupWithBLOBs!=null&& StringUtils.isNotEmpty(panelGroupWithBLOBs.getSource())){
|
||||
return panelGroupMapper.selectByPrimaryKey(panelGroupWithBLOBs.getSource());
|
||||
if (panelGroupWithBLOBs != null && StringUtils.isNotEmpty(panelGroupWithBLOBs.getSource())) {
|
||||
return panelGroupMapper.selectByPrimaryKey(panelGroupWithBLOBs.getSource());
|
||||
}
|
||||
return panelGroupWithBLOBs;
|
||||
}
|
||||
|
||||
|
||||
public List<ChartViewDTO> getUsableViews(String panelId) throws Exception {
|
||||
public List<ChartViewDTO> getUsableViews() throws Exception {
|
||||
List<ChartViewDTO> chartViewDTOList = new ArrayList<>();
|
||||
List<ChartView> allChartView = chartViewMapper.selectByExample(null);
|
||||
Optional.ofNullable(allChartView).orElse(new ArrayList<>()).stream().forEach(chartView -> {
|
||||
Optional.ofNullable(allChartView).orElse(new ArrayList<>()).forEach(chartView -> {
|
||||
try {
|
||||
chartViewDTOList.add(chartViewService.getData(chartView.getId(), null));
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -1,14 +1,11 @@
|
||||
package io.dataease.service.panel;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.dataease.base.domain.DatasetTableField;
|
||||
import io.dataease.base.domain.PanelLinkJumpTargetViewInfo;
|
||||
import io.dataease.base.mapper.PanelLinkJumpInfoMapper;
|
||||
import io.dataease.base.mapper.PanelLinkJumpMapper;
|
||||
import io.dataease.base.mapper.PanelLinkJumpTargetViewInfoMapper;
|
||||
import io.dataease.base.mapper.ext.ExtPanelLinkJumpMapper;
|
||||
import io.dataease.base.mapper.ext.ExtPanelViewLinkageMapper;
|
||||
import io.dataease.dto.LinkageInfoDTO;
|
||||
import io.dataease.dto.panel.linkJump.PanelLinkJumpBaseRequest;
|
||||
import io.dataease.dto.panel.linkJump.PanelLinkJumpBaseResponse;
|
||||
import io.dataease.dto.panel.linkJump.PanelLinkJumpDTO;
|
||||
@ -17,7 +14,6 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
@ -52,8 +48,7 @@ public class PanelLinkJumpService {
|
||||
}
|
||||
|
||||
public List<PanelLinkJumpDTO> queryWithPanelId(String panelId) {
|
||||
List<PanelLinkJumpDTO> resultInfo = extPanelLinkJumpMapper.queryWithPanelId(panelId);
|
||||
return resultInfo;
|
||||
return extPanelLinkJumpMapper.queryWithPanelId(panelId);
|
||||
}
|
||||
|
||||
//获取仪表板的跳转信息
|
||||
@ -64,27 +59,26 @@ public class PanelLinkJumpService {
|
||||
if (resultLinkJump.getChecked()) {
|
||||
String sourceViewId = resultLinkJump.getSourceViewId();
|
||||
Optional.ofNullable(resultLinkJump.getLinkJumpInfoArray()).orElse(new ArrayList<>()).forEach(linkJumpInfo -> {
|
||||
if(linkJumpInfo.getChecked()){
|
||||
if (linkJumpInfo.getChecked()) {
|
||||
String sourceJumpInfo = sourceViewId + "#" + linkJumpInfo.getSourceFieldId();
|
||||
// 内部仪表板跳转 需要设置好仪表板ID
|
||||
if("inner".equals(linkJumpInfo.getLinkType())){
|
||||
if(StringUtils.isNotEmpty(linkJumpInfo.getTargetPanelId())){
|
||||
resultBase.put(sourceJumpInfo,linkJumpInfo);
|
||||
if ("inner".equals(linkJumpInfo.getLinkType())) {
|
||||
if (StringUtils.isNotEmpty(linkJumpInfo.getTargetPanelId())) {
|
||||
resultBase.put(sourceJumpInfo, linkJumpInfo);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
// 外部跳转
|
||||
resultBase.put(sourceJumpInfo,linkJumpInfo);
|
||||
resultBase.put(sourceJumpInfo, linkJumpInfo);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return new PanelLinkJumpBaseResponse(resultBase,null);
|
||||
return new PanelLinkJumpBaseResponse(resultBase, null);
|
||||
}
|
||||
|
||||
public PanelLinkJumpDTO queryWithView(String panelId, String viewId) {
|
||||
PanelLinkJumpDTO resultInfo = extPanelLinkJumpMapper.queryWithViewId(panelId, viewId);
|
||||
return resultInfo;
|
||||
return extPanelLinkJumpMapper.queryWithViewId(panelId, viewId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -116,9 +110,9 @@ public class PanelLinkJumpService {
|
||||
});
|
||||
}
|
||||
|
||||
public PanelLinkJumpBaseResponse queryTargetPanelJumpInfo(PanelLinkJumpBaseRequest request){
|
||||
public PanelLinkJumpBaseResponse queryTargetPanelJumpInfo(PanelLinkJumpBaseRequest request) {
|
||||
List<PanelLinkJumpDTO> result = extPanelLinkJumpMapper.getTargetPanelJumpInfo(request);
|
||||
return new PanelLinkJumpBaseResponse(null,Optional.ofNullable(result).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(PanelLinkJumpDTO::getSourceInfo,PanelLinkJumpDTO::getTargetInfoList)));
|
||||
return new PanelLinkJumpBaseResponse(null, Optional.ofNullable(result).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(PanelLinkJumpDTO::getSourceInfo, PanelLinkJumpDTO::getTargetInfoList)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package io.dataease.service.panel;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.auth.config.RsaProperties;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.auth.util.RsaUtil;
|
||||
@ -14,7 +12,6 @@ import io.dataease.base.mapper.PanelLinkMapper;
|
||||
import io.dataease.base.mapper.PanelLinkMappingMapper;
|
||||
import io.dataease.base.mapper.ext.ExtPanelLinkMapper;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.controller.request.panel.link.EnablePwdRequest;
|
||||
import io.dataease.controller.request.panel.link.LinkRequest;
|
||||
import io.dataease.controller.request.panel.link.OverTimeRequest;
|
||||
@ -23,53 +20,44 @@ import io.dataease.dto.panel.link.GenerateDto;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class PanelLinkService {
|
||||
|
||||
private static final String BASEURL = "/link.html?link=";
|
||||
|
||||
|
||||
|
||||
private static final String SHORT_URL_PREFIX = "/xggznb/";
|
||||
|
||||
@Resource
|
||||
private PanelLinkMapper mapper;
|
||||
|
||||
@Resource
|
||||
private PanelGroupMapper panelGroupMapper;
|
||||
|
||||
@Resource
|
||||
private ExtPanelLinkMapper extPanelLinkMapper;
|
||||
|
||||
@Resource
|
||||
private PanelLinkMappingMapper panelLinkMappingMapper;
|
||||
|
||||
public void changeValid(LinkRequest request){
|
||||
public void changeValid(LinkRequest request) {
|
||||
PanelLink po = new PanelLink();
|
||||
po.setResourceId(request.getResourceId());
|
||||
po.setValid(request.isValid());
|
||||
mapper.updateByPrimaryKeySelective(po);
|
||||
}
|
||||
|
||||
public void changeEnablePwd(EnablePwdRequest request){
|
||||
public void changeEnablePwd(EnablePwdRequest request) {
|
||||
PanelLink po = new PanelLink();
|
||||
po.setResourceId(request.getResourceId());
|
||||
po.setEnablePwd(request.isEnablePwd());
|
||||
mapper.updateByPrimaryKeySelective(po);
|
||||
}
|
||||
|
||||
public void password(PasswordRequest request){
|
||||
public void password(PasswordRequest request) {
|
||||
PanelLink po = new PanelLink();
|
||||
po.setResourceId(request.getResourceId());
|
||||
po.setPwd(request.getPassword());
|
||||
@ -77,13 +65,11 @@ public class PanelLinkService {
|
||||
}
|
||||
|
||||
public void overTime(OverTimeRequest request) {
|
||||
|
||||
extPanelLinkMapper.updateOverTime(request);
|
||||
}
|
||||
|
||||
public PanelLink findOne(String resourceId){
|
||||
PanelLink panelLink = mapper.selectByPrimaryKey(resourceId);
|
||||
return panelLink;
|
||||
public PanelLink findOne(String resourceId) {
|
||||
return mapper.selectByPrimaryKey(resourceId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -98,11 +84,10 @@ public class PanelLinkService {
|
||||
mapper.insert(one);
|
||||
}
|
||||
|
||||
|
||||
PanelLinkMappingExample example = new PanelLinkMappingExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId);
|
||||
List<PanelLinkMapping> mappings = panelLinkMappingMapper.selectByExample(example);
|
||||
if(CollectionUtils.isEmpty(mappings)) {
|
||||
if (CollectionUtils.isEmpty(mappings)) {
|
||||
PanelLinkMapping mapping = new PanelLinkMapping();
|
||||
mapping.setResourceId(resourceId);
|
||||
panelLinkMappingMapper.insert(mapping);
|
||||
@ -110,7 +95,7 @@ public class PanelLinkService {
|
||||
return convertDto(one);
|
||||
}
|
||||
|
||||
public void deleteByResourceId(String resourceId){
|
||||
public void deleteByResourceId(String resourceId) {
|
||||
mapper.deleteByPrimaryKey(resourceId);
|
||||
}
|
||||
|
||||
@ -128,24 +113,22 @@ public class PanelLinkService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildLinkParam(String resourceId){
|
||||
|
||||
String encrypt = encrypt(resourceId);
|
||||
|
||||
return encrypt;
|
||||
private String buildLinkParam(String resourceId) {
|
||||
return encrypt(resourceId);
|
||||
}
|
||||
private GenerateDto convertDto(PanelLink linl){
|
||||
|
||||
private GenerateDto convertDto(PanelLink link) {
|
||||
GenerateDto result = new GenerateDto();
|
||||
result.setValid(linl.getValid());
|
||||
result.setEnablePwd(linl.getEnablePwd());
|
||||
result.setPwd(linl.getPwd());
|
||||
result.setUri(BASEURL+buildLinkParam(linl.getResourceId()));
|
||||
result.setOverTime(linl.getOverTime());
|
||||
result.setValid(link.getValid());
|
||||
result.setEnablePwd(link.getEnablePwd());
|
||||
result.setPwd(link.getPwd());
|
||||
result.setUri(BASEURL + buildLinkParam(link.getResourceId()));
|
||||
result.setOverTime(link.getOverTime());
|
||||
return result;
|
||||
}
|
||||
|
||||
// 验证请求头部携带的信息 如果正确说明通过密码验证 否则没有通过
|
||||
public Boolean validateHeads(PanelLink panelLink) throws Exception{
|
||||
public Boolean validateHeads(PanelLink panelLink) throws Exception {
|
||||
HttpServletRequest request = ServletUtils.request();
|
||||
String token = request.getHeader("LINK-PWD-TOKEN");
|
||||
if (!panelLink.getEnablePwd() || StringUtils.isEmpty(token) || StringUtils.equals("undefined", token) || StringUtils.equals("null", token)) {
|
||||
@ -158,8 +141,7 @@ public class PanelLinkService {
|
||||
return false;
|
||||
}
|
||||
if (StringUtils.isEmpty(panelLink.getPwd())) return false;
|
||||
boolean verify = JWTUtils.verifyLink(token, panelLink.getResourceId(), panelLink.getPwd());
|
||||
return verify;
|
||||
return JWTUtils.verifyLink(token, panelLink.getResourceId(), panelLink.getPwd());
|
||||
}
|
||||
|
||||
// 验证链接是否过期
|
||||
@ -167,7 +149,7 @@ public class PanelLinkService {
|
||||
if (ObjectUtils.isEmpty(panelLink.getOverTime())) {
|
||||
return false;
|
||||
}
|
||||
return System.currentTimeMillis() > panelLink.getOverTime();
|
||||
return System.currentTimeMillis() > panelLink.getOverTime();
|
||||
}
|
||||
|
||||
public boolean validatePwd(PasswordRequest request) throws Exception {
|
||||
@ -176,7 +158,7 @@ public class PanelLinkService {
|
||||
PanelLink one = findOne(resourceId);
|
||||
String pwd = one.getPwd();
|
||||
boolean pass = StringUtils.equals(pwd, password);
|
||||
if (pass){
|
||||
if (pass) {
|
||||
String token = JWTUtils.signLink(resourceId, password);
|
||||
HttpServletResponse httpServletResponse = ServletUtils.response();
|
||||
httpServletResponse.addHeader("Access-Control-Expose-Headers", "LINK-PWD-TOKEN");
|
||||
@ -189,7 +171,6 @@ public class PanelLinkService {
|
||||
return panelGroupMapper.selectByPrimaryKey(resourceId);
|
||||
}
|
||||
|
||||
|
||||
public String getShortUrl(String resourceId) {
|
||||
PanelLinkMappingExample example = new PanelLinkMappingExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId);
|
||||
|
||||
@ -19,7 +19,7 @@ public class PanelPdfTemplateService {
|
||||
@Resource
|
||||
private PanelPdfTemplateMapper panelPdfTemplateMapper;
|
||||
|
||||
public List<PanelPdfTemplate> queryAll(){
|
||||
public List<PanelPdfTemplate> queryAll() {
|
||||
PanelPdfTemplateExample example = new PanelPdfTemplateExample();
|
||||
example.setOrderByClause("sort asc");
|
||||
return panelPdfTemplateMapper.selectByExampleWithBLOBs(example);
|
||||
|
||||
@ -6,15 +6,12 @@ import io.dataease.base.mapper.PanelSubjectMapper;
|
||||
import io.dataease.controller.request.panel.PanelSubjectRequest;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -26,60 +23,56 @@ import java.util.UUID;
|
||||
@Service
|
||||
public class PanelSubjectService {
|
||||
|
||||
private Logger LOGGER = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource
|
||||
private PanelSubjectMapper panelSubjectMapper;
|
||||
|
||||
public List<PanelSubject> query(PanelSubjectRequest request){
|
||||
public List<PanelSubject> query(PanelSubjectRequest request) {
|
||||
PanelSubjectExample example = new PanelSubjectExample();
|
||||
example.setOrderByClause( "create_time asc");
|
||||
example.setOrderByClause("create_time asc");
|
||||
return panelSubjectMapper.selectByExampleWithBLOBs(example);
|
||||
}
|
||||
|
||||
public List querySubjectWithGroup(PanelSubjectRequest request){
|
||||
public List querySubjectWithGroup(PanelSubjectRequest request) {
|
||||
List result = new ArrayList();
|
||||
int pageSize = 4;
|
||||
PanelSubjectExample example = new PanelSubjectExample();
|
||||
example.setOrderByClause( "create_time asc");
|
||||
List<PanelSubject> allInfo = panelSubjectMapper.selectByExampleWithBLOBs(example);
|
||||
for(int i =0;i<allInfo.size();i=i+pageSize){
|
||||
List<PanelSubject> tmp = allInfo.subList(i,i+pageSize<allInfo.size()?i+pageSize:allInfo.size());
|
||||
example.setOrderByClause("create_time asc");
|
||||
List<PanelSubject> allInfo = panelSubjectMapper.selectByExampleWithBLOBs(example);
|
||||
for (int i = 0; i < allInfo.size(); i = i + pageSize) {
|
||||
List<PanelSubject> tmp = allInfo.subList(i, Math.min(i + pageSize, allInfo.size()));
|
||||
result.add(tmp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void update(PanelSubject request){
|
||||
if(StringUtils.isEmpty(request.getId())){
|
||||
public synchronized void update(PanelSubject request) {
|
||||
if (StringUtils.isEmpty(request.getId())) {
|
||||
PanelSubjectExample example = new PanelSubjectExample();
|
||||
example.createCriteria().andTypeEqualTo("self");
|
||||
List<PanelSubject> subjectAll = panelSubjectMapper.selectByExample(example);
|
||||
int count = CollectionUtils.isEmpty(subjectAll)?0:subjectAll.size();
|
||||
int count = CollectionUtils.isEmpty(subjectAll) ? 0 : subjectAll.size();
|
||||
request.setId(UUID.randomUUID().toString());
|
||||
request.setCreateTime(System.currentTimeMillis());
|
||||
request.setType("self");
|
||||
request.setName("个人主题"+count);
|
||||
request.setName("个人主题" + count);
|
||||
panelSubjectMapper.insertSelective(request);
|
||||
}else{
|
||||
} else {
|
||||
PanelSubjectExample example = new PanelSubjectExample();
|
||||
example.createCriteria().andNameEqualTo(request.getName()).andIdNotEqualTo(request.getId());
|
||||
List<PanelSubject> subjectAll = panelSubjectMapper.selectByExample(example);
|
||||
if(CollectionUtils.isEmpty(subjectAll)){
|
||||
if (CollectionUtils.isEmpty(subjectAll)) {
|
||||
request.setUpdateTime(System.currentTimeMillis());
|
||||
panelSubjectMapper.updateByPrimaryKeySelective(request);
|
||||
}else{
|
||||
} else {
|
||||
DataEaseException.throwException("名称已经存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(String id){
|
||||
Assert.notNull(id,"subjectId should not be null");
|
||||
public void delete(String id) {
|
||||
Assert.notNull(id, "subjectId should not be null");
|
||||
panelSubjectMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -11,8 +11,6 @@ import io.dataease.dto.panel.PanelTemplateDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
@ -31,8 +29,6 @@ import java.util.UUID;
|
||||
@Service
|
||||
public class PanelTemplateService {
|
||||
|
||||
private Logger LOGGER = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource
|
||||
private PanelTemplateMapper panelTemplateMapper;
|
||||
@Resource
|
||||
@ -41,13 +37,13 @@ public class PanelTemplateService {
|
||||
public List<PanelTemplateDTO> templateList(PanelTemplateRequest panelTemplateRequest) {
|
||||
panelTemplateRequest.setWithBlobs("N");
|
||||
List<PanelTemplateDTO> panelTemplateList = extPanelTemplateMapper.panelTemplateList(panelTemplateRequest);
|
||||
if(panelTemplateRequest.getWithChildren()){
|
||||
if (panelTemplateRequest.getWithChildren()) {
|
||||
getTreeChildren(panelTemplateList);
|
||||
}
|
||||
return panelTemplateList;
|
||||
}
|
||||
|
||||
public void getTreeChildren(List<PanelTemplateDTO> parentPanelTemplateDTO){
|
||||
public void getTreeChildren(List<PanelTemplateDTO> parentPanelTemplateDTO) {
|
||||
Optional.ofNullable(parentPanelTemplateDTO).ifPresent(parent -> parent.forEach(panelTemplateDTO -> {
|
||||
List<PanelTemplateDTO> panelTemplateDTOChildren = extPanelTemplateMapper.panelTemplateList(new PanelTemplateRequest(panelTemplateDTO.getId()));
|
||||
panelTemplateDTO.setChildren(panelTemplateDTOChildren);
|
||||
@ -55,11 +51,10 @@ public class PanelTemplateService {
|
||||
}));
|
||||
}
|
||||
|
||||
public List<PanelTemplateDTO> getSystemTemplateType(PanelTemplateRequest panelTemplateRequest){
|
||||
public List<PanelTemplateDTO> getSystemTemplateType(PanelTemplateRequest panelTemplateRequest) {
|
||||
return extPanelTemplateMapper.panelTemplateList(panelTemplateRequest);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public PanelTemplateDTO save(PanelTemplateRequest request) {
|
||||
if (StringUtils.isEmpty(request.getId())) {
|
||||
@ -67,21 +62,21 @@ public class PanelTemplateService {
|
||||
request.setCreateTime(System.currentTimeMillis());
|
||||
request.setCreateBy(AuthUtils.getUser().getUsername());
|
||||
//如果level 是0(第一级)指的是分类目录 设置父级为对应的templateType
|
||||
if(request.getLevel()==0){
|
||||
if (request.getLevel() == 0) {
|
||||
request.setPid(request.getTemplateType());
|
||||
String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.INSERT,request.getName(),request.getPid(),null);
|
||||
if(CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)){
|
||||
String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.INSERT, request.getName(), request.getPid(), null);
|
||||
if (CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_same_folder_can_not_repeat"));
|
||||
}
|
||||
}else{//模板插入 相同文件夹同名的模板进行覆盖(先删除)
|
||||
} else {//模板插入 相同文件夹同名的模板进行覆盖(先删除)
|
||||
PanelTemplateExample exampleDelete = new PanelTemplateExample();
|
||||
exampleDelete.createCriteria().andPidEqualTo(request.getPid()).andNameEqualTo(request.getName());
|
||||
panelTemplateMapper.deleteByExample(exampleDelete);
|
||||
}
|
||||
panelTemplateMapper.insert(request);
|
||||
} else {
|
||||
String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.UPDATE,request.getName(),request.getPid(),request.getId());
|
||||
if(CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)){
|
||||
String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.UPDATE, request.getName(), request.getPid(), request.getId());
|
||||
if (CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)) {
|
||||
DataEaseException.throwException(Translator.get("i18n_same_folder_can_not_repeat"));
|
||||
}
|
||||
panelTemplateMapper.updateByPrimaryKeySelective(request);
|
||||
@ -92,43 +87,39 @@ public class PanelTemplateService {
|
||||
return panelTemplateDTO;
|
||||
}
|
||||
|
||||
|
||||
//名称检查
|
||||
public String nameCheck(String optType,String name,String pid,String id){
|
||||
public String nameCheck(String optType, String name, String pid, String id) {
|
||||
PanelTemplateExample example = new PanelTemplateExample();
|
||||
if(CommonConstants.OPT_TYPE.INSERT.equals(optType)){
|
||||
if (CommonConstants.OPT_TYPE.INSERT.equals(optType)) {
|
||||
example.createCriteria().andPidEqualTo(pid).andNameEqualTo(name);
|
||||
|
||||
}else if(CommonConstants.OPT_TYPE.UPDATE.equals(optType)){
|
||||
} else if (CommonConstants.OPT_TYPE.UPDATE.equals(optType)) {
|
||||
example.createCriteria().andPidEqualTo(pid).andNameEqualTo(name).andIdNotEqualTo(id);
|
||||
}
|
||||
List<PanelTemplate> panelTemplates = panelTemplateMapper.selectByExample(example);
|
||||
if(CollectionUtils.isEmpty(panelTemplates)){
|
||||
if (CollectionUtils.isEmpty(panelTemplates)) {
|
||||
return CommonConstants.CHECK_RESULT.NONE;
|
||||
}else{
|
||||
} else {
|
||||
return CommonConstants.CHECK_RESULT.EXIST_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
public String nameCheck(PanelTemplateRequest request){
|
||||
return nameCheck(request.getOptType(),request.getName(),request.getPid(),request.getId());
|
||||
public String nameCheck(PanelTemplateRequest request) {
|
||||
return nameCheck(request.getOptType(), request.getName(), request.getPid(), request.getId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void delete(String id){
|
||||
public void delete(String id) {
|
||||
Assert.notNull(id, "id cannot be null");
|
||||
panelTemplateMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
|
||||
public PanelTemplateWithBLOBs findOne(String panelId){
|
||||
return panelTemplateMapper.selectByPrimaryKey(panelId);
|
||||
public PanelTemplateWithBLOBs findOne(String panelId) {
|
||||
return panelTemplateMapper.selectByPrimaryKey(panelId);
|
||||
}
|
||||
|
||||
public List<PanelTemplateDTO> find(PanelTemplateRequest panelTemplateRequest){
|
||||
List<PanelTemplateDTO> panelTemplateList = extPanelTemplateMapper.panelTemplateList(panelTemplateRequest);
|
||||
return panelTemplateList;
|
||||
public List<PanelTemplateDTO> find(PanelTemplateRequest panelTemplateRequest) {
|
||||
return extPanelTemplateMapper.panelTemplateList(panelTemplateRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -43,39 +43,37 @@ public class PanelViewLinkageService {
|
||||
|
||||
|
||||
public Map<String, PanelViewLinkageDTO> getViewLinkageGather(PanelLinkageRequest request) {
|
||||
if(CollectionUtils.isNotEmpty(request.getTargetViewIds())){
|
||||
List<PanelViewLinkageDTO> linkageDTOList = extPanelViewLinkageMapper.getViewLinkageGather(request.getPanelId(),request.getSourceViewId(),request.getTargetViewIds());
|
||||
Map<String, PanelViewLinkageDTO> result = linkageDTOList.stream()
|
||||
.collect(Collectors.toMap(PanelViewLinkageDTO::getTargetViewId,PanelViewLinkageDTO->PanelViewLinkageDTO));
|
||||
return result;
|
||||
if (CollectionUtils.isNotEmpty(request.getTargetViewIds())) {
|
||||
List<PanelViewLinkageDTO> linkageDTOList = extPanelViewLinkageMapper.getViewLinkageGather(request.getPanelId(), request.getSourceViewId(), request.getTargetViewIds());
|
||||
return linkageDTOList.stream().collect(Collectors.toMap(PanelViewLinkageDTO::getTargetViewId, PanelViewLinkageDTO -> PanelViewLinkageDTO));
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveLinkage(PanelLinkageRequest request){
|
||||
public void saveLinkage(PanelLinkageRequest request) {
|
||||
Long updateTime = System.currentTimeMillis();
|
||||
Map<String, PanelViewLinkageDTO> linkageInfo = request.getLinkageInfo();
|
||||
Map<String, PanelViewLinkageDTO> linkageInfo = request.getLinkageInfo();
|
||||
String sourceViewId = request.getSourceViewId();
|
||||
String panelId = request.getPanelId();
|
||||
|
||||
Assert.notNull(sourceViewId,"source View ID can not be null");
|
||||
Assert.notNull(panelId,"panelId can not be null");
|
||||
Assert.notNull(sourceViewId, "source View ID can not be null");
|
||||
Assert.notNull(panelId, "panelId can not be null");
|
||||
|
||||
//去掉source view 的信息
|
||||
linkageInfo.remove(sourceViewId);
|
||||
|
||||
// 清理原有关系
|
||||
extPanelViewLinkageMapper.deleteViewLinkageField(panelId,sourceViewId);
|
||||
extPanelViewLinkageMapper.deleteViewLinkage(panelId,sourceViewId);
|
||||
extPanelViewLinkageMapper.deleteViewLinkageField(panelId, sourceViewId);
|
||||
extPanelViewLinkageMapper.deleteViewLinkage(panelId, sourceViewId);
|
||||
|
||||
//重新建立关系
|
||||
for(Map.Entry<String, PanelViewLinkageDTO> entry : linkageInfo.entrySet()){
|
||||
for (Map.Entry<String, PanelViewLinkageDTO> entry : linkageInfo.entrySet()) {
|
||||
String targetViewId = entry.getKey();
|
||||
PanelViewLinkageDTO linkageDTO = entry.getValue();
|
||||
List<PanelViewLinkageField> linkageFields = linkageDTO.getLinkageFields();
|
||||
|
||||
if(CollectionUtils.isNotEmpty(linkageFields)&&linkageDTO.isLinkageActive()){
|
||||
if (CollectionUtils.isNotEmpty(linkageFields) && linkageDTO.isLinkageActive()) {
|
||||
String linkageId = UUID.randomUUID().toString();
|
||||
PanelViewLinkage linkage = new PanelViewLinkage();
|
||||
linkage.setId(linkageId);
|
||||
@ -86,7 +84,7 @@ public class PanelViewLinkageService {
|
||||
linkage.setUpdateTime(updateTime);
|
||||
panelViewLinkageMapper.insert(linkage);
|
||||
|
||||
linkageFields.stream().forEach(linkageField->{
|
||||
linkageFields.forEach(linkageField -> {
|
||||
linkageField.setId(UUID.randomUUID().toString());
|
||||
linkageField.setLinkageId(linkageId);
|
||||
linkageField.setUpdateTime(updateTime);
|
||||
@ -99,11 +97,11 @@ public class PanelViewLinkageService {
|
||||
|
||||
public Map<String, List<String>> getPanelAllLinkageInfo(String panelId) {
|
||||
PanelGroupWithBLOBs panelInfo = panelGroupMapper.selectByPrimaryKey(panelId);
|
||||
if(panelInfo!=null && StringUtils.isNotEmpty(panelInfo.getSource())){
|
||||
panelId=panelInfo.getSource();
|
||||
if (panelInfo != null && StringUtils.isNotEmpty(panelInfo.getSource())) {
|
||||
panelId = panelInfo.getSource();
|
||||
}
|
||||
List<LinkageInfoDTO> info = extPanelViewLinkageMapper.getPanelAllLinkageInfo(panelId);
|
||||
return Optional.ofNullable(info).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(LinkageInfoDTO::getSourceInfo,LinkageInfoDTO::getTargetInfoList));
|
||||
return Optional.ofNullable(info).orElse(new ArrayList<>()).stream().collect(Collectors.toMap(LinkageInfoDTO::getSourceInfo, LinkageInfoDTO::getTargetInfoList));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import io.dataease.base.domain.PanelGroupWithBLOBs;
|
||||
import io.dataease.base.mapper.ext.ExtPanelViewMapper;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.dto.chart.ChartViewDTO;
|
||||
import io.dataease.dto.panel.PanelViewDto;
|
||||
import io.dataease.dto.panel.PanelViewTableDTO;
|
||||
import io.dataease.dto.panel.po.PanelViewInsertDTO;
|
||||
@ -33,7 +32,6 @@ public class PanelViewService {
|
||||
@Autowired(required = false)
|
||||
private ExtPanelViewMapper extPanelViewMapper;
|
||||
|
||||
|
||||
private final static String SCENE_TYPE = "scene";
|
||||
|
||||
public List<PanelViewDto> groups(){
|
||||
@ -45,9 +43,7 @@ public class PanelViewService {
|
||||
}
|
||||
|
||||
public List<PanelViewDto> buildTree(List<PanelViewPo> groups, List<PanelViewPo> views){
|
||||
|
||||
if (CollectionUtils.isEmpty(groups) || CollectionUtils.isEmpty(views)) return null;
|
||||
|
||||
Map<String, List<PanelViewPo>> viewsMap = views.stream().collect(Collectors.groupingBy(PanelViewPo::getPid));
|
||||
List<PanelViewDto> dtos = groups.stream().map(group -> BeanUtils.copyBean(new PanelViewDto(), group)).collect(Collectors.toList());
|
||||
List<PanelViewDto> roots = new ArrayList<>();
|
||||
@ -98,8 +94,6 @@ public class PanelViewService {
|
||||
}
|
||||
|
||||
public List<PanelViewTableDTO> detailList(String panelId){
|
||||
|
||||
|
||||
return extPanelViewMapper.getPanelViewDetails(panelId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class ShareService {
|
||||
|
||||
for (Map.Entry<Integer, List<Long>> entry : authURDMap.entrySet()) {
|
||||
Integer key = entry.getKey();
|
||||
List<TempShareNode> shareNodes = null;
|
||||
List<TempShareNode> shareNodes;
|
||||
if (null == typeSharedMap || null == typeSharedMap.get(key)) {
|
||||
shareNodes = new ArrayList<>();
|
||||
}else{
|
||||
@ -121,24 +121,21 @@ public class ShareService {
|
||||
// 下面是消息发送
|
||||
Set<Long> addUserIdSet = AuthUtils.userIdsByURD(addAuthURD);
|
||||
Set<Long> redUserIdSet = AuthUtils.userIdsByURD(sharedAuthURD);
|
||||
|
||||
|
||||
PanelGroup panelGroup = panelGroupMapper.selectByPrimaryKey(panelGroupId);;
|
||||
PanelGroup panelGroup = panelGroupMapper.selectByPrimaryKey(panelGroupId);
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
Gson gson = new Gson();
|
||||
String msg = panelGroup.getName();
|
||||
|
||||
|
||||
List<String> msgParam = new ArrayList<String>();
|
||||
List<String> msgParam = new ArrayList<>();
|
||||
msgParam.add(panelGroupId);
|
||||
addUserIdSet.forEach(userId -> {
|
||||
if (!redUserIdSet.contains(userId) && user.getUserId() != userId){
|
||||
if (!redUserIdSet.contains(userId) && !user.getUserId().equals(userId)){
|
||||
DeMsgutil.sendMsg(userId, 2L,user.getNickName()+" 分享了仪表板【"+msg+"】,请查收!", gson.toJson(msgParam));
|
||||
}
|
||||
});
|
||||
|
||||
redUserIdSet.forEach(userId -> {
|
||||
if (!addUserIdSet.contains(userId) && user.getUserId() != userId){
|
||||
if (!addUserIdSet.contains(userId) && !user.getUserId().equals(userId)){
|
||||
DeMsgutil.sendMsg(userId, 3L, user.getNickName()+" 取消分享了仪表板【"+msg+"】,请查收!", gson.toJson(msgParam));
|
||||
}
|
||||
});
|
||||
@ -164,7 +161,6 @@ public class ShareService {
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Object> filterData(List<Long> newTargets, List<TempShareNode> shareNodes) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<Long> newUserIds = new ArrayList<>();
|
||||
for (int i = 0; i < newTargets.size(); i++) {
|
||||
@ -173,7 +169,7 @@ public class ShareService {
|
||||
for (int j = 0; j < shareNodes.size(); j++) {
|
||||
TempShareNode shareNode = shareNodes.get(j);
|
||||
Long sharedId = shareNode.getTargetId();
|
||||
if (newTargetId == sharedId) {
|
||||
if (newTargetId.equals(sharedId)) {
|
||||
shareNode.setMatched(true); // 已分享 重新命中
|
||||
isNew = false;
|
||||
}
|
||||
@ -198,7 +194,7 @@ public class ShareService {
|
||||
private Boolean matched = false;
|
||||
|
||||
public boolean targetMatch(Long tid) {
|
||||
return targetId == tid;
|
||||
return targetId.equals(tid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,9 +213,7 @@ public class ShareService {
|
||||
// 使用原生对象会导致事物失效 所以这里需要使用spring代理对象
|
||||
if (CollectionUtils.isNotEmpty(panelIds)){
|
||||
ShareService proxy = CommonBeanFactory.getBean(ShareService.class);
|
||||
panelIds.forEach(panelId -> {
|
||||
proxy.delete(panelId, type);
|
||||
});
|
||||
panelIds.forEach(panelId -> proxy.delete(panelId, type));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(targetIds)) return;
|
||||
|
||||
@ -239,7 +233,7 @@ public class ShareService {
|
||||
}
|
||||
|
||||
// 下面是发送提醒消息逻辑
|
||||
Set<Long> userIdSet = new HashSet<Long>();
|
||||
Set<Long> userIdSet;
|
||||
AuthURD authURD = new AuthURD();
|
||||
if (type == 0) {
|
||||
authURD.setUserIds(targetIds);
|
||||
@ -255,9 +249,7 @@ public class ShareService {
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
String msg = StringUtils.joinWith(",", panelGroups.stream().map(PanelGroup::getName).collect(Collectors.toList()));
|
||||
Gson gson = new Gson();
|
||||
userIdSet.forEach(userId -> {
|
||||
DeMsgutil.sendMsg(userId, 2L, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!", gson.toJson(panelIds));
|
||||
});
|
||||
userIdSet.forEach(userId -> DeMsgutil.sendMsg(userId, 2L, user.getNickName()+" 分享了仪表板【"+msg+"】给您,请查收!", gson.toJson(panelIds)));
|
||||
|
||||
}
|
||||
|
||||
@ -286,8 +278,7 @@ public class ShareService {
|
||||
|
||||
public List<PanelSharePo> queryShareOut() {
|
||||
String username = AuthUtils.getUser().getUsername();
|
||||
List<PanelSharePo> panelSharePos = extPanelShareMapper.queryOut(username);
|
||||
return panelSharePos;
|
||||
return extPanelShareMapper.queryOut(username);
|
||||
}
|
||||
|
||||
public List<PanelShareDto> queryTree(BaseGridRequest request){
|
||||
@ -302,8 +293,6 @@ public class ShareService {
|
||||
param.put("roleIds", roleIds);
|
||||
|
||||
List<PanelSharePo> datas = extPanelShareMapper.query(param);
|
||||
|
||||
|
||||
List<PanelShareDto> dtoLists = datas.stream().map(po -> BeanUtils.copyBean(new PanelShareDto(), po)).collect(Collectors.toList());
|
||||
return convertTree(dtoLists);
|
||||
}
|
||||
@ -329,7 +318,6 @@ public class ShareService {
|
||||
return extPanelShareMapper.queryTargets(panelId);
|
||||
}
|
||||
|
||||
|
||||
public void removeShares(PanelShareRemoveRequest removeRequest) {
|
||||
extPanelShareMapper.removeShares(removeRequest);
|
||||
}
|
||||
|
||||
@ -40,14 +40,6 @@ public class StoreService {
|
||||
panelStoreMapper.deleteByExample(panelStoreExample);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 按照当前用户ID查询收藏仪表板
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public List<PanelStoreDto> query(BaseGridRequest request) {
|
||||
Long userId = AuthUtils.getUser().getUserId();
|
||||
ConditionEntity condition = new ConditionEntity();
|
||||
@ -58,8 +50,7 @@ public class StoreService {
|
||||
add(condition);
|
||||
}});
|
||||
GridExample example = request.convertExample();
|
||||
List<PanelStoreDto> stores = extPanelStoreMapper.query(example);
|
||||
return stores;
|
||||
return extPanelStoreMapper.query(example);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import io.dataease.base.mapper.SysDeptMapper;
|
||||
import io.dataease.base.mapper.ext.ExtDeptMapper;
|
||||
import io.dataease.base.mapper.ext.query.GridExample;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.DeptCreateRequest;
|
||||
import io.dataease.controller.sys.request.DeptDeleteRequest;
|
||||
@ -23,15 +22,12 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class DeptService {
|
||||
|
||||
private final static Integer DEPT_ROOT_LEVEL = 0;
|
||||
private final static Integer DEFAULT_SUBCOUNT = 0;
|
||||
public final static Long DEPT_ROOT_PID = 0L;
|
||||
|
||||
@Autowired(required = false)
|
||||
private SysDeptMapper sysDeptMapper;
|
||||
|
||||
|
||||
@Autowired(required = false)
|
||||
private ExtDeptMapper extDeptMapper;
|
||||
|
||||
@ -44,8 +40,7 @@ public class DeptService {
|
||||
criteria.andPidEqualTo(pid);
|
||||
}
|
||||
example.setOrderByClause("dept_sort");
|
||||
List<SysDept> sysDepts = sysDeptMapper.selectByExample(example);
|
||||
return sysDepts;
|
||||
return sysDeptMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -63,8 +58,8 @@ public class DeptService {
|
||||
sysDept.setSubCount(DEFAULT_SUBCOUNT);
|
||||
try {
|
||||
int insert = sysDeptMapper.insert(sysDept);
|
||||
Long pid = null;
|
||||
if ((pid = sysDept.getPid()) != DEPT_ROOT_PID ){
|
||||
Long pid;
|
||||
if (!(pid = sysDept.getPid()).equals(DEPT_ROOT_PID)){
|
||||
//这里需要更新上级节点SubCount
|
||||
extDeptMapper.incrementalSubcount(pid);
|
||||
}
|
||||
@ -81,7 +76,7 @@ public class DeptService {
|
||||
public int batchDelete(List<DeptDeleteRequest> requests){
|
||||
List<Long> ids = requests.stream().map(request -> {
|
||||
Long pid = request.getPid();
|
||||
if (pid != DEPT_ROOT_PID){
|
||||
if (!pid.equals(DEPT_ROOT_PID)){
|
||||
extDeptMapper.decreasingSubcount(pid);
|
||||
}
|
||||
return request.getDeptId();
|
||||
@ -102,12 +97,12 @@ public class DeptService {
|
||||
//如果PID发生了改变
|
||||
//判断oldPid是否是跟节点PID ? nothing : parent.subcount-1
|
||||
//判断newPid是否是跟节点PID ? nothing : parent.subcount+1
|
||||
if (sysDept.getPid() != dept_old.getPid()){
|
||||
if (!sysDept.getPid().equals(dept_old.getPid())){
|
||||
Long oldPid = dept_old.getPid();
|
||||
if (oldPid != DEPT_ROOT_PID){
|
||||
if (!oldPid.equals(DEPT_ROOT_PID)){
|
||||
extDeptMapper.decreasingSubcount(oldPid);
|
||||
}
|
||||
if (sysDept.getPid() != DEPT_ROOT_PID){
|
||||
if (!sysDept.getPid().equals(DEPT_ROOT_PID)){
|
||||
extDeptMapper.incrementalSubcount(sysDept.getPid());
|
||||
}
|
||||
}
|
||||
@ -116,14 +111,11 @@ public class DeptService {
|
||||
|
||||
public int updateStatus(DeptStatusRequest request){
|
||||
Long deptId = request.getDeptId();
|
||||
boolean status = request.isStatus();
|
||||
SysDept sysDept = new SysDept();
|
||||
sysDept.setDeptId(deptId);
|
||||
return sysDeptMapper.updateByPrimaryKeySelective(sysDept);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<SysDept> nodesTreeByCondition(BaseGridRequest request){
|
||||
List<SimpleTreeNode> allNodes = allNodes();
|
||||
List<SimpleTreeNode> targetNodes = nodeByCondition(request);
|
||||
@ -137,18 +129,17 @@ public class DeptService {
|
||||
criteria.andDeptIdIn(ids);
|
||||
}
|
||||
example.setOrderByClause("dept_sort");
|
||||
List<SysDept> sysDepts = sysDeptMapper.selectByExample(example);
|
||||
return sysDepts;
|
||||
return sysDeptMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<DeptTreeNode> searchTree(Long deptId){
|
||||
List<SysDept> roots = nodesByPid(0L);
|
||||
if (deptId == DEPT_ROOT_PID) return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
if (deptId.equals(DEPT_ROOT_PID)) return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
SysDept sysDept = sysDeptMapper.selectByPrimaryKey(deptId);
|
||||
if (roots.stream().anyMatch(node -> node.getDeptId() == deptId)) return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
if (roots.stream().anyMatch(node -> node.getDeptId().equals(deptId))) return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
SysDept current = sysDept;
|
||||
DeptTreeNode currentNode = format(sysDept);
|
||||
while (current.getPid() != DEPT_ROOT_PID){
|
||||
while (!current.getPid().equals(DEPT_ROOT_PID)){
|
||||
SysDept parent = sysDeptMapper.selectByPrimaryKey(current.getPid()); //pid上有索引 所以效率不会太差
|
||||
DeptTreeNode parentNode = format(parent);
|
||||
parentNode.setChildren(currentNode.toList());
|
||||
@ -157,7 +148,7 @@ public class DeptService {
|
||||
}
|
||||
|
||||
DeptTreeNode targetRootNode = currentNode;
|
||||
return roots.stream().map(node -> node.getDeptId() == targetRootNode.getId() ? targetRootNode : format(node)).collect(Collectors.toList());
|
||||
return roots.stream().map(node -> node.getDeptId().equals(targetRootNode.getId()) ? targetRootNode : format(node)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private DeptTreeNode format(SysDept sysDept){
|
||||
@ -168,20 +159,13 @@ public class DeptService {
|
||||
return deptTreeNode;
|
||||
}
|
||||
|
||||
private DeptService proxy(){
|
||||
return CommonBeanFactory.getBean(DeptService.class);
|
||||
}
|
||||
|
||||
|
||||
private List<SimpleTreeNode> allNodes(){
|
||||
List<SimpleTreeNode> simpleTreeNodes = extDeptMapper.allNodes();
|
||||
return simpleTreeNodes;
|
||||
return extDeptMapper.allNodes();
|
||||
}
|
||||
|
||||
private List<SimpleTreeNode> nodeByCondition(BaseGridRequest request){
|
||||
GridExample gridExample = request.convertExample();
|
||||
List<SimpleTreeNode> simpleTreeNodes = extDeptMapper.nodesByExample(gridExample);
|
||||
return simpleTreeNodes;
|
||||
return extDeptMapper.nodesByExample(gridExample);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,7 +176,7 @@ public class DeptService {
|
||||
*/
|
||||
private List<Long> upTree(List<SimpleTreeNode> allNodes, List<SimpleTreeNode> targetNodes){
|
||||
final Map<Long, SimpleTreeNode> map = allNodes.stream().collect(Collectors.toMap(SimpleTreeNode::getId, node -> node));
|
||||
List<Long> results = targetNodes.parallelStream().flatMap(targetNode -> {
|
||||
return targetNodes.parallelStream().flatMap(targetNode -> {
|
||||
//向上逐级找爹
|
||||
List<Long> ids = new ArrayList<>();
|
||||
SimpleTreeNode node = targetNode;
|
||||
@ -203,9 +187,6 @@ public class DeptService {
|
||||
}
|
||||
return ids.stream();
|
||||
}).distinct().collect(Collectors.toList());
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -24,8 +25,6 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class MenuService {
|
||||
|
||||
|
||||
|
||||
private final static Integer DEFAULT_SUBCOUNT = 0;
|
||||
public final static Long MENU_ROOT_PID = 0L;
|
||||
|
||||
@ -38,23 +37,22 @@ public class MenuService {
|
||||
@Resource
|
||||
private ExtMenuMapper extMenuMapper;
|
||||
|
||||
public List<SysMenu> nodesByPid(Long pid){
|
||||
public List<SysMenu> nodesByPid(Long pid) {
|
||||
SysMenuExample example = new SysMenuExample();
|
||||
SysMenuExample.Criteria criteria = example.createCriteria();
|
||||
if (ObjectUtils.isEmpty(pid)){
|
||||
if (ObjectUtils.isEmpty(pid)) {
|
||||
criteria.andPidEqualTo(MENU_ROOT_PID);
|
||||
}else {
|
||||
} else {
|
||||
criteria.andPidEqualTo(pid);
|
||||
}
|
||||
example.setOrderByClause("menu_sort");
|
||||
List<SysMenu> sysMenus = sysMenuMapper.selectByExample(example);
|
||||
return sysMenus;
|
||||
return sysMenuMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean add(MenuCreateRequest menuCreateRequest){
|
||||
public boolean add(MenuCreateRequest menuCreateRequest) {
|
||||
SysMenu sysMenu = BeanUtils.copyBean(new SysMenu(), menuCreateRequest);
|
||||
if (menuCreateRequest.isTop()){
|
||||
if (menuCreateRequest.isTop()) {
|
||||
sysMenu.setPid(MENU_ROOT_PID);
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
@ -65,24 +63,24 @@ public class MenuService {
|
||||
sysMenu.setSubCount(DEFAULT_SUBCOUNT);
|
||||
try {
|
||||
int insert = sysMenuMapper.insert(sysMenu);
|
||||
Long pid = null;
|
||||
if ((pid = sysMenu.getPid()) != MENU_ROOT_PID ){
|
||||
Long pid;
|
||||
if (!(pid = sysMenu.getPid()).equals(MENU_ROOT_PID)) {
|
||||
//这里需要更新上级节点SubCount
|
||||
extMenuMapper.incrementalSubcount(pid);
|
||||
}
|
||||
if (insert == 1){
|
||||
if (insert == 1) {
|
||||
return true;
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int delete(MenuDeleteRequest request){
|
||||
public int delete(MenuDeleteRequest request) {
|
||||
Long pid = request.getPid();
|
||||
if (pid != MENU_ROOT_PID){
|
||||
if (!pid.equals(MENU_ROOT_PID)) {
|
||||
extMenuMapper.decreasingSubcount(pid);
|
||||
}
|
||||
Long menuId = request.getMenuId();
|
||||
@ -90,12 +88,10 @@ public class MenuService {
|
||||
return sysMenuMapper.deleteByPrimaryKey(menuId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
public int update(MenuCreateRequest menuCreateRequest){
|
||||
public int update(MenuCreateRequest menuCreateRequest) {
|
||||
SysMenu sysMenu = BeanUtils.copyBean(new SysMenu(), menuCreateRequest);
|
||||
if (menuCreateRequest.isTop()){
|
||||
if (menuCreateRequest.isTop()) {
|
||||
sysMenu.setPid(MENU_ROOT_PID);
|
||||
}
|
||||
|
||||
@ -106,33 +102,33 @@ public class MenuService {
|
||||
//如果PID发生了改变
|
||||
//判断oldPid是否是跟节点PID ? nothing : parent.subcount-1
|
||||
//判断newPid是否是跟节点PID ? nothing : parent.subcount+1
|
||||
if (menu_old.getPid() != sysMenu.getPid()){
|
||||
if (!menu_old.getPid().equals(sysMenu.getPid())) {
|
||||
Long oldPid = menu_old.getPid();
|
||||
if (oldPid != MENU_ROOT_PID){
|
||||
if (!oldPid.equals(MENU_ROOT_PID)) {
|
||||
extMenuMapper.decreasingSubcount(oldPid);
|
||||
}
|
||||
if (sysMenu.getPid() != MENU_ROOT_PID){
|
||||
if (!sysMenu.getPid().equals(MENU_ROOT_PID)) {
|
||||
extMenuMapper.incrementalSubcount(sysMenu.getPid());
|
||||
}
|
||||
}
|
||||
return sysMenuMapper.updateByPrimaryKeySelective(sysMenu);
|
||||
}
|
||||
|
||||
public List<MenuNodeResponse> childs(Long pid){
|
||||
public List<MenuNodeResponse> childs(Long pid) {
|
||||
Set<SysMenu> childs = getChilds(nodesByPid(pid), new HashSet());
|
||||
List<SysMenu> menus = childs.stream().collect(Collectors.toList());
|
||||
List<MenuNodeResponse> responses = convert(menus);
|
||||
return responses;
|
||||
List<SysMenu> menus = new ArrayList<>(childs);
|
||||
return convert(menus);
|
||||
}
|
||||
|
||||
public List<MenuTreeNode> searchTree(Long menuId) {
|
||||
List<SysMenu> roots = nodesByPid(0L);
|
||||
if (menuId == MENU_ROOT_PID) return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
if (menuId.equals(MENU_ROOT_PID)) return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
SysMenu sysMenu = sysMenuMapper.selectByPrimaryKey(menuId);
|
||||
if (roots.stream().anyMatch(node -> node.getMenuId() == menuId)) return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
if (roots.stream().anyMatch(node -> node.getMenuId().equals(menuId)))
|
||||
return roots.stream().map(this::format).collect(Collectors.toList());
|
||||
SysMenu current = sysMenu;
|
||||
MenuTreeNode currentNode = format(sysMenu);
|
||||
while (current.getPid() != MENU_ROOT_PID){
|
||||
while (!current.getPid().equals(MENU_ROOT_PID)) {
|
||||
SysMenu parent = sysMenuMapper.selectByPrimaryKey(current.getPid()); //pid上有索引 所以效率不会太差
|
||||
MenuTreeNode parentNode = format(parent);
|
||||
parentNode.setChildren(currentNode.toList());
|
||||
@ -140,14 +136,14 @@ public class MenuService {
|
||||
currentNode = parentNode;
|
||||
}
|
||||
MenuTreeNode targetRootNode = currentNode;
|
||||
return roots.stream().map(node -> node.getMenuId() == targetRootNode.getId() ? targetRootNode : format(node)).collect(Collectors.toList());
|
||||
return roots.stream().map(node -> node.getMenuId().equals(targetRootNode.getId()) ? targetRootNode : format(node)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Set<SysMenu> getChilds(List<SysMenu> lists, Set<SysMenu> sets){
|
||||
private Set<SysMenu> getChilds(List<SysMenu> lists, Set<SysMenu> sets) {
|
||||
lists.forEach(menu -> {
|
||||
sets.add(menu);
|
||||
List<SysMenu> kidMenus = nodesByPid(menu.getMenuId());
|
||||
if (CollectionUtils.isNotEmpty(kidMenus)){
|
||||
if (CollectionUtils.isNotEmpty(kidMenus)) {
|
||||
getChilds(kidMenus, sets);
|
||||
}
|
||||
});
|
||||
@ -163,52 +159,49 @@ public class MenuService {
|
||||
return menuTreeNode;
|
||||
}
|
||||
|
||||
public List<MenuNodeResponse> convert(List<SysMenu> menus){
|
||||
public List<MenuNodeResponse> convert(List<SysMenu> menus) {
|
||||
return menus.stream().map(node -> {
|
||||
MenuNodeResponse menuNodeResponse = BeanUtils.copyBean(new MenuNodeResponse(), node);
|
||||
menuNodeResponse.setHasChildren(node.getSubCount() > 0);
|
||||
menuNodeResponse.setTop(node.getPid() == MENU_ROOT_PID);
|
||||
menuNodeResponse.setTop(node.getPid().equals(MENU_ROOT_PID));
|
||||
return menuNodeResponse;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<SysMenu> nodesTreeByCondition(BaseGridRequest request){
|
||||
public List<SysMenu> nodesTreeByCondition(BaseGridRequest request) {
|
||||
List<SimpleTreeNode> allNodes = allNodes();
|
||||
List<SimpleTreeNode> targetNodes = nodeByCondition(request);
|
||||
if(org.apache.commons.collections.CollectionUtils.isEmpty(targetNodes)){
|
||||
if (org.apache.commons.collections.CollectionUtils.isEmpty(targetNodes)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Long> ids = upTree(allNodes, targetNodes);
|
||||
SysMenuExample example = new SysMenuExample();
|
||||
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(ids)){
|
||||
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(ids)) {
|
||||
SysMenuExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andMenuIdIn(ids);
|
||||
}
|
||||
List<SysMenu> sysMenus = sysMenuMapper.selectByExample(example);
|
||||
return sysMenus;
|
||||
return sysMenuMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<SimpleTreeNode> allNodes() {
|
||||
List<SimpleTreeNode> allNodes = extSysMenuMapper.allNodes();
|
||||
return allNodes;
|
||||
return extSysMenuMapper.allNodes();
|
||||
}
|
||||
|
||||
public List<SimpleTreeNode> nodeByCondition(BaseGridRequest request) {
|
||||
List<SimpleTreeNode> simpleTreeNodes = extSysMenuMapper.nodesByExample(request.convertExample());
|
||||
return simpleTreeNodes;
|
||||
return extSysMenuMapper.nodesByExample(request.convertExample());
|
||||
}
|
||||
|
||||
/**
|
||||
* 找出目标节点所在路径上的所有节点 向上找
|
||||
* @param allNodes 所有节点
|
||||
*
|
||||
* @param allNodes 所有节点
|
||||
* @param targetNodes 目标节点
|
||||
* @return
|
||||
*/
|
||||
private List<Long> upTree(List<SimpleTreeNode> allNodes, List<SimpleTreeNode> targetNodes){
|
||||
private List<Long> upTree(List<SimpleTreeNode> allNodes, List<SimpleTreeNode> targetNodes) {
|
||||
final Map<Long, SimpleTreeNode> map = allNodes.stream().collect(Collectors.toMap(SimpleTreeNode::getId, node -> node));
|
||||
List<Long> results = targetNodes.parallelStream().flatMap(targetNode -> {
|
||||
return targetNodes.parallelStream().flatMap(targetNode -> {
|
||||
//向上逐级找爹
|
||||
List<Long> ids = new ArrayList<>();
|
||||
SimpleTreeNode node = targetNode;
|
||||
@ -219,7 +212,6 @@ public class MenuService {
|
||||
}
|
||||
return ids.stream();
|
||||
}).distinct().collect(Collectors.toList());
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -45,24 +46,24 @@ public class PluginService {
|
||||
|
||||
public List<MyPlugin> query(BaseGridRequest request) {
|
||||
GridExample gridExample = request.convertExample();
|
||||
List<MyPlugin> results = extSysPluginMapper.query(gridExample);
|
||||
return results;
|
||||
return extSysPluginMapper.query(gridExample);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从本地安装处插件
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> localInstall(MultipartFile file) {
|
||||
//1.上传文件到服务器pluginDir目录下
|
||||
File dest = DeFileUtils.upload(file, pluginDir+"temp/");
|
||||
File dest = DeFileUtils.upload(file, pluginDir + "temp/");
|
||||
//2.解压目标文件dest 得到plugin.json和jar
|
||||
String folder = pluginDir+"folder/";
|
||||
String folder = pluginDir + "folder/";
|
||||
try {
|
||||
ZipUtils.upZipFile(dest, folder);
|
||||
} catch (IOException e) {
|
||||
DeFileUtils.deleteFile(pluginDir+"temp/");
|
||||
DeFileUtils.deleteFile(pluginDir + "temp/");
|
||||
DeFileUtils.deleteFile(folder);
|
||||
// 需要删除文件
|
||||
e.printStackTrace();
|
||||
@ -71,7 +72,7 @@ public class PluginService {
|
||||
File folderFile = new File(folder);
|
||||
File[] jsonFiles = folderFile.listFiles(this::isPluginJson);
|
||||
if (ArrayUtils.isEmpty(jsonFiles)) {
|
||||
DeFileUtils.deleteFile(pluginDir+"temp/");
|
||||
DeFileUtils.deleteFile(pluginDir + "temp/");
|
||||
DeFileUtils.deleteFile(folder);
|
||||
throw new RuntimeException("缺少插件描述文件");
|
||||
}
|
||||
@ -79,7 +80,7 @@ public class PluginService {
|
||||
//4.加载jar包 失败则 直接返回错误 删除文件
|
||||
File[] jarFiles = folderFile.listFiles(this::isPluginJar);
|
||||
if (ArrayUtils.isEmpty(jarFiles)) {
|
||||
DeFileUtils.deleteFile(pluginDir+"temp/");
|
||||
DeFileUtils.deleteFile(pluginDir + "temp/");
|
||||
DeFileUtils.deleteFile(folder);
|
||||
throw new RuntimeException("缺少插件jar文件");
|
||||
}
|
||||
@ -87,7 +88,7 @@ public class PluginService {
|
||||
try {
|
||||
File jarFile = jarFiles[0];
|
||||
targetDir = makeTargetDir(myPlugin);
|
||||
String jarPath = null;
|
||||
String jarPath;
|
||||
jarPath = DeFileUtils.copy(jarFile, targetDir);
|
||||
loadJar(jarPath, myPlugin);
|
||||
myPluginMapper.insert(myPlugin);
|
||||
@ -100,12 +101,10 @@ public class PluginService {
|
||||
DeFileUtils.deleteFile(targetDir);
|
||||
}
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
DeFileUtils.deleteFile(pluginDir+"temp/");
|
||||
} finally {
|
||||
DeFileUtils.deleteFile(pluginDir + "temp/");
|
||||
DeFileUtils.deleteFile(folder);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -113,9 +112,6 @@ public class PluginService {
|
||||
loadjarUtil.loadJar(jarPath, myPlugin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private String makeTargetDir(MyPlugin myPlugin) {
|
||||
String store = myPlugin.getStore();
|
||||
String dir = pluginDir + store + "/";
|
||||
@ -128,6 +124,7 @@ public class PluginService {
|
||||
|
||||
/**
|
||||
* 卸载插件
|
||||
*
|
||||
* @param pluginId
|
||||
* @return
|
||||
*/
|
||||
@ -141,6 +138,7 @@ public class PluginService {
|
||||
|
||||
/**
|
||||
* 改变插件状态
|
||||
*
|
||||
* @param pluginId
|
||||
* @param status true ? 使用状态 : 禁用状态
|
||||
* @return
|
||||
@ -165,14 +163,15 @@ public class PluginService {
|
||||
|
||||
/**
|
||||
* 从plugin.json文件反序列化为MyPlugin实例对象
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private MyPlugin formatJsonFile(File file) {
|
||||
String str = DeFileUtils.readJson(file);
|
||||
Gson gson = new Gson();
|
||||
Map<String, Object> myPlugin = gson.fromJson(str, Map.class);
|
||||
myPlugin.put("free", (Double)myPlugin.get("free") > 0.0);
|
||||
myPlugin.put("loadMybatis", (Double)myPlugin.get("loadMybatis") > 0.0);
|
||||
myPlugin.put("free", (Double) myPlugin.get("free") > 0.0);
|
||||
myPlugin.put("loadMybatis", (Double) myPlugin.get("loadMybatis") > 0.0);
|
||||
MyPlugin result = new MyPlugin();
|
||||
try {
|
||||
org.apache.commons.beanutils.BeanUtils.populate(result, myPlugin);
|
||||
@ -182,12 +181,13 @@ public class PluginService {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//BeanUtils.copyBean(result, myPlugin);
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从插件商城远程安装插件
|
||||
* 2.0版本实现
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ -14,8 +14,8 @@ public class SysAuthService {
|
||||
@Resource
|
||||
private ExtSysAuthMapper extSysAuthMapper;
|
||||
|
||||
public void checkTreeNoManageCount(String modelType,String nodeId){
|
||||
if(extSysAuthMapper.checkTreeNoManageCount(AuthUtils.getUser().getUserId(),modelType,nodeId)){
|
||||
public void checkTreeNoManageCount(String modelType, String nodeId) {
|
||||
if (extSysAuthMapper.checkTreeNoManageCount(AuthUtils.getUser().getUserId(), modelType, nodeId)) {
|
||||
throw new RuntimeException(Translator.get("i18n_no_all_delete_privilege_folder"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package io.dataease.service.sys;
|
||||
|
||||
import io.dataease.base.domain.SysRole;
|
||||
import io.dataease.base.mapper.ext.ExtSysRoleMapper;
|
||||
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.response.RoleUserItem;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -11,24 +10,19 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class SysRoleService {
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private ExtSysRoleMapper extSysRoleMapper;
|
||||
|
||||
|
||||
public List<SysRole> query(BaseGridRequest request){
|
||||
public List<SysRole> query(BaseGridRequest request) {
|
||||
List<SysRole> result = extSysRoleMapper.query(request.convertExample());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public List<RoleUserItem> allRoles(){
|
||||
public List<RoleUserItem> allRoles() {
|
||||
return extSysRoleMapper.queryAll();
|
||||
}
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ public class EmailService {
|
||||
JavaMailSenderImpl driver = driver(mailInfo);
|
||||
|
||||
MimeMessage mimeMessage = driver.createMimeMessage();
|
||||
MimeMessageHelper helper = null;
|
||||
MimeMessageHelper helper;
|
||||
try {
|
||||
helper = new MimeMessageHelper(mimeMessage, true);
|
||||
helper.setFrom(driver.getUsername());
|
||||
@ -83,7 +83,6 @@ public class EmailService {
|
||||
if (StringUtils.isBlank(to)) return ;
|
||||
MailInfo mailInfo = proxy().mailInfo();
|
||||
JavaMailSenderImpl driver = driver(mailInfo);
|
||||
|
||||
MimeMessage mimeMessage = driver.createMimeMessage();
|
||||
|
||||
MimeBodyPart image = new MimeBodyPart();
|
||||
@ -116,7 +115,7 @@ public class EmailService {
|
||||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
||||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
javaMailSender.setHost(mailInfo.getHost());
|
||||
javaMailSender.setPort(Integer.valueOf(mailInfo.getPort()));
|
||||
javaMailSender.setPort(Integer.parseInt(mailInfo.getPort()));
|
||||
javaMailSender.setUsername(mailInfo.getAccount());
|
||||
javaMailSender.setPassword(mailInfo.getPassword());
|
||||
Properties props = new Properties();
|
||||
@ -196,7 +195,7 @@ public class EmailService {
|
||||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
||||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
javaMailSender.setHost(hashMap.get(ParamConstants.MAIL.SERVER.getValue()));
|
||||
javaMailSender.setPort(Integer.valueOf(hashMap.get(ParamConstants.MAIL.PORT.getValue())));
|
||||
javaMailSender.setPort(Integer.parseInt(hashMap.get(ParamConstants.MAIL.PORT.getValue())));
|
||||
javaMailSender.setUsername(hashMap.get(ParamConstants.MAIL.ACCOUNT.getValue()));
|
||||
javaMailSender.setPassword(hashMap.get(ParamConstants.MAIL.PASSWORD.getValue()));
|
||||
Properties props = new Properties();
|
||||
@ -218,7 +217,7 @@ public class EmailService {
|
||||
}
|
||||
if(!StringUtils.isBlank(recipients)){
|
||||
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = null;
|
||||
MimeMessageHelper helper;
|
||||
try {
|
||||
helper = new MimeMessageHelper(mimeMessage, true);
|
||||
helper.setFrom(javaMailSender.getUsername());
|
||||
|
||||
@ -17,13 +17,13 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SystemParameterService {
|
||||
@ -46,10 +46,10 @@ public class SystemParameterService {
|
||||
for (SystemParameter param : paramList) {
|
||||
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.FRONT_TIME_OUT.getValue())) {
|
||||
result.setFrontTimeOut(param.getParamValue());
|
||||
}
|
||||
}
|
||||
if (StringUtils.equals(param.getParamKey(), ParamConstants.BASIC.MSG_TIME_OUT.getValue())) {
|
||||
result.setMsgTimeOut(param.getParamValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -69,10 +69,10 @@ public class SystemParameterService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void editBasic(List<SystemParameter> parameters) {
|
||||
public void editBasic(List<SystemParameter> parameters) {
|
||||
parameters.forEach(parameter -> {
|
||||
SystemParameterExample example = new SystemParameterExample();
|
||||
|
||||
|
||||
example.createCriteria().andParamKeyEqualTo(parameter.getParamKey());
|
||||
if (systemParameterMapper.countByExample(example) > 0) {
|
||||
systemParameterMapper.updateByPrimaryKey(parameter);
|
||||
@ -137,29 +137,29 @@ public class SystemParameterService {
|
||||
return dtoList;
|
||||
}
|
||||
|
||||
public void saveUIInfo(Map<String,List<SystemParameterDTO>> request, List<MultipartFile> bodyFiles) throws IOException {
|
||||
public void saveUIInfo(Map<String, List<SystemParameterDTO>> request, List<MultipartFile> bodyFiles) throws IOException {
|
||||
List<SystemParameterDTO> parameters = request.get("systemParams");
|
||||
if (null != bodyFiles)
|
||||
for (MultipartFile multipartFile : bodyFiles) {
|
||||
if (!multipartFile.isEmpty()) {
|
||||
//防止添加非图片文件
|
||||
try (InputStream input = multipartFile.getInputStream()) {
|
||||
try {
|
||||
// It's an image (only BMP, GIF, JPG and PNG are recognized).
|
||||
ImageIO.read(input).toString();
|
||||
} catch (Exception e) {
|
||||
DEException.throwException("Uploaded images do not meet the image format requirements");
|
||||
return;
|
||||
for (MultipartFile multipartFile : bodyFiles) {
|
||||
if (!multipartFile.isEmpty()) {
|
||||
//防止添加非图片文件
|
||||
try (InputStream input = multipartFile.getInputStream()) {
|
||||
try {
|
||||
// It's an image (only BMP, GIF, JPG and PNG are recognized).
|
||||
ImageIO.read(input).toString();
|
||||
} catch (Exception e) {
|
||||
DEException.throwException("Uploaded images do not meet the image format requirements");
|
||||
return;
|
||||
}
|
||||
}
|
||||
String multipartFileName = multipartFile.getOriginalFilename();
|
||||
String[] split = Objects.requireNonNull(multipartFileName).split(",");
|
||||
parameters.stream().filter(systemParameterDTO -> systemParameterDTO.getParamKey().equalsIgnoreCase(split[1])).forEach(systemParameterDTO -> {
|
||||
systemParameterDTO.setFileName(split[0]);
|
||||
systemParameterDTO.setFile(multipartFile);
|
||||
});
|
||||
}
|
||||
String multipartFileName = multipartFile.getOriginalFilename();
|
||||
String[] split = Objects.requireNonNull(multipartFileName).split(",");
|
||||
parameters.stream().filter(systemParameterDTO -> systemParameterDTO.getParamKey().equalsIgnoreCase(split[1])).forEach(systemParameterDTO -> {
|
||||
systemParameterDTO.setFileName(split[0]);
|
||||
systemParameterDTO.setFile(multipartFile);
|
||||
});
|
||||
}
|
||||
}
|
||||
for (SystemParameterDTO systemParameter : parameters) {
|
||||
MultipartFile file = systemParameter.getFile();
|
||||
if (systemParameter.getType().equalsIgnoreCase("file")) {
|
||||
@ -168,7 +168,7 @@ public class SystemParameterService {
|
||||
}
|
||||
if (file != null) {
|
||||
fileService.deleteFileById(systemParameter.getParamValue());
|
||||
FileMetadata fileMetadata = fileService.saveFile(systemParameter.getFile(),systemParameter.getFileName());
|
||||
FileMetadata fileMetadata = fileService.saveFile(systemParameter.getFile(), systemParameter.getFileName());
|
||||
systemParameter.setParamValue(fileMetadata.getId());
|
||||
}
|
||||
if (file == null && systemParameter.getFileName() == null) {
|
||||
|
||||
@ -8,7 +8,6 @@ import javax.websocket.server.ServerEndpointConfig;
|
||||
public class ServerEndpointConfigurator extends ServerEndpointConfig.Configurator {
|
||||
@Override
|
||||
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
|
||||
|
||||
super.modifyHandshake(sec, request, response);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ CREATE TABLE `sys_msg` (
|
||||
KEY `inx_msg_userid` (`user_id`) USING BTREE,
|
||||
KEY `inx_msg_type` (`type_id`) USING BTREE,
|
||||
KEY `inx_msg_status` (`status`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='消息通知表';
|
||||
) COMMENT='消息通知表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_msg_channel
|
||||
@ -23,7 +23,7 @@ CREATE TABLE `sys_msg_channel` (
|
||||
`msg_channel_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`channel_name` varchar(255) DEFAULT NULL COMMENT '渠道名称',
|
||||
PRIMARY KEY (`msg_channel_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='消息渠道表';
|
||||
) AUTO_INCREMENT=4 COMMENT='消息渠道表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_msg_channel
|
||||
@ -44,7 +44,7 @@ CREATE TABLE `sys_msg_type` (
|
||||
`callback` varchar(255) DEFAULT NULL COMMENT '回调方法',
|
||||
PRIMARY KEY (`msg_type_id`) USING BTREE,
|
||||
KEY `inx_msgtype_pid` (`pid`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='消息类型表';
|
||||
) AUTO_INCREMENT=7 COMMENT='消息类型表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_msg_type
|
||||
@ -68,7 +68,7 @@ CREATE TABLE `sys_msg_setting` (
|
||||
`channel_id` bigint(20) NOT NULL COMMENT '渠道ID',
|
||||
`enable` tinyint(1) DEFAULT NULL COMMENT '是否启用',
|
||||
PRIMARY KEY (`msg_setting_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='消息设置表';
|
||||
) AUTO_INCREMENT=1 COMMENT='消息设置表';
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO `sys_menu` VALUES (53, 1, 3, 1, '站内消息', 'sys-msg-web', 'msg/index', 1000, 'all-msg', 'system-msg-web', b'0', b'0', b'0', NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
@ -9,4 +9,4 @@ CREATE TABLE `panel_view` (
|
||||
`update_by` varchar(255) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` bigint(13) DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
@ -7,4 +7,4 @@ CREATE TABLE `area_mapping` (
|
||||
`county_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '县名称',
|
||||
`county_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '县代码',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci;
|
||||
) ;
|
||||
|
||||
@ -6,29 +6,29 @@ CREATE TABLE `demo_olympiad_athlete` (
|
||||
`game` varchar(255) DEFAULT NULL,
|
||||
`hot_num` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
);
|
||||
|
||||
CREATE TABLE `demo_olympiad_audience_age` (
|
||||
`age` varchar(255) NOT NULL,
|
||||
`percent` float(255,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`age`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `demo_olympiad_audience_sex` (
|
||||
`sex` varchar(255) NOT NULL,
|
||||
`percent` float(255,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`sex`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `demo_olympiad_country` (
|
||||
`code` varchar(255) NOT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
);
|
||||
|
||||
CREATE TABLE `demo_olympiad_data_update` (
|
||||
`update_date` datetime DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `demo_olympiad_gold_date` (
|
||||
`id` varchar(255) NOT NULL,
|
||||
@ -36,26 +36,27 @@ CREATE TABLE `demo_olympiad_gold_date` (
|
||||
`game` varchar(255) DEFAULT NULL,
|
||||
`qty` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `demo_olympiad_hot_game` (
|
||||
`code` varchar(255) NOT NULL,
|
||||
`sort` varchar(255) DEFAULT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `demo_olympiad_medal` (
|
||||
`code` int(11) NOT NULL,
|
||||
`name` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `demo_olympiad_medal_qty` (
|
||||
`id` varchar(255) DEFAULT NULL,
|
||||
`country` varchar(255) DEFAULT NULL,
|
||||
`medal` varchar(255) DEFAULT NULL,
|
||||
`qty` varchar(255) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
|
||||
CREATE TABLE `demo_sales_dashboard` (
|
||||
@ -66,7 +67,7 @@ CREATE TABLE `demo_sales_dashboard` (
|
||||
`sales_qty` int(11) DEFAULT NULL,
|
||||
`sales_amount` int(255) DEFAULT NULL,
|
||||
`target_qty` int(11) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
|
||||
INSERT INTO `demo_olympiad_athlete` (`code`,`sort`,`name`,`country`,`game`,`hot_num`) VALUES ('1',1,'郑妮娜力','1','3',37770);
|
||||
@ -230,12 +231,11 @@ SET FOREIGN_KEY_CHECKS = 0;
|
||||
-- ----------------------------
|
||||
-- Table structure for demo_new_trend_of_diagnosis
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `demo_new_trend_of_diagnosis`;
|
||||
CREATE TABLE `demo_new_trend_of_diagnosis` (
|
||||
`date` varchar(50) NOT NULL DEFAULT '' COMMENT '日期',
|
||||
`new_diagnosis` bigint(13) DEFAULT NULL COMMENT '新增确诊',
|
||||
`current_diagnosis` bigint(13) DEFAULT NULL COMMENT '现有确诊'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
`date` varchar(50) NOT NULL DEFAULT '' COMMENT '日期',
|
||||
`new_diagnosis` bigint(13) DEFAULT NULL COMMENT '新增确诊',
|
||||
`current_diagnosis` bigint(13) DEFAULT NULL COMMENT '现有确诊'
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of demo_new_trend_of_diagnosis
|
||||
|
||||
@ -13,14 +13,14 @@ SET FOREIGN_KEY_CHECKS = 0;
|
||||
-- Table structure for dataset_table_function
|
||||
-- ----------------------------
|
||||
CREATE TABLE `dataset_table_function` (
|
||||
`id` bigint(20) NOT NULL COMMENT 'ID',
|
||||
`name` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '函数名称',
|
||||
`func` varchar(500) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '函数表达式',
|
||||
`db_type` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '所属数据库',
|
||||
`func_type` int(10) DEFAULT NULL COMMENT '函数类型:0-聚合函数;1-快速计算函数;2-数学和三角函数;3-日期函数;4-文本函数;5-逻辑函数;6-其它函数',
|
||||
`desc` longtext COLLATE utf8mb4_bin COMMENT '描述',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
||||
`id` bigint(20) NOT NULL COMMENT 'ID',
|
||||
`name` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '函数名称',
|
||||
`func` varchar(500) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '函数表达式',
|
||||
`db_type` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '所属数据库',
|
||||
`func_type` int(10) DEFAULT NULL COMMENT '函数类型:0-聚合函数;1-快速计算函数;2-数学和三角函数;3-日期函数;4-文本函数;5-逻辑函数;6-其它函数',
|
||||
`desc` longtext COLLATE utf8mb4_bin COMMENT '描述',
|
||||
PRIMARY KEY (`id`)
|
||||
) ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of dataset_table_function
|
||||
@ -171,7 +171,7 @@ CREATE TABLE `area_mapping` (
|
||||
`county_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '县名称',
|
||||
`county_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '县代码',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci;
|
||||
) ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of area_mapping
|
||||
|
||||
@ -14,7 +14,7 @@ CREATE TABLE `panel_view_linkage` (
|
||||
`ext1` varchar(2000) DEFAULT NULL,
|
||||
`ext2` varchar(2000) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for panel_view_linkage_field
|
||||
@ -26,6 +26,6 @@ CREATE TABLE `panel_view_linkage_field` (
|
||||
`target_field` varchar(255) DEFAULT NULL COMMENT '目标视图字段',
|
||||
`update_time` bigint(13) DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@ -11,4 +11,4 @@ CREATE TABLE `user_key` (
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `IDX_AK` (`access_key`),
|
||||
KEY `IDX_USER_K_ID` (`user_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户KEY';
|
||||
) AUTO_INCREMENT=17 ROW_FORMAT=COMPACT COMMENT='用户KEY';
|
||||
|
||||
@ -12,7 +12,7 @@ CREATE TABLE `demo_gdp_2021` (
|
||||
`2020GDP` varchar(255) DEFAULT NULL,
|
||||
`increase` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
|
||||
) AUTO_INCREMENT=10 ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of demo_gdp_2021
|
||||
@ -30,7 +30,7 @@ CREATE TABLE `demo_gdp_by_city` (
|
||||
`city` varchar(255) DEFAULT NULL,
|
||||
`gdp` double(255,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=309 DEFAULT CHARSET=utf8;
|
||||
)AUTO_INCREMENT=309 ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of demo_gdp_by_city
|
||||
@ -354,7 +354,7 @@ CREATE TABLE `demo_gdp_by_city_top10` (
|
||||
`province` varchar(255) DEFAULT NULL,
|
||||
`city` varchar(255) DEFAULT NULL,
|
||||
`gdp` double(255,2) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of demo_gdp_by_city_top10
|
||||
@ -380,7 +380,7 @@ CREATE TABLE `demo_gdp_by_industry` (
|
||||
`industry` varchar(255) DEFAULT NULL,
|
||||
`GDP` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
|
||||
) AUTO_INCREMENT=4;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of demo_gdp_by_industry
|
||||
@ -399,7 +399,7 @@ CREATE TABLE `demo_gdp_district_top100` (
|
||||
`province` varchar(255) DEFAULT NULL,
|
||||
`num` int(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
|
||||
) AUTO_INCREMENT=17 ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of demo_gdp_district_top100
|
||||
@ -432,7 +432,7 @@ CREATE TABLE `demo_gdp_history` (
|
||||
`gdp` double(255,2) DEFAULT NULL,
|
||||
`percent` double(255,2) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
|
||||
) AUTO_INCREMENT=11;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of demo_gdp_history
|
||||
|
||||
@ -18,7 +18,7 @@ CREATE TABLE `panel_pdf_template` (
|
||||
`template_content` longtext COMMENT '模板内容',
|
||||
`sort` int(8) DEFAULT NULL COMMENT '排序',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
INSERT INTO `panel_pdf_template` (`id`, `name`, `create_time`, `create_user`, `template_content`, `sort`) VALUES ('1', '默认模板(加参数样式)', NULL, NULL, '<div style=\"margin-top: 5px\">\n <div contenteditable=\"true\"> \n 仪表板名称:$panelName$ </br>\n 导出时间:$yyyy-MM-dd hh:mm:ss$ </br>\n 导出人:$nickName$ </br>\n 这里可以输入其他内容\n </div>\n <div>\n <img width=\"100%\" src=\"$snapshot$\">\n </div>\n </div>', 1);
|
||||
INSERT INTO `panel_pdf_template` (`id`, `name`, `create_time`, `create_user`, `template_content`, `sort`) VALUES ('2', '默认模板(只截图)', NULL, NULL, '\n<div style=\"margin-top: 5px\">\n <div>\n <img width=\"100%\" src=\"$snapshot$\">\n </div>\n </div>', 2);
|
||||
|
||||
@ -2,11 +2,8 @@ ALTER TABLE `chart_view` ADD COLUMN `render` varchar(50) COMMENT '视图渲染
|
||||
UPDATE `chart_view` SET `render` = 'echarts' WHERE `type` != 'liquid';
|
||||
UPDATE `chart_view` SET `render` = 'antv' WHERE `type` = 'liquid';
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `panel_link` ADD COLUMN `over_time` bigint(13) NULL DEFAULT NULL COMMENT '有效截止时间' AFTER `pwd`;
|
||||
|
||||
|
||||
CREATE TABLE `panel_link_jump` (
|
||||
`id` varchar(50) NOT NULL,
|
||||
`source_panel_id` varchar(50) DEFAULT NULL COMMENT '源仪表板ID',
|
||||
@ -14,7 +11,7 @@ CREATE TABLE `panel_link_jump` (
|
||||
`link_jump_info` varchar(4000) DEFAULT NULL COMMENT '跳转信息',
|
||||
`checked` tinyint(1) DEFAULT NULL COMMENT '是否启用',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `panel_link_jump_info` (
|
||||
`id` varchar(50) NOT NULL,
|
||||
@ -26,7 +23,7 @@ CREATE TABLE `panel_link_jump_info` (
|
||||
`content` varchar(4000) DEFAULT NULL COMMENT '内容 linkType = outer时使用',
|
||||
`checked` tinyint(1) DEFAULT NULL COMMENT '是否可用',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `panel_link_jump_target_view_info` (
|
||||
`target_id` varchar(50) NOT NULL,
|
||||
@ -34,7 +31,7 @@ CREATE TABLE `panel_link_jump_target_view_info` (
|
||||
`target_view_id` varchar(50) DEFAULT NULL,
|
||||
`target_field_id` varchar(50) DEFAULT NULL,
|
||||
PRIMARY KEY (`target_id`) USING BTREE
|
||||
) ENGINE=InnoDB ;
|
||||
);
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO `sys_menu` VALUES (6, 1, 0, 1, '系统参数', 'system-param', 'system/SysParam/index', 6, 'sys-tools', 'system-param', b'0', b'0', b'0', 'sysparam:read', NULL, NULL, NULL, NULL);
|
||||
@ -56,7 +53,6 @@ ALTER TABLE `dataset_table`
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_theme
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_theme`;
|
||||
CREATE TABLE `sys_theme` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主题id',
|
||||
`name` varchar(255) NOT NULL COMMENT '主题名称',
|
||||
@ -64,7 +60,7 @@ CREATE TABLE `sys_theme` (
|
||||
`img` varchar(255) DEFAULT NULL COMMENT '主题缩略图',
|
||||
`status` tinyint(1) DEFAULT NULL COMMENT '状态',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
|
||||
) AUTO_INCREMENT=4 ROW_FORMAT=COMPACT;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_theme
|
||||
@ -82,12 +78,11 @@ SET FOREIGN_KEY_CHECKS = 1;
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_theme_item
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sys_theme_item`;
|
||||
CREATE TABLE `sys_theme_item` (
|
||||
`theme_id` bigint(20) NOT NULL COMMENT '主题ID',
|
||||
`key` varchar(255) DEFAULT NULL COMMENT '样式key',
|
||||
`val` varchar(255) DEFAULT NULL COMMENT '样式val'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_theme_item
|
||||
|
||||
@ -1,29 +1,26 @@
|
||||
-- ----------------------------
|
||||
-- 新增我分享出去的功能
|
||||
-- ----------------------------
|
||||
ALTER TABLE `dataease`.`panel_share`
|
||||
ALTER TABLE `panel_share`
|
||||
ADD COLUMN `granter` varchar(255) NULL COMMENT '分享人' AFTER `target_id`;
|
||||
|
||||
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for panel_link_mapping
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `panel_link_mapping`;
|
||||
CREATE TABLE `panel_link_mapping` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`resource_id` varchar(255) DEFAULT NULL COMMENT '仪表板ID',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
) AUTO_INCREMENT=1 ;
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- 策略模式优化发送消息
|
||||
-- ----------------------------
|
||||
ALTER TABLE `dataease`.`sys_msg_channel`
|
||||
ALTER TABLE `sys_msg_channel`
|
||||
ADD COLUMN `service_name` varchar(255) NULL COMMENT '策略名称' AFTER `channel_name`;
|
||||
|
||||
|
||||
UPDATE `dataease`.`sys_msg_channel` SET `service_name` = 'sendStation' WHERE `msg_channel_id` = 1;
|
||||
INSERT INTO `dataease`.`sys_msg_channel`(`msg_channel_id`, `channel_name`, `service_name`) VALUES (2, 'webmsg.channel_email_msg', 'sendEmail');
|
||||
UPDATE `sys_msg_channel` SET `service_name` = 'sendStation' WHERE `msg_channel_id` = 1;
|
||||
INSERT INTO `sys_msg_channel`(`msg_channel_id`, `channel_name`, `service_name`) VALUES (2, 'webmsg.channel_email_msg', 'sendEmail');
|
||||
|
||||
@ -2,9 +2,7 @@ CREATE TABLE IF NOT EXISTS `file_content` (
|
||||
`file_id` varchar(64) NOT NULL COMMENT 'File ID',
|
||||
`file` longblob COMMENT 'File content',
|
||||
PRIMARY KEY (`file_id`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `file_metadata` (
|
||||
`id` varchar(64) NOT NULL COMMENT 'File ID',
|
||||
@ -14,7 +12,7 @@ CREATE TABLE IF NOT EXISTS `file_metadata` (
|
||||
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
||||
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `system_parameter` (
|
||||
`param_key` varchar(64) CHARACTER SET utf8mb4 NOT NULL COMMENT 'Parameter name',
|
||||
@ -22,22 +20,20 @@ CREATE TABLE IF NOT EXISTS `system_parameter` (
|
||||
`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;
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE `datasource` (
|
||||
`id` varchar(50) NOT NULL DEFAULT '' COMMENT 'ID',
|
||||
`name` varchar(50) NOT NULL COMMENT '名称',
|
||||
`desc` varchar(50) COMMENT '描述',
|
||||
`type` varchar(50) NOT NULL COMMENT '类型',
|
||||
`configuration` longtext NOT NULL COMMENT '详细信息',
|
||||
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
||||
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
||||
`create_by` varchar(50) COMMENT '创建人ID',
|
||||
PRIMARY KEY (`id`)
|
||||
)ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
CREATE TABLE IF NOT EXISTS `datasource`(
|
||||
`id` varchar(50) NOT NULL DEFAULT '' COMMENT 'ID',
|
||||
`name` varchar(50) NOT NULL COMMENT '名称',
|
||||
`desc` varchar(50) COMMENT '描述',
|
||||
`type` varchar(50) NOT NULL COMMENT '类型',
|
||||
`configuration` longtext NOT NULL COMMENT '详细信息',
|
||||
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
||||
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
||||
`create_by` varchar(50) COMMENT '创建人ID',
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `dataset_group` (
|
||||
`id` varchar(50) NOT NULL COMMENT 'ID',
|
||||
@ -48,9 +44,7 @@ CREATE TABLE IF NOT EXISTS `dataset_group` (
|
||||
`create_by` varchar(50) COMMENT '创建人ID',
|
||||
`create_time` bigint(13) COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
);
|
||||
|
||||
CREATE TABLE `sys_dept` (
|
||||
`dept_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
@ -64,7 +58,7 @@ CREATE TABLE `sys_dept` (
|
||||
`update_time` bigint(13) DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`dept_id`) USING BTREE,
|
||||
KEY `inx_pid` (`pid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='组织机构';
|
||||
) AUTO_INCREMENT=2 ROW_FORMAT=COMPACT COMMENT='组织机构';
|
||||
|
||||
CREATE TABLE `sys_menu` (
|
||||
`menu_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
@ -89,7 +83,7 @@ CREATE TABLE `sys_menu` (
|
||||
UNIQUE KEY `uniq_title` (`title`),
|
||||
UNIQUE KEY `uniq_name` (`name`),
|
||||
KEY `inx_pid` (`pid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统菜单';
|
||||
) AUTO_INCREMENT=53 ROW_FORMAT=COMPACT COMMENT='系统菜单';
|
||||
|
||||
CREATE TABLE `sys_user` (
|
||||
`user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
@ -115,7 +109,7 @@ CREATE TABLE `sys_user` (
|
||||
UNIQUE KEY `uniq_email` (`email`),
|
||||
KEY `FK5rwmryny6jthaaxkogownknqp` (`dept_id`) USING BTREE,
|
||||
KEY `inx_enabled` (`enabled`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='系统用户';
|
||||
) AUTO_INCREMENT=3 ROW_FORMAT=COMPACT COMMENT='系统用户';
|
||||
|
||||
CREATE TABLE `sys_role` (
|
||||
`role_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
@ -128,21 +122,21 @@ CREATE TABLE `sys_role` (
|
||||
PRIMARY KEY (`role_id`) USING BTREE,
|
||||
UNIQUE KEY `uniq_name` (`name`),
|
||||
KEY `role_name_index` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色表';
|
||||
) AUTO_INCREMENT=3 ROW_FORMAT=COMPACT COMMENT='角色表';
|
||||
|
||||
CREATE TABLE `sys_roles_menus` (
|
||||
`menu_id` bigint(20) NOT NULL COMMENT '菜单ID',
|
||||
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
|
||||
PRIMARY KEY (`menu_id`,`role_id`) USING BTREE,
|
||||
KEY `FKcngg2qadojhi3a651a5adkvbq` (`role_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='角色菜单关联';
|
||||
) ROW_FORMAT=COMPACT COMMENT='角色菜单关联';
|
||||
|
||||
CREATE TABLE `sys_users_roles` (
|
||||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||
`role_id` bigint(20) NOT NULL COMMENT '角色ID',
|
||||
PRIMARY KEY (`user_id`,`role_id`) USING BTREE,
|
||||
KEY `FKq4eq273l04bpu4efj0jd0jb98` (`role_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='用户角色关联';
|
||||
) ROW_FORMAT=COMPACT COMMENT='用户角色关联';
|
||||
|
||||
CREATE TABLE `my_plugin` (
|
||||
`plugin_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
@ -161,7 +155,7 @@ CREATE TABLE `my_plugin` (
|
||||
`module_name` varchar(255) DEFAULT NULL COMMENT 'jar包名称',
|
||||
`icon` varchar(255) DEFAULT NULL COMMENT '图标',
|
||||
PRIMARY KEY (`plugin_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='插件表';
|
||||
) AUTO_INCREMENT=2 ROW_FORMAT=COMPACT COMMENT='插件表';
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `dataset_table`
|
||||
@ -176,8 +170,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table`
|
||||
`create_by` varchar(50) COMMENT '创建人ID',
|
||||
`create_time` bigint(13) COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `dataset_table_field` (
|
||||
`id` varchar(50) NOT NULL COMMENT 'ID',
|
||||
@ -195,7 +188,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table_field` (
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `IDX_TABLE_ID` (`table_id`),
|
||||
KEY `IDX_DE_TYPE` (`de_type`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `dataset_table_task`
|
||||
(
|
||||
@ -211,8 +204,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table_task`
|
||||
`create_time` bigint(13) COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `IDX_TABLE_ID` (`table_id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `dataset_table_task_log` (
|
||||
`id` varchar(50) NOT NULL COMMENT 'ID',
|
||||
@ -225,7 +217,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table_task_log` (
|
||||
`create_time` bigint(13) DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `IDX_TABLE_ID` (`task_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
-- chart start
|
||||
CREATE TABLE IF NOT EXISTS `chart_group`
|
||||
@ -238,8 +230,7 @@ CREATE TABLE IF NOT EXISTS `chart_group`
|
||||
`create_by` varchar(50) COMMENT '创建人ID',
|
||||
`create_time` bigint(13) COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `chart_view` (
|
||||
`id` varchar(50) NOT NULL COMMENT 'ID',
|
||||
@ -260,7 +251,7 @@ CREATE TABLE `chart_view` (
|
||||
`style_priority` varchar(255) DEFAULT 'panel' COMMENT '样式优先级 panel 仪表板 view 视图',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `IDX_TABLE_ID` (`table_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
-- chart end
|
||||
|
||||
@ -275,7 +266,7 @@ CREATE TABLE `panel_design` (
|
||||
`update_time` bigint(13) DEFAULT NULL COMMENT '修改时间',
|
||||
`update_person` varchar(255) DEFAULT NULL COMMENT '修改人',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='仪表板和组件的关联关系 组件分为普通视图和系统组件';
|
||||
) COMMENT='仪表板和组件的关联关系 组件分为普通视图和系统组件';
|
||||
|
||||
CREATE TABLE `panel_group` (
|
||||
`id` varchar(50) NOT NULL,
|
||||
@ -293,7 +284,7 @@ CREATE TABLE `panel_group` (
|
||||
`extend2` varchar(255) DEFAULT NULL,
|
||||
`remark` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
|
||||
CREATE TABLE `panel_view` (
|
||||
@ -305,7 +296,7 @@ CREATE TABLE `panel_view` (
|
||||
`update_by` varchar(255) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` bigint(13) DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
);
|
||||
|
||||
CREATE TABLE `panel_store` (
|
||||
`store_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
@ -314,7 +305,7 @@ CREATE TABLE `panel_store` (
|
||||
`create_time` bigint(13) DEFAULT NULL COMMENT '创建日期',
|
||||
PRIMARY KEY (`store_id`) USING BTREE,
|
||||
KEY `UK_store_user_id` (`user_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='仪表板收藏';
|
||||
) AUTO_INCREMENT=7 ROW_FORMAT=COMPACT COMMENT='仪表板收藏';
|
||||
|
||||
|
||||
CREATE TABLE `panel_share` (
|
||||
@ -327,7 +318,7 @@ CREATE TABLE `panel_share` (
|
||||
KEY `UK_share_arget_id` (`target_id`) ,
|
||||
KEY `UK_share_panel_group_id` (`panel_group_id`) ,
|
||||
KEY `UK_share_type` (`type`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='仪表板分享';
|
||||
) AUTO_INCREMENT=7 ROW_FORMAT=COMPACT COMMENT='仪表板分享';
|
||||
|
||||
CREATE TABLE `panel_link` (
|
||||
`resource_id` varchar(50) NOT NULL COMMENT '资源ID',
|
||||
@ -335,7 +326,7 @@ CREATE TABLE `panel_link` (
|
||||
`enable_pwd` tinyint(1) default 0 COMMENT '启用密码',
|
||||
`pwd` varchar(255) DEFAULT NULL COMMENT '密码',
|
||||
PRIMARY KEY (`resource_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='仪表板链接';
|
||||
) ROW_FORMAT=COMPACT COMMENT='仪表板链接';
|
||||
|
||||
CREATE TABLE `panel_template` (
|
||||
`id` varchar(50) NOT NULL,
|
||||
@ -351,7 +342,7 @@ CREATE TABLE `panel_template` (
|
||||
`template_data` longtext COMMENT 'template 数据',
|
||||
`dynamic_data` longtext COMMENT '预存数据',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `panel_subject` (
|
||||
`id` varchar(50) NOT NULL,
|
||||
@ -363,7 +354,7 @@ CREATE TABLE `panel_subject` (
|
||||
`update_time` bigint(13) DEFAULT NULL COMMENT '更新时间',
|
||||
`update_by` varchar(255) DEFAULT NULL COMMENT '更新人',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `dataset_table_incremental_config`
|
||||
(
|
||||
@ -372,8 +363,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table_incremental_config`
|
||||
`incremental_delete` longtext COMMENT '详细信息',
|
||||
`incremental_add` longtext COMMENT '详细信息',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `dataset_table_union`
|
||||
(
|
||||
@ -387,8 +377,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table_union`
|
||||
`create_by` varchar(50) COMMENT '创建人ID',
|
||||
`create_time` bigint(13) COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
);
|
||||
|
||||
CREATE TABLE `license` (
|
||||
`id` varchar(50) NOT NULL,
|
||||
@ -396,7 +385,7 @@ CREATE TABLE `license` (
|
||||
`license` longtext COMMENT 'license',
|
||||
`f2c_license` longtext COMMENT 'F2C License',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE `plugin_sys_menu` (
|
||||
@ -420,4 +409,4 @@ CREATE TABLE `plugin_sys_menu` (
|
||||
`update_time` bigint(13) DEFAULT NULL,
|
||||
`no_layout` tinyint(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`menu_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
);
|
||||
|
||||
@ -13,7 +13,7 @@ CREATE TABLE `qrtz_job_details` (
|
||||
PRIMARY KEY (`SCHED_NAME`,`JOB_NAME`,`JOB_GROUP`),
|
||||
KEY `IDX_QRTZ_J_REQ_RECOVERY` (`SCHED_NAME`,`REQUESTS_RECOVERY`),
|
||||
KEY `IDX_QRTZ_J_GRP` (`SCHED_NAME`,`JOB_GROUP`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_triggers` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
@ -46,7 +46,7 @@ CREATE TABLE `qrtz_triggers` (
|
||||
KEY `IDX_QRTZ_T_NFT_ST_MISFIRE` (`SCHED_NAME`,`MISFIRE_INSTR`,`NEXT_FIRE_TIME`,`TRIGGER_STATE`),
|
||||
KEY `IDX_QRTZ_T_NFT_ST_MISFIRE_GRP` (`SCHED_NAME`,`MISFIRE_INSTR`,`NEXT_FIRE_TIME`,`TRIGGER_GROUP`,`TRIGGER_STATE`),
|
||||
CONSTRAINT `qrtz_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) REFERENCES `qrtz_job_details` (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_blob_triggers` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
@ -56,14 +56,14 @@ CREATE TABLE `qrtz_blob_triggers` (
|
||||
PRIMARY KEY (`SCHED_NAME`,`TRIGGER_NAME`,`TRIGGER_GROUP`),
|
||||
KEY `SCHED_NAME` (`SCHED_NAME`,`TRIGGER_NAME`,`TRIGGER_GROUP`),
|
||||
CONSTRAINT `qrtz_blob_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) REFERENCES `qrtz_triggers` (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_calendars` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
`CALENDAR_NAME` varchar(200) NOT NULL,
|
||||
`CALENDAR` blob NOT NULL,
|
||||
PRIMARY KEY (`SCHED_NAME`,`CALENDAR_NAME`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_cron_triggers` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
@ -73,7 +73,7 @@ CREATE TABLE `qrtz_cron_triggers` (
|
||||
`TIME_ZONE_ID` varchar(80) DEFAULT NULL,
|
||||
PRIMARY KEY (`SCHED_NAME`,`TRIGGER_NAME`,`TRIGGER_GROUP`),
|
||||
CONSTRAINT `qrtz_cron_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) REFERENCES `qrtz_triggers` (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_fired_triggers` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
@ -96,19 +96,19 @@ CREATE TABLE `qrtz_fired_triggers` (
|
||||
KEY `IDX_QRTZ_FT_JG` (`SCHED_NAME`,`JOB_GROUP`),
|
||||
KEY `IDX_QRTZ_FT_T_G` (`SCHED_NAME`,`TRIGGER_NAME`,`TRIGGER_GROUP`),
|
||||
KEY `IDX_QRTZ_FT_TG` (`SCHED_NAME`,`TRIGGER_GROUP`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_locks` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
`LOCK_NAME` varchar(40) NOT NULL,
|
||||
PRIMARY KEY (`SCHED_NAME`,`LOCK_NAME`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_paused_trigger_grps` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
`TRIGGER_GROUP` varchar(200) NOT NULL,
|
||||
PRIMARY KEY (`SCHED_NAME`,`TRIGGER_GROUP`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_scheduler_state` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
@ -116,7 +116,7 @@ CREATE TABLE `qrtz_scheduler_state` (
|
||||
`LAST_CHECKIN_TIME` bigint(13) NOT NULL,
|
||||
`CHECKIN_INTERVAL` bigint(13) NOT NULL,
|
||||
PRIMARY KEY (`SCHED_NAME`,`INSTANCE_NAME`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_simple_triggers` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
@ -127,7 +127,7 @@ CREATE TABLE `qrtz_simple_triggers` (
|
||||
`TIMES_TRIGGERED` bigint(10) NOT NULL,
|
||||
PRIMARY KEY (`SCHED_NAME`,`TRIGGER_NAME`,`TRIGGER_GROUP`),
|
||||
CONSTRAINT `qrtz_simple_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) REFERENCES `qrtz_triggers` (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
CREATE TABLE `qrtz_simprop_triggers` (
|
||||
`SCHED_NAME` varchar(120) NOT NULL,
|
||||
@ -146,7 +146,7 @@ CREATE TABLE `qrtz_simprop_triggers` (
|
||||
`BOOL_PROP_2` varchar(1) DEFAULT NULL,
|
||||
PRIMARY KEY (`SCHED_NAME`,`TRIGGER_NAME`,`TRIGGER_GROUP`),
|
||||
CONSTRAINT `qrtz_simprop_triggers_ibfk_1` FOREIGN KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) REFERENCES `qrtz_triggers` (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
) ;
|
||||
|
||||
-- quartz end
|
||||
|
||||
@ -163,4 +163,4 @@ CREATE TABLE IF NOT EXISTS `schedule` (
|
||||
`custom_data` longtext COMMENT 'Custom Data (JSON format)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `resource_id` ( `resource_id` )
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
|
||||
) ;
|
||||
|
||||
@ -19,7 +19,7 @@ CREATE TABLE `sys_auth` (
|
||||
`auth_user` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '授权人员',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci;
|
||||
) ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_auth_detail
|
||||
@ -36,7 +36,7 @@ CREATE TABLE `sys_auth_detail` (
|
||||
`create_time` bigint(13) NULL DEFAULT NULL,
|
||||
`update_time` bigint(13) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci;
|
||||
) ;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sys_auth_detail
|
||||
|
||||
@ -5,8 +5,7 @@ CREATE TABLE `demo_recent_local_cases` (
|
||||
`existing` bigint(13) COMMENT '现有',
|
||||
`risk` varchar(50) NOT NULL COMMENT '区域风险',
|
||||
PRIMARY KEY (`city`)
|
||||
)ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
);
|
||||
|
||||
|
||||
INSERT INTO `demo_recent_local_cases` (`city`, `province`, `new_add`, `existing`, `risk`) VALUES ('广州', '广东', '8', '106', '部分中高风险');
|
||||
@ -21,8 +20,7 @@ CREATE TABLE `demo_vaccination` (
|
||||
`cumulative` DECIMAL(10,2) NOT NULL COMMENT '累计接种',
|
||||
`new_add` DECIMAL(10,2) COMMENT '较上日新增',
|
||||
`vaccination_per_100_people` DECIMAL(10,2) NOT NULL COMMENT '每百人接种'
|
||||
)ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
);
|
||||
|
||||
INSERT INTO `demo_vaccination` (`cumulative`, `new_add`, `vaccination_per_100_people`) VALUES (7.9, 1625.5, 55.17);
|
||||
|
||||
@ -35,8 +33,7 @@ CREATE TABLE `demo_domestic_epidemic` (
|
||||
`asymptomatic_patient` bigint(13) COMMENT '无症状感染者',
|
||||
`input` bigint(13) COMMENT '境外输入',
|
||||
`cumulative_death` bigint(13) COMMENT '累计死亡'
|
||||
)ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
);
|
||||
|
||||
INSERT INTO `demo_domestic_epidemic` (`statistical_time`, `cumulative_cure`, `current_diagnosis`, `cumulative_diagnosis`, `asymptomatic_patient`, `input` , `cumulative_death`) VALUES ('2021-06-09 10:24:27 ', 99071, 10740, 114929, 361, 6173, 5154);
|
||||
|
||||
|
||||
@ -278,8 +278,8 @@ i18n_msg_type_dataset_sync=Data set synchronization
|
||||
i18n_msg_type_dataset_sync_success=Dataset synchronization successful
|
||||
i18n_msg_type_dataset_sync_faild=Dataset synchronization failed
|
||||
i18n_data_not_sync=Please sync data first
|
||||
i18n_excel_colume_change=The column name of Excel is inconsistent with the original data set
|
||||
i18n_excel_colume_inconsistent=The column names of the selected sheet pages are inconsistent
|
||||
i18n_excel_column_change=The column name of Excel is inconsistent with the original data set
|
||||
i18n_excel_column_inconsistent=The column names of the selected sheet pages are inconsistent
|
||||
i18n_timed_task=Timed Task
|
||||
i18n_datasource_connect_error=Data source connection exception:
|
||||
i18n_check_sql_error=Check incremental SQL exception,
|
||||
|
||||
@ -277,8 +277,8 @@ i18n_msg_type_dataset_sync=数据集同步
|
||||
i18n_msg_type_dataset_sync_success=数据集同步成功
|
||||
i18n_msg_type_dataset_sync_faild=数据集同步失败
|
||||
i18n_data_not_sync=请先完成数据同步
|
||||
i18n_excel_colume_change=Excel的列名与原数据集不一致
|
||||
i18n_excel_colume_inconsistent=所选sheet页面的列名不一致
|
||||
i18n_excel_column_change=Excel的列名与原数据集不一致
|
||||
i18n_excel_column_inconsistent=所选sheet页面的列名不一致
|
||||
i18n_timed_task=定时任务
|
||||
i18n_datasource_connect_error=数据源连接异常:
|
||||
i18n_check_sql_error=校验增量 SQL 异常,
|
||||
|
||||
@ -280,8 +280,8 @@ i18n_msg_type_dataset_sync=數據集同步
|
||||
i18n_msg_type_dataset_sync_success=數據集同步成功
|
||||
i18n_msg_type_dataset_sync_faild=數據集同步失敗
|
||||
i18n_data_not_sync=請先完成數據同步
|
||||
i18n_excel_colume_change=Excel的列名與原數據集不一致
|
||||
i18n_excel_colume_inconsistent=所選sheet頁面的列名不一致
|
||||
i18n_excel_column_change=Excel的列名與原數據集不一致
|
||||
i18n_excel_column_inconsistent=所選sheet頁面的列名不一致
|
||||
i18n_timed_task=定時任務
|
||||
i18n_datasource_connect_error=數據源連接異常:
|
||||
i18n_check_sql_error=校驗增量SQL異常,
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
"vue-codemirror": "^4.0.6",
|
||||
"vue-fullscreen": "^2.5.2",
|
||||
"vue-i18n": "7.3.2",
|
||||
"vue-proportion-directive": "^1.1.0",
|
||||
"vue-router": "3.0.6",
|
||||
"vue-to-pdf": "^1.0.0",
|
||||
"vue-uuid": "2.0.2",
|
||||
|
||||
@ -29,7 +29,8 @@
|
||||
]"
|
||||
:style="mainSlotStyle"
|
||||
>
|
||||
<edit-bar v-if="curComponent&&(active||linkageSettingStatus)" style="transform: translateZ(10px)" :active-model="'edit'" :element="element" @showViewDetails="showViewDetails" @amRemoveItem="amRemoveItem" @amAddItem="amAddItem" @resizeView="resizeView" @linkJumpSet="linkJumpSet" />
|
||||
<edit-bar v-if="editBarShow" style="transform: translateZ(10px)" :active-model="'edit'" :element="element" @showViewDetails="showViewDetails" @amRemoveItem="amRemoveItem" @amAddItem="amAddItem" @resizeView="resizeView" @linkJumpSet="linkJumpSet" />
|
||||
<mobile-check-bar v-if="mobileCheckBarShow" :element="element" @amRemoveItem="amRemoveItem" />
|
||||
<div v-if="resizing" style="transform: translateZ(11px);position: absolute; z-index: 3" :style="resizeShadowStyle" />
|
||||
<div
|
||||
v-for="(handlei, indexi) in actualHandles"
|
||||
@ -55,13 +56,13 @@ let eventsFor = events.mouse
|
||||
// private
|
||||
import eventBus from '@/components/canvas/utils/eventBus'
|
||||
import { mapState } from 'vuex'
|
||||
import SettingMenu from '@/components/canvas/components/Editor/SettingMenu'
|
||||
import EditBar from '@/components/canvas/components/Editor/EditBar'
|
||||
import MobileCheckBar from '@/components/canvas/components/Editor/MobileCheckBar'
|
||||
|
||||
export default {
|
||||
replace: true,
|
||||
name: 'Dedrag',
|
||||
components: { EditBar },
|
||||
components: { EditBar, MobileCheckBar },
|
||||
props: {
|
||||
className: {
|
||||
type: String,
|
||||
@ -362,10 +363,8 @@ export default {
|
||||
// 新增 保存中心点位置,用于计算旋转的方向矢量
|
||||
lastCenterX: 0,
|
||||
lastCenterY: 0,
|
||||
//
|
||||
parentX: 0,
|
||||
parentY: 0,
|
||||
|
||||
// private
|
||||
// 鼠标移入事件
|
||||
mouseOn: false,
|
||||
@ -374,6 +373,16 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 编辑组件显示
|
||||
editBarShow() {
|
||||
// 编辑组件显示条件:1.当前组件存在 2.组件是激活状态或者当前在联动设置撞他 3.当前不在移动端画布编辑状态
|
||||
return this.curComponent && (this.active || this.linkageSettingStatus) && !this.mobileLayoutStatus
|
||||
},
|
||||
// 移动端编辑组件选择按钮显示
|
||||
mobileCheckBarShow() {
|
||||
// 显示条件:1.当前是移动端画布编辑状态 2.当前组件在激活状态或者鼠标移入状态
|
||||
return this.mobileLayoutStatus && (this.active || this.mouseOn)
|
||||
},
|
||||
handleStyle() {
|
||||
return (stick, index) => {
|
||||
if (!this.handleInfo.switch) return { display: this.enabled ? 'block' : 'none' }
|
||||
@ -534,6 +543,7 @@ export default {
|
||||
'curCanvasScale',
|
||||
'canvasStyleData',
|
||||
'linkageSettingStatus',
|
||||
'mobileLayoutStatus',
|
||||
'componentGap'
|
||||
])
|
||||
},
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
@click="handleClick"
|
||||
@mousedown="elementMouseDown"
|
||||
>
|
||||
<edit-bar v-if="curComponent && config === curComponent" :element="config" @showViewDetails="showViewDetails" />
|
||||
<edit-bar v-if="editBarShow" :element="config" @showViewDetails="showViewDetails" />
|
||||
<de-out-widget
|
||||
v-if="config.type==='custom'"
|
||||
:id="'component' + config.id"
|
||||
@ -15,7 +15,6 @@
|
||||
:element="config"
|
||||
:in-screen="inScreen"
|
||||
/>
|
||||
|
||||
<component
|
||||
:is="config.component"
|
||||
v-else
|
||||
@ -38,9 +37,10 @@ import { mixins } from '@/components/canvas/utils/events'
|
||||
import { mapState } from 'vuex'
|
||||
import DeOutWidget from '@/components/dataease/DeOutWidget'
|
||||
import EditBar from '@/components/canvas/components/Editor/EditBar'
|
||||
import MobileCheckBar from '@/components/canvas/components/Editor/MobileCheckBar'
|
||||
|
||||
export default {
|
||||
components: { DeOutWidget, EditBar },
|
||||
components: { MobileCheckBar, DeOutWidget, EditBar },
|
||||
mixins: [mixins],
|
||||
props: {
|
||||
config: {
|
||||
@ -65,10 +65,14 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
editBarShow() {
|
||||
return this.curComponent && this.config === this.curComponent
|
||||
},
|
||||
curGap() {
|
||||
return this.canvasStyleData.panel.gap === 'yes' && this.config.auxiliaryMatrix ? this.componentGap : 0
|
||||
},
|
||||
...mapState([
|
||||
'mobileLayoutStatus',
|
||||
'canvasStyleData',
|
||||
'curComponent',
|
||||
'componentGap'
|
||||
@ -79,7 +83,6 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getStyle,
|
||||
|
||||
getShapeStyleIntDeDrag(style, prop) {
|
||||
if (prop === 'rotate') {
|
||||
return style['rotate']
|
||||
@ -95,7 +98,6 @@ export default {
|
||||
}
|
||||
if (prop === 'top') {
|
||||
const top = this.format(style['top'], this.scaleHeight)
|
||||
// console.log('top:' + top)
|
||||
return top
|
||||
}
|
||||
},
|
||||
@ -106,25 +108,33 @@ export default {
|
||||
getOutStyleDefault(style) {
|
||||
const result = {
|
||||
padding: this.curGap + 'px'
|
||||
};
|
||||
['width', 'left'].forEach(attr => {
|
||||
result[attr] = style[attr] + 'px'
|
||||
});
|
||||
['height', 'top'].forEach(attr => {
|
||||
result[attr] = style[attr] + 'px'
|
||||
})
|
||||
result['rotate'] = style['rotate']
|
||||
// result['opacity'] = style['opacity']
|
||||
|
||||
}
|
||||
// 移动端编辑状态 且 未被移动端选中的组件 放满容器
|
||||
if (this.mobileLayoutStatus && !this.config.mobileSelected) {
|
||||
result.width = '100%'
|
||||
result.height = '100%'
|
||||
} else {
|
||||
['width', 'left'].forEach(attr => {
|
||||
result[attr] = style[attr] + 'px'
|
||||
});
|
||||
['height', 'top'].forEach(attr => {
|
||||
result[attr] = style[attr] + 'px'
|
||||
})
|
||||
result['rotate'] = style['rotate']
|
||||
}
|
||||
return result
|
||||
// return style
|
||||
},
|
||||
|
||||
getComponentStyleDefault(style) {
|
||||
return getStyle(style, ['top', 'left', 'width', 'height', 'rotate'])
|
||||
// console.log('styleInfo', JSON.stringify(styleInfo))
|
||||
// return styleInfo
|
||||
// return style
|
||||
// 移动端编辑状态 且 未被移动端选中的组件 放满容器
|
||||
if (this.mobileLayoutStatus && !this.config.mobileSelected) {
|
||||
return {
|
||||
width: '100%',
|
||||
height: '100%'
|
||||
}
|
||||
} else {
|
||||
return getStyle(style, ['top', 'left', 'width', 'height', 'rotate'])
|
||||
}
|
||||
},
|
||||
|
||||
handleClick() {
|
||||
@ -151,19 +161,21 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.component {
|
||||
.component {
|
||||
position: absolute;
|
||||
}
|
||||
}
|
||||
|
||||
.component:hover {
|
||||
box-shadow:0px 0px 7px #0a7be0;
|
||||
}
|
||||
.gap_class{
|
||||
padding:5px;
|
||||
}
|
||||
.component-custom {
|
||||
outline: none;
|
||||
width: 100% !important;
|
||||
height: 100%;
|
||||
}
|
||||
.component:hover {
|
||||
box-shadow: 0px 0px 7px #0a7be0;
|
||||
}
|
||||
|
||||
.gap_class {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.component-custom {
|
||||
outline: none;
|
||||
width: 100% !important;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
<div v-if="linkageSettingStatus&&element!==curLinkageView&&element.type==='view'" style="margin-right: -1px;width: 18px">
|
||||
<el-checkbox v-model="linkageInfo.linkageActive" />
|
||||
<linkage-field v-if="linkageInfo.linkageActive" :element="element" />
|
||||
<!-- <i v-if="linkageInfo.linkageActive" class="icon iconfont icon-edit" @click.stop="linkageEdit" />-->
|
||||
</div>
|
||||
<div v-else-if="!linkageSettingStatus">
|
||||
<setting-menu v-if="activeModel==='edit'" style="float: right;height: 24px!important;" @amRemoveItem="amRemoveItem" @linkJumpSet="linkJumpSet">
|
||||
@ -26,9 +25,6 @@
|
||||
<span :title="$t('panel.cancel_linkage')">
|
||||
<i v-if="curComponent.type==='view'&&existLinkage" class="icon iconfont icon-quxiaoliandong" @click.stop="clearLinkage" />
|
||||
</span>
|
||||
<!-- <spa>-->
|
||||
<!-- {{ curComponent.x }}-{{ curComponent.y }}--{{ curComponent.sizex }}-{{ curComponent.sizey }}-->
|
||||
<!-- </spa>-->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -39,7 +35,6 @@ import { mapState } from 'vuex'
|
||||
import bus from '@/utils/bus'
|
||||
import SettingMenu from '@/components/canvas/components/Editor/SettingMenu'
|
||||
import LinkageField from '@/components/canvas/components/Editor/LinkageField'
|
||||
import { deepCopy } from '@/components/canvas/utils/utils'
|
||||
|
||||
export default {
|
||||
components: { SettingMenu, LinkageField },
|
||||
@ -73,7 +68,6 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// this.createTimer()
|
||||
},
|
||||
computed: {
|
||||
existLinkage() {
|
||||
@ -106,7 +100,6 @@ export default {
|
||||
])
|
||||
},
|
||||
beforeDestroy() {
|
||||
// this.destroyTimer()
|
||||
},
|
||||
methods: {
|
||||
createTimer() {
|
||||
@ -172,9 +165,7 @@ export default {
|
||||
if (this.curComponent.type === 'custom') {
|
||||
bus.$emit('component-dialog-edit')
|
||||
}
|
||||
|
||||
// 编辑样式组件
|
||||
|
||||
if (this.curComponent.type === 'v-text' || this.curComponent.type === 'rect-shape') {
|
||||
bus.$emit('component-dialog-style')
|
||||
}
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div class="bar-main">
|
||||
<div style="width: 18px">
|
||||
<!-- <svg-icon icon-class="field_text" class="el-icon-close" />-->
|
||||
<el-checkbox v-model="element.mobileSelected" @change="onChange" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { mapState } from 'vuex'
|
||||
export default {
|
||||
props: {
|
||||
element: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
timer: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState([
|
||||
'pcComponentData',
|
||||
'pcComponentGap'
|
||||
])
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
beforeDestroy() {
|
||||
},
|
||||
methods: {
|
||||
onChange() {
|
||||
if (this.element.mobileSelected) {
|
||||
this.element.style.width = 1600
|
||||
this.element.style.height = 300
|
||||
this.element.style.left = 0
|
||||
this.element.style.top = 0
|
||||
this.element.sizex = 6
|
||||
this.element.sizey = 4
|
||||
this.element.x = 1
|
||||
this.element.y = 1
|
||||
this.element.auxiliaryMatrix = true
|
||||
this.$store.commit('addComponent', { component: this.element })
|
||||
} else {
|
||||
this.deleteComponent()
|
||||
}
|
||||
// this.updateMobileSelected(this.element.id)
|
||||
},
|
||||
deleteComponent() {
|
||||
this.$emit('amRemoveItem')
|
||||
this.$store.commit('deleteComponent')
|
||||
this.$store.commit('setCurComponent', { component: null, index: null })
|
||||
},
|
||||
updateMobileSelected(id, mobileSelected) {
|
||||
this.pcComponentData.forEach(item => {
|
||||
if (item.id === id) {
|
||||
item.mobileSelected = mobileSelected
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.bar-main{
|
||||
position: absolute;
|
||||
float:right;
|
||||
z-index: 2;
|
||||
border-radius:2px;
|
||||
padding-left: 1px;
|
||||
padding-right: 1px;
|
||||
cursor:pointer!important;
|
||||
background-color: #0a7be0;
|
||||
}
|
||||
.bar-main i{
|
||||
color: white;
|
||||
float: right;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
</style>
|
||||
@ -1,33 +1,41 @@
|
||||
<template>
|
||||
<div id="canvasInfoMain" ref="canvasInfoMain" :style="customStyle" class="bg">
|
||||
<div id="canvasInfoTemp" ref="canvasInfoTemp" class="main-class" @mouseup="deselectCurComponent" @mousedown="handleMouseDown">
|
||||
<el-row v-if="componentDataShow.length===0" style="height: 100%;" class="custom-position">
|
||||
{{ $t('panel.panelNull') }}
|
||||
</el-row>
|
||||
<canvas-opt-bar />
|
||||
<ComponentWrapper
|
||||
v-for="(item, index) in componentDataInfo"
|
||||
:key="index"
|
||||
:config="item"
|
||||
:search-count="searchCount"
|
||||
:in-screen="inScreen"
|
||||
/>
|
||||
<!--视图详情-->
|
||||
<el-dialog
|
||||
:title="'['+showChartInfo.name+']'+$t('chart.chart_details')"
|
||||
:visible.sync="chartDetailsVisible"
|
||||
width="70%"
|
||||
class="dialog-css"
|
||||
:destroy-on-close="true"
|
||||
<div class="bg" :style="customStyle">
|
||||
<div id="canvasInfoMain" ref="canvasInfoMain" style="width: 100%;height: 100%">
|
||||
<div
|
||||
id="canvasInfoTemp"
|
||||
ref="canvasInfoTemp"
|
||||
class="main-class"
|
||||
@mouseup="deselectCurComponent"
|
||||
@mousedown="handleMouseDown"
|
||||
>
|
||||
<span style="position: absolute;right: 70px;top:15px">
|
||||
<el-button size="mini" @click="exportExcel">
|
||||
<svg-icon icon-class="ds-excel" class="ds-icon-excel" />
|
||||
{{ $t('chart.export_details') }}
|
||||
</el-button>
|
||||
</span>
|
||||
<UserViewDialog ref="userViewDialog" :chart="showChartInfo" :chart-table="showChartTableInfo" />
|
||||
</el-dialog>
|
||||
<el-row v-if="componentDataShow.length===0" style="height: 100%;" class="custom-position">
|
||||
{{ $t('panel.panelNull') }}
|
||||
</el-row>
|
||||
<canvas-opt-bar />
|
||||
<ComponentWrapper
|
||||
v-for="(item, index) in componentDataInfo"
|
||||
:key="index"
|
||||
:config="item"
|
||||
:search-count="searchCount"
|
||||
:in-screen="inScreen"
|
||||
/>
|
||||
<!--视图详情-->
|
||||
<el-dialog
|
||||
:title="'['+showChartInfo.name+']'+$t('chart.chart_details')"
|
||||
:visible.sync="chartDetailsVisible"
|
||||
width="70%"
|
||||
class="dialog-css"
|
||||
:destroy-on-close="true"
|
||||
>
|
||||
<span style="position: absolute;right: 70px;top:15px">
|
||||
<el-button size="mini" @click="exportExcel">
|
||||
<svg-icon icon-class="ds-excel" class="ds-icon-excel" />
|
||||
{{ $t('chart.export_details') }}
|
||||
</el-button>
|
||||
</span>
|
||||
<UserViewDialog ref="userViewDialog" :chart="showChartInfo" :chart-table="showChartTableInfo" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -94,9 +102,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
customStyle() {
|
||||
let style = {
|
||||
padding: this.componentGap + 'px'
|
||||
}
|
||||
let style = {}
|
||||
if (this.canvasStyleData.openCommonStyle) {
|
||||
if (this.canvasStyleData.panel.backgroundType === 'image' && this.canvasStyleData.panel.imageUrl) {
|
||||
style = {
|
||||
@ -110,16 +116,6 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (this.canvasStyleData.selfAdaption) {
|
||||
// style = {
|
||||
// overflow: 'hidden',
|
||||
// ...style
|
||||
// }
|
||||
// }
|
||||
// style = {
|
||||
// overflow-x :'hidden',
|
||||
// ...style
|
||||
// }
|
||||
return style
|
||||
},
|
||||
// 此处单独计算componentData的值 不放入全局mapState中
|
||||
@ -152,17 +148,17 @@ export default {
|
||||
const _this = this
|
||||
const erd = elementResizeDetectorMaker()
|
||||
// 监听div变动事件
|
||||
const tempDom = document.getElementById('canvasInfoMain')
|
||||
erd.listenTo(tempDom, element => {
|
||||
const mainDom = document.getElementById('canvasInfoMain')
|
||||
erd.listenTo(mainDom, element => {
|
||||
_this.$nextTick(() => {
|
||||
_this.restore()
|
||||
// 将mainHeight 修改为px 临时解决html2canvas 截图不全的问题
|
||||
_this.mainHeight = tempDom.scrollHeight + 'px!important'
|
||||
_this.mainHeight = mainDom.scrollHeight + 'px!important'
|
||||
})
|
||||
})
|
||||
eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog)
|
||||
this.$store.commit('clearLinkageSettingInfo', false)
|
||||
this.canvasStyleDataInit()
|
||||
_this.$store.commit('clearLinkageSettingInfo', false)
|
||||
_this.canvasStyleDataInit()
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearInterval(this.timer)
|
||||
@ -235,8 +231,6 @@ export default {
|
||||
}
|
||||
},
|
||||
handleMouseDown() {
|
||||
// console.log('handleMouseDown123')
|
||||
|
||||
this.$store.commit('setClickComponentStatus', false)
|
||||
}
|
||||
}
|
||||
@ -244,47 +238,45 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.bg {
|
||||
.bg {
|
||||
padding: 5px;
|
||||
min-width: 600px;
|
||||
min-height: 300px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-x: hidden;
|
||||
/*border: 1px solid #E6E6E6;*/
|
||||
background-size: 100% 100% !important;
|
||||
.canvas-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.canvas {
|
||||
position: relative;
|
||||
margin: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
.main-class {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.custom-position {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
flex-flow: row nowrap;
|
||||
color: #9ea6b2;
|
||||
}
|
||||
.gap_class{
|
||||
padding:5px;
|
||||
}
|
||||
.dialog-css>>>.el-dialog__title {
|
||||
font-size: 14px;
|
||||
}
|
||||
.dialog-css >>> .el-dialog__header {
|
||||
padding: 20px 20px 0;
|
||||
}
|
||||
.dialog-css >>> .el-dialog__body {
|
||||
padding: 10px 20px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.main-class {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.custom-position {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
flex-flow: row nowrap;
|
||||
color: #9ea6b2;
|
||||
}
|
||||
|
||||
.gap_class {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.dialog-css > > > .el-dialog__title {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.dialog-css > > > .el-dialog__header {
|
||||
padding: 20px 20px 0;
|
||||
}
|
||||
|
||||
.dialog-css > > > .el-dialog__body {
|
||||
padding: 10px 20px 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
<!--页面组件列表展示-->
|
||||
<de-drag
|
||||
v-for="(item, index) in componentData"
|
||||
ref="deDragRef"
|
||||
:key="item.id"
|
||||
:class="{item:true,moveAnimation:moveAnimate,movingItem:item.isPlayer}"
|
||||
:index="index"
|
||||
@ -244,15 +245,12 @@ function resetPositionBox() {
|
||||
const rows = this.matrixCount.y // 初始100行,后面根据需求会自动增加
|
||||
for (let i = 0; i < rows; i++) {
|
||||
const row = []
|
||||
|
||||
for (let j = 0; j < this.maxCell; j++) {
|
||||
row.push({
|
||||
el: false
|
||||
})
|
||||
}
|
||||
|
||||
positionBox.push(row)
|
||||
// console.log('positionBox:' + JSON.stringify(positionBox))
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +260,6 @@ function resetPositionBox() {
|
||||
* @param {any} item
|
||||
*/
|
||||
function addItemToPositionBox(item) {
|
||||
// console.log('itemInfo:' + JSON.stringify(item))
|
||||
const pb = positionBox
|
||||
if (item.x <= 0 || item.y <= 0) return
|
||||
|
||||
@ -289,15 +286,11 @@ function fillPositionBox(maxY) {
|
||||
pb.push(row)
|
||||
}
|
||||
}
|
||||
|
||||
itemMaxY = maxY
|
||||
// console.log('height:' + ((itemMaxY) * this.cellHeight) + 'px')
|
||||
// $(this.$el).css('height', ((itemMaxY) * this.cellHeight) + 'px')
|
||||
}
|
||||
|
||||
function removeItemFromPositionBox(item) {
|
||||
const pb = positionBox
|
||||
// console.log('removeItem=>x:' + item.x + ';y:' + item.y + ';sizex:' + item.sizex + ';sizey:' + item.sizey)
|
||||
if (!item || item.x <= 0 || item.y <= 0) return
|
||||
for (let i = item.x - 1; i < item.x - 1 + item.sizex; i++) {
|
||||
for (let j = item.y - 1; j < item.y - 1 + item.sizey; j++) {
|
||||
@ -313,20 +306,10 @@ function removeItemFromPositionBox(item) {
|
||||
*
|
||||
*/
|
||||
function recalcCellWidth() {
|
||||
// const containerNode = this.$refs['container']
|
||||
// this.outStyle.width && this.outStyle.height
|
||||
// const containerWidth = this.outStyle.width
|
||||
|
||||
// const cells = Math.round(containerWidth / this.cellWidth)
|
||||
this.maxCell = this.matrixCount.x
|
||||
|
||||
// if (containerWidth % this.cellWidth !=== 0) {
|
||||
// this.cellWidth += containerWidth % this.cellWidth / cells;
|
||||
// }
|
||||
}
|
||||
|
||||
function init() {
|
||||
// console.log('init-cellWidth')
|
||||
this.cellWidth = this.baseWidth + this.baseMarginLeft
|
||||
this.cellHeight = this.baseHeight + this.baseMarginTop
|
||||
this.yourList = this.getList()
|
||||
@ -342,12 +325,9 @@ function init() {
|
||||
itemMaxX = 0
|
||||
|
||||
const vm = this
|
||||
|
||||
recalcCellWidth.call(this)
|
||||
|
||||
resetPositionBox.call(this)
|
||||
let i = 0
|
||||
// console.log('initList:' + JSON.stringify(vm.yourList))
|
||||
const timeid = setInterval(function() {
|
||||
if (i >= vm.yourList.length) {
|
||||
clearInterval(timeid)
|
||||
@ -364,15 +344,12 @@ function init() {
|
||||
}
|
||||
|
||||
function resizePlayer(item, newSize) {
|
||||
// console.log('resizePlayer')
|
||||
const vm = this
|
||||
removeItemFromPositionBox(item)
|
||||
|
||||
const belowItems = findBelowItems.call(this, item)
|
||||
|
||||
_.forEach(belowItems, function(upItem) {
|
||||
const canGoUpRows = canItemGoUp(upItem)
|
||||
|
||||
if (canGoUpRows > 0) {
|
||||
moveItemUp.call(vm, upItem, canGoUpRows)
|
||||
}
|
||||
@ -394,13 +371,9 @@ function resizePlayer(item, newSize) {
|
||||
}
|
||||
|
||||
emptyTargetCell.call(this, item)
|
||||
|
||||
addItemToPositionBox.call(this, item)
|
||||
|
||||
changeItemCoord.call(this, item)
|
||||
|
||||
const canGoUpRows = canItemGoUp(item)
|
||||
|
||||
if (canGoUpRows > 0) {
|
||||
moveItemUp.call(this, item, canGoUpRows)
|
||||
}
|
||||
@ -413,7 +386,6 @@ function resizePlayer(item, newSize) {
|
||||
* @param {any} position
|
||||
*/
|
||||
function checkItemPosition(item, position) {
|
||||
// console.log('checkItemPosition-info' + JSON.stringify(item))
|
||||
position = position || {}
|
||||
position.x = position.x || item.x
|
||||
position.y = position.y || item.y
|
||||
@ -459,12 +431,10 @@ function checkItemPosition(item, position) {
|
||||
* @param {any} position
|
||||
*/
|
||||
function movePlayer(item, position) {
|
||||
// console.log('movePlayer')
|
||||
const vm = this
|
||||
removeItemFromPositionBox(item)
|
||||
|
||||
const belowItems = findBelowItems.call(this, item)
|
||||
|
||||
_.forEach(belowItems, function(upItem) {
|
||||
const canGoUpRows = canItemGoUp(upItem)
|
||||
if (canGoUpRows > 0) {
|
||||
@ -474,17 +444,11 @@ function movePlayer(item, position) {
|
||||
|
||||
item.x = position.x
|
||||
item.y = position.y
|
||||
// console.log('checkItemPosition3')
|
||||
checkItemPosition.call(this, item, position)
|
||||
|
||||
emptyTargetCell.call(this, item)
|
||||
|
||||
addItemToPositionBox.call(this, item)
|
||||
|
||||
changeItemCoord.call(this, item)
|
||||
|
||||
const canGoUpRows = canItemGoUp(item)
|
||||
|
||||
if (canGoUpRows > 0) {
|
||||
moveItemUp.call(this, item, canGoUpRows)
|
||||
}
|
||||
@ -496,12 +460,8 @@ function removeItem(index) {
|
||||
removeItemFromPositionBox(item)
|
||||
|
||||
const belowItems = findBelowItems.call(this, item)
|
||||
|
||||
// $(this.$refs['item' + item._dragId][0]).remove();
|
||||
|
||||
_.forEach(belowItems, function(upItem) {
|
||||
const canGoUpRows = canItemGoUp(upItem)
|
||||
|
||||
if (canGoUpRows > 0) {
|
||||
moveItemUp.call(vm, upItem, canGoUpRows)
|
||||
}
|
||||
@ -516,23 +476,17 @@ function addItem(item, index) {
|
||||
index = this.yourList.length
|
||||
}
|
||||
item._dragId = index
|
||||
|
||||
// console.log('checkItemPosition4')
|
||||
checkItemPosition.call(this, item, {
|
||||
x: item.x,
|
||||
y: item.y
|
||||
})
|
||||
|
||||
emptyTargetCell.call(this, item)
|
||||
|
||||
addItemToPositionBox.call(this, item)
|
||||
|
||||
const canGoUpRows = canItemGoUp(item)
|
||||
|
||||
if (canGoUpRows > 0) {
|
||||
moveItemUp.call(this, item, canGoUpRows)
|
||||
}
|
||||
|
||||
// 生成坐标点
|
||||
// makeCoordinate.call(this, item);
|
||||
}
|
||||
@ -645,7 +599,6 @@ function changeItemCoord(item) {
|
||||
* @param {any} item
|
||||
*/
|
||||
function emptyTargetCell(item) {
|
||||
// console.log('emptyTargetCell')
|
||||
const vm = this
|
||||
const belowItems = findBelowItems(item)
|
||||
|
||||
@ -687,9 +640,7 @@ function canItemGoUp(item) {
|
||||
function moveItemDown(item, size) {
|
||||
const vm = this
|
||||
removeItemFromPositionBox(item)
|
||||
|
||||
const belowItems = findBelowItems(item)
|
||||
|
||||
_.forEach(belowItems, function(downItem, index) {
|
||||
if (downItem._dragId === item._dragId) return
|
||||
const moveSize = calcDiff(item, downItem, size)
|
||||
@ -697,23 +648,17 @@ function moveItemDown(item, size) {
|
||||
moveItemDown.call(vm, downItem, moveSize)
|
||||
}
|
||||
})
|
||||
|
||||
const targetPosition = {
|
||||
y: item.y + size
|
||||
}
|
||||
setPlayerPosition.call(this, item, targetPosition)
|
||||
// console.log('checkItemPosition1')
|
||||
checkItemPosition.call(this, item, targetPosition)
|
||||
|
||||
addItemToPositionBox.call(this, item)
|
||||
|
||||
changeItemCoord.call(this, item)
|
||||
}
|
||||
|
||||
function setPlayerPosition(item, position) {
|
||||
const vm = this
|
||||
position = position || {}
|
||||
|
||||
const targetX = position.x || item.x
|
||||
const targetY = position.y || item.y
|
||||
|
||||
@ -721,14 +666,8 @@ function setPlayerPosition(item, position) {
|
||||
item.y = targetY
|
||||
|
||||
// 还原到像素
|
||||
// item.style.left = (item.x - 1) * this.matrixStyle.width
|
||||
// item.style.top = (item.y - 1) * this.matrixStyle.height
|
||||
item.style.left = ((item.x - 1) * this.matrixStyle.width) / this.scalePointWidth
|
||||
item.style.top = ((item.y - 1) * this.matrixStyle.height) / this.scalePointHeight
|
||||
// console.log('setPlayerPosition:' + item._dragId + '--' + item.x + '--' + item.y + '--top' + item.style.top)
|
||||
|
||||
// console.log('setPlayerPosition:x=' + item.style.left + ';y=' + item.style.top + 'componentData:' + JSON.stringify(this.componentData))
|
||||
|
||||
if (item.y + item.sizey > itemMaxY) {
|
||||
itemMaxY = item.y + item.sizey
|
||||
}
|
||||
@ -762,14 +701,11 @@ function calcDiff(parent, son, size) {
|
||||
}
|
||||
|
||||
function moveItemUp(item, size) {
|
||||
// console.log('moveItemUp')
|
||||
const vm = this
|
||||
|
||||
removeItemFromPositionBox(item)
|
||||
|
||||
const belowItems = findBelowItems.call(this, item)
|
||||
|
||||
// item.y -= size;
|
||||
setPlayerPosition.call(this, item, {
|
||||
y: item.y - size
|
||||
})
|
||||
@ -857,6 +793,16 @@ export default {
|
||||
required: false,
|
||||
type: Function,
|
||||
default: function() {}
|
||||
},
|
||||
matrixCount: {
|
||||
required: false,
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
x: 36,
|
||||
y: 18
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -900,11 +846,6 @@ export default {
|
||||
originWidth: 80, // 原始尺寸
|
||||
originHeight: 20
|
||||
},
|
||||
// 矩阵数量 默认 128 * 72
|
||||
matrixCount: {
|
||||
x: 36,
|
||||
y: 18
|
||||
},
|
||||
customStyleHistory: null,
|
||||
showDrag: true,
|
||||
vLine: [],
|
||||
@ -940,9 +881,6 @@ export default {
|
||||
return this.chartDetailsVisible || this.linkJumpSetVisible
|
||||
},
|
||||
// 挤占式画布设计
|
||||
// positionBoxInfo() {
|
||||
// return getoPsitionBox()
|
||||
// },
|
||||
coordinates() {
|
||||
return coordinates
|
||||
},
|
||||
@ -965,8 +903,6 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log('customStyle=>' + JSON.stringify(style) + JSON.stringify(this.canvasStyleData))
|
||||
|
||||
return style
|
||||
},
|
||||
panelInfo() {
|
||||
@ -983,65 +919,44 @@ export default {
|
||||
'linkageSettingStatus',
|
||||
'curLinkageView',
|
||||
'doSnapshotIndex',
|
||||
'componentGap'
|
||||
'componentGap',
|
||||
'mobileLayoutStatus'
|
||||
])
|
||||
},
|
||||
watch: {
|
||||
customStyle: {
|
||||
handler(newVal) {
|
||||
// 获取当前宽高(宽高改变后重新渲染画布)
|
||||
// if (oldVla && newVal !== oldVla) {
|
||||
// this.showDrag = false
|
||||
// this.$nextTick(() => (this.showDrag = true))
|
||||
// }
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
outStyle: {
|
||||
handler(newVal, oldVla) {
|
||||
this.resizeParentBoundsRef()
|
||||
this.changeScale()
|
||||
// console.log('newVal:' + JSON.stringify(newVal) + 'oldVla:' + JSON.stringify(this.outStyleOld))
|
||||
if (this.outStyleOld && (newVal.width > this.outStyleOld.width || newVal.height > this.outStyleOld.height)) {
|
||||
this.resizeParentBounds()
|
||||
}
|
||||
this.outStyleOld = deepCopy(newVal)
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
// canvasStyleData: {
|
||||
// handler(newVal, oldVla) {
|
||||
// // 第一次变化 不需要 重置边界 待改进
|
||||
// if (this.changeIndex++ > 0) {
|
||||
// // this.resizeParentBounds()
|
||||
// this.$store.state.styleChangeTimes++
|
||||
// }
|
||||
// // this.changeScale()
|
||||
// },
|
||||
// deep: true
|
||||
// },
|
||||
componentData: {
|
||||
handler(newVal, oldVla) {
|
||||
// console.log('newVal:' + JSON.stringify(newVal) + ';oldVla:' + JSON.stringify(oldVla))
|
||||
// 初始化时componentData 加载可能出现慢的情况 此时重新初始化一下matrix
|
||||
if (newVal.length !== this.lastComponentDataLength) {
|
||||
this.lastComponentDataLength = newVal.length
|
||||
// console.log('.initMatrix2')
|
||||
this.initMatrix()
|
||||
// console.log('componentData-initMatrix')
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
positionBox: {
|
||||
handler(newVal, oldVla) {
|
||||
// console.log('positionBox:' + JSON.stringify(positionBox))
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
// 镜像索引有变化 刷新一下矩阵(撤销重做等)
|
||||
doSnapshotIndex: {
|
||||
handler(newVal, oldVla) {
|
||||
// console.log('snapshotIndexChange:' + newVal)
|
||||
// console.log('.initMatrix3')
|
||||
this.initMatrix()
|
||||
},
|
||||
deep: true
|
||||
@ -1053,22 +968,12 @@ export default {
|
||||
this.changeScale()
|
||||
this.editShow = true
|
||||
}, 500)
|
||||
// this.changeScale()
|
||||
// 获取编辑器元素
|
||||
this.$store.commit('getEditor')
|
||||
const _this = this
|
||||
// bus.$on('auxiliaryMatrixChange', this.initMatrix)
|
||||
// bus.$on('auxiliaryMatrixChange', () => {
|
||||
// _this.$nextTick(() => {
|
||||
// _this.initMatrix()
|
||||
// })
|
||||
// })
|
||||
eventBus.$on('hideArea', () => {
|
||||
this.hideArea()
|
||||
})
|
||||
// bus.$on('delete-condition', condition => {
|
||||
// this.deleteCondition(condition)
|
||||
// })
|
||||
eventBus.$on('startMoveIn', this.startMoveIn)
|
||||
eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog)
|
||||
bus.$on('onRemoveLastItem', this.removeLastItem)
|
||||
@ -1081,7 +986,6 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// this.$store.dispatch('conditions/clear')
|
||||
},
|
||||
methods: {
|
||||
changeStyleWithScale,
|
||||
@ -1090,9 +994,7 @@ export default {
|
||||
if (!this.curComponent || (this.curComponent.component !== 'v-text' && this.curComponent.component !== 'rect-shape')) {
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
this.hideArea()
|
||||
|
||||
// 获取编辑器的位移信息,每次点击时都需要获取一次。主要是为了方便开发时调试用。
|
||||
const rectInfo = this.editor.getBoundingClientRect()
|
||||
this.editorX = rectInfo.x
|
||||
@ -1116,19 +1018,15 @@ export default {
|
||||
this.start.y = moveEvent.clientY - this.editorY
|
||||
}
|
||||
}
|
||||
|
||||
const up = (e) => {
|
||||
document.removeEventListener('mousemove', move)
|
||||
document.removeEventListener('mouseup', up)
|
||||
|
||||
if (e.clientX === startX && e.clientY === startY) {
|
||||
this.hideArea()
|
||||
return
|
||||
}
|
||||
|
||||
this.createGroup()
|
||||
}
|
||||
|
||||
document.addEventListener('mousemove', move)
|
||||
document.addEventListener('mouseup', up)
|
||||
|
||||
@ -1337,7 +1235,6 @@ export default {
|
||||
}
|
||||
},
|
||||
getRefLineParams(params) {
|
||||
// console.log(JSON.stringify(params))
|
||||
const { vLine, hLine } = params
|
||||
this.vLine = vLine
|
||||
this.hLine = hLine
|
||||
@ -1350,11 +1247,11 @@ export default {
|
||||
parentBoundsChange(index) {
|
||||
this.timeMachine = setTimeout(() => {
|
||||
if (index === this.changeIndex) {
|
||||
this.showDrag = false
|
||||
this.$nextTick(() => (this.showDrag = true))
|
||||
this.changeScale()
|
||||
console.log('changeScale')
|
||||
}
|
||||
this.destroyTimeMachine()
|
||||
}, 500)
|
||||
}, 1500)
|
||||
},
|
||||
destroyTimeMachine() {
|
||||
this.timeMachine && clearTimeout(this.timeMachine)
|
||||
@ -1408,7 +1305,6 @@ export default {
|
||||
|
||||
// 挤占式画布设计
|
||||
startResize(e, item, index) {
|
||||
// console.log('startResize:' + index)
|
||||
if (!this.resizable) return
|
||||
this.resizeStart.call(null, e, item, index)
|
||||
|
||||
@ -1418,9 +1314,6 @@ export default {
|
||||
if (!this.infoBox) {
|
||||
this.infoBox = {}
|
||||
}
|
||||
|
||||
const itemNode = target.parents('.item')
|
||||
|
||||
this.infoBox.resizeItem = item
|
||||
this.infoBox.resizeItemIndex = index
|
||||
// this.onStartMove(e, item, index)
|
||||
@ -1432,22 +1325,14 @@ export default {
|
||||
if (!this.infoBox) {
|
||||
this.infoBox = {}
|
||||
}
|
||||
// console.log('containerMouseDown=' + e.pageX + ';' + e.pageY)
|
||||
|
||||
this.infoBox.startX = e.pageX
|
||||
this.infoBox.startY = e.pageY
|
||||
},
|
||||
onStartMove(e, item, index) {
|
||||
// console.log('onStartMove:' + index)
|
||||
const vm = this
|
||||
// e.preventDefault();
|
||||
|
||||
if (!this.infoBox) {
|
||||
this.infoBox = {}
|
||||
}
|
||||
const infoBox = this.infoBox
|
||||
const target = $(e.target)
|
||||
|
||||
this.dragStart.call(null, e, item, index)
|
||||
infoBox.moveItem = item
|
||||
infoBox.moveItemIndex = index
|
||||
@ -1485,15 +1370,9 @@ export default {
|
||||
const infoBox = this.infoBox
|
||||
const resizeItem = _.get(infoBox, 'resizeItem')
|
||||
const vm = this
|
||||
// console.log('resizeItem')
|
||||
|
||||
vm.$set(resizeItem, 'isPlayer', true)
|
||||
const nowItemIndex = infoBox.resizeItemIndex
|
||||
// const cloneItem = infoBox.cloneItem
|
||||
const startX = infoBox.startX
|
||||
const startY = infoBox.startY
|
||||
const oldSizeX = infoBox.oldSizeX
|
||||
const oldSizeY = infoBox.oldSizeY
|
||||
const moveXSize = e.pageX - startX // X方向移动的距离
|
||||
const moveYSize = e.pageY - startY // Y方向移动的距离
|
||||
|
||||
@ -1534,8 +1413,6 @@ export default {
|
||||
const infoBox = this.infoBox
|
||||
const moveItem = _.get(infoBox, 'moveItem')
|
||||
const vm = this
|
||||
// console.log('onDragging')
|
||||
|
||||
scrollScreen(e)
|
||||
if (!vm.draggable) return
|
||||
vm.dragging.call(null, e, moveItem, moveItem._dragId)
|
||||
@ -1584,10 +1461,7 @@ export default {
|
||||
}
|
||||
},
|
||||
getList() {
|
||||
// console.log('getList:')
|
||||
|
||||
// 不使用copy 保持原有对象
|
||||
// const returnList = _.sortBy(_.cloneDeep(this.componentData), 'y')
|
||||
const finalList = []
|
||||
_.forEach(this.componentData, function(item, index) {
|
||||
if (_.isEmpty(item)) return
|
||||
@ -1598,7 +1472,6 @@ export default {
|
||||
}
|
||||
})
|
||||
return finalList
|
||||
// return this.componentData
|
||||
},
|
||||
/**
|
||||
* 获取x最大值
|
||||
@ -1649,8 +1522,6 @@ export default {
|
||||
if (this.$store.state.dragComponentInfo.auxiliaryMatrix) {
|
||||
const moveInItemInfo = this.$store.state.dragComponentInfo
|
||||
this.addItemBox(moveInItemInfo)
|
||||
// console.log('startMoveIn:')
|
||||
const vm = this
|
||||
// e.preventDefault();
|
||||
if (!this.infoBox) {
|
||||
this.infoBox = {}
|
||||
@ -1672,6 +1543,13 @@ export default {
|
||||
},
|
||||
closeJumpSetDialog() {
|
||||
this.linkJumpSetVisible = false
|
||||
},
|
||||
// 调整父级组件边界
|
||||
resizeParentBoundsRef() {
|
||||
const _this = this
|
||||
_this.componentData.forEach(function(data, index) {
|
||||
_this.$refs.deDragRef && _this.$refs.deDragRef[index] && _this.$refs.deDragRef[index].checkParentSize()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,37 +1,28 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- linkageActiveStatus:{{ linkageActiveStatus }}-->
|
||||
<div v-if="linkageSettingStatus" class="toolbar">
|
||||
<div v-if="editControlButton" class="toolbar">
|
||||
<span style="float: right;">
|
||||
<el-button size="mini" @click="saveLinkage">
|
||||
<el-button size="mini" @click="editSave">
|
||||
{{ $t('commons.confirm') }}
|
||||
</el-button>
|
||||
<el-button size="mini" @click="cancelLinkage">
|
||||
<el-button size="mini" @click="editCancel">
|
||||
{{ $t('commons.cancel') }}
|
||||
</el-button>
|
||||
</span>
|
||||
</div>
|
||||
<div v-else class="toolbar">
|
||||
<el-tooltip :content="'移动端布局'">
|
||||
<el-button class="icon iconfont-tb icon-yidongduan" size="mini" circle @click="openMobileLayout" />
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="!canvasStyleData.auxiliaryMatrix" :content="$t('panel.new_element_distribution')+':'+$t('panel.suspension')">
|
||||
<el-button class="icon iconfont-tb icon-xuanfuanniu" size="mini" circle @click="auxiliaryMatrixChange" />
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="canvasStyleData.auxiliaryMatrix" :content="$t('panel.new_element_distribution')+':'+$t('panel.matrix')">
|
||||
<el-button class="icon iconfont-tb icon-shujujuzhen" size="mini" circle @click="auxiliaryMatrixChange" />
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip :content="$t('panel.style')">
|
||||
<el-button class="el-icon-magic-stick" size="mini" circle @click="showPanel" />
|
||||
<!-- <el-button :class="styleButtonActive?'button-show':'button-closed'" class="el-icon-magic-stick" size="mini" circle @click="showPanel" />-->
|
||||
</el-tooltip>
|
||||
|
||||
<!-- <el-tooltip v-if="!aidedButtonActive" :content="$t('panel.open_aided_design') ">-->
|
||||
<!-- <el-button class="el-icon-help button-closed" size="mini" circle @click="changeAidedDesign" />-->
|
||||
<!-- </el-tooltip>-->
|
||||
|
||||
<!-- <el-tooltip v-if="aidedButtonActive" :content="$t('panel.close_aided_design') ">-->
|
||||
<!-- <el-button class="el-icon-help button-show" size="mini" circle @click="changeAidedDesign" />-->
|
||||
<!-- </el-tooltip>-->
|
||||
|
||||
<el-tooltip :content="$t('panel.undo') ">
|
||||
<el-button class="el-icon-refresh-right" size="mini" circle @click="undo" />
|
||||
</el-tooltip>
|
||||
@ -44,7 +35,6 @@
|
||||
<el-tooltip :content="$t('panel.fullscreen_preview')">
|
||||
<el-button class="el-icon-view" size="mini" circle @click="clickPreview" />
|
||||
</el-tooltip>
|
||||
|
||||
<span style="float: right;margin-left: 10px">
|
||||
<el-button size="mini" :disabled="changeTimes===0||snapshotIndex===lastSaveSnapshotIndex" @click="save(false)">
|
||||
{{ $t('commons.save') }}
|
||||
@ -81,7 +71,7 @@ import toast from '@/components/canvas/utils/toast'
|
||||
import { mapState } from 'vuex'
|
||||
import { commonStyle, commonAttr } from '@/components/canvas/custom-component/component-list'
|
||||
import eventBus from '@/components/canvas/utils/eventBus'
|
||||
import { deepCopy } from '@/components/canvas/utils/utils'
|
||||
import { deepCopy, mobile2MainCanvas } from '@/components/canvas/utils/utils'
|
||||
import { panelSave } from '@/api/panel/panel'
|
||||
import { saveLinkage, getPanelAllLinkageInfo } from '@/api/panel/linkage'
|
||||
import bus from '@/utils/bus'
|
||||
@ -89,7 +79,7 @@ import bus from '@/utils/bus'
|
||||
import {
|
||||
DEFAULT_COMMON_CANVAS_STYLE_STRING
|
||||
} from '@/views/panel/panel'
|
||||
import {queryPanelJumpInfo} from "@/api/panel/linkJump";
|
||||
import { queryPanelJumpInfo } from '@/api/panel/linkJump'
|
||||
|
||||
export default {
|
||||
name: 'Toolbar',
|
||||
@ -114,27 +104,32 @@ export default {
|
||||
closePanelVisible: false
|
||||
}
|
||||
},
|
||||
computed: mapState([
|
||||
'componentData',
|
||||
'canvasStyleData',
|
||||
'areaData',
|
||||
'curComponent',
|
||||
'changeTimes',
|
||||
'snapshotIndex',
|
||||
'lastSaveSnapshotIndex',
|
||||
'linkageSettingStatus',
|
||||
'curLinkageView',
|
||||
'targetLinkageInfo'
|
||||
]),
|
||||
|
||||
computed: {
|
||||
editControlButton() {
|
||||
return this.linkageSettingStatus || this.mobileLayoutStatus
|
||||
},
|
||||
...mapState([
|
||||
'componentData',
|
||||
'canvasStyleData',
|
||||
'areaData',
|
||||
'curComponent',
|
||||
'changeTimes',
|
||||
'snapshotIndex',
|
||||
'lastSaveSnapshotIndex',
|
||||
'linkageSettingStatus',
|
||||
'curLinkageView',
|
||||
'targetLinkageInfo',
|
||||
'mobileLayoutStatus',
|
||||
'mobileComponentData',
|
||||
'componentDataCache'
|
||||
])
|
||||
},
|
||||
created() {
|
||||
eventBus.$on('preview', this.preview)
|
||||
eventBus.$on('save', this.save)
|
||||
eventBus.$on('clearCanvas', this.clearCanvas)
|
||||
|
||||
this.scale = this.canvasStyleData.scale
|
||||
},
|
||||
|
||||
methods: {
|
||||
close() {
|
||||
// 关闭页面清理缓存
|
||||
@ -158,13 +153,11 @@ export default {
|
||||
const scale = this.scale
|
||||
return value * scale / 100
|
||||
},
|
||||
|
||||
getOriginStyle(value) {
|
||||
const scale = this.canvasStyleData.scale
|
||||
const result = value / (scale / 100)
|
||||
return result
|
||||
},
|
||||
|
||||
handleScaleChange() {
|
||||
clearTimeout(this.timer)
|
||||
setTimeout(() => {
|
||||
@ -178,7 +171,6 @@ export default {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
this.$store.commit('setComponentData', componentData)
|
||||
this.$store.commit('setCanvasStyle', {
|
||||
...this.canvasStyleData,
|
||||
@ -216,13 +208,13 @@ export default {
|
||||
showPanel() {
|
||||
this.$emit('showPanel', 2)
|
||||
},
|
||||
|
||||
handleFileChange(e) {
|
||||
const file = e.target.files[0]
|
||||
if (!file.type.includes('image')) {
|
||||
toast('只能插入图片')
|
||||
return
|
||||
}
|
||||
|
||||
const reader = new FileReader()
|
||||
reader.onload = (res) => {
|
||||
const fileResult = res.target.result
|
||||
@ -249,10 +241,8 @@ export default {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
this.$store.commit('recordSnapshot', 'handleFileChange')
|
||||
}
|
||||
|
||||
img.src = fileResult
|
||||
}
|
||||
|
||||
@ -267,7 +257,6 @@ export default {
|
||||
save(withClose) {
|
||||
// 清理联动信息
|
||||
this.$store.commit('clearPanelLinkageInfo')
|
||||
|
||||
// 保存到数据库
|
||||
const requestInfo = {
|
||||
id: this.$store.state.panel.panelInfo.id,
|
||||
@ -307,7 +296,6 @@ export default {
|
||||
},
|
||||
saveLinkage() {
|
||||
// 字段检查
|
||||
// let checkCount = 0
|
||||
for (const key in this.targetLinkageInfo) {
|
||||
let subCheckCount = 0
|
||||
const linkageInfo = this.targetLinkageInfo[key]
|
||||
@ -329,15 +317,6 @@ export default {
|
||||
return
|
||||
}
|
||||
}
|
||||
// if (checkCount > 0) {
|
||||
// this.$message({
|
||||
// message: this.$t('panel.exit_un_march_linkage_field'),
|
||||
// type: 'error',
|
||||
// showClose: true
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
|
||||
const request = {
|
||||
panelId: this.$store.state.panel.panelInfo.id,
|
||||
sourceViewId: this.curLinkageView.propValue.viewId,
|
||||
@ -355,6 +334,10 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
cancelMobileLayoutStatue(sourceComponentData) {
|
||||
this.$store.commit('setComponentData', sourceComponentData)
|
||||
this.$store.commit('setMobileLayoutStatus', false)
|
||||
},
|
||||
cancelLinkage() {
|
||||
this.cancelLinkageSettingStatus()
|
||||
},
|
||||
@ -363,6 +346,57 @@ export default {
|
||||
},
|
||||
auxiliaryMatrixChange() {
|
||||
this.canvasStyleData.auxiliaryMatrix = !this.canvasStyleData.auxiliaryMatrix
|
||||
},
|
||||
openMobileLayout() {
|
||||
this.$store.commit('setComponentDataCache', JSON.stringify(this.componentData))
|
||||
this.$store.commit('setPcComponentData', this.componentData)
|
||||
const mainComponentData = []
|
||||
// 移动端布局转换
|
||||
this.componentData.forEach(item => {
|
||||
if (item.mobileSelected) {
|
||||
item.style = item.mobileStyle.style
|
||||
item.x = item.mobileStyle.x
|
||||
item.y = item.mobileStyle.y
|
||||
item.sizex = item.mobileStyle.sizex
|
||||
item.sizey = item.mobileStyle.sizey
|
||||
item.auxiliaryMatrix = item.mobileStyle.auxiliaryMatrix
|
||||
mainComponentData.push(item)
|
||||
}
|
||||
})
|
||||
|
||||
this.$store.commit('setComponentData', mainComponentData)
|
||||
this.$store.commit('setMobileLayoutStatus', !this.mobileLayoutStatus)
|
||||
},
|
||||
editSave() {
|
||||
if (this.mobileLayoutStatus) {
|
||||
this.mobileLayoutSave()
|
||||
} else {
|
||||
this.saveLinkage()
|
||||
}
|
||||
},
|
||||
editCancel() {
|
||||
if (this.mobileLayoutStatus) {
|
||||
this.cancelMobileLayoutStatue(JSON.parse(this.componentDataCache))
|
||||
} else {
|
||||
this.cancelLinkageSettingStatus()
|
||||
}
|
||||
},
|
||||
// 移动端布局保存
|
||||
mobileLayoutSave() {
|
||||
this.$store.state.styleChangeTimes++
|
||||
const mobileDataObj = {}
|
||||
this.componentData.forEach(item => {
|
||||
mobileDataObj[item.id] = item
|
||||
})
|
||||
const sourceComponentData = JSON.parse(this.componentDataCache)
|
||||
sourceComponentData.forEach(item => {
|
||||
if (mobileDataObj[item.id]) {
|
||||
mobile2MainCanvas(item, mobileDataObj[item.id])
|
||||
} else {
|
||||
item.mobileSelected = false
|
||||
}
|
||||
})
|
||||
this.cancelMobileLayoutStatue(sourceComponentData)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -374,9 +408,6 @@ export default {
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
min-width: 400px;
|
||||
/*background: #fff;*/
|
||||
/*border-bottom: 1px solid #ddd;*/
|
||||
|
||||
.canvas-config {
|
||||
display: inline-block;
|
||||
margin-left: 10px;
|
||||
@ -439,7 +470,6 @@ export default {
|
||||
>>>.el-switch__core{
|
||||
width:30px!important;
|
||||
height:15px;
|
||||
/*color:#409EFF;*/
|
||||
}
|
||||
/*设置圆*/
|
||||
>>>.el-switch__core::after{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user