Kingdee K3 Cloud 报表插件二次开发
库存预留关系查询报表添加SO资材回复日期
namespace K3.App.Service.PlugIn.ReportPlugIn
{
[Description("库存预留关系查询报表添加SO资材回复日期")]
// [Kingdee.BOS.Util.HotUpdate]
//GSB.K3.App.Service.PlugIn.ReportPlugIn.ReportServicePlugIn, GSB.K3.App.Service.PlugIn
public class ReportServicePlugIn : InvReserveAnalyzeRpt
{
private string[] CustomRptFieldNames;
public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
{
base.BuilderReportSqlAndTempTable(filter, tableName);
IDBService dbservice = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
CustomRptFieldNames = dbservice.CreateTemporaryTableName(this.Context, 1);
string strTable = CustomRptFieldNames[0]; //调用基类的方法,获取初步的查询结果到临时表
base.BuilderReportSqlAndTempTable(filter, strTable); //初步结果处理,然后回写积累的数据到临时表
StringBuilder sb = new StringBuilder();
sb.AppendLine("SELECT T1.*,SO.FDELIVERYDATE F_BHR_FDeliveryDate");//
sb.AppendFormat(" into {0} ", tableName);
sb.AppendFormat(" FROM {0} T1", strTable);
sb.AppendFormat(" LEFT JOIN (SELECT FDELIVERYDATE,s.FBILLNO,s_e.FSEQ,s_ed.FENTRYID FROM dbo.T_SAL_ORDERENTRY_D s_ed " +
"JOIN dbo.T_SAL_ORDERENTRY s_e ON s_e.FENTRYID = s_ed.FENTRYID " +
"JOIN dbo.T_SAL_ORDER s ON s.FID = s_ed.FID) SO ON SO.FBILLNO=t1.fsrcbillno AND SO.FENTRYID=t1.FSrcEntrySeq");
// CustomLog.WriteOperaterLog(this.Context, "ReportServicePlugIn", "ReportServicePlugIn", "计划订单", sb.ToString());
//删除临时表
DBUtils.Execute(this.Context, "DROP TABLE " + tableName);
//执行新的查询
DBUtils.Execute(this.Context, sb.ToString());
}
public override void CloseReport()
{
if (CustomRptFieldNames.IsNullOrEmptyOrWhiteSpace())
return;
IDBService dbservice = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
dbservice.DeleteTemporaryTableName(this.Context, CustomRptFieldNames);
base.CloseReport();
}
}
}