提交 f1d0316c 编写于 作者: Z zhourui

add surface

上级 aaf6f4f7
......@@ -49,7 +49,7 @@ public class ManualTaskIdentityMatrix extends GsonPropertyObject {
public ManualTaskIdentityMatrix extend(String identity, boolean replace, List<String> list) {
for (Row row : matrix) {
int idx = row.indexOf(identity);
if (idx > 0) {
if (idx > -1) {
row.addAll(idx + 1, list);
if (replace) {
row.remove(idx);
......
package com.x.base.core.project.scripting;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
public class TestClient {
public static void main(String[] args) throws ScriptException {
ScriptEngine engine = ScriptingFactory.newScriptEngine();
Object so = engine.eval("'aaaa';");
Object ao = engine.eval("[];");
Object oo = engine.eval("{};");
System.out.println(so.getClass() + ":" + so.toString());
System.out.println(ao.getClass() + ":" + ao.toString());
System.out.println(oo.getClass() + ":" + oo.toString());
}
}
......@@ -1055,4 +1055,41 @@ public class TaskAction extends StandardJaxrsAction {
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "V2_在指定待办位置扩充处理人.", action = V2Extend.class)
@POST
@Path("v2/extend")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void v2Extend(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<V2Extend.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new V2Extend().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "V2_在指定待办位置新增处理人.", action = V2Add.class)
@POST
@Path("v2/add")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void v2Add(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<V2Add.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new V2Add().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
package com.x.processplatform.assemble.surface.jaxrs.task;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
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.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.jaxrs.WoId;
import com.x.base.core.project.jaxrs.WrapBoolean;
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;
import com.x.processplatform.assemble.surface.ThisApplication;
import com.x.processplatform.assemble.surface.WorkControl;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.RecordProperties.NextManual;
import com.x.processplatform.core.entity.content.Task;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.content.WorkCompleted;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.core.express.ProcessingAttributes;
import com.x.processplatform.core.express.service.processing.jaxrs.task.V2AddWi;
import com.x.processplatform.core.express.service.processing.jaxrs.task.WrapProcessing;
import com.x.processplatform.core.express.service.processing.jaxrs.task.WrapUpdatePrevTaskIdentity;
import com.x.processplatform.core.express.service.processing.jaxrs.taskcompleted.WrapUpdateNextTaskIdentity;
public class V2Add extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(V2Add.class);
// 当前提交的串号
private final String series = StringTools.uniqueToken();
// 新加入的身份列表
private List<String> identites = new ArrayList<>();
// 新创建的待办标识列表
private List<String> newTasks = new ArrayList<>();
// 当前待办转成已办得到的已办id
private String taskCompletedId;
// 已经存在的待办标识列表
private List<String> existTaskIds = new ArrayList<>();
// 输入
private Wi wi;
// 当前执行用户
private EffectivePerson effectivePerson;
// 根据输入得到的待办
private Task task = null;
// 当前待办的workLog
private WorkLog workLog = null;
// 本环节创建的record
private Record concreteRecord = null;
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
}
this.init(effectivePerson, jsonElement);
this.add(this.task, wi.getAfter(), wi.getReplace(), identites);
if (BooleanUtils.isTrue(wi.getReplace())) {
taskCompletedId = this.processingTask(this.task);
}
this.processingWork(this.task);
this.createRecord(task, workLog);
if (StringUtils.isNotEmpty(taskCompletedId)) {
this.updateTaskCompleted();
}
this.updateTask();
return result();
}
private void init(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
this.effectivePerson = effectivePerson;
this.wi = this.convertToWrapIn(jsonElement, Wi.class);
this.task = emc.find(wi.getTask(), Task.class);
if (null == task) {
throw new ExceptionEntityNotExist(wi.getTask(), Task.class);
}
if (emc.countEqual(Work.class, JpaObject.id_FIELDNAME, task.getWork()) < 1) {
throw new ExceptionEntityNotExist(task.getWork(), Work.class);
}
this.workLog = emc.firstEqualAndEqual(WorkLog.class, WorkLog.job_FIELDNAME, task.getJob(),
WorkLog.fromActivityToken_FIELDNAME, task.getActivityToken());
if (null == workLog) {
throw new ExceptionEntityNotExist(WorkLog.class);
}
WoControl control = business.getControl(effectivePerson, task, WoControl.class);
if (BooleanUtils.isNotTrue(control.getAllowReset())) {
throw new ExceptionAccessDenied(effectivePerson, task);
}
this.existTaskIds = emc.idsEqualAndEqual(Task.class, Task.job_FIELDNAME, task.getJob(),
Task.activityToken_FIELDNAME, task.getActivityToken());
this.identites = business.organization().identity().list(wi.getIdentityList());
// 在新扩充待办人员中去除已经有待办人员
identites.remove(task.getIdentity());
if (ListTools.isEmpty(identites)) {
throw new ExceptionIdentityEmpty();
}
}
}
private void add(Task task, Boolean after, Boolean replace, List<String> identites) throws Exception {
V2AddWi req = new V2AddWi();
req.setTask(task.getId());
req.setAfter(after);
req.setReplace(replace);
req.setIdentityList(identites);
WrapBoolean resp = ThisApplication.context().applications()
.postQuery(x_processplatform_service_processing.class, Applications.joinQueryUri("task", "v2", "add"),
req, task.getJob())
.getData(WrapBoolean.class);
if (BooleanUtils.isNotTrue(resp.getValue())) {
throw new ExceptionExtend(task.getId());
}
}
private String processingTask(Task task) throws Exception {
WrapProcessing req = new WrapProcessing();
req.setProcessingType(TaskCompleted.PROCESSINGTYPE_EXTEND);
WoId resp = ThisApplication.context().applications()
.putQuery(x_processplatform_service_processing.class,
Applications.joinQueryUri("task", task.getId(), "processing"), req, task.getJob())
.getData(WoId.class);
if (StringUtils.isEmpty(resp.getId())) {
throw new ExceptionTaskProcessing(task.getId());
} else {
return resp.getId();
}
}
private void processingWork(Task task) throws Exception {
ProcessingAttributes req = new ProcessingAttributes();
req.setType(ProcessingAttributes.TYPE_TASKEXTEND);
req.setSeries(this.series);
WoId resp = ThisApplication.context().applications()
.putQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
Applications.joinQueryUri("work", task.getWork(), "processing"), req, task.getJob())
.getData(WoId.class);
if (StringUtils.isEmpty(resp.getId())) {
throw new ExceptionWorkProcessing(task.getWork());
}
}
private void createRecord(Task task, WorkLog workLog) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
concreteRecord = new Record(workLog, task);
// 校验workCompleted,如果存在,那么说明工作已经完成,标识状态为已经完成.
WorkCompleted workCompleted = emc.firstEqual(WorkCompleted.class, WorkCompleted.job_FIELDNAME,
task.getJob());
if (null != workCompleted) {
concreteRecord.setCompleted(true);
concreteRecord.setWorkCompleted(workCompleted.getId());
}
concreteRecord.setPerson(effectivePerson.getDistinguishedName());
concreteRecord.setType(Record.TYPE_TASKEXTEND);
recordAdjust(business, task, concreteRecord);
}
WoId resp = ThisApplication.context().applications()
.postQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
Applications.joinQueryUri("record", "job", task.getJob()), concreteRecord, task.getJob())
.getData(WoId.class);
if (StringUtils.isBlank(resp.getId())) {
throw new ExceptionExtend(task.getId());
}
}
private void recordAdjust(Business business, Task task, Record concreteRecord) throws Exception {
final List<String> nextTaskIdentities = new ArrayList<>();
List<String> ids = business.entityManagerContainer().idsEqualAndEqual(Task.class, Task.job_FIELDNAME,
task.getJob(), Task.activity_FIELDNAME, task.getActivity());
ids = ListUtils.subtract(ids, existTaskIds);
List<Task> list = business.entityManagerContainer().fetch(ids, Task.class,
ListTools.toList(Task.identity_FIELDNAME, Task.job_FIELDNAME, Task.work_FIELDNAME,
Task.activity_FIELDNAME, Task.activityAlias_FIELDNAME, Task.activityName_FIELDNAME,
Task.activityToken_FIELDNAME, Task.activityType_FIELDNAME, Task.identity_FIELDNAME));
list.stream().collect(Collectors.groupingBy(Task::getActivity, Collectors.toList())).entrySet().stream()
.forEach(o -> {
Task next = o.getValue().get(0);
NextManual nextManual = new NextManual();
nextManual.setActivity(next.getActivity());
nextManual.setActivityAlias(next.getActivityAlias());
nextManual.setActivityName(next.getActivityName());
nextManual.setActivityToken(next.getActivityToken());
nextManual.setActivityType(next.getActivityType());
for (Task t : o.getValue()) {
nextManual.getTaskIdentityList().add(t.getIdentity());
nextTaskIdentities.add(t.getIdentity());
}
concreteRecord.getProperties().getNextManualList().add(nextManual);
});
// 去重
concreteRecord.getProperties().setNextManualTaskIdentityList(ListTools.trim(nextTaskIdentities, true, true));
}
private void updateTaskCompleted() throws Exception {
/* 记录下一处理人信息 */
WrapUpdateNextTaskIdentity req = new WrapUpdateNextTaskIdentity();
req.getTaskCompletedList().add(this.taskCompletedId);
req.setNextTaskIdentityList(concreteRecord.getProperties().getNextManualTaskIdentityList());
ThisApplication.context().applications()
.putQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
Applications.joinQueryUri("taskcompleted", "next", "task", "identity"), req, task.getJob())
.getData(WrapBoolean.class);
}
private void updateTask() throws Exception {
/* 记录上一处理人信息 */
if (ListTools.isNotEmpty(newTasks)) {
WrapUpdatePrevTaskIdentity req = new WrapUpdatePrevTaskIdentity();
req.setTaskList(newTasks);
req.setPrevTaskIdentity(task.getIdentity());
req.getPrevTaskIdentityList().add(task.getIdentity());
ThisApplication.context().applications()
.putQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
Applications.joinQueryUri("task", "prev", "task", "identity"), req, task.getJob())
.getData(WrapBoolean.class);
}
}
private ActionResult<Wo> result() {
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
public static class Wi extends V2AddWi {
private static final long serialVersionUID = -3241215869441470402L;
}
public static class WoControl extends WorkControl {
private static final long serialVersionUID = -8781558581462660831L;
}
public static class Wo extends WrapBoolean {
private static final long serialVersionUID = 4883624438858385234L;
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
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.project.Applications;
import com.x.base.core.project.x_processplatform_service_processing;
import com.x.base.core.project.exception.ExceptionAccessDenied;
......@@ -30,7 +31,6 @@ import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.RecordProperties.NextManual;
import com.x.processplatform.core.entity.content.Task;
import com.x.processplatform.core.entity.content.TaskCompleted;
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.content.WorkLog;
......@@ -55,16 +55,14 @@ public class V2Extend extends BaseAction {
private List<String> existTaskIds = new ArrayList<>();
// 输入
private Wi wi;
// 本操作创建的记录
private Record record;
// 当前执行用户
private EffectivePerson effectivePerson;
// 根据输入得到的待办
private Task task = null;
// 根据待办获取的工作
private Work work = null;
// 当前待办的workLog
private WorkLog workLog = null;
// 本环节创建的record
private Record concreteRecord = null;
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
if (LOGGER.isDebugEnabled()) {
......@@ -76,7 +74,7 @@ public class V2Extend extends BaseAction {
taskCompletedId = this.processingTask(this.task);
}
this.processingWork(this.task);
this.record(task, workLog);
this.createRecord(task, workLog);
if (StringUtils.isNotEmpty(taskCompletedId)) {
this.updateTaskCompleted();
}
......@@ -93,8 +91,7 @@ public class V2Extend extends BaseAction {
if (null == task) {
throw new ExceptionEntityNotExist(wi.getTask(), Task.class);
}
this.work = emc.find(task.getWork(), Work.class);
if (null == work) {
if (emc.countEqual(Work.class, JpaObject.id_FIELDNAME, task.getWork()) < 1) {
throw new ExceptionEntityNotExist(task.getWork(), Work.class);
}
this.workLog = emc.firstEqualAndEqual(WorkLog.class, WorkLog.job_FIELDNAME, task.getJob(),
......@@ -106,11 +103,11 @@ public class V2Extend extends BaseAction {
if (BooleanUtils.isNotTrue(control.getAllowReset())) {
throw new ExceptionAccessDenied(effectivePerson, task);
}
this.existTaskIds = emc.idsEqualAndEqual(Task.class, Task.job_FIELDNAME, task.getJob(),
Task.activity_FIELDNAME, task.getActivity());
this.existTaskIds = emc.idsEqualAndEqual(Task.class, Task.job_FIELDNAME, task.getJob(), Task.work_FIELDNAME,
task.getWork());
this.identites = business.organization().identity().list(wi.getIdentityList());
// 在新扩充待办人员中去除已经有待办人员
this.identites = ListUtils.subtract(this.identites, ListTools.toList(task.getIdentity()));
identites.remove(task.getIdentity());
if (ListTools.isEmpty(identites)) {
throw new ExceptionIdentityEmpty();
}
......@@ -123,8 +120,8 @@ public class V2Extend extends BaseAction {
req.setReplace(replace);
req.setIdentityList(identites);
WrapBoolean resp = ThisApplication.context().applications()
.postQuery(x_processplatform_service_processing.class, Applications.joinQueryUri("task", "extend"), req,
task.getJob())
.postQuery(x_processplatform_service_processing.class,
Applications.joinQueryUri("task", "v2", "extend"), req, task.getJob())
.getData(WrapBoolean.class);
if (BooleanUtils.isNotTrue(resp.getValue())) {
throw new ExceptionExtend(task.getId());
......@@ -158,58 +155,63 @@ public class V2Extend extends BaseAction {
}
}
private void record(Task task, WorkLog workLog) throws Exception {
private void createRecord(Task task, WorkLog workLog) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
final List<String> nextTaskIdentities = new ArrayList<>();
this.record = new Record(workLog, task);
Business business = new Business(emc);
concreteRecord = new Record(workLog, task);
// 校验workCompleted,如果存在,那么说明工作已经完成,标识状态为已经完成.
WorkCompleted workCompleted = emc.firstEqual(WorkCompleted.class, WorkCompleted.job_FIELDNAME,
task.getJob());
if (null != workCompleted) {
record.setCompleted(true);
record.setWorkCompleted(workCompleted.getId());
concreteRecord.setCompleted(true);
concreteRecord.setWorkCompleted(workCompleted.getId());
}
record.setPerson(effectivePerson.getDistinguishedName());
record.setType(Record.TYPE_RESET);
List<String> ids = emc.idsEqualAndEqual(Task.class, Task.job_FIELDNAME, task.getJob(),
Task.activity_FIELDNAME, task.getActivity());
ids = ListUtils.subtract(ids, existTaskIds);
List<Task> list = emc.fetch(ids, Task.class,
ListTools.toList(Task.identity_FIELDNAME, Task.job_FIELDNAME, Task.work_FIELDNAME,
Task.activity_FIELDNAME, Task.activityAlias_FIELDNAME, Task.activityName_FIELDNAME,
Task.activityToken_FIELDNAME, Task.activityType_FIELDNAME, Task.identity_FIELDNAME));
list.stream().collect(Collectors.groupingBy(Task::getActivity, Collectors.toList())).entrySet().stream()
.forEach(o -> {
Task next = o.getValue().get(0);
NextManual nextManual = new NextManual();
nextManual.setActivity(next.getActivity());
nextManual.setActivityAlias(next.getActivityAlias());
nextManual.setActivityName(next.getActivityName());
nextManual.setActivityToken(next.getActivityToken());
nextManual.setActivityType(next.getActivityType());
for (Task t : o.getValue()) {
nextManual.getTaskIdentityList().add(t.getIdentity());
nextTaskIdentities.add(t.getIdentity());
}
record.getProperties().getNextManualList().add(nextManual);
});
// 去重
record.getProperties().setNextManualTaskIdentityList(ListTools.trim(nextTaskIdentities, true, true));
concreteRecord.setPerson(effectivePerson.getDistinguishedName());
concreteRecord.setType(Record.TYPE_TASKEXTEND);
createRecordAdjust(business, task, concreteRecord);
}
WoId resp = ThisApplication.context().applications()
.postQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
Applications.joinQueryUri("record", "job", task.getJob()), record, task.getJob())
Applications.joinQueryUri("record", "job", task.getJob()), concreteRecord, task.getJob())
.getData(WoId.class);
if (StringUtils.isBlank(resp.getId())) {
throw new ExceptionExtend(task.getId());
}
}
private void createRecordAdjust(Business business, Task task, Record concreteRecord) throws Exception {
List<String> ids = business.entityManagerContainer().idsEqualAndEqual(Task.class, Task.job_FIELDNAME,
task.getJob(), Task.work_FIELDNAME, task.getWork());
ids = ListUtils.subtract(ids, existTaskIds);
List<Task> list = business.entityManagerContainer().fetch(ids, Task.class,
ListTools.toList(Task.identity_FIELDNAME, Task.job_FIELDNAME, Task.work_FIELDNAME,
Task.activity_FIELDNAME, Task.activityAlias_FIELDNAME, Task.activityName_FIELDNAME,
Task.activityToken_FIELDNAME, Task.activityType_FIELDNAME, Task.identity_FIELDNAME));
final List<String> nextTaskIdentities = new ArrayList<>();
list.stream().collect(Collectors.groupingBy(Task::getActivity, Collectors.toList())).entrySet().stream()
.forEach(o -> {
Task next = o.getValue().get(0);
NextManual nextManual = new NextManual();
nextManual.setActivity(next.getActivity());
nextManual.setActivityAlias(next.getActivityAlias());
nextManual.setActivityName(next.getActivityName());
nextManual.setActivityToken(next.getActivityToken());
nextManual.setActivityType(next.getActivityType());
for (Task t : o.getValue()) {
nextManual.getTaskIdentityList().add(t.getIdentity());
nextTaskIdentities.add(t.getIdentity());
}
concreteRecord.getProperties().getNextManualList().add(nextManual);
});
// 去重
concreteRecord.getProperties().setNextManualTaskIdentityList(ListTools.trim(nextTaskIdentities, true, true));
}
private void updateTaskCompleted() throws Exception {
/* 记录下一处理人信息 */
// 记录下一处理人信息
WrapUpdateNextTaskIdentity req = new WrapUpdateNextTaskIdentity();
req.getTaskCompletedList().add(this.taskCompletedId);
req.setNextTaskIdentityList(record.getProperties().getNextManualTaskIdentityList());
req.setNextTaskIdentityList(concreteRecord.getProperties().getNextManualTaskIdentityList());
ThisApplication.context().applications()
.putQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
Applications.joinQueryUri("taskcompleted", "next", "task", "identity"), req, task.getJob())
......@@ -217,7 +219,7 @@ public class V2Extend extends BaseAction {
}
private void updateTask() throws Exception {
/* 记录上一处理人信息 */
// 记录上一处理人信息
if (ListTools.isNotEmpty(newTasks)) {
WrapUpdatePrevTaskIdentity req = new WrapUpdatePrevTaskIdentity();
req.setTaskList(newTasks);
......
......@@ -85,9 +85,12 @@ public class Record extends SliceJpaObject {
/* 外部调用流转 */
public static final String TYPE_SERVICE = "service";
/* 待办扩充 */
/* 扩充待办 */
public static final String TYPE_TASKEXTEND = "taskExtend";
/* 添加待办 */
public static final String TYPE_TASKADD = "taskAdd";
/* 定制意见 */
public static final String TYPE_CUSTOM = "custom";
......
......@@ -83,9 +83,7 @@ public class TaskCompleted extends SliceJpaObject implements ProjectionInterface
/* 扩充办理人 */
public static final String PROCESSINGTYPE_EXTEND = "extend";
/* 前添加处理人 */
public static final String PROCESSINGTYPE_ADDBEFORE = "addBefore";
/* 后添加处理人 */
public static final String PROCESSINGTYPE_ADDAFTER = "addAfter";
public static final String PROCESSINGTYPE_ADD = "add";
public String getId() {
return id;
......@@ -124,6 +122,8 @@ public class TaskCompleted extends SliceJpaObject implements ProjectionInterface
case PROCESSINGTYPE_ROLLBACK:
case PROCESSINGTYPE_EMPOWER:
case PROCESSINGTYPE_RESET:
case PROCESSINGTYPE_EXTEND:
case PROCESSINGTYPE_ADD:
this.joinInquire = false;
break;
default:
......
......@@ -3,6 +3,8 @@ package com.x.processplatform.core.express;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.BooleanUtils;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
......@@ -24,8 +26,7 @@ public class ProcessingAttributes extends GsonPropertyObject {
public static final String TYPE_ROLLBACK = "rollback";
public static final String TYPE_SERVICE = "service";
public static final String TYPE_TASKEXTEND = "taskExtend";
public static final String TYPE_TASKADDBEFORE = "taskAddBefore";
public static final String TYPE_TASKADDAFTER = "taskAddAfter";
public static final String TYPE_TASKADD = "taskAdd";
private Integer loop = 1;
......@@ -77,17 +78,11 @@ public class ProcessingAttributes extends GsonPropertyObject {
}
public Boolean ifForceJoinAtArrive() {
if (this.getForceJoinAtArrive() && loop == 1) {
return true;
}
return false;
return BooleanUtils.isTrue(this.getForceJoinAtArrive()) && (loop == 1);
}
public Boolean ifForceJoinAtInquire() {
if (this.getForceJoinAtInquire() && loop == 1) {
return true;
}
return false;
return BooleanUtils.isTrue(this.getForceJoinAtInquire()) && (loop == 1);
}
public Boolean getForceJoinAtArrive() {
......
package com.x.processplatform.core.express.service.processing.jaxrs.task;
import java.util.ArrayList;
import java.util.List;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
public class V2AddBeforeWi extends GsonPropertyObject {
private static final long serialVersionUID = -3293122515327864483L;
@FieldDescribe("身份")
private List<String> identityList = new ArrayList<>();
@FieldDescribe("是否执行替换")
private Boolean replace;
@FieldDescribe("是否删除")
private String task;
public List<String> getIdentityList() {
return identityList;
}
public void setIdentityList(List<String> identityList) {
this.identityList = identityList;
}
public Boolean getReplace() {
return replace;
}
public void setReplace(Boolean replace) {
this.replace = replace;
}
public String getTask() {
return task;
}
public void setTask(String task) {
this.task = task;
}
}
\ No newline at end of file
......@@ -3,16 +3,21 @@ package com.x.processplatform.core.express.service.processing.jaxrs.task;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.BooleanUtils;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
public class V2AddAfterWi extends GsonPropertyObject {
public class V2AddWi extends GsonPropertyObject {
private static final long serialVersionUID = -3293122515327864483L;
@FieldDescribe("身份")
private List<String> identityList = new ArrayList<>();
@FieldDescribe("加入在指定位置之后,否则加入在指定位置之前.")
private Boolean after;
@FieldDescribe("是否执行替换")
private Boolean replace;
......@@ -28,7 +33,7 @@ import com.x.base.core.project.gson.GsonPropertyObject;
}
public Boolean getReplace() {
return replace;
return BooleanUtils.isTrue(replace);
}
public void setReplace(Boolean replace) {
......@@ -43,4 +48,12 @@ import com.x.base.core.project.gson.GsonPropertyObject;
this.task = task;
}
public Boolean getAfter() {
return BooleanUtils.isTrue(after);
}
public void setAfter(Boolean after) {
this.after = after;
}
}
\ No newline at end of file
......@@ -3,10 +3,12 @@ package com.x.processplatform.core.express.service.processing.jaxrs.task;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.BooleanUtils;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
public class V2ExtendWi extends GsonPropertyObject {
public class V2ExtendWi extends GsonPropertyObject {
private static final long serialVersionUID = -3293122515327864483L;
......@@ -16,7 +18,7 @@ import com.x.base.core.project.gson.GsonPropertyObject;
@FieldDescribe("是否执行替换")
private Boolean replace;
@FieldDescribe("是否删除")
@FieldDescribe("待办标识")
private String task;
public List<String> getIdentityList() {
......@@ -28,7 +30,7 @@ import com.x.base.core.project.gson.GsonPropertyObject;
}
public Boolean getReplace() {
return replace;
return BooleanUtils.isTrue(replace);
}
public void setReplace(Boolean replace) {
......
......@@ -284,35 +284,17 @@ public class TaskAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "V2_在指定待办位置前新增处理人.", action = V2AddBefore.class)
@JaxrsMethodDescribe(value = "V2_在指定待办位置新增处理人.", action = V2Add.class)
@POST
@Path("v2/add/before")
@Path("v2/add")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void v2AddBefore(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
public void v2Add(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<V2AddBefore.Wo> result = new ActionResult<>();
ActionResult<V2Add.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new V2AddBefore().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "V2_在指定待办位置后新增处理人.", action = V2AddAfter.class)
@POST
@Path("v2/add/after")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void v2AddAfter(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<V2AddAfter.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new V2AddAfter().execute(effectivePerson, jsonElement);
result = new V2Add().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
......
......@@ -19,11 +19,11 @@ import com.x.base.core.project.processplatform.ManualTaskIdentityMatrix;
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.express.service.processing.jaxrs.task.V2AddAfterWi;
import com.x.processplatform.core.express.service.processing.jaxrs.task.V2AddWi;
class V2AddAfter extends BaseAction {
class V2Add extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(V2AddAfter.class);
private static final Logger LOGGER = LoggerFactory.getLogger(V2Add.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
......@@ -43,9 +43,8 @@ class V2AddAfter extends BaseAction {
throw new ExceptionEntityNotExist(task.getWork(), Work.class);
}
return ProcessPlatformExecutorFactory.get(task.getJob())
.submit(new CallableImpl(task.getWork(), task.getIdentity(), wi.getReplace(), wi.getIdentityList()))
.get(300, TimeUnit.SECONDS);
return ProcessPlatformExecutorFactory.get(task.getJob()).submit(new CallableImpl(task.getWork(),
task.getIdentity(), wi.getAfter(), wi.getReplace(), wi.getIdentityList())).get(300, TimeUnit.SECONDS);
}
......@@ -68,13 +67,16 @@ class V2AddAfter extends BaseAction {
private String identity;
private Boolean after;
private Boolean replace;
private List<String> identities;
CallableImpl(String id, String identity, Boolean replace, List<String> identities) {
CallableImpl(String id, String identity, Boolean after, Boolean replace, List<String> identities) {
this.id = id;
this.identity = identity;
this.after = after;
this.replace = replace;
this.identities = identities;
}
......@@ -85,7 +87,7 @@ class V2AddAfter extends BaseAction {
emc.beginTransaction(Work.class);
Work work = emc.find(this.id, Work.class);
ManualTaskIdentityMatrix matrix = work.getManualTaskIdentityMatrix();
matrix.addAfter(identity, replace, identities);
matrix.add(identity, after, replace, identities);
work.setManualTaskIdentityMatrix(matrix);
emc.check(work, CheckPersistType.all);
emc.commit();
......@@ -101,7 +103,7 @@ class V2AddAfter extends BaseAction {
}
public static class Wi extends V2AddAfterWi {
public static class Wi extends V2AddWi {
private static final long serialVersionUID = -3542693358569393097L;
......
package com.x.processplatform.service.processing.jaxrs.task;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
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.annotation.CheckPersistType;
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.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.processplatform.ManualTaskIdentityMatrix;
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.express.service.processing.jaxrs.task.V2AddBeforeWi;
class V2AddBefore extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(V2AddBefore.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
final Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
}
Task task = getTask(wi.getTask());
if (null == task) {
throw new ExceptionEntityNotExist(wi.getTask(), Task.class);
}
if (null == this.getWork(task.getWork())) {
throw new ExceptionEntityNotExist(task.getWork(), Work.class);
}
return ProcessPlatformExecutorFactory.get(task.getJob())
.submit(new CallableImpl(task.getWork(), task.getIdentity(), wi.getReplace(), wi.getIdentityList()))
.get(300, TimeUnit.SECONDS);
}
private Task getTask(String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
return emc.fetch(id, Task.class,
ListTools.toList(Task.job_FIELDNAME, Task.identity_FIELDNAME, Task.work_FIELDNAME));
}
}
private Work getWork(String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
return emc.fetch(id, Work.class, ListTools.toList());
}
}
private class CallableImpl implements Callable<ActionResult<Wo>> {
private String id;
private String identity;
private Boolean replace;
private List<String> identities;
CallableImpl(String id, String identity, Boolean replace, List<String> identities) {
this.id = id;
this.identity = identity;
this.replace = replace;
this.identities = identities;
}
@Override
public ActionResult<Wo> call() throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
emc.beginTransaction(Work.class);
Work work = emc.find(this.id, Work.class);
ManualTaskIdentityMatrix matrix = work.getManualTaskIdentityMatrix();
matrix.addBefore(identity, replace, identities);
work.setManualTaskIdentityMatrix(matrix);
emc.check(work, CheckPersistType.all);
emc.commit();
} catch (Exception e) {
LOGGER.error(e);
}
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
wo.setValue(true);
result.setData(wo);
return result;
}
}
public static class Wi extends V2AddBeforeWi {
private static final long serialVersionUID = -3542693358569393097L;
}
public static class Wo extends WrapBoolean {
private static final long serialVersionUID = 6457473592503074552L;
}
}
......@@ -86,7 +86,7 @@ class V2Extend extends BaseAction {
Work work = emc.find(this.id, Work.class);
ManualTaskIdentityMatrix matrix = work.getManualTaskIdentityMatrix();
matrix.extend(identity, replace, identities);
// work.setManualTaskIdentityMatrix(matrix);
work.setManualTaskIdentityMatrix(matrix);
emc.check(work, CheckPersistType.all);
emc.commit();
} catch (Exception e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册