parent
							
								
									8b4104c704
								
							
						
					
					
						commit
						24298d2043
					
				@ -6,6 +6,7 @@ from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_BIOTOPES_EXTRA_CODE
 | 
			
		||||
from compensation.models import Compensation, CompensationState
 | 
			
		||||
from intervention.models import Responsibility, Handler, Intervention
 | 
			
		||||
from konova.management.commands.kspMigrater.base_migrater import BaseMigrater
 | 
			
		||||
from konova.models import Deadline, DeadlineType
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CompensationMigrater(BaseMigrater):
 | 
			
		||||
@ -59,6 +60,7 @@ class CompensationMigrater(BaseMigrater):
 | 
			
		||||
                compensation = self._migrate_responsibility(compensation, kom)
 | 
			
		||||
                compensation = self._migrate_compensation_type(compensation, kom)
 | 
			
		||||
                compensation = self._migrate_states(compensation, kom)
 | 
			
		||||
                compensation = self._migrate_deadlines(compensation, kom)
 | 
			
		||||
                try:
 | 
			
		||||
                    compensation = self._migrate_interventions_reference(compensation, kom)
 | 
			
		||||
                    compensation.save()
 | 
			
		||||
@ -197,4 +199,76 @@ class CompensationMigrater(BaseMigrater):
 | 
			
		||||
            compensation.is_coherence_keeping = True
 | 
			
		||||
            compensation.is_cef = True
 | 
			
		||||
        tmp_cursor.close()
 | 
			
		||||
        return compensation
 | 
			
		||||
 | 
			
		||||
    def _migrate_deadlines(self, compensation, kom):
 | 
			
		||||
        kom_identifier = f"'{kom[0]}'"
 | 
			
		||||
        tmp_cursor = self.db_connection.cursor()
 | 
			
		||||
        tmp_cursor.execute(
 | 
			
		||||
            'select '
 | 
			
		||||
                'f.umsetzungbis, '
 | 
			
		||||
                'f.unterhaltungbis, '
 | 
			
		||||
                'f.artunterhaltungbis, '
 | 
			
		||||
                'f.artumsetzungbis '
 | 
			
		||||
            'from kom k '
 | 
			
		||||
                'left join fristen f on k.fristen=f.id '
 | 
			
		||||
                'left join "OBJ_MASTER" om on k.gispadid=om."GISPADID" '
 | 
			
		||||
            'where '
 | 
			
		||||
                f'om."KENNUNG"={kom_identifier}'
 | 
			
		||||
        )
 | 
			
		||||
        db_results = tmp_cursor.fetchall()
 | 
			
		||||
 | 
			
		||||
        for result in db_results:
 | 
			
		||||
            finish_until = result[0]
 | 
			
		||||
            maintain_until = result[1]
 | 
			
		||||
            maintain_until_type = result[2]
 | 
			
		||||
            finish_until_type = result[3]
 | 
			
		||||
 | 
			
		||||
            if finish_until_type == 941256187:
 | 
			
		||||
                finish_until_type = "Termin endgültig"
 | 
			
		||||
            elif finish_until_type == 889700393:
 | 
			
		||||
                finish_until_type = "Termin vorläufig"
 | 
			
		||||
            else:
 | 
			
		||||
                finish_until_type = "Unbekannt ob Termin vorläufig oder endgültig"
 | 
			
		||||
 | 
			
		||||
            if maintain_until_type == 807238388:
 | 
			
		||||
                maintain_until_type = "Terminart 'bis zum'"
 | 
			
		||||
            elif maintain_until_type == 23925195:
 | 
			
		||||
                maintain_until_type = "Terminart 'dauerhaft'"
 | 
			
		||||
            elif maintain_until_type == 322729640:
 | 
			
		||||
                maintain_until_type = "Terminart 'nicht erforderlich'"
 | 
			
		||||
            else:
 | 
			
		||||
                maintain_until_type = "Unbekannte Terminart"
 | 
			
		||||
 | 
			
		||||
            if finish_until is not None:
 | 
			
		||||
                try:
 | 
			
		||||
                    deadline = compensation.deadlines.get(
 | 
			
		||||
                        type=DeadlineType.FINISHED,
 | 
			
		||||
                        date=finish_until,
 | 
			
		||||
                        comment=finish_until_type
 | 
			
		||||
                    )
 | 
			
		||||
                except ObjectDoesNotExist:
 | 
			
		||||
                    deadline = Deadline.objects.create(
 | 
			
		||||
                        type=DeadlineType.FINISHED,
 | 
			
		||||
                        date=finish_until,
 | 
			
		||||
                        comment=finish_until_type
 | 
			
		||||
                    )
 | 
			
		||||
                    compensation.deadlines.add(deadline)
 | 
			
		||||
 | 
			
		||||
            if maintain_until is not None:
 | 
			
		||||
                try:
 | 
			
		||||
                    deadline = compensation.deadlines.get(
 | 
			
		||||
                        type=DeadlineType.MAINTAIN,
 | 
			
		||||
                        date=maintain_until,
 | 
			
		||||
                        comment=maintain_until_type
 | 
			
		||||
                    )
 | 
			
		||||
                except ObjectDoesNotExist:
 | 
			
		||||
                    deadline = Deadline.objects.create(
 | 
			
		||||
                        type=DeadlineType.MAINTAIN,
 | 
			
		||||
                        date=maintain_until,
 | 
			
		||||
                        comment=maintain_until_type
 | 
			
		||||
                    )
 | 
			
		||||
                    compensation.deadlines.add(deadline)
 | 
			
		||||
 | 
			
		||||
        tmp_cursor.close()
 | 
			
		||||
        return compensation
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user