ganti format table

This commit is contained in:
sas.fajri
2025-04-24 14:39:28 +07:00
parent f481cc76f1
commit a2a700280b
11 changed files with 2078 additions and 1397 deletions

View File

@@ -3,217 +3,241 @@
-- Master Regulations Table
CREATE TABLE master_regulations (
regulation_id INT PRIMARY KEY AUTO_INCREMENT,
regulation_code VARCHAR(50) NOT NULL,
regulation_name VARCHAR(200) NOT NULL,
issuing_authority VARCHAR(100) NOT NULL,
regulation_type VARCHAR(50),
issue_date DATE,
effective_date DATE,
description TEXT,
file_path VARCHAR(255),
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
MasterRegulationID INT PRIMARY KEY AUTO_INCREMENT,
MasterRegulationCode VARCHAR(50) NOT NULL,
MasterRegulationName VARCHAR(200) NOT NULL,
MasterRegulationIssuingAuthority VARCHAR(100) NOT NULL,
MasterRegulationType VARCHAR(50),
MasterRegulationIssueDate DATE,
MasterRegulationEffectiveDate DATE,
MasterRegulationDescription TEXT,
MasterRegulationFilePath VARCHAR(255),
MasterRegulationIsActive BOOLEAN DEFAULT TRUE,
MasterRegulationCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterRegulationCreatedUserID INT,
MasterRegulationUpdatedAt DATETIME,
MasterRegulationUpdatedUserID INT,
MasterRegulationDeletedAt DATETIME,
MasterRegulationDeletedUserID INT
);
-- Master Climate Parameters Table
CREATE TABLE master_climate_parameters (
parameter_id INT PRIMARY KEY AUTO_INCREMENT,
parameter_code VARCHAR(50) NOT NULL,
parameter_name VARCHAR(100) NOT NULL,
parameter_group VARCHAR(50), -- Physical, Chemical, Biological
unit VARCHAR(20),
analysis_method VARCHAR(100),
description TEXT,
price DECIMAL(12, 2),
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
MasterClimateParameterID INT PRIMARY KEY AUTO_INCREMENT,
MasterClimateParameterCode VARCHAR(50) NOT NULL,
MasterClimateParameterName VARCHAR(100) NOT NULL,
MasterClimateParameterGroup VARCHAR(50),
MasterClimateParameterUnit VARCHAR(20),
MasterClimateParameterMethod VARCHAR(100),
MasterClimateParameterDescription TEXT,
MasterClimateParameterPrice DECIMAL(12,2),
MasterClimateParameterIsActive BOOLEAN DEFAULT TRUE,
MasterClimateParameterCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterClimateParameterCreatedUserID INT,
MasterClimateParameterUpdatedAt DATETIME,
MasterClimateParameterUpdatedUserID INT,
MasterClimateParameterDeletedAt DATETIME,
MasterClimateParameterDeletedUserID INT
);
-- Master Threshold Limit Values (TLV) Table
-- Master Threshold Values Table
CREATE TABLE master_threshold_values (
threshold_id INT PRIMARY KEY AUTO_INCREMENT,
regulation_id INT,
parameter_id INT,
room_type VARCHAR(100) NOT NULL,
min_value DECIMAL(8, 2),
max_value DECIMAL(8, 2),
unit VARCHAR(20),
description TEXT,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (regulation_id) REFERENCES master_regulations(regulation_id),
FOREIGN KEY (parameter_id) REFERENCES master_climate_parameters(parameter_id)
MasterThresholdValueID INT PRIMARY KEY AUTO_INCREMENT,
MasterRegulationID INT,
MasterClimateParameterID INT,
MasterThresholdValueRoomType VARCHAR(100) NOT NULL,
MasterThresholdValueMin DECIMAL(8,2),
MasterThresholdValueMax DECIMAL(8,2),
MasterThresholdValueUnit VARCHAR(20),
MasterThresholdValueDescription TEXT,
MasterThresholdValueIsActive BOOLEAN DEFAULT TRUE,
MasterThresholdValueCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterThresholdValueCreatedUserID INT,
MasterThresholdValueUpdatedAt DATETIME,
MasterThresholdValueUpdatedUserID INT,
MasterThresholdValueDeletedAt DATETIME,
MasterThresholdValueDeletedUserID INT
);
-- Master Clients Table
CREATE TABLE master_clients (
client_id INT PRIMARY KEY AUTO_INCREMENT,
client_code VARCHAR(50) NOT NULL,
client_name VARCHAR(200) NOT NULL,
address TEXT,
city VARCHAR(100),
province VARCHAR(100),
postal_code VARCHAR(20),
phone_number VARCHAR(50),
email VARCHAR(100),
contact_person VARCHAR(100),
contact_position VARCHAR(100),
business_field VARCHAR(100),
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
MasterClientID INT PRIMARY KEY AUTO_INCREMENT,
MasterClientCode VARCHAR(50) NOT NULL,
MasterClientName VARCHAR(200) NOT NULL,
MasterClientAddress TEXT,
MasterClientCity VARCHAR(100),
MasterClientProvince VARCHAR(100),
MasterClientPostalCode VARCHAR(20),
MasterClientPhoneNumber VARCHAR(50),
MasterClientEmail VARCHAR(100),
MasterClientContactPerson VARCHAR(100),
MasterClientContactPosition VARCHAR(100),
MasterClientBusinessField VARCHAR(100),
MasterClientIsActive BOOLEAN DEFAULT TRUE,
MasterClientCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterClientCreatedUserID INT,
MasterClientUpdatedAt DATETIME,
MasterClientUpdatedUserID INT,
MasterClientDeletedAt DATETIME,
MasterClientDeletedUserID INT
);
-- Master Personnel Table (Sampling Officers, Analysts, etc.)
-- Master Personnel Table
CREATE TABLE master_personnel (
personnel_id INT PRIMARY KEY AUTO_INCREMENT,
employee_id VARCHAR(50) NOT NULL,
name VARCHAR(100) NOT NULL,
position VARCHAR(100),
department VARCHAR(100),
email VARCHAR(100),
phone_number VARCHAR(50),
certifications TEXT,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
MasterPersonnelID INT PRIMARY KEY AUTO_INCREMENT,
MasterPersonnelEmployeeID VARCHAR(50) NOT NULL,
MasterPersonnelName VARCHAR(100) NOT NULL,
MasterPersonnelPosition VARCHAR(100),
MasterPersonnelDepartment VARCHAR(100),
MasterPersonnelEmail VARCHAR(100),
MasterPersonnelPhoneNumber VARCHAR(50),
MasterPersonnelCertifications TEXT,
MasterPersonnelIsActive BOOLEAN DEFAULT TRUE,
MasterPersonnelCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterPersonnelCreatedUserID INT,
MasterPersonnelUpdatedAt DATETIME,
MasterPersonnelUpdatedUserID INT,
MasterPersonnelDeletedAt DATETIME,
MasterPersonnelDeletedUserID INT
);
-- Master Measurement Equipment Table
-- Master Equipment Table
CREATE TABLE master_equipment (
equipment_id INT PRIMARY KEY AUTO_INCREMENT,
equipment_code VARCHAR(50) NOT NULL,
equipment_name VARCHAR(100) NOT NULL,
brand VARCHAR(100),
model VARCHAR(100),
serial_number VARCHAR(100),
calibration_date DATE,
next_calibration_date DATE,
parameter_id INT,
specifications TEXT,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (parameter_id) REFERENCES master_climate_parameters(parameter_id)
MasterEquipmentID INT PRIMARY KEY AUTO_INCREMENT,
MasterEquipmentCode VARCHAR(50) NOT NULL,
MasterEquipmentName VARCHAR(100) NOT NULL,
MasterEquipmentBrand VARCHAR(100),
MasterEquipmentModel VARCHAR(100),
MasterEquipmentSerialNumber VARCHAR(100),
MasterEquipmentCalibrationDate DATE,
MasterEquipmentNextCalibrationDate DATE,
MasterClimateParameterID INT,
MasterEquipmentSpecifications TEXT,
MasterEquipmentIsActive BOOLEAN DEFAULT TRUE,
MasterEquipmentCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterEquipmentCreatedUserID INT,
MasterEquipmentUpdatedAt DATETIME,
MasterEquipmentUpdatedUserID INT,
MasterEquipmentDeletedAt DATETIME,
MasterEquipmentDeletedUserID INT
);
-- Master Sampling Locations Table
CREATE TABLE master_sampling_locations (
location_id INT PRIMARY KEY AUTO_INCREMENT,
client_id INT,
location_name VARCHAR(200) NOT NULL,
address TEXT,
latitude DECIMAL(10, 8),
longitude DECIMAL(11, 8),
room_type VARCHAR(100),
description TEXT,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (client_id) REFERENCES master_clients(client_id)
MasterSamplingLocationID INT PRIMARY KEY AUTO_INCREMENT,
MasterClientID INT,
MasterSamplingLocationName VARCHAR(200) NOT NULL,
MasterSamplingLocationAddress TEXT,
MasterSamplingLocationLatitude DECIMAL(10,8),
MasterSamplingLocationLongitude DECIMAL(11,8),
MasterSamplingLocationRoomType VARCHAR(100),
MasterSamplingLocationDescription TEXT,
MasterSamplingLocationIsActive BOOLEAN DEFAULT TRUE,
MasterSamplingLocationCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterSamplingLocationCreatedUserID INT,
MasterSamplingLocationUpdatedAt DATETIME,
MasterSamplingLocationUpdatedUserID INT,
MasterSamplingLocationDeletedAt DATETIME,
MasterSamplingLocationDeletedUserID INT
);
-- Measurement Requests Table (Request Form)
-- Measurement Requests Table
CREATE TABLE measurement_requests (
request_id INT PRIMARY KEY AUTO_INCREMENT,
request_number VARCHAR(50) NOT NULL,
client_id INT,
request_date DATE,
planned_sampling_date DATE,
contact_person VARCHAR(100),
status VARCHAR(50), -- draft, submitted, approved, scheduled, completed, canceled
notes TEXT,
created_by INT,
approved_by INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (client_id) REFERENCES master_clients(client_id),
FOREIGN KEY (created_by) REFERENCES master_personnel(personnel_id),
FOREIGN KEY (approved_by) REFERENCES master_personnel(personnel_id)
MeasurementRequestID INT PRIMARY KEY AUTO_INCREMENT,
MeasurementRequestNumber VARCHAR(50) NOT NULL,
MasterClientID INT,
MeasurementRequestDate DATE,
MeasurementRequestPlannedDate DATE,
MeasurementRequestContactPerson VARCHAR(100),
MeasurementRequestStatus VARCHAR(50),
MeasurementRequestNotes TEXT,
MeasurementRequestCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MeasurementRequestCreatedUserID INT,
MeasurementRequestUpdatedAt DATETIME,
MeasurementRequestUpdatedUserID INT,
MeasurementRequestDeletedAt DATETIME,
MeasurementRequestDeletedUserID INT,
MeasurementRequestApprovedByID INT
);
-- Measurement Request Details Table
CREATE TABLE measurement_request_details (
detail_id INT PRIMARY KEY AUTO_INCREMENT,
request_id INT,
parameter_id INT,
location_id INT,
points_count INT DEFAULT 1,
unit_price DECIMAL(12, 2),
subtotal DECIMAL(12, 2),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (request_id) REFERENCES measurement_requests(request_id),
FOREIGN KEY (parameter_id) REFERENCES master_climate_parameters(parameter_id),
FOREIGN KEY (location_id) REFERENCES master_sampling_locations(location_id)
MeasurementRequestDetailID INT PRIMARY KEY AUTO_INCREMENT,
MeasurementRequestID INT,
MasterClimateParameterID INT,
MasterSamplingLocationID INT,
MeasurementRequestDetailPointCount INT DEFAULT 1,
MeasurementRequestDetailUnitPrice DECIMAL(12,2),
MeasurementRequestDetailSubtotal DECIMAL(12,2),
MeasurementRequestDetailCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MeasurementRequestDetailCreatedUserID INT,
MeasurementRequestDetailUpdatedAt DATETIME,
MeasurementRequestDetailUpdatedUserID INT,
MeasurementRequestDetailDeletedAt DATETIME,
MeasurementRequestDetailDeletedUserID INT
);
-- Measurement Schedules Table
CREATE TABLE measurement_schedules (
schedule_id INT PRIMARY KEY AUTO_INCREMENT,
schedule_number VARCHAR(50) NOT NULL,
request_id INT,
measurement_date DATE,
officer_id INT,
status VARCHAR(50), -- scheduled, completed, rescheduled, canceled
notes TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (request_id) REFERENCES measurement_requests(request_id),
FOREIGN KEY (officer_id) REFERENCES master_personnel(personnel_id)
MeasurementScheduleID INT PRIMARY KEY AUTO_INCREMENT,
MeasurementScheduleNumber VARCHAR(50) NOT NULL,
MeasurementRequestID INT,
MeasurementScheduleDate DATE,
MasterPersonnelID INT,
MeasurementScheduleStatus VARCHAR(50),
MeasurementScheduleNotes TEXT,
MeasurementScheduleCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MeasurementScheduleCreatedUserID INT,
MeasurementScheduleUpdatedAt DATETIME,
MeasurementScheduleUpdatedUserID INT,
MeasurementScheduleDeletedAt DATETIME,
MeasurementScheduleDeletedUserID INT
);
-- Test Reports Table
CREATE TABLE test_reports (
report_id INT PRIMARY KEY AUTO_INCREMENT,
report_number VARCHAR(50) NOT NULL,
request_id INT,
schedule_id INT,
measurement_date DATE,
issue_date DATE,
client_id INT,
officer_id INT,
verified_by INT,
approved_by INT,
status VARCHAR(50), -- draft, verification, approved, published, revised
page_count INT DEFAULT 1,
notes TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (request_id) REFERENCES measurement_requests(request_id),
FOREIGN KEY (schedule_id) REFERENCES measurement_schedules(schedule_id),
FOREIGN KEY (client_id) REFERENCES master_clients(client_id),
FOREIGN KEY (officer_id) REFERENCES master_personnel(personnel_id),
FOREIGN KEY (verified_by) REFERENCES master_personnel(personnel_id),
FOREIGN KEY (approved_by) REFERENCES master_personnel(personnel_id)
TestReportID INT PRIMARY KEY AUTO_INCREMENT,
TestReportNumber VARCHAR(50) NOT NULL,
MeasurementRequestID INT,
MeasurementScheduleID INT,
TestReportMeasurementDate DATE,
TestReportIssueDate DATE,
MasterClientID INT,
MasterPersonnelID INT,
TestReportVerifiedByID INT,
TestReportApprovedByID INT,
TestReportStatus VARCHAR(50),
TestReportPageCount INT DEFAULT 1,
TestReportNotes TEXT,
TestReportCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
TestReportCreatedUserID INT,
TestReportUpdatedAt DATETIME,
TestReportUpdatedUserID INT,
TestReportDeletedAt DATETIME,
TestReportDeletedUserID INT
);
-- Temperature Measurement Results Table
CREATE TABLE temperature_measurement_results (
result_id INT PRIMARY KEY AUTO_INCREMENT,
report_id INT,
location_id INT,
sample_code VARCHAR(50) NOT NULL,
measurement_time_start TIME,
measurement_time_end TIME,
parameter_id INT,
measurement_value DECIMAL(8, 2),
unit VARCHAR(20),
method VARCHAR(100),
threshold_id INT,
notes TEXT,
equipment_id INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (report_id) REFERENCES test_reports(report_id),
FOREIGN KEY (location_id) REFERENCES master_sampling_locations(location_id),
FOREIGN KEY (parameter_id) REFERENCES master_climate_parameters(parameter_id),
FOREIGN KEY (threshold_id) REFERENCES master_threshold_values(threshold_id),
FOREIGN KEY (equipment_id) REFERENCES master_equipment(equipment_id)
TemperatureMeasurementResultID INT PRIMARY KEY AUTO_INCREMENT,
TestReportID INT,
MasterSamplingLocationID INT,
TemperatureMeasurementResultSampleCode VARCHAR(50) NOT NULL,
TemperatureMeasurementResultStartTime TIME,
TemperatureMeasurementResultEndTime TIME,
MasterClimateParameterID INT,
TemperatureMeasurementResultValue DECIMAL(8,2),
TemperatureMeasurementResultUnit VARCHAR(20),
TemperatureMeasurementResultMethod VARCHAR(100),
MasterThresholdValueID INT,
TemperatureMeasurementResultNotes TEXT,
MasterEquipmentID INT,
TemperatureMeasurementResultCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
TemperatureMeasurementResultCreatedUserID INT,
TemperatureMeasurementResultUpdatedAt DATETIME,
TemperatureMeasurementResultUpdatedUserID INT,
TemperatureMeasurementResultDeletedAt DATETIME,
TemperatureMeasurementResultDeletedUserID INT
);
-- ================================
@@ -221,19 +245,32 @@ CREATE TABLE temperature_measurement_results (
-- ================================
-- Insert Regulations
INSERT INTO master_regulations (regulation_id, regulation_code, regulation_name, issuing_authority, regulation_type, issue_date, effective_date, description, file_path, is_active) VALUES
(1, 'PMK-02-2023', 'Ministry of Health Regulation No. 2 Year 2023', 'Ministry of Health of Indonesia', 'Ministerial Regulation', '2023-01-20', '2023-02-01', 'Regulation on Environmental Health Quality Standards and Health Requirements', '/documents/regulations/PMK_02_2023.pdf', TRUE),
(2, 'PERMENAKER-05-2018', 'Ministry of Manpower Regulation No. 5 Year 2018', 'Ministry of Manpower of Indonesia', 'Ministerial Regulation', '2018-04-25', '2018-05-10', 'Regulation on Occupational Safety and Health for the Work Environment', '/documents/regulations/PERMENAKER_05_2018.pdf', TRUE);
INSERT INTO master_regulations (
MasterRegulationID,
MasterRegulationCode,
MasterRegulationName,
MasterRegulationIssuingAuthority,
MasterRegulationType,
MasterRegulationIssueDate,
MasterRegulationEffectiveDate,
MasterRegulationDescription,
MasterRegulationFilePath,
MasterRegulationIsActive
) VALUES (
1, 'PMK-02-2023', 'Ministry of Health Regulation No. 2 Year 2023', 'Ministry of Health of Indonesia', 'Ministerial Regulation', '2023-01-20', '2023-02-01', 'Regulation on Environmental Health Quality Standards and Health Requirements', '/documents/regulations/PMK_02_2023.pdf', TRUE
), (
2, 'PERMENAKER-05-2018', 'Ministry of Manpower Regulation No. 5 Year 2018', 'Ministry of Manpower of Indonesia', 'Ministerial Regulation', '2018-04-25', '2018-05-10', 'Regulation on Occupational Safety and Health for the Work Environment', '/documents/regulations/PERMENAKER_05_2018.pdf', TRUE
);
-- Insert Climate Parameters
INSERT INTO master_climate_parameters (parameter_id, parameter_code, parameter_name, parameter_group, unit, analysis_method, description, price, is_active) VALUES
INSERT INTO master_climate_parameters (MasterClimateParameterID, MasterClimateParameterCode, MasterClimateParameterName, MasterClimateParameterGroup, MasterClimateParameterUnit, MasterClimateParameterMethod, MasterClimateParameterDescription, MasterClimateParameterPrice, MasterClimateParameterIsActive) VALUES
(1, 'TEMP', 'Temperature', 'Physical', '°C', 'SNI 7062: 2019', 'Work climate parameter for room temperature measurement', 75000.00, TRUE),
(2, 'HUMID', 'Humidity', 'Physical', '%RH', 'SNI 7062: 2019', 'Work climate parameter for relative humidity measurement', 75000.00, TRUE),
(3, 'WBGT', 'Wet Bulb Globe Temperature', 'Physical', '°C', 'SNI 7062: 2019', 'Work climate parameter for indoor/outdoor WBGT measurement', 100000.00, TRUE),
(4, 'AIRVEL', 'Air Velocity', 'Physical', 'm/s', 'SNI 7062: 2019', 'Work climate parameter for air velocity measurement', 75000.00, TRUE);
-- Insert Threshold Values for Temperature
INSERT INTO master_threshold_values (threshold_id, regulation_id, parameter_id, room_type, min_value, max_value, unit, description, is_active) VALUES
INSERT INTO master_threshold_values (MasterThresholdValueID, MasterRegulationID, MasterClimateParameterID, MasterThresholdValueRoomType, MasterThresholdValueMin, MasterThresholdValueMax, MasterThresholdValueUnit, MasterThresholdValueDescription, MasterThresholdValueIsActive) VALUES
(1, 1, 1, 'Administration', 20.00, 25.00, '°C', 'Administration and office work area', TRUE),
(2, 1, 1, 'Special Room', 18.00, 24.00, '°C', 'Server room, laboratory, etc.', TRUE),
(3, 1, 1, 'Production', 23.00, 26.00, '°C', 'Production area', TRUE),
@@ -242,27 +279,27 @@ INSERT INTO master_threshold_values (threshold_id, regulation_id, parameter_id,
(6, 1, 1, 'Storage', 16.00, 30.00, '°C', 'Storage room, warehouse', TRUE);
-- Insert Clients
INSERT INTO master_clients (client_id, client_code, client_name, address, city, province, postal_code, phone_number, email, contact_person, contact_position, business_field, is_active) VALUES
INSERT INTO master_clients (MasterClientID, MasterClientCode, MasterClientName, MasterClientAddress, MasterClientCity, MasterClientProvince, MasterClientPostalCode, MasterClientPhoneNumber, MasterClientEmail, MasterClientContactPerson, MasterClientContactPosition, MasterClientBusinessField, MasterClientIsActive) VALUES
(1, 'CLT-001', 'PT. Indonesia Manufacturing Industry', 'Jl. Industry Raya No. 123', 'Jakarta', 'DKI Jakarta', '12950', '021-5551234', 'contact@manufacturingindonesia.com', 'Budi Santoso', 'HSE Manager', 'Manufacturing', TRUE),
(2, 'CLT-002', 'PT. Digital Technology Nusantara', 'Jl. Gatot Subroto Kav. 52-53', 'Jakarta', 'DKI Jakarta', '12710', '021-5552345', 'hrd@dtn.co.id', 'Siti Rahma', 'HR Director', 'Information Technology', TRUE),
(3, 'CLT-003', 'City Public Hospital', 'Jl. Health No. 45', 'Bandung', 'West Java', '40112', '022-7654321', 'info@cityhospital.go.id', 'Dr. Ahmad Hidayat', 'Director', 'Healthcare', TRUE);
-- Insert Personnel
INSERT INTO master_personnel (personnel_id, employee_id, name, position, department, email, phone_number, certifications, is_active) VALUES
INSERT INTO master_personnel (MasterPersonnelID, MasterPersonnelEmployeeID, MasterPersonnelName, MasterPersonnelPosition, MasterPersonnelDepartment, MasterPersonnelEmail, MasterPersonnelPhoneNumber, MasterPersonnelCertifications, MasterPersonnelIsActive) VALUES
(1, 'EMP-001', 'Hendra Wijaya', 'Testing Supervisor', 'Laboratory', 'hendra@lab-env.co.id', '081234567890', 'Work Environment Sampling Certification', TRUE),
(2, 'EMP-002', 'Ratna Dewi', 'Senior Analyst', 'Laboratory', 'ratna@lab-env.co.id', '081234567891', 'Laboratory Analyst Certification, General OSH Certification', TRUE),
(3, 'EMP-003', 'Deni Hermawan', 'Sampling Officer', 'Laboratory', 'deni@lab-env.co.id', '081234567892', 'Test Sample Collection Certification', TRUE),
(4, 'EMP-004', 'Farida Nurhasanah', 'Laboratory Manager', 'Laboratory', 'farida@lab-env.co.id', '081234567893', 'Quality Manager Certification, OSH Certification', TRUE);
-- Insert Measurement Equipment
INSERT INTO master_equipment (equipment_id, equipment_code, equipment_name, brand, model, serial_number, calibration_date, next_calibration_date, parameter_id, specifications, is_active) VALUES
INSERT INTO master_equipment (MasterEquipmentID, MasterEquipmentCode, MasterEquipmentName, MasterEquipmentBrand, MasterEquipmentModel, MasterEquipmentSerialNumber, MasterEquipmentCalibrationDate, MasterEquipmentNextCalibrationDate, MasterClimateParameterID, MasterEquipmentSpecifications, MasterEquipmentIsActive) VALUES
(1, 'EQP-TH001', 'Thermohygrometer', 'Lutron', 'PHB-318', 'LT12345678', '2023-11-10', '2024-05-10', 1, 'Temperature range: -20°C to 60°C, accuracy ±0.8°C', TRUE),
(2, 'EQP-TH002', 'Thermohygrometer', 'Extech', 'RHT50', 'EX87654321', '2023-10-15', '2024-04-15', 1, 'Temperature range: -30°C to 70°C, accuracy ±0.5°C', TRUE),
(3, 'EQP-WBGT001', 'WBGT Meter', 'Lutron', 'WBGT-2010SD', 'LW12348765', '2023-11-05', '2024-05-05', 3, 'WBGT range: 15°C to 59°C, accuracy ±0.8°C', TRUE),
(4, 'EQP-ANM001', 'Anemometer', 'Lutron', 'AM-4214SD', 'LA23456789', '2023-09-20', '2024-03-20', 4, 'Air velocity range: 0.2 m/s to 35 m/s, accuracy ±2%', TRUE);
-- Insert Sampling Locations for PT. Indonesia Manufacturing Industry
INSERT INTO master_sampling_locations (location_id, client_id, location_name, address, room_type, description, is_active) VALUES
INSERT INTO master_sampling_locations (MasterSamplingLocationID, MasterClientID, MasterSamplingLocationName, MasterSamplingLocationAddress, MasterSamplingLocationRoomType, MasterSamplingLocationDescription, MasterSamplingLocationIsActive) VALUES
(1, 1, 'Main Meeting Room', 'Floor 2, Main Building', 'Administration', 'Meeting room with 20 person capacity', TRUE),
(2, 1, 'HR Work Area', 'Floor 2, Main Building', 'Administration', 'HR staff work area', TRUE),
(3, 1, 'Server Room', 'Floor 1, Main Building', 'Special Room', 'Server room with special cooling', TRUE),
@@ -274,29 +311,29 @@ INSERT INTO master_sampling_locations (location_id, client_id, location_name, ad
-- ================================
-- Measurement Request Example
INSERT INTO measurement_requests (request_id, request_number, client_id, request_date, planned_sampling_date, contact_person, status, notes, created_by, approved_by) VALUES
INSERT INTO measurement_requests (MeasurementRequestID, MeasurementRequestNumber, MasterClientID, MeasurementRequestDate, MeasurementRequestPlannedDate, MeasurementRequestContactPerson, MeasurementRequestStatus, MeasurementRequestNotes, MeasurementRequestCreatedUserID, MeasurementRequestApprovedByID) VALUES
(1, 'REQ/2024/04/001', 1, '2024-04-05', '2024-04-25', 'Budi Santoso', 'approved', 'Quarterly routine measurement for work climate parameters', 3, 4);
-- Request Details
INSERT INTO measurement_request_details (detail_id, request_id, parameter_id, location_id, points_count, unit_price, subtotal) VALUES
(1, 1, 1, 1, 1, 75000.00, 75000.00),
(2, 1, 1, 2, 1, 75000.00, 75000.00),
(3, 1, 1, 3, 1, 75000.00, 75000.00),
(4, 1, 1, 4, 1, 75000.00, 75000.00),
(5, 1, 1, 5, 1, 75000.00, 75000.00);
INSERT INTO measurement_request_details (MeasurementRequestDetailID, MeasurementRequestID, MasterClimateParameterID, MasterSamplingLocationID, MeasurementRequestDetailPointCount, MeasurementRequestDetailUnitPrice, MeasurementRequestDetailSubtotal, MeasurementRequestDetailCreatedUserID) VALUES
(1, 1, 1, 1, 1, 75000.00, 75000.00, 3),
(2, 1, 1, 2, 1, 75000.00, 75000.00, 3),
(3, 1, 1, 3, 1, 75000.00, 75000.00, 3),
(4, 1, 1, 4, 1, 75000.00, 75000.00, 3),
(5, 1, 1, 5, 1, 75000.00, 75000.00, 3);
-- Measurement Schedule
INSERT INTO measurement_schedules (schedule_id, schedule_number, request_id, measurement_date, officer_id, status, notes) VALUES
(1, 'SCH/2024/04/001', 1, '2024-04-25', 3, 'completed', 'Measurement conducted during normal operating hours');
INSERT INTO measurement_schedules (MeasurementScheduleID, MeasurementScheduleNumber, MeasurementRequestID, MeasurementScheduleDate, MasterPersonnelID, MeasurementScheduleStatus, MeasurementScheduleNotes, MeasurementScheduleCreatedUserID) VALUES
(1, 'SCH/2024/04/001', 1, '2024-04-25', 3, 'completed', 'Measurement conducted during normal operating hours', 3);
-- Test Report
INSERT INTO test_reports (report_id, report_number, request_id, schedule_id, measurement_date, issue_date, client_id, officer_id, verified_by, approved_by, status, page_count, notes) VALUES
(1, 'LHU/TEMP/04/2024/001', 1, 1, '2024-04-25', '2024-04-28', 1, 3, 2, 4, 'published', 2, 'Measurement results show all parameters within normal limits');
INSERT INTO test_reports (TestReportID, TestReportNumber, MeasurementRequestID, MeasurementScheduleID, TestReportMeasurementDate, TestReportIssueDate, MasterClientID, MasterPersonnelID, TestReportVerifiedByID, TestReportApprovedByID, TestReportStatus, TestReportPageCount, TestReportNotes, TestReportCreatedUserID) VALUES
(1, 'LHU/TEMP/04/2024/001', 1, 1, '2024-04-25', '2024-04-28', 1, 3, 2, 4, 'published', 2, 'Measurement results show all parameters within normal limits', 3);
-- Temperature Measurement Results
INSERT INTO temperature_measurement_results (result_id, report_id, location_id, sample_code, measurement_time_start, measurement_time_end, parameter_id, measurement_value, unit, method, threshold_id, notes, equipment_id) VALUES
(1, 1, 1, 'C2504090001', '09:00:00', '09:15:00', 1, 21.00, '°C', 'SNI 7062: 2019', 1, NULL, 1),
(2, 1, 2, 'C2504090002', '09:30:00', '09:45:00', 1, 22.00, '°C', 'SNI 7062: 2019', 1, NULL, 1),
(3, 1, 3, 'C2504090003', '10:00:00', '10:15:00', 1, 19.00, '°C', 'SNI 7062: 2019', 2, NULL, 1),
(4, 1, 4, 'C2504090004', '10:30:00', '10:45:00', 1, 26.00, '°C', 'SNI 7062: 2019', 3, NULL, 1),
(5, 1, 5, 'C2504090005', '11:00:00', '11:15:00', 1, 24.00, '°C', 'SNI 7062: 2019', 4, NULL, 1);
INSERT INTO temperature_measurement_results (TemperatureMeasurementResultID, TestReportID, MasterSamplingLocationID, TemperatureMeasurementResultSampleCode, TemperatureMeasurementResultStartTime, TemperatureMeasurementResultEndTime, MasterClimateParameterID, TemperatureMeasurementResultValue, TemperatureMeasurementResultUnit, TemperatureMeasurementResultMethod, MasterThresholdValueID, TemperatureMeasurementResultNotes, MasterEquipmentID, TemperatureMeasurementResultCreatedUserID) VALUES
(1, 1, 1, 'C2504090001', '09:00:00', '09:15:00', 1, 21.00, '°C', 'SNI 7062: 2019', 1, NULL, 1, 3),
(2, 1, 2, 'C2504090002', '09:30:00', '09:45:00', 1, 22.00, '°C', 'SNI 7062: 2019', 1, NULL, 1, 3),
(3, 1, 3, 'C2504090003', '10:00:00', '10:15:00', 1, 19.00, '°C', 'SNI 7062: 2019', 2, NULL, 1, 3),
(4, 1, 4, 'C2504090004', '10:30:00', '10:45:00', 1, 26.00, '°C', 'SNI 7062: 2019', 3, NULL, 1, 3),
(5, 1, 5, 'C2504090005', '11:00:00', '11:15:00', 1, 24.00, '°C', 'SNI 7062: 2019', 4, NULL, 1, 3);