فهرست منبع

1、增加版本描述字段;2、增加列示未启用版本流程接口

o2sword 5 سال پیش
والد
کامیت
d7615c329c

+ 22 - 4
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/element/factory/ProcessFactory.java

@@ -5,10 +5,7 @@ import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManager;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
+import javax.persistence.criteria.*;
 
 
 import com.x.processplatform.assemble.designer.AbstractFactory;
 import com.x.processplatform.assemble.designer.AbstractFactory;
 import com.x.processplatform.assemble.designer.Business;
 import com.x.processplatform.assemble.designer.Business;
@@ -69,6 +66,27 @@ public class ProcessFactory extends AbstractFactory {
 		return em.createQuery(cq).getResultList();
 		return em.createQuery(cq).getResultList();
 	}
 	}
 
 
+	public List<String> listProcessDisableEdition(String application) throws Exception {
+		EntityManager em = this.entityManagerContainer().get(Process.class);
+		CriteriaBuilder cb = em.getCriteriaBuilder();
+		CriteriaQuery<String> cq = cb.createQuery(String.class);
+		Root<Process> root = cq.from(Process.class);
+		Predicate p = cb.equal(root.get(Process_.application), application);
+		p = cb.and(p, cb.isNotNull(root.get(Process_.edition)));
+		p = cb.and(p, cb.notEqual(root.get(Process_.edition), ""));
+
+		Subquery<Process> subquery = cq.subquery(Process.class);
+		Root<Process> subRoot = subquery.from(Process.class);
+		Predicate subP = cb.conjunction();
+		subP = cb.and(subP, cb.equal(root.get(Process_.edition), subRoot.get(Process_.edition)));
+		subP = cb.and(subP, cb.isTrue(subRoot.get(Process_.editionEnable)));
+		subquery.select(subRoot).where(subP);
+		p = cb.and(p, cb.not(cb.exists(subquery)));
+
+		cq.distinct(true).select(root.get(Process_.edition)).where(p);
+		return em.createQuery(cq).getResultList();
+	}
+
 	public Process getEnabledProcess(String application, String edition) throws Exception {
 	public Process getEnabledProcess(String application, String edition) throws Exception {
 		EntityManager em = this.entityManagerContainer().get(Process.class);
 		EntityManager em = this.entityManagerContainer().get(Process.class);
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaBuilder cb = em.getCriteriaBuilder();

+ 73 - 0
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/process/ActionDisable.java

@@ -0,0 +1,73 @@
+package com.x.processplatform.assemble.designer.jaxrs.process;
+
+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.assemble.designer.Business;
+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.StringUtils;
+
+import java.util.Date;
+
+class ActionDisable extends BaseAction {
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			Process process = emc.find(id, Process.class);
+			if (null == process) {
+				throw new ExceptionProcessNotExisted(id);
+			}
+			Application application = emc.find(process.getApplication(), Application.class);
+			if (null == application) {
+				throw new ExceptionApplicationNotExist(process.getApplication());
+			}
+			if (!business.editable(effectivePerson, application)) {
+				throw new ExceptionApplicationAccessDenied(effectivePerson.getDistinguishedName(),
+						application.getName(), application.getId());
+			}
+			emc.beginTransaction(Process.class);
+			if(StringUtils.isEmpty(process.getEdition())){
+				process.setLastUpdateTime(new Date());
+				process.setEdition(process.getId());
+				process.setEditionEnable(false);
+				process.setEditionNumber(1.0);
+				process.setEditionName(process.getName() + "_V" + process.getEditionNumber());
+				this.updateCreatePersonLastUpdatePerson(effectivePerson, business, process);
+			}else{
+				if(BooleanUtils.isTrue(process.getEditionEnable())){
+					process.setLastUpdateTime(new Date());
+					process.setEditionEnable(false);
+					this.updateCreatePersonLastUpdatePerson(effectivePerson, business, process);
+				}
+			}
+			emc.commit();
+			cacheNotify();
+			Wo wo = new Wo();
+			wo.setValue(true);
+			result.setData(wo);
+			return result;
+		}
+	}
+
+	public static class Wo extends WrapBoolean {
+
+	}
+
+	private void updateCreatePersonLastUpdatePerson(EffectivePerson effectivePerson, Business business, Process process)
+			throws Exception {
+		process.setLastUpdatePerson(effectivePerson.getDistinguishedName());
+		String name = business.organization().person().get(process.getCreatorPerson());
+		if (StringUtils.isEmpty(name)) {
+			process.setCreatorPerson(effectivePerson.getDistinguishedName());
+		} else {
+			process.setCreatorPerson(name);
+		}
+	}
+
+}

+ 52 - 0
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/process/ActionListDisableEdition.java

@@ -0,0 +1,52 @@
+package com.x.processplatform.assemble.designer.jaxrs.process;
+
+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.bean.WrapCopier;
+import com.x.base.core.project.bean.WrapCopierFactory;
+import com.x.base.core.project.exception.ExceptionWhen;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.processplatform.assemble.designer.Business;
+import com.x.processplatform.core.entity.element.Application;
+import com.x.processplatform.core.entity.element.Process;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class ActionListDisableEdition extends BaseAction {
+
+	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String applicationId) throws Exception {
+		ActionResult<List<Wo>> result = new ActionResult<>();
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			Application application = emc.find(applicationId, Application.class, ExceptionWhen.not_found);
+			if (null == application) {
+				throw new ExceptionApplicationNotExist(applicationId);
+			}
+			if (!business.editable(effectivePerson, application)) {
+				throw new ExceptionApplicationAccessDenied(effectivePerson.getDistinguishedName(),
+						application.getName(), application.getId());
+			}
+			List<Process> listProcess = new ArrayList<>();
+			List<String> editions = business.process().listProcessDisableEdition(applicationId);
+			for(String edition : editions){
+				listProcess.add(business.process().listProcessEditionObject(applicationId, edition).get(0));
+			}
+			List<Wo> wos = Wo.copier.copy(listProcess);
+			wos = business.process().sort(wos);
+			result.setData(wos);
+			return result;
+		}
+	}
+
+	public static class Wo extends Process {
+
+		private static final long serialVersionUID = 1439909268641168987L;
+
+		static WrapCopier<Process, Wo> copier = WrapCopierFactory.wo(Process.class, Wo.class, null,
+				JpaObject.FieldsInvisible);
+	}
+
+}

+ 36 - 0
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/process/ProcessAction.java

@@ -269,4 +269,40 @@ public class ProcessAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 	}
 
 
+	@JaxrsMethodDescribe(value = "列示未启用的流程版本.", action = ActionListDisableEdition.class)
+	@GET
+	@Path("application/{applicationId}/disable/edition")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void listDisableEdition(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+							@JaxrsParameterDescribe("应用标识") @PathParam("applicationId") String applicationId) {
+		ActionResult<List<ActionListDisableEdition.Wo>> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionListDisableEdition().execute(effectivePerson, applicationId);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+	@JaxrsMethodDescribe(value = "停用当前版本流程.", action = ActionDisable.class)
+	@GET
+	@Path("{id}/disable")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void disableProcess(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+							  @JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+		ActionResult<ActionDisable.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionDisable().execute(effectivePerson, id);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
 }
 }

+ 13 - 0
o2server/x_processplatform_core_entity/src/main/java/com/x/processplatform/core/entity/element/Process.java

@@ -490,6 +490,12 @@ public class Process extends SliceJpaObject {
 	@Column(name = ColumnNamePrefix + editionNumber_FIELDNAME)
 	@Column(name = ColumnNamePrefix + editionNumber_FIELDNAME)
 	private Double editionNumber;
 	private Double editionNumber;
 
 
+	public static final String editionDes_FIELDNAME = "editionDes";
+	@FieldDescribe("版本描述.")
+	@Column(length = length_255B, name = ColumnNamePrefix + editionDes_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private String editionDes;
+
 	/* flag标志位 */
 	/* flag标志位 */
 
 
 	public String getName() {
 	public String getName() {
@@ -820,4 +826,11 @@ public class Process extends SliceJpaObject {
 		this.editionNumber = editionNumber;
 		this.editionNumber = editionNumber;
 	}
 	}
 
 
+	public String getEditionDes() {
+		return editionDes;
+	}
+
+	public void setEditionDes(String editionDes) {
+		this.editionDes = editionDes;
+	}
 }
 }