| | |
| | | [ApiDescriptionSettings("DataFile", Name = "测试", Order = 999)] |
| | | public class Test_Controller : IDynamicApiController, ITransient |
| | | { |
| | | private readonly IHttpContextAccessor _httpContextAccessor; |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public Test_Controller(IHttpContextAccessor httpContextAccessor) |
| | | { |
| | | _httpContextAccessor = httpContextAccessor; |
| | | } |
| | | |
| | | private readonly Service.EtaMultiRealRecord _service = new Service.EtaMultiRealRecord(); |
| | | |
| | | /// <summary> |
| | | /// 生成 |
| | | /// </summary> |
| | | [Route("Create@V1.0")] |
| | | [HttpPost] |
| | | public bool Create([Required] DataFileTestInput input) |
| | | public string Create([FromQuery][Required] ObjectUnderCorpInput input, [FromQuery][Required] DateTime DateTime) |
| | | { |
| | | var filePath = FileHelper.GetFilePath2(input.Sub,input.Name); |
| | | var paras = new DataFile.EnginePumpDayReportParasV1(); |
| | | paras.EnginePumpName = "测试机泵"; |
| | | paras.EnginePumpNo = "测试编码"; |
| | | paras.ReportDay = DateTime.Now.Date; |
| | | paras.ErangeList = new List<KeyValuePair<string, string>>() |
| | | var station = new Service.Station().GetByID(input.CorpID,input.ObjectID); |
| | | var ePumpPipeLineList = new Service.PipeLine().GetByBelongTypeAndBelongID(input.CorpID,input.ObjectType,input.ObjectID)?.FindAll(x => x.Catalog == IStation.Product.Catalog_JiBeng); |
| | | if (ePumpPipeLineList == null) |
| | | return null; |
| | | List<Model.EtaSumSingleDayRecord> etaSumSingleDayRecordList = new List<Model.EtaSumSingleDayRecord>(); |
| | | foreach (var pipeLineitem in ePumpPipeLineList) |
| | | { |
| | | new KeyValuePair<string, string>("20%-50%","2h"), |
| | | new KeyValuePair<string, string>("50%-60%","3h"), |
| | | new KeyValuePair<string, string>("60%-80%","4h"), |
| | | new KeyValuePair<string, string>("80%-100%","5h"), |
| | | }; |
| | | paras.RunTime = "14h"; |
| | | var helper = new DataFile.EnginePumpDayReportV1Helper(); |
| | | var bol = helper.Create(filePath, paras,out string msg); |
| | | if (!bol) |
| | | { |
| | | throw new Exception(msg); |
| | | var etaSumSingleRecord = new Service.EtaSumSingleRecord().GetDayByObjectOfDay(pipeLineitem.CorpID, IStation.ObjectType.PipeLine, pipeLineitem.ID, DateTime); |
| | | etaSumSingleDayRecordList.Add(etaSumSingleRecord); |
| | | } |
| | | return bol; |
| | | |
| | | ReportPdf4Default pdf = new ReportPdf4Default(); |
| | | |
| | | string DataPath= ConfigHelper.DataPath; |
| | | string PATH = ""; |
| | | var Data= Directory.CreateDirectory(DataPath + "\\能效报告"); |
| | | if (Data != null) |
| | | { |
| | | PATH = DataPath+ "\\能效报告\\"+station.Name+"_能效报告_"+DateTime.Now.ToString("yyyy.MM.dd.hh.mm.ss")+".pdf"; |
| | | } |
| | | |
| | | if (pdf.Create4Stream(station,ePumpPipeLineList, etaSumSingleDayRecordList, DateTime, PATH)) |
| | | return PATH = string.Format("http://101.133.133.173:9019/" + PATH); |
| | | return PATH; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取 |
| | | /// </summary> |
| | | [Route("Get@V1.0")] |
| | | [HttpGet] |
| | | public string Get([FromQuery][Required] DataFileTestInput input) |
| | | { |
| | | var url = $"http://{_httpContextAccessor.HttpContext.Request.Host}/{FileHelper.GetRelatedFilePath(input.Sub, input.Name)}"; |
| | | return url; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |