forked from github/dataease
perf(global): 移除hutool库
This commit is contained in:
parent
613be11209
commit
bf9e54b69b
@ -1,10 +1,10 @@
|
||||
package io.dataease.auth.aop;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.dataease.auth.annotation.DeRateLimiter;
|
||||
import io.dataease.auth.service.DeLimitService;
|
||||
import io.dataease.commons.utils.IPUtils;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
@ -34,8 +34,8 @@ public class DeRateLimiterHandler {
|
||||
DeRateLimiter rateLimiter = AnnotationUtils.findAnnotation(method, DeRateLimiter.class);
|
||||
if (rateLimiter != null) {
|
||||
String key = rateLimiter.key();
|
||||
if (StrUtil.isBlank(key)) {
|
||||
key = method.getDeclaringClass().getName() + StrUtil.DOT + method.getName();
|
||||
if (StringUtils.isBlank(key)) {
|
||||
key = method.getDeclaringClass().getName() + "." + method.getName();
|
||||
}
|
||||
key = key + SEPARATOR + IPUtils.get();
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package io.dataease.auth.aop;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import io.dataease.auth.annotation.SqlInjectValidator;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.KeywordRequest;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
@ -56,7 +56,7 @@ public class SqlInjectAop {
|
||||
}
|
||||
|
||||
private boolean isIllegal(String[] value, List<String> orderList) {
|
||||
if (CollectionUtils.isEmpty(orderList) || ArrayUtil.isEmpty(value)) return false;
|
||||
if (CollectionUtils.isEmpty(orderList) || ArrayUtils.isEmpty(value)) return false;
|
||||
Set<String> wordList = Arrays.stream(value).collect(Collectors.toSet());
|
||||
wordList.add("asc");
|
||||
wordList.add("desc");
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.auth.filter;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
@ -9,6 +8,7 @@ import io.dataease.commons.license.DefaultLicenseService;
|
||||
import io.dataease.commons.license.F2CLicenseResponse;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.web.filter.AccessControlFilter;
|
||||
@ -66,7 +66,7 @@ public class F2CDocFilter extends AccessControlFilter {
|
||||
String authorization = request.getHeader("Authorization");
|
||||
if (StringUtils.isBlank(authorization)) {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if (ArrayUtil.isNotEmpty(cookies)) {
|
||||
if (ArrayUtils.isNotEmpty(cookies)) {
|
||||
Cookie cookie = Arrays.stream(cookies).filter(item -> StringUtils.equals(item.getName(), "Authorization")).findFirst().orElse(null);
|
||||
if (ObjectUtils.isNotEmpty(cookie) && StringUtils.isNotBlank(cookie.getValue())) {
|
||||
authorization = cookie.getValue();
|
||||
|
@ -1,12 +1,12 @@
|
||||
package io.dataease.auth.filter;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.auth.util.LinkUtil;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.plugins.common.base.domain.PanelLink;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.shiro.web.filter.authc.AnonymousFilter;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
@ -26,7 +26,7 @@ public class F2CLinkFilter extends AnonymousFilter {
|
||||
String resourceId = jwt.getClaim("resourceId").asString();
|
||||
Long userId = jwt.getClaim("userId").asLong();
|
||||
PanelLink panelLink = LinkUtil.queryLink(resourceId, userId);
|
||||
if (ObjectUtil.isEmpty(panelLink)) return false;
|
||||
if (ObjectUtils.isEmpty(panelLink)) return false;
|
||||
String pwd;
|
||||
if (!panelLink.getEnablePwd()) {
|
||||
panelLink.setPwd("dataease");
|
||||
|
@ -2,7 +2,10 @@ package io.dataease.commons.utils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BeanUtils {
|
||||
|
||||
@ -65,4 +68,19 @@ public class BeanUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Object> bean2Map(Object bean) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Class<?> aClass = bean.getClass();
|
||||
Field[] fields = aClass.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
result.put(field.getName(), field.get(bean));
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,20 @@
|
||||
package io.dataease.commons.utils;
|
||||
|
||||
import io.dataease.commons.model.excel.ExcelSheetModel;
|
||||
import io.dataease.plugins.common.util.FileUtil;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import io.dataease.commons.model.excel.ExcelSheetModel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
|
||||
public class ExcelUtils {
|
||||
private static final String suffix = ".xlsx";
|
||||
@ -78,10 +75,11 @@ public class ExcelUtils {
|
||||
folderPath += Thread.currentThread().getId() + "/";
|
||||
|
||||
if (!FileUtil.exist(folderPath)) {
|
||||
FileUtil.mkdir(folderPath);
|
||||
new File(folderPath).mkdirs();
|
||||
}
|
||||
File result = new File(folderPath + realFileName.get());
|
||||
BufferedOutputStream outputStream = FileUtil.getOutputStream(result);
|
||||
FileOutputStream fos = new FileOutputStream(result);
|
||||
BufferedOutputStream outputStream = new BufferedOutputStream(fos);
|
||||
try {
|
||||
wb.write(outputStream);
|
||||
} catch (Exception e) {
|
||||
|
@ -1,17 +1,17 @@
|
||||
package io.dataease.commons.utils;
|
||||
|
||||
import static io.dataease.commons.constants.StaticResourceConstants.*;
|
||||
|
||||
import cn.hutool.core.codec.Base64Encoder;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static io.dataease.commons.constants.StaticResourceConstants.*;
|
||||
|
||||
/**
|
||||
* Author: wangjiahao
|
||||
* Date: 2022/4/24
|
||||
@ -19,7 +19,7 @@ import java.io.InputStream;
|
||||
*/
|
||||
public class StaticResourceUtils {
|
||||
|
||||
private final static String FILE_BASE_PATH = USER_HOME+ FILE_SEPARATOR+UPLOAD_URL_PREFIX;
|
||||
private final static String FILE_BASE_PATH = USER_HOME + FILE_SEPARATOR + UPLOAD_URL_PREFIX;
|
||||
|
||||
private static final String FILE_NAME_REGEX_PATTERN = "^[A-Za-z0-9.-]{1,255}$";
|
||||
|
||||
@ -69,12 +69,11 @@ public class StaticResourceUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param imgFile local storage path
|
||||
* @param imgFile local storage path
|
||||
* @return
|
||||
*/
|
||||
public static String getImgFileToBase64(String imgFile) {
|
||||
if(!validateStringFilenameUsingRegex(imgFile)){
|
||||
if (!validateStringFilenameUsingRegex(imgFile)) {
|
||||
DataEaseException.throwException("Illegal File Name");
|
||||
}
|
||||
//Convert the picture file into byte array and encode it with Base64
|
||||
@ -82,7 +81,7 @@ public class StaticResourceUtils {
|
||||
byte[] buffer = null;
|
||||
//Read picture byte array
|
||||
try {
|
||||
inputStream = new FileInputStream(FILE_BASE_PATH+FILE_SEPARATOR+imgFile);
|
||||
inputStream = new FileInputStream(FILE_BASE_PATH + FILE_SEPARATOR + imgFile);
|
||||
int count = 0;
|
||||
while (count == 0) {
|
||||
count = inputStream.available();
|
||||
@ -91,9 +90,9 @@ public class StaticResourceUtils {
|
||||
inputStream.read(buffer);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}finally {
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
// Close InputStream
|
||||
@ -104,10 +103,9 @@ public class StaticResourceUtils {
|
||||
}
|
||||
}
|
||||
// Encode byte array as Base64
|
||||
if(buffer!=null){
|
||||
|
||||
return Base64Encoder.encode(buffer);
|
||||
}else{
|
||||
if (buffer != null) {
|
||||
return Base64Utils.encodeToString(buffer);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.controller.dataset;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
@ -32,6 +31,7 @@ import io.dataease.service.datasource.DatasourceService;
|
||||
import io.dataease.service.engine.EngineService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -235,7 +235,7 @@ public class DataSetTableFieldController {
|
||||
List<Object> results = new ArrayList<>();
|
||||
for (String fieldId : multFieldValuesRequest.getFieldIds()) {
|
||||
List<Object> fieldValues = dataSetFieldService.fieldValues(fieldId, multFieldValuesRequest.getSort(), multFieldValuesRequest.getUserId(), true, false, multFieldValuesRequest.getKeyword());
|
||||
if (CollectionUtil.isNotEmpty(fieldValues)) {
|
||||
if (CollectionUtils.isNotEmpty(fieldValues)) {
|
||||
results.addAll(fieldValues);
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ public class DataSetTableFieldController {
|
||||
List<Object> results = new ArrayList<>();
|
||||
for (String fieldId : multFieldValuesRequest.getFieldIds()) {
|
||||
List<Object> fieldValues = dataSetFieldService.fieldValues(fieldId, multFieldValuesRequest.getUserId(), false, true);
|
||||
if (CollectionUtil.isNotEmpty(fieldValues)) {
|
||||
if (CollectionUtils.isNotEmpty(fieldValues)) {
|
||||
results.addAll(fieldValues);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.job.sechedule.strategy.impl;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
@ -16,6 +15,7 @@ import io.dataease.job.sechedule.strategy.TaskHandler;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskInstance;
|
||||
import io.dataease.plugins.common.util.FileUtil;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.dingtalk.dto.entity.DingtalkMsgResult;
|
||||
import io.dataease.plugins.xpack.dingtalk.service.DingtalkXpackService;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.map.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.map.dto.entity.AreaEntity;
|
||||
@ -10,6 +9,8 @@ import io.dataease.map.utils.MapUtils;
|
||||
import io.dataease.plugins.common.base.domain.AreaMappingGlobal;
|
||||
import io.dataease.plugins.common.base.domain.AreaMappingGlobalExample;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.FileUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@ -50,7 +51,7 @@ public class MapService {
|
||||
return areaEntity.getChildren();
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(areaEntity.getChildren())) {
|
||||
if (CollectionUtils.isNotEmpty(areaEntity.getChildren())) {
|
||||
List<AreaEntity> areaEntities = entitiesByPid(areaEntity.getChildren(), pid);
|
||||
if (null != areaEntities) {
|
||||
return areaEntities;
|
||||
@ -96,7 +97,7 @@ public class MapService {
|
||||
Set<String> sets = nodes.stream().flatMap(node -> codesByNode(node, pLevel).stream()).collect(Collectors.toSet());
|
||||
sets.forEach(code -> {
|
||||
String countryCode = code.substring(0, 3);
|
||||
String path = rootGeoPath + "/full/" + countryCode + "/" + code +"_full.json";
|
||||
String path = rootGeoPath + "/full/" + countryCode + "/" + code + "_full.json";
|
||||
if (FileUtil.exist(path)) {
|
||||
FileUtil.del(path);
|
||||
}
|
||||
@ -107,19 +108,19 @@ public class MapService {
|
||||
Set<String> sets = new TreeSet<>();
|
||||
|
||||
if (pLevel == 2) {
|
||||
if(StringUtils.isNotBlank(node.getProvinceCode())) sets.add(node.getProvinceCode());
|
||||
if(StringUtils.isNotBlank(node.getCityCode())) sets.add(node.getCityCode());
|
||||
if(StringUtils.isNotBlank(node.getCountyCode())) sets.add(node.getCountyCode());
|
||||
if (StringUtils.isNotBlank(node.getProvinceCode())) sets.add(node.getProvinceCode());
|
||||
if (StringUtils.isNotBlank(node.getCityCode())) sets.add(node.getCityCode());
|
||||
if (StringUtils.isNotBlank(node.getCountyCode())) sets.add(node.getCountyCode());
|
||||
} else if (pLevel == 3) {
|
||||
if(StringUtils.isNotBlank(node.getCityCode())) sets.add(node.getCityCode());
|
||||
if(StringUtils.isNotBlank(node.getCountyCode())) sets.add(node.getCountyCode());
|
||||
if (StringUtils.isNotBlank(node.getCityCode())) sets.add(node.getCityCode());
|
||||
if (StringUtils.isNotBlank(node.getCountyCode())) sets.add(node.getCountyCode());
|
||||
} else if (pLevel == 4) {
|
||||
if(StringUtils.isNotBlank(node.getCountyCode())) sets.add(node.getCountyCode());
|
||||
if (StringUtils.isNotBlank(node.getCountyCode())) sets.add(node.getCountyCode());
|
||||
} else {
|
||||
if(StringUtils.isNotBlank(node.getCountryCode())) sets.add(node.getCountryCode());
|
||||
if(StringUtils.isNotBlank(node.getProvinceCode())) sets.add(node.getProvinceCode());
|
||||
if(StringUtils.isNotBlank(node.getCityCode())) sets.add(node.getCityCode());
|
||||
if(StringUtils.isNotBlank(node.getCountyCode())) sets.add(node.getCountyCode());
|
||||
if (StringUtils.isNotBlank(node.getCountryCode())) sets.add(node.getCountryCode());
|
||||
if (StringUtils.isNotBlank(node.getProvinceCode())) sets.add(node.getProvinceCode());
|
||||
if (StringUtils.isNotBlank(node.getCityCode())) sets.add(node.getCityCode());
|
||||
if (StringUtils.isNotBlank(node.getCountyCode())) sets.add(node.getCountyCode());
|
||||
}
|
||||
return sets;
|
||||
}
|
||||
@ -132,7 +133,7 @@ public class MapService {
|
||||
AreaMappingGlobalExample example = new AreaMappingGlobalExample();
|
||||
AreaMappingGlobal curRoot = new AreaMappingGlobal();
|
||||
List<AreaMappingGlobal> nodes = null;
|
||||
if(pLevel == 0) {
|
||||
if (pLevel == 0) {
|
||||
nodes = MapUtils.selectByExample(example);
|
||||
MapUtils.deleteByExample(example);
|
||||
delFileByNodes(nodes, pLevel);
|
||||
@ -147,7 +148,7 @@ public class MapService {
|
||||
MapUtils.deleteByExample(example);
|
||||
example.clear();
|
||||
example.createCriteria().andCountryCodeEqualTo(pCode);
|
||||
if (!MapUtils.exampleExist(example) && CollectionUtil.isNotEmpty(nodes)) {
|
||||
if (!MapUtils.exampleExist(example) && CollectionUtils.isNotEmpty(nodes)) {
|
||||
AreaMappingGlobal template = nodes.get(0);
|
||||
curRoot.setCountryCode(template.getCountryCode());
|
||||
curRoot.setCountryName(template.getCountryName());
|
||||
@ -163,7 +164,7 @@ public class MapService {
|
||||
example.clear();
|
||||
example.createCriteria().andProvinceCodeEqualTo(pCode);
|
||||
|
||||
if (!MapUtils.exampleExist(example) && CollectionUtil.isNotEmpty(nodes)) {
|
||||
if (!MapUtils.exampleExist(example) && CollectionUtils.isNotEmpty(nodes)) {
|
||||
AreaMappingGlobal template = nodes.get(0);
|
||||
curRoot.setCountryCode(template.getCountryCode());
|
||||
curRoot.setCountryName(template.getCountryName());
|
||||
@ -180,7 +181,7 @@ public class MapService {
|
||||
example.clear();
|
||||
example.createCriteria().andProvinceCodeEqualTo(pCode);
|
||||
|
||||
if (!MapUtils.exampleExist(example) && CollectionUtil.isNotEmpty(nodes)) {
|
||||
if (!MapUtils.exampleExist(example) && CollectionUtils.isNotEmpty(nodes)) {
|
||||
AreaMappingGlobal template = nodes.get(0);
|
||||
curRoot.setCountryCode(template.getCountryCode());
|
||||
curRoot.setCountryName(template.getCountryName());
|
||||
@ -205,14 +206,15 @@ public class MapService {
|
||||
DataEaseException.throwException("only json file supported");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveMapNode(MapNodeRequest request, MultipartFile file) throws Exception{
|
||||
public void saveMapNode(MapNodeRequest request, MultipartFile file) throws Exception {
|
||||
validateFile(file);
|
||||
String pCode = request.getPcode();
|
||||
Integer plevel = request.getPlevel();
|
||||
String code = request.getCode();
|
||||
|
||||
if(StringUtils.isBlank(code)) {
|
||||
if (StringUtils.isBlank(code)) {
|
||||
String newAreaCode = generateAreaCode(pCode);
|
||||
request.setCode(newAreaCode);
|
||||
}
|
||||
@ -222,19 +224,17 @@ public class MapService {
|
||||
|
||||
if (plevel == 1) {
|
||||
example.createCriteria().andCountryCodeEqualTo(code);
|
||||
}
|
||||
else if (plevel == 2) {
|
||||
} else if (plevel == 2) {
|
||||
example.createCriteria().andCountryCodeEqualTo(pCode).andProvinceCodeEqualTo(code);
|
||||
}
|
||||
else if (plevel == 3) {
|
||||
} else if (plevel == 3) {
|
||||
example.createCriteria().andProvinceCodeEqualTo(pCode).andCityCodeEqualTo(code);
|
||||
}else if (plevel == 4) {
|
||||
} else if (plevel == 4) {
|
||||
example.createCriteria().andCityCodeEqualTo(pCode).andCountyCodeEqualTo(code);
|
||||
} else {
|
||||
DataEaseException.throwException("只支持3级行政区");
|
||||
}
|
||||
List<AreaMappingGlobal> lists = MapUtils.selectByExample(example);
|
||||
if (CollectionUtil.isNotEmpty(lists)) {
|
||||
if (CollectionUtils.isNotEmpty(lists)) {
|
||||
DataEaseException.throwException("区域代码已存在");
|
||||
}
|
||||
|
||||
@ -243,27 +243,26 @@ public class MapService {
|
||||
if (plevel == 1) {
|
||||
pExample.createCriteria().andCountryCodeIsNull().andProvinceCodeIsNull().andCityCodeIsNull().andCountyCodeIsNull();
|
||||
List<AreaMappingGlobal> existLists = MapUtils.selectByExample(pExample);
|
||||
if (CollectionUtil.isNotEmpty(existLists)) {
|
||||
if (CollectionUtils.isNotEmpty(existLists)) {
|
||||
AreaMappingGlobal node = existLists.get(0);
|
||||
node.setCountryCode(code);
|
||||
node.setCountryName(request.getName());
|
||||
MapUtils.update(node);
|
||||
}else {
|
||||
} else {
|
||||
AreaMappingGlobal node = new AreaMappingGlobal();
|
||||
node.setCountryCode(code);
|
||||
node.setCountryName(request.getName());
|
||||
MapUtils.addNode(node);
|
||||
}
|
||||
}
|
||||
else if (plevel == 2) {
|
||||
} else if (plevel == 2) {
|
||||
pExample.createCriteria().andCountryCodeEqualTo(pCode).andProvinceCodeIsNull().andCityCodeIsNull().andCountyCodeIsNull();
|
||||
List<AreaMappingGlobal> existLists = MapUtils.selectByExample(pExample);
|
||||
if (CollectionUtil.isNotEmpty(existLists)) {
|
||||
if (CollectionUtils.isNotEmpty(existLists)) {
|
||||
AreaMappingGlobal node = existLists.get(0);
|
||||
node.setProvinceCode(code);
|
||||
node.setProvinceName(request.getName());
|
||||
MapUtils.update(node);
|
||||
}else {
|
||||
} else {
|
||||
AreaMappingGlobal country = country(pCode);
|
||||
AreaMappingGlobal node = new AreaMappingGlobal();
|
||||
node.setCountryCode(pCode);
|
||||
@ -272,16 +271,15 @@ public class MapService {
|
||||
node.setProvinceName(request.getName());
|
||||
MapUtils.addNode(node);
|
||||
}
|
||||
}
|
||||
else if (plevel == 3) {
|
||||
} else if (plevel == 3) {
|
||||
pExample.createCriteria().andProvinceCodeEqualTo(pCode).andCityCodeIsNull();
|
||||
List<AreaMappingGlobal> existLists = MapUtils.selectByExample(pExample);
|
||||
if (CollectionUtil.isNotEmpty(existLists)) {
|
||||
if (CollectionUtils.isNotEmpty(existLists)) {
|
||||
AreaMappingGlobal node = existLists.get(0);
|
||||
node.setCityCode(code);
|
||||
node.setCityName(request.getName());
|
||||
MapUtils.update(node);
|
||||
}else {
|
||||
} else {
|
||||
AreaMappingGlobal province = province(pCode);
|
||||
AreaMappingGlobal node = new AreaMappingGlobal();
|
||||
node.setCountryCode(province.getCountryCode());
|
||||
@ -295,12 +293,12 @@ public class MapService {
|
||||
} else if (plevel == 4) {
|
||||
pExample.createCriteria().andCountryCodeEqualTo(pCode).andCountyCodeIsNull();
|
||||
List<AreaMappingGlobal> existLists = MapUtils.selectByExample(pExample);
|
||||
if (CollectionUtil.isNotEmpty(existLists)) {
|
||||
if (CollectionUtils.isNotEmpty(existLists)) {
|
||||
AreaMappingGlobal node = existLists.get(0);
|
||||
node.setCountyCode(code);
|
||||
node.setCountyName(request.getName());
|
||||
MapUtils.update(node);
|
||||
}else {
|
||||
} else {
|
||||
AreaMappingGlobal city = city(pCode);
|
||||
AreaMappingGlobal node = new AreaMappingGlobal();
|
||||
node.setCountryCode(city.getCountryCode());
|
||||
@ -320,7 +318,7 @@ public class MapService {
|
||||
CacheUtils.removeAll("sys_map_areas_global");
|
||||
}
|
||||
|
||||
public void uploadMapFile(MultipartFile file, String areaCode) throws Exception{
|
||||
public void uploadMapFile(MultipartFile file, String areaCode) throws Exception {
|
||||
|
||||
String countryCode = areaCode.substring(0, 3);
|
||||
String dir = rootGeoPath + "full/" + countryCode + "/";
|
||||
@ -329,7 +327,7 @@ public class MapService {
|
||||
fileDir.mkdirs();
|
||||
}
|
||||
|
||||
String targetPath = dir + areaCode+"_full.json";
|
||||
String targetPath = dir + areaCode + "_full.json";
|
||||
File target = new File(targetPath);
|
||||
file.transferTo(target);
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package io.dataease.map.service;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.plugins.common.base.domain.ChartView;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewExample;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.mapper.ChartViewMapper;
|
||||
import io.dataease.plugins.common.util.FileUtil;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -72,7 +73,7 @@ public class MapTransferService {
|
||||
String chinaRootPath = geoPath + FULL_KEY + FILE_SEPARATOR;
|
||||
File chinaRootDir = new File(chinaRootPath);
|
||||
File[] files = chinaRootDir.listFiles();
|
||||
if (ArrayUtil.isEmpty(files)) return;
|
||||
if (ArrayUtils.isEmpty(files)) return;
|
||||
Map<String, List<File>> listMap = Arrays.stream(files).filter(FileUtil::isFile).collect(Collectors.groupingBy(this::fileType));
|
||||
if (ObjectUtils.isEmpty(listMap)) return;
|
||||
moveFiles(listMap, BORDER_KEY);
|
||||
|
@ -1,40 +0,0 @@
|
||||
package io.dataease.map.utils;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import io.dataease.map.dto.request.MapRequest;
|
||||
import io.dataease.map.dto.response.MapResponse;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class HttpUtils {
|
||||
|
||||
private static final String url = "https://restapi.amap.com/v3/config/district";
|
||||
|
||||
|
||||
private static final String key = "a5d10d5d05a3a0868cec67c4d66cf025";
|
||||
private static final String extensions = "all";
|
||||
private static final Integer subdistrict = 0;
|
||||
|
||||
|
||||
|
||||
public static MapResponse get(MapRequest request){
|
||||
request.setKey(key);
|
||||
request.setExtensions(extensions);
|
||||
request.setSubdistrict(subdistrict);
|
||||
Map<String, Object> param = BeanUtil.beanToMap(request);
|
||||
|
||||
String s = HttpUtil.get(url, param);
|
||||
MapResponse mapResponse = JSONUtil.toBean(s, MapResponse.class);
|
||||
return mapResponse;
|
||||
}
|
||||
|
||||
public static MapResponse get(String code) {
|
||||
MapRequest request = MapRequest.builder().keywords(code).build();
|
||||
return get(request);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.map.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.dataease.map.dto.entity.AreaEntity;
|
||||
import io.dataease.map.dto.entity.Constants;
|
||||
import io.dataease.plugins.common.base.domain.AreaMapping;
|
||||
@ -84,7 +83,7 @@ public class MapUtils {
|
||||
String city_code = map.getCityCode();
|
||||
String county_code = map.getCountyCode();
|
||||
// 是否是跨级直辖
|
||||
Boolean isCrossLevel = StrUtil.equals(province_code, city_code) && !StrUtil.equals(province_code, "156710000");
|
||||
Boolean isCrossLevel = StringUtils.equals(province_code, city_code) && !StringUtils.equals(province_code, "156710000");
|
||||
|
||||
if (!countryMap.containsKey(country_code)) {
|
||||
String country_name = map.getCountryName();
|
||||
@ -154,7 +153,7 @@ public class MapUtils {
|
||||
county_code = formatCode(county_code);
|
||||
|
||||
// 是否是跨级直辖
|
||||
Boolean isCrossLevel = StrUtil.equals(province_code, city_code) && !StrUtil.equals(province_code, "710000");
|
||||
Boolean isCrossLevel = StringUtils.equals(province_code, city_code) && !StringUtils.equals(province_code, "710000");
|
||||
|
||||
if (!provinceMap.containsKey(province_code)) {
|
||||
String province_name = map.get(Constants.PROVINCE_NAME).toString();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
@ -14,6 +13,7 @@ import io.dataease.i18n.Translator;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
import io.dataease.service.system.SystemParameterService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jasig.cas.client.authentication.AttributePrincipal;
|
||||
import org.jasig.cas.client.util.AssertionHolder;
|
||||
@ -67,7 +67,7 @@ public class CasServer {
|
||||
sysUserEntity = authUserService.getCasUserByName(name);
|
||||
}
|
||||
if (null == sysUserEntity) {
|
||||
String s = RandomUtil.randomString(6);
|
||||
String s = RandomStringUtils.random(6);
|
||||
String email = s + "@xxx.com";
|
||||
sysUserService.validateCasUser(name);
|
||||
sysUserService.saveCASUser(name, email);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.dataease.auth.annotation.DeLog;
|
||||
@ -30,6 +29,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -190,7 +190,7 @@ public class XDeptServer {
|
||||
@PostMapping("/unBindUser")
|
||||
public void unBindUser(@RequestBody XpackDeptBindRequest request) {
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
if (CollectionUtil.isEmpty(request.getUserIds())) {
|
||||
if (CollectionUtils.isEmpty(request.getUserIds())) {
|
||||
DataEaseException.throwException("userIds can not be empty");
|
||||
}
|
||||
request.getUserIds().forEach(userId -> {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.dataease.auth.annotation.DeRateLimiter;
|
||||
@ -21,6 +20,7 @@ import io.dataease.plugins.xpack.email.dto.response.XpackTaskInstanceDTO;
|
||||
import io.dataease.plugins.xpack.email.service.EmailXpackService;
|
||||
import io.dataease.service.ScheduleService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
@ -180,7 +180,7 @@ public class XEmailTaskServer {
|
||||
Object object = future.get();
|
||||
if (ObjectUtils.isNotEmpty(object)) {
|
||||
bytes = (byte[]) object;
|
||||
if (ArrayUtil.isNotEmpty(bytes)) {
|
||||
if (ArrayUtils.isNotEmpty(bytes)) {
|
||||
String fileName = request.getPanelId() + ".pdf";
|
||||
ByteArrayResource bar = new ByteArrayResource(bytes);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@ -218,7 +218,7 @@ public class XEmailTaskServer {
|
||||
Object object = future.get();
|
||||
if (ObjectUtils.isNotEmpty(object)) {
|
||||
bytes = (byte[]) object;
|
||||
if (ArrayUtil.isNotEmpty(bytes)) {
|
||||
if (ArrayUtils.isNotEmpty(bytes)) {
|
||||
String fileName = request.getPanelId() + ".jpeg";
|
||||
ByteArrayResource bar = new ByteArrayResource(bytes);
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
@ -18,8 +18,8 @@ import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.datasource.entity.Status;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import io.dataease.commons.utils.HttpClientConfig;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.plugins.common.util.HttpClientConfig;
|
||||
import io.dataease.plugins.common.util.HttpClientUtil;
|
||||
import io.dataease.controller.request.datasource.ApiDefinition;
|
||||
import io.dataease.controller.request.datasource.ApiDefinitionRequest;
|
||||
|
||||
|
@ -2,8 +2,8 @@ package io.dataease.provider.datasource;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParser;
|
||||
import io.dataease.commons.utils.HttpClientConfig;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.plugins.common.util.HttpClientConfig;
|
||||
import io.dataease.plugins.common.util.HttpClientUtil;
|
||||
import io.dataease.controller.request.datasource.es.EsResponse;
|
||||
import io.dataease.controller.request.datasource.es.Request;
|
||||
import io.dataease.controller.request.datasource.es.RequestWithCursor;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.service.chart;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
@ -66,6 +65,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.service.chart;
|
||||
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import io.dataease.commons.model.PluginViewSetImpl;
|
||||
@ -33,6 +32,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
@ -232,7 +232,7 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService {
|
||||
Method method = declaredMethods[i];
|
||||
if (StringUtils.equals(method.getName(), methodName)) {
|
||||
method.setAccessible(true);
|
||||
return ReflectUtil.invoke(queryProvider, method, args);
|
||||
return ReflectionUtils.invokeMethod(method, queryProvider, args);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -240,11 +240,10 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService {
|
||||
|
||||
private Object execProviderMethod(QueryProvider queryProvider, String methodName, Object... args) {
|
||||
Method[] declaredMethods = queryProvider.getClass().getDeclaredMethods();
|
||||
for (int i = 0; i < declaredMethods.length; i++) {
|
||||
Method method = declaredMethods[i];
|
||||
for (Method method : declaredMethods) {
|
||||
if (StringUtils.equals(method.getName(), methodName)) {
|
||||
method.setAccessible(true);
|
||||
return ReflectUtil.invoke(queryProvider, method, args);
|
||||
return ReflectionUtils.invokeMethod(method, queryProvider, args);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -1,16 +1,13 @@
|
||||
package io.dataease.service.chart.build;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import io.dataease.dto.chart.FilterParamTO;
|
||||
import io.dataease.service.chart.FilterBuildTemplate;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("numberRangeWidget")
|
||||
public class NumberRangeBuild extends FilterBuildTemplate {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.dataease.service.chart.build;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.controller.dataset.DataSetTableFieldController;
|
||||
import io.dataease.controller.request.dataset.MultFieldValuesRequest;
|
||||
@ -74,7 +74,7 @@ public class SelectBuild extends FilterBuildTemplate {
|
||||
MultFieldValuesRequest request = new MultFieldValuesRequest();
|
||||
request.setFieldIds(Arrays.stream(attrs.get("fieldId").toString().split(",")).collect(Collectors.toList()));
|
||||
if (ObjectUtils.isNotEmpty(attrs.get("sort"))) {
|
||||
DeSortDTO sort = BeanUtil.copyProperties(attrs.get("sort"), DeSortDTO.class);
|
||||
DeSortDTO sort = BeanUtils.copyBean(new DeSortDTO(), attrs.get("sort"));
|
||||
request.setSort(sort);
|
||||
}
|
||||
List<Object> list = null;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package io.dataease.service.chart.util;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import io.dataease.controller.request.chart.ChartDrillRequest;
|
||||
import io.dataease.dto.chart.*;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.xpack.auth.dto.request.ColumnPermissionItem;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -1049,7 +1049,7 @@ public class ChartDataBuild {
|
||||
Map<String, Object> map = transTableNormal(fields, null, data, desensitizationList);
|
||||
List<Map<String, Object>> tableRow = (List<Map<String, Object>>) map.get("tableRow");
|
||||
final int xEndIndex = detailIndex;
|
||||
Map<String, List<String[]>> groupDataList = detailData.stream().collect(Collectors.groupingBy(item -> ArrayUtil.join(ArrayUtil.sub(item, 0, xEndIndex), "-de-", "(", ")")));
|
||||
Map<String, List<String[]>> groupDataList = detailData.stream().collect(Collectors.groupingBy(item -> StringUtils.join(ArrayUtils.subarray(item, 0, xEndIndex), "-de-", "(", ")")));
|
||||
|
||||
tableRow.forEach(row -> {
|
||||
String key = xAxis.stream().map(x -> String.format(format, row.get(x.getDataeaseName()).toString())).collect(Collectors.joining("-de-"));
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.service.dataset;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import io.dataease.commons.constants.ParamConstants;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
@ -14,6 +13,7 @@ import io.dataease.plugins.common.base.domain.DatasetTableTaskLogExample;
|
||||
import io.dataease.plugins.common.base.mapper.DatasetTableTaskLogMapper;
|
||||
import io.dataease.plugins.common.base.mapper.DatasetTableTaskMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.GlobalDateUtils;
|
||||
import io.dataease.service.system.SystemParameterService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -79,8 +79,12 @@ public class DataSetTableTaskLogService {
|
||||
String[] row = new String[5];
|
||||
row[0] = item.getName();
|
||||
row[1] = item.getDatasetName();
|
||||
row[2] = DateUtil.formatDateTime(new Date(item.getStartTime()));
|
||||
row[3] = item.getEndTime() != null ? DateUtil.formatDateTime(new Date(item.getEndTime())) : "";
|
||||
try {
|
||||
row[2] = GlobalDateUtils.getTimeString(item.getStartTime());
|
||||
row[3] = item.getEndTime() != null ? GlobalDateUtils.getTimeString(item.getEndTime()) : "";
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
row[4] = Translator.get("I18N_TASK_LOG_" + item.getStatus().toUpperCase());
|
||||
return row;
|
||||
}).collect(Collectors.toList());
|
||||
|
@ -1,7 +1,5 @@
|
||||
package io.dataease.service.dataset.impl.direct;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.model.BaseTreeNode;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
@ -27,7 +25,8 @@ import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.service.dataset.*;
|
||||
import io.dataease.service.datasource.DatasourceService;
|
||||
import io.dataease.service.engine.EngineService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -81,15 +80,14 @@ public class DirectFieldService implements DataSetFieldService {
|
||||
|
||||
@Override
|
||||
public List<Object> chineseSort(List<Object> list, DeSortDTO sortDTO) throws Exception {
|
||||
if (ObjectUtils.isEmpty(sortDTO) || CollectionUtil.isEmpty(list)) return list;
|
||||
if (ObjectUtils.isEmpty(sortDTO) || CollectionUtils.isEmpty(list)) return list;
|
||||
String sort = sortDTO.getSort();
|
||||
if (!StringUtils.equals(sort, "chinese")) {
|
||||
return list;
|
||||
}
|
||||
String id = sortDTO.getId();
|
||||
String sortStr = StringUtils.equalsIgnoreCase("chineseDesc", id) ? "desc" : "asc";
|
||||
|
||||
return CollectionUtil.sort(list, (v1, v2) -> {
|
||||
list.sort((v1, v2) -> {
|
||||
Collator instance = Collator.getInstance(Locale.CHINESE);
|
||||
if (ObjectUtils.isEmpty(v1) || ObjectUtils.isEmpty(v2)) return 0;
|
||||
if (StringUtils.equals("desc", sortStr)) {
|
||||
@ -97,6 +95,7 @@ public class DirectFieldService implements DataSetFieldService {
|
||||
}
|
||||
return instance.compare(v1, v2);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@ -225,7 +224,7 @@ public class DirectFieldService implements DataSetFieldService {
|
||||
}
|
||||
Set<String> pkSet = new HashSet<>();
|
||||
if (CollectionUtils.isNotEmpty(rows) && existExtSortField && originSize > 0) {
|
||||
rows = rows.stream().map(row -> ArrayUtil.sub(row, 0, originSize)).collect(Collectors.toList());
|
||||
rows = rows.stream().map(row -> ArrayUtils.subarray(row, 0, originSize)).collect(Collectors.toList());
|
||||
}
|
||||
List<BaseTreeNode> treeNodes = rows.stream().map(row -> buildTreeNode(row, pkSet)).flatMap(Collection::stream).collect(Collectors.toList());
|
||||
List tree = TreeUtils.mergeDuplicateTree(treeNodes, TreeUtils.DEFAULT_ROOT);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.service.datasource;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
@ -17,6 +16,7 @@ import io.dataease.plugins.datasource.entity.JdbcConfiguration;
|
||||
import io.dataease.plugins.datasource.provider.DefaultJdbcProvider;
|
||||
import io.dataease.plugins.datasource.provider.ExtendedJdbcClassLoader;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -81,7 +81,7 @@ public class DriverService {
|
||||
}
|
||||
DeDriverExample example = new DeDriverExample();
|
||||
example.createCriteria().andNameEqualTo(deDriver.getName());
|
||||
if(CollectionUtil.isNotEmpty(deDriverMapper.selectByExampleWithBLOBs(example))){
|
||||
if(CollectionUtils.isNotEmpty(deDriverMapper.selectByExampleWithBLOBs(example))){
|
||||
throw new RuntimeException(Translator.get("I18N_DRIVER_REPEAT_NAME"));
|
||||
}
|
||||
deDriver.setCreateTime(System.currentTimeMillis());
|
||||
@ -147,7 +147,7 @@ public class DriverService {
|
||||
|
||||
DeDriverDetailsExample deDriverDetailsExample = new DeDriverDetailsExample();
|
||||
deDriverDetailsExample.createCriteria().andDeDriverIdEqualTo(driverId).andFileNameEqualTo(filename);
|
||||
if(CollectionUtil.isNotEmpty(deDriverDetailsMapper.selectByExample(deDriverDetailsExample))){
|
||||
if(CollectionUtils.isNotEmpty(deDriverDetailsMapper.selectByExample(deDriverDetailsExample))){
|
||||
throw new Exception("A file with the same name already exists:" + filename);
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,8 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.HttpClientConfig;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.plugins.common.util.HttpClientConfig;
|
||||
import io.dataease.plugins.common.util.HttpClientUtil;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.dto.datasource.DorisConfiguration;
|
||||
import io.dataease.dto.datasource.MysqlConfiguration;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package io.dataease.service.kettle;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.utils.HttpClientConfig;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.plugins.common.util.HttpClientConfig;
|
||||
import io.dataease.plugins.common.util.HttpClientUtil;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.dto.KettleDTO;
|
||||
import io.dataease.plugins.common.base.domain.DeEngine;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.service.panel;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
@ -33,12 +32,14 @@ import io.dataease.plugins.common.base.domain.*;
|
||||
import io.dataease.plugins.common.base.mapper.*;
|
||||
import io.dataease.plugins.common.constants.DeTypeConstants;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.HttpClientUtil;
|
||||
import io.dataease.service.chart.ChartViewService;
|
||||
import io.dataease.service.dataset.DataSetGroupService;
|
||||
import io.dataease.service.dataset.DataSetTableService;
|
||||
import io.dataease.service.staticResource.StaticResourceService;
|
||||
import io.dataease.service.sys.SysAuthService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
|
||||
@ -46,7 +47,6 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.pentaho.di.core.util.UUIDUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -685,7 +685,7 @@ public class PanelGroupService {
|
||||
|
||||
Boolean mergeHead = false;
|
||||
ViewDetailField[] detailFields = request.getDetailFields();
|
||||
if (ArrayUtil.isNotEmpty(detailFields)) {
|
||||
if (ArrayUtils.isNotEmpty(detailFields)) {
|
||||
cellStyle.setBorderTop(BorderStyle.THIN);
|
||||
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
@ -1,16 +1,16 @@
|
||||
package io.dataease.service.staticResource;
|
||||
|
||||
import cn.hutool.core.codec.Base64Decoder;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.utils.FileUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.StaticResourceUtils;
|
||||
import io.dataease.controller.request.resource.StaticResourceRequest;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ -93,7 +93,7 @@ public class StaticResourceService {
|
||||
} else {
|
||||
if (StringUtils.isNotEmpty(content)) {
|
||||
Files.createFile(uploadPath);
|
||||
FileCopyUtils.copy(Base64Decoder.decode(content), Files.newOutputStream(uploadPath));
|
||||
FileCopyUtils.copy(Base64Utils.decodeFromString(content), Files.newOutputStream(uploadPath));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -103,7 +103,7 @@ public class StaticResourceService {
|
||||
|
||||
public Map<String, String> findResourceAsBase64(StaticResourceRequest resourceRequest) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
if (CollectionUtil.isNotEmpty(resourceRequest.getResourcePathList())) {
|
||||
if (CollectionUtils.isNotEmpty(resourceRequest.getResourcePathList())) {
|
||||
for (String path : resourceRequest.getResourcePathList()) {
|
||||
String value = StaticResourceUtils.getImgFileToBase64(path.substring(path.lastIndexOf("/") + 1, path.length()));
|
||||
result.put(path, value);
|
||||
|
@ -1,13 +1,8 @@
|
||||
package io.dataease.service.sys;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.DeFileUtils;
|
||||
import io.dataease.commons.utils.IPUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.dto.MyPluginDTO;
|
||||
import io.dataease.ext.ExtSysPluginMapper;
|
||||
import io.dataease.i18n.Translator;
|
||||
@ -16,6 +11,7 @@ import io.dataease.plugins.common.base.domain.MyPlugin;
|
||||
import io.dataease.plugins.common.base.mapper.MyPluginMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.KeywordRequest;
|
||||
import io.dataease.plugins.common.util.FileUtil;
|
||||
import io.dataease.plugins.config.LoadjarUtil;
|
||||
import io.dataease.plugins.entity.PluginOperate;
|
||||
import io.dataease.service.datasource.DatasourceService;
|
||||
@ -84,7 +80,7 @@ public class PluginService {
|
||||
//2.解压目标文件dest 得到plugin.json和jar
|
||||
String folder = pluginDir + "folder/";
|
||||
try {
|
||||
ZipUtil.unzip(dest.getAbsolutePath(), folder);
|
||||
ZipUtils.unZipIt(dest.getAbsolutePath(), folder);
|
||||
} catch (Exception e) {
|
||||
DeFileUtils.deleteFile(pluginDir + "temp/");
|
||||
DeFileUtils.deleteFile(folder);
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.service.sys.log;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.commons.constants.ParamConstants;
|
||||
@ -20,6 +19,7 @@ import io.dataease.plugins.common.base.domain.SysLogExample;
|
||||
import io.dataease.plugins.common.base.domain.SysLogWithBLOBs;
|
||||
import io.dataease.plugins.common.base.mapper.SysLogMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.GlobalDateUtils;
|
||||
import io.dataease.service.system.SystemParameterService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@ -265,7 +265,12 @@ public class LogService {
|
||||
row[1] = logManager.detailInfo(item);
|
||||
row[2] = item.getNickName();
|
||||
row[3] = item.getIp();
|
||||
row[4] = DateUtil.formatDateTime(new Date(item.getTime()));
|
||||
// row[4] = DateUtil.formatDateTime(new Date(item.getTime()));
|
||||
try {
|
||||
row[4] = GlobalDateUtils.getTimeString(item.getTime());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return row;
|
||||
}).collect(Collectors.toList());
|
||||
String[] headArr = {"操作类型", "详情", "用户", "IP地址", "时间"};
|
||||
|
@ -1,8 +1,6 @@
|
||||
package io.dataease.service.system;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import io.dataease.commons.constants.ParamConstants;
|
||||
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.commons.utils.EncryptUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
@ -13,6 +11,7 @@ import io.dataease.plugins.common.base.domain.SystemParameterExample;
|
||||
import io.dataease.plugins.common.base.mapper.SystemParameterMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
@ -85,7 +84,7 @@ public class EmailService {
|
||||
|
||||
|
||||
public void sendPdfWithFiles(String to, String title, String content, byte[] bytes, List<File> files) {
|
||||
if (ArrayUtil.isEmpty(bytes)) {
|
||||
if (ArrayUtils.isEmpty(bytes)) {
|
||||
send(to, title, content);
|
||||
return;
|
||||
}
|
||||
@ -118,7 +117,7 @@ public class EmailService {
|
||||
if (StringUtils.isBlank(to))
|
||||
return;
|
||||
|
||||
if (ArrayUtil.isEmpty(bytes)) {
|
||||
if (ArrayUtils.isEmpty(bytes)) {
|
||||
send(to, title, content);
|
||||
return;
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package io.dataease.service.templateMarket;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.utils.HttpClientConfig;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.plugins.common.util.HttpClientConfig;
|
||||
import io.dataease.plugins.common.util.HttpClientUtil;
|
||||
import io.dataease.controller.request.templateMarket.TemplateMarketSearchRequest;
|
||||
import io.dataease.controller.sys.response.BasicInfo;
|
||||
import io.dataease.dto.panel.PanelTemplateFileDTO;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.dataease.service.wizard;
|
||||
|
||||
import io.dataease.commons.utils.HttpClientConfig;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.plugins.common.util.HttpClientConfig;
|
||||
import io.dataease.plugins.common.util.HttpClientUtil;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
|
@ -7,6 +7,13 @@
|
||||
<groupId>io.dataease</groupId>
|
||||
<version>${dataease.version}</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>dataease-plugin-common</artifactId>
|
||||
|
@ -1,15 +1,16 @@
|
||||
package io.dataease.plugins.common.util;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import io.dataease.plugins.common.constants.datasource.SQLConstants;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.io.ResolverUtil;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@ -33,6 +34,10 @@ public class ConstantsUtil {
|
||||
return SQLConstantsCache;
|
||||
}
|
||||
|
||||
public static Object getFieldValue(Class<?> classz, String key) {
|
||||
return ReflectionUtils.getField(Objects.requireNonNull(ReflectionUtils.findField(classz, key)), null);
|
||||
}
|
||||
|
||||
public static String constantsValue(String dsType, String constantKey) {
|
||||
String[] mysqlTreaties = {"mariadb", "ds_doris", "TiDB", "StarRocks"};
|
||||
if (Stream.of(mysqlTreaties).collect(Collectors.toList()).contains(dsType)) {
|
||||
@ -44,9 +49,9 @@ public class ConstantsUtil {
|
||||
List<Class> allSQLConstantsClass = ConstantsUtil.getAllSQLConstants();
|
||||
for (int i = 0; i < allSQLConstantsClass.size(); i++) {
|
||||
Class classz = allSQLConstantsClass.get(i);
|
||||
Object fieldValue = ReflectUtil.getFieldValue(classz, ConstantsUtil.TYPE_KEY_FIELD);
|
||||
Object fieldValue = getFieldValue(classz, ConstantsUtil.TYPE_KEY_FIELD);
|
||||
if (ObjectUtils.isNotEmpty(fieldValue) && StringUtils.equals(dsType, fieldValue.toString())) {
|
||||
result = ReflectUtil.getFieldValue(classz, constantKey);
|
||||
result = getFieldValue(classz, constantKey);
|
||||
return ObjectUtils.isNotEmpty(result) ? result.toString() : null;
|
||||
}
|
||||
}
|
||||
@ -56,9 +61,9 @@ public class ConstantsUtil {
|
||||
for (ModuleClassLoader moduleClassLoader : ClassloaderResponsity.getInstance().getAllClassLoader()) {
|
||||
Thread.currentThread().setContextClassLoader(moduleClassLoader);
|
||||
for (Class<? extends Class<?>> scanConstant : scanConstants("io.dataease.plugins.datasource", SQLConstants.class)) {
|
||||
Object fieldValue = ReflectUtil.getFieldValue(scanConstant, ConstantsUtil.TYPE_KEY_FIELD);
|
||||
Object fieldValue = getFieldValue(scanConstant, ConstantsUtil.TYPE_KEY_FIELD);
|
||||
if (ObjectUtils.isNotEmpty(fieldValue) && StringUtils.equals(dsType, fieldValue.toString())) {
|
||||
result = ReflectUtil.getFieldValue(scanConstant, constantKey);
|
||||
result = getFieldValue(scanConstant, constantKey);
|
||||
return ObjectUtils.isNotEmpty(result) ? result.toString() : null;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,93 @@
|
||||
package io.dataease.plugins.common.util;
|
||||
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FileUtil {
|
||||
|
||||
public static byte[] readBytes(String path) {
|
||||
File file = new File(path);
|
||||
if (!file.exists() || !file.isFile()) {
|
||||
DataEaseException.throwException("文件不存在");
|
||||
}
|
||||
byte[] bytes = null;
|
||||
try (FileInputStream fis = new FileInputStream(file);
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
|
||||
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = fis.read(buffer)) != -1) {
|
||||
bos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
bytes = bos.toByteArray();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static String getSuffix(String fileName) {
|
||||
return fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String name = "test.text";
|
||||
System.out.println(getSuffix(name));
|
||||
System.out.println(getPrefix(name));
|
||||
|
||||
String dirPath = "/opt/dataease/plugins/default";
|
||||
List<String> strings = listFileNames(dirPath);
|
||||
assert strings != null;
|
||||
strings.forEach(System.out::println);
|
||||
}
|
||||
|
||||
public static boolean exist(String path) {
|
||||
return new File(path).exists();
|
||||
}
|
||||
|
||||
public static List<String> listFileNames(String dirPath){
|
||||
File file = new File(dirPath);
|
||||
if (!file.exists()) return null;
|
||||
File[] files = file.listFiles();
|
||||
assert files != null;
|
||||
return Arrays.stream(files).map(File::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static String getPrefix(String fileName) {
|
||||
return fileName.substring(0, fileName.lastIndexOf("."));
|
||||
}
|
||||
|
||||
public static void del(File file) {
|
||||
if (!file.exists()) return;
|
||||
file.delete();
|
||||
}
|
||||
|
||||
public static void del(String path) {
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFile(File file) {
|
||||
return file.isFile();
|
||||
}
|
||||
|
||||
public static void move(File file, File target, boolean replace) {
|
||||
if (!file.exists()) return;
|
||||
try {
|
||||
Files.move(file.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package io.dataease.plugins.common.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GlobalDateUtils {
|
||||
|
||||
public static final String DATE_PATTERM = "yyyy-MM-dd";
|
||||
public static final String TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
|
||||
public static Date getDate(String dateString) throws Exception {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERM);
|
||||
return dateFormat.parse(dateString);
|
||||
}
|
||||
public static Date getTime(String timeString) throws Exception {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_PATTERN);
|
||||
return dateFormat.parse(timeString);
|
||||
}
|
||||
|
||||
public static String getDateString(Date date) throws Exception {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERM);
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
public static String formatDate(Date date) {
|
||||
try {
|
||||
return getDateString(date);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDateString(long timeStamp) throws Exception {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERM);
|
||||
return dateFormat.format(timeStamp);
|
||||
}
|
||||
|
||||
public static String getTimeString(Date date) throws Exception {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_PATTERN);
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
public static String getTimeString(long timeStamp) throws Exception {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_PATTERN);
|
||||
return dateFormat.format(timeStamp);
|
||||
}
|
||||
|
||||
public static String getTimeStr(long timeStamp) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(TIME_PATTERN);
|
||||
return dateFormat.format(timeStamp);
|
||||
}
|
||||
|
||||
|
||||
public static Date dateSum (Date date,int countDays){
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DAY_OF_MONTH,countDays);
|
||||
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取入参日期所在周的周一周末日期。 日期对应的时间为当日的零点
|
||||
*
|
||||
* @return Map<String, String>(2); key取值范围:firstTime/lastTime
|
||||
*/
|
||||
public static Map<String, Date> getWeedFirstTimeAndLastTime(Date date) {
|
||||
Map<String, Date> returnMap = new HashMap<>();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
//Calendar默认一周的开始是周日。业务需求从周一开始算,所以要"+1"
|
||||
int weekDayAdd = 1;
|
||||
|
||||
try {
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.DAY_OF_WEEK, calendar.getActualMinimum(Calendar.DAY_OF_WEEK));
|
||||
calendar.add(Calendar.DAY_OF_MONTH,weekDayAdd);
|
||||
|
||||
//第一天的时分秒是 00:00:00 这里直接取日期,默认就是零点零分
|
||||
Date thisWeekFirstTime = getDate(getDateString(calendar.getTime()));
|
||||
|
||||
calendar.clear();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.DAY_OF_WEEK, calendar.getActualMaximum(Calendar.DAY_OF_WEEK));
|
||||
calendar.add(Calendar.DAY_OF_MONTH,weekDayAdd);
|
||||
|
||||
//最后一天的时分秒应当是23:59:59。 处理方式是增加一天计算日期再-1
|
||||
calendar.add(Calendar.DAY_OF_MONTH,1);
|
||||
Date nextWeekFirstDay = getDate(getDateString(calendar.getTime()));
|
||||
Date thisWeekLastTime = getTime(getTimeString(nextWeekFirstDay.getTime()-1));
|
||||
|
||||
returnMap.put("firstTime", thisWeekFirstTime);
|
||||
returnMap.put("lastTime", thisWeekLastTime);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return returnMap;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取当天的起始时间Date
|
||||
* @param time 指定日期 例: 2020-12-13 06:12:42
|
||||
* @return 当天起始时间 例: 2020-12-13 00:00:00
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Date getDayStartTime(Date time) throws Exception {
|
||||
return getDate(getDateString(time));
|
||||
}
|
||||
}
|
@ -1,17 +1,18 @@
|
||||
package io.dataease.plugins.common.util;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
public class GlobalFileUtil {
|
||||
@ -27,16 +28,25 @@ public class GlobalFileUtil {
|
||||
private static final String SPLITOR = "-de-";
|
||||
|
||||
public static String upload(byte[] bytes, String suffix) {
|
||||
String dateStr = DateUtil.formatDate(new Date());
|
||||
String formatRoot = formatRoot();
|
||||
String dirPath = formatRoot + dateStr;
|
||||
if (!FileUtil.exist(dirPath)) {
|
||||
FileUtil.mkdir(dirPath);
|
||||
String dateStr = null;
|
||||
try {
|
||||
dateStr = GlobalDateUtils.getDateString(new Date());
|
||||
String formatRoot = formatRoot();
|
||||
String dirPath = formatRoot + dateStr;
|
||||
File dirFile = new File(dirPath);
|
||||
if (!dirFile.exists()) {
|
||||
dirFile.mkdirs();
|
||||
}
|
||||
String fileId = fileIdByDate(dateStr);
|
||||
String filePath = formatRoot + dateStr + "/" + fileId + "." + suffix;
|
||||
File file = new File(filePath);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(bytes);
|
||||
fos.close();
|
||||
return fileId;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String fileId = fileIdByDate(dateStr);
|
||||
String filePath = formatRoot + dateStr + "/" + fileId + "." + suffix;
|
||||
FileUtil.writeBytes(bytes, filePath);
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public static ResponseEntity<byte[]> showPicture(String fileId) {
|
||||
@ -71,9 +81,9 @@ public class GlobalFileUtil {
|
||||
}
|
||||
|
||||
private static String fileIdByDate(String dateStr) {
|
||||
dateStr = StringUtils.isBlank(dateStr) ? DateUtil.formatDate(new Date()) : dateStr;
|
||||
dateStr = StringUtils.isBlank(dateStr) ? GlobalDateUtils.formatDate(new Date()) : dateStr;
|
||||
|
||||
String uuid = IdUtil.fastUUID();
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
return dateStr + SPLITOR + uuid;
|
||||
}
|
||||
|
||||
@ -93,8 +103,8 @@ public class GlobalFileUtil {
|
||||
return filePath;
|
||||
}
|
||||
List<String> fileNames = FileUtil.listFileNames(dirPath);
|
||||
for (int i = 0; i < fileNames.size(); i++) {
|
||||
String fileName = fileNames.get(i);
|
||||
assert fileNames != null;
|
||||
for (String fileName : fileNames) {
|
||||
String prefix = FileUtil.getPrefix(fileName);
|
||||
if (StringUtils.equals(fileId, prefix)) {
|
||||
return dirPath + "/" + fileName;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package io.dataease.commons.utils;
|
||||
package io.dataease.plugins.common.util;
|
||||
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.config.RequestConfig.Builder;
|
@ -1,5 +1,6 @@
|
||||
package io.dataease.commons.utils;
|
||||
package io.dataease.plugins.common.util;
|
||||
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
@ -16,17 +17,22 @@ import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.mime.HttpMultipartMode;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.entity.mime.content.FileBody;
|
||||
import org.apache.http.entity.mime.content.StringBody;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
import org.apache.http.ssl.SSLContextBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -64,6 +70,7 @@ public class HttpClientUtil {
|
||||
throw new RuntimeException("HttpClient构建失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get http请求
|
||||
*
|
||||
@ -199,14 +206,82 @@ public class HttpClientUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getResponseStr(HttpResponse response, HttpClientConfig config) throws Exception{
|
||||
if(response.getStatusLine().getStatusCode() >= 400){
|
||||
private static String getResponseStr(HttpResponse response, HttpClientConfig config) throws Exception {
|
||||
if (response.getStatusLine().getStatusCode() >= 400) {
|
||||
String msg = EntityUtils.toString(response.getEntity(), config.getCharset());
|
||||
if(StringUtils.isEmpty(msg)){
|
||||
if (StringUtils.isEmpty(msg)) {
|
||||
msg = "StatusCode: " + response.getStatusLine().getStatusCode();
|
||||
}
|
||||
throw new Exception(msg);
|
||||
}
|
||||
return EntityUtils.toString(response.getEntity(), config.getCharset());
|
||||
}
|
||||
|
||||
|
||||
public static String postFile(String fileServer, File file, Map<String, String> param, HttpClientConfig config) {
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost postRequest = new HttpPost(fileServer);
|
||||
if (config == null) {
|
||||
config = new HttpClientConfig();
|
||||
}
|
||||
Map<String, String> header = config.getHeader();
|
||||
if (MapUtils.isNotEmpty(header)) {
|
||||
for (String key : header.keySet()) {
|
||||
postRequest.addHeader(key, header.get(key));
|
||||
}
|
||||
}
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
|
||||
builder.setCharset(StandardCharsets.UTF_8);
|
||||
FileBody fileBody = new FileBody(file);
|
||||
builder.addPart(file.getName(), fileBody);
|
||||
if (param != null) {
|
||||
for (Map.Entry<String, String> entry : param.entrySet()) {
|
||||
|
||||
StringBody stringBody = new StringBody(entry.getValue(), ContentType.TEXT_PLAIN.withCharset("utf-8"));
|
||||
builder.addPart(entry.getKey(), stringBody);
|
||||
}
|
||||
}
|
||||
try {
|
||||
postRequest.setEntity(builder.build());
|
||||
return getResponseStr(httpClient.execute(postRequest), config);
|
||||
} catch (Exception e) {
|
||||
logger.error("HttpClient查询失败", e);
|
||||
throw new RuntimeException("HttpClient查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String postFile(String fileServer, byte[] bytes, String fileName, Map<String, String> param, HttpClientConfig config) {
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost postRequest = new HttpPost(fileServer);
|
||||
if (config == null) {
|
||||
config = new HttpClientConfig();
|
||||
}
|
||||
Map<String, String> header = config.getHeader();
|
||||
if (MapUtils.isNotEmpty(header)) {
|
||||
for (String key : header.keySet()) {
|
||||
postRequest.addHeader(key, header.get(key));
|
||||
}
|
||||
}
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
|
||||
builder.setCharset(StandardCharsets.UTF_8);
|
||||
builder.addBinaryBody(fileName, bytes);
|
||||
|
||||
if (param != null) {
|
||||
for (Map.Entry<String, String> entry : param.entrySet()) {
|
||||
StringBody stringBody = new StringBody(entry.getValue(), ContentType.TEXT_PLAIN.withCharset("utf-8"));
|
||||
builder.addPart(entry.getKey(), stringBody);
|
||||
}
|
||||
}
|
||||
try {
|
||||
postRequest.setEntity(builder.build());
|
||||
return getResponseStr(httpClient.execute(postRequest), config);
|
||||
} catch (Exception e) {
|
||||
logger.error("HttpClient查询失败", e);
|
||||
throw new RuntimeException("HttpClient查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -90,11 +90,6 @@
|
||||
<artifactId>antlr-complete</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
|
Loading…
Reference in New Issue
Block a user