单据转换.二开案例.下推时仅部分行下推成功时不允许下推
【场景】单据转换时,会根据选单条件策略进行计算;存在满足条件的行就会继续下推;
部分场景下不支持部分下推,必须保留完整关系
【数据准备】采购申请单-》采购订单
(a)采购申请单
![image.webp](/download/0100dda02722f350420db779f1228a07030a.webp)
(b)转换规则
![image.webp](/download/01003de39b834f60480eba39d6fcc932c50c.webp)
(c)直接下推结果
![image.webp](/download/0100d621087823b14024be248269d209cfc4.webp)
【案例】当存在行不满足时,不允许下推
![image.webp](/download/0100b6d9b56a452e476480542407110fcb9e.webp)
```csharp
using Kingdee.BOS;
using Kingdee.BOS.Core.Const;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.FormElement;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.ServiceHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DynamicFormPlugIn.BillConvert
{
[Kingdee.BOS.Util.HotUpdate]
[System.ComponentModel.Description("")]
public class ConvertServicePlugIn_SourceDataPickError : AbstractConvertPlugIn
{
/*
* 当单据转换是源单携带仅携带部分行时,不允许转换
*
*/
public override void OnGetSourceData(GetSourceDataEventArgs e)
{
string srcEntryKey;
Option.TryGetVariableValue("SourceEntryKey", out srcEntryKey);
if (string.IsNullOrEmpty(srcEntryKey))
return;
ListSelectedRow[] selectRows;
Option.TryGetVariableValue("SelectedRows", out selectRows);
if (selectRows == null || selectRows.Length <=0)
return;
int originSelectRowCnt = 0;
if (IsGetByEntry(srcEntryKey, selectRows))
{
//按分录计算
var pkValueArray = (from p in selectRows
where !string.IsNullOrEmpty(p.EntryPrimaryKeyValue)
select p.EntryPrimaryKeyValue).ToArray();
originSelectRowCnt = pkValueArray.Length;
}
else
{
//按整单计算
var entity = e.SourceBusinessInfo.GetEntity(srcEntryKey);
QueryBuilderParemeter queryBuilder = new QueryBuilderParemeter();
queryBuilder.FormId = e.SourceBusinessInfo.GetForm().Id;
List<string> selectFields = new List<string>();
//主键PK
selectFields.Add(e.SourceBusinessInfo.GetForm().PkFieldName);
//分录主键 entry_entryPK
selectFields.Add(string.Concat(entity.Key, "_", entity.EntryPkFieldName));
foreach (var field in selectFields)
{
queryBuilder.SelectItems.Add(new SelectorItemInfo(field));
}
var result = QueryServiceHelper.GetDynamicObjectCollection(this.Context, queryBuilder);
originSelectRowCnt = result.Count;
}
//行数不匹配的逻辑
if(originSelectRowCnt != e.SourceData.Count)
{
throw new KDBusinessException("", "源单携带行数不匹配");
}
}
private bool IsGetByEntry(string srcEntryKey, ListSelectedRow[] selectRows)
{
var firstRow = selectRows.First();
if (string.IsNullOrEmpty(firstRow.EntryPrimaryKeyValue))
return false;
if (!srcEntryKey.Equals(firstRow.EntryEntityKey, StringComparison.OrdinalIgnoreCase))
return false;
bool SelectByBillId = false;
Option.TryGetVariableValue(ConvertConst.SelectByBillId, out SelectByBillId);
if (SelectByBillId) return false;
return true;
}
}
}
```
【效果】
![image.webp](/download/0100a503f376ed04400a9041ff28c3645910.webp)
单据转换.二开案例.下推时仅部分行下推成功时不允许下推
【场景】单据转换时,会根据选单条件策略进行计算;存在满足条件的行就会继续下推;部分场景下不支持部分下推,必须保留完整关系【数据准备...
点击下载文档
上一篇:过滤应用性能监控耗时日志下一篇:万能报表自定义合计
本文2024-09-16 18:31:50发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-22739.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章