feat: AutoGenReport (#717)

* enh: whenUpdateFields

* feat: AutoGenReport

* bump lib

* fix

* Update SysbaseSupport.java

* be: triggerlog

---------

Co-authored-by: devezhao <zhaofang123@gmail.com>
This commit is contained in:
REBUILD 企业管理系统 2024-02-21 20:10:11 +08:00 committed by GitHub
parent 91010899a0
commit 9c7dcca5e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 305 additions and 87 deletions

2
@rbv

@ -1 +1 @@
Subproject commit e30741d980c3d40f31590401bcb3c4070bbe8268
Subproject commit b97388f77b68c6fcdf174168472948fdadbf3707

44
pom.xml
View file

@ -316,17 +316,17 @@
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.20</version>
<version>1.9.21.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.20</version>
<version>1.2.21</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.2.0</version>
<version>8.3.0</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
@ -341,7 +341,7 @@
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>7.14.0</version>
<version>7.15.0</version>
</dependency>
<dependency>
<groupId>com.github.whvcse</groupId>
@ -351,12 +351,12 @@
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>6.4.5</version>
<version>6.4.12</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.16.1</version>
<version>1.17.2</version>
</dependency>
<dependency>
<groupId>com.hankcs</groupId>
@ -391,7 +391,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.2</version>
<version>3.3.3</version>
<exclusions>
<exclusion>
<artifactId>ehcache</artifactId>
@ -402,17 +402,17 @@
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.12.1</version>
<version>1.12.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.4</version>
<version>5.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.4</version>
<version>5.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
@ -422,12 +422,12 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.220</version>
<version>2.2.224</version>
</dependency>
<dependency>
<groupId>com.googlecode.aviator</groupId>
<artifactId>aviator</artifactId>
<version>5.3.3</version>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
@ -442,12 +442,12 @@
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.5.2</version>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.23.3</version>
<version>3.26.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@ -473,12 +473,12 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
<version>5.8.25</version>
<version>5.8.26</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.13.0</version>
<version>3.14.0</version>
</dependency>
<!-- Need JDK11+ -->
<!--
@ -491,7 +491,7 @@
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>2.4.0</version>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>org.zwobble.mammoth</groupId>
@ -501,19 +501,19 @@
<dependency>
<groupId>com.getui.push</groupId>
<artifactId>restful-sdk</artifactId>
<version>1.0.0.15</version>
<version>1.0.0.16</version>
</dependency>
<!-- fix: CVEs -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.13.0</version>
<version>2.15.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.24.0</version>
<version>1.25.0</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
@ -523,12 +523,12 @@
<dependency>
<groupId>com.fasterxml.woodstox</groupId>
<artifactId>woodstox-core</artifactId>
<version>6.4.0</version>
<version>6.6.0</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.94.Final</version>
<version>4.1.107.Final</version>
</dependency>
</dependencies>
</project>

View file

@ -151,7 +151,7 @@ public class DataReportManager implements ConfigManager {
// v35 HTML5
if (templateContent != null) {
return new TemplateFile(templateContent, entity);
return new TemplateFile(templateContent, entity, reportId);
}
if (templateFile == null) {
@ -163,7 +163,7 @@ public class DataReportManager implements ConfigManager {
throw new ConfigurationException("File of template not extsts : " + file);
}
return new TemplateFile(file, entity, type, isV33);
return new TemplateFile(file, entity, type, isV33, reportId);
}
/**

View file

@ -239,6 +239,7 @@ public class EasyExcelGenerator extends SetUser {
final Map<String, List<Map<String, Object>>> datas = new HashMap<>();
final String baseSql = "select %s,%s from %s where %s = ?";
// 主记录
if (!fieldsOfMain.isEmpty()) {
String sql = String.format(baseSql,
StringUtils.join(fieldsOfMain, ","),

View file

@ -22,10 +22,15 @@ import com.rebuild.core.support.general.RecordBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.PrintSetup;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFSimpleShape;
import org.apache.poi.xssf.usermodel.XSSFTextRun;
import org.springframework.util.Assert;
import java.io.File;
@ -38,6 +43,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import static com.rebuild.core.service.datareport.TemplateExtractor.APPROVAL_PREFIX;
import static com.rebuild.core.service.datareport.TemplateExtractor.NROW_PREFIX;
@ -57,6 +64,9 @@ public class EasyExcelGenerator33 extends EasyExcelGenerator {
final private List<ID> recordIdMultiple;
private Set<String> inShapeVars;
private Map<String, Object> mdataHolder;
protected EasyExcelGenerator33(File templateFile, ID recordId) {
super(templateFile, recordId);
this.recordIdMultiple = null;
@ -146,6 +156,7 @@ public class EasyExcelGenerator33 extends EasyExcelGenerator {
Map<String, Object> d = buildData(record, varsMapOfMain);
datas.put(MDATA_KEY, Collections.singletonList(d));
mdataHolder = d;
}
// 相关记录含明细审批
@ -219,6 +230,7 @@ public class EasyExcelGenerator33 extends EasyExcelGenerator {
datas.put(refKey, refDatas);
}
inShapeVars = templateExtractor33.getInShapeVars();
return datas;
}
@ -233,7 +245,7 @@ public class EasyExcelGenerator33 extends EasyExcelGenerator {
@Override
public File generate() {
if (recordIdMultiple == null) return super.generate();
if (recordIdMultiple == null) return superGenerate();
// init
File targetFile = super.getTargetFile();
@ -282,7 +294,7 @@ public class EasyExcelGenerator33 extends EasyExcelGenerator {
this.phNumber = 1;
this.phValues.clear();
targetFile = super.generate();
targetFile = superGenerate();
}
// 删除模板 Sheet
@ -297,4 +309,54 @@ public class EasyExcelGenerator33 extends EasyExcelGenerator {
return targetFile;
}
private File superGenerate() {
File file = super.generate();
if (inShapeVars.isEmpty() || mdataHolder == null) return file;
// v3.6 提取文本框
try (Workbook wb = WorkbookFactory.create(file)) {
Sheet sheet = wb.getSheetAt(0);
for (Object o : sheet.getDrawingPatriarch()) {
XSSFSimpleShape shape = (XSSFSimpleShape) o;
String shapeText = shape.getText();
Matcher matcher = TemplateExtractor33.PATT_V2.matcher(shapeText);
while (matcher.find()) {
String varName = matcher.group(1);
if (StringUtils.isNotBlank(varName)) {
shapeText = shapeText.replace("{" + varName +"}", String.valueOf(mdataHolder.get(varName)));
}
}
// 样式
XSSFTextRun s = shape.getTextParagraphs().get(0).getTextRuns().get(0);
XSSFFont font = (XSSFFont) wb.createFont();
font.setFontName(s.getFontFamily());
font.setFontHeightInPoints((short) s.getFontSize());
font.setBold(s.isBold());
font.setItalic(s.isItalic());
font.setStrikeout(s.isStrikethrough());
font.setUnderline(s.isUnderline() ? Font.U_SINGLE : Font.U_NONE);
// TODO 颜色不生效
XSSFRichTextString richTextString = new XSSFRichTextString(shapeText);
richTextString.applyFont(font);
shape.setText(richTextString);
}
// 保存生效
File file2 = new File(file.getParent(), "2" + file.getName());
try (FileOutputStream fos = new FileOutputStream(file2)) {
wb.write(fos);
FileUtils.deleteQuietly(file);
return file2;
}
} catch (Exception ex) {
log.error("Cannot fill vars to shape", ex);
}
return file;
}
}

View file

@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -95,7 +96,9 @@ public class EasyExcelListGenerator extends EasyExcelGenerator {
if (varsMap.containsKey(PH__CURRENTDATE)) phValues.put(PH__CURRENTDATE, getPhValue(PH__CURRENTDATE));
if (varsMap.containsKey(PH__CURRENTDATETIME)) phValues.put(PH__CURRENTDATETIME, getPhValue(PH__CURRENTDATETIME));
return Collections.singletonMap(MDATA_KEY, datas);
Map<String, List<Map<String, Object>>> datasMap = new HashMap<>();
datasMap.put(MDATA_KEY, datas);
return datasMap;
}
public int getExportCount() {
@ -110,7 +113,8 @@ public class EasyExcelListGenerator extends EasyExcelGenerator {
* @return
*/
public static EasyExcelListGenerator create(ID reportId, JSONObject queryData) {
TemplateFile tb = DataReportManager.instance.getTemplateFile(MetadataHelper.getEntity(queryData.getString("entity")), reportId);
TemplateFile tb = DataReportManager.instance.getTemplateFile(
MetadataHelper.getEntity(queryData.getString("entity")), reportId);
return create(tb.templateFile, queryData);
}

View file

@ -11,11 +11,20 @@ import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Field;
import com.rebuild.core.metadata.EntityHelper;
import com.rebuild.core.metadata.MetadataHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFSimpleShape;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
/**
* V33
@ -23,6 +32,7 @@ import java.util.Set;
* @author devezhao
* @since 2023/4/5
*/
@Slf4j
public class TemplateExtractor33 extends TemplateExtractor {
// 明细字段
@ -37,6 +47,8 @@ public class TemplateExtractor33 extends TemplateExtractor {
private static final String SORT_DESC = ":desc";
private Map<String, String> sortFields = new HashMap<>();
private Set<String> inShapeVars = new HashSet<>();
/**
* @param templateFile
*/
@ -161,4 +173,43 @@ public class TemplateExtractor33 extends TemplateExtractor {
|| varName.contains(NROW_PREFIX + PLACEHOLDER)
|| varName.contains(NROW_PREFIX2 + PLACEHOLDER);
}
@Override
protected Set<String> extractVars() {
Set<String> vars = super.extractVars();
// v3.6 LAB 提取文本框
if (templateFile.getName().endsWith(".xlsx")) {
try (Workbook wb = WorkbookFactory.create(templateFile)) {
Sheet sheet = wb.getSheetAt(0);
Drawing<?> drawing = sheet.getDrawingPatriarch();
if (drawing != null) {
for (Object o : sheet.getDrawingPatriarch()) {
XSSFSimpleShape shape = (XSSFSimpleShape) o;
String shapeText = shape.getText();
Matcher matcher = PATT_V2.matcher(shapeText);
while (matcher.find()) {
String varName = matcher.group(1);
if (StringUtils.isNotBlank(varName)) {
vars.add(varName);
inShapeVars.add(varName);
}
}
}
}
} catch (Exception ex) {
log.error("Cannot extract vars in shape", ex);
}
}
return vars;
}
/**
* @return
*/
public Set<String> getInShapeVars() {
return inShapeVars;
}
}

View file

@ -8,6 +8,7 @@ See LICENSE and COMMERCIAL in the project root for license information.
package com.rebuild.core.service.datareport;
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.engine.ID;
import java.io.File;
@ -22,21 +23,24 @@ public class TemplateFile {
final public Entity entity;
final public int type;
final public boolean isV33;
final public ID configId;
public TemplateFile(File templateFile, Entity entity, int type, boolean isV33) {
public TemplateFile(File templateFile, Entity entity, int type, boolean isV33, ID configId) {
this.templateFile = templateFile;
this.entity = entity;
this.type = type;
this.isV33 = isV33;
this.templateContent = null;
this.configId = configId;
}
// HTML5
public TemplateFile(String templateContent, Entity entity) {
public TemplateFile(String templateContent, Entity entity, ID configId) {
this.templateContent = templateContent;
this.entity = entity;
this.type = DataReportManager.TYPE_HTML5;
this.isV33 = true;
this.templateFile = null;
this.configId = configId;
}
}

View file

@ -71,7 +71,8 @@ public class FilesHelper {
if (FILESIZES.containsKey(filePath)) {
attach.setInt("fileSize", FILESIZES.remove(filePath));
} else {
Object[] db = Application.createQueryNoFilter("select fileSize from Attachment where filePath = ?")
Object[] db = Application.createQueryNoFilter(
"select fileSize from Attachment where filePath = ?")
.setParameter(1, filePath)
.unique();
if (db != null) {

View file

@ -7,7 +7,13 @@ See LICENSE and COMMERCIAL in the project root for license information.
package com.rebuild.core.service.trigger;
import com.rebuild.core.service.trigger.impl.*;
import com.rebuild.core.service.trigger.impl.AutoApproval;
import com.rebuild.core.service.trigger.impl.AutoAssign;
import com.rebuild.core.service.trigger.impl.AutoShare;
import com.rebuild.core.service.trigger.impl.FieldAggregation;
import com.rebuild.core.service.trigger.impl.FieldWriteback;
import com.rebuild.core.service.trigger.impl.GroupAggregation;
import com.rebuild.core.service.trigger.impl.SendNotification;
import org.apache.commons.lang.ClassUtils;
import org.springframework.util.ReflectionUtils;
@ -36,6 +42,7 @@ public enum ActionType {
CREATEFEED("新建动态", "com.rebuild.rbv.trigger.CreateFeed"),
HOOKURL("回调 URL", "com.rebuild.rbv.trigger.HookUrl"),
PROXYTRIGGERACTION("自定义触发器", "com.rebuild.rbv.trigger.ProxyTriggerAction"),
AUTOGENREPORT("自动报表导出", "com.rebuild.rbv.trigger.AutoGenReport"),
;

View file

@ -23,11 +23,11 @@ import java.util.Collection;
public class TriggerResult implements JSONAware {
// 状态 1=成功, 2=警告, 3=错误
private int level;
final private int level;
// 消息
private String message;
final private String message;
// 影响的记录
private Collection<ID> affected;
final private Collection<ID> affected;
private TriggerSource chain;
@ -44,6 +44,14 @@ public class TriggerResult implements JSONAware {
public boolean hasAffected() {
return affected != null && !affected.isEmpty();
}
public int getLevel() {
return level;
}
public String getMessage() {
return message;
}
@Override
public String toJSONString() {

View file

@ -142,6 +142,10 @@ public class FieldAggregation extends TriggerAction {
@Override
public Object execute(OperatingContext operatingContext) throws TriggerException {
if (operatingContext.getAction() == BizzPermission.UPDATE && !hasUpdateFields(operatingContext)) {
return TriggerResult.noUpdateFields();
}
final String chainName = String.format("%s:%s:%s", actionContext.getConfigId(),
operatingContext.getFixedRecordId(), operatingContext.getAction().getName());
final List<String> tschain = checkTriggerChain(chainName);

View file

@ -107,6 +107,10 @@ public class FieldWriteback extends FieldAggregation {
@Override
public Object execute(OperatingContext operatingContext) throws TriggerException {
if (operatingContext.getAction() == BizzPermission.UPDATE && !hasUpdateFields(operatingContext)) {
return TriggerResult.noUpdateFields();
}
final String chainName = String.format("%s:%s:%s", actionContext.getConfigId(),
operatingContext.getFixedRecordId(), operatingContext.getAction().getName());
final List<String> tschain = checkTriggerChain(chainName);

View file

@ -17,6 +17,7 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.IOException;
@ -35,11 +36,18 @@ public class SysbaseSupport {
* @return
*/
public String submit() {
File file = SysbaseHeartbeat.getLogbackFile();
StringBuilder logConf = new StringBuilder("RebuildConfiguration :\n----------\n");
for (ConfigurationItem item : ConfigurationItem.values()) {
String v = RebuildConfiguration.get(item);
logConf.append(StringUtils.rightPad(item.name(), 31)).append(" : ").append(v == null ? "" : v).append("\n");
}
log.warn(logConf.append("----------").toString());
File logFile = SysbaseHeartbeat.getLogbackFile();
JSONObject resJson;
try {
String res = upload(file, "https://getrebuild.com/api/misc/request-support");
String res = upload(logFile, "https://getrebuild.com/api/misc/request-support");
log.info("Upload support-file : {}", res);
resJson = (JSONObject) JSON.parse(res);
} catch (IOException e) {

View file

@ -92,17 +92,17 @@ public class PdfConverter {
protected static Path convert(Path path, String type, boolean forceRegen) throws IOException {
type = StringUtils.defaultIfBlank(type, TYPE_PDF);
String pathFileName = path.getFileName().toString();
boolean isExcel = pathFileName.endsWith(".xlsx") || pathFileName.endsWith(".xls");
boolean isWord = pathFileName.endsWith(".docx") || pathFileName.endsWith(".doc");
final String pathFileName = path.getFileName().toString();
final boolean isExcel = pathFileName.endsWith(".xlsx") || pathFileName.endsWith(".xls");
final boolean isWord = pathFileName.endsWith(".docx") || pathFileName.endsWith(".doc");
// Excel 公式生效
if (isExcel) {
ExcelUtils.reSaveAndCalcFormula(path);
}
final File outdir = RebuildConfiguration.getFileOfTemp(null);
String outName = pathFileName.substring(0, pathFileName.lastIndexOf(".") + 1) + type;
final File dest = new File(outdir, outName);
final File outDir = RebuildConfiguration.getFileOfTemp(null);
final String outName = pathFileName.substring(0, pathFileName.lastIndexOf(".") + 1) + type;
final File dest = new File(outDir, outName);
if (dest.exists()) {
if (forceRegen) FileUtils.deleteQuietly(dest);
@ -125,7 +125,7 @@ public class PdfConverter {
// alias
String soffice = RebuildConfiguration.get(ConfigurationItem.LibreofficeBin);
if (StringUtils.isBlank(soffice)) soffice = SystemUtils.IS_OS_WINDOWS ? "soffice.exe" : "libreoffice";
String cmd = String.format("%s --headless --convert-to %s \"%s\" --outdir \"%s\"", soffice, type, path, outdir);
String cmd = String.format("%s --headless --convert-to %s \"%s\" --outdir \"%s\"", soffice, type, path, outDir);
String echo = DatabaseBackup.execFor(cmd);
if (!echo.isEmpty()) log.info(echo);

View file

@ -174,7 +174,7 @@ public class ReportTemplateController extends BaseController {
String entity = getParameter(request, "entity");
String template = getParameter(request, "file");
int type = getIntParameter(request, "type", DataReportManager.TYPE_RECORD);
tt = new TemplateFile(RebuildConfiguration.getFileOfData(template), MetadataHelper.getEntity(entity), type, true);
tt = new TemplateFile(RebuildConfiguration.getFileOfData(template), MetadataHelper.getEntity(entity), type, true, null);
} else {
// 使用配置
tt = DataReportManager.instance.getTemplateFile(reportId);

View file

@ -28,11 +28,11 @@
<td data-id="DingtalkAgentid" th:data-value="${DingtalkAgentid ?:''}">[[${DingtalkAgentid ?:bundle.L('未设置')}]]</td>
</tr>
<tr>
<td>AppKey</td>
<td>AppKey (Client ID)</td>
<td data-id="DingtalkAppkey" th:data-value="${DingtalkAppkey ?:''}">[[${DingtalkAppkey ?:bundle.L('未设置')}]]</td>
</tr>
<tr>
<td>AppSecret</td>
<td>AppSecret (Client Secret)</td>
<td data-id="DingtalkAppsecret" th:data-value="${DingtalkAppsecret ?:''}">[[${DingtalkAppsecret ?:bundle.L('未设置')}]]</td>
</tr>
<tr>

View file

@ -565,3 +565,18 @@ textarea.formula-code + .fields-vars {
padding: 4px 10px;
border-left: 4px solid #e0e0e0;
}
.auto-gen-report .dist-tips .alert {
width: auto;
margin-bottom: 0;
}
.v36-logdesc > .badge {
font-size: 12px;
margin-left: 5px;
margin-right: 5px;
}
.v36-logdesc > .badge + .badge {
margin-left: 0;
}

View file

@ -182,7 +182,7 @@ class PreviewTable extends React.Component {
)
}
} else if (item.type === 'BOOL') {
return item.value ? $L('是') : $L('否')
return item.value === 'T' || item.value === true ? $L('是') : $L('否')
} else if (item.type === 'MULTISELECT') {
return (
<ul className="m-0 p-0 pl-4">

View file

@ -6,11 +6,6 @@ See LICENSE and COMMERCIAL in the project root for license information.
*/
/* global InitModels, FIELD_TYPES */
window.__LAB_SHOWNDETAIL = false
window.bosskeyTrigger = function () {
window.__LAB_SHOWNDETAIL = true
}
// ~~ 新建实体
// eslint-disable-next-line no-unused-vars
class EntityNew2 extends RbModalHandler {
@ -98,7 +93,7 @@ class EntityNew2 extends RbModalHandler {
{this.state.entities &&
this.state.entities.map((item) => {
if (item.mainEntity) return null
if (item.detailEntity && !window.__LAB_SHOWNDETAIL) return null
if (item.detailEntity && !window.__BOSSKEY) return null
return (
<option key={item.entityName} value={item.entityName}>
{item.entityLabel}

View file

@ -137,6 +137,7 @@ $(function () {
if (++bosskey === 6) {
$('.bosskey-show').removeClass('bosskey-show')
typeof window.bosskeyTrigger === 'function' && window.bosskeyTrigger()
window.__BOSSKEY = true
}
}
})
@ -748,7 +749,6 @@ var $unmount = function (container, delay, keepContainer) {
* 初始化引用字段搜索
*/
var $initReferenceSelect2 = function (el, option) {
console.log(option)
var search_input = null
var $el = $(el).select2({
placeholder: option.placeholder || $L('选择%s', option.label),

View file

@ -120,6 +120,7 @@ $(document).ready(() => {
const content = contentComp.buildContent()
if (content === false) return
if (window.whenUpdateFields) content.whenUpdateFields = window.whenUpdateFields
const data = {
when: when,
whenTimer: whenTimer,
@ -384,8 +385,17 @@ class DlgSpecFields extends RbModalHandler {
const _selected = this.props.selected || []
return (
<RbModal title={$L('指定字段')} ref={(c) => (this._dlg = c)} disposeOnHide width="780">
<div className="p-1">
<RbModal
title={
<RF>
{$L('指定字段')}
<sup className="rbv" />
</RF>
}
ref={(c) => (this._dlg = c)}
disposeOnHide
width="780">
<div className="p-2">
<RbAlertBox message={$L('指定字段被更新时触发默认为全部字段')} />
<div className="row " ref={(c) => (this._fields = c)}>
@ -404,18 +414,23 @@ class DlgSpecFields extends RbModalHandler {
</div>
<div className="dialog-footer">
<button className="btn btn-primary btn-space mr-2" type="button" onClick={this.handleConfirm}>
{$L('确定')}
</button>
<button className="btn btn-secondary btn-space" type="button" onClick={this.hide}>
<button className="btn btn-secondary btn-space mr-2" type="button" onClick={this.hide}>
{$L('取消')}
</button>
<button className="btn btn-primary btn-space" type="button" onClick={() => this.handleConfirm()}>
{$L('确定')}
</button>
</div>
</RbModal>
)
}
handleConfirm = () => {
handleConfirm() {
if (rb.commercial < 1) {
RbHighbar.error(WrapHtml($L('免费版不支持此功能 [(查看详情)](https://getrebuild.com/docs/rbv-features)')))
return
}
const selected = []
$(this._fields)
.find('input:checked')

View file

@ -6,11 +6,6 @@ See LICENSE and COMMERCIAL in the project root for license information.
*/
/* global dlgActionAfter ShowEnable */
let bosskeyShow = false
window.bosskeyTrigger = function () {
bosskeyShow = true
}
$(document).ready(function () {
$('.J_add').click(() => renderRbcomp(<TriggerEdit />))
renderRbcomp(<TriggerList />, 'dataList')
@ -25,6 +20,7 @@ const RBV_TRIGGERS = {
'PROXYTRIGGERACTION': $L('自定义触发器'),
'AUTOUNSHARE': $L('自动取消共享'),
'CREATEFEED': $L('新建动态'),
'AUTOGENREPORT': $L('自动报表导出'),
}
const WHENS = {
@ -197,8 +193,8 @@ class TriggerEdit extends ConfigFormDlg {
// #1
$.get('/admin/robot/trigger/available-actions', (res) => {
let actions = res.data || []
if (!bosskeyShow) {
actions = actions.filter((item) => item[0] !== 'PROXYTRIGGERACTION')
if (!window.__BOSSKEY) {
actions = actions.filter((item) => !['PROXYTRIGGERACTION', 'AUTOGENREPORT'].includes(item[0]))
}
this.setState({ actions }, () => {

View file

@ -230,6 +230,9 @@ class ContentFieldAggregation extends ActionContentSpec {
if (content.stopPropagation === true) $(this._$stopPropagation).attr('checked', true).parents('.bosskey-show').removeClass('bosskey-show')
this.saveAdvFilter(content.dataFilter)
$(this._$matchFields).val(content.targetEntityMatchFields || null)
// eslint-disable-next-line no-undef
DlgSpecFields.render(content)
}
}
@ -434,6 +437,9 @@ renderContentComp = function (props) {
$('#react-content [data-toggle="tooltip"]').tooltip()
})
// 指定字段
$('.when-update a.hide').removeClass('hide')
// eslint-disable-next-line no-undef
useExecManual()
}

View file

@ -244,6 +244,9 @@ class ContentFieldWriteback extends ActionContentSpec {
$(this._$stopPropagation).attr('checked', content.stopPropagation === true)
if (content.stopPropagation === true) $(this._$stopPropagation).parents('.bosskey-show').removeClass('bosskey-show')
$(this._$matchFields).val(content.targetEntityMatchFields || null)
// eslint-disable-next-line no-undef
DlgSpecFields.render(content)
}
}
@ -637,6 +640,9 @@ renderContentComp = function (props) {
$('#react-content [data-toggle="tooltip"]').tooltip()
})
// 指定字段
$('.when-update a.hide').removeClass('hide')
// eslint-disable-next-line no-undef
useExecManual()
}

View file

@ -284,6 +284,9 @@ class ContentGroupAggregation extends ActionContentSpec {
$(this._$stopPropagation).attr('checked', true).parents('.bosskey-show').removeClass('bosskey-show')
}
this.saveAdvFilter(content.dataFilter)
// eslint-disable-next-line no-undef
DlgSpecFields.render(content)
} else {
$(this._$autoCreate).attr('checked', true)
}
@ -546,6 +549,9 @@ renderContentComp = function (props) {
$('#react-content [data-toggle="tooltip"]').tooltip()
})
// 指定字段
$('.when-update a.hide').removeClass('hide')
// eslint-disable-next-line no-undef
useExecManual()
}

View file

@ -232,7 +232,6 @@ class ContentSendNotification extends ActionContentSpec {
return false
}
if (window.whenUpdateFields) _data.whenUpdateFields = window.whenUpdateFields
return _data
}
}
@ -277,22 +276,20 @@ class AccountSelectorWithField extends UserSelector {
// eslint-disable-next-line no-undef
LastLogsViewer.renderLog = function (log) {
return log.level === 1 && log.message ? (
<dl className="m-0">
<dt>{$L('已发送至')}</dt>
<dd className="mb-0">
{log.message.split(',').map((a, idx) => {
return $regex.isId(a) ? (
<a key={idx} className="badge text-id" href={`${rb.baseUrl}/app/redirect?id=${a}&type=newtab`} target="_blank">
{a}
</a>
) : (
<span key={idx} className="badge text-id text-break">
{a}
</span>
)
})}
</dd>
</dl>
<div className="v36-logdesc">
{$L('已发送至')}
{log.message.split(',').map((a, idx) => {
return $regex.isId(a) ? (
<a key={idx} className="badge text-id" href={`${rb.baseUrl}/app/redirect?id=${a}&type=newtab`} target="_blank">
{a}
</a>
) : (
<span key={idx} className="badge">
{a}
</span>
)
})}
</div>
) : (
<p className="m-0 text-muted text-uppercase">{log.message || 'N'}</p>
)

View file

@ -8,9 +8,17 @@ See LICENSE and COMMERCIAL in the project root for license information.
package com.rebuild.utils;
import cn.devezhao.commons.excel.IRow;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFSimpleShape;
import org.apache.poi.xssf.usermodel.XSSFTextRun;
import org.junit.jupiter.api.Test;
import org.springframework.util.ResourceUtils;
import java.io.File;
import java.io.IOException;
/**
@ -29,4 +37,24 @@ class ExcelUtilsTest {
System.out.println(row.getCell("h"));
}
}
@Test
void testShape() throws IOException {
try (Workbook wb = WorkbookFactory.create(new File("/Users/zhaoff/Desktop/1.xlsx"))) {
Sheet sheet = wb.getSheetAt(0);
for (Object o : sheet.getDrawingPatriarch()) {
XSSFSimpleShape shape = (XSSFSimpleShape) o;
XSSFTextRun s = shape.getTextParagraphs().get(0).getTextRuns().get(0);
XSSFFont font = (XSSFFont) wb.createFont();
font.setFontName(s.getFontFamily());
font.setFontHeightInPoints((short) s.getFontSize());
font.setBold(s.isBold());
font.setItalic(s.isItalic());
XSSFRichTextString richTextString = new XSSFRichTextString("11");
richTextString.applyFont(font);
}
}
}
}