Browse code

mlt: Erhebliche Erweiterungen des Art. 15-Exports wg. komplett fehlender Substruktur.

Matthias Lüttgert authored on 27/09/2016 09:44:06
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,44 @@
0
+# -*- coding: utf-8 -*-
1
+class Art15_XML_Exporter
2
+  attr :glade
3
+  attr :dbh
4
+
5
+  # ACHTUNG: Die Datenbankverbindung ist anzupassen.
6
+  def get_connection
7
+    begin
8
+      @dbh = DBI.connect("DBI:Pg:datenbankname:server.domain.toplevel", "user", 'parole')
9
+      row = @dbh.select_one("SELECT VERSION()")
10
+      puts "Server version: " + row[0]
11
+    rescue DBI::DatabaseError => e
12
+      puts "An error occurred"
13
+      puts "Error code: #{e.err}"
14
+      puts "Error message: #{e.errstr}"
15
+    ensure
16
+      ## disconnect from server
17
+      #dbh.disconnect if @dbh
18
+    end
19
+    return @dbh
20
+  end
21
+end
22
+
23
+class Art17_XML_Exporter
24
+  attr :glade
25
+  attr :dbh
26
+
27
+  # ACHTUNG: Die Datenbankverbindung ist anzupassen.
28
+  def get_connection
29
+    begin
30
+      @dbh = DBI.connect("DBI:Pg:datenbankname:server.domain.toplevel", "user", 'parole')
31
+      row = @dbh.select_one("SELECT VERSION()")
32
+      puts "Server version: " + row[0]
33
+    rescue DBI::DatabaseError => e
34
+      puts "An error occurred"
35
+      puts "Error code: #{e.err}"
36
+      puts "Error message: #{e.errstr}"
37
+    ensure
38
+      ## disconnect from server
39
+      #dbh.disconnect if @dbh
40
+    end
41
+    return @dbh
42
+  end
43
+end
... ...
@@ -29,8 +29,11 @@
29 29
 #   already documented and know problem bears pl_kan_id (TP) and
30 30
 #   dp_surface_id and plant_id (DP)
31 31
 #
32
+# Rel-1-3-5
33
+#   2016-08-02 mlt: XML-Art.15-Export erweitert um Art. 5.4-Angaben zu Anlagenzahl, -kapazität
34
+#   und -frachten N in/out, P in/out sowie einem XML-Kommentar zur Differenzierung von KKA und KA
32 35
 # Rel-1-3-4
33
-#   2016-06-29 xx:xx mlt: XML-Art.15-Export mit Prüfung der Tabelle agglomerations_plants versehen
36
+#   2016-06-29 mlt: XML-Art.15-Export mit Prüfung der Tabelle agglomerations_plants versehen
34 37
 # Rel-1-3-3
35 38
 #   2016-06-28 17:58 mlt: XML-Art.15-Export mit Dummy-Werten versehen
36 39
 # Rel-1-3-1
... ...
@@ -70,7 +73,7 @@ begin
70 70
   include RbConfig
71 71
 
72 72
   APPNAME = "e-Kommu XML Exporter"
73
-  APPVERSION = "1.3.4"
73
+  APPVERSION = "1.3.5"
74 74
   ABOUT = <<EOS
75 75
 
76 76
 (c) ENDA, 2016, 2014, 2013, 2012, 2011, 2010
... ...
@@ -5,7 +5,9 @@
5 5
 # 
6 6
 # by mlt
7 7
 #
8
-# Rel-1-3-4
8
+# Rel-1-3-5
9
+# 2016-08-02, mlt: Erweiterung ReceivingAreasSA54 (Art.5.4-Daten)
10
+# 2016-07-26, mlt: Erweiterung Receiving Areas (ERA)
9 11
 # 2016-06-29, mlt: def check_some_data neu: Vor dem Export prüfen, ob die Tabelle agglomerations_plants
10 12
 #                  Einträge besitzt, bei denen from_date oder to_date = null ist
11 13
 # 2016-06-28, mlt: Dummy-Werte für aggC1, aggC2 und aggPercWithoutTreatment, wenn state=2; Konform mit der COM-
... ...
@@ -193,7 +195,7 @@ class Art15_XML_Exporter
193 193
     @dbh = get_connection
194 194
     report << create_areas_main
