业务流程.常见问题.link实体 源单信息字段讲解
【场景】link实体 源单信息字段讲解
背景:星空的关联关系是通过在数据包中的关联实体增加源单信息,而后通过标准保存操作将link信息转换为实际的关联关系和反写计算逻辑
【问题1】自定义单据怎么增加关联关系
a)下游单据增加单据关联实体配置,建议如果下游存在单据体字段跟上游关联,则把单据关联实体设置在单据体(按行关联源单)
下图为标准产品采购订单的单据关联实体配置
![image.webp](/download/010037d02d2a980a49848bdf177a1efe530f.webp)
b)在转换规则中,配置转换类型为关联携带,在下游单据数据包生成的时候,平台会把信息填入到该实体中
![image.webp](/download/01001142d6001cc24f5593c70e8ba3198ff6.webp)
【问题2】link表怎么查看对应的源单
0)数据准备,上游采购申请单下推采购订单,按照物料编码分录合并
![image.webp](/download/0100d2015d7d5cef4258a6e6d5c612ccaf94.webp)
1)生成的下游单据
![image.webp](/download/0100dfcc0c6811ac4f26a80068b686384be7.webp)
2)数据库讲解
```sql
declare @billid varchar(50);
set @billid = 'CGDD001981';
select bill.FID, bill.FBILLNO, entry.FSEQ ,lk.FSTABLENAME as '源单实体标识',
lk.FSID as '源单分录内码', lk.FSBILLID as '源单单据内码',
srcBill.FBILLNO as '采购申请单源单编号'
from T_PUR_POORDER bill
left join T_PUR_POORDERENTRY entry on bill.FID = entry.FID
left join T_PUR_POORDERENTRY_LK lk on entry.FENTRYID = lk.FENTRYID
left join T_PUR_REQUISITION srcBill on lk.FSTABLENAME = 'T_PUR_ReqEntry' and srcBill.FID = lk.FSBILLID
where bill.FBILLNO = @billid
```
![image.webp](/download/010027ce059c360d4b748db7927d9ba7ca76.webp)
link实体本质就是一个子实体,如果关联的是单据头,就用单据头的单据内码和link实体的外键关联;如果关联的是单据体,就用分录内码和link实体关联。
link实体中
FSTABLENAME 记录了上游的关联实体,本案例中就是采购申请单的明细T_PUR_ReqEntry;
FSID 记录了上游关联实体的主键,如果是关联的明细就是源单分录内码,关联的是单据头就是源单单据内码
FSBILLID 记录了上游关联单据的主键
【问题3】插件中使用单据数据包怎么查看对应的源单
![20240202 1924.webp](/download/010025f4832d0cf74803be6e7a4b6b4a4d4b.webp)
```csharp
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Orm.DataEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DynamicFormPlugIn.Test
{
[Kingdee.BOS.Util.HotUpdate]
[System.ComponentModel.Description("link实体讲解,获取源单案例")]
public class AdjustTrackResultBillPlugIn : AbstractBillPlugIn
{
public override void BarItemClick(BarItemClickEventArgs e)
{
if (string.Equals("tb_ShowLinkInfo", e.BarItemKey, StringComparison.OrdinalIgnoreCase))
{
this.View.ShowMessage(LinkHelper.GetSrcLinkInfoByBillObj(this.View.BillBusinessInfo, this.Model.DataObject));
}
}
}
public static class LinkHelper
{
/// <summary>
/// 获取link实体
/// </summary>
/// <param name="businessInfo"></param>
/// <returns></returns>
public static LinkEntity GetLinkEntity(BusinessInfo businessInfo)
{
var billForm = businessInfo.GetForm();
if (billForm.LinkSet == null || billForm.LinkSet.LinkEntitys.Count == 0)
return null;
return billForm.LinkSet.LinkEntitys[0];
}
/// <summary>
/// 获取link实体的关联实体
/// </summary>
/// <param name="businessInfo"></param>
/// <returns></returns>
public static Entity GetLinkParentEntiy(BusinessInfo businessInfo)
{
var linkEntity = GetLinkEntity(businessInfo);
if (linkEntity == null)
return null;
var linkParentEntity = businessInfo.GetEntity(linkEntity.ParentEntityKey);
return linkParentEntity;
}
/// <summary>
/// 输出数据包的关联源单关系
/// </summary>
/// <param name="businessInfo">元数据</param>
/// <param name="billDataObj">数据包</param>
/// <returns></returns>
public static string GetSrcLinkInfoByBillObj(BusinessInfo businessInfo, DynamicObject billDataObj)
{
var linkParentEntity = GetLinkParentEntiy(businessInfo);
var linkEntity = GetLinkEntity(businessInfo);
StringBuilder msgBuilder = new StringBuilder();
if (linkParentEntity is HeadEntity)
{
//关联实体在单据头
if (!billDataObj.DynamicObjectType.Properties.ContainsKey(linkEntity.Key))
return string.Empty;
msgBuilder.AppendLine("关联实体在单据头");
DynamicObjectCollection linkObjColl = billDataObj[linkEntity.Key] as DynamicObjectCollection;
ScanLinkDataObj(linkObjColl, (x) => { GetLinkMessage(x, msgBuilder); });
}
else if (linkParentEntity is EntryEntity)
{
if (!billDataObj.DynamicObjectType.Properties.Contains(linkParentEntity.DynamicProperty))
return string.Empty;
msgBuilder.AppendLine("关联实体在单据体");
DynamicObjectCollection entityObjColl = billDataObj[linkParentEntity.DynamicProperty] as DynamicObjectCollection;
for (int i = 0; i < entityObjColl.Count; ++i)
{
var entityObj = entityObjColl[i];
if (entityObj == null)
continue;
msgBuilder.AppendLine(string.Format("分录序号:{0}", i + 1));
if (!entityObj.DynamicObjectType.Properties.ContainsKey(linkEntity.Key))
return string.Empty;
DynamicObjectCollection linkObjColl = entityObj[linkEntity.Key] as DynamicObjectCollection;
ScanLinkDataObj(linkObjColl, (x) => { GetLinkMessage(x, msgBuilder); });
}
}
return msgBuilder.ToString();
}
/// <summary>
/// link实体遍历
/// </summary>
/// <param name="linkObjColl"></param>
/// <param name="linkObjAct"></param>
private static void ScanLinkDataObj(DynamicObjectCollection linkObjColl, Action<DynamicObject> linkObjAct)
{
if (linkObjColl == null)
return;
foreach (var linkRowObj in linkObjColl)
{
linkObjAct(linkRowObj);
}
}
/// <summary>
/// 输出单个link数据包的源单信息
/// </summary>
/// <param name="linkObj"></param>
/// <param name="msgBuilder"></param>
private static void GetLinkMessage(DynamicObject linkObj, StringBuilder msgBuilder)
{
if (linkObj == null)
return;
const string fstablename = "STABLENAME";
const string fsid = "SID";
const string fsbillid = "SBILLID";
string sTableName = linkObj[fstablename].ToString();
long sid = Convert.ToInt64(linkObj[fsid]);
long sbillId = Convert.ToInt64(linkObj[fsbillid]);
msgBuilder.AppendLine(string.Format("源单实体表名:{0},源单实体分录内码:{1},源单单据内码:{2}", sTableName, sid, sbillId));
}
/// <summary>
/// 输出单据内码的关联源单关系
/// </summary>
/// <param name="businessInfo"></param>
/// <param name="billId"></param>
/// <returns></returns>
public static string GetSrcLinkInfoByBillId(BusinessInfo businessInfo, object billId)
{
return string.Empty;
}
}
}
```
【问题4】webapi怎么手工传数据包关联源单
需注意业务单据有控制字段的逻辑,控制字段需要按照业务逻辑传入,不确定如何传入需要咨询业务领域
[WebAPI保存接口实现上下游关联](https://wenku.my7c.com/article/171055?productLineId=1)
Mark!~
业务流程.常见问题.link实体 源单信息字段讲解
【场景】link实体 源单信息字段讲解背景:星空的关联关系是通过在数据包中的关联实体增加源单信息,而后通过标准保存操作将link信息转换为...
点击下载文档
本文2024-09-16 18:11:39发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-20553.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章