蓝凌EKP产品:优化业务文档可阅读者可编辑者权限更新性能

发布于:2025-07-23 ⋅ 阅读:(14) ⋅ 点赞:(0)

EKP里面业务文档都会有自己的权限字段如 authReaders、authEditors 等常为集合类型,当每一次涉及到权限变动,都会对业务文档的所有authReaders,authEditors 集合属性做权限更新,导致性能大量消耗。现在针对此处做相关优化,提供了基于 Hibernate 的增量计算机制,不对集合做权限做全量更新,只做增量更新,提升 update 效率。具体如下:

一、配置懒加载集合类型

hbm.xml 示例:
		<!-- 所有可阅读者-->
		<bag
			name="authAllReaders"
			table="modeling_model_main_areader"
			collection-type="com.landray.kmss.sys.right.hibernate.spi.type.AuthBagType"
			lazy="extra">
			<key
				column="fd_main_id" />
			<many-to-many
				class="com.landray.kmss.sys.organization.model.SysOrgElement"
				column="auth_all_reader_id" />
		</bag>

    		<!-- 传阅机制 -->
    		<bag
    				name="authTemporary"
    				inverse="true"
    				cascade="all-delete-orphan"
    				collection-type="com.landray.kmss.sys.right.hibernate.spi.type.TemporaryAuthBagType"
    				lazy="extra">
    			<key
    					column="fd_model_id" />
    			<one-to-many
    					class="com.landray.kmss.sys.modeling.main.model.ModelingAppModelAuthMain"/>
    		</bag>
      • AuthBagType:用于 List
      • TemporaryAuthBagType:用于 List

      二、改造主文档 Model

      重写以下方法:

      	public Map<String,AuthPredicate>  getAllReaderRelatedPredicate() {
      		if(allReaderRelatedPredicate!=null){
      			return allReaderRelatedPredicate;
      		}
      		//用父类的结果初始化
      		allReaderRelatedPredicate = new LinkedHashMap<>(super.getAllReaderRelatedPredicate());
      		//在补充业务自己的内容
      		//业务用户指派
      		allReaderRelatedPredicate.put("authBusReaders", ModelMainAuthBusReaderPredicate.INSTANCE);
      		allReaderRelatedPredicate.put("authTemporary", AlwaysTrueAuthPredicate.INSTANCE);
      
      		return allReaderRelatedPredicate;
      	}

      三、改造主文档Form绑定方式

      // 原写法

      formToModelPropertyMap.put("authReaderIds", 
      new FormConvertor_IDsToModelList("authReaders", SysOrgElement.class));


      // 替换为增量绑定方式
       

      	toModelPropertyMap.put("authReaderIds",
      					new FormPartiallyConvertor_IDsToModelList("authReaders",
      							SysOrgElement.class));
      

      四、使用建议

      • 避免使用 clear() 清空集合,可用 remove + iterator 替代
      • 可暂时从 getAllReaderRelatedPredicate() 中移除不相关字段控制 update 范围

      五、总结

              此优化对于流程流转过程中涉及到权限经常变动或者其他权限联动等高频更新场景效果显著,由此更新业务文档操作性能将大大提升。


      网站公告

      今日签到

      点亮在社区的每一天
      去签到