zhourui 5 лет назад
Родитель
Сommit
0508677702
12 измененных файлов с 555 добавлено и 36 удалено
  1. 3 1
      o2server/configSample/person.json
  2. 12 10
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/WrapStringList.java
  3. 8 2
      o2server/x_calendar_assemble_control/src/main/webapp/describe/sources/com/x/calendar/assemble/control/factory/CalendarFactory.java
  4. 16 2
      o2server/x_calendar_assemble_control/src/main/webapp/describe/sources/com/x/calendar/assemble/control/jaxrs/calendar/ActionListWhatICanView.java
  5. 1 1
      o2server/x_calendar_assemble_control/src/main/webapp/describe/sources/com/x/calendar/assemble/control/service/CalendarService.java
  6. 3 6
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionManageRetract.java
  7. 242 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/V2AddSplit.java
  8. 31 13
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/WorkAction.java
  9. 1 0
      o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/ProcessingAttributes.java
  10. 43 0
      o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/work/V2AddSplitWi.java
  11. 177 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/V2AddSplit.java
  12. 18 1
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/WorkAction.java

+ 3 - 1
o2server/configSample/person.json

@@ -10,6 +10,7 @@
   "passwordRegexHint": "6位以上,包含数字和字母.",
   "passwordRegexHint": "6位以上,包含数字和字母.",
   "register": "disable",
   "register": "disable",
   "superPermission": true,
   "superPermission": true,
+  "personUnitOrderByAsc": true,
   "###captchaLogin": "是否启用验证码登录,默认值:true###",
   "###captchaLogin": "是否启用验证码登录,默认值:true###",
   "###codeLogin": "是否启用验证码登录,默认值:true###",
   "###codeLogin": "是否启用验证码登录,默认值:true###",
   "###bindLogin": "是否启用扫描二维码登录,默认值:false###",
   "###bindLogin": "是否启用扫描二维码登录,默认值:false###",
@@ -32,5 +33,6 @@
   },
   },
   "###failureInterval": "登录限制时间(分钟)###",
   "###failureInterval": "登录限制时间(分钟)###",
   "###failureCount": "尝试登录次数###",
   "###failureCount": "尝试登录次数###",
-  "###tokenExpiredMinutes": "token时长,分钟###"
+  "###tokenExpiredMinutes": "token时长,分钟###",
+  "###personUnitOrderByAsc": "人员组织排序是否为升序,true为升序(默认),false为降序###"
 }
 }

+ 12 - 10
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/WrapStringList.java

