wangzelong
2022-09-20 f2567c7e2afc6f377be549c8ce440edc3c35c36a
Application/IStation.Application.DataFile/eta_month_report/PdfCreate/Eta_Month_ReportPdf.cs
ÎļþÃû´Ó Application/IStation.Application.DataFile/Report/PdfCreate/Eta_Month_ReportPdf.cs ÐÞ¸Ä
@@ -31,12 +31,13 @@
        /// ç”ŸæˆæŠ¥è¡¨
        /// </summary>
        /// <param name="station">泵站信息</param>
        /// <param name="sum">汇总</param>
        /// <param name="datatime">时间</param>
        /// <param name="pipeList">机泵管路列表</param>
        /// <param name="list">机泵信息列表</param>
        /// <param name="monthlist">泵站月列表</param>
        /// <param name="path">路径</param>
        /// <returns></returns>
        public bool Create4Stream(Station station, List<Model.PipeLine> pipeList, List<Model.EtaSumSingleMonthRecord> list,string path)
        public bool Create4Stream(Station station, Model.EtaSumMultiMonthRecord sum, List<Model.PipeLine> pipeList, List<Model.EtaSumSingleMonthRecord> list, string datatime, string path)
        {
            InitialFont();
            //初始化标题中的LOGO图片
@@ -47,7 +48,7 @@
            _document.SetMargins(-40, -40, 40, 40);
            _writer = PdfWriter.GetInstance(_document, new FileStream(path, FileMode.Create));
            _writer.PageEvent = new CreatHeaderAndFoot();
            CreatestationInfoPage(station, pipeList, list);//产品信息
            CreatestationInfoPage(station, pipeList, sum, list, datatime);//产品信息
            _document.Close();
            return true;
        }
