322 lines
13 KiB
C#
322 lines
13 KiB
C#
using Kingdee.BOS.Contracts.Report;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.ComponentModel;
|
||
using Kingdee.BOS;
|
||
using Kingdee.BOS.Util;
|
||
using Kingdee.BOS.Core;
|
||
using Kingdee.BOS.Core.Report;
|
||
using Kingdee.BOS.Core.Report.PlugIn;
|
||
using Kingdee.BOS.Core.Report.PlugIn.Args;
|
||
using Kingdee.BOS.Core.List;
|
||
using Kingdee.BOS.App.Data;
|
||
using Kingdee.BOS.Orm.DataEntity;
|
||
using Kingdee.BOS.Core.Metadata;
|
||
using Kingdee.BOS.Core.Metadata.Util;
|
||
using System.Data;
|
||
|
||
|
||
namespace MonthlyProductionSchedule
|
||
{
|
||
[Description("生产计划表-服务插件"), HotUpdate]
|
||
public class ProductionPlanRptPlugIn : SysReportBaseService
|
||
{
|
||
/***********事件执行顺序*************
|
||
2015/8/31 18:04:12 : Initialize
|
||
2015/8/31 18:04:12 : GetTableName
|
||
2015/8/31 18:04:15 : BuilderReportSqlAndTempTable
|
||
2015/8/31 18:04:15 : GetIdentityFieldIndexSQL
|
||
2015/8/31 18:04:15 : ExecuteBatch
|
||
2015/8/31 18:04:19 : GetReportHeaders
|
||
2015/8/31 18:04:19 : GetReportTitles
|
||
2015/8/31 18:04:27 : GetTableName
|
||
2015/8/31 18:04:27 : GetIdentityFieldIndexSQL
|
||
2015/8/31 18:04:28 : ExecuteBatch
|
||
2015/8/31 18:04:28 : AnalyzeDspCloumn
|
||
2015/8/31 18:04:28 : AfterCreateTempTable
|
||
2015/8/31 18:04:28 : GetSummaryColumnInfo
|
||
2015/8/31 18:04:28 : GetSummaryColumsSQL
|
||
2015/8/31 18:04:28 : GetTableName
|
||
2015/8/31 18:04:28 : GetTableName
|
||
2015/8/31 18:04:29 : ExecuteBatch
|
||
2015/8/31 18:04:29 : GetIdentityFieldIndexSQL
|
||
2015/8/31 18:04:29 : ExecuteBatch
|
||
2015/8/31 18:04:29 : CreateGroupSummaryData
|
||
2015/8/31 18:04:29 : GetListData
|
||
2015/8/31 18:04:30 : GetReportData
|
||
2015/8/31 18:04:30 : GetRowsCount
|
||
2015/8/31 18:04:30 : GetListData
|
||
*/
|
||
|
||
public override void Initialize()
|
||
{
|
||
base.Initialize();
|
||
// 简单账表类型:普通、树形、分页
|
||
this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;
|
||
// 报表名称
|
||
this.ReportProperty.ReportName = new LocaleValue("生产计划表", base.Context.UserLocale.LCID);
|
||
//
|
||
this.IsCreateTempTableByPlugin = true;
|
||
//
|
||
this.ReportProperty.IsUIDesignerColumns = false;
|
||
//
|
||
this.ReportProperty.IsGroupSummary = true;
|
||
//
|
||
this.ReportProperty.SimpleAllCols = false;
|
||
// 单据主键:两行FID相同,则为同一单的两条分录,单据编号可以不重复显示
|
||
this.ReportProperty.PrimaryKeyFieldName = "FID";
|
||
//
|
||
this.ReportProperty.IsDefaultOnlyDspSumAndDetailData = true;
|
||
|
||
// 报表主键字段名:默认为FIDENTITYID,可以修改
|
||
//this.ReportProperty.IdentityFieldName = "FIDENTITYID";
|
||
//
|
||
// 设置精度控制
|
||
var list = new List<DecimalControlField>();
|
||
|
||
this.ReportProperty.DecimalControlFieldList = list;
|
||
}
|
||
|
||
public override string GetTableName()
|
||
{
|
||
var result = base.GetTableName();
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 向报表临时表,插入报表数据
|
||
/// </summary>
|
||
/// <param name="filter"></param>
|
||
/// <param name="tableName"></param>
|
||
public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
|
||
{
|
||
base.BuilderReportSqlAndTempTable(filter, tableName);
|
||
|
||
// 拼接过滤条件 : filter
|
||
// 略
|
||
|
||
// 默认排序字段:需要从filter中取用户设置的排序字段
|
||
string seqFld = string.Format(base.KSQL_SEQ, " t0.FID ");
|
||
var year = filter.FilterParameter.CustomFilter["DataHoldYear"].Long2Int();
|
||
var month = filter.FilterParameter.CustomFilter["DataHoldMonth"].Long2Int();
|
||
var date = new DateTime(year, month, 1);
|
||
// 取数SQL
|
||
// FID, FEntryId, 编号、状态、物料、数量、单位、单位精度、单价、价税合计
|
||
object resa = 0;
|
||
var startDate = date.ToString("yyyy-MM-dd");
|
||
var endDate = date.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd");
|
||
// string sql = $@"
|
||
//EXEC PROC_ProductionSchedule '{tableName}','{startDate}','{endDate}', {base.Context.UserLocale.LCID} ,'{seqFld}';
|
||
//";
|
||
//DBUtils.ExecuteDynamicObject(this.Context, sql);
|
||
var para = new List<SqlParam>
|
||
{
|
||
new SqlParam("@tableName", KDDbType.String,tableName),
|
||
new SqlParam("@startDate", KDDbType.String,startDate),
|
||
new SqlParam("@endDate", KDDbType.String,endDate),
|
||
new SqlParam("@LCID", KDDbType.Int32,base.Context.UserLocale.LCID),
|
||
new SqlParam("@seqFld", KDDbType.String,seqFld),
|
||
new SqlParam("@year", KDDbType.Int32,year),
|
||
new SqlParam("@month", KDDbType.Int32,month),
|
||
new SqlParam("@HasId", KDDbType.Int32, resa,ParameterDirection.Output)
|
||
};
|
||
|
||
var res = DBUtils.ExecuteStoreProcedure(this.Context, "PROC_ProductionSchedule", para);
|
||
//filter.FilterParameter.CustomOption.Add("res", res[0].Value);
|
||
filter.FilterParameter.CustomFilter["DataBDStatu"] = res.First(x => x.Name.Equals("@HasId")).Value;
|
||
}
|
||
|
||
protected override string GetIdentityFieldIndexSQL(string tableName)
|
||
{
|
||
string result = base.GetIdentityFieldIndexSQL(tableName);
|
||
return result;
|
||
}
|
||
|
||
protected override void ExecuteBatch(List<string> listSql)
|
||
{
|
||
base.ExecuteBatch(listSql);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 构建出报表列
|
||
///
|
||
///
|
||
///
|
||
///
|
||
/// // 如下代码,演示如何设置同一分组的分组头字段合并
|
||
/// // 需配合Initialize事件,设置分组依据字段(PrimaryKeyFieldName)
|
||
/// ReportHeader header = new ReportHeader();
|
||
/// header.Mergeable = true;
|
||
/// int width = 80;
|
||
/// ListHeader headChild1 = header.AddChild("FBILLNO", new LocaleValue("应付单号"));
|
||
/// headChild1.Width = width;
|
||
/// headChild1.Mergeable = true;
|
||
///
|
||
/// ListHeader headChild2 = header.AddChild("FPURMAN", new LocaleValue("采购员"));
|
||
/// headChild2.Width = width;
|
||
/// headChild2.Mergeable = true;
|
||
/// </summary>
|
||
/// <param name="filter"></param>
|
||
/// <returns></returns>
|
||
public override ReportHeader GetReportHeaders(IRptParams filter)
|
||
{
|
||
var year = filter.FilterParameter.CustomFilter["DataHoldYear"].Long2Int();
|
||
var month = filter.FilterParameter.CustomFilter["DataHoldMonth"].Long2Int();
|
||
var date = new DateTime(year, month, 1);
|
||
|
||
// FID, FEntryId,
|
||
var _colIndex = 0;
|
||
ReportHeader header = new ReportHeader();
|
||
|
||
header.AddChild("FNUMBER", new LocaleValue("产品编码"), _colIndex++);
|
||
header.AddChild("FNAME", new LocaleValue("产品名称"), _colIndex++);
|
||
header.AddChild("SHELFLIFE", new LocaleValue("有效期"), _colIndex++);
|
||
header.AddChild("StandardLot", new LocaleValue("标准批量"), _colIndex++);
|
||
header.AddChild("FLOTYIELD", new LocaleValue("每批产量"), _colIndex++);
|
||
header.AddChild("FPACKUNITCONVERRATIO", new LocaleValue("包装规格"), _colIndex++);
|
||
header.AddChild("FPACKUNITCONVT", new LocaleValue("包装规格"), _colIndex++);
|
||
header.AddChild("FPACKUNITNAME", new LocaleValue("单位"), _colIndex++);
|
||
header.AddChild("SAFESTOCKCOUNT", new LocaleValue("安全库存量"), _colIndex++);
|
||
header.AddChild("SAFESTOCK", new LocaleValue("安全库存数量"), _colIndex++);
|
||
header.AddChild("M01", new LocaleValue("本月预计需求量"), _colIndex++);
|
||
header.AddChild("S01", new LocaleValue(date.AddMonths(-1).ToString("yyyy年MM月") + "发货量"), _colIndex++);
|
||
header.AddChild("S02", new LocaleValue(date.AddMonths(-2).ToString("yyyy年MM月") + "发货量"), _colIndex++);
|
||
header.AddChild("S03", new LocaleValue(date.AddMonths(-3).ToString("yyyy年MM月") + "发货量"), _colIndex++);
|
||
header.AddChild("InStockQty", new LocaleValue("已入库量"), _colIndex++);
|
||
header.AddChild("InProductionQty", new LocaleValue("在生产量"), _colIndex++);
|
||
header.AddChild("TotalStockQty", new LocaleValue("合计入库量"), _colIndex++);
|
||
header.AddChild("OrderLotQty", new LocaleValue("系统计划生产批数"), _colIndex++);
|
||
header.AddChild("FirmLotQty", new LocaleValue("确认计划生产批数"), _colIndex++);
|
||
header.AddChild("FFirmQty", new LocaleValue("确认计划生产量"), _colIndex++);
|
||
header.AddChild("Note", new LocaleValue("备注"), _colIndex++);
|
||
|
||
return header;
|
||
}
|
||
|
||
public override ReportTitles GetReportTitles(IRptParams filter)
|
||
{
|
||
var result = base.GetReportTitles(filter);
|
||
DynamicObject dyFilter = filter.FilterParameter.CustomFilter;
|
||
if (dyFilter != null)
|
||
{
|
||
if (result == null)
|
||
{
|
||
result = new ReportTitles();
|
||
}
|
||
//数据保存状态
|
||
object saveDataStauts = dyFilter["DataBDStatu"];
|
||
result.AddTitle("FDataBDStatu", saveDataStauts.ToString());
|
||
result.AddTitle("FDataHoldYear", dyFilter["DataHoldYear"].ToString());
|
||
result.AddTitle("FDataHoldMonth", dyFilter["DataHoldMonth"].ToString());
|
||
result.AddTitle("FDataHoldDate", $"{dyFilter["DataHoldYear"]}-{dyFilter["DataHoldMonth"]}");
|
||
//if (saveDataStauts != null)
|
||
//{
|
||
// if (saveDataStauts.Long2Int() == 1)
|
||
// result.AddTitle("FSaveDataButton", "更新覆盖当月数据");
|
||
// else
|
||
// result.AddTitle("FSaveDataButton", "保存当月数据1");
|
||
|
||
//}
|
||
//result.AddTitle("F_JD_Date", Convert.ToString(dyFilter["F_JD_Date"]));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
protected override string AnalyzeDspCloumn(IRptParams filter, string tablename)
|
||
{
|
||
string result = base.AnalyzeDspCloumn(filter, tablename);
|
||
return result;
|
||
}
|
||
protected override void AfterCreateTempTable(string tablename)
|
||
{
|
||
base.AfterCreateTempTable(tablename);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置报表合计列
|
||
/// </summary>
|
||
/// <param name="filter"></param>
|
||
/// <returns></returns>
|
||
public override List<SummaryField> GetSummaryColumnInfo(IRptParams filter)
|
||
{
|
||
var result = base.GetSummaryColumnInfo(filter);
|
||
return result;
|
||
}
|
||
protected override string GetSummaryColumsSQL(List<SummaryField> summaryFields)
|
||
{
|
||
var result = base.GetSummaryColumsSQL(summaryFields);
|
||
return result;
|
||
}
|
||
protected override System.Data.DataTable GetListData(string sSQL)
|
||
{
|
||
var result = base.GetListData(sSQL);
|
||
return result;
|
||
}
|
||
protected override System.Data.DataTable GetReportData(IRptParams filter)
|
||
{
|
||
var result = base.GetReportData(filter);
|
||
return result;
|
||
}
|
||
protected override System.Data.DataTable GetReportData(string tablename, IRptParams filter)
|
||
{
|
||
var result = base.GetReportData(tablename, filter);
|
||
return result;
|
||
}
|
||
public override int GetRowsCount(IRptParams filter)
|
||
{
|
||
var result = base.GetRowsCount(filter);
|
||
return result;
|
||
}
|
||
protected override string BuilderFromWhereSQL(IRptParams filter)
|
||
{
|
||
string result = base.BuilderFromWhereSQL(filter);
|
||
return result;
|
||
}
|
||
protected override string BuilderSelectFieldSQL(IRptParams filter)
|
||
{
|
||
string result = base.BuilderSelectFieldSQL(filter);
|
||
return result;
|
||
}
|
||
protected override string BuilderTempTableOrderBySQL(IRptParams filter)
|
||
{
|
||
string result = base.BuilderTempTableOrderBySQL(filter);
|
||
return result;
|
||
}
|
||
public override void CloseReport()
|
||
{
|
||
base.CloseReport();
|
||
}
|
||
protected override string CreateGroupSummaryData(IRptParams filter, string tablename)
|
||
{
|
||
string result = base.CreateGroupSummaryData(filter, tablename);
|
||
return result;
|
||
}
|
||
protected override void CreateTempTable(string sSQL)
|
||
{
|
||
base.CreateTempTable(sSQL);
|
||
}
|
||
public override void DropTempTable()
|
||
{
|
||
base.DropTempTable();
|
||
}
|
||
public override System.Data.DataTable GetList(IRptParams filter)
|
||
{
|
||
var result = base.GetList(filter);
|
||
return result;
|
||
}
|
||
public override List<long> GetOrgIdList(IRptParams filter)
|
||
{
|
||
var result = base.GetOrgIdList(filter);
|
||
return result;
|
||
}
|
||
public override List<TreeNode> GetTreeNodes(IRptParams filter)
|
||
{
|
||
var result = base.GetTreeNodes(filter);
|
||
return result;
|
||
}
|
||
|
||
}
|
||
}
|