Bläddra i källkod

支持service活动

Zhou Rui 5 år sedan
förälder
incheckning
484bc59bf5
35 ändrade filer med 658 tillägg och 167 borttagningar
  1. 22 48
      o2server/pom.xml
  2. 3 4
      o2server/x_base_core_project/pom.xml
  3. 7 27
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/executor/ProcessPlatformExecutorFactory.java
  4. 0 1
      o2server/x_console/src/main/java/com/x/server/console/server/application/ApplicationServerTools.java
  5. 3 3
      o2server/x_okr_assemble_control/src/main/webapp/describe/sources/com/x/okr/assemble/control/jaxrs/okrworkreportbaseinfo/ActionSaveDraftReport.java
  6. 2 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/ActionApplication.java
  7. 10 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/ApplicationServiceFilter.java
  8. 7 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/draft/BaseAction.java
  9. 35 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/draft/DraftAction.java
  10. 134 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ActionTouch.java
  11. 7 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/BaseAction.java
  12. 13 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ExceptionActivityNotService.java
  13. 12 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ExceptionService.java
  14. 12 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ExceptionWorkLogWithActivityTokenNotExist.java
  15. 50 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ServiceAction.java
  16. 4 4
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ActionProcessing.java
  17. 7 8
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionCreate.java
  18. 5 0
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionReroute.java
  19. 2 1
      o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/schedule/CleanKeyLock.java
  20. 3 0
      o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Record.java
  21. 24 39
      o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Work.java
  22. 17 0
      o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/WorkProperties.java
  23. 1 1
      o2server/x_processplatform_core_express/src/main/java/com/x/processplatform/core/express/ProcessingAttributes.java
  24. 2 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/ActionApplication.java
  25. 10 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/ServiceJaxrsFilter.java
  26. 79 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ActionTouch.java
  27. 7 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/BaseAction.java
  28. 13 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ExceptionActivityNotService.java
  29. 12 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ExceptionService.java
  30. 12 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ExceptionWorkLogWithActivityTokenNotExist.java
  31. 50 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ServiceAction.java
  32. 49 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/ActionProcessingNonblocking.java
  33. 4 4
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/V2Reroute.java
  34. 19 0
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/WorkAction.java
  35. 21 27
      o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/service/ServiceProcessor.java

+ 22 - 48
o2server/pom.xml

@@ -27,7 +27,6 @@
 		<module>x_portal_core_entity</module>
 		<module>x_processplatform_core_entity</module>
 		<module>x_teamwork_core_entity</module>
-		<!--module>x_workschedu_core_entity</module -->
 		<module>x_program_center_core_entity</module>
 		<module>x_organization_core_express</module>
 		<module>x_query_core_express</module>
@@ -59,7 +58,6 @@
 		<module>x_query_assemble_surface</module>
 		<module>x_query_service_processing</module>
 		<module>x_teamwork_assemble_control</module>
-		<!-- module>x_workschedu_assemble_control</module -->
 		<module>x_program_center</module>
 		<module>x_console</module>
 	</modules>
@@ -335,38 +333,6 @@
 					<artifactId>maven-resources-plugin</artifactId>
 					<version>3.1.0</version>
 				</plugin>
-				<!--This plugin's configuration is used to store Eclipse m2e settings 
-					only. It has no influence on the Maven build itself. -->
-				<plugin>
-					<groupId>org.eclipse.m2e</groupId>
-					<artifactId>lifecycle-mapping</artifactId>
-					<version>1.0.0</version>
-					<configuration>
-						<lifecycleMappingMetadata>
-							<pluginExecutions>
-								<pluginExecution>
-									<pluginExecutionFilter>
-										<groupId>
-											org.codehaus.mojo
-										</groupId>
-										<artifactId>
-											exec-maven-plugin
-										</artifactId>
-										<versionRange>
-											[1.6.0,)
-										</versionRange>
-										<goals>
-											<goal>java</goal>
-										</goals>
-									</pluginExecutionFilter>
-									<action>
-										<ignore></ignore>
-									</action>
-								</pluginExecution>
-							</pluginExecutions>
-						</lifecycleMappingMetadata>
-					</configuration>
-				</plugin>
 				<plugin>
 					<groupId>org.apache.maven.plugins</groupId>
 					<artifactId>maven-compiler-plugin</artifactId>
@@ -409,6 +375,28 @@
 					</excludes>
 				</configuration>
 			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-pmd-plugin</artifactId>
+				<version>3.13.0</version>
+				<configuration>
+					<linkXref>true</linkXref>
+					<sourceEncoding>utf-8</sourceEncoding>
+					<minimumTokens>100</minimumTokens>
+					<targetJdk>1.8</targetJdk>
+					<failOnViolation>false</failOnViolation>
+					<outputDirectory>${basedir}</outputDirectory>
+				</configuration>
+				<executions>
+					<execution>
+						<id>pmd-check</id>
+						<phase>verify</phase>
+						<goals>
+							<goal>check</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
 		</plugins>
 	</build>
 	<dependencyManagement>
@@ -702,20 +690,6 @@
 				<groupId>org.neuroph</groupId>
 				<artifactId>neuroph-core</artifactId>
 				<version>2.96</version>
-				<exclusions>
-					<exclusion>
-						<groupId>ch.qos.logback</groupId>
-						<artifactId>logback-core</artifactId>
-					</exclusion>
-					<exclusion>
-						<groupId>ch.qos.logback</groupId>
-						<artifactId>logback-classic</artifactId>
-					</exclusion>
-					<exclusion>
-						<groupId>javax.visrec</groupId>
-						<artifactId>visrec-api</artifactId>
-					</exclusion>
-				</exclusions>
 			</dependency>
 			<dependency>
 				<groupId>org.slf4j</groupId>