195 195
     report << create_areas_parameter
196
-    #report << create_areas_sa54
196
+    report << create_areas_sa54
197 197
     report << create_agglomerations
198 198
     #report << create_big_city_dischargers
199 199
     report << create_plants
... ...
@@ -253,7 +255,6 @@ class Art15_XML_Exporter
253 253
     return reporter
254 254
   end
255 255
 
256
-
257 256
   def create_period
258 257
     period = XML::Node.new('ReportPeriod')
259 258
     period << state_key = XML::Node.new('dd817:rptMStateKey')
... ...
@@ -268,7 +269,6 @@ class Art15_XML_Exporter
268 268
     return period
269 269
   end
270 270
 
271
-
272 271
   def create_contacts
273 272
     contacts = XML::Node.new('Contacts')
274 273
     contacts << contact = XML::Node.new('Contact')
... ...
@@ -296,91 +296,241 @@ class Art15_XML_Exporter
296 296
     return contacts
297 297
   end
298 298
 
299
-  def calculate_overall_data
300
-    area_data = {}
301
-    stmt = "select count(*) as anzahl from plants
302
-      where date_from = #{DATE_FROM} and state = 0 and federal_state_id < 17
303
-        and pl_state_active = 1
304
-        and pl_to_be_reported is distinct from 0"
305
-    num_plants_1 = @dbh.select_one(stmt)['anzahl']
306
-    pulse
307
-
308
-    stmt = "select sum(kka_number) as kka_number, sum(kka_cap) as kka_cap,
309
-              sum(kka_load_n_incoming) as kka_load_n_incoming, sum(kka_load_n) as kka_load_n,
310
-              sum(kka_load_p_incoming) as kka_load_p_incoming, sum(kka_load_p) as kka_load_p,
311
-              sum(s_prod) as s_prod
312
-      from federal_state_info
313
-      where date_from = #{DATE_FROM} and state = 0"
314
-    federal_row = @dbh.select_one(stmt)
315
-    num_plants_2 = federal_row.by_field('kka_number')
316
-    pulse
299
+  # Simple Listen-id-zu-Schlüssel-Auflösung (1=C, 2=E, 3=M)
300
+  def get_cem_representation_from_id(method_id)
301
+    return 'c' if method_id == 1
302
+    return 'e' if method_id == 2
303
+    return 'm' if method_id == 3
304
+    raise Exception.new, "ERROR: get_cem_representation_from_number case: <#{method_id}>"
305
+  end
317 306
 
318
-    area_data[:plants_number] = num_plants_1 + num_plants_2
307
+  # Hier wird entschieden, ob die Anlage als C, E oder M eingestuft wird.
308
+  # Da wir die Anlagenzahl übermitteln müssen, müssen wir uns entscheiden, wo wir die
309
+  # Anlage (und ihre Auslegungsgröße ODC) hinzurechnen.
310
+  # Wenn wir nichts haben, ist es geschätzt. So haben wir auch in der Vergangenheit die
311
+  # Kleinkläranlagen behandelt, bei denen das nicht angegeben wird.
312
+  def detect_cem_state(row)
313
+    if row['dp_load_n_incoming_method_id']
314
+      return get_cem_representation_from_id(row['dp_load_n_incoming_method_id'])
315
+    elsif row['dp_load_n_method_id']
316
+      return get_cem_representation_from_id(row['dp_load_n_method_id'])
317
+    elsif row['dp_load_p_incoming_method_id']
318
+      return get_cem_representation_from_id(row['dp_load_p_incoming_method_id'])
319
+    elsif row['dp_load_p_method_id']
320
+      return get_cem_representation_from_id(row['dp_load_p_method_id'])
321
+    else
322
+      return 'e'
323
+    end
324
+  end
319 325
 
320
-    stmt = "select sum(pl_odc) from plants
321
-      where date_from = #{DATE_FROM} and state = 0 and federal_state_id < 17
322
-        and pl_state_active = 1 and pl_to_be_reported is distinct from 0"
323
-    plants_odc = @dbh.select_one(stmt)[0]
326
+  def calculate_overall_data
327
+    pulse
328
+    area_data = {}
329
+    stmt = "SELECT p.id, p.pl_odc,
330
+      dp_load_n_incoming, dp_load_n_incoming_method_id, dp_load_n, dp_load_n_method_id,
331
+      dp_load_p_incoming, dp_load_p_incoming_method_id, dp_load_p, dp_load_p_method_id
332
+      FROM plants p
333
+      WHERE state = 0
334
+        AND date_from = #{DATE_FROM}
335
+        AND federal_state_id < 17
336
+        AND pl_state_active = 1
337
+        AND pl_to_be_reported IS DISTINCT FROM 0"
338
+    sth = dbh.execute(stmt)
324 339
     pulse
