From e6b2ea8e2d0b4b6f8b4bbe11224fa9cfae6d6360 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?REBUILD=20=E4=BC=81=E4=B8=9A=E7=AE=A1=E7=90=86=E7=B3=BB?=
=?UTF-8?q?=E7=BB=9F?= <42044143+getrebuild@users.noreply.github.com>
Date: Wed, 18 Oct 2023 13:56:46 +0800
Subject: [PATCH] tmpl better (#668)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* be: isSame
* socketTimeout=0
* feat: front
* WordReportGenerator
* style: print
* be: common-save
* be: 本地加载PDF
* fops
* inTriggerTime2
* report 100w
* word tmpl
* word table
* style
* Update @rbv
* AppHome._InTab
* IsNullFunction
* modal onDoubleClick
---
@rbv | 2 +-
pom.xml | 14 +-
.../core/service/dataimport/DataExporter.java | 6 +-
.../service/datareport/DataReportManager.java | 59 +-
.../datareport/EasyExcelGenerator.java | 35 +-
.../datareport/EasyExcelGenerator33.java | 31 +-
.../datareport/EasyExcelListGenerator.java | 4 +-
.../service/datareport/TemplateExtractor.java | 18 +-
.../datareport/TemplateExtractor33.java | 8 +-
.../core/service/datareport/TemplateFile.java | 17 +-
.../service/general/RecordDifference.java | 22 +-
.../core/service/query/QueryFactory.java | 4 +-
.../service/trigger/aviator/AviatorUtils.java | 1 +
.../trigger/aviator/IsNullFunction.java | 58 +
.../support/general/BatchOperatorQuery.java | 4 +-
.../core/support/integration/QiniuCloud.java | 42 +-
.../java/com/rebuild/utils/CommonsUtils.java | 19 +
.../java/com/rebuild/utils/PdfConverter.java | 18 +-
.../rebuild/web/KnownExceptionConverter.java | 6 +-
.../web/admin/ConfigurationController.java | 4 +-
.../admin/data/ReportTemplateController.java | 55 +-
.../rebuild/web/commons/CommonPageView.java | 8 +-
.../rebuild/web/commons/FileDownloader.java | 2 +-
.../general/CommonOperatingController.java | 8 +-
.../web/general/GeneralListController.java | 25 +-
.../web/general/GeneralModelController.java | 2 +-
.../web/general/ModelExtrasController.java | 4 +-
.../web/general/ReportsController.java | 21 +-
src/main/resources/application-bean.xml | 3 +
src/main/resources/logback.xml | 7 +-
src/main/resources/web/_include/header.html | 2 +
.../web/admin/integration/apis-manager.html | 2 +-
.../web/admin/metadata/entities.html | 2 +-
src/main/resources/web/assets/css/rb-page.css | 17 +-
.../resources/web/assets/css/view-page.css | 8 +-
.../web/assets/js/admin/report-templates.js | 114 +-
.../web/assets/js/charts/chart-design.js | 2 +-
.../resources/web/assets/js/charts/charts.js | 2 +-
.../resources/web/assets/js/file-preview.js | 21 +-
.../resources/web/assets/js/print-preview.js | 42 +-
.../web/assets/js/project/project-tasks.js | 2 +-
.../resources/web/assets/js/rb-components.js | 13 +-
.../web/assets/js/rb-datalist.common.js | 9 +-
src/main/resources/web/assets/js/rb-forms.js | 23 +-
src/main/resources/web/assets/js/rb-page.js | 20 +
.../resources/web/assets/js/rb-view.append.js | 2 +-
src/main/resources/web/assets/js/rb-view.js | 18 +-
.../web/assets/js/trigger/trigger-design.js | 6 +-
.../web/assets/lib/wangeditor/index.js | 24129 ++++++++++++++++
.../assets/lib/wangeditor/normalize.min.css | 2 +
.../web/assets/lib/wangeditor/style.css | 27 +
.../resources/web/general/print-preview.html | 68 +-
src/test/resources/frontjs-sdk-demo.js | 13 +
53 files changed, 24798 insertions(+), 253 deletions(-)
create mode 100644 src/main/java/com/rebuild/core/service/trigger/aviator/IsNullFunction.java
create mode 100644 src/main/resources/web/assets/lib/wangeditor/index.js
create mode 100644 src/main/resources/web/assets/lib/wangeditor/normalize.min.css
create mode 100644 src/main/resources/web/assets/lib/wangeditor/style.css
diff --git a/@rbv b/@rbv
index 551b01618..8dbf3078a 160000
--- a/@rbv
+++ b/@rbv
@@ -1 +1 @@
-Subproject commit 551b01618f09293e287ef53fba4f4d6a68821eb2
+Subproject commit 8dbf3078ac9aa1a3741ba85bc071aadfcb44c67c
diff --git a/pom.xml b/pom.xml
index 8e91d3a5c..75cc953a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -320,12 +320,12 @@
com.alibaba
druid
- 1.2.18
+ 1.2.20
com.mysql
mysql-connector-j
- 8.0.33
+ 8.1.0
net.sf.ehcache
@@ -398,15 +398,20 @@
+
+ com.deepoove
+ poi-tl
+ 1.12.1
+
org.apache.poi
poi
- 4.1.2
+ 5.2.4
org.apache.poi
poi-ooxml
- 4.1.2
+ 5.2.4
org.apache.poi
@@ -488,6 +493,7 @@
2.4.0
+
commons-io
diff --git a/src/main/java/com/rebuild/core/service/dataimport/DataExporter.java b/src/main/java/com/rebuild/core/service/dataimport/DataExporter.java
index 96f597b85..0370768e0 100644
--- a/src/main/java/com/rebuild/core/service/dataimport/DataExporter.java
+++ b/src/main/java/com/rebuild/core/service/dataimport/DataExporter.java
@@ -62,10 +62,10 @@
public class DataExporter extends SetUser {
/**
- * 最大行数
+ * 最大导出行数
*/
- public static final int MAX_ROWS = 65535 - 1;
-
+ public static final int MAX_ROWS = 1000000;
+
final private JSONObject queryData;
// 字段
private List headFields = new ArrayList<>();
diff --git a/src/main/java/com/rebuild/core/service/datareport/DataReportManager.java b/src/main/java/com/rebuild/core/service/datareport/DataReportManager.java
index 7b6e12892..819f0b283 100644
--- a/src/main/java/com/rebuild/core/service/datareport/DataReportManager.java
+++ b/src/main/java/com/rebuild/core/service/datareport/DataReportManager.java
@@ -45,19 +45,31 @@ private DataReportManager() {}
public static final int TYPE_RECORD = 1;
public static final int TYPE_LIST = 2;
+ public static final int TYPE_HTML5 = 3;
+ public static final int TYPE_WORD = 4;
/**
- * 获取报表列表
+ * 获取可用报表
*
* @param entity
- * @param type
+ * @param type 指定类型
* @param user
* @return
*/
public JSONArray getReports(Entity entity, int type, ID user) {
JSONArray alist = new JSONArray();
for (ConfigBean e : getReportsRaw(entity)) {
- if (!e.getBoolean("disabled") && e.getInteger("type") == type) {
+ if (e.getBoolean("disabled")) continue;
+
+ boolean can;
+ int aType = e.getInteger("type");
+ if (type == DataReportManager.TYPE_LIST) {
+ can = aType == type;
+ } else {
+ can = aType == DataReportManager.TYPE_RECORD || aType == DataReportManager.TYPE_WORD;
+ }
+
+ if (can) {
// v3.5
String vuDef = e.getString("visibleUsers");
if (StringUtils.isNotBlank(vuDef)) {
@@ -85,7 +97,7 @@ public ConfigBean[] getReportsRaw(Entity entity) {
}
Object[][] array = Application.createQueryNoFilter(
- "select configId,name,isDisabled,templateFile,templateType,extraDefinition from DataReportConfig where belongEntity = ?")
+ "select configId,name,isDisabled,templateFile,templateType,extraDefinition,templateContent from DataReportConfig where belongEntity = ?")
.setParameter(1, entity.getName())
.array();
@@ -104,7 +116,8 @@ public ConfigBean[] getReportsRaw(Entity entity) {
.set("type", ObjectUtils.toInt(o[4], TYPE_RECORD))
.set("outputType", outputType)
.set("templateVersion", templateVersion)
- .set("visibleUsers", visibleUsersDef);
+ .set("visibleUsers", visibleUsersDef)
+ .set("templateContent", o[6]);
alist.add(cb);
}
@@ -119,29 +132,36 @@ public ConfigBean[] getReportsRaw(Entity entity) {
* @return
*/
public TemplateFile getTemplateFile(Entity entity, ID reportId) {
- String template = null;
- boolean isList = false;
+ String templateFile = null;
+ String templateContent = null;
+ int type = DataReportManager.TYPE_RECORD;
boolean isV33 = false;
for (ConfigBean e : getReportsRaw(entity)) {
if (e.getID("id").equals(reportId)) {
- template = e.getString("template");
- isList = e.getInteger("type") == TYPE_LIST;
+ templateFile = e.getString("template");
+ templateContent = e.getString("templateContent");
+ type = e.getInteger("type");
isV33 = e.getInteger("templateVersion") == 3;
break;
}
}
- if (template == null) {
+ // v35 HTML5
+ if (templateContent != null) {
+ return new TemplateFile(templateContent, entity);
+ }
+
+ if (templateFile == null) {
throw new ConfigurationException("No template of report found : " + reportId);
}
- File file = RebuildConfiguration.getFileOfData(template);
+ File file = RebuildConfiguration.getFileOfData(templateFile);
if (!file.exists()) {
throw new ConfigurationException("File of template not extsts : " + file);
}
- return new TemplateFile(file, entity, isList, isV33);
+ return new TemplateFile(file, entity, type, isV33);
}
/**
@@ -150,15 +170,12 @@ public TemplateFile getTemplateFile(Entity entity, ID reportId) {
* @see #getTemplateFile(Entity, ID) 性能好
*/
public TemplateFile getTemplateFile(ID reportId) {
- Object[] report = Application.createQueryNoFilter(
- "select belongEntity from DataReportConfig where configId = ?")
- .setParameter(1, reportId)
- .unique();
- if (report == null || !MetadataHelper.containsEntity((String) report[0])) {
+ Object[] o = Application.getQueryFactory().uniqueNoFilter(reportId, "belongEntity");
+ if (o == null || !MetadataHelper.containsEntity((String) o[0])) {
throw new ConfigurationException("No config of report found : " + reportId);
}
- return getTemplateFile(MetadataHelper.getEntity((String) report[0]), reportId);
+ return getTemplateFile(MetadataHelper.getEntity((String) o[0]), reportId);
}
@Override
@@ -167,6 +184,8 @@ public void clean(Object entity) {
Application.getCommonsCache().evict(cKey);
}
+ // --
+
/**
* 获取报表名称
*
@@ -176,7 +195,8 @@ public void clean(Object entity) {
* @return
*/
public static String getReportName(ID reportId, Object idOrEntity, String fileName) {
- Entity be = idOrEntity instanceof ID ? MetadataHelper.getEntity(((ID) idOrEntity).getEntityCode())
+ final Entity be = idOrEntity instanceof ID
+ ? MetadataHelper.getEntity(((ID) idOrEntity).getEntityCode())
: MetadataHelper.getEntity((String) idOrEntity);
String name = null;
@@ -191,6 +211,7 @@ public static String getReportName(ID reportId, Object idOrEntity, String fileNa
// suffix
if (fileName.endsWith(".pdf")) name += ".pdf";
+ else if (fileName.endsWith(".docx")) name += ".docx";
else name += fileName.endsWith(".xlsx") ? ".xlsx" : ".xls";
break;
}
diff --git a/src/main/java/com/rebuild/core/service/datareport/EasyExcelGenerator.java b/src/main/java/com/rebuild/core/service/datareport/EasyExcelGenerator.java
index 818dfd3ab..5ff303e66 100644
--- a/src/main/java/com/rebuild/core/service/datareport/EasyExcelGenerator.java
+++ b/src/main/java/com/rebuild/core/service/datareport/EasyExcelGenerator.java
@@ -79,7 +79,7 @@
@Slf4j
public class EasyExcelGenerator extends SetUser {
- protected File template;
+ protected File templateFile;
protected Integer writeSheetAt = null;
protected ID recordId;
@@ -92,7 +92,7 @@ public class EasyExcelGenerator extends SetUser {
* @param recordId
*/
protected EasyExcelGenerator(File template, ID recordId) {
- this.template = getFixTemplate(template);
+ this.templateFile = getFixTemplate(template);
this.recordId = recordId;
}
@@ -116,7 +116,7 @@ public File generate() {
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
- try (ExcelWriter excelWriter = EasyExcel.write(target).withTemplate(template).build()) {
+ try (ExcelWriter excelWriter = EasyExcel.write(target).withTemplate(templateFile).build()) {
WriteSheet writeSheet = EasyExcel.writerSheet(writeSheetAt)
.registerWriteHandler(new FixsMergeStrategy())
.registerWriteHandler(new FormulaCellWriteHandler())
@@ -150,8 +150,13 @@ public File generate() {
* @return
*/
protected File getTargetFile() {
- return RebuildConfiguration.getFileOfTemp(String.format("RBREPORT-%d.%s",
- System.currentTimeMillis(), template.getName().endsWith(".xlsx") ? "xlsx" : "xls"));
+ String suffix = "xls";
+ if (templateFile.getName().endsWith(".xlsx")) suffix = "xlsx";
+ if (templateFile.getName().endsWith(".html")) suffix = "html";
+ if (templateFile.getName().endsWith(".docx")) suffix = "docx";
+ if (templateFile.getName().endsWith(".doc")) suffix = "doc";
+
+ return RebuildConfiguration.getFileOfTemp(String.format("RBREPORT-%d.%s", System.currentTimeMillis(), suffix));
}
/**
@@ -160,9 +165,9 @@ protected File getTargetFile() {
* @return 第一个为主记录(若有)
*/
protected List