zhourui 5 anni fa
parent
commit
4848cda1e9

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

@@ -5,6 +5,7 @@ import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
 import java.util.zip.CRC32;
 
 import org.apache.commons.lang3.BooleanUtils;
@@ -163,6 +164,7 @@ class V2LookupWorkOrWorkCompleted extends BaseAction {
 			_relatedForm.get();
 			_relatedScript.get();
 			list.add(form.getId() + form.getUpdateTime().getTime());
+			list = list.stream().sorted().collect(Collectors.toList());
 			Wo wo = new Wo();
 			wo.setId(form.getId());
 			CRC32 crc = new CRC32();

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

@@ -5,6 +5,7 @@ import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
 import java.util.zip.CRC32;
 
 import org.apache.commons.lang3.BooleanUtils;
@@ -164,6 +165,7 @@ class V2LookupWorkOrWorkCompletedMobile extends BaseAction {
 			_relatedForm.get();
 			_relatedScript.get();
 			list.add(form.getId() + form.getUpdateTime().getTime());
+			list = list.stream().sorted().collect(Collectors.toList());
 			Wo wo = new Wo();
 			wo.setId(form.getId());
 			CRC32 crc = new CRC32();

+ 78 - 5
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/test/ActionTest5.java

@@ -1,18 +1,91 @@
 package com.x.processplatform.service.processing.jaxrs.test;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
 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.processplatform.service.processing.ThisApplication;
+import com.x.processplatform.core.entity.content.Work;
 
 class ActionTest5 extends BaseAction {
 
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
+	ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
 		ActionResult<Wo> result = new ActionResult<>();
 		Wo wo = new Wo();
-		System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-		System.out.println("Action5_id:" + id);
-		System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			for (int i = 0; i < 10000; i++) {
+				final String j = i + "";
+				CompletableFuture<List<String>> f1 = CompletableFuture.supplyAsync(() -> {
+					List<String> list = new ArrayList<>();
+					try {
+						for (Work work : emc.listNotEqual(Work.class, Work.activityToken_FIELDNAME, j)) {
+							list.add(work.getProcess());
+						}
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+					return list;
+				});
+
+				CompletableFuture<List<String>> f2 = CompletableFuture.supplyAsync(() -> {
+					List<String> list = new ArrayList<>();
+					try {
+						emc.beginTransaction(Work.class);
+						for (Work work : emc.listNotEqual(Work.class, Work.process_FIELDNAME, j)) {
+							list.add(work.getProcess());
+							work.setScratchString(j);
+						}
+						emc.commit();
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+					return list;
+				});
+
+				CompletableFuture<List<String>> f3 = CompletableFuture.supplyAsync(() -> {
+					List<String> list = new ArrayList<>();
+					try {
+						emc.beginTransaction(Work.class);
+						for (Work work : emc.listNotEqual(Work.class, Work.activity_FIELDNAME, j)) {
+							list.add(work.getProcess());
+							work.setScratchString(j);
+						}
+						emc.commit();
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+					return list;
+				});
+
+				CompletableFuture<List<String>> f4 = CompletableFuture.supplyAsync(() -> {
+					List<String> list = new ArrayList<>();
+					try {
+						for (Work work : emc.listNotEqual(Work.class, Work.id_FIELDNAME, j)) {
+							list.add(work.getProcess());
+						}
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+					return list;
+				});
+
+				List<String> list1 = f1.get();
+				List<String> list2 = f2.get();
+				List<String> list3 = f3.get();
+				List<String> list4 = f4.get();
+				System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+				System.out.println("loop:" + i + "list1:" + list1.size());
+				System.out.println("loop:" + i + "list2:" + list2.size());
+				System.out.println("loop:" + i + "list3:" + list3.size());
+				System.out.println("loop:" + i + "list4:" + list4.size());
+				System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+			}
+
+		}
 		result.setData(wo);
 		return result;
 	}

+ 0 - 23
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/test/ActionTest52.java

@@ -1,23 +0,0 @@
-package com.x.processplatform.service.processing.jaxrs.test;
-
-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.processplatform.service.processing.ThisApplication;
-
-class ActionTest52 extends BaseAction {
-
-	ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
-		ActionResult<Wo> result = new ActionResult<>();
-		Wo wo = new Wo();
-		System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-		System.out.println("Action52");
-		System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-		result.setData(wo);
-		return result;
-	}
-
-	public static class Wo extends WrapBoolean {
-
-	}
-}

+ 95 - 0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/test/ActionTest6.java

@@ -0,0 +1,95 @@
+package com.x.processplatform.service.processing.jaxrs.test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+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.processplatform.core.entity.content.Work;
+
+class ActionTest6 extends BaseAction {
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		Wo wo = new Wo();
+
+		for (int i = 0; i < 10000; i++) {
+			final String j = i + "";
+			CompletableFuture<List<String>> f1 = CompletableFuture.supplyAsync(() -> {
+				List<String> list = new ArrayList<>();
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					for (Work work : emc.listNotEqual(Work.class, Work.activityToken_FIELDNAME, j)) {
+						list.add(work.getProcess());
+					}
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+				return list;
+			});
+
+			CompletableFuture<List<String>> f2 = CompletableFuture.supplyAsync(() -> {
+				List<String> list = new ArrayList<>();
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					emc.beginTransaction(Work.class);
+					for (Work work : emc.listNotEqual(Work.class, Work.process_FIELDNAME, j)) {
+						list.add(work.getProcess());
+						work.setScratchString(j);
+					}
+					emc.commit();
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+				return list;
+			});
+
+			CompletableFuture<List<String>> f3 = CompletableFuture.supplyAsync(() -> {
+				List<String> list = new ArrayList<>();
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					emc.beginTransaction(Work.class);
+					for (Work work : emc.listNotEqual(Work.class, Work.activity_FIELDNAME, j)) {
+						list.add(work.getProcess());
+						work.setScratchString(j);
+					}
+					emc.commit();
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+				return list;
+			});
+
+			CompletableFuture<List<String>> f4 = CompletableFuture.supplyAsync(() -> {
+				List<String> list = new ArrayList<>();
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					for (Work work : emc.listNotEqual(Work.class, Work.id_FIELDNAME, j)) {
+						list.add(work.getProcess());
+					}
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+				return list;
+			});
+
+			List<String> list1 = f1.get();
+			List<String> list2 = f2.get();
+			List<String> list3 = f3.get();
+			List<String> list4 = f4.get();
+			System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+			System.out.println("loop:" + i + "list1:" + list1.size());
+			System.out.println("loop:" + i + "list2:" + list2.size());
+			System.out.println("loop:" + i + "list3:" + list3.size());
+			System.out.println("loop:" + i + "list4:" + list4.size());
+			System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+		}
+
+		result.setData(wo);
+		return result;
+	}
+
+	public static class Wo extends WrapBoolean {
+
+	}
+}

+ 10 - 12
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/test/TestAction.java

@@ -1,7 +1,5 @@
 package com.x.processplatform.service.processing.jaxrs.test;
 
-import java.util.Map;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
@@ -234,17 +232,16 @@ public class TestAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
-	@JaxrsMethodDescribe(value = "test1.", action = ActionTest1.class)
+	@JaxrsMethodDescribe(value = "test5.", action = ActionTest5.class)
 	@GET
-	@Path("test5/{id}")
+	@Path("test5")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void test5(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
-			@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+	public void test5(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
 		ActionResult<ActionTest5.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionTest5().execute(effectivePerson, id);
+			result = new ActionTest5().execute(effectivePerson);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
@@ -252,20 +249,21 @@ public class TestAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
-	@JaxrsMethodDescribe(value = "test1.", action = ActionTest52.class)
+	@JaxrsMethodDescribe(value = "test6.", action = ActionTest6.class)
 	@GET
-	@Path("test5/123")
+	@Path("test6")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void test5(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
-		ActionResult<ActionTest52.Wo> result = new ActionResult<>();
+	public void test6(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
+		ActionResult<ActionTest6.Wo> result = new ActionResult<>();
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		try {
-			result = new ActionTest52().execute(effectivePerson);
+			result = new ActionTest6().execute(effectivePerson);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);
 		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
+
 }