using ExtensionMethods; using K3CExttensionMethods; using Kingdee.BOS; using Kingdee.BOS.App.Data; using Kingdee.BOS.Contracts.Report; using Kingdee.BOS.Core.List; using Kingdee.BOS.Core.List.PlugIn.Args; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Core.Report; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.Resource; using Kingdee.BOS.Util; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProductionMaterialsReport { [Description("生产投料报表-服务插件"), HotUpdate] public class ProductionMaterialsReport : 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 */ private List billNames = new List(); 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.SimpleAllCols = false; // 单据主键:两行FID相同,则为同一单的两条分录,单据编号可以不重复显示 this.ReportProperty.PrimaryKeyFieldName = "FID"; // this.ReportProperty.IsDefaultOnlyDspSumAndDetailData = true; // 报表主键字段名:默认为FIDENTITYID,可以修改 this.ReportProperty.IdentityFieldName = "FIDENTITYID"; // 设置精度控制 var list = new List { new DecimalControlField("LOWEST6","FQTY"), new DecimalControlField("LOWEST6","FUnitNeedQty"), new DecimalControlField("LOWEST6","FBASEQTY"), new DecimalControlField("LOWEST6","FNEEDQTY"), new DecimalControlField("LOWEST6","FBASEWIPQTY"), new DecimalControlField("LOWEST6","FBASELACKQTY"), new DecimalControlField("LOWEST6","FBASEONORDERQTY"), new DecimalControlField("LOWEST6","FPICKEDQTY"), new DecimalControlField("LOWEST6","FNOPICKEDQTY"), new DecimalControlField("LOWEST6","FSTDQTY"), new DecimalControlField("LOWEST6","FMUSTQTY"), new DecimalControlField("LOWEST6","FLossQty"), new DecimalControlField("LOWEST6","FSCRAPQTY"), new DecimalControlField("LOWEST6","FREPICKEDQTY"), }; this.ReportProperty.DecimalControlFieldList = list; base.ReportProperty.IsGroupSummary = true; base.ReportProperty.DspInsteadColumnsInfo.DefaultDspInsteadColumns.Add("FSTOCKID", "FSTOCKNAME"); base.ReportProperty.DspInsteadColumnsInfo.DefaultDspInsteadColumns.Add("ProMaterialId", "ProNumber"); //列头是否是通过BOSIDE设计 //base.ReportProperty.IsUIDesignerColumns = true; } /// /// 向报表临时表,插入报表数据 /// /// /// public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName) { base.BuilderReportSqlAndTempTable(filter, tableName); string seqFld = string.Format(base.KSQL_SEQ, " t0.FID "); var proMaterialId = filter.FilterParameter.CustomFilter["ProMaterialId"].Long2Int(); var materialId = filter.FilterParameter.CustomFilter["MaterialId"].Long2Int(); var BILLNO = filter.FilterParameter.CustomFilter["BILLNO"].ToSafeTurnString(); var PPBOMBILLNO = filter.FilterParameter.CustomFilter["PPBOMBILLNO"].ToSafeTurnString(); var SALEORDERNO = filter.FilterParameter.CustomFilter["SALEORDERNO"].ToSafeTurnString(); var sql = $@" PROC_PPBOM_RPT '{tableName}', '{seqFld}' ,{proMaterialId} ,{materialId},'{BILLNO}','{PPBOMBILLNO}','{SALEORDERNO}' ,{this.Context.UserLocale.LCID} "; var res = DBUtils.ExecuteDynamicObject(this.Context, $"/*dialect*/{sql}"); } public override ReportHeader GetReportHeaders(IRptParams filter) { var header = base.GetReportHeaders(filter); int _colIndex = 0; //var head1 = header.AddChild("FNUMBER", new LocaleValue("产品编码"), _colIndex++); //head1.Mergeable = true; //header.AddChild("FIDENTITYID", new LocaleValue("行号"), _colIndex++); header.AddRange(new List { new ListHeader("FDATE", new LocaleValue("单据日期")) }); header.AddChild("FDATE", new LocaleValue("单据日期"), _colIndex++).SetHeader(x => { x.Mergeable = true;x.ColType = SqlStorageType.SqlDecimal;}); header.AddChild("FPPBOMBILLNO", new LocaleValue("生产投料单号"), _colIndex++).SetHeader(x => { x.Mergeable = true; }); header.AddChild("FSALEORDERNO", new LocaleValue("销售订单号"), _colIndex++).SetHeader(x => { x.Mergeable = true; }); header.AddChild("SaleUnitId", new LocaleValue("购货单位代码"), _colIndex++); header.AddChild("ProMnemoniccode", new LocaleValue("助记码"), _colIndex++).SetHeader(x => { x.Mergeable = true; }); header.AddChild("FBILLNO", new LocaleValue("生产任务单号"), _colIndex++).SetHeader(x => { x.Mergeable = true; }); header.AddChild("ProMaterialId", new LocaleValue("产品代码"), _colIndex++).SetHeader(x => { x.Mergeable = true; }); header.AddChild("ProName", new LocaleValue("产品名称"), _colIndex++).SetHeader(x => { x.Mergeable = true; }); header.AddChild("ProSpecification", new LocaleValue("产品规格型号"), _colIndex++).SetHeader(x => { x.Mergeable = true; }); header.AddChild("ProUnitName", new LocaleValue("产品单位"), _colIndex++).SetHeader(x => { x.Mergeable = true; }); header.AddChild("FQTY", new LocaleValue("产品生产数量"), _colIndex++).SetHeader(x => { x.Mergeable = true; }); header.AddChild("MaterialNumber", new LocaleValue("物料代码"), _colIndex++); header.AddChild("MaterialName", new LocaleValue("物料名称"), _colIndex++); header.AddChild("Materialsrc", new LocaleValue("物料来源"), _colIndex++); header.AddChild("MaterialSpecification", new LocaleValue("物料规格型号"), _colIndex++); header.AddChild("ROUTENAME", new LocaleValue("物料技术标准"), _colIndex++); header.AddChild("FUnitNeedQty", new LocaleValue("物料单位用量"), _colIndex++); header.AddChild("MaterialUnitName", new LocaleValue("物料单位"), _colIndex++); header.AddChild("FBASEQTY", new LocaleValue("物料库存量"), _colIndex++); header.AddChild("ToBeInspectQTY", new LocaleValue("物料待检数"), _colIndex++); header.AddChild("FNEEDQTY", new LocaleValue("物料总需求"), _colIndex++); header.AddChild("FBASEWIPQTY", new LocaleValue("当前在制品数量"), _colIndex++); header.AddChild("FBASELACKQTY", new LocaleValue("欠料"), _colIndex++); header.AddChild("FBASEONORDERQTY", new LocaleValue("物料在途数"), _colIndex++); header.AddChild("PlanThrowInQty", new LocaleValue("计划投料数量"), _colIndex++); header.AddChild("FPICKEDQTY", new LocaleValue("已领数量"), _colIndex++); header.AddChild("FNOPICKEDQTY", new LocaleValue("未领数量"), _colIndex++); header.AddChild("FSTDQTY", new LocaleValue("标准数量"), _colIndex++); header.AddChild("FMUSTQTY", new LocaleValue("应发数量"), _colIndex++); header.AddChild("FMEMO", new LocaleValue("备注"), _colIndex++); header.AddChild("FLossQty", new LocaleValue("损耗数量"), _colIndex++); header.AddChild("FSCRAPQTY", new LocaleValue("报废数量"), _colIndex++); header.AddChild("PlanThrowInDate", new LocaleValue("计划发料日期"), _colIndex++); header.AddChild("FSTOCKNAME", new LocaleValue("仓库"), _colIndex++); header.AddChild("FSTOCKLOCID", new LocaleValue("仓位"), _colIndex++); header.AddChild("FREPICKEDQTY", new LocaleValue("补料数量"), _colIndex++); header.AddChild("FPLANSTARTDATE", new LocaleValue("计划开工日期"), _colIndex++); header.AddChild("FPLANFINISHDATE", new LocaleValue("计划完工日期"), _colIndex++); header.AddChild("CubicleName", new LocaleValue("工位"), _colIndex++); header.AddChild("OTHERMEMO", new LocaleValue("其他备注项"), _colIndex++); header.AddChild("BOMMEMO", new LocaleValue("BOM备注项"), _colIndex++); header.AddChild("PRODUCTTYPE", new LocaleValue("生产类型"), _colIndex++); header.AddChild("WORKSHOPNAME", new LocaleValue("生产车间"), _colIndex++); header.AddChild("StatusIs6", new LocaleValue("生产任务单结案否"), _colIndex++); header.AddChild("PPBOMStatus", new LocaleValue("生产投料单状态"), _colIndex++); header.AddChild("PR_C2PO_QTY", new LocaleValue("PR已审未转PO数量"), _colIndex++); return header; } public override ReportTitles GetReportTitles(IRptParams filter) { var titles = base.GetReportTitles(filter); DynamicObject dyFilter = filter.FilterParameter.CustomFilter; if (dyFilter != null) { if (titles == null) { titles = new ReportTitles(); } var materialId = dyFilter["ProMaterialId_Id"].ToString(); if (!materialId.IsNullOrEmpty()) titles.AddTitle("FTitleProMaterialId", materialId); } return titles; } } }