Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VAS-1170] feat: Bump api-config-starter dependency #308

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/resources/h2/data-h2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,16 @@ INSERT INTO NODO4_CFG.IBAN_ATTRIBUTES_MASTER (OBJ_ID, FK_IBAN_MASTER, FK_IBAN_AT
values (200, 200, 200),
(201, 201, 200),
(202, 202, 201);

INSERT INTO NODO4_CFG.STATION_MAINTENANCE (OBJ_ID, START_DATE_TIME, END_DATE_TIME, STANDIN, FK_STATION, CI_TAX_CODE)
VALUES('1', '2024-02-15 01:00:00', '2024-02-15 20:00:00', false, 2, '11100011113');
INSERT INTO NODO4_CFG.STATION_MAINTENANCE (OBJ_ID, START_DATE_TIME, END_DATE_TIME, STANDIN, FK_STATION, CI_TAX_CODE)
VALUES('2', '2024-04-15 01:00:00', '2024-04-15 20:00:00', true, 2, '11100011113');
INSERT INTO NODO4_CFG.STATION_MAINTENANCE (OBJ_ID, START_DATE_TIME, END_DATE_TIME, STANDIN, FK_STATION, CI_TAX_CODE)
VALUES('3', '2024-07-15 01:00:00', '2024-07-15 20:00:00', true, 2, '11100011113');
INSERT INTO NODO4_CFG.STATION_MAINTENANCE (OBJ_ID, START_DATE_TIME, END_DATE_TIME, STANDIN, FK_STATION, CI_TAX_CODE)
VALUES('4', '2023-12-31 11:00:00', '2024-01-01 18:00:00', false, 2, '11100011113');
INSERT INTO NODO4_CFG.STATION_MAINTENANCE (OBJ_ID, START_DATE_TIME, END_DATE_TIME, STANDIN, FK_STATION, CI_TAX_CODE)
VALUES('5', '2024-05-21 01:00:00', '2024-05-21 20:00:00', true, 3, '11100011112');
INSERT INTO NODO4_CFG.STATION_MAINTENANCE (OBJ_ID, START_DATE_TIME, END_DATE_TIME, STANDIN, FK_STATION, CI_TAX_CODE)
VALUES('6', '2023-12-31 11:00:00', '2024-01-01 18:00:00', true, 3, '11100011112');
49 changes: 47 additions & 2 deletions src/main/resources/h2/schema-h2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ create table NODO4_CFG.STAZIONI
VERSIONE numeric not null default 1.0,
SERVIZIO_NMP varchar(255),
INVIO_RT_ISTANTANEO char not null default 'N',
FLAG_STANDIN char not null default 'Y',
TARGET_HOST varchar(100),
TARGET_PORT numeric,
TARGET_PATH varchar(100),
Expand Down Expand Up @@ -719,5 +720,49 @@ CREATE OR REPLACE VIEW NODO4_CFG.IBAN_VALIDI_PER_PA AS
JOIN NODO4_CFG.PA p ON (( mas.FK_PA = p.OBJ_ID))
);



CREATE TABLE NODO4_CFG.STATION_MAINTENANCE
(
OBJ_ID numeric GENERATED BY DEFAULT AS IDENTITY,
START_DATE_TIME TIMESTAMP(0) WITH TIME ZONE not null,
END_DATE_TIME TIMESTAMP(0) WITH TIME ZONE not null,
STANDIN boolean not null,
FK_STATION numeric not null,
CI_TAX_CODE varchar(35) not null,
constraint PK_STATION_MAINTENANCE
primary key (OBJ_ID),
constraint FK_STATION_MAINTENANCE_STAZIONE
foreign key (FK_STATION)
references NODO4_CFG.STAZIONI
);

-- STATION_MAINTENANCE_EXPANDED VIEW
CREATE OR REPLACE VIEW NODO4_CFG.STATION_MAINTENANCE_EXPANDED AS
SELECT mequal.OBJ_ID::varchar(255) AS ID, mequal.START_DATE_TIME, mequal.END_DATE_TIME, mequal.CI_TAX_CODE
FROM NODO4_CFG.STATION_MAINTENANCE mequal
WHERE EXTRACT('year' FROM mequal.START_DATE_TIME) = EXTRACT('year' FROM mequal.END_DATE_TIME )
UNION ALL
SELECT mdiffStart.OBJ_ID || 'start' AS ID, mdiffStart.START_DATE_TIME, (DATE_TRUNC('year', mdiffStart.START_DATE_TIME) + interval '1' year) AS END_DATE_TIME , mdiffStart.CI_TAX_CODE
FROM NODO4_CFG.STATION_MAINTENANCE mdiffStart
WHERE EXTRACT('year' FROM mdiffStart.START_DATE_TIME) != EXTRACT('year' FROM mdiffStart.END_DATE_TIME )
UNION ALL
SELECT mdiffEnd.OBJ_ID || 'end' AS ID, (DATE_TRUNC('year', mdiffEnd.END_DATE_TIME )) AS START_DATE_TIME, mdiffEnd.END_DATE_TIME , mdiffEnd.CI_TAX_CODE
FROM NODO4_CFG.STATION_MAINTENANCE mdiffEnd
WHERE EXTRACT('year' FROM mdiffEnd.START_DATE_TIME) != EXTRACT('year' FROM mdiffEnd.END_DATE_TIME );

-- STATION_MAINTENANCE_SUMMARY VIEW
CREATE OR REPLACE VIEW NODO4_CFG.STATION_MAINTENANCE_SUMMARY AS
SELECT CI_TAX_CODE , TO_CHAR(DATE_TRUNC('year', START_DATE_TIME), 'YYYY') AS MAINTENANCE_YEAR,
SUM(COALESCE(
(
SELECT EXTRACT(epoch FROM END_DATE_TIME - START_DATE_TIME)/3600
FROM NODO4_CFG.STATION_MAINTENANCE_EXPANDED AS maintenanceForUsedHours
WHERE maintenanceForUsedHours.END_DATE_TIME < CURRENT_TIMESTAMP and maintenanceForUsedHours.ID = maintenanceBase.ID
), 0)) AS USED_HOURS,
SUM(COALESCE(
(
SELECT EXTRACT(epoch FROM END_DATE_TIME - START_DATE_TIME)/3600
FROM NODO4_CFG.STATION_MAINTENANCE_EXPANDED AS maintenanceForScheduledHours
WHERE maintenanceForScheduledHours.START_DATE_TIME > CURRENT_TIMESTAMP and maintenanceForScheduledHours.ID = maintenanceBase.ID
), 0)) AS SCHEDULED_HOURS
FROM NODO4_CFG.STATION_MAINTENANCE_EXPANDED AS maintenanceBase
GROUP BY CI_TAX_CODE, MAINTENANCE_YEAR;
Loading