WEB API 生成其它出库单时出错
金蝶云社区-liuxin_438
liuxin_438
0人赞赏了该文章 776次浏览 未经作者许可,禁止转载编辑于2017年02月08日 15:58:05

我通过Web API 保存其它出库时报如下错误,麻烦大神帮忙看看是什么原因引起的,要怎么解决,谢谢!

报错如下:
{"Result":{"ResponseStatus":{"ErrorCode":500,"IsSuccess":false,"Errors":[{"FieldName":"请先录入库存组织(FStockOrgId)的内容(物料编码(FMaterialId))!","Message":" at Kingdee.BOS.Core.Metadata.FieldElement.BaseDataField.ReadUseOrgId(IDynamicFormModel model, DynamicObject activeRow, String& orgId)\r\n at Kingdee.BOS.Core.Metadata.FieldElement.BaseDataField.BuildQueryParemeter(IDynamicFormModel model, DynamicObject activeRow)\r\n at Kingdee.BOS.Model.DynamicForm.DynamicFormModel.LoadFieldDataWithCoreFilter(BatchBaseDataQueryInputParam queryParam)\r\n at Kingdee.BOS.WebApi.FormService.MapPropertyService.DoBatchBaseFieldNumbers(BaseDataField field, Tuple`2 numberInfos, Int32 rowIndex)\r\n at Kingdee.BOS.WebApi.FormService.MapPropertyService.SetBaseDataField(BaseDataField field, DynamicObject targetObject, Object value, Int32 rowIndex)\r\n at Kingdee.BOS.WebApi.FormService.MapPropertyService.MapComplexProperty(String pkProperty, Dictionary`2 sourceObj, DynamicObject targetObj, Int32 rowIndex, HashSet`1 NeedUpDateFields)\r\n at Kingdee.BOS.WebApi.FormService.MapPropertyService.MapCollectionProperty(Entity enity, IList`1 sourceRows, DynamicObjectCollection targetRows, HashSet`1 NeedUpDateFields, String specialReferenceTable)\r\n at Kingdee.BOS.WebApi.FormService.MapPropertyService.MapComplexProperty(String pkProperty, Dictionary`2 sourceObj, DynamicObject targetObj, Int32 rowIndex, HashSet`1 NeedUpDateFields)\r\n at Kingdee.BOS.WebApi.FormService.Save.Revole()\r\n at Kingdee.BOS.WebApi.FormService.Save.Execute()\r\n at Kingdee.BOS.WebApi.FormService.BillOperationService.ExecuteOperation(FormOperation op, String data)","DIndex":0}],"SuccessEntitys":[],"SuccessMessages":[]}}}

jsonRoot 字符串格式及内容如下:
{
"Creator": "三方调用者标识",
"NeedUpDateFields": [
"FBILLNO",
"FBillTypeID",
"FStockOrgId",
"FDate",
"FDocumentStatus",
"FSUPPLIERID",
"FDEPTID",
"FNOTE",
"STK_MISDELIVERY__FEntity",
"FMATERIALID",
"FUnitID",
"FQty",
"FSTOCKID",
"FPrice",
"FAmount",
"FEntryNote",
"FBASEQTY"
],
"Model": {
"FID": 0,
"FBillTypeID": {
"FNumber": "CGDD01_SYS"
},
"FStockOrgId": {
"FNumber": "100"
},
"FSUPPLIERID": {
"FNumber": "007"
},
"FDocumentStatus": "A",
"STK_MISDELIVERY__FEntity": [
{
"FMaterialId": {
"FNumber": "AA2358X001"
},
"FUnitID": {
"FNumber": "Pcs"
},
"FQty": "2.0000000000",
"FBASEQTY": "2.0000000000",
"FStockId": {
"FNumber": "00019_GZW"
}
}
]
}
}

调用方式如下:
public string OtherOutSave()
{
KDLogin login = new KDLogin();
string result = "";

ApiClient client = login.LoginExt();

if (client != null)
{
DataTable otherIns = DBManager.getDataTableFromDB(" select t3.FNUMBER as FMaterialNumber,t6.FNumber as FUnitNumber, t5.FNUMBER as FStockNumber , sum(t1.FQTY ) as FQty from T_STK_ASSEMBLYSUBITEM t1 left join T_STK_INVENTORY t2 on t1.FMATERIALID = t2.FMATERIALID and t2.FQTY > 0 inner join T_BD_MATERIAL t3 on t3.FMATERIALID = t1.FMATERIALID inner join T_BD_MATERIALBASE t4 on t3.FMATERIALID = t4.FMATERIALID inner join T_BD_Unit t6 on t6.FUnitID = t4.FBASEUNITID left join T_BD_STOCK t5 on t5.FSTOCKID = t1.FSTOCKID where t3.FNUMBER='AA2358X001' group by t3.FNUMBER , t5.FNUMBER , t6.FNumber");

if (otherIns == null || otherIns.Rows.Count <= 0)
{
return "没有查询到可生成其它入库单的数据!";
}

for (int i = 0; i < otherIns.Rows.Count; i++)
{

string jsonRoot;
DataRow dr = otherIns.Rows[i];

jsonRoot = GetOtherOutSaveEntry(dr);

System.Console.WriteLine("=其它入库单保存==" + jsonRoot);

// 调用Web API接口服务
result = client.Execute(
"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
new object[] { "STK_MISDELIVERY", jsonRoot });

}
}

return result;
}