forked from github/dataease
refactor: 格式化代码
This commit is contained in:
parent
f50274dc1c
commit
6e8020b148
@ -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,29 +4,25 @@ 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);
|
||||
@ -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) {
|
||||
} 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);
|
||||
}
|
||||
|
||||
@ -65,30 +67,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());
|
||||
@ -96,10 +99,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);
|
||||
@ -108,6 +112,7 @@ public class AuthUserServiceImpl implements AuthUserService {
|
||||
|
||||
/**
|
||||
* 一波清除3个缓存
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@ -117,37 +122,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;
|
||||
}
|
||||
|
@ -59,8 +59,6 @@ public abstract class QueryProvider {
|
||||
return 50;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 单指标汇总
|
||||
*
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -771,9 +761,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 +972,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 +1173,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 +1241,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,10 +83,7 @@ public class EmailService {
|
||||
if (StringUtils.isBlank(to)) return ;
|
||||
MailInfo mailInfo = proxy().mailInfo();
|
||||
JavaMailSenderImpl driver = driver(mailInfo);
|
||||
|
||||
MimeMessage mimeMessage = driver.createMimeMessage();
|
||||
MimeMessageHelper helper = null;
|
||||
|
||||
MimeBodyPart image = new MimeBodyPart();
|
||||
DataHandler png = new DataHandler(new ByteArrayDataSource(bytes, "image/png"));
|
||||
|
||||
@ -117,7 +114,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();
|
||||
@ -197,7 +194,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();
|
||||
@ -219,7 +216,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);
|
||||
}
|
||||
}
|
||||
|
@ -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異常,
|
||||
|
Loading…
Reference in New Issue
Block a user