Przeglądaj źródła

Merge branch 'fix/completableFuture' into 'wrdp'

修正completableFuture嵌套导致的deadlock

See merge request o2oa/o2oa!2188
o2null 5 lat temu
rodzic
commit
cf3d78470f
21 zmienionych plików z 828 dodań i 959 usunięć
  1. 17 21
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionListWithWorkOrWorkCompleted.java
  2. 30 10
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/BaseAction.java
  3. 12 21
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/control/ActionGetWorkOrWorkCompleted.java
  4. 25 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/control/BaseAction.java
  5. 77 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/BaseAction.java
  6. 34 56
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2Get.java
  7. 34 56
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2GetMobile.java
  8. 79 138
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2LookupWorkOrWorkCompleted.java
  9. 80 139
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2LookupWorkOrWorkCompletedMobile.java
  10. 23 14
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/record/ActionListWithWorkOrWorkCompleted.java
  11. 22 14
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/record/ActionListWithWorkOrWorkCompletedPaging.java
  12. 82 49
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionCountWithPerson.java
  13. 104 216
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionGetWithWorkOrWorkCompleted.java
  14. 60 61
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionRefer.java
  15. 28 11
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/BaseAction.java
  16. 91 123
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/V2GetWorkOrWorkCompleted.java
  17. 7 7
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/workcompleted/ActionManageGetAssignment.java
  18. 9 9
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/workcompleted/BaseAction.java
  19. 6 6
      o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/WorkCompletedProperties.java
  20. 3 3
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionMerge.java
  21. 5 5
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/end/EndProcessor.java

+ 17 - 21
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionListWithWorkOrWorkCompleted.java

@@ -5,6 +5,7 @@ import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.BooleanUtils;
@@ -12,6 +13,7 @@ import org.apache.commons.lang3.BooleanUtils;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
+import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
@@ -31,14 +33,24 @@ class ActionListWithWorkOrWorkCompleted extends BaseAction {
 	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String workOrWorkCompleted) throws Exception {
 
 		ActionResult<List<Wo>> result = new ActionResult<>();
+		CompletableFuture<List<Wo>> listFuture = listFuture(effectivePerson, workOrWorkCompleted);
+		CompletableFuture<Boolean> checkControlFuture = checkControlFuture(effectivePerson, workOrWorkCompleted);
+		result.setData(listFuture.get(10, TimeUnit.SECONDS));
+		if (BooleanUtils.isFalse(checkControlFuture.get(10, TimeUnit.SECONDS))) {
+			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
+		}
+		return result;
+
+	}
 
