Parcourir la source

Merge branch 'feature/cms表单优化' into 'wrdp'

[内容管理]表单优化

See merge request o2oa/o2oa!2914
o2null il y a 5 ans
Parent
commit
73199b3ae0
19 fichiers modifiés avec 1401 ajouts et 78 suppressions
  1. 4 0
      o2server/x_cms_assemble_control/pom.xml
  2. 35 15
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/Business.java
  3. 40 30
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/CategoryInfoFactory.java
  4. 10 1
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/FormFactory.java
  5. 15 5
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/ScriptFactory.java
  6. 21 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/portal/PortalFactory.java
  7. 17 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/portal/ScriptFactory.java
  8. 21 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/process/ProcessFactory.java
  9. 17 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/process/ScriptFactory.java
  10. 56 1
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/ActionSave.java
  11. 228 4
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/BaseAction.java
  12. 93 19
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/FormAction.java
  13. 76 2
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/FormAnonymousAction.java
  14. 134 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/V2Get.java
  15. 134 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/V2GetMobile.java
  16. 192 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/V2LookupDoc.java
  17. 194 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/V2LookupDocMobile.java
  18. 57 1
      o2server/x_cms_core_entity/src/main/java/com/x/cms/core/entity/element/Form.java
  19. 57 0
      o2server/x_cms_core_entity/src/main/java/com/x/cms/core/entity/element/FormProperties.java

+ 4 - 0
o2server/x_cms_assemble_control/pom.xml

@@ -44,6 +44,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_processplatform_core_entity</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_portal_core_entity</artifactId>
+		</dependency>
 		<dependency>
 			<groupId>o2oa</groupId>
 			<artifactId>x_general_core_entity</artifactId>

+ 35 - 15
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/Business.java

@@ -6,6 +6,8 @@ import com.x.base.core.project.organization.OrganizationDefinition;
 import com.x.base.core.project.tools.ListTools;
 import com.x.cms.assemble.control.factory.*;
 import com.x.cms.assemble.control.factory.element.QueryViewFactory;
+import com.x.cms.assemble.control.factory.portal.PortalFactory;
+import com.x.cms.assemble.control.factory.process.ProcessFactory;
 import com.x.cms.core.entity.AppInfo;
 import com.x.organization.core.express.Organization;
 import org.apache.commons.lang3.StringUtils;
@@ -66,63 +68,63 @@ public class Business {
 		}
 		return documentCommentCommendFactory;
 	}
-	
+
 	public ReviewFactory reviewFactory() throws Exception {
 		if (null == this.reviewFactory) {
 			this.reviewFactory = new ReviewFactory(this);
 		}
 		return reviewFactory;
 	}
-	
+
 	public CmsBatchOperationFactory cmsBatchOperationFactory() throws Exception {
 		if (null == this.cmsBatchOperationFactory) {
 			this.cmsBatchOperationFactory = new CmsBatchOperationFactory(this);
 		}
 		return cmsBatchOperationFactory;
 	}
-	
+
 	public DocumentCommentInfoFactory documentCommentInfoFactory() throws Exception {
 		if (null == this.documentCommentInfoFactory) {
 			this.documentCommentInfoFactory = new DocumentCommentInfoFactory(this);
 		}
 		return documentCommentInfoFactory;
 	}
-	
+
 	public DocumentCommendFactory documentCommendFactory() throws Exception {
 		if (null == this.documentCommendFactory) {
 			this.documentCommendFactory = new DocumentCommendFactory(this);
 		}
 		return documentCommendFactory;
 	}
-	
+
 	public FileFactory fileFactory() throws Exception {
 		if (null == this.fileFactory) {
 			this.fileFactory = new FileFactory(this);
 		}
 		return fileFactory;
 	}
-	
+
 	public FormFieldFactory formFieldFactory() throws Exception {
 		if (null == this.formFieldFactory) {
 			this.formFieldFactory = new FormFieldFactory(this);
 		}
 		return formFieldFactory;
 	}
-	
+
 	public ItemFactory itemFactory() throws Exception {
 		if (null == this.itemFactory) {
 			this.itemFactory = new ItemFactory(this);
 		}
 		return itemFactory;
 	}
-	
+
 	public CategoryExtFactory categoryExtFactory() throws Exception {
 		if (null == this.categoryExtFactory) {
 			this.categoryExtFactory = new CategoryExtFactory(this);
 		}
 		return categoryExtFactory;
 	}
-	
+
 	public Organization organization() throws Exception {
 		if (null == this.organization) {
 			this.organization = new Organization(ThisApplication.context());
@@ -144,7 +146,7 @@ public class Business {
 		return documentViewRecordFactory;
 	}
 
-	
+
 
 	public QueryViewFactory queryViewFactory() throws Exception {
 		if (null == this.queryViewFactory) {
@@ -236,7 +238,7 @@ public class Business {
 		}
 		return fileInfoFactory;
 	}
-	
+
 	public LogFactory getLogFactory() throws Exception {
 		if (null == this.logFactory) {
 			this.logFactory = new LogFactory(this);
@@ -244,6 +246,24 @@ public class Business {
 		return logFactory;
 	}
 
+	private ProcessFactory process;
+
+	public ProcessFactory process() throws Exception {
+		if (null == this.process) {
+			this.process = new ProcessFactory(this);
+		}
+		return process;
+	}
+
+	private PortalFactory portal;
+
+	public PortalFactory portal() throws Exception {
+		if (null == this.portal) {
+			this.portal = new PortalFactory(this);
+		}
+		return portal;
+	}
+
 	public boolean isHasPlatformRole( String personName, String roleName) throws Exception {
 		if ( StringUtils.isEmpty( personName ) ) {
 			throw new Exception("personName is null!");
@@ -262,7 +282,7 @@ public class Business {
 		}
 		return false;
 	}
-	
+
 	/**
 	 * 判断用户是否管理员权限
 	 * 1、person.isManager()
@@ -339,7 +359,7 @@ public class Business {
 						OrganizationDefinition.CMSManager)) {
 			return true;
 		}
-		
+
 		//判断effectivePerson是不是该栏目的管理者:涉及 个人,组织和群组
 		List<String> unitNameList= this.organization().unit().listWithPersonSupNested( effectivePerson.getDistinguishedName() );
 		List<String> groupNameList = new ArrayList<String>();
@@ -353,14 +373,14 @@ public class Business {
 				return true;
 			}
 		}
-		
+
 		if( ListTools.isNotEmpty( appInfo.getManageableGroupList() ) && ListTools.isNotEmpty( groupNameList )) {
 			groupNameList.retainAll( appInfo.getManageableGroupList()  );
 			if( ListTools.isNotEmpty( groupNameList )) {
 				return true;
 			}
 		}
-		
+
 		if( ListTools.isNotEmpty( appInfo.getManageableUnitList() )&& ListTools.isNotEmpty( unitNameList )) {
 			unitNameList.retainAll( appInfo.getManageableUnitList()  );
 			if( ListTools.isNotEmpty( unitNameList )) {

+ 40 - 30
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/CategoryInfoFactory.java

@@ -1,5 +1,6 @@
 package com.x.cms.assemble.control.factory;
 
+import com.x.base.core.project.exception.ExceptionWhen;
 import com.x.base.core.project.tools.ListTools;
 import com.x.cms.assemble.control.AbstractFactory;
 import com.x.cms.assemble.control.Business;
@@ -18,20 +19,29 @@ import java.util.List;
 
 /**
  * 分类信息基础功能服务类
- * 
+ *
  * @author O2LEE
  */
-public class CategoryInfoFactory extends AbstractFactory {
+public class CategoryInfoFactory extends ElementFactory {
 
 	public CategoryInfoFactory(Business business) throws Exception {
 		super(business);
 	}
 
+	public CategoryInfo pick(String flag) throws Exception {
+		return this.pick(flag, ExceptionWhen.none);
+	}
+
+	@Deprecated
+	public CategoryInfo pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
+		return this.pick(flag, CategoryInfo.class);
+	}
+
 	//@MethodDescribe("获取指定Id的CategoryInfo分类信息对象")
 	public CategoryInfo get( String id ) throws Exception {
 		return this.entityManagerContainer().find( id, CategoryInfo.class );
 	}
-	
+
 	//@MethodDescribe("列示全部的CategoryInfo分类信息列表")
 	@SuppressWarnings("unused")
 	public List<CategoryInfo> listAll() throws Exception {
@@ -41,7 +51,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 		Root<CategoryInfo> root = cq.from( CategoryInfo.class );
 		return em.createQuery(cq).getResultList();
 	}
-	
+
 	//@MethodDescribe("列示全部的CategoryInfo分类信息列表")
 	public List<String> listAllIds() throws Exception {
 		EntityManager em = this.entityManagerContainer().get( CategoryInfo.class );
@@ -51,7 +61,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 		cq.select(root.get(CategoryInfo_.id));
 		return em.createQuery(cq).getResultList();
 	}
-	
+
 	//@MethodDescribe("列示指定Id的CategoryInfo分类信息列表")
 //	public List<CategoryInfo> list(List<String> ids) throws Exception {
 //		EntityManager em = this.entityManagerContainer().get( CategoryInfo.class );
@@ -61,7 +71,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 //		Predicate p = root.get( CategoryInfo_.id).in(ids);
 //		return em.createQuery(cq.where(p)).getResultList();
 //	}
-	
+
 	//@MethodDescribe("根据应用ID列示所有的CategoryInfo分类信息列表")
 	public List<String> listByAppId( String appId ) throws Exception {
 		EntityManager em = this.entityManagerContainer().get( CategoryInfo.class );
@@ -105,7 +115,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 
 		return em.createQuery( cq.where(p) ).setMaxResults(maxCount).getResultList();
 	}
-	
+
 	public List<CategoryInfo> listCategoryByAppId( String appId, String documentType, Integer maxCount ) throws Exception {
 		EntityManager em = this.entityManagerContainer().get( CategoryInfo.class );
 		CriteriaBuilder cb = em.getCriteriaBuilder();
@@ -117,7 +127,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 		}
 		return em.createQuery( cq.where(p) ).setMaxResults(maxCount).getResultList();
 	}
-	
+
 	//@MethodDescribe("根据应用ID列示所有的CategoryInfo分类信息数量")
 	public Long countByAppId( String appId, String documentType ) throws Exception {
 		EntityManager em = this.entityManagerContainer().get(CategoryInfo.class);
@@ -131,7 +141,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 		cq.select(cb.count(root));
 		return em.createQuery(cq.where(p)).getSingleResult();
 	}
-	
+
 	//@MethodDescribe("根据分类ID列示所有下级CategoryInfo分类信息列表")
 	public List<String> listByParentId( String categoryId ) throws Exception {
 		EntityManager em = this.entityManagerContainer().get( CategoryInfo.class );
@@ -160,7 +170,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 		cq.select(root.get( CategoryInfo_.id));
 		return em.createQuery(cq.where(p)).setMaxResults(200).getResultList();
 	}
-	
+
 	public List<String> listMyCategoryWithAppId( List<String> myCategoryIds, String documentType, String appId ) throws Exception {
 		EntityManager em = this.entityManagerContainer().get( CategoryInfo.class );
 		CriteriaBuilder cb = em.getCriteriaBuilder();
@@ -189,7 +199,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 		Predicate p = root.get( CategoryInfo_.categoryAlias ).in( categoryAlias );
 		return em.createQuery(cq.where( p )).getResultList();
 	}
-	
+
 	public List<CategoryInfo> listByAliases(List<String> categoryAlias) throws Exception {
 		if(ListTools.isEmpty( categoryAlias )) {
 			return null;
@@ -212,7 +222,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 	 * @param inCategoryIds  - 栏目ID的最大范围
 	 * @param excludCategoryIds - 需要排除的栏目ID
 	 * @return
-	 * @throws Exception 
+	 * @throws Exception
 	 */
 	public List<String> listPublishableCategoryInfoIdsWithPermission(String personName, List<String> unitNames,
 			List<String> groupNames, List<String> inAppInfoIds, List<String> inCategoryIds,
@@ -221,7 +231,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
 		Root<CategoryInfo> root = cq.from(CategoryInfo.class);
-		
+
 		Predicate p = null;
 		Predicate p_filter = null;
 		//限定栏目范围
@@ -243,12 +253,12 @@ public class CategoryInfoFactory extends AbstractFactory {
 			}else {
 				p_filter = cb.and( p_filter, cb.not( root.get( CategoryInfo_.id ).in( excludCategoryIds )));
 			}
-		}		
+		}
 		Predicate p_permission = null;
 		if( StringUtils.isNotEmpty( personName )) {
 			//可以管理的栏目,肯定可以发布信息
-			p_permission = cb.isMember( personName, root.get( CategoryInfo_.manageablePersonList ));	
-			p_permission = cb.or( p_permission, cb.isMember( personName, root.get( CategoryInfo_.publishablePersonList )));			
+			p_permission = cb.isMember( personName, root.get( CategoryInfo_.manageablePersonList ));
+			p_permission = cb.or( p_permission, cb.isMember( personName, root.get( CategoryInfo_.publishablePersonList )));
 		}
 		if( ListTools.isNotEmpty( unitNames )) {
 			if( p_permission == null  ) {
@@ -264,7 +274,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 				p_permission = cb.or( p_permission,  root.get( CategoryInfo_.publishableGroupList).in(groupNames));
 			}
 		}
-		
+
 		//使用新的条件将两个条件组合起来
 		if( p_filter != null ) {
 			p = p_filter;
@@ -295,7 +305,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 	 * @param inCategoryIds  - 栏目ID的最大范围
 	 * @param excludCategoryIds - 需要排除的栏目ID
 	 * @return
-	 * @throws Exception 
+	 * @throws Exception
 	 */
 	public List<String> listViewableCategoryInfoIdsWithPermission(String personName, List<String> unitNames, List<String> groupNames,
 			List<String> inAppInfoIds, List<String> inCategoryIds, List<String> excludCategoryIds,
@@ -304,7 +314,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
 		Root<CategoryInfo> root = cq.from(CategoryInfo.class);
-		
+
 		Predicate p = null;
 		Predicate p_filter = null;
 		//限定栏目范围
@@ -318,7 +328,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 			}else {
 				p_filter = cb.and( p_filter, root.get( CategoryInfo_.id ).in( inCategoryIds ));
 			}
-		}		
+		}
 		//排除指定的ID列表
 		if( ListTools.isNotEmpty( excludCategoryIds )) {
 			if( p_filter == null ) {
@@ -327,11 +337,11 @@ public class CategoryInfoFactory extends AbstractFactory {
 				p_filter = cb.and( p_filter, cb.not( root.get( CategoryInfo_.id ).in( excludCategoryIds )));
 			}
 		}
-		
+
 		Predicate p_permission = null;
 		if( StringUtils.isNotEmpty( personName )) {
 			//可以管理的栏目,肯定可以发布信息
-			p_permission = cb.isMember( personName, root.get( CategoryInfo_.manageablePersonList ));	
+			p_permission = cb.isMember( personName, root.get( CategoryInfo_.manageablePersonList ));
 			p_permission = cb.or( p_permission, cb.isMember( personName, root.get( CategoryInfo_.publishablePersonList )));
 		}
 		if( ListTools.isNotEmpty( unitNames )) {
@@ -352,7 +362,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 				p_permission = cb.or( p_permission,  root.get( CategoryInfo_.viewableGroupList).in(groupNames));
 			}
 		}
-		
+
 		//使用新的条件将两个条件组合起来
 		if( p_filter != null ) {
 			p = p_filter;
@@ -379,7 +389,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 	 * @param inCategoryIds
 	 * @param excludCategoryIds
 	 * @return
-	 * @throws Exception 
+	 * @throws Exception
 	 */
 	public List<String> listAllPeoplePublishableCategoryInfoIds(List<String> inAppInfoIds, List<String> inCategoryIds,
 			List<String> excludCategoryIds, String documentType, Integer maxCount ) throws Exception {
@@ -403,14 +413,14 @@ public class CategoryInfoFactory extends AbstractFactory {
 		}
 		return em.createQuery(cq.where( p )).setMaxResults(maxCount).getResultList();
 	}
-	
+
 	/**
 	 * 查询所有用户都可以发布的分类ID列表(检测allPeopleView和allPeoplePublish)
 	 * @param inAppInfoIds
 	 * @param inCategoryIds
 	 * @param excludCategoryIds
 	 * @return
-	 * @throws Exception 
+	 * @throws Exception
 	 */
 	public List<String> listAllPeopleViewableCategoryInfoIds(List<String> inAppInfoIds, List<String> inCategoryIds, List<String> excludCategoryIds,
 			String documentType, Integer maxCount ) throws Exception {
@@ -419,10 +429,10 @@ public class CategoryInfoFactory extends AbstractFactory {
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
 		Root<CategoryInfo> root = cq.from(CategoryInfo.class);
 		cq.select(root.get(CategoryInfo_.id));
-		
+
 		Predicate p_all = cb.isTrue( root.get( CategoryInfo_.allPeopleView ) );
 		p_all = cb.or( p_all,  cb.isTrue( root.get( CategoryInfo_.allPeoplePublish )));
-		
+
 		Predicate p = root.get( CategoryInfo_.id ).isNotNull();
 		if( ListTools.isNotEmpty( inAppInfoIds )) {
 			p = cb.and( p,  root.get( CategoryInfo_.appId ).in( inAppInfoIds ) );
@@ -455,7 +465,7 @@ public class CategoryInfoFactory extends AbstractFactory {
 		CriteriaBuilder cb = em.getCriteriaBuilder();
 		CriteriaQuery<String> cq = cb.createQuery(String.class);
 		Root<CategoryInfo> root = cq.from(CategoryInfo.class);
-		
+
 		Predicate p = cb.isMember( personName, root.get( CategoryInfo_.manageablePersonList ));
 		if( ListTools.isNotEmpty( inAppInfoIds )) {
 			p = cb.and( p, root.get( CategoryInfo_.appId ).in( inAppInfoIds ) );
@@ -472,4 +482,4 @@ public class CategoryInfoFactory extends AbstractFactory {
 		}
 		return em.createQuery( cq.where( p ) ).setMaxResults(maxCount).getResultList();
 	}
-}
+}

+ 10 - 1
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/FormFactory.java

@@ -22,12 +22,21 @@ import java.util.List;
  *
  * @author O2LEE
  */
-public class FormFactory extends AbstractFactory {
+public class FormFactory extends ElementFactory {
 
 	public FormFactory( Business business ) throws Exception {
 		super(business);
 	}
 
+	public Form pick(String flag) throws Exception {
+		return this.pick(flag, ExceptionWhen.none);
+	}
+
+	@Deprecated
+	public Form pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
+		return this.pick(flag, Form.class);
+	}
+
 	/**
 	 * @param id
 	 * @return Form

+ 15 - 5
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/ScriptFactory.java

@@ -11,6 +11,7 @@ import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 
 import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.exception.ExceptionWhen;
 import com.x.cms.assemble.control.AbstractFactory;
 import com.x.cms.assemble.control.Business;
 import com.x.cms.core.entity.element.Script;
@@ -20,12 +21,21 @@ import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
 
 
-public class ScriptFactory extends AbstractFactory {
+public class ScriptFactory extends ElementFactory {
 
 	public ScriptFactory(Business business) throws Exception {
 		super(business);
 	}
 
+	public Script pick(String flag) throws Exception {
+		return this.pick(flag, ExceptionWhen.none);
+	}
+
+	@Deprecated
+	public Script pick(String flag, ExceptionWhen exceptionWhen) throws Exception {
+		return this.pick(flag, Script.class);
+	}
+
 //    public List<Script> list( List<String> ids ) throws Exception {
 //        EntityManager em = this.entityManagerContainer().get(Script.class);
 //        CriteriaBuilder cb = em.getCriteriaBuilder();
@@ -44,7 +54,7 @@ public class ScriptFactory extends AbstractFactory {
 		cq.select(root.get(Script_.id)).where(p);
 		return em.createQuery(cq).getResultList();
 	}
-	
+
 	public List<Script> listScriptWithApp(String appId) throws Exception {
 		EntityManager em = this.entityManagerContainer().get(Script.class);
 		CriteriaBuilder cb = em.getCriteriaBuilder();
@@ -66,7 +76,7 @@ public class ScriptFactory extends AbstractFactory {
 		List<String> list = em.createQuery(cq).setMaxResults(1).getResultList();
 		return list.isEmpty() ? null : list.get(0);
 	}
-	
+
 	@SuppressWarnings("unchecked")
 	public List<Script> listScriptNestedWithAppInfoWithUniqueName( String appId, String uniqueName ) throws Exception {
 		List<Script> list = new ArrayList<>();
@@ -100,7 +110,7 @@ public class ScriptFactory extends AbstractFactory {
 			throw new Exception("listScriptNestedWithAppInfoWithUniqueName error.", e);
 		}
 	}
-	
+
 	public Script getScriptWithAppInfoWithUniqueName( String appId, String uniqueName ) throws Exception {
 		Script script = null;
 		try {
@@ -129,4 +139,4 @@ public class ScriptFactory extends AbstractFactory {
 			throw new Exception("getScriptWithAppInfoWithUniqueName error.", e);
 		}
 	}
-}
+}

+ 21 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/portal/PortalFactory.java

@@ -0,0 +1,21 @@
+package com.x.cms.assemble.control.factory.portal;
+
+import com.x.cms.assemble.control.AbstractFactory;
+import com.x.cms.assemble.control.Business;
+
+public class PortalFactory extends AbstractFactory {
+
+	public PortalFactory(Business abstractBusiness) throws Exception {
+		super(abstractBusiness);
+	}
+
+	private ScriptFactory script;
+
+	public ScriptFactory script() throws Exception {
+		if (null == this.script) {
+			this.script = new ScriptFactory(this.business());
+		}
+		return script;
+	}
+
+}

+ 17 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/portal/ScriptFactory.java

@@ -0,0 +1,17 @@
+package com.x.cms.assemble.control.factory.portal;
+
+import com.x.cms.assemble.control.Business;
+import com.x.cms.assemble.control.factory.ElementFactory;
+import com.x.portal.core.entity.Script;
+
+public class ScriptFactory extends ElementFactory {
+
+	public ScriptFactory(Business abstractBusiness) throws Exception {
+		super(abstractBusiness);
+	}
+
+	public Script pick(String flag) throws Exception {
+		return this.pick(flag, Script.class);
+	}
+
+}

+ 21 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/process/ProcessFactory.java

@@ -0,0 +1,21 @@
+package com.x.cms.assemble.control.factory.process;
+
+import com.x.cms.assemble.control.AbstractFactory;
+import com.x.cms.assemble.control.Business;
+
+public class ProcessFactory extends AbstractFactory {
+
+	public ProcessFactory(Business abstractBusiness) throws Exception {
+		super(abstractBusiness);
+	}
+
+	private ScriptFactory script;
+
+	public ScriptFactory script() throws Exception {
+		if (null == this.script) {
+			this.script = new ScriptFactory(this.business());
+		}
+		return script;
+	}
+
+}

+ 17 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/factory/process/ScriptFactory.java

@@ -0,0 +1,17 @@
+package com.x.cms.assemble.control.factory.process;
+
+import com.x.cms.assemble.control.Business;
+import com.x.cms.assemble.control.factory.ElementFactory;
+import com.x.processplatform.core.entity.element.Script;
+
+public class ScriptFactory extends ElementFactory {
+
+	public ScriptFactory(Business abstractBusiness) throws Exception {
+		super(abstractBusiness);
+	}
+
+	public Script pick(String flag) throws Exception {
+		return this.pick(flag, Script.class);
+	}
+
+}

+ 56 - 1
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/ActionSave.java

@@ -6,6 +6,7 @@ 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.project.annotation.AuditLog;
+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.cache.ApplicationCache;
@@ -24,7 +25,9 @@ import com.x.cms.core.entity.element.ViewFieldConfig;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 
 public class ActionSave extends BaseAction {
 
@@ -65,6 +68,10 @@ public class ActionSave extends BaseAction {
 						form.setId(wi.getId());
 					}
 					emc.beginTransaction(Form.class);
+					form.getProperties().setRelatedFormList(wi.getRelatedFormList());
+					form.getProperties().setMobileRelatedFormList(wi.getMobileRelatedFormList());
+					form.getProperties().setRelatedScriptMap(wi.getRelatedScriptMap());
+					form.getProperties().setMobileRelatedScriptMap(wi.getMobileRelatedScriptMap());
 					emc.persist(form, CheckPersistType.all);
 					emc.commit();
 					logService.log(emc, effectivePerson.getDistinguishedName(), form.getName(), form.getAppId(), "", "",
@@ -76,6 +83,10 @@ public class ActionSave extends BaseAction {
 				} else {
 					Wi.copier.copy(wi, form);
 					emc.beginTransaction(Form.class);
+					form.getProperties().setRelatedFormList(wi.getRelatedFormList());
+					form.getProperties().setMobileRelatedFormList(wi.getMobileRelatedFormList());
+					form.getProperties().setRelatedScriptMap(wi.getRelatedScriptMap());
+					form.getProperties().setMobileRelatedScriptMap(wi.getMobileRelatedScriptMap());
 					emc.check(form, CheckPersistType.all);
 					emc.commit();
 
@@ -110,5 +121,49 @@ public class ActionSave extends BaseAction {
 
 		public static WrapCopier<Wi, Form> copier = WrapCopierFactory.wi(Wi.class, Form.class, null,
 				JpaObject.FieldsUnmodify);
+
+		@FieldDescribe("关联表单")
+		private List<String> relatedFormList = new ArrayList<>();
+
+		@FieldDescribe("移动端关联表单")
+		private List<String> mobileRelatedFormList = new ArrayList<>();
+
+		@FieldDescribe("关联脚本.")
+		private Map<String, String> relatedScriptMap = new LinkedHashMap<>();
+
+		@FieldDescribe("移动端关联脚本.")
+		private Map<String, String> mobileRelatedScriptMap = new LinkedHashMap<>();
+
+		public List<String> getRelatedFormList() {
+			return relatedFormList;
+		}
+
+		public void setRelatedFormList(List<String> relatedFormList) {
+			this.relatedFormList = relatedFormList;
+		}
+
+		public List<String> getMobileRelatedFormList() {
+			return mobileRelatedFormList;
+		}
+
+		public void setMobileRelatedFormList(List<String> mobileRelatedFormList) {
+			this.mobileRelatedFormList = mobileRelatedFormList;
+		}
+
+		public Map<String, String> getRelatedScriptMap() {
+			return relatedScriptMap;
+		}
+
+		public void setRelatedScriptMap(Map<String, String> relatedScriptMap) {
+			this.relatedScriptMap = relatedScriptMap;
+		}
+
+		public Map<String, String> getMobileRelatedScriptMap() {
+			return mobileRelatedScriptMap;
+		}
+
+		public void setMobileRelatedScriptMap(Map<String, String> mobileRelatedScriptMap) {
+			this.mobileRelatedScriptMap = mobileRelatedScriptMap;
+		}
 	}
-}
+}

+ 228 - 4
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/BaseAction.java

@@ -1,16 +1,240 @@
 package com.x.cms.assemble.control.jaxrs.form;
 
 import com.x.base.core.project.cache.Cache;
+import com.x.base.core.project.gson.GsonPropertyObject;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.base.core.project.jaxrs.WoMaxAgeFastETag;
+import com.x.cms.assemble.control.Business;
 import com.x.cms.assemble.control.service.LogService;
-import com.x.cms.core.entity.element.Form;
-import com.x.cms.core.entity.element.View;
-import com.x.cms.core.entity.element.ViewCategory;
-import com.x.cms.core.entity.element.ViewFieldConfig;
+import com.x.cms.core.entity.element.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 public class BaseAction extends StandardJaxrsAction {
 
 	protected Cache.CacheCategory cacheCategory = new Cache.CacheCategory(Form.class, View.class, ViewFieldConfig.class, ViewCategory.class);
 
 	protected LogService logService = new LogService();
+
+	protected static final String FORM_OPEN_MODE_READ = "read";
+
+	protected List<String> convertScriptToCacheTag(Business business, Map<String, String> map) throws Exception {
+		List<String> list = new ArrayList<>();
+		for (Map.Entry<String, String> entry : map.entrySet()) {
+			switch (entry.getValue()) {
+				case RelatedScript.TYPE_PROCESS_PLATFORM:
+					com.x.processplatform.core.entity.element.Script pp = business.process().script().pick(entry.getKey());
+					if (null != pp) {
+						list.add(pp.getId() + pp.getUpdateTime().getTime());
+					}
+					break;
+				case RelatedScript.TYPE_CMS:
+					Script cms = business.getScriptFactory().pick(entry.getKey());
+					if (null != cms) {
+						list.add(cms.getId() + cms.getUpdateTime().getTime());
+					}
+					break;
+				case RelatedScript.TYPE_PORTAL:
+					com.x.portal.core.entity.Script p = business.portal().script().pick(entry.getKey());
+					if (null != p) {
+						list.add(p.getId() + p.getUpdateTime().getTime());
+					}
+					break;
+				default:
+					break;
+			}
+		}
+		return list;
+	}
+
+	public static class AbstractWo extends WoMaxAgeFastETag {
+
+		private static final long serialVersionUID = 4473155051937494454L;
+
+		private RelatedForm form;
+
+		private Map<String, RelatedForm> relatedFormMap = new HashMap<>();
+
+		private Map<String, RelatedScript> relatedScriptMap = new HashMap<>();
+
+		public RelatedForm getForm() {
+			return form;
+		}
+
+		public void setForm(RelatedForm form) {
+			this.form = form;
+		}
+
+		public Map<String, RelatedScript> getRelatedScriptMap() {
+			return relatedScriptMap;
+		}
+
+		public void setRelatedScriptMap(Map<String, RelatedScript> relatedScriptMap) {
+			this.relatedScriptMap = relatedScriptMap;
+		}
+
+		public Map<String, RelatedForm> getRelatedFormMap() {
+			return relatedFormMap;
+		}
+
+		public void setRelatedFormMap(Map<String, RelatedForm> relatedFormMap) {
+			this.relatedFormMap = relatedFormMap;
+		}
+	}
+
+	public static class RelatedForm extends GsonPropertyObject {
+
+		private static final long serialVersionUID = 3099673570508709007L;
+
+		public RelatedForm() {
+		}
+
+		public RelatedForm(Form form, String data) {
+			this.id = form.getId();
+			this.alias = form.getAlias();
+			this.name = form.getName();
+			this.description = form.getDescription();
+			this.appId = form.getAppId();
+			this.hasMobile = form.getHasMobile();
+			this.data = data;
+		}
+
+		private String id;
+		private String alias;
+		private String name;
+		private String description;
+		private String appId;
+		private Boolean hasMobile;
+		private String data;
+
+		public String getAppId() {
+			return appId;
+		}
+
+		public void setAppId(String appId) {
+			this.appId = appId;
+		}
+
+		public Boolean getHasMobile() {
+			return hasMobile;
+		}
+
+		public void setHasMobile(Boolean hasMobile) {
+			this.hasMobile = hasMobile;
+		}
+
+		public String getAlias() {
+			return alias;
+		}
+
+		public void setAlias(String alias) {
+			this.alias = alias;
+		}
+
+		public String getName() {
+			return name;
+		}
+
+		public void setName(String name) {
+			this.name = name;
+		}
+
+		public String getId() {
+			return id;
+		}
+
+		public void setId(String id) {
+			this.id = id;
+		}
+
+		public String getData() {
+			return data;
+		}
+
+		public void setData(String data) {
+			this.data = data;
+		}
+
+		public String getDescription() {
+			return description;
+		}
+
+		public void setDescription(String description) {
+			this.description = description;
+		}
+	}
+
+	public static class RelatedScript extends GsonPropertyObject {
+
+		private static final long serialVersionUID = -4465416667636529080L;
+
+		public static final String TYPE_PROCESS_PLATFORM = "processPlatform";
+		public static final String TYPE_CMS = "cms";
+		public static final String TYPE_PORTAL = "portal";
+
+		public RelatedScript() {
+		}
+
+		public RelatedScript(String id, String name, String alias, String text, String type) {
+			this.id = id;
+			this.alias = alias;
+			this.name = name;
+			this.text = text;
+			this.type = type;
+		}
+
+		private String type;
+
+		private String id;
+
+		private String alias;
+
+		private String name;
+
+		private String text;
+
+		public String getId() {
+			return id;
+		}
+
+		public void setId(String id) {
+			this.id = id;
+		}
+
+		public String getAlias() {
+			return alias;
+		}
+
+		public void setAlias(String alias) {
+			this.alias = alias;
+		}
+
+		public String getName() {
+			return name;
+		}
+
+		public void setName(String name) {
+			this.name = name;
+		}
+
+		public String getType() {
+			return type;
+		}
+
+		public void setType(String type) {
+			this.type = type;
+		}
+
+		public String getText() {
+			return text;
+		}
+
+		public void setText(String text) {
+			this.text = text;
+		}
+
+	}
 }

+ 93 - 19
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/FormAction.java

@@ -39,7 +39,7 @@ public class FormAction extends StandardJaxrsAction {
 			Exception exception = new ExceptionServiceLogic( e, "系统在查询所有CMS表单时发生异常。" );
 			result.error( exception );
 			logger.error( e, effectivePerson, request, null);
-		}		
+		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
@@ -48,7 +48,7 @@ public class FormAction extends StandardJaxrsAction {
 	@Path("list/app/{appId}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void listFormByAppId( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, 
+	public void listFormByAppId( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 			@JaxrsParameterDescribe("栏目ID") @PathParam("appId") String appId ) {
 		EffectivePerson effectivePerson = this.effectivePerson( request );
 		ActionResult<List<ActionListByApp.Wo>> result = new ActionResult<>();
@@ -68,7 +68,7 @@ public class FormAction extends StandardJaxrsAction {
 	@Path("{id}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void get( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, 
+	public void get( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 			@JaxrsParameterDescribe("表单ID") @PathParam("id") String id) {
 		EffectivePerson effectivePerson = this.effectivePerson( request );
 		ActionResult<ActionGet.Wo> result = new ActionResult<>();
@@ -101,7 +101,7 @@ public class FormAction extends StandardJaxrsAction {
 		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
-	
+
 	@JaxrsMethodDescribe(value = "保存表单信息对象.", action = ActionSave.class)
 	@POST
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@@ -110,7 +110,7 @@ public class FormAction extends StandardJaxrsAction {
 		EffectivePerson effectivePerson = this.effectivePerson( request );
 		ActionResult<ActionSave.Wo> result = new ActionResult<>();
 		Boolean check = true;
-		
+
 		if( check ){
 			try {
 				result = new ActionSave().execute( request, effectivePerson, null, jsonElement );
@@ -128,7 +128,7 @@ public class FormAction extends StandardJaxrsAction {
 	@Path("{id}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void put( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, 
+	public void put( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 			@JaxrsParameterDescribe("表单ID") @PathParam("id") String id, JsonElement jsonElement) {
 		EffectivePerson effectivePerson = this.effectivePerson( request );
 		ActionResult<ActionSave.Wo> result = new ActionResult<>();
@@ -151,7 +151,7 @@ public class FormAction extends StandardJaxrsAction {
 	@Path("{id}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void delete( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, 
+	public void delete( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 			@JaxrsParameterDescribe("表单ID") @PathParam("id") String id) {
 		EffectivePerson effectivePerson = this.effectivePerson( request );
 		ActionResult<WrapOutId> result = new ActionResult<>();
@@ -171,10 +171,10 @@ public class FormAction extends StandardJaxrsAction {
 	@Path("filter/list/{id}/next/{count}/app/{appId}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void listNextWithFilter( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, 
-			@JaxrsParameterDescribe("最后一条信息ID,如果是第一页,则可以用(0)代替") @PathParam("id") String id, 
-			@JaxrsParameterDescribe("每页显示的条目数量") @PathParam("count") Integer count, 
-			@JaxrsParameterDescribe("栏目ID") @PathParam("appId") String appId, 
+	public void listNextWithFilter( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("最后一条信息ID,如果是第一页,则可以用(0)代替") @PathParam("id") String id,
+			@JaxrsParameterDescribe("每页显示的条目数量") @PathParam("count") Integer count,
+			@JaxrsParameterDescribe("栏目ID") @PathParam("appId") String appId,
 			JsonElement jsonElement) {
 		EffectivePerson effectivePerson = this.effectivePerson( request );
 		ActionResult<List<ActionListNextWithFilter.Wo>> result = new ActionResult<>();
@@ -185,7 +185,7 @@ public class FormAction extends StandardJaxrsAction {
 			Exception exception = new ExceptionServiceLogic( e, "系统在查询所有CMS表单时发生异常。" );
 			result.error( exception );
 			logger.error( e, effectivePerson, request, null);
-		}		
+		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
@@ -194,10 +194,10 @@ public class FormAction extends StandardJaxrsAction {
 	@Path("filter/list/{id}/prev/{count}/app/{appId}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void listPrevWithFilter( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, 
-			@JaxrsParameterDescribe("最后一条信息ID,如果是第一页,则可以用(0)代替") @PathParam("id") String id, 
-			@JaxrsParameterDescribe("每页显示的条目数量") @PathParam("count") Integer count, 
-			@JaxrsParameterDescribe("栏目ID") @PathParam("appId") String appId, 
+	public void listPrevWithFilter( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+			@JaxrsParameterDescribe("最后一条信息ID,如果是第一页,则可以用(0)代替") @PathParam("id") String id,
+			@JaxrsParameterDescribe("每页显示的条目数量") @PathParam("count") Integer count,
+			@JaxrsParameterDescribe("栏目ID") @PathParam("appId") String appId,
 			JsonElement jsonElement) {
 		EffectivePerson effectivePerson = this.effectivePerson( request );
 		ActionResult<List<ActionListPrevWithFilter.Wo>> result = new ActionResult<>();
@@ -208,10 +208,10 @@ public class FormAction extends StandardJaxrsAction {
 			Exception exception = new ExceptionServiceLogic( e, "系统在查询所有CMS表单时发生异常。" );
 			result.error( exception );
 			logger.error( e, effectivePerson, request, null);
-		}		
+		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
-	
+
 	@JaxrsMethodDescribe(value = "根据指定的栏目获取栏目下所有表单包含的字段字段信息.", action = ActionListFormFieldWithAppInfo.class)
 	@GET
 	@Path("list/formfield/appInfo/{appId}")
@@ -248,4 +248,78 @@ public class FormAction extends StandardJaxrsAction {
 		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
-}
+
+	@JaxrsMethodDescribe(value = "查询表单,如果有表单那么返回表单id,如果表单不存在那么返回分类的默认Form.", action = V2LookupDoc.class)
+	@GET
+	@Path("v2/lookup/document/{docId}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void V2LookupDoc(@Suspended final AsyncResponse asyncResponse,
+											@Context HttpServletRequest request,
+											@JaxrsParameterDescribe("文档ID") @PathParam("docId") String docId) {
+		ActionResult<V2LookupDoc.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2LookupDoc().execute(effectivePerson, docId);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+	@JaxrsMethodDescribe(value = "查询表单,如果有表单那么返回表单id,如果表单不存在返回分类的默认FormMobile.", action = V2LookupDocMobile.class)
+	@GET
+	@Path("v2/lookup/document/{docId}/mobile")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void V2LookupDocMobile(@Suspended final AsyncResponse asyncResponse,
+												  @Context HttpServletRequest request,
+												  @JaxrsParameterDescribe("文档ID") @PathParam("docId") String docId) {
+		ActionResult<V2LookupDocMobile.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2LookupDocMobile().execute(effectivePerson, docId);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+	@JaxrsMethodDescribe(value = "获取表单.", action = V2Get.class)
+	@GET
+	@Path("v2/{id}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void V2Get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+					  @JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+		ActionResult<V2Get.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2Get().execute(effectivePerson, id);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+	@JaxrsMethodDescribe(value = "获取表单Mobile.", action = V2GetMobile.class)
+	@GET
+	@Path("v2/{id}/mobile")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void V2GetMobile(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+							@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+		ActionResult<V2GetMobile.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2GetMobile().execute(effectivePerson, id);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+}

+ 76 - 2
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/FormAnonymousAction.java

@@ -33,7 +33,7 @@ public class FormAnonymousAction extends StandardJaxrsAction {
 	@Path("{id}")
 	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
 	@Consumes(MediaType.APPLICATION_JSON)
-	public void get( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, 
+	public void get( @Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
 			@JaxrsParameterDescribe("表单ID") @PathParam("id") String id) {
 		EffectivePerson effectivePerson = this.effectivePerson( request );
 		ActionResult<ActionGet.Wo> result = new ActionResult<>();
@@ -47,4 +47,78 @@ public class FormAnonymousAction extends StandardJaxrsAction {
 		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
-}
+
+	@JaxrsMethodDescribe(value = "查询表单,如果有表单那么返回表单id,如果表单不存在那么返回分类的默认Form.", action = V2LookupDoc.class)
+	@GET
+	@Path("v2/lookup/document/{docId}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void V2LookupDoc(@Suspended final AsyncResponse asyncResponse,
+											@Context HttpServletRequest request,
+											@JaxrsParameterDescribe("文档ID") @PathParam("docId") String docId) {
+		ActionResult<V2LookupDoc.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2LookupDoc().execute(effectivePerson, docId);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+	@JaxrsMethodDescribe(value = "查询表单,如果有表单那么返回表单id,如果表单不存在返回分类的默认FormMobile.", action = V2LookupDocMobile.class)
+	@GET
+	@Path("v2/lookup/document/{docId}/mobile")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void V2LookupDocMobile(@Suspended final AsyncResponse asyncResponse,
+												  @Context HttpServletRequest request,
+												  @JaxrsParameterDescribe("文档ID") @PathParam("docId") String docId) {
+		ActionResult<V2LookupDocMobile.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2LookupDocMobile().execute(effectivePerson, docId);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+	@JaxrsMethodDescribe(value = "获取表单.", action = V2Get.class)
+	@GET
+	@Path("v2/{id}")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void V2Get(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+					  @JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+		ActionResult<V2Get.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2Get().execute(effectivePerson, id);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+	@JaxrsMethodDescribe(value = "获取表单Mobile.", action = V2GetMobile.class)
+	@GET
+	@Path("v2/{id}/mobile")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void V2GetMobile(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+							@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
+		ActionResult<V2GetMobile.Wo> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new V2GetMobile().execute(effectivePerson, id);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+}

+ 134 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/V2Get.java

@@ -0,0 +1,134 @@
+package com.x.cms.assemble.control.jaxrs.form;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
+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.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.base.core.project.tools.ListTools;
+import com.x.cms.assemble.control.Business;
+import com.x.cms.core.entity.element.Form;
+import com.x.cms.core.entity.element.FormProperties;
+import com.x.cms.core.entity.element.Script;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.TreeMap;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+class V2Get extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(V2Get.class);
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		CacheKey cacheKey = new CacheKey(this.getClass(), id);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			result.setData((Wo) optional.get());
+		} else {
+			Form form = null;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				form = business.getFormFactory().pick(id);
+			}
+			if (null == form) {
+				throw new ExceptionEntityNotExist(id, Form.class);
+			}
+			Wo wo = new Wo();
+			final FormProperties properties = form.getProperties();
+			wo.setFastETag(form.getId() + form.getUpdateTime().getTime());
+			wo.setForm(new RelatedForm(form, form.getDataOrMobileData()));
+			CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture = this.getRelatedFormFuture(properties);
+			CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture = this
+					.getRelatedScriptFuture(properties);
+			wo.setRelatedFormMap(getRelatedFormFuture.get(10, TimeUnit.SECONDS));
+			wo.setRelatedScriptMap(getRelatedScriptFuture.get(10, TimeUnit.SECONDS));
+			wo.setMaxAge(3600 * 24);
+			CacheManager.put(cacheCategory, cacheKey, wo);
+			result.setData(wo);
+		}
+		return result;
+	}
+
+	private CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			Map<String, RelatedForm> map = new TreeMap<>();
+			if (ListTools.isNotEmpty(properties.getRelatedFormList())) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business bus = new Business(emc);
+					Form f;
+					for (String id : properties.getRelatedFormList()) {
+						f = bus.getFormFactory().pick(id);
+						if (null != f) {
+							map.put(id, new RelatedForm(f, f.getDataOrMobileData()));
+						}
+					}
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return map;
+		});
+	}
+
+	private CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			Map<String, RelatedScript> map = new TreeMap<>();
+			if ((null != properties.getRelatedScriptMap()) && (properties.getRelatedScriptMap().size() > 0)) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					map = convertScript(business, properties);
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return map;
+		});
+	}
+
+	private Map<String, RelatedScript> convertScript(Business bus, FormProperties properties) throws Exception {
+		Map<String, RelatedScript> map = new TreeMap<>();
+		for (Entry<String, String> entry : properties.getRelatedScriptMap().entrySet()) {
+			switch (entry.getValue()) {
+				case RelatedScript.TYPE_PROCESS_PLATFORM:
+					com.x.processplatform.core.entity.element.Script pp = bus.process().script().pick(entry.getKey());
+					if (null != pp) {
+						map.put(entry.getKey(),
+								new RelatedScript(pp.getId(), pp.getName(), pp.getAlias(), pp.getText(), entry.getValue()));
+					}
+					break;
+				case RelatedScript.TYPE_CMS:
+					Script cms = bus.getScriptFactory().pick(entry.getKey());
+					if (null != cms) {
+						map.put(entry.getKey(), new RelatedScript(cms.getId(), cms.getName(), cms.getAlias(), cms.getText(),
+								entry.getValue()));
+					}
+					break;
+				case RelatedScript.TYPE_PORTAL:
+					com.x.portal.core.entity.Script p = bus.portal().script().pick(entry.getKey());
+					if (null != p) {
+						map.put(entry.getKey(),
+								new RelatedScript(p.getId(), p.getName(), p.getAlias(), p.getText(), entry.getValue()));
+					}
+					break;
+				default:
+					break;
+			}
+		}
+		return map;
+	}
+
+	public static class Wo extends AbstractWo {
+
+		private static final long serialVersionUID = 3540820372721279101L;
+
+	}
+
+}

+ 134 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/V2GetMobile.java

@@ -0,0 +1,134 @@
+package com.x.cms.assemble.control.jaxrs.form;
+
+import com.x.base.core.container.EntityManagerContainer;
+import com.x.base.core.container.factory.EntityManagerContainerFactory;
+import com.x.base.core.project.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
+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.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.base.core.project.tools.ListTools;
+import com.x.cms.assemble.control.Business;
+import com.x.cms.core.entity.element.Form;
+import com.x.cms.core.entity.element.FormProperties;
+import com.x.cms.core.entity.element.Script;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.TreeMap;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+class V2GetMobile extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(V2GetMobile.class);
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String id) throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		CacheKey cacheKey = new CacheKey(this.getClass(), id);
+		Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+		if (optional.isPresent()) {
+			result.setData((Wo) optional.get());
+		} else {
+			Form form = null;
+			try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+				Business business = new Business(emc);
+				form = business.getFormFactory().pick(id);
+			}
+			if (null == form) {
+				throw new ExceptionEntityNotExist(id, Form.class);
+			}
+			Wo wo = new Wo();
+			final FormProperties properties = form.getProperties();
+			wo.setFastETag(form.getId() + form.getUpdateTime().getTime());
+			wo.setForm(new RelatedForm(form, form.getMobileDataOrData()));
+			CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture = this.getRelatedFormFuture(properties);
+			CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture = this
+					.getRelatedScriptFuture(properties);
+			wo.setRelatedFormMap(getRelatedFormFuture.get(10, TimeUnit.SECONDS));
+			wo.setRelatedScriptMap(getRelatedScriptFuture.get(10, TimeUnit.SECONDS));
+			wo.setMaxAge(3600 * 24);
+			CacheManager.put(cacheCategory, cacheKey, wo);
+			result.setData(wo);
+		}
+		return result;
+	}
+
+	private CompletableFuture<Map<String, RelatedForm>> getRelatedFormFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			Map<String, RelatedForm> map = new TreeMap<>();
+			if (ListTools.isNotEmpty(properties.getMobileRelatedFormList())) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business bus = new Business(emc);
+					Form f;
+					for (String id : properties.getMobileRelatedFormList()) {
+						f = bus.getFormFactory().pick(id);
+						if (null != f) {
+							map.put(id, new RelatedForm(f, f.getMobileDataOrData()));
+						}
+					}
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return map;
+		});
+	}
+
+	private CompletableFuture<Map<String, RelatedScript>> getRelatedScriptFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			Map<String, RelatedScript> map = new TreeMap<>();
+			if ((null != properties.getMobileRelatedScriptMap()) && (properties.getMobileRelatedScriptMap().size() > 0)) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					map = convertScript(business, properties);
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return map;
+		});
+	}
+
+	private Map<String, RelatedScript> convertScript(Business bus, FormProperties properties) throws Exception {
+		Map<String, RelatedScript> map = new TreeMap<>();
+		for (Entry<String, String> entry : properties.getMobileRelatedScriptMap().entrySet()) {
+			switch (entry.getValue()) {
+				case RelatedScript.TYPE_PROCESS_PLATFORM:
+					com.x.processplatform.core.entity.element.Script pp = bus.process().script().pick(entry.getKey());
+					if (null != pp) {
+						map.put(entry.getKey(),
+								new RelatedScript(pp.getId(), pp.getName(), pp.getAlias(), pp.getText(), entry.getValue()));
+					}
+					break;
+				case RelatedScript.TYPE_CMS:
+					Script cms = bus.getScriptFactory().pick(entry.getKey());
+					if (null != cms) {
+						map.put(entry.getKey(), new RelatedScript(cms.getId(), cms.getName(), cms.getAlias(), cms.getText(),
+								entry.getValue()));
+					}
+					break;
+				case RelatedScript.TYPE_PORTAL:
+					com.x.portal.core.entity.Script p = bus.portal().script().pick(entry.getKey());
+					if (null != p) {
+						map.put(entry.getKey(),
+								new RelatedScript(p.getId(), p.getName(), p.getAlias(), p.getText(), entry.getValue()));
+					}
+					break;
+				default:
+					break;
+			}
+		}
+		return map;
+	}
+
+	public static class Wo extends AbstractWo {
+
+		private static final long serialVersionUID = 3540820372721279101L;
+
+	}
+
+}

+ 192 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/V2LookupDoc.java

@@ -0,0 +1,192 @@
+package com.x.cms.assemble.control.jaxrs.form;
+
+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.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+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.cms.assemble.control.Business;
+import com.x.cms.core.entity.CategoryInfo;
+import com.x.cms.core.entity.Document;
+import com.x.cms.core.entity.element.Form;
+import com.x.cms.core.entity.element.FormProperties;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import java.util.zip.CRC32;
+
+class V2LookupDoc extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(V2LookupDoc.class);
+
+	private Form form = null;
+	private Form readForm = null;
+	private Wo wo = new Wo();
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String docId) throws Exception {
+
+		ActionResult<Wo> result = new ActionResult<>();
+
+		this.getDocForm(docId);
+		String formId = "";
+		String readFormId = "";
+		if (null != this.form) {
+			formId = form.getId();
+			this.wo.setFormId(formId);
+		}
+		if (null != this.readForm) {
+			readFormId = readForm.getId();
+			this.wo.setReadFormId(readFormId);
+		}
+		if(StringUtils.isNotEmpty(formId) || StringUtils.isNotEmpty(readFormId)){
+			CacheKey cacheKey = new CacheKey(this.getClass(), formId, readFormId);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				this.wo = (Wo) optional.get();
+			} else {
+				List<String> list = new ArrayList<>();
+				if (null != this.form) {
+					CompletableFuture<List<String>> relatedFormFuture = this.relatedFormFuture(this.form.getProperties());
+					CompletableFuture<List<String>> relatedScriptFuture = this
+							.relatedScriptFuture(this.form.getProperties());
+					list.add(this.form.getId() + this.form.getUpdateTime().getTime());
+					list.addAll(relatedFormFuture.get(10, TimeUnit.SECONDS));
+					list.addAll(relatedScriptFuture.get(10, TimeUnit.SECONDS));
+				}
+				if (null != this.readForm && !formId.equals(readFormId)) {
+					CompletableFuture<List<String>> relatedFormFuture = this.relatedFormFuture(this.readForm.getProperties());
+					CompletableFuture<List<String>> relatedScriptFuture = this
+							.relatedScriptFuture(this.readForm.getProperties());
+					list.add(this.readForm.getId() + this.readForm.getUpdateTime().getTime());
+					list.addAll(relatedFormFuture.get(10, TimeUnit.SECONDS));
+					list.addAll(relatedScriptFuture.get(10, TimeUnit.SECONDS));
+				}
+				list = list.stream().sorted().collect(Collectors.toList());
+				CRC32 crc = new CRC32();
+				crc.update(StringUtils.join(list, "#").getBytes());
+				this.wo.setCacheTag(crc.getValue() + "");
+				CacheManager.put(cacheCategory, cacheKey, wo);
+			}
+		}
+		result.setData(wo);
+		return result;
+	}
+
+	private void getDocForm(String docId) throws Exception {
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			Document document = emc.fetch(docId, Document.class, ListTools.toList(JpaObject.id_FIELDNAME, Document.form_FIELDNAME,
+					Document.readFormId_FIELDNAME, Document.categoryId_FIELDNAME));
+			if (null != document) {
+				String formId = document.getForm();
+				String readFormId = document.getReadFormId();
+				if(StringUtils.isNotBlank(formId)) {
+					this.form = business.getFormFactory().pick(formId);
+				}
+				if (null == this.form) {
+					CategoryInfo categoryInfo = business.getCategoryInfoFactory().pick(document.getCategoryId());
+					if (null != categoryInfo) {
+						formId = categoryInfo.getFormId();
+						this.form = business.getFormFactory().pick(formId);
+					}
+				}
+				if(StringUtils.isNotBlank(readFormId)) {
+					if(readFormId.equals(formId)){
+						this.readForm = this.form;
+					}else {
+						this.readForm = business.getFormFactory().pick(formId);
+					}
+				}
+				if (null == this.readForm) {
+					CategoryInfo categoryInfo = business.getCategoryInfoFactory().pick(document.getCategoryId());
+					if (null != categoryInfo) {
+						readFormId = categoryInfo.getReadFormId();
+						this.readForm = business.getFormFactory().pick(readFormId);
+					}
+				}
+			}
+		}
+	}
+
+	private CompletableFuture<List<String>> relatedFormFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<String> list = new ArrayList<>();
+			if (ListTools.isNotEmpty(properties.getRelatedFormList())) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Form f;
+					for (String id : properties.getRelatedFormList()) {
+						f = emc.fetch(id, Form.class, ListTools.toList(JpaObject.id_FIELDNAME, JpaObject.updateTime_FIELDNAME));
+						if (null != f) {
+							list.add(f.getId() + f.getUpdateTime().getTime());
+						}
+					}
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return list;
+		});
+	}
+
+	private CompletableFuture<List<String>> relatedScriptFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<String> list = new ArrayList<>();
+			if ((null != properties.getRelatedScriptMap()) && (properties.getRelatedScriptMap().size() > 0)) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					list = convertScriptToCacheTag(business, properties.getRelatedScriptMap());
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return list;
+		});
+	}
+
+	public static class Wo extends AbstractWo {
+
+		private static final long serialVersionUID = -4090679604631097945L;
+
+		private String formId;
+
+		private String readFormId;
+
+		private String cacheTag;
+
+		public String getFormId() {
+			return formId;
+		}
+
+		public void setFormId(String formId) {
+			this.formId = formId;
+		}
+
+		public String getReadFormId() {
+			return readFormId;
+		}
+
+		public void setReadFormId(String readFormId) {
+			this.readFormId = readFormId;
+		}
+
+		public String getCacheTag() {
+			return cacheTag;
+		}
+
+		public void setCacheTag(String cacheTag) {
+			this.cacheTag = cacheTag;
+		}
+
+	}
+
+}

+ 194 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/form/V2LookupDocMobile.java

@@ -0,0 +1,194 @@
+package com.x.cms.assemble.control.jaxrs.form;
+
+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.cache.Cache.CacheKey;
+import com.x.base.core.project.cache.CacheManager;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+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.cms.assemble.control.Business;
+import com.x.cms.core.entity.CategoryInfo;
+import com.x.cms.core.entity.Document;
+import com.x.cms.core.entity.element.Form;
+import com.x.cms.core.entity.element.FormProperties;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import java.util.zip.CRC32;
+
+class V2LookupDocMobile extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(V2LookupDocMobile.class);
+
+	private Form form = null;
+	private Form readForm = null;
+	private Wo wo = new Wo();
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String docId) throws Exception {
+
+		ActionResult<Wo> result = new ActionResult<>();
+
+		this.getDocForm(docId);
+
+		String formId = "";
+		String readFormId = "";
+		if (null != this.form) {
+			formId = form.getId();
+			this.wo.setFormId(formId);
+		}
+		if (null != this.readForm) {
+			readFormId = readForm.getId();
+			this.wo.setReadFormId(readFormId);
+		}
+		if(StringUtils.isNotEmpty(formId) || StringUtils.isNotEmpty(readFormId)){
+			CacheKey cacheKey = new CacheKey(this.getClass(), formId, readFormId);
+			Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
+			if (optional.isPresent()) {
+				this.wo = (Wo) optional.get();
+			} else {
+				List<String> list = new ArrayList<>();
+				if (null != this.form) {
+					CompletableFuture<List<String>> relatedFormFuture = this.relatedFormFuture(this.form.getProperties());
+					CompletableFuture<List<String>> relatedScriptFuture = this
+							.relatedScriptFuture(this.form.getProperties());
+					list.add(this.form.getId() + this.form.getUpdateTime().getTime());
+					list.addAll(relatedFormFuture.get(10, TimeUnit.SECONDS));
+					list.addAll(relatedScriptFuture.get(10, TimeUnit.SECONDS));
+				}
+				if (null != this.readForm && !formId.equals(readFormId)) {
+					CompletableFuture<List<String>> relatedFormFuture = this.relatedFormFuture(this.readForm.getProperties());
+					CompletableFuture<List<String>> relatedScriptFuture = this
+							.relatedScriptFuture(this.readForm.getProperties());
+					list.add(this.readForm.getId() + this.readForm.getUpdateTime().getTime());
+					list.addAll(relatedFormFuture.get(10, TimeUnit.SECONDS));
+					list.addAll(relatedScriptFuture.get(10, TimeUnit.SECONDS));
+				}
+				list = list.stream().sorted().collect(Collectors.toList());
+				CRC32 crc = new CRC32();
+				crc.update(StringUtils.join(list, "#").getBytes());
+				this.wo.setCacheTag(crc.getValue() + "");
+				CacheManager.put(cacheCategory, cacheKey, wo);
+			}
+		}
+		result.setData(wo);
+		return result;
+	}
+
+	private void getDocForm(String docId) throws Exception {
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			Business business = new Business(emc);
+			Document document = emc.fetch(docId, Document.class, ListTools.toList(JpaObject.id_FIELDNAME, Document.form_FIELDNAME,
+					Document.readFormId_FIELDNAME, Document.categoryId_FIELDNAME));
+			if (null != document) {
+				String formId = document.getForm();
+				String readFormId = document.getReadFormId();
+				if(StringUtils.isNotBlank(formId)) {
+					this.form = business.getFormFactory().pick(formId);
+				}
+				if (null == this.form) {
+					CategoryInfo categoryInfo = business.getCategoryInfoFactory().pick(document.getCategoryId());
+					if (null != categoryInfo) {
+						formId = categoryInfo.getFormId();
+						this.form = business.getFormFactory().pick(formId);
+					}
+				}
+				if(StringUtils.isNotBlank(readFormId)) {
+					if(readFormId.equals(formId)){
+						this.readForm = this.form;
+					}else {
+						this.readForm = business.getFormFactory().pick(formId);
+					}
+				}
+				if (null == this.readForm) {
+					CategoryInfo categoryInfo = business.getCategoryInfoFactory().pick(document.getCategoryId());
+					if (null != categoryInfo) {
+						readFormId = categoryInfo.getReadFormId();
+						this.readForm = business.getFormFactory().pick(readFormId);
+					}
+				}
+			}
+		}
+	}
+
+	private CompletableFuture<List<String>> relatedFormFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<String> list = new ArrayList<>();
+			if (ListTools.isNotEmpty(properties.getMobileRelatedFormList())) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					Form f;
+					for (String id : properties.getMobileRelatedFormList()) {
+						f = emc.fetch(id, Form.class, ListTools.toList(JpaObject.id_FIELDNAME, JpaObject.updateTime_FIELDNAME));
+						if (null != f) {
+							list.add(f.getId() + f.getUpdateTime().getTime());
+						}
+					}
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return list;
+		});
+	}
+
+	private CompletableFuture<List<String>> relatedScriptFuture(FormProperties properties) {
+		return CompletableFuture.supplyAsync(() -> {
+			List<String> list = new ArrayList<>();
+			if ((null != properties.getMobileRelatedScriptMap()) && (properties.getMobileRelatedScriptMap().size() > 0)) {
+				try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+					Business business = new Business(emc);
+					list = convertScriptToCacheTag(business, properties.getMobileRelatedScriptMap());
+				} catch (Exception e) {
+					logger.error(e);
+				}
+			}
+			return list;
+		});
+	}
+
+	public static class Wo extends AbstractWo {
+
+		private static final long serialVersionUID = -955543425744298907L;
+
+		private String formId;
+
+		private String readFormId;
+
+		private String cacheTag;
+
+		public String getFormId() {
+			return formId;
+		}
+
+		public void setFormId(String formId) {
+			this.formId = formId;
+		}
+
+		public String getReadFormId() {
+			return readFormId;
+		}
+
+		public void setReadFormId(String readFormId) {
+			this.readFormId = readFormId;
+		}
+
+		public String getCacheTag() {
+			return cacheTag;
+		}
+
+		public void setCacheTag(String cacheTag) {
+			this.cacheTag = cacheTag;
+		}
+
+	}
+
+}

+ 57 - 1
o2server/x_cms_core_entity/src/main/java/com/x/cms/core/entity/element/Form.java

@@ -12,6 +12,7 @@ import javax.persistence.Table;
 import javax.persistence.UniqueConstraint;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.openjpa.persistence.Persistent;
 import org.apache.openjpa.persistence.jdbc.Index;
 
 import com.x.base.core.entity.AbstractPersistenceProperties;
@@ -23,6 +24,7 @@ import com.x.base.core.entity.annotation.ContainerEntity;
 import com.x.base.core.project.annotation.FieldDescribe;
 import com.x.cms.core.entity.AppInfo;
 import com.x.cms.core.entity.PersistenceProperties;
+import org.apache.openjpa.persistence.jdbc.Strategy;
 
 @Entity
 @ContainerEntity(dumpSize = 5, type = ContainerEntity.Type.content, reference = ContainerEntity.Reference.strong)
@@ -53,6 +55,39 @@ public class Form extends SliceJpaObject {
 		this.editor = StringUtils.trimToEmpty(this.editor);
 	}
 
+	public Form() {
+		this.properties = new FormProperties();
+	}
+
+	public FormProperties getProperties() {
+		if (null == this.properties) {
+			this.properties = new FormProperties();
+		}
+		return this.properties;
+	}
+
+	public void setProperties(FormProperties properties) {
+		this.properties = properties;
+	}
+
+	public String getDataOrMobileData() {
+		if (StringUtils.isNotEmpty(this.getData())) {
+			return this.getData();
+		} else if (StringUtils.isNotEmpty(this.getMobileData())) {
+			return this.getMobileData();
+		}
+		return null;
+	}
+
+	public String getMobileDataOrData() {
+		if (StringUtils.isNotEmpty(this.getMobileData())) {
+			return this.getMobileData();
+		} else if (StringUtils.isNotEmpty(this.getData())) {
+			return this.getData();
+		}
+		return null;
+	}
+
 	/* 以上为 JpaObject 默认字段 */
 
 	/* 更新运行方法 */
@@ -67,6 +102,7 @@ public class Form extends SliceJpaObject {
 	@FieldDescribe("表单别名.")
 	@Column(length = AbstractPersistenceProperties.processPlatform_name_length, name = ColumnNamePrefix
 			+ alias_FIELDNAME)
+	@Index(name = TABLE + IndexNameMiddle + alias_FIELDNAME)
 	private String alias;
 
 	public static final String description_FIELDNAME = "description";
@@ -103,6 +139,19 @@ public class Form extends SliceJpaObject {
 	@Column(length = JpaObject.length_10M, name = ColumnNamePrefix + mobileData_FIELDNAME)
 	private String mobileData;
 
+	public static final String hasMobile_FIELDNAME = "hasMobile";
+	@FieldDescribe("是否有移动端内容.")
+	@Column(name = ColumnNamePrefix + hasMobile_FIELDNAME)
+	private Boolean hasMobile;
+
+	public static final String properties_FIELDNAME = "properties";
+	@FieldDescribe("属性对象存储字段.")
+	@Persistent(fetch = FetchType.EAGER)
+	@Strategy(JsonPropertiesValueHandler)
+	@Column(length = JpaObject.length_10M, name = ColumnNamePrefix + properties_FIELDNAME)
+	@CheckPersist(allowEmpty = true)
+	private FormProperties properties;
+
 	public String getName() {
 		return name;
 	}
@@ -159,4 +208,11 @@ public class Form extends SliceJpaObject {
 		this.alias = alias;
 	}
 
-}
+	public Boolean getHasMobile() {
+		return hasMobile;
+	}
+
+	public void setHasMobile(Boolean hasMobile) {
+		this.hasMobile = hasMobile;
+	}
+}

+ 57 - 0
o2server/x_cms_core_entity/src/main/java/com/x/cms/core/entity/element/FormProperties.java

@@ -0,0 +1,57 @@
+package com.x.cms.core.entity.element;
+
+import com.x.base.core.entity.JsonProperties;
+import com.x.base.core.project.annotation.FieldDescribe;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class FormProperties extends JsonProperties {
+
+	@FieldDescribe("关联表单.")
+	private List<String> relatedFormList = new ArrayList<>();
+
+	@FieldDescribe("移动端关联表单.")
+	private List<String> mobileRelatedFormList = new ArrayList<>();
+
+	@FieldDescribe("关联脚本.")
+	private Map<String, String> relatedScriptMap = new LinkedHashMap<>();
+
+	@FieldDescribe("移动端关联脚本.")
+	private Map<String, String> mobileRelatedScriptMap = new LinkedHashMap<>();
+
+	public List<String> getRelatedFormList() {
+		return this.relatedFormList == null ? new ArrayList<>() : this.relatedFormList;
+	}
+
+	public List<String> getMobileRelatedFormList() {
+		return this.mobileRelatedFormList == null ? new ArrayList<>() : this.mobileRelatedFormList;
+	}
+
+	public Map<String, String> getRelatedScriptMap() {
+		return this.relatedScriptMap == null ? new LinkedHashMap<>() : this.relatedScriptMap;
+	}
+
+	public Map<String, String> getMobileRelatedScriptMap() {
+		return this.mobileRelatedScriptMap == null ? new LinkedHashMap<>() : this.mobileRelatedScriptMap;
+	}
+
+	public void setRelatedFormList(List<String> relatedFormList) {
+		this.relatedFormList = relatedFormList;
+	}
+
+	public void setMobileRelatedFormList(List<String> mobileRelatedFormList) {
+		this.mobileRelatedFormList = mobileRelatedFormList;
+	}
+
+	public void setRelatedScriptMap(Map<String, String> relatedScriptMap) {
+		this.relatedScriptMap = relatedScriptMap;
+	}
+
+	public void setMobileRelatedScriptMap(Map<String, String> mobileRelatedScriptMap) {
+		this.mobileRelatedScriptMap = mobileRelatedScriptMap;
+	}
+
+}