46 | | select vozenje_id from project.vozenje |
47 | | join dnevniruti on vozenje.dr_id=dnevniruti.dr_id |
48 | | join linija on dnevniruti.li_id=linija.li_id |
49 | | where date_trunc("minute", now()) between date_trunc("minute", vozenje.start) and date_trunc("minute", vozenje.end); |
50 | | }}} |
51 | | }}} |
52 | | |
53 | | |
54 | | {{{#!div style="font-size: 80%" |
55 | | {{{#!sql |
56 | | insert into kontroli(kontrola_datum, konduktor_l_id, vozenje_id) |
57 | | values (now(), 1, 1); |
58 | | }}} |
59 | | }}} |
60 | | |
61 | | [[Image(Kontrola.png)]] |
62 | | |
63 | | |
64 | | |
65 | | === Чекор 4: Валидација на билет и пишување казна |
66 | | |
67 | | {{{#!div style="font-size: 80%" |
68 | | {{{#!sql |
69 | | select konduktor_l_id, kontrola_id, patnik_l_id from project.kontrola |
70 | | join vozenje on kontrola.vozenje_id = vozenje.vozenje_id |
71 | | join bilet on vozenje.patnik_l_id=bilet.patnik_l_id |
72 | | where (tb_id=1 and age(kontrola_datum, b_datum_na_kupuvanje) > interval '1 hour') or |
73 | | (tb_id=2 and age(kontrola_datum, b_datum_na_kupuvanje) > interval '1 day') or |
74 | | (tb_id=3 and age(kontrola_datum, b_datum_na_kupuvanje) > interval '1 week') or |
75 | | (tb_id=4 and age(kontrola_datum, b_datum_na_kupuvanje) > interval '1 month') or |
76 | | (tb_id=5 and age(kontrola_datum, b_datum_na_kupuvanje) > interval '1 year'); |
| 32 | select il.inl_id |
| 33 | from instancanalinija as il |
| 34 | join linija as l on l.li_id = il.li_id |
| 35 | where l.li_ime like 'Line 1' and l.li_pravec like 'Aerodrom-Gjorce' and il.inl_datum_start = '2023-01-01 12:00:00.000' |
82 | | insert into kazna(k_iznos, k_plateno, k_datum, konduktor_l_id, kontrola_id, patnik_l_id) |
83 | | values (3000, false, now(), 1, 2, 1); |
84 | | |
| 41 | insert into kontroli (kontrola_datum, kondukter_k_id, inl_id) |
| 42 | values ('2023-01-01 12:00:00.000' + interval '6 minutes', 2, 1); |
89 | | [[Image(Kazna.png)]] |
| 47 | === Чекор 4: Валидација на билет |
| 48 | |
| 49 | {{{#!div style="font-size: 80%" |
| 50 | {{{#!sql |
| 51 | select b.patnik_k_id |
| 52 | from instancanalinija as il |
| 53 | join vozenje as v on v.inl_id = il.inl_id |
| 54 | join bilet as b on v.b_id = b.b_id |
| 55 | join tipbilet as t on b.tb_id = t.tb_id |
| 56 | where il.inl_id = 1 and (b.b_status like 'EXPIRED' or b.b_status like 'INACTIVE') and b.b_datum_na_kupuvanje + t.tb_trajnost * interval '1 second' < v.vozenje_start |
| 57 | }}} |
| 58 | }}} |
| 59 | |
| 60 | |
| 61 | |
| 62 | === Чекор 5.1: Пишување казна на регистриран патник |
| 63 | |
| 64 | {{{#!div style="font-size: 80%" |
| 65 | {{{#!sql |
| 66 | insert into kazna (kz_dokument, kz_iznos, kz_datum, kz_plateno, kz_datum_plateno) |
| 67 | values ('AH45691', 1000, '2023-01-01 12:00:00.000' + interval '10 minutes', false, null) |
| 68 | |
| 69 | insert into kaznazaregistriran (kz.kz_id, patnik_k_id) |
| 70 | values (15, 9) |
| 71 | }}} |
| 72 | }}} |
| 73 | |
| 74 | === Чекор 5.2: Пишување казна на нерегистриран патник |
| 75 | |
| 76 | {{{#!div style="font-size: 80%" |
| 77 | {{{#!sql |
| 78 | insert into kazna (kz_dokument, kz_iznos, kz_datum, kz_plateno, kz_datum_plateno) |
| 79 | values ('AH45691', 1000, '2023-01-01 12:00:00.000' + interval '10 minutes', false, null) |
| 80 | |
| 81 | insert into kaznazaneregistriran (kz_id, kzn_telefon, kzn_ime, kzn_adresa) |
| 82 | values (15, '074845632', 'Stefce Janekievski', 'Slovenecka') |
| 83 | }}} |
| 84 | }}} |