mirror of
https://gitee.com/anji-plus/report.git
synced 2026-02-02 09:27:47 +08:00
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,4 +7,3 @@ target
|
||||
dist
|
||||
logs
|
||||
cache
|
||||
build
|
||||
|
||||
@@ -3,7 +3,7 @@ FROM eclipse-temurin:8-jre
|
||||
RUN mkdir -p /opt/aj-report/logs
|
||||
|
||||
WORKDIR /opt/aj-report
|
||||
|
||||
COPY ../../build/aj-report-1.3.0.RELEASE /opt/aj-report
|
||||
unzip build/aj-report-*.zip ./build
|
||||
COPY build/aj-report-1.3.0.RELEASE /opt/aj-report
|
||||
|
||||
CMD /opt/aj-report/bin/start.sh && tail -f /opt/aj-report/logs/aj-report.log
|
||||
@@ -72,7 +72,7 @@
|
||||
- [Jdk] 1.8
|
||||
|
||||
### 后端
|
||||
|
||||
- [aj-gaea](https://gitee.com/anji-plus/gaea) 低代码平台+spring微服务组件.
|
||||
- [Spring Boot2.3.5.RELEASE](https://spring.io/projects/spring-boot/): Spring Boot是一款开箱即用框架,让我们的Spring应用变的更轻量化、更快的入门。
|
||||
在主程序执行main函数就可以运行。你也可以打包你的应用为jar并通过使用java -jar来运行你的Web应用;
|
||||
- [Mybatis-plus3.3.2](https://mp.baomidou.com/): MyBatis-plus(简称 MP)是一个 MyBatis (opens new window) 的增强工具。
|
||||
|
||||
19
build.sh
19
build.sh
@@ -11,23 +11,28 @@ echo "build web"
|
||||
cd $BuildDir/report-ui
|
||||
echo "npm install"
|
||||
npm install
|
||||
echo ""
|
||||
if [ $? -ne 0 ]; then
|
||||
npm install --registry=https://mirrors.cloud.tencent.com/npm/
|
||||
fi
|
||||
echo "cp echarts map js"
|
||||
cp -r node_modules_echarts_need/* node_modules/echarts/
|
||||
echo "npm run build"
|
||||
npm run build:prod
|
||||
|
||||
echo "publish web to springboot src/main/resources/static"
|
||||
rm -rf $BuildDir/report-core/src/main/resources/static
|
||||
mkdir -p $BuildDir/report-core/src/main/resources/static
|
||||
mv $BuildDir/report-ui/dist/* $BuildDir/report-core/src/main/resources/static/
|
||||
if [ ! -e "$BuildDir/report-ui/dist" ];then
|
||||
echo "no build dist exist,web-build-failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
cp -r $BuildDir/report-ui/dist/* $BuildDir/report-core/src/main/resources/static/
|
||||
echo "build springboot"
|
||||
cd $BuildDir/report-core
|
||||
echo "mvn clean"
|
||||
mvn clean
|
||||
echo ""
|
||||
echo "mvn package"
|
||||
mvn package -Dmaven.test.skip=true
|
||||
echo "mvn clean package"
|
||||
mvn clean package -Dmaven.test.skip=true
|
||||
|
||||
echo "zip finish in build dir"
|
||||
if [ ! -d "$BuildDir/build" ]; then
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
## 注意事项
|
||||
|
||||
- 本次版本必须更新bootstrap.yml配置文件
|
||||
- 特别注意,1.5版本开始,node版本最低使用V16版本。
|
||||
- 之前版本更新至本版本时,可能会遇到图表不显示静态、动态数据,需对该图表重新配置;如果已对旧版本进行二次开发,请谨慎更新。<br>
|
||||
跨版本更新可查对应版本的[releases](https://gitee.com/anji-plus/report/releases)。<br>
|
||||
|
||||
|
||||
## v1.4.2更新至1.5.0
|
||||
|
||||
- 1、下载node16
|
||||
- 2、删除node_modules
|
||||
- 2、删除node_modules文件夹
|
||||
- 3、清缓存,执行 npm cache clean --force
|
||||
- 4、使用node16,执行 npm install
|
||||
|
||||
### nvm工具
|
||||
|
||||
用来管理多个node版本,不会的跟这个文档尝试。
|
||||
https://blog.csdn.net/i_for/article/details/135060019
|
||||
|
||||
### 镜像源
|
||||
|
||||
- 查看当前源配置
|
||||
npm config get registry
|
||||
- 淘宝源
|
||||
@@ -30,21 +32,22 @@ https://blog.csdn.net/i_for/article/details/135060019
|
||||
- 网易源
|
||||
npm config set registry https://mirrors.163.com/npm/
|
||||
|
||||
## 1.5版本开始前端编译注意事项
|
||||
|
||||
## 1.5前端编译注意事项
|
||||
前端目录:report-ui/node_modules_echarts_need/
|
||||
执行完npm install后需要将map文件夹拷贝到node_modules/echarts/文件夹下,
|
||||
因为echarts v5.0之后的版本不在包含map文件夹
|
||||
|
||||
前端目录:report-ui/node_modules_echarts_need/ <br>
|
||||
执行完npm install后需要将node_modules_echarts_need目录下map文件夹整体拷贝到node_modules/echarts/文件夹下,
|
||||
因为echarts v5.0之后的版本不在包含map文件夹 <br>
|
||||

|
||||
|
||||
## 版本变化
|
||||
- 1、node: 14 -> 16
|
||||
- 2、echarts: 4.9.0 -> 5.5.1
|
||||
- 3、element-ui: 2.9.2 -> 2.15.14
|
||||
- 4、vue: 2.6.11 -> 2.7.16
|
||||
- 5、移除node-sass
|
||||
- 其他请看package.json
|
||||
|
||||
- 1、spring-boot: 2.3.5 -> 2.7.14
|
||||
- 2、node: 14 -> 16
|
||||
- 3、echarts: 4.9.0 -> 5.5.1
|
||||
- 4、element-ui: 2.9.2 -> 2.15.14
|
||||
- 5、vue: 2.6.11 -> 2.7.16
|
||||
- 6、移除node-sass
|
||||
- 前端其他版本请看package.json
|
||||
|
||||
## 新增
|
||||
|
||||
@@ -52,27 +55,30 @@ https://blog.csdn.net/i_for/article/details/135060019
|
||||
- 2、配置文件增加时区配置
|
||||
- 3、报表分享增加显示报表名称
|
||||
- 4、新增柱线图-单坐标
|
||||
|
||||
- 5、新增使用druid1.2.0
|
||||
|
||||
## 优化
|
||||
|
||||
- 1、大屏图表-文本组件换行符默认不开启
|
||||
- 2、数据集查询参数-高级规则切换优化
|
||||
- 3、大屏图表-提示语优化
|
||||
- 4、大屏图表-数值设定调整
|
||||
- 3、大屏图表-提示语配置项优化
|
||||
- 4、大屏图表-数值设定配置项优化
|
||||
- 5、大屏图表-散点图半重做
|
||||
- 6、大屏图表-饼图系列调整
|
||||
- 7、大屏图表-百分比图调整
|
||||
- 8、大屏图片-地图系列-增加广东地图js
|
||||
- 9、大屏数据集切换将清空原先图表属性
|
||||
- 10、散点图优化
|
||||
|
||||
## 修复
|
||||
- 1、分享链接下Excel导出异常的问题
|
||||
|
||||
- 1、修复分享链接下Excel导出异常的问题
|
||||
- 2、修复滚动文本联动不生效的问题
|
||||
- 3、修复数据集复制对应的查询参数只复制了一个的问题
|
||||
|
||||
## 其他
|
||||
|
||||
- 1、文档更新
|
||||
- 2、ele样式调整
|
||||
|
||||
## 示例数据
|
||||
|
||||
|
||||
BIN
doc/docs/picture/releases/img.png
Normal file
BIN
doc/docs/picture/releases/img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.5.RELEASE</version>
|
||||
<version>2.7.14</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
@@ -26,6 +26,16 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
<version>3.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-context</artifactId>
|
||||
<version>3.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
@@ -38,18 +48,11 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-to-slf4j</artifactId>
|
||||
<version>2.15.0</version>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.15.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
@@ -66,12 +69,6 @@
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-context</artifactId>
|
||||
<version>2.2.6.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
@@ -81,7 +78,7 @@
|
||||
<dependency>
|
||||
<groupId>com.anji-plus</groupId>
|
||||
<artifactId>spring-boot-gaea</artifactId>
|
||||
<version>2.0.5.RELEASE</version>
|
||||
<version>2.9.4.RELEASE</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -97,15 +94,22 @@
|
||||
<dependency>
|
||||
<groupId>com.anji-plus</groupId>
|
||||
<artifactId>spring-boot-starter-gaea-oss</artifactId>
|
||||
<version>2.0.5.RELEASE</version>
|
||||
<version>2.9.4.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.9.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
@@ -114,7 +118,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
@@ -137,7 +141,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.10</version>
|
||||
<version>1.18.34</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
@@ -185,7 +189,6 @@
|
||||
<artifactId>xmlworker</artifactId>
|
||||
<version>5.5.13</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<developers>
|
||||
@@ -233,11 +236,12 @@
|
||||
<nonFilteredFileExtension>woff2</nonFilteredFileExtension>
|
||||
</nonFilteredFileExtensions>
|
||||
</configuration>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<!--<version>3.3.0</version>-->
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.anjiplus.template.gaea.business.base;
|
||||
|
||||
import com.anji.plus.gaea.curd.entity.GaeaBaseEntity;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
import com.anji.plus.gaea.curd.controller.GaeaBaseController;
|
||||
import com.anji.plus.gaea.curd.dto.BaseDTO;
|
||||
import com.anji.plus.gaea.curd.entity.BaseEntity;
|
||||
import com.anji.plus.gaea.curd.params.PageParam;
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@ import com.anji.plus.gaea.curd.params.PageParam;
|
||||
* @author WongBin
|
||||
* @date 2021/3/26
|
||||
*/
|
||||
public abstract class BaseController<P extends PageParam, T extends BaseEntity, D extends BaseDTO>
|
||||
public abstract class BaseController<P extends PageParam, T extends GaeaBaseEntity, D extends BaseDTO>
|
||||
extends GaeaBaseController<P,T,D> {
|
||||
/**
|
||||
* 获取当前语言类型
|
||||
|
||||
@@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -63,10 +64,8 @@ public class UrlDecodeFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getParameterNames() {
|
||||
|
||||
Set<String> keySet = parameterMap.keySet();
|
||||
IteratorEnumeration iteratorEnumeration = new IteratorEnumeration(keySet.iterator());
|
||||
return iteratorEnumeration;
|
||||
return Collections.enumeration(keySet);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -395,17 +395,23 @@ public class DataSetServiceImpl implements DataSetService {
|
||||
DataSet dateSetCopy = copyDataSet(dataSet, dto);
|
||||
insert(dateSetCopy);
|
||||
String copySetCode = dateSetCopy.getSetCode();
|
||||
DataSetParam dataSetParam = dataSetParamService.selectOne("set_code", setCode);
|
||||
if (null != dataSetParam){
|
||||
dataSetParam.setId(null);
|
||||
dataSetParam.setSetCode(copySetCode);
|
||||
dataSetParamService.insert(dataSetParam);
|
||||
|
||||
List<DataSetParam> dataSetParamList = dataSetParamService.list("set_code", setCode);
|
||||
if (!CollectionUtils.isEmpty(dataSetParamList)){
|
||||
dataSetParamList.forEach(dataSetParam -> {
|
||||
dataSetParam.setId(null);
|
||||
dataSetParam.setSetCode(copySetCode);
|
||||
});
|
||||
dataSetParamService.insertBatch(dataSetParamList);
|
||||
}
|
||||
DataSetTransform dataSetTransform = dataSetTransformService.selectOne("set_code", setCode);
|
||||
if (null != dataSetTransform){
|
||||
dataSetTransform.setId(null);
|
||||
dataSetTransform.setSetCode(copySetCode);
|
||||
dataSetTransformService.insert(dataSetTransform);
|
||||
|
||||
List<DataSetTransform> dataSetTransformList = dataSetTransformService.list("set_code", setCode);
|
||||
if (!CollectionUtils.isEmpty(dataSetTransformList)){
|
||||
dataSetTransformList.forEach(dataSetTransform -> {
|
||||
dataSetTransform.setId(null);
|
||||
dataSetTransform.setSetCode(copySetCode);
|
||||
});
|
||||
dataSetTransformService.insertBatch(dataSetTransformList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,26 +2,22 @@ package com.anjiplus.template.gaea.business.modules.datasetparam.service.impl;
|
||||
|
||||
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
|
||||
import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
|
||||
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.controller.dto.DataSetParamDto;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.dao.DataSetParamMapper;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.dao.entity.DataSetParam;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.service.DataSetParamService;
|
||||
import com.anjiplus.template.gaea.business.modules.datasetparam.util.ParamsResolverHelper;
|
||||
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Sets;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
|
||||
import com.anjiplus.template.gaea.business.util.JsEngineUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @desc DataSetParam 数据集动态参数服务实现
|
||||
@@ -32,15 +28,6 @@ import java.util.Set;
|
||||
//@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DataSetParamServiceImpl implements DataSetParamService {
|
||||
static final Set<String> blackList = Sets.newHashSet("java.lang.ProcessBuilder", "java.lang.Runtime", "java.lang.ProcessImpl");
|
||||
private static final ThreadLocal<ScriptEngine> engineHolder = ThreadLocal.withInitial(() -> {
|
||||
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
|
||||
ScriptEngine engine = factory.getScriptEngine(clz -> !blackList.contains(clz));
|
||||
return engine;
|
||||
});
|
||||
public static ScriptEngine getEngine() {
|
||||
return engineHolder.get();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DataSetParamMapper dataSetParamMapper;
|
||||
@@ -50,6 +37,8 @@ public class DataSetParamServiceImpl implements DataSetParamService {
|
||||
return dataSetParamMapper;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private JsEngineUtil jsEngineUtil;
|
||||
/**
|
||||
* 参数替换
|
||||
*
|
||||
@@ -101,24 +90,10 @@ public class DataSetParamServiceImpl implements DataSetParamService {
|
||||
String validationRules = dataSetParamDto.getValidationRules();
|
||||
if (StringUtils.isNotBlank(validationRules)) {
|
||||
try {
|
||||
ScriptEngine engine = getEngine();
|
||||
engine.eval(validationRules);
|
||||
if(engine instanceof Invocable){
|
||||
Invocable invocable = (Invocable) engine;
|
||||
Object exec = invocable.invokeFunction("verification", dataSetParamDto);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
if (exec instanceof Boolean) {
|
||||
return objectMapper.convertValue(exec, Boolean.class);
|
||||
}else {
|
||||
return objectMapper.convertValue(exec, String.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return jsEngineUtil.verification(validationRules,dataSetParamDto);
|
||||
} catch (Exception ex) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_JS_ERROR, ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,14 +5,11 @@ import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
|
||||
import com.anjiplus.template.gaea.business.code.ResponseCode;
|
||||
import com.anjiplus.template.gaea.business.modules.datasettransform.controller.dto.DataSetTransformDto;
|
||||
import com.anjiplus.template.gaea.business.modules.datasettransform.service.TransformStrategy;
|
||||
import jdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
import com.anjiplus.template.gaea.business.util.JsEngineUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import java.util.ArrayList;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -21,13 +18,6 @@ import java.util.List;
|
||||
@Component
|
||||
@Slf4j
|
||||
public class JsTransformServiceImpl implements TransformStrategy {
|
||||
|
||||
private ScriptEngine engine;
|
||||
{
|
||||
ScriptEngineManager manager = new ScriptEngineManager();
|
||||
engine = manager.getEngineByName("JavaScript");
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据清洗转换 类型
|
||||
*
|
||||
@@ -46,35 +36,19 @@ public class JsTransformServiceImpl implements TransformStrategy {
|
||||
*/
|
||||
@Override
|
||||
public List<JSONObject> transform(DataSetTransformDto def, List<JSONObject> data) {
|
||||
return getValueFromJs(def,data);
|
||||
return getValueFromJs(def, data);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private JsEngineUtil jsEngineUtil;
|
||||
|
||||
private List<JSONObject> getValueFromJs(DataSetTransformDto def, List<JSONObject> data) {
|
||||
String js = def.getTransformScript();
|
||||
try {
|
||||
engine.eval(js);
|
||||
if(engine instanceof Invocable){
|
||||
Invocable invocable = (Invocable) engine;
|
||||
Object dataTransform = invocable.invokeFunction("dataTransform", data);
|
||||
if (dataTransform instanceof List) {
|
||||
return (List<JSONObject>) dataTransform;
|
||||
}
|
||||
//前端js自定义的数组[{"aa":"bb"}]解析后变成{"0":{"aa":"bb"}}
|
||||
ScriptObjectMirror scriptObjectMirror = (ScriptObjectMirror) dataTransform;
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
scriptObjectMirror.forEach((key, value) -> {
|
||||
ScriptObjectMirror valueObject = (ScriptObjectMirror) value;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.putAll(valueObject);
|
||||
result.add(jsonObject);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
return jsEngineUtil.eval(js, data);
|
||||
} catch (Exception ex) {
|
||||
log.info("执行js异常", ex);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.EXECUTE_JS_ERROR, ex.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,9 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -41,7 +39,7 @@ import java.util.UUID;
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RefreshScope
|
||||
//@RefreshScope
|
||||
public class GaeaFileServiceImpl implements GaeaFileService {
|
||||
|
||||
@Value("${spring.gaea.subscribes.oss.downloadPath:''}")
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.anjiplus.template.gaea.business.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Sets;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
|
||||
import jdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
import org.springframework.core.NamedInheritableThreadLocal;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import javax.script.ScriptEngine;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class JsEngineUtil {
|
||||
|
||||
final Set<String> blackList = Sets.newHashSet(
|
||||
"java.lang.ProcessBuilder", "java.lang.Runtime", "java.lang.ProcessImpl");
|
||||
ThreadLocal<ScriptEngine> engineHolder = new NamedInheritableThreadLocal<ScriptEngine>("jsEngine") {
|
||||
@Override
|
||||
protected ScriptEngine initialValue() {
|
||||
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
|
||||
return factory.getScriptEngine((clz) -> {
|
||||
return !blackList.contains(clz);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
public ScriptEngine getEngine() {
|
||||
return engineHolder.get();
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
private String filter(String input) {
|
||||
//把blackList中的类替换成空字符串
|
||||
for (String clz : blackList) {
|
||||
input = input.replace(clz, "");
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
public List<JSONObject> eval(String js, List<JSONObject> data) throws Exception {
|
||||
ScriptEngine engine = getEngine();
|
||||
engine.eval(filter(js));
|
||||
if (engine instanceof Invocable) {
|
||||
Invocable invocable = (Invocable) engine;
|
||||
Object dataTransform = invocable.invokeFunction("dataTransform", data);
|
||||
if (dataTransform instanceof List) {
|
||||
return (List<JSONObject>) dataTransform;
|
||||
}
|
||||
//前端js自定义的数组[{"aa":"bb"}]解析后变成{"0":{"aa":"bb"}}
|
||||
ScriptObjectMirror scriptObjectMirror = (ScriptObjectMirror) dataTransform;
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
scriptObjectMirror.forEach((key, value) -> {
|
||||
ScriptObjectMirror valueObject = (ScriptObjectMirror) value;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.putAll(valueObject);
|
||||
result.add(jsonObject);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object verification(String validationRules, Object dataSetParamDto) throws Exception {
|
||||
ScriptEngine engine = getEngine();
|
||||
engine.eval(filter(validationRules));
|
||||
if (engine instanceof Invocable) {
|
||||
Invocable invocable = (Invocable) engine;
|
||||
Object exec = invocable.invokeFunction("verification", dataSetParamDto);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
if (exec instanceof Boolean) {
|
||||
return objectMapper.convertValue(exec, Boolean.class);
|
||||
} else {
|
||||
return objectMapper.convertValue(exec, String.class);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,14 @@ spring:
|
||||
url: jdbc:mysql://10.108.26.197:3306/aj_report?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
|
||||
username: root
|
||||
password: appuser@anji
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
gaea:
|
||||
subscribes:
|
||||
oss: #文件存储
|
||||
enabled: true
|
||||
##允许上传的文件后缀
|
||||
file-type-while-list: .png|.jpg|.gif|.icon|.pdf|.xlsx|.xls|.csv|.mp4|.avi|.jpeg|.aaa|.svg
|
||||
file-type-white-list: .png|.jpg|.gif|.icon|.pdf|.xlsx|.xls|.csv|.mp4|.avi|.jpeg|.aaa|.svg
|
||||
# 用于文件上传成功后,生成文件的下载公网完整URL
|
||||
downloadPath: http://127.0.0.1:9095/file/download
|
||||
nfs:
|
||||
path: D:\\aaa\\
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,20 @@ server:
|
||||
charset: UTF-8
|
||||
force: true
|
||||
enabled: true
|
||||
springfox:
|
||||
documentation:
|
||||
auto-startup: false
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
bootstrap:
|
||||
enabled: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
allow-circular-references: true
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
profiles:
|
||||
active: dev
|
||||
application:
|
||||
@@ -78,7 +90,7 @@ spring:
|
||||
oss: #文件存储 都配置的情况下优先级minio->amazonS3->nfs
|
||||
enabled: true
|
||||
##允许上传的文件后缀
|
||||
file-type-while-list: .png|.jpg|.gif|.icon|.pdf|.xlsx|.xls|.csv|.mp4|.avi|.jpeg|.aaa|.svg
|
||||
file-type-white-list: .png|.jpg|.gif|.icon|.pdf|.xlsx|.xls|.csv|.mp4|.avi|.jpeg|.aaa|.svg
|
||||
# 用于文件上传成功后,生成文件的下载公网完整URL,http://serverip:9095/file/download,注意填写IP必须填写后端服务所在的机器IP
|
||||
downloadPath: http://10.108.26.197:9095/file/download
|
||||
nfs:
|
||||
|
||||
@@ -97,20 +97,11 @@ const webpackConfig = merge(baseWebpackConfig, {
|
||||
// keep module.id stable when vender modules does not change
|
||||
new webpack.HashedModuleIdsPlugin(),
|
||||
// copy custom static assets
|
||||
/* new CopyWebpackPlugin([{
|
||||
new CopyWebpackPlugin([{
|
||||
from: path.resolve(__dirname, '../static'),
|
||||
to: config.build.assetsSubDirectory,
|
||||
ignore: ['.*']
|
||||
}])*/
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: path.resolve(__dirname, '../static'),
|
||||
to: config.build.assetsSubDirectory,
|
||||
ignore: ['.*']
|
||||
}
|
||||
]
|
||||
}),
|
||||
}])
|
||||
],
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
@@ -144,7 +135,7 @@ const webpackConfig = merge(baseWebpackConfig, {
|
||||
},
|
||||
sourceMap: config.build.productionSourceMap,
|
||||
cache: true,
|
||||
parallel: true
|
||||
parallel: true,
|
||||
}),
|
||||
// Compress extracted CSS. We are using this plugin so that possible
|
||||
// duplicated CSS from different components can be deduped.
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
"shelljs": "0.8.2",
|
||||
"svg-sprite-loader": "6.0.0",
|
||||
"svgo": "2.0.0",
|
||||
"uglifyjs-webpack-plugin": "2.0.0",
|
||||
"uglifyjs-webpack-plugin": "1.2.7",
|
||||
"url-loader": "4.0.0",
|
||||
"vue-loader": "^15.10.2",
|
||||
"vue-style-loader": "4.1.2",
|
||||
|
||||
Reference in New Issue
Block a user