Fix v3.4.2 (#659)

* fix: Gitee#I7ZYWV

* be: getNetworkDate

* fix: disabled DateNotSync

* 3.4.2

* feat: DDD/EVW/WVM
This commit is contained in:
REBUILD 企业管理系统 2023-09-14 20:59:38 +08:00 committed by GitHub
parent 5ef90d9924
commit 37c01feb0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 97 additions and 30 deletions

2
@rbv

@ -1 +1 @@
Subproject commit 1800694397aa07bee3317f059b25e1b78a569f08
Subproject commit e83ed9efb79ef2bffacbbe8c2288aecc7bcd2042

View file

@ -82,7 +82,7 @@ REBUILD 对于开发环境的要求非常简单,由于使用 Java 开发,因
- MySQL 5.6+
- Redis 3.2+(非必须,默认使用内置的 Ehcache 缓存)
- Tomcat 8.0+(非必须,默认使用 SpringBooot 内置 Tomcat
- Apache Maven 3.3+
- Apache Maven 3.6+
- IDEA 或 Eclipse (for JEE)
更多详情请参见 [开发人员文档](https://getrebuild.com/docs/dev/)

View file

@ -10,7 +10,7 @@
</parent>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
<name>rebuild</name>
<description>Building your business-systems freely!</description>
<!-- UNCOMMENT USE TOMCAT -->

View file

@ -73,11 +73,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/**
* Rebuild Version
*/
public static final String VER = "3.4.1";
public static final String VER = "3.4.2";
/**
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
*/
public static final int BUILD = 3040106;
public static final int BUILD = 3040207;
static {
// Driver for DB

View file

@ -22,6 +22,7 @@ import com.rebuild.core.metadata.EntityHelper;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.metadata.MetadataSorter;
import com.rebuild.core.metadata.easymeta.DisplayType;
import com.rebuild.core.metadata.easymeta.EasyDecimal;
import com.rebuild.core.metadata.easymeta.EasyField;
import com.rebuild.core.metadata.easymeta.EasyMetaFactory;
import com.rebuild.core.metadata.impl.EasyEntityConfigProps;
@ -219,7 +220,7 @@ public class FormsBuilder extends FormsManager {
}
}
buildModelElements(elements, entityMeta, recordData, user, !viewMode);
buildModelElements(elements, entityMeta, recordData, user, viewMode, !viewMode);
if (elements.isEmpty()) {
return formatModelError(Language.L("此表单布局尚未配置,请配置后使用"));
@ -318,9 +319,10 @@ public class FormsBuilder extends FormsManager {
* @param entity
* @param recordData
* @param user
* @param viewModel
* @param useAdvControl
*/
protected void buildModelElements(JSONArray elements, Entity entity, Record recordData, ID user, boolean useAdvControl) {
protected void buildModelElements(JSONArray elements, Entity entity, Record recordData, ID user, boolean viewModel, boolean useAdvControl) {
final User formUser = Application.getUserStore().getUser(user);
final Date now = CalendarUtils.now();
@ -345,6 +347,7 @@ public class FormsBuilder extends FormsManager {
Object displayOnUpdate = el.remove("displayOnUpdate");
Object requiredOnCreate = el.remove("requiredOnCreate");
Object requiredOnUpdate = el.remove("requiredOnUpdate");
if (viewModel) useAdvControl = false;
if (useAdvControl) {
// fix v3.3.4 跟随主记录新建/更新
boolean isNew2 = isNew;
@ -474,12 +477,12 @@ public class FormsBuilder extends FormsManager {
} else {
Object defaultValue = easyField.exprDefaultValue();
if (defaultValue != null) {
defaultValue = easyField.wrapValue(defaultValue);
// `wrapValue` 会添加格式符号
if (easyField.getDisplayType() == DisplayType.DECIMAL) {
el.put("value", defaultValue.toString());
} else {
el.put("value", easyField.wrapValue(defaultValue));
defaultValue = EasyDecimal.clearFlaged(defaultValue);
}
el.put("value", defaultValue);
}
}
}
@ -514,9 +517,14 @@ public class FormsBuilder extends FormsManager {
// 编辑/视图/记录转换
if (recordData != null) {
// FIXME `wrapFieldValue` 会添加格式符号小数
Object value = wrapFieldValue(recordData, easyField, user);
if (value != null) el.put("value", value);
if (value != null) {
// `wrapValue` 会添加格式符号
if (!viewModel && easyField.getDisplayType() == DisplayType.DECIMAL) {
value = EasyDecimal.clearFlaged(value);
}
el.put("value", value);
}
// 父级级联
if ((dt == DisplayType.REFERENCE || dt == DisplayType.N2NREFERENCE) && recordData.getPrimary() != null) {

View file

@ -65,7 +65,7 @@ public class LiteFormBuilder {
}
}
FormsBuilder.instance.buildModelElements(fieldElements, entity, recordData, user, false);
FormsBuilder.instance.buildModelElements(fieldElements, entity, recordData, user, false, false);
return fieldElements;
}

View file

@ -108,4 +108,15 @@ public class EasyDecimal extends EasyField {
return BigDecimal.valueOf(d);
}
}
/**
* 清除小数符号
*
* @param flagedValue
* @return
*/
public static String clearFlaged(Object flagedValue) {
if (flagedValue == null) return null;
return flagedValue.toString().replaceAll("[^\\d^.^-]", "");
}
}

View file

@ -180,7 +180,7 @@ public class TransformerPreview {
if (hasError != null) throw new DataSpecificationException(hasError);
JSONArray elements = ((JSONObject) model).getJSONArray("elements");
buildModelElements(elements, entity, record, user, true);
buildModelElements(elements, entity, record, user, false, true);
return model;
}
}

View file

@ -39,6 +39,7 @@ import org.springframework.util.Assert;
import java.math.BigDecimal;
import java.time.temporal.TemporalAccessor;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap;
@ -326,9 +327,36 @@ public class AdvFilterParser extends SetUser {
if (ParseHelper.TDA.equalsIgnoreCase(op)
|| ParseHelper.YTA.equalsIgnoreCase(op)
|| ParseHelper.TTA.equalsIgnoreCase(op)) {
|| ParseHelper.TTA.equalsIgnoreCase(op)
|| ParseHelper.DDD.equalsIgnoreCase(op)
|| ParseHelper.EVW.equalsIgnoreCase(op) || ParseHelper.EVM.equalsIgnoreCase(op)) {
if (ParseHelper.YTA.equalsIgnoreCase(op)) {
if (ParseHelper.DDD.equalsIgnoreCase(op)) {
int x = NumberUtils.toInt(value);
value = formatDate(addDay(x), 0);
} else if (ParseHelper.EVW.equalsIgnoreCase(op) || ParseHelper.EVM.equalsIgnoreCase(op)) {
Calendar c = CalendarUtils.getInstance();
int x = NumberUtils.toInt(value);
if (ParseHelper.EVW.equalsIgnoreCase(op)) {
boolean isSunday = c.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY;
if (isSunday) c.add(Calendar.DAY_OF_WEEK, -1);
if (x < 1) x = 1;
if (x > 7) x = 7;
x += 1;
if (x <= 7) {
c.set(Calendar.DAY_OF_WEEK, x);
} else {
c.set(Calendar.DAY_OF_WEEK, 7);
c.add(Calendar.DAY_OF_WEEK, 1);
}
} else {
if (x < 1) x = 1;
if (x > 31) x = 31;
c.set(Calendar.DAY_OF_MONTH, x);
}
value = formatDate(c.getTime(), 0);
}
else if (ParseHelper.YTA.equalsIgnoreCase(op)) {
value = formatDate(addDay(-1), 0);
} else if (ParseHelper.TTA.equalsIgnoreCase(op)) {
value = formatDate(addDay(1), 0);
@ -774,9 +802,7 @@ public class AdvFilterParser extends SetUser {
// 括弧成对出现
for (int i = 0; i < 20; i++) {
clearEquation = clearEquation.replace("()", "");
if (clearEquation.length() == 0) {
return equation;
}
if (clearEquation.isEmpty()) return equation;
}
return null;
}

View file

@ -94,6 +94,9 @@ public class ParseHelper {
public static final String PUY = "PUY"; // 本年-
public static final String CUY = "CUY"; // 本年
public static final String NUY = "NUY"; // 本年+
public static final String DDD = "DDD"; // 指定天+-
public static final String EVW = "EVW"; // 每周几
public static final String EVM = "EVM"; // 每月几
// 日期时间
@ -180,6 +183,8 @@ public class ParseHelper {
PUW.equalsIgnoreCase(token) || PUM.equalsIgnoreCase(token) || PUQ.equalsIgnoreCase(token) || PUY.equalsIgnoreCase(token) ||
NUW.equalsIgnoreCase(token) || NUM.equalsIgnoreCase(token) || NUQ.equalsIgnoreCase(token) || NUY.equalsIgnoreCase(token)) {
return "between";
} else if (DDD.equalsIgnoreCase(token) || EVW.equalsIgnoreCase(token) || EVM.equalsIgnoreCase(token)) {
return "=";
}
throw new UnsupportedOperationException("Unsupported token of operation : " + token);

View file

@ -18,6 +18,7 @@ import com.rebuild.core.cache.CommonsCache;
import com.rebuild.core.support.i18n.Language;
import com.rebuild.utils.CommonsUtils;
import com.rebuild.utils.OshiUtils;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;
import java.io.File;
@ -29,6 +30,7 @@ import java.util.LinkedHashMap;
* @author devezhao
* @since 2020/12/7
*/
@Slf4j
public class SysbaseHeartbeat {
private static final String CKEY_DANGERS = "_DANGERS";
@ -75,10 +77,14 @@ public class SysbaseHeartbeat {
}
// #3
Date networkDate = OshiUtils.getNetworkDate();
long networkDateLeft = (networkDate.getTime() - CalendarUtils.now().getTime()) / 1000;
final Date networkDate = OshiUtils.getNetworkDate();
final Date localDate = CalendarUtils.now();
final long networkDateLeft = (networkDate.getTime() - localDate.getTime()) / 1000;
if (Math.abs(networkDateLeft) > 15) {
log.warn("Server date offset : {} vs {}", networkDate, localDate);
dangers.put(DateNotSync, String.valueOf(networkDateLeft));
// FIXME v3.4.2 暂时禁用
dangers.remove(DateNotSync);
} else {
dangers.remove(DateNotSync);
}

View file

@ -7,6 +7,7 @@ See LICENSE and COMMERCIAL in the project root for license information.
package com.rebuild.utils;
import cn.devezhao.commons.CalendarUtils;
import cn.devezhao.commons.ObjectUtils;
import cn.devezhao.commons.runtime.MemoryInformationBean;
import com.esotericsoftware.minlog.Log;
@ -115,9 +116,8 @@ public class OshiUtils {
*/
public static Date getNetworkDate() {
final String[] FROMURLS = new String[] {
"http://www.baidu.com/",
"http://bjtime.cn/",
"http://www.google.com/",
"https://www.baidu.com/",
"https://www.microsoft.com/",
};
for (String u : FROMURLS) {
@ -126,11 +126,10 @@ public class OshiUtils {
long l = conn.getDate();
return new Date(l);
} catch (Exception ex) {
Log.debug("Failed with : {}", u);
log.warn("Cannot fetch date from : {}", u, ex);
}
}
log.warn("Cannot getdate from network");
return new Date();
return CalendarUtils.now();
}
}

View file

@ -2724,5 +2724,8 @@
"你无权撤销审批":"你无权撤销审批",
"你无权撤回审批":"你无权撤回审批",
"无权访问该页面":"无权访问该页面",
"系统即将开始维护,暂时禁止登录":"系统即将开始维护,暂时禁止登录"
"系统即将开始维护,暂时禁止登录":"系统即将开始维护,暂时禁止登录",
"本月..":"本月..",
"指定..天":"指定..天",
"本周..":"本周.."
}

View file

@ -337,6 +337,9 @@ const OP_TYPE = {
NUQ: $L('下季度'),
PUY: $L('去年'),
NUY: $L('明年'),
EVW: $L('本周..'),
EVM: $L('本月..'),
DDD: $L('指定..'),
}
const OP_NOVALUE = ['NL', 'NT', 'SFU', 'SFB', 'SFD', 'YTA', 'TDA', 'TTA', 'PUW', 'CUW', 'NUW', 'PUM', 'CUM', 'NUM', 'PUQ', 'CUQ', 'NUQ', 'PUY', 'CUY', 'NUY']
const OP_DATE_NOPICKER = [
@ -367,6 +370,9 @@ const OP_DATE_NOPICKER = [
'PUY',
'CUY',
'NUY',
'EVW',
'EVM',
'DDD',
]
const REFENTITY_CACHE = {}
const PICKLIST_CACHE = {}
@ -453,6 +459,9 @@ class FilterItem extends React.Component {
'PUY',
'CUY',
'NUY',
'EVW',
'EVM',
'DDD',
]
} else if (fieldType === 'TIME') {
op = ['GT', 'LT', 'EQ', 'BW']

View file

@ -88,11 +88,11 @@
</tr>
<tr>
<th>System Time</th>
<td>[[${T(cn.devezhao.commons.CalendarUtils).now().toLocaleString()}]]</td>
<td>[[${T(cn.devezhao.commons.CalendarUtils).now()}]]</td>
</tr>
<tr>
<th>Startup Time</th>
<td>[[${T(com.rebuild.core.ServerStatus).STARTUP_TIME.toLocaleString()}]]</td>
<td>[[${T(com.rebuild.core.ServerStatus).STARTUP_TIME}]]</td>
</tr>
<tr>
<th>Data Directory</th>