Просмотр исходного кода

Merge branch 'wrdp' into 'develop'

Wrdp

See merge request o2oa/o2oa!2501
o2null 5 лет назад
Родитель
Сommit
da05509f06

+ 7 - 7
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/element/Delay.java

@@ -352,12 +352,12 @@ public class Delay extends Activity {
 	@CheckPersist(allowEmpty = true)
 	private String route;
 
-	public static final String delayMode_FIELDNAME = "delayMode";
+	public static final String delayType_FIELDNAME = "delayType";
 	@Enumerated(EnumType.STRING)
 	@FieldDescribe("延时类型,minute或者until")
-	@Column(length = DelayMode.length, name = ColumnNamePrefix + delayMode_FIELDNAME)
+	@Column(length = DelayType.length, name = ColumnNamePrefix + delayType_FIELDNAME)
 	@CheckPersist(allowEmpty = true)
-	private DelayMode delayMode;
+	private DelayType delayType;
 
 	public static final String delayTime_FIELDNAME = "delayTime";
 	@FieldDescribe("延时至时间.")
@@ -792,12 +792,12 @@ public class Delay extends Activity {
 		this.opinionGroup = opinionGroup;
 	}
 
-	public DelayMode getDelayMode() {
-		return delayMode;
+	public DelayType getDelayType() {
+		return delayType;
 	}
 
-	public void setDelayMode(DelayMode delayMode) {
-		this.delayMode = delayMode;
+	public void setDelayType(DelayType delayType) {
+		this.delayType = delayType;
 	}
 
 	public String getEdition() {

+ 1 - 2
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/element/DelayMode.java → o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/element/DelayType.java

@@ -2,8 +2,7 @@ package com.x.processplatform.core.entity.element;
 
 import com.x.base.core.entity.JpaObject;
 
-public enum DelayMode {
-	/* 定义的时候使用了 @Enumerated(EnumType.ORDINAL),这里的顺序不能修改 */
+public enum DelayType {
 	until, minute;
 	public static final int length = JpaObject.length_16B;
 }

+ 37 - 23
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/delay/DelayProcessor.java

@@ -5,6 +5,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
+import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateUtils;
 
@@ -15,7 +16,7 @@ import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.DateTools;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.element.Delay;
-import com.x.processplatform.core.entity.element.DelayMode;
+import com.x.processplatform.core.entity.element.DelayType;
 import com.x.processplatform.core.entity.element.Route;
 import com.x.processplatform.core.entity.log.Signal;
 import com.x.processplatform.service.processing.Business;
@@ -38,6 +39,7 @@ public class DelayProcessor extends AbstractDelayProcessor {
 
 	@Override
 	protected void arrivingCommitted(AeiObjects aeiObjects, Delay delay) throws Exception {
+		// nothing
 	}
 
 	@Override
@@ -46,11 +48,11 @@ public class DelayProcessor extends AbstractDelayProcessor {
 		aeiObjects.getProcessingAttributes().push(Signal.delayExecute(aeiObjects.getWork().getActivityToken(), delay));
 		List<Work> results = new ArrayList<>();
 		Date limit = null;
-		if (null != delay.getDelayMode() && Objects.equals(DelayMode.until, delay.getDelayMode())) {
+		if (null != delay.getDelayType() && Objects.equals(DelayType.until, delay.getDelayType())) {
 			limit = this.until(aeiObjects, delay);
 		} else {
 			Integer minutes = this.minute(aeiObjects, delay);
-			if (delay.getWorkMinute()) {
+			if (BooleanUtils.isTrue(delay.getWorkMinute())) {
 				limit = Config.workTime().forwardMinutes(aeiObjects.getWork().getStartTime(), minutes);
 			} else {
 				limit = DateUtils.addMinutes(aeiObjects.getWork().getStartTime(), minutes);
@@ -72,28 +74,38 @@ public class DelayProcessor extends AbstractDelayProcessor {
 		if (null != delay.getDelayTime()) {
 			return delay.getDelayTime();
 		} else if (StringUtils.isNotEmpty(delay.getDelayDataPath())) {
-			Object o = aeiObjects.getData().find(delay.getDelayDataPath());
-			if (null != o) {
-				if (o instanceof Date) {
-					return (Date) o;
-				} else {
-					if (o instanceof String) {
-						return DateTools.parse(o.toString());
-					}
-				}
-			}
+			return untilDelayDataPath(aeiObjects, delay);
 		} else if (StringUtils.isNotEmpty(delay.getDelayScript())
 				|| StringUtils.isNotEmpty(delay.getDelayScriptText())) {
-			Object o = aeiObjects.business().element()
-					.getCompiledScript(aeiObjects.getWork().getApplication(), delay, Business.EVENT_DELAY)
-					.eval(aeiObjects.scriptContext());
-			if (null != o) {
-				if (o instanceof Date) {
-					return (Date) o;
-				} else {
-					if (o instanceof String) {
-						return DateTools.parse(o.toString());
-					}
+			return untilDelayScript(aeiObjects, delay);
+		}
+		return null;
+	}
+
+	private Date untilDelayDataPath(AeiObjects aeiObjects, Delay delay) throws Exception {
+		Object o = aeiObjects.getData().find(delay.getDelayDataPath());
+		if (null != o) {
+			if (o instanceof Date) {
+				return (Date) o;
+			} else {
+				if (o instanceof String) {
+					return DateTools.parse(o.toString());
+				}
+			}
+		}
+		return null;
+	}
+
+	private Date untilDelayScript(AeiObjects aeiObjects, Delay delay) throws Exception {
+		Object o = aeiObjects.business().element()
+				.getCompiledScript(aeiObjects.getWork().getApplication(), delay, Business.EVENT_DELAY)
+				.eval(aeiObjects.scriptContext());
+		if (null != o) {
+			if (o instanceof Date) {
+				return (Date) o;
+			} else {
+				if (o instanceof String) {
+					return DateTools.parse(o.toString());
 				}
 			}
 		}
@@ -117,6 +129,7 @@ public class DelayProcessor extends AbstractDelayProcessor {
 
 	@Override
 	protected void executingCommitted(AeiObjects aeiObjects, Delay delay) throws Exception {
+		// nothing
 	}
 
 	@Override
@@ -130,5 +143,6 @@ public class DelayProcessor extends AbstractDelayProcessor {
 
 	@Override
 	protected void inquiringCommitted(AeiObjects aeiObjects, Delay delay) throws Exception {
+		// nothing
 	}
 }