这篇文章距离最后更新已过176 天,如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
推式生单配置目标单据类型编码查询
C# 实体查询方式
/// <summary>
/// 推式生单配置
/// </summary>
/// <param name="SrcOrg">来源组织</param>
/// <param name="DocType">来源单据类型</param>
/// <param name="SourceEntityKey">来源实体ID</param>
/// <param name="TargetEntityKey">目标实体ID</param>
/// <returns></returns>
public static string GetPushToDocTypeConfig(Organization SrcOrg, long DocType,
long SourceEntityKey, long TargetEntityKey,string tab)
{
// 生单规则
PushToDocTypeRule PTTRData =
PushToDocTypeRule.Finder.Find($"PushToDocTypeConfig.SourceEntity =
{SourceEntityKey} and PushToDocTypeConfig.TargetEntity = {TargetEntityKey} and
TargetOrg = {SrcOrg.ID}");
// 生单规则条件
PushToDocTypeRuleLine PTTRLData =
PushToDocTypeRuleLine.Finder.Find($"PushToDocTypeRule = {PTTRData.ID} and
SourceOrg = {SrcOrg.ID} and EntityFieldValue{tab} = {DocType}");
return PTTRLData?.TargetDocTypeCode;
}
SQL语句方式
select dbo.Fun_Cust_GetTargetDocTypeCode('UFIDA.U9.SM.ShipPlan.ShipPlan', 'UFIDA.U9.SM.Ship.Ship', 1002109230000231, (select ID from Base_Organization where Code='T001'))
-- =============================================
CREATE OR ALTER FUNCTION Fun_Cust_GetTargetDocTypeCode
(
@SourceEntityName varchar(255), -- 来源实体类型全称
@TargetEntityName varchar(255), -- 目标实体类型全称
@SourceDocType bigint, -- 来源单据类型
@TargetOrg bigint -- 目标组织
)
RETURNS nvarchar(255)
AS
BEGIN
declare @SourceEntity bigint,@TargetEntity bigint,@TargetDocTypeCode
nvarchar(255)
select @SourceEntity=Local_ID from UBF_MD_Class where
FullName=@SourceEntityName
select @TargetEntity=Local_ID from UBF_MD_Class where
FullName=@TargetEntityName
select @TargetDocTypeCode=TargetDocTypeCode from Base_PushToDocTypeRuleLine
line
join Base_PushToDocTypeRule head on head.ID=line.PushToDocTypeRule and
head.TargetOrg=@TargetOrg
join Base_PushToDocTypeConfig conf on conf.ID=head.PushToDocTypeConfig and
SourceEntity=@SourceEntity and TargetEntity=@TargetEntity
where (EntityFieldValue1=@SourceDocType or EntityFieldValue2=@SourceDocType
or EntityFieldValue3=@SourceDocType or EntityFieldValue4=@SourceDocType or
EntityFieldValue5=@SourceDocType)
return @TargetDocTypeCode
END
GO