diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ActionWill.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ActionWill.java new file mode 100644 index 0000000000000000000000000000000000000000..506fb6545aaa64fef2a0b32f23bae8c079067cae --- /dev/null +++ b/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 execute(EffectivePerson effectivePerson, String id) throws Exception { + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + ActionResult 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; + + } + +} diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/TaskAction.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/TaskAction.java index 92a5c2a3960fe0ffb4eba569c8d30aaa7858306c..ec4c35265f30d2124ed459af19b9a23f513d0704 100644 --- a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/TaskAction.java +++ b/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)); } + @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 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) @GET @Path("{id}/reference") @@ -815,14 +833,13 @@ public class TaskAction extends StandardJaxrsAction { asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result)); } - @JaxrsMethodDescribe(value = "待办提醒,message类型:task_press.", action = ActionManagePress.class) @GET @Path("{id}/press/manage") @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void managePress(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, - @JaxrsParameterDescribe("标识") @PathParam("id") String id) { + @JaxrsParameterDescribe("标识") @PathParam("id") String id) { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { diff --git a/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/WillWo.java b/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/WillWo.java new file mode 100644 index 0000000000000000000000000000000000000000..d3b91adf5481b1c8c2cd7b65dd1255e7bdabb96e --- /dev/null +++ b/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 nextTaskIdentityList = new ArrayList<>(); + + public String getDefaultRouteName() { + return defaultRouteName; + } + + public void setDefaultRouteName(String defaultRouteName) { + this.defaultRouteName = defaultRouteName; + } + + public List getNextTaskIdentityList() { + return nextTaskIdentityList; + } + + public void setNextTaskIdentityList(List 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; + } + +} \ No newline at end of file diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionWill.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionWill.java new file mode 100644 index 0000000000000000000000000000000000000000..5b94fef12077c6b6054928bb7a295c1e301ea25f --- /dev/null +++ b/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 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> { + + private String id; + + private CallableImpl(String id) { + this.id = id; + } + + public ActionResult 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 routes = business.element().listRouteWithManual(manual.getId()); + Route route = null; + if (routes.size() == 1) { + route = routes.get(0); + } else { + Optional 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 result = new ActionResult<>(); + result.setData(wo); + return result; + } + } + } + + public static class Wo extends WillWo { + + private static final long serialVersionUID = 663543271322651720L; + } + +} \ No newline at end of file diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/TaskAction.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/TaskAction.java index ef13203bb96d7405c8c8df282e4c73b241b200a9..75d75a83ce692277bfb320dcf66223fdd11f6100 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/TaskAction.java +++ b/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)); } + @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 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) @DELETE @Path("{id}") @@ -217,7 +235,7 @@ public class TaskAction extends StandardJaxrsAction { @Produces(HttpMediaType.APPLICATION_JSON_UTF_8) @Consumes(MediaType.APPLICATION_JSON) public void press(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, - @JaxrsParameterDescribe("标识") @PathParam("id") String id) { + @JaxrsParameterDescribe("标识") @PathParam("id") String id) { ActionResult result = new ActionResult<>(); EffectivePerson effectivePerson = this.effectivePerson(request); try { diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/choice/ChoiceProcessor.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/choice/ChoiceProcessor.java index 6354136c502cc188c85f67e43c470886e1752fb0..6c2227434746bc59337989f04a4ec2f9a8609afa 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/choice/ChoiceProcessor.java +++ b/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 protected void arrivingCommitted(AeiObjects aeiObjects, Choice choice) throws Exception { - +//nothing } @Override @@ -46,7 +46,7 @@ public class ChoiceProcessor extends AbstractChoiceProcessor { @Override protected void executingCommitted(AeiObjects aeiObjects, Choice choice) throws Exception { - +//nothing } @Override @@ -73,6 +73,6 @@ public class ChoiceProcessor extends AbstractChoiceProcessor { @Override protected void inquiringCommitted(AeiObjects aeiObjects, Choice choice) throws Exception { - + // nothing } } \ No newline at end of file diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/parallel/ParallelProcessor.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/parallel/ParallelProcessor.java index 8ab5fb452697e4b55c5efe730b83096241c2691c..ce71935e65e6bbd6e0a13c4b4ef12506f1b478b7 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/parallel/ParallelProcessor.java +++ b/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 protected void arrivingCommitted(AeiObjects aeiObjects, Parallel parallel) throws Exception { - +//nothing } @Override @@ -102,6 +102,7 @@ public class ParallelProcessor extends AbstractParallelProcessor { @Override protected void executingCommitted(AeiObjects aeiObjects, Parallel parallel) throws Exception { + //nothing } @Override @@ -124,5 +125,6 @@ public class ParallelProcessor extends AbstractParallelProcessor { @Override protected void inquiringCommitted(AeiObjects aeiObjects, Parallel parallel) throws Exception { + //nothing } } diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/split/SplitProcessor.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/split/SplitProcessor.java index 201e3126ac4db3565efaa3c6df53f491a5bdcb64..e945a41e01c683d8101071d608b3198eef30dfc4 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/split/SplitProcessor.java +++ b/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 protected void arrivingCommitted(AeiObjects aeiObjects, Split split) throws Exception { + // nothing } @Override