01 MES系统访问金蝶云星空(WebApi集成方式):读取BOM数据接口

返回根目录 MES系统访问金蝶云星空(ERP)的接口定义及示例

接口定义:

 /// 查询
        /// 
        /// 
        public List ExecuteBillQuery(string data)
 
 

请求参数:

{
    "FormId": "ENG_BOM",//物料清单唯一标识
    "FieldKeys": "FID,FNumber,FMaterialId.FNumber,FMaterialId.FName,FMATERIALIDCHILD.FNumber,FMATERIALIDCHILD.FName,FCHILDUNITID.FNumber,FNUMERATOR,FDENOMINATOR",//物料清单字段信息
    "FilterString": "FDocumentStatus='C'",//已审核的BOM
    "OrderString": "",
    "TopRowCount": 0,
    "StartRow": 0,
    "Limit": 0
}

返回结果:

[
    [100347, 1, "004", "测试零件1", " ", "010", "原材料1", " ", "Pcs", 1.0, 1.0],
    [100348, 1, "005", "测试零件2", " ", "011", "测试原材料2", " ", "Pcs", 1.0, 1.0],
    [100349, 1, "002", "测试部件1", " ", "004", "测试零件1", " ", "Pcs", 1.0, 1.0],
    [100350, 1, "003", "测试部件2", " ", "005", "测试零件2", " ", "Pcs", 1.0, 1.0],
    [100351, 1, "001", "测试产品", " ", "002", "测试部件1", " ", "Pcs", 1.0, 1.0],
    [100351, 2, "001", "测试产品", " ", "010", "原材料1", " ", "Pcs", 15.0, 1.0]
]

代码示例:

1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll)
引用组件Kingdee.BOS.WebApi.Client.dll
下载链接: https://pan.baidu.com/s/1RthbrrtUgeqWGi-eLM-yjg
提取码: eqin

 if (LoginByAppSecret())
            {
                var dataObj = new
                {
                    FormId = "ENG_BOM",//物料清单唯一标识
                    FieldKeys = GetBomFieldKeys(),//需查询的字段key集合,字符串类型,格式:"key1,key2,..."(必录) 注(查询单据体内码,需加单据体Key和下划线,如:FEntryKey_FEntryId)
                    FilterString = "FDocumentStatus='C'",//获取已经审核BOM
                    OrderString = "",//排序
                    TopRowCount = 0,
                    StartRow = 0,
                    Limit = 0
                };
                var data = JsonConvert.SerializeObject(dataObj);
                var result = apiClient.ExecuteBillQuery(data);

                return JsonConvert.SerializeObject(result);
            }
            else
            {
                return "登录失败!";
            }

2)无引用组件示例(不引用金蝶的组件):
http://ServerIp/K3Cloud/接口命名空间.接口实现类名.方法,组件名.common.kdsvc

if (LoginByAppSecret())
            {
                HttpClient httpClient = new HttpClient();
                httpClient.Url = "http://localhost/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
                var dataObj = new
                {
                    FormId = "ENG_BOM",//物料清单唯一标识
                    FieldKeys = GetBomFieldKeys(),//需查询的字段key集合,字符串类型,格式:"key1,key2,..."(必录) 注(查询单据体内码,需加单据体Key和下划线,如:FEntryKey_FEntryId)
                    FilterString = "FDocumentStatus='C'",//获取已经审核BOM
                    OrderString = "",//排序
                    TopRowCount = 0,
                    StartRow = 0,
                    Limit = 0
                };
                List parameters = new List();
                parameters.Add(dataObj);
                var data = JsonConvert.SerializeObject(parameters);
                httpClient.Content = data;

                var result = httpClient.AsyncRequest();

                return result;
            }
            else
            {
                return "登录失败!";
            }
 
 
 private string GetBomFieldKeys()
        {
            List fieldKeys = new List();
            fieldKeys.Add("FID");//内码
            fieldKeys.Add("FTreeEntity_FSeq");//行号
            fieldKeys.Add("FTreeEntity_FEntryId");//分录内码
            fieldKeys.Add("FMaterialId.FNumber");//父项物料编码
            fieldKeys.Add("FMaterialId.FName");//父项物料名称
            fieldKeys.Add("FMaterialId.Fspecification");//父项规格型号

            fieldKeys.Add("FMATERIALIDCHILD.FNumber");//子项物料编码
            fieldKeys.Add("FMATERIALIDCHILD.FName");//子项物料名称
            fieldKeys.Add("FMATERIALIDCHILD.Fspecification");//子项规格型号
            fieldKeys.Add("FUnitId.FNumber");//子项物料计量单位
            fieldKeys.Add("FNUMERATOR");//分子用量
            fieldKeys.Add("FDENOMINATOR");//分母用量

            return string.Join(",", fieldKeys.ToArray());
        }

返回根目录 MES系统访问金蝶云星空(ERP)的接口定义及示例

你可能感兴趣的:(01 MES系统访问金蝶云星空(WebApi集成方式):读取BOM数据接口)