From fbf04c020425bbb9502521f558e559ad4f15c468 Mon Sep 17 00:00:00 2001 From: zhourui Date: Mon, 16 May 2022 13:23:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20reset=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ManualTaskIdentityMatrix.java | 40 ++++++++++ .../surface/jaxrs/task/ActionProcessing.java | 8 +- .../surface/jaxrs/task/ExceptionAdd.java | 13 ++++ .../assemble/surface/jaxrs/task/V2Add.java | 35 ++++----- .../assemble/surface/jaxrs/task/V2Extend.java | 4 +- .../assemble/surface/jaxrs/task/V2Reset.java | 4 +- ...{WrapProcessing.java => ProcessingWi.java} | 24 +----- ...ionProcessingWo.java => ProcessingWo.java} | 2 +- .../processing/jaxrs/task/V2ResetWi.java | 71 +++++++++++------- .../jaxrs/task/ActionProcessing.java | 4 +- .../service/processing/jaxrs/task/V2Add.java | 39 +++++----- .../processing/jaxrs/task/V2Extend.java | 37 ++++----- .../processing/jaxrs/task/V2Reset.java | 75 +++++++++---------- .../processing/schedule/PassExpired.java | 4 +- 14 files changed, 207 insertions(+), 153 deletions(-) create mode 100644 o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ExceptionAdd.java rename o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/{WrapProcessing.java => ProcessingWi.java} (50%) rename o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/{ActionProcessingWo.java => ProcessingWo.java} (93%) diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/processplatform/ManualTaskIdentityMatrix.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/processplatform/ManualTaskIdentityMatrix.java index 01443e5329..978abdfef6 100644 --- a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/processplatform/ManualTaskIdentityMatrix.java +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/processplatform/ManualTaskIdentityMatrix.java @@ -94,6 +94,46 @@ public class ManualTaskIdentityMatrix extends GsonPropertyObject { return this.add(identity, after, replace, Arrays.asList(arr)); } + public ManualTaskIdentityMatrix reset(String identity, List addBeforeIdentities, + List extendIdentities, List addAfterIdentities, boolean remove) { + int rowpos = 0; + int colpos = -1; + for (Row row : matrix) { + colpos = row.indexOf(identity); + if (colpos > -1) { + break; + } else { + rowpos++; + } + } + if (colpos > -1) { + resetUpdate(rowpos, colpos, addBeforeIdentities, extendIdentities, addAfterIdentities); + } + return this; + } + + private void resetUpdate(int rowpos, int colpos, List addBeforeIdentities, List extendIdentities, + List addAfterIdentities) { + if ((null != addBeforeIdentities) && (!addBeforeIdentities.isEmpty())) { + for (String str : addBeforeIdentities) { + Row row = new Row(); + row.add(str); + matrix.add(rowpos++, row); + } + } + if ((null != extendIdentities) && (!extendIdentities.isEmpty())) { + matrix.get(rowpos).addAll(colpos, extendIdentities); + } + if ((null != addAfterIdentities) && (!addAfterIdentities.isEmpty())) { + for (String str : addAfterIdentities) { + Row row = new Row(); + row.add(str); + matrix.add(rowpos++, row); + } + compact(); + } + } + public void clear() { this.matrix.clear(); } diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ActionProcessing.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ActionProcessing.java index 8c6cd055ca..5115cdcc65 100644 --- a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ActionProcessing.java +++ b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ActionProcessing.java @@ -44,9 +44,9 @@ import com.x.processplatform.core.entity.element.Manual; import com.x.processplatform.core.entity.element.Route; import com.x.processplatform.core.entity.log.SignalStack; import com.x.processplatform.core.express.ProcessingAttributes; -import com.x.processplatform.core.express.service.processing.jaxrs.task.ActionProcessingWo; +import com.x.processplatform.core.express.service.processing.jaxrs.task.ProcessingWi; +import com.x.processplatform.core.express.service.processing.jaxrs.task.ProcessingWo; import com.x.processplatform.core.express.service.processing.jaxrs.task.WrapAppend; -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.task.WrapUpdatePrevTaskIdentity.PrevTask; import com.x.processplatform.core.express.service.processing.jaxrs.taskcompleted.WrapUpdateNextTaskIdentity; @@ -275,7 +275,7 @@ class ActionProcessing extends BaseAction { } private String processingProcessingTask(String processType) throws Exception { - WrapProcessing req = new WrapProcessing(); + ProcessingWi req = new ProcessingWi(); req.setProcessingType(processType); WoId resp = ThisApplication.context().applications() .putQuery(x_processplatform_service_processing.class, @@ -491,7 +491,7 @@ class ActionProcessing extends BaseAction { return o; } - public static class Wo extends ActionProcessingWo { + public static class Wo extends ProcessingWo { private static final long serialVersionUID = -1771383649634969945L; static WrapCopier copier = WrapCopierFactory.wo(Record.class, Wo.class, null, diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ExceptionAdd.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ExceptionAdd.java new file mode 100644 index 0000000000..1556705f94 --- /dev/null +++ b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ExceptionAdd.java @@ -0,0 +1,13 @@ +package com.x.processplatform.assemble.surface.jaxrs.task; + +import com.x.base.core.project.exception.LanguagePromptException; + +class ExceptionAdd extends LanguagePromptException { + + private static final long serialVersionUID = -1678718913437722938L; + + ExceptionAdd(String id) { + super("添加待办人失败, task:{}.", id); + } + +} \ No newline at end of file diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Add.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Add.java index 4b26e20139..fdfe893e50 100644 --- a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Add.java +++ b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Add.java @@ -35,8 +35,8 @@ 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.ProcessingWi; 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; @@ -103,8 +103,8 @@ public class V2Add extends BaseAction { 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.existTaskIds = emc.idsEqualAndEqual(Task.class, Task.job_FIELDNAME, task.getJob(), Task.work_FIELDNAME, + task.getWork()); this.identites = business.organization().identity().list(wi.getIdentityList()); // 在新扩充待办人员中去除已经有待办人员 identites.remove(task.getIdentity()); @@ -125,13 +125,13 @@ public class V2Add extends BaseAction { req, task.getJob()) .getData(WrapBoolean.class); if (BooleanUtils.isNotTrue(resp.getValue())) { - throw new ExceptionExtend(task.getId()); + throw new ExceptionAdd(task.getId()); } } private String processingTask(Task task) throws Exception { - WrapProcessing req = new WrapProcessing(); - req.setProcessingType(TaskCompleted.PROCESSINGTYPE_EXTEND); + ProcessingWi req = new ProcessingWi(); + req.setProcessingType(TaskCompleted.PROCESSINGTYPE_ADD); WoId resp = ThisApplication.context().applications() .putQuery(x_processplatform_service_processing.class, Applications.joinQueryUri("task", task.getId(), "processing"), req, task.getJob()) @@ -145,7 +145,7 @@ public class V2Add extends BaseAction { private void processingWork(Task task) throws Exception { ProcessingAttributes req = new ProcessingAttributes(); - req.setType(ProcessingAttributes.TYPE_TASKEXTEND); + req.setType(ProcessingAttributes.TYPE_TASKADD); req.setSeries(this.series); WoId resp = ThisApplication.context().applications() .putQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class, @@ -168,8 +168,8 @@ public class V2Add extends BaseAction { concreteRecord.setWorkCompleted(workCompleted.getId()); } concreteRecord.setPerson(effectivePerson.getDistinguishedName()); - concreteRecord.setType(Record.TYPE_TASKEXTEND); - recordAdjust(business, task, concreteRecord); + concreteRecord.setType(Record.TYPE_TASKADD); + createRecordAdjust(business, task, concreteRecord); } WoId resp = ThisApplication.context().applications() .postQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class, @@ -180,15 +180,15 @@ public class V2Add extends BaseAction { } } - private void recordAdjust(Business business, Task task, Record concreteRecord) throws Exception { - final List nextTaskIdentities = new ArrayList<>(); + private void createRecordAdjust(Business business, Task task, Record concreteRecord) throws Exception { List ids = business.entityManagerContainer().idsEqualAndEqual(Task.class, Task.job_FIELDNAME, - task.getJob(), Task.activity_FIELDNAME, task.getActivity()); + task.getJob(), Task.work_FIELDNAME, task.getWork()); ids = ListUtils.subtract(ids, existTaskIds); List 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 nextTaskIdentities = new ArrayList<>(); list.stream().collect(Collectors.groupingBy(Task::getActivity, Collectors.toList())).entrySet().stream() .forEach(o -> { Task next = o.getValue().get(0); @@ -209,7 +209,7 @@ public class V2Add extends BaseAction { } private void updateTaskCompleted() throws Exception { - /* 记录下一处理人信息 */ + // 记录下一处理人信息 WrapUpdateNextTaskIdentity req = new WrapUpdateNextTaskIdentity(); req.getTaskCompletedList().add(this.taskCompletedId); req.setNextTaskIdentityList(concreteRecord.getProperties().getNextManualTaskIdentityList()); @@ -220,7 +220,7 @@ public class V2Add extends BaseAction { } private void updateTask() throws Exception { - /* 记录上一处理人信息 */ + // 记录上一处理人信息 if (ListTools.isNotEmpty(newTasks)) { WrapUpdatePrevTaskIdentity req = new WrapUpdatePrevTaskIdentity(); req.setTaskList(newTasks); @@ -243,18 +243,19 @@ public class V2Add extends BaseAction { public static class Wi extends V2AddWi { - private static final long serialVersionUID = -3241215869441470402L; + private static final long serialVersionUID = -6251874269093504136L; } public static class WoControl extends WorkControl { - private static final long serialVersionUID = -8781558581462660831L; + private static final long serialVersionUID = -8675239528577375846L; + } public static class Wo extends WrapBoolean { - private static final long serialVersionUID = 4883624438858385234L; + private static final long serialVersionUID = 8155067200427920853L; } diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Extend.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Extend.java index 717c41472e..a9059b21f4 100644 --- a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Extend.java +++ b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Extend.java @@ -35,8 +35,8 @@ 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.ProcessingWi; import com.x.processplatform.core.express.service.processing.jaxrs.task.V2ExtendWi; -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; @@ -129,7 +129,7 @@ public class V2Extend extends BaseAction { } private String processingTask(Task task) throws Exception { - WrapProcessing req = new WrapProcessing(); + ProcessingWi req = new ProcessingWi(); req.setProcessingType(TaskCompleted.PROCESSINGTYPE_EXTEND); WoId resp = ThisApplication.context().applications() .putQuery(x_processplatform_service_processing.class, diff --git a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Reset.java b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Reset.java index 8efd3b4a39..0329c2c720 100644 --- a/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Reset.java +++ b/o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/V2Reset.java @@ -37,8 +37,8 @@ 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.ProcessingWi; import com.x.processplatform.core.express.service.processing.jaxrs.task.V2ResetWi; -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; @@ -137,7 +137,7 @@ public class V2Reset extends BaseAction { } private void processingTask() throws Exception { - WrapProcessing req = new WrapProcessing(); + ProcessingWi req = new ProcessingWi(); req.setProcessingType(TaskCompleted.PROCESSINGTYPE_RESET); WoId resp = ThisApplication.context().applications() .putQuery(x_processplatform_service_processing.class, diff --git a/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/WrapProcessing.java b/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/ProcessingWi.java similarity index 50% rename from o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/WrapProcessing.java rename to o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/ProcessingWi.java index 420cdff35e..fd0bd28981 100644 --- a/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/WrapProcessing.java +++ b/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/ProcessingWi.java @@ -3,7 +3,7 @@ package com.x.processplatform.core.express.service.processing.jaxrs.task; import com.x.base.core.project.annotation.FieldDescribe; import com.x.base.core.project.gson.GsonPropertyObject; -public class WrapProcessing extends GsonPropertyObject { +public class ProcessingWi extends GsonPropertyObject { private static final long serialVersionUID = -2272062779655632688L; @@ -11,12 +11,6 @@ public class WrapProcessing extends GsonPropertyObject { public static final String PROCESSINGTYPE_RESET = "reset"; -// @FieldDescribe("当前处理人") -// private String processingPerson; -// -// @FieldDescribe("当前处理身份") -// private String processingIdentity; - @FieldDescribe("流转类型.") private String processingType; @@ -28,20 +22,4 @@ public class WrapProcessing extends GsonPropertyObject { this.processingType = processingType; } -// public String getProcessingPerson() { -// return processingPerson; -// } -// -// public void setProcessingPerson(String processingPerson) { -// this.processingPerson = processingPerson; -// } -// -// public String getProcessingIdentity() { -// return processingIdentity; -// } -// -// public void setProcessingIdentity(String processingIdentity) { -// this.processingIdentity = processingIdentity; -// } - } diff --git a/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/ActionProcessingWo.java b/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/ProcessingWo.java similarity index 93% rename from o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/ActionProcessingWo.java rename to o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/ProcessingWo.java index 87a5217c20..5878a56bc4 100644 --- a/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/ActionProcessingWo.java +++ b/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/ProcessingWo.java @@ -3,7 +3,7 @@ package com.x.processplatform.core.express.service.processing.jaxrs.task; import com.x.processplatform.core.entity.content.Record; import com.x.processplatform.core.entity.log.SignalStack; -public class ActionProcessingWo extends Record { +public class ProcessingWo extends Record { private static final long serialVersionUID = -8450939016187545724L; diff --git a/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/V2ResetWi.java b/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/V2ResetWi.java index 7b3b50cd55..296fced1a6 100644 --- a/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/V2ResetWi.java +++ b/o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/task/V2ResetWi.java @@ -2,6 +2,8 @@ package com.x.processplatform.core.express.service.processing.jaxrs.task; 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; import com.x.base.core.project.tools.StringTools; @@ -10,17 +12,23 @@ public class V2ResetWi extends GsonPropertyObject { private static final long serialVersionUID = -8631082471633729236L; - @FieldDescribe("路由名称") - private String routeName; + @FieldDescribe("待办") + private String task; - @FieldDescribe("意见") - private String opinion; + @FieldDescribe("在指定待办前添加身份") + private List addBeforeList; + + @FieldDescribe("在指定待办扩充的身份") + private List extendList; + + @FieldDescribe("在指定待办后添加身份") + private List addAfterList; - @FieldDescribe("重置身份") - private List identityList; + @FieldDescribe("是否删除指定待办身份") + private Boolean remove; - @FieldDescribe("保留自身待办.") - private Boolean keep; + @FieldDescribe("意见") + private String opinion; @FieldDescribe("操作串号") private String series; @@ -29,27 +37,44 @@ public class V2ResetWi extends GsonPropertyObject { this.series = StringTools.uniqueToken(); } - public Boolean getKeep() { - if (null == keep) { - keep = false; - } - return keep; + public String getTask() { + return task; } - public List getIdentityList() { - return identityList; + public void setTask(String task) { + this.task = task; } - public void setIdentityList(List identityList) { - this.identityList = identityList; + public List getAddBeforeList() { + return addBeforeList; } - public String getRouteName() { - return routeName; + public void setAddBeforeList(List addBeforeList) { + this.addBeforeList = addBeforeList; } - public void setRouteName(String routeName) { - this.routeName = routeName; + public List getExtendList() { + return extendList; + } + + public void setExtendList(List extendList) { + this.extendList = extendList; + } + + public List getAddAfterList() { + return addAfterList; + } + + public void setAddAfterList(List addAfterList) { + this.addAfterList = addAfterList; + } + + public Boolean getRemove() { + return BooleanUtils.isTrue(remove); + } + + public void setRemove(Boolean remove) { + this.remove = remove; } public String getOpinion() { @@ -60,10 +85,6 @@ public class V2ResetWi extends GsonPropertyObject { this.opinion = opinion; } - public void setKeep(Boolean keep) { - this.keep = keep; - } - public String getSeries() { return series; } diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionProcessing.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionProcessing.java index 975a02eaf2..5161500002 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionProcessing.java +++ b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/ActionProcessing.java @@ -33,7 +33,7 @@ import com.x.processplatform.core.entity.element.ActivityType; import com.x.processplatform.core.entity.element.Manual; import com.x.processplatform.core.entity.element.Process; import com.x.processplatform.core.express.ProcessingAttributes; -import com.x.processplatform.core.express.service.processing.jaxrs.task.WrapProcessing; +import com.x.processplatform.core.express.service.processing.jaxrs.task.ProcessingWi; import com.x.processplatform.service.processing.Business; import com.x.processplatform.service.processing.MessageFactory; import com.x.processplatform.service.processing.WorkContext; @@ -226,7 +226,7 @@ class ActionProcessing extends BaseAction { private static final long serialVersionUID = 1L; } - public static class Wi extends WrapProcessing { + public static class Wi extends ProcessingWi { private static final long serialVersionUID = -6828623155146710691L; diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Add.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Add.java index 6a84e7f6b0..75bf78c8c2 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Add.java +++ b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Add.java @@ -7,6 +7,7 @@ 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.JpaObject; import com.x.base.core.entity.annotation.CheckPersistType; import com.x.base.core.project.exception.ExceptionEntityNotExist; import com.x.base.core.project.executor.ProcessPlatformExecutorFactory; @@ -20,6 +21,7 @@ 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.V2AddWi; +import com.x.processplatform.service.processing.Business; class V2Add extends BaseAction { @@ -33,14 +35,17 @@ class V2Add extends BaseAction { LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName); } - Task task = getTask(wi.getTask()); + Task task = null; - if (null == task) { - throw new ExceptionEntityNotExist(wi.getTask(), Task.class); - } - - if (null == this.getWork(task.getWork())) { - throw new ExceptionEntityNotExist(task.getWork(), Work.class); + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + Business business = new Business(emc); + task = getTask(business, wi.getTask()); + if (null == task) { + throw new ExceptionEntityNotExist(wi.getTask(), Task.class); + } + if (!this.checkWorkExist(business, task.getWork())) { + throw new ExceptionEntityNotExist(task.getWork(), Work.class); + } } return ProcessPlatformExecutorFactory.get(task.getJob()).submit(new CallableImpl(task.getWork(), @@ -48,17 +53,13 @@ class V2Add extends BaseAction { } - 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 Task getTask(Business business, String id) throws Exception { + return business.entityManagerContainer().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 boolean checkWorkExist(Business business, String id) throws Exception { + return business.entityManagerContainer().countEqual(Work.class, JpaObject.id_FIELDNAME, id) > 0; } private class CallableImpl implements Callable> { @@ -105,14 +106,14 @@ class V2Add extends BaseAction { public static class Wi extends V2AddWi { - private static final long serialVersionUID = -3542693358569393097L; + private static final long serialVersionUID = 7870902860170655791L; } public static class Wo extends WrapBoolean { - private static final long serialVersionUID = 6457473592503074552L; + private static final long serialVersionUID = -8882214104176786739L; } -} +} \ No newline at end of file diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Extend.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Extend.java index 83018c9c62..616ab4226d 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Extend.java +++ b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Extend.java @@ -7,6 +7,7 @@ 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.JpaObject; import com.x.base.core.entity.annotation.CheckPersistType; import com.x.base.core.project.exception.ExceptionEntityNotExist; import com.x.base.core.project.executor.ProcessPlatformExecutorFactory; @@ -20,6 +21,7 @@ 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.V2ExtendWi; +import com.x.processplatform.service.processing.Business; class V2Extend extends BaseAction { @@ -32,15 +34,18 @@ class V2Extend extends BaseAction { if (LOGGER.isDebugEnabled()) { LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName); } + + Task task = null; - 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); + try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { + Business business = new Business(emc); + task = getTask(business, wi.getTask()); + if (null == task) { + throw new ExceptionEntityNotExist(wi.getTask(), Task.class); + } + if (!this.checkWorkExist(business, task.getWork())) { + throw new ExceptionEntityNotExist(task.getWork(), Work.class); + } } return ProcessPlatformExecutorFactory.get(task.getJob()) @@ -49,17 +54,13 @@ class V2Extend extends BaseAction { } - 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 Task getTask(Business business, String id) throws Exception { + return business.entityManagerContainer().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 boolean checkWorkExist(Business business, String id) throws Exception { + return business.entityManagerContainer().countEqual(Work.class, JpaObject.id_FIELDNAME, id) > 0; } private class CallableImpl implements Callable> { @@ -113,4 +114,4 @@ class V2Extend extends BaseAction { } -} +} \ No newline at end of file diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Reset.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Reset.java index 3ac69123e3..0e5a15f10a 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Reset.java +++ b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/task/V2Reset.java @@ -4,9 +4,6 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import org.apache.commons.collections4.ListUtils; -import org.apache.commons.lang3.BooleanUtils; - import com.google.gson.JsonElement; import com.x.base.core.container.EntityManagerContainer; import com.x.base.core.container.factory.EntityManagerContainerFactory; @@ -18,11 +15,10 @@ 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.entity.element.ActivityType; -import com.x.processplatform.core.entity.element.Manual; import com.x.processplatform.core.express.service.processing.jaxrs.task.V2ResetWi; import com.x.processplatform.service.processing.Business; @@ -36,17 +32,40 @@ class V2Reset extends BaseAction { final Wi wi = this.convertToWrapIn(jsonElement, Wi.class); - final String job; + Task task = null; try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { - Task task = emc.fetch(id, Task.class, ListTools.toList(Task.job_FIELDNAME)); + task = emc.fetch(id, Task.class, ListTools.toList(Task.job_FIELDNAME)); if (null == task) { throw new ExceptionEntityNotExist(id, Task.class); } - job = task.getJob(); } - Callable> callable = () -> { + return ProcessPlatformExecutorFactory.get(task.getJob()).submit(new CallableImpl(task.getId(), + wi.getAddBeforeList(), wi.getExtendList(), wi.getAddAfterList(), wi.getRemove())) + .get(300, TimeUnit.SECONDS); + + } + + private class CallableImpl implements Callable> { + + private String id; + private List addBeforeIdentities; + private List extendIdentities; + private List addAfterIdentities; + private boolean remove; + + private CallableImpl(String id, List addBeforeIdentities, List extendIdentities, + List addAfterIdentities, boolean remove) { + this.id = id; + this.addBeforeIdentities = addBeforeIdentities; + this.extendIdentities = extendIdentities; + this.addAfterIdentities = addAfterIdentities; + this.remove = remove; + } + + @Override + public ActionResult call() throws Exception { try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) { Business business = new Business(emc); Task task = emc.find(id, Task.class); @@ -58,35 +77,17 @@ class V2Reset extends BaseAction { 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); - } - - /* 检查reset人员 */ - List identites = ListTools.trim(business.organization().identity().list(wi.getIdentityList()), + this.addBeforeIdentities = ListTools.trim(business.organization().identity().list(addBeforeIdentities), + true, true); + this.extendIdentities = ListTools.trim(business.organization().identity().list(extendIdentities), true, + true); + this.addAfterIdentities = ListTools.trim(business.organization().identity().list(addAfterIdentities), true, true); - - if (identites.isEmpty()) { - throw new ExceptionResetEmpty(); - } emc.beginTransaction(Work.class); - List os = ListTools.trim(work.getManualTaskIdentityMatrix().flat(), true, true); - - os = ListUtils.sum(os, identites); - /* 在新增待办人员中删除当前的处理人 */ - if (BooleanUtils.isNotTrue(wi.getKeep())) { - os = ListUtils.subtract(os, ListTools.toList(task.getIdentity())); - } - - if (ListTools.isEmpty(os)) { - throw new ExceptionResetEmpty(); - } - work.setManualTaskIdentityMatrix( - manual.identitiesToManualTaskIdentityMatrix(ListTools.trim(os, true, true))); - // work.setManualTaskIdentityList(ListTools.trim(os, true, true)); + ManualTaskIdentityMatrix matrix = work.getManualTaskIdentityMatrix(); + matrix.reset(task.getIdentity(), addBeforeIdentities, extendIdentities, addAfterIdentities, remove); + work.setManualTaskIdentityMatrix(matrix); emc.check(work, CheckPersistType.all); emc.commit(); @@ -96,9 +97,7 @@ class V2Reset extends BaseAction { ActionResult result = new ActionResult<>(); result.setData(wo); return result; - }; - - return ProcessPlatformExecutorFactory.get(job).submit(callable).get(300, TimeUnit.SECONDS); + } } diff --git a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/PassExpired.java b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/PassExpired.java index bd49ede0cc..db6230e77a 100644 --- a/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/PassExpired.java +++ b/o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/PassExpired.java @@ -42,7 +42,7 @@ import com.x.processplatform.core.entity.content.WorkLog; 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.WrapProcessing; +import com.x.processplatform.core.express.service.processing.jaxrs.task.ProcessingWi; import com.x.processplatform.core.express.service.processing.jaxrs.task.WrapUpdatePrevTaskIdentity; import com.x.processplatform.core.express.service.processing.jaxrs.taskcompleted.WrapUpdateNextTaskIdentity; import com.x.processplatform.service.processing.Business; @@ -124,7 +124,7 @@ public class PassExpired extends AbstractJob { } private String porcessingTask(Task task) throws Exception { - WrapProcessing req = new WrapProcessing(); + ProcessingWi req = new ProcessingWi(); req.setProcessingType(TaskCompleted.PROCESSINGTYPE_PASSEXPIRED); WoId resp = ThisApplication.context().applications() .putQuery(x_processplatform_service_processing.class, -- GitLab