commit
4928945444
@ -37,6 +37,9 @@ public class DeCleanerAnnotationHandler {
|
||||
|
||||
|
||||
switch (type.name()) {
|
||||
case "DATA_FILL":
|
||||
catchProcess().cleanDataFiling(paramValue);
|
||||
break;
|
||||
case "DATASOURCE":
|
||||
catchProcess().cleanDataSource(paramValue);
|
||||
break;
|
||||
|
||||
@ -92,8 +92,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
|
||||
|
||||
if (isLoginAttempt(request, response) || ApiKeyHandler.isApiKeyCall(hRequest)) {
|
||||
try {
|
||||
boolean loginSuccess = executeLogin(request, response);
|
||||
return loginSuccess;
|
||||
return executeLogin(request, response);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
if (e instanceof AuthenticationException && StringUtils.equals(e.getMessage(), expireMessage)) {
|
||||
|
||||
@ -26,7 +26,6 @@ import io.dataease.plugins.xpack.ldap.dto.response.ValidateResult;
|
||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
|
||||
import io.dataease.service.system.SystemParameterService;
|
||||
import io.dataease.websocket.entity.WsMessage;
|
||||
import io.dataease.websocket.service.WsService;
|
||||
@ -38,15 +37,14 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@RestController
|
||||
public class AuthServer implements AuthApi {
|
||||
|
||||
@ -203,11 +201,12 @@ public class AuthServer implements AuthApi {
|
||||
result.put("defaultPwd", DEFAULT_PWD);
|
||||
}
|
||||
}
|
||||
|
||||
Long expireTime = System.currentTimeMillis() + JWTUtils.getExpireTime();
|
||||
TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).build();
|
||||
String token = JWTUtils.sign(tokenInfo, realPwd);
|
||||
// 记录token操作时间
|
||||
result.put("token", token);
|
||||
result.put("expireTime", expireTime);
|
||||
ServletUtils.setToken(token);
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.LOGIN, SysLogConstants.SOURCE_TYPE.USER, user.getUserId(), null, null, null);
|
||||
authUserService.unlockAccount(username, ObjectUtils.isEmpty(loginType) ? 0 : loginType);
|
||||
|
||||
@ -15,19 +15,33 @@ public interface ExtAuthService {
|
||||
AuthURD resourceTarget(String resourceId);
|
||||
|
||||
List<AuthItem> dataSourceIdByUser(Long userId);
|
||||
|
||||
List<AuthItem> dataSetIdByUser(Long userId);
|
||||
|
||||
List<AuthItem> panelIdByUser(Long userId);
|
||||
|
||||
List<AuthItem> dataFillingIdByUser(Long userId);
|
||||
|
||||
List<AuthItem> dataSourceIdByRole(Long roleId);
|
||||
|
||||
List<AuthItem> dataSetIdByRole(Long roleId);
|
||||
|
||||
List<AuthItem> panelIdByRole(Long roleId);
|
||||
|
||||
List<AuthItem> dataFillingIdByRole(Long roleId);
|
||||
|
||||
List<AuthItem> dataSourceIdByDept(Long deptId);
|
||||
|
||||
List<AuthItem> dataSetIdByDept(Long deptId);
|
||||
|
||||
List<AuthItem> panelIdByDept(Long deptId);
|
||||
|
||||
List<AuthItem> dataFillingIdByDept(Long deptId);
|
||||
|
||||
void clearUserResource(Long userId);
|
||||
|
||||
void clearDeptResource(Long deptId);
|
||||
|
||||
void clearRoleResource(Long roleId);
|
||||
|
||||
List<String> parentResource(String resourceId, String type);
|
||||
|
||||
@ -90,7 +90,7 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
||||
dynamicMenuDto.setPermission(sysMenu.getPermission());
|
||||
dynamicMenuDto.setMenuSort(sysMenu.getMenuSort());
|
||||
dynamicMenuDto.setHidden(sysMenu.getHidden());
|
||||
dynamicMenuDto.setIsPlugin(true);
|
||||
dynamicMenuDto.setIsPlugin(!sysMenu.isUseBasicResource());
|
||||
dynamicMenuDto.setNoLayout(!!sysMenu.isNoLayout());
|
||||
return dynamicMenuDto;
|
||||
}
|
||||
|
||||
@ -2,12 +2,12 @@ package io.dataease.auth.service.impl;
|
||||
|
||||
import io.dataease.auth.entity.AuthItem;
|
||||
import io.dataease.auth.service.ExtAuthService;
|
||||
import io.dataease.commons.constants.SysAuthConstants;
|
||||
import io.dataease.plugins.common.base.domain.SysAuth;
|
||||
import io.dataease.ext.ExtAuthMapper;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.constants.SysAuthConstants;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.ext.ExtAuthMapper;
|
||||
import io.dataease.plugins.common.base.domain.SysAuth;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@ -109,6 +109,16 @@ public class ExtAuthServiceImpl implements ExtAuthService {
|
||||
);
|
||||
}
|
||||
|
||||
@Cacheable(value = AuthConstants.USER_DATA_FILL_NAME, key = "'user' + #userId")
|
||||
@Override
|
||||
public List<AuthItem> dataFillingIdByUser(Long userId) {
|
||||
return extAuthMapper.queryAuthItems(
|
||||
SysAuthConstants.AUTH_TARGET_TYPE_USER,
|
||||
userId.toString(),
|
||||
SysAuthConstants.AUTH_SOURCE_TYPE_DATA_FILLING
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(value = AuthConstants.ROLE_LINK_NAME, key = "'role' + #roleId")
|
||||
@Override
|
||||
@ -140,6 +150,16 @@ public class ExtAuthServiceImpl implements ExtAuthService {
|
||||
);
|
||||
}
|
||||
|
||||
@Cacheable(value = AuthConstants.ROLE_DATA_FILL_NAME, key = "'role' + #roleId")
|
||||
@Override
|
||||
public List<AuthItem> dataFillingIdByRole(Long roleId) {
|
||||
return extAuthMapper.queryAuthItems(
|
||||
SysAuthConstants.AUTH_TARGET_TYPE_ROLE,
|
||||
roleId.toString(),
|
||||
SysAuthConstants.AUTH_SOURCE_TYPE_DATA_FILLING
|
||||
);
|
||||
}
|
||||
|
||||
@Cacheable(value = AuthConstants.DEPT_LINK_NAME, key = "'dept' + #deptId")
|
||||
@Override
|
||||
public List<AuthItem> dataSourceIdByDept(Long deptId) {
|
||||
@ -173,10 +193,22 @@ public class ExtAuthServiceImpl implements ExtAuthService {
|
||||
);
|
||||
}
|
||||
|
||||
@Cacheable(value = AuthConstants.DEPT_DATA_FILL_NAME, key = "'dept' + #deptId")
|
||||
@Override
|
||||
public List<AuthItem> dataFillingIdByDept(Long deptId) {
|
||||
if (ObjectUtils.isEmpty(deptId)) return emptyResult;
|
||||
return extAuthMapper.queryAuthItems(
|
||||
SysAuthConstants.AUTH_TARGET_TYPE_DEPT,
|
||||
deptId.toString(),
|
||||
SysAuthConstants.AUTH_SOURCE_TYPE_DATA_FILLING
|
||||
);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(value = AuthConstants.USER_LINK_NAME, key = "'user' + #userId"),
|
||||
@CacheEvict(value = AuthConstants.USER_DATASET_NAME, key = "'user' + #userId"),
|
||||
@CacheEvict(value = AuthConstants.USER_PANEL_NAME, key = "'user' + #userId")
|
||||
@CacheEvict(value = AuthConstants.USER_PANEL_NAME, key = "'user' + #userId"),
|
||||
@CacheEvict(value = AuthConstants.USER_DATA_FILL_NAME, key = "'user' + #userId")
|
||||
})
|
||||
public void clearUserResource(Long userId) {
|
||||
LogUtil.info("all permission resource of user {} is cleaning...", userId);
|
||||
@ -185,7 +217,8 @@ public class ExtAuthServiceImpl implements ExtAuthService {
|
||||
@Caching(evict = {
|
||||
@CacheEvict(value = AuthConstants.DEPT_LINK_NAME, key = "'dept' + #deptId"),
|
||||
@CacheEvict(value = AuthConstants.DEPT_DATASET_NAME, key = "'dept' + #deptId"),
|
||||
@CacheEvict(value = AuthConstants.DEPT_PANEL_NAME, key = "'dept' + #deptId")
|
||||
@CacheEvict(value = AuthConstants.DEPT_PANEL_NAME, key = "'dept' + #deptId"),
|
||||
@CacheEvict(value = AuthConstants.DEPT_DATA_FILL_NAME, key = "'dept' + #deptId")
|
||||
})
|
||||
public void clearDeptResource(Long deptId) {
|
||||
LogUtil.info("all permission resource of dept {} is cleaning...", deptId);
|
||||
@ -194,7 +227,8 @@ public class ExtAuthServiceImpl implements ExtAuthService {
|
||||
@Caching(evict = {
|
||||
@CacheEvict(value = AuthConstants.ROLE_LINK_NAME, key = "'role' + #roleId"),
|
||||
@CacheEvict(value = AuthConstants.ROLE_DATASET_NAME, key = "'role' + #roleId"),
|
||||
@CacheEvict(value = AuthConstants.ROLE_PANEL_NAME, key = "'role' + #roleId")
|
||||
@CacheEvict(value = AuthConstants.ROLE_PANEL_NAME, key = "'role' + #roleId"),
|
||||
@CacheEvict(value = AuthConstants.ROLE_DATA_FILL_NAME, key = "'role' + #roleId")
|
||||
})
|
||||
public void clearRoleResource(Long roleId) {
|
||||
LogUtil.info("all permission resource of role {} is cleaning...", roleId);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package io.dataease.auth.util;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.JWTCreator.Builder;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.auth0.jwt.interfaces.Verification;
|
||||
@ -10,7 +10,10 @@ import com.google.gson.Gson;
|
||||
import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.entity.TokenInfo.TokenInfoBuilder;
|
||||
import io.dataease.commons.model.OnlineUserModel;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.commons.utils.IPUtils;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.commons.utils.TokenCacheUtils;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -77,6 +80,13 @@ public class JWTUtils {
|
||||
return sign(tokenInfo, secret, true);
|
||||
}
|
||||
|
||||
public static Long getExpireTime() {
|
||||
if (ObjectUtils.isEmpty(expireTime)) {
|
||||
expireTime = Objects.requireNonNull(CommonBeanFactory.getBean(Environment.class)).getProperty("dataease.login_timeout", Long.class, 480L);
|
||||
}
|
||||
return expireTime * 60000L;
|
||||
}
|
||||
|
||||
private static boolean tokenValid(OnlineUserModel model) {
|
||||
String token = model.getToken();
|
||||
// 如果已经加入黑名单 则直接返回无效
|
||||
@ -84,10 +94,7 @@ public class JWTUtils {
|
||||
if (invalid) return false;
|
||||
|
||||
Long loginTime = model.getLoginTime();
|
||||
if (ObjectUtils.isEmpty(expireTime)) {
|
||||
expireTime = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout", Long.class, 480L);
|
||||
}
|
||||
long expireTimeMillis = expireTime * 60000L;
|
||||
long expireTimeMillis = getExpireTime();
|
||||
// 如果当前时间减去登录时间小于超时时间则说明token未过期 返回有效状态
|
||||
return System.currentTimeMillis() - loginTime < expireTimeMillis;
|
||||
|
||||
@ -133,10 +140,7 @@ public class JWTUtils {
|
||||
DataEaseException.throwException("MultiLoginError1");
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isEmpty(expireTime)) {
|
||||
expireTime = CommonBeanFactory.getBean(Environment.class).getProperty("dataease.login_timeout", Long.class, 480L);
|
||||
}
|
||||
long expireTimeMillis = expireTime * 60000L;
|
||||
long expireTimeMillis = getExpireTime();
|
||||
Date date = new Date(System.currentTimeMillis() + expireTimeMillis);
|
||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||
Builder builder = JWT.create()
|
||||
|
||||
@ -12,14 +12,17 @@ public class AuthConstants {
|
||||
public final static String USER_LINK_NAME = "user_link";
|
||||
public final static String USER_DATASET_NAME = "user_dataset";
|
||||
public final static String USER_PANEL_NAME = "user_panel";
|
||||
public final static String USER_DATA_FILL_NAME = "user_data_fill";
|
||||
|
||||
public final static String ROLE_LINK_NAME = "role_link";
|
||||
public final static String ROLE_DATASET_NAME = "role_dataset";
|
||||
public final static String ROLE_PANEL_NAME = "role_panel";
|
||||
public final static String ROLE_DATA_FILL_NAME = "role_data_fill";
|
||||
|
||||
public final static String DEPT_LINK_NAME = "dept_link";
|
||||
public final static String DEPT_DATASET_NAME = "dept_dataset";
|
||||
public final static String DEPT_PANEL_NAME = "dept_panel";
|
||||
public final static String DEPT_DATA_FILL_NAME = "dept_data_fill";
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package io.dataease.commons.constants;
|
||||
|
||||
|
||||
public class DataFillConstants {
|
||||
|
||||
|
||||
public final static String DATA_FILL_NODE_TYPE_FOlDER = "folder";
|
||||
|
||||
public final static String DATA_FILL_NODE_TYPE_DATA_FILL = "data_fill";
|
||||
|
||||
public final static String OPT_TYPE_INSERT = "insert";
|
||||
|
||||
public final static String OPT_TYPE_UPDATE = "update";
|
||||
|
||||
|
||||
public final static String DATA_FILL_GATHER_DATA_FILL_LIST = "data_fill_list";
|
||||
|
||||
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
package io.dataease.commons.constants;
|
||||
|
||||
public enum DePermissionType {
|
||||
DATASOURCE, DATASET, PANEL
|
||||
DATASOURCE, DATASET, PANEL, DATA_FILL
|
||||
}
|
||||
|
||||
@ -19,7 +19,12 @@ public enum ResourceAuthLevel {
|
||||
|
||||
DATASOURCE_LEVEL_USE(1),
|
||||
DATASOURCE_LEVEL_MANAGE(3),
|
||||
DATASOURCE_LEVEL_GRANT(15);
|
||||
DATASOURCE_LEVEL_GRANT(15),
|
||||
|
||||
|
||||
DATA_FILLING_LEVEL_USE(1),
|
||||
DATA_FILLING_LEVEL_MANAGE(3),
|
||||
DATA_FILLING_LEVEL_GRANT(15);
|
||||
|
||||
private Integer level;
|
||||
|
||||
|
||||
@ -19,4 +19,6 @@ public class SysAuthConstants {
|
||||
|
||||
public final static String AUTH_SOURCE_TYPE_DATASOURCE = "link";
|
||||
|
||||
public final static String AUTH_SOURCE_TYPE_DATA_FILLING = "data_fill";
|
||||
|
||||
}
|
||||
|
||||
@ -70,7 +70,10 @@ public class SysLogConstants {
|
||||
DRIVER(9, "SOURCE_TYPE_DRIVER"),
|
||||
DRIVER_FILE(10, "SOURCE_TYPE_DRIVER_FILE"),
|
||||
MENU(11, "SOURCE_TYPE_MENU"),
|
||||
APIKEY(12, "SOURCE_TYPE_APIKEY");
|
||||
APIKEY(12, "SOURCE_TYPE_APIKEY"),
|
||||
DATA_FILL_FORM(13,"SOURCE_TYPE_DATA_FILL_FORM"),
|
||||
DATA_FILL_DATA(14,"SOURCE_TYPE_DATA_FILL_DATA");
|
||||
|
||||
private Integer value;
|
||||
private String name;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package io.dataease.commons.filter;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -16,6 +17,9 @@ public class HtmlResourceFilter implements Filter, Ordered {
|
||||
return 99;
|
||||
}
|
||||
|
||||
@Value("${dataease.http.cache:false}")
|
||||
private Boolean httpCache;
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
@ -24,11 +28,13 @@ public class HtmlResourceFilter implements Filter, Ordered {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
|
||||
// 禁用缓存
|
||||
httpResponse.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
|
||||
httpResponse.setHeader("Cache", "no-cache");
|
||||
httpResponse.setHeader(HttpHeaders.PRAGMA, "no-cache");
|
||||
httpResponse.setHeader(HttpHeaders.EXPIRES, "0");
|
||||
if(httpCache == null || !httpCache){
|
||||
// 禁用缓存
|
||||
httpResponse.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
|
||||
httpResponse.setHeader("Cache", "no-cache");
|
||||
httpResponse.setHeader(HttpHeaders.PRAGMA, "no-cache");
|
||||
httpResponse.setHeader(HttpHeaders.EXPIRES, "0");
|
||||
}
|
||||
// 继续执行过滤器链
|
||||
filterChain.doFilter(servletRequest, httpResponse);
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ public class AuthUtils {
|
||||
private static final String[] defaultPanelPermissions = { "panel_list" };
|
||||
private static final String[] defaultDataSetPermissions = { "0" };
|
||||
private static final String[] defaultLinkPermissions = { "0" };
|
||||
private static final String[] defaultDataFillingPermissions = { "0" };
|
||||
|
||||
private static final ThreadLocal<CurrentUserDto> USER_INFO = new ThreadLocal<CurrentUserDto>();
|
||||
|
||||
@ -138,6 +139,18 @@ public class AuthUtils {
|
||||
result.add(new AuthItem(item, ResourceAuthLevel.PANEL_LEVEL_MANAGE.getLevel()));
|
||||
});
|
||||
return result;
|
||||
} else if (StringUtils.equals(DePermissionType.DATA_FILL.name().toLowerCase(), type)) {
|
||||
Set<AuthItem> userSet = extAuthService.dataFillingIdByUser(userId).stream().collect(Collectors.toSet());
|
||||
Set<AuthItem> roleSet = roles.stream().map(role -> extAuthService.dataFillingIdByRole(role.getId()))
|
||||
.flatMap(Collection::stream).collect(Collectors.toSet());
|
||||
Set<AuthItem> deptSet = extAuthService.dataFillingIdByDept(deptId).stream().collect(Collectors.toSet());
|
||||
result.addAll(userSet);
|
||||
result.addAll(roleSet);
|
||||
result.addAll(deptSet);
|
||||
Arrays.stream(defaultDataFillingPermissions).forEach(item -> {
|
||||
result.add(new AuthItem(item, ResourceAuthLevel.DATA_FILLING_LEVEL_MANAGE.getLevel()));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package io.dataease.commons.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
@ -17,4 +19,16 @@ public class UrlTestUtils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isURLAvailable(String urlString) {
|
||||
try {
|
||||
URL url = new URL(urlString);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("HEAD");
|
||||
int responseCode = connection.getResponseCode();
|
||||
return responseCode == HttpURLConnection.HTTP_OK;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,6 +71,10 @@ public class IndexController {
|
||||
if (StringUtils.isNotEmpty(fromLink)) {
|
||||
url = url + "&fromLink=" + fromLink;
|
||||
}
|
||||
String ticket = request.getParameter("ticket");
|
||||
if (StringUtils.isNotEmpty(ticket)) {
|
||||
url = url + "&ticket=" + ticket;
|
||||
}
|
||||
response.sendRedirect(url);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e.getMessage());
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package io.dataease.controller.ai;
|
||||
|
||||
import io.dataease.service.ai.AiBaseService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author : WangJiaHao
|
||||
* @date : 2024/3/27 09:44
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("aiBase")
|
||||
public class AiComponentController {
|
||||
@Resource
|
||||
private AiBaseService aiBaseService;
|
||||
|
||||
@GetMapping("findTargetUrl")
|
||||
Map<String, String> findTargetUrl(){
|
||||
return aiBaseService.findTargetUrl();
|
||||
}
|
||||
}
|
||||
@ -109,6 +109,13 @@ public class ChartViewController {
|
||||
return chartViewService.chartCopy(id, panelId);
|
||||
}
|
||||
|
||||
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANEL_LEVEL_MANAGE, paramIndex = 1)
|
||||
@ApiOperation("复制")
|
||||
@PostMapping("chartCopyWithId/{id}/{panelId}/{newId}")
|
||||
public String chartCopyWithId(@PathVariable String id, @PathVariable String panelId, @PathVariable String newId) {
|
||||
return chartViewService.chartCopy(id, newId,panelId);
|
||||
}
|
||||
|
||||
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANEL_LEVEL_MANAGE, paramIndex = 1)
|
||||
@ApiOperation("批量复制")
|
||||
@PostMapping("chartBatchCopy/{panelId}")
|
||||
|
||||
@ -0,0 +1,177 @@
|
||||
package io.dataease.controller.datafill;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.controller.request.datafill.*;
|
||||
import io.dataease.controller.response.datafill.DataFillFormTableDataResponse;
|
||||
import io.dataease.dto.datafill.DataFillCommitLogDTO;
|
||||
import io.dataease.dto.datafill.DataFillFormDTO;
|
||||
import io.dataease.dto.datafill.DataFillTaskDTO;
|
||||
import io.dataease.dto.datafill.DataFillUserTaskDTO;
|
||||
import io.dataease.plugins.common.base.domain.DataFillFormWithBLOBs;
|
||||
import io.dataease.plugins.common.dto.datafill.ExtTableField;
|
||||
import io.dataease.service.datafill.DataFillDataService;
|
||||
import io.dataease.service.datafill.DataFillLogService;
|
||||
import io.dataease.service.datafill.DataFillService;
|
||||
import io.dataease.service.datafill.DataFillTaskService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiIgnore
|
||||
@RequestMapping("dataFilling")
|
||||
@RestController
|
||||
public class DataFillController {
|
||||
|
||||
@Resource
|
||||
private DataFillService dataFillService;
|
||||
@Resource
|
||||
private DataFillLogService dataFillLogService;
|
||||
@Resource
|
||||
private DataFillTaskService dataFillTaskService;
|
||||
@Resource
|
||||
private DataFillDataService dataFillDataService;
|
||||
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/save")
|
||||
public ResultHolder saveForm(@RequestBody DataFillFormWithBLOBs dataFillForm) throws Exception {
|
||||
return dataFillService.saveForm(dataFillForm);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/update")
|
||||
public ResultHolder updateForm(@RequestBody DataFillFormWithBLOBs dataFillForm) throws Exception {
|
||||
return dataFillService.updateForm(dataFillForm);
|
||||
}
|
||||
|
||||
@PostMapping("/manage/form/{id}")
|
||||
public DataFillFormDTO getWithPrivileges(@PathVariable String id) throws Exception {
|
||||
return dataFillService.getWithPrivileges(id);
|
||||
}
|
||||
|
||||
@PostMapping("/form/get/{id}")
|
||||
public DataFillFormWithBLOBs get(@PathVariable String id) throws Exception {
|
||||
return dataFillService.get(id);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/delete/{id}")
|
||||
public void saveForm(@PathVariable String id) throws Exception {
|
||||
dataFillService.deleteForm(id);
|
||||
}
|
||||
|
||||
@ApiOperation("查询树")
|
||||
@PostMapping("/form/tree")
|
||||
public List<DataFillFormDTO> tree(@RequestBody DataFillFormRequest request) {
|
||||
return dataFillService.tree(request);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/{id}/tableData")
|
||||
public DataFillFormTableDataResponse tableData(@PathVariable String id, @RequestBody DataFillFormTableDataRequest request) throws Exception {
|
||||
request.setId(id);
|
||||
return dataFillDataService.listData(request);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/fields/{id}")
|
||||
public List<ExtTableField> listFields(@PathVariable String id) throws Exception {
|
||||
return dataFillService.listFields(id);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/{formId}/delete/{id}")
|
||||
public void deleteRowData(@PathVariable String formId, @PathVariable String id) throws Exception {
|
||||
dataFillDataService.deleteRowData(formId, id);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/{formId}/rowData/save")
|
||||
public String newRowData(@PathVariable String formId, @RequestBody Map<String, Object> data) throws Exception {
|
||||
return dataFillDataService.updateRowData(formId, null, data, true);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/{formId}/rowData/save/{id}")
|
||||
public String updateRowData(@PathVariable String formId, @PathVariable String id, @RequestBody Map<String, Object> data) throws Exception {
|
||||
return dataFillDataService.updateRowData(formId, id, data, false);
|
||||
}
|
||||
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/{formId}/commitLog/{goPage}/{pageSize}")
|
||||
public Pager<List<DataFillCommitLogDTO>> commitLogs(@PathVariable String formId, @PathVariable int goPage, @PathVariable int pageSize, @RequestBody DataFillCommitLogSearchRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
List<DataFillCommitLogDTO> logs = dataFillLogService.commitLogs(formId, request);
|
||||
|
||||
return PageUtils.setPageInfo(page, logs);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/{formId}/task/{goPage}/{pageSize}")
|
||||
public Pager<List<DataFillTaskDTO>> tasks(@PathVariable String formId, @PathVariable int goPage, @PathVariable int pageSize, @RequestBody DataFillTaskSearchRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
List<DataFillTaskDTO> tasks = dataFillTaskService.tasks(formId, request);
|
||||
|
||||
return PageUtils.setPageInfo(page, tasks);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/{formId}/task/save")
|
||||
public void saveTask(@PathVariable String formId, @RequestBody DataFillTaskSearchRequest request) throws Exception {
|
||||
|
||||
dataFillTaskService.saveTask(formId, request);
|
||||
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/task/{taskId}/delete")
|
||||
public void deleteTask(@PathVariable Long taskId) {
|
||||
|
||||
dataFillTaskService.deleteTask(taskId);
|
||||
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/task/{taskId}/enable")
|
||||
public void enableTask(@PathVariable Long taskId) throws Exception {
|
||||
|
||||
dataFillTaskService.enableTask(taskId);
|
||||
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/form/task/{taskId}/disable")
|
||||
public void disableTask(@PathVariable Long taskId) throws Exception {
|
||||
|
||||
dataFillTaskService.disableTask(taskId);
|
||||
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/myTask/{type}/{goPage}/{pageSize}")
|
||||
public Pager<List<DataFillUserTaskDTO>> userTasks(@PathVariable String type, @PathVariable int goPage, @PathVariable int pageSize, @RequestBody DataFillUserTaskSearchRequest request) {
|
||||
Long userId = AuthUtils.getUser().getUserId();
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
List<DataFillUserTaskDTO> tasks = dataFillTaskService.userTasks(userId, type, request);
|
||||
|
||||
return PageUtils.setPageInfo(page, tasks);
|
||||
}
|
||||
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/myTask/fill/{taskId}")
|
||||
public void userFillData(@PathVariable String taskId, @RequestBody Map<String, Object> data) throws Exception {
|
||||
dataFillService.fillFormData(taskId, data);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,9 @@ package io.dataease.controller.handler;
|
||||
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.i18n.Translator;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.web.servlet.error.ErrorAttributes;
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
@ -49,7 +51,7 @@ public class GlobalExceptionHandler implements ErrorController {
|
||||
response.setStatus(code);
|
||||
String errorMessage = StringUtils.EMPTY;
|
||||
if (t != null) {
|
||||
if (Logger.isDebugEnabled()) {
|
||||
if (Logger.isDebugEnabled() && (ObjectUtils.isEmpty(t.getCause()) || !(t.getCause() instanceof AuthenticationException))) {
|
||||
Logger.error("Fail to proceed " + errorAttributeMap.get("path"), t);
|
||||
}
|
||||
errorMessage = t.getMessage();
|
||||
|
||||
@ -8,11 +8,13 @@ import io.dataease.controller.request.panel.PanelViewLogRequest;
|
||||
import io.dataease.controller.request.panel.link.*;
|
||||
import io.dataease.dto.panel.link.GenerateDto;
|
||||
import io.dataease.dto.panel.link.ValidateDto;
|
||||
import io.dataease.plugins.common.base.domain.PanelLinkTicket;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags = "仪表板:链接管理")
|
||||
@ -45,6 +47,11 @@ public interface LinkApi {
|
||||
@PostMapping("/currentGenerate/{resourceId}")
|
||||
GenerateDto currentGenerate(String resourceId);
|
||||
|
||||
@DePermission(type = DePermissionType.PANEL)
|
||||
@ApiOperation("当前ticket信息")
|
||||
@PostMapping("/currentTicket/{resourceId}")
|
||||
List<PanelLinkTicket> queryTicket(String resourceId);
|
||||
|
||||
@ApiOperation("验证访问")
|
||||
@PostMapping("/validate")
|
||||
ValidateDto validate(LinkValidateRequest request) throws Exception;
|
||||
@ -70,5 +77,15 @@ public interface LinkApi {
|
||||
@PostMapping("/viewLog")
|
||||
void viewLinkLog(@RequestBody LinkViewLogRequest request);
|
||||
|
||||
@ApiOperation("保存ticket")
|
||||
@PostMapping("/saveTicket")
|
||||
String saveTicket(@RequestBody TicketCreator creator);
|
||||
|
||||
@ApiOperation("删除ticket")
|
||||
@PostMapping("/delTicket")
|
||||
void deleteTicket(@RequestBody TicketDelRequest request);
|
||||
|
||||
@ApiOperation("切换是否必填ticket")
|
||||
@PostMapping("/enableTicket")
|
||||
void switchRequire(@RequestBody TicketSwitchRequest request);
|
||||
}
|
||||
|
||||
@ -9,9 +9,12 @@ import io.dataease.controller.panel.api.LinkApi;
|
||||
import io.dataease.controller.request.chart.ChartExtRequest;
|
||||
import io.dataease.controller.request.panel.link.*;
|
||||
import io.dataease.dto.panel.link.GenerateDto;
|
||||
import io.dataease.dto.panel.link.TicketDto;
|
||||
import io.dataease.dto.panel.link.ValidateDto;
|
||||
import io.dataease.plugins.common.base.domain.PanelGroupWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.PanelLink;
|
||||
import io.dataease.plugins.common.base.domain.PanelLinkMapping;
|
||||
import io.dataease.plugins.common.base.domain.PanelLinkTicket;
|
||||
import io.dataease.service.chart.ChartViewService;
|
||||
import io.dataease.service.panel.PanelLinkService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@ -27,6 +30,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@ -64,6 +68,11 @@ public class LinkServer implements LinkApi {
|
||||
return panelLinkService.currentGenerate(resourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PanelLinkTicket> queryTicket(@PathVariable("resourceId") String resourceId) {
|
||||
return panelLinkService.queryTicket(resourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValidateDto validate(@RequestBody LinkValidateRequest request) throws Exception {
|
||||
String link = request.getLink();
|
||||
@ -88,7 +97,8 @@ public class LinkServer implements LinkApi {
|
||||
dto.setValid(false);
|
||||
return dto;
|
||||
}
|
||||
String mappingUuid = panelLinkService.getMappingUuid(one);
|
||||
PanelLinkMapping mapping = panelLinkService.getMapping(one);
|
||||
String mappingUuid = mapping.getUuid();
|
||||
if (!StringUtils.equals(uuid, mappingUuid)) {
|
||||
dto.setValid(false);
|
||||
return dto;
|
||||
@ -97,6 +107,10 @@ public class LinkServer implements LinkApi {
|
||||
dto.setEnablePwd(one.getEnablePwd());
|
||||
dto.setPassPwd(panelLinkService.validateHeads(one));
|
||||
dto.setExpire(panelLinkService.isExpire(one));
|
||||
|
||||
String ticketText = request.getTicket();
|
||||
TicketDto ticketDto = panelLinkService.validateTicket(ticketText, mapping);
|
||||
dto.setTicket(ticketDto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@ -141,4 +155,19 @@ public class LinkServer implements LinkApi {
|
||||
String pid = panelGroupWithBLOBs.getPid();
|
||||
DeLogUtils.save(operateType, SysLogConstants.SOURCE_TYPE.LINK, panelId, pid, userId, SysLogConstants.SOURCE_TYPE.USER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveTicket(TicketCreator creator) {
|
||||
return panelLinkService.saveTicket(creator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTicket(TicketDelRequest request) {
|
||||
panelLinkService.deleteTicket(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchRequire(TicketSwitchRequest request) {
|
||||
panelLinkService.switchRequire(request);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package io.dataease.controller.request.datafill;
|
||||
|
||||
import io.dataease.dto.datafill.DataFillCommitLogDTO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DataFillCommitLogSearchRequest extends DataFillCommitLogDTO {
|
||||
|
||||
private static final long serialVersionUID = -1067572649791328116L;
|
||||
|
||||
private List<String> formIds;
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package io.dataease.controller.request.datafill;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.DataFillForm;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@Data
|
||||
@Accessors(chain=true)
|
||||
public class DataFillFormRequest extends DataFillForm {
|
||||
|
||||
private static final long serialVersionUID = -6752223673862214909L;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
private String sort;
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
@ApiModelProperty("ID集合")
|
||||
private Set<String> ids;
|
||||
@ApiModelProperty("排除的ID")
|
||||
private String excludedId;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package io.dataease.controller.request.datafill;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
@Data
|
||||
@Accessors(chain=true)
|
||||
public class DataFillFormTableDataRequest extends DataFillFormRequest {
|
||||
|
||||
private static final long serialVersionUID = -314618516232771747L;
|
||||
|
||||
private long currentPage;
|
||||
|
||||
private long pageSize;
|
||||
|
||||
private String primaryKeyValue;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package io.dataease.controller.request.datafill;
|
||||
|
||||
import io.dataease.dto.datafill.DataFillTaskDTO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DataFillTaskSearchRequest extends DataFillTaskDTO {
|
||||
|
||||
private static final long serialVersionUID = 5881604308639714955L;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package io.dataease.controller.request.datafill;
|
||||
|
||||
import io.dataease.dto.datafill.DataFillUserTaskDTO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DataFillUserTaskSearchRequest extends DataFillUserTaskDTO {
|
||||
|
||||
private static final long serialVersionUID = 5881604308639714955L;
|
||||
|
||||
}
|
||||
@ -9,4 +9,5 @@ public class LinkValidateRequest implements Serializable {
|
||||
|
||||
private String link;
|
||||
private String user;
|
||||
private String ticket;
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package io.dataease.controller.request.panel.link;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TicketCreator implements Serializable {
|
||||
|
||||
private String ticket;
|
||||
|
||||
private Long exp;
|
||||
|
||||
private String args;
|
||||
|
||||
private String uuid;
|
||||
|
||||
private boolean generateNew;
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package io.dataease.controller.request.panel.link;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TicketDelRequest implements Serializable {
|
||||
|
||||
private String ticket;
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package io.dataease.controller.request.panel.link;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TicketSwitchRequest implements Serializable {
|
||||
|
||||
private String resourceId;
|
||||
|
||||
private Boolean require = false;
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package io.dataease.controller.response.datafill;
|
||||
|
||||
import io.dataease.plugins.common.dto.datafill.ExtTableField;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DataFillFormTableDataResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6463885075511811532L;
|
||||
|
||||
private Object data;
|
||||
|
||||
private List<ExtTableField> fields;
|
||||
|
||||
private long total;
|
||||
|
||||
private long currentPage;
|
||||
|
||||
private long pageSize;
|
||||
|
||||
private String key;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package io.dataease.dto.datafill;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.DataFillCommitLog;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataFillCommitLogDTO extends DataFillCommitLog {
|
||||
|
||||
private static final long serialVersionUID = 5324275156717345584L;
|
||||
|
||||
private String commitByName;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package io.dataease.dto.datafill;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.DataFillFormWithBLOBs;
|
||||
import io.dataease.plugins.common.model.ITreeBase;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DataFillFormDTO extends DataFillFormWithBLOBs implements ITreeBase<DataFillFormDTO> {
|
||||
|
||||
private static final long serialVersionUID = 1428065978308162738L;
|
||||
|
||||
@ApiModelProperty("标签")
|
||||
private String label;
|
||||
@ApiModelProperty("子节点")
|
||||
private List<DataFillFormDTO> children;
|
||||
@ApiModelProperty("权限")
|
||||
private String privileges;
|
||||
|
||||
private String creatorName;
|
||||
private String datasourceName;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package io.dataease.dto.datafill;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.DataFillTaskWithBLOBs;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataFillTaskDTO extends DataFillTaskWithBLOBs {
|
||||
|
||||
private static final long serialVersionUID = 3610753131867651856L;
|
||||
|
||||
private String formName;
|
||||
|
||||
private String creatorName;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package io.dataease.dto.datafill;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.DataFillUserTask;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataFillUserTaskDTO extends DataFillUserTask {
|
||||
|
||||
private static final long serialVersionUID = 3610753131867651856L;
|
||||
|
||||
private String taskName;
|
||||
private String formName;
|
||||
private Long creator;
|
||||
private String creatorName;
|
||||
|
||||
}
|
||||
@ -16,4 +16,8 @@ public class GenerateDto {
|
||||
private String pwd;
|
||||
@ApiModelProperty("有效期")
|
||||
private Long overTime;
|
||||
@ApiModelProperty("ticket必填")
|
||||
private boolean requireTicket;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package io.dataease.dto.panel.link;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TicketDto implements Serializable {
|
||||
|
||||
private boolean ticketValid;
|
||||
|
||||
private boolean ticketExp;
|
||||
|
||||
private String args;
|
||||
}
|
||||
@ -19,4 +19,6 @@ public class ValidateDto {
|
||||
private String resourceId;
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
|
||||
private TicketDto ticket;
|
||||
}
|
||||
|
||||
@ -613,7 +613,7 @@
|
||||
|
||||
<delete id="deleteNoUseView">
|
||||
delete from chart_view
|
||||
where scene_id = #{panelId}
|
||||
where scene_id = #{panelId} and create_time < ( unix_timestamp()- 30 ) * 1000
|
||||
<if test="viewIds != null and viewIds.size() > 0">
|
||||
and id not in
|
||||
<foreach collection="viewIds" item="viewId" open='(' separator=',' close=')'>
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package io.dataease.ext;
|
||||
|
||||
import io.dataease.controller.request.datafill.DataFillFormRequest;
|
||||
import io.dataease.controller.request.datafill.DataFillTaskSearchRequest;
|
||||
import io.dataease.dto.datafill.DataFillCommitLogDTO;
|
||||
import io.dataease.dto.datafill.DataFillFormDTO;
|
||||
import io.dataease.dto.datafill.DataFillTaskDTO;
|
||||
import io.dataease.dto.datafill.DataFillUserTaskDTO;
|
||||
import io.dataease.plugins.common.base.domain.DataFillTask;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ExtDataFillFormMapper {
|
||||
List<DataFillFormDTO> search(DataFillFormRequest request);
|
||||
|
||||
Map<String, String> searchChildrenIds(String id, String type);
|
||||
|
||||
List<DataFillCommitLogDTO> selectLatestLogByFormDataIds(String formId, List<String> dataIds);
|
||||
|
||||
List<DataFillCommitLogDTO> selectDataFillLogs(String formId, String commitByName);
|
||||
|
||||
List<DataFillTaskDTO> selectDataFillTasks(DataFillTaskSearchRequest request);
|
||||
List<DataFillTask> selectActiveDataFillTasks();
|
||||
|
||||
List<DataFillUserTaskDTO> listTodoUserTask(long userId, Date current, String taskName);
|
||||
List<DataFillUserTaskDTO> listFinishedUserTask(long userId, String taskName);
|
||||
List<DataFillUserTaskDTO> listExpiredUserTask(long userId, Date current, String taskName);
|
||||
}
|
||||
@ -0,0 +1,267 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.dataease.ext.ExtDataFillFormMapper">
|
||||
|
||||
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.datafill.DataFillFormDTO"
|
||||
extends="io.dataease.plugins.common.base.mapper.DataFillFormMapper.BaseResultMap">
|
||||
<result column="label" property="label"/>
|
||||
<result column="privileges" property="privileges"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="search" resultMap="BaseResultMapDTO">
|
||||
select
|
||||
id, `name`, ifnull(pid, 0) as pid, `level`, node_type, `table_name`, datasource, create_index, create_by,
|
||||
create_time, update_by, update_time,
|
||||
`name` as label,
|
||||
authInfo.privileges as `privileges`
|
||||
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'data_fill') cids) t, data_fill_form
|
||||
left join (
|
||||
SELECT
|
||||
auth_source,
|
||||
group_concat( DISTINCT sys_auth_detail.privilege_extend ) as `privileges`
|
||||
FROM
|
||||
(
|
||||
`sys_auth`
|
||||
LEFT JOIN `sys_auth_detail` ON ((
|
||||
`sys_auth`.`id` = `sys_auth_detail`.`auth_id`
|
||||
)))
|
||||
WHERE
|
||||
sys_auth_detail.privilege_value = 1
|
||||
AND sys_auth.auth_source_type = 'data_fill'
|
||||
AND (
|
||||
(
|
||||
sys_auth.auth_target_type = 'dept'
|
||||
AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{userId} )
|
||||
)
|
||||
OR (
|
||||
sys_auth.auth_target_type = 'user'
|
||||
AND sys_auth.auth_target = #{userId}
|
||||
)
|
||||
OR (
|
||||
sys_auth.auth_target_type = 'role'
|
||||
AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} )
|
||||
)
|
||||
)
|
||||
GROUP BY
|
||||
`sys_auth`.`auth_source`
|
||||
) authInfo
|
||||
on data_fill_form.id = authInfo.auth_source
|
||||
<where>
|
||||
FIND_IN_SET(data_fill_form.id, cids)
|
||||
<if test="id != null">
|
||||
and data_fill_form.id = #{id,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and data_fill_form.`name` like CONCAT('%', #{name},'%')
|
||||
</if>
|
||||
<if test="pid != null">
|
||||
and data_fill_form.pid = #{pid,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="nodeType != null">
|
||||
and data_fill_form.node_type = #{nodeType,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="level != null">
|
||||
and data_fill_form.`level` = #{level,jdbcType=INTEGER}
|
||||
</if>
|
||||
|
||||
<if test="createBy != null">
|
||||
and data_fill_form.create_by = #{createBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and data_fill_form.create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="updateBy != null">
|
||||
and data_fill_form.update_by = #{updateBy,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and data_fill_form.update_time = #{updateTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
|
||||
|
||||
<if test="excludedId != null">
|
||||
and data_fill_form.id != #{excludedId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
and id in
|
||||
<foreach collection="ids" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY CONVERT(`name` using gbk)
|
||||
</select>
|
||||
|
||||
<select id="searchChildrenIds" resultType="java.util.Map">
|
||||
select GET_V_AUTH_MODEL_WITH_CHILDREN(#{id}, #{type}) ids
|
||||
</select>
|
||||
|
||||
|
||||
<resultMap id="BaseResultMapLogDTO" type="io.dataease.dto.datafill.DataFillCommitLogDTO"
|
||||
extends="io.dataease.plugins.common.base.mapper.DataFillCommitLogMapper.BaseResultMap">
|
||||
<result column="nick_name" property="commitByName"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectDataFillLogs" resultMap="BaseResultMapLogDTO">
|
||||
SELECT t1.id,
|
||||
t1.form_id,
|
||||
t1.data_id,
|
||||
t1.operate,
|
||||
t1.commit_by,
|
||||
t1.commit_time,
|
||||
t2.nick_name
|
||||
FROM (SELECT * FROM data_fill_commit_log
|
||||
WHERE form_id = #{formId} ) t1
|
||||
LEFT JOIN (SELECT username, nick_name FROM sys_user) t2 ON t1.commit_by = t2.username
|
||||
<where>
|
||||
<if test="commitByName != null" >
|
||||
AND t2.nick_name LIKE CONCAT('%',#{commitByName},'%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t1.commit_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectLatestLogByFormDataIds" resultMap="BaseResultMapLogDTO">
|
||||
SELECT t3.id,
|
||||
t3.form_id,
|
||||
t3.data_id,
|
||||
t3.operate,
|
||||
t3.commit_by,
|
||||
t3.commit_time,
|
||||
t4.nick_name
|
||||
FROM (SELECT t1.id,
|
||||
t1.form_id,
|
||||
t1.data_id,
|
||||
t1.operate,
|
||||
t1.commit_by,
|
||||
t1.commit_time
|
||||
FROM (SELECT * FROM data_fill_commit_log
|
||||
WHERE form_id = #{formId}
|
||||
<if test="dataIds != null and dataIds.size() > 0">
|
||||
AND data_id in
|
||||
<foreach collection="dataIds" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
) t1
|
||||
INNER JOIN (SELECT MAX(commit_time) AS commit_time, form_id, data_id
|
||||
FROM data_fill_commit_log
|
||||
GROUP BY form_id, data_id) t2
|
||||
ON t1.form_id = t2.form_id AND t1.commit_time = t2.commit_time AND t1.data_id = t2.data_id) t3
|
||||
LEFT JOIN (SELECT username, nick_name FROM sys_user) t4 ON t3.commit_by = t4.username
|
||||
</select>
|
||||
|
||||
<resultMap id="BaseResultMapTaskDTO" type="io.dataease.dto.datafill.DataFillTaskDTO"
|
||||
extends="io.dataease.plugins.common.base.mapper.DataFillTaskMapper.ResultMapWithBLOBs">
|
||||
<result column="formName" property="formName"/>
|
||||
<result column="nick_name" property="creatorName"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectDataFillTasks" resultMap="BaseResultMapTaskDTO">
|
||||
SELECT t1.id, t1.`name`, t1.form_id, t1.start_time, t1.end_time, t1.rate_type, t1.rate_val, t1.publish_start_time,
|
||||
t1.publish_end_time, t1.publish_range_time_type, t1.publish_range_time, t1.creator, t1.create_time,
|
||||
t1.`status`,
|
||||
t1.reci_users, t1.role_list, t1.org_list,
|
||||
t2.nick_name, t3.`name` AS formName
|
||||
FROM (SELECT * FROM data_fill_task
|
||||
WHERE form_id = #{formId}
|
||||
<if test="id != null">
|
||||
and `id` = #{id,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="name != null" >
|
||||
AND `name` LIKE CONCAT('%',#{name},'%')
|
||||
</if>
|
||||
) t1
|
||||
LEFT JOIN (SELECT user_id, nick_name FROM sys_user) t2 ON t1.creator = t2.user_id
|
||||
LEFT JOIN (SELECT name, id FROM data_fill_form) t3 ON t1.form_id = t3.id
|
||||
WHERE 1 = 1
|
||||
ORDER BY t1.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectActiveDataFillTasks" resultMap="io.dataease.plugins.common.base.mapper.DataFillTaskMapper.BaseResultMap">
|
||||
SELECT
|
||||
<include refid="io.dataease.plugins.common.base.mapper.DataFillTaskMapper.Base_Column_List" />
|
||||
FROM data_fill_task
|
||||
WHERE status = 1
|
||||
AND ((rate_type = -1 AND publish_start_time <= current_timestamp AND (publish_end_time is null OR
|
||||
publish_end_time >= current_timestamp))
|
||||
OR
|
||||
(rate_type != -1 AND start_time <= current_timestamp AND (end_time is null OR end_time >=
|
||||
current_timestamp))
|
||||
)
|
||||
</select>
|
||||
|
||||
<resultMap id="BaseResultMapUserTaskDTO" type="io.dataease.dto.datafill.DataFillUserTaskDTO"
|
||||
extends="io.dataease.plugins.common.base.mapper.DataFillUserTaskMapper.BaseResultMap">
|
||||
<result column="taskName" property="taskName"/>
|
||||
<result column="formName" property="formName"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="creatorName" property="creatorName"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="listTodoUserTask" resultMap="BaseResultMapUserTaskDTO">
|
||||
SELECT
|
||||
t1.id, t1.task_id, t1.form_id, t1.value_id, t1.`user`, t1.start_time, t1.end_time, t1.finish_time,
|
||||
t2.`name` AS formName, t3.`name` AS taskName, t3.`creator`, t4.`nick_name` AS creatorName
|
||||
FROM
|
||||
(SELECT
|
||||
<include refid="io.dataease.plugins.common.base.mapper.DataFillUserTaskMapper.Base_Column_List" />
|
||||
FROM data_fill_user_task
|
||||
WHERE user = #{userId}
|
||||
AND finish_time IS NULL
|
||||
AND start_time <= #{current} AND (end_time IS NULL OR end_time >= #{current})) t1
|
||||
LEFT JOIN (SELECT id, `name` FROM data_fill_form) t2 ON t1.form_id = t2.id
|
||||
LEFT JOIN (SELECT id, `name`, `creator` FROM data_fill_task) t3 ON t1.task_id = t3.id
|
||||
LEFT JOIN (SELECT user_id, nick_name FROM sys_user) t4 ON t3.creator = t4.user_id
|
||||
<where>
|
||||
<if test="taskName != null" >
|
||||
AND t3.`name` LIKE CONCAT('%',#{taskName},'%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t1.end_time, t1.start_time
|
||||
</select>
|
||||
|
||||
<select id="listFinishedUserTask" resultMap="BaseResultMapUserTaskDTO">
|
||||
SELECT
|
||||
t1.id, t1.task_id, t1.form_id, t1.value_id, t1.`user`, t1.start_time, t1.end_time, t1.finish_time,
|
||||
t2.`name` AS formName, t3.`name` AS taskName, t3.`creator`, t4.`nick_name` AS creatorName
|
||||
FROM
|
||||
(SELECT
|
||||
<include refid="io.dataease.plugins.common.base.mapper.DataFillUserTaskMapper.Base_Column_List" />
|
||||
FROM data_fill_user_task
|
||||
WHERE user = #{userId}
|
||||
AND finish_time IS NOT NULL) t1
|
||||
LEFT JOIN (SELECT id, `name` FROM data_fill_form) t2 ON t1.form_id = t2.id
|
||||
LEFT JOIN (SELECT id, `name`, `creator` FROM data_fill_task) t3 ON t1.task_id = t3.id
|
||||
LEFT JOIN (SELECT user_id, nick_name FROM sys_user) t4 ON t3.creator = t4.user_id
|
||||
<where>
|
||||
<if test="taskName != null" >
|
||||
AND t3.`name` LIKE CONCAT('%',#{taskName},'%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t1.finish_time DESC, t1.end_time DESC, t1.start_time
|
||||
</select>
|
||||
|
||||
<select id="listExpiredUserTask" resultMap="BaseResultMapUserTaskDTO">
|
||||
SELECT
|
||||
t1.id, t1.task_id, t1.form_id, t1.value_id, t1.`user`, t1.start_time, t1.end_time, t1.finish_time,
|
||||
t2.`name` AS formName, t3.`name` AS taskName, t3.`creator`, t4.`nick_name` AS creatorName
|
||||
FROM
|
||||
(SELECT
|
||||
<include refid="io.dataease.plugins.common.base.mapper.DataFillUserTaskMapper.Base_Column_List" />
|
||||
FROM data_fill_user_task
|
||||
WHERE user = #{userId}
|
||||
AND end_time <= #{current}) t1
|
||||
LEFT JOIN (SELECT id, `name` FROM data_fill_form) t2 ON t1.form_id = t2.id
|
||||
LEFT JOIN (SELECT id, `name`, `creator` FROM data_fill_task) t3 ON t1.task_id = t3.id
|
||||
LEFT JOIN (SELECT user_id, nick_name FROM sys_user) t4 ON t3.creator = t4.user_id
|
||||
<where>
|
||||
<if test="taskName != null" >
|
||||
AND t3.`name` LIKE CONCAT('%',#{taskName},'%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t1.end_time DESC, t1.start_time
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -199,7 +199,7 @@
|
||||
and panel_group.level = #{level}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY panel_group.node_type desc, CONVERT(panel_group.name using gbk)
|
||||
ORDER BY panel_group.create_time desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteLinkDefaultCircle">
|
||||
|
||||
@ -206,6 +206,21 @@
|
||||
</where>
|
||||
</if>
|
||||
|
||||
<if test="type == 13">
|
||||
id, name
|
||||
from data_fill_form
|
||||
<where>
|
||||
id in
|
||||
<foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
ORDER BY FIELD(id,
|
||||
<foreach collection="ids" item="id" index="index" open="" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
@ -4,10 +4,11 @@ import io.dataease.commons.utils.CronUtils;
|
||||
import io.dataease.job.sechedule.ScheduleManager;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.quartz.*;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public abstract class TaskHandler implements InitializingBean {
|
||||
|
||||
@ -0,0 +1,184 @@
|
||||
package io.dataease.job.sechedule.strategy.impl;
|
||||
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.commons.utils.CronUtils;
|
||||
import io.dataease.service.datafill.DataFillTaskService;
|
||||
import io.dataease.job.sechedule.ScheduleManager;
|
||||
import io.dataease.job.sechedule.strategy.TaskHandler;
|
||||
import io.dataease.plugins.common.base.domain.DataFillTaskWithBLOBs;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.quartz.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
@Service("dataFillTaskHandler")
|
||||
public class DataFillTaskHandler extends TaskHandler implements Job {
|
||||
|
||||
|
||||
@Override
|
||||
protected JobDataMap jobDataMap(GlobalTaskEntity taskEntity) {
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put("taskEntity", taskEntity);
|
||||
|
||||
return jobDataMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetRunningInstance(Long taskId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean taskIsRunning(Long taskId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
// 插件没有加载 空转
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded())
|
||||
return;
|
||||
|
||||
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
|
||||
GlobalTaskEntity taskEntity = (GlobalTaskEntity) jobDataMap.get("taskEntity");
|
||||
|
||||
ScheduleManager scheduleManager = SpringContextUtil.getBean(ScheduleManager.class);
|
||||
|
||||
DataFillTaskService dataFillTaskService = SpringContextUtil.getBean(DataFillTaskService.class);
|
||||
|
||||
DataFillTaskWithBLOBs task = dataFillTaskService.getTaskById(taskEntity.getTaskId());
|
||||
|
||||
try {
|
||||
dataFillTaskService.createUserTasks(task, null);
|
||||
|
||||
if (task.getRateType() == -1) {
|
||||
//一次性任务执行完之后需要修改为停止
|
||||
dataFillTaskService.finishTask(task.getId());
|
||||
removeTask(scheduleManager, taskEntity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTask(ScheduleManager scheduleManager, GlobalTaskEntity taskEntity) throws Exception {
|
||||
|
||||
DataFillTaskService dataFillTaskService = SpringContextUtil.getBean(DataFillTaskService.class);
|
||||
// 1。首先看看是否过期
|
||||
Long endTime = taskEntity.getEndTime();
|
||||
removeTask(scheduleManager, taskEntity);
|
||||
if (CronUtils.taskExpire(endTime)) { // 过期了就删除任务
|
||||
dataFillTaskService.finishTask(taskEntity.getTaskId()); //状态置为已停止
|
||||
return;
|
||||
}
|
||||
if (!taskEntity.getStatus()) return;
|
||||
JobKey jobKey = new JobKey("DATA_FILL_TASK_" + taskEntity.getTaskId().toString());
|
||||
TriggerKey triggerKey = new TriggerKey("DATA_FILL_TASK_" + taskEntity.getTaskId());
|
||||
Date start = new Date(taskEntity.getStartTime());
|
||||
Date end = null;
|
||||
if (ObjectUtils.isNotEmpty(taskEntity.getEndTime())) {
|
||||
end = new Date(taskEntity.getEndTime());
|
||||
}
|
||||
Class<? extends TaskHandler> executor = this.getClass();
|
||||
String cron = cron(taskEntity);
|
||||
if (taskEntity.getRateType() == -1) {
|
||||
long currentTriggerTime = System.currentTimeMillis() + 30 * 1000; //一次性的任务,确保下发成功,增加一点延时
|
||||
if (taskEntity.getStartTime() >= currentTriggerTime) {
|
||||
currentTriggerTime = taskEntity.getStartTime();
|
||||
start = new Date(taskEntity.getStartTime() - 30 * 1000);
|
||||
}
|
||||
cron = cron(new Date(currentTriggerTime));
|
||||
}
|
||||
scheduleManager.addOrUpdateCronJob(jobKey, triggerKey, executor, cron, start, end, jobDataMap(taskEntity));
|
||||
}
|
||||
|
||||
private static String cron(Date date) {
|
||||
Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(date);
|
||||
|
||||
return instance.get(Calendar.SECOND) + " " +
|
||||
instance.get(Calendar.MINUTE) + " " +
|
||||
instance.get(Calendar.HOUR_OF_DAY) + " " +
|
||||
instance.get(Calendar.DAY_OF_MONTH) + " " +
|
||||
(instance.get(Calendar.MONTH) + 1) + " ? " +
|
||||
instance.get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
private static String cron(GlobalTaskEntity taskEntity) {
|
||||
if (taskEntity.getRateType() == -1) {
|
||||
return taskEntity.getRateVal();
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
Date date = null;
|
||||
try {
|
||||
date = sdf.parse(taskEntity.getRateVal());
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
java.util.Calendar instance = java.util.Calendar.getInstance();
|
||||
instance.setTime(date);
|
||||
|
||||
if (taskEntity.getRateType() == 0) {
|
||||
return instance.get(java.util.Calendar.SECOND) + " " +
|
||||
instance.get(java.util.Calendar.MINUTE) + " " +
|
||||
instance.get(java.util.Calendar.HOUR_OF_DAY) + " * * ?";
|
||||
}
|
||||
if (taskEntity.getRateType() == 1) {
|
||||
return instance.get(java.util.Calendar.SECOND) + " " +
|
||||
instance.get(java.util.Calendar.MINUTE) + " " +
|
||||
instance.get(java.util.Calendar.HOUR_OF_DAY) + " ? * " +
|
||||
getWeekDayStr(instance.get(Calendar.DATE)); //这里是拿日当作周来保存的
|
||||
}
|
||||
if (taskEntity.getRateType() == 2) {
|
||||
return instance.get(java.util.Calendar.SECOND) + " " +
|
||||
instance.get(java.util.Calendar.MINUTE) + " " +
|
||||
instance.get(java.util.Calendar.HOUR_OF_DAY) + " " +
|
||||
instance.get(Calendar.DATE) + " * ?";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getWeekDayStr(int day) {
|
||||
switch (day) {
|
||||
case 1:
|
||||
return "MON";
|
||||
case 2:
|
||||
return "TUE";
|
||||
case 3:
|
||||
return "WED";
|
||||
case 4:
|
||||
return "THU";
|
||||
case 5:
|
||||
return "FRI";
|
||||
case 6:
|
||||
return "SAT";
|
||||
case 7:
|
||||
return "SUN";
|
||||
}
|
||||
return "*";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTask(ScheduleManager scheduleManager, GlobalTaskEntity taskEntity) {
|
||||
JobKey jobKey = new JobKey("DATA_FILL_TASK_" + taskEntity.getTaskId().toString());
|
||||
TriggerKey triggerKey = new TriggerKey("DATA_FILL_TASK_" + taskEntity.getTaskId());
|
||||
scheduleManager.removeJob(jobKey, triggerKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask(ScheduleManager scheduleManager, GlobalTaskEntity taskEntity) throws Exception {
|
||||
JobKey jobKey = new JobKey("DATA_FILL_TASK_" + taskEntity.getTaskId().toString());
|
||||
scheduleManager.fireNow(jobKey);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package io.dataease.listener;
|
||||
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.service.datasource.DatasourceService;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -8,17 +9,23 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextClosedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
public class ApplicationCloseEventListener implements ApplicationListener<ContextClosedEvent> {
|
||||
|
||||
@Autowired(required = false)
|
||||
CacheManager cacheManager;
|
||||
@Resource
|
||||
DatasourceService datasourceService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextClosedEvent event) {
|
||||
|
||||
if (ObjectUtils.isNotEmpty(cacheManager))
|
||||
cacheManager.shutdown();
|
||||
datasourceService.releaseDsconnections();
|
||||
LogUtil.info("DataEase is stopping");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
package io.dataease.listener;
|
||||
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.service.datafill.DataFillTaskService;
|
||||
import io.dataease.job.sechedule.ScheduleManager;
|
||||
import io.dataease.job.sechedule.strategy.TaskHandler;
|
||||
import io.dataease.job.sechedule.strategy.TaskStrategyFactory;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class DataFillTaskStartListener implements ApplicationListener<ApplicationReadyEvent> {
|
||||
|
||||
@Autowired
|
||||
private AuthUserService authUserService;
|
||||
|
||||
@Autowired
|
||||
private ScheduleManager scheduleManager;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent event) {
|
||||
if (authUserService.pluginLoaded()) {
|
||||
DataFillTaskService service = SpringContextUtil.getBean(DataFillTaskService.class);
|
||||
|
||||
List<GlobalTaskEntity> tasks = service.listActiveTasksGlobalTaskEntity();
|
||||
tasks.stream().forEach(task -> {
|
||||
TaskHandler taskHandler = TaskStrategyFactory.getInvokeStrategy(task.getTaskType());
|
||||
try {
|
||||
taskHandler.resetRunningInstance(task.getTaskId());
|
||||
taskHandler.addTask(scheduleManager, task);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,27 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiIgnore
|
||||
@RequestMapping("/plugin/oidc")
|
||||
@RestController
|
||||
@ -31,19 +41,19 @@ public class XOidcServer {
|
||||
oidcXpackService.save(settings);
|
||||
}
|
||||
|
||||
@PostMapping(value="/authInfo")
|
||||
@PostMapping(value = "/authInfo")
|
||||
public Map<String, Object> authInfo() {
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
List<SysSettingDto> oidcSettings = oidcXpackService.oidcSettings();
|
||||
|
||||
|
||||
Map<String, String> authParam = new HashMap<>();
|
||||
authParam.put("response_type", "code");
|
||||
authParam.put("state", "state");
|
||||
|
||||
|
||||
|
||||
oidcSettings.forEach(param -> {
|
||||
if(StringUtils.isNotBlank(param.getParamKey())) {
|
||||
if (StringUtils.isNotBlank(param.getParamKey())) {
|
||||
if (StringUtils.equals(param.getParamKey(), "oidc.authEndpoint")) {
|
||||
result.put("authEndpoint", param.getParamValue());
|
||||
}
|
||||
@ -53,10 +63,46 @@ public class XOidcServer {
|
||||
if (StringUtils.equals(param.getParamKey(), "oidc.clientId")) {
|
||||
authParam.put("client_id", param.getParamValue());
|
||||
}
|
||||
if (StringUtils.equals(param.getParamKey(), "oidc.pkce") && StringUtils.isNotBlank(param.getParamValue())) {
|
||||
String pkceMethod = param.getParamValue();
|
||||
authParam.put("code_challenge_method", pkceMethod);
|
||||
if (StringUtils.equalsIgnoreCase("S256", pkceMethod)) {
|
||||
String verifier = generateVerifier();
|
||||
authParam.put("code_challenge", s256Challenge(verifier));
|
||||
authParam.put("state", verifier);
|
||||
} else if (StringUtils.equalsIgnoreCase("plain", pkceMethod)) {
|
||||
String verifier = generateVerifier();
|
||||
authParam.put("code_challenge", verifier);
|
||||
authParam.put("state", verifier);
|
||||
} else {
|
||||
authParam.remove("code_challenge_method");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
result.put("authParam", authParam);
|
||||
return result;
|
||||
}
|
||||
|
||||
private String generateVerifier() {
|
||||
SecureRandom sr = new SecureRandom();
|
||||
byte[] code = new byte[32];
|
||||
sr.nextBytes(code);
|
||||
return Base64.getUrlEncoder().withoutPadding().encodeToString(code);
|
||||
}
|
||||
|
||||
private String s256Challenge(String verifier) {
|
||||
try {
|
||||
byte[] bytes = verifier.getBytes(StandardCharsets.US_ASCII);
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
md.update(bytes, 0, bytes.length);
|
||||
byte[] digest = md.digest();
|
||||
return org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(digest);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage());
|
||||
DataEaseException.throwException(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ import io.dataease.plugins.datasource.provider.DefaultJdbcProvider;
|
||||
import io.dataease.plugins.datasource.provider.ExtendedJdbcClassLoader;
|
||||
import io.dataease.plugins.datasource.provider.ProviderFactory;
|
||||
import io.dataease.plugins.datasource.query.QueryProvider;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -76,11 +77,38 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public int execWithPreparedStatement(DatasourceRequest datasourceRequest) throws Exception {
|
||||
JdbcConfiguration jdbcConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), JdbcConfiguration.class);
|
||||
int queryTimeout = jdbcConfiguration.getQueryTimeout() > 0 ? jdbcConfiguration.getQueryTimeout() : 0;
|
||||
try (Connection connection = getConnectionFromPool(datasourceRequest); PreparedStatement stat = getPreparedStatement(connection, queryTimeout, datasourceRequest.getQuery())) {
|
||||
|
||||
if (CollectionUtils.isNotEmpty(datasourceRequest.getTableFieldWithValues())) {
|
||||
LogUtil.info("execWithPreparedStatement sql: " + datasourceRequest.getQuery());
|
||||
for (int i = 0; i < datasourceRequest.getTableFieldWithValues().size(); i++) {
|
||||
stat.setObject(i + 1, datasourceRequest.getTableFieldWithValues().get(i).getValue(), datasourceRequest.getTableFieldWithValues().get(i).getType());
|
||||
LogUtil.info("execWithPreparedStatement param[" + (i + 1) + "]: " + datasourceRequest.getTableFieldWithValues().get(i).getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return stat.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
DataEaseException.throwException(e);
|
||||
} catch (Exception e) {
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TableField> getTableFields(DatasourceRequest datasourceRequest) throws Exception {
|
||||
String requestTableName = datasourceRequest.getTable();
|
||||
if (datasourceRequest.isLowerCaseTaleNames()) {
|
||||
requestTableName = requestTableName.toLowerCase();
|
||||
}
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase("mongo")) {
|
||||
datasourceRequest.setQuery("select * from " + datasourceRequest.getTable());
|
||||
datasourceRequest.setQuery("select * from " + requestTableName);
|
||||
return fetchResultField(datasourceRequest);
|
||||
}
|
||||
List<TableField> list = new LinkedList<>();
|
||||
@ -93,7 +121,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
}
|
||||
}
|
||||
DatabaseMetaData databaseMetaData = connection.getMetaData();
|
||||
String tableNamePattern = datasourceRequest.getTable();
|
||||
String tableNamePattern = requestTableName;
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.mysql.name())) {
|
||||
if (databaseMetaData.getDriverMajorVersion() < 8) {
|
||||
tableNamePattern = String.format(MySQLConstants.KEYWORD_TABLE, tableNamePattern);
|
||||
@ -110,6 +138,10 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
Set<String> primaryKeySet = new HashSet<>();
|
||||
while (primaryKeys.next()) {
|
||||
String tableName = primaryKeys.getString("TABLE_NAME");
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.mysql.name()) || datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.mariadb.name())) {
|
||||
//这里因为旧版mysql驱动问题,需要特殊处理
|
||||
tableName = tableName.replaceAll("`", "");
|
||||
}
|
||||
String database;
|
||||
String schema = primaryKeys.getString("TABLE_SCHEM");
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.pg.name()) || datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.ck.name())
|
||||
@ -118,22 +150,25 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
} else {
|
||||
database = primaryKeys.getString("TABLE_CAT");
|
||||
}
|
||||
if (datasourceRequest.isLowerCaseTaleNames()) {
|
||||
tableName = tableName.toLowerCase();
|
||||
}
|
||||
//获取主键的名称
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.pg.name())) {
|
||||
if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDsSchema(datasourceRequest))) {
|
||||
if (tableName.equals(requestTableName) && database.equalsIgnoreCase(getDsSchema(datasourceRequest))) {
|
||||
primaryKeySet.add(primaryKeys.getString("COLUMN_NAME"));
|
||||
}
|
||||
} else if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.sqlServer.name())) {
|
||||
if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDatabase(datasourceRequest)) && schema.equalsIgnoreCase(getDsSchema(datasourceRequest))) {
|
||||
if (tableName.equals(requestTableName) && database.equalsIgnoreCase(getDatabase(datasourceRequest)) && schema.equalsIgnoreCase(getDsSchema(datasourceRequest))) {
|
||||
primaryKeySet.add(primaryKeys.getString("COLUMN_NAME"));
|
||||
}
|
||||
} else {
|
||||
if (database != null) {
|
||||
if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDatabase(datasourceRequest))) {
|
||||
if (tableName.equals(requestTableName) && database.equalsIgnoreCase(getDatabase(datasourceRequest))) {
|
||||
primaryKeySet.add(primaryKeys.getString("COLUMN_NAME"));
|
||||
}
|
||||
} else {
|
||||
if (tableName.equals(datasourceRequest.getTable())) {
|
||||
if (tableName.equals(requestTableName)) {
|
||||
primaryKeySet.add(primaryKeys.getString("COLUMN_NAME"));
|
||||
}
|
||||
}
|
||||
@ -151,24 +186,27 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
} else {
|
||||
database = resultSet.getString("TABLE_CAT");
|
||||
}
|
||||
if (datasourceRequest.isLowerCaseTaleNames()) {
|
||||
tableName = tableName.toLowerCase();
|
||||
}
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.pg.name())) {
|
||||
if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDsSchema(datasourceRequest))) {
|
||||
if (tableName.equals(requestTableName) && database.equalsIgnoreCase(getDsSchema(datasourceRequest))) {
|
||||
TableField tableField = getTableFiled(resultSet, datasourceRequest, primaryKeySet);
|
||||
list.add(tableField);
|
||||
}
|
||||
} else if (datasourceRequest.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.sqlServer.name())) {
|
||||
if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDatabase(datasourceRequest)) && schema.equalsIgnoreCase(getDsSchema(datasourceRequest))) {
|
||||
if (tableName.equals(requestTableName) && database.equalsIgnoreCase(getDatabase(datasourceRequest)) && schema.equalsIgnoreCase(getDsSchema(datasourceRequest))) {
|
||||
TableField tableField = getTableFiled(resultSet, datasourceRequest, primaryKeySet);
|
||||
list.add(tableField);
|
||||
}
|
||||
} else {
|
||||
if (database != null) {
|
||||
if (tableName.equals(datasourceRequest.getTable()) && database.equalsIgnoreCase(getDatabase(datasourceRequest))) {
|
||||
if (tableName.equals(requestTableName) && database.equalsIgnoreCase(getDatabase(datasourceRequest))) {
|
||||
TableField tableField = getTableFiled(resultSet, datasourceRequest, primaryKeySet);
|
||||
list.add(tableField);
|
||||
}
|
||||
} else {
|
||||
if (tableName.equals(datasourceRequest.getTable())) {
|
||||
if (tableName.equals(requestTableName)) {
|
||||
TableField tableField = getTableFiled(resultSet, datasourceRequest, primaryKeySet);
|
||||
list.add(tableField);
|
||||
}
|
||||
@ -181,7 +219,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
DataEaseException.throwException(e);
|
||||
} catch (Exception e) {
|
||||
if (datasourceRequest.getDatasource().getType().equalsIgnoreCase("ds_doris") || datasourceRequest.getDatasource().getType().equalsIgnoreCase("StarRocks")) {
|
||||
datasourceRequest.setQuery("select * from " + datasourceRequest.getTable());
|
||||
datasourceRequest.setQuery("select * from " + requestTableName);
|
||||
return fetchResultField(datasourceRequest);
|
||||
} else {
|
||||
DataEaseException.throwException(Translator.get("i18n_datasource_connect_error") + e.getMessage());
|
||||
@ -201,6 +239,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
}
|
||||
tableField.setRemarks(remarks);
|
||||
String dbType = resultSet.getString("TYPE_NAME").toUpperCase();
|
||||
tableField.setType(resultSet.getInt("DATA_TYPE"));
|
||||
tableField.setFieldType(dbType);
|
||||
if (dbType.equalsIgnoreCase("LONG")) {
|
||||
tableField.setFieldSize(65533);
|
||||
@ -398,7 +437,17 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
List<String[]> list = new LinkedList<>();
|
||||
JdbcConfiguration jdbcConfiguration = new Gson().fromJson(dsr.getDatasource().getConfiguration(), JdbcConfiguration.class);
|
||||
int queryTimeout = jdbcConfiguration.getQueryTimeout() > 0 ? jdbcConfiguration.getQueryTimeout() : 0;
|
||||
try (Connection connection = getConnectionFromPool(dsr); Statement stat = getStatement(connection, queryTimeout); ResultSet rs = stat.executeQuery(dsr.getQuery())) {
|
||||
try (Connection connection = getConnectionFromPool(dsr); PreparedStatement stat = getPreparedStatement(connection, queryTimeout, dsr.getQuery())) {
|
||||
LogUtil.info("getData sql: " + dsr.getQuery());
|
||||
if (CollectionUtils.isNotEmpty(dsr.getTableFieldWithValues())) {
|
||||
for (int i = 0; i < dsr.getTableFieldWithValues().size(); i++) {
|
||||
stat.setObject(i + 1, dsr.getTableFieldWithValues().get(i).getValue(), dsr.getTableFieldWithValues().get(i).getType());
|
||||
LogUtil.info("getData param[" + (i + 1) + "]: " + dsr.getTableFieldWithValues().get(i).getValue());
|
||||
}
|
||||
}
|
||||
|
||||
ResultSet rs = stat.executeQuery();
|
||||
|
||||
list = getDataResult(rs, dsr);
|
||||
if (dsr.isPageable() && (dsr.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.sqlServer.name()) || dsr.getDatasource().getType().equalsIgnoreCase(DatasourceTypes.db2.name()))) {
|
||||
Integer realSize = dsr.getPage() * dsr.getPageSize() < list.size() ? dsr.getPage() * dsr.getPageSize() : list.size();
|
||||
@ -448,8 +497,9 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
String username = null;
|
||||
String password = null;
|
||||
String defaultDriver = null;
|
||||
String jdbcurl = null;
|
||||
String customDriver = null;
|
||||
String jdbcurl = null;
|
||||
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasourceRequest.getDatasource().getType());
|
||||
Properties props = new Properties();
|
||||
DeDriver deDriver = null;
|
||||
@ -583,13 +633,13 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
jdbcClassLoader = extendedJdbcClassLoader;
|
||||
|
||||
DeDriver driver = deDriverMapper.selectByPrimaryKey("default-" + datasourceRequest.getDatasource().getType());
|
||||
if(driver == null){
|
||||
if (driver == null) {
|
||||
for (DataSourceType value : SpringContextUtil.getApplicationContext().getBeansOfType(DataSourceType.class).values()) {
|
||||
if (value.getType().equalsIgnoreCase(datasourceRequest.getDatasource().getType())) {
|
||||
surpportVersions = value.getSurpportVersions();
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
surpportVersions = driver.getSurpportVersions();
|
||||
}
|
||||
} else {
|
||||
@ -614,9 +664,9 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
|
||||
if (StringUtils.isNotEmpty(surpportVersions) && surpportVersions.split(",").length > 0) {
|
||||
if (!Arrays.asList(surpportVersions.split(",")).contains(String.valueOf(conn.getMetaData().getDatabaseMajorVersion()))) {
|
||||
conn.close();
|
||||
DataEaseException.throwException("当前驱动不支持此版本!");
|
||||
}
|
||||
;
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
@ -626,6 +676,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
public JdbcConfiguration setCredential(DatasourceRequest datasourceRequest, DruidDataSource dataSource) throws Exception {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(datasourceRequest.getDatasource().getType());
|
||||
JdbcConfiguration jdbcConfiguration = new JdbcConfiguration();
|
||||
String defaultDriver = null;
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
case mariadb:
|
||||
@ -636,41 +687,44 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
case StarRocks:
|
||||
MysqlConfiguration mysqlConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MysqlConfiguration.class);
|
||||
dataSource.setUrl(mysqlConfiguration.getJdbc());
|
||||
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
|
||||
dataSource.setValidationQuery("select 1");
|
||||
jdbcConfiguration = mysqlConfiguration;
|
||||
defaultDriver = mysqlConfiguration.getDriver();
|
||||
break;
|
||||
case sqlServer:
|
||||
SqlServerConfiguration sqlServerConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), SqlServerConfiguration.class);
|
||||
dataSource.setDriverClassName(sqlServerConfiguration.getDriver());
|
||||
dataSource.setUrl(sqlServerConfiguration.getJdbc());
|
||||
dataSource.setValidationQuery("select 1");
|
||||
jdbcConfiguration = sqlServerConfiguration;
|
||||
defaultDriver = sqlServerConfiguration.getDriver();
|
||||
break;
|
||||
case oracle:
|
||||
OracleConfiguration oracleConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), OracleConfiguration.class);
|
||||
dataSource.setDriverClassName(oracleConfiguration.getDriver());
|
||||
dataSource.setUrl(oracleConfiguration.getJdbc());
|
||||
dataSource.setValidationQuery("select 1 from dual");
|
||||
jdbcConfiguration = oracleConfiguration;
|
||||
defaultDriver = oracleConfiguration.getDriver();
|
||||
break;
|
||||
case pg:
|
||||
PgConfiguration pgConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), PgConfiguration.class);
|
||||
dataSource.setDriverClassName(pgConfiguration.getDriver());
|
||||
dataSource.setUrl(pgConfiguration.getJdbc());
|
||||
jdbcConfiguration = pgConfiguration;
|
||||
defaultDriver = pgConfiguration.getDriver();
|
||||
break;
|
||||
case ck:
|
||||
CHConfiguration chConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), CHConfiguration.class);
|
||||
dataSource.setDriverClassName(chConfiguration.getDriver());
|
||||
dataSource.setUrl(chConfiguration.getJdbc());
|
||||
jdbcConfiguration = chConfiguration;
|
||||
defaultDriver = chConfiguration.getDriver();
|
||||
break;
|
||||
case mongo:
|
||||
MongodbConfiguration mongodbConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), MongodbConfiguration.class);
|
||||
dataSource.setDriverClassName(mongodbConfiguration.getDriver());
|
||||
dataSource.setUrl(mongodbConfiguration.getJdbc(datasourceRequest.getDatasource().getId()));
|
||||
jdbcConfiguration = mongodbConfiguration;
|
||||
defaultDriver = mongodbConfiguration.getDriver();
|
||||
break;
|
||||
case redshift:
|
||||
RedshiftConfiguration redshiftConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), RedshiftConfiguration.class);
|
||||
@ -678,6 +732,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
dataSource.setDriverClassName(redshiftConfiguration.getDriver());
|
||||
dataSource.setUrl(redshiftConfiguration.getJdbc());
|
||||
jdbcConfiguration = redshiftConfiguration;
|
||||
defaultDriver = redshiftConfiguration.getDriver();
|
||||
break;
|
||||
case hive:
|
||||
HiveConfiguration hiveConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), HiveConfiguration.class);
|
||||
@ -685,6 +740,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
dataSource.setDriverClassName(hiveConfiguration.getDriver());
|
||||
dataSource.setUrl(hiveConfiguration.getJdbc());
|
||||
jdbcConfiguration = hiveConfiguration;
|
||||
defaultDriver = hiveConfiguration.getDriver();
|
||||
break;
|
||||
case impala:
|
||||
ImpalaConfiguration impalaConfiguration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), ImpalaConfiguration.class);
|
||||
@ -692,6 +748,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
dataSource.setDriverClassName(impalaConfiguration.getDriver());
|
||||
dataSource.setUrl(impalaConfiguration.getJdbc());
|
||||
jdbcConfiguration = impalaConfiguration;
|
||||
defaultDriver = impalaConfiguration.getDriver();
|
||||
break;
|
||||
case db2:
|
||||
Db2Configuration db2Configuration = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), Db2Configuration.class);
|
||||
@ -699,6 +756,7 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
dataSource.setDriverClassName(db2Configuration.getDriver());
|
||||
dataSource.setUrl(db2Configuration.getJdbc());
|
||||
jdbcConfiguration = db2Configuration;
|
||||
defaultDriver = db2Configuration.getDriver();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -707,14 +765,15 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
|
||||
ExtendedJdbcClassLoader classLoader;
|
||||
if (isDefaultClassLoader(jdbcConfiguration.getCustomDriver())) {
|
||||
dataSource.setDriverClassName(defaultDriver);
|
||||
classLoader = extendedJdbcClassLoader;
|
||||
} else {
|
||||
DeDriver deDriver = deDriverMapper.selectByPrimaryKey(jdbcConfiguration.getCustomDriver());
|
||||
classLoader = getCustomJdbcClassLoader(deDriver);
|
||||
dataSource.setDriverClassName(deDriver.getDriverClass());
|
||||
}
|
||||
dataSource.setDriverClassLoader(classLoader);
|
||||
dataSource.setPassword(jdbcConfiguration.getPassword());
|
||||
|
||||
return jdbcConfiguration;
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +99,11 @@ public class DorisDDLProvider extends DDLProviderImpl {
|
||||
}
|
||||
switch (datasetTableField.getDeExtractType()) {
|
||||
case 0:
|
||||
if (size <= 65533 || (keys != null && keys.contains(datasetTableField.getDataeaseName()))) {
|
||||
if (datasetTableField.getDataeaseName().equalsIgnoreCase("dataease_uuid")) {
|
||||
Column_Fields.append("VARCHAR(length)".replace("length", String.valueOf(size))).append(",`");
|
||||
break;
|
||||
}
|
||||
if (keys != null && keys.contains(datasetTableField.getDataeaseName())) {
|
||||
Column_Fields.append("VARCHAR(length)".replace("length", String.valueOf(size))).append(",`");
|
||||
} else {
|
||||
Column_Fields.append("STRING".replace("length", String.valueOf(size))).append(",`");
|
||||
|
||||
@ -1437,7 +1437,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == 1) {
|
||||
|
||||
@ -1379,7 +1379,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == 1) {
|
||||
|
||||
@ -0,0 +1,349 @@
|
||||
package io.dataease.provider.ext;
|
||||
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.plugins.common.dto.datafill.ExtIndexField;
|
||||
import io.dataease.plugins.common.dto.datafill.ExtTableField;
|
||||
import io.dataease.plugins.common.dto.datasource.TableField;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.datasource.provider.DefaultExtDDLProvider;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service("extMysqlDDLProvider")
|
||||
public class MysqlExtDDLProvider extends DefaultExtDDLProvider {
|
||||
|
||||
private static final String creatTableSql =
|
||||
"CREATE TABLE `TABLE_NAME`" +
|
||||
"Column_Fields" + " ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;";
|
||||
|
||||
private static final String creatTableIndexSql =
|
||||
"create index `INDEX_NAME` on `TABLE_NAME` (Column_Fields);";
|
||||
|
||||
private static final String dropTableSql = "DROP TABLE IF EXISTS `TABLE_NAME`";
|
||||
|
||||
@Override
|
||||
public String getLowerCaseTaleNames() {
|
||||
return "SHOW VARIABLES LIKE 'lower_case_table_names'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String dropTableSql(String table) {
|
||||
return dropTableSql.replace("TABLE_NAME", table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createTableSql(String table, List<ExtTableField> formFields) {
|
||||
//check inject
|
||||
if (checkSqlInjection(table)) {
|
||||
throw new RuntimeException("包含SQL注入的参数,请检查参数!");
|
||||
}
|
||||
|
||||
List<ExtTableField.TableField> fields = convertTableFields(true, formFields);
|
||||
String fieldSql = convertTableFieldsString(table, fields);
|
||||
return creatTableSql.replace("TABLE_NAME", table).replace("Column_Fields", fieldSql);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String searchSql(String table, List<TableField> formFields, String whereSql, long limit, long offset) {
|
||||
String baseSql = "SELECT $Column_Fields$ FROM `$TABLE_NAME$` $WHERE_SQL$ LIMIT $OFFSET_COUNT$, $LIMIT_COUNT$ ;";
|
||||
baseSql = baseSql.replace("$TABLE_NAME$", table)
|
||||
.replace("$OFFSET_COUNT$", Long.toString(offset))
|
||||
.replace("$LIMIT_COUNT$", Long.toString(limit));
|
||||
if (StringUtils.isBlank(whereSql)) {
|
||||
baseSql = baseSql.replace("$WHERE_SQL$", "");
|
||||
} else {
|
||||
baseSql = baseSql.replace("$WHERE_SQL$", whereSql);
|
||||
}
|
||||
baseSql = baseSql.replace("$Column_Fields$", convertSearchFields(formFields));
|
||||
return baseSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String whereSql(String tableName, List<TableField> searchFields) {
|
||||
StringBuilder builder = new StringBuilder("WHERE 1 = 1 ");
|
||||
for (TableField searchField : searchFields) {
|
||||
//目前只考虑等于
|
||||
builder.append("AND $Column_Field$ = ? ".replace("$Column_Field$", searchField.getFieldName()));
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String countSql(String table, List<TableField> formFields, String whereSql) {
|
||||
String baseSql = "SELECT COUNT(1) FROM `$TABLE_NAME$` $WHERE_SQL$ ;";
|
||||
baseSql = baseSql.replace("$TABLE_NAME$", table);
|
||||
if (StringUtils.isBlank(whereSql)) {
|
||||
baseSql = baseSql.replace("$WHERE_SQL$", "");
|
||||
} else {
|
||||
baseSql = baseSql.replace("$WHERE_SQL$", whereSql);
|
||||
}
|
||||
return baseSql;
|
||||
}
|
||||
|
||||
private String convertSearchFields(List<TableField> formFields) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < formFields.size(); i++) {
|
||||
TableField f = formFields.get(i);
|
||||
if (StringUtils.equalsAnyIgnoreCase(f.getFieldType(), "datetime")) {
|
||||
//特殊处理,全部使用统一格式输出
|
||||
builder.append("DATE_FORMAT(`").append(f.getFieldName()).append("`,'%Y-%m-%d %H:%i:%S')");
|
||||
} else {
|
||||
builder.append("`").append(f.getFieldName()).append("`");
|
||||
}
|
||||
if (i < formFields.size() - 1) {
|
||||
builder.append(", ");
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private List<ExtTableField.TableField> convertTableFields(boolean create, List<ExtTableField> formFields) {
|
||||
List<ExtTableField.TableField> list = new ArrayList<>();
|
||||
if (create) {
|
||||
list.add(
|
||||
ExtTableField.TableField.builder()
|
||||
.columnName("id")
|
||||
.comment("ID")
|
||||
.primaryKey(true)
|
||||
.type(ExtTableField.BaseType.nvarchar)
|
||||
.size(128)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
for (ExtTableField formField : formFields) {
|
||||
ExtTableField.TableField.TableFieldBuilder fieldBuilder = ExtTableField.TableField.builder()
|
||||
.columnName(formField.getSettings().getMapping().getColumnName())
|
||||
.type(formField.getSettings().getMapping().getType())
|
||||
.comment(formField.getSettings().getName())
|
||||
.required(formField.getSettings().isRequired());
|
||||
if (StringUtils.equalsIgnoreCase(formField.getType(), "dateRange")) {
|
||||
ExtTableField.TableField f1 = fieldBuilder
|
||||
.columnName(formField.getSettings().getMapping().getColumnName1())
|
||||
.comment(formField.getSettings().getName() + " start")
|
||||
.build();
|
||||
list.add(f1);
|
||||
|
||||
ExtTableField.TableField f2 = BeanUtils.copyBean(new ExtTableField.TableField(), f1);
|
||||
f2.setColumnName(formField.getSettings().getMapping().getColumnName2());
|
||||
f2.setComment(formField.getSettings().getName() + " end");
|
||||
list.add(f2);
|
||||
} else {
|
||||
list.add(fieldBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deleteDataByIdSql(String table, DatasourceRequest.TableFieldWithValue pk) {
|
||||
String deleteSql = "DELETE FROM `$TABLE_NAME$` WHERE `$PRIMARY_KEY$` = ?;";
|
||||
return deleteSql.replace("$TABLE_NAME$", table)
|
||||
.replace("$PRIMARY_KEY$", pk.getFiledName());
|
||||
}
|
||||
|
||||
private String convertFields(List<DatasourceRequest.TableFieldWithValue> fields) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
DatasourceRequest.TableFieldWithValue f = fields.get(i);
|
||||
builder.append("`").append(f.getFiledName()).append("`");
|
||||
if (i < fields.size() - 1) {
|
||||
builder.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String convertValueFields(List<DatasourceRequest.TableFieldWithValue> fields) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
DatasourceRequest.TableFieldWithValue f = fields.get(i);
|
||||
builder.append("?");
|
||||
if (i < fields.size() - 1) {
|
||||
builder.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String insertDataSql(String tableName, List<DatasourceRequest.TableFieldWithValue> fields) {
|
||||
String sql = "INSERT INTO `$TABLE_NAME$`($Column_Fields$) VALUES ($Value_Fields$);";
|
||||
return sql.replace("$TABLE_NAME$", tableName)
|
||||
.replace("$Column_Fields$", convertFields(fields))
|
||||
.replace("$Value_Fields$", convertValueFields(fields));
|
||||
}
|
||||
|
||||
private String convertUpdateFields(List<DatasourceRequest.TableFieldWithValue> fields) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
DatasourceRequest.TableFieldWithValue f = fields.get(i);
|
||||
builder.append("`").append(f.getFiledName()).append("` = ?");
|
||||
if (i < fields.size() - 1) {
|
||||
builder.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updateDataByIdSql(String tableName, List<DatasourceRequest.TableFieldWithValue> fields, DatasourceRequest.TableFieldWithValue pk) {
|
||||
String sql = "UPDATE `$TABLE_NAME$` SET $Column_Fields$ WHERE `$PRIMARY_KEY$` = ?;";
|
||||
return sql.replace("$TABLE_NAME$", tableName)
|
||||
.replace("$Column_Fields$", convertUpdateFields(fields))
|
||||
.replace("$PRIMARY_KEY$", pk.getFiledName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkUniqueValueSql(String tableName, DatasourceRequest.TableFieldWithValue field, DatasourceRequest.TableFieldWithValue pk) {
|
||||
String sql = "SELECT COUNT(1) FROM `$TABLE_NAME$` WHERE `$Column_Field$` = ? $PRIMARY_KEY_CONDITION$;";
|
||||
|
||||
StringBuilder pkCondition = new StringBuilder();
|
||||
if (pk != null) {
|
||||
pkCondition.append("AND `").append(pk.getFiledName()).append("` != ?");
|
||||
}
|
||||
|
||||
return sql.replace("$TABLE_NAME$", tableName)
|
||||
.replace("$Column_Field$", field.getFiledName())
|
||||
.replace("$PRIMARY_KEY_CONDITION$", pkCondition.toString());
|
||||
}
|
||||
|
||||
private String convertTableFieldsString(String table, List<ExtTableField.TableField> fields) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
str.append("(\n");
|
||||
|
||||
ExtTableField.TableField primaryKeyField = null;
|
||||
for (ExtTableField.TableField field : fields) {
|
||||
if (field.isPrimaryKey()) {
|
||||
primaryKeyField = field;
|
||||
}
|
||||
|
||||
//check inject
|
||||
if (checkSqlInjection(field.getColumnName())) {
|
||||
throw new RuntimeException("包含SQL注入的参数,请检查参数!");
|
||||
}
|
||||
|
||||
//column name
|
||||
str.append("`").append(field.getColumnName()).append("` ");
|
||||
//type
|
||||
switch (field.getType()) {
|
||||
case nvarchar:
|
||||
str.append("NVARCHAR(");
|
||||
if (field.getSize() != null && field.getSize() > 0) {
|
||||
str.append(field.getSize());
|
||||
} else {
|
||||
str.append(256);
|
||||
}
|
||||
str.append(") ");
|
||||
break;
|
||||
case number:
|
||||
str.append("BIGINT(");
|
||||
if (field.getSize() != null && field.getSize() > 0) {
|
||||
str.append(field.getSize());
|
||||
} else {
|
||||
str.append(20);
|
||||
}
|
||||
str.append(") ");
|
||||
break;
|
||||
case decimal:
|
||||
str.append("DECIMAL(");
|
||||
if (field.getSize() != null && field.getSize() > 0) {
|
||||
str.append(field.getSize());
|
||||
} else {
|
||||
str.append(20);
|
||||
}
|
||||
str.append(",");
|
||||
if (field.getAccuracy() != null && field.getAccuracy() >= 0) {
|
||||
str.append(field.getAccuracy());
|
||||
} else {
|
||||
str.append(8);
|
||||
}
|
||||
str.append(") ");
|
||||
break;
|
||||
case datetime:
|
||||
str.append("DATETIME ");
|
||||
break;
|
||||
default:
|
||||
str.append("LONGTEXT ");
|
||||
break;
|
||||
}
|
||||
|
||||
//必填
|
||||
if (field.isRequired()) {
|
||||
str.append("NOT NULL ");
|
||||
}
|
||||
|
||||
//comment
|
||||
str.append("COMMENT '").append(field.getComment()).append("' ");
|
||||
|
||||
//换行
|
||||
str.append(",\n");
|
||||
|
||||
}
|
||||
|
||||
if (primaryKeyField != null) {
|
||||
str.append("constraint `")
|
||||
.append(table)
|
||||
.append("_pk` ")
|
||||
.append("PRIMARY KEY (")
|
||||
.append("`")
|
||||
.append(primaryKeyField.getColumnName())
|
||||
.append("`)");
|
||||
}
|
||||
|
||||
str.append("\n)\n");
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> createTableIndexSql(String table, List<ExtIndexField> indexFields) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (ExtIndexField indexField : indexFields) {
|
||||
String c = convertTableIndexSql(table, indexField);
|
||||
if (StringUtils.isNotEmpty(c)) {
|
||||
list.add(c);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private String convertTableIndexSql(String table, ExtIndexField indexField) {
|
||||
StringBuilder column = new StringBuilder();
|
||||
if (CollectionUtils.isEmpty(indexField.getColumns())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//check inject
|
||||
if (checkSqlInjection(table) || checkSqlInjection(indexField.getName())) {
|
||||
throw new RuntimeException("包含SQL注入的参数,请检查参数!");
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (ExtIndexField.ColumnSetting indexFieldColumn : indexField.getColumns()) {
|
||||
count++;
|
||||
column.append("`").append(indexFieldColumn.getColumn()).append("` ");
|
||||
if (StringUtils.equalsIgnoreCase(indexFieldColumn.getOrder(), "asc")) {
|
||||
column.append("asc");
|
||||
} else if (StringUtils.equalsIgnoreCase(indexFieldColumn.getOrder(), "desc")) {
|
||||
column.append("desc");
|
||||
}
|
||||
if (count < indexField.getColumns().size()) {
|
||||
column.append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
return creatTableIndexSql.replace("TABLE_NAME", table).replace("INDEX_NAME", indexField.getName()).replace("Column_Fields", column.toString());
|
||||
}
|
||||
}
|
||||
@ -1427,7 +1427,17 @@ public class CKQueryProvider extends QueryProvider {
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(request.getDateStyle(), request.getDatePattern());
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, originName), format);
|
||||
if (StringUtils.equalsIgnoreCase(request.getDateStyle(), "y_Q")) {
|
||||
whereName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originName + ")"),
|
||||
String.format(CKConstants.toQuarter, "toDate(" + originName + ")"));
|
||||
} else if (StringUtils.equalsIgnoreCase(request.getDateStyle(), "y_W")) {
|
||||
whereName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originName + ")"),
|
||||
String.format(CKConstants.toWeek, "toDate(" + originName + ")"));
|
||||
} else {
|
||||
whereName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, originName), format);
|
||||
}
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(CKConstants.toFloat64, originName);
|
||||
@ -1470,7 +1480,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == DeTypeConstants.DE_TIME) {
|
||||
@ -1540,8 +1550,12 @@ public class CKQueryProvider extends QueryProvider {
|
||||
switch (dateStyle) {
|
||||
case "y":
|
||||
return "%Y";
|
||||
case "y_Q":
|
||||
return "CONCAT(toString(%s),'" + split + "','Q',toString(%s))";
|
||||
case "y_M":
|
||||
return "%Y" + split + "%m";
|
||||
case "y_W":
|
||||
return "CONCAT(toString(%s),'" + split + "','W',toString(%s))";
|
||||
case "y_M_d":
|
||||
return "%Y" + split + "%m" + split + "%d";
|
||||
case "H_m_s":
|
||||
@ -1568,7 +1582,17 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
fieldName = String.format(CKConstants.formatDateTime, originField, format);
|
||||
if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_Q")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originField + ")"),
|
||||
String.format(CKConstants.toQuarter, "toDate(" + originField + ")"));
|
||||
} else if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_W")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, "toDate(" + originField + ")"),
|
||||
String.format(CKConstants.toWeek, "toDate(" + originField + ")"));
|
||||
} else {
|
||||
fieldName = String.format(CKConstants.formatDateTime, originField, format);
|
||||
}
|
||||
} else {
|
||||
fieldName = originField;
|
||||
}
|
||||
@ -1576,9 +1600,31 @@ public class CKQueryProvider extends QueryProvider {
|
||||
if (x.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
String format = transDateFormat(x.getDateStyle(), x.getDatePattern());
|
||||
if (x.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
||||
fieldName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, originField), format);
|
||||
String s = String.format(CKConstants.toDateTime, originField);
|
||||
if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_Q")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, s),
|
||||
String.format(CKConstants.toQuarter, s));
|
||||
} else if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_W")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, s),
|
||||
String.format(CKConstants.toWeek, s));
|
||||
} else {
|
||||
fieldName = String.format(CKConstants.formatDateTime, s, format);
|
||||
}
|
||||
} else {
|
||||
fieldName = String.format(CKConstants.formatDateTime, String.format(CKConstants.toDateTime, String.format(CKConstants.toFloat64, originField)), format);
|
||||
String s = String.format(CKConstants.toDateTime, String.format(CKConstants.toFloat64, originField));
|
||||
if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_Q")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, s),
|
||||
String.format(CKConstants.toQuarter, s));
|
||||
} else if (StringUtils.equalsIgnoreCase(x.getDateStyle(), "y_W")) {
|
||||
fieldName = String.format(format,
|
||||
String.format(CKConstants.toYear, s),
|
||||
String.format(CKConstants.toWeek, s));
|
||||
} else {
|
||||
fieldName = String.format(CKConstants.formatDateTime, s, format);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (x.getDeType() == DeTypeConstants.DE_INT) {
|
||||
|
||||
@ -1476,7 +1476,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == DeTypeConstants.DE_TIME) {
|
||||
|
||||
@ -1403,7 +1403,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "UCASE(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == 1) {
|
||||
|
||||
@ -1360,7 +1360,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == DeTypeConstants.DE_TIME) {
|
||||
|
||||
@ -1380,7 +1380,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == DeTypeConstants.DE_TIME) {
|
||||
|
||||
@ -1235,7 +1235,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == DeTypeConstants.DE_TIME) {
|
||||
|
||||
@ -1444,7 +1444,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == 1) {
|
||||
|
||||
@ -1550,7 +1550,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == 1) {
|
||||
@ -1605,8 +1605,12 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
switch (dateStyle) {
|
||||
case "y":
|
||||
return "YYYY";
|
||||
case "y_Q":
|
||||
return "YYYY" + split + "\"Q\"Q";
|
||||
case "y_M":
|
||||
return "YYYY" + split + "MM";
|
||||
case "y_W":
|
||||
return "YYYY" + split + "\"W\"IW";
|
||||
case "y_M_d":
|
||||
return "YYYY" + split + "MM" + split + "DD";
|
||||
case "H_m_s":
|
||||
|
||||
@ -1009,7 +1009,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
String tableWithSchema = String.format(SqlServerSQLConstants.KEYWORD_TABLE, schema) + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, table);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_PAGE_SIZE OFFSET DE_OFFSET ", StringUtils.join(array, ","), tableWithSchema);
|
||||
} else {
|
||||
return MessageFormat.format("SELECT {0} FROM {1} LIMIT DE_PAGE_SIZE OFFSET DE_OFFSET ", StringUtils.join(array, ","), table);
|
||||
return MessageFormat.format("SELECT {0} FROM {1} ", StringUtils.join(array, ","), table);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1400,7 +1400,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == 1) {
|
||||
|
||||
@ -1386,7 +1386,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == 1) {
|
||||
|
||||
@ -1532,7 +1532,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||
String keyword = value.get(0).toUpperCase();
|
||||
whereValue = "'%" + keyword + "%'";
|
||||
whereValue = formatLikeValue(keyword);
|
||||
whereName = "upper(" + whereName + ")";
|
||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
||||
if (request.getDatasetTableField().getDeType() == DeTypeConstants.DE_TIME) {
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package io.dataease.service.ai;
|
||||
|
||||
import io.dataease.commons.utils.UrlTestUtils;
|
||||
import io.dataease.service.system.SystemParameterService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author : WangJiaHao
|
||||
* @date : 2024/3/27 09:47
|
||||
*/
|
||||
@Service
|
||||
public class AiBaseService {
|
||||
@Resource
|
||||
private SystemParameterService parameterService;
|
||||
|
||||
public Map<String, String> findTargetUrl() {
|
||||
String baseUrl = parameterService.getValue("ai.baseUrl");
|
||||
Map<String,String> result = new HashMap<>();
|
||||
|
||||
if(StringUtils.isNotEmpty(baseUrl) && UrlTestUtils.isURLAvailable(baseUrl)){
|
||||
result.put("ai.baseUrl",baseUrl);
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -10,5 +10,6 @@ public class ChartConstants {
|
||||
public static final String YEAR_YOY = "year_yoy";
|
||||
public static final String DAY_MOM = "day_mom";
|
||||
public static final String MONTH_YOY = "month_yoy";
|
||||
public static final String[] M_Y = {YEAR_MOM, MONTH_MOM, YEAR_YOY, DAY_MOM, MONTH_YOY};
|
||||
public static final String WEEK_MOM = "week_mom";
|
||||
public static final String[] M_Y = {YEAR_MOM, MONTH_MOM, YEAR_YOY, DAY_MOM, MONTH_YOY, WEEK_MOM};
|
||||
}
|
||||
|
||||
@ -73,6 +73,7 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@ -730,7 +731,11 @@ public class ChartViewService {
|
||||
}
|
||||
if (chartExtRequest.getPageSize() == null) {
|
||||
String pageSize = (String) mapSize.get("tablePageSize");
|
||||
chartExtRequest.setPageSize(Math.min(Long.parseLong(pageSize), view.getResultCount().longValue()));
|
||||
if (StringUtils.equalsIgnoreCase(view.getResultMode(), "custom")) {
|
||||
chartExtRequest.setPageSize(Math.min(Long.parseLong(pageSize), view.getResultCount().longValue()));
|
||||
} else {
|
||||
chartExtRequest.setPageSize(Long.parseLong(pageSize));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.equalsIgnoreCase(view.getResultMode(), "custom")) {
|
||||
@ -1034,6 +1039,18 @@ public class ChartViewService {
|
||||
|| StringUtils.containsIgnoreCase(view.getType(), "table-pivot")) {
|
||||
// 动态阈值
|
||||
dynamicAssistFields = getDynamicThresholdFields(view);
|
||||
// 明细表非数据列字段要加进来
|
||||
if (StringUtils.containsIgnoreCase(view.getType(), "table-info")) {
|
||||
Set<String> fieldIds = xAxis.stream().map(ChartViewFieldDTO::getId).collect(Collectors.toSet());
|
||||
List<ChartViewFieldDTO> finalXAxis = xAxis;
|
||||
dynamicAssistFields.forEach(i -> {
|
||||
if (!fieldIds.contains(i.getFieldId())) {
|
||||
ChartViewFieldDTO fieldDTO = new ChartViewFieldDTO();
|
||||
BeanUtils.copyBean(fieldDTO, i.getCurField());
|
||||
finalXAxis.add(fieldDTO);
|
||||
}
|
||||
});
|
||||
}
|
||||
assistFields = getAssistFields(dynamicAssistFields, yAxis, xAxis);
|
||||
}
|
||||
|
||||
@ -1059,7 +1076,9 @@ public class ChartViewService {
|
||||
xAxis.addAll(xAxisExtList);
|
||||
}
|
||||
fieldMap.put("xAxis", xAxis);
|
||||
fieldMap.put("xAxisExt", xAxisExt);
|
||||
if (!StringUtils.equals(view.getType(), "race-bar")) {
|
||||
fieldMap.put("xAxisExt", xAxisExt);
|
||||
}
|
||||
fieldMap.put("extStack", extStack);
|
||||
fieldMap.put("extBubble", extBubble);
|
||||
fieldMap.put("yAxis", yAxis);
|
||||
@ -1258,11 +1277,10 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLScatter(tableName, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extBubble, extStack, ds, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
querySql = qp.getSQLWithPage(true, tableName, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view, pageInfo);
|
||||
datasourceRequest.setQuery(querySql);
|
||||
totalPageSql = qp.getResultCount(true, tableName, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view);
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
|
||||
datasourceRequest.setQuery(qp.getSQLRangeBar(tableName, xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, ds, view));
|
||||
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQL(tableName, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
if (containDetailField(view) && CollectionUtils.isNotEmpty(viewFields)) {
|
||||
@ -1285,6 +1303,9 @@ public class ChartViewService {
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(assistFields)) {
|
||||
if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(querySql);
|
||||
}
|
||||
datasourceAssistRequest.setQuery(assistSQL(datasourceRequest.getQuery(), assistFields, ds));
|
||||
logger.info(datasourceAssistRequest.getQuery());
|
||||
assistData = datasourceProvider.getData(datasourceAssistRequest);
|
||||
@ -1328,9 +1349,9 @@ public class ChartViewService {
|
||||
data = resultCustomSort(xAxis, data);
|
||||
}
|
||||
// 如果是表格导出查询 则在此处直接就可以返回
|
||||
if(chartExtRequest.getExcelExportFlag()){
|
||||
if (chartExtRequest.getExcelExportFlag()) {
|
||||
Map<String, Object> sourceInfo = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList);
|
||||
sourceInfo.put("sourceData",data);
|
||||
sourceInfo.put("sourceData", data);
|
||||
view.setData(sourceInfo);
|
||||
return view;
|
||||
}
|
||||
@ -1398,7 +1419,7 @@ public class ChartViewService {
|
||||
String cValue = item[dataIndex];
|
||||
|
||||
// 获取计算后的时间,并且与所有维度拼接
|
||||
String lastTime = calcLastTime(cTime, compareCalc.getType(), timeField.getDateStyle(), timeField.getDatePattern());
|
||||
String lastTime = calcLastTime(cTime, compareCalc.getType(), timeField.getDateStyle(), timeField.getDatePattern(), ds);
|
||||
String[] dimension = Arrays.copyOfRange(item, 0, checkedField.size());
|
||||
dimension[timeIndex] = lastTime;
|
||||
|
||||
@ -1447,6 +1468,86 @@ public class ChartViewService {
|
||||
.divide(sum, 8, RoundingMode.HALF_UP)
|
||||
.toString();
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(compareCalc.getType(), "accumulate")) {
|
||||
// 累加
|
||||
if (data.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
if (StringUtils.containsAny(view.getType(), "group", "stack")) {
|
||||
if (xAxisBase.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(view.getType(), "stack") && extStack.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(view.getType(), "group") && xAxisExt.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
final Map<String, Integer> mainIndexMap = new HashMap<>();
|
||||
final List<List<String[]>> mainMatrix = new ArrayList<>();
|
||||
List<ChartViewFieldDTO> finalXAxisBase = xAxisBase;
|
||||
data.forEach(item -> {
|
||||
String[] mainAxisArr = Arrays.copyOfRange(item, 0, finalXAxisBase.size());
|
||||
String mainAxis = StringUtils.join(mainAxisArr, '-');
|
||||
Integer index = mainIndexMap.get(mainAxis);
|
||||
if (index == null) {
|
||||
mainIndexMap.put(mainAxis, mainMatrix.size());
|
||||
List<String[]> tmp = new ArrayList<>();
|
||||
tmp.add(item);
|
||||
mainMatrix.add(tmp);
|
||||
} else {
|
||||
List<String[]> tmp = mainMatrix.get(index);
|
||||
tmp.add(item);
|
||||
}
|
||||
});
|
||||
int finalDataIndex = dataIndex;
|
||||
int subEndIndex = finalXAxisBase.size();
|
||||
if (StringUtils.containsIgnoreCase(view.getType(), "group")) {
|
||||
subEndIndex += xAxisExt.size();
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
|
||||
subEndIndex += extStack.size();
|
||||
}
|
||||
int finalSubEndIndex = subEndIndex;
|
||||
//滑动累加
|
||||
for (int k = 1; k < mainMatrix.size(); k++) {
|
||||
List<String[]> preDataItems = mainMatrix.get(k - 1);
|
||||
List<String[]> curDataItems = mainMatrix.get(k);
|
||||
Map<String, BigDecimal> preDataMap = new HashMap<>();
|
||||
preDataItems.forEach(preDataItem -> {
|
||||
String[] groupStackAxisArr = Arrays.copyOfRange(preDataItem, finalXAxisBase.size(), finalSubEndIndex);
|
||||
String groupStackAxis = StringUtils.join(groupStackAxisArr, '-');
|
||||
String preVal = preDataItem[finalDataIndex];
|
||||
if (StringUtils.isBlank(preVal)) {
|
||||
preVal = "0";
|
||||
}
|
||||
preDataMap.put(groupStackAxis, new BigDecimal(preVal));
|
||||
});
|
||||
curDataItems.forEach(curDataItem -> {
|
||||
String[] groupStackAxisArr = Arrays.copyOfRange(curDataItem, finalXAxisBase.size(), finalSubEndIndex);
|
||||
String groupStackAxis = StringUtils.join(groupStackAxisArr, '-');
|
||||
BigDecimal preValue = preDataMap.get(groupStackAxis);
|
||||
if (preValue != null) {
|
||||
curDataItem[finalDataIndex] = new BigDecimal(curDataItem[finalDataIndex])
|
||||
.add(preValue)
|
||||
.toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
final int index = dataIndex;
|
||||
final AtomicReference<BigDecimal> accumValue = new AtomicReference<>(new BigDecimal(0));
|
||||
data.forEach(item -> {
|
||||
String val = item[index];
|
||||
BigDecimal curAccumValue = accumValue.get();
|
||||
if (!StringUtils.isBlank(val)) {
|
||||
BigDecimal curVal = new BigDecimal(val);
|
||||
curAccumValue = curAccumValue.add(curVal);
|
||||
accumValue.set(curAccumValue);
|
||||
}
|
||||
item[index] = curAccumValue.toString();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1684,11 +1785,14 @@ public class ChartViewService {
|
||||
return StringUtils.equalsIgnoreCase(calcType, "day_mom")
|
||||
|| StringUtils.equalsIgnoreCase(calcType, "month_yoy")
|
||||
|| StringUtils.equalsIgnoreCase(calcType, "year_yoy");
|
||||
case "y_W":
|
||||
return StringUtils.equalsIgnoreCase(calcType, "week_mom")
|
||||
|| StringUtils.equalsIgnoreCase(calcType, "year_yoy");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String calcLastTime(String cTime, String type, String dateStyle, String datePattern) {
|
||||
private String calcLastTime(String cTime, String type, String dateStyle, String datePattern, Datasource ds) {
|
||||
try {
|
||||
String lastTime = null;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
@ -1723,6 +1827,12 @@ public class ChartViewService {
|
||||
} else {
|
||||
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(dateStyle, "y_W")) {
|
||||
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
|
||||
simpleDateFormat = new SimpleDateFormat("yyyy/'W'w");
|
||||
} else {
|
||||
simpleDateFormat = new SimpleDateFormat("yyyy-'W'w");
|
||||
}
|
||||
}
|
||||
Date date = simpleDateFormat.parse(cTime);
|
||||
calendar.setTime(date);
|
||||
@ -1758,6 +1868,26 @@ public class ChartViewService {
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.MONTH, -1);
|
||||
lastTime = simpleDateFormat.format(calendar.getTime());
|
||||
} else if (StringUtils.equalsIgnoreCase(type, ChartConstants.WEEK_MOM)) {
|
||||
SimpleDateFormat simpleDateFormat = null;
|
||||
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
|
||||
if (StringUtils.equalsIgnoreCase(ds.getType(), "ck")) {
|
||||
simpleDateFormat = new SimpleDateFormat("yyyy/'W'w");
|
||||
} else {
|
||||
simpleDateFormat = new SimpleDateFormat("yyyy/'W'ww");
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.equalsIgnoreCase(ds.getType(), "ck")) {
|
||||
simpleDateFormat = new SimpleDateFormat("yyyy-'W'w");
|
||||
} else {
|
||||
simpleDateFormat = new SimpleDateFormat("yyyy-'W'ww");
|
||||
}
|
||||
}
|
||||
Date date = simpleDateFormat.parse(cTime);
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 6);// 加6天用一周最后一天计算周,可避免跨年的问题
|
||||
calendar.add(Calendar.WEEK_OF_YEAR, -1);
|
||||
lastTime = simpleDateFormat.format(calendar.getTime());
|
||||
}
|
||||
return lastTime;
|
||||
} catch (Exception e) {
|
||||
@ -2302,7 +2432,7 @@ public class ChartViewService {
|
||||
List<ChartSeniorThresholdDTO> conditions = gson.fromJson(itemConditions.toJSONString(), new TypeToken<List<ChartSeniorThresholdDTO>>() {
|
||||
}.getType());
|
||||
for (ChartSeniorThresholdDTO condition : conditions) {
|
||||
if (StringUtils.equalsIgnoreCase(condition.getField(), "0")) {
|
||||
if (StringUtils.equalsAnyIgnoreCase(condition.getField(), "0", "2")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,431 @@
|
||||
package io.dataease.service.datafill;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.controller.request.datafill.DataFillFormTableDataRequest;
|
||||
import io.dataease.controller.response.datafill.DataFillFormTableDataResponse;
|
||||
import io.dataease.dto.datafill.DataFillCommitLogDTO;
|
||||
import io.dataease.ext.ExtDataFillFormMapper;
|
||||
import io.dataease.plugins.common.base.domain.DataFillFormWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.base.mapper.DataFillFormMapper;
|
||||
import io.dataease.plugins.common.constants.DatasourceTypes;
|
||||
import io.dataease.plugins.common.dto.datafill.ExtTableField;
|
||||
import io.dataease.plugins.common.dto.datasource.TableField;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.datasource.provider.ExtDDLProvider;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
import io.dataease.plugins.datasource.provider.ProviderFactory;
|
||||
import io.dataease.provider.datasource.JdbcProvider;
|
||||
import io.dataease.service.datasource.DatasourceService;
|
||||
import io.dataease.service.sys.SysAuthService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.pentaho.di.core.util.UUIDUtil;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DataFillDataService {
|
||||
|
||||
@Resource
|
||||
private Environment env;
|
||||
@Resource
|
||||
private DataFillFormMapper dataFillFormMapper;
|
||||
@Resource
|
||||
private ExtDataFillFormMapper extDataFillFormMapper;
|
||||
@Resource
|
||||
private DatasourceService datasource;
|
||||
@Resource
|
||||
private SysAuthService sysAuthService;
|
||||
|
||||
@Resource
|
||||
private DataFillLogService dataFillLogService;
|
||||
|
||||
|
||||
private final static Gson gson = new Gson();
|
||||
|
||||
public static void setLowerCaseRequest(Datasource ds, Provider datasourceProvider, ExtDDLProvider extDDLProvider, DatasourceRequest datasourceRequest) throws Exception {
|
||||
DatasourceTypes datasourceType = DatasourceTypes.valueOf(ds.getType());
|
||||
switch (datasourceType) {
|
||||
case mysql:
|
||||
case mariadb:
|
||||
String checkLowerCaseSql = extDDLProvider.getLowerCaseTaleNames();
|
||||
datasourceRequest.setQuery(checkLowerCaseSql);
|
||||
List<String[]> checkLowerCaseData = datasourceProvider.getData(datasourceRequest);
|
||||
long lowCase = NumberUtils.toLong(checkLowerCaseData.get(0)[1]);
|
||||
datasourceRequest.setLowerCaseTaleNames(lowCase > 0);
|
||||
break;
|
||||
default:
|
||||
datasourceRequest.setLowerCaseTaleNames(true);
|
||||
}
|
||||
}
|
||||
|
||||
public DataFillFormTableDataResponse listData(DataFillFormTableDataRequest searchRequest) throws Exception {
|
||||
|
||||
DataFillFormWithBLOBs dataFillForm = dataFillFormMapper.selectByPrimaryKey(searchRequest.getId());
|
||||
|
||||
if (StringUtils.equals(dataFillForm.getNodeType(), "folder")) {
|
||||
return null;
|
||||
}
|
||||
List<ExtTableField> fields = gson.fromJson(dataFillForm.getForms(), new TypeToken<List<ExtTableField>>() {
|
||||
}.getType());
|
||||
|
||||
Datasource ds = datasource.get(dataFillForm.getDatasource());
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
datasourceRequest.setTable(dataFillForm.getTableName());
|
||||
|
||||
ExtDDLProvider extDDLProvider = ProviderFactory.gerExtDDLProvider(ds.getType());
|
||||
|
||||
setLowerCaseRequest(ds, datasourceProvider, extDDLProvider, datasourceRequest);
|
||||
|
||||
List<TableField> tableFields = datasourceProvider.getTableFields(datasourceRequest);
|
||||
Map<String, ExtTableField.BaseType> extTableFieldTypeMap = new HashMap<>();
|
||||
Map<String, TableField> tableFieldMap = new HashMap<>();
|
||||
List<TableField> searchFields = new ArrayList<>();
|
||||
|
||||
String key = "";
|
||||
TableField pk = null;
|
||||
|
||||
for (TableField tableField : tableFields) {
|
||||
if (tableField.isPrimaryKey()) {
|
||||
//先把ID放进来
|
||||
searchFields.add(tableField);
|
||||
key = tableField.getFieldName();
|
||||
pk = tableField;
|
||||
}
|
||||
tableFieldMap.put(tableField.getFieldName(), tableField);
|
||||
}
|
||||
|
||||
//核对一下字段
|
||||
for (ExtTableField field : fields) {
|
||||
if (StringUtils.equalsIgnoreCase(field.getType(), "dateRange")) {
|
||||
String name1 = field.getSettings().getMapping().getColumnName1();
|
||||
extTableFieldTypeMap.put(name1, field.getSettings().getMapping().getType());
|
||||
TableField f1 = tableFieldMap.get(name1);
|
||||
if (f1 != null) {
|
||||
//调整类型,给后面解析字段用
|
||||
f1.setFieldType(field.getSettings().getMapping().getType().name());
|
||||
searchFields.add(f1);
|
||||
}
|
||||
String name2 = field.getSettings().getMapping().getColumnName2();
|
||||
extTableFieldTypeMap.put(name2, field.getSettings().getMapping().getType());
|
||||
TableField f2 = tableFieldMap.get(name2);
|
||||
if (f2 != null) {
|
||||
//调整类型,给后面解析字段用
|
||||
f2.setFieldType(field.getSettings().getMapping().getType().name());
|
||||
searchFields.add(f2);
|
||||
}
|
||||
} else {
|
||||
String name = field.getSettings().getMapping().getColumnName();
|
||||
extTableFieldTypeMap.put(name, field.getSettings().getMapping().getType());
|
||||
TableField f = tableFieldMap.get(field.getSettings().getMapping().getColumnName());
|
||||
if (f != null) {
|
||||
//调整类型,给后面解析字段用
|
||||
f.setFieldType(field.getSettings().getMapping().getType().name());
|
||||
searchFields.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String whereSql = "";
|
||||
if (StringUtils.isNoneBlank(searchRequest.getPrimaryKeyValue())) {
|
||||
whereSql = extDDLProvider.whereSql(dataFillForm.getTableName(), List.of(pk));
|
||||
}
|
||||
|
||||
String countSql = extDDLProvider.countSql(dataFillForm.getTableName(), searchFields, whereSql);
|
||||
if (StringUtils.isNoneBlank(searchRequest.getPrimaryKeyValue())) {
|
||||
datasourceRequest.setTableFieldWithValues(List.of(new DatasourceRequest.TableFieldWithValue()
|
||||
.setValue(searchRequest.getPrimaryKeyValue())
|
||||
.setFiledName(pk.getFieldName())
|
||||
.setTypeName(pk.getFieldType())
|
||||
.setType(pk.getType())));
|
||||
}
|
||||
datasourceRequest.setQuery(countSql);
|
||||
List<String[]> countData = datasourceProvider.getData(datasourceRequest);
|
||||
long count = NumberUtils.toLong(countData.get(0)[0]);
|
||||
|
||||
String searchSql = extDDLProvider.searchSql(dataFillForm.getTableName(), searchFields, whereSql, searchRequest.getPageSize(), (searchRequest.getCurrentPage() - 1) * searchRequest.getPageSize());
|
||||
datasourceRequest.setQuery(searchSql);
|
||||
|
||||
List<String[]> data2 = datasourceProvider.getData(datasourceRequest);
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
|
||||
List<String> ids = new ArrayList<>();
|
||||
|
||||
for (String[] strings : data2) {
|
||||
Map<String, Object> object = new HashMap<>();
|
||||
for (int i = 0; i < searchFields.size(); i++) {
|
||||
TableField f = searchFields.get(i);
|
||||
String name = f.getFieldName();
|
||||
String data = strings[i];
|
||||
if (data == null) {
|
||||
object.put(name, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (StringUtils.equals(key, name)) {
|
||||
ids.add(strings[i]);
|
||||
}
|
||||
|
||||
ExtTableField.BaseType extFieldType = extTableFieldTypeMap.get(name);
|
||||
if (extFieldType != null) {
|
||||
switch (extFieldType) {
|
||||
case number:
|
||||
object.put(name, NumberUtils.toLong(strings[i]));
|
||||
break;
|
||||
case decimal:
|
||||
object.put(name, new BigDecimal(strings[i]));
|
||||
break;
|
||||
case datetime:
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(extDDLProvider.DEFAULT_DATE_FORMAT_STR);
|
||||
object.put(name, sdf.parse(strings[i]));
|
||||
break;
|
||||
default:
|
||||
object.put(name, strings[i]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
object.put(name, strings[i]);
|
||||
}
|
||||
}
|
||||
result.add(object);
|
||||
}
|
||||
|
||||
|
||||
List<DataFillCommitLogDTO> list = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
list = extDataFillFormMapper.selectLatestLogByFormDataIds(dataFillForm.getId(), ids);
|
||||
}
|
||||
Map<String, DataFillCommitLogDTO> logMap = list.stream().collect(Collectors.toMap(log -> log.getFormId() + "__" + log.getDataId(), log -> log));
|
||||
|
||||
for (Map<String, Object> object : result) {
|
||||
Map<String, Object> temp = new HashMap<>();
|
||||
temp.put("data", object);
|
||||
temp.put("logInfo", logMap.get(dataFillForm.getId() + "__" + object.get(key)));
|
||||
|
||||
resultList.add(temp);
|
||||
}
|
||||
|
||||
|
||||
return new DataFillFormTableDataResponse()
|
||||
.setKey(key)
|
||||
.setData(resultList)
|
||||
.setFields(fields)
|
||||
.setTotal(count)
|
||||
.setPageSize(searchRequest.getPageSize())
|
||||
.setCurrentPage(searchRequest.getCurrentPage());
|
||||
}
|
||||
|
||||
|
||||
public void deleteRowData(String formId, String id) throws Exception {
|
||||
DataFillFormWithBLOBs dataFillForm = dataFillFormMapper.selectByPrimaryKey(formId);
|
||||
|
||||
if (StringUtils.equals(dataFillForm.getNodeType(), "folder")) {
|
||||
return;
|
||||
}
|
||||
Datasource ds = datasource.get(dataFillForm.getDatasource());
|
||||
|
||||
ExtDDLProvider extDDLProvider = ProviderFactory.gerExtDDLProvider(ds.getType());
|
||||
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
datasourceRequest.setTable(dataFillForm.getTableName());
|
||||
|
||||
setLowerCaseRequest(ds, datasourceProvider, extDDLProvider, datasourceRequest);
|
||||
|
||||
List<TableField> tableFields = datasourceProvider.getTableFields(datasourceRequest).stream().filter(TableField::isPrimaryKey).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(tableFields)) {
|
||||
throw new RuntimeException("没有主键");
|
||||
}
|
||||
TableField key = tableFields.get(0);
|
||||
|
||||
DatasourceRequest.TableFieldWithValue pk = new DatasourceRequest.TableFieldWithValue()
|
||||
.setValue(id) //todo 有可能是数字
|
||||
.setFiledName(key.getFieldName())
|
||||
.setTypeName(key.getFieldType())
|
||||
.setType(key.getType());
|
||||
|
||||
String deleteSql = extDDLProvider.deleteDataByIdSql(dataFillForm.getTableName(), pk);
|
||||
|
||||
datasourceRequest.setQuery(deleteSql);
|
||||
datasourceRequest.setTableFieldWithValues(List.of(pk));
|
||||
|
||||
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
|
||||
jdbcProvider.execWithPreparedStatement(datasourceRequest);
|
||||
|
||||
dataFillLogService.saveCommitOperation(DataFillLogService.COMMIT_OPERATE_DELETE, dataFillForm.getId(), id);
|
||||
|
||||
}
|
||||
|
||||
public String updateRowData(String formId, String rowId, Map<String, Object> data, boolean insert) throws Exception {
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) {
|
||||
DataEaseException.throwException("invalid");
|
||||
}
|
||||
|
||||
if (rowId == null) {
|
||||
insert = true;
|
||||
//先默认主键是uuid
|
||||
rowId = UUIDUtil.getUUIDAsString();
|
||||
}
|
||||
|
||||
DataFillFormWithBLOBs dataFillForm = dataFillFormMapper.selectByPrimaryKey(formId);
|
||||
|
||||
List<ExtTableField> fields = gson.fromJson(dataFillForm.getForms(), new TypeToken<List<ExtTableField>>() {
|
||||
}.getType());
|
||||
|
||||
Datasource ds = datasource.get(dataFillForm.getDatasource());
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
ExtDDLProvider extDDLProvider = ProviderFactory.gerExtDDLProvider(ds.getType());
|
||||
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
datasourceRequest.setTable(dataFillForm.getTableName());
|
||||
|
||||
setLowerCaseRequest(ds, datasourceProvider, extDDLProvider, datasourceRequest);
|
||||
|
||||
List<TableField> tableFields = datasourceProvider.getTableFields(datasourceRequest);
|
||||
|
||||
Map<String, TableField> tableFieldMap = new HashMap<>();
|
||||
|
||||
List<DatasourceRequest.TableFieldWithValue> searchFields = new ArrayList<>();
|
||||
List<DatasourceRequest.TableFieldWithValue> uniqueFields = new ArrayList<>();
|
||||
Map<String, ExtTableField> extTableFields = new HashMap<>();
|
||||
|
||||
DatasourceRequest.TableFieldWithValue pk = null;
|
||||
for (TableField tableField : tableFields) {
|
||||
if (tableField.isPrimaryKey()) {
|
||||
pk = new DatasourceRequest.TableFieldWithValue()
|
||||
.setValue(rowId)
|
||||
.setFiledName(tableField.getFieldName())
|
||||
.setTypeName(tableField.getFieldType())
|
||||
.setType(tableField.getType());
|
||||
if (insert) {
|
||||
searchFields.add(pk);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
tableFieldMap.put(tableField.getFieldName(), tableField);
|
||||
}
|
||||
|
||||
for (ExtTableField field : fields) {
|
||||
if (StringUtils.equalsIgnoreCase(field.getType(), "dateRange")) {
|
||||
String name1 = field.getSettings().getMapping().getColumnName1();
|
||||
String name2 = field.getSettings().getMapping().getColumnName2();
|
||||
if (tableFieldMap.containsKey(name1)) {
|
||||
DatasourceRequest.TableFieldWithValue value1 = new DatasourceRequest.TableFieldWithValue()
|
||||
.setValue(data.get(name1) != null ? new java.sql.Date((long) data.get(name1)) : null)
|
||||
.setFiledName(name1)
|
||||
.setTypeName(tableFieldMap.get(name1).getFieldType())
|
||||
.setType(tableFieldMap.get(name1).getType());
|
||||
searchFields.add(value1);
|
||||
extTableFields.put(name1, field);
|
||||
}
|
||||
if (tableFieldMap.containsKey(name2)) {
|
||||
DatasourceRequest.TableFieldWithValue value2 = new DatasourceRequest.TableFieldWithValue()
|
||||
.setValue(data.get(name2) != null ? new java.sql.Date((long) data.get(name2)) : null)
|
||||
.setFiledName(name2)
|
||||
.setTypeName(tableFieldMap.get(name2).getFieldType())
|
||||
.setType(tableFieldMap.get(name2).getType());
|
||||
searchFields.add(value2);
|
||||
extTableFields.put(name2, field);
|
||||
}
|
||||
} else {
|
||||
String name = field.getSettings().getMapping().getColumnName();
|
||||
if (tableFieldMap.containsKey(name)) {
|
||||
DatasourceRequest.TableFieldWithValue value = new DatasourceRequest.TableFieldWithValue()
|
||||
.setValue(data.get(name))
|
||||
.setFiledName(name)
|
||||
.setTypeName(tableFieldMap.get(name).getFieldType())
|
||||
.setType(tableFieldMap.get(name).getType());
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(field.getType(), "date")) {
|
||||
value.setValue(data.get(name) != null ? new java.sql.Date((long) data.get(name)) : null);
|
||||
}
|
||||
searchFields.add(value);
|
||||
|
||||
extTableFields.put(name, field);
|
||||
|
||||
// 关于unique的字段判断
|
||||
if (field.getSettings().isUnique() && data.get(name) != null) {
|
||||
|
||||
uniqueFields.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(uniqueFields)) {
|
||||
for (DatasourceRequest.TableFieldWithValue uniqueField : uniqueFields) {
|
||||
|
||||
String sql = extDDLProvider.checkUniqueValueSql(dataFillForm.getTableName(), uniqueField, insert ? null : pk);
|
||||
datasourceRequest.setQuery(sql);
|
||||
List<DatasourceRequest.TableFieldWithValue> fs = new ArrayList<>();
|
||||
fs.add(uniqueField);
|
||||
if (!insert) {
|
||||
fs.add(pk);
|
||||
}
|
||||
datasourceRequest.setTableFieldWithValues(fs);
|
||||
List<String[]> countData = datasourceProvider.getData(datasourceRequest);
|
||||
long count = NumberUtils.toLong(countData.get(0)[0]);
|
||||
|
||||
if (count > 0) {
|
||||
DataEaseException.throwException(extTableFields.get(uniqueField.getFiledName()).getSettings().getName() + " 值不能重复");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String sql = insert ?
|
||||
extDDLProvider.insertDataSql(dataFillForm.getTableName(), searchFields) :
|
||||
extDDLProvider.updateDataByIdSql(dataFillForm.getTableName(), searchFields, pk);
|
||||
datasourceRequest.setQuery(sql);
|
||||
|
||||
boolean skip = false;
|
||||
if (!insert && CollectionUtils.isEmpty(searchFields)) {
|
||||
//DataEaseException.throwException("没有修改");
|
||||
skip = true;
|
||||
}
|
||||
|
||||
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
|
||||
|
||||
// 主键在最后传进去
|
||||
if (!insert) {
|
||||
searchFields.add(pk);
|
||||
}
|
||||
datasourceRequest.setTableFieldWithValues(searchFields);
|
||||
|
||||
if (!skip) {
|
||||
int result = jdbcProvider.execWithPreparedStatement(datasourceRequest);
|
||||
}
|
||||
|
||||
if (insert) {
|
||||
dataFillLogService.saveCommitOperation(DataFillLogService.COMMIT_OPERATE_INSERT, dataFillForm.getId(), rowId);
|
||||
} else {
|
||||
dataFillLogService.saveCommitOperation(DataFillLogService.COMMIT_OPERATE_UPDATE, dataFillForm.getId(), rowId);
|
||||
}
|
||||
|
||||
return rowId;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package io.dataease.service.datafill;
|
||||
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.controller.request.datafill.DataFillCommitLogSearchRequest;
|
||||
import io.dataease.dto.datafill.DataFillCommitLogDTO;
|
||||
import io.dataease.ext.ExtDataFillFormMapper;
|
||||
import io.dataease.plugins.common.base.domain.DataFillCommitLog;
|
||||
import io.dataease.plugins.common.base.mapper.DataFillCommitLogMapper;
|
||||
import org.pentaho.di.core.util.UUIDUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DataFillLogService {
|
||||
|
||||
@Resource
|
||||
private ExtDataFillFormMapper extDataFillFormMapper;
|
||||
|
||||
@Resource
|
||||
private DataFillCommitLogMapper dataFillCommitLogMapper;
|
||||
|
||||
|
||||
public static final String COMMIT_OPERATE_INSERT = "INSERT";
|
||||
public static final String COMMIT_OPERATE_UPDATE = "UPDATE";
|
||||
public static final String COMMIT_OPERATE_DELETE = "DELETE";
|
||||
|
||||
|
||||
public List<DataFillCommitLogDTO> commitLogs(String formId, DataFillCommitLogSearchRequest request) {
|
||||
|
||||
|
||||
return extDataFillFormMapper.selectDataFillLogs(formId, request.getCommitByName());
|
||||
|
||||
}
|
||||
|
||||
public void saveCommitOperation(String operate, String formId, String dataId) {
|
||||
DataFillCommitLog log = new DataFillCommitLog();
|
||||
log.setId(UUIDUtil.getUUIDAsString());
|
||||
log.setFormId(formId);
|
||||
log.setDataId(dataId);
|
||||
log.setCommitBy(AuthUtils.getUser().getUsername());
|
||||
log.setOperate(operate);
|
||||
log.setCommitTime(new Date());
|
||||
|
||||
dataFillCommitLogMapper.insertSelective(log);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,348 @@
|
||||
package io.dataease.service.datafill;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.auth.annotation.DeCleaner;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.commons.constants.DataFillConstants;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.SysAuthConstants;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.controller.request.datafill.DataFillFormRequest;
|
||||
import io.dataease.dto.DatasourceDTO;
|
||||
import io.dataease.dto.datafill.DataFillFormDTO;
|
||||
import io.dataease.ext.ExtDataFillFormMapper;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
import io.dataease.plugins.common.base.mapper.DataFillFormMapper;
|
||||
import io.dataease.plugins.common.base.mapper.DataFillUserTaskMapper;
|
||||
import io.dataease.plugins.common.base.mapper.SysUserMapper;
|
||||
import io.dataease.plugins.common.dto.datafill.ExtIndexField;
|
||||
import io.dataease.plugins.common.dto.datafill.ExtTableField;
|
||||
import io.dataease.plugins.common.dto.datasource.TableField;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.datasource.provider.ExtDDLProvider;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
import io.dataease.plugins.datasource.provider.ProviderFactory;
|
||||
import io.dataease.provider.datasource.JdbcProvider;
|
||||
import io.dataease.service.datasource.DatasourceService;
|
||||
import io.dataease.service.sys.SysAuthService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.pentaho.di.core.util.UUIDUtil;
|
||||
import org.springframework.core.env.Environment;
|
||||
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.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DataFillService {
|
||||
|
||||
@Resource
|
||||
private Environment env;
|
||||
@Resource
|
||||
private DataFillFormMapper dataFillFormMapper;
|
||||
@Resource
|
||||
private ExtDataFillFormMapper extDataFillFormMapper;
|
||||
@Resource
|
||||
private DatasourceService datasource;
|
||||
@Resource
|
||||
private SysAuthService sysAuthService;
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Resource
|
||||
private DataFillTaskService dataFillTaskService;
|
||||
@Resource
|
||||
private DataFillDataService dataFillDataService;
|
||||
@Resource
|
||||
private DataFillUserTaskMapper dataFillUserTaskMapper;
|
||||
|
||||
|
||||
private final static Gson gson = new Gson();
|
||||
|
||||
|
||||
@DeCleaner(value = DePermissionType.DATA_FILL, key = "pid")
|
||||
public ResultHolder saveForm(DataFillFormWithBLOBs dataFillForm) throws Exception {
|
||||
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) {
|
||||
DataEaseException.throwException("invalid");
|
||||
}
|
||||
|
||||
String uuid = UUIDUtil.getUUID().toString();
|
||||
|
||||
dataFillForm.setId(uuid);
|
||||
|
||||
checkName(uuid, dataFillForm.getName(), dataFillForm.getPid(), dataFillForm.getLevel(), dataFillForm.getNodeType(), DataFillConstants.OPT_TYPE_INSERT);
|
||||
|
||||
if (!StringUtils.equals(dataFillForm.getNodeType(), "folder")) {
|
||||
List<ExtTableField> fields = gson.fromJson(dataFillForm.getForms(), new TypeToken<List<ExtTableField>>() {
|
||||
}.getType());
|
||||
|
||||
List<ExtIndexField> indexes = new ArrayList<>();
|
||||
if (dataFillForm.getCreateIndex()) {
|
||||
indexes = gson.fromJson(dataFillForm.getTableIndexes(), new TypeToken<List<ExtIndexField>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
DatasourceDTO datasourceDTO = datasource.getDataSourceDetails(dataFillForm.getDatasource());
|
||||
|
||||
datasourceDTO.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasourceDTO.getConfiguration())));
|
||||
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasourceDTO);
|
||||
datasourceRequest.setQuery("SELECT VERSION()");
|
||||
|
||||
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
|
||||
String version = jdbcProvider.getData(datasourceRequest).get(0)[0];
|
||||
|
||||
//拼sql
|
||||
ExtDDLProvider extDDLProvider = ProviderFactory.gerExtDDLProvider(datasourceDTO.getType());
|
||||
String sql = extDDLProvider.createTableSql(dataFillForm.getTableName(), fields);
|
||||
//创建表
|
||||
datasourceRequest.setQuery(sql);
|
||||
jdbcProvider.exec(datasourceRequest);
|
||||
|
||||
if (dataFillForm.getCreateIndex()) {
|
||||
try {
|
||||
List<String> sqls = extDDLProvider.createTableIndexSql(dataFillForm.getTableName(), indexes);
|
||||
|
||||
for (String indexSql : sqls) {
|
||||
datasourceRequest.setQuery(indexSql);
|
||||
jdbcProvider.exec(datasourceRequest);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 执行到这里说明表已经建成功了,创建index出错,那就需要回滚删除创建的表
|
||||
datasourceRequest.setQuery(extDDLProvider.dropTableSql(dataFillForm.getTableName()));
|
||||
jdbcProvider.exec(datasourceRequest);
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
dataFillForm.setCreateBy(AuthUtils.getUser().getUsername());
|
||||
dataFillForm.setUpdateBy(AuthUtils.getUser().getUsername());
|
||||
Date current = new Date();
|
||||
dataFillForm.setCreateTime(current);
|
||||
dataFillForm.setUpdateTime(current);
|
||||
|
||||
dataFillFormMapper.insertSelective(dataFillForm);
|
||||
|
||||
// 清理权限缓存,应该不需要
|
||||
//clearPermissionCache();
|
||||
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, SysLogConstants.SOURCE_TYPE.DATA_FILL_FORM, dataFillForm.getId(), dataFillForm.getPid(), null, null);
|
||||
|
||||
sysAuthService.copyAuth(uuid, SysAuthConstants.AUTH_SOURCE_TYPE_DATA_FILLING);
|
||||
|
||||
|
||||
return ResultHolder.success(uuid);
|
||||
}
|
||||
|
||||
@DeCleaner(value = DePermissionType.DATA_FILL, key = "pid")
|
||||
public ResultHolder updateForm(DataFillFormWithBLOBs dataFillForm) {
|
||||
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) {
|
||||
DataEaseException.throwException("invalid");
|
||||
}
|
||||
|
||||
Assert.notNull(dataFillForm.getId(), "id cannot be null");
|
||||
|
||||
DataFillFormWithBLOBs form = dataFillFormMapper.selectByPrimaryKey(dataFillForm.getId());
|
||||
//todo 改变文件夹位置
|
||||
checkName(dataFillForm.getId(), dataFillForm.getName(), form.getPid(), form.getLevel(), form.getNodeType(), DataFillConstants.OPT_TYPE_UPDATE);
|
||||
|
||||
dataFillForm.setUpdateTime(new Date());
|
||||
dataFillFormMapper.updateByPrimaryKeySelective(dataFillForm);
|
||||
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, SysLogConstants.SOURCE_TYPE.DATA_FILL_FORM, dataFillForm.getId(), dataFillForm.getPid(), null, null);
|
||||
|
||||
return ResultHolder.success(dataFillForm.getId());
|
||||
}
|
||||
|
||||
private void checkName(String id, String name, String pid, int level, String nodeType, String optType) {
|
||||
DataFillFormExample example = new DataFillFormExample();
|
||||
if (DataFillConstants.OPT_TYPE_INSERT.equalsIgnoreCase(optType)) {
|
||||
example.createCriteria().andPidEqualTo(pid).andNameEqualTo(name).andNodeTypeEqualTo(nodeType);
|
||||
} else if (DataFillConstants.OPT_TYPE_UPDATE.equalsIgnoreCase(optType)) {
|
||||
example.createCriteria().andPidEqualTo(pid).andNameEqualTo(name).andIdNotEqualTo(id).andNodeTypeEqualTo(nodeType);
|
||||
}
|
||||
|
||||
List<DataFillForm> checkResult = dataFillFormMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(checkResult)) {
|
||||
DataEaseException.throwException(DataFillConstants.DATA_FILL_NODE_TYPE_DATA_FILL.equals(nodeType) ? Translator.get("I18N_DATA_FILL_FORM_EXIST") : Translator.get("I18N_FOlDER_EXIST"));
|
||||
}
|
||||
}
|
||||
|
||||
public List<DataFillFormDTO> tree(DataFillFormRequest request) {
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) {
|
||||
DataEaseException.throwException("invalid");
|
||||
}
|
||||
|
||||
String userId = String.valueOf(AuthUtils.getUser().getUserId());
|
||||
request.setUserId(userId);
|
||||
List<DataFillFormDTO> list = extDataFillFormMapper.search(request);
|
||||
return TreeUtils.mergeTree(list);
|
||||
|
||||
}
|
||||
|
||||
public DataFillFormWithBLOBs get(String id) {
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) {
|
||||
DataEaseException.throwException("invalid");
|
||||
}
|
||||
|
||||
Assert.notNull(id, "id cannot be null");
|
||||
return dataFillFormMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public DataFillFormDTO getWithPrivileges(String id) {
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) {
|
||||
DataEaseException.throwException("invalid");
|
||||
}
|
||||
|
||||
Assert.notNull(id, "id cannot be null");
|
||||
String userId = String.valueOf(AuthUtils.getUser().getUserId());
|
||||
DataFillFormRequest request = new DataFillFormRequest();
|
||||
request.setUserId(userId);
|
||||
request.setId(id);
|
||||
List<DataFillFormDTO> list = extDataFillFormMapper.search(request);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
DataFillFormDTO base = list.stream().filter(dto -> StringUtils.equals(dto.getId(), id)).collect(Collectors.toList()).get(0);
|
||||
DataFillFormDTO result = new DataFillFormDTO();
|
||||
|
||||
BeanUtils.copyBean(result, get(id));
|
||||
|
||||
result.setPrivileges(base.getPrivileges());
|
||||
|
||||
SysUserExample userExample = new SysUserExample();
|
||||
userExample.createCriteria().andUsernameEqualTo(result.getCreateBy());
|
||||
List<SysUser> sysUsers = sysUserMapper.selectByExample(userExample);
|
||||
if (CollectionUtils.isNotEmpty(sysUsers)) {
|
||||
result.setCreatorName(sysUsers.get(0).getNickName());
|
||||
}
|
||||
|
||||
Datasource d = datasource.get(result.getDatasource());
|
||||
if (d != null) {
|
||||
result.setDatasourceName(d.getName());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void deleteForm(String id) throws Exception {
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) {
|
||||
DataEaseException.throwException("invalid");
|
||||
}
|
||||
|
||||
Assert.notNull(id, "id cannot be null");
|
||||
sysAuthService.checkTreeNoManageCount(SysAuthConstants.AUTH_SOURCE_TYPE_DATA_FILLING, id);
|
||||
|
||||
Map<String, String> stringStringMap = extDataFillFormMapper.searchChildrenIds(id, SysAuthConstants.AUTH_SOURCE_TYPE_DATA_FILLING);
|
||||
String[] split = stringStringMap.get("ids").split(",");
|
||||
|
||||
DataFillFormWithBLOBs dataFillForm = dataFillFormMapper.selectByPrimaryKey(id);
|
||||
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (String dsId : split) {
|
||||
if (StringUtils.isNotEmpty(dsId)) {
|
||||
ids.add(dsId);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
DataFillFormExample example = new DataFillFormExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
dataFillFormMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
if (dataFillForm != null) {
|
||||
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.DELETE, SysLogConstants.SOURCE_TYPE.DATA_FILL_FORM, dataFillForm.getId(), dataFillForm.getPid(), null, null);
|
||||
|
||||
dataFillTaskService.deleteTaskByFormId(id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<ExtTableField> listFields(String id) throws Exception {
|
||||
DataFillFormWithBLOBs dataFillForm = dataFillFormMapper.selectByPrimaryKey(id);
|
||||
|
||||
if (StringUtils.equals(dataFillForm.getNodeType(), "folder")) {
|
||||
return null;
|
||||
}
|
||||
return gson.fromJson(dataFillForm.getForms(), new TypeToken<List<ExtTableField>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
|
||||
public void fillFormData(String userTaskId, Map<String, Object> data) throws Exception {
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) {
|
||||
DataEaseException.throwException("invalid");
|
||||
}
|
||||
|
||||
DataFillUserTask task = dataFillUserTaskMapper.selectByPrimaryKey(userTaskId);
|
||||
|
||||
if (task == null) {
|
||||
DataEaseException.throwException("任务不存在");
|
||||
}
|
||||
|
||||
if (!AuthUtils.getUser().getUserId().equals(task.getUser())) {
|
||||
DataEaseException.throwException("当前用户非任务用户");
|
||||
}
|
||||
|
||||
if (task.getEndTime() != null) {
|
||||
if (task.getEndTime().getTime() < System.currentTimeMillis()) {
|
||||
DataEaseException.throwException("已经超过了任务截止时间");
|
||||
}
|
||||
}
|
||||
|
||||
String formId = task.getFormId();
|
||||
|
||||
String rowId = null;
|
||||
if (StringUtils.isNotBlank(task.getValueId())) {
|
||||
rowId = task.getValueId();
|
||||
} else {
|
||||
DataFillFormWithBLOBs dataFillForm = dataFillFormMapper.selectByPrimaryKey(formId);
|
||||
|
||||
Datasource ds = datasource.get(dataFillForm.getDatasource());
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
ExtDDLProvider extDDLProvider = ProviderFactory.gerExtDDLProvider(ds.getType());
|
||||
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(ds);
|
||||
datasourceRequest.setTable(dataFillForm.getTableName());
|
||||
|
||||
DataFillDataService.setLowerCaseRequest(ds, datasourceProvider, extDDLProvider, datasourceRequest);
|
||||
|
||||
List<TableField> tableFields = datasourceProvider.getTableFields(datasourceRequest);
|
||||
|
||||
for (TableField tableField : tableFields) {
|
||||
if (tableField.isPrimaryKey()) {
|
||||
rowId = (String) data.get(tableField.getFieldName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rowId = dataFillDataService.updateRowData(formId, rowId, data, rowId == null);
|
||||
|
||||
task.setValueId(rowId);
|
||||
task.setFinishTime(new Date());
|
||||
|
||||
dataFillUserTaskMapper.updateByPrimaryKeySelective(task);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,274 @@
|
||||
package io.dataease.service.datafill;
|
||||
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.controller.request.datafill.DataFillTaskSearchRequest;
|
||||
import io.dataease.controller.request.datafill.DataFillUserTaskSearchRequest;
|
||||
import io.dataease.dto.datafill.DataFillTaskDTO;
|
||||
import io.dataease.dto.datafill.DataFillUserTaskDTO;
|
||||
import io.dataease.ext.ExtDataFillFormMapper;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.job.sechedule.ScheduleManager;
|
||||
import io.dataease.job.sechedule.strategy.TaskHandler;
|
||||
import io.dataease.job.sechedule.strategy.TaskStrategyFactory;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
import io.dataease.plugins.common.base.mapper.DataFillTaskMapper;
|
||||
import io.dataease.plugins.common.base.mapper.DataFillUserTaskMapper;
|
||||
import io.dataease.plugins.common.base.mapper.SysUserMapper;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.pentaho.di.core.util.UUIDUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DataFillTaskService {
|
||||
|
||||
@Resource
|
||||
private ExtDataFillFormMapper extDataFillFormMapper;
|
||||
|
||||
@Resource
|
||||
private DataFillTaskMapper dataFillTaskMapper;
|
||||
@Resource
|
||||
private DataFillUserTaskMapper dataFillUserTaskMapper;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Resource
|
||||
private ScheduleManager scheduleManager;
|
||||
|
||||
|
||||
public List<DataFillTaskDTO> tasks(String formId, DataFillTaskSearchRequest request) {
|
||||
request.setFormId(formId);
|
||||
return extDataFillFormMapper.selectDataFillTasks(request);
|
||||
}
|
||||
|
||||
private List<DataFillTask> listActiveTasks() {
|
||||
return extDataFillFormMapper.selectActiveDataFillTasks();
|
||||
}
|
||||
|
||||
public List<GlobalTaskEntity> listActiveTasksGlobalTaskEntity() {
|
||||
List<GlobalTaskEntity> list = new ArrayList<>();
|
||||
List<DataFillTask> tasks = dataFillTaskMapper.selectByExample(null);
|
||||
for (DataFillTask task : tasks) {
|
||||
list.add(getGlobalTaskEntity(task));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private GlobalTaskEntity getGlobalTaskEntity(DataFillTask task) {
|
||||
GlobalTaskEntity entity = new GlobalTaskEntity()
|
||||
.setTaskId(task.getId())
|
||||
.setTaskName(task.getName())
|
||||
.setRateType(task.getRateType())
|
||||
.setRateVal(task.getRateVal())
|
||||
.setStatus(task.getStatus())
|
||||
.setTaskType("dataFillTaskHandler")
|
||||
.setCreator(task.getCreator());
|
||||
if (task.getRateType() == -1) {
|
||||
entity.setStartTime(task.getPublishStartTime() == null ? null : task.getPublishStartTime().getTime());
|
||||
entity.setEndTime(task.getPublishEndTime() == null ? null : task.getPublishEndTime().getTime());
|
||||
} else {
|
||||
entity.setStartTime(task.getStartTime() == null ? null : task.getStartTime().getTime());
|
||||
entity.setEndTime(task.getEndTime() == null ? null : task.getEndTime().getTime());
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void saveTask(String formId, DataFillTaskSearchRequest request) throws Exception {
|
||||
if (!CommonBeanFactory.getBean(AuthUserService.class).pluginLoaded()) {
|
||||
DataEaseException.throwException("invalid");
|
||||
}
|
||||
|
||||
request.setCreator(AuthUtils.getUser().getUserId());
|
||||
boolean insert = false;
|
||||
if (request.getId() == null) {
|
||||
insert = true;
|
||||
request.setFormId(formId);
|
||||
request.setCreateTime(new Date());
|
||||
}
|
||||
|
||||
DataFillTaskExample example = new DataFillTaskExample();
|
||||
DataFillTaskExample.Criteria criteria = example.createCriteria()
|
||||
.andFormIdEqualTo(formId)
|
||||
.andNameEqualTo(request.getName());
|
||||
|
||||
if (insert) {
|
||||
if (dataFillTaskMapper.countByExample(example) > 0) {
|
||||
DataEaseException.throwException(Translator.get("I18N_DATA_FILL_TASK_EXIST"));
|
||||
}
|
||||
dataFillTaskMapper.insertSelective(request);
|
||||
} else {
|
||||
criteria.andIdNotEqualTo(request.getId());
|
||||
if (dataFillTaskMapper.countByExample(example) > 0) {
|
||||
DataEaseException.throwException(Translator.get("I18N_DATA_FILL_TASK_EXIST"));
|
||||
}
|
||||
dataFillTaskMapper.updateByPrimaryKeySelective(request);
|
||||
}
|
||||
|
||||
DataFillTaskWithBLOBs task = dataFillTaskMapper.selectByPrimaryKey(request.getId());
|
||||
|
||||
|
||||
GlobalTaskEntity entity = getGlobalTaskEntity(task);
|
||||
TaskHandler taskHandler = TaskStrategyFactory.getInvokeStrategy(entity.getTaskType());
|
||||
taskHandler.addTask(scheduleManager, entity);
|
||||
|
||||
}
|
||||
|
||||
public DataFillTaskWithBLOBs getTaskById(Long id) {
|
||||
return dataFillTaskMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void finishTask(Long id) {
|
||||
DataFillTaskWithBLOBs task = new DataFillTaskWithBLOBs();
|
||||
task.setId(id);
|
||||
task.setStatus(false);
|
||||
dataFillTaskMapper.updateByPrimaryKeySelective(task);
|
||||
}
|
||||
|
||||
public void deleteTaskByFormId(String formId) {
|
||||
DataFillTaskExample example = new DataFillTaskExample();
|
||||
example.createCriteria().andFormIdEqualTo(formId);
|
||||
for (DataFillTask dataFillTask : dataFillTaskMapper.selectByExample(example)) {
|
||||
deleteTask(dataFillTask.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteTask(Long id) {
|
||||
|
||||
try {
|
||||
GlobalTaskEntity entity = getGlobalTaskEntity(dataFillTaskMapper.selectByPrimaryKey(id));
|
||||
TaskHandler taskHandler = TaskStrategyFactory.getInvokeStrategy(entity.getTaskType());
|
||||
taskHandler.removeTask(scheduleManager, entity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
dataFillTaskMapper.deleteByPrimaryKey(id);
|
||||
|
||||
DataFillUserTaskExample example = new DataFillUserTaskExample();
|
||||
example.createCriteria().andTaskIdEqualTo(id);
|
||||
dataFillUserTaskMapper.deleteByExample(example);
|
||||
|
||||
}
|
||||
|
||||
public void enableTask(Long taskId) throws Exception {
|
||||
DataFillTask task = dataFillTaskMapper.selectByPrimaryKey(taskId);
|
||||
DataFillTaskSearchRequest request = new DataFillTaskSearchRequest();
|
||||
request.setId(taskId);
|
||||
request.setStatus(true);
|
||||
saveTask(task.getFormId(), request);
|
||||
}
|
||||
|
||||
public void disableTask(Long taskId) throws Exception {
|
||||
DataFillTask task = dataFillTaskMapper.selectByPrimaryKey(taskId);
|
||||
DataFillTaskSearchRequest request = new DataFillTaskSearchRequest();
|
||||
request.setId(taskId);
|
||||
request.setStatus(false);
|
||||
saveTask(task.getFormId(), request);
|
||||
}
|
||||
|
||||
public void createUserTasks(DataFillTaskWithBLOBs dataFillTask, String valueId) throws Exception {
|
||||
String reciUsers = dataFillTask.getReciUsers();
|
||||
List<String> accountSet = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(reciUsers)) {
|
||||
accountSet.addAll(Arrays.stream(reciUsers.split(",")).collect(Collectors.toSet()));
|
||||
}
|
||||
List<SysUser> sysUsers = new ArrayList<>();
|
||||
if (!accountSet.isEmpty()) {
|
||||
SysUserExample example = new SysUserExample();
|
||||
example.createCriteria().andUsernameIn(accountSet);
|
||||
sysUsers = sysUserMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
|
||||
String roleList = dataFillTask.getRoleList();
|
||||
String orgList = dataFillTask.getOrgList();
|
||||
AuthURD authURD = new AuthURD();
|
||||
if (StringUtils.isNotBlank(roleList)) {
|
||||
authURD.setRoleIds(Arrays.stream(roleList.split(",")).map(Long::parseLong).collect(Collectors.toList()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(orgList)) {
|
||||
authURD.setDeptIds(Arrays.stream(orgList.split(",")).map(Long::parseLong).collect(Collectors.toList()));
|
||||
}
|
||||
Set<Long> ids = AuthUtils.userIdsByURD(authURD);
|
||||
|
||||
for (SysUser sysUser : sysUsers) {
|
||||
ids.add(sysUser.getUserId());
|
||||
}
|
||||
|
||||
Date startTime = null;
|
||||
Date endTime = null;
|
||||
|
||||
if (dataFillTask.getRateType() == -1) {
|
||||
//startTime = dataFillTask.getPublishStartTime();
|
||||
startTime = new Date();
|
||||
endTime = dataFillTask.getPublishEndTime();
|
||||
} else {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date val = sdf.parse(dataFillTask.getRateVal());
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(val);
|
||||
|
||||
Calendar current = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, current.get(Calendar.YEAR));
|
||||
calendar.set(Calendar.MONTH, current.get(Calendar.MONTH));
|
||||
calendar.set(Calendar.DAY_OF_MONTH, current.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
startTime = calendar.getTime();
|
||||
|
||||
if (dataFillTask.getPublishRangeTimeType() == -1) {
|
||||
calendar.add(Calendar.HOUR_OF_DAY, dataFillTask.getPublishRangeTime());
|
||||
} else if (dataFillTask.getPublishRangeTimeType() == 0) {
|
||||
calendar.add(Calendar.DAY_OF_MONTH, dataFillTask.getPublishRangeTime());
|
||||
} else if (dataFillTask.getPublishRangeTimeType() == 1) {
|
||||
calendar.add(Calendar.WEEK_OF_YEAR, dataFillTask.getPublishRangeTime());
|
||||
} else if (dataFillTask.getPublishRangeTimeType() == 2) {
|
||||
calendar.add(Calendar.MONTH, dataFillTask.getPublishRangeTime());
|
||||
}
|
||||
endTime = calendar.getTime();
|
||||
}
|
||||
|
||||
for (Long id : ids) {
|
||||
DataFillUserTask task = new DataFillUserTask();
|
||||
task.setId(UUIDUtil.getUUIDAsString());
|
||||
task.setTaskId(dataFillTask.getId());
|
||||
task.setFormId(dataFillTask.getFormId());
|
||||
task.setUser(id);
|
||||
task.setStartTime(startTime);
|
||||
task.setEndTime(endTime);
|
||||
task.setValueId(valueId);
|
||||
|
||||
dataFillUserTaskMapper.insertSelective(task);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<DataFillUserTaskDTO> userTasks(Long userId, String type, DataFillUserTaskSearchRequest request) {
|
||||
List<DataFillUserTaskDTO> list = new ArrayList<>();
|
||||
|
||||
String taskName = StringUtils.isNotBlank(request.getTaskName()) ? request.getTaskName() : null;
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(type, "finished")) {
|
||||
list = extDataFillFormMapper.listFinishedUserTask(userId, taskName);
|
||||
} else if (StringUtils.equalsIgnoreCase(type, "expired")) {
|
||||
list = extDataFillFormMapper.listExpiredUserTask(userId, new Date(), taskName);
|
||||
} else {
|
||||
list = extDataFillFormMapper.listTodoUserTask(userId, new Date(), taskName);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
}
|
||||
}
|
||||
@ -567,8 +567,8 @@ public class ExtractDataService {
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
// File deleteFile = new File(root_path + datasetTable.getId() + ".sh");
|
||||
// FileUtils.forceDelete(deleteFile);
|
||||
File deleteFile = new File(root_path + datasetTable.getId() + ".sh");
|
||||
FileUtils.forceDelete(deleteFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,10 +10,7 @@ import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.RedisConstants;
|
||||
import io.dataease.commons.constants.SysAuthConstants;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CommonThreadPool;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.controller.datasource.request.UpdataDsRequest;
|
||||
import io.dataease.controller.request.DatasourceUnionRequest;
|
||||
@ -43,6 +40,7 @@ import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.datasource.entity.JdbcConfiguration;
|
||||
import io.dataease.plugins.datasource.entity.Status;
|
||||
import io.dataease.plugins.datasource.provider.DefaultJdbcProvider;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
import io.dataease.plugins.datasource.provider.ProviderFactory;
|
||||
import io.dataease.provider.datasource.ApiProvider;
|
||||
@ -654,4 +652,15 @@ public class DatasourceService {
|
||||
datasourceMapper.updateByPrimaryKeyWithBLOBs(datasource);
|
||||
}
|
||||
|
||||
public void releaseDsconnections(){
|
||||
List<DefaultJdbcProvider> providers = (List<DefaultJdbcProvider>)SpringContextUtil.getApplicationContext().getBeansOfType(DefaultJdbcProvider.class).values();
|
||||
providers.forEach(provider ->{
|
||||
provider.getJdbcConnection().values().forEach(druidDataSource -> {
|
||||
try {
|
||||
druidDataSource.close();
|
||||
}catch (Exception e){}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -62,6 +62,18 @@ public class DeCatchProcess {
|
||||
cleanCacheParent(resourceId.toString(), "link");
|
||||
});
|
||||
}
|
||||
public void cleanDataFiling(Object pid) {
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
CacheUtils.remove(AuthConstants.USER_DATA_FILL_NAME, "user" + user.getUserId());
|
||||
CacheUtils.remove(AuthConstants.DEPT_DATA_FILL_NAME, "dept" + user.getDeptId());
|
||||
user.getRoles().forEach(role -> {
|
||||
CacheUtils.remove(AuthConstants.ROLE_DATA_FILL_NAME, "role" + role.getId());
|
||||
});
|
||||
|
||||
Optional.ofNullable(pid).ifPresent(resourceId -> {
|
||||
cleanCacheParent(resourceId.toString(), "data_fill");
|
||||
});
|
||||
}
|
||||
|
||||
private void cleanCacheParent(String pid, String type) {
|
||||
if (StringUtils.isBlank(pid) || StringUtils.isBlank(type)) {
|
||||
|
||||
@ -8,19 +8,15 @@ import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.controller.request.panel.link.EnablePwdRequest;
|
||||
import io.dataease.controller.request.panel.link.LinkRequest;
|
||||
import io.dataease.controller.request.panel.link.OverTimeRequest;
|
||||
import io.dataease.controller.request.panel.link.PasswordRequest;
|
||||
import io.dataease.controller.request.panel.link.*;
|
||||
import io.dataease.dto.panel.PanelGroupDTO;
|
||||
import io.dataease.dto.panel.link.GenerateDto;
|
||||
import io.dataease.dto.panel.link.TicketDto;
|
||||
import io.dataease.ext.ExtPanelGroupMapper;
|
||||
import io.dataease.ext.ExtPanelLinkMapper;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
import io.dataease.plugins.common.base.mapper.PanelGroupMapper;
|
||||
import io.dataease.plugins.common.base.mapper.PanelLinkMapper;
|
||||
import io.dataease.plugins.common.base.mapper.PanelLinkMappingMapper;
|
||||
import io.dataease.plugins.common.base.mapper.PanelWatermarkMapper;
|
||||
import io.dataease.plugins.common.base.mapper.*;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -56,6 +52,9 @@ public class PanelLinkService {
|
||||
@Resource
|
||||
private ExtPanelGroupMapper extPanelGroupMapper;
|
||||
|
||||
@Resource
|
||||
private PanelLinkTicketMapper panelLinkTicketMapper;
|
||||
|
||||
@Transactional
|
||||
public void changeValid(LinkRequest request) {
|
||||
PanelLink po = new PanelLink();
|
||||
@ -130,16 +129,28 @@ public class PanelLinkService {
|
||||
}
|
||||
}
|
||||
|
||||
public String getMappingUuid(PanelLink link) {
|
||||
public PanelLinkMapping getMapping(PanelLink link) {
|
||||
String resourceId = link.getResourceId();
|
||||
Long userId = link.getUserId();
|
||||
PanelLinkMappingExample example = new PanelLinkMappingExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId).andUserIdEqualTo(userId);
|
||||
List<PanelLinkMapping> mappings = panelLinkMappingMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(mappings)) return mappings.get(0).getUuid();
|
||||
if (CollectionUtils.isNotEmpty(mappings)) return mappings.get(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<PanelLinkTicket> queryTicket(String resourceId) {
|
||||
Long userId = AuthUtils.getUser().getUserId();
|
||||
PanelLinkMappingExample example = new PanelLinkMappingExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId).andUserIdEqualTo(userId);
|
||||
List<PanelLinkMapping> mappings = panelLinkMappingMapper.selectByExample(example);
|
||||
PanelLinkMapping mapping = mappings.get(0);
|
||||
String uuid = mapping.getUuid();
|
||||
PanelLinkTicketExample exampleTicket = new PanelLinkTicketExample();
|
||||
exampleTicket.createCriteria().andUuidEqualTo(uuid);
|
||||
return panelLinkTicketMapper.selectByExample(exampleTicket);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public GenerateDto currentGenerate(String resourceId) {
|
||||
PanelLink one = findOne(resourceId, AuthUtils.getUser().getUserId());
|
||||
@ -152,7 +163,6 @@ public class PanelLinkService {
|
||||
one.setEnablePwd(false);
|
||||
mapper.insert(one);
|
||||
}
|
||||
|
||||
PanelLinkMappingExample example = new PanelLinkMappingExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId).andUserIdEqualTo(AuthUtils.getUser().getUserId());
|
||||
List<PanelLinkMapping> mappings = panelLinkMappingMapper.selectByExample(example);
|
||||
@ -162,11 +172,12 @@ public class PanelLinkService {
|
||||
mapping.setResourceId(resourceId);
|
||||
mapping.setUserId(AuthUtils.getUser().getUserId());
|
||||
mapping.setUuid(CodingUtil.shortUuid());
|
||||
mapping.setRequireTicket(false);
|
||||
panelLinkMappingMapper.insert(mapping);
|
||||
} else {
|
||||
mapping = mappings.get(0);
|
||||
}
|
||||
return convertDto(one, mapping.getUuid());
|
||||
return convertDto(one, mapping.getUuid(), mapping.getRequireTicket());
|
||||
}
|
||||
|
||||
public void deleteByResourceId(String resourceId) {
|
||||
@ -205,13 +216,14 @@ public class PanelLinkService {
|
||||
return linkParam;
|
||||
}
|
||||
|
||||
private GenerateDto convertDto(PanelLink link, String uuid) {
|
||||
private GenerateDto convertDto(PanelLink link, String uuid, boolean requireTicket) {
|
||||
GenerateDto result = new GenerateDto();
|
||||
result.setValid(link.getValid());
|
||||
result.setEnablePwd(link.getEnablePwd());
|
||||
result.setPwd(link.getPwd());
|
||||
result.setUri(BASEURL + buildLinkParam(link, uuid));
|
||||
result.setOverTime(link.getOverTime());
|
||||
result.setRequireTicket(requireTicket);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -272,6 +284,62 @@ public class PanelLinkService {
|
||||
return contextPath + SHORT_URL_PREFIX + (StringUtils.isBlank(uuid) ? mapping.getId() : uuid);
|
||||
}
|
||||
|
||||
public String saveTicket(TicketCreator creator) {
|
||||
String ticket = creator.getTicket();
|
||||
if (StringUtils.isNotBlank(ticket)) {
|
||||
PanelLinkTicket ticketEntity = getByTicket(ticket);
|
||||
if (ObjectUtils.isNotEmpty(ticketEntity)) {
|
||||
PanelLinkTicketExample example = new PanelLinkTicketExample();
|
||||
example.createCriteria().andTicketEqualTo(ticket);
|
||||
if (creator.isGenerateNew()) {
|
||||
ticketEntity.setAccessTime(null);
|
||||
ticketEntity.setTicket(CodingUtil.shortUuid());
|
||||
}
|
||||
ticketEntity.setArgs(creator.getArgs());
|
||||
ticketEntity.setExp(creator.getExp());
|
||||
ticketEntity.setUuid(creator.getUuid());
|
||||
panelLinkTicketMapper.updateByExample(ticketEntity, example);
|
||||
return ticketEntity.getTicket();
|
||||
}
|
||||
}
|
||||
ticket = CodingUtil.shortUuid();
|
||||
PanelLinkTicket linkTicket = new PanelLinkTicket();
|
||||
linkTicket.setTicket(ticket);
|
||||
linkTicket.setArgs(creator.getArgs());
|
||||
linkTicket.setExp(creator.getExp());
|
||||
linkTicket.setUuid(creator.getUuid());
|
||||
panelLinkTicketMapper.insert(linkTicket);
|
||||
return ticket;
|
||||
}
|
||||
|
||||
public void deleteTicket(TicketDelRequest request) {
|
||||
String ticket = request.getTicket();
|
||||
if (StringUtils.isBlank(ticket)) {
|
||||
DataEaseException.throwException("ticket为必填参数");
|
||||
}
|
||||
PanelLinkTicketExample example = new PanelLinkTicketExample();
|
||||
example.createCriteria().andTicketEqualTo(ticket);
|
||||
panelLinkTicketMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public void switchRequire(TicketSwitchRequest request) {
|
||||
String resourceId = request.getResourceId();
|
||||
Boolean require = request.getRequire();
|
||||
PanelLinkMappingExample example = new PanelLinkMappingExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId).andUserIdEqualTo(AuthUtils.getUser().getUserId());
|
||||
PanelLinkMapping mapping = new PanelLinkMapping();
|
||||
mapping.setRequireTicket(require);
|
||||
panelLinkMappingMapper.updateByExampleSelective(mapping, example);
|
||||
}
|
||||
|
||||
public PanelLinkTicket getByTicket(String ticket) {
|
||||
PanelLinkTicketExample example = new PanelLinkTicketExample();
|
||||
example.createCriteria().andTicketEqualTo(ticket);
|
||||
List<PanelLinkTicket> tickets = panelLinkTicketMapper.selectByExample(example);
|
||||
if (CollectionUtils.isEmpty(tickets)) return null;
|
||||
return tickets.get(0);
|
||||
}
|
||||
|
||||
public String getUrlByIndex(Long index) {
|
||||
PanelLinkMapping mapping = panelLinkMappingMapper.selectByPrimaryKey(index);
|
||||
|
||||
@ -281,7 +349,7 @@ public class PanelLinkService {
|
||||
if (StringUtils.isNotBlank(mapping.getUuid())) {
|
||||
one.setResourceId("error-resource-id");
|
||||
}
|
||||
return convertDto(one, mapping.getUuid()).getUri();
|
||||
return convertDto(one, mapping.getUuid(), mapping.getRequireTicket()).getUri();
|
||||
}
|
||||
|
||||
public String getUrlByUuid(String uuid) {
|
||||
@ -297,6 +365,43 @@ public class PanelLinkService {
|
||||
String resourceId = mapping.getResourceId();
|
||||
Long userId = mapping.getUserId();
|
||||
PanelLink one = findOne(resourceId, userId);
|
||||
return convertDto(one, uuid).getUri();
|
||||
return convertDto(one, uuid, mapping.getRequireTicket()).getUri();
|
||||
}
|
||||
|
||||
public TicketDto validateTicket(String ticket, PanelLinkMapping mapping) {
|
||||
String uuid = mapping.getUuid();
|
||||
TicketDto ticketDto = new TicketDto();
|
||||
if (StringUtils.isBlank(ticket)) {
|
||||
ticketDto.setTicketValid(!mapping.getRequireTicket());
|
||||
return ticketDto;
|
||||
}
|
||||
PanelLinkTicketExample example = new PanelLinkTicketExample();
|
||||
example.createCriteria().andTicketEqualTo(ticket).andUuidEqualTo(uuid);
|
||||
List<PanelLinkTicket> tickets = panelLinkTicketMapper.selectByExample(example);
|
||||
if (CollectionUtils.isEmpty(tickets)) {
|
||||
ticketDto.setTicketValid(false);
|
||||
return ticketDto;
|
||||
}
|
||||
PanelLinkTicket linkTicket = tickets.get(0);
|
||||
ticketDto.setTicketValid(true);
|
||||
ticketDto.setArgs(linkTicket.getArgs());
|
||||
Long accessTime = linkTicket.getAccessTime();
|
||||
long now = System.currentTimeMillis();
|
||||
if (ObjectUtils.isEmpty(accessTime)) {
|
||||
accessTime = now;
|
||||
ticketDto.setTicketExp(false);
|
||||
linkTicket.setAccessTime(accessTime);
|
||||
panelLinkTicketMapper.updateByPrimaryKey(linkTicket);
|
||||
return ticketDto;
|
||||
}
|
||||
Long exp = linkTicket.getExp();
|
||||
if (ObjectUtils.isEmpty(exp) || exp.equals(0L)) {
|
||||
ticketDto.setTicketExp(false);
|
||||
return ticketDto;
|
||||
}
|
||||
long expTime = exp * 60L * 1000L;
|
||||
long time = now - accessTime;
|
||||
ticketDto.setTicketExp(time > expTime);
|
||||
return ticketDto;
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,8 +131,12 @@ public class PanelViewService {
|
||||
//将视图从cache表中更新到正式表中
|
||||
viewIds = panelViewInsertDTOList.stream().map(panelView -> panelView.getChartViewId()).collect(Collectors.toList());
|
||||
}
|
||||
extChartViewMapper.deleteCacheWithPanel(viewIds, panelId);
|
||||
extChartViewMapper.deleteNoUseView(viewIds, panelId);
|
||||
// viewIds 不存在时 不执行删除缓存防止误删情况
|
||||
if(CollectionUtils.isNotEmpty(viewIds)){
|
||||
extChartViewMapper.deleteCacheWithPanel(viewIds, panelId);
|
||||
extChartViewMapper.deleteNoUseView(viewIds, panelId);
|
||||
}
|
||||
|
||||
}
|
||||
panelGroup.setMobileLayout(mobileLayout);
|
||||
return viewIds;
|
||||
|
||||
@ -44,9 +44,10 @@ public class StaticResourceService {
|
||||
}
|
||||
String originName = file.getOriginalFilename();
|
||||
String newFileName = fileId + originName.substring(originName.lastIndexOf("."), originName.length());
|
||||
Path uploadPath = Paths.get(staticDir.toString(), newFileName);
|
||||
Path basePath = Paths.get(staticDir.toString());
|
||||
// create dir is absent
|
||||
FileUtils.createIfAbsent(Paths.get(staticDir.toString()));
|
||||
FileUtils.createIfAbsent(basePath);
|
||||
Path uploadPath = basePath.resolve(newFileName);
|
||||
Files.createFile(uploadPath);
|
||||
file.transferTo(uploadPath);
|
||||
} catch (IOException e) {
|
||||
@ -86,9 +87,10 @@ public class StaticResourceService {
|
||||
}
|
||||
|
||||
public void saveSingleFileToServe(String fileName, String content) {
|
||||
Path uploadPath = Paths.get(staticDir.toString(), fileName);
|
||||
Path basePath = Paths.get(staticDir.toString());
|
||||
Path uploadPath = basePath.resolve(fileName);
|
||||
try {
|
||||
if (uploadPath.toFile().exists()) {
|
||||
if (Files.exists(uploadPath)) {
|
||||
LogUtil.info("file exists");
|
||||
} else {
|
||||
if (StringUtils.isNotEmpty(content)) {
|
||||
|
||||
@ -81,6 +81,7 @@ server.servlet.context-parameters.configurationStrategy=SYSTEM_PROPERTIES
|
||||
server.servlet.session.cookie.http-only=true
|
||||
server.servlet.session.tracking-modes=cookie
|
||||
spring.jackson.parser.allow-numeric-leading-zeros=true
|
||||
logging.level.org.apache.shiro=OFF
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
-- ----------------------------
|
||||
-- Table structure for panel_link_ticket
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `panel_link_ticket`;
|
||||
CREATE TABLE `panel_link_ticket`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`uuid` varchar(255) NOT NULL,
|
||||
`ticket` varchar(255) NOT NULL,
|
||||
`exp` bigint DEFAULT NULL,
|
||||
`args` varchar(255) DEFAULT NULL,
|
||||
`access_time` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 1;
|
||||
|
||||
ALTER TABLE `panel_link_mapping`
|
||||
ADD COLUMN `require_ticket` tinyint(1) NOT NULL DEFAULT 0 AFTER `uuid`;
|
||||
|
||||
INSERT INTO `system_parameter` (`param_key`, `param_value`, `type`, `sort`) VALUES ('ai.baseUrl', 'https://maxkb.fit2cloud.com/ui/chat/5baa787163381fa2', 'text', 100);
|
||||
@ -0,0 +1,330 @@
|
||||
DROP TABLE IF EXISTS `data_fill_form`;
|
||||
create table data_fill_form
|
||||
(
|
||||
id varchar(50) not null comment '主键ID'
|
||||
primary key,
|
||||
name varchar(255) null comment '名称',
|
||||
pid varchar(255) null comment '父级ID',
|
||||
level int(10) null comment '层级',
|
||||
node_type varchar(255) null comment 'folder/panel 目录或文件夹',
|
||||
table_name varchar(255) null comment '表名',
|
||||
datasource varchar(255) null comment '数据源',
|
||||
forms longtext null comment '表单内容',
|
||||
create_index tinyint(1) default 0 null comment '是否创建索引',
|
||||
table_indexes longtext null comment '索引',
|
||||
create_by varchar(255) null comment '创建人',
|
||||
create_time datetime default current_timestamp() null comment '创建时间',
|
||||
update_by varchar(255) null comment '更新人',
|
||||
update_time datetime default current_timestamp() null comment '更新时间'
|
||||
)
|
||||
comment '数据填报表单';
|
||||
|
||||
CREATE TRIGGER `delete_auth_data_fill_form`
|
||||
AFTER DELETE
|
||||
ON `data_fill_form`
|
||||
FOR EACH ROW select delete_auth_source(OLD.id, 'data_fill')
|
||||
into @ee;
|
||||
|
||||
|
||||
DROP VIEW IF EXISTS `v_auth_model`;
|
||||
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `v_auth_model` AS
|
||||
SELECT `sys_user`.`user_id` AS `id`,
|
||||
concat(`sys_user`.`nick_name`, '(', `sys_user`.`username`, ')') AS `name`,
|
||||
`sys_user`.`username` AS `label`,
|
||||
'0' AS `pid`,
|
||||
'leaf' AS `node_type`,
|
||||
'user' AS `model_type`,
|
||||
'user' AS `model_inner_type`,
|
||||
'target' AS `auth_type`,
|
||||
`sys_user`.`create_by` AS `create_by`,
|
||||
0 AS `level`,
|
||||
0 AS `mode`,
|
||||
'0' AS `data_source_id`
|
||||
FROM `sys_user`
|
||||
WHERE (`sys_user`.`is_admin` <> 1)
|
||||
UNION ALL
|
||||
SELECT `sys_role`.`role_id` AS `id`,
|
||||
`sys_role`.`name` AS `name`,
|
||||
`sys_role`.`name` AS `label`,
|
||||
'0' AS `pid`,
|
||||
'leaf' AS `node_type`,
|
||||
'role' AS `model_type`,
|
||||
'role' AS `model_inner_type`,
|
||||
'target' AS `auth_type`,
|
||||
`sys_role`.`create_by` AS `create_by`,
|
||||
0 AS `level`,
|
||||
0 AS `mode`,
|
||||
'0' AS `data_source_id`
|
||||
FROM `sys_role`
|
||||
UNION ALL
|
||||
SELECT `sys_dept`.`dept_id` AS `id`,
|
||||
`sys_dept`.`name` AS `name`,
|
||||
`sys_dept`.`name` AS `label`,
|
||||
(
|
||||
cast(`sys_dept`.`pid` AS CHAR charset utf8mb4) COLLATE utf8mb4_general_ci
|
||||
) AS `pid`,
|
||||
IF
|
||||
((`sys_dept`.`sub_count` = 0), 'leaf', 'spine') AS `node_type`,
|
||||
'dept' AS `model_type`,
|
||||
'dept' AS `model_inner_type`,
|
||||
'target' AS `auth_type`,
|
||||
`sys_dept`.`create_by` AS `create_by`,
|
||||
0 AS `level`,
|
||||
0 AS `mode`,
|
||||
'0' AS `data_source_id`
|
||||
FROM `sys_dept`
|
||||
UNION ALL
|
||||
SELECT `datasource`.`id` AS `id`,
|
||||
`datasource`.`name` AS `NAME`,
|
||||
`datasource`.`name` AS `label`,
|
||||
'0' AS `pid`,
|
||||
'leaf' AS `node_type`,
|
||||
'link' AS `model_type`,
|
||||
`datasource`.`type` AS `model_inner_type`,
|
||||
'source' AS `auth_type`,
|
||||
`datasource`.`create_by` AS `create_by`,
|
||||
0 AS `level`,
|
||||
0 AS `mode`,
|
||||
'0' AS `data_source_id`
|
||||
FROM `datasource`
|
||||
UNION ALL
|
||||
SELECT `dataset_group`.`id` AS `id`,
|
||||
`dataset_group`.`name` AS `NAME`,
|
||||
`dataset_group`.`name` AS `label`,
|
||||
IF
|
||||
(isnull(`dataset_group`.`pid`), '0', `dataset_group`.`pid`) AS `pid`,
|
||||
'spine' AS `node_type`,
|
||||
'dataset' AS `model_type`,
|
||||
`dataset_group`.`type` AS `model_inner_type`,
|
||||
'source' AS `auth_type`,
|
||||
`dataset_group`.`create_by` AS `create_by`,
|
||||
`dataset_group`.`level` AS `level`,
|
||||
0 AS `mode`,
|
||||
'0' AS `data_source_id`
|
||||
FROM `dataset_group`
|
||||
UNION ALL
|
||||
SELECT `data_fill_form`.`id` AS `id`,
|
||||
`data_fill_form`.`name` AS `NAME`,
|
||||
`data_fill_form`.`name` AS `label`,
|
||||
(
|
||||
CASE
|
||||
`data_fill_form`.`id`
|
||||
WHEN 'data_fill_list' THEN
|
||||
'0'
|
||||
WHEN 'default_data_fill' THEN
|
||||
'0'
|
||||
ELSE `data_fill_form`.`pid`
|
||||
END
|
||||
) AS `pid`,
|
||||
IF
|
||||
((`data_fill_form`.`node_type` = 'folder'), 'spine', 'leaf') AS `node_type`,
|
||||
'data_fill' AS `model_type`,
|
||||
'form' AS `model_inner_type`,
|
||||
'source' AS `auth_type`,
|
||||
`data_fill_form`.`create_by` AS `create_by`,
|
||||
`data_fill_form`.`level` AS `level`,
|
||||
0 AS `mode`,
|
||||
'0' AS `data_source_id`
|
||||
FROM `data_fill_form`
|
||||
UNION ALL
|
||||
SELECT `dataset_table`.`id` AS `id`,
|
||||
`dataset_table`.`name` AS `NAME`,
|
||||
`dataset_table`.`name` AS `label`,
|
||||
`dataset_table`.`scene_id` AS `pid`,
|
||||
'leaf' AS `node_type`,
|
||||
'dataset' AS `model_type`,
|
||||
`dataset_table`.`type` AS `model_inner_type`,
|
||||
'source' AS `auth_type`,
|
||||
`dataset_table`.`create_by` AS `create_by`,
|
||||
0 AS `level`,
|
||||
`dataset_table`.`mode` AS `mode`,
|
||||
`dataset_table`.`data_source_id` AS `data_source_id`
|
||||
FROM `dataset_table`
|
||||
UNION ALL
|
||||
SELECT `panel_group`.`id` AS `id`,
|
||||
`panel_group`.`name` AS `NAME`,
|
||||
`panel_group`.`name` AS `label`,
|
||||
(
|
||||
CASE
|
||||
`panel_group`.`id`
|
||||
WHEN 'panel_list' THEN
|
||||
'0'
|
||||
WHEN 'default_panel' THEN
|
||||
'0'
|
||||
ELSE `panel_group`.`pid`
|
||||
END
|
||||
) AS `pid`,
|
||||
IF
|
||||
((`panel_group`.`node_type` = 'folder'), 'spine', 'leaf') AS `node_type`,
|
||||
'panel' AS `model_type`,
|
||||
`panel_group`.`panel_type` AS `model_inner_type`,
|
||||
'source' AS `auth_type`,
|
||||
`panel_group`.`create_by` AS `create_by`,
|
||||
0 AS `level`,
|
||||
0 AS `mode`,
|
||||
'0' AS `data_source_id`
|
||||
FROM `panel_group`
|
||||
UNION ALL
|
||||
SELECT `sys_menu`.`menu_id` AS `menu_id`,
|
||||
`sys_menu`.`title` AS `name`,
|
||||
`sys_menu`.`title` AS `label`,
|
||||
`sys_menu`.`pid` AS `pid`,
|
||||
IF
|
||||
((`sys_menu`.`sub_count` > 0), 'spine', 'leaf') AS `node_type`,
|
||||
'menu' AS `model_type`,
|
||||
(
|
||||
CASE
|
||||
`sys_menu`.`type`
|
||||
WHEN 0 THEN
|
||||
'folder'
|
||||
WHEN 1 THEN
|
||||
'menu'
|
||||
WHEN 2 THEN
|
||||
'button'
|
||||
END
|
||||
) AS `model_inner_type`,
|
||||
'source' AS `auth_type`,
|
||||
`sys_menu`.`create_by` AS `create_by`,
|
||||
0 AS `level`,
|
||||
0 AS `mode`,
|
||||
'0' AS `data_source_id`
|
||||
FROM `sys_menu`
|
||||
WHERE ((
|
||||
`sys_menu`.`i_frame` <> 1
|
||||
)
|
||||
OR isnull(`sys_menu`.`i_frame`))
|
||||
UNION ALL
|
||||
SELECT `plugin_sys_menu`.`menu_id` AS `menu_id`,
|
||||
`plugin_sys_menu`.`title` AS `name`,
|
||||
`plugin_sys_menu`.`title` AS `label`,
|
||||
`plugin_sys_menu`.`pid` AS `pid`,
|
||||
IF
|
||||
((`plugin_sys_menu`.`sub_count` > 0), 'spine', 'leaf') AS `node_type`,
|
||||
'menu' AS `model_type`,
|
||||
(
|
||||
CASE
|
||||
`plugin_sys_menu`.`type`
|
||||
WHEN 0 THEN
|
||||
'folder'
|
||||
WHEN 1 THEN
|
||||
'menu'
|
||||
WHEN 2 THEN
|
||||
'button'
|
||||
END
|
||||
) AS `model_inner_type`,
|
||||
'source' AS `auth_type`,
|
||||
`plugin_sys_menu`.`create_by` AS `create_by`,
|
||||
0 AS `level`,
|
||||
0 AS `mode`,
|
||||
'0' AS `data_source_id`
|
||||
FROM `plugin_sys_menu`
|
||||
WHERE ((
|
||||
`plugin_sys_menu`.`i_frame` <> 1
|
||||
)
|
||||
OR isnull(`plugin_sys_menu`.`i_frame`));
|
||||
|
||||
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`,
|
||||
`privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`,
|
||||
`copy_id`)
|
||||
VALUES ('data_fill_grant', 'data_fill', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'system', NULL, NULL, NULL,
|
||||
NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`,
|
||||
`privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`,
|
||||
`copy_id`)
|
||||
VALUES ('data_fill_manage', 'data_fill', 'i18n_auth_manage', 3, 0, 'manage', '基础权限-管理', 'system', NULL, NULL,
|
||||
NULL, NULL);
|
||||
INSERT INTO `sys_auth_detail` (`id`, `auth_id`, `privilege_name`, `privilege_type`, `privilege_value`,
|
||||
`privilege_extend`, `remark`, `create_user`, `create_time`, `update_time`, `copy_from`,
|
||||
`copy_id`)
|
||||
VALUES ('data_fill_use', 'data_fill', 'i18n_auth_use', 1, 0, 'use', '基础权限-使用', 'system', NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `data_fill_commit_log`;
|
||||
create table data_fill_commit_log
|
||||
(
|
||||
id varchar(50) not null
|
||||
primary key,
|
||||
form_id varchar(50) not null,
|
||||
data_id varchar(255) null,
|
||||
operate varchar(50) not null,
|
||||
commit_by varchar(255) not null,
|
||||
commit_time datetime default current_timestamp() null
|
||||
);
|
||||
|
||||
create index data_fill_commit_log_form_id_index
|
||||
on data_fill_commit_log (form_id);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `data_fill_task`;
|
||||
create table data_fill_task
|
||||
(
|
||||
id bigint auto_increment comment '任务ID'
|
||||
primary key,
|
||||
name varchar(255) not null comment '任务名称',
|
||||
form_id varchar(100) not null comment '任务ID',
|
||||
start_time datetime null comment '开始时间',
|
||||
end_time datetime null comment '结束时间',
|
||||
rate_type int(10) not null comment '频率方式',
|
||||
rate_val varchar(255) null comment '频率值',
|
||||
publish_start_time datetime null,
|
||||
publish_end_time datetime null,
|
||||
publish_range_time_type int null,
|
||||
publish_range_time int null,
|
||||
creator bigint not null comment '创建者ID',
|
||||
create_time datetime default current_timestamp() null comment '创建时间',
|
||||
status tinyint(1) default 1 null comment '运行状态',
|
||||
reci_users longtext null comment '接收人账号',
|
||||
role_list longtext null comment '收件角色',
|
||||
org_list longtext null comment '收件组织'
|
||||
)
|
||||
comment '数据填报任务';
|
||||
|
||||
create index data_fill_task_form_id_index
|
||||
on data_fill_task (form_id);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `data_fill_user_task`;
|
||||
create table data_fill_user_task
|
||||
(
|
||||
id varchar(50) not null comment 'ID'
|
||||
primary key,
|
||||
task_id bigint not null comment '任务ID',
|
||||
form_id varchar(100) not null comment '表单ID',
|
||||
value_id varchar(100) null comment '表内值ID',
|
||||
user bigint not null comment '用户ID',
|
||||
start_time datetime null comment '开始时间',
|
||||
end_time datetime null comment '结束时间',
|
||||
finish_time datetime null comment '完成时间'
|
||||
)
|
||||
comment '数据填报用户任务';
|
||||
|
||||
create index data_fill_user_task_form_id_index
|
||||
on data_fill_user_task (form_id);
|
||||
|
||||
create index data_fill_user_task_task_id_index
|
||||
on data_fill_user_task (task_id);
|
||||
|
||||
|
||||
INSERT INTO dataease.sys_auth (id, auth_source, auth_source_type, auth_target, auth_target_type, auth_time, auth_details, auth_user, update_time, copy_from, copy_id) VALUES ('3c790b17-17c0-4ba6-8c8b-b7a6bee57772', '1200', 'menu', '1', 'role', 1711448429062, null, 'admin', null, null, null);
|
||||
INSERT INTO dataease.sys_auth (id, auth_source, auth_source_type, auth_target, auth_target_type, auth_time, auth_details, auth_user, update_time, copy_from, copy_id) VALUES ('8e5404a8-ef7f-407e-b67e-4ff7064fdede', '1200', 'menu', '2', 'role', 1711517966976, null, 'admin', null, null, null);
|
||||
INSERT INTO dataease.sys_auth (id, auth_source, auth_source_type, auth_target, auth_target_type, auth_time, auth_details, auth_user, update_time, copy_from, copy_id) VALUES ('31fa8a67-1513-4297-8a00-c34458a0f760', '1201', 'menu', '1', 'role', 1711448429055, null, 'admin', null, null, null);
|
||||
INSERT INTO dataease.sys_auth (id, auth_source, auth_source_type, auth_target, auth_target_type, auth_time, auth_details, auth_user, update_time, copy_from, copy_id) VALUES ('44d9496a-047c-4fd4-9b20-94eaff01fa0b', '1201', 'menu', '2', 'role', 1711517966965, null, 'admin', null, null, null);
|
||||
INSERT INTO dataease.sys_auth (id, auth_source, auth_source_type, auth_target, auth_target_type, auth_time, auth_details, auth_user, update_time, copy_from, copy_id) VALUES ('16eeb4df-e194-4f5b-9817-d1e48c006036', '1202', 'menu', '2', 'role', 1711448593512, null, 'admin', null, null, null);
|
||||
INSERT INTO dataease.sys_auth (id, auth_source, auth_source_type, auth_target, auth_target_type, auth_time, auth_details, auth_user, update_time, copy_from, copy_id) VALUES ('f4112033-f9bf-4e99-9d8e-9417663a6683', '1202', 'menu', '1', 'role', 1711448429067, null, 'admin', null, null, null);
|
||||
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('31b8e9ef-ebfc-11ee-8430-0242ac140002', '44d9496a-047c-4fd4-9b20-94eaff01fa0b', 'i18n_auth_use', 1, 0, 'use', '基础权限-使用', 'admin', 1711517966000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('31ba695a-ebfc-11ee-8430-0242ac140002', '8e5404a8-ef7f-407e-b67e-4ff7064fdede', 'i18n_auth_use', 1, 0, 'use', '基础权限-使用', 'admin', 1711517966000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('49c77c8d-eb5a-11ee-8430-0242ac140002', '31fa8a67-1513-4297-8a00-c34458a0f760', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1711448429000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('49c81b67-eb5a-11ee-8430-0242ac140002', '3c790b17-17c0-4ba6-8c8b-b7a6bee57772', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1711448429000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('49c8c0b7-eb5a-11ee-8430-0242ac140002', 'f4112033-f9bf-4e99-9d8e-9417663a6683', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1711448429000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('abccfe10-eb5a-11ee-8430-0242ac140002', '16eeb4df-e194-4f5b-9817-d1e48c006036', 'i18n_auth_use', 1, 1, 'use', '基础权限-使用', 'admin', 1711448593000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('31b8e988-ebfc-11ee-8430-0242ac140002', '44d9496a-047c-4fd4-9b20-94eaff01fa0b', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1711517966000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('31ba6902-ebfc-11ee-8430-0242ac140002', '8e5404a8-ef7f-407e-b67e-4ff7064fdede', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1711517966000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('49c77c73-eb5a-11ee-8430-0242ac140002', '31fa8a67-1513-4297-8a00-c34458a0f760', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1711448429000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('49c81b44-eb5a-11ee-8430-0242ac140002', '3c790b17-17c0-4ba6-8c8b-b7a6bee57772', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1711448429000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('49c8c096-eb5a-11ee-8430-0242ac140002', 'f4112033-f9bf-4e99-9d8e-9417663a6683', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1711448429000, null, null, null);
|
||||
INSERT INTO dataease.sys_auth_detail (id, auth_id, privilege_name, privilege_type, privilege_value, privilege_extend, remark, create_user, create_time, update_time, copy_from, copy_id) VALUES ('abccfdbb-eb5a-11ee-8430-0242ac140002', '16eeb4df-e194-4f5b-9817-d1e48c006036', 'i18n_auth_grant', 15, 0, 'grant', '基础权限-授权', 'admin', 1711448593000, null, null, null);
|
||||
|
||||
|
||||
@ -221,6 +221,40 @@
|
||||
timeToLiveSeconds="3600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<!--数据填报缓存-->
|
||||
<cache
|
||||
name="user_data_fill"
|
||||
eternal="false"
|
||||
maxElementsInMemory="100"
|
||||
maxElementsOnDisk="1000"
|
||||
overflowToDisk="true"
|
||||
diskPersistent="true"
|
||||
timeToIdleSeconds="1800"
|
||||
timeToLiveSeconds="3600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<cache
|
||||
name="role_data_fill"
|
||||
eternal="false"
|
||||
maxElementsInMemory="100"
|
||||
maxElementsOnDisk="1000"
|
||||
overflowToDisk="true"
|
||||
diskPersistent="true"
|
||||
timeToIdleSeconds="1800"
|
||||
timeToLiveSeconds="3600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
<cache
|
||||
name="dept_data_fill"
|
||||
eternal="false"
|
||||
maxElementsInMemory="100"
|
||||
maxElementsOnDisk="1000"
|
||||
overflowToDisk="true"
|
||||
diskPersistent="true"
|
||||
timeToIdleSeconds="1800"
|
||||
timeToLiveSeconds="3600"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
/>
|
||||
|
||||
<!--组织授权数据源缓存-->
|
||||
<cache
|
||||
|
||||
@ -173,6 +173,7 @@ SOURCE_TYPE_DRIVER_FILE=DRIVER FILE
|
||||
SOURCE_TYPE_MENU=MENU
|
||||
SOURCE_TYPE_LINK=PUBLIC LINK
|
||||
SOURCE_TYPE_APIKEY=APIKEY
|
||||
SOURCE_TYPE_DATA_FILL_FORM=DATA FILL FORM
|
||||
I18N_OPERATE_TYPE=Operation type
|
||||
I18N_DETAIL=Operation details
|
||||
I18N_USER=Operator
|
||||
@ -237,6 +238,8 @@ I18N_DS_INVALID=Datasource is invalid
|
||||
I18N_DS_INVALID_TABLE=Datasource has invalid tables
|
||||
I18N_ACCOUNT_LOCKED=Account\u3010%s\u3011is locked(Please contact the administrator to unlock or try again in %s minutes)
|
||||
I18N_PANEL_EXIST=The current panel name already exists under this directory
|
||||
I18N_DATA_FILL_FORM_EXIST=The current data filling form name already exists under this directory
|
||||
I18N_DATA_FILL_TASK_EXIST=The current data filling task name already exists under this form
|
||||
I18N_FOlDER_EXIST=The name already exists under this directory
|
||||
I18N_DATASET_GROUP_EXIST=The current dataset grouping name already exists under this directory
|
||||
I18N_NOT_JAR=File is not jar!
|
||||
|
||||
@ -94,7 +94,7 @@ i18n_sql_delete_not_matching=\u589E\u91CF\u5220\u9664 SQL \u7684\u6570\u636E\u52
|
||||
i18n_cst_ds_tb_or_field_deleted=\u81EA\u5B9A\u4E49\u6570\u636E\u96C6\u6240\u5173\u8054\u6570\u636E\u88AB\u5220\u9664\u6216\u5B57\u6BB5\u53D1\u751F\u53D8\u5316\uFF0C\u65E0\u6CD5\u6B63\u5E38\u663E\u793A
|
||||
i18n_no_all_delete_privilege_folder=\u8BE5\u76EE\u5F55\u4E0B\u5B58\u5728\u6CA1\u6709\u7BA1\u7406\u6743\u9650\u6216\u67E5\u770B\u6743\u9650\u7684\u8D44\u6E90\uFF0C\u65E0\u6CD5\u5220\u9664
|
||||
i18n_excel_field_repeat=\u5B58\u5728\u91CD\u590D\u5B57\u6BB5\uFF1A
|
||||
i18n_dont_contain_key=\u5f53\u524d\u7684sql\u4e0d\u5305\u542b\u8fd9\u4e2a\u952e\uff1a
|
||||
i18n_dont_contain_key=\u5F53\u524D\u7684sql\u4E0D\u5305\u542B\u8FD9\u4E2A\u952E\uFF1A
|
||||
i18n_schema_is_empty=\u6570\u636E\u5E93 Schema \u4E3A\u7A7A
|
||||
\u7AD9\u5185\u6D88\u606F=\u6D88\u606F\u4E2D\u5FC3
|
||||
\u6240\u6709\u6D88\u606F=\u6240\u6709\u6D88\u606F
|
||||
@ -173,6 +173,7 @@ SOURCE_TYPE_DRIVER_FILE=\u9A71\u52A8\u6587\u4EF6
|
||||
SOURCE_TYPE_MENU=\u83DC\u5355
|
||||
SOURCE_TYPE_LINK=\u516C\u5171\u94FE\u63A5
|
||||
SOURCE_TYPE_APIKEY=APIKEY
|
||||
SOURCE_TYPE_DATA_FILL_FORM=\u6570\u636E\u586B\u62A5\u8868\u5355
|
||||
I18N_OPERATE_TYPE=\u64CD\u4F5C\u7C7B\u578B
|
||||
I18N_DETAIL=\u64CD\u4F5C\u8BE6\u60C5
|
||||
I18N_USER=\u64CD\u4F5C\u4EBA
|
||||
@ -237,6 +238,8 @@ I18N_DS_INVALID=\u6570\u636E\u6E90\u65E0\u6548
|
||||
I18N_DS_INVALID_TABLE=\u6570\u636E\u6E90\u4E2D\u6709\u65E0\u6548\u7684\u8868
|
||||
I18N_ACCOUNT_LOCKED=\u8D26\u53F7\u3010%s\u3011\u5DF2\u9501\u5B9A(\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u89E3\u9501\u6216%s\u5206\u949F\u540E\u91CD\u8BD5)
|
||||
I18N_PANEL_EXIST=\u5F53\u524D\u4EEA\u8868\u677F\u540D\u79F0\u5728\u8BE5\u76EE\u5F55\u4E0B\u9762\u5DF2\u7ECF\u5B58\u5728
|
||||
I18N_DATA_FILL_FORM_EXIST=\u5F53\u524D\u6570\u636E\u586B\u62A5\u8868\u5355\u540D\u79F0\u5728\u8BE5\u76EE\u5F55\u4E0B\u9762\u5DF2\u7ECF\u5B58\u5728
|
||||
I18N_DATA_FILL_TASK_EXIST=\u5F53\u524D\u6570\u636E\u586B\u62A5\u4EFB\u52A1\u540D\u79F0\u5728\u8BE5\u8868\u5355\u4E0B\u9762\u5DF2\u7ECF\u5B58\u5728
|
||||
I18N_FOlDER_EXIST=\u5F53\u524D\u540D\u79F0\u5728\u8BE5\u76EE\u5F55\u4E0B\u9762\u5DF2\u7ECF\u5B58\u5728
|
||||
I18N_DATASET_GROUP_EXIST=\u5F53\u524D\u6570\u636E\u96C6\u5206\u7EC4\u540D\u79F0\u5728\u8BE5\u76EE\u5F55\u4E0B\u9762\u5DF2\u7ECF\u5B58\u5728
|
||||
I18N_NOT_JAR=\u6587\u4EF6\u4E0D\u662F jar \u5305!
|
||||
@ -268,6 +271,6 @@ I18N_PANEL_PDF_TEMPLATE_WITH_PARAMS=\u9ED8\u8BA4\u6A21\u677F(\u52A0\u4EEA\u8868\
|
||||
I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=\u9ED8\u8BA4\u6A21\u677F(\u53EA\u622A\u56FE)
|
||||
I18n_name_cant_empty=\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\uFF01
|
||||
I18n_del_admin_tips=\u7981\u6B62\u5220\u9664admin\u8D26\u53F7
|
||||
I18N_NO_DRIVER_PERMISSION=\u6ca1\u6709\u6743\u9650\uff01
|
||||
I18N_NO_DRIVER_PERMISSION=\u6CA1\u6709\u6743\u9650\uFF01
|
||||
i18n_field_circular_error=\u5B57\u6BB5\u89E3\u6790\u9519\u8BEF\uFF0C\u53EF\u80FD\u539F\u56E0\uFF1A\u5B57\u6BB5\u5DF2\u5220\u9664\u3001\u8BA1\u7B97\u5B57\u6BB5\u5F15\u7528\u5C42\u7EA7\u8FC7\u6DF1\u3001\u5B58\u5728\u5FAA\u73AF\u5F15\u7528\u7B49\uFF0C\u8BF7\u68C0\u67E5\u8868\u8282\u70B9\u548C\u5B57\u6BB5\u5E76\u91CD\u65B0\u7F16\u8F91\u3002
|
||||
i18n_field_circular_ref=\u5B57\u6BB5\u5B58\u5728\u5FAA\u73AF\u5F15\u7528
|
||||
|
||||
@ -94,7 +94,7 @@ i18n_sql_delete_not_matching=\u589E\u91CF\u522A\u9664 sql \u7684\u6578\u64DA\u52
|
||||
i18n_cst_ds_tb_or_field_deleted=\u81EA\u5B9A\u7FA9\u6578\u64DA\u96C6\u6240\u95DC\u806F\u6578\u64DA\u88AB\u522A\u9664\u6216\u5B57\u6BB5\u767C\u751F\u8B8A\u5316\uFF0C\u7121\u6CD5\u6B63\u5E38\u986F\u793A
|
||||
i18n_no_all_delete_privilege_folder=\u8A72\u76EE\u9304\u4E0B\u5B58\u5728\u6C92\u6709\u7BA1\u7406\u6B0A\u9650\u6216\u67E5\u770B\u6B0A\u9650\u7684\u8CC7\u6E90\uFF0C\u7121\u6CD5\u522A\u9664
|
||||
i18n_excel_field_repeat=\u5B58\u5728\u91CD\u5FA9\u5B57\u6BB5\uFF1A
|
||||
i18n_dont_contain_key=\u7576\u524d\u7684sql\u4e0d\u5305\u542b\u9019\u500b\u9375\uff1a
|
||||
i18n_dont_contain_key=\u7576\u524D\u7684sql\u4E0D\u5305\u542B\u9019\u500B\u9375\uFF1A
|
||||
i18n_schema_is_empty=\u6578\u64DA\u5EAB Schema \u70BA\u7A7A
|
||||
\u7AD9\u5185\u6D88\u606F=\u6D88\u606F\u4E2D\u5FC3
|
||||
\u6240\u6709\u6D88\u606F=\u6240\u6709\u6D88\u606F
|
||||
@ -173,6 +173,7 @@ SOURCE_TYPE_DRIVER_FILE=\u9A45\u52D5\u6587\u4EF6
|
||||
SOURCE_TYPE_MENU=\u83DC\u55AE
|
||||
SOURCE_TYPE_LINK=\u516C\u5171\u93C8\u63A5
|
||||
SOURCE_TYPE_APIKEY=APIKEY
|
||||
SOURCE_TYPE_DATA_FILL_FORM=\u6578\u64DA\u586B\u5831\u8868\u55AE
|
||||
I18N_DRIVER_NOT_DELETE=\u4F7F\u7528\u4E2D\u7684\u9A45\u52D5\u4E0D\u5141\u8A31\u5220\u9664
|
||||
I18N_DRIVER_REPEAT_NAME=\u540D\u7A31\u91CD\u8907
|
||||
I18N_DRIVER_NOT_FOUND=\u672A\u627E\u5230\u9A45\u52D5
|
||||
@ -233,6 +234,8 @@ I18N_DS_INVALID=\u6578\u64DA\u6E90\u7121\u6548
|
||||
I18N_DS_INVALID_TABLE=\u6578\u64DA\u6E90\u4E2D\u6709\u7121\u6548\u7684\u8868
|
||||
I18N_ACCOUNT_LOCKED=\u8CEC\u865F\u3010%s\u3011\u5DF2\u9396\u5B9A(\u8ACB\u806F\u7CFB\u7BA1\u7406\u54E1\u89E3\u9396\u6216%s\u5206\u9418\u5F8C\u91CD\u8A66)
|
||||
I18N_PANEL_EXIST=\u7576\u524D\u5100\u9336\u95C6\u540D\u7A31\u5728\u8A72\u76EE\u9304\u4E0B\u9762\u5DF2\u7D93\u5B58\u5728
|
||||
I18N_DATA_FILL_FORM_EXIST=\u7576\u524D\u6578\u64DA\u586B\u5831\u8868\u55AE\u540D\u7A31\u5728\u8A72\u76EE\u9304\u4E0B\u9762\u5DF2\u7D93\u5B58\u5728
|
||||
I18N_DATA_FILL_TASK_EXIST=\u7576\u524D\u6578\u64DA\u586B\u5831\u4EFB\u52D9\u540D\u7A31\u5728\u8A72\u8868\u55AE\u4E0B\u9762\u5DF2\u7D93\u5B58\u5728
|
||||
I18N_FOlDER_EXIST=\u540D\u7A31\u5728\u8A72\u76EE\u9304\u4E0B\u9762\u5DF2\u7D93\u5B58\u5728
|
||||
I18N_DATASET_GROUP_EXIST=\u7576\u524D\u6578\u64DA\u96C6\u5206\u7D44\u540D\u7A31\u5728\u8A72\u76EE\u9304\u4E0B\u9762\u5DF2\u7D93\u5B58\u5728
|
||||
I18N_NOT_JAR=\u6587\u4EF6\u4E0D\u662F jar \u5305!
|
||||
@ -274,6 +277,6 @@ I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=\u9ED8\u8A8D\u6A21\u677F(\u53EA\u622A\u5716)
|
||||
\u8FB9\u684610=\u908A\u6846 10
|
||||
I18n_name_cant_empty=\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A\uFF01
|
||||
I18n_del_admin_tips=\u7981\u6B62\u522A\u9664admin\u8CEC\u865F
|
||||
I18N_NO_DRIVER_PERMISSION=\u6c92\u6709\u8a31\u53ef\u6b0a\uff01
|
||||
I18N_NO_DRIVER_PERMISSION=\u6C92\u6709\u8A31\u53EF\u6B0A\uFF01
|
||||
i18n_field_circular_error=\u5B57\u6BB5\u89E3\u6790\u932F\u8AA4\uFF0C\u53EF\u80FD\u539F\u56E0\uFF1A\u5B57\u6BB5\u5DF2\u522A\u9664\u3001\u8A08\u7B97\u5B57\u6BB5\u5F15\u7528\u5C64\u7D1A\u904E\u6DF1\u3001\u5B58\u5728\u5FAA\u74B0\u5F15\u7528\u7B49\uFF0C\u8ACB\u6AA2\u67E5\u8868\u7BC0\u9EDE\u548C\u5B57\u6BB5\u4E26\u91CD\u65B0\u7DE8\u8F2F\u3002
|
||||
i18n_field_circular_ref=\u5B57\u6BB5\u5B58\u5728\u5FAA\u74B0\u5F15\u7528
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
"@tinymce/tinymce-vue": "^3.2.8",
|
||||
"axios": "^1.6.1",
|
||||
"core-js": "^2.6.5",
|
||||
"dayjs": "^1.11.10",
|
||||
"echarts": "^5.0.1",
|
||||
"element-resize-detector": "^1.2.3",
|
||||
"element-ui": "2.15.7",
|
||||
@ -73,6 +74,7 @@
|
||||
"svgo": "1.2.2",
|
||||
"tinymce": "^5.8.2",
|
||||
"umy-ui": "^1.1.6",
|
||||
"uuid": "^9.0.1",
|
||||
"vant": "^2.13.2",
|
||||
"vue": "2.6.10",
|
||||
"vue-clipboard2": "0.3.1",
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
const terminal = getQueryVariable('terminal')
|
||||
const attachParams = getQueryVariable('attachParams')
|
||||
const fromLink = getQueryVariable('fromLink')
|
||||
const ticket = getQueryVariable('ticket')
|
||||
const baseUrl = window.location.pathname.replace('link.html', '')
|
||||
let url = baseUrl + "#/delink?link=" + encodeURIComponent(link)
|
||||
if (terminal) {
|
||||
@ -48,6 +49,9 @@
|
||||
if (fromLink) {
|
||||
url += '&fromLink=' + fromLink
|
||||
}
|
||||
if (ticket) {
|
||||
url += '&ticket=' + ticket
|
||||
}
|
||||
window.location.href = url
|
||||
</script>
|
||||
|
||||
|
||||
10
core/frontend/src/api/ai/aiComponent.js
Normal file
10
core/frontend/src/api/ai/aiComponent.js
Normal file
@ -0,0 +1,10 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export async function findBaseParams() {
|
||||
return request({
|
||||
url: '/aiBase/findTargetUrl',
|
||||
method: 'get',
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
@ -50,6 +50,14 @@ export function switchEnablePwd(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function switchEnableTicket(data) {
|
||||
return request({
|
||||
url: 'api/link/enableTicket',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function viewLinkLog(data) {
|
||||
return request({
|
||||
url: 'api/link/viewLog',
|
||||
@ -66,6 +74,28 @@ export function loadGenerate(resourceId) {
|
||||
})
|
||||
}
|
||||
|
||||
export function loadTicketApi(resourceId) {
|
||||
return request({
|
||||
url: 'api/link/currentTicket/' + resourceId,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
export function saveTicketApi(data) {
|
||||
return request({
|
||||
url: 'api/link/saveTicket',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
export function delTicketApi(data) {
|
||||
return request({
|
||||
url: 'api/link/delTicket',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function loadResource(resourceId, userId) {
|
||||
return request({
|
||||
url: 'api/link/resourceDetail/' + resourceId + '/' + userId,
|
||||
|
||||
@ -260,7 +260,7 @@ export default {
|
||||
showPosition: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'NotProvided'
|
||||
default: 'preview'
|
||||
},
|
||||
panelInfo: {
|
||||
type: Object,
|
||||
@ -313,7 +313,7 @@ export default {
|
||||
scaleWidth: '100',
|
||||
scaleHeight: '100',
|
||||
timer: null,
|
||||
componentDataShow: null,
|
||||
componentDataShow: [],
|
||||
mainWidth: '100%',
|
||||
mainHeight: '100%',
|
||||
searchCount: 0,
|
||||
@ -828,26 +828,21 @@ export default {
|
||||
if (this.componentData) {
|
||||
const componentData = deepCopy(this.componentData)
|
||||
componentData.forEach(component => {
|
||||
if (!this.isMainCanvas() && component.type === 'custom' && component.options?.attrs?.selectFirst && this.format(component.style.width, this.scaleWidth) < 80) {
|
||||
// do continue
|
||||
} else {
|
||||
Object.keys(component.style).forEach(key => {
|
||||
if (this.needToChangeHeight.includes(key)) {
|
||||
component.style[key] = this.format(component.style[key], this.scaleHeight)
|
||||
Object.keys(component.style).forEach(key => {
|
||||
if (this.needToChangeHeight.includes(key)) {
|
||||
component.style[key] = this.format(component.style[key], this.scaleHeight)
|
||||
}
|
||||
if (this.needToChangeWidth.includes(key)) {
|
||||
component.style[key] = this.format(component.style[key], this.scaleWidth)
|
||||
}
|
||||
if (this.needToChangeInnerWidth.includes(key)) {
|
||||
if ((key === 'fontSize' || key === 'activeFontSize') && (this.terminal === 'mobile' || ['custom'].includes(component.type))) {
|
||||
// do nothing 移动端字符大小无需按照比例缩放,当前保持不变(包括 v-text 和 过滤组件)
|
||||
} else {
|
||||
component.style[key] = this.formatPoint(component.style[key], this.previewCanvasScale.scalePointWidth)
|
||||
}
|
||||
if (this.needToChangeWidth.includes(key)) {
|
||||
component.style[key] = this.format(component.style[key], this.scaleWidth)
|
||||
}
|
||||
if (this.needToChangeInnerWidth.includes(key)) {
|
||||
if ((key === 'fontSize' || key === 'activeFontSize') && (this.terminal === 'mobile' || ['custom'].includes(component.type))) {
|
||||
// do nothing 移动端字符大小无需按照比例缩放,当前保持不变(包括 v-text 和 过滤组件)
|
||||
} else {
|
||||
component.style[key] = this.formatPoint(component.style[key], this.previewCanvasScale.scalePointWidth)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
const maxWidth = this.canvasStyleData.width * this.scaleWidth / 100
|
||||
if (component.style['width'] > maxWidth) {
|
||||
component.style['width'] = maxWidth
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
:src="element.frameLinks.src"
|
||||
scrolling="auto"
|
||||
frameborder="0"
|
||||
class="main-frame"
|
||||
class="main-frame main-de-iframe "
|
||||
@load="loaded"
|
||||
@error="onError"
|
||||
/>
|
||||
@ -103,6 +103,14 @@ export default {
|
||||
mounted() {
|
||||
bus.$on('frameLinksChange-' + this.element.id, this.frameLinksChange)
|
||||
eventBus.$on('startMoveIn', this.frameLinksChange)
|
||||
window.addEventListener('click', function(event) {
|
||||
const iframes = document.getElementsByClassName('main-de-iframe')
|
||||
if (iframes) {
|
||||
iframes.forEach(function(iframe) {
|
||||
iframe.contentWindow.postMessage('closeFilterComponent', '*')
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
beforeDestroy() {
|
||||
bus.$off('frameLinksChange-' + this.element.id, this.frameLinksChange)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div
|
||||
v-loading="loadingFlag"
|
||||
element-loading-background="rgba(0,0,0,0)"
|
||||
:class="[
|
||||
{
|
||||
['active']: active
|
||||
@ -354,6 +355,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
unReadyList: [],
|
||||
dialogLoading: false,
|
||||
imageDownloading: false,
|
||||
innerRefreshTimer: null,
|
||||
@ -653,6 +655,7 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
bus.$on('tab-canvas-change', this.tabSwitch)
|
||||
bus.$on('resolve-wait-condition', this.resolveWaitCondition)
|
||||
this.bindPluginEvent()
|
||||
},
|
||||
|
||||
@ -674,15 +677,16 @@ export default {
|
||||
bus.$off('onThemeAttrChange', this.optFromBatchSingleProp)
|
||||
bus.$off('clear_panel_linkage', this.clearPanelLinkage)
|
||||
bus.$off('tab-canvas-change', this.tabSwitch)
|
||||
bus.$off('resolve-wait-condition', this.resolveWaitCondition)
|
||||
},
|
||||
created() {
|
||||
this.refId = uuid.v1
|
||||
if (this.element && this.element.propValue && this.element.propValue.viewId) {
|
||||
const group = this.groupFilter(this.filters)
|
||||
const unReadyList = group.unReady
|
||||
this.unReadyList = group.unReady
|
||||
const readyList = group.ready
|
||||
if (unReadyList.length) {
|
||||
Promise.all(this.filters.filter(f => f instanceof Promise)).then(fList => {
|
||||
if (this.unReadyList.length) {
|
||||
Promise.all(this.unReadyList.filter(f => f instanceof Promise)).then(fList => {
|
||||
this.filter.filter = readyList.concat(fList)
|
||||
this.getData(this.element.propValue.viewId, false)
|
||||
})
|
||||
@ -692,6 +696,11 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
resolveWaitCondition(p) {
|
||||
this.unReadyList.filter(f => f instanceof Promise && f.componentId === p.componentId).map(f => {
|
||||
f.cacheObj.cb(p)
|
||||
})
|
||||
},
|
||||
groupFilter(filters) {
|
||||
const result = {
|
||||
ready: [],
|
||||
@ -946,6 +955,7 @@ export default {
|
||||
}
|
||||
if (this.isFirstLoad) {
|
||||
this.element.filters = this.filter.filter?.length ? JSON.parse(JSON.stringify(this.filter.filter)) : []
|
||||
this.$store.commit('setViewInitFilter', this.element)
|
||||
}
|
||||
method(id, this.panelInfo.id, requestInfo).then(response => {
|
||||
try {
|
||||
|
||||
@ -124,7 +124,8 @@ export const customAttrTrans = {
|
||||
'quotaSuffixFontSize'
|
||||
],
|
||||
'label': [
|
||||
'fontSize'
|
||||
'fontSize',
|
||||
'subFontSize'
|
||||
],
|
||||
'tooltip': {
|
||||
'textStyle': ['fontSize']
|
||||
|
||||
@ -179,10 +179,12 @@ export function panelDataPrepare(componentData, componentStyle, callback) {
|
||||
})
|
||||
// 初始化密度为最高密度
|
||||
componentStyle.aidedDesign.matrixBase = 4
|
||||
callback({
|
||||
const result = {
|
||||
'componentData': resetID(componentData),
|
||||
'componentStyle': componentStyle
|
||||
})
|
||||
}
|
||||
store.state.sourceComponentData = deepCopy(result.componentData)
|
||||
callback(result)
|
||||
}
|
||||
|
||||
export function resetID(data) {
|
||||
@ -307,6 +309,8 @@ export function imgUrlTrans(url) {
|
||||
export function getNowCanvasComponentData(canvasId, showPosition) {
|
||||
if (showPosition && (showPosition.includes('email-task') || showPosition.includes('multiplexing'))) {
|
||||
return store.state.previewComponentData.filter(item => item.canvasId === canvasId)
|
||||
} else if (showPosition === 'preview') {
|
||||
return deepCopy(store.state.sourceComponentData.filter(item => item.canvasId === canvasId))
|
||||
} else {
|
||||
return store.state.componentData.filter(item => item.canvasId === canvasId)
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ export default {
|
||||
styleEle.id = `style${this.element.id}`
|
||||
document.querySelector('head').appendChild(styleEle)
|
||||
}
|
||||
styleEle.innerHTML = `#component${this.element.id} .el-input__inner::placeholder {\n color: ${this.element.style.wordColor} \n }`
|
||||
styleEle.innerHTML = `#component${this.element.id}.component-custom .el-input__inner::placeholder {\n color: ${this.element.style.wordColor}b3 \n }`
|
||||
},
|
||||
filterLoaded(p) {
|
||||
this.$emit('filter-loaded', p)
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
class="tree-select-all"
|
||||
><el-checkbox
|
||||
v-model="selectAll"
|
||||
v-customStyle="customStyle"
|
||||
class="is-tree-select"
|
||||
:indeterminate="isIndeterminate"
|
||||
@change="selectAllChange"
|
||||
>{{ $t('dataset.check_all') }}</el-checkbox></p>
|
||||
@ -590,15 +590,14 @@ export default {
|
||||
</script>
|
||||
<style>
|
||||
.el-tree-select .de-select-option {
|
||||
display: none !important;
|
||||
display: none !important;
|
||||
}
|
||||
.tree-select-all {
|
||||
padding: 10px 20px 0 24px;
|
||||
|
||||
}
|
||||
.tree-select-all .el-checkbox__label {
|
||||
color: var(--SelectTreeColor, #606266);
|
||||
}
|
||||
padding: 10px 20px 0 24px;
|
||||
}
|
||||
.tree-select-all .el-checkbox__label {
|
||||
color: var(--SelectTreeColor, #606266) !important;
|
||||
}
|
||||
[aria-disabled='true'] > .el-tree-node__content {
|
||||
color: inherit !important;
|
||||
background: transparent !important;
|
||||
|
||||
@ -19,11 +19,12 @@
|
||||
>
|
||||
<el-checkbox
|
||||
v-model="selectAll"
|
||||
class="is-tree-select"
|
||||
v-customStyle="customStyle"
|
||||
:indeterminate="isIndeterminate"
|
||||
@change="selectAllChange"
|
||||
>
|
||||
<span :style="{ color: `${isConfig ? '#1F2329' : customStyle.wordColor} !important`}">{{ $t('dataset.check_all') }}</span>
|
||||
<span :style="{ color: `${isConfig ? '#1F2329' : customStyle.wordColor}`}">{{ $t('dataset.check_all') }}</span>
|
||||
</el-checkbox>
|
||||
</p>
|
||||
<el-option
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
184
core/frontend/src/components/widget/deWidget/DeRadio.vue
Normal file
184
core/frontend/src/components/widget/deWidget/DeRadio.vue
Normal file
@ -0,0 +1,184 @@
|
||||
<template>
|
||||
<el-radio-group
|
||||
style="height: 40px; line-height: 40px"
|
||||
@change="visualChange"
|
||||
v-model="selectValue"
|
||||
>
|
||||
<template v-for="item in options">
|
||||
<el-radio
|
||||
:key="item.id + 'radio'"
|
||||
:label="item.id"
|
||||
class="is-custom-select"
|
||||
v-if="radioStyle.showStyle === 'single'"
|
||||
:disabled="itemDisabled"
|
||||
>{{ item.text }}</el-radio
|
||||
>
|
||||
<el-radio-button
|
||||
v-else
|
||||
:disabled="itemDisabled"
|
||||
:key="item.id + 'tab'"
|
||||
class="is-custom-select"
|
||||
:label="item.id"
|
||||
>{{ item.text }}</el-radio-button
|
||||
>
|
||||
</template>
|
||||
</el-radio-group>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { uuid } from "vue-uuid";
|
||||
|
||||
export default {
|
||||
name: "DeRadio",
|
||||
model: {
|
||||
prop: "value", // 绑定的值,通过父组件传递
|
||||
event: "update", // 自定义名
|
||||
},
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
require: true,
|
||||
default: uuid.v1(),
|
||||
},
|
||||
radioStyle: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return [];
|
||||
},
|
||||
},
|
||||
value: {
|
||||
type: [String, Number],
|
||||
default: "",
|
||||
},
|
||||
isConfig: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
itemDisabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
newList: [],
|
||||
selectValue: this.value,
|
||||
options: [],
|
||||
defaultFirst: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
maxLength() {
|
||||
return this.radioStyle.showNum || 5;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
this.selectValue = val;
|
||||
},
|
||||
selectValue(val) {
|
||||
this.$emit("update", val);
|
||||
if (!val) {
|
||||
this.resetList();
|
||||
}
|
||||
},
|
||||
maxLength() {
|
||||
this.resetList();
|
||||
},
|
||||
list() {
|
||||
this.resetList();
|
||||
this.$nextTick(() => {
|
||||
this.init();
|
||||
});
|
||||
},
|
||||
radioStyle: {
|
||||
handler() {
|
||||
this.setPlaceholderColor();
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.resetList();
|
||||
this.$nextTick(() => {
|
||||
this.init();
|
||||
this.setPlaceholderColor();
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
let styleEle = document.querySelector(`#radio-style${this.id}`);
|
||||
if (styleEle) {
|
||||
styleEle.parentElement.removeChild(styleEle);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setPlaceholderColor() {
|
||||
let styleEle = document.querySelector(`#radio-style${this.id}`);
|
||||
if (!styleEle) {
|
||||
styleEle = document.createElement("style");
|
||||
styleEle.id = `radio-style${this.id}`;
|
||||
document.querySelector("head").appendChild(styleEle);
|
||||
}
|
||||
styleEle.innerHTML = `#component${this.id} .el-radio-button:not(.is-active) .el-radio-button__inner {\n color: ${this.radioStyle.wordColor}; \n border-color: ${this.radioStyle.brColor}; \n background-color: ${this.radioStyle.innerBgColor}; \n } #component${this.id} .el-radio:not(.is-check) .el-radio__label {\n color: ${this.radioStyle.wordColor}; \n }`;
|
||||
},
|
||||
resetList(arrays) {
|
||||
if (Array.isArray(arrays)) {
|
||||
this.newList = arrays.slice();
|
||||
} else {
|
||||
this.newList = this.list.slice();
|
||||
}
|
||||
this.options = this.newList.slice(0, this.maxLength);
|
||||
},
|
||||
init() {
|
||||
if (this.defaultFirst && this.list.length > 0) {
|
||||
this.selectValue = this.list[0].value;
|
||||
}
|
||||
},
|
||||
visualChange(val) {
|
||||
this.$emit("change", val);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.VisualSelects {
|
||||
.el-scrollbar {
|
||||
position: relative;
|
||||
height: 245px;
|
||||
overflow: inherit;
|
||||
overflow-x: hidden;
|
||||
content-visibility: auto;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
background: #ffffff !important;
|
||||
}
|
||||
|
||||
.el-select-height {
|
||||
width: 1px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.el-select-dropdown__list {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.el-select-dropdown__wrap {
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.select-all {
|
||||
padding: 10px 20px 0 20px;
|
||||
}
|
||||
</style>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user