Browse Source

Geschlossene TSG nach MSG verlängern #16

basisressourcen
Daniel Quathamer 10 months ago
parent
commit
e3735619b8
  1. 156
      src-modules/module/costage/hilfstabellen/costage_st_studien_aggr_fuellen.sql

156
src-modules/module/costage/hilfstabellen/costage_st_studien_aggr_fuellen.sql

@ -9,6 +9,7 @@ where param_id='COSTAGE_start_st_sem'; @@ -9,6 +9,7 @@ where param_id='COSTAGE_start_st_sem';
drop table if exists tmp_studien;
drop table if exists tmp_studien2;
drop table if exists tmp_tsg2msg;
SELECT
SM.semester_tid as semester,
@ -34,6 +35,7 @@ S.second_nationality, @@ -34,6 +35,7 @@ S.second_nationality,
SG.fachkennzeichen,
ST.studienform_statistik_code,
(case when SG.studiengangs_typ_kb in ('MSG') then SG.st_studiengang_nr else null::integer end) as st_studiengang_nr_msg,
null::varchar(255) as studiengangs_identifikator_msg,
null::integer as st_studiengang_nr_msg_primaerflag,
(case when SG.studiengangs_typ_kb in ('TSG') then SG.st_studiengang_nr else null::integer end) as st_studiengang_nr_tsg,
null::integer as studienfach_sortierung,
@ -197,42 +199,41 @@ select 40,timestamp_str(now()) from xdummy; @@ -197,42 +199,41 @@ select 40,timestamp_str(now()) from xdummy;
--Ermittlung msg bei TSG:
--es kann pro Studi und Semester und Abschlussziel mehrere MSG geben,
--daqher zuerst den jeweils letzten ermitteln. Dieser ist dann der Default-MSG:
select st_sem_nr,
st_absz_nr,
st_studstamm_nr,
null::integer as st_studiengang_nr_msg,
max(beginn_datum) as beginn_datum
into temp tmp_last_msg_per_term
from tmp_studien
where studiengangs_typ_kb='MSG'
group by 1,2,3
select S.st_sem_nr,
S.st_studstamm_nr,
S2.st_studium_nr as st_studium_nr_tsg ,
S.primaerflag_studien,
S.beginn_datum,min(S.st_studium_nr) as st_studium_nr_msg
into temp tmp_tsg2msg
from tmp_studien2 S2,tmp_studien S, costage_st_studiengaenge_mtsg M
where
S.st_sem_nr=S2.st_sem_nr
and S.st_studstamm_nr=S2.st_studstamm_nr
and S2.st_studiengang_nr=M.st_studiengang_nr_tsg
and S.status_historie=1
and S.studiengangs_typ_kb='MSG'
and S.st_absz_nr=S2.st_absz_nr
and S.st_studiengang_nr_msg=M.st_studiengang_nr_msg
group by 1,2,3,4,5
;
update tmp_last_msg_per_term set st_studiengang_nr_msg=T.st_studiengang_nr_msg
from tmp_studien T
where T.studiengangs_typ_kb='MSG'
and T.st_absz_nr=tmp_last_msg_per_term.st_absz_nr
and T.st_studiengang_nr_msg is not null
and T.st_sem_nr=tmp_last_msg_per_term.st_sem_nr
and T.st_studstamm_nr=tmp_last_msg_per_term.st_studstamm_nr
and T.beginn_datum=tmp_last_msg_per_term.beginn_datum
;
create index tmp_ix222 on tmp_tsg2msg(primaerflag_studien);
--nur Diagnose Einzelschritt:
--select st_studiengang_nr_msg,* from tmp_studien2 where semester=20222
--;
--zuerst den jeweils letzten (=jüngsten) MSG zuweisen:
--TODO: langsam:
update tmp_studien2 set st_studiengang_nr_msg=E.st_studiengang_nr_msg
from tmp_last_msg_per_term E
where E.st_sem_nr=tmp_studien2.st_sem_nr
and E.st_studstamm_nr=tmp_studien2.st_studstamm_nr
and E.st_absz_nr=tmp_studien2.st_absz_nr
and tmp_studien2.studiengangs_typ_kb ='TSG'
;
-- update tmp_studien2 set st_studiengang_nr_msg=E.st_studiengang_nr_msg
-- from tmp_last_msg_per_term E
-- where E.st_sem_nr=tmp_studien2.st_sem_nr
-- and E.st_studstamm_nr=tmp_studien2.st_studstamm_nr
-- and E.st_absz_nr=tmp_studien2.st_absz_nr
-- and tmp_studien2.studiengangs_typ_kb ='TSG'
-- ;
--
--TODO: langsam:
-- update tmp_studien2 set st_studiengang_nr_msg=T.st_studiengang_nr_msg
-- from tmp_studien T,tmp_last_msg_per_term E, costage_st_studiengaenge_mtsg M
-- where M.st_studiengang_nr_tsg=tmp_studien2.st_studiengang_nr
@ -249,6 +250,58 @@ and tmp_studien2.studiengangs_typ_kb ='TSG' @@ -249,6 +250,58 @@ and tmp_studien2.studiengangs_typ_kb ='TSG'
-- and tmp_studien2.studiengangs_typ_kb ='TSG'
-- ;
-- update tmp_studien2 set st_studiengang_nr_msg=T.st_studiengang_nr_msg
-- from tmp_studien T,
-- --tmp_last_msg_per_term E,
-- costage_st_studiengaenge_mtsg M
-- where M.st_studiengang_nr_tsg=tmp_studien2.st_studiengang_nr
-- and M.st_studiengang_nr_msg=T.st_studiengang_nr_msg
-- and T.st_sem_nr=tmp_studien2.st_sem_nr
-- and T.st_studstamm_nr=tmp_studien2.st_studstamm_nr
-- --and E.st_sem_nr=tmp_studien2.st_sem_nr
-- --and E.st_studstamm_nr=tmp_studien2.st_studstamm_nr
-- --and E.st_absz_nr=tmp_studien2.st_absz_nr
-- --and E.beginn_datum=T.beginn_datum
-- and T.status_historie=1
-- and T.studiengangs_typ_kb='MSG'
-- and T.st_absz_nr=tmp_studien2.st_absz_nr
-- and T.st_studiengang_nr_msg is not null
-- and tmp_studien2.studiengangs_typ_kb ='TSG'
-- ;
--1.prio: primärflag=1
update tmp_studien2 set st_studiengang_nr_msg=M.st_studiengang_nr_msg,
studienfach_sortierung=M.studienfach_sortierung,
studiengangs_identifikator_msg=S.studiengangs_identifikator
from tmp_tsg2msg T, tmp_studien S,
costage_st_studiengaenge_mtsg M
where M.st_studiengang_nr_tsg=tmp_studien2.st_studiengang_nr
and M.st_studiengang_nr_msg=S.st_studiengang_nr
and S.st_sem_nr=tmp_studien2.st_sem_nr
and S.st_studstamm_nr=tmp_studien2.st_studstamm_nr
and S.beginn_datum=T.beginn_datum
and T.st_studium_nr_tsg=tmp_studien2.st_studium_nr
and T.st_studium_nr_msg=S.st_studium_nr
and tmp_studien2.studiengangs_typ_kb ='TSG'
and T.primaerflag_studien=1;
--2. prio: ohne primärflag:
update tmp_studien2 set st_studiengang_nr_msg=M.st_studiengang_nr_msg,
studienfach_sortierung=M.studienfach_sortierung,
studiengangs_identifikator_msg=S.studiengangs_identifikator
from tmp_tsg2msg T, tmp_studien S,
costage_st_studiengaenge_mtsg M
where M.st_studiengang_nr_tsg=tmp_studien2.st_studiengang_nr
and M.st_studiengang_nr_msg=S.st_studiengang_nr
and S.st_sem_nr=tmp_studien2.st_sem_nr
and S.st_studstamm_nr=tmp_studien2.st_studstamm_nr
and S.beginn_datum=T.beginn_datum
and T.st_studium_nr_tsg=tmp_studien2.st_studium_nr
and T.st_studium_nr_msg=S.st_studium_nr
and tmp_studien2.studiengangs_typ_kb ='TSG'
and tmp_studien2.st_studiengang_nr_msg is null
;
drop table tmp_tsg2msg;
select 50,timestamp_str(now()) from xdummy;
@ -284,12 +337,10 @@ and S.status_historie=1 @@ -284,12 +337,10 @@ and S.status_historie=1
select 70,timestamp_str(now()) from xdummy;
drop table tmp_last_msg_per_term;
<#if K_COSTAGE_TSG_GENERATE == 1>
--alle möglichen TSG/MSG-Kombinationen laden:
select T.*,M.st_studiengang_nr_msg as st_studiengang_nr_msg_possible,ST.st_studium_nr as st_studium_nr_msg_possible
into temp tmp_studien3
from tmp_studien2 T, costage_st_studiengaenge_mtsg M, costage_st_studien ST
@ -299,8 +350,6 @@ and M.st_studiengang_nr_tsg=T.st_studiengang_nr @@ -299,8 +350,6 @@ and M.st_studiengang_nr_tsg=T.st_studiengang_nr
and T.studiengangs_typ_kb ='TSG'
;
select 80,timestamp_str(now()) from xdummy;
--Start- und Endsemester aller MSG pro Student:
drop table if exists tmp_studien_msg;
@ -315,13 +364,10 @@ and T.studiengangs_typ_kb ='MSG'--enthält die MSG @@ -315,13 +364,10 @@ and T.studiengangs_typ_kb ='MSG'--enthält die MSG
and T.status_historie=1
group by 1,2
;
select 90,timestamp_str(now()) from xdummy;
--Verknüpfung mit TSG über alle möglichen Semester:
drop table if exists tmp_studien_msg_tsg;
select distinct
G.studiengangs_identifikator as studiengangs_identifikator_msg,
M.st_studiengang_nr_msg,
T.st_studiengang_nr as st_studiengang_nr_tsg,
M.st_studstamm_nr,
@ -332,8 +378,9 @@ E.st_sem_nr, @@ -332,8 +378,9 @@ E.st_sem_nr,
M.startsemester,
M.endsemester
into temp tmp_studien_msg_tsg
from tmp_studien_msg M, tmp_studien3 T,costage_st_semester E
where M.st_studiengang_nr_msg=T.st_studiengang_nr_msg_possible
from costage_st_studiengaenge G,tmp_studien_msg M, tmp_studien3 T,costage_st_semester E
where G.st_studiengang_nr=M.st_studiengang_nr_msg
and M.st_studiengang_nr_msg=T.st_studiengang_nr_msg_possible
and M.st_studstamm_nr=T.st_studstamm_nr
--and T.semester between M.startsemester and M.endsemester
and E.semester_tid between M.startsemester and M.endsemester
@ -347,9 +394,10 @@ drop table if exists tmp_studien_msg_tsg_fehlend; @@ -347,9 +394,10 @@ drop table if exists tmp_studien_msg_tsg_fehlend;
select T.*
into temp tmp_studien_msg_tsg_fehlend
from tmp_studien_msg_tsg T --enthält alle möglichen TSG
left outer join tmp_studien3 T2 --enthält die tatsächlich vorhandenen TSG
on (T2.st_studiengang_nr_msg_possible=T.st_studiengang_nr_msg
and T2.st_studiengang_nr=T.st_studiengang_nr_tsg
left outer join tmp_studien2 T2 --enthält die tatsächlich vorhandenen TSG
on (--T2.st_studiengang_nr_msg=T.st_studiengang_nr_msg
--and
T2.st_studiengang_nr=T.st_studiengang_nr_tsg
and T2.st_studstamm_nr=T.st_studstamm_nr
and T2.studiengangs_typ_kb ='TSG'
and T.semester=T2.semester)
@ -380,6 +428,7 @@ second_nationality, @@ -380,6 +428,7 @@ second_nationality,
fachkennzeichen,
studienform_statistik_code,
st_studiengang_nr_msg,
studiengangs_identifikator_msg,
st_studiengang_nr_tsg,
hrst,
hssem,
@ -417,6 +466,7 @@ S.second_nationality, @@ -417,6 +466,7 @@ S.second_nationality,
S.fachkennzeichen,
S.studienform_statistik_code,
M.st_studiengang_nr_msg,
M.studiengangs_identifikator_msg,
S.st_studiengang_nr_tsg,
null::char(10) as hrst,--hrst kann im Studienverlauf wechseln, daher nachher vom MSG nachladen
S.hssem,
@ -431,9 +481,10 @@ S.hzb_note, @@ -431,9 +481,10 @@ S.hzb_note,
null::char(10) as abm_art_s,
null::integer as fachsemester,
max(S.semester)
from tmp_studien_msg_tsg_fehlend M, tmp_studien3 S --,costage_st_semester E
where M.st_studiengang_nr_msg=S.st_studiengang_nr_msg_possible
and M.st_studiengang_nr_tsg=S.st_studiengang_nr
from tmp_studien_msg_tsg_fehlend M, tmp_studien2 S, costage_st_studiengaenge_mtsg MT
where M.st_studiengang_nr_msg=MT.st_studiengang_nr_msg
and MT.st_studiengang_nr_tsg=M.st_studiengang_nr_tsg
and MT.st_studiengang_nr_tsg=S.st_studiengang_nr
and M.st_studstamm_nr=S.st_studstamm_nr
and S.studiengangs_typ_kb ='TSG'
and M.semester != S.semester
@ -441,7 +492,7 @@ and M.semester != S.semester @@ -441,7 +492,7 @@ and M.semester != S.semester
--and S.st_studiengang_nr_msg=34454
--and S.studiengangs_bezeichnung='Bildungswissenschaften'
--and M.semester=20211
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,23,24,25,26,27,28,29,30,31,32
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,23,24,25,26,27,28,29,30,31,32,33
;
select 110,timestamp_str(now()) from xdummy;
@ -501,12 +552,13 @@ drop table tmp_studien3; @@ -501,12 +552,13 @@ drop table tmp_studien3;
drop table tmp_studien;
--Ermittlung fach_nr:
update tmp_studien2 set fach_nr=M.studienfach_sortierung
from costage_st_studiengaenge_mtsg M
where M.st_studiengang_nr_msg=tmp_studien2.st_studiengang_nr_msg
and M.st_studiengang_nr_tsg=tmp_studien2.st_studiengang_nr
and tmp_studien2.studiengangs_typ_kb ='TSG'
;
update tmp_studien2 set fach_nr=studienfach_sortierung;
-- from costage_st_studiengaenge_mtsg M
-- where M.st_studiengang_nr_msg=tmp_studien2.st_studiengang_nr_msg
-- and M.st_studiengang_nr_tsg=tmp_studien2.st_studiengang_nr
-- and tmp_studien2.studiengangs_typ_kb ='TSG'
-- ;
update tmp_studien2 set fach_nr=1
where fach_nr is null;
@ -571,7 +623,7 @@ into temp tmp_studien3 @@ -571,7 +623,7 @@ into temp tmp_studien3
from tmp_studien2 T left outer join costage_st_studien_spoversionen SPO
on (SPO.st_studium_nr=T.st_studium_nr
and SPO.gueltig_ab < T.semester_ende)
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51
group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52
;
select 160,timestamp_str(now()) from xdummy;
@ -654,7 +706,7 @@ select st_studium_nr, @@ -654,7 +706,7 @@ select st_studium_nr,
(case when studiengang_nr =1 then studiengang_nr
else
dense_rank () over (partition by semester, st_studstamm_nr,studiengang_nr order by
(case when studiengangs_typ_kb='TSG' then st_studiengang_nr_msg else st_studium_nr end ))+1
(case when studiengangs_typ_kb='TSG' then studiengangs_identifikator_msg else st_studium_nr::varchar(255) end ))+1
end)
as studiengang_nr,
(case when primaerflag =1 then 1

Loading…
Cancel
Save