diff --git a/src/RevitDeclarations/Models/DeclarationProjects/ApartmentsProject.cs b/src/RevitDeclarations/Models/DeclarationProjects/ApartmentsProject.cs index 69de9549..6ec2c7e6 100644 --- a/src/RevitDeclarations/Models/DeclarationProjects/ApartmentsProject.cs +++ b/src/RevitDeclarations/Models/DeclarationProjects/ApartmentsProject.cs @@ -36,7 +36,7 @@ public ErrorsListViewModel CheckRoomAreasEquality() { foreach(Apartment apartment in _roomGroups) { if(!apartment.CheckEqualityOfRoomAreas()) { - string apartInfo = $"Квартира № {apartment.Number} на этаже {apartment.Level}"; + string apartInfo = $"Группа помещений № {apartment.Number} на этаже {apartment.Level}"; string apartAreas = "Площади квартиры (без коэффициента/с коэффициентом/жилая/без ЛП) " + "должны быть одинаковыми для каждого помещения квартиры"; errorListVM.Errors.Add(new ErrorElement(apartInfo, apartAreas)); @@ -55,7 +55,7 @@ public ErrorsListViewModel CheckActualApartmentAreas() { foreach(Apartment apartment in _roomGroups) { if(!apartment.CheckActualApartmentAreas()) { - string apartInfo = $"Квартира № {apartment.Number} на этаже {apartment.Level}"; + string apartInfo = $"Группа помещений № {apartment.Number} на этаже {apartment.Level}"; string apartAreas = "Площади квартиры, рассчитанные квартирографией " + "отличаются от суммы актуальных системных площадей этой квартиры. " + "Проверьте общую площадь квартиры, площадь с коэффициентом, " + diff --git a/src/RevitDeclarations/Models/DeclarationProjects/DeclarationProject.cs b/src/RevitDeclarations/Models/DeclarationProjects/DeclarationProject.cs index 2aa1915d..cdd48557 100644 --- a/src/RevitDeclarations/Models/DeclarationProjects/DeclarationProject.cs +++ b/src/RevitDeclarations/Models/DeclarationProjects/DeclarationProject.cs @@ -73,7 +73,7 @@ public ErrorsListViewModel CheckActualRoomAreas() { foreach(RoomGroup roomGroup in _roomGroups) { if(!roomGroup.CheckActualRoomAreas()) { - string groupInfo = $"Квартира № {roomGroup.Number} на этаже {roomGroup.Level}"; + string groupInfo = $"Группа помещений № {roomGroup.Number} на этаже {roomGroup.Level}"; string groupAreas = "Площади помещений, рассчитанные квартирографией " + "отличаются от актуальной системной площадей помещения."; errorListVM.Errors.Add(new ErrorElement(groupInfo, groupAreas)); diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/ApartmentsDataTable.cs b/src/RevitDeclarations/Models/Export/DeclarationData/ApartmentsDataTable.cs index 8594bbd3..db4d74a2 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/ApartmentsDataTable.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/ApartmentsDataTable.cs @@ -4,7 +4,7 @@ namespace RevitDeclarations.Models { internal class ApartmentsDataTable : DeclarationDataTable { - public ApartmentsDataTable(ApartmentsTableInfo tableInfo) : base(tableInfo) { + public ApartmentsDataTable(string name, ApartmentsTableInfo tableInfo) : base(name,tableInfo) { } protected override void FillTableHeader() { @@ -17,7 +17,7 @@ protected override void FillTableHeader() { _headerTable.Rows[0][6] = "Номер ОКС"; _headerTable.Rows[0][7] = "Общая площадь с пониж. коэффициентом, м²"; _headerTable.Rows[0][8] = "Количество комнат"; - _headerTable.Rows[0][9] = "Жилая площадь, м²"; + _headerTable.Rows[0][9] = "Общая жилая площадь, м²"; _headerTable.Rows[0][10] = "Высота потолков, м"; _headerTable.Rows[0][11] = "ИД Объекта"; _headerTable.Rows[0][12] = "Номер на площадке"; @@ -46,7 +46,7 @@ private void FillTableRoomsHeader() { int columnIndex = columnNumber + k * ApartmentsTableInfo.SummerRoomCells; _headerTable.Rows[0][columnIndex] = "№ Пом."; _headerTable.Rows[0][columnIndex + 1] = "Наименование на планировке"; - _headerTable.Rows[0][columnIndex + 2] = $"{priority.Name} {k + 1}, без коэф."; + _headerTable.Rows[0][columnIndex + 2] = $"{priority.Name} {k + 1}, площадь без коэф."; _headerTable.Rows[0][columnIndex + 3] = $"{priority.Name} {k + 1}, площадь с коэф."; } columnNumber += priority.MaxRoomAmount * ApartmentsTableInfo.SummerRoomCells; diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/CommercialDataTable.cs b/src/RevitDeclarations/Models/Export/DeclarationData/CommercialDataTable.cs index 3ea53eac..811ffb00 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/CommercialDataTable.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/CommercialDataTable.cs @@ -5,7 +5,7 @@ namespace RevitDeclarations.Models { internal class CommercialDataTable : DeclarationDataTable { - public CommercialDataTable(CommercialTableInfo tableInfo) : base(tableInfo) { + public CommercialDataTable(string name, CommercialTableInfo tableInfo) : base(name, tableInfo) { } protected override void FillTableHeader() { @@ -51,17 +51,19 @@ protected override void FillAdditionalInfo() { } private void GenerateSubTables() { + List rooms = new List(); foreach(var commercialRooms in _tableInfo.RoomGroups.Cast()) { if(!commercialRooms.IsOneRoomGroup) { - List rooms = new List { commercialRooms }; - - CommercialGroupTableInfo tableInfo = new CommercialGroupTableInfo(rooms, _settings); - CommercialGroupDataTable table = new CommercialGroupDataTable(tableInfo); - table.GenerateTable(); - - _subTables.Add(table); + rooms.Add(commercialRooms); } } + + CommercialGroupTableInfo tableInfo = new CommercialGroupTableInfo(rooms, _settings); + CommercialGroupDataTable table = + new CommercialGroupDataTable("15.3 Части нежилых помещения", tableInfo); + table.GenerateTable(); + + _subTables.Add(table); } } } diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/CommercialGroupDataTable.cs b/src/RevitDeclarations/Models/Export/DeclarationData/CommercialGroupDataTable.cs index 05c671e5..c73592c0 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/CommercialGroupDataTable.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/CommercialGroupDataTable.cs @@ -1,9 +1,11 @@ +using System.Collections.Generic; using System.Data; using System.Linq; +using System.Windows.Documents; namespace RevitDeclarations.Models { internal class CommercialGroupDataTable : DeclarationDataTable { - public CommercialGroupDataTable(CommercialGroupTableInfo tableInfo) : base(tableInfo) { + public CommercialGroupDataTable(string name, CommercialGroupTableInfo tableInfo) : base(name, tableInfo) { } protected override void FillTableHeader() { @@ -15,16 +17,14 @@ protected override void FillTableHeader() { protected override void FillMainTable() { int rowNumber = 0; - CommercialRooms commercialRooms = _tableInfo.RoomGroups - .Cast() - .First(); + foreach(CommercialRooms commercialRooms in _tableInfo.RoomGroups) { + foreach(RoomElement room in commercialRooms.Rooms) { + _mainTable.Rows[rowNumber][0] = room.Name ?? ""; + _mainTable.Rows[rowNumber][1] = room.Area; + _mainTable.Rows[rowNumber][2] = commercialRooms.DeclarationNumber ?? ""; - foreach(RoomElement room in commercialRooms.Rooms) { - _mainTable.Rows[rowNumber][0] = room.Name ?? ""; - _mainTable.Rows[rowNumber][1] = room.Area; - _mainTable.Rows[rowNumber][2] = commercialRooms.DeclarationNumber ?? ""; - - rowNumber++; + rowNumber++; + } } } diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/DeclarationDataTable.cs b/src/RevitDeclarations/Models/Export/DeclarationData/DeclarationDataTable.cs index 70ea014f..789aea25 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/DeclarationDataTable.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/DeclarationDataTable.cs @@ -7,13 +7,15 @@ namespace RevitDeclarations.Models { internal abstract class DeclarationDataTable : IDeclarationDataTable { + protected readonly string _name; protected readonly ITableInfo _tableInfo; protected readonly DeclarationSettings _settings; protected readonly DataTable _mainTable; protected readonly DataTable _headerTable; protected readonly List _subTables = new List(); - protected DeclarationDataTable(ITableInfo tableInfo) { + protected DeclarationDataTable(string name, ITableInfo tableInfo) { + _name = name; _tableInfo = tableInfo; _settings = tableInfo.Settings; @@ -21,6 +23,7 @@ protected DeclarationDataTable(ITableInfo tableInfo) { _headerTable = new DataTable(); } + public string Name => _name; public DataTable MainDataTable => _mainTable; public DataTable HeaderDataTable => _headerTable; public ITableInfo TableInfo => _tableInfo; diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/IDeclarationDataTable.cs b/src/RevitDeclarations/Models/Export/DeclarationData/IDeclarationDataTable.cs index 4ddfaa7e..8e333ab8 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/IDeclarationDataTable.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/IDeclarationDataTable.cs @@ -3,6 +3,7 @@ namespace RevitDeclarations.Models { internal interface IDeclarationDataTable { + string Name { get; } DataTable HeaderDataTable { get; } DataTable MainDataTable { get; } List SubTables { get; } diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/PublicAreasDataTable.cs b/src/RevitDeclarations/Models/Export/DeclarationData/PublicAreasDataTable.cs index 2f6d3a31..13959154 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/PublicAreasDataTable.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/PublicAreasDataTable.cs @@ -7,7 +7,7 @@ namespace RevitDeclarations.Models { internal class PublicAreasDataTable : DeclarationDataTable { - public PublicAreasDataTable(PublicAreasTableInfo tableInfo) : base(tableInfo) { + public PublicAreasDataTable(string name, PublicAreasTableInfo tableInfo) : base(name, tableInfo) { } protected override void FillTableHeader() { @@ -27,7 +27,7 @@ protected override void FillMainTable() { _mainTable.Rows[rowNumber][2] = publicArea.RoomPosition ?? ""; _mainTable.Rows[rowNumber][3] = publicArea.Department ?? ""; _mainTable.Rows[rowNumber][4] = publicArea.AreaMain; - _mainTable.Rows[rowNumber][5] = ""; + _mainTable.Rows[rowNumber][5] = _settings.ProjectName ?? ""; rowNumber++; } diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/ApartmentsTableInfo.cs b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/ApartmentsTableInfo.cs index 246580f6..9eeecff1 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/ApartmentsTableInfo.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/ApartmentsTableInfo.cs @@ -9,6 +9,8 @@ internal class ApartmentsTableInfo : ITableInfo { private readonly int _rowsTotalNumber; private readonly int _groupsInfoColumnsNumber; private readonly int[] _numericColumnsIndexes; + private readonly int[] _areaTypeColumnsIndexes; + private readonly int[] _lengthTypeColumnsIndexes; private readonly int _utpWidth = 9; private readonly DeclarationSettings _settings; @@ -36,10 +38,15 @@ public ApartmentsTableInfo(IReadOnlyCollection apartments, Declaratio CountRoomsForPriorities(); CalculateTableSizes(); - int[] mainColumnsIndexes = new int[] { 7, 8, 9, 10, 13, 14 }; - _numericColumnsIndexes = mainColumnsIndexes + int[] mainColumnsNumIndexes = new int[] { 7, 8, 9, 13, 14 }; + _areaTypeColumnsIndexes = mainColumnsNumIndexes .Concat(FindNumericColumns()) .ToArray(); + _lengthTypeColumnsIndexes = new int[] { 10 }; + + _numericColumnsIndexes = _areaTypeColumnsIndexes + .Concat(_lengthTypeColumnsIndexes) + .ToArray(); } public int ColumnsTotalNumber => _columnsTotalNumber; @@ -50,6 +57,8 @@ public ApartmentsTableInfo(IReadOnlyCollection apartments, Declaratio public int OtherRoomsStart => _otherRoomsStart; public int UtpStart => _utpStart; public int[] NumericColumnsIndexes => _numericColumnsIndexes; + public int[] AreaTypeColumnsIndexes => _areaTypeColumnsIndexes; + public int[] LengthTypeColumnsIndexes => _lengthTypeColumnsIndexes; public DeclarationSettings Settings => _settings; public IReadOnlyCollection RoomGroups => _apartments; diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/CommercialGroupTableInfo.cs b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/CommercialGroupTableInfo.cs index 0389bca3..b431d037 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/CommercialGroupTableInfo.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/CommercialGroupTableInfo.cs @@ -9,6 +9,8 @@ internal class CommercialGroupTableInfo : ITableInfo { private readonly int _otherRoomsStart; private readonly int _utpStart; private readonly int[] _numericColumnsIndexes; + private readonly int[] _areaTypeColumnsIndexes; + private readonly int[] _lengthTypeColumnsIndexes; private readonly DeclarationSettings _settings; private readonly IReadOnlyCollection _roomGroups; @@ -22,8 +24,14 @@ public CommercialGroupTableInfo(IReadOnlyCollection roomGroups, _summerRoomsStart = 0; _otherRoomsStart = 0; _utpStart = 0; - _numericColumnsIndexes = new int[] { 1 }; - _rowsTotalNumber = RoomGroups.First().Rooms.Count(); + + _areaTypeColumnsIndexes = new int[] { 1 }; + _lengthTypeColumnsIndexes = new int[] { }; + _numericColumnsIndexes = _areaTypeColumnsIndexes + .Concat(_lengthTypeColumnsIndexes) + .ToArray(); + + _rowsTotalNumber = RoomGroups.Select(x => x.Rooms.Count()).Sum(); } public int ColumnsTotalNumber => _columnsTotalNumber; @@ -34,6 +42,8 @@ public CommercialGroupTableInfo(IReadOnlyCollection roomGroups, public int OtherRoomsStart => _otherRoomsStart; public int UtpStart => _utpStart; public int[] NumericColumnsIndexes => _numericColumnsIndexes; + public int[] AreaTypeColumnsIndexes => _areaTypeColumnsIndexes; + public int[] LengthTypeColumnsIndexes => _lengthTypeColumnsIndexes; public DeclarationSettings Settings => _settings; public IReadOnlyCollection RoomGroups => _roomGroups; diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/CommercialTableInfo.cs b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/CommercialTableInfo.cs index ab0e8f71..8368eb74 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/CommercialTableInfo.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/CommercialTableInfo.cs @@ -12,6 +12,8 @@ internal class CommercialTableInfo : ITableInfo { private readonly int _otherRoomsStart; private readonly int _utpStart; private readonly int[] _numericColumnsIndexes; + private readonly int[] _areaTypeColumnsIndexes; + private readonly int[] _lengthTypeColumnsIndexes; private readonly DeclarationSettings _settings; private readonly IReadOnlyCollection _commercialRooms; @@ -27,6 +29,12 @@ public CommercialTableInfo(IReadOnlyCollection commercialRooms, _utpStart = 0; _numericColumnsIndexes = new int[] { 7, 8 }; _rowsTotalNumber = RoomGroups.Count; + + _areaTypeColumnsIndexes = new int[] { 7 }; + _lengthTypeColumnsIndexes = new int[] { 8 }; + _numericColumnsIndexes = _areaTypeColumnsIndexes + .Concat(_lengthTypeColumnsIndexes) + .ToArray(); } public int ColumnsTotalNumber => _columnsTotalNumber; @@ -36,6 +44,8 @@ public CommercialTableInfo(IReadOnlyCollection commercialRooms, public int OtherRoomsStart => _otherRoomsStart; public int UtpStart => _utpStart; public int[] NumericColumnsIndexes => _numericColumnsIndexes; + public int[] AreaTypeColumnsIndexes => _areaTypeColumnsIndexes; + public int[] LengthTypeColumnsIndexes => _lengthTypeColumnsIndexes; public DeclarationSettings Settings => _settings; public IReadOnlyCollection RoomGroups => _commercialRooms; diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/ITableInfo.cs b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/ITableInfo.cs index e707a582..77e38ed5 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/ITableInfo.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/ITableInfo.cs @@ -1,8 +1,4 @@ -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace RevitDeclarations.Models { internal interface ITableInfo { @@ -14,6 +10,8 @@ internal interface ITableInfo { int OtherRoomsStart { get; } int UtpStart { get; } int[] NumericColumnsIndexes { get; } + int[] AreaTypeColumnsIndexes { get; } + int[] LengthTypeColumnsIndexes { get; } DeclarationSettings Settings { get; } IReadOnlyCollection RoomGroups { get; } diff --git a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/PublicAreasTableInfo.cs b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/PublicAreasTableInfo.cs index 25cf9176..2c36f1d5 100644 --- a/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/PublicAreasTableInfo.cs +++ b/src/RevitDeclarations/Models/Export/DeclarationData/TableInfo/PublicAreasTableInfo.cs @@ -13,6 +13,8 @@ internal class PublicAreasTableInfo : ITableInfo { private readonly int _otherRoomsStart; private readonly int _utpStart; private readonly int[] _numericColumnsIndexes; + private readonly int[] _areaTypeColumnsIndexes; + private readonly int[] _lengthTypeColumnsIndexes; private readonly DeclarationSettings _settings; private readonly IReadOnlyCollection _publicAreas; @@ -26,8 +28,13 @@ public PublicAreasTableInfo(IReadOnlyCollection publicAreas, _summerRoomsStart = 0; _otherRoomsStart = 0; _utpStart = 0; - _numericColumnsIndexes = new int[] { 4 }; _rowsTotalNumber = RoomGroups.Count; + + _areaTypeColumnsIndexes = new int[] { 4 }; + _lengthTypeColumnsIndexes = new int[] { }; + _numericColumnsIndexes = _areaTypeColumnsIndexes + .Concat(_lengthTypeColumnsIndexes) + .ToArray(); } public int ColumnsTotalNumber => _columnsTotalNumber; @@ -37,6 +44,8 @@ public PublicAreasTableInfo(IReadOnlyCollection publicAreas, public int OtherRoomsStart => _otherRoomsStart; public int UtpStart => _utpStart; public int[] NumericColumnsIndexes => _numericColumnsIndexes; + public int[] AreaTypeColumnsIndexes => _areaTypeColumnsIndexes; + public int[] LengthTypeColumnsIndexes => _lengthTypeColumnsIndexes; public DeclarationSettings Settings => _settings; public IReadOnlyCollection RoomGroups => _publicAreas; diff --git a/src/RevitDeclarations/Models/Export/Exporters/CsvExporter.cs b/src/RevitDeclarations/Models/Export/Exporters/CsvExporter.cs index e85898e7..2ebd2295 100644 --- a/src/RevitDeclarations/Models/Export/Exporters/CsvExporter.cs +++ b/src/RevitDeclarations/Models/Export/Exporters/CsvExporter.cs @@ -6,13 +6,22 @@ namespace RevitDeclarations.Models { internal class CsvExporter : ITableExporter { public void Export(string path, IDeclarationDataTable table) { - path = Path.ChangeExtension(path, "csv"); + string fullPath = Path.ChangeExtension(path, "csv"); string strData = ConvertDataTableToString(table); - using(StreamWriter file = File.CreateText(path)) { + using(StreamWriter file = File.CreateText(fullPath)) { file.Write(strData); } + + if(table.SubTables.Any()) { + int tableNumber = 1; + foreach(var subTable in table.SubTables) { + path = $"{path}-{tableNumber}"; + Export(path, subTable); + tableNumber++; + } + } } private string ConvertDataTableToString(IDeclarationDataTable table) { diff --git a/src/RevitDeclarations/Models/Export/Exporters/ExcelExporter.cs b/src/RevitDeclarations/Models/Export/Exporters/ExcelExporter.cs index 75012957..a716baf8 100644 --- a/src/RevitDeclarations/Models/Export/Exporters/ExcelExporter.cs +++ b/src/RevitDeclarations/Models/Export/Exporters/ExcelExporter.cs @@ -17,7 +17,7 @@ internal class ExcelExporter : ITableExporter { private readonly Color _nonConfigRoomsColor = Color.FromArgb(237, 237, 237); private readonly Color _utpColor = Color.FromArgb(226, 207, 245); - public void Export(string path, IDeclarationDataTable declarationTable) { + public void Export(string path, IDeclarationDataTable declarationDataTable) { /* Releasing all COM objects was made on the basis of the article: * https://www.add-in-express.com/creating-addins-blog/release-excel-com-objects/ */ @@ -42,38 +42,36 @@ public void Export(string path, IDeclarationDataTable declarationTable) { workBooks = excelApp.Workbooks; workBook = workBooks.Add(); workSheets = workBook.Worksheets; - workSheet = (Worksheet) workSheets["Лист1"]; - workSheet.Name = "Помещения"; + workSheet = (Worksheet) workSheets[1]; + workSheet.Name = declarationDataTable.Name; - SetMainSheetGraphicSettings(workSheet, declarationTable.TableInfo); + SetMainSheetGraphicSettings(workSheet, declarationDataTable.TableInfo); - DataTable headerTable = declarationTable.HeaderDataTable; + DataTable headerTable = declarationDataTable.HeaderDataTable; for(int i = 0; i < headerTable.Columns.Count; i++) { workSheet.Cells[1, i + 1] = headerTable.Rows[0][i]; } - DataTable mainTable = declarationTable.MainDataTable; + DataTable mainTable = declarationDataTable.MainDataTable; for(int i = 0; i < mainTable.Rows.Count; i++) { for(int j = 0; j < mainTable.Columns.Count; j++) { workSheet.Cells[i + 2, j + 1] = mainTable.Rows[i][j]; } } - - int counter = 1; - if(declarationTable.SubTables.Any()) { + if(declarationDataTable.SubTables.Any()) { Worksheet subWorkSheet = null; - foreach(var subTable in declarationTable.SubTables) { + foreach(var subDataTable in declarationDataTable.SubTables) { subWorkSheet = (Worksheet) workSheets.Add(After: workBook.Sheets[workBook.Sheets.Count]); - subWorkSheet.Name = $"Части помещений-{counter}"; + subWorkSheet.Name = subDataTable.Name; - DataTable subHeaderTable = subTable.HeaderDataTable; + DataTable subHeaderTable = subDataTable.HeaderDataTable; for(int i = 0; i < subHeaderTable.Columns.Count; i++) { subWorkSheet.Cells[1, i + 1] = subHeaderTable.Rows[0][i]; } - DataTable subMainTable = subTable.MainDataTable; + DataTable subMainTable = subDataTable.MainDataTable; for(int i = 0; i < subMainTable.Rows.Count; i++) { for(int j = 0; j < subMainTable.Columns.Count; j++) { subWorkSheet.Cells[i + 2, j + 1] = subMainTable.Rows[i][j]; @@ -81,7 +79,6 @@ public void Export(string path, IDeclarationDataTable declarationTable) { } SetSubSheetGraphicSettings(subWorkSheet); - counter++; } } @@ -111,6 +108,18 @@ private void SetMainSheetGraphicSettings(Worksheet workSheet, ITableInfo tableIn workSheet.Range[firstCell, lastCell].HorizontalAlignment = XlHAlign.xlHAlignCenter; workSheet.Range[firstCell, lastCell].VerticalAlignment = XlVAlign.xlVAlignCenter; + for(int i = 0; i < tableInfo.ColumnsTotalNumber; i++) { + if(tableInfo.AreaTypeColumnsIndexes.Contains(i)) { + string strFormat = $"0.{new string('0', tableInfo.Settings.AccuracyForArea)}"; + ((Range) workSheet.Columns[i + 1]).NumberFormat = strFormat; + } else if(tableInfo.LengthTypeColumnsIndexes.Contains(i)) { + string strFormat = $"0.{new string('0', tableInfo.Settings.AccuracyForLength)}"; + ((Range) workSheet.Columns[i + 1]).NumberFormat = strFormat; + } else { + ((Range) workSheet.Columns[i + 1]).NumberFormat = "@"; + } + } + // Настройка шапки таблицы Range range = (Range) workSheet.Rows[1]; range.RowHeight = 60; @@ -131,7 +140,7 @@ private void SetMainSheetGraphicSettings(Worksheet workSheet, ITableInfo tableIn int checkColumnNumber = (i - tableInfo.GroupsInfoColumnsNumber) % 3; if(checkColumnNumber == 0) { - ((Range) workSheet.Columns[i - 2]).NumberFormat = "@"; + //((Range) workSheet.Columns[i - 2]).NumberFormat = "@"; ((Range) workSheet.Columns[i - 1]).ColumnWidth = 17; } // Летние помещения квартир @@ -141,7 +150,7 @@ private void SetMainSheetGraphicSettings(Worksheet workSheet, ITableInfo tableIn int checkColumnNumber = (i - tableInfo.SummerRoomsStart) % 4; if(checkColumnNumber == 0) { - ((Range) workSheet.Columns[i - 3]).NumberFormat = "@"; + //((Range) workSheet.Columns[i - 3]).NumberFormat = "@"; ((Range) workSheet.Columns[i - 2]).ColumnWidth = 17; } // Остальные (не из списка приоритетов) помещения квартир @@ -151,7 +160,7 @@ private void SetMainSheetGraphicSettings(Worksheet workSheet, ITableInfo tableIn int checkColumnNumber = (i - tableInfo.OtherRoomsStart) % 3; if(checkColumnNumber == 0) { - ((Range) workSheet.Columns[i - 2]).NumberFormat = "@"; + //((Range) workSheet.Columns[i - 2]).NumberFormat = "@"; ((Range) workSheet.Columns[i - 1]).ColumnWidth = 17; } // УТП квартир @@ -171,6 +180,8 @@ private void SetSubSheetGraphicSettings(Worksheet workSheet) { ((Range) workSheet.Columns[2]).ColumnWidth = 43; ((Range) workSheet.Columns[3]).ColumnWidth = 17; + ((Range) workSheet.Columns[2]).NumberFormat = "0.0"; + ((Range) workSheet.Rows[1]).HorizontalAlignment = XlHAlign.xlHAlignCenter; ((Range) workSheet.Columns[2]).HorizontalAlignment = XlHAlign.xlHAlignCenter; } diff --git a/src/RevitDeclarations/Models/Rooms/RoomElement.cs b/src/RevitDeclarations/Models/Rooms/RoomElement.cs index 52bd9e56..ceaf65e8 100644 --- a/src/RevitDeclarations/Models/Rooms/RoomElement.cs +++ b/src/RevitDeclarations/Models/Rooms/RoomElement.cs @@ -25,14 +25,14 @@ public RoomElement(Room room, DeclarationSettings settings) { _name = _revitRoom.get_Parameter(BuiltInParameter.ROOM_NAME).AsString(); - _areaRevit = ParamConverter.ConvertArea(_revitRoom.Area, settings.Accuracy); + _areaRevit = ParamConverter.ConvertArea(_revitRoom.Area, settings.AccuracyForArea); RoomAreaCalculator areaCalculator = new RoomAreaCalculator(settings, this); _areaCoefRevit = areaCalculator.CalculateAreaCoefRevit(); _areaLivingRevit = areaCalculator.CalculateAreaLivingRevit(); _areaNonSummerRevit = areaCalculator.CalculateAreaNonSummerRevit(); - _area = GetAreaParamValue(settings.RoomAreaParam, settings.Accuracy); - _areaCoef = GetAreaParamValue(settings.RoomAreaCoefParam, settings.Accuracy); + _area = GetAreaParamValue(settings.RoomAreaParam, settings.AccuracyForArea); + _areaCoef = GetAreaParamValue(settings.RoomAreaCoefParam, settings.AccuracyForArea); } [JsonIgnore] diff --git a/src/RevitDeclarations/Models/Rooms/RoomGroup.cs b/src/RevitDeclarations/Models/Rooms/RoomGroup.cs index cb258074..d3f52bf8 100644 --- a/src/RevitDeclarations/Models/Rooms/RoomGroup.cs +++ b/src/RevitDeclarations/Models/Rooms/RoomGroup.cs @@ -22,7 +22,7 @@ internal abstract class RoomGroup { public RoomGroup(IEnumerable rooms, DeclarationSettings settings, RoomParamProvider paramProvider) { _settings = settings; _paramProvider = paramProvider; - _accuracy = settings.Accuracy; + _accuracy = settings.AccuracyForArea; _rooms = rooms.ToList(); _firstRoom = rooms.FirstOrDefault(); diff --git a/src/RevitDeclarations/Models/Settings/DeclarationSettings.cs b/src/RevitDeclarations/Models/Settings/DeclarationSettings.cs index 151ff5cf..c27ec7c6 100644 --- a/src/RevitDeclarations/Models/Settings/DeclarationSettings.cs +++ b/src/RevitDeclarations/Models/Settings/DeclarationSettings.cs @@ -13,7 +13,8 @@ internal abstract class DeclarationSettings { .ToList(); public Phase SelectedPhase { get; set; } - public int Accuracy { get; set; } + public int AccuracyForArea { get; set; } + public int AccuracyForLength { get; set; } public bool LoadUtp { get; set; } public IReadOnlyCollection MainRoomNames => PrioritiesConfig .Priorities diff --git a/src/RevitDeclarations/Models/UtpCalculator.cs b/src/RevitDeclarations/Models/UtpCalculator.cs index ae16cc01..6ba60a95 100644 --- a/src/RevitDeclarations/Models/UtpCalculator.cs +++ b/src/RevitDeclarations/Models/UtpCalculator.cs @@ -118,7 +118,7 @@ public IReadOnlyCollection CheckProjectForUtp() { // Все помещения в квартире имеют высоту от 3400 мм. public string CalculateHighflat(Apartment apartment) { foreach(var room in apartment.Rooms) { - double height = room.GetLengthParamValue(_settings.RoomsHeightParam, _settings.Accuracy); + double height = room.GetLengthParamValue(_settings.RoomsHeightParam, _settings.AccuracyForArea); if(height < _minHighFlatHeight) { return "Нет"; } @@ -217,7 +217,7 @@ public string CalculateExtraBalconyArea(Apartment apartment) { if(summerRooms.Any()) { return ContourChecker - .CheckAnyRoomSizes(summerRevitRooms, _settings.Accuracy, 0, _minBalconyDepth) + .CheckAnyRoomSizes(summerRevitRooms, _settings.AccuracyForArea, 0, _minBalconyDepth) .GetDescription(); } else { return "Нет"; @@ -240,12 +240,12 @@ public string CalculatePantry(Apartment apartment) { .GetRoomsByPrior(_priorities.Pantry) .Select(x => x.RevitRoom) .Where(x => !_pantriesWithBedroom.Contains(x.Id)) - .Where(x => ContourChecker.CheckArea(x, _settings.Accuracy, _minPantryArea)) + .Where(x => ContourChecker.CheckArea(x, _settings.AccuracyForArea, _minPantryArea)) .ToList(); if(pantriesWithoutBedrooms.Any()) { return ContourChecker - .CheckAnyRoomSizes(pantriesWithoutBedrooms, _settings.Accuracy, _minPantryDepth) + .CheckAnyRoomSizes(pantriesWithoutBedrooms, _settings.AccuracyForArea, _minPantryDepth) .GetDescription(); } else { return "Нет"; diff --git a/src/RevitDeclarations/README.md b/src/RevitDeclarations/README.md index 99cbc786..8d6cce0b 100644 --- a/src/RevitDeclarations/README.md +++ b/src/RevitDeclarations/README.md @@ -1,5 +1,5 @@ # RevitDeclarations (Декларации) -Плагин для выгрузки делкараций по квартирам. +Плагин для выгрузки деклараций по квартирам. # Сборка проекта ``` diff --git a/src/RevitDeclarations/ViewModels/ExportViewModels/ApartmentsCsvExportVM.cs b/src/RevitDeclarations/ViewModels/ExportViewModels/ApartmentsCsvExportVM.cs index 21b242c0..2507aad0 100644 --- a/src/RevitDeclarations/ViewModels/ExportViewModels/ApartmentsCsvExportVM.cs +++ b/src/RevitDeclarations/ViewModels/ExportViewModels/ApartmentsCsvExportVM.cs @@ -12,8 +12,8 @@ public ApartmentsCsvExportVM(string name, Guid id, DeclarationSettings settings) public override void Export(string path, IEnumerable roomGroups) { List apartments = roomGroups.Cast().ToList(); - ApartmentsTableInfo tableData = new ApartmentsTableInfo(apartments, _settings); - ApartmentsDataTable table = new ApartmentsDataTable(tableData); + ApartmentsTableInfo tableInfo = new ApartmentsTableInfo(apartments, _settings); + ApartmentsDataTable table = new ApartmentsDataTable("15.2 Жилые помещения", tableInfo); table.GenerateTable(); ExportTable(path, table); diff --git a/src/RevitDeclarations/ViewModels/ExportViewModels/ApartmentsExcelExportVM.cs b/src/RevitDeclarations/ViewModels/ExportViewModels/ApartmentsExcelExportVM.cs index 8b366c42..5c264f01 100644 --- a/src/RevitDeclarations/ViewModels/ExportViewModels/ApartmentsExcelExportVM.cs +++ b/src/RevitDeclarations/ViewModels/ExportViewModels/ApartmentsExcelExportVM.cs @@ -13,7 +13,7 @@ public ApartmentsExcelExportVM(string name, Guid id, DeclarationSettings setting public override void Export(string path, IEnumerable roomGroups) { List apartments = roomGroups.Cast().ToList(); ApartmentsTableInfo tableData = new ApartmentsTableInfo(apartments, _settings); - ApartmentsDataTable table = new ApartmentsDataTable(tableData); + ApartmentsDataTable table = new ApartmentsDataTable("15.2 Жилые помещения", tableData); table.GenerateTable(); ExportTable(path, table); diff --git a/src/RevitDeclarations/ViewModels/ExportViewModels/CommercialCsvExportVM.cs b/src/RevitDeclarations/ViewModels/ExportViewModels/CommercialCsvExportVM.cs index 3b8304c0..184bd202 100644 --- a/src/RevitDeclarations/ViewModels/ExportViewModels/CommercialCsvExportVM.cs +++ b/src/RevitDeclarations/ViewModels/ExportViewModels/CommercialCsvExportVM.cs @@ -15,7 +15,7 @@ public CommercialCsvExportVM(string name, Guid id, DeclarationSettings settings) public override void Export(string path, IEnumerable roomGroups) { List commercialRooms = roomGroups.Cast().ToList(); CommercialTableInfo tableData = new CommercialTableInfo(commercialRooms, _settings); - CommercialDataTable table = new CommercialDataTable(tableData); + CommercialDataTable table = new CommercialDataTable("15.3 Нежилые помещения", tableData); table.GenerateTable(); ExportTable(path, table); diff --git a/src/RevitDeclarations/ViewModels/ExportViewModels/CommercialExcelExportVM.cs b/src/RevitDeclarations/ViewModels/ExportViewModels/CommercialExcelExportVM.cs index c1b2d1e8..d9cec4b0 100644 --- a/src/RevitDeclarations/ViewModels/ExportViewModels/CommercialExcelExportVM.cs +++ b/src/RevitDeclarations/ViewModels/ExportViewModels/CommercialExcelExportVM.cs @@ -15,7 +15,7 @@ public CommercialExcelExportVM(string name, Guid id, DeclarationSettings setting public override void Export(string path, IEnumerable roomGroups) { List commercialRooms = roomGroups.Cast().ToList(); CommercialTableInfo tableInfo = new CommercialTableInfo(commercialRooms, _settings); - CommercialDataTable table = new CommercialDataTable(tableInfo); + CommercialDataTable table = new CommercialDataTable("15.3 Нежилые помещения", tableInfo); table.GenerateTable(); ExportTable(path, table); diff --git a/src/RevitDeclarations/ViewModels/ExportViewModels/PublicAreasCsvExportVM.cs b/src/RevitDeclarations/ViewModels/ExportViewModels/PublicAreasCsvExportVM.cs index 1f820aa3..b5746126 100644 --- a/src/RevitDeclarations/ViewModels/ExportViewModels/PublicAreasCsvExportVM.cs +++ b/src/RevitDeclarations/ViewModels/ExportViewModels/PublicAreasCsvExportVM.cs @@ -16,7 +16,7 @@ public PublicAreasCsvExportVM(string name, Guid id, DeclarationSettings settings public override void Export(string path, IEnumerable roomGroups) { List publicAreas = roomGroups.Cast().ToList(); PublicAreasTableInfo tableData = new PublicAreasTableInfo(publicAreas, _settings); - PublicAreasDataTable table = new PublicAreasDataTable(tableData); + PublicAreasDataTable table = new PublicAreasDataTable("16.1 МОП", tableData); table.GenerateTable(); ExportTable(path, table); diff --git a/src/RevitDeclarations/ViewModels/ExportViewModels/PublicAreasExcelExportVM.cs b/src/RevitDeclarations/ViewModels/ExportViewModels/PublicAreasExcelExportVM.cs index a4aae5ce..099503bf 100644 --- a/src/RevitDeclarations/ViewModels/ExportViewModels/PublicAreasExcelExportVM.cs +++ b/src/RevitDeclarations/ViewModels/ExportViewModels/PublicAreasExcelExportVM.cs @@ -16,7 +16,7 @@ public PublicAreasExcelExportVM(string name, Guid id, DeclarationSettings settin public override void Export(string path, IEnumerable roomGroups) { List publicAreas = roomGroups.Cast().ToList(); PublicAreasTableInfo tableData = new PublicAreasTableInfo(publicAreas, _settings); - PublicAreasDataTable table = new PublicAreasDataTable(tableData); + PublicAreasDataTable table = new PublicAreasDataTable("16.1 МОП", tableData); table.GenerateTable(); ExportTable(path, table); diff --git a/src/RevitDeclarations/ViewModels/MainViewModels/MainViewModel.cs b/src/RevitDeclarations/ViewModels/MainViewModels/MainViewModel.cs index 5c154eac..132929ef 100644 --- a/src/RevitDeclarations/ViewModels/MainViewModels/MainViewModel.cs +++ b/src/RevitDeclarations/ViewModels/MainViewModels/MainViewModel.cs @@ -189,7 +189,8 @@ public bool CanExport(object obj) { public void SetSelectedSettings() { int.TryParse(_accuracy, out int accuracy); - _settings.Accuracy = accuracy; + _settings.AccuracyForArea = accuracy; + _settings.AccuracyForLength = 2; _settings.SelectedPhase = _selectedPhase; _settings.PrioritiesConfig = _prioritiesViewModel.PrioritiesConfig; diff --git a/src/RevitDeclarations/Views/TabItems/PrioritiesTabItem.xaml b/src/RevitDeclarations/Views/TabItems/PrioritiesTabItem.xaml index f9e3716f..3570c7a7 100644 --- a/src/RevitDeclarations/Views/TabItems/PrioritiesTabItem.xaml +++ b/src/RevitDeclarations/Views/TabItems/PrioritiesTabItem.xaml @@ -60,7 +60,7 @@