@@ -7,6 +7,8 @@ import java.util.List;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.gson.GsonPropertyObject;
 
 
+import org.apache.commons.lang3.BooleanUtils;
+
 public class WrapStringList extends GsonPropertyObject {
 public class WrapStringList extends GsonPropertyObject {
 
 
 	public WrapStringList() {
 	public WrapStringList() {
@@ -26,19 +28,19 @@ public class WrapStringList extends GsonPropertyObject {
 	public void setValueList(List<String> valueList) {
 	public void setValueList(List<String> valueList) {
 		this.valueList = valueList;
 		this.valueList = valueList;
 	}
 	}
-	
-	public List<String> addValue( String value, Boolean unique ){
-		if( this.valueList == null ) {
+
+	public List<String> addValue(String value, Boolean unique) {
+		if (this.valueList == null) {
 			this.valueList = new ArrayList<>();
 			this.valueList = new ArrayList<>();
 		}
 		}
-		if( unique ) {
-			 if( !this.valueList.contains( value )) {
-				 this.valueList.add( value );
-			 }
-		}else {
-			this.valueList.add( value );
+		if (BooleanUtils.isTrue(unique)) {
+			if (!this.valueList.contains(value)) {
+				this.valueList.add(value);
+			}
+		} else {
+			this.valueList.add(value);
 		}
 		}
 		return this.valueList;
 		return this.valueList;
 	}
 	}
-	
+
 }
 }

+ 8 - 2
o2server/x_calendar_assemble_control/src/main/webapp/describe/sources/com/x/calendar/assemble/control/factory/CalendarFactory.java

@@ -104,7 +104,10 @@ public class CalendarFactory extends AbstractFactory {
 			p = CriteriaBuilderTools.predicate_and( cb, p, cb.equal(root.get(Calendar_.source), source));
 			p = CriteriaBuilderTools.predicate_and( cb, p, cb.equal(root.get(Calendar_.source), source));
 		}
 		}
 		if( StringUtils.isNotEmpty( createor )) {
 		if( StringUtils.isNotEmpty( createor )) {
-			p = CriteriaBuilderTools.predicate_and( cb, p, cb.equal(root.get(Calendar_.createor), createor));
+			p = CriteriaBuilderTools.predicate_and( cb, p, cb.or(
+					cb.equal(root.get(Calendar_.createor), createor),
+					cb.equal(root.get(Calendar_.target), createor)
+			));
 		}		
 		}		
 		
 		
 		Predicate permission = null;
 		Predicate permission = null;
@@ -140,7 +143,10 @@ public class CalendarFactory extends AbstractFactory {
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
 		Root<Calendar> root = cq.from(Calendar.class);
 		Root<Calendar> root = cq.from(Calendar.class);
-		Predicate permission = cb.equal( root.get(Calendar_.createor), personName );
+		Predicate permission = cb.or(
+				cb.equal(root.get(Calendar_.createor), personName),
+				cb.equal(root.get(Calendar_.target), personName)
+		);
 		cq.select(root.get(Calendar_.id));
 		cq.select(root.get(Calendar_.id));
 		return em.createQuery(cq.where(permission)).getResultList();
 		return em.createQuery(cq.where(permission)).getResultList();
 	}
 	}

+ 16 - 2
o2server/x_calendar_assemble_control/src/main/webapp/describe/sources/com/x/calendar/assemble/control/jaxrs/calendar/ActionListWhatICanView.java

@@ -11,6 +11,7 @@ import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.tools.ListTools;
 import com.x.base.core.project.tools.ListTools;
 import com.x.calendar.assemble.control.ThisApplication;
 import com.x.calendar.assemble.control.ThisApplication;
 import com.x.calendar.core.entity.Calendar;
 import com.x.calendar.core.entity.Calendar;
+import org.apache.commons.lang3.StringUtils;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -70,6 +71,7 @@ public class ActionListWhatICanView extends BaseAction {
 			if( ListTools.isNotEmpty( calendarList )) {
 			if( ListTools.isNotEmpty( calendarList )) {
 				result.setCount( Long.parseLong( calendarList.size() + "" ));
 				result.setCount( Long.parseLong( calendarList.size() + "" ));
 				WoCalendar woCalendar = null;
 				WoCalendar woCalendar = null;
+				Boolean existsSystemDefaultCalendar = false;
 				for( Calendar calendar : calendarList ) {
 				for( Calendar calendar : calendarList ) {
 					woCalendar = WoCalendar.copier.copy( calendar ) ;
 					woCalendar = WoCalendar.copier.copy( calendar ) ;
 					woCalendar.setManageable( ThisApplication.isCalendarManager( effectivePerson, calendar ) );
 					woCalendar.setManageable( ThisApplication.isCalendarManager( effectivePerson, calendar ) );
@@ -79,8 +81,20 @@ public class ActionListWhatICanView extends BaseAction {
 					if( "UNIT".equalsIgnoreCase( calendar.getType() ) ) {
 					if( "UNIT".equalsIgnoreCase( calendar.getType() ) ) {
 						wo.addUnitCalendar( woCalendar );
 						wo.addUnitCalendar( woCalendar );
 					}else {
 					}else {
-						if( calendar.getCreateor().equalsIgnoreCase( effectivePerson.getDistinguishedName() )) {
-							wo.addMyCalendar( woCalendar );
+						if( calendar.getCreateor().equalsIgnoreCase( effectivePerson.getDistinguishedName() )
+								|| StringUtils.equalsAnyIgnoreCase("SYSTEM", calendar.getCreateor() )) {
+							if( StringUtils.equalsAnyIgnoreCase("SYSTEM", calendar.getCreateor() )) {
+								if( !existsSystemDefaultCalendar ){
+									wo.addMyCalendar( woCalendar );
+									existsSystemDefaultCalendar = true;
+								}else{
+									//多了一个系统日历,删除当前这个日历
+									calendarServiceAdv.destory( calendar.getId() );
+								}
+							}else{
+								wo.addMyCalendar( woCalendar );
+							}
+
 						}else {
 						}else {
 							wo.addFollowCalendar( woCalendar );
 							wo.addFollowCalendar( woCalendar );
 						}
 						}

+ 1 - 1
o2server/x_calendar_assemble_control/src/main/webapp/describe/sources/com/x/calendar/assemble/control/service/CalendarService.java

@@ -174,7 +174,7 @@ public class CalendarService {
 			//创建一个自己的默认日历
 			//创建一个自己的默认日历
 			Calendar calendar = new Calendar();
 			Calendar calendar = new Calendar();
 			calendar.setSource( "PERSON" );
 			calendar.setSource( "PERSON" );
-			calendar.setCreateor( personName );
+			calendar.setCreateor( "SYSTEM" );
 			calendar.setColor( "#1462be" );
 			calendar.setColor( "#1462be" );
 			calendar.setDescription( "我的默认日历" );
 			calendar.setDescription( "我的默认日历" );
 			calendar.setId( Calendar.createId() );
 			calendar.setId( Calendar.createId() );

+ 3 - 6
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionManagerRetract.java → o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionManageRetract.java

@@ -42,10 +42,10 @@ import java.util.Comparator;
 import java.util.List;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
-class ActionManagerRetract extends BaseAction {
+class ActionManageRetract extends BaseAction {
 
 
 	@ActionLogger
 	@ActionLogger
-	private static Logger logger = LoggerFactory.getLogger(ActionManagerRetract.class);
+	private static Logger logger = LoggerFactory.getLogger(ActionManageRetract.class);
 
 
 	private WorkLog workLog;
 	private WorkLog workLog;
 	private TaskCompleted taskCompleted;
 	private TaskCompleted taskCompleted;
@@ -135,7 +135,6 @@ class ActionManagerRetract extends BaseAction {
 
 
 	}
 	}
 
 
-
 	private TaskCompleted findLastTaskCompleted(Business business) throws Exception {
 	private TaskCompleted findLastTaskCompleted(Business business) throws Exception {
 		List<TaskCompleted> list = business.entityManagerContainer().listEqualAndEqualAndEqual(TaskCompleted.class,
 		List<TaskCompleted> list = business.entityManagerContainer().listEqualAndEqualAndEqual(TaskCompleted.class,
 				TaskCompleted.job_FIELDNAME, workLog.getJob(), TaskCompleted.activityToken_FIELDNAME,
 				TaskCompleted.job_FIELDNAME, workLog.getJob(), TaskCompleted.activityToken_FIELDNAME,
@@ -143,7 +142,7 @@ class ActionManagerRetract extends BaseAction {
 		return list.stream().sorted(Comparator.comparing(TaskCompleted::getStartTime).reversed()).findFirst()
 		return list.stream().sorted(Comparator.comparing(TaskCompleted::getStartTime).reversed()).findFirst()
 				.orElse(null);
 				.orElse(null);
 	}
 	}
-	
+
 	private void retract() throws Exception {
 	private void retract() throws Exception {
 		Req req = new Req();
 		Req req = new Req();
 		req.setTaskCompleted(taskCompleted.getId());
 		req.setTaskCompleted(taskCompleted.getId());
@@ -221,8 +220,6 @@ class ActionManagerRetract extends BaseAction {
 		}
 		}
 	}
 	}
 
 
-
-
 	public static class Req extends V2RetractWi {
 	public static class Req extends V2RetractWi {
 
 
 	}
 	}

+ 242 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/V2AddSplit.java

@@ -0,0 +1,242 @@
+package com.x.processplatform.assemble.surface.jaxrs.work;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+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.bean.WrapCopier;
+import com.x.base.core.project.bean.WrapCopierFactory;
+import com.x.base.core.project.config.Config;
+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.WrapStringList;
+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.WorkLog;
+import com.x.processplatform.core.entity.element.ActivityType;
+import com.x.processplatform.core.entity.element.Manual;
+import com.x.processplatform.core.entity.element.util.WorkLogTree;
+import com.x.processplatform.core.entity.element.util.WorkLogTree.Node;
+import com.x.processplatform.core.entity.element.util.WorkLogTree.Nodes;
+import com.x.processplatform.core.express.ProcessingAttributes;
+import com.x.processplatform.core.express.service.processing.jaxrs.work.V2AddSplitWi;
+
+import org.apache.commons.collections4.ListUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+
+class V2AddSplit extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(V2AddSplit.class);
+
+	private EffectivePerson effectivePerson;
+	private Work work;
+	private WorkLog addSplitWorkLog;
+	private Record record;
+	private String series = StringTools.uniqueToken();
+	private List<String> existTaskIds = new ArrayList<>();
+	private V2AddSplitWi req = new V2AddSplitWi();
+	private Wi wi;
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
+		this.effectivePerson = effectivePerson;
+		wi = this.convertToWrapIn(jsonElement, Wi.class);
+		ActionResult<Wo> result = new ActionResult<>();
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			work = emc.find(id, Work.class);
+			if (null == work) {
+				throw new ExceptionWorkNotExist(id);
+			}
+
+			Manual manual = business.manual().pick(work.getActivity());
+			if (null == manual || BooleanUtils.isFalse(manual.getAllowAddSplit())
+					|| (!BooleanUtils.isTrue(work.getSplitting()))) {
+				throw new ExceptionCannotAddSplit(work.getId());
+			}
+
+			List<WorkLog> workLogs = this.listWorkLog(business, work);
+
+			WorkLogTree tree = new WorkLogTree(workLogs);
+
+			Node currentNode = tree.location(work);
+
+			if (null == currentNode) {
+				throw new ExceptionWorkLogWithActivityTokenNotExist(work.getActivityToken());
+			}
+
+			Node addSplitNode = this.findSplitNode(tree, currentNode);
+			if (null == addSplitNode) {
+				throw new ExceptionNoneSplitNode(work.getId());
+			}
+			addSplitWorkLog = addSplitNode.getWorkLog();
+
+			if (BooleanUtils.isTrue(wi.getTrimExist())) {
+				List<String> splitValues = ListUtils.subtract(wi.getSplitValueList(),
+						this.existSplitValues(tree, addSplitNode));
+				if (ListTools.isEmpty(splitValues)) {
+					throw new ExceptionEmptySplitValueAfterTrim(work.getId());
+				}
+				req.setSplitValueList(splitValues);
+			} else {
+				if (ListTools.isEmpty(wi.getSplitValueList())) {
+					throw new ExceptionEmptySplitValue(work.getId());
+				}
+				req.setSplitValueList(wi.getSplitValueList());
+			}
+			existTaskIds = emc.idsEqual(Task.class, Task.job_FIELDNAME, work.getJob());
+		}
+
+		List<String> ids = addSplit();
+		processing(ids);
+		record();
+		Wo wo = Wo.copier.copy(record);
+		result.setData(wo);
+		return result;
+	}
+
+	private List<String> existSplitValues(WorkLogTree tree, Node splitNode) {
+		List<String> values = new ArrayList<>();
+		for (Node node : splitNode.parents()) {
+			for (Node o : tree.down(node)) {
+				if (StringUtils.isNotEmpty(o.getWorkLog().getSplitValue())) {
+					values.add(o.getWorkLog().getSplitValue());
+				}
+			}
+		}
+		values = ListTools.trim(values, true, true);
+		return values;
+	}
+
+	private List<WorkLog> listWorkLog(Business business, Work work) throws Exception {
+		return business.entityManagerContainer().listEqual(WorkLog.class, WorkLog.job_FIELDNAME, work.getJob());
+	}
+
+	/**
+	 * 进行回溯定位到前一次进行拆分的节点
+	 */
+	private Node findSplitNode(WorkLogTree tree, Node currentNode) {
+		Nodes nodes = currentNode.upTo(ActivityType.split, ActivityType.manual, ActivityType.choice);
+		if (!nodes.isEmpty()) {
+			return nodes.get(0);
+		}
+		return null;
+	}
+
+	private List<String> addSplit() throws Exception {
+		req.setWorkLog(addSplitWorkLog.getId());
+		WrapStringList resp = ThisApplication.context().applications()
+				.putQuery(x_processplatform_service_processing.class,
+						Applications.joinQueryUri("work", "v2", work.getId(), "add", "split"), req, work.getJob())
+				.getData(WrapStringList.class);
+		if (ListTools.isEmpty(resp.getValueList())) {
+			throw new ExceptionReroute(this.work.getId());
+		}
+		return resp.getValueList();
+
+	}
+
+	private void processing(List<String> ids) throws Exception {
+		for (String id : ids) {
+			ProcessingAttributes processingAttributes = new ProcessingAttributes();
+			processingAttributes.setType(ProcessingAttributes.TYPE_ADDSPLIT);
+			processingAttributes.setSeries(series);
+			processingAttributes.setForceJoinAtArrive(true);
+			WoId processingResp = ThisApplication.context().applications()
+					.putQuery(x_processplatform_service_processing.class,
+							Applications.joinQueryUri("work", id, "processing"), processingAttributes, work.getJob())
+					.getData(WoId.class);
+			if (StringUtils.isBlank(processingResp.getId())) {
+				throw new ExceptionReroute(this.work.getId());
+			}
+		}
+	}
+
+	private void record() throws Exception {
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			final List<String> nextTaskIdentities = new ArrayList<>();
+			record = new Record(addSplitWorkLog);
+			record.setPerson(effectivePerson.getDistinguishedName());
+			record.setType(Record.TYPE_ADDSPLIT);
+			record.getProperties().setElapsed(
+					Config.workTime().betweenMinutes(record.getProperties().getStartTime(), record.getRecordTime()));
+			/* 需要记录处理人,先查看当前用户有没有之前处理过的信息,如果没有,取默认身份 */
+			TaskCompleted existTaskCompleted = emc.firstEqualAndEqual(TaskCompleted.class, TaskCompleted.job_FIELDNAME,
+					work.getJob(), TaskCompleted.person_FIELDNAME, effectivePerson.getDistinguishedName());
+			record.setPerson(effectivePerson.getDistinguishedName());
+			if (null != existTaskCompleted) {
+				record.setIdentity(existTaskCompleted.getIdentity());
+				record.setUnit(existTaskCompleted.getUnit());
+			} else {
+				record.setIdentity(
+						business.organization().identity().getMajorWithPerson(effectivePerson.getDistinguishedName()));
+				record.setUnit(business.organization().unit().getWithIdentity(record.getIdentity()));
+			}
+			List<String> ids = emc.idsEqual(Task.class, Task.job_FIELDNAME, work.getJob());
+			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 task = o.getValue().get(0);
+						NextManual nextManual = new NextManual();
+						nextManual.setActivity(task.getActivity());
+						nextManual.setActivityAlias(task.getActivityAlias());
+						nextManual.setActivityName(task.getActivityName());
+						nextManual.setActivityToken(task.getActivityToken());
+						nextManual.setActivityType(task.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));
+		}
+		WoId resp = ThisApplication.context().applications()
+				.postQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
+						Applications.joinQueryUri("record", "job", work.getJob()), record, this.work.getJob())
+				.getData(WoId.class);
+		if (StringUtils.isBlank(resp.getId())) {
+			throw new ExceptionRecord(this.work.getId());
+		}
+	}
+
+	public static class Wi extends V2AddSplitWi {
+
+	}
+
+	public static class Wo extends Record {
+
+		private static final long serialVersionUID = -8410749558739884101L;
+
+		static WrapCopier<Record, Wo> copier = WrapCopierFactory.wo(Record.class, Wo.class, null,
+				JpaObject.FieldsInvisible);
+	}
+
+	public static class WoControl extends WorkControl {
+
+	}
+
+}

+ 31 - 13
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/WorkAction.java

@@ -224,7 +224,7 @@ public class WorkAction extends StandardJaxrsAction {
 	@Path("process/{processFlag}/force")
 	@Path("process/{processFlag}/force")
 	@JaxrsMethodDescribe(value = "创建工作(强制创建存在的流程).", action = ActionCreateForce.class)
 	@JaxrsMethodDescribe(value = "创建工作(强制创建存在的流程).", action = ActionCreateForce.class)
 	public void createForce(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 	public void createForce(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-					   @JaxrsParameterDescribe("流程标识") @PathParam("processFlag") String processFlag, JsonElement jsonElement) {
+			@JaxrsParameterDescribe("流程标识") @PathParam("processFlag") String processFlag, JsonElement jsonElement) {
 		ActionResult<List<ActionCreateForce.Wo>> result = new ActionResult<>();
 		ActionResult<List<ActionCreateForce.Wo>> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
 		try {
@@ -263,14 +263,14 @@ public class WorkAction extends StandardJaxrsAction {
 	@Consumes(MediaType.APPLICATION_JSON)
 	@Consumes(MediaType.APPLICATION_JSON)
 	@Path("application/{applicationFlag}/process/{processFlag}/force")
 	@Path("application/{applicationFlag}/process/{processFlag}/force")
 	public void createWithApplicationProcessForce(@Suspended final AsyncResponse asyncResponse,
 	public void createWithApplicationProcessForce(@Suspended final AsyncResponse asyncResponse,
-											 @Context HttpServletRequest request,
-											 @JaxrsParameterDescribe("应用标识") @PathParam("applicationFlag") String applicationFlag,
-											 @JaxrsParameterDescribe("流程标识") @PathParam("processFlag") String processFlag, JsonElement jsonElement) {
+			@Context HttpServletRequest request,
+			@JaxrsParameterDescribe("应用标识") @PathParam("applicationFlag") String applicationFlag,
+			@JaxrsParameterDescribe("流程标识") @PathParam("processFlag") String processFlag, JsonElement jsonElement) {
 		ActionResult<List<ActionCreateWithApplicationProcessForce.Wo>> result = new ActionResult<>();
 		ActionResult<List<ActionCreateWithApplicationProcessForce.Wo>> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
 		try {
-			result = new ActionCreateWithApplicationProcessForce().execute(effectivePerson, applicationFlag, processFlag,
-					jsonElement);
+			result = new ActionCreateWithApplicationProcessForce().execute(effectivePerson, applicationFlag,
+					processFlag, jsonElement);
 		} catch (Exception e) {
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, jsonElement);
 			logger.error(e, effectivePerson, request, jsonElement);
 			result.error(e);
 			result.error(e);
@@ -977,18 +977,36 @@ public class WorkAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 	}
 
 
-	@JaxrsMethodDescribe(value = "管理员替代person操作工作召回。", action = ActionManagerRetract.class)
+	@JaxrsMethodDescribe(value = "V2_增加一个会签分支", action = ActionAddSplit.class)
 	@PUT
 	@PUT
-	@Path("v2/{id}/person/{person}/retract/manager")
+	@Path("v2/{id}/add/split")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void managerRetract(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-							   @JaxrsParameterDescribe("工作标识") @PathParam("id") String id,
-							   @JaxrsParameterDescribe("召回工作已办人员(根据流转记录确认)") @PathParam("person") String person,JsonElement jsonElement) {
-		ActionResult<ActionManagerRetract.Wo> result = new ActionResult<>();
+	public void V2AddSplit(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("工作标识") @PathParam("id") String id, JsonElement jsonElement) {
+		ActionResult<V2AddSplit.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2AddSplit().execute(effectivePerson, id, jsonElement);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, jsonElement);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+	@JaxrsMethodDescribe(value = "管理员替代person操作工作召回。", action = ActionManageRetract.class)
+	@PUT
+	@Path("v2/{id}/person/{person}/retract/manage")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void manageRetract(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("工作标识") @PathParam("id") String id,
+			@JaxrsParameterDescribe("召回工作已办人员(根据流转记录确认)") @PathParam("person") String person, JsonElement jsonElement) {
+		ActionResult<ActionManageRetract.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
 		try {
-			result = new ActionManagerRetract().execute(effectivePerson, id, person);
+			result = new ActionManageRetract().execute(effectivePerson, id, person);
 		} catch (Exception e) {
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, jsonElement);
 			logger.error(e, effectivePerson, request, jsonElement);
 			result.error(e);
 			result.error(e);

+ 1 - 0
o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/ProcessingAttributes.java

@@ -12,6 +12,7 @@ public class ProcessingAttributes extends GsonPropertyObject {
 
 
 	public static final String TYPE_TASK = "task";
 	public static final String TYPE_TASK = "task";
 	public static final String TYPE_APPENDTASK = "appendTask";
 	public static final String TYPE_APPENDTASK = "appendTask";
+	public static final String TYPE_ADDSPLIT = "addSplit";
 	public static final String TYPE_REROUTE = "reroute";
 	public static final String TYPE_REROUTE = "reroute";
 	public static final String TYPE_RESET = "reset";
 	public static final String TYPE_RESET = "reset";
 	public static final String TYPE_RETRACT = "retract";
 	public static final String TYPE_RETRACT = "retract";

+ 43 - 0
o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/service/processing/jaxrs/work/V2AddSplitWi.java

@@ -0,0 +1,43 @@
+package com.x.processplatform.core.express.service.processing.jaxrs.work;
+
+import java.util.List;
+
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.gson.GsonPropertyObject;
+
+public class V2AddSplitWi extends GsonPropertyObject {
+
+    @FieldDescribe("添加的拆分值.")
+    private List<String> splitValueList;
+
+    @FieldDescribe("排除已经存在的拆分值.")
+    private Boolean trimExist;
+
+    @FieldDescribe("添加分支的workLog.")
+    private String workLog;
+
+    public List<String> getSplitValueList() {
+        return splitValueList;
+    }
+
+    public void setSplitValueList(List<String> splitValueList) {
+        this.splitValueList = splitValueList;
+    }
+
+    public Boolean getTrimExist() {
+        return trimExist;
+    }
+
+    public void setTrimExist(Boolean trimExist) {
+        this.trimExist = trimExist;
+    }
+
+    public String getWorkLog() {
+        return workLog;
+    }
+
+    public void setWorkLog(String workLog) {
+        this.workLog = workLog;
+    }
+
+}

+ 177 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/V2AddSplit.java

@@ -0,0 +1,177 @@
+package com.x.processplatform.service.processing.jaxrs.work;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+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.WrapStringList;
+import com.x.base.core.project.tools.ListTools;
+import com.x.base.core.project.tools.StringTools;
+import com.x.processplatform.core.entity.content.Work;
+import com.x.processplatform.core.entity.content.WorkLog;
+import com.x.processplatform.core.entity.element.Activity;
+import com.x.processplatform.core.entity.element.util.WorkLogTree;
+import com.x.processplatform.core.express.service.processing.jaxrs.work.V2AddSplitWi;
+import com.x.processplatform.service.processing.Business;
+
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+
+class V2AddSplit extends BaseAction {
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
+
+		final String job;
+		final Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Work work = emc.fetch(id, Work.class, ListTools.toList(Work.job_FIELDNAME));
+			if (null == work) {
+				throw new ExceptionEntityNotExist(id, Work.class);
+			}
+			job = work.getJob();
+		}
+
+		Callable<ActionResult<Wo>> callable = new Callable<ActionResult<Wo>>() {
+
+			public ActionResult<Wo> call() throws Exception {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+
+					ActionResult<Wo> result = new ActionResult<>();
+					Wo wo = new Wo();
+
+					Business business = new Business(emc);
+
+					/* 校验work是否存在 */
+					Work work = emc.find(id, Work.class);
+					if (null == work) {
+						throw new ExceptionEntityNotExist(id, Work.class);
+					}
+
+					if (BooleanUtils.isNotTrue(work.getSplitting())) {
+						throw new ExceptionNotSplit(work.getId());
+					}
+					if (ListTools.isEmpty(wi.getSplitValueList())) {
+						throw new ExceptionEmptySplitValue(work.getId());
+					}
+
+					List<WorkLog> workLogs = emc.listEqual(WorkLog.class, WorkLog.job_FIELDNAME, work.getJob());
+
+					WorkLogTree tree = new WorkLogTree(workLogs);
+
+					WorkLog arrived = workLogs.stream().filter(o -> {
+						return StringUtils.equals(o.getId(), wi.getWorkLog());
+					}).findFirst().orElse(null);
+
+					WorkLog from = tree.children(arrived).stream().findFirst().orElse(null);
+
+					if (null == arrived) {
+						throw new ExceptionInvalidArrivedWorkLog(wi.getWorkLog());
+					}
+
+					if (null == from) {
+						throw new ExceptionInvalidFromWorkLog(wi.getWorkLog());
+					}
+
+					Activity activity = business.element().getActivity(from.getFromActivity());
+
+					for (String splitValue : wi.getSplitValueList()) {
+
+						emc.beginTransaction(Work.class);
+						emc.beginTransaction(WorkLog.class);
+
+						Work workCopy = new Work(work);
+						workCopy.setActivity(activity.getId());
+						workCopy.setActivityAlias(activity.getAlias());
+						workCopy.setActivityArrivedTime(new Date());
+						workCopy.setActivityDescription(activity.getDescription());
+						workCopy.setActivityName(activity.getName());
+						workCopy.setActivityToken(StringTools.uniqueToken());
+						workCopy.setActivityType(activity.getActivityType());
+						workCopy.setSplitTokenList(arrived.getProperties().getSplitTokenList());
+						workCopy.setSplitToken(arrived.getSplitToken());
+						workCopy.setSplitting(from.getSplitting());
+						workCopy.setSplitValue(splitValue);
+						workCopy.getManualTaskIdentityList().clear();
+						workCopy.setBeforeExecuted(false);
+						workCopy.setDestinationActivity(null);
+						workCopy.setDestinationActivityType(null);
+						workCopy.setDestinationRoute(null);
+						workCopy.setDestinationRouteName(null);
+
+						WorkLog arrivedCopy = new WorkLog(arrived);
+						arrivedCopy.setArrivedActivity(activity.getId());
+						arrivedCopy.setArrivedActivityAlias(activity.getAlias());
+						arrivedCopy.setArrivedActivityName(activity.getName());
+						arrivedCopy.setArrivedActivityToken(workCopy.getActivityToken());
+						arrivedCopy.setArrivedActivityType(activity.getActivityType());
+						arrivedCopy.setWork(workCopy.getId());
+						arrivedCopy.setArrivedTime(workCopy.getActivityArrivedTime());
+						arrivedCopy.setSplitValue(workCopy.getSplitValue());
+
+						WorkLog fromCopy = new WorkLog(from);
+						fromCopy.setConnected(false);
+						fromCopy.setFromActivity(activity.getId());
+						fromCopy.setFromActivityAlias(activity.getAlias());
+						fromCopy.setFromActivityName(activity.getName());
+						fromCopy.setFromActivityType(activity.getActivityType());
+						fromCopy.setFromActivityToken(workCopy.getActivityToken());
+						fromCopy.setFromTime(workCopy.getActivityArrivedTime());
+						fromCopy.setWork(workCopy.getId());
+						arrivedCopy.setSplitValue(workCopy.getSplitValue());
+						fromCopy.setArrivedActivity("");
+						fromCopy.setArrivedActivityAlias("");
+						fromCopy.setArrivedActivityName("");
+						fromCopy.setArrivedActivityToken("");
+						fromCopy.setArrivedActivityType(null);
+						fromCopy.setArrivedTime(null);
+
+						emc.persist(workCopy, CheckPersistType.all);
+						emc.persist(arrivedCopy, CheckPersistType.all);
+						emc.persist(fromCopy, CheckPersistType.all);
+						emc.commit();
+						// Processing processing = new Processing(wi);
+						// processing.processing(workCopy.getId());
+						wo.addValue(work.getId(), true);
+					}
+					result.setData(wo);
+					return result;
+				}
+			}
+		};
+
+		return ProcessPlatformExecutorFactory.get(job).submit(callable).get();
+
+	}
+
+	// private Wo wo(Business business, Work copy) throws Exception {
+	// Wo wo = business.entityManagerContainer().fetch(copy.getId(), Wo.copier);
+	// if (null != wo) {
+	// wo.setTaskList(this.woTasks(business, copy));
+	// return wo;
+	// }
+	// return null;
+	// }
+
+	// private List<WoTask> woTasks(Business business, Work copy) throws Exception {
+	// return business.entityManagerContainer().fetchEqual(Task.class,
+	// WoTask.copier, Task.work_FIELDNAME,
+	// copy.getId());
+	// }
+
+	public static class Wi extends V2AddSplitWi {
+
+	}
+
+	public static class Wo extends WrapStringList {
+
+	}
+
+}

+ 18 - 1
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/WorkAction.java

@@ -87,7 +87,6 @@ public class WorkAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 	}
 
 
-	
 	@JaxrsMethodDescribe(value = "流转一个流程实例,以非阻塞队列方式运行.", action = ActionProcessingNonblocking.class)
 	@JaxrsMethodDescribe(value = "流转一个流程实例,以非阻塞队列方式运行.", action = ActionProcessingNonblocking.class)
 	@PUT
 	@PUT
 	@Path("{id}/processing/nonblocking")
 	@Path("{id}/processing/nonblocking")
@@ -286,4 +285,22 @@ public class WorkAction extends StandardJaxrsAction {
 		}
 		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 	}
+
+	@JaxrsMethodDescribe(value = "V2_回滚.", action = V2Rollback.class)
+	@PUT
+	@Path("v2/{id}/add/split")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void V2AddSplit(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("工作标识") @PathParam("id") String id, JsonElement jsonElement) {
+		ActionResult<V2AddSplit.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2AddSplit().execute(effectivePerson, id, jsonElement);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, jsonElement);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
 }
 }