From 987d288f74e7ebeb5f8b5fb66f8154fe1da42896 Mon Sep 17 00:00:00 2001 From: DavidMakarov Date: Wed, 29 May 2024 17:51:41 +0400 Subject: [PATCH 1/2] report view fix --- .../Implements/WorkpieceStorage.cs | 2 -- .../Home/PlanProductionByProductReport.cshtml | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Factory/FactoryDatabaseImplement/Implements/WorkpieceStorage.cs b/Factory/FactoryDatabaseImplement/Implements/WorkpieceStorage.cs index c63f45c..64c4dcc 100644 --- a/Factory/FactoryDatabaseImplement/Implements/WorkpieceStorage.cs +++ b/Factory/FactoryDatabaseImplement/Implements/WorkpieceStorage.cs @@ -19,8 +19,6 @@ namespace FactoryDatabaseImplement.Implements .Select(x => new WorkpieceTimeReportViewModel() { WorkpieceName = x.WorkpieceName, - ExecutionPhases = x.ExecutionPhases.Select(x => x.PlanProduction.GetViewModel).ToList(), - Machines = x.Machines.Select(x => x.Product.GetViewModel).ToList(), }) .ToList(); } diff --git a/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml b/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml index 57e3ca1..95af491 100644 --- a/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml +++ b/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml @@ -23,6 +23,8 @@ Изделие План производства + Количество + Срок @@ -38,6 +40,22 @@ } + + + + + + } From 8af62f18f372baa44fea715f5cef5cf079cd3685 Mon Sep 17 00:00:00 2001 From: DavidMakarov Date: Wed, 29 May 2024 18:46:06 +0400 Subject: [PATCH 2/2] savetoword, savetoexcel implementation --- .../BusinessLogics/StorekeeperReportLogic.cs | 2 +- .../OfficePackage/AbstractSaveToPdf.cs | 2 +- .../OfficePackage/AbstractSaveToWord.cs | 31 ++++++++----- .../Controllers/HomeController.cs | 45 +++++++++++++++++++ .../Views/Home/MachinePeriodReport.cshtml | 4 +- .../Home/PlanProductionByProductReport.cshtml | 16 +++++++ 6 files changed, 86 insertions(+), 14 deletions(-) diff --git a/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs b/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs index ec74ddb..3cf175a 100644 --- a/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs +++ b/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs @@ -44,7 +44,7 @@ namespace FactoryBusinessLogic.BusinessLogics _saveToPdf.CreateStorekeeperDoc(new StorekeeperPdfInfo { FileName = model.FileName, - Title = "Список станков", + Title = "Список станков за период", DateFrom = model.DateFrom!.Value, DateTo = model.DateTo!.Value, Machines = GetMachines(client, model) diff --git a/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToPdf.cs b/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToPdf.cs index fd9032d..7ac555c 100644 --- a/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -16,7 +16,7 @@ namespace FactoryBusinessLogic.OfficePackage }); CreateParagraph(new PdfParagraph { - Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", + Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateTable(new List { "3cm", "5cm", "5cm"}); diff --git a/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToWord.cs b/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToWord.cs index 025c707..c0023da 100644 --- a/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -21,21 +21,10 @@ namespace FactoryBusinessLogic.OfficePackage }); foreach (var ppp in info.ProductPlanProductions) { - var t = ppp.PlanProductions; List<(string, WordTextProperties)> texts = new List<(string, WordTextProperties)> { (ppp.ProductName, new WordTextProperties { Bold = true, Size = "24", }) }; - foreach (var plan in ppp.PlanProductions) - { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.Append(plan.ProductionName); - stringBuilder.Append(" — "); - stringBuilder.Append(plan.Count.ToString()); - stringBuilder.Append(" — "); - stringBuilder.Append(plan.Deadline.ToString()); - texts.Add((stringBuilder.ToString(), new WordTextProperties { Size = "24" })); - } CreateParagraph(new WordParagraph { Texts = texts, @@ -45,6 +34,26 @@ namespace FactoryBusinessLogic.OfficePackage JustificationType = WordJustificationType.Both } }); + foreach (var plan in ppp.PlanProductions) + { + texts = new List<(string, WordTextProperties)>(); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.Append(plan.ProductionName); + stringBuilder.Append(" — "); + stringBuilder.Append(plan.Count.ToString()); + stringBuilder.Append(" — "); + stringBuilder.Append(plan.Deadline.ToString()); + texts.Add((stringBuilder.ToString(), new WordTextProperties { Size = "24" })); + CreateParagraph(new WordParagraph + { + Texts = texts, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } } SaveStorekeeperWord(info); } diff --git a/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs b/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs index 34a9256..7678e88 100644 --- a/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs +++ b/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs @@ -415,6 +415,8 @@ namespace FactoryStorekeeperApp.Controllers { return Redirect("~/Home/Enter"); } + ViewBag.DateFrom = datefrom; + ViewBag.DateTo = dateto; var reports = storekeeperReportLogic.GetMachines( new ClientSearchModel { @@ -446,8 +448,51 @@ namespace FactoryStorekeeperApp.Controllers { return Redirect("~/Home/Enter"); } + ViewBag.ids = products; var report = storekeeperReportLogic.GetPlanProductionsByProduct(products); return View(report); + } + + [HttpPost] + public IActionResult CreateWord(List ids) + { + storekeeperReportLogic.SavePlanProductionsToWordFile( + new ReportBindingModel + { + FileName = "D:\\temp\\report.docx" + }, + ids); + return PhysicalFile("D:\\temp\\report.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Отчет по изделиям.docx"); + } + + [HttpPost] + public IActionResult CreateExcel(List ids) + { + storekeeperReportLogic.SavePlanProductionsToExcelFile( + new ReportBindingModel + { + FileName = "D:\\temp\\report.xlsx" + }, + ids); + return PhysicalFile("D:\\temp\\report.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Отчет по изделиям.xlsx"); + } + + [HttpPost] + public IActionResult SendMail(DateTime datefrom, DateTime dateto) + { + storekeeperReportLogic.SaveMachinesToPdfFile( + new ClientSearchModel + { + Id = Client.client.Id + }, + new ReportBindingModel + { + DateFrom = datefrom, + DateTo = dateto, + FileName="D:\\temp\\report.pdf" + }); + // TODO: implement sending + throw new NotImplementedException(); } } } diff --git a/Factory/FactoryStorekeeperApp/Views/Home/MachinePeriodReport.cshtml b/Factory/FactoryStorekeeperApp/Views/Home/MachinePeriodReport.cshtml index 53bf257..1d7e432 100644 --- a/Factory/FactoryStorekeeperApp/Views/Home/MachinePeriodReport.cshtml +++ b/Factory/FactoryStorekeeperApp/Views/Home/MachinePeriodReport.cshtml @@ -10,7 +10,9 @@

Список станков за период

-
+ + +
diff --git a/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml b/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml index 95af491..5b05d55 100644 --- a/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml +++ b/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml @@ -11,9 +11,25 @@
+
+ +
+
+ +