[feat:] tabular overview of plz groups
This commit is contained in:
@@ -749,6 +749,7 @@ public class PdfBuilder
|
||||
document.Info.Author = "logofclient";
|
||||
|
||||
var grouped_nums = GroupAddresses(setID).ToList();
|
||||
DrawPostalCodeOverview(document, grouped_nums);
|
||||
|
||||
// Zwei Tabellen pro A4-Seite
|
||||
int sheets = (grouped_nums.Count + 1) / 2;
|
||||
@@ -840,6 +841,97 @@ public class PdfBuilder
|
||||
document.Save(path);
|
||||
}
|
||||
|
||||
private void DrawPostalCodeOverview(PdfDocument document, List<(int, string, string, string, int)> groupedNumbers)
|
||||
{
|
||||
if (groupedNumbers.Count == 0)
|
||||
return;
|
||||
|
||||
var summaries = groupedNumbers
|
||||
.GroupBy(item => item.Item2)
|
||||
.OrderBy(group => group.Key, StringComparer.Ordinal)
|
||||
.Select(group => new
|
||||
{
|
||||
Prefix = group.Key,
|
||||
AddressCount = group.Sum(item => item.Item5),
|
||||
GroupCount = group.Count(),
|
||||
StartPostalCode = group.First().Item3,
|
||||
EndPostalCode = group.Last().Item4
|
||||
})
|
||||
.ToList();
|
||||
|
||||
const double tableTop = 58;
|
||||
const double headerHeight = 16;
|
||||
const double rowHeight = 14;
|
||||
const double tableGap = 12;
|
||||
double[] columnWidths = { 40, 50, 36, 55, 55 };
|
||||
string[] headers = { "PLZ-Gr.", "Anz.", "Anz.Gr.", "Start", "Ende" };
|
||||
var titleFont = new XFont("Arial", 13, XFontStyleEx.Bold);
|
||||
var headerFont = new XFont("Arial", 7.5, XFontStyleEx.Bold);
|
||||
var textFont = new XFont("Arial", 7.5, XFontStyleEx.Regular);
|
||||
var groupCountFont = new XFont("Arial", 7.5, XFontStyleEx.Bold);
|
||||
int leftCount = (summaries.Count + 1) / 2;
|
||||
double tableWidth = columnWidths.Sum();
|
||||
double allTablesWidth = tableWidth * 2 + tableGap;
|
||||
|
||||
var page = document.AddPage();
|
||||
page.Size = PageSize.A4;
|
||||
using var gfx = XGraphics.FromPdfPage(page);
|
||||
|
||||
gfx.DrawString("Übersicht PLZ-Gruppen", titleFont, XBrushes.Black,
|
||||
new XRect(28, 26, page.Width.Point - 56, 22), XStringFormats.TopLeft);
|
||||
|
||||
double firstTableX = (page.Width.Point - allTablesWidth) / 2;
|
||||
for (int tableIndex = 0; tableIndex < 2; tableIndex++)
|
||||
{
|
||||
int startIndex = tableIndex == 0 ? 0 : leftCount;
|
||||
int itemCount = tableIndex == 0 ? leftCount : summaries.Count - leftCount;
|
||||
if (itemCount == 0)
|
||||
continue;
|
||||
|
||||
double tableX = firstTableX + tableIndex * (tableWidth + tableGap);
|
||||
gfx.DrawRectangle(XBrushes.LightGray, tableX, tableTop, tableWidth, headerHeight);
|
||||
gfx.DrawRectangle(XPens.Black, tableX, tableTop, tableWidth, headerHeight);
|
||||
|
||||
double columnX = tableX;
|
||||
for (int columnIndex = 0; columnIndex < headers.Length; columnIndex++)
|
||||
{
|
||||
gfx.DrawString(headers[columnIndex], headerFont, XBrushes.Black,
|
||||
new XRect(columnX + 2, tableTop, columnWidths[columnIndex] - 4, headerHeight),
|
||||
XStringFormats.Center);
|
||||
columnX += columnWidths[columnIndex];
|
||||
if (columnIndex < headers.Length - 1)
|
||||
gfx.DrawLine(XPens.Black, columnX, tableTop, columnX, tableTop + headerHeight);
|
||||
}
|
||||
|
||||
for (int rowIndex = 0; rowIndex < itemCount; rowIndex++)
|
||||
{
|
||||
var summary = summaries[startIndex + rowIndex];
|
||||
string[] values =
|
||||
{
|
||||
summary.Prefix,
|
||||
summary.AddressCount.ToString(),
|
||||
summary.GroupCount.ToString(),
|
||||
summary.StartPostalCode,
|
||||
summary.EndPostalCode
|
||||
};
|
||||
double rowY = tableTop + headerHeight + rowIndex * rowHeight;
|
||||
gfx.DrawRectangle(XPens.Black, tableX, rowY, tableWidth, rowHeight);
|
||||
|
||||
columnX = tableX;
|
||||
for (int columnIndex = 0; columnIndex < values.Length; columnIndex++)
|
||||
{
|
||||
gfx.DrawString(values[columnIndex], columnIndex == 2 ? groupCountFont : textFont,
|
||||
XBrushes.Black,
|
||||
new XRect(columnX + 2, rowY, columnWidths[columnIndex] - 4, rowHeight),
|
||||
XStringFormats.Center);
|
||||
columnX += columnWidths[columnIndex];
|
||||
if (columnIndex < values.Length - 1)
|
||||
gfx.DrawLine(XPens.Black, columnX, rowY, columnX, rowY + rowHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGermanyRunningSheet(XGraphics gfx, double x, double y, double w, double h, KasAddressList list, dynamic result, List<(int,string,string,string,int)> grouped_nums, XFont fontLabel, XFont fontText, XFont fontBig, int? pal_nr, int? bundleOnPallet, int totalBundleNumber)
|
||||
{
|
||||
double line = 1.0;
|
||||
|
||||
Reference in New Issue
Block a user