340
+    counter = 0
325 341
 
326
-    area_data[:overall_odc] = plants_odc + federal_row.by_field('kka_cap')
342
+    # Initialisierung des Werte-Hashs area_data mit 0:
343
+    cemmis = ['c', 'e', 'm']
344
+    cemmis.each do |cemmi|
345
+      area_data['plants_number_' + cemmi] = 0
346
+      area_data['plants_number_50to1999_' + cemmi] = 0
347
+      area_data['plants_number_2000up_' + cemmi] = 0
348
+      area_data['odc_' + cemmi] = 0
349
+      area_data['n_in_' + cemmi] = 0.0
350
+      area_data['n_out_' + cemmi] = 0.0
351
+      area_data['p_in_' + cemmi] = 0.0
352
+      area_data['p_out_' + cemmi] = 0.0
353
+      area_data['odc_50to1999_' + cemmi] = 0
354
+      area_data['n_in_50to1999_' + cemmi] = 0.0
355
+      area_data['n_out_50to1999_' + cemmi] = 0.0
356
+      area_data['p_in_50to1999_' + cemmi] = 0.0
357
+      area_data['p_out_50to1999_' + cemmi] = 0.0
358
+      area_data['odc_2000up_' + cemmi] = 0
359
+      area_data['n_in_2000up_' + cemmi] = 0.0
360
+      area_data['n_out_2000up_' + cemmi] = 0.0
361
+      area_data['p_in_2000up_' + cemmi] = 0.0
362
+      area_data['p_out_2000up_' + cemmi] = 0.0
363
+      area_data['comment_' + cemmi] = ''
364
+    end
327 365
 
