diff --git a/ServiceStation/ServiceStationBusinessLogic/BusinessLogic/ClientLogic.cs b/ServiceStation/ServiceStationBusinessLogic/BusinessLogic/ClientLogic.cs index 366d9aa..5a45b9e 100644 --- a/ServiceStation/ServiceStationBusinessLogic/BusinessLogic/ClientLogic.cs +++ b/ServiceStation/ServiceStationBusinessLogic/BusinessLogic/ClientLogic.cs @@ -87,7 +87,7 @@ namespace ServiceStationBusinessLogic.BusinessLogic { throw new ArgumentNullException("Нет ФИО клиента", nameof(model.FIO)); } - _logger.LogInformation($"Client.Id:{model.Id}.FIO:{model.FIO}.TotalPoints:{model.TotalPoints}"); + _logger.LogInformation($"Client.Id:{model.Id}.FIO:{model.FIO}"); } } } diff --git a/ServiceStation/ServiceStationBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/ServiceStation/ServiceStationBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 685f5ae..a3f2dc8 100644 --- a/ServiceStation/ServiceStationBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/ServiceStation/ServiceStationBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -33,6 +33,12 @@ namespace ServiceStationBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.Text }); + InsertCellInWorksheet(new ExcelCellParameters { + ColumnName = "B", + RowIndex = rowIndex, + StyleInfo = ExcelStyleInfoType.Text + }); + MergeCells(new ExcelMergeParameters { CellFromName = $"A{rowIndex}", CellToName = $"B{rowIndex}" @@ -45,6 +51,12 @@ namespace ServiceStationBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.Text }); + InsertCellInWorksheet(new ExcelCellParameters { + ColumnName = "D", + RowIndex = rowIndex, + StyleInfo = ExcelStyleInfoType.Text + }); + MergeCells(new ExcelMergeParameters { CellFromName = $"C{rowIndex}", CellToName = $"D{rowIndex}" @@ -57,6 +69,12 @@ namespace ServiceStationBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.Text }); + InsertCellInWorksheet(new ExcelCellParameters { + ColumnName = "F", + RowIndex = rowIndex, + StyleInfo = ExcelStyleInfoType.Text + }); + MergeCells(new ExcelMergeParameters { CellFromName = $"E{rowIndex}", CellToName = $"F{rowIndex}" @@ -71,6 +89,12 @@ namespace ServiceStationBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.TextWithBorder }); + InsertCellInWorksheet(new ExcelCellParameters { + ColumnName = "C", + RowIndex = rowIndex, + StyleInfo = ExcelStyleInfoType.TextWithBorder + }); + MergeCells(new ExcelMergeParameters { CellFromName = $"B{rowIndex}", CellToName = $"C{rowIndex}" @@ -83,6 +107,11 @@ namespace ServiceStationBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.TextWithBorder }); + InsertCellInWorksheet(new ExcelCellParameters { + ColumnName = "E", + RowIndex = rowIndex, + StyleInfo = ExcelStyleInfoType.TextWithBorder + }); MergeCells(new ExcelMergeParameters { CellFromName = $"D{rowIndex}", diff --git a/ServiceStation/ServiceStationBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/ServiceStation/ServiceStationBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 921535a..e6d8d92 100644 --- a/ServiceStation/ServiceStationBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/ServiceStation/ServiceStationBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -10,6 +10,9 @@ namespace ServiceStationBusinessLogic.OfficePackage { public abstract class AbstractSaveToWord { public byte[]? CreateDoc(WordInfo info) { + + CreateWord(info); + CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24"})}, TextProperties = new WordTextProperties { diff --git a/ServiceStation/ServiceStationContracts/BindingModels/ClientBindingModel.cs b/ServiceStation/ServiceStationContracts/BindingModels/ClientBindingModel.cs index d10fdd8..8a2e94c 100644 --- a/ServiceStation/ServiceStationContracts/BindingModels/ClientBindingModel.cs +++ b/ServiceStation/ServiceStationContracts/BindingModels/ClientBindingModel.cs @@ -6,6 +6,5 @@ namespace ServiceStationContracts.BindingModels public int Id { get; set; } public string FIO { get; set; } = string.Empty; - public int TotalPoints { get; set; } } } diff --git a/ServiceStation/ServiceStationContracts/ViewModels/ClientViewModel.cs b/ServiceStation/ServiceStationContracts/ViewModels/ClientViewModel.cs index c38513e..57dde40 100644 --- a/ServiceStation/ServiceStationContracts/ViewModels/ClientViewModel.cs +++ b/ServiceStation/ServiceStationContracts/ViewModels/ClientViewModel.cs @@ -10,9 +10,6 @@ namespace ServiceStationContracts.ViewModels [DisplayName("ФИО")] public string FIO { get; set; } = string.Empty; - [DisplayName("Всего баллов")] - public int TotalPoints { get; set; } - public bool Equals(ClientViewModel? other) { if (other is null) { return false; diff --git a/ServiceStation/ServiceStationDataModels/Models/IClientModel.cs b/ServiceStation/ServiceStationDataModels/Models/IClientModel.cs index c933265..662744e 100644 --- a/ServiceStation/ServiceStationDataModels/Models/IClientModel.cs +++ b/ServiceStation/ServiceStationDataModels/Models/IClientModel.cs @@ -5,6 +5,5 @@ namespace ServiceStationDataModels.Models public interface IClientModel : IId { string FIO { get; } - int TotalPoints { get; } } } diff --git a/ServiceStation/ServiceStationExecutorApp/Controllers/HomeController.cs b/ServiceStation/ServiceStationExecutorApp/Controllers/HomeController.cs index f6744d8..0c0433f 100644 --- a/ServiceStation/ServiceStationExecutorApp/Controllers/HomeController.cs +++ b/ServiceStation/ServiceStationExecutorApp/Controllers/HomeController.cs @@ -229,5 +229,62 @@ namespace ServiceSourceClientApp.Controllers { } return new JsonResult(works); } + + [HttpGet] + public IActionResult Report() { + if (APIClient.executor == null) { + return Redirect("~/Home/Enter"); + } + var view = APIClient.GetRequest>($"api/Main/GetWorks?_executorId={APIClient.executor.Id}"); + return View(view); + } + + [HttpPost] + public void Report(DateTime DateFrom, DateTime DateTo) { + if (DateTo == DateTime.MinValue || DateFrom > DateTo) { + throw new Exception(" "); + } + Response.Redirect($"ReportSearchDate?_datefrom={DateFrom}&_dateto={DateTo + DateTime.Now.TimeOfDay}"); + } + + [HttpGet] + public IActionResult ReportSearchDate(string _datefrom, string _dateto) { + var reports = APIClient.GetRequest>($"api/Main/GerWorksDate?_start={_datefrom}&_end={_dateto}"); + (DateTime, DateTime, List?) tuple = (DateTime.Parse(_datefrom), DateTime.Parse(_dateto), reports); + return View(tuple); + } + + [HttpGet] + public IActionResult CreatePdfReport(string DateFrom, string DateTo) { + APIClient.PostRequest("api/Main/SendReportPdfMail", new ReportBindeingModel { + EmailAddress = APIClient.executor?.Email ?? throw new Exception(" "), + DateFrom = DateTime.Parse(DateFrom), + DateTo = DateTime.Parse(DateTo) + }); + return Redirect("Report"); + } + + [HttpGet] + public IActionResult CreateWordReport(string ids) { + + var fileMemStream = APIClient.GetRequest($"api/Main/CreateWordReport?_ids={ids}"); + + if (fileMemStream == null) { + throw new Exception(" "); + } + + return File(fileMemStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Report.docx"); + } + + [HttpGet] + public IActionResult CreateExcelReport(string ids) { + var fileMemStream = APIClient.GetRequest($"api/Main/CreateXlsxReport?_ids={ids}"); + + if (fileMemStream == null) { + throw new Exception(" "); + } + + return File(fileMemStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Report.xlsx"); + } } } \ No newline at end of file diff --git a/ServiceStation/ServiceStationExecutorApp/Views/Home/Report.cshtml b/ServiceStation/ServiceStationExecutorApp/Views/Home/Report.cshtml new file mode 100644 index 0000000..42cc47f --- /dev/null +++ b/ServiceStation/ServiceStationExecutorApp/Views/Home/Report.cshtml @@ -0,0 +1,151 @@ +@using ServiceStationContracts.ViewModels +@model List +@{ + ViewData["Title"] = "Report"; +} + + + +
+

Отчёты

+
+ +
+

Отчёт за период

+
+ +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+ +
+

Выбрать оплаты в отечет

+
+ +
+ @{ + if (Model == null) { +

Авторизируйтесь

+ return; + } +
+ +
+ +
+ + +
+ + + + + + + + + + + + + + @foreach (var item in Model) { + + + + + + + + + } + +
+ Номер + + Дата работы + + Стоимость работы + + Номер задания + + Задание + + Выбрать все +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.Date) + + @Html.DisplayFor(modelItem => item.Price) + + @Html.DisplayFor(modelItem => item.TaskByWorkId) + + @Html.DisplayFor(modelItem => item.TaskName) + + +
+ } +
+ + \ No newline at end of file diff --git a/ServiceStation/ServiceStationExecutorApp/Views/Home/ReportSearchDate.cshtml b/ServiceStation/ServiceStationExecutorApp/Views/Home/ReportSearchDate.cshtml new file mode 100644 index 0000000..eca04bd --- /dev/null +++ b/ServiceStation/ServiceStationExecutorApp/Views/Home/ReportSearchDate.cshtml @@ -0,0 +1,82 @@ +@using ServiceStationContracts.ViewModels +@model (DateTime, DateTime, List) + +@{ + ViewData["Title"] = "ReportSearchDate"; +} + + + + +
+

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +

+ +
+ + +
+ @{ + + + + + + + + + + + + @foreach (var item in Model.Item3) { + + + + + + + + } + +
+ Номер + + Дата работы + + Стоимость работы + + Номер задания + + Задание +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.Date) + + @Html.DisplayFor(modelItem => item.Price) + + @Html.DisplayFor(modelItem => item.TaskByWorkId) + + @Html.DisplayFor(modelItem => item.TaskName) +
+ } +
\ No newline at end of file diff --git a/ServiceStation/ServiceStationRestAPI/Controllers/MainController.cs b/ServiceStation/ServiceStationRestAPI/Controllers/MainController.cs index af508b0..f200fd7 100644 --- a/ServiceStation/ServiceStationRestAPI/Controllers/MainController.cs +++ b/ServiceStation/ServiceStationRestAPI/Controllers/MainController.cs @@ -138,6 +138,21 @@ namespace ServiceStationRestAPI.Controllers } } + [HttpGet] + public List? GerWorksDate(string _start, string _end) { + try { + var data = _workLogic.ReadList(new WorkSearchModel { + DateFrom = DateTime.Parse(_start), + DateTo = DateTime.Parse(_end) + }); + return data; + } + catch (Exception ex) { + _logger.LogError(ex, "Ошибка получения данных"); + throw; + } + } + [HttpGet] public List> GetWork(int _workId) { try { @@ -150,7 +165,6 @@ namespace ServiceStationRestAPI.Controllers var record = new ClientViewModel { Id = client.Key, FIO = client.Value.FIO, - TotalPoints = client.Value.TotalPoints, }; string jsRec = JsonConvert.SerializeObject(record); client_list.Add(jsRec); diff --git a/ServiceStation/ServiceStationsDataBaseImplement/Models/Client.cs b/ServiceStation/ServiceStationsDataBaseImplement/Models/Client.cs index 5bd5047..5184a49 100644 --- a/ServiceStation/ServiceStationsDataBaseImplement/Models/Client.cs +++ b/ServiceStation/ServiceStationsDataBaseImplement/Models/Client.cs @@ -18,8 +18,6 @@ namespace ServiceStationsDataBaseImplement.Models [Required] public string FIO { get; set; } = string.Empty; - public int TotalPoints { get; set; } - [ForeignKey("ClientId")] public virtual List WorkClients { get; set; } = new(); @@ -30,7 +28,6 @@ namespace ServiceStationsDataBaseImplement.Models return new Client() { Id = model.Id, FIO = model.FIO, - TotalPoints = model.TotalPoints, }; } @@ -39,13 +36,11 @@ namespace ServiceStationsDataBaseImplement.Models return; } FIO = model.FIO; - TotalPoints = model.TotalPoints; } public ClientViewModel GetViewModel => new() { Id = Id, - FIO = FIO, - TotalPoints = TotalPoints + FIO = FIO }; } }