-		CompletableFuture<List<Wo>> _wos = CompletableFuture.supplyAsync(() -> {
+	private CompletableFuture<List<Wo>> listFuture(EffectivePerson effectivePerson, String flag) {
+		return CompletableFuture.supplyAsync(() -> {
 			List<Wo> wos = new ArrayList<>();
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
 				List<String> identities = business.organization().identity().listWithPerson(effectivePerson);
 				List<String> units = business.organization().unit().listWithPerson(effectivePerson);
-				final String job = business.job().findWithWorkOrWorkCompleted(workOrWorkCompleted);
+				final String job = business.job().findWithWorkOrWorkCompleted(flag);
 				for (Attachment attachment : business.entityManagerContainer().listEqual(Attachment.class,
 						Attachment.job_FIELDNAME, job)) {
 					Wo wo = Wo.copier.copy(attachment);
@@ -63,25 +75,6 @@ class ActionListWithWorkOrWorkCompleted extends BaseAction {
 			return wos;
 		});
 
-		CompletableFuture<Boolean> _control = CompletableFuture.supplyAsync(() -> {
-			Boolean value = false;
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				Business business = new Business(emc);
-				value = business.readableWithWorkOrWorkCompleted(effectivePerson, workOrWorkCompleted,
-						new ExceptionEntityNotExist(workOrWorkCompleted));
-			} catch (Exception e) {
-				logger.error(e);
-			}
-			return value;
-		});
-
-		if (BooleanUtils.isFalse(_control.get())) {
-			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
-		}
-
-		result.setData(_wos.get());
-
-		return result;
 	}
 
 	public static class Wo extends Attachment {
@@ -105,8 +98,11 @@ class ActionListWithWorkOrWorkCompleted extends BaseAction {
 
 	public static class WoControl extends GsonPropertyObject {
 		private static final long serialVersionUID = -7283783148043076205L;
+		@FieldDescribe("可读")
 		private Boolean allowRead = false;
+		@FieldDescribe("可写")
 		private Boolean allowEdit = false;
+		@FieldDescribe("可控制")
 		private Boolean allowControl = false;
 
 		public Boolean getAllowRead() {

+ 30 - 10
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/BaseAction.java

@@ -2,6 +2,7 @@ package com.x.processplatform.assemble.surface.jaxrs.attachment;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 import javax.persistence.EntityManager;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -13,9 +14,14 @@ import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.ListTools;
 import com.x.base.core.project.tools.StringTools;
 import com.x.processplatform.assemble.surface.Business;
@@ -24,6 +30,8 @@ import com.x.processplatform.core.entity.content.Attachment_;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
+	private static Logger logger = LoggerFactory.getLogger(BaseAction.class);
+
 	public static class WiExtraParam {
 		private String site;
 
@@ -176,13 +184,12 @@ abstract class BaseAction extends StandardJaxrsAction {
 	public boolean read(Attachment attachment, EffectivePerson effectivePerson, List<String> identities,
 			List<String> units, Business business) throws Exception {
 		boolean value = false;
-		if (ListTools.isEmpty(attachment.getReadIdentityList())
-				&& ListTools.isEmpty(attachment.getReadUnitList())) {
+		if (ListTools.isEmpty(attachment.getReadIdentityList()) && ListTools.isEmpty(attachment.getReadUnitList())) {
 			value = true;
-		}else if (ListTools.containsAny(identities, attachment.getReadIdentityList())
-					|| ListTools.containsAny(units, attachment.getReadUnitList())) {
+		} else if (ListTools.containsAny(identities, attachment.getReadIdentityList())
+				|| ListTools.containsAny(units, attachment.getReadUnitList())) {
 			value = true;
-		}else{
+		} else {
 			value = this.edit(attachment, effectivePerson, identities, units, business);
 		}
 		return value;
@@ -191,13 +198,12 @@ abstract class BaseAction extends StandardJaxrsAction {
 	public boolean edit(Attachment attachment, EffectivePerson effectivePerson, List<String> identities,
 			List<String> units, Business business) throws Exception {
 		boolean value = false;
-		if (ListTools.isEmpty(attachment.getEditIdentityList())
-				&& ListTools.isEmpty(attachment.getEditUnitList())) {
+		if (ListTools.isEmpty(attachment.getEditIdentityList()) && ListTools.isEmpty(attachment.getEditUnitList())) {
 			value = true;
-		}else if (ListTools.containsAny(identities, attachment.getEditIdentityList())
-					|| ListTools.containsAny(units, attachment.getEditUnitList())) {
+		} else if (ListTools.containsAny(identities, attachment.getEditIdentityList())
+				|| ListTools.containsAny(units, attachment.getEditUnitList())) {
 			value = true;
-		}else{
+		} else {
 			value = this.control(attachment, effectivePerson, identities, units, business);
 		}
 		return value;
@@ -221,4 +227,18 @@ abstract class BaseAction extends StandardJaxrsAction {
 		}
 		return value;
 	}
+
+	protected CompletableFuture<Boolean> checkControlFuture(EffectivePerson effectivePerson, String flag) {
+		return CompletableFuture.supplyAsync(() -> {
+			Boolean value = false;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				value = business.readableWithWorkOrWorkCompleted(effectivePerson, flag,
+						new ExceptionEntityNotExist(flag));
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return value;
+		});
+	}
 }

+ 12 - 21
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/control/ActionGetWorkOrWorkCompleted.java

@@ -3,13 +3,13 @@ package com.x.processplatform.assemble.surface.jaxrs.control;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.lang3.BooleanUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
-import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.logger.Logger;
@@ -47,7 +47,17 @@ class ActionGetWorkOrWorkCompleted extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workOrWorkCompleted) throws Exception {
 		ActionResult<Wo> result = new ActionResult<>();
-		CompletableFuture<Wo> _wo = CompletableFuture.supplyAsync(() -> {
+		CompletableFuture<Wo> getFuture = this.getFuture(effectivePerson, workOrWorkCompleted);
+		CompletableFuture<Boolean> checkControlFuture = this.checkControlFuture(effectivePerson, workOrWorkCompleted);
+		result.setData(getFuture.get(10, TimeUnit.SECONDS));
+		if (BooleanUtils.isFalse(checkControlFuture.get(10, TimeUnit.SECONDS))) {
+			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
+		}
+		return result;
+	}
+
+	private CompletableFuture<Wo> getFuture(EffectivePerson effectivePerson, String workOrWorkCompleted) {
+		return CompletableFuture.supplyAsync(() -> {
 			Wo wo = null;
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
@@ -65,25 +75,6 @@ class ActionGetWorkOrWorkCompleted extends BaseAction {
 			}
 			return wo;
 		});
-
-		CompletableFuture<Boolean> _control = CompletableFuture.supplyAsync(() -> {
-			Boolean value = false;
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				Business business = new Business(emc);
-				value = business.readableWithWorkOrWorkCompleted(effectivePerson, workOrWorkCompleted,
-						new ExceptionEntityNotExist(workOrWorkCompleted));
-			} catch (Exception e) {
-				logger.error(e);
-			}
-			return value;
-		});
-
-		if (BooleanUtils.isFalse(_control.get())) {
-			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
-		}
-
-		result.setData(_wo.get());
-		return result;
 	}
 
 	private Wo workCompleted(Business business, EffectivePerson effectivePerson, WorkCompleted workCompleted)

+ 25 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/control/BaseAction.java

@@ -1,10 +1,21 @@
 package com.x.processplatform.assemble.surface.jaxrs.control;
 
+import java.util.concurrent.CompletableFuture;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.gson.GsonPropertyObject;
+import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.processplatform.assemble.surface.Business;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
+	private static Logger logger = LoggerFactory.getLogger(BaseAction.class);
+
 	protected static class AbstractControl extends GsonPropertyObject {
 		/* 是否可以看到 */
 		private Boolean allowVisit = false;
@@ -119,4 +130,18 @@ abstract class BaseAction extends StandardJaxrsAction {
 
 	}
 
+	protected CompletableFuture<Boolean> checkControlFuture(EffectivePerson effectivePerson, String flag) {
+		return CompletableFuture.supplyAsync(() -> {
+			Boolean value = false;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				value = business.readableWithWorkOrWorkCompleted(effectivePerson, flag,
+						new ExceptionEntityNotExist(flag));
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return value;
+		});
+	}
+
 }

+ 77 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/BaseAction.java

@@ -1,18 +1,33 @@
 package com.x.processplatform.assemble.surface.jaxrs.form;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+import java.util.concurrent.CompletableFuture;
 
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.cache.Cache.CacheCategory;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
 import com.x.base.core.project.jaxrs.WoMaxAgeFastETag;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.processplatform.assemble.surface.Business;
+import com.x.processplatform.core.entity.content.WorkCompletedProperties;
 import com.x.processplatform.core.entity.content.WorkCompletedProperties.RelatedForm;
 import com.x.processplatform.core.entity.content.WorkCompletedProperties.RelatedScript;
 import com.x.processplatform.core.entity.element.Form;
+import com.x.processplatform.core.entity.element.FormProperties;
 import com.x.processplatform.core.entity.element.Script;
 
 abstract class BaseAction extends StandardJaxrsAction {
 
+	private static Logger logger = LoggerFactory.getLogger(BaseAction.class);
+
+	
 	CacheCategory cacheCategory = new CacheCategory(Form.class, Script.class, com.x.portal.core.entity.Script.class,
 			com.x.cms.core.entity.element.Script.class);
 
@@ -52,4 +67,66 @@ abstract class BaseAction extends StandardJaxrsAction {
 
 	}
 
+	protected Map<String, RelatedScript> convertScript(Business bus, FormProperties properties) throws Exception {
+		Map<String, RelatedScript> map = new TreeMap<>();
+		for (Entry<String, String> entry : properties.getMobileRelatedScriptMap().entrySet()) {
+			switch (entry.getValue()) {
+			case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
+				Script pp = bus.script().pick(entry.getKey());
+				if (null != pp) {
+					map.put(entry.getKey(),
+							new RelatedScript(pp.getId(), pp.getName(), pp.getAlias(), pp.getText(), entry.getValue()));
+				}
+				break;
+			case WorkCompletedProperties.RelatedScript.TYPE_CMS:
+				com.x.cms.core.entity.element.Script cms = bus.cms().script().pick(entry.getKey());
+				if (null != cms) {
+					map.put(entry.getKey(), new RelatedScript(cms.getId(), cms.getName(), cms.getAlias(), cms.getText(),
+							entry.getValue()));
+				}
+				break;
+			case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
+				com.x.portal.core.entity.Script p = bus.portal().script().pick(entry.getKey());
+				if (null != p) {
+					map.put(entry.getKey(),
+							new RelatedScript(p.getId(), p.getName(), p.getAlias(), p.getText(), entry.getValue()));
+				}
+				break;
+			default:
+				break;
+			}
+		}
+		return map;
+	}
+
+	protected List<String> convertScriptToCacheTag(Business business, Map<String, String> map) throws Exception {
+		List<String> list = new ArrayList<>();
+		for (Entry<String, String> entry : map.entrySet()) {
+			switch (entry.getValue()) {
+			case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
+				Script pp = business.script().pick(entry.getKey());
+				if (null != pp) {
+					list.add(pp.getId() + pp.getUpdateTime().getTime());
+				}
+				break;
+			case WorkCompletedProperties.RelatedScript.TYPE_CMS:
+				com.x.cms.core.entity.element.Script cms = business.cms().script().pick(entry.getKey());
+				if (null != cms) {
+					list.add(cms.getId() + cms.getUpdateTime().getTime());
+				}
+				break;
+			case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
+				com.x.portal.core.entity.Script p = business.portal().script().pick(entry.getKey());
+				if (null != p) {
+					list.add(p.getId() + p.getUpdateTime().getTime());
+				}
+				break;
+			default:
+				break;
+			}
+		}
+		return list;
+	}
+
+
 }

+ 34 - 56
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2Get.java

@@ -1,10 +1,10 @@
 package com.x.processplatform.assemble.surface.jaxrs.form;
 
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.TreeMap;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
@@ -17,12 +17,10 @@ import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.ListTools;
 import com.x.processplatform.assemble.surface.Business;
-import com.x.processplatform.core.entity.content.WorkCompletedProperties;
 import com.x.processplatform.core.entity.content.WorkCompletedProperties.RelatedForm;
 import com.x.processplatform.core.entity.content.WorkCompletedProperties.RelatedScript;
 import com.x.processplatform.core.entity.element.Form;
 import com.x.processplatform.core.entity.element.FormProperties;
-import com.x.processplatform.core.entity.element.Script;
 
 class V2Get extends BaseAction {
 
@@ -35,36 +33,41 @@ class V2Get extends BaseAction {
 		if (optional.isPresent()) {
 			result.setData((Wo) optional.get());
 		} else {
-			Wo wo = this.get(id);
+			Form form = null;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				form = business.form().pick(id);
+			}
+			if (null == form) {
+				throw new ExceptionEntityNotExist(id, Form.class);
+			}
+			Wo wo = new Wo();
+			final FormProperties properties = form.getProperties();
+			wo.setFastETag(form.getId() + form.getUpdateTime().getTime());
+			wo.setForm(new RelatedForm(form, form.getDataOrMobileData()));
+			CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture = this.getRelatedFormFuture(properties);
+			CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture = this
+					.getRelatedScriptFuture(properties);
+			wo.setRelatedFormMap(getRelatedFormFuture.get(10, TimeUnit.SECONDS));
+			wo.setRelatedScriptMap(getRelatedScriptFuture.get(10, TimeUnit.SECONDS));
+			wo.setMaxAge(3600 * 24);
 			CacheManager.put(cacheCategory, cacheKey, wo);
 			result.setData(wo);
 		}
 		return result;
 	}
 
-	private Wo get(String id) throws Exception {
-		Form form = null;
-		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			Business business = new Business(emc);
-			form = business.form().pick(id);
-		}
-		if (null == form) {
-			throw new ExceptionEntityNotExist(id, Form.class);
-		}
-		Wo wo = new Wo();
-		final FormProperties properties = form.getProperties();
-		wo.setFastETag(form.getId() + form.getUpdateTime().getTime());
-		wo.setForm(new RelatedForm(form, form.getDataOrMobileData()));
-		CompletableFuture<Map<String, RelatedForm>> _relatedForm = CompletableFuture.supplyAsync(() -> {
+	private CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
 			Map<String, RelatedForm> map = new TreeMap<>();
 			if (ListTools.isNotEmpty(properties.getRelatedFormList())) {
 				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 					Business bus = new Business(emc);
-					Form _f;
-					for (String _id : properties.getRelatedFormList()) {
-						_f = bus.form().pick(_id);
-						if (null != _f) {
-							map.put(_id, new RelatedForm(_f, _f.getDataOrMobileData()));
+					Form f;
+					for (String id : properties.getRelatedFormList()) {
+						f = bus.form().pick(id);
+						if (null != f) {
+							map.put(id, new RelatedForm(f, f.getDataOrMobileData()));
 						}
 					}
 				} catch (Exception e) {
@@ -73,52 +76,27 @@ class V2Get extends BaseAction {
 			}
 			return map;
 		});
-		CompletableFuture<Map<String, RelatedScript>> _relatedScript = CompletableFuture.supplyAsync(() -> {
+	}
+
+	private CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
 			Map<String, RelatedScript> map = new TreeMap<>();
 			if ((null != properties.getRelatedScriptMap()) && (properties.getRelatedScriptMap().size() > 0)) {
 				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					Business bus = new Business(emc);
-					for (Entry<String, String> entry : properties.getRelatedScriptMap().entrySet()) {
-						switch (entry.getValue()) {
-						case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
-							Script _pp = bus.script().pick(entry.getKey());
-							if (null != _pp) {
-								map.put(entry.getKey(), new RelatedScript(_pp.getId(), _pp.getName(), _pp.getAlias(),
-										_pp.getText(), entry.getValue()));
-							}
-							break;
-						case WorkCompletedProperties.RelatedScript.TYPE_CMS:
-							com.x.cms.core.entity.element.Script _cms = bus.cms().script().pick(entry.getKey());
-							if (null != _cms) {
-								map.put(entry.getKey(), new RelatedScript(_cms.getId(), _cms.getName(), _cms.getAlias(),
-										_cms.getText(), entry.getValue()));
-							}
-							break;
-						case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
-							com.x.portal.core.entity.Script _p = bus.portal().script().pick(entry.getKey());
-							if (null != _p) {
-								map.put(entry.getKey(), new RelatedScript(_p.getId(), _p.getName(), _p.getAlias(),
-										_p.getText(), entry.getValue()));
-							}
-							break;
-						default:
-							break;
-						}
-					}
+					Business business = new Business(emc);
+					map = convertScript(business, properties);
 				} catch (Exception e) {
 					logger.error(e);
 				}
 			}
 			return map;
 		});
-		wo.setRelatedFormMap(_relatedForm.get());
-		wo.setRelatedScriptMap(_relatedScript.get());
-		wo.setMaxAge(3600 * 24);
-		return wo;
 	}
 
 	public static class Wo extends AbstractWo {
 
+		private static final long serialVersionUID = 2776033956637839042L;
+
 	}
 
 }

+ 34 - 56
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2GetMobile.java

@@ -1,10 +1,10 @@
 package com.x.processplatform.assemble.surface.jaxrs.form;
 
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.TreeMap;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
 
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
@@ -17,12 +17,10 @@ import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.ListTools;
 import com.x.processplatform.assemble.surface.Business;
-import com.x.processplatform.core.entity.content.WorkCompletedProperties;
 import com.x.processplatform.core.entity.content.WorkCompletedProperties.RelatedForm;
 import com.x.processplatform.core.entity.content.WorkCompletedProperties.RelatedScript;
 import com.x.processplatform.core.entity.element.Form;
 import com.x.processplatform.core.entity.element.FormProperties;
-import com.x.processplatform.core.entity.element.Script;
 
 class V2GetMobile extends BaseAction {
 
@@ -35,36 +33,41 @@ class V2GetMobile extends BaseAction {
 		if (optional.isPresent()) {
 			result.setData((Wo) optional.get());
 		} else {
-			Wo wo = this.get(id);
+			Form form = null;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				form = business.form().pick(id);
+			}
+			if (null == form) {
+				throw new ExceptionEntityNotExist(id, Form.class);
+			}
+			Wo wo = new Wo();
+			final FormProperties properties = form.getProperties();
+			wo.setFastETag(form.getId() + form.getUpdateTime().getTime());
+			wo.setForm(new RelatedForm(form, form.getMobileDataOrData()));
+			CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture = this.getRelatedFormFuture(properties);
+			CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture = this
+					.getRelatedScriptFuture(properties);
+			wo.setRelatedFormMap(getRelatedFormFuture.get(10, TimeUnit.SECONDS));
+			wo.setRelatedScriptMap(getRelatedScriptFuture.get(10, TimeUnit.SECONDS));
+			wo.setMaxAge(3600 * 24);
 			CacheManager.put(cacheCategory, cacheKey, wo);
 			result.setData(wo);
 		}
 		return result;
 	}
 
-	private Wo get(String id) throws Exception {
-		Form form = null;
-		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			Business business = new Business(emc);
-			form = business.form().pick(id);
-		}
-		if (null == form) {
-			throw new ExceptionEntityNotExist(id, Form.class);
-		}
-		Wo wo = new Wo();
-		final FormProperties properties = form.getProperties();
-		wo.setFastETag(form.getId() + form.getUpdateTime().getTime());
-		wo.setForm(new RelatedForm(form, form.getMobileDataOrData()));
-		CompletableFuture<Map<String, RelatedForm>> _relatedForm = CompletableFuture.supplyAsync(() -> {
+	private CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
 			Map<String, RelatedForm> map = new TreeMap<>();
 			if (ListTools.isNotEmpty(properties.getMobileRelatedFormList())) {
 				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 					Business bus = new Business(emc);
-					Form _f;
-					for (String _id : properties.getMobileRelatedFormList()) {
-						_f = bus.form().pick(_id);
-						if (null != _f) {
-							map.put(_id, new RelatedForm(_f, _f.getMobileDataOrData()));
+					Form f;
+					for (String id : properties.getMobileRelatedFormList()) {
+						f = bus.form().pick(id);
+						if (null != f) {
+							map.put(id, new RelatedForm(f, f.getMobileDataOrData()));
 						}
 					}
 				} catch (Exception e) {
@@ -73,53 +76,28 @@ class V2GetMobile extends BaseAction {
 			}
 			return map;
 		});
-		CompletableFuture<Map<String, RelatedScript>> _relatedScript = CompletableFuture.supplyAsync(() -> {
+	}
+
+	private CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
 			Map<String, RelatedScript> map = new TreeMap<>();
 			if ((null != properties.getMobileRelatedScriptMap())
 					&& (properties.getMobileRelatedScriptMap().size() > 0)) {
 				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					Business bus = new Business(emc);
-					for (Entry<String, String> entry : properties.getMobileRelatedScriptMap().entrySet()) {
-						switch (entry.getValue()) {
-						case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
-							Script _pp = bus.script().pick(entry.getKey());
-							if (null != _pp) {
-								map.put(entry.getKey(), new RelatedScript(_pp.getId(), _pp.getName(), _pp.getAlias(),
-										_pp.getText(), entry.getValue()));
-							}
-							break;
-						case WorkCompletedProperties.RelatedScript.TYPE_CMS:
-							com.x.cms.core.entity.element.Script _cms = bus.cms().script().pick(entry.getKey());
-							if (null != _cms) {
-								map.put(entry.getKey(), new RelatedScript(_cms.getId(), _cms.getName(), _cms.getAlias(),
-										_cms.getText(), entry.getValue()));
-							}
-							break;
-						case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
-							com.x.portal.core.entity.Script _p = bus.portal().script().pick(entry.getKey());
-							if (null != _p) {
-								map.put(entry.getKey(), new RelatedScript(_p.getId(), _p.getName(), _p.getAlias(),
-										_p.getText(), entry.getValue()));
-							}
-							break;
-						default:
-							break;
-						}
-					}
+					Business business = new Business(emc);
+					map = convertScript(business, properties);
 				} catch (Exception e) {
 					logger.error(e);
 				}
 			}
 			return map;
 		});
-		wo.setRelatedFormMap(_relatedForm.get());
-		wo.setRelatedScriptMap(_relatedScript.get());
-		wo.setMaxAge(3600 * 24);
-		return wo;
 	}
 
 	public static class Wo extends AbstractWo {
 
+		private static final long serialVersionUID = 6413992232196084934L;
+
 	}
 
 }

+ 79 - 138
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2LookupWorkOrWorkCompleted.java

@@ -1,14 +1,13 @@
 package com.x.processplatform.assemble.surface.jaxrs.form;
 
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.zip.CRC32;
 
-import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
@@ -16,8 +15,6 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.project.cache.Cache.CacheKey;
 import com.x.base.core.project.cache.CacheManager;
-import com.x.base.core.project.exception.ExceptionAccessDenied;
-import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.gson.XGsonBuilder;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -27,172 +24,116 @@ import com.x.base.core.project.tools.ListTools;
 import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
-import com.x.processplatform.core.entity.content.WorkCompletedProperties;
 import com.x.processplatform.core.entity.content.WorkCompletedProperties.StoreForm;
 import com.x.processplatform.core.entity.element.Activity;
 import com.x.processplatform.core.entity.element.Form;
-import com.x.processplatform.core.entity.element.Script;
+import com.x.processplatform.core.entity.element.FormProperties;
 
 class V2LookupWorkOrWorkCompleted extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(V2LookupWorkOrWorkCompleted.class);
 
+	private Form form = null;
+	private Wo wo = new Wo();
+
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workOrWorkCompleted) throws Exception {
 
 		ActionResult<Wo> result = new ActionResult<>();
 
-		CompletableFuture<Wo> _wo = CompletableFuture.supplyAsync(() -> {
-			Wo wo = new Wo();
-			try {
-				Work work = null;
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					work = emc.fetch(workOrWorkCompleted, Work.class, ListTools.toList(JpaObject.id_FIELDNAME,
-							Work.form_FIELDNAME, Work.activity_FIELDNAME, Work.activityType_FIELDNAME));
-				}
-				if (null != work) {
-					wo = this.work(work);
-				} else {
-					WorkCompleted workCompleted = null;
-					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-						workCompleted = emc.flag(workOrWorkCompleted, WorkCompleted.class);
-					}
-					if (null != workCompleted) {
-						wo = this.workCompleted(workCompleted);
-					}
-				}
-			} catch (Exception e) {
-				logger.error(e);
-			}
-			return wo;
-		});
-
-		CompletableFuture<Boolean> _control = CompletableFuture.supplyAsync(() -> {
-			Boolean value = false;
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				Business business = new Business(emc);
-				value = business.readableWithWorkOrWorkCompleted(effectivePerson, workOrWorkCompleted,
-						new ExceptionEntityNotExist(workOrWorkCompleted));
-			} catch (Exception e) {
-				logger.error(e);
+		this.getWorkWorkCompletedForm(workOrWorkCompleted);
+
+		if (null != this.form) {
+			CacheKey cacheKey = new CacheKey(this.getClass(), this.form.getId());
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				this.wo = (Wo) optional.get();
+			} else {
+				List<String> list = new ArrayList<>();
+				CompletableFuture<List<String>> relatedFormFuture = this.relatedFormFuture(this.form.getProperties());
+				CompletableFuture<List<String>> relatedScriptFuture = this
+						.relatedScriptFuture(this.form.getProperties());
+				list.add(this.form.getId() + this.form.getUpdateTime().getTime());
+				list.addAll(relatedFormFuture.get(10, TimeUnit.SECONDS));
+				list.addAll(relatedScriptFuture.get(10, TimeUnit.SECONDS));
+				list = list.stream().sorted().collect(Collectors.toList());
+				this.wo.setId(this.form.getId());
+				CRC32 crc = new CRC32();
+				crc.update(StringUtils.join(list, "#").getBytes());
+				this.wo.setCacheTag(crc.getValue() + "");
+				CacheManager.put(cacheCategory, cacheKey, wo);
 			}
-			return value;
-		});
-
-		if (BooleanUtils.isFalse(_control.get())) {
-			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
 		}
-		result.setData(_wo.get());
+		result.setData(wo);
 		return result;
 	}
 
-	private Wo work(Work work) throws Exception {
-		Form form = null;
+	private void getWorkWorkCompletedForm(String flag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			Business business = new Business(emc);
-			form = business.form().pick(work.getForm());
-			if (null == form) {
-				Activity activity = business.getActivity(work);
-				if (null != activity) {
-					form = business.form().pick(activity.getForm());
+			WorkCompleted workCompleted = null;
+			Work work = emc.fetch(flag, Work.class, ListTools.toList(JpaObject.id_FIELDNAME, Work.form_FIELDNAME,
+					Work.activity_FIELDNAME, Work.activityType_FIELDNAME));
+			if (null == work) {
+				workCompleted = emc.flag(flag, WorkCompleted.class);
+			}
+			if (null != work) {
+				this.form = business.form().pick(work.getForm());
+				if (null == this.form) {
+					Activity activity = business.getActivity(work);
+					if (null != activity) {
+						this.form = business.form().pick(activity.getForm());
+					}
+				}
+			} else if (null != workCompleted) {
+				this.form = business.form().pick(workCompleted.getForm());
+				if (null == this.form) {
+					StoreForm storeForm = workCompleted.getProperties().getStoreForm();
+					this.wo = XGsonBuilder.convert(storeForm, Wo.class);
 				}
 			}
 		}
-		if (null != form) {
-			return this.get(form);
-		}
-		return new Wo();
 	}
 
-	private Wo get(Form form) throws Exception {
-		CacheKey cacheKey = new CacheKey(this.getClass(), form.getId());
-		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
-		if (optional.isPresent()) {
-			return (Wo) optional.get();
-		} else {
-			final List<String> list = new CopyOnWriteArrayList<>();
-			CompletableFuture<Void> _relatedForm = CompletableFuture.runAsync(() -> {
-				if (ListTools.isNotEmpty(form.getProperties().getRelatedFormList())) {
-					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-						Business business = new Business(emc);
-						Form _f;
-						for (String _id : form.getProperties().getRelatedFormList()) {
-							_f = business.form().pick(_id);
-							if (null != _f) {
-								list.add(_f.getId() + _f.getUpdateTime().getTime());
-							}
-						}
-					} catch (Exception e) {
-						logger.error(e);
-					}
-				}
-			});
-			CompletableFuture<Void> _relatedScript = CompletableFuture.runAsync(() -> {
-				if ((null != form.getProperties().getRelatedScriptMap())
-						&& (form.getProperties().getRelatedScriptMap().size() > 0)) {
-					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-						Business business = new Business(emc);
-						for (Entry<String, String> entry : form.getProperties().getRelatedScriptMap().entrySet()) {
-							switch (entry.getValue()) {
-							case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
-								Script _pp = business.script().pick(entry.getKey());
-								if (null != _pp) {
-									list.add(_pp.getId() + _pp.getUpdateTime().getTime());
-								}
-								break;
-							case WorkCompletedProperties.RelatedScript.TYPE_CMS:
-								com.x.cms.core.entity.element.Script _cms = business.cms().script()
-										.pick(entry.getKey());
-								if (null != _cms) {
-									list.add(_cms.getId() + _cms.getUpdateTime().getTime());
-								}
-								break;
-							case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
-								com.x.portal.core.entity.Script _p = business.portal().script().pick(entry.getKey());
-								if (null != _p) {
-									list.add(_p.getId() + _p.getUpdateTime().getTime());
-								}
-								break;
-							default:
-								break;
-							}
+	private CompletableFuture<List<String>> relatedFormFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<String> list = new ArrayList<>();
+			if (ListTools.isNotEmpty(properties.getRelatedFormList())) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					Form f;
+					for (String id : properties.getRelatedFormList()) {
+						f = business.form().pick(id);
+						if (null != f) {
+							list.add(f.getId() + f.getUpdateTime().getTime());
 						}
-					} catch (Exception e) {
-						logger.error(e);
 					}
+				} catch (Exception e) {
+					logger.error(e);
 				}
-			});
-			_relatedForm.get();
-			_relatedScript.get();
-			list.add(form.getId() + form.getUpdateTime().getTime());
-			List<String> sortList = list.stream().sorted().collect(Collectors.toList());
-			Wo wo = new Wo();
-			wo.setId(form.getId());
-			CRC32 crc = new CRC32();
-			crc.update(StringUtils.join(sortList, "#").getBytes());
-			wo.setCacheTag(crc.getValue() + "");
-			return wo;
-		}
+			}
+			return list;
+		});
 	}
 
-	private Wo workCompleted(WorkCompleted workCompleted) throws Exception {
-		// 先使用当前库的表单,如果不存在使用储存的表单.
-		Wo wo = new Wo();
-		Form form = null;
-		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			Business business = new Business(emc);
-			form = business.form().pick(workCompleted.getForm());
-		}
-		if (null != form) {
-			return this.get(form);
-		} else if (null != workCompleted.getProperties().getStoreForm()) {
-			StoreForm storeForm = workCompleted.getProperties().getStoreForm();
-			wo = XGsonBuilder.convert(storeForm, Wo.class);
-		}
-		return wo;
+	private CompletableFuture<List<String>> relatedScriptFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<String> list = new ArrayList<>();
+			if ((null != properties.getRelatedScriptMap()) && (properties.getRelatedScriptMap().size() > 0)) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					list = convertScriptToCacheTag(business, properties.getMobileRelatedScriptMap());
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return list;
+		});
 	}
 
 	public static class Wo extends AbstractWo {
 
+		private static final long serialVersionUID = -6321756621818503364L;
+
 		private String id;
 
 		private String cacheTag;

+ 80 - 139
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/form/V2LookupWorkOrWorkCompletedMobile.java

@@ -1,14 +1,13 @@
 package com.x.processplatform.assemble.surface.jaxrs.form;
 
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.zip.CRC32;
 
-import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import com.x.base.core.container.EntityManagerContainer;
@@ -16,8 +15,6 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.project.cache.Cache.CacheKey;
 import com.x.base.core.project.cache.CacheManager;
-import com.x.base.core.project.exception.ExceptionAccessDenied;
-import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.gson.XGsonBuilder;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -27,173 +24,117 @@ import com.x.base.core.project.tools.ListTools;
 import com.x.processplatform.assemble.surface.Business;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
-import com.x.processplatform.core.entity.content.WorkCompletedProperties;
 import com.x.processplatform.core.entity.content.WorkCompletedProperties.StoreForm;
 import com.x.processplatform.core.entity.element.Activity;
 import com.x.processplatform.core.entity.element.Form;
-import com.x.processplatform.core.entity.element.Script;
+import com.x.processplatform.core.entity.element.FormProperties;
 
 class V2LookupWorkOrWorkCompletedMobile extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(V2LookupWorkOrWorkCompletedMobile.class);
 
+	private Form form = null;
+	private Wo wo = new Wo();
+
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workOrWorkCompleted) throws Exception {
 
 		ActionResult<Wo> result = new ActionResult<>();
 
-		CompletableFuture<Wo> _wo = CompletableFuture.supplyAsync(() -> {
-			Wo wo = new Wo();
-			try {
-				Work work = null;
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					work = emc.fetch(workOrWorkCompleted, Work.class, ListTools.toList(JpaObject.id_FIELDNAME,
-							Work.form_FIELDNAME, Work.activity_FIELDNAME, Work.activityType_FIELDNAME));
-				}
-				if (null != work) {
-					wo = this.work(work);
-				} else {
-					WorkCompleted workCompleted = null;
-					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-						workCompleted = emc.flag(workOrWorkCompleted, WorkCompleted.class);
-					}
-					if (null != workCompleted) {
-						wo = this.workCompleted(workCompleted);
-					}
-				}
-			} catch (Exception e) {
-				logger.error(e);
-			}
-			return wo;
-		});
-
-		CompletableFuture<Boolean> _control = CompletableFuture.supplyAsync(() -> {
-			Boolean value = false;
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				Business business = new Business(emc);
-				value = business.readableWithWorkOrWorkCompleted(effectivePerson, workOrWorkCompleted,
-						new ExceptionEntityNotExist(workOrWorkCompleted));
-			} catch (Exception e) {
-				logger.error(e);
+		this.getWorkWorkCompletedForm(workOrWorkCompleted);
+
+		if (null != this.form) {
+			CacheKey cacheKey = new CacheKey(this.getClass(), this.form.getId());
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				this.wo = (Wo) optional.get();
+			} else {
+				List<String> list = new ArrayList<>();
+				CompletableFuture<List<String>> relatedFormFuture = this.relatedFormFuture(this.form.getProperties());
+				CompletableFuture<List<String>> relatedScriptFuture = this
+						.relatedScriptFuture(this.form.getProperties());
+				list.add(this.form.getId() + this.form.getUpdateTime().getTime());
+				list.addAll(relatedFormFuture.get(10, TimeUnit.SECONDS));
+				list.addAll(relatedScriptFuture.get(10, TimeUnit.SECONDS));
+				list = list.stream().sorted().collect(Collectors.toList());
+				this.wo.setId(this.form.getId());
+				CRC32 crc = new CRC32();
+				crc.update(StringUtils.join(list, "#").getBytes());
+				this.wo.setCacheTag(crc.getValue() + "");
+				CacheManager.put(cacheCategory, cacheKey, wo);
 			}
-			return value;
-		});
-
-		if (BooleanUtils.isFalse(_control.get())) {
-			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
 		}
-		result.setData(_wo.get());
+		result.setData(wo);
 		return result;
 	}
 
-	private Wo work(Work work) throws Exception {
-		Form form = null;
+	private void getWorkWorkCompletedForm(String flag) throws Exception {
 		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 			Business business = new Business(emc);
-			form = business.form().pick(work.getForm());
-			if (null == form) {
-				Activity activity = business.getActivity(work);
-				if (null != activity) {
-					form = business.form().pick(activity.getForm());
+			WorkCompleted workCompleted = null;
+			Work work = emc.fetch(flag, Work.class, ListTools.toList(JpaObject.id_FIELDNAME, Work.form_FIELDNAME,
+					Work.activity_FIELDNAME, Work.activityType_FIELDNAME));
+			if (null == work) {
+				workCompleted = emc.flag(flag, WorkCompleted.class);
+			}
+			if (null != work) {
+				this.form = business.form().pick(work.getForm());
+				if (null == this.form) {
+					Activity activity = business.getActivity(work);
+					if (null != activity) {
+						this.form = business.form().pick(activity.getForm());
+					}
+				}
+			} else if (null != workCompleted) {
+				this.form = business.form().pick(workCompleted.getForm());
+				if (null == this.form) {
+					StoreForm storeForm = workCompleted.getProperties().storeForm(true);
+					this.wo = XGsonBuilder.convert(storeForm, Wo.class);
 				}
 			}
 		}
-		if (null != form) {
-			return this.get(form);
-		}
-		return new Wo();
 	}
 
-	private Wo get(Form form) throws Exception {
-		CacheKey cacheKey = new CacheKey(this.getClass(), form.getId());
-		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
-		if (optional.isPresent()) {
-			return (Wo) optional.get();
-		} else {
-			final List<String> list = new CopyOnWriteArrayList<>();
-			CompletableFuture<Void> _relatedForm = CompletableFuture.runAsync(() -> {
-				if (ListTools.isNotEmpty(form.getProperties().getMobileRelatedFormList())) {
-					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-						Business business = new Business(emc);
-						Form _f;
-						for (String _id : form.getProperties().getMobileRelatedFormList()) {
-							_f = business.form().pick(_id);
-							if (null != _f) {
-								list.add(_f.getId() + _f.getUpdateTime().getTime());
-							}
-						}
-					} catch (Exception e) {
-						logger.error(e);
-					}
-				}
-			});
-			CompletableFuture<Void> _relatedScript = CompletableFuture.runAsync(() -> {
-				if ((null != form.getProperties().getMobileRelatedScriptMap())
-						&& (form.getProperties().getMobileRelatedScriptMap().size() > 0)) {
-					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-						Business business = new Business(emc);
-						for (Entry<String, String> entry : form.getProperties().getMobileRelatedScriptMap()
-								.entrySet()) {
-							switch (entry.getValue()) {
-							case WorkCompletedProperties.RelatedScript.TYPE_PROCESSPLATFORM:
-								Script _pp = business.script().pick(entry.getKey());
-								if (null != _pp) {
-									list.add(_pp.getId() + _pp.getUpdateTime().getTime());
-								}
-								break;
-							case WorkCompletedProperties.RelatedScript.TYPE_CMS:
-								com.x.cms.core.entity.element.Script _cms = business.cms().script()
-										.pick(entry.getKey());
-								if (null != _cms) {
-									list.add(_cms.getId() + _cms.getUpdateTime().getTime());
-								}
-								break;
-							case WorkCompletedProperties.RelatedScript.TYPE_PORTAL:
-								com.x.portal.core.entity.Script _p = business.portal().script().pick(entry.getKey());
-								if (null != _p) {
-									list.add(_p.getId() + _p.getUpdateTime().getTime());
-								}
-								break;
-							default:
-								break;
-							}
+	private CompletableFuture<List<String>> relatedFormFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<String> list = new ArrayList<>();
+			if (ListTools.isNotEmpty(properties.getMobileRelatedFormList())) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					Form f;
+					for (String id : properties.getMobileRelatedFormList()) {
+						f = business.form().pick(id);
+						if (null != f) {
+							list.add(f.getId() + f.getUpdateTime().getTime());
 						}
-					} catch (Exception e) {
-						logger.error(e);
 					}
+				} catch (Exception e) {
+					logger.error(e);
 				}
-			});
-			_relatedForm.get();
-			_relatedScript.get();
-			list.add(form.getId() + form.getUpdateTime().getTime());
-			List<String> sortList = list.stream().sorted().collect(Collectors.toList());
-			Wo wo = new Wo();
-			wo.setId(form.getId());
-			CRC32 crc = new CRC32();
-			crc.update(StringUtils.join(sortList, "#").getBytes());
-			wo.setCacheTag(crc.getValue() + "");
-			return wo;
-		}
+			}
+			return list;
+		});
 	}
 