328
-    # Gemessene und Berechnete kommen ausschließlich aus plants
329
-    # Geschätzte sind Summe aus plants und federal_state_info
330
-    stmt = "select sum(p.dp_load_n_incoming) from plants p
331
-      inner join l_meth
332
-        on p.dp_load_n_incoming_method_id = l_meth.id
333
-      where p.date_from = #{DATE_FROM} and p.state = 0 and p.federal_state_id < 17
334
-        and p.pl_state_active = 1  and p.pl_to_be_reported is distinct from 0
335
-        and l_meth.key = ?"
336
-    area_data[:n_in_c] = sprintf("%.4e", @dbh.select_one(stmt, 'C')[0] / 1000.0).to_f.to_s rescue area_data[:n_in_c] = "0.0"
337
-    area_data[:n_in_m] = sprintf("%.4e", @dbh.select_one(stmt, 'M')[0] / 1000.0).to_f.to_s rescue area_data[:n_in_m] = "0.0"
338
-    area_data[:n_in_e] = sprintf("%.4e", (@dbh.select_one(stmt, 'E')[0] + federal_row[2]) / 1000.0).to_f.to_s rescue area_data[:n_in_e] = "0.0"
366
+    # Alle Kläranlagen Zu- und Ablauffrachten N und P bei KA >= 2000 EW zusammenzählen (ODC auch):
367
+    sth.fetch do |row|
368
+      counter += 1
369
+      cem_state = detect_cem_state(row)
370
+      area_data['plants_number_' + cem_state] += 1
371
+      area_data['plants_number_2000up_' + cem_state] += 1
372
+      area_data['odc_' + cem_state] += row['pl_odc']
373
+      area_data['n_in_' + cem_state] += row['dp_load_n_incoming'] if row['dp_load_n_incoming']
374
+      area_data['n_out_' + cem_state] += row['dp_load_n'] if row['dp_load_n']
375
+      area_data['p_in_' + cem_state] += row['dp_load_p_incoming'] if row['dp_load_p_incoming']
376
+      area_data['p_out_' + cem_state] += row['dp_load_p'] if row['dp_load_p']
377
+      area_data['odc_2000up_' + cem_state] += row['pl_odc']
378
+      area_data['n_in_2000up_' + cem_state] += row['dp_load_n_incoming'] if row['dp_load_n_incoming']
379
+      area_data['n_out_2000up_' + cem_state] += row['dp_load_n'] if row['dp_load_n']
380
+      area_data['p_in_2000up_' + cem_state] += row['dp_load_p_incoming'] if row['dp_load_p_incoming']
381
+      area_data['p_out_2000up_' + cem_state] += row['dp_load_p'] if row['dp_load_p']
382
+      if counter % 100 == 0
383
+        pulse
384
+        print "."
385
+        STDOUT.flush
386
+      end
387
+    end
388
+    sth.finish
389
+
390
+    # Bei den Kleinkläranlagen wissen wir nicht, ob es C, E oder M ist. Bisher wurde es
391
+    # immer der Gruppe E (estimated) zuschlagen, so machen wir es auch weiterhin:
392
+    stmt = "SELECT f.id, f.kka_number, f.kka_cap,
393
+      f.kka_load_n_incoming, f.kka_load_n,
394
+      f.kka_load_p_incoming, f.kka_load_p
395
+      FROM federal_state_info f
396
+      WHERE state = 0
397
+        AND date_from = #{DATE_FROM}
398
+        AND federal_state_id < 17"
399
+    sth = dbh.execute(stmt)
400
+    sth.fetch do |row|
401
+      cem_nil_state = 'e'
402
+      area_data['plants_number_' + cem_nil_state] += row['kka_number']
403
+      area_data['plants_number_50to1999_' + cem_nil_state] += row['kka_number']
404
+      area_data['odc_' + cem_nil_state] += row['kka_cap']
405
+      area_data['n_in_' + cem_nil_state] += row['kka_load_n_incoming']
406
+      area_data['n_out_' + cem_nil_state] += row['kka_load_n']
407
+      area_data['p_in_' + cem_nil_state] += row['kka_load_p_incoming']
408
+      area_data['p_out_' + cem_nil_state] += row['kka_load_p']
409
+      area_data['odc_50to1999_' + cem_nil_state] += row['kka_cap']
410
+      area_data['n_in_50to1999_' + cem_nil_state] += row['kka_load_n_incoming']
411
+      area_data['n_out_50to1999_' + cem_nil_state] += row['kka_load_n']
412
+      area_data['p_in_50to1999_' + cem_nil_state] += row['kka_load_p_incoming']
413
+      area_data['p_out_50to1999_' + cem_nil_state] += row['kka_load_p']
414
+    end
415
+    sth.finish
339 416
     pulse
340 417
 
