From e35fa908adb87c8c52da0cd1a4fbf29c42aa8b47 Mon Sep 17 00:00:00 2001 From: HuskyTeufel Date: Fri, 13 Aug 2021 10:39:48 +0200 Subject: [PATCH] =?UTF-8?q?WIP=20umsatz=20f=C3=BCr=20Junker=20nach=20Stra?= =?UTF-8?q?=C3=9Fen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XMLParser/CalculateDay.cs | 23 ++++++++++++--- XMLParser/Enums.cs | 6 +++- XMLParser/KanalObjekt.cs | 4 +++ XMLParser/Kante.cs | 2 ++ XMLParser/Profil.cs | 20 +++++++++++++ XMLParser/XMLParse.cs | 18 ++++++++++++ XMLProgramm/CSVWriter.cs | 53 +++++++++++++++++++++++++++++++++++ XMLProgramm/Program.cs | 59 +++++++++++---------------------------- 8 files changed, 137 insertions(+), 48 deletions(-) create mode 100644 XMLParser/Profil.cs create mode 100644 XMLProgramm/CSVWriter.cs diff --git a/XMLParser/CalculateDay.cs b/XMLParser/CalculateDay.cs index fe910a4..b19b567 100644 --- a/XMLParser/CalculateDay.cs +++ b/XMLParser/CalculateDay.cs @@ -11,11 +11,26 @@ namespace XMLParser Dictionary result = new Dictionary(); decimal HauptkanalLaenge =0.0m; - inspektionen + List ranges = new List() + { + 250, + 400, + 600, + 800, + 1000, + int.MaxValue + }; + var rangePairs = ranges.Select((r,i)=> new {Range = r,Index = i}).ToList(); + var groupedInspektionen = inspektionen .FindAll(s => s.Inspektionsdaten.Anlagentyp.Equals(EAnlagetyp.Haltung)) - .ForEach(g => HauptkanalLaenge += g.Inspektionsdaten.OptischeInspektion.Rohrleitung.Inspektionslaenge); - result.Add(ECalculatedResult.HAUPTKANALLAENGE,HauptkanalLaenge); - + .OrderBy(a => a.Inspektionsdaten.OptischeInspektion.Rohrleitung.Grunddaten.Profilbreite) + .GroupBy(x => rangePairs.FirstOrDefault(r => r.Range >= x.Inspektionsdaten.OptischeInspektion.Rohrleitung.Grunddaten.Profilbreite)?.Index ?? -1); + + //inspektionen + // .FindAll(s => s.Inspektionsdaten.Anlagentyp.Equals(EAnlagetyp.Haltung)) + // .ForEach(g => HauptkanalLaenge += g.Inspektionsdaten.OptischeInspektion.Rohrleitung.Inspektionslaenge); + //result.Add(ECalculatedResult.HAUPTKANALLAENGE,HauptkanalLaenge); + //result.Add(ECalculatedResult.DN150DN250); List Anschlussleitungen = inspektionen.FindAll(x => x.Inspektionsdaten.Anlagentyp.Equals(EAnlagetyp.Anschlussleitung)); List SEs = Anschlussleitungen.FindAll(x => x.Stammdaten.Knoten != null && x.Stammdaten.Knoten.Anschlusspunkt != null && x.Stammdaten.Knoten.Anschlusspunkt.Punktkennung.Equals("SE")); List SOs = Anschlussleitungen.FindAll(x => x.Stammdaten.Knoten != null && x.Stammdaten.Knoten.Anschlusspunkt != null && !x.Stammdaten.Knoten.Anschlusspunkt.Punktkennung.Equals("SE")); diff --git a/XMLParser/Enums.cs b/XMLParser/Enums.cs index 290f2b6..c762b71 100644 --- a/XMLParser/Enums.cs +++ b/XMLParser/Enums.cs @@ -71,7 +71,11 @@ namespace XMLParser SONSTIGEANZAHL, STRASSENABLAUFUMSATZ, SONSTIGEUMSATZ, - HAUPTKANALLAENGE, + DN150DN250, + DN300DN400, + DN450DN600, + DN650DN800, + DN850DN1000, HAUPTKANALUMSATZ, SONSTIGELAENGEZULAGEMETER, STRASSENABLAUFLAENGEZULAGEMETER, diff --git a/XMLParser/KanalObjekt.cs b/XMLParser/KanalObjekt.cs index 8d76823..fa7c9d7 100644 --- a/XMLParser/KanalObjekt.cs +++ b/XMLParser/KanalObjekt.cs @@ -5,5 +5,9 @@ namespace XMLParser public string XmlFileName {get;set;} public AbwassertechnischeAnlage Stammdaten { get; internal set; } public InspizierteAbwassertechnischeAnlage Inspektionsdaten { get; internal set; } + public override string ToString() + { + return string.Format("{0} ({1})",Stammdaten.Objektbezeichnung,Inspektionsdaten.OptischeInspektion.Rohrleitung.Grunddaten.Profilbreite); + } } } diff --git a/XMLParser/Kante.cs b/XMLParser/Kante.cs index 6ad7504..242267d 100644 --- a/XMLParser/Kante.cs +++ b/XMLParser/Kante.cs @@ -9,6 +9,7 @@ namespace XMLParser int knotenAblaufTyp; int knotenZulaufTyp; bool isFiktiveLeitung = true; + Profil profil; public string knotenZulaufTemp; public string knotenAblaufTemp; @@ -20,5 +21,6 @@ namespace XMLParser public int KnotenAblaufTyp { get => knotenAblaufTyp; set => knotenAblaufTyp = value; } public int KnotenZulaufTyp { get => knotenZulaufTyp; set => knotenZulaufTyp = value; } public bool IsFiktiveLeitung { get => isFiktiveLeitung; set => isFiktiveLeitung = value; } + public Profil Profil { get => profil; set => profil = value; } } } \ No newline at end of file diff --git a/XMLParser/Profil.cs b/XMLParser/Profil.cs new file mode 100644 index 0000000..257c1f8 --- /dev/null +++ b/XMLParser/Profil.cs @@ -0,0 +1,20 @@ +namespace XMLParser +{ + public class Profil + { + int profilart; + int profilbreite; + int profilhoehe; + + public Profil(int profilart, int profilbreite, int profilhoehe) + { + Profilart = profilart; + Profilbreite = profilbreite; + Profilhoehe = profilhoehe; + } + + public int Profilart { get => profilart; set => profilart = value; } + public int Profilbreite { get => profilbreite; set => profilbreite = value; } + public int Profilhoehe { get => profilhoehe; set => profilhoehe = value; } + } +} \ No newline at end of file diff --git a/XMLParser/XMLParse.cs b/XMLParser/XMLParse.cs index ab6393e..830077c 100644 --- a/XMLParser/XMLParse.cs +++ b/XMLParser/XMLParse.cs @@ -387,12 +387,30 @@ namespace XMLParser { case "KnotenZulauf": result.knotenZulaufTemp = s.InnerText; break; case "KnotenAblauf": result.knotenAblaufTemp = s.InnerText; break; + case "Profil": result.Profil = getProfil(s);break; } } return result; } + private Profil getProfil(XmlNode s) + { + int Profilart =0, Profilbreite=0, Profilhoehe =0; + foreach(XmlNode d in s.ChildNodes) + { + switch(d.Name) + { + case "SonderprofilVorhanden": break; + case "Profilart": Profilart = Convert.ToInt32(s.InnerText); break; + case "Profilbreite": Profilbreite = Convert.ToInt32(s.InnerText); break; + case "Profilhoehe": Profilhoehe = Convert.ToInt32(s.InnerText); break; + default: throw new NotImplementedException(d.Name); + } + } + return new Profil(Profilart,Profilbreite,Profilhoehe); + } + private static Knoten parseStammdatenKnoten(XmlNode aktuell) { Knoten result = new Knoten(); diff --git a/XMLProgramm/CSVWriter.cs b/XMLProgramm/CSVWriter.cs new file mode 100644 index 0000000..af5bcdf --- /dev/null +++ b/XMLProgramm/CSVWriter.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using XMLParser; + +namespace XMLProgramm +{ + [DebuggerDisplay("{" + nameof(GetDebuggerDisplay) + "(),nq}")] + class CSVWriter + { + FileStream handle = null; + void writeToFile(string content) + { + content += Environment.NewLine; + byte[] bytes = Encoding.UTF8.GetBytes(content); + handle.Write(bytes,0,bytes.Length); + handle.Flush(); + } + public CSVWriter() + { + handle = File.Create("./data.csv"); + string WriteHeader = "Inspektionsdatum#Anzahl Straßenablaufe#Länge über 5m#SonstigeLeitungen#Sonstige Länge über 5m#Hauptkanallänge"; + writeToFile(WriteHeader); + } + + public void Save() + { + handle.Close(); + } + + internal void WriteDay(Dictionary calculated, List inspektionenAmTag) + { + int anzahlStraßenablaufe = (int)calculated[ECalculatedResult.STRASSENABLAUFANZAHL]; + int sonstigeLeitungen = (int)calculated[ECalculatedResult.SONSTIGEANZAHL]; + decimal Strassenablaufzulage = calculated[ECalculatedResult.STRASSENABLAUFLAENGEZULAGEMETER]; + decimal Sonstigezulage = calculated[ECalculatedResult.SONSTIGELAENGEZULAGEMETER]; + decimal HauptkanalLänge = calculated[ECalculatedResult.DN150DN250]; + + KanalObjekt last = inspektionenAmTag.Last(); + + string entry = last.Inspektionsdaten.OptischeInspektion.Inspektionsdatum + "#"+anzahlStraßenablaufe+"#"+Strassenablaufzulage+"#"+sonstigeLeitungen+"#"+Sonstigezulage+"#"+HauptkanalLänge; + writeToFile(entry); + } + + private string GetDebuggerDisplay() + { + return ToString(); + } + } +} diff --git a/XMLProgramm/Program.cs b/XMLProgramm/Program.cs index 207e0fb..c449c54 100644 --- a/XMLProgramm/Program.cs +++ b/XMLProgramm/Program.cs @@ -3,58 +3,32 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; -using System.Text; using XMLParser; namespace XMLProgramm { - class CSVWriter - { - FileStream handle = null; - int handleOffset; - - void writeToFile(string content) - { - content += Environment.NewLine; - byte[] bytes = Encoding.UTF8.GetBytes(content); - handle.Write(bytes,0,bytes.Length); - handle.Flush(); - - handleOffset += bytes.Length; - } - public CSVWriter() - { - handle = File.Create("./data.csv"); - handleOffset = 0; - string WriteHeader = "Inspektionsdatum#Anzahl Straßenablaufe#Länge über 5m#SonstigeLeitungen#Sonstige Länge über 5m#Hauptkanallänge"; - writeToFile(WriteHeader); - } - - public void Save() - { - handle.Close(); - } - - internal void WriteDay(Dictionary calculated, List inspektionenAmTag) - { - int anzahlStraßenablaufe = (int)calculated[ECalculatedResult.STRASSENABLAUFANZAHL]; - int sonstigeLeitungen = (int)calculated[ECalculatedResult.SONSTIGEANZAHL]; - decimal Strassenablaufzulage = calculated[ECalculatedResult.STRASSENABLAUFLAENGEZULAGEMETER]; - decimal Sonstigezulage = calculated[ECalculatedResult.SONSTIGELAENGEZULAGEMETER]; - decimal HauptkanalLänge = calculated[ECalculatedResult.HAUPTKANALLAENGE]; - - KanalObjekt last = inspektionenAmTag.Last(); - - string entry = last.Inspektionsdaten.OptischeInspektion.Inspektionsdatum + "#"+anzahlStraßenablaufe+"#"+Strassenablaufzulage+"#"+sonstigeLeitungen+"#"+Sonstigezulage+"#"+HauptkanalLänge; - writeToFile(entry); - } - } class Program { static void Main(string[] args) { CSVWriter csvWriter = new CSVWriter(); List objekte = new List(); + + StrassenUmsatz(csvWriter,objekte); + //TagesUmsatz(csvWriter,objekte); + } + + private static void StrassenUmsatz(CSVWriter csvWriter, List objekte) + { + // KS_Oldenburg_Lönsweg.xml + XMLParse ser = new XMLParse("2021-07-29_KR_H_L_Oldenburg_Eichenstraße.xml"); + objekte.AddRange(ser.KanalObjekte); + Dictionary d = Calculate.CalculateDay(objekte); + + } + + static void TagesUmsatz(CSVWriter csvWriter, List objekte) + { DirectoryInfo info = new DirectoryInfo("./"); FileInfo[] daten = info.GetFiles("*.xml"); foreach(FileInfo aktuell in daten) { @@ -77,7 +51,6 @@ namespace XMLProgramm decimal Durchschnitt = gesamt / anzahlTage; int prognosedays = 63; Console.WriteLine(string.Format("Tage : {0} \nGesamt umsatz: {1}\nDurchschnitt : {2}\nPrognose für {3} tage {4}",anzahlTage,gesamt,Durchschnitt,prognosedays,prognosedays*Durchschnitt)); - } } }