gpt4 book ai didi

acumatica - 在自定义屏幕中查看委托(delegate)时需要帮助

转载 作者:行者123 更新时间:2023-12-04 03:58:53 24 4
gpt4 key购买 nike

我们创建了一个自定义屏幕,它根据过滤条件(今天、昨天、本周、本月、本季度、今年)显示销售数据列表,我们为此创建了一个 SQL View ,然后从我们创建的 VIEW和 DAC 并在自定义屏幕中使用它。我们的屏幕中也有过滤器。对于过滤条件,我们使用 View 委托(delegate)并返回数据。问题是为什么屏幕加载 2K 记录需要大约 70 秒的时间。使用 View 委托(delegate)会降低加载数据的速度。我们可以使用 GI,但我们需要在 GRID 中显示图像,因此我们选择了自定义屏幕,并且我们在标题中有一些报告按钮可以打印报告。因为我们不能在 GI 中显示图像,所以我们选择了这个。

最佳答案

您看到的缓慢很可能是由两个原因共同造成的。

  1. 当您使用 BQL View 时,它实际上只请求您在屏幕上看到的记录数。例如,如果您有带分页的网格并且页面上只有 20 条记录可见,则 SQL 选择将有前 20 条限制。但是,一旦您拥有选择委托(delegate),该优化就会停止工作,因为框架不知道您想要对您选择的数据做什么。这里的解决方案是使用 SelectWithViewContextDelegateResult 返回对象而不是常规选择。在这种情况下,用户过滤、分页和排序将保留在选择中。 (仅当屏幕上的结果记录与您选择的记录一对一相关时才使用此方法。如果您使用任何类型的聚合或从 2 个不同的选择中插入记录,则该方法不起作用)

例子:

protected virtual IEnumerable ardocumentlist()
{
PXSelectBase<BalancedARDocument> cmd =
new PXSelectJoinGroupBy<BalancedARDocument,
...
OrderBy<Asc<BalancedARDocument.docType, //Set necessary sorting fields: use the key fields
Asc<BalancedARDocument.refNbr>>>> //Set necessary sorting fields: use the key fields
(this);

PXDelegateResult delegResult = new PXDelegateResult
{
IsResultFiltered = true, //set these fields to indicate that the result does not need re-filtering, resorting and re-paging
IsResultTruncated = true,
IsResultSorted = true
}

foreach (PXResult<BalancedARDocument> res_record in cmd.SelectWithViewContext())
{
// add the code to process res_record
delegResult.Add(res_record);
}
return delegResult;
}
  1. 可能您的表上没有合适的索引,因为即使您一次选择所有 2k 条记录,加载时间也不应达到 70 秒。这里的建议是使用请求探查器来捕获生成的确切 SQL (https://help-2020r2.acumatica.com/Help?ScreenId=ShowWiki&pageid=e4c450bb-86bc-4fb2-b7e6-1f715abe3c8b) 并在 MS SQL Management studio 中使用选项“包括实际执行计划”(https://learn.microsoft.com/en-us/sql/relational-databases/performance/display-an-actual-execution-plan?view=sql-server-ver15) 执行 SQL。通常在这种模式下,MS SQL 服务器会建议加速查询执行所需的索引。

关于acumatica - 在自定义屏幕中查看委托(delegate)时需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63371743/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com