341
-    stmt = "select sum(p.dp_load_n) from plants p
342
-      inner join l_meth
343
-        on p.dp_load_n_method_id = l_meth.id
344
-      where p.date_from = #{DATE_FROM} and p.state = 0 and p.federal_state_id < 17
345
-        and p.pl_state_active = 1  and p.pl_to_be_reported is distinct from 0
346
-        and l_meth.key = ?"
347
-    area_data[:n_out_c] = sprintf("%.4e", @dbh.select_one(stmt, 'C')[0] / 1000.0).to_f.to_s rescue area_data[:n_out_c] = "0.0"
348
-    area_data[:n_out_m] = sprintf("%.4e", @dbh.select_one(stmt, 'M')[0] / 1000.0).to_f.to_s rescue area_data[:n_out_m] = "0.0"
349
-    area_data[:n_out_e] = sprintf("%.4e", (@dbh.select_one(stmt, 'E')[0] + federal_row[3]) / 1000.0).to_f.to_s rescue area_data[:n_out_e] = "0.0"
350
-
351
-    stmt = "select sum(p.dp_load_p_incoming) from plants p
352
-      inner join l_meth
353
-        on p.dp_load_p_incoming_method_id = l_meth.id
354
-      where p.date_from = #{DATE_FROM} and p.state = 0 and p.federal_state_id < 17
355
-        and p.pl_state_active = 1  and p.pl_to_be_reported is distinct from 0
356
-        and l_meth.key = ?"
357
-    area_data[:p_in_c] = sprintf("%.4e", @dbh.select_one(stmt, 'C')[0] / 1000.0).to_f.to_s rescue area_data[:p_in_c] = "0.0"
358
-    area_data[:p_in_m] = sprintf("%.4e", @dbh.select_one(stmt, 'M')[0] / 1000.0).to_f.to_s rescue area_data[:p_in_m] = "0.0"
359
-    area_data[:p_in_e] = sprintf("%.4e", (@dbh.select_one(stmt, 'E')[0] + federal_row[4]) / 1000.0).to_f.to_s rescue area_data[:p_in_e] = "0.0"
360
-
361
-    stmt = "select sum(p.dp_load_p) from plants p
362
-      inner join l_meth
363
-        on p.dp_load_p_method_id = l_meth.id
364
-      where p.date_from = #{DATE_FROM} and p.state = 0 and p.federal_state_id < 17
365
-        and p.pl_state_active = 1  and p.pl_to_be_reported is distinct from 0
366
-        and l_meth.key = ?"
367
-    area_data[:p_out_c] = sprintf("%.4e", @dbh.select_one(stmt, 'C')[0] / 1000.0).to_f.to_s rescue area_data[:p_out_c] = "0.0"
368
-    area_data[:p_out_m] = sprintf("%.4e", @dbh.select_one(stmt, 'M')[0] / 1000.0).to_f.to_s rescue area_data[:p_out_m] = "0.0"
369
-    area_data[:p_out_e] = sprintf("%.4e", (@dbh.select_one(stmt, 'E')[0] + federal_row[5]) / 1000.0).to_f.to_s rescue area_data[:p_out_e] = "0.0"
418
+    cemmis.each do |cemmi|
419
+      # Einheit Fracht beim COM ist t, bei uns kg, daher / 1000
420
+      # außerdem Nachkommastellenrauschen entfernen:
421
+      area_data['n_in_' + cemmi] = sprintf("%.4e", area_data['n_in_' + cemmi] / 1000.0).to_f.to_s
422
+      area_data['n_out_' + cemmi] = sprintf("%.4e", area_data['n_out_' + cemmi] / 1000.0).to_f.to_s
423
+      area_data['p_in_' + cemmi] = sprintf("%.4e", area_data['p_in_' + cemmi] / 1000.0).to_f.to_s
424
+      area_data['p_out_' + cemmi] = sprintf("%.4e", area_data['p_out_' + cemmi] / 1000.0).to_f.to_s
425
+      area_data['n_in_50to1999_' + cemmi] = sprintf("%.4e", area_data['n_in_50to1999_' + cemmi] / 1000.0).to_f.to_s
426
+      area_data['n_out_50to1999_' + cemmi] = sprintf("%.4e", area_data['n_out_50to1999_' + cemmi] / 1000.0).to_f.to_s
427
+      area_data['p_in_50to1999_' + cemmi] = sprintf("%.4e", area_data['p_in_50to1999_' + cemmi] / 1000.0).to_f.to_s
428
+      area_data['p_out_50to1999_' + cemmi] = sprintf("%.4e", area_data['p_out_50to1999_' + cemmi] / 1000.0).to_f.to_s
429
+      area_data['n_in_2000up_' + cemmi] = sprintf("%.4e", area_data['n_in_2000up_' + cemmi] / 1000.0).to_f.to_s
430
+      area_data['n_out_2000up_' + cemmi] = sprintf("%.4e", area_data['n_out_2000up_' + cemmi] / 1000.0).to_f.to_s
431
+      area_data['p_in_2000up_' + cemmi] = sprintf("%.4e", area_data['p_in_2000up_' + cemmi] / 1000.0).to_f.to_s
432
+      area_data['p_out_2000up_' + cemmi] = sprintf("%.4e", area_data['p_out_2000up_' + cemmi] / 1000.0).to_f.to_s
433
+    end
370 434
 
371 435
     return area_data
372 436
   end
373 437
 
374
-
438
+  # TODO: (ERA)
375 439
   def create_areas_sa54
440
+    @bar.text="areas 5.4..."
441
+    pulse
442
+    # Hauptknoten anlegen:
376 443
     sa54 = XML::Node.new('ReceivingAreasSA54')
