## 业务背景
目前的逻辑是入库数量/计划数量=达成率,需要加入计划完成时间和数据/实际完成时间和数量=达成率。
## 业务需求
过滤框提供输入时间段,作为入库单的时间限制,算出入库数,实际达成率=入库数/计划数*100%。
## 方案设计
二开标准产品,添加字段,创建插件继承标准产品插件,重写方法,申请一个临时表,获取初步的查询结果到临时表,然后关联处理得到新的列插入到报表的临时表
## 详细设计
### 扩展《委外订单执行明细表》
引入,扩展,添加入库数和实际达成率
### 扩展《委外订单执行明细过滤》
引入,扩展,快捷过滤添加两个日期控件。
### 创建插件,并实现报表逻辑修改
#### 创建插件,添加引用
#### 创建类,继承原数据源类ROExecuteDetailRpt
重写BuilderReportSqlAndTempTable
using Kingdee.BOS.App.Data; using Kingdee.BOS.Contracts; using Kingdee.BOS.Core.Report; using Kingdee.BOS.Core.Util; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Util; using Kingdee.K3.MFG.SUB.App.ReportPlugIn.ROExecute; using System; using System.ComponentModel; using System.Text; namespace Krystal.K3.SCGL.App.Report.SUB { /// <summary> /// 功能描述 :Krystal_ROExecuteDetailRpt /// 创 建 者 :Administrator /// 创建日期 :2024/7/12 17:33:14 /// 最后修改者 :Krystal /// 最后修改日期:2024/7/12 17:33:14 /// </summary> [Description("委外订单执行明细表服务端插件二开-报表插件"), HotUpdate] public class Krystal_ROExecuteDetailRpt: ROExecuteDetailRpt { #region <常量> #endregion <常量> #region <变量> /// <summary> /// 页面过滤参数 /// </summary> FilterArgs _filterArgs = new FilterArgs(); private string[] rptTempTableNames; #endregion <变量> #region <方法> /// <summary> /// 获取过滤条件 /// </summary> /// <param name="filter"></param> private DynamicObject GetFilter(IRptParams filter) { DynamicObject dyFilter = filter.FilterParameter.CustomFilter; _filterArgs.ISBeginTime = this.GetDataByKey(dyFilter, "F_Krystal_InStockBeginTime") == string.Empty ? DateTime.MinValue : Convert.ToDateTime(this.GetDataByKey(dyFilter, "F_Krystal_InStockBeginTime")); _filterArgs.ISEndTime = this.GetDataByKey(dyFilter, "F_Krystal_InStockEndTime") == string.Empty ? DateTime.MaxValue : Convert.ToDateTime(this.GetDataByKey(dyFilter, "F_Krystal_InStockEndTime")); return dyFilter; } /// <summary> /// 构建报表sql和临时表 /// 申请一个临时表,获取初步的查询结果到临时表,然后关联处理得到新的列插入到报表的临时表 /// </summary> /// <param name="filter"></param> /// <param name="tableName"></param> public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName) { IDBService dbservice = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>(); rptTempTableNames = dbservice.CreateTemporaryTableName(this.Context, 1); string strTable = rptTempTableNames[0]; //调用基类的方法,获取初步的查询结果到临时表 base.BuilderReportSqlAndTempTable(filter, strTable); DynamicObject dyFilter = this.GetFilter(filter); StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format(@"/*dialect*/SELECT T1.*,isnull(MOE.FInstockQty,0) F_Krystal_InStockQty,(case when T1.FPLANQTY>0 then round(isnull(MOE.FInstockQty,0)*1.0/T1.FPLANQTY,4)*100 else 0 end) F_Krystal_FinishPercent")); sb.AppendFormat(" into {0} ", tableName); sb.AppendFormat(" FROM {0} T1", strTable); sb.AppendFormat(@" LEFT JOIN (SELECT b.FMOENTRYID FENTRYID ,SUM(b.FREALQTY) FInstockQty FROM T_PRD_INSTOCK a JOIN T_PRD_INSTOCKENTRY b ON a.FID=b.FID WHERE a.FDOCUMENTSTATUS='C' AND CONVERT(varchar(100), a.FAPPROVEDATE, 23) BETWEEN '{0}' AND '{1}' GROUP BY b.FMOENTRYID ) MOE ON T1.FMOENTRYID=MOE.FENTRYID", _filterArgs.ISBeginTime, _filterArgs.ISEndTime); //DBUtils.Execute(this.Context, "DROP TABLE " + tableName); DBUtils.Execute(this.Context, sb.ToString()); } /// <summary> /// 查询条件标题 /// </summary> /// <param name="filter"></param> /// <returns></returns> public override ReportTitles GetReportTitles(IRptParams filter) { ReportTitles reportTitle = base.GetReportTitles(filter); reportTitle.AddTitle("F_Krystal_InStockTitle" , string.Format("{0}--{1}" , FieldFormatterUtil.GetDateFormatString(base.Context, _filterArgs.ISBeginTime) , FieldFormatterUtil.GetDateFormatString(base.Context, _filterArgs.ISEndTime))); return reportTitle; } #endregion <方法> #region 过滤参数 FilterArgs internal class FilterArgs { public DateTime ISBeginTime { get; set; }//起始年月 public DateTime ISEndTime { get; set; }//结束年月 } #endregion } }完整代码
#### 报表挂载插件
标签:插件,string,二开,委外,BOS,Kingdee,明细表,using,Krystal From: https://www.cnblogs.com/lanrenka/p/18298285