报表查询逻辑通常比较复杂,如果查询数据量过大,在执行查询过程中,数据量过大可能会引起脚本阻塞,临时表数据暴涨,内存不足等情况,引发系统卡顿卡死甚至内存爆满后系统退出等问题
解决办法可以考虑通过二开,在报表点击过滤框的确定按钮时校验查询条件中的日期范围,如果日期范围超出一定的范围,终止查询,并弹出提示,具体的日期范围限制,可根据实际业务数据量大小评估一个相对合理的范围,比如半年或一年等。这个二开是做在过滤条件的表单插件上,以销售利润估算分析表为例,二开代码demo如下,可参考:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.Core.CommonFilter.PlugIn;
namespace Kingdee.K3.SCM.Sal.Report.PlugIn //命名空间根据实际代码所在工程
{
public class SalProfitAnalyseFilterCheckDate : AbstractCommonFilterPlugIn
{
public override void ButtonClick(BOS.Core.DynamicForm.PlugIn.Args.ButtonClickEventArgs e)
{
base.ButtonClick(e);
if (e.Key.ToUpperInvariant() == "FBTNOK") //确定按钮点击
{
DateTime beginDate = DateTime.MinValue;
beginDate = Convert.ToDateTime(this.View.Model.GetValue("FDateFrom")); //单据日期起始时间
DateTime endDate = DateTime.MinValue;
endDate = Convert.ToDateTime(this.View.Model.GetValue("FDateTo")); //单据日期终止时间
if ((endDate - beginDate).TotalDays > 180) //默认180天范围
{
e.Cancel = true;
this.View.ShowErrMessage("单据日期过滤范围请勿超过半年!");
}
DateTime beginArDate = DateTime.MinValue;
beginArDate = Convert.ToDateTime(this.View.Model.GetValue("FRecDateFrom"));
DateTime endArDate = DateTime.MinValue;
endArDate = Convert.ToDateTime(this.View.Model.GetValue("FRecDateTo"));
if ((endArDate - beginArDate).TotalDays > 180)
{
e.Cancel = true;
this.View.ShowErrMessage("应收日期过滤范围请勿超过半年!");
}
}
}
}
}
表单插件注册
效果示例