Quellcode durchsuchen

增加预计下一处理人接口

zhourui vor 5 Jahren
Ursprung
Commit
8f9dfffcc1

+ 50 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ActionWill.java

@@ -0,0 +1,50 @@
+package com.x.processplatform.assemble.surface.jaxrs.task;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.Applications;
+import com.x.base.core.project.x_processplatform_service_processing;
+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;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.processplatform.assemble.surface.Business;
+import com.x.processplatform.assemble.surface.ThisApplication;
+import com.x.processplatform.core.entity.content.Task;
+import com.x.processplatform.core.express.service.processing.jaxrs.task.WillWo;
+
+class ActionWill extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(ActionWill.class);
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			ActionResult<Wo> result = new ActionResult<>();
+			Business business = new Business(emc);
+			Task task = emc.find(id, Task.class);
+			if (null == task) {
+				throw new ExceptionEntityNotExist(id, Task.class);
+			}
+			if (!business.readable(effectivePerson, task)) {
+				throw new ExceptionAccessDenied(effectivePerson, task);
+			}
+			Wo wo = get(task);
+			result.setData(wo);
+			return result;
+		}
+	}
+
+	private Wo get(Task task) throws Exception {
+		return ThisApplication.context().applications().getQuery(x_processplatform_service_processing.class,
+				Applications.joinQueryUri("task", task.getId(), "will"), task.getJob()).getData(Wo.class);
+	}
+
+	public static class Wo extends WillWo {
+
+		private static final long serialVersionUID = 2279846765261247910L;
+
+	}
+
+}

+ 19 - 2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/TaskAction.java