377
-    sa54 << el = XML::Node.new('ReceivingAreaSA54')
378
-
379
-    el << repcode = XML::Node.new('dd845:repCode')
380
-    el << code = XML::Node.new('dd845:rcaCode')
381
-    
382
-    repcode << REP_CODE
383
-    code << "DE"
444
+    # Drei Areas für C/E/M anlegen:
445
+    sa54 << el_calculated = XML::Node.new('ReceivingAreaSA54')   # 1 x calculated-Summen
446
+    sa54 << el_estimated = XML::Node.new('ReceivingAreaSA54')   # 1 x estimated-Summen
447
+    sa54 << el_measured = XML::Node.new('ReceivingAreaSA54')   # 1 x measured-Summen
448
+
449
+    # Standardwerte und jeweils C/E/M-Method als Element anlegen:
450
+    el_calculated << repcode_c = XML::Node.new('dd845:repCode')
451
+    el_calculated << code_c = XML::Node.new('dd845:rcaCode')
452
+    el_calculated << method_c = XML::Node.new('dd845:rcaMethod54')
453
+    el_estimated << repcode_e = XML::Node.new('dd845:repCode')
454
+    el_estimated << code_e = XML::Node.new('dd845:rcaCode')
455
+    el_estimated << method_e = XML::Node.new('dd845:rcaMethod54')
456
+    el_measured << repcode_m = XML::Node.new('dd845:repCode')
457
+    el_measured << code_m = XML::Node.new('dd845:rcaCode')
458
+    el_measured << method_m = XML::Node.new('dd845:rcaMethod54')
459
+
460
+    # Standard-Elementinhalte schreiben
461
+    repcode_c << REP_CODE
462
+    code_c << "DE"
463
+    method_c << "C"
464
+    repcode_e << REP_CODE
465
+    code_e << "DE"
466
+    method_e << "E"
467
+    repcode_m << REP_CODE
468
+    code_m << "DE"
469
+    method_m << "M"
470
+    # Kopfinfo ist angelegt und gefüllt
471
+
472
+    # Rumpfelemente anlegen:
473
+    el_calculated << plants_number_c = XML::Node.new('dd845:rcaPlants54')
474
+    el_calculated << overall_design_capacity_c = XML::Node.new('dd845:rcaPlantsCapacity54')
475
+    el_calculated << n_in_c = XML::Node.new('dd845:rcaNIncoming54')
476
+    el_calculated << n_out_c = XML::Node.new('dd845:rcaNDischarged54')
477
+    el_calculated << p_in_c = XML::Node.new('dd845:rcaPIncoming54')
478
+    el_calculated << p_out_c = XML::Node.new('dd845:rcaPDischarged54')
479
+    el_calculated << comment_c = XML::Node.new_comment()
480
+
481
+    el_estimated << plants_number_e = XML::Node.new('dd845:rcaPlants54')
482
+    el_estimated << overall_design_capacity_e = XML::Node.new('dd845:rcaPlantsCapacity54')
483
+    el_estimated << n_in_e = XML::Node.new('dd845:rcaNIncoming54')
484
+    el_estimated << n_out_e = XML::Node.new('dd845:rcaNDischarged54')
485
+    el_estimated << p_in_e = XML::Node.new('dd845:rcaPIncoming54')
486
+    el_estimated << p_out_e = XML::Node.new('dd845:rcaPDischarged54')
487
+    el_estimated << comment_e = XML::Node.new_comment()
488
+
489
+    el_measured << plants_number_m = XML::Node.new('dd845:rcaPlants54')
490
+    el_measured << overall_design_capacity_m = XML::Node.new('dd845:rcaPlantsCapacity54')
491
+    el_measured << n_in_m = XML::Node.new('dd845:rcaNIncoming54')
492
+    el_measured << n_out_m = XML::Node.new('dd845:rcaNDischarged54')
493
+    el_measured << p_in_m = XML::Node.new('dd845:rcaPIncoming54')
494
+    el_measured << p_out_m = XML::Node.new('dd845:rcaPDischarged54')
495
+    el_measured << comment_m = XML::Node.new_comment()
496
+    # Rumpfelelemte angelegt.
497
+
498
+    # Daten ermitteln:
499
+    area_data = calculate_overall_data
500
+
501
+    plants_number_c << area_data['plants_number_c']
502
+    plants_number_e << area_data['plants_number_e']
503
+    plants_number_m << area_data['plants_number_m']
504
+    overall_design_capacity_c << area_data['odc_c']
505
+    overall_design_capacity_e << area_data['odc_e']
506
+    overall_design_capacity_m << area_data['odc_m']
507
+    n_in_c << area_data['n_in_c']
508
+    n_in_e << area_data['n_in_e']
509
+    n_in_m << area_data['n_in_m']
510
+    n_out_c << area_data['n_out_c']
511
+    n_out_e << area_data['n_out_e']
512
+    n_out_m << area_data['n_out_m']
513
+    p_in_c << area_data['p_in_c']
514
+    p_in_e << area_data['p_in_e']
515
+    p_in_m << area_data['p_in_m']
516
+    p_out_c << area_data['p_out_c']
517
+    p_out_e << area_data['p_out_e']
518
+    p_out_m << area_data['p_out_m']
519
+    comment_c << " Only Plants >= 2000 p.e. "
520
+    comment_e << "\nPlant number 50 to 1999 p.e.: " + area_data['plants_number_50to1999_e'].to_s +
521
+        ";\nCap. 50 to 1999 p.e.: " + area_data['odc_50to1999_e'].to_s +
522
+        ";\nLoads Plants 50 to 1999 p.e.:\n  N in = " + area_data['n_in_50to1999_e'].to_s +
523
+        ",\n  N out = " + area_data['n_out_50to1999_e'].to_s +
524
+        ",\n  P in = " + area_data['p_in_50to1999_e'].to_s +
525
+        ",\n  P out = " + area_data['p_out_50to1999_e'].to_s +
526
+        ";\nPlant number >= 2000 p.e.: " + area_data['plants_number_2000up_e'].to_s +
527
+        ";\nCap. >= 2000 p.e.: " + area_data['odc_2000up_e'].to_s +
528
+        ";\nLoads Plants >= 2000 p.e.:\n  N in = " + area_data['n_in_2000up_e'].to_s +
529
+        ",\n  N out = " + area_data['n_out_2000up_e'].to_s +
530
+        ",\n  P in = " + area_data['p_in_2000up_e'].to_s +
531
+        ",\n  P out = " + area_data['p_out_2000up_e'].to_s
532
+    comment_m << " Only Plants >= 2000 p.e. "
533
+    pulse
384 534
 
