Merge branch 'main' of git.avatic.de:avatic/lcc_tool
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
This commit is contained in:
parent
562764561e
commit
9604d342d7
3 changed files with 17 additions and 7 deletions
|
|
@ -210,7 +210,7 @@ public class CalculationExecutionService {
|
|||
destinationCalculationJob.setAnnualCustomCost(customCost.getAnnualCost());
|
||||
|
||||
destinationCalculationJob.setAnnualTransportationCost(sections.stream().map(SectionInfo::result).map(CalculationJobRouteSection::getAnnualCost).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
destinationCalculationJob.setTransportWeightExceeded(sections.stream().map(SectionInfo::result).anyMatch(CalculationJobRouteSection::isWeightPrice));
|
||||
destinationCalculationJob.setTransportWeightExceeded(sections.stream().map(SectionInfo::result).filter(CalculationJobRouteSection::getMainRun).anyMatch(CalculationJobRouteSection::isWeightPrice));
|
||||
destinationCalculationJob.setLayerCount(sections.getFirst().containerResult().getLayer());
|
||||
destinationCalculationJob.setLayerStructure(null); //TODO generate layer structure
|
||||
destinationCalculationJob.setHuCount(sections.getFirst().containerResult().getHuUnitCount());
|
||||
|
|
|
|||
|
|
@ -26,15 +26,18 @@ def normalize_part_number(part_number):
|
|||
# Zu String konvertieren (ohne Float-Konvertierung)
|
||||
part_str = str(part_number).strip()
|
||||
|
||||
if len(part_str) > 12:
|
||||
raise Exception("Part number longer than 12 digits. "+part_str)
|
||||
|
||||
# Bei rein numerischen Werten: mit führenden Nullen auffüllen
|
||||
if part_str.isdigit():
|
||||
return part_str.zfill(12)
|
||||
else:
|
||||
# Bei alphanumerischen Part Numbers: auf 12 Zeichen begrenzen/auffüllen
|
||||
if len(part_str) > 12:
|
||||
return part_str[:12] # Kürzen auf 12 Zeichen
|
||||
raise Exception("Part number longer than 12 digits. "+part_str)
|
||||
else:
|
||||
return part_str.ljust(12, '0') # Mit Nullen am Ende auffüllen
|
||||
return part_str.rjust(12, '0') # Mit Nullen am Anfang auffüllen
|
||||
|
||||
def format_hs_code(hs_code):
|
||||
"""Formatiert HS Code als 8-stelligen String"""
|
||||
|
|
@ -95,6 +98,8 @@ def excel_to_sql(excel_file_path, output_sql_path=None):
|
|||
sql_statements.append("-- Material Daten Import")
|
||||
sql_statements.append("-- Generiert aus Excel-Datei\n")
|
||||
|
||||
existing_materials = set()
|
||||
|
||||
for index, row in df.iterrows():
|
||||
try:
|
||||
# Daten extrahieren und bereinigen
|
||||
|
|
@ -103,6 +108,7 @@ def excel_to_sql(excel_file_path, output_sql_path=None):
|
|||
name = clean_text(row['description'])
|
||||
hs_code = format_hs_code(row['hs_code'])
|
||||
|
||||
|
||||
# Überspringe Zeilen ohne Part Number oder Description
|
||||
if not part_number or not name or part_number == 'nan':
|
||||
print(f"Überspringe Zeile {index + 2}: Fehlende Daten")
|
||||
|
|
@ -112,7 +118,11 @@ def excel_to_sql(excel_file_path, output_sql_path=None):
|
|||
sql = f"""INSERT INTO material (part_number, normalized_part_number, hs_code, name, is_deprecated)
|
||||
VALUES ('{part_number}', '{normalized_part_number}', {hs_code}, '{name}', FALSE);"""
|
||||
|
||||
if not normalized_part_number in existing_materials:
|
||||
existing_materials.add(normalized_part_number)
|
||||
sql_statements.append(sql)
|
||||
else:
|
||||
print(f"Duplikat gefunden: {normalized_part_number}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Fehler bei Zeile {index + 2}: {e}")
|
||||
|
|
@ -129,7 +139,7 @@ VALUES ('{part_number}', '{normalized_part_number}', {hs_code}, '{name}', FALSE)
|
|||
|
||||
# Auch auf Konsole ausgeben
|
||||
print(f"\n--- SQL-Statements ({len(sql_statements) - 2} Datensätze) ---")
|
||||
print(sql_content)
|
||||
#print(sql_content)
|
||||
|
||||
return sql_content
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Reference in a new issue