Compare commits
No commits in common. "022e4a580b4ea30937f2a230ff5c74bbfbe3c460" and "a633663e9d8d0fe9533ad2b539f51a9293457b60" have entirely different histories.
022e4a580b
...
a633663e9d
@ -11,7 +11,6 @@ import json
|
|||||||
import pika
|
import pika
|
||||||
import xmltodict
|
import xmltodict
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
from django.utils import formats
|
|
||||||
|
|
||||||
from intervention.settings import EGON_RABBITMQ_HOST, EGON_RABBITMQ_USER, EGON_RABBITMQ_PW, EGON_RABBITMQ_PORT
|
from intervention.settings import EGON_RABBITMQ_HOST, EGON_RABBITMQ_USER, EGON_RABBITMQ_PW, EGON_RABBITMQ_PORT
|
||||||
from konova.sub_settings.django_settings import DEFAULT_DATE_FORMAT
|
from konova.sub_settings.django_settings import DEFAULT_DATE_FORMAT
|
||||||
@ -93,9 +92,6 @@ class EgonGmlBuilder:
|
|||||||
)["summed"]
|
)["summed"]
|
||||||
return all_payments
|
return all_payments
|
||||||
|
|
||||||
def _float_to_localized_string(self, value: float):
|
|
||||||
return formats.number_format(value, use_l10n=True, decimal_pos=2)
|
|
||||||
|
|
||||||
def _gen_kompensationsArt(self) -> (str, int):
|
def _gen_kompensationsArt(self) -> (str, int):
|
||||||
comp_type = "Ersatzzahlung"
|
comp_type = "Ersatzzahlung"
|
||||||
comp_type_code = 774898901
|
comp_type_code = 774898901
|
||||||
@ -195,7 +191,7 @@ class EgonGmlBuilder:
|
|||||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1053/{reg_office.atom_id if reg_office else None}",
|
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1053/{reg_office.atom_id if reg_office else None}",
|
||||||
"#text": reg_office.long_name if reg_office else None
|
"#text": reg_office.long_name if reg_office else None
|
||||||
},
|
},
|
||||||
"oneo:ersatzzahlung": self._float_to_localized_string(self._sum_all_payments()),
|
"oneo:ersatzzahlung": self._sum_all_payments(),
|
||||||
"oneo:kompensationsart": {
|
"oneo:kompensationsart": {
|
||||||
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/88140/{comp_type_code}",
|
"@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/88140/{comp_type_code}",
|
||||||
"#text": comp_type
|
"#text": comp_type
|
||||||
|
@ -90,22 +90,18 @@ class BaseMigrater:
|
|||||||
doc_comment = doc_result[1]
|
doc_comment = doc_result[1]
|
||||||
doc_date = doc_result[2]
|
doc_date = doc_result[2]
|
||||||
try:
|
try:
|
||||||
with open(doc_path, "rb") as file:
|
with open(doc_path, encoding="latin1") as file:
|
||||||
file = UploadedFile(file)
|
file = UploadedFile(file)
|
||||||
doc_title = "Migrierte Datei"
|
doc_title = "Migrierte Datei"
|
||||||
doc_date = doc_date or "1970-01-01"
|
doc_date = doc_date or "1970-01-01"
|
||||||
|
doc_exists = document_cls.objects.filter(
|
||||||
doc_file = self.__find_migrated_file_recursive(
|
instance=instance,
|
||||||
document_cls,
|
title=doc_title,
|
||||||
instance,
|
comment=doc_comment,
|
||||||
file.name
|
date_of_creation=doc_date
|
||||||
)
|
).exists()
|
||||||
|
if doc_exists:
|
||||||
if doc_file is not None:
|
continue
|
||||||
doc_file.delete()
|
|
||||||
else:
|
|
||||||
print(f"------ Could not find file, that should have been migrated already. Adding new version anyway: {doc_path}")
|
|
||||||
|
|
||||||
doc = document_cls.objects.create(
|
doc = document_cls.objects.create(
|
||||||
title=doc_title,
|
title=doc_title,
|
||||||
comment=doc_comment,
|
comment=doc_comment,
|
||||||
@ -118,21 +114,6 @@ class BaseMigrater:
|
|||||||
tmp_cursor.close()
|
tmp_cursor.close()
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def __find_migrated_file_recursive(self, document_cls, instance, file_name):
|
|
||||||
file_name_tmp = file_name
|
|
||||||
try:
|
|
||||||
doc_file = document_cls.objects.get(
|
|
||||||
instance=instance,
|
|
||||||
file__icontains=file_name_tmp
|
|
||||||
)
|
|
||||||
return doc_file
|
|
||||||
except ObjectDoesNotExist:
|
|
||||||
file_name_tmp = file_name_tmp[:len(file_name_tmp) - 1]
|
|
||||||
if len(file_name_tmp) > 0:
|
|
||||||
return self.__find_migrated_file_recursive(document_cls, instance, file_name_tmp)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _migrate_log(self, instance, db_result: tuple):
|
def _migrate_log(self, instance, db_result: tuple):
|
||||||
identifier = f"'{db_result[0]}'"
|
identifier = f"'{db_result[0]}'"
|
||||||
tmp_cursor = self.db_connection.cursor()
|
tmp_cursor = self.db_connection.cursor()
|
||||||
|
@ -146,7 +146,6 @@ class InterventionMigrater(BaseMigrater):
|
|||||||
|
|
||||||
def migrate(self):
|
def migrate(self):
|
||||||
self.connect_db()
|
self.connect_db()
|
||||||
el = "'EIV-1380625802430'"
|
|
||||||
cursor = self.db_connection.cursor()
|
cursor = self.db_connection.cursor()
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
'select '
|
'select '
|
||||||
@ -181,8 +180,7 @@ class InterventionMigrater(BaseMigrater):
|
|||||||
'where '
|
'where '
|
||||||
'om."OKL"=7730085 and '
|
'om."OKL"=7730085 and '
|
||||||
'om.archiv=false and '
|
'om.archiv=false and '
|
||||||
'om.nicht_vollstaendig=0 and '
|
'om.nicht_vollstaendig=0 '
|
||||||
f'om."KENNUNG"={el}'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
all_eivs = cursor.fetchall()
|
all_eivs = cursor.fetchall()
|
||||||
@ -198,17 +196,17 @@ class InterventionMigrater(BaseMigrater):
|
|||||||
intervention = Intervention.objects.get_or_create(
|
intervention = Intervention.objects.get_or_create(
|
||||||
identifier=eiv[0]
|
identifier=eiv[0]
|
||||||
)[0]
|
)[0]
|
||||||
#intervention.title = eiv[1]
|
intervention.title = eiv[1]
|
||||||
#intervention.comment = eiv_comment
|
intervention.comment = eiv_comment
|
||||||
#intervention = self._migrate_intervention_legal(intervention, eiv)
|
intervention = self._migrate_intervention_legal(intervention, eiv)
|
||||||
#intervention = self._migrate_intervention_responsibility(intervention, eiv)
|
intervention = self._migrate_intervention_responsibility(intervention, eiv)
|
||||||
intervention = self._migrate_documents(intervention, InterventionDocument, eiv)
|
intervention = self._migrate_documents(intervention, InterventionDocument, eiv)
|
||||||
#intervention = self._migrate_log(intervention, eiv)
|
intervention = self._migrate_log(intervention, eiv)
|
||||||
#intervention = self._migrate_revocation(intervention, eiv)
|
intervention = self._migrate_revocation(intervention, eiv)
|
||||||
intervention.save()
|
intervention.save()
|
||||||
|
|
||||||
#intervention = self._migrate_geometry(intervention, eiv)
|
intervention = self._migrate_geometry(intervention, eiv)
|
||||||
#intervention = self._migrate_intervention_payment(intervention, eiv)
|
intervention = self._migrate_intervention_payment(intervention, eiv)
|
||||||
intervention.save()
|
intervention.save()
|
||||||
|
|
||||||
num_processed += 1
|
num_processed += 1
|
||||||
|
@ -20,11 +20,11 @@ class Command(BaseKonovaCommand):
|
|||||||
try:
|
try:
|
||||||
migraters = [
|
migraters = [
|
||||||
InterventionMigrater(options),
|
InterventionMigrater(options),
|
||||||
#CompensationMigrater(options),
|
CompensationMigrater(options),
|
||||||
#EmaMigrater(options),
|
EmaMigrater(options),
|
||||||
#EcoAccountMigrater(options),
|
EcoAccountMigrater(options),
|
||||||
#InterventionRecordedMigrater(options),
|
InterventionRecordedMigrater(options),
|
||||||
#UserMigrater(options),
|
UserMigrater(options),
|
||||||
]
|
]
|
||||||
for migrater in migraters:
|
for migrater in migraters:
|
||||||
migrater.migrate()
|
migrater.migrate()
|
||||||
|
Loading…
Reference in New Issue
Block a user