68、WebApi,批量保存,接口原创
金蝶云社区-林荫大道cc
林荫大道cc
8人赞赏了该文章 8140次浏览 未经作者许可,禁止转载编辑于2021年06月22日 13:45:58
封面

业务场景:使用WebApi,同时保存3张采购订单


 1、操作步骤 和 66.1 类似


2、拖一个按钮,批量保存


3、修改按钮名字


image.png



4、双击按钮进去,自动生成代码


5、复制代码到按钮


6、把Save 改成对应的操作


       批量保存:BatchSave


        //批量保存
        private void button10_Click(object sender, EventArgs e)
        {
            if (LogIn() == 1)
            {
                this.textBox2.Text = client.BatchSave("PUR_PurchaseOrder", this.textBox1.Text);
            }
            else
            {
                this.textBox2.Text = "登录失败";
            }
        }


7、下面操作步骤 和 66.2 类似


8、输入Json,点批量保存按钮,保存3张采购订单

{
    "NeedUpDateFields": [],
    "BatchCount": "2",
    "Model": [
        {
            "FBillTypeID": {
                "FNUMBER": "CGDD01_SYS"
            },
            "FDate": "2020-07-18",
            "FSupplierId": {
                "FNumber": "001"
            },
            "FPurchaseOrgId": {
                "FNumber": "100"
            },
            "FPOOrderFinance": {
                "FSettleCurrId": {
                    "FNumber": "PRE001"
                },
                "FEXCHANGETYPEID": {
                    "FNumber": "HLTX01_SYS"
                },
                "FEXCHANGERATE": 1
            },
            "FPOOrderEntry": [
                {
                    "FMaterialId": {
                        "FNumber": "001"
                    },
                    "FPriceUnitId": {
                        "FNumber": "Pcs"
                    },
                    "FQty": 300.0,
                    "FTaxPrice": 10,
                    "FEntryTaxRate": 17.00
                }
            ]
        },
        {
            "FBillTypeID": {
                "FNUMBER": "CGDD01_SYS"
            },
            "FDate": "2020-07-18",
            "FSupplierId": {
                "FNumber": "001"
            },
            "FPurchaseOrgId": {
                "FNumber": "100"
            },
            "FPOOrderFinance": {
                "FSettleCurrId": {
                    "FNumber": "PRE001"
                },
                "FEXCHANGETYPEID": {
                    "FNumber": "HLTX01_SYS"
                },
                "FEXCHANGERATE": 1
            },
            "FPOOrderEntry": [
                {
                    "FMaterialId": {
                        "FNumber": "001"
                    },
                    "FPriceUnitId": {
                        "FNumber": "Pcs"
                    },
                    "FQty": 300.0,
                    "FTaxPrice": 10,
                    "FEntryTaxRate": 17.00
                }
            ]
        },
        {
            "FBillTypeID": {
                "FNUMBER": "CGDD01_SYS"
            },
            "FDate": "2020-07-18",
            "FSupplierId": {
                "FNumber": "001"
            },
            "FPurchaseOrgId": {
                "FNumber": "100"
            },
            "FPOOrderFinance": {
                "FSettleCurrId": {
                    "FNumber": "PRE001"
                },
                "FEXCHANGETYPEID": {
                    "FNumber": "HLTX01_SYS"
                },
                "FEXCHANGERATE": 1
            },
            "FPOOrderEntry": [
                {
                    "FMaterialId": {
                        "FNumber": "001"
                    },
                    "FPriceUnitId": {
                        "FNumber": "Pcs"
                    },
                    "FQty": 300.0,
                    "FTaxPrice": 10,
                    "FEntryTaxRate": 17.00
                }
            ]
        }
    ]
}


image.png


image.png



image.png


image.png


image.png



9、添加批量提交审核


"IsAutoSubmitAndAudit":true,


image.png


image.png


WebApi批量保存接口


 1.     调用的方法 client.BatchSave

 2.     json格式


{
       "NumberSearch": "true",
       "ValidateFlag": "true",
       "IsDeleteEntry": "true",
       "IsEntryBatchFill": "true",
       "NeedUpDateFields": [],
       "NeedReturnFields": [],
       "SubSystemId": "",
       "InterationFlags": "",
       "IsAutoSubmitAndAudit": "false",
       "Model": [],
       "BatchCount": 0
}

 


请求参数说明:


  1. formid:业务对象表单Id,字符串类型(必录)

  2. data:JSON格式数据(详情参考JSON格式数据)(必录)


     2.1.NumberSearch:是否用编码搜索基础资料,布尔类型,默认true(非必录)

     2.2.ValidateFlag:是否验证标志,布尔类型,默认true(非必录)

     2.3.IsDeleteEntry:是否删除已存在的分录,布尔类型,默认true(非必录)

     2.4.IsEntryBatchFill:是否批量填充分录,默认true(非必录)


     2.5.NeedUpDateFields:需要更新的字段,数组类型,格式:[key1,key2,...](非必录) 

                                            注(更新单据体字段得加上单据体key)


     2.6.NeedReturnFields:需返回结果的字段集合,数组类型,格式:[key,entitykey.key,...](非必录)  

                                           注(返回单据体字段格式:entitykey.key)


     2.7.SubSystemId:表单所在的子系统内码,字符串类型(非必录)


     2.8.InterationFlags:交互标志集合,字符串类型,分号分隔,格式:"flag1;flag2;..."(非必录),

                                      例如(允许负库存标识:STK_InvCheckResult)


     2.9.IsAutoSubmitAndAudit:是否自动提交与审核,布尔类型,默认false(非必录) 

                                                   注(启用此参数,保存,提交和审核是在一个事务中)


     2.10.Model:表单数据包,JSON类型(必录) 

                          注(1.数据包包含所有允许引入的字段,实际按需构建 2.如需创建关联关系)可参考


     2.11.BatchCount:服务端开启的线程数,整型(非必录) 注(数据包数应大于此值,否则无效。)


image.png

视频下载链接:

链接:https://pan.baidu.com/s/1f8Z3-qwGFJrKGKbkoWY2vA

提取码:KISS 



总目录链接

https://vip.kingdee.com/article/649938720145912

68.zip(284.26KB)

赞 8