-	private Wo workCompleted(WorkCompleted workCompleted) throws Exception {
-		// 先使用当前库的表单,如果不存在使用储存的表单.
-		Wo wo = new Wo();
-		Form form = null;
-		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			Business business = new Business(emc);
-			form = business.form().pick(workCompleted.getForm());
-		}
-		if (null != form) {
-			return this.get(form);
-		} else if (null != workCompleted.getProperties().getStoreFormMobile()) {
-			StoreForm storeForm = workCompleted.getProperties().getStoreFormMobile();
-			wo = XGsonBuilder.convert(storeForm, Wo.class);
-		}
-		return wo;
+	private CompletableFuture<List<String>> relatedScriptFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<String> list = new ArrayList<>();
+			if ((null != properties.getMobileRelatedScriptMap())
+					&& (properties.getMobileRelatedScriptMap().size() > 0)) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					list = convertScriptToCacheTag(business, properties.getMobileRelatedScriptMap());
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return list;
+		});
 	}
 
 	public static class Wo extends AbstractWo {
 
+		private static final long serialVersionUID = 4034113778768000046L;
+
 		private String id;
 
 		private String cacheTag;

+ 23 - 14
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/record/ActionListWithWorkOrWorkCompleted.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.BooleanUtils;
@@ -32,15 +33,29 @@ class ActionListWithWorkOrWorkCompleted extends BaseAction {
 	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String workOrWorkCompleted) throws Exception {
 
 		ActionResult<List<Wo>> result = new ActionResult<>();
-		CompletableFuture<List<Wo>> _wos = CompletableFuture.supplyAsync(() -> {
+		CompletableFuture<List<Wo>> listFuture = this.listFuture(workOrWorkCompleted);
+		CompletableFuture<Boolean> checkControlFuture = this.checkControlFuture(effectivePerson, workOrWorkCompleted);
+
+		if (BooleanUtils.isFalse(checkControlFuture.get(10, TimeUnit.SECONDS))) {
+			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
+		}
+
+		result.setData(listFuture.get(10, TimeUnit.SECONDS));
+
+		return result;
+
+	}
+
+	private CompletableFuture<List<Wo>> listFuture(String flag) {
+		return CompletableFuture.supplyAsync(() -> {
 			List<Wo> wos = new ArrayList<>();
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
-				String job = business.job().findWithWork(workOrWorkCompleted);
+				String job = business.job().findWithWork(flag);
 				if (null != job) {
 					wos = emc.fetchEqual(Record.class, Wo.copier, Record.job_FIELDNAME, job);
 				} else {
-					job = business.job().findWithWorkCompleted(workOrWorkCompleted);
+					job = business.job().findWithWorkCompleted(flag);
 					WorkCompleted workCompleted = emc.firstEqual(WorkCompleted.class, WorkCompleted.job_FIELDNAME, job);
 					if (ListTools.isNotEmpty(workCompleted.getProperties().getRecordList())) {
 						wos = Wo.copier.copy(workCompleted.getProperties().getRecordList());
@@ -59,26 +74,20 @@ class ActionListWithWorkOrWorkCompleted extends BaseAction {
 			}
 			return wos;
 		});
+	}
 
-		CompletableFuture<Boolean> _control = CompletableFuture.supplyAsync(() -> {
+	private CompletableFuture<Boolean> checkControlFuture(EffectivePerson effectivePerson, String flag) {
+		return CompletableFuture.supplyAsync(() -> {
 			Boolean value = false;
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
-				value = business.readableWithWorkOrWorkCompleted(effectivePerson, workOrWorkCompleted,
-						new ExceptionEntityNotExist(workOrWorkCompleted));
+				value = business.readableWithWorkOrWorkCompleted(effectivePerson, flag,
+						new ExceptionEntityNotExist(flag));
 			} catch (Exception e) {
 				logger.error(e);
 			}
 			return value;
 		});
-
-		if (BooleanUtils.isFalse(_control.get())) {
-			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
-		}
-
-		result.setData(_wos.get());
-		return result;
-
 	}
 
 	private Record taskToRecord(Task task) {

+ 22 - 14
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/record/ActionListWithWorkOrWorkCompletedPaging.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.BooleanUtils;
@@ -34,16 +35,29 @@ class ActionListWithWorkOrWorkCompletedPaging extends BaseAction {
 
 		ActionResult<List<Wo>> result = new ActionResult<>();
 
-		CompletableFuture<List<Wo>> _wos = CompletableFuture.supplyAsync(() -> {
+		CompletableFuture<List<Wo>> listFuture = this.listFuture(workOrWorkCompleted, page, size);
+		CompletableFuture<Boolean> checkControlFuture = this.checkControlFuture(effectivePerson, workOrWorkCompleted);
+
+		if (BooleanUtils.isFalse(checkControlFuture.get(10, TimeUnit.SECONDS))) {
+			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
+		}
+
+		result.setData(listFuture.get(10, TimeUnit.SECONDS));
+		return result;
+
+	}
+
+	private CompletableFuture<List<Wo>> listFuture(String flag, Integer page, Integer size) {
+		return CompletableFuture.supplyAsync(() -> {
 			List<Wo> wos = new ArrayList<>();
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
-				String job = business.job().findWithWork(workOrWorkCompleted);
+				String job = business.job().findWithWork(flag);
 				if (null != job) {
 					wos = emc.fetchEqualAscPaging(Record.class, Wo.copier, Record.job_FIELDNAME, job, page, size,
 							Record.order_FIELDNAME);
 				} else {
-					job = business.job().findWithWorkCompleted(workOrWorkCompleted);
+					job = business.job().findWithWorkCompleted(flag);
 					WorkCompleted workCompleted = emc.firstEqual(WorkCompleted.class, WorkCompleted.job_FIELDNAME, job);
 					if (ListTools.isNotEmpty(workCompleted.getProperties().getRecordList())) {
 						List<Record> os = workCompleted.getProperties().getRecordList();
@@ -67,26 +81,20 @@ class ActionListWithWorkOrWorkCompletedPaging extends BaseAction {
 			}
 			return wos;
 		});
+	}
 
-		CompletableFuture<Boolean> _control = CompletableFuture.supplyAsync(() -> {
+	private CompletableFuture<Boolean> checkControlFuture(EffectivePerson effectivePerson, String flag) {
+		return CompletableFuture.supplyAsync(() -> {
 			Boolean value = false;
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
-				value = business.readableWithWorkOrWorkCompleted(effectivePerson, workOrWorkCompleted,
-						new ExceptionEntityNotExist(workOrWorkCompleted));
+				value = business.readableWithWorkOrWorkCompleted(effectivePerson, flag,
+						new ExceptionEntityNotExist(flag));
 			} catch (Exception e) {
 				logger.error(e);
 			}
 			return value;
 		});
-
-		if (BooleanUtils.isFalse(_control.get())) {
-			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
-		}
-
-		result.setData(_wos.get());
-		return result;
-
 	}
 
 	private Record taskToRecord(Task task) {

+ 82 - 49
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionCountWithPerson.java

@@ -41,62 +41,95 @@ class ActionCountWithPerson extends BaseAction {
 		}
 		if (StringUtils.isNotEmpty(person)) {
 			final String dn = person;
-			CompletableFuture<Void> future_task = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					wo.setTask(emc.countEqual(Task.class, Task.person_FIELDNAME, dn));
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			/* 已办仅取latest */
-			CompletableFuture<Void> future_taskCompleted = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					EntityManager em;
-					em = emc.get(TaskCompleted.class);
-					CriteriaBuilder cb = em.getCriteriaBuilder();
-					CriteriaQuery<Long> cq = cb.createQuery(Long.class);
-					Root<TaskCompleted> root = cq.from(TaskCompleted.class);
-					Predicate p = cb.equal(root.get(TaskCompleted_.person), dn);
-					p = cb.and(p, cb.or(cb.equal(root.get(TaskCompleted_.latest), true),
-							cb.isNull(root.get(TaskCompleted_.latest))));
-					wo.setTaskCompleted(em.createQuery(cq.select(cb.count(root)).where(p)).getSingleResult());
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			CompletableFuture<Void> future_read = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					wo.setRead(emc.countEqual(Read.class, Read.person_FIELDNAME, dn));
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			CompletableFuture<Void> future_readCompleted = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					wo.setReadCompleted(emc.countEqual(ReadCompleted.class, ReadCompleted.person_FIELDNAME, dn));
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			CompletableFuture<Void> future_review = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					wo.setReview(emc.countEqual(Review.class, Review.person_FIELDNAME, dn));
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			future_task.get(300, TimeUnit.SECONDS);
-			future_taskCompleted.get(300, TimeUnit.SECONDS);
-			future_read.get(300, TimeUnit.SECONDS);
-			future_readCompleted.get(300, TimeUnit.SECONDS);
-			future_review.get(300, TimeUnit.SECONDS);
+			CompletableFuture<Long> taskFuture = this.taskFuture(dn);
+			CompletableFuture<Long> taskCompletedFuture = this.taskCompletedFuture(dn);
+			CompletableFuture<Long> readFuture = this.readFuture(dn);
+			CompletableFuture<Long> readCompletedFuture = this.readCompletedFuture(dn);
+			CompletableFuture<Long> reviewFuture = this.reviewFuture(dn);
+			wo.setTask(taskFuture.get(10, TimeUnit.SECONDS));
+			wo.setTaskCompleted(taskCompletedFuture.get(10, TimeUnit.SECONDS));
+			wo.setRead(readFuture.get(10, TimeUnit.SECONDS));
+			wo.setReadCompleted(readCompletedFuture.get(10, TimeUnit.SECONDS));
+			wo.setReview(reviewFuture.get(10, TimeUnit.SECONDS));
 		}
 		result.setData(wo);
 		return result;
 	}
 
+	private CompletableFuture<Long> taskFuture(String dn) {
+		return CompletableFuture.supplyAsync(() -> {
+			Long count = 0L;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				count = emc.countEqual(Task.class, Task.person_FIELDNAME, dn);
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return count;
+		});
+	}
+
+	private CompletableFuture<Long> taskCompletedFuture(String dn) {
+		return CompletableFuture.supplyAsync(() -> {
+			Long count = 0L;
+			// 已办仅取latest
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				EntityManager em;
+				em = emc.get(TaskCompleted.class);
+				CriteriaBuilder cb = em.getCriteriaBuilder();
+				CriteriaQuery<Long> cq = cb.createQuery(Long.class);
+				Root<TaskCompleted> root = cq.from(TaskCompleted.class);
+				Predicate p = cb.equal(root.get(TaskCompleted_.person), dn);
+				p = cb.and(p, cb.or(cb.equal(root.get(TaskCompleted_.latest), true),
+						cb.isNull(root.get(TaskCompleted_.latest))));
+				count = em.createQuery(cq.select(cb.count(root)).where(p)).getSingleResult();
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return count;
+		});
+
+	}
+
+	private CompletableFuture<Long> readFuture(String dn) {
+		return CompletableFuture.supplyAsync(() -> {
+			Long count = 0L;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				count = emc.countEqual(Read.class, Read.person_FIELDNAME, dn);
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return count;
+		});
+	}
+
+	private CompletableFuture<Long> readCompletedFuture(String dn) {
+		return CompletableFuture.supplyAsync(() -> {
+			Long count = 0L;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				count = emc.countEqual(ReadCompleted.class, ReadCompleted.person_FIELDNAME, dn);
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return count;
+		});
+	}
+
+	private CompletableFuture<Long> reviewFuture(String dn) {
+		return CompletableFuture.supplyAsync(() -> {
+			Long count = 0L;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				count = emc.countEqual(Review.class, Review.person_FIELDNAME, dn);
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return count;
+		});
+	}
+
 	public static class Wo extends GsonPropertyObject {
 
+		private static final long serialVersionUID = -4391978436352777470L;
+
 		@FieldDescribe("待办数量")
 		private Long task = 0L;
 		@FieldDescribe("已办数量")

+ 104 - 216
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionGetWithWorkOrWorkCompleted.java

@@ -1,7 +1,9 @@
 package com.x.processplatform.assemble.surface.jaxrs.work;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
 
 import javax.persistence.EntityManager;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -31,8 +33,6 @@ import com.x.processplatform.core.entity.content.Read;
 import com.x.processplatform.core.entity.content.Task;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.content.WorkCompleted;
-import com.x.processplatform.core.entity.element.Activity;
-import com.x.processplatform.core.entity.element.ManualMode;
 import com.x.query.core.entity.Item;
 import com.x.query.core.entity.Item_;
 
@@ -43,146 +43,130 @@ class ActionGetWithWorkOrWorkCompleted extends BaseAction {
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workOrWorkCompleted) throws Exception {
 
 		ActionResult<Wo> result = new ActionResult<>();
-		CompletableFuture<Wo> _wo = CompletableFuture.supplyAsync(() -> {
-			Wo wo = null;
-			try {
-				Work work = null;
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					work = emc.find(workOrWorkCompleted, Work.class);
-				}
-				if (null != work) {
-					wo = this.work(effectivePerson, work);
-				} else {
-					WorkCompleted workCompleted = null;
-					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-						workCompleted = emc.flag(workOrWorkCompleted, WorkCompleted.class);
-					}
-					if (null != workCompleted) {
-						wo = this.workCompleted(effectivePerson, workCompleted);
-					}
-				}
-			} catch (Exception e) {
-				logger.error(e);
+		Wo wo = new Wo();
+		Work work = null;
+		WorkCompleted workCompleted = null;
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			work = emc.find(workOrWorkCompleted, Work.class);
+			if (null == work) {
+				workCompleted = emc.flag(workOrWorkCompleted, WorkCompleted.class);
 			}
-			return wo;
-		});
+		}
 
-		CompletableFuture<Boolean> _control = CompletableFuture.supplyAsync(() -> {
-			Boolean value = false;
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				Business business = new Business(emc);
-				value = business.readableWithWorkOrWorkCompleted(effectivePerson, workOrWorkCompleted,
-						new ExceptionEntityNotExist(workOrWorkCompleted));
-			} catch (Exception e) {
-				logger.error(e);
-			}
-			return value;
-		});
+		CompletableFuture<Boolean> checkControlFuture = this.checkControlFuture(effectivePerson, workOrWorkCompleted);
 
-		if (BooleanUtils.isFalse(_control.get())) {
+		if (null != work) {
+			CompletableFuture<Data> dataFuture = this.dataFuture(work);
+			CompletableFuture<List<WoTask>> taskFuture = this.taskFuture(work.getJob());
+			CompletableFuture<List<WoRead>> readFuture = this.readFuture(work.getJob());
+			wo.setData(dataFuture.get(10, TimeUnit.SECONDS));
+			wo.setTaskList(taskFuture.get(10, TimeUnit.SECONDS));
+			wo.setReadList(readFuture.get(10, TimeUnit.SECONDS));
+			this.setCurrentReadIndex(effectivePerson, wo);
+			this.setCurrentTaskIndex(effectivePerson, wo);
+		} else if (null != workCompleted) {
+			CompletableFuture<Data> dataFuture = this.dataFuture(workCompleted);
+			CompletableFuture<List<WoRead>> readFuture = this.readFuture(workCompleted.getJob());
+			wo.setData(dataFuture.get(10, TimeUnit.SECONDS));
+			wo.setReadList(readFuture.get(10, TimeUnit.SECONDS));
+			this.setCurrentReadIndex(effectivePerson, wo);
+		}
+
+		if (BooleanUtils.isFalse(checkControlFuture.get(10, TimeUnit.SECONDS))) {
 			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
 		}
 
-		result.setData(_wo.get());
+		result.setData(wo);
 		return result;
 	}
 
-	private Wo work(EffectivePerson effectivePerson, Work work) throws Exception {
-		Wo wo = new Wo();
-		wo.setWork(gson.toJsonTree(WoWork.copier.copy(work)));
-		wo.setActivity(this.activity(work));
-		CompletableFuture<Data> future_data = CompletableFuture.supplyAsync(() -> {
-			return this.data(work.getJob());
-		});
-		CompletableFuture<List<WoTask>> future_task = CompletableFuture.supplyAsync(() -> {
-			return this.tasks(work.getId());
-		});
-		CompletableFuture<List<WoRead>> future_read = CompletableFuture.supplyAsync(() -> {
-			return this.reads(work.getJob());
-		});
-		wo.setData(future_data.get());
-		wo.setTaskList(future_task.get());
-		wo.setReadList(future_read.get());
-		this.setCurrentReadIndex(effectivePerson, wo);
-		this.setCurrentTaskIndex(effectivePerson, wo);
-		return wo;
-	}
 
-	private Wo workCompleted(EffectivePerson effectivePerson, WorkCompleted workCompleted) throws Exception {
-		Wo wo = new Wo();
-		wo.setWork(gson.toJsonTree(WoWorkCompleted.copier.copy(workCompleted)));
-		CompletableFuture<Data> future_data = CompletableFuture.supplyAsync(() -> {
-			if (BooleanUtils.isTrue(workCompleted.getMerged())) {
-				/* 如果data已经merged */
-				return workCompleted.getProperties().getData();
-			} else {
-				return this.data(workCompleted.getJob());
+
+	private CompletableFuture<Data> dataFuture(Work work) {
+		return CompletableFuture.supplyAsync(() -> {
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				EntityManager em = business.entityManagerContainer().get(Item.class);
+				CriteriaBuilder cb = em.getCriteriaBuilder();
+				CriteriaQuery<Item> cq = cb.createQuery(Item.class);
+				Root<Item> root = cq.from(Item.class);
+				Predicate p = cb.equal(root.get(Item_.bundle), work.getJob());
+				p = cb.and(p, cb.equal(root.get(Item_.itemCategory), ItemCategory.pp));
+				List<Item> list = em.createQuery(cq.where(p)).getResultList();
+				if (list.isEmpty()) {
+					return new Data();
+				} else {
+					JsonElement jsonElement = itemConverter.assemble(list);
+					if (jsonElement.isJsonObject()) {
+						return gson.fromJson(jsonElement, Data.class);
+					} else {
+						// 如果不是Object强制返回一个Map对象
+						return new Data();
+					}
+				}
+			} catch (Exception e) {
+				logger.error(e);
 			}
+			return null;
 		});
-		CompletableFuture<List<WoRead>> future_read = CompletableFuture.supplyAsync(() -> {
-			return this.reads(workCompleted.getJob());
-		});
-		wo.setData(future_data.get());
-		wo.setReadList(future_read.get());
-		this.setCurrentReadIndex(effectivePerson, wo);
-		return wo;
 	}
 
-	private Data data(String job) {
-		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			Business business = new Business(emc);
-			EntityManager em = business.entityManagerContainer().get(Item.class);
-			CriteriaBuilder cb = em.getCriteriaBuilder();
-			CriteriaQuery<Item> cq = cb.createQuery(Item.class);
-			Root<Item> root = cq.from(Item.class);
-			Predicate p = cb.equal(root.get(Item_.bundle), job);
-			p = cb.and(p, cb.equal(root.get(Item_.itemCategory), ItemCategory.pp));
-			List<Item> list = em.createQuery(cq.where(p)).getResultList();
-			if (list.isEmpty()) {
-				return new Data();
+	private CompletableFuture<Data> dataFuture(WorkCompleted workCompleted) {
+		return CompletableFuture.supplyAsync(() -> {
+			if (BooleanUtils.isTrue(workCompleted.getMerged())) {
+				return workCompleted.getProperties().getData();
 			} else {
-				JsonElement jsonElement = itemConverter.assemble(list);
-				if (jsonElement.isJsonObject()) {
-					return gson.fromJson(jsonElement, Data.class);
-				} else {
-					/* 如果不是Object强制返回一个Map对象 */
-					return new Data();
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					EntityManager em = business.entityManagerContainer().get(Item.class);
+					CriteriaBuilder cb = em.getCriteriaBuilder();
+					CriteriaQuery<Item> cq = cb.createQuery(Item.class);
+					Root<Item> root = cq.from(Item.class);
+					Predicate p = cb.equal(root.get(Item_.bundle), workCompleted.getJob());
+					p = cb.and(p, cb.equal(root.get(Item_.itemCategory), ItemCategory.pp));
+					List<Item> list = em.createQuery(cq.where(p)).getResultList();
+					if (list.isEmpty()) {
+						return new Data();
+					} else {
+						JsonElement jsonElement = itemConverter.assemble(list);
+						if (jsonElement.isJsonObject()) {
+							return gson.fromJson(jsonElement, Data.class);
+						} else {
+							// 如果不是Object强制返回一个Map对象
+							return new Data();
+						}
+					}
+				} catch (Exception e) {
+					logger.error(e);
 				}
 			}
-		} catch (Exception e) {
-			logger.error(e);
-		}
-		return null;
-	}
+			return null;
+		});
 
-	private List<WoTask> tasks(String workId) {
-		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			return WoTask.copier.copy(emc.listEqual(Task.class, Task.work_FIELDNAME, workId));
-		} catch (Exception e) {
-			logger.error(e);
-		}
-		return null;
 	}
 
-	private List<WoRead> reads(String job) {
-		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			return WoRead.copier.copy(emc.listEqual(Read.class, Read.job_FIELDNAME, job));
-		} catch (Exception e) {
-			logger.error(e);
-		}
-		return null;
+	private CompletableFuture<List<WoTask>> taskFuture(String job) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<WoTask> list = new ArrayList<>();
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				list = WoTask.copier.copy(emc.listEqual(Task.class, Task.work_FIELDNAME, job));
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return list;
+		});
 	}
 
-	private WoActivity activity(Work work) throws Exception {
-		WoActivity woActivity = new WoActivity();
-		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-			Business business = new Business(emc);
-			Activity activity = business.getActivity(work);
-			if (null != activity) {
-				activity.copyTo(woActivity);
+	private CompletableFuture<List<WoRead>> readFuture(String job) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<WoRead> list = new ArrayList<>();
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				list = WoRead.copier.copy(emc.listEqual(Read.class, Read.job_FIELDNAME, job));
+			} catch (Exception e) {
+				logger.error(e);
 			}
-			return woActivity;
-		}
+			return list;
+		});
 	}
 
 	private void setCurrentTaskIndex(EffectivePerson effectivePerson, Wo wo) {
@@ -210,6 +194,7 @@ class ActionGetWithWorkOrWorkCompleted extends BaseAction {
 
 	public static class Wo extends GsonPropertyObject {
 
+		private static final long serialVersionUID = -869684415398137301L;
 		/* work和workCompleted都有 */
 		private JsonElement work;
 		/* work和workCompleted都有 */
@@ -319,101 +304,4 @@ class ActionGetWithWorkOrWorkCompleted extends BaseAction {
 
 	}
 
-	public static class WoActivity extends GsonPropertyObject {
-
-		static WrapCopier<Activity, WoActivity> copier = WrapCopierFactory.wo(Activity.class, WoActivity.class,
-				JpaObject.singularAttributeField(Activity.class, true, true), JpaObject.FieldsInvisible);
-
-		private String id;
-
-		private String name;
-
-		private String description;
-
-		private String alias;
-
-		private String position;
-
-		private String resetRange;
-
-		private Integer resetCount;
-
-		private Boolean allowReset;
-
-		private ManualMode manualMode;
-
-		public String getName() {
-			return name;
-		}
-
-		public void setName(String name) {
-			this.name = name;
-		}
-
-		public String getDescription() {
-			return description;
-		}
-
-		public void setDescription(String description) {
-			this.description = description;
-		}
-
-		public String getAlias() {
-			return alias;
-		}
-
-		public void setAlias(String alias) {
-			this.alias = alias;
-		}
-
-		public String getPosition() {
-			return position;
-		}
-
-		public void setPosition(String position) {
-			this.position = position;
-		}
-
-		public String getId() {
-			return id;
-		}
-
-		public void setId(String id) {
-			this.id = id;
-		}
-
-		public String getResetRange() {
-			return resetRange;
-		}
-
-		public void setResetRange(String resetRange) {
-			this.resetRange = resetRange;
-		}
-
-		public Integer getResetCount() {
-			return resetCount;
-		}
-
-		public void setResetCount(Integer resetCount) {
-			this.resetCount = resetCount;
-		}
-
-		public Boolean getAllowReset() {
-			return allowReset;
-		}
-
-		public void setAllowReset(Boolean allowReset) {
-			this.allowReset = allowReset;
-		}
-
-		public ManualMode getManualMode() {
-			return manualMode;
-		}
-
-		public void setManualMode(ManualMode manualMode) {
-			this.manualMode = manualMode;
-		}
-
-	}
-
 }

+ 60 - 61
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionRefer.java

@@ -16,7 +16,6 @@ import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
-import com.x.base.core.project.utils.time.TimeStamp;
 import com.x.processplatform.core.entity.content.Read;
 import com.x.processplatform.core.entity.content.ReadCompleted;
 import com.x.processplatform.core.entity.content.Review;
@@ -29,66 +28,66 @@ class ActionRefer extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workId) throws Exception {
 
-			ActionResult<Wo> result = new ActionResult<>();
-			Wo wo = new Wo();
-			CompletableFuture<Void> future_task = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					List<Task> os = emc.listEqualAndEqual(Task.class, Task.work_FIELDNAME, workId,
-							Task.person_FIELDNAME, effectivePerson.getDistinguishedName());
-					wo.getTaskList().addAll(WoTask.copier.copy(os));
-					wo.setHasTask(!os.isEmpty());
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			CompletableFuture<Void> future_taskCompleted = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					List<TaskCompleted> os = emc.listEqualAndEqual(TaskCompleted.class, TaskCompleted.work_FIELDNAME,
-							workId, TaskCompleted.person_FIELDNAME, effectivePerson.getDistinguishedName());
-					wo.getTaskCompletedList().addAll(WoTaskCompleted.copier.copy(os));
-					wo.setHasTaskCompleted(!os.isEmpty());
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			CompletableFuture<Void> future_read = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					List<Read> os = emc.listEqualAndEqual(Read.class, Read.work_FIELDNAME, workId,
-							Read.person_FIELDNAME, effectivePerson.getDistinguishedName());
-					wo.getReadList().addAll(WoRead.copier.copy(os));
-					wo.setHasRead(!os.isEmpty());
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			CompletableFuture<Void> future_readCompleted = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					List<ReadCompleted> os = emc.listEqualAndEqual(ReadCompleted.class, ReadCompleted.work_FIELDNAME,
-							workId, ReadCompleted.person_FIELDNAME, effectivePerson.getDistinguishedName());
-					wo.getReadCompletedList().addAll(WoReadCompleted.copier.copy(os));
-					wo.setHasReadCompleted(!os.isEmpty());
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			CompletableFuture<Void> future_review = CompletableFuture.runAsync(() -> {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					List<Review> os = emc.listEqualAndEqual(Review.class, Review.work_FIELDNAME, workId,
-							Review.person_FIELDNAME, effectivePerson.getDistinguishedName());
-					wo.getReviewList().addAll(WoReview.copier.copy(os));
-					wo.setHasReview(!os.isEmpty());
-				} catch (Exception e) {
-					logger.error(e);
-				}
-			});
-			future_task.get(300, TimeUnit.SECONDS);
-			future_taskCompleted.get(300, TimeUnit.SECONDS);
-			future_read.get(300, TimeUnit.SECONDS);
-			future_readCompleted.get(300, TimeUnit.SECONDS);
-			future_review.get(300, TimeUnit.SECONDS);
-			result.setData(wo);
-
-			return result;
+		ActionResult<Wo> result = new ActionResult<>();
+		Wo wo = new Wo();
+		CompletableFuture<Void> future_task = CompletableFuture.runAsync(() -> {
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				List<Task> os = emc.listEqualAndEqual(Task.class, Task.work_FIELDNAME, workId, Task.person_FIELDNAME,
+						effectivePerson.getDistinguishedName());
+				wo.getTaskList().addAll(WoTask.copier.copy(os));
+				wo.setHasTask(!os.isEmpty());
+			} catch (Exception e) {
+				logger.error(e);
+			}
+		});
+		CompletableFuture<Void> future_taskCompleted = CompletableFuture.runAsync(() -> {
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				List<TaskCompleted> os = emc.listEqualAndEqual(TaskCompleted.class, TaskCompleted.work_FIELDNAME,
+						workId, TaskCompleted.person_FIELDNAME, effectivePerson.getDistinguishedName());
+				wo.getTaskCompletedList().addAll(WoTaskCompleted.copier.copy(os));
+				wo.setHasTaskCompleted(!os.isEmpty());
+			} catch (Exception e) {
+				logger.error(e);
+			}
+		});
+		CompletableFuture<Void> future_read = CompletableFuture.runAsync(() -> {
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				List<Read> os = emc.listEqualAndEqual(Read.class, Read.work_FIELDNAME, workId, Read.person_FIELDNAME,
+						effectivePerson.getDistinguishedName());
+				wo.getReadList().addAll(WoRead.copier.copy(os));
+				wo.setHasRead(!os.isEmpty());
+			} catch (Exception e) {
+				logger.error(e);
+			}
+		});
+		CompletableFuture<Void> future_readCompleted = CompletableFuture.runAsync(() -> {
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				List<ReadCompleted> os = emc.listEqualAndEqual(ReadCompleted.class, ReadCompleted.work_FIELDNAME,
+						workId, ReadCompleted.person_FIELDNAME, effectivePerson.getDistinguishedName());
+				wo.getReadCompletedList().addAll(WoReadCompleted.copier.copy(os));
+				wo.setHasReadCompleted(!os.isEmpty());
+			} catch (Exception e) {
+				logger.error(e);
+			}
+		});
+		CompletableFuture<Void> future_review = CompletableFuture.runAsync(() -> {
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				List<Review> os = emc.listEqualAndEqual(Review.class, Review.work_FIELDNAME, workId,
+						Review.person_FIELDNAME, effectivePerson.getDistinguishedName());
+				wo.getReviewList().addAll(WoReview.copier.copy(os));
+				wo.setHasReview(!os.isEmpty());
+			} catch (Exception e) {
+				logger.error(e);
+			}
+		});
+		future_task.get(10, TimeUnit.SECONDS);
+		future_taskCompleted.get(10, TimeUnit.SECONDS);
+		future_read.get(10, TimeUnit.SECONDS);
+		future_readCompleted.get(10, TimeUnit.SECONDS);
+		future_review.get(10, TimeUnit.SECONDS);
+		result.setData(wo);
+
+		return result;
 	}
 
 	public static class Wo extends GsonPropertyObject {

+ 28 - 11
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/BaseAction.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 import javax.persistence.EntityManager;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -15,12 +16,14 @@ import org.apache.commons.collections4.ListUtils;
 
 import com.google.gson.JsonElement;
 import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.entity.JpaObject;
 import com.x.base.core.entity.dataitem.DataItemConverter;
 import com.x.base.core.entity.dataitem.ItemCategory;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
+import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
@@ -110,6 +113,20 @@ abstract class BaseAction extends StandardJaxrsAction {
 		}
 	}
 
+	protected CompletableFuture<Boolean> checkControlFuture(EffectivePerson effectivePerson, String flag) {
+		return CompletableFuture.supplyAsync(() -> {
+			Boolean value = false;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				value = business.readableWithWorkOrWorkCompleted(effectivePerson, flag,
+						new ExceptionEntityNotExist(flag));
+			} catch (Exception e) {
+				logger.error(e);
+			}
+			return value;
+		});
+	}
+
 	public static class AbstractWo extends GsonPropertyObject {
 
 		@FieldDescribe("活动节点")
@@ -591,7 +608,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //		Activity activity = null;
 //		Long reviewCount = 0L;
 //
-//		CompletableFuture111111<Void> future_tasks = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_tasks = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<Task> os = business.entityManagerContainer()
 //						.listEqual(Task.class, WoTask.job_FIELDNAME, work.getJob()).stream()
@@ -611,7 +628,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //			}
 //		});
 //
-//		CompletableFuture111111<Void> future_taskCompleteds = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_taskCompleteds = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<TaskCompleted> os = business.entityManagerContainer()
 //						.listEqual(TaskCompleted.class, TaskCompleted.job_FIELDNAME, work.getJob()).stream()
@@ -624,7 +641,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //			}
 //		});
 //
-//		CompletableFuture111111<Void> future_reads = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_reads = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<Read> os = business.entityManagerContainer()
 //						.listEqual(Read.class, Read.job_FIELDNAME, work.getJob()).stream()
@@ -643,7 +660,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Void> future_readCompleteds = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_readCompleteds = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<ReadCompleted> os = business.entityManagerContainer()
 //						.listEqual(ReadCompleted.class, ReadCompleted.job_FIELDNAME, work.getJob()).stream()
@@ -655,7 +672,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Void> future_attachments = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_attachments = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<Attachment> os = business.entityManagerContainer()
 //						.listEqual(Attachment.class, Attachment.job_FIELDNAME, work.getJob()).stream()
@@ -670,7 +687,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Void> future_workLogs = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_workLogs = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<WorkLog> os = business.entityManagerContainer()
 //						.listEqual(WorkLog.class, WorkLog.job_FIELDNAME, work.getJob()).stream()
@@ -681,14 +698,14 @@ abstract class BaseAction extends StandardJaxrsAction {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Void> future_data = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_data = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				t.setData(this.loadData(business, work));
 //			} catch (Exception e) {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Application> future_application = CompletableFuture111111.supplyAsync(() -> {
+//		CompletableFuture111111111111111111111111<Application> future_application = CompletableFuture111111111111111111111111.supplyAsync(() -> {
 //			Application o = null;
 //			try {
 //				o = business.application().pick(work.getApplication());
@@ -697,7 +714,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //			}
 //			return o;
 //		});
-//		CompletableFuture111111<Process> future_process = CompletableFuture111111.supplyAsync(() -> {
+//		CompletableFuture111111111111111111111111<Process> future_process = CompletableFuture111111111111111111111111.supplyAsync(() -> {
 //			Process o = null;
 //			try {
 //				o = business.process().pick(work.getProcess());
@@ -706,7 +723,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //			}
 //			return o;
 //		});
-//		CompletableFuture111111<Activity> future_activity = CompletableFuture111111.supplyAsync(() -> {
+//		CompletableFuture111111111111111111111111<Activity> future_activity = CompletableFuture111111111111111111111111.supplyAsync(() -> {
 //			Activity o = null;
 //			try {
 //				o = business.getActivity(work);
@@ -721,7 +738,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //			}
 //			return o;
 //		});
-//		CompletableFuture111111<Long> future_reviewCount = CompletableFuture111111.supplyAsync(() -> {
+//		CompletableFuture111111111111111111111111<Long> future_reviewCount = CompletableFuture111111111111111111111111.supplyAsync(() -> {
 //			Long o = 0L;
 //			try {
 //				o = business.entityManagerContainer().countEqualAndEqual(Review.class, Review.person_FIELDNAME,

+ 91 - 123
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/V2GetWorkOrWorkCompleted.java

@@ -6,7 +6,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import org.apache.commons.collections4.ListUtils;
@@ -21,7 +21,6 @@ import com.x.base.core.entity.dataitem.ItemCategory;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
 import com.x.base.core.project.exception.ExceptionAccessDenied;
-import com.x.base.core.project.exception.ExceptionEntityNotExist;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -53,61 +52,64 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String workOrWorkCompleted) throws Exception {
 		ActionResult<Wo> result = new ActionResult<>();
 
-		CompletableFuture<Wo> _wo = CompletableFuture.supplyAsync(() -> {
-			Wo wo = null;
-			Work work = null;
-			try {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					work = emc.find(workOrWorkCompleted, Work.class);
-				}
-				if (null != work) {
-					wo = this.work(effectivePerson, work);
-				} else {
-					WorkCompleted workCompleted = null;
-					try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-						workCompleted = emc.flag(workOrWorkCompleted, WorkCompleted.class);
-						if (null != workCompleted) {
-							wo = this.workCompleted(effectivePerson, workCompleted);
-						}
-					}
-				}
-			} catch (Exception e) {
-				logger.error(e);
+		Wo wo = new Wo();
+		Work work = null;
+		WorkCompleted workCompleted = null;
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			work = emc.find(workOrWorkCompleted, Work.class);
+			if (null == work) {
+				workCompleted = emc.flag(workOrWorkCompleted, WorkCompleted.class);
 			}
-			return wo;
-		});
+		}
 
-		CompletableFuture<Boolean> _control = CompletableFuture.supplyAsync(() -> {
-			Boolean value = false;
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				Business business = new Business(emc);
-				value = business.readableWithWorkOrWorkCompleted(effectivePerson, workOrWorkCompleted,
-						new ExceptionEntityNotExist(workOrWorkCompleted));
-			} catch (Exception e) {
-				logger.error(e);
+		CompletableFuture<Boolean> checkControlFuture = this.checkControlFuture(effectivePerson, workOrWorkCompleted);
+
+		if (null != work) {
+			CompletableFuture<Void> workJsonFuture = this.workJsonFuture(work, wo);
+			CompletableFuture<Void> activityRouteFuture = this.activityRouteFuture(work, wo);
+			CompletableFuture<Void> dataFuture = this.dataFuture(work, wo);
+			CompletableFuture<Void> taskFuture = this.taskFuture(effectivePerson, work.getJob(), wo);
+			CompletableFuture<Void> readFuture = this.readFuture(effectivePerson, work.getJob(), wo);
+			CompletableFuture<Void> creatorIdentityFuture = this.creatorIdentityFuture(work.getCreatorIdentity(), wo);
+			CompletableFuture<Void> creatorPersonFuture = this.creatorPersonFuture(work.getCreatorPerson(), wo);
+			CompletableFuture<Void> creatorUnitFuture = this.creatorUnitFuture(work.getCreatorUnit(), wo);
+			CompletableFuture<Void> attachmentFuture = this.attachmentFuture(effectivePerson, work.getJob(), wo);
+			workJsonFuture.get(10, TimeUnit.SECONDS);
+			activityRouteFuture.get(10, TimeUnit.SECONDS);
+			dataFuture.get(10, TimeUnit.SECONDS);
+			taskFuture.get(10, TimeUnit.SECONDS);
+			readFuture.get(10, TimeUnit.SECONDS);
+			creatorIdentityFuture.get(10, TimeUnit.SECONDS);
+			creatorPersonFuture.get(10, TimeUnit.SECONDS);
+			creatorUnitFuture.get(10, TimeUnit.SECONDS);
+			attachmentFuture.get(10, TimeUnit.SECONDS);
+			for (WoTask woTask : wo.getTaskList()) {
+				wo.getRecordList().add(taskToRecord(woTask));
 			}
-			return value;
-		});
-
-		if (BooleanUtils.isFalse(_control.get())) {
+		} else if (null != workCompleted) {
+			CompletableFuture<Void> workCompletedJsonFuture = this.workCompletedJsonFuture(workCompleted, wo);
+			CompletableFuture<Void> workCompletedDataFuture = this.workCompletedDataFuture(workCompleted, wo);
+			CompletableFuture<Void> readFuture = readFuture(effectivePerson, workCompleted.getJob(), wo);
+			CompletableFuture<Void> creatorIdentityFuture = creatorIdentityFuture(workCompleted.getCreatorIdentity(),
+					wo);
+			CompletableFuture<Void> creatorPersonFuture = creatorPersonFuture(workCompleted.getCreatorPerson(), wo);
+			CompletableFuture<Void> creatorUnitFuture = creatorUnitFuture(workCompleted.getCreatorUnit(), wo);
+			CompletableFuture<Void> attachmentFuture = attachmentFuture(effectivePerson, workCompleted.getJob(), wo);
+			workCompletedJsonFuture.get(10, TimeUnit.SECONDS);
+			workCompletedDataFuture.get(10, TimeUnit.SECONDS);
+			readFuture.get(10, TimeUnit.SECONDS);
+			creatorIdentityFuture.get(10, TimeUnit.SECONDS);
+			creatorPersonFuture.get(10, TimeUnit.SECONDS);
+			creatorUnitFuture.get(10, TimeUnit.SECONDS);
+			attachmentFuture.get(10, TimeUnit.SECONDS);
+		}
+
+		if (BooleanUtils.isFalse(checkControlFuture.get(10, TimeUnit.SECONDS))) {
 			throw new ExceptionAccessDenied(effectivePerson, workOrWorkCompleted);
 		}
-		result.setData(_wo.get());
-		return result;
-	}
 
-	private Wo work(EffectivePerson effectivePerson, Work work) throws InterruptedException, ExecutionException {
-		Wo wo = new Wo();
-		CompletableFuture
-				.allOf(workJson(work, wo), activity(work, wo), data(work, wo), task(effectivePerson, work, wo),
-						read(effectivePerson, work.getJob(), wo), creatorIdentity(work.getCreatorIdentity(), wo),
-						creatorPerson(work.getCreatorPerson(), wo), creatorUnit(work.getCreatorUnit(), wo),
-						attachment(effectivePerson, work.getJob(), wo), record(effectivePerson, work.getJob(), wo))
-				.get();
-		for (WoTask woTask : wo.getTaskList()) {
-			wo.getRecordList().add(taskToRecord(woTask));
-		}
-		return wo;
+		result.setData(wo);
+		return result;
 	}
 
 	private WoRecord taskToRecord(WoTask woTask) {
@@ -126,7 +128,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		return o;
 	}
 
-	private CompletableFuture<Void> data(Work work, Wo wo) {
+	private CompletableFuture<Void> dataFuture(Work work, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				List<Item> list = emc.listEqualAndEqual(Item.class, DataItem.bundle_FIELDNAME, work.getJob(),
@@ -144,58 +146,12 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		});
 	}
 
-	private CompletableFuture<Void> record(EffectivePerson effectivePerson, String job, Wo wo) {
-		return CompletableFuture.runAsync(() -> {
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				wo.setRecordList(emc.fetchEqual(Record.class, WoRecord.copier, Record.job_FIELDNAME, job).stream()
-						.sorted(Comparator.comparing(WoRecord::getOrder)).collect(Collectors.toList()));
-			} catch (Exception e) {
-				logger.error(e);
-			}
-		});
-	}
+ 
 
-	private CompletableFuture<Void> completedRecord(EffectivePerson effectivePerson, WorkCompleted workCompleted,
-			Wo wo) {
+	private CompletableFuture<Void> taskFuture(EffectivePerson effectivePerson, String job, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				if (ListTools.isNotEmpty(workCompleted.getProperties().getRecordList())) {
-					wo.setRecordList(WoRecord.copier.copy(workCompleted.getProperties().getRecordList()).stream()
-							.sorted(Comparator.comparing(WoRecord::getOrder)).collect(Collectors.toList()));
-				} else {
-					wo.setRecordList(emc
-							.fetchEqual(Record.class, WoRecord.copier, Record.job_FIELDNAME, workCompleted.getJob())
-							.stream().sorted(Comparator.comparing(WoRecord::getOrder)).collect(Collectors.toList()));
-				}
-			} catch (Exception e) {
-				logger.error(e);
-			}
-		});
-	}
-
-	private CompletableFuture<Void> activity(Work work, Wo wo) {
-		return CompletableFuture.runAsync(() -> {
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				Business business = new Business(emc);
-				Activity activity = business.getActivity(work);
-				if (null != activity) {
-					WoActivity woActivity = new WoActivity();
-					activity.copyTo(woActivity);
-					wo.setActivity(woActivity);
-					if (Objects.equals(ActivityType.manual, activity.getActivityType())) {
-						wo.setRouteList(WoRoute.copier.copy(business.route().pick(((Manual) activity).getRouteList())));
-					}
-				}
-			} catch (Exception e) {
-				logger.error(e);
-			}
-		});
-	}
-
-	private CompletableFuture<Void> task(EffectivePerson effectivePerson, Work work, Wo wo) {
-		return CompletableFuture.runAsync(() -> {
-			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				wo.setTaskList(WoTask.copier.copy(emc.listEqual(Task.class, Task.job_FIELDNAME, work.getJob())));
+				wo.setTaskList(WoTask.copier.copy(emc.listEqual(Task.class, Task.job_FIELDNAME, job)));
 				wo.setCurrentTaskIndex(
 						ListUtils.indexOf(wo.getTaskList(), e -> effectivePerson.isPerson(e.getPerson())));
 			} catch (Exception e) {
@@ -204,7 +160,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		});
 	}
 