385 535
     return sa54
386 536
   end
... ...
@@ -404,7 +554,7 @@ class Art15_XML_Exporter
404 404
     par_an << parcode = XML::Node.new('dd844:rcaParameter')
405 405
     par_an << date_designation = XML::Node.new('dd844:rcaDateDesignation')
406 406
     repcode << REP_CODE
407
-    # TODO: Evtl. hier Ziffernkombi statt DE
407
+    # Evtl. hier Ziffernkombi statt DE
408 408
     code << "DE"
409 409
     parcode << "aP"
410 410
     date_designation << "1999-01-01"
... ...
@@ -440,7 +590,7 @@ class Art15_XML_Exporter
440 440
     z_type << 'UWWCMSA'
441 441
     sp_z_typ << 'A5854'
442 442
 
443
-    # todo: mit was füllen wir die Vier?
443
+    # Womit füllen wir die vier?
444 444
     parameter_n << 'true'
445 445
     parameter_p << 'true'
446 446
     parameter_m << 'true'
... ...
@@ -454,51 +604,11 @@ class Art15_XML_Exporter
454 454
     area << date_art54 = XML::Node.new('dd843:rcaDateArt54')
455 455
     date_art54 << "1999-01-01"
456 456
 
457
-    #area << plants_number = XML::Node.new('rcaPlants')
458
-    #area << overall_design_capacity = XML::Node.new('rcaPlantsCapacity')
459
-    #area << n_in_m = XML::Node.new('rcaNIncomingMeasured')
460
-    #area << n_in_c = XML::Node.new('rcaNIncomingCalculated')
461
-    #area << n_in_e = XML::Node.new('rcaNIncomingEstimated')
462
-    #area << p_in_m = XML::Node.new('rcaPIncomingMeasured')
463
-    #area << p_in_c = XML::Node.new('rcaPIncomingCalculated')
464
-    #area << p_in_e = XML::Node.new('rcaPIncomingEstimated')
465
-    #area << n_out_m = XML::Node.new('rcaNDischargedMeasured')
466
-    #area << n_out_c = XML::Node.new('rcaNDischargedCalculated')
467
-    #area << n_out_e = XML::Node.new('rcaNDischargedEstimated')
468
-    #area << p_out_m = XML::Node.new('rcaPDischargedMeasured')
469
-    #area << p_out_c = XML::Node.new('rcaPDischargedCalculated')
470
-    #area << p_out_e = XML::Node.new('rcaPDischargedEstimated')
471
-
472
-    #area_data = calculate_overall_data
473
-
474
-    #plants_number << area_data[:plants_number]
475
-    #overall_design_capacity << area_data[:overall_odc]
476
-    #n_in_m << area_data[:n_in_m]
477
-    #n_in_c << area_data[:n_in_c]
478
-    #n_in_e << area_data[:n_in_e]
479
-    #p_in_m << area_data[:p_in_m]
480
-    #p_in_c << area_data[:p_in_c]
481
-    #p_in_e << area_data[:p_in_e]
482
-    #n_out_m << area_data[:n_out_m]
483
-    #n_out_c << area_data[:n_out_c]
484
-    #n_out_e << area_data[:n_out_e]
485
-    #p_out_m << area_data[:p_out_m]
486
-    #p_out_c << area_data[:p_out_c]
487
-    #p_out_e << area_data[:p_out_e]
488
-
489
-    # rcaPlantsCapacity = plant.pl_odc + federal_state_info.kka_cap
490
-    # N und P load incoming und outgoing aus plants UND federal_state_info (dort: estimated)
491
-    
492
-    #rcaArt54Applied = 'true' # Boolean ist 'false' oder 'true'
493
-    #area << art54_applied = XML::Node.new('rcaArt54Applied')
494
-    #art54_applied << rcaArt54Applied
495
-
496 457
     pulse
