二开案例.webapi.根据formid得到表单的entry信息(主键、单据状态字段、单据编号字段、单据类型字段)
该功能可以通过接口的方式获得表单的关键信息,十分有用。
废话不多说直接上代码
using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Core.Metadata.EntityElement; using Kingdee.BOS.ServiceFacade.KDServiceFx; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using Kingdee.BOS.WebApi.ServicesStub; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; namespace scjr.extend.plugin.ly.lyproject { [Kingdee.BOS.Util.HotUpdate] class fdatatowebapidatatable : AbstractWebApiBusinessService { public fdatatowebapidatatable(KDServiceContext context) : base(context) { } private string _formId = string.Empty; private FormMetadata _formMetadata; private JObject _json_info; public object getWebApiData(string param) { try { _json_info = JObject.Parse(param); var ctx = KDContext.Session.AppContext; if (ctx == null) { // 会话超时,需重新登录 return new { isSuccess = false, message = "会话超时,请重新登录" }; } this._formId = String.Format("{0}", _json_info["formid"]); _formMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, _formId); List<Entity> entrys = _formMetadata.BusinessInfo.Entrys; List<object> results = new List<object>(); var bus = _formMetadata.BusinessInfo; foreach (Entity ent in entrys) { if (ent.GetType().Name.EqualsIgnoreCase("HeadEntity")) { results.Add(new { pkname = ent.EntryPkFieldName, tablename = ent.TableName, entryname = ent.EntryName, entrytype = ent.GetType().Name, billnoname = bus.GetBillNoField().Name[2052], billnofieldname = bus.GetBillNoField().FieldName, billstatusname = bus.GetBillStatusField().Name[2052], billstatusfieldname = bus.GetBillStatusField().FieldName, billtypename = bus.GetBillTypeField().Name[2052], billtypefieldname = bus.GetBillTypeField().FieldName }); continue; } results.Add(new { pkname = ent.EntryPkFieldName, tablename = ent.TableName, entryname = ent.EntryName, entrytype = ent.GetType().Name, entrytypeid = ent.EntityType }); } return new { isSuccess = true, message = "", data = results }; } catch (Exception e) { return new { isSuccess = false, message = e.Message }; } } } }
效果如下图:
响应结果:
{
"isSuccess": true,
"message": "",
"data": [
{
"pkname": "FID",
"tablename": "T_STK_STKTRANSFERIN",
"entryname": "STK_STKTRANSFERIN",
"entrytype": "HeadEntity",
"billnoname": "单据编号",
"billnofieldname": "FBILLNO",
"billstatusname": "单据状态",
"billstatusfieldname": "FDOCUMENTSTATUS",
"billtypename": "单据类型",
"billtypefieldname": "FBILLTYPEID"
},
{
"pkname": "FEntryID",
"tablename": "T_STK_STKTRANSFERINENTRY",
"entryname": "STK_STKTRANSFERINENTRY",
"entrytype": "EntryEntity",
"entrytypeid": 1
},
{
"pkname": "FDetailID",
"tablename": "T_STK_STKTRANSFERINSERIAL",
"entryname": "STK_STKTRANSFERINSERIAL",
"entrytype": "SNSubEntryEntity",
"entrytypeid": 1
},
{
"pkname": "FLinkId",
"tablename": "T_STK_STKTRANSFERINENTRY_LK",
"entryname": "FSTKTSTKRANSFERINENTRY_Link",
"entrytype": "SubEntryEntity",
"entrytypeid": 2
}
]
}
制作不易,谢谢大家收藏、点赞、关注
二开案例.webapi.根据formid得到表单的entry信息(主键、单据状态字段、单据编号字段、单据类型字段)
该功能可以通过接口的方式获得表单的关键信息,十分有用。废话不多说直接上代码using Kingdee.BOS.Core.Metadata;using Kingdee.BOS.Core.M...
点击下载文档
本文2024-09-16 17:10:51发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-14040.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章