-	private CompletableFuture<Void> attachment(EffectivePerson effectivePerson, String job, Wo wo) {
+	private CompletableFuture<Void> attachmentFuture(EffectivePerson effectivePerson, String job, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
@@ -237,7 +193,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		});
 	}
 
-	private CompletableFuture<Void> read(EffectivePerson effectivePerson, String job, Wo wo) {
+	private CompletableFuture<Void> readFuture(EffectivePerson effectivePerson, String job, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				wo.setReadList(WoRead.copier.copy(emc.listEqual(Read.class, Read.job_FIELDNAME, job)));
@@ -249,7 +205,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		});
 	}
 
-	private CompletableFuture<Void> workJson(Work work, Wo wo) {
+	private CompletableFuture<Void> workJsonFuture(Work work, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			try {
 				wo.setWork(gson.toJsonTree(WoWork.copier.copy(work)));
@@ -259,7 +215,26 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		});
 	}
 
-	private CompletableFuture<Void> creatorIdentity(String creatorIdentity, Wo wo) {
+	private CompletableFuture<Void> activityRouteFuture(Work work, Wo wo) {
+		return CompletableFuture.runAsync(() -> {
+			WoActivity woActivity = new WoActivity();
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				Activity activity = business.getActivity(work);
+				if (null != activity) {
+					activity.copyTo(woActivity);
+					wo.setActivity(woActivity);
+					if (Objects.equals(ActivityType.manual, activity.getActivityType())) {
+						wo.setRouteList(WoRoute.copier.copy(business.route().pick(((Manual) activity).getRouteList())));
+					}
+				}
+			} catch (Exception e) {
+				logger.error(e);
+			}
+		});
+	}
+
+	private CompletableFuture<Void> creatorIdentityFuture(String creatorIdentity, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
@@ -270,7 +245,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		});
 	}
 
-	private CompletableFuture<Void> creatorPerson(String creatorPerson, Wo wo) {
+	private CompletableFuture<Void> creatorPersonFuture(String creatorPerson, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
@@ -281,7 +256,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		});
 	}
 
-	private CompletableFuture<Void> creatorUnit(String creatorUnit, Wo wo) {
+	private CompletableFuture<Void> creatorUnitFuture(String creatorUnit, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
 				Business business = new Business(emc);
@@ -292,19 +267,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		});
 	}
 
-	private Wo workCompleted(EffectivePerson effectivePerson, WorkCompleted workCompleted)
-			throws InterruptedException, ExecutionException {
-		Wo wo = new Wo();
-		CompletableFuture.allOf(completedJson(workCompleted, wo), completedData(workCompleted, wo),
-				read(effectivePerson, workCompleted.getJob(), wo),
-				creatorIdentity(workCompleted.getCreatorIdentity(), wo),
-				creatorPerson(workCompleted.getCreatorPerson(), wo), creatorUnit(workCompleted.getCreatorUnit(), wo),
-				attachment(effectivePerson, workCompleted.getJob(), wo),
-				completedRecord(effectivePerson, workCompleted, wo)).get();
-		return wo;
-	}
-
-	private CompletableFuture<Void> completedJson(WorkCompleted workCompleted, Wo wo) {
+	private CompletableFuture<Void> workCompletedJsonFuture(WorkCompleted workCompleted, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			try {
 				wo.setWork(gson.toJsonTree(WoWorkCompleted.copier.copy(workCompleted)));
@@ -314,7 +277,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		});
 	}
 
-	private CompletableFuture<Void> completedData(WorkCompleted workCompleted, Wo wo) {
+	private CompletableFuture<Void> workCompletedDataFuture(WorkCompleted workCompleted, Wo wo) {
 		return CompletableFuture.runAsync(() -> {
 			if (BooleanUtils.isTrue(workCompleted.getMerged())) {
 				wo.setData(workCompleted.getProperties().getData());
@@ -395,6 +358,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 
 	public static class Wo extends GsonPropertyObject {
 
+		private static final long serialVersionUID = -2651851022553574012L;
 		// work和workCompleted都有
 		private JsonElement work;
 		// work和workCompleted都有
@@ -416,8 +380,8 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 		// work和workCompleted都有
 		private List<WoAttachment> attachmentList;
 
-		// work和workCompleted都有
-		private List<WoRecord> recordList;
+		// work和workCompleted都有,需要先行初始化,因为record可能为空
+		private List<WoRecord> recordList = new ArrayList<>();
 
 		// 只有work有
 		private WoActivity activity;
@@ -680,6 +644,9 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 	}
 
 	public static class WoAttachment extends Attachment {
+
+		private static final long serialVersionUID = -5323646346508661416L;
+
 		static WrapCopier<Attachment, WoAttachment> copier = WrapCopierFactory.wo(Attachment.class, WoAttachment.class,
 				null, JpaObject.FieldsInvisibleIncludeProperites);
 
@@ -696,6 +663,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
 
 	public static class WoAttachmentControl extends GsonPropertyObject {
 
+		private static final long serialVersionUID = -1159880170066584166L;
 		private Boolean allowRead = false;
 		private Boolean allowEdit = false;
 		private Boolean allowControl = false;

+ 7 - 7
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/workcompleted/ActionManageGetAssignment.java

@@ -78,7 +78,7 @@ class ActionManageGetAssignment extends BaseAction {
 						.forEach(o -> {
 							try {
 								WoRead w = WoRead.copier.copy(o);
-								//w.setControl(control);
+								// w.setControl(control);
 								wo.getReadList().add(w);
 							} catch (Exception e) {
 								logger.error(e);
@@ -95,7 +95,7 @@ class ActionManageGetAssignment extends BaseAction {
 						.forEach(o -> {
 							try {
 								WoReadCompleted w = WoReadCompleted.copier.copy(o);
-								//w.setControl(control);
+								// w.setControl(control);
 								wo.getReadCompletedList().add(w);
 							} catch (Exception e) {
 								logger.error(e);
@@ -112,7 +112,7 @@ class ActionManageGetAssignment extends BaseAction {
 						.forEach(o -> {
 							try {
 								WoReview w = WoReview.copier.copy(o);
-								//w.setControl(control);
+								// w.setControl(control);
 								wo.getReviewList().add(w);
 							} catch (Exception e) {
 								logger.error(e);
@@ -122,10 +122,10 @@ class ActionManageGetAssignment extends BaseAction {
 				logger.error(e);
 			}
 		});
-		future_taskCompleted.get(300, TimeUnit.SECONDS);
-		future_read.get(300, TimeUnit.SECONDS);
-		future_readCompleted.get(300, TimeUnit.SECONDS);
-		future_review.get(300, TimeUnit.SECONDS);
+		future_taskCompleted.get(10, TimeUnit.SECONDS);
+		future_read.get(10, TimeUnit.SECONDS);
+		future_readCompleted.get(10, TimeUnit.SECONDS);
+		future_review.get(10, TimeUnit.SECONDS);
 		result.setData(wo);
 		return result;
 	}

+ 9 - 9
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/workcompleted/BaseAction.java

@@ -348,7 +348,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //		Activity activity = null;
 //		Long reviewCount = 0L;
 //
-//		CompletableFuture111111<Void> future_taskCompleteds = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_taskCompleteds = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<TaskCompleted> os = business.entityManagerContainer()
 //						.listEqual(TaskCompleted.class, TaskCompleted.job_FIELDNAME, workCompleted.getJob()).stream()
@@ -360,7 +360,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Void> future_reads = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_reads = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<Read> os = business.entityManagerContainer()
 //						.listEqual(Read.class, Read.job_FIELDNAME, workCompleted.getJob()).stream()
@@ -379,7 +379,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Void> future_readCompleteds = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_readCompleteds = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<ReadCompleted> os = business.entityManagerContainer()
 //						.listEqual(ReadCompleted.class, ReadCompleted.job_FIELDNAME, workCompleted.getJob()).stream()
@@ -391,7 +391,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Void> future_attachments = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_attachments = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<Attachment> os = business.entityManagerContainer()
 //						.listEqual(Attachment.class, Attachment.job_FIELDNAME, workCompleted.getJob()).stream()
@@ -402,7 +402,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Void> future_workLogs = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_workLogs = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				List<WorkLog> os = business.entityManagerContainer()
 //						.listEqual(WorkLog.class, WorkLog.job_FIELDNAME, workCompleted.getJob()).stream()
@@ -413,14 +413,14 @@ abstract class BaseAction extends StandardJaxrsAction {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Void> future_data = CompletableFuture111111.runAsync(() -> {
+//		CompletableFuture111111111111111111111111<Void> future_data = CompletableFuture111111111111111111111111.runAsync(() -> {
 //			try {
 //				t.setData(this.loadData(business, workCompleted));
 //			} catch (Exception e) {
 //				logger.error(e);
 //			}
 //		});
-//		CompletableFuture111111<Application> future_application = CompletableFuture111111.supplyAsync(() -> {
+//		CompletableFuture111111111111111111111111<Application> future_application = CompletableFuture111111111111111111111111.supplyAsync(() -> {
 //			Application o = null;
 //			try {
 //				o = business.application().pick(workCompleted.getApplication());
@@ -429,7 +429,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //			}
 //			return o;
 //		});
-//		CompletableFuture111111<Process> future_process = CompletableFuture111111.supplyAsync(() -> {
+//		CompletableFuture111111111111111111111111<Process> future_process = CompletableFuture111111111111111111111111.supplyAsync(() -> {
 //			Process o = null;
 //			try {
 //				o = business.process().pick(workCompleted.getProcess());
@@ -438,7 +438,7 @@ abstract class BaseAction extends StandardJaxrsAction {
 //			}
 //			return o;
 //		});
-//		CompletableFuture111111<Long> future_reviewCount = CompletableFuture111111.supplyAsync(() -> {
+//		CompletableFuture111111111111111111111111<Long> future_reviewCount = CompletableFuture111111111111111111111111.supplyAsync(() -> {
 //			Long o = 0L;
 //			try {
 //				o = business.entityManagerContainer().countEqualAndEqual(Review.class, Review.person_FIELDNAME,

+ 6 - 6
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/WorkCompletedProperties.java

@@ -35,7 +35,7 @@ public class WorkCompletedProperties extends JsonProperties {
 	private StoreForm storeForm;
 
 	@FieldDescribe("合并工作Form,移动端.")
-	private StoreForm storeFormMobile;
+	private StoreForm mobileStoreForm;
 
 	@FieldDescribe("标题")
 	private String title;
@@ -98,7 +98,7 @@ public class WorkCompletedProperties extends JsonProperties {
 
 	public StoreForm storeForm(boolean mobile) throws Exception {
 		if (mobile) {
-			return this.getStoreFormMobile();
+			return this.getMobileStoreForm();
 		} else {
 			return this.getStoreForm();
 		}
@@ -112,12 +112,12 @@ public class WorkCompletedProperties extends JsonProperties {
 		this.storeForm = storeForm;
 	}
 
-	public StoreForm getStoreFormMobile() {
-		return storeFormMobile;
+	public StoreForm getMobileStoreForm() {
+		return mobileStoreForm;
 	}
 
-	public void setStoreFormMobile(StoreForm storeFormMobile) {
-		this.storeFormMobile = storeFormMobile;
+	public void setMobileStoreForm(StoreForm mobileStoreForm) {
+		this.mobileStoreForm = mobileStoreForm;
 	}
 
 	public static class StoreForm extends GsonPropertyObject {

+ 3 - 3
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionMerge.java

@@ -93,14 +93,14 @@ class ActionMerge extends BaseAction {
 					Form form = business.element().get(workCompleted.getForm(), Form.class);
 					if (null != form) {
 						StoreForm storeForm = new StoreForm();
-						StoreForm storeFormMobile = new StoreForm();
+						StoreForm mobileStoreForm = new StoreForm();
 						storeForm.setForm(new RelatedForm(form, form.getDataOrMobileData()));
-						storeFormMobile.setForm(new RelatedForm(form, form.getMobileDataOrData()));
+						mobileStoreForm.setForm(new RelatedForm(form, form.getMobileDataOrData()));
 						CompletableFuture.allOf(relateForm(business, form, storeForm),
 								relateScript(business, form, storeForm), relateFormMobile(business, form, storeForm),
 								relateScriptMobile(business, form, storeForm)).get();
 						workCompleted.getProperties().setStoreForm(storeForm);
-						workCompleted.getProperties().setStoreFormMobile(storeFormMobile);
+						workCompleted.getProperties().setMobileStoreForm(mobileStoreForm);
 					}
 					CompletableFuture.allOf(mergeItem(business, workCompleted, items),
 							mergeTaskCompleted(business, workCompleted, taskCompleteds),

+ 5 - 5
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/end/EndProcessor.java

@@ -188,9 +188,9 @@ public class EndProcessor extends AbstractEndProcessor {
 			Form form = (aeiObjects.business().element().get(work.getForm(), Form.class));
 			if (null != form) {
 				StoreForm storeForm = new StoreForm();
-				StoreForm storeFormMobile = new StoreForm();
+				StoreForm mobileStoreForm = new StoreForm();
 				storeForm.setForm(new RelatedForm(form, form.getDataOrMobileData()));
-				storeFormMobile.setForm(new RelatedForm(form, form.getMobileDataOrData()));
+				mobileStoreForm.setForm(new RelatedForm(form, form.getMobileDataOrData()));
 				CompletableFuture<Map<String, RelatedForm>> _relatedForm = CompletableFuture.supplyAsync(() -> {
 					Map<String, RelatedForm> map = new TreeMap<>();
 					try {
@@ -300,10 +300,10 @@ public class EndProcessor extends AbstractEndProcessor {
 						});
 				storeForm.setRelatedFormMap(_relatedForm.get());
 				storeForm.setRelatedScriptMap(_relatedScript.get());
-				storeFormMobile.setRelatedFormMap(_relatedFormMobile.get());
-				storeFormMobile.setRelatedScriptMap(_relatedScriptMobile.get());
+				mobileStoreForm.setRelatedFormMap(_relatedFormMobile.get());
+				mobileStoreForm.setRelatedScriptMap(_relatedScriptMobile.get());
 				workCompleted.getProperties().setStoreForm(storeForm);
-				workCompleted.getProperties().setStoreFormMobile(storeFormMobile);
+				workCompleted.getProperties().setMobileStoreForm(mobileStoreForm);
 			}
 		}
 		return workCompleted;