497 458
 
498 459
     return areas
499 460
   end
500 461
 
501
-
502 462
   def fill_agglo(agglo, row)
503 463
     agglo << state = XML::Node.new('dd820:aggState')
504 464
     active = true
... ...
@@ -646,8 +756,6 @@ class Art15_XML_Exporter
646 646
     end
647 647
   end
648 648
 
649
-
650
-
651 649
   def create_agglomerations
652 650
     @bar.text="agglomerations..."
653 651
     agglos = XML::Node.new('Agglomerations')
... ...
@@ -697,7 +805,6 @@ class Art15_XML_Exporter
697 697
     return agglos
698 698
   end
699 699
 
700
-
701 700
   def create_big_city_dischargers
702 701
     big_disses = XML::Node.new('BigCityDischargers')
703 702
     stmt = "select distinct lc.key, lc.description
... ...
@@ -815,7 +922,7 @@ class Art15_XML_Exporter
815 815
     # TODO: Leider hat die Anwendung offenbar einen Bug, der date_from und date_to der Tabelle
816 816
     # agglomerations_plants mit null füllt anstatt ordentich mit 20140101 - 20141231 (z. B.)
817 817
     # Dann findet dieses Statement keine Zuordnungen!
818
-    # Lösungen: 1. das bescherte date_from aus der where-Clause raus. Wozu überhaupt!
818
+    # Lösungen: 1. das bescheuerte date_from aus der where-Clause raus. Wozu überhaupt!
819 819
     # Die ID ist genau mit einem Satz verbunden und der kommt aus den Agglomerations, hat
820 820
     # also das korrekte from_date.
821 821
     stmt = "select agglomeration_id from agglomerations_plants ap
... ...
@@ -1130,7 +1237,7 @@ class Art15_XML_Exporter
1130 1130
     end
1131 1131
     
1132 1132
     poke(dp_node, 'A54', 'dd823:dcpTypeOfReceivingArea')
1133
-    # TODO: Evtl. hier Ziffernkombi statt DE
1133
+    # Evtl. hier Ziffernkombi statt DE
1134 1134
     poke(dp_node, 'DE', 'dd823:rcaCode') # Das ist die ID, die oben für die Receiving Area Deutschland hartcodiert vergeben wurde
1135 1135
     fill_node_10(dp_node, dp_row, 'dp_surface', 'dd823:dcpSurfaceWaters')
1136 1136
     fill_node(dp_node, dp_row, 'water_body_eu_key', 'dd823:dcpWaterbodyID')