[#34] DeliveryAdminWindow: Show cultivation beside attribute

This commit is contained in:
2024-02-23 12:54:09 +01:00
parent 7b1a3b4f8b
commit 190ef82872
2 changed files with 40 additions and 17 deletions

View File

@ -107,6 +107,7 @@
<Bold>Saison</Bold>: z.B. 2020, &gt;2015, 2017-2019, &lt;2005, 2019-, ...<LineBreak/> <Bold>Saison</Bold>: z.B. 2020, &gt;2015, 2017-2019, &lt;2005, 2019-, ...<LineBreak/>
<Bold>Zweigstelle</Bold>: z.B. musterort, ...<LineBreak/> <Bold>Zweigstelle</Bold>: z.B. musterort, ...<LineBreak/>
<Bold>Attribut</Bold>: z.B. kabinett, !kabinett (alle außer kabinett), ...<LineBreak/> <Bold>Attribut</Bold>: z.B. kabinett, !kabinett (alle außer kabinett), ...<LineBreak/>
<Bold>Bewirtschaftung</Bold>: z.B. bio, !kip (alle außer KIP), ...<LineBreak/>
<Bold>Datum</Bold>: z.B. 1.9., 15.9.-10.10., -15.10.2020, ...<LineBreak/> <Bold>Datum</Bold>: z.B. 1.9., 15.9.-10.10., -15.10.2020, ...<LineBreak/>
<Bold>Uhrzeit</Bold>: z.B. 06:00-08:00, 18:00-, ...<LineBreak/> <Bold>Uhrzeit</Bold>: z.B. 06:00-08:00, 18:00-, ...<LineBreak/>
<Bold>Freitext</Bold>: z.B. Lieferscheinnummern, Anmerkung, "quw" (sucht nach dem Text "quw") <Bold>Freitext</Bold>: z.B. Lieferscheinnummern, Anmerkung, "quw" (sucht nach dem Text "quw")
@ -415,7 +416,8 @@
<TextBlock Text="{Binding Kmw, StringFormat='{}{0:0.0}°'}" Width="40" TextAlignment="Right" Padding="0,0,10,0"/> <TextBlock Text="{Binding Kmw, StringFormat='{}{0:0.0}°'}" Width="40" TextAlignment="Right" Padding="0,0,10,0"/>
<TextBlock Text="{Binding QualId}" Width="30"/> <TextBlock Text="{Binding QualId}" Width="30"/>
<TextBlock Text="{Binding Weight, StringFormat='{}{0:N0} kg'}" Width="60" TextAlignment="Right" Padding="0,0,10,0"/> <TextBlock Text="{Binding Weight, StringFormat='{}{0:N0} kg'}" Width="60" TextAlignment="Right" Padding="0,0,10,0"/>
<TextBlock Text="{Binding Attribute.Name}" Width="100"/> <TextBlock Text="{Binding Attribute.Name}" Width="60"/>
<TextBlock Text="{Binding Cultivation.Name}" Width="50"/>
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>

View File

@ -118,7 +118,7 @@ namespace Elwig.Windows {
NewDeliveryButton_Click(null, null); NewDeliveryButton_Click(null, null);
if ((Context.Seasons.Find(Utils.CurrentYear)) == null) { if ((Context.Seasons.Find(Utils.CurrentYear)) == null) {
MessageBox.Show("Die Saison für das aktuelle Jahr wurde noch nicht erstellt. Neue Lieferungen können nicht abgespeichert werden.", MessageBox.Show("Die Saison für das aktuelle Jahr wurde noch nicht erstellt. Neue Lieferungen können nicht abgespeichert werden.",
"Saison noch nicht erstellt", MessageBoxButton.OK, MessageBoxImage.Error); "Saison noch nicht erstellt", MessageBoxButton.OK, MessageBoxImage.Warning);
} }
} }
} }
@ -335,6 +335,8 @@ namespace Elwig.Windows {
var filterZwst = new List<string>(); var filterZwst = new List<string>();
var filterAttr = new List<string>(); var filterAttr = new List<string>();
var filterNotAttr = new List<string>(); var filterNotAttr = new List<string>();
var filterCult = new List<string>();
var filterNotCult = new List<string>();
var filterDate = new List<(string?, string?)>(); var filterDate = new List<(string?, string?)>();
var filterTime = new List<(string?, string?)>(); var filterTime = new List<(string?, string?)>();
int filterYearGt = 0, filterYearLt = 0; int filterYearGt = 0, filterYearLt = 0;
@ -347,7 +349,8 @@ namespace Elwig.Windows {
var qual = await Context.WineQualityLevels.Where(q => !q.IsPredicate).ToDictionaryAsync(q => q.QualId, q => q); var qual = await Context.WineQualityLevels.Where(q => !q.IsPredicate).ToDictionaryAsync(q => q.QualId, q => q);
var mgnr = await Context.Members.ToDictionaryAsync(m => m.MgNr.ToString(), m => m); var mgnr = await Context.Members.ToDictionaryAsync(m => m.MgNr.ToString(), m => m);
var zwst = await Context.Branches.ToDictionaryAsync(b => b.Name.ToLower().Split(" ")[0], b => b); var zwst = await Context.Branches.ToDictionaryAsync(b => b.Name.ToLower().Split(" ")[0], b => b);
var attr = await Context.WineAttributes.ToDictionaryAsync(a => a.Name.ToLower().Split(" ")[0], a => a); var attr = await Context.WineAttributes.ToDictionaryAsync(a => a.Name.ToLower().Split(' ')[0], a => a);
var cult = await Context.WineCultivations.ToDictionaryAsync(c => c.Name.ToLower().Split(' ')[0], c => c);
for (int i = 0; i < filter.Count; i++) { for (int i = 0; i < filter.Count; i++) {
var e = filter[i]; var e = filter[i];
@ -399,6 +402,16 @@ namespace Elwig.Windows {
filterNotAttr.Add(a.AttrId); filterNotAttr.Add(a.AttrId);
filter.RemoveAt(i--); filter.RemoveAt(i--);
filterNames.Add($"ohne Attribut {a.Name}"); filterNames.Add($"ohne Attribut {a.Name}");
} else if (cult.ContainsKey(e.ToLower())) {
var c = cult[e.ToLower()];
filterCult.Add(c.CultId);
filter.RemoveAt(i--);
filterNames.Add($"Bewirtschaftung {c.Name}");
} else if (e[0] == '!' && cult.ContainsKey(e[1..].ToLower())) {
var c = cult[e[1..].ToLower()];
filterNotCult.Add(c.CultId);
filter.RemoveAt(i--);
filterNames.Add($"ohne Bewirtschaftung {c.Name}");
} else if (zwst.ContainsKey(e.ToLower())) { } else if (zwst.ContainsKey(e.ToLower())) {
var b = zwst[e.ToLower()]; var b = zwst[e.ToLower()];
filterZwst.Add(b.ZwstId); filterZwst.Add(b.ZwstId);
@ -523,6 +536,8 @@ namespace Elwig.Windows {
if (filterZwst.Count > 0) prd = prd.And(p => filterZwst.Contains(p.Delivery.ZwstId)); if (filterZwst.Count > 0) prd = prd.And(p => filterZwst.Contains(p.Delivery.ZwstId));
if (filterAttr.Count > 0) prd = prd.And(p => p.AttrId != null && filterAttr.Contains(p.AttrId)); if (filterAttr.Count > 0) prd = prd.And(p => p.AttrId != null && filterAttr.Contains(p.AttrId));
if (filterNotAttr.Count > 0) prd = prd.And(p => p.AttrId == null || !filterNotAttr.Contains(p.AttrId)); if (filterNotAttr.Count > 0) prd = prd.And(p => p.AttrId == null || !filterNotAttr.Contains(p.AttrId));
if (filterCult.Count > 0) prd = prd.And(p => p.CultId != null && filterCult.Contains(p.CultId));
if (filterNotCult.Count > 0) prd = prd.And(p => p.CultId == null || !filterNotCult.Contains(p.CultId));
if (filterKmwGt > 0) prd = prd.And(p => p.Kmw >= filterKmwGt); if (filterKmwGt > 0) prd = prd.And(p => p.Kmw >= filterKmwGt);
if (filterKmwLt > 0) prd = prd.And(p => p.Kmw < filterKmwLt); if (filterKmwLt > 0) prd = prd.And(p => p.Kmw < filterKmwLt);
if (filterOeGt > 0) prd = prd.And(p => p.Kmw * (4.54 + 0.022 * p.Kmw) >= filterOeGt); if (filterOeGt > 0) prd = prd.And(p => p.Kmw * (4.54 + 0.022 * p.Kmw) >= filterOeGt);
@ -646,9 +661,10 @@ namespace Elwig.Windows {
AddGradationToolTipRow(1, "Gradation", null, kmwMin, kmwAvg, kmwMax); AddGradationToolTipRow(1, "Gradation", null, kmwMin, kmwAvg, kmwMax);
var attrGroups = await deliveryParts var attrGroups = await deliveryParts
.GroupBy(p => p.Attribute.Name) .GroupBy(p => new { Attr = p.Attribute.Name, Cult = p.Cultivation.Name })
.Select(g => new { .Select(g => new {
Attr = g.Key, g.Key.Attr,
g.Key.Cult,
Weight = g.Sum(p => p.Weight), Weight = g.Sum(p => p.Weight),
Min = g.Min(p => p.Kmw), Min = g.Min(p => p.Kmw),
Avg = g.Sum(p => p.Kmw * p.Weight) / g.Sum(p => p.Weight), Avg = g.Sum(p => p.Kmw * p.Weight) / g.Sum(p => p.Weight),
@ -671,11 +687,13 @@ namespace Elwig.Windows {
.ToListAsync(); .ToListAsync();
var groups = await deliveryParts var groups = await deliveryParts
.GroupBy(p => new { .GroupBy(p => new {
p.Attribute.Name, Attr = p.Attribute.Name,
Cult = p.Cultivation.Name,
p.SortId, p.SortId,
}) })
.Select(g => new { .Select(g => new {
Attr = g.Key.Name, g.Key.Attr,
g.Key.Cult,
g.Key.SortId, g.Key.SortId,
Weight = g.Sum(p => p.Weight), Weight = g.Sum(p => p.Weight),
Min = g.Min(p => p.Kmw), Min = g.Min(p => p.Kmw),
@ -690,25 +708,28 @@ namespace Elwig.Windows {
int rowNum = 1; int rowNum = 1;
foreach (var attrG in attrGroups) { foreach (var attrG in attrGroups) {
rowNum++; rowNum++;
AddWeightToolTipRow(rowNum++, attrG.Attr, null, attrG.Weight, attrG.Weight, weight); var name = attrG.Attr == null && attrG.Cult == null ? null : attrG.Attr + (attrG.Attr != null && attrG.Cult != null ? " / " : "") + attrG.Cult;
foreach (var g in groups.Where(g => g.Attr == attrG.Attr).OrderByDescending(g => g.Weight).ThenBy(g => g.SortId)) { AddWeightToolTipRow(rowNum++, name, null, attrG.Weight, attrG.Weight, weight);
foreach (var g in groups.Where(g => g.Attr == attrG.Attr && g.Cult == attrG.Cult).OrderByDescending(g => g.Weight).ThenBy(g => g.SortId)) {
AddWeightToolTipRow(rowNum++, null, g.SortId, g.Weight, attrG.Weight, weight); AddWeightToolTipRow(rowNum++, null, g.SortId, g.Weight, attrG.Weight, weight);
} }
} }
rowNum = 2; rowNum = 2;
foreach (var attrG in attrGroups) { foreach (var attrG in attrGroups) {
rowNum++; rowNum++;
AddGradationToolTipRow(rowNum++, attrG.Attr, null, attrG.Min, attrG.Avg, attrG.Max); var name = attrG.Attr == null && attrG.Cult == null ? null : attrG.Attr + (attrG.Attr != null && attrG.Cult != null ? " / " : "") + attrG.Cult;
foreach (var g in groups.Where(g => g.Attr == attrG.Attr).OrderByDescending(g => g.Avg).ThenBy(g => g.SortId)) { AddGradationToolTipRow(rowNum++, name, null, attrG.Min, attrG.Avg, attrG.Max);
foreach (var g in groups.Where(g => g.Attr == attrG.Attr && g.Cult == attrG.Cult).OrderByDescending(g => g.Avg).ThenBy(g => g.SortId)) {
AddGradationToolTipRow(rowNum++, null, g.SortId, g.Min, g.Avg, g.Max); AddGradationToolTipRow(rowNum++, null, g.SortId, g.Min, g.Avg, g.Max);
} }
} }
if (attrGroups.Count == 1) { if (attrGroups.Count == 1) {
var g = attrGroups.First().Attr; var g = attrGroups.First();
if (g != null) { var name = g.Attr == null && g.Cult == null ? null : g.Attr + (g.Attr != null && g.Cult != null ? " / " : "") + g.Cult;
StatusWeight.Text += $" [{g}]"; if (name != null) {
StatusGradation.Text += $" [{g}]"; StatusWeight.Text += $" [{name}]";
StatusGradation.Text += $" [{name}]";
} }
if (sortGroups.Count > 1 && sortGroups.Count <= 4) { if (sortGroups.Count > 1 && sortGroups.Count <= 4) {
StatusWeight.Text += $" = {string.Join(" + ", sortGroups.Select(g => $"{g.Weight:N0} kg ({(double)g.Weight / weight:0%})" + (g.SortId == null ? "" : $" [{g.SortId}]")))}"; StatusWeight.Text += $" = {string.Join(" + ", sortGroups.Select(g => $"{g.Weight:N0} kg ({(double)g.Weight / weight:0%})" + (g.SortId == null ? "" : $" [{g.SortId}]")))}";
@ -716,8 +737,8 @@ namespace Elwig.Windows {
} }
} else if (attrGroups.Count <= 4) { } else if (attrGroups.Count <= 4) {
StatusWeight.Text += $" = {string.Join(" + ", attrGroups.Select(g => $"{g.Weight:N0} kg ({(double)g.Weight / weight:0%})" + (g.Attr == null ? "" : $" [{g.Attr}]")))}"; StatusWeight.Text += $" = {string.Join(" + ", attrGroups.Select(g => $"{g.Weight:N0} kg ({(double)g.Weight / weight:0%})" + (g.Attr == null && g.Cult == null ? "" : $" [{g.Attr}{(g.Attr != null && g.Cult != null ? " / " : "")}{g.Cult}]")))}";
StatusGradation.Text += $" = {string.Join(" + ", attrGroups.Select(g => $"{g.Min:N1}/{g.Avg:N1}/{g.Max:N1}" + (g.Attr == null ? "" : $" [{g.Attr}]")))}"; StatusGradation.Text += $" = {string.Join(" + ", attrGroups.Select(g => $"{g.Min:N1}/{g.Avg:N1}/{g.Max:N1}" + (g.Attr == null && g.Cult == null ? "" : $" [{g.Attr}{(g.Attr != null && g.Cult != null ? " / " : "")}{g.Cult}]")))}";
} }
} else { } else {
StatusGradation.Text = "Gradation: -"; StatusGradation.Text = "Gradation: -";