логика отчетов. раб
This commit is contained in:
parent
f9eae8c2da
commit
f1be1d5783
@ -1,4 +1,6 @@
|
|||||||
using FactoryContracts.BindingModels;
|
using FactoryBusinessLogic.OfficePackage;
|
||||||
|
using FactoryBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using FactoryContracts.BindingModels;
|
||||||
using FactoryContracts.BusinessLogicsContracts;
|
using FactoryContracts.BusinessLogicsContracts;
|
||||||
using FactoryContracts.SearchModels;
|
using FactoryContracts.SearchModels;
|
||||||
using FactoryContracts.StoragesContracts;
|
using FactoryContracts.StoragesContracts;
|
||||||
@ -8,34 +10,57 @@ namespace FactoryBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
public class WorkerReportLogic : IWorkerReportLogic
|
public class WorkerReportLogic : IWorkerReportLogic
|
||||||
{
|
{
|
||||||
private readonly IMachineStorage _machineStorage;
|
private readonly IWorkpieceStorage _workpieceStorage;
|
||||||
private readonly IProductStorage _productStorage;
|
private readonly IPlanProductionStorage _planProduction;
|
||||||
public WorkerReportLogic(IMachineStorage machineStorage, IProductStorage productStorage)
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
|
public WorkerReportLogic(IWorkpieceStorage workpieceStorage, IPlanProductionStorage planProductionStorage, AbstractSaveToWord saveToWord, AbstractSaveToExcel saveToExcel, AbstractSaveToPdf saveToPdf)
|
||||||
{
|
{
|
||||||
_machineStorage = machineStorage;
|
_workpieceStorage = workpieceStorage;
|
||||||
_productStorage = productStorage;
|
_planProduction = planProductionStorage;
|
||||||
|
_saveToExcel = saveToExcel;
|
||||||
|
_saveToPdf = saveToPdf;
|
||||||
|
_saveToWord = saveToWord;
|
||||||
}
|
}
|
||||||
public List<PlanProductionProductReportViewModel> GetProductsByPlanProduction(List<PlanProductionSearchModel> plans)
|
public List<PlanProductionProductReportViewModel> GetProductsByPlanProduction(List<PlanProductionSearchModel> plans)
|
||||||
{
|
{
|
||||||
//return _productStorage.GetProducts(plans);
|
List<int> ids = plans.Select(x =>(int)x.Id).ToList();
|
||||||
throw new NotImplementedException();
|
return _planProduction.GetProducts(ids);
|
||||||
}
|
}
|
||||||
public List<WorkpieceTimeReportViewModel> GetWorkpieces(ClientSearchModel client, ReportBindingModel model)
|
public List<WorkpieceTimeReportViewModel> GetWorkpieces(ClientSearchModel client, ReportBindingModel model)
|
||||||
{
|
{
|
||||||
//return _workpieceStorage.GetWorkpiecesByPeriod(client, model);
|
return _workpieceStorage.GetWorkpiecesByPeriod(client, model);
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
public void SaveMachinesToPdfFile(ReportBindingModel model)
|
public void SaveWorkpiecesToPdfFile(ClientSearchModel client, ReportBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_saveToPdf.CreateWorkerDoc(new WorkerPdfInfo
|
||||||
}
|
|
||||||
public void SavePlanProductionsToExcelFile(ReportBindingModel model)
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
FileName = model.FileName,
|
||||||
|
Title = "Список заготовок",
|
||||||
|
DateFrom = model.DateFrom!.Value,
|
||||||
|
DateTo = model.DateTo!.Value,
|
||||||
|
Workpieces = GetWorkpieces(client, model)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public void SavePlanProductionsToWordFile(ReportBindingModel model)
|
public void SaveProductsToExcelFile(ReportBindingModel model, List<int> plans)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_saveToExcel.CreateWorkerReport(new WorkerExcelInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список планов",
|
||||||
|
//PlanProductionProducts = GetProductsByPlanProduction(plans)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public void SaveProudctsToWordFile(ReportBindingModel model, List<int> ids)
|
||||||
|
{
|
||||||
|
var plans = _planProduction.GetProducts(ids);
|
||||||
|
_saveToWord.CreateWorkerDoc(new WorkerWordInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список планов",
|
||||||
|
//PlanProductionProducts = GetProductsByPlanProduction(plans)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,10 +64,63 @@ namespace FactoryBusinessLogic.OfficePackage
|
|||||||
rowIndex++;
|
rowIndex++;
|
||||||
}
|
}
|
||||||
SaveStorekeeperExcel(info);
|
SaveStorekeeperExcel(info);
|
||||||
|
}
|
||||||
|
public void CreateWorkerReport(WorkerExcelInfo info)
|
||||||
|
{
|
||||||
|
CreateWorkerExcel(info);
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = 1,
|
||||||
|
Text = info.Title,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Title
|
||||||
|
});
|
||||||
|
MergeCells(new ExcelMergeParameters
|
||||||
|
{
|
||||||
|
CellFromName = "A1",
|
||||||
|
CellToName = "C1"
|
||||||
|
});
|
||||||
|
uint rowIndex = 2;
|
||||||
|
foreach (var pp in info.PlanProductionProducts)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = pp.ProductionName,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
rowIndex++;
|
||||||
|
|
||||||
|
foreach (var product in pp.Products)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "B",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = product.ProductName,
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||||
|
});
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "C",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = product.Price.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||||
|
});
|
||||||
|
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
SaveWorkerExcel(info);
|
||||||
}
|
}
|
||||||
protected abstract void CreateStorekeeperExcel(StorekeeperExcelInfo info);
|
protected abstract void CreateStorekeeperExcel(StorekeeperExcelInfo info);
|
||||||
|
protected abstract void CreateWorkerExcel(WorkerExcelInfo info);
|
||||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||||
protected abstract void SaveStorekeeperExcel(StorekeeperExcelInfo info);
|
protected abstract void SaveStorekeeperExcel(StorekeeperExcelInfo info);
|
||||||
|
protected abstract void SaveWorkerExcel(StorekeeperExcelInfo info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,12 +78,89 @@ namespace FactoryBusinessLogic.OfficePackage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SaveStorekeeperPdf(info);
|
SaveStorekeeperPdf(info);
|
||||||
|
}
|
||||||
|
public void CreateWorkerDoc(WorkerPdfInfo info)
|
||||||
|
{
|
||||||
|
CreateWorkerPdf(info);
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = info.Title,
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
CreateParagraph(new PdfParagraph
|
||||||
|
{
|
||||||
|
Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
CreateTable(new List<string> { "3cm", "5cm", "5cm" });
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Название изделия", "Этапы выполнения", "Станки" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
foreach (var workpiece in info.Workpieces)
|
||||||
|
{
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string>
|
||||||
|
{
|
||||||
|
workpiece.WorkpieceName,
|
||||||
|
string.Empty,
|
||||||
|
string.Empty,
|
||||||
|
},
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
var phaseNames = workpiece.ExecutionPhases.Select(x => x.ExecutionPhaseName).ToList();
|
||||||
|
var machineNames = workpiece.Machines.Select(x => x.MachineName).ToList();
|
||||||
|
|
||||||
|
if (phaseNames.Count != machineNames.Count)
|
||||||
|
{
|
||||||
|
if (phaseNames.Count > machineNames.Count)
|
||||||
|
{
|
||||||
|
var diff = phaseNames.Count - machineNames.Count;
|
||||||
|
for (int i = 0; i < diff; i++)
|
||||||
|
{
|
||||||
|
machineNames.Add(string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var diff = machineNames.Count - phaseNames.Count;
|
||||||
|
for (int i = 0; i < diff; i++)
|
||||||
|
{
|
||||||
|
phaseNames.Add(string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var tupleList = machineNames.Zip(phaseNames, Tuple.Create);
|
||||||
|
foreach (var tuple in tupleList)
|
||||||
|
{
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string>
|
||||||
|
{
|
||||||
|
string.Empty,
|
||||||
|
tuple.Item1,
|
||||||
|
tuple.Item2,
|
||||||
|
},
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SaveWorkerPdf(info);
|
||||||
}
|
}
|
||||||
protected abstract void CreateStorekeeperPdf(StorekeeperPdfInfo info);
|
protected abstract void CreateStorekeeperPdf(StorekeeperPdfInfo info);
|
||||||
|
protected abstract void CreateWorkerPdf(WorkerPdfInfo info);
|
||||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||||
protected abstract void CreateTable(List<string> columns);
|
protected abstract void CreateTable(List<string> columns);
|
||||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||||
protected abstract void SaveStorekeeperPdf(StorekeeperPdfInfo info);
|
protected abstract void SaveStorekeeperPdf(StorekeeperPdfInfo info);
|
||||||
|
protected abstract void SaveWorkerPdf(WorkerPdfInfo info);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,52 @@ namespace FactoryBusinessLogic.OfficePackage
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
SaveStorekeeperWord(info);
|
SaveStorekeeperWord(info);
|
||||||
|
}
|
||||||
|
public void CreateWorkerDoc(WorkerWordInfo info)
|
||||||
|
{
|
||||||
|
CreateWorkerWord(info);
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> {
|
||||||
|
(info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
foreach (var ppp in info.PlanProductionProducts)
|
||||||
|
{
|
||||||
|
var t = ppp.Products;
|
||||||
|
List<(string, WordTextProperties)> texts = new List<(string, WordTextProperties)>
|
||||||
|
{
|
||||||
|
(ppp.ProductionName, new WordTextProperties { Bold = true, Size = "24", })
|
||||||
|
};
|
||||||
|
foreach (var product in ppp.Products)
|
||||||
|
{
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.Append(product.ProductName);
|
||||||
|
stringBuilder.Append(" — ");
|
||||||
|
stringBuilder.Append(product.Price.ToString());
|
||||||
|
texts.Add((stringBuilder.ToString(), new WordTextProperties { Size = "24" }));
|
||||||
|
}
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = texts,
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Both
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
SaveWorkerWord(info);
|
||||||
}
|
}
|
||||||
protected abstract void CreateStorekeeperWord(StorekeeperWordInfo info);
|
protected abstract void CreateStorekeeperWord(StorekeeperWordInfo info);
|
||||||
|
protected abstract void CreateWorkerWord(WorkerWordInfo info);
|
||||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||||
protected abstract void SaveStorekeeperWord(StorekeeperWordInfo info);
|
protected abstract void SaveStorekeeperWord(StorekeeperWordInfo info);
|
||||||
|
protected abstract void SaveWorkerWord(WorkerWordInfo info);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
using FactoryContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace FactoryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WorkerExcelInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<PlanProductionProductReportViewModel> PlanProductionProducts
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using FactoryContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace FactoryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WorkerPdfInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public DateTime DateFrom { get; set; }
|
||||||
|
public DateTime DateTo { get; set; }
|
||||||
|
public List<WorkpieceTimeReportViewModel> Workpieces { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using FactoryContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace FactoryBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WorkerWordInfo
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<PlanProductionProductReportViewModel> PlanProductionProducts
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = new();
|
||||||
|
}
|
||||||
|
}
|
@ -176,6 +176,39 @@ namespace FactoryBusinessLogic.OfficePackage.Implements
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
protected override void CreateStorekeeperExcel(StorekeeperExcelInfo info)
|
protected override void CreateStorekeeperExcel(StorekeeperExcelInfo info)
|
||||||
|
{
|
||||||
|
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||||
|
// Создаем книгу (в ней хранятся листы)
|
||||||
|
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||||
|
workbookpart.Workbook = new Workbook();
|
||||||
|
CreateStyles(workbookpart);
|
||||||
|
// Получаем/создаем хранилище текстов для книги
|
||||||
|
_shareStringPart =
|
||||||
|
_spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
|
||||||
|
?
|
||||||
|
_spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
||||||
|
:
|
||||||
|
_spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||||
|
// Создаем SharedStringTable, если его нет
|
||||||
|
if (_shareStringPart.SharedStringTable == null)
|
||||||
|
{
|
||||||
|
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||||
|
}
|
||||||
|
// Создаем лист в книгу
|
||||||
|
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||||
|
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||||
|
// Добавляем лист в книгу
|
||||||
|
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||||
|
var sheet = new Sheet()
|
||||||
|
{
|
||||||
|
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||||
|
SheetId = 1,
|
||||||
|
Name = "Лист"
|
||||||
|
};
|
||||||
|
sheets.Append(sheet);
|
||||||
|
_worksheet = worksheetPart.Worksheet;
|
||||||
|
}
|
||||||
|
protected override void CreateWorkerExcel(WorkerExcelInfo info)
|
||||||
{
|
{
|
||||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||||
// Создаем книгу (в ней хранятся листы)
|
// Создаем книгу (в ней хранятся листы)
|
||||||
@ -296,6 +329,15 @@ namespace FactoryBusinessLogic.OfficePackage.Implements
|
|||||||
mergeCells.Append(mergeCell);
|
mergeCells.Append(mergeCell);
|
||||||
}
|
}
|
||||||
protected override void SaveStorekeeperExcel(StorekeeperExcelInfo info)
|
protected override void SaveStorekeeperExcel(StorekeeperExcelInfo info)
|
||||||
|
{
|
||||||
|
if (_spreadsheetDocument == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||||
|
_spreadsheetDocument.Dispose();
|
||||||
|
}
|
||||||
|
protected override void SaveWorkerExcel(WorkerExcelInfo info)
|
||||||
{
|
{
|
||||||
if (_spreadsheetDocument == null)
|
if (_spreadsheetDocument == null)
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,12 @@ namespace FactoryBusinessLogic.OfficePackage.Implements
|
|||||||
style.Font.Bold = true;
|
style.Font.Bold = true;
|
||||||
}
|
}
|
||||||
protected override void CreateStorekeeperPdf(StorekeeperPdfInfo info)
|
protected override void CreateStorekeeperPdf(StorekeeperPdfInfo info)
|
||||||
|
{
|
||||||
|
_document = new Document();
|
||||||
|
DefineStyles(_document);
|
||||||
|
_section = _document.AddSection();
|
||||||
|
}
|
||||||
|
protected override void CreateWorkerPdf(WorkerPdfInfo info)
|
||||||
{
|
{
|
||||||
_document = new Document();
|
_document = new Document();
|
||||||
DefineStyles(_document);
|
DefineStyles(_document);
|
||||||
@ -90,6 +96,15 @@ namespace FactoryBusinessLogic.OfficePackage.Implements
|
|||||||
renderer.RenderDocument();
|
renderer.RenderDocument();
|
||||||
renderer.PdfDocument.Save(info.FileName);
|
renderer.PdfDocument.Save(info.FileName);
|
||||||
}
|
}
|
||||||
|
protected override void SaveWorkerPdf(WorkerPdfInfo info)
|
||||||
|
{
|
||||||
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
|
{
|
||||||
|
Document = _document
|
||||||
|
};
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(info.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -57,6 +57,13 @@ namespace FactoryBusinessLogic.OfficePackage.Implements
|
|||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
protected override void CreateStorekeeperWord(StorekeeperWordInfo info)
|
protected override void CreateStorekeeperWord(StorekeeperWordInfo info)
|
||||||
|
{
|
||||||
|
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||||
|
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = new Document();
|
||||||
|
_docBody = mainPart.Document.AppendChild(new Body());
|
||||||
|
}
|
||||||
|
protected override void CreateWorkerWord(WorkerWordInfo info)
|
||||||
{
|
{
|
||||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||||
@ -92,6 +99,16 @@ namespace FactoryBusinessLogic.OfficePackage.Implements
|
|||||||
_docBody.AppendChild(docParagraph);
|
_docBody.AppendChild(docParagraph);
|
||||||
}
|
}
|
||||||
protected override void SaveStorekeeperWord(StorekeeperWordInfo info)
|
protected override void SaveStorekeeperWord(StorekeeperWordInfo info)
|
||||||
|
{
|
||||||
|
if (_docBody == null || _wordDocument == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_docBody.AppendChild(CreateSectionProperties());
|
||||||
|
_wordDocument.MainDocumentPart!.Document.Save();
|
||||||
|
_wordDocument.Dispose();
|
||||||
|
}
|
||||||
|
protected override void SaveWorkerWord(WorkerWordInfo info)
|
||||||
{
|
{
|
||||||
if (_docBody == null || _wordDocument == null)
|
if (_docBody == null || _wordDocument == null)
|
||||||
{
|
{
|
||||||
|
@ -8,8 +8,9 @@ namespace FactoryContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
List<PlanProductionProductReportViewModel> GetProductsByPlanProduction(List<PlanProductionSearchModel> plans);
|
List<PlanProductionProductReportViewModel> GetProductsByPlanProduction(List<PlanProductionSearchModel> plans);
|
||||||
List<WorkpieceTimeReportViewModel> GetWorkpieces(ClientSearchModel client, ReportBindingModel model);
|
List<WorkpieceTimeReportViewModel> GetWorkpieces(ClientSearchModel client, ReportBindingModel model);
|
||||||
void SavePlanProductionsToWordFile(ReportBindingModel model);
|
void SaveProudctsToWordFile(ReportBindingModel model, List<int> plans);
|
||||||
void SavePlanProductionsToExcelFile(ReportBindingModel model);
|
void SaveProductsToExcelFile(ReportBindingModel model, List<int> plans);
|
||||||
void SaveMachinesToPdfFile(ReportBindingModel model);
|
void SaveWorkpiecesToPdfFile(ClientSearchModel client, ReportBindingModel model);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,8 @@ namespace FactoryContracts.StoragesContracts
|
|||||||
PlanProductionViewModel? Update(PlanProductionBindingModel model);
|
PlanProductionViewModel? Update(PlanProductionBindingModel model);
|
||||||
|
|
||||||
PlanProductionViewModel? Delete(PlanProductionBindingModel model);
|
PlanProductionViewModel? Delete(PlanProductionBindingModel model);
|
||||||
|
|
||||||
|
List<PlanProductionProductReportViewModel> GetProducts(List<int> ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,8 @@ namespace FactoryContracts.StoragesContracts
|
|||||||
List<WorkpieceViewModel> GetFullList();
|
List<WorkpieceViewModel> GetFullList();
|
||||||
|
|
||||||
List<WorkpieceViewModel> GetFilteredList(WorkpieceSearchModel model);
|
List<WorkpieceViewModel> GetFilteredList(WorkpieceSearchModel model);
|
||||||
|
List<WorkpieceTimeReportViewModel> GetWorkpiecesByPeriod(ClientSearchModel client, ReportBindingModel model);
|
||||||
|
|
||||||
|
|
||||||
WorkpieceViewModel? GetElement(WorkpieceSearchModel model);
|
WorkpieceViewModel? GetElement(WorkpieceSearchModel model);
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
public class PlanProductionProductReportViewModel
|
public class PlanProductionProductReportViewModel
|
||||||
{
|
{
|
||||||
public string ProductionName { get; set; } = string.Empty;
|
public string ProductionName { get; set; } = string.Empty;
|
||||||
public List<string> Products { get; set; } = new();
|
public List<ProductViewModel> Products { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
public class WorkpieceTimeReportViewModel
|
public class WorkpieceTimeReportViewModel
|
||||||
{
|
{
|
||||||
public string WorkpieceName { get; set; } = string.Empty;
|
public string WorkpieceName { get; set; } = string.Empty;
|
||||||
public List<string> ExecutionPhases { get; set; } = new();
|
public List<ExecutionPhaseViewModel> ExecutionPhases { get; set; } = new();
|
||||||
public List<string> Machines { get; set; } = new();
|
public List<MachineViewModel> Machines { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,5 +123,21 @@ namespace FactoryDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PlanProductionProductReportViewModel> GetProducts(List<int> ids)
|
||||||
|
{
|
||||||
|
using var context = new FactoryDatabase();
|
||||||
|
return context.PlanProductions
|
||||||
|
.Where(plan => ids.Contains(plan.Id))
|
||||||
|
.Select(plan => new PlanProductionProductReportViewModel()
|
||||||
|
{
|
||||||
|
ProductionName = plan.ProductionName,
|
||||||
|
Products = context.WorkpieceProducts
|
||||||
|
.Include(x => x.Product)
|
||||||
|
.Where(product => plan.Id == product.Product.Id)
|
||||||
|
.Select(x => x.Product.GetViewModel)
|
||||||
|
.ToList()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,21 @@ namespace FactoryDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public class WorkpieceStorage : IWorkpieceStorage
|
public class WorkpieceStorage : IWorkpieceStorage
|
||||||
{
|
{
|
||||||
|
public List<WorkpieceTimeReportViewModel> GetWorkpiecesByPeriod(ClientSearchModel client, ReportBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FactoryDatabase();
|
||||||
|
return context.Workpieces
|
||||||
|
.Include(x => x.Client)
|
||||||
|
// not sure if its true
|
||||||
|
.Where(x => x.ClientId == client.Id && x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||||
|
.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();
|
||||||
|
}
|
||||||
public List<WorkpieceViewModel> GetFullList()
|
public List<WorkpieceViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new FactoryDatabase();
|
using var context = new FactoryDatabase();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
using FactoryContracts.BindingModels;
|
using FactoryContracts.BindingModels;
|
||||||
|
using FactoryContracts.BusinessLogicsContracts;
|
||||||
using FactoryContracts.ViewModels;
|
using FactoryContracts.ViewModels;
|
||||||
using FactoryDatabaseImplement.Models;
|
using FactoryDatabaseImplement.Models;
|
||||||
using FactoryDataModels.Enums;
|
using FactoryDataModels.Enums;
|
||||||
@ -14,13 +15,15 @@ namespace FactoryWorkerApp.Controllers
|
|||||||
{
|
{
|
||||||
private readonly ILogger<HomeController> _logger;
|
private readonly ILogger<HomeController> _logger;
|
||||||
private readonly WorkerLogic _logic;
|
private readonly WorkerLogic _logic;
|
||||||
|
private readonly IWorkerReportLogic _workerReportLogic;
|
||||||
private bool IsLoggedIn { get { return Client.user != null; } }
|
private bool IsLoggedIn { get { return Client.user != null; } }
|
||||||
private int UserId { get { return Client.user!.Id; } }
|
private int UserId { get { return Client.user!.Id; } }
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger, WorkerLogic logic)
|
public HomeController(ILogger<HomeController> logger, WorkerLogic logic, IWorkerReportLogic workerReportLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
|
_workerReportLogic = workerReportLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -225,24 +228,7 @@ namespace FactoryWorkerApp.Controllers
|
|||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
[HttpGet]
|
|
||||||
public IActionResult ProductProductionReport()
|
|
||||||
{
|
|
||||||
List<PlanProductionProductReportViewModel> reports = new List<PlanProductionProductReportViewModel>
|
|
||||||
{
|
|
||||||
new PlanProductionProductReportViewModel
|
|
||||||
{
|
|
||||||
ProductionName = "План производства X",
|
|
||||||
Products = new List<string> { "Изделие 1", "Изделие 2" }
|
|
||||||
},
|
|
||||||
new PlanProductionProductReportViewModel
|
|
||||||
{
|
|
||||||
ProductionName = "План производства Y",
|
|
||||||
Products = new List<string> { "Изделие 3", "Изделие 4" }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return View(reports);
|
|
||||||
}
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult WorkpieceTimeChoose()
|
public IActionResult WorkpieceTimeChoose()
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,6 @@
|
|||||||
`;
|
`;
|
||||||
$('#productsTable tbody').append(newRow);
|
$('#productsTable tbody').append(newRow);
|
||||||
|
|
||||||
updateSum();
|
|
||||||
$('#productSelect').val('');
|
$('#productSelect').val('');
|
||||||
} else {
|
} else {
|
||||||
alert('Выберите изделие для добавления');
|
alert('Выберите изделие для добавления');
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using DocumentFormat.OpenXml.ExtendedProperties;
|
||||||
|
using FactoryBusinessLogic.OfficePackage;
|
||||||
using FactoryContracts.BindingModels;
|
using FactoryContracts.BindingModels;
|
||||||
using FactoryContracts.BusinessLogicsContracts;
|
using FactoryContracts.BusinessLogicsContracts;
|
||||||
using FactoryContracts.SearchModels;
|
using FactoryContracts.SearchModels;
|
||||||
@ -13,8 +15,10 @@ namespace FactoryWorkerApp
|
|||||||
private readonly IPlanProductionLogic _planProductionLogic;
|
private readonly IPlanProductionLogic _planProductionLogic;
|
||||||
private readonly IProductLogic _productLogic;
|
private readonly IProductLogic _productLogic;
|
||||||
private readonly IExecutionPhaseLogic _executionPhaseLogic;
|
private readonly IExecutionPhaseLogic _executionPhaseLogic;
|
||||||
|
private readonly IWorkerReportLogic _workerReport;
|
||||||
|
|
||||||
public WorkerLogic(ILogger<WorkerLogic> logger, IClientLogic clientLogic, IWorkpieceLogic workpieceLogic, IPlanProductionLogic planProductionLogic, IExecutionPhaseLogic executionPhaseLogic, IProductLogic productLogic)
|
|
||||||
|
public WorkerLogic(ILogger<WorkerLogic> logger, IClientLogic clientLogic, IWorkpieceLogic workpieceLogic, IPlanProductionLogic planProductionLogic, IExecutionPhaseLogic executionPhaseLogic, IProductLogic productLogic, IWorkerReportLogic reportLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_clientLogic = clientLogic;
|
_clientLogic = clientLogic;
|
||||||
@ -22,6 +26,7 @@ namespace FactoryWorkerApp
|
|||||||
_planProductionLogic = planProductionLogic;
|
_planProductionLogic = planProductionLogic;
|
||||||
_executionPhaseLogic = executionPhaseLogic;
|
_executionPhaseLogic = executionPhaseLogic;
|
||||||
_productLogic = productLogic;
|
_productLogic = productLogic;
|
||||||
|
_workerReport = reportLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Login(string login, string password)
|
public ClientViewModel? Login(string login, string password)
|
||||||
|
Loading…
Reference in New Issue
Block a user