10.MES系统访问金蝶云星空(ERP):批量查询物料库存
2020-03-29 本文已影响0人
Steve_Hu
返回根目录 MES系统访问金蝶云星空(ERP)的接口定义及示例
需求描述
按照物料代码和仓库查询库存,
物料代码是任务的物料代码,
返回物料代码、物料名称和对应仓库的库存数量。
接口定义
批量查询物料库存接口(自定义webapi接口)的定义如下:
//其中BLN.CY.ApiClient.K3Cloud.Stub是命名空间,PrdInStockService是类名
BLN.CY.ApiClient.K3Cloud.Stub.StockService.FindInvStock(string param)
请求参数
[{
"MaterialNumber": "0001",
"StockNumber": "01"
},
{
"MaterialNumber": "0002",
"StockNumber": "02"
}]
返回结果
{
"IsSuccess": true,
"Message": null,
"ErrorStackTrace": null,
"Value": [{
"MaterialId": 100232,
"StockId": 101250,
"MaterialNumber": "1.02.001.0004",
"StockNumber": "CK001",
"Qty": 19885.0000000000,
"MaterialName": "屏幕"
}, {
"MaterialId": 100465,
"StockId": 101253,
"MaterialNumber": "S1.06",
"StockNumber": "CK003",
"Qty": 22.0000000000,
"MaterialName": "智能手机-6S"
}]
}
代码示例
无引用组件示例(不引用金蝶的组件):
http://ServerIp/K3Cloud/接口命名空间.接口实现类名.方法,组件名.common.kdsvc
if (LoginByAppSecret())
{
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://localhost/k3cloud/BLN.CY.ApiClient.K3Cloud.Stub.StockService.FindInvStock,BLN.CY.ApiClient.K3Cloud.Stub.common.kdsvc";
List<FindInvStockParameter> invStockParameterLst = new List<FindInvStockParameter>();
invStockParameterLst.Add(new FindInvStockParameter {
MaterialNumber= "S1.06",
StockNumber= "CK003"
});
invStockParameterLst.Add(new FindInvStockParameter
{
MaterialNumber = "1.02.001.0004",
StockNumber = "CK001"
});
List<object> parameters = new List<object>();
parameters.Add(invStockParameterLst);
httpClient.Content = JsonConvert.SerializeObject(parameters);
var result = httpClient.AsyncRequest();
}
查询库存参数实体定义
[Serializable]
public class FindInvStockParameter
{
/// <summary>
/// 物料编码
/// </summary>
public string MaterialNumber { get; set; }
/// <summary>
///仓编码
/// </summary>
public string StockNumber { get; set; }
}