First Commit - Source Code from Reply
This commit is contained in:
95
dbcmnpsrc/FE/mnpapp/script/governance/sql/SDNRESP69.sql
Normal file
95
dbcmnpsrc/FE/mnpapp/script/governance/sql/SDNRESP69.sql
Normal file
@@ -0,0 +1,95 @@
|
||||
--L'indicatore deve riportare giornalmente il tempo massimo rilevato per il passaggio di stato da
|
||||
--"acquisita" a "cessata" del 95% delle richieste.
|
||||
--Il tempo massimo rilevato deve essere suddiviso per: Tipologia Cliente (CO/BU).
|
||||
--Devono essere prodotti tanti record riportanti ognuno il tempo massimo rilevato per ognuna delle
|
||||
--tipologie cliente previste.
|
||||
--Il dato deve essere calcolato giornalmente per le richieste che nella giornata di rilevazione hanno
|
||||
--subito un passaggio nello stato di "cessata".
|
||||
--Per cui se nella giornata di rilevazione non esistono richieste che sono transitate nello stato
|
||||
--"cessata" il dato non viene rilevato. Il record però deve essere prodotto anche in
|
||||
--questo caso associando all'indicatore il valore '-' (trattino).
|
||||
--Nel calcolo dei tempi di passaggio di stato devono essere presi in considerazione solo i giorni lavorativi.
|
||||
|
||||
SET serveroutput on
|
||||
|
||||
DECLARE
|
||||
|
||||
id_richiesta varchar2(23);
|
||||
gg number(10):=0;
|
||||
rich_prc number(10):=0;
|
||||
id_rich_max number(10):=0;
|
||||
data_val date;
|
||||
var_tipo_cliente varchar2(2);
|
||||
file1 UTL_FILE.file_type;
|
||||
freq varchar2(255):='&1';
|
||||
|
||||
cursor cur_giorni is
|
||||
select abs(trunc(b.data_lavorazione) - trunc(a.data_lavorazione)) - sum(decode(tip_gio,'F',1,'P',1,0)) giorni, c.id_richiesta
|
||||
,sysdate
|
||||
from mnp_storico_richiesta a,mnp_storico_richiesta b, mnp_gestione_richiesta c, s_dim_tempo d
|
||||
where a.stato_a=1
|
||||
and b.stato_a=15
|
||||
and b.data_lavorazione > trunc(sysdate)-1/86400
|
||||
and b.data_lavorazione < trunc(sysdate+1)
|
||||
and a.id_richiesta=b.id_richiesta
|
||||
and b.id_richiesta=c.id_richiesta
|
||||
and c.tipo_cliente=var_tipo_cliente
|
||||
and (c.richiestaadhocaom=1 or c.richiestaadhoc=1)
|
||||
and d.data>=a.data_lavorazione and d.data<=b.data_lavorazione
|
||||
group by c.id_richiesta,abs(trunc(b.data_lavorazione) - trunc(a.data_lavorazione))
|
||||
order by giorni;
|
||||
|
||||
begin
|
||||
|
||||
dbms_output.put_line('apro il file ' || 'MNP' || '.' || to_char(sysdate,'yyyyMMdd'));
|
||||
file1 := UTL_FILE.fopen('&2','MNP' || '.' || to_char(sysdate,'yyyyMMdd'),'a');
|
||||
|
||||
for j in 0..1 loop
|
||||
if (j=0) then var_tipo_cliente:='CO';
|
||||
else var_tipo_cliente:='BU';
|
||||
end if;
|
||||
select count(*) into rich_prc
|
||||
from mnp_storico_richiesta a, mnp_gestione_richiesta b
|
||||
where a.stato_a=15
|
||||
and a.id_richiesta=b.id_richiesta
|
||||
and a.data_lavorazione > trunc(sysdate)-1/86400
|
||||
and a.data_lavorazione < trunc(sysdate+1)
|
||||
and b.tipo_cliente=var_tipo_cliente
|
||||
and (b.richiestaadhocaom=1 or b.richiestaadhoc=1);
|
||||
|
||||
id_rich_max:=trunc(rich_prc/95*100);
|
||||
rich_prc:=0;
|
||||
|
||||
open cur_giorni;
|
||||
loop
|
||||
fetch cur_giorni into gg, id_richiesta,data_val;
|
||||
exit when cur_giorni%notfound;
|
||||
rich_prc:=rich_prc+1;
|
||||
if(rich_prc=id_rich_max) then
|
||||
UTL_FILE.put_line(file1,'SDNRESP69'||';'||var_tipo_cliente||';'||gg||';'
|
||||
||freq||';'||'&3'|| ';'
|
||||
||to_char(data_val,'yyyymmdd')||';'||to_char(data_val,'hh24:mi:ss') ||';'
|
||||
||to_char(sysdate,'yyyymmdd')||';'||to_char(sysdate,'hh24:mi:ss') ||';'
|
||||
||'0'||';'||var_tipo_cliente||';;');
|
||||
exit;
|
||||
end if;
|
||||
end loop;
|
||||
if(rich_prc=0) then
|
||||
UTL_FILE.put_line(file1,'SDNRESP69'||';'||var_tipo_cliente||';'||'-'||';'
|
||||
||freq||';'||'&3'|| ';'
|
||||
||to_char(data_val,'yyyymmdd')||';'||to_char(data_val,'hh24:mi:ss') ||';'
|
||||
||to_char(sysdate,'yyyymmdd')||';'||to_char(sysdate,'hh24:mi:ss') ||';'
|
||||
||'0'||';'||var_tipo_cliente||';;');
|
||||
end if;
|
||||
close cur_giorni;
|
||||
end loop;
|
||||
UTL_FILE.fflush(file1);
|
||||
UTL_FILE.fclose(file1);
|
||||
dbms_output.put_line('chiudo il file ' || 'MNP' || '.' || to_char(sysdate,'yyyyMMdd'));
|
||||
exception
|
||||
when others then
|
||||
DBMS_OUTPUT.PUT_LINE(sqlerrm);
|
||||
end;
|
||||
/
|
||||
exit
|
||||
|
||||
Reference in New Issue
Block a user