ÎļþÃû´Ó Application/IStation.Application.DataFile/Report/PdfCreate/ReportPdf4Default.cs ÐÞ¸Ä |
| | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class ReportPdf4Default |
| | | public class Eta_Day_ReportPdf |
| | | { |
| | | #region 屿§ |
| | | Document _document; |
| | |
| | | var ProductList = new Service.Product().GetByCorpID(list.FirstOrDefault().CorpID); |
| | | cell = CreateCell2("è½æä¿¡æ¯", _fontSize11, 5, 1, 40, 0, Element.ALIGN_CENTER); |
| | | table.AddCell(cell); |
| | | var seviceEnginePump = new Service.Product(); |
| | | foreach (var item in list) |
| | | { |
| | | var EnginePumpLine = pipeList?.Find(x => x.ID == item.ObjectID); |
| | | var EnginePump = ProductList.Find(x => x.BelongID == stationID && x.Name == EnginePumpLine.Name); |
| | | var Pump = new Service.Product().GetChildPumpByEnginePumpID(EnginePump.CorpID, EnginePump.ID); |
| | | var Motor = new Service.Product().GetChildMotorByEnginePumpID(EnginePump.CorpID, EnginePump.ID); |
| | | 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); |
| | | table.AddCell(cell); |
copy from Application/IStation.Application.DataFile/Report/PdfCreate/ReportPdf4Default.cs
copy to Application/IStation.Application.DataFile/Report/PdfCreate/Eta_Month_ReportPdf.cs
Îļþ´Ó Application/IStation.Application.DataFile/Report/PdfCreate/ReportPdf4Default.cs ¸´ÖÆ |
| | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public class ReportPdf4Default |
| | | public class Eta_Month_ReportPdf |
| | | { |
| | | #region 屿§ |
| | | Document _document; |
| | |
| | | /// <param name="list">æºæ³µä¿¡æ¯å表</param> |
| | | /// <param name="path">è·¯å¾</param> |
| | | /// <returns></returns> |
| | | public bool Create4Stream(Station station, List<Model.PipeLine> pipeList, List<EtaSumSingleDayRecord> list, DateTime datatime, string path) |
| | | public bool Create4Stream(Station station, List<Model.PipeLine> pipeList, List<Model.EtaSumSingleMonthRecord> list,string path) |
| | | { |
| | | InitialFont(); |
| | | //åå§åæ é¢ä¸çLOGOå¾ç |
| | |
| | | _document.SetMargins(-40, -40, 40, 40); |
| | | _writer = PdfWriter.GetInstance(_document, new FileStream(path, FileMode.Create)); |
| | | _writer.PageEvent = new CreatHeaderAndFoot(); |
| | | CreatestationInfoPage(station, pipeList, list, datatime);//产åä¿¡æ¯ |
| | | CreatestationInfoPage(station, pipeList, list);//产åä¿¡æ¯ |
| | | _document.Close(); |
| | | return true; |
| | | } |
| | |
| | | /// <param name="sum"></param> |
| | | /// <param name="pipeList"></param> |
| | | /// <param name="list"></param> |
| | | public void CreatestationInfoPage(Station station, List<Model.PipeLine> pipeList, List<EtaSumSingleDayRecord> list, DateTime dateTime) |
| | | public void CreatestationInfoPage(Station station, List<Model.PipeLine> pipeList, List<Model.EtaSumSingleMonthRecord> list) |
| | | { |
| | | _document.Open(); |
| | | _document.NewPage(); |
| | |
| | | Dt = Math.Round((double)dt, 2).ToString(); |
| | | if (dt > 1000) |
| | | Dt = Math.Round((double)dt, 1).ToString(); |
| | | CreatestationTable(station, runcout, dateTime, Qt, Dt); |
| | | CreatestationTable(station, runcout, Qt, Dt); |
| | | CreatestationInfoTable(pipeList, list, station.ID); |
| | | PdfPTable table1 = new PdfPTable(3); |
| | | float[] widths = { 80, 140, 300 }; |
| | |
| | | /// 设å¤ä¿¡æ¯ |
| | | /// </summary> |
| | | // |
| | | public void CreatestationTable(Station station, int cout, DateTime datatime, string qt, string dt) |
| | | public void CreatestationTable(Station station, int cout, string qt, string dt) |
| | | { |
| | | PdfPTable table = new PdfPTable(4); |
| | | PdfPCell cell = new PdfPCell(); |
| | |
| | | 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("", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER); |
| | | table.AddCell(cell); |
| | | cell = CreateCell2("使ç¨ç¶æ", _fontSize11, 1, 1, 40, 0, Element.ALIGN_CENTER); |
| | | table.AddCell(cell); |
| | |
| | | /// çææºæ³µå表 |
| | | /// </summary> |
| | | /// <param name="list">æºæ³µå表</param> |
| | | public void CreatestationInfoTable(List<Model.PipeLine> pipeList, List<EtaSumSingleDayRecord> list, long stationID) |
| | | public void CreatestationInfoTable(List<Model.PipeLine> pipeList, List<Model.EtaSumSingleMonthRecord> list, long stationID) |
| | | { |
| | | |
| | | PdfPTable table = new PdfPTable(5); |
| | |
| | | var ProductList = new Service.Product().GetByCorpID(list.FirstOrDefault().CorpID); |
| | | cell = CreateCell2("è½æä¿¡æ¯", _fontSize11, 5, 1, 40, 0, Element.ALIGN_CENTER); |
| | | table.AddCell(cell); |
| | | var seviceEnginePump = new Service.Product(); |
| | | foreach (var item in list) |
| | | { |
| | | var EnginePumpLine = pipeList?.Find(x => x.ID == item.ObjectID); |
| | | var EnginePump = ProductList.Find(x => x.BelongID == stationID && x.Name == EnginePumpLine.Name); |
| | | var Pump = new Service.Product().GetChildPumpByEnginePumpID(EnginePump.CorpID, EnginePump.ID); |
| | | var Motor = new Service.Product().GetChildMotorByEnginePumpID(EnginePump.CorpID, EnginePump.ID); |
| | | 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); |
| | | table.AddCell(cell); |
| | |
| | | namespace IStation.Application |
| | | { |
| | | /// <summary> |
| | | /// æ¥è¡¨ |
| | | /// Report |
| | | /// </summary> |
| | | [AllowAnonymous] |
| | | [Route("DataFile/Report ")] |
| | |
| | | /// </summary> |
| | | [Route("StationEtaDayReport@V1.0")] |
| | | [HttpPost] |
| | | public string StationEtaDayReport([FromQuery][Required] ObjectUnderCorpInput input, [FromQuery][Required] DateTime DateTime) |
| | | public string StationEtaDayReport([FromQuery][Required] ObjectUnderCorpInput input, int year,int month) |
| | | { |
| | | var station = new Service.Station().GetByID(input.CorpID, input.ObjectID); |
| | | if (station == null) |
| | |
| | | throw Oops.Oh(ErrorCodes.D001, $"æºæ³µä¸åå¨!"); |
| | | } |
| | | |
| | | var etaSumSingleDayRecordList = new List<Model.EtaSumSingleDayRecord>(); |
| | | var etaSumSingleDayRecordList = new List<Model.EtaSumSingleMonthRecord>(); |
| | | var etaSumSingleService = new Service.EtaSumSingleRecord(); |
| | | foreach (var pipeLineitem in pumpPipeLineList) |
| | | { |
| | | var etaSumSingleRecord = etaSumSingleService.GetDayByObjectOfDay(pipeLineitem.CorpID, IStation.ObjectType.PipeLine, pipeLineitem.ID, DateTime); |
| | | var etaSumSingleRecord = etaSumSingleService.GetMonthByObjectOfMonth(pipeLineitem.CorpID, IStation.ObjectType.PipeLine, pipeLineitem.ID, year,month); |
| | | etaSumSingleDayRecordList.Add(etaSumSingleRecord); |
| | | } |
| | | |
| | | if (etaSumSingleDayRecordList == null || etaSumSingleDayRecordList.Count < 1) |
| | | { |
| | | throw Oops.Oh(ErrorCodes.D001, $"è½ææ°æ®ä¸åå¨!-æ¥æ:[{DateTime}]"); |
| | | throw Oops.Oh(ErrorCodes.D001, $"è½ææ°æ®ä¸åå¨!-æ¥æ:[{year-month}]"); |
| | | } |
| | | |
| | | var pdf = new ReportPdf4Default(); |
| | | var pdf = new Eta_Month_ReportPdf(); |
| | | var folderPath = Path.Combine(ConfigHelper.DataPath, Settings.DataFile.PdfFolder); |
| | | if (!Directory.Exists(folderPath)) |
| | | Directory.CreateDirectory(folderPath); |
| | | |
| | | var etaPdfFileName = $"{station.Name}_Eta_{DateTime.ToString("M")}.pdf"; |
| | | var etaPdfFileName = $"{station.Name}_Eta_{DateTime.Now.ToString("M")}.pdf"; |
| | | var etaPdfFilePath = Path.Combine(folderPath, etaPdfFileName); |
| | | if (File.Exists(etaPdfFilePath)) |
| | | File.Delete(etaPdfFilePath); |
| | | |
| | | if (!pdf.Create4Stream(station, pumpPipeLineList, etaSumSingleDayRecordList, DateTime, etaPdfFilePath)) |
| | | if (!pdf.Create4Stream(station, pumpPipeLineList, etaSumSingleDayRecordList, etaPdfFilePath)) |
| | | { |
| | | throw Oops.Oh(ErrorCodes.D002, $"[{etaPdfFileName}]æä»¶çæå¤±è´¥!"); |
| | | } |