+ 3 - 4
o2server/x_base_core_project/pom.xml

@@ -1,7 +1,6 @@
 <?xml version="1.0"?>
-<project
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
-	xmlns="http://maven.apache.org/POM/4.0.0"
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" 
+	xmlns="http://maven.apache.org/POM/4.0.0" 
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
@@ -15,7 +14,7 @@
 
 	</dependencies>
 
-	
+
 	<build>
 		<plugins>
 			<plugin>

+ 7 - 27
o2server/x_base_core_project/src/main/java/com/x/base/core/project/executor/ProcessPlatformExecutorFactory.java

@@ -8,35 +8,15 @@ import com.x.base.core.project.config.Config;
 
 public class ProcessPlatformExecutorFactory {
 
-	private static ExecutorService[] executors;
+	private ProcessPlatformExecutorFactory() {
+		throw new IllegalStateException("ProcessPlatformExecutorFactory class");
+	}
 
-//	private static int count;
-//
-//	public static ExecutorService get(String seed) throws Exception {
-//		if (null == executors) {
-//			synchronized (ProcessPlatformExecutorServiceFactory.class) {
-//				if (null == executors) {
-//					count = Config.processPlatform().getExecutorCount();
-//					executors = new ExecutorService[count];
-//					for (int i = 0; i < count; i++) {
-//						executors[i] = Executors.newSingleThreadExecutor();
-//					}
-//				}
-//			}
-//		}
-//		CRC32 crc32 = new CRC32();
-//		crc32.update(Objects.toString(seed, "").getBytes());
-//		int idx = (int) (crc32.getValue() % count);
-//		return executors[idx];
-//	}
+	private static ExecutorService[] executors;
 
-	public static ExecutorService get(String seed) throws Exception {
+	public static synchronized ExecutorService get(String seed) throws Exception {
 		if (null == executors) {
-			synchronized (ProcessPlatformExecutorFactory.class) {
-				if (null == executors) {
-					executors = Config.resource_node_processPlatformExecutors();
-				}
-			}
+			executors = Config.resource_node_processPlatformExecutors();
 		}
 		CRC32 crc32 = new CRC32();
 		crc32.update(Objects.toString(seed, "").getBytes());
@@ -44,4 +24,4 @@ public class ProcessPlatformExecutorFactory {
 		return executors[idx];
 	}
 
-}
+}

+ 0 - 1
o2server/x_console/src/main/java/com/x/server/console/server/application/ApplicationServerTools.java

@@ -126,7 +126,6 @@ public class ApplicationServerTools extends JettySeverTools {
 				webApp.setResourceBase(dir.getAbsolutePath());
 				webApp.setDescriptor(new File(dir, "WEB-INF/web.xml").getAbsolutePath());
 				webApp.setExtraClasspath(calculateExtraClassPath(clz));
-				webApp.getMimeTypes().addMimeMapping("vcf", "text/x-vcard");
 				//webApp.getMimeTypes().addMimeMapping("wcss", "application/json");
 				webApp.getInitParams().put("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
 				webApp.getInitParams().put("org.eclipse.jetty.jsp.precompiled", "true");

+ 3 - 3
o2server/x_okr_assemble_control/src/main/webapp/describe/sources/com/x/okr/assemble/control/jaxrs/okrworkreportbaseinfo/ActionSaveDraftReport.java

@@ -64,7 +64,7 @@ public class ActionSaveDraftReport extends BaseAction {
 		}
 				
 		//设置当前登录用户为创建工作汇报的用户
-		if (check) {
+		if( Boolean.TRUE.equals( check ) ){
 			try {
 				wrapIn.setCreatorName( effectivePerson.getDistinguishedName() );
 				wrapIn.setCreatorIdentity( okrUserManagerService.getIdentityWithPerson(effectivePerson.getDistinguishedName()) );
@@ -75,7 +75,7 @@ public class ActionSaveDraftReport extends BaseAction {
 				logger.error( e, effectivePerson, request, null);
 			}
 		}
-		if (check) {
+		if( Boolean.TRUE.equals( check ) ){
 			try {
 				wrapIn.setCreatorUnitName( okrUserManagerService.getUnitNameByIdentity(wrapIn.getCreatorIdentity()));
 			} catch (Exception e) {
@@ -85,7 +85,7 @@ public class ActionSaveDraftReport extends BaseAction {
 				logger.error( e, effectivePerson, request, null);
 			}
 		}
-		if (check) {
+		if( Boolean.TRUE.equals( check ) ){
 			try {
 				wrapIn.setCreatorTopUnitName( okrUserManagerService.getTopUnitNameByIdentity(wrapIn.getCreatorIdentity()) );
 			} catch (Exception e) {

+ 2 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/ActionApplication.java

@@ -23,6 +23,7 @@ import com.x.processplatform.assemble.surface.jaxrs.review.ReviewAction;
 import com.x.processplatform.assemble.surface.jaxrs.route.RouteAction;
 import com.x.processplatform.assemble.surface.jaxrs.script.ScriptAction;
 import com.x.processplatform.assemble.surface.jaxrs.serialnumber.SerialNumberAction;
+import com.x.processplatform.assemble.surface.jaxrs.service.ServiceAction;
 import com.x.processplatform.assemble.surface.jaxrs.task.TaskAction;
 import com.x.processplatform.assemble.surface.jaxrs.taskcompleted.TaskCompletedAction;
 import com.x.processplatform.assemble.surface.jaxrs.work.WorkAction;
@@ -57,6 +58,7 @@ public class ActionApplication extends AbstractActionApplication {
 		classes.add(KeyLockAction.class);
 		classes.add(DocumentVersionAction.class);
 		classes.add(RecordAction.class);
+		classes.add(ServiceAction.class);
 		return classes;
 	}
 }

+ 10 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/ApplicationServiceFilter.java

@@ -0,0 +1,10 @@
+package com.x.processplatform.assemble.surface.jaxrs;
+
+import javax.servlet.annotation.WebFilter;
+
+import com.x.base.core.project.jaxrs.AnonymousCipherManagerUserJaxrsFilter;
+
+@WebFilter(urlPatterns = "/jaxrs/service/*", asyncSupported = true)
+public class ApplicationServiceFilter extends AnonymousCipherManagerUserJaxrsFilter {
+
+}

+ 7 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/draft/BaseAction.java

@@ -0,0 +1,7 @@
+package com.x.processplatform.assemble.surface.jaxrs.draft;
+
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+
+abstract class BaseAction extends StandardJaxrsAction {
+
+}

+ 35 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/draft/DraftAction.java

@@ -0,0 +1,35 @@
+package com.x.processplatform.assemble.surface.jaxrs.draft;
+
+import javax.ws.rs.Path;
+
+import com.x.base.core.project.annotation.JaxrsDescribe;
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+
+@Path("draft")
+@JaxrsDescribe("草稿")
+public class DraftAction extends StandardJaxrsAction {
+
+	private static Logger logger = LoggerFactory.getLogger(DraftAction.class);
+
+	// @JaxrsMethodDescribe(value = "列示指定工作或已完成工作的版式文件历史版本.", action = ActionListWithWorkOrWorkCompleted.class)
+	// @GET
+	// @Path("list/workorworkcompleted/{workOrWorkCompleted}")
+	// @Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	// @Consumes(MediaType.APPLICATION_JSON)
+	// public void listWithWorkOrWorkCompleted(@Suspended final AsyncResponse asyncResponse,
+	// 		@Context HttpServletRequest request,
+	// 		@JaxrsParameterDescribe("标识") @PathParam("workOrWorkCompleted") String workOrWorkCompleted) {
+	// 	ActionResult<List<ActionListWithWorkOrWorkCompleted.Wo>> result = new ActionResult<>();
+	// 	EffectivePerson effectivePerson = this.effectivePerson(request);
+	// 	try {
+	// 		result = new ActionListWithWorkOrWorkCompleted().execute(effectivePerson, workOrWorkCompleted);
+	// 	} catch (Exception e) {
+	// 		logger.error(e, effectivePerson, request, null);
+	// 		result.error(e);
+	// 	}
+	// 	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	// }
+
+}

+ 134 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ActionTouch.java

@@ -0,0 +1,134 @@
+package com.x.processplatform.assemble.surface.jaxrs.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+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.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.tools.ListTools;
+import com.x.base.core.project.tools.StringTools;
+import com.x.processplatform.assemble.surface.ThisApplication;
+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.Work;
+import com.x.processplatform.core.entity.content.WorkLog;
+import com.x.processplatform.core.entity.element.ActivityType;
+import com.x.processplatform.core.express.ProcessingAttributes;
+
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+
+class ActionTouch extends BaseAction {
+
+	private Work work;
+
+	private String series = StringTools.uniqueToken();
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
+		WorkLog workLog;
+		ActionResult<Wo> result = new ActionResult<>();
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			work = emc.find(id, Work.class);
+			if (null == work) {
+				throw new ExceptionEntityNotExist(id, Work.class);
+			}
+			if (!Objects.equals(ActivityType.service, work.getActivityType())) {
+				throw new ExceptionActivityNotService(work.getId());
+			}
+			workLog = emc.firstEqualAndEqual(WorkLog.class, WorkLog.job_FIELDNAME, work.getJob(),
+					WorkLog.fromActivityToken_FIELDNAME, work.getActivityToken());
+			if (null == workLog) {
+				throw new ExceptionWorkLogWithActivityTokenNotExist(work.getActivityToken());
+			}
+		}
+
+		WrapBoolean resp = ThisApplication.context().applications()
+				.putQuery(x_processplatform_service_processing.class,
+						Applications.joinQueryUri("service", "work", work.getId(), "touch"), jsonElement, work.getJob())
+				.getData(WrapBoolean.class);
+
+		if (BooleanUtils.isTrue(resp.getValue())) {
+			ProcessingAttributes req = new ProcessingAttributes();
+			req.setType(ProcessingAttributes.TYPE_SERVICE);
+			req.setSeries(this.series);
+			ThisApplication.context().applications()
+					.putQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
+							Applications.joinQueryUri("work", work.getId(), "processing","nonblocking"), null, work.getJob())
+					.getData(Wo.class);
+		}
+
+		Record record = this.record(workLog);
+
+		this.concreteRecord(record);
+
+		result.setData(Wo.copier.copy(record));
+
+		return result;
+	}
+
+	private Record record(WorkLog workLog) throws Exception {
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			final List<String> nextTaskIdentities = new ArrayList<>();
+			final Record record = new Record(workLog);
+			record.getProperties().setElapsed(
+					Config.workTime().betweenMinutes(record.getProperties().getStartTime(), record.getRecordTime()));
+			record.setType(Record.TYPE_SERVICE);
+			List<Task> list = emc.fetchEqualAndEqual(Task.class,
+					ListTools.toList(Task.person_FIELDNAME, Task.identity_FIELDNAME, Task.unit_FIELDNAME,
+							Task.job_FIELDNAME, Task.work_FIELDNAME, Task.activity_FIELDNAME,
+							Task.activityAlias_FIELDNAME, Task.activityName_FIELDNAME, Task.activityToken_FIELDNAME,
+							Task.activityType_FIELDNAME, Task.empowerFromIdentity_FIELDNAME),
+					Task.job_FIELDNAME, workLog.getJob(), Task.series_FIELDNAME, this.series);
+			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));
+			return record;
+		}
+	}
+
+	private void concreteRecord(Record record) throws Exception {
+		WoId resp = ThisApplication.context().applications()
+				.postQuery(x_processplatform_service_processing.class,
+						Applications.joinQueryUri("record", "job", this.work.getJob()), record, work.getJob())
+				.getData(WoId.class);
+		if (StringUtils.isBlank(resp.getId())) {
+			throw new ExceptionService(this.work.getId());
+		}
+	}
+
+	public static class Wo extends Record {
+		private static final long serialVersionUID = -1771383649634969945L;
+		static WrapCopier<Record, Wo> copier = WrapCopierFactory.wo(Record.class, Wo.class, null,
+				JpaObject.FieldsInvisible);
+	}
+
+}

+ 7 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/BaseAction.java

@@ -0,0 +1,7 @@
+package com.x.processplatform.assemble.surface.jaxrs.service;
+
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+
+abstract class BaseAction extends StandardJaxrsAction {
+
+}

+ 13 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ExceptionActivityNotService.java

@@ -0,0 +1,13 @@
+package com.x.processplatform.assemble.surface.jaxrs.service;
+
+import com.x.base.core.project.exception.PromptException;
+
+class ExceptionActivityNotService extends PromptException {
+
+	private static final long serialVersionUID = -7038279889683420366L;
+
+	ExceptionActivityNotService(String id) {
+		super("工作:{}, 未处于服务活动环节.", id);
+	}
+
+}

+ 12 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ExceptionService.java

@@ -0,0 +1,12 @@
+package com.x.processplatform.assemble.surface.jaxrs.service;
+
+import com.x.base.core.project.exception.PromptException;
+
+class ExceptionService extends PromptException {
+
+	private static final long serialVersionUID = 1040883405179987063L;
+
+	ExceptionService(String workId) {
+		super("服务执行失败,工作:{}.", workId);
+	}
+}

+ 12 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ExceptionWorkLogWithActivityTokenNotExist.java

@@ -0,0 +1,12 @@
+package com.x.processplatform.assemble.surface.jaxrs.service;
+
+import com.x.base.core.project.exception.PromptException;
+
+class ExceptionWorkLogWithActivityTokenNotExist extends PromptException {
+
+	private static final long serialVersionUID = -9089355008820123519L;
+
+	ExceptionWorkLogWithActivityTokenNotExist(String str) {
+		super("无法根据活动令牌获取工作日志:{}.", str);
+	}
+}

+ 50 - 0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/service/ServiceAction.java

@@ -0,0 +1,50 @@
+package com.x.processplatform.assemble.surface.jaxrs.service;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.AsyncResponse;
+import javax.ws.rs.container.Suspended;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import com.google.gson.JsonElement;
+import com.x.base.core.project.annotation.JaxrsDescribe;
+import com.x.base.core.project.annotation.JaxrsMethodDescribe;
+import com.x.base.core.project.annotation.JaxrsParameterDescribe;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.http.HttpMediaType;
+import com.x.base.core.project.jaxrs.ResponseFactory;
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+
+@Path("service")
+@JaxrsDescribe("服务活动")
+public class ServiceAction extends StandardJaxrsAction {
+
+	private static Logger logger = LoggerFactory.getLogger(ServiceAction.class);
+
+	@JaxrsMethodDescribe(value = "访问服务", action = ActionTouch.class)
+	@PUT
+	@Path("work/{id}/touch")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("工作标识") @PathParam("id") String id, JsonElement jsonElement) {
+		ActionResult<ActionTouch.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionTouch().execute(effectivePerson, id, jsonElement);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+}

+ 4 - 4
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/task/ActionProcessing.java

@@ -4,8 +4,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
-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;
@@ -44,6 +42,8 @@ import com.x.processplatform.core.express.service.processing.jaxrs.task.WrapProc
 import com.x.processplatform.core.express.service.processing.jaxrs.task.WrapUpdatePrevTaskIdentity;
 import com.x.processplatform.core.express.service.processing.jaxrs.taskcompleted.WrapUpdateNextTaskIdentity;
 
+import org.apache.commons.lang3.StringUtils;
+
 class ActionProcessing extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionProcessing.class);
@@ -261,7 +261,7 @@ class ActionProcessing extends BaseAction {
 		/* 记录上一处理人信息 */
 		if (ListTools.isNotEmpty(newTasks)) {
 			WrapUpdatePrevTaskIdentity req = new WrapUpdatePrevTaskIdentity();
-			req.setTaskList(ListTools.extractProperty(newTasks, Task.id_FIELDNAME, String.class, true, true));
+			req.setTaskList(ListTools.extractProperty(newTasks, JpaObject.id_FIELDNAME, String.class, true, true));
 			req.getPrevTaskIdentityList().add(task.getIdentity());
 			ThisApplication.context().applications()
 					.putQuery(effectivePerson.getDebugger(), x_processplatform_service_processing.class,
@@ -345,7 +345,7 @@ class ActionProcessing extends BaseAction {
 		private static final long serialVersionUID = 2702712453822143654L;
 
 		static WrapCopier<Task, WoTask> copier = WrapCopierFactory.wo(Task.class, WoTask.class,
-				ListTools.toList(Task.id_FIELDNAME, Task.activity_FIELDNAME, Task.activityName_FIELDNAME,
+				ListTools.toList(JpaObject.id_FIELDNAME, Task.activity_FIELDNAME, Task.activityName_FIELDNAME,
 						Task.person_FIELDNAME, Task.identity_FIELDNAME, Task.unit_FIELDNAME),
 				null);
 

+ 7 - 8
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/work/ActionCreate.java

@@ -6,13 +6,6 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
-import com.x.base.core.project.logger.Audit;
-import com.x.base.core.project.logger.Logger;
-import com.x.base.core.project.logger.LoggerFactory;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.ObjectUtils;
-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;
@@ -22,12 +15,14 @@ import com.x.base.core.project.x_processplatform_service_processing;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
-import com.x.base.core.project.exception.ExceptionAccessDenied;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.http.TokenType;
 import com.x.base.core.project.jaxrs.WoId;
+import com.x.base.core.project.logger.Audit;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.organization.Unit;
 import com.x.base.core.project.tools.DefaultCharset;
 import com.x.base.core.project.tools.ListTools;
@@ -44,6 +39,10 @@ import com.x.processplatform.core.entity.content.WorkLog;
 import com.x.processplatform.core.entity.element.Application;
 import com.x.processplatform.core.entity.element.Process;
 
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+
 class ActionCreate extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionCreate.class);

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

@@ -31,6 +31,11 @@ import com.x.processplatform.core.entity.element.Manual;
 import com.x.processplatform.core.entity.element.Process;
 import com.x.processplatform.core.express.ProcessingAttributes;
 
+/**
+ * @deprecated
+ * 
+ * 废弃,不再使用,改用V2Reroute
+ */
 class ActionReroute extends BaseAction {
 
 	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, String activityId, ActivityType activityType,

+ 2 - 1
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/schedule/CleanKeyLock.java

@@ -6,6 +6,7 @@ import java.util.List;
 
 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.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.base.core.project.schedule.AbstractJob;
@@ -26,7 +27,7 @@ public class CleanKeyLock extends AbstractJob {
 			Integer count = 0;
 			do {
 				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					targets = emc.listLessThan(KeyLock.class, KeyLock.createTime_FIELDNAME,
+					targets = emc.listLessThan(KeyLock.class, JpaObject.createTime_FIELDNAME,
 							DateUtils.addMinutes(new Date(), -2));
 					if (!targets.isEmpty()) {
 						emc.beginTransaction(KeyLock.class);

+ 3 - 0
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Record.java

@@ -80,6 +80,9 @@ public class Record extends SliceJpaObject {
 	/* 超时自动流转 */
 	public final static String TYPE_PASSEXPIRED = "passExpired";
 
+	/* 外部调用流转 */
+	public final static String TYPE_SERVICE = "service";
+
 	/* 定制意见 */
 	public final static String TYPE_CUSTOM = "custom";
 

+ 24 - 39
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/Work.java

@@ -138,7 +138,6 @@ public class Work extends SliceJpaObject implements ProjectionInterface {
 				: WORKCREATETYPE_SURFACE;
 	}
 
- 
 	/* 修改过的Set Get 方法 */
 
 	public static final String job_FIELDNAME = "job";
@@ -334,11 +333,11 @@ public class Work extends SliceJpaObject implements ProjectionInterface {
 	@CheckPersist(allowEmpty = false)
 	private WorkStatus workStatus;
 
-//	public static final String errorRetry_FIELDNAME = "errorRetry";
-//	@FieldDescribe("重试次数.")
-//	@Column(name = ColumnNamePrefix + errorRetry_FIELDNAME)
-//	@CheckPersist(allowEmpty = false)
-//	private Integer errorRetry;
+	// public static final String errorRetry_FIELDNAME = "errorRetry";
+	// @FieldDescribe("重试次数.")
+	// @Column(name = ColumnNamePrefix + errorRetry_FIELDNAME)
+	// @CheckPersist(allowEmpty = false)
+	// private Integer errorRetry;
 
 	public static final String beforeExecuted_FIELDNAME = "beforeExecuted";
 	@FieldDescribe("是否已经通过执行前")
@@ -396,13 +395,6 @@ public class Work extends SliceJpaObject implements ProjectionInterface {
 	@CheckPersist(allowEmpty = true)
 	private String splitValue;
 
-	public static final String serviceValue_FIELDNAME = "serviceValue";
-	@FieldDescribe("Service活动环节回写的值ID")
-	@Column(length = JpaObject.length_id, name = ColumnNamePrefix + serviceValue_FIELDNAME)
-	@Index(name = TABLE + IndexNameMiddle + serviceValue_FIELDNAME)
-	@CheckPersist(allowEmpty = true)
-	private String serviceValue;
-
 	public static final String form_FIELDNAME = "form";
 	@FieldDescribe("使用表单")
 	@Column(length = JpaObject.length_id, name = ColumnNamePrefix + form_FIELDNAME)
@@ -436,17 +428,18 @@ public class Work extends SliceJpaObject implements ProjectionInterface {
 	@CheckPersist(allowEmpty = true)
 	private String destinationActivity;
 
-//	public static final String forceRoute_FIELDNAME = "forceRoute";
-//	@FieldDescribe("强制路由,用于调度等需要跳过执行环节直接进行的.")
-//	@Column(name = ColumnNamePrefix + forceRoute_FIELDNAME)
-//	@CheckPersist(allowEmpty = true)
-//	private Boolean forceRoute;
-//
-//	public static final String forceRouteArriveCurrentActivity_FIELDNAME = "forceRouteArriveCurrentActivity";
-//	@FieldDescribe("是否是强制路由进入当前节点.")
-//	@Column(name = ColumnNamePrefix + forceRouteArriveCurrentActivity_FIELDNAME)
-//	@CheckPersist(allowEmpty = true)
-//	private Boolean forceRouteArriveCurrentActivity;
+	// public static final String forceRoute_FIELDNAME = "forceRoute";
+	// @FieldDescribe("强制路由,用于调度等需要跳过执行环节直接进行的.")
+	// @Column(name = ColumnNamePrefix + forceRoute_FIELDNAME)
+	// @CheckPersist(allowEmpty = true)
+	// private Boolean forceRoute;
+	//
+	// public static final String forceRouteArriveCurrentActivity_FIELDNAME =
+	// "forceRouteArriveCurrentActivity";
+	// @FieldDescribe("是否是强制路由进入当前节点.")
+	// @Column(name = ColumnNamePrefix + forceRouteArriveCurrentActivity_FIELDNAME)
+	// @CheckPersist(allowEmpty = true)
+	// private Boolean forceRouteArriveCurrentActivity;
 
 	public static final String expireTime_FIELDNAME = "expireTime";
 	@FieldDescribe("任务截止时间.")
@@ -841,13 +834,13 @@ public class Work extends SliceJpaObject implements ProjectionInterface {
 		this.form = form;
 	}
 
-//	public Integer getErrorRetry() {
-//		return errorRetry;
-//	}
-//
-//	public void setErrorRetry(Integer errorRetry) {
-//		this.errorRetry = errorRetry;
-//	}
+	// public Integer getErrorRetry() {
+	// return errorRetry;
+	// }
+	//
+	// public void setErrorRetry(Integer errorRetry) {
+	// this.errorRetry = errorRetry;
+	// }
 
 	public String getDestinationRoute() {
 		return destinationRoute;
@@ -933,14 +926,6 @@ public class Work extends SliceJpaObject implements ProjectionInterface {
 		this.applicationAlias = applicationAlias;
 	}
 
-	public String getServiceValue() {
-		return serviceValue;
-	}
-
-	public void setServiceValue(String serviceValue) {
-		this.serviceValue = serviceValue;
-	}
-
 	public Date getExpireTime() {
 		return expireTime;
 	}

+ 17 - 0
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/content/WorkProperties.java

@@ -12,6 +12,8 @@ public class WorkProperties extends JsonProperties {
 
 	private LinkedHashMap<String, String> manualEmpowerMap = new LinkedHashMap<>();
 
+	private LinkedHashMap<String, Object> serviceValue = new LinkedHashMap<>();
+
 	public List<String> getManualForceTaskIdentityList() {
 		if (this.manualForceTaskIdentityList == null) {
 			this.manualForceTaskIdentityList = new ArrayList<String>();
@@ -34,6 +36,21 @@ public class WorkProperties extends JsonProperties {
 		this.manualEmpowerMap = manualEmpowerMap;
 	}
 
+	public LinkedHashMap<String, Object> getServiceValue() {
+		if (this.serviceValue == null) {
+			this.serviceValue = new LinkedHashMap<String, Object>();
+		}
+		return this.serviceValue;
+	}
+
+	public void setServiceValue(LinkedHashMap<String, Object> serviceValue) {
+		this.serviceValue = serviceValue;
+	}
+
+
+
+	
+
 //	private String destinationRoute;
 //
 //	private String destinationRouteName;

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

@@ -16,7 +16,7 @@ public class ProcessingAttributes extends GsonPropertyObject {
 	public static final String TYPE_RESET = "reset";
 	public static final String TYPE_RETRACT = "retract";
 	public static final String TYPE_ROLLBACK = "rollback";
-	//public static final String TYPE_BEGIN = "begin";
+	public static final String TYPE_SERVICE = "service";
 	private Integer loop = 1;
 
 	@FieldDescribe("强制从arrive开始")

+ 2 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/ActionApplication.java

@@ -14,6 +14,7 @@ import com.x.processplatform.service.processing.jaxrs.read.ReadAction;
 import com.x.processplatform.service.processing.jaxrs.readcompleted.ReadCompletedAction;
 import com.x.processplatform.service.processing.jaxrs.record.RecordAction;
 import com.x.processplatform.service.processing.jaxrs.review.ReviewAction;
+import com.x.processplatform.service.processing.jaxrs.service.ServiceAction;
 import com.x.processplatform.service.processing.jaxrs.task.TaskAction;
 import com.x.processplatform.service.processing.jaxrs.taskcompleted.TaskCompletedAction;
 import com.x.processplatform.service.processing.jaxrs.test.TestAction;
@@ -38,6 +39,7 @@ public class ActionApplication extends AbstractActionApplication {
 		classes.add(DocumentVersionAction.class);
 		classes.add(TestAction.class);
 		classes.add(RecordAction.class);
+		classes.add(ServiceAction.class);
 		return classes;
 	}
 

+ 10 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/ServiceJaxrsFilter.java

@@ -0,0 +1,10 @@
+package com.x.processplatform.service.processing.jaxrs;
+
+import javax.servlet.annotation.WebFilter;
+
+import com.x.base.core.project.jaxrs.CipherManagerJaxrsFilter;
+
+@WebFilter(urlPatterns = "/jaxrs/service/*", asyncSupported = true)
+public class ServiceJaxrsFilter extends CipherManagerJaxrsFilter {
+
+}

+ 79 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ActionTouch.java

@@ -0,0 +1,79 @@
+package com.x.processplatform.service.processing.jaxrs.service;
+
+import java.lang.reflect.Type;
+import java.util.LinkedHashMap;
+import java.util.Objects;
+import java.util.concurrent.Callable;
+
+import com.google.gson.JsonElement;
+import com.google.gson.reflect.TypeToken;
+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.gson.XGsonBuilder;
+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.tools.ListTools;
+import com.x.processplatform.core.entity.content.Work;
+import com.x.processplatform.core.entity.element.ActivityType;
+
+class ActionTouch extends BaseAction{
+
+	private static Logger logger = LoggerFactory.getLogger(ActionTouch.class);
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
+		String job = null;
+		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();
+		}
+		return ProcessPlatformExecutorFactory.get(job).submit(new CallableAction(id, jsonElement)).get();
+	}
+
+	public class CallableAction implements Callable<ActionResult<Wo>> {
+
+		private String id;
+
+		private JsonElement jsonElement;
+
+		public CallableAction(String id, JsonElement jsonElement) {
+			this.id = id;
+			this.jsonElement = jsonElement;
+		}
+
+		public ActionResult<Wo> call() throws Exception {
+			ActionResult<Wo> result = new ActionResult<>();
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Work work = emc.find(id, Work.class);
+				if (null == work) {
+					throw new ExceptionEntityNotExist(id, Work.class);
+				}
+				if (!Objects.equals(ActivityType.service, work.getActivityType())) {
+					throw new ExceptionActivityNotService(id);
+				}
+				emc.beginTransaction(Work.class);
+				Type type = new TypeToken<LinkedHashMap<String, Object>>() {
+				}.getType();
+				work.getProperties().setServiceValue(XGsonBuilder.instance().fromJson(jsonElement, type));
+				emc.check(work, CheckPersistType.all);
+				emc.commit();
+				Wo wo = new Wo();
+				wo.setValue(true);
+				result.setData(wo);
+				return result;
+			}
+		}
+	}
+
+	public static class Wo extends WrapBoolean {
+	}
+
+}

+ 7 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/BaseAction.java

@@ -0,0 +1,7 @@
+package com.x.processplatform.service.processing.jaxrs.service;
+
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+
+abstract class BaseAction extends StandardJaxrsAction {
+
+}

+ 13 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ExceptionActivityNotService.java

@@ -0,0 +1,13 @@
+package com.x.processplatform.service.processing.jaxrs.service;
+
+import com.x.base.core.project.exception.PromptException;
+
+class ExceptionActivityNotService extends PromptException {
+
+	private static final long serialVersionUID = -7038279889683420366L;
+
+	ExceptionActivityNotService(String id) {
+		super("工作:{}, 未处于服务活动环节.", id);
+	}
+
+}

+ 12 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ExceptionService.java

@@ -0,0 +1,12 @@
+package com.x.processplatform.service.processing.jaxrs.service;
+
+import com.x.base.core.project.exception.PromptException;
+
+class ExceptionService extends PromptException {
+
+	private static final long serialVersionUID = 1040883405179987063L;
+
+	ExceptionService(String workId) {
+		super("服务执行失败,工作:{}.", workId);
+	}
+}

+ 12 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ExceptionWorkLogWithActivityTokenNotExist.java

@@ -0,0 +1,12 @@
+package com.x.processplatform.service.processing.jaxrs.service;
+
+import com.x.base.core.project.exception.PromptException;
+
+class ExceptionWorkLogWithActivityTokenNotExist extends PromptException {
+
+	private static final long serialVersionUID = -9089355008820123519L;
+
+	ExceptionWorkLogWithActivityTokenNotExist(String str) {
+		super("无法根据活动令牌获取工作日志:{}.", str);
+	}
+}

+ 50 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/service/ServiceAction.java

@@ -0,0 +1,50 @@
+package com.x.processplatform.service.processing.jaxrs.service;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.AsyncResponse;
+import javax.ws.rs.container.Suspended;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import com.google.gson.JsonElement;
+import com.x.base.core.project.annotation.JaxrsDescribe;
+import com.x.base.core.project.annotation.JaxrsMethodDescribe;
+import com.x.base.core.project.annotation.JaxrsParameterDescribe;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.http.HttpMediaType;
+import com.x.base.core.project.jaxrs.ResponseFactory;
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+
+@Path("service")
+@JaxrsDescribe("服务活动")
+public class ServiceAction extends StandardJaxrsAction {
+
+	private static Logger logger = LoggerFactory.getLogger(ServiceAction.class);
+
+	@JaxrsMethodDescribe(value = "访问服务", action = ActionTouch.class)
+	@PUT
+	@Path("work/{id}/touch")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("工作标识") @PathParam("id") String id, JsonElement jsonElement) {
+		ActionResult<ActionTouch.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionTouch().execute(effectivePerson, id, jsonElement);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+}

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

@@ -0,0 +1,49 @@
+package com.x.processplatform.service.processing.jaxrs.work;
+
+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.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.processplatform.core.entity.content.Work;
+import com.x.processplatform.core.express.ProcessingAttributes;
+import com.x.processplatform.service.processing.Processing;
+
+class ActionProcessingNonblocking extends BaseAction {
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
+
+		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
+
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+
+			wi.setDebugger(effectivePerson.getDebugger());
+
+			Work work = emc.find(id, Work.class);
+
+			if (null == work) {
+				throw new ExceptionEntityNotExist(id, Work.class);
+			}
+
+		}
+
+		Processing processing = new Processing(wi);
+		processing.processing(id);
+		ActionResult<Wo> result = new ActionResult<>();
+		Wo wo = new Wo();
+		wo.setId(id);
+		result.setData(wo);
+		return result;
+
+	}
+
+	public static class Wi extends ProcessingAttributes {
+
+	}
+
+	public static class Wo extends WoId {
+	}
+
+}

+ 4 - 4
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/V2Reroute.java

@@ -4,11 +4,10 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Callable;
 
-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.entity.annotation.CheckPersistType;
 import com.x.base.core.entity.annotation.CheckRemoveType;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
@@ -26,7 +25,8 @@ import com.x.processplatform.core.entity.element.Activity;
 import com.x.processplatform.core.express.service.processing.jaxrs.work.V2RerouteWi;
 import com.x.processplatform.service.processing.Business;
 import com.x.processplatform.service.processing.MessageFactory;
-import com.x.processplatform.service.processing.jaxrs.work.V2Retract.Wo;
+
+import org.apache.commons.lang3.StringUtils;
 
 class V2Reroute extends BaseAction {
 
@@ -120,7 +120,7 @@ class V2Reroute extends BaseAction {
 
 	private void removeOtherWork(Business business, Work work) throws Exception {
 		List<Work> os = business.entityManagerContainer().listEqualAndNotEqual(Work.class, Work.job_FIELDNAME,
-				work.getJob(), Work.id_FIELDNAME, work.getId());
+				work.getJob(), JpaObject.id_FIELDNAME, work.getId());
 		os.stream().forEach(o -> {
 			try {
 				business.entityManagerContainer().remove(o, CheckRemoveType.all);

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

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

+ 21 - 27
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/processor/service/ServiceProcessor.java

@@ -1,13 +1,12 @@
 package com.x.processplatform.service.processing.processor.service;
 
 import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.List;
 
 import javax.script.CompiledScript;
 import javax.script.ScriptContext;
 
-import org.apache.commons.lang3.StringUtils;
-
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
@@ -15,10 +14,11 @@ import com.x.base.core.project.script.ScriptFactory;
 import com.x.processplatform.core.entity.content.Work;
 import com.x.processplatform.core.entity.element.Route;
 import com.x.processplatform.core.entity.element.Service;
-import com.x.processplatform.core.entity.temporary.ServiceValue;
 import com.x.processplatform.service.processing.Business;
 import com.x.processplatform.service.processing.processor.AeiObjects;
 
+import org.apache.commons.lang3.StringUtils;
+
 public class ServiceProcessor extends AbstractServiceProcessor {
 
 	private static Logger logger = LoggerFactory.getLogger(ServiceProcessor.class);
@@ -30,47 +30,40 @@ public class ServiceProcessor extends AbstractServiceProcessor {
 	@Override
 	protected Work arriving(AeiObjects aeiObjects, Service service) throws Exception {
 		/** 清空上一次调用值 */
-		aeiObjects.getWork().setServiceValue("");
+		aeiObjects.getWork().getProperties().setServiceValue(new LinkedHashMap<String, Object>());
 		return aeiObjects.getWork();
 	}
 
 	@Override
 	protected void arrivingCommitted(AeiObjects aeiObjects, Service service) throws Exception {
+	 // Do nothing
 	}
 
 	@Override
 	protected List<Work> executing(AeiObjects aeiObjects, Service service) throws Exception {
 		List<Work> results = new ArrayList<>();
-		if (StringUtils.isNotEmpty(aeiObjects.getWork().getServiceValue())) {
-			boolean passThrough = false;
-			if (StringUtils.isNotEmpty(service.getScript()) || StringUtils.isNotEmpty(service.getScriptText())) {
-				ServiceValue serviceValue = this.entityManagerContainer().find(aeiObjects.getWork().getServiceValue(),
-						ServiceValue.class);
-				if (null != serviceValue) {
 
-					ScriptContext scriptContext = aeiObjects.scriptContext();
-					scriptContext.getBindings(ScriptContext.ENGINE_SCOPE).put(ScriptFactory.BINDING_NAME_SERVICEVALUE,
-							serviceValue);
-					CompiledScript cs = aeiObjects.business().element().getCompiledScript(
-							aeiObjects.getWork().getApplication(), aeiObjects.getActivity(), Business.EVENT_SERVICE);
-					passThrough = ScriptFactory.asBoolean(cs.eval(scriptContext));
-//					ScriptHelper scriptHelper = ScriptHelperFactory.create(aeiObjects,
-//							new BindingPair("serviceValue", serviceValue));
-//					passThrough = scriptHelper.evalAsBoolean(aeiObjects.getWork().getApplication(),
-//							service.getScript(), service.getScriptText());
-				}
-			} else {
-				passThrough = true;
-			}
-			if (passThrough) {
-				results.add(aeiObjects.getWork());
-			}
+		boolean passThrough = false;
+		if (StringUtils.isNotEmpty(service.getScript()) || StringUtils.isNotEmpty(service.getScriptText())) {
+			ScriptContext scriptContext = aeiObjects.scriptContext();
+			scriptContext.getBindings(ScriptContext.ENGINE_SCOPE).put(ScriptFactory.BINDING_NAME_SERVICEVALUE,
+					gson.toJson(aeiObjects.getWork().getProperties().getServiceValue()));
+			CompiledScript cs = aeiObjects.business().element().getCompiledScript(aeiObjects.getWork().getApplication(),
+					aeiObjects.getActivity(), Business.EVENT_SERVICE);
+			passThrough = ScriptFactory.asBoolean(cs.eval(scriptContext));
+		} else {
+			passThrough = true;
+		}
+		if (passThrough) {
+			results.add(aeiObjects.getWork());
 		}
+
 		return results;
 	}
 
 	@Override
 	protected void executingCommitted(AeiObjects aeiObjects, Service service) throws Exception {
+	// Do nothing
 	}
 
 	@Override
@@ -82,5 +75,6 @@ public class ServiceProcessor extends AbstractServiceProcessor {
 
 	@Override
 	protected void inquiringCommitted(AeiObjects aeiObjects, Service service) throws Exception {
+	// Do nothing
 	}
 }