wangzelong
2022-11-30 ebe14c5eb181f60f3380ba9389bc170e5c395f6a
Application/IStation.Application.DataFile/eta_day_report/PdfCreate/Eta_Day_ReportPdf.cs
@@ -1,4 +1,5 @@
using IStation.Application.Report.Helper;
using Furion.LinqBuilder;
using IStation.Application.Report.Helper;
using IStation.Model;
using IStation.Model.Eta;
using iTextSharp.text;
@@ -30,7 +31,7 @@
        /// <summary>
        /// 生成报表
        /// </summary>
        /// <param name="station">泵站信息</param>
        /// <param name="station?">泵站信息</param>
        /// <param name="datatime">时间</param>
        /// <param name="pipeList">机泵管路列表</param>
        /// <param name="list">机泵信息列表</param>
@@ -39,6 +40,18 @@
        /// <returns></returns>
        public bool Create4Stream(Station station, List<Model.PipeLine> pipeList, List<EtaSumSingleDayRecord> list,long corpID, DateTime datatime, string path)
        {
            if (station == null)
                return false;
            if (pipeList == null || pipeList.Count < 1)
                return false;
            if (list == null || list.Count < 1)
                return false;
            if (corpID < 1)
                return false;
            if (string.IsNullOrEmpty(datatime.ToShortDateString()))
                return false;
            if (path == "")
                return false;
            InitialFont();
            //初始化标题中的LOGO图片
            InitialTitleLogoImage();
@@ -124,7 +137,7 @@
        /// <summary>
        /// 
        /// </summary>
        /// <param name="station"></param>
        /// <param name="station?"></param>
        /// <param name="pipeList"></param>
        /// <param name="list"></param>
        /// <param name="dateTime"></param>
@@ -138,14 +151,17 @@
            int runcout = 0;
            double? qt = 0;
            double? dt = 0;
            foreach (var item in list)
            if (list != null || list.Count > 0)
            {
                if (item.RunTime > 0)
                    runcout = runcout + 1;
                if (item.Qt > 0)
                    qt += item.Qt;
                if (item.Dt > 0)
                    dt += item.Dt;
                foreach (var item in list)
                {
                    if (item.RunTime > 0)
                        runcout = runcout + 1;
                    if (item.Qt > 0)
                        qt += item.Qt;
                    if (item.Dt > 0)
                        dt += item.Dt;
                }
            }
            LogHelper.Info("设置总电能和总流量");
            string Qt = "";
@@ -171,14 +187,14 @@
            LogHelper.Info("保留电能和流量小数");
            CreatestationTable(station, runcout, dateTime, Qt, Dt);
            LogHelper.Info("创建泵站能效整合表格");
            CreatestationInfoTable(pipeList, list, corpID, station.ID);
            CreatestationInfoTable(pipeList, list, corpID, station?.ID);
            LogHelper.Info("创建泵站能效主体表格");
            PdfPTable table1 = new PdfPTable(3);
            float[] widths = { 80, 140, 300 };
            table1.SetWidths(widths);
            PdfPCell cell = new PdfPCell();
            cell = CreateCell2("设备状态:" + station.UseStatus, _fontSize8, 1, 1);
            cell = CreateCell2("设备状态:" + station?.UseStatus, _fontSize8, 1, 1);
            table1.AddCell(cell);
            _document.Add(table1);
            CreatePropTable();
@@ -317,7 +333,7 @@
            table.AddCell(cell);
            cell = CreateCell2("泵站名称", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2(station.Name, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            cell = CreateCell2(station?.Name, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2("运行数量" + " (台)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
@@ -333,19 +349,19 @@
            table.AddCell(cell);
            cell = CreateCell2("报告日期", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2(datatime.ToShortDateString(), _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            cell = CreateCell2(datatime.ToShortDateString()==""? "": datatime.ToShortDateString(), _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(station.UseStatus == eUseStatus.Enable ? "使用中" : "已停用", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            if (station.UseStatus == eUseStatus.Enable)
            cell = CreateCell2(station?.UseStatus == eUseStatus.Enable ? "使用中" : "已停用", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            if (station?.UseStatus == eUseStatus.Enable)
                cell.BackgroundColor = BaseColor.Green;
            if (station.UseStatus == eUseStatus.Disable)
            if (station?.UseStatus == eUseStatus.Disable)
                cell.BackgroundColor = BaseColor.Gray;
            table.AddCell(cell);
            cell = CreateCell2("地址", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            cell = CreateCell2(station.Address, _fontSize11, 3, 1, 40, 0, Element.ALIGN_CENTER);
            cell = CreateCell2(station?.Address, _fontSize11, 3, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            table.SetWidths(widths);
@@ -360,112 +376,21 @@
        /// <param name="list"></param>
        /// <param name="stationID"></param>
        /// <param name="corpID"></param>
        public void CreatestationInfoTable(List<Model.PipeLine> pipeList, List<EtaSumSingleDayRecord> list,long corpID, long stationID)
        public void CreatestationInfoTable(List<Model.PipeLine> pipeList, List<EtaSumSingleDayRecord> list,long corpID, long? stationID)
        {
            PdfPTable table = new PdfPTable(5);
            PdfPCell cell = new PdfPCell();
            float[] widths = new float[] { 60, 60, 60, 60, 60 };
            var ProductList = new Service.Product().GetByCorpID(list.FirstOrDefault().CorpID);
            var ProductList = new Service.Product().GetByCorpID(corpID);
            cell = CreateCell2("能效信息", _fontSize11, 5, 1, 40, 0, Element.ALIGN_CENTER);
            table.AddCell(cell);
            var seviceEnginePump = new Service.Product();
            foreach (var item in list)
            if (list != null || list.Count > 0)
            {
                var EnginePumpLine = pipeList.Find(x => x.ID == item.ObjectID);
                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);
                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);
                int usetatus = 0;
                if (item.UWPavg < 1)
                    usetatus = 0;
                if (item.UWPavg > 0)
                    usetatus = 1;
                cell = CreateCell2(usetatus == 1 ? "开启" : "未开启", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                if (usetatus == 1)
                    cell.BackgroundColor = BaseColor.Green;
                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);
                cell = CreateCell2(runtime < 1 ? @"/" : runtime.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);
                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);
                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);
                string Dt = "";
                if (item.Dt < 10)
                    Dt = Math.Round((double)item.Dt, 3).ToString();
                if (10 < item.Dt && item.Dt < 1000)
                    Dt = Math.Round((double)item.Dt, 2).ToString();
                if (item.Dt > 1000)
                    Dt = Math.Round((double)item.Dt, 1).ToString();
                cell = CreateCell2(item.Dt < 1 ? @"/" : Dt, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                cell = CreateCell2("总流量" + " (m³)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                string Qt = "";
                if (item.Qt < 10)
                    Qt = Math.Round((double)item.Qt, 3).ToString();
                if (10 < item.Qt && item.Qt < 1000)
                    Qt = Math.Round((double)item.Qt, 2).ToString();
                if (item.Qt > 1000)
                    Qt = Math.Round((double)item.Qt, 1).ToString();
                cell = CreateCell2(item.Qt < 1 ? @"/" : Qt, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                cell = CreateCell2("平均单位能耗" + " \n(kw·h)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                string UWPavg = "";
                if (item.UWPavg < 10)
                    UWPavg = Math.Round((double)item.UWPavg, 3).ToString();
                if (10 < item.UWPavg && item.UWPavg < 1000)
                    UWPavg = Math.Round((double)item.UWPavg, 2).ToString();
                if (item.UWPavg > 1000)
                    UWPavg = Math.Round((double)item.UWPavg, 1).ToString();
                cell = CreateCell2(item.UWPavg < 1 ? @"/" : UWPavg, _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                cell = CreateCell2("平均千吨能耗" + " \n(kw·h)", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER);
                table.AddCell(cell);
                string wpavg = "";
                if (item.WPavg < 10)
                    wpavg = Math.Round((double)item.WPavg, 3).ToString();
                if (10 < item.WPavg && item.WPavg < 1000)
                    wpavg = Math.Round((double)item.WPavg, 2).ToString();
                if (item.WPavg > 1000)
                    wpavg = Math.Round((double)item.WPavg, 1).ToString();
                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);
            _document.Add(table);
            LogHelper.Info("主体已创建");