Jelajahi Sumber

Merge branch 'develop' of https://git.o2oa.net/o2oa/o2oa into develop

Zhou Rui 5 tahun lalu
induk
melakukan
2a3a099105

+ 0 - 1
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/factory/PersonFactory.java

@@ -120,7 +120,6 @@ public class PersonFactory extends AbstractFactory {
 		p = cb.or(p, cb.equal(root.get(Person_.open4Id), credential));
 		p = cb.or(p, cb.equal(root.get(Person_.open5Id), credential));
 		cq.select(root.get(Person_.id));
-		Query query = em.createQuery(cq.where(p));
 		List<String> list = em.createQuery(cq.where(p).distinct(true)).getResultList();
 		if (list.size() == 1) {
 			return list.get(0);

+ 58 - 75
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/work/ActionAssignCreate.java

@@ -3,7 +3,6 @@ package com.x.processplatform.service.processing.jaxrs.work;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.concurrent.Callable;
 
 import javax.persistence.EntityManager;
 import javax.persistence.criteria.CriteriaBuilder;
@@ -11,9 +10,6 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.StringUtils;
-
 import com.google.gson.JsonElement;
 import com.x.base.core.container.EntityManagerContainer;
 import com.x.base.core.container.factory.EntityManagerContainerFactory;
@@ -27,7 +23,6 @@ import com.x.base.core.project.bean.WrapCopier;
 import com.x.base.core.project.bean.WrapCopierFactory;
 import com.x.base.core.project.config.StorageMapping;
 import com.x.base.core.project.exception.ExceptionEntityNotExist;
-import com.x.base.core.project.executor.ProcessPlatformExecutorFactory;
 import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
@@ -51,11 +46,15 @@ import com.x.processplatform.service.processing.MessageFactory;
 import com.x.processplatform.service.processing.ThisApplication;
 import com.x.processplatform.service.processing.WorkDataHelper;
 
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+
 /**
  * 创建处于start状态的work
  * 
  * @author Rui
  *
+ * 此方法不需要推入线程池运行
  */
 class ActionAssignCreate extends BaseAction {
 
@@ -67,86 +66,70 @@ class ActionAssignCreate extends BaseAction {
 		Wo wo = new Wo();
 		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
 		Boolean processing = wi.getProcessing();
-		CallWrapObject callWrapObject = new CallWrapObject();
-
-		Callable<String> callable = new Callable<String>() {
-			public String call() throws Exception {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					Business business = new Business(emc);
-					List<String> applicationIds = listApplication(business, wi.getApplication());
-					if (ListTools.isEmpty(applicationIds)) {
-						throw new ExceptionEntityNotExist(wi.getApplication(), Application.class);
-					}
-					Process process = getProcess(business, applicationIds, wi.getProcess());
-					Application application = business.element().get(process.getApplication(), Application.class);
-					Begin begin = business.element().getBeginWithProcess(process.getId());
-					Work work = create(application, process, begin);
-					callWrapObject.job = work.getJob();
-					callWrapObject.id = work.getId();
-					String identityDn = business.organization().identity().get(wi.getIdentity());
-					if (StringUtils.isEmpty(identityDn)) {
-						throw new ExceptionIdentityNotExist(wi.getIdentity());
-					}
-					work.setTitle(wi.getTitle());
-					work.setCreatorIdentity(identityDn);
-					work.setCreatorPerson(business.organization().person().getWithIdentity(identityDn));
-					work.setCreatorUnit(business.organization().unit().getWithIdentity(identityDn));
-					/* 通过赋值调用的是不能被作为草稿删除的 */
-					work.setDataChanged(true);
-					if (ListTools.isNotEmpty(wi.getAttachmentList())) {
-						emc.beginTransaction(Attachment.class);
-						/** 这个attachmentList要手动初始化 */
-						// work.setAttachmentList(new ArrayList<String>());
-						for (WiAttachment o : wi.getAttachmentList()) {
-							StorageMapping fromMapping = ThisApplication.context().storageMappings()
-									.get(Attachment.class, o.getStorage());
-							if (null == fromMapping) {
-								throw new ExceptionFromMappingNotExist(o.getStorage());
-							}
-							StorageMapping toMapping = ThisApplication.context().storageMappings()
-									.random(Attachment.class);
-							if (null == toMapping) {
-								throw new ExceptionToMappingNotExist(Attachment.class);
-							}
-							Attachment attachment = new Attachment(work, effectivePerson.getDistinguishedName(),
-									o.getSite());
-							attachment.setActivity(begin.getId());
-							attachment.setActivityName(begin.getName());
-							attachment.setActivityType(ActivityType.begin);
-							attachment.setActivityToken(work.getActivityToken());
-							attachment.saveContent(toMapping, o.readContent(fromMapping), o.getName());
-							emc.persist(attachment, CheckPersistType.all);
-						}
+
+		Work work = null;
+
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			List<String> applicationIds = listApplication(business, wi.getApplication());
+			if (ListTools.isEmpty(applicationIds)) {
+				throw new ExceptionEntityNotExist(wi.getApplication(), Application.class);
+			}
+			Process process = getProcess(business, applicationIds, wi.getProcess());
+			Application application = business.element().get(process.getApplication(), Application.class);
+			Begin begin = business.element().getBeginWithProcess(process.getId());
+			work = create(application, process, begin);
+			String identityDn = business.organization().identity().get(wi.getIdentity());
+			if (StringUtils.isEmpty(identityDn)) {
+				throw new ExceptionIdentityNotExist(wi.getIdentity());
+			}
+			work.setTitle(wi.getTitle());
+			work.setCreatorIdentity(identityDn);
+			work.setCreatorPerson(business.organization().person().getWithIdentity(identityDn));
+			work.setCreatorUnit(business.organization().unit().getWithIdentity(identityDn));
+			/* 通过赋值调用的是不能被作为草稿删除的 */
+			work.setDataChanged(true);
+			if (ListTools.isNotEmpty(wi.getAttachmentList())) {
+				emc.beginTransaction(Attachment.class);
+				/** 这个attachmentList要手动初始化 */
+				// work.setAttachmentList(new ArrayList<String>());
+				for (WiAttachment o : wi.getAttachmentList()) {
+					StorageMapping fromMapping = ThisApplication.context().storageMappings().get(Attachment.class,
+							o.getStorage());
+					if (null == fromMapping) {
+						throw new ExceptionFromMappingNotExist(o.getStorage());
 					}
-					emc.beginTransaction(Work.class);
-					emc.persist(work, CheckPersistType.all);
-					if (null != wi.getData()) {
-						WorkDataHelper workDataHelper = new WorkDataHelper(emc, work);
-						workDataHelper.update(wi.getData());
+					StorageMapping toMapping = ThisApplication.context().storageMappings().random(Attachment.class);
+					if (null == toMapping) {
+						throw new ExceptionToMappingNotExist(Attachment.class);
 					}
-					emc.commit();
-					MessageFactory.work_create(work);
+					Attachment attachment = new Attachment(work, effectivePerson.getDistinguishedName(), o.getSite());
+					attachment.setActivity(begin.getId());
+					attachment.setActivityName(begin.getName());
+					attachment.setActivityType(ActivityType.begin);
+					attachment.setActivityToken(work.getActivityToken());
+					attachment.saveContent(toMapping, o.readContent(fromMapping), o.getName());
+					emc.persist(attachment, CheckPersistType.all);
 				}
-				return "";
 			}
-		};
-
-		ProcessPlatformExecutorFactory.get(wi.getProcess()).submit(callable).get();
-
+			emc.beginTransaction(Work.class);
+			emc.persist(work, CheckPersistType.all);
+			if (null != wi.getData()) {
+				WorkDataHelper workDataHelper = new WorkDataHelper(emc, work);
+				workDataHelper.update(wi.getData());
+			}
+			emc.commit();
+		}
+		MessageFactory.work_create(work);
 		if (BooleanUtils.isTrue(processing)) {
 			ThisApplication.context().applications().putQuery(x_processplatform_service_processing.class,
-					Applications.joinQueryUri("work", callWrapObject.id, "processing"), null, callWrapObject.job);
+					Applications.joinQueryUri("work", work.getId(), "processing"), null, work.getJob());
 		}
-		wo.setId(callWrapObject.id);
+		wo.setId(work.getId());
 		result.setData(wo);
 		return result;
 	}
 
-	public static class CallWrapObject {
-		private String job;
-		private String id;
-	}
-
 	public static class Wi extends GsonPropertyObject {
 
 		@FieldDescribe("应用标识")
@@ -282,7 +265,7 @@ class ActionAssignCreate extends BaseAction {
 		work.setProcessAlias(process.getAlias());
 		work.setJob(StringTools.uniqueToken());
 		work.setStartTime(now);
-//		work.setErrorRetry(0);
+		// work.setErrorRetry(0);
 		work.setWorkStatus(WorkStatus.start);
 		work.setDestinationActivity(begin.getId());
 		work.setDestinationActivityType(ActivityType.begin);

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

@@ -1,13 +1,11 @@
 package com.x.processplatform.service.processing.jaxrs.work;
 
 import java.util.Date;
-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.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.WoId;
@@ -26,7 +24,8 @@ import com.x.processplatform.service.processing.WorkDataHelper;
  * 创建处于start状态的work
  * 
  * @author Rui
- *
+ * 
+ * 此方法不需要推入线程池运行
  */
 class ActionCreate extends BaseAction {
 
@@ -35,33 +34,24 @@ class ActionCreate extends BaseAction {
 
 		ActionResult<Wo> result = new ActionResult<>();
 		Wo wo = new Wo();
+		Work work = null;
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			Process process = business.element().get(processId, Process.class);
+			Application application = business.element().get(process.getApplication(), Application.class);
+			Begin begin = business.element().getBeginWithProcess(process.getId());
 
-		Callable<String> callable = new Callable<String>() {
-			public String call() throws Exception {
-				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-					Business business = new Business(emc);
-					Process process = business.element().get(processId, Process.class);
-					Application application = business.element().get(process.getApplication(), Application.class);
-					Begin begin = business.element().getBeginWithProcess(process.getId());
-
-					Work work = create(application, process, begin);
-					emc.beginTransaction(Work.class);
-					if ((null != jsonElement) && jsonElement.isJsonObject()) {
-						WorkDataHelper workDataHelper = new WorkDataHelper(emc, work);
-						workDataHelper.update(jsonElement);
-					}
-					emc.persist(work, CheckPersistType.all);
-					emc.commit();
-					wo.setId(work.getId());
-					MessageFactory.work_create(work);
-				}
-				return "";
+			work = create(application, process, begin);
+			emc.beginTransaction(Work.class);
+			if ((null != jsonElement) && jsonElement.isJsonObject()) {
+				WorkDataHelper workDataHelper = new WorkDataHelper(emc, work);
+				workDataHelper.update(jsonElement);
 			}
-		};
-
-		/* 根据流程应用id分派进程号. */
-		ProcessPlatformExecutorFactory.get(processId).submit(callable).get();
-
+			emc.persist(work, CheckPersistType.all);
+			emc.commit();
+			wo.setId(work.getId());
+		}
+		MessageFactory.work_create(work);
 		result.setData(wo);
 		return result;
 	}
@@ -85,7 +75,7 @@ class ActionCreate extends BaseAction {
 		work.setProcessAlias(process.getAlias());
 		work.setJob(StringTools.uniqueToken());
 		work.setStartTime(now);
-//		work.setErrorRetry(0);
+		// work.setErrorRetry(0);
 		work.setWorkStatus(WorkStatus.start);
 		work.setDestinationActivity(begin.getId());
 		work.setDestinationActivityType(ActivityType.begin);

+ 6 - 3
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/schedule/PassExpired.java

@@ -20,6 +20,7 @@ import com.x.base.core.container.factory.EntityManagerContainerFactory;
 import com.x.base.core.project.Applications;
 import com.x.base.core.project.x_processplatform_service_processing;
 import com.x.base.core.project.config.Config;
+import com.x.base.core.project.gson.XGsonBuilder;
 import com.x.base.core.project.jaxrs.WoId;
 import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.base.core.project.logger.Logger;
@@ -61,9 +62,7 @@ public class PassExpired extends AbstractJob {
 			Map<String, Route> manualToRoute = null;
 			AtomicInteger count = new AtomicInteger(0);
 			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
-				if (null == manualToRoute) {
 					manualToRoute = this.linkPassExpiredManualToRoute(emc);
-				}
 			}
 			if (!manualToRoute.isEmpty()) {
 				do {
@@ -74,7 +73,9 @@ public class PassExpired extends AbstractJob {
 						sequence = targets.get(targets.size() - 1).getSequence();
 						for (Task task : targets) {
 							try {
+								logger.print("执行超时工作默认路由流转:{}, id:{}.", task.getTitle(),task.getId());
 								this.execute(task);
+								count.incrementAndGet();
 							} catch (Exception e) {
 								logger.error(e);
 							}
@@ -286,12 +287,13 @@ public class PassExpired extends AbstractJob {
 		Path<String> id_path = root.get(Task_.id);
 		Path<String> job_path = root.get(Task_.job);
 		Path<String> sequence_path = root.get(Task_.sequence);
+		Path<String> work_path = root.get(Task_.work);
 		Predicate p = cb.equal(root.get(Task_.expired), true);
 		p = cb.and(p, root.get(Task_.activity).in(manualToRoute.keySet()));
 		if (StringUtils.isNotEmpty(sequence)) {
 			p = cb.and(p, cb.greaterThan(sequence_path, sequence));
 		}
-		cq.multiselect(id_path, job_path, sequence_path).where(p).orderBy(cb.asc(sequence_path));
+		cq.multiselect(id_path, job_path, sequence_path,work_path).where(p).orderBy(cb.asc(sequence_path));
 		List<Tuple> os = em.createQuery(cq).setMaxResults(200).getResultList();
 		List<Task> list = new ArrayList<>();
 		for (Tuple o : os) {
@@ -299,6 +301,7 @@ public class PassExpired extends AbstractJob {
 			task.setId(o.get(id_path));
 			task.setJob(o.get(job_path));
 			task.setSequence(o.get(sequence_path));
+			task.setWork(o.get(work_path));
 			list.add(task);
 		}
 		return list;

+ 7 - 7
o2web/source/x_component_Selector/Person.js

@@ -2211,12 +2211,12 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         }).inject(this.node, "after");
         if (!this.selector.options.expand) this.children.setStyle("display", "none");
 
-        // var subIdList = this.selector._getChildrenItemIds(this.data);
-        // if (subIdList){
-        //     var count = subIdList.length;
-        //     this.childrenHeight = count*this.selector.options.itemHeight;
-        //     this.children.setStyle("height", ""+this.childrenHeight+"px");
-        // }
+        var subIdList = this.selector._getChildrenItemIds(this.data);
+        if (subIdList){
+            var count = subIdList.length;
+            this.childrenHeight = count*this.selector.options.itemHeight;
+            this.children.setStyle("height", ""+this.childrenHeight+"px");
+        }
 
         if (!this._hasChild()){
             this.actionNode.setStyle("background", "transparent");
@@ -2346,7 +2346,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             }else if (display === "none"){
                 this.children.setStyles({
                     "display": "block",
-                    "height": this.childrenHeight+"px"
+                    "height": "auto"
                 });
                 this.node.setStyles( this.selector.css.flatCategoryItemNode_selected );
                 this.isExpand = true;

+ 2 - 2
o2web/source/x_component_Selector/Unit.js

@@ -555,13 +555,13 @@ MWF.xApplication.Selector.Unit.Item = new Class({
                 this.flatCategoryItemNode.setStyles(this.selector.css.flatCategoryItemNode);
                 this.isExpand = false;
             }else if( firstLoaded ){
-                this.children.setStyles({"display": "block"});
+                this.children.setStyles({ "display": "block", "height" : "auto" });
                 this.flatCategoryItemNode.setStyles( this.selector.css.flatCategoryItemNode_selected );
                 this.isExpand = true;
             }else {
                 var display = this.children.getStyle("display");
                 if (display === "none") {
-                    this.children.setStyles({ "display": "block" });
+                    this.children.setStyles({ "display": "block" , "height" : "auto"});
                     this.flatCategoryItemNode.setStyles(this.selector.css.flatCategoryItemNode_selected);
                     this.isExpand = true;
                 } else {