@@ -123,7 +124,7 @@
        /// <param name="sum"></param>
        /// <param name="pipeList"></param>
        /// <param name="list"></param>
        public void CreatestationInfoPage(Station station, List<Model.PipeLine> pipeList, List<Model.EtaSumSingleMonthRecord> list)
        public void CreatestationInfoPage(Station station, List<Model.PipeLine> pipeList, Model.EtaSumMultiMonthRecord sum, List<Model.EtaSumSingleMonthRecord> list, string dateTime)
        {
            _document.Open();
            _document.NewPage();
@@ -155,7 +156,7 @@
                Dt = Math.Round((double)dt, 2).ToString();
            if (dt > 1000)
                Dt = Math.Round((double)dt, 1).ToString();
            CreatestationTable(station, runcout, Qt, Dt);
            CreatestationTable(station,sum, runcout,dateTime);
            CreatestationInfoTable(pipeList, list, station.ID);
            PdfPTable table1 = new PdfPTable(3);
            float[] widths = { 80, 140, 300 };
@@ -278,7 +279,7 @@
        {
            PdfPTable table = new PdfPTable(1);
            PdfPCell cell = new PdfPCell();
            cell = CreateCell2("泵站能效日报表", _fontSize13_bold, 1, 1, 50, 0, Element.ALIGN_CENTER);
            cell = CreateCell2("泵站能效月报表", _fontSize13_bold, 1, 1, 50, 0, Element.ALIGN_CENTER);
            cell.HorizontalAlignment = Element.ALIGN_CENTER;//水平居中
            cell.VerticalAlignment = Element.ALIGN_MIDDLE;//垂直居中
            table.AddCell(cell);
@@ -291,7 +292,7 @@
        /// è®¾å¤‡ä¿¡æ¯
        /// </summary>
        //
        public void CreatestationTable(Station station, int cout, string qt, string dt)
        public void CreatestationTable(Station station, EtaSumMultiMonthRecord sum, int cout, string datatime)
        {
            PdfPTable table = new PdfPTable(4);
            PdfPCell cell = new PdfPCell();
@@ -309,15 +310,15 @@
            table.AddCell(cell);
            cell = CreateCell2("总电能" + " (A)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2(dt, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            cell = CreateCell2(sum.Dt.ToString(), _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2("总流量" + " (m³)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            cell = CreateCell2("供水量" + " (t)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2(qt, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            cell = CreateCell2(sum.Qt.ToString(), _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2("报告日期", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2("", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            cell = CreateCell2(datatime, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2("使用状态", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
@@ -356,8 +357,10 @@
                var EnginePump = ProductList.Find(x => x.BelongID == stationID && x.Name == EnginePumpLine.Name);
                var Pump = seviceEnginePump.GetChildPumpByEnginePumpID(EnginePump.CorpID, EnginePump.ID);
                var Motor = seviceEnginePump.GetChildMotorByEnginePumpID(EnginePump.CorpID, EnginePump.ID);
                cell = CreateCell2(EnginePump?.Name, _fontSize11, 1, 4, 40, 0, Element.ALIGN_CENTER);
                string EnginePumpName = "";
                if (EnginePump != null)
                    EnginePumpName = EnginePump.Name;
                cell = CreateCell2(EnginePumpName, _fontSize11, 1, 5, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                cell = CreateCell2("状态", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
@@ -372,6 +375,7 @@
                if (usetatus == 0)
                    cell.BackgroundColor = BaseColor.Gray;
                table.AddCell(cell);
                cell = CreateCell2("运行时间" + " (h)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                var runtime = Math.Round((decimal)item.RunTime / 3600, 1);
@@ -379,11 +383,17 @@
                table.AddCell(cell);
                cell = CreateCell2("泵型号", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                cell = CreateCell2(Pump?.Code, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                string PumpCode = "";
                if (Pump != null)
                    PumpCode = Pump.Code;
                cell = CreateCell2(PumpCode, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                cell = CreateCell2("电机型号", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                cell = CreateCell2(Motor?.Code, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                string MotorCode = "";
                if (Pump != null)
                    MotorCode = Motor.Code;
                cell = CreateCell2(MotorCode, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                cell = CreateCell2("总电能" + " (A)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
@@ -427,7 +437,14 @@
                    wpavg = Math.Round((double)item.WPavg, 2).ToString();
                if (item.WPavg > 1000)
                    wpavg = Math.Round((double)item.WPavg, 1).ToString();
                cell = CreateCell2(item.WPavg < 1 ? @"/" : wpavg, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                cell = CreateCell2(item.WPavg == 0 ? @"/" : wpavg, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                cell = CreateCell2("耗煤" + " (t)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                var run_coal = item.Pavg + item.BootTimes / 3600f;
                var value = ((run_coal / 10000f) * 2.7978);
                cell = CreateCell2(value == 0 ? "/" : Math.Round((double)value, 5).ToString(), _fontSize11, 3, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
            }
            table.SetWidths(widths);
@@ -670,6 +687,29 @@
            table1.WidthPercentage = percentage;//表格所占界面的百分比
            return table1;
        }
        /// <summary>
        /// æ ¹æ® å¹´ å’Œ æœˆï¼ŒèŽ·å–å½“æœˆç¬¬ä¸€å¤©
        /// </summary>
        /// <param name="years">å¹´</param>
        /// <param name="months">月</param>
        /// <returns>返回:yyyy-MM-dd å½¢å¼</returns>
        public  DateTime GetFirstDayByYearMonth(int years, int months)
        {
            DateTime datetime = DateTime.Parse(years + "-" + months + "-" + "15");
            return datetime.AddDays(1 - datetime.Day);
        }
        /// <summary>
        /// æ ¹æ® å¹´ å’Œ æœˆï¼ŒèŽ·å–å½“æœˆæœ€åŽä¸€å¤©
        /// </summary>
        /// <param name="years">å¹´</param>
        /// <param name="months">月</param>
        /// <returns>返回:yyyy-MM-dd å½¢å¼</returns>
        public  DateTime GetLastDayByYearMonth(int years, int months)
        {
            DateTime datetime = DateTime.Parse(years + "-" + months + "-" + "15");
            return datetime.AddDays(1 - datetime.Day).AddMonths(1).AddDays(-1);
        }
    }
}
#endregion