Skip to content

Commit

Permalink
Fix 3.4.4 (#665)
Browse files Browse the repository at this point in the history
* fix:Gitee#I8326Z

* fix: 删除时不生效

* fix: tag fillback

* v3.4.4

* frontjs-sdk-demo

* bk: getActualMaximum
  • Loading branch information
getrebuild authored Sep 28, 2023
1 parent 188cbf7 commit 41d33a4
Show file tree
Hide file tree
Showing 10 changed files with 320 additions and 22 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from e83ed9 to 0ace77
10 changes: 4 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>3.4.3</version>
<version>3.4.4</version>
<name>rebuild</name>
<description>Building your business-systems freely!</description>
<!-- UNCOMMENT USE TOMCAT -->
Expand Down Expand Up @@ -38,19 +38,17 @@
<!-- <includeSystemScope>true</includeSystemScope> -->
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-g:lines</arg>
<arg>-Xlint:unchecked</arg>
<arg>-Xlint:deprecation</arg>
<!-- <arg>-g:none</arg> -->
<!-- <arg>-Xlint:unchecked</arg> -->
<!-- <arg>-Xlint:deprecation</arg> -->
</compilerArgs>
</configuration>
</plugin>
-->
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/rebuild/core/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/**
* Rebuild Version
*/
public static final String VER = "3.4.3";
public static final String VER = "3.4.4";
/**
* Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2}
*/
public static final int BUILD = 3040308;
public static final int BUILD = 3040409;

static {
// Driver for DB
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/rebuild/core/service/BaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ private Callable2<Integer, Record> processN2NReference(final Record record, bool
for (Field n2nField : n2nFields) {
ID[] newRefs;
if (isNew) {
newRefs = record.getIDArray(n2nField.getName());
Object maybeNull = record.getObjectValue(n2nField.getName());
newRefs = NullValue.is(maybeNull) ? ID.EMPTY_ID_ARRAY : (ID[]) maybeNull;
if (newRefs == null || newRefs.length == 0) continue;
} else {
if (record.hasValue(n2nField.getName())) {
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/rebuild/core/service/approval/FlowParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
import com.rebuild.utils.JSONUtils;
import org.apache.commons.lang.StringUtils;

import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* 流程解析
Expand Down Expand Up @@ -102,11 +109,14 @@ public List<FlowNode> getNextNodes(String nodeId) {
return Collections.emptyList();
}

// 非条件分支,只会有一个节点
// 非条件分支只会有一个节点
if (!FlowNode.TYPE_BRANCH.equals(next.get(0).getType())) {
return next;
}

// fix:Gitee#I8326Z 移除非条件节点
next.removeIf(flowNode -> !flowNode.getType().equals(FlowNode.TYPE_BRANCH));

// 条件节点优先级排序
next.sort((o1, o2) -> {
int p1 = ((FlowBranch) o1).getPriority();
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/com/rebuild/core/service/query/AdvFilterParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,26 +335,32 @@ else if (ParseHelper.IN.equals(op) && ID.isId(value)) {
int x = NumberUtils.toInt(value);
value = formatDate(addDay(x), 0);
} else if (ParseHelper.EVW.equalsIgnoreCase(op) || ParseHelper.EVM.equalsIgnoreCase(op)) {
Calendar c = CalendarUtils.getInstance();
final Calendar today = 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);
boolean isSunday = today.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY;
if (isSunday) today.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);
today.set(Calendar.DAY_OF_WEEK, x);
} else {
c.set(Calendar.DAY_OF_WEEK, 7);
c.add(Calendar.DAY_OF_WEEK, 1);
today.set(Calendar.DAY_OF_WEEK, 7);
today.add(Calendar.DAY_OF_WEEK, 1);
}
} else {
if (x < 1) x = 1;
if (x > 31) x = 31;
c.set(Calendar.DAY_OF_MONTH, x);

// v3.4.4 每月最后一天
int maxDayOfMonth = today.getActualMaximum(Calendar.DAY_OF_MONTH);
if (x > maxDayOfMonth) x = maxDayOfMonth;

today.set(Calendar.DAY_OF_MONTH, x);
}
value = formatDate(c.getTime(), 0);
value = formatDate(today.getTime(), 0);
}
else if (ParseHelper.YTA.equalsIgnoreCase(op)) {
value = formatDate(addDay(-1), 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*!
Copyright (c) Ruifang Tech <http://ruifang-tech.com/> and/or its owners. All rights reserved.
*/

package com.rebuild.core.service.trigger.impl;

import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Field;
import cn.devezhao.persist4j.dialect.FieldType;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.core.Application;
import com.rebuild.core.metadata.EntityHelper;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.privileges.bizz.InternalPermission;
import com.rebuild.core.service.approval.ApprovalHelper;
import com.rebuild.core.service.approval.ApprovalState;
import com.rebuild.core.service.general.OperatingContext;
import com.rebuild.core.service.trigger.ActionContext;
import com.rebuild.core.service.trigger.TriggerAction;
import com.rebuild.core.service.trigger.TriggerException;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* @author devezhao
* @since 2023/9/27
*/
@Slf4j
public abstract class AutoHoldTriggerAction extends TriggerAction {

private Set<ID> willRecords;

protected AutoHoldTriggerAction(ActionContext actionContext) {
super(actionContext);
}

// 删除前保持
@Override
protected void prepare(OperatingContext operatingContext) throws TriggerException {
if (operatingContext.getAction() == InternalPermission.DELETE_BEFORE) {
willRecords = getRelatedRecords(
actionContext, operatingContext.getAnyRecord().getPrimary());
}
}

/**
* 获取待处理记录
*
* @param operatingContext
* @return
*/
protected Set<ID> getWillRecords(OperatingContext operatingContext) {
if (willRecords == null) {
willRecords = getRelatedRecords(
actionContext, operatingContext.getAnyRecord().getPrimary());
}
return willRecords;
}

/**
* 获取相关记录
*
* @param actionContext
* @param sourceRecordId
* @return
*/
protected static Set<ID> getRelatedRecords(ActionContext actionContext, ID sourceRecordId) {
// 共享的需要使用记录 ID
if (sourceRecordId.getEntityCode() == EntityHelper.ShareAccess) {
Object[] o = Application.getQueryFactory().uniqueNoFilter(sourceRecordId, "recordId");
if (o == null) return Collections.emptySet();
sourceRecordId = (ID) o[0];
}

final JSONObject actionContent = (JSONObject) actionContext.getActionContent();

Entity sourceEntity = actionContext.getSourceEntity();
JSONArray fs = actionContent.getJSONArray("fields");

List<String> fieldsSelf = new ArrayList<>();
List<Field> fieldsRefto = new ArrayList<>();
boolean hasSelf = false;

for (Object o : fs) {
String field = (String) o;
if (field.contains(".")) {
String[] fieldAndEntity = field.split("\\.");
if (MetadataHelper.containsField(fieldAndEntity[1], fieldAndEntity[0])) {
fieldsRefto.add(MetadataHelper.getField(fieldAndEntity[1], fieldAndEntity[0]));
}

} else {
if (SOURCE_SELF.equals(field)) {
fieldsSelf.add(sourceEntity.getPrimaryField().getName());
hasSelf = true;
} if (sourceEntity.containsField(field)) {
fieldsSelf.add(field);
}
}
}

final Set<ID> relateds = new HashSet<>();

if (!fieldsSelf.isEmpty()) {
fieldsSelf.add(sourceEntity.getPrimaryField().getName());
Object[] o = Application.getQueryFactory().uniqueNoFilter(sourceRecordId, fieldsSelf.toArray(new String[0]));
if (o != null) {
for (Object id : o) {
if (id != null) {
if (id instanceof ID[]) Collections.addAll(relateds, (ID[]) id);
else relateds.add((ID) id);
}
}
}
}

for (Field refto : fieldsRefto) {
Entity ownEntity = refto.getOwnEntity();
String sql = String.format("select %s from %s where ",
ownEntity.getPrimaryField().getName(), ownEntity.getName());

// N2N
if (refto.getType() == FieldType.REFERENCE_LIST) {
sql += String.format(
"exists (select recordId from NreferenceItem where ^%s = recordId and belongField = '%s' and referenceId = '%s')",
ownEntity.getPrimaryField().getName(), refto.getName(), sourceRecordId);
} else {
sql += String.format("%s = '%s'", refto.getName(), sourceRecordId);
}

Object[][] array = Application.createQueryNoFilter(sql).array();
for (Object[] o : array) relateds.add((ID) o[0]);
}

// 不含自己
if (!hasSelf) relateds.remove(sourceRecordId);

return relateds;
}

/**
* 获取审核状态
*
* @param recordId
* @return
* @see ApprovalHelper#getApprovalState(ID)
*/
protected static ApprovalState getApprovalState(ID recordId) {
Entity entity = MetadataHelper.getEntity(recordId.getEntityCode());
if (MetadataHelper.hasApprovalField(entity)) return ApprovalHelper.getApprovalState(recordId);
else return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
package com.rebuild.core.service.trigger.impl;

import cn.devezhao.bizz.privileges.impl.BizzPermission;
import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.core.Application;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.privileges.PrivilegesGuardContextHolder;
import com.rebuild.core.privileges.UserHelper;
import com.rebuild.core.service.general.EntityService;
import com.rebuild.core.service.general.GeneralEntityServiceContextHolder;
import com.rebuild.core.service.general.OperatingContext;
import com.rebuild.core.service.trigger.ActionContext;
import com.rebuild.core.service.trigger.ActionType;
import com.rebuild.core.service.trigger.TriggerAction;
import com.rebuild.core.service.trigger.TriggerException;
import com.rebuild.core.service.trigger.TriggerResult;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -33,7 +36,7 @@
* @since 2019/8/23
*/
@Slf4j
public class AutoShare extends AutoAssign {
public class AutoShare extends TriggerAction {

public AutoShare(ActionContext context) {
super(context);
Expand All @@ -44,6 +47,12 @@ public ActionType getType() {
return ActionType.AUTOSHARE;
}

@Override
public boolean isUsableSourceEntity(int entityCode) {
Entity e = MetadataHelper.getEntity(entityCode);
return MetadataHelper.hasPrivilegesField(e) || e.getMainEntity() != null;
}

@Override
public Object execute(OperatingContext operatingContext) throws TriggerException {
final JSONObject content = (JSONObject) actionContext.getActionContent();
Expand Down
19 changes: 18 additions & 1 deletion src/main/resources/web/assets/js/rb-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2683,7 +2683,24 @@ class RbFormTag extends RbFormElement {
}
}

// isValueUnchanged() {}
setValue(val) {
if (typeof val === 'object') val = val.join('$$$$')
super.setValue(val)

// fix: v3.4.4
if ($empty(val)) {
this.__select2.val(null).trigger('change')
} else {
const names = []
val.split('$$$$').forEach((name) => {
if (!names.includes(name)) {
const o = new Option(name, name, true, true)
this.__select2.append(o)
names.push(name)
}
})
}
}
}

// 不支持/未开放的字段
Expand Down
Loading

0 comments on commit 41d33a4

Please sign in to comment.