@@ -388,6 +388,24 @@ public class TaskAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 	}
 
 
+	@JaxrsMethodDescribe(value = "预计下一活动处理状态及处理人.", action = ActionWill.class)
+	@GET
+	@Path("{id}/will")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void will(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+		ActionResult<ActionWill.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionWill().execute(effectivePerson, id);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
 	@JaxrsMethodDescribe(value = "取得复合的待办.", action = ActionReference.class)
 	@JaxrsMethodDescribe(value = "取得复合的待办.", action = ActionReference.class)
 	@GET
 	@GET
 	@Path("{id}/reference")
 	@Path("{id}/reference")
@@ -815,14 +833,13 @@ public class TaskAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 	}
 
 
-
 	@JaxrsMethodDescribe(value = "待办提醒,message类型:task_press.", action = ActionManagePress.class)
 	@JaxrsMethodDescribe(value = "待办提醒,message类型:task_press.", action = ActionManagePress.class)
 	@GET
 	@GET
 	@Path("{id}/press/manage")
 	@Path("{id}/press/manage")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void managePress(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 	public void managePress(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-							@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+			@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
 		ActionResult<ActionManagePress.Wo> result = new ActionResult<>();
 		ActionResult<ActionManagePress.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
 		try {

+ 93 - 0
o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/WillWo.java

@@ -0,0 +1,93 @@
+package com.x.processplatform.core.express.service.processing.jaxrs.task;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.x.base.core.project.gson.GsonPropertyObject;
+import com.x.processplatform.core.entity.element.ActivityType;
+
+public class WillWo extends GsonPropertyObject {
+
+	private static final long serialVersionUID = 2279846765261247910L;
+
+	private String defaultRouteName;
+
+	private Boolean hasSole;
+
+	private ActivityType nextActivityType;
+
+	private String nextActivityName;
+
+	private String nextActivityDescription;
+
+	private String nextActivityAlias;
+
+	private Boolean allowRapid;
+
+	private List<String> nextTaskIdentityList = new ArrayList<>();
+
+	public String getDefaultRouteName() {
+		return defaultRouteName;
+	}
+
+	public void setDefaultRouteName(String defaultRouteName) {
+		this.defaultRouteName = defaultRouteName;
+	}
+
+	public List<String> getNextTaskIdentityList() {
+		return nextTaskIdentityList;
+	}
+
+	public void setNextTaskIdentityList(List<String> nextTaskIdentityList) {
+		this.nextTaskIdentityList = nextTaskIdentityList;
+	}
+
+	public Boolean getAllowRapid() {
+		return allowRapid;
+	}
+
+	public void setAllowRapid(Boolean allowRapid) {
+		this.allowRapid = allowRapid;
+	}
+
+	public ActivityType getNextActivityType() {
+		return nextActivityType;
+	}
+
+	public void setNextActivityType(ActivityType nextActivityType) {
+		this.nextActivityType = nextActivityType;
+	}
+
+	public Boolean getHasSole() {
+		return hasSole;
+	}
+
+	public void setHasSole(Boolean hasSole) {
+		this.hasSole = hasSole;
+	}
+
+	public String getNextActivityName() {
+		return nextActivityName;
+	}
+
+	public void setNextActivityName(String nextActivityName) {
+		this.nextActivityName = nextActivityName;
+	}
+
+	public String getNextActivityDescription() {
+		return nextActivityDescription;
+	}
+
+	public void setNextActivityDescription(String nextActivityDescription) {
+		this.nextActivityDescription = nextActivityDescription;
+	}
+
+	public String getNextActivityAlias() {
+		return nextActivityAlias;
+	}
+
+	public void setNextActivityAlias(String nextActivityAlias) {
+		this.nextActivityAlias = nextActivityAlias;
+	}
+
+}

+ 116 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionWill.java

@@ -0,0 +1,116 @@
+package com.x.processplatform.service.processing.jaxrs.task;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.concurrent.Callable;
+
+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.ExceptionEntityNotExist;
+import com.x.base.core.project.executor.ProcessPlatformExecutorFactory;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.tools.ListTools;
+import com.x.processplatform.core.entity.content.Task;
+import com.x.processplatform.core.entity.content.Work;
+import com.x.processplatform.core.entity.element.Activity;
+import com.x.processplatform.core.entity.element.ActivityType;
+import com.x.processplatform.core.entity.element.Manual;
+import com.x.processplatform.core.entity.element.Route;
+import com.x.processplatform.core.express.ProcessingAttributes;
+import com.x.processplatform.core.express.service.processing.jaxrs.task.WillWo;
+import com.x.processplatform.service.processing.Business;
+import com.x.processplatform.service.processing.configurator.ProcessingConfigurator;
+import com.x.processplatform.service.processing.processor.AeiObjects;
+import com.x.processplatform.service.processing.processor.manual.TaskIdentities;
+import com.x.processplatform.service.processing.processor.manual.TranslateTaskIdentityTools;
+
+class ActionWill extends BaseAction {
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
+
+		String executorSeed = null;
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+
+			Task task = emc.fetch(id, Task.class, ListTools.toList(Task.job_FIELDNAME));
+
+			if (null == task) {
+				throw new ExceptionEntityNotExist(id, Task.class);
+			}
+
+			executorSeed = task.getJob();
+		}
+
+		return ProcessPlatformExecutorFactory.get(executorSeed).submit(new CallableImpl(id)).get();
+	}
+
+	private class CallableImpl implements Callable<ActionResult<Wo>> {
+
+		private String id;
+
+		private CallableImpl(String id) {
+			this.id = id;
+		}
+
+		public ActionResult<Wo> call() throws Exception {
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				Wo wo = new Wo();
+				Task task = emc.find(id, Task.class);
+				Work work = emc.find(task.getWork(), Work.class);
+				if (null == work) {
+					throw new ExceptionEntityNotExist(task.getWork(), Work.class);
+				}
+				Manual manual = (Manual) business.element().get(work.getActivity(), ActivityType.manual);
+				if (null == manual) {
+					throw new ExceptionEntityNotExist(work.getActivity(), Manual.class);
+				}
+				if (BooleanUtils.isTrue(manual.getAllowRapid())) {
+					wo.setAllowRapid(true);
+				}
+				List<Route> routes = business.element().listRouteWithManual(manual.getId());
+				Route route = null;
+				if (routes.size() == 1) {
+					route = routes.get(0);
+				} else {
+					Optional<Route> optional = routes.stream().filter(o -> BooleanUtils.isTrue(o.getSole()))
+							.findFirst();
+					if (optional.isPresent()) {
+						route = optional.get();
+						wo.setHasSole(route.getSole());
+					}
+				}
+				if (null != route) {
+					wo.setDefaultRouteName(route.getName());
+					wo.setNextActivityType(route.getActivityType());
+					Activity nextActivity = business.element().getActivity(route.getActivity());
+					if (null != nextActivity) {
+						wo.setNextActivityName(nextActivity.getName());
+						wo.setNextActivityAlias(nextActivity.getAlias());
+						wo.setNextActivityDescription(nextActivity.getDescription());
+						if (Objects.equals(ActivityType.manual, nextActivity.getActivityType())) {
+							Manual nextManual = (Manual) nextActivity;
+							AeiObjects aeiObjects = new AeiObjects(business, work, nextManual,
+									new ProcessingConfigurator(), new ProcessingAttributes());
+							TaskIdentities taskIdentities = TranslateTaskIdentityTools.translate(aeiObjects,
+									nextManual);
+							wo.setNextTaskIdentityList(taskIdentities.identities());
+						}
+					}
+				}
+				ActionResult<Wo> result = new ActionResult<>();
+				result.setData(wo);
+				return result;
+			}
+		}
+	}
+
+	public static class Wo extends WillWo {
+
+		private static final long serialVersionUID = 663543271322651720L;
+	}
+
+}

+ 19 - 1
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/TaskAction.java

@@ -85,6 +85,24 @@ public class TaskAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 	}
 
 
+	@JaxrsMethodDescribe(value = "预计下一活动处理状态及处理人.", action = ActionWill.class)
+	@GET
+	@Path("{id}/will")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void will(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+		ActionResult<ActionWill.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionWill().execute(effectivePerson, id);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
 	@JaxrsMethodDescribe(value = "删除待办.", action = ActionDelete.class)
 	@JaxrsMethodDescribe(value = "删除待办.", action = ActionDelete.class)
 	@DELETE
 	@DELETE
 	@Path("{id}")
 	@Path("{id}")
@@ -217,7 +235,7 @@ public class TaskAction extends StandardJaxrsAction {
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	@Consumes(MediaType.APPLICATION_JSON)
 	public void press(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 	public void press(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-					 @JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+			@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
 		ActionResult<ActionPress.Wo> result = new ActionResult<>();
 		ActionResult<ActionPress.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
 		try {

+ 3 - 3
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/choice/ChoiceProcessor.java

@@ -34,7 +34,7 @@ public class ChoiceProcessor extends AbstractChoiceProcessor {
 
 
 	@Override
 	@Override
 	protected void arrivingCommitted(AeiObjects aeiObjects, Choice choice) throws Exception {
 	protected void arrivingCommitted(AeiObjects aeiObjects, Choice choice) throws Exception {
-
+//nothing
 	}
 	}
 
 
 	@Override
 	@Override
@@ -46,7 +46,7 @@ public class ChoiceProcessor extends AbstractChoiceProcessor {
 
 
 	@Override
 	@Override
 	protected void executingCommitted(AeiObjects aeiObjects, Choice choice) throws Exception {
 	protected void executingCommitted(AeiObjects aeiObjects, Choice choice) throws Exception {
-
+//nothing
 	}
 	}
 
 
 	@Override
 	@Override
@@ -73,6 +73,6 @@ public class ChoiceProcessor extends AbstractChoiceProcessor {
 
 
 	@Override
 	@Override
 	protected void inquiringCommitted(AeiObjects aeiObjects, Choice choice) throws Exception {
 	protected void inquiringCommitted(AeiObjects aeiObjects, Choice choice) throws Exception {
-
+		// nothing
 	}
 	}
 }
 }

+ 3 - 1
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/parallel/ParallelProcessor.java

@@ -41,7 +41,7 @@ public class ParallelProcessor extends AbstractParallelProcessor {
 
 
 	@Override
 	@Override
 	protected void arrivingCommitted(AeiObjects aeiObjects, Parallel parallel) throws Exception {
 	protected void arrivingCommitted(AeiObjects aeiObjects, Parallel parallel) throws Exception {
-
+//nothing
 	}
 	}
 
 
 	@Override
 	@Override
@@ -102,6 +102,7 @@ public class ParallelProcessor extends AbstractParallelProcessor {
 
 
 	@Override
 	@Override
 	protected void executingCommitted(AeiObjects aeiObjects, Parallel parallel) throws Exception {
 	protected void executingCommitted(AeiObjects aeiObjects, Parallel parallel) throws Exception {
+		//nothing
 	}
 	}
 
 
 	@Override
 	@Override
@@ -124,5 +125,6 @@ public class ParallelProcessor extends AbstractParallelProcessor {
 
 
 	@Override
 	@Override
 	protected void inquiringCommitted(AeiObjects aeiObjects, Parallel parallel) throws Exception {
 	protected void inquiringCommitted(AeiObjects aeiObjects, Parallel parallel) throws Exception {
+		//nothing
 	}
 	}
 }
 }

+ 1 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/split/SplitProcessor.java

@@ -33,6 +33,7 @@ public class SplitProcessor extends AbstractSplitProcessor {
 
 
 	@Override
 	@Override
 	protected void arrivingCommitted(AeiObjects aeiObjects, Split split) throws Exception {
 	protected void arrivingCommitted(AeiObjects aeiObjects, Split split) throws Exception {
+		// nothing
 	}
 	}
 
 
 	@Override
 	@Override