ningshuxia
2022-11-30 79c26fdc8c4c4fa459318460d85faef8e50321ed
Merge branch 'master' of http://47.103.154.90:83/r/IStation/Service.V4.1
已修改4个文件
198 ■■■■■ 文件已修改
Application/IStation.Application.DataFile/eta_day_report/Eta_Day_Report_Controller.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.DataFile/eta_day_report/PdfCreate/Eta_Day_ReportPdf.cs 153 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.DataFile/eta_month_report/Eta_Month_Report_Controller.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.DataFile/eta_month_report/PdfCreate/Eta_Month_ReportPdf.cs 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Application/IStation.Application.DataFile/eta_day_report/Eta_Day_Report_Controller.cs
@@ -15,6 +15,7 @@
namespace IStation.Application
{
    #region 报表生成
    /// <summary>
    /// Report
    /// </summary>
@@ -57,7 +58,7 @@
            }
            LogHelper.Info("生成根目录");
            var pdf = new Eta_Day_ReportPdf();
            var ReportPath = Path.Combine(ConfigHelper.DataPath, Settings.DataFile.PdfFolder);
            var ReportPath = Path.Combine(ConfigHelper.DataPath, @"Report");
            if (!Directory.Exists(ReportPath))
                Directory.CreateDirectory(ReportPath);
            LogHelper.Info("拼接日期文件夹");
@@ -75,8 +76,8 @@
            var etaPdfFileName = $"Station_Eta_{station.ID}_{input.DateTime.ToString("MM-dd")}.pdf";
            var etaPdfFilePath = Path.Combine(pdfPath, etaPdfFileName);
            var turePath = Path.Combine("/" + Settings.DataFile.PdfFolder, EtaPathName, dateTimePathName, etaPdfFileName);
            turePath = turePath.Replace("\\", "/");
            var turePath = Path.Combine(@"Report", EtaPathName, dateTimePathName, etaPdfFileName);
            turePath = turePath.Replace(@"\\", @"/");
            LogHelper.Info("拼接最终路径");
            if (!File.Exists(etaPdfFilePath))
@@ -102,4 +103,5 @@
    }
#endregion
}
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("主体已创建");
Application/IStation.Application.DataFile/eta_month_report/Eta_Month_Report_Controller.cs
@@ -68,7 +68,7 @@
            }
            var pdf = new Eta_Month_ReportPdf();
            var ReportPath = Path.Combine(ConfigHelper.DataPath, Settings.DataFile.PdfFolder);
            var ReportPath = Path.Combine(ConfigHelper.DataPath, @"Report");
            if (!Directory.Exists(ReportPath))
                Directory.CreateDirectory(ReportPath);
            LogHelper.Info("已创建根目录");
@@ -89,8 +89,8 @@
            var etaPdfFilePath = Path.Combine(pdfPath, etaPdfFileName);
            LogHelper.Info("已拼接最终文件路径");
            var turePath = Path.Combine("/" + Settings.DataFile.PdfFolder, EtaPathName, dateTimePathName, etaPdfFileName);
            turePath = turePath.Replace("\\", "/");
            var turePath = Path.Combine(@"Report", EtaPathName, dateTimePathName, etaPdfFileName);
            turePath = turePath.Replace(@"\\", @"/");
            LogHelper.Info("已拼接最终返回路径");
            if (!File.Exists(etaPdfFilePath))
Application/IStation.Application.DataFile/eta_month_report/PdfCreate/Eta_Month_ReportPdf.cs
@@ -5,6 +5,7 @@
using iTextSharp.text.pdf;
using iTextSharp.text.rtf.headerfooter;
using Microsoft.AspNetCore.Http;
using System;
using System.Text;
namespace IStation.Application
@@ -15,7 +16,7 @@
    /// </summary>
    public class Eta_Month_ReportPdf
    {
        #region 属性
        #region 报表生成
        Document _document;
        PdfWriter _writer;
        //BaseFont _baseFont_general = null;//常规字体
@@ -40,6 +41,20 @@
        /// <returns></returns>
        public bool Create4Stream(Station station, Model.EtaSumMultiMonthRecord sum, List<Model.PipeLine> pipeList, List<Model.EtaSumSingleMonthRecord> list, string datatime,long corpID, string path)
        {
            if (station == null)
                return false;
            if (pipeList == null || pipeList.Count < 1)
                return false;
            if (sum == null)
                return false;
            if (list == null || list.Count < 1)
                return false;
            if (corpID < 1)
                return false;
            if (string.IsNullOrEmpty(datatime))
                return false;
            if (path =="")
                return false;
            InitialFont();
            //初始化标题中的LOGO图片
            InitialTitleLogoImage();
@@ -132,6 +147,18 @@
        /// <param name="dateTime"></param>
        public void CreatestationInfoPage(Station station, List<Model.PipeLine> pipeList, Model.EtaSumMultiMonthRecord sum, List<Model.EtaSumSingleMonthRecord> list,long corpID, string dateTime)
        {
            if (station == null)
                return;
            if (pipeList == null || pipeList.Count < 1)
                return;
            if (sum == null)
                return;
            if (list == null||list.Count<1)
                return;
            if (corpID<1)
                return;
            if (string.IsNullOrEmpty(dateTime))
                return;
            _document.Open();
            _document.NewPage();
            _currentPage++;
@@ -731,5 +758,5 @@
            return datetime.AddDays(1 - datetime.Day).AddMonths(1).AddDays(-1);
        }
    }
    #endregion
}
#endregion