本文介绍了一个分页报表取数WebApi接口的使用说明。首先,需要新建一个过滤方案,因为默认方案无法保存元数据。其次,介绍了查询过滤方案FSCHEMEID的四种方式。然后,说明了准备接口参数的方法,包括快捷过滤条件和高级过滤条件的设置,并给出了参数示例。
接口地址:
http://{服务器地址}/k3cloud/Kingdee.K3.SCM.WebApi.ServicesStub.StockReportQueryService.GetReportData,Kingdee.K3.SCM.WebApi.ServicesStub.common.kdsvc
接口说明:分页报表取数WebApi接口说明
调用接口步骤
一、新建过滤方案
由于默认过滤方案没有保存元数据,无法对相应字段进行赋值,因此不能使用默认方案作为API接口的过滤方案,建议单独给API创建一个过滤方案使用。过滤方案建议把固定的条件以及常用条件设置好,传入接口的参数会覆盖过滤方案原有值,不传则不会覆盖。
二、查询过滤方案FSCHEMEID
方式一:到数据库中直接查询
SELECT FSCHEMEID,FSCHEMENAME FROM T_BAS_FILTERSCHEME WHERE FFORMID='STK_InvAgeAnalyzeRpt'
方式二:通过BOS设计器新增一个SQL直接账表查询
方式三:通过BOS设计器导入导出数据方式查询
方式四:通过系统自带的http监控数据方式查询
三、准备接口参数
只有需要修改过滤方案中自带的条件才需要填写相应的字段,比如过滤方案默认是过滤全部物料,接口中如果传了物料字段则会给物料条件赋值,过滤指定的物料。
快捷过滤条件用的是快捷页签以及选项页签中的条件:
单选按钮赋值取所在单选按钮组的绑定属性以及枚举值:
高级过滤取条件以及高级页签中的字段标识:
参数示例:
FieldKeys是返回字段,留空时返回所有
{ "parameters": [ { "FORMID": "STK_InvAgeAnalyzeRpt", "FSCHEMEID": "62c4091c8f9a53", "QuicklyCondition": [ { "FieldName": "StockOrgId",/*库存组织比较特殊,需要传库存组织內码ID*/ "FieldValue": "100001,100002,100005,100006,100003,100004" }, { "FieldName": "MaterialFrom", "FieldValue": "052601" }, { "FieldName": "MaterialTo", "FieldValue": "052601" }, { "FieldName": "QueryGroup",/*单选按钮赋值需要取所在单选按钮组的绑定属性和枚举值*/ "FieldValue": "History" }, { "FieldName": "QueryDate", "FieldValue": "2022-07-05" }, { "FieldName": "InvAgeEntity",/*单据体赋值是一个字符串*/ "FieldValue": "[{\"IntervalTxt\": \"0到30天\", \"DownDay\": 0, \"IntervalDay\": 30, \"UpperDay\": 30}, {\"IntervalTxt\": \"30到60天\", \"DownDay\": 30, \"IntervalDay\": 30, \"UpperDay\": 60}, {\"IntervalTxt\": \"60天以上\", \"DownDay\": 60, \"IntervalDay\": 0, \"UpperDay\": 0}]" } ], "MoreCondition": [/*高级过滤中,FieldName使用的是字段标识*/ { "Left": "(", "FieldName": "FMaterialNumber", "Compare": "=", "FieldValue": "052601", "Right": ")", "Logic": "AND" }, { "Left": "(", "FieldName": "FMaterialNumber", "Compare": "=", "FieldValue": "052601", "Right": ")", "Logic": "AND" } ], "StartRow": 1, "Limit": 3, "CurQueryId": "",/*用于分页查询,仅在分页取数时使用。使用了CurQueryId,则不再使用过滤条件,而是根据首次查询结果取指定索引范围内的数据*/ "FieldKeys": "FSTOCKORGID,FStockOrgNumber,FMATERIALID,FMATERIALNUMBER,FSTOCKSTATUSNAME,FOWNERTYPENAME,FBASEQTY,FAGEDAYS" } ] }
取第二页数据参数,注意CurQueryId,传了上一次返回的值(如果是一次新的查询,也就是不想使用上次结果,则不用填写CurQueryId),此时只会从首次查询结果中取指定索引范围内的数据,不在应用过滤条件。
{ "parameters": [ { "FORMID": "STK_InvAgeAnalyzeRpt", "FSCHEMEID": "62c4091c8f9a53", "QuicklyCondition": [ { "FieldName": "StockOrgId", "FieldValue": "100001,100002,100005,100006,100009,100003,100004" }, { "FieldName": "MaterialFrom", "FieldValue": "052601" }, { "FieldName": "MaterialTo", "FieldValue": "052601" }, { "FieldName": "QueryGroup", "FieldValue": "History" }, { "FieldName": "QueryDate", "FieldValue": "2022-07-05" }, { "FieldName": "InvAgeEntity", "FieldValue": "[{\"IntervalTxt\": \"0到30天\", \"DownDay\": 0, \"IntervalDay\": 30, \"UpperDay\": 30}, {\"IntervalTxt\": \"30到60天\", \"DownDay\": 30, \"IntervalDay\": 30, \"UpperDay\": 60}, {\"IntervalTxt\": \"60天以上\", \"DownDay\": 60, \"IntervalDay\": 0, \"UpperDay\": 0}]" } ], "MoreCondition": [ { "Left": "(", "FieldName": "FMaterialNumber", "Compare": "=", "FieldValue": "052601", "Right": ")", "Logic": "AND" }, { "Left": "(", "FieldName": "FMaterialNumber", "Compare": "=", "FieldValue": "052601", "Right": ")", "Logic": "AND" } ], "StartRow": 4, "Limit": 3, "CurQueryId": "DADBB3BF602111ED91A50050569", "FieldKeys": "FSTOCKORGID,FStockOrgNumber,FMATERIALID,FMATERIALNUMBER,FSTOCKSTATUSNAME,FOWNERTYPENAME,FBASEQTY,FAGEDAYS" } ] }
使用金蝶SDK调用示例:
参考资料路径:
1)网址:https://openapi.open.kingdee.com/ApiDoc
2)路径:API文档->供应链->库存管理->分页报表取数,如下图:
四、查询结果
{ "success": true, "message": "查询成功", "CurQueryId": "DADBB3BF602111ED91A50050569", "data": [ { "FSTOCKORGID": 100003, "FStockOrgNumber": "101.2", "FMATERIALID": 128635, "FMATERIALNUMBER": "052601", "FSTOCKSTATUSNAME": "可用", "FOWNERTYPENAME": "客户", "fbaseqty": 0.0000000000, "FAGEDAYS": "10日以上" }, { "FSTOCKORGID": 100003, "FStockOrgNumber": "101.2", "FMATERIALID": 128635, "FMATERIALNUMBER": "052601", "FSTOCKSTATUSNAME": "可用", "FOWNERTYPENAME": "业务组织", "fbaseqty": 536.0000000000, "FAGEDAYS": "10日以上" }, { "FSTOCKORGID": 100003, "FStockOrgNumber": "101.2", "FMATERIALID": 128635, "FMATERIALNUMBER": "052601", "FSTOCKSTATUSNAME": "可用", "FOWNERTYPENAME": "业务组织", "fbaseqty": 10.0000000000, "FAGEDAYS": "10日以上" } ], "TotalCount": 6 }
推荐阅读