【业务流程】--通过接口取关联数据原创
金蝶云社区-eris
eris
13人赞赏了该文章 2086次浏览 未经作者许可,禁止转载编辑于2023年11月20日 16:35:37

说明

1、关联数据是由平台统一维护的,因为存在归档和压缩,取出来比较麻烦的,故提供了统一接口。

2、接口把所有关联流程实例数据放到临时表中,以返回临时表的形式供使用。

3、默认返回的临时表包括

1)TmpTableMasterIds 根流程实例内码

2)TmpTableInst 流程实例内码

3)TmpTableEntry 流程实例节点

4)TmpTableAmount 控制字段反写分配量。

5、由于上面临时表并不是所有业务都需要,一般只会用到流程实例节点,为此在2020年4月2号的版本(PT-146832 [7.5.1604.4])做了优化,可以使用传入参数控制取那些临时表,具体控制方式,参考示例代码。

6、由于业务流程实例数据越来越多,接口存在一定的性能问题,因此最好不要把调出此接口的代码放在事务中。

7、事务中嵌套多个会话事务,多个会话事务都创建相同的临时表,那么要主动删除临时表,否则就会报错。

示例代码

下面查询采购订单的上游单据为例

using System;

using System.Data;

using System.ComponentModel;

using System.Collections.Generic;

using Kingdee.BOS.Core;

using Kingdee.BOS.Util;

using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;

using Kingdee.BOS.Core.Bill.PlugIn;

using Kingdee.BOS.App.Data;

using Kingdee.BOS.Contracts;

using Kingdee.BOS.Core.BusinessFlow.ServiceArgs

using Kingdee.BOS.ServiceHelper;

using (SessionScope scope = new SessionScope())

{

//构建参数,假设参数为:

//采购订单formid:PUR_PurchaseOrder, 明细实体key:FPOOrderEntry,明细信息内码集合:new long[] { 100000, 100001 }

 var instArgs = new ReadInstDatasWithHisArgs("PUR_PurchaseOrder", "FPOOrderEntry", new long[] { 100000, 100001 });

//使用参数中的IsGetInst,IsGetEntry,IsGetAmount 属性,分别控制否还回实例表,节点表,携带量临时表。

//假设不需要返回实例表,携带量临时表,则设置为false.

instArgs.IsGetInst = false;

instArgs.IsGetAmount = false;

//web层写法

var instResult = BusinessFlowDataServiceHelper.LoadInstDatasWithHis(this.Context, instArgs);

//app层写法

// BusinessFlowDataService bfService = new BusinessFlowDataService();

// instResult = bfService.LoadInstDatasWithHis(this.Context, instArgs);

//得到关联的采购申请单表名和内码,并使用

var sql = string.Format(@"select FSTableName,FSId from {0} where FTTableName='t_PUR_POOrderEntry' 

                                and FTId in ( 100000, 100001) and FSTableName='T_PUR_ReqEntry'", instResult.TmpTableEntry);

using (IDataReader reader = DBUtils.ExecuteReader(this.Context, sql))

 {

       IList<Schedule> scheduleList = new List<Schedule>();

       while (reader.Read())

        {

           var stbName = Convert.ToString(reader["FSTableName"]);

           var sId = Convert.ToInt64(reader["FSId"]);

         }

}           

//由于上面只需要返回流程节点临时表,则清理临时表时,只需要删除Master和节点临时表

DBUtils.DropSessionTemplateTable(this.Context, instResult.TmpTableMasterIds);

DBUtils.DropSessionTemplateTable(this.Context, instResult.TmpTableEntry);

}

其他

参考贴:取横向输出的关联数据


赞 13