| | |
| | | namespace IStation.Application |
| | | { |
| | | /// <summary> |
| | | /// Test |
| | | /// 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}]文件生成失败!"); |
| | | } |