提交 8f9dfffc 编写于 作者: Z zhourui

增加预计下一处理人接口

上级 6a4bfd32
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;
}
}
......@@ -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<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)
@GET
@Path("{id}/reference")
......@@ -815,7 +833,6 @@ public class TaskAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "待办提醒,message类型:task_press.", action = ActionManagePress.class)
@GET
@Path("{id}/press/manage")
......
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;
}
}
\ No newline at end of file
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;
}
}
\ No newline at end of file
......@@ -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<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)
@DELETE
@Path("{id}")
......
......@@ -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
......@@ -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
}
}
......@@ -33,6 +33,7 @@ public class SplitProcessor extends AbstractSplitProcessor {
@Override
protected void arrivingCommitted(AeiObjects aeiObjects, Split split) throws Exception {
// nothing
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册