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

@@ -1,218 +1,247 @@
-- Master Data untuk Pengelolaan Laporan Pengukuran Iklim Kerja Suhu
-- Berdasarkan PMK RI No.2 Tahun 2023
-- Master Tables
-- Tabel Master Regulasi
CREATE TABLE master_regulasi (
regulasi_id INT PRIMARY KEY AUTO_INCREMENT,
kode_regulasi VARCHAR(50) NOT NULL,
nama_regulasi VARCHAR(200) NOT NULL,
instansi_penerbit VARCHAR(100) NOT NULL,
tahun_terbit INT NOT NULL,
tanggal_berlaku DATE,
deskripsi 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
CREATE TABLE master_regulations (
MasterRegulationID INT PRIMARY KEY AUTO_INCREMENT,
MasterRegulationCode VARCHAR(50) NOT NULL,
MasterRegulationName VARCHAR(200) NOT NULL,
MasterRegulationIssuer VARCHAR(100) NOT NULL,
MasterRegulationYear INT NOT NULL,
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
);
-- Tabel Master Parameter Lingkungan Kerja
CREATE TABLE master_parameter (
parameter_id INT PRIMARY KEY AUTO_INCREMENT,
kode_parameter VARCHAR(50) NOT NULL,
nama_parameter VARCHAR(100) NOT NULL,
kelompok_parameter VARCHAR(50), -- Fisika, Kimia, Biologi
satuan VARCHAR(20),
metode_analisis VARCHAR(100),
deskripsi TEXT,
harga DECIMAL(12, 2),
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
-- Tabel Master Parameter
CREATE TABLE master_parameters (
MasterParameterID INT PRIMARY KEY AUTO_INCREMENT,
MasterParameterCode VARCHAR(50) NOT NULL,
MasterParameterName VARCHAR(100) NOT NULL,
MasterParameterGroup VARCHAR(50),
MasterParameterUnit VARCHAR(20),
MasterParameterMethod VARCHAR(100),
MasterParameterDescription TEXT,
MasterParameterPrice DECIMAL(12,2),
MasterParameterIsActive BOOLEAN DEFAULT TRUE,
MasterParameterCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterParameterCreatedUserID INT,
MasterParameterUpdatedAt DATETIME,
MasterParameterUpdatedUserID INT,
MasterParameterDeletedAt DATETIME,
MasterParameterDeletedUserID INT
);
-- Tabel Master Nilai Ambang Batas untuk Iklim Kerja
CREATE TABLE master_nilai_ambang_batas (
nab_id INT PRIMARY KEY AUTO_INCREMENT,
regulasi_id INT,
parameter_id INT,
tipe_ruangan VARCHAR(100) NOT NULL,
nilai_minimal DECIMAL(8, 2),
nilai_maksimal DECIMAL(8, 2),
satuan VARCHAR(20),
keterangan TEXT,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (regulasi_id) REFERENCES master_regulasi(regulasi_id),
FOREIGN KEY (parameter_id) REFERENCES master_parameter(parameter_id)
-- Tabel Master Nilai Ambang Batas
CREATE TABLE master_thresholds (
MasterThresholdID INT PRIMARY KEY AUTO_INCREMENT,
MasterRegulationID INT,
MasterParameterID INT,
MasterThresholdRoomType VARCHAR(100) NOT NULL,
MasterThresholdMinValue DECIMAL(8,2),
MasterThresholdMaxValue DECIMAL(8,2),
MasterThresholdUnit VARCHAR(20),
MasterThresholdRemarks TEXT,
MasterThresholdIsActive BOOLEAN DEFAULT TRUE,
MasterThresholdCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterThresholdCreatedUserID INT,
MasterThresholdUpdatedAt DATETIME,
MasterThresholdUpdatedUserID INT,
MasterThresholdDeletedAt DATETIME,
MasterThresholdDeletedUserID INT
);
-- Tabel Master Pelanggan
CREATE TABLE master_pelanggan (
pelanggan_id INT PRIMARY KEY AUTO_INCREMENT,
kode_pelanggan VARCHAR(50) NOT NULL,
nama_pelanggan VARCHAR(200) NOT NULL,
alamat TEXT,
kota VARCHAR(100),
provinsi VARCHAR(100),
kode_pos VARCHAR(20),
no_telepon VARCHAR(50),
email VARCHAR(100),
contact_person VARCHAR(100),
jabatan_contact VARCHAR(100),
bidang_usaha VARCHAR(100),
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
CREATE TABLE master_customers (
MasterCustomerID INT PRIMARY KEY AUTO_INCREMENT,
MasterCustomerCode VARCHAR(50) NOT NULL,
MasterCustomerName VARCHAR(200) NOT NULL,
MasterCustomerAddress TEXT,
MasterCustomerCity VARCHAR(100),
MasterCustomerProvince VARCHAR(100),
MasterCustomerPostalCode VARCHAR(20),
MasterCustomerPhone VARCHAR(50),
MasterCustomerEmail VARCHAR(100),
MasterCustomerContactPerson VARCHAR(100),
MasterCustomerContactPosition VARCHAR(100),
MasterCustomerBusinessField VARCHAR(100),
MasterCustomerIsActive BOOLEAN DEFAULT TRUE,
MasterCustomerCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterCustomerCreatedUserID INT,
MasterCustomerUpdatedAt DATETIME,
MasterCustomerUpdatedUserID INT,
MasterCustomerDeletedAt DATETIME,
MasterCustomerDeletedUserID INT
);
-- Tabel Master Personel (Petugas Sampling, Analis, dll)
CREATE TABLE master_personel (
personel_id INT PRIMARY KEY AUTO_INCREMENT,
nik VARCHAR(50) NOT NULL,
nama VARCHAR(100) NOT NULL,
jabatan VARCHAR(100),
departemen VARCHAR(100),
email VARCHAR(100),
no_telepon VARCHAR(50),
sertifikasi TEXT,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
-- Tabel Master Personel
CREATE TABLE master_personnel (
MasterPersonnelID INT PRIMARY KEY AUTO_INCREMENT,
MasterPersonnelNIK VARCHAR(50) NOT NULL,
MasterPersonnelName VARCHAR(100) NOT NULL,
MasterPersonnelPosition VARCHAR(100),
MasterPersonnelDepartment VARCHAR(100),
MasterPersonnelEmail VARCHAR(100),
MasterPersonnelPhone VARCHAR(50),
MasterPersonnelCertification TEXT,
MasterPersonnelIsActive BOOLEAN DEFAULT TRUE,
MasterPersonnelCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterPersonnelCreatedUserID INT,
MasterPersonnelUpdatedAt DATETIME,
MasterPersonnelUpdatedUserID INT,
MasterPersonnelDeletedAt DATETIME,
MasterPersonnelDeletedUserID INT
);
-- Tabel Master Peralatan Pengukuran
CREATE TABLE master_peralatan (
peralatan_id INT PRIMARY KEY AUTO_INCREMENT,
kode_peralatan VARCHAR(50) NOT NULL,
nama_peralatan VARCHAR(100) NOT NULL,
merk VARCHAR(100),
model VARCHAR(100),
nomor_seri VARCHAR(100),
tanggal_kalibrasi DATE,
tanggal_kalibrasi_selanjutnya DATE,
parameter_id INT,
spesifikasi 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_parameter(parameter_id)
-- Tabel Master Peralatan
CREATE TABLE master_equipment (
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,
MasterParameterID INT,
MasterEquipmentSpecification TEXT,
MasterEquipmentIsActive BOOLEAN DEFAULT TRUE,
MasterEquipmentCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MasterEquipmentCreatedUserID INT,
MasterEquipmentUpdatedAt DATETIME,
MasterEquipmentUpdatedUserID INT,
MasterEquipmentDeletedAt DATETIME,
MasterEquipmentDeletedUserID INT
);
-- Tabel Master Lokasi Sampling
CREATE TABLE master_lokasi_sampling (
lokasi_id INT PRIMARY KEY AUTO_INCREMENT,
pelanggan_id INT,
nama_lokasi VARCHAR(200) NOT NULL,
alamat TEXT,
koordinat_latitude DECIMAL(10, 8),
koordinat_longitude DECIMAL(11, 8),
jenis_ruangan VARCHAR(100),
deskripsi TEXT,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (pelanggan_id) REFERENCES master_pelanggan(pelanggan_id)
CREATE TABLE master_sampling_locations (
MasterSamplingLocationID INT PRIMARY KEY AUTO_INCREMENT,
MasterCustomerID 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
);
-- Tabel Permintaan Pengukuran (Form Request)
CREATE TABLE permintaan_pengukuran (
permintaan_id INT PRIMARY KEY AUTO_INCREMENT,
nomor_permintaan VARCHAR(50) NOT NULL,
pelanggan_id INT,
tanggal_permintaan DATE,
tanggal_rencana_sampling DATE,
contact_person VARCHAR(100),
status VARCHAR(50), -- draft, submitted, approved, scheduled, completed, canceled
catatan TEXT,
dibuat_oleh INT,
disetujui_oleh INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (pelanggan_id) REFERENCES master_pelanggan(pelanggan_id),
FOREIGN KEY (dibuat_oleh) REFERENCES master_personel(personel_id),
FOREIGN KEY (disetujui_oleh) REFERENCES master_personel(personel_id)
-- Transaction Tables
-- Tabel Permintaan Pengukuran
CREATE TABLE measurement_requests (
MeasurementRequestID INT PRIMARY KEY AUTO_INCREMENT,
MeasurementRequestNumber VARCHAR(50) NOT NULL,
MasterCustomerID INT,
MeasurementRequestDate DATE,
MeasurementRequestPlanDate DATE,
MeasurementRequestContactPerson VARCHAR(100),
MeasurementRequestStatus VARCHAR(50),
MeasurementRequestNotes TEXT,
MeasurementRequestCreatedBy INT,
MeasurementRequestApprovedBy INT,
MeasurementRequestCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
MeasurementRequestCreatedUserID INT,
MeasurementRequestUpdatedAt DATETIME,
MeasurementRequestUpdatedUserID INT,
MeasurementRequestDeletedAt DATETIME,
MeasurementRequestDeletedUserID INT
);
-- Tabel Detail Permintaan Pengukuran
CREATE TABLE detail_permintaan_pengukuran (
detail_permintaan_id INT PRIMARY KEY AUTO_INCREMENT,
permintaan_id INT,
parameter_id INT,
lokasi_id INT,
jumlah_titik INT DEFAULT 1,
harga_satuan 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 (permintaan_id) REFERENCES permintaan_pengukuran(permintaan_id),
FOREIGN KEY (parameter_id) REFERENCES master_parameter(parameter_id),
FOREIGN KEY (lokasi_id) REFERENCES master_lokasi_sampling(lokasi_id)
CREATE TABLE measurement_request_details (
MeasurementRequestDetailID INT PRIMARY KEY AUTO_INCREMENT,
MeasurementRequestID INT,
MasterParameterID 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
);
-- Tabel Jadwal Pengukuran
CREATE TABLE jadwal_pengukuran (
jadwal_id INT PRIMARY KEY AUTO_INCREMENT,
nomor_jadwal VARCHAR(50) NOT NULL,
permintaan_id INT,
tanggal_pengukuran DATE,
petugas_id INT,
status VARCHAR(50), -- scheduled, completed, rescheduled, canceled
catatan TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (permintaan_id) REFERENCES permintaan_pengukuran(permintaan_id),
FOREIGN KEY (petugas_id) REFERENCES master_personel(personel_id)
CREATE TABLE measurement_schedules (
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
);
-- Tabel Laporan Hasil Uji Iklim Kerja
CREATE TABLE laporan_hasil_uji (
laporan_id INT PRIMARY KEY AUTO_INCREMENT,
nomor_laporan VARCHAR(50) NOT NULL,
permintaan_id INT,
jadwal_id INT,
tanggal_pengukuran DATE,
tanggal_terbit DATE,
pelanggan_id INT,
petugas_id INT,
diverifikasi_oleh INT,
disetujui_oleh INT,
status VARCHAR(50), -- draft, verification, approved, published, revised
halaman_jumlah INT DEFAULT 1,
catatan TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (permintaan_id) REFERENCES permintaan_pengukuran(permintaan_id),
FOREIGN KEY (jadwal_id) REFERENCES jadwal_pengukuran(jadwal_id),
FOREIGN KEY (pelanggan_id) REFERENCES master_pelanggan(pelanggan_id),
FOREIGN KEY (petugas_id) REFERENCES master_personel(personel_id),
FOREIGN KEY (diverifikasi_oleh) REFERENCES master_personel(personel_id),
FOREIGN KEY (disetujui_oleh) REFERENCES master_personel(personel_id)
-- Tabel Laporan Hasil Uji
CREATE TABLE test_reports (
TestReportID INT PRIMARY KEY AUTO_INCREMENT,
TestReportNumber VARCHAR(50) NOT NULL,
MeasurementRequestID INT,
MeasurementScheduleID INT,
TestReportMeasurementDate DATE,
TestReportIssueDate DATE,
MasterCustomerID INT,
MasterPersonnelID INT,
TestReportVerifiedBy INT,
TestReportApprovedBy 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
);
-- Tabel Detail Hasil Pengukuran Iklim Kerja Suhu
CREATE TABLE hasil_pengukuran_suhu (
hasil_id INT PRIMARY KEY AUTO_INCREMENT,
laporan_id INT,
lokasi_id INT,
kode_sampel VARCHAR(50) NOT NULL,
waktu_pengukuran_mulai TIME,
waktu_pengukuran_selesai TIME,
parameter_id INT,
hasil_pengukuran DECIMAL(8, 2),
satuan VARCHAR(20),
metode VARCHAR(100),
nab_id INT,
keterangan TEXT,
peralatan_id INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (laporan_id) REFERENCES laporan_hasil_uji(laporan_id),
FOREIGN KEY (lokasi_id) REFERENCES master_lokasi_sampling(lokasi_id),
FOREIGN KEY (parameter_id) REFERENCES master_parameter(parameter_id),
FOREIGN KEY (nab_id) REFERENCES master_nilai_ambang_batas(nab_id),
FOREIGN KEY (peralatan_id) REFERENCES master_peralatan(peralatan_id)
-- Tabel Hasil Pengukuran Suhu
CREATE TABLE temperature_measurements (
TemperatureMeasurementID INT PRIMARY KEY AUTO_INCREMENT,
TestReportID INT,
MasterSamplingLocationID INT,
TemperatureMeasurementCode VARCHAR(50) NOT NULL,
TemperatureMeasurementStartTime TIME,
TemperatureMeasurementEndTime TIME,
MasterParameterID INT,
TemperatureMeasurementValue DECIMAL(8,2),
TemperatureMeasurementUnit VARCHAR(20),
TemperatureMeasurementMethod VARCHAR(100),
MasterThresholdID INT,
TemperatureMeasurementRemarks TEXT,
MasterEquipmentID INT,
TemperatureMeasurementCreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
TemperatureMeasurementCreatedUserID INT,
TemperatureMeasurementUpdatedAt DATETIME,
TemperatureMeasurementUpdatedUserID INT,
TemperatureMeasurementDeletedAt DATETIME,
TemperatureMeasurementDeletedUserID INT
);
-- ================================
@@ -220,19 +249,19 @@ CREATE TABLE hasil_pengukuran_suhu (
-- ================================
-- Insert Master Regulasi
INSERT INTO master_regulasi (regulasi_id, kode_regulasi, nama_regulasi, instansi_penerbit, tahun_terbit, tanggal_berlaku, deskripsi, file_path, is_active) VALUES
INSERT INTO master_regulations (MasterRegulationID, MasterRegulationCode, MasterRegulationName, MasterRegulationIssuer, MasterRegulationYear, MasterRegulationEffectiveDate, MasterRegulationDescription, MasterRegulationFilePath, MasterRegulationIsActive) VALUES
(1, 'PMK-02-2023', 'Peraturan Menteri Kesehatan Republik Indonesia Nomor 2 Tahun 2023', 'Kementerian Kesehatan RI', 2023, '2023-02-01', 'Peraturan mengenai Standar Baku Mutu Kesehatan Lingkungan dan Persyaratan Kesehatan', '/documents/regulasi/PMK_02_2023.pdf', TRUE),
(2, 'PERMENAKER-05-2018', 'Peraturan Menteri Ketenagakerjaan Republik Indonesia Nomor 5 Tahun 2018', 'Kementerian Ketenagakerjaan RI', 2018, '2018-05-10', 'Peraturan mengenai Keselamatan dan Kesehatan Kerja Lingkungan Kerja', '/documents/regulasi/PERMENAKER_05_2018.pdf', TRUE);
-- Insert Master Parameter
INSERT INTO master_parameter (parameter_id, kode_parameter, nama_parameter, kelompok_parameter, satuan, metode_analisis, deskripsi, harga, is_active) VALUES
INSERT INTO master_parameters (MasterParameterID, MasterParameterCode, MasterParameterName, MasterParameterGroup, MasterParameterUnit, MasterParameterMethod, MasterParameterDescription, MasterParameterPrice, MasterParameterIsActive) VALUES
(1, 'SUHU', 'Suhu', 'Fisika', '°C', 'SNI 7062: 2019', 'Parameter iklim kerja untuk pengukuran suhu ruangan', 75000.00, TRUE),
(2, 'KELEMBABAN', 'Kelembaban', 'Fisika', '%RH', 'SNI 7062: 2019', 'Parameter iklim kerja untuk pengukuran kelembaban relatif', 75000.00, TRUE),
(3, 'ISBB', 'Indeks Suhu Basah dan Bola', 'Fisika', '°C', 'SNI 7062: 2019', 'Parameter iklim kerja untuk pengukuran ISBB indoor/outdoor', 100000.00, TRUE),
(4, 'KECUDARA', 'Kecepatan Aliran Udara', 'Fisika', 'm/s', 'SNI 7062: 2019', 'Parameter iklim kerja untuk pengukuran kecepatan aliran udara', 75000.00, TRUE);
-- Insert Master Nilai Ambang Batas untuk Parameter Suhu
INSERT INTO master_nilai_ambang_batas (nab_id, regulasi_id, parameter_id, tipe_ruangan, nilai_minimal, nilai_maksimal, satuan, keterangan, is_active) VALUES
INSERT INTO master_thresholds (MasterThresholdID, MasterRegulationID, MasterParameterID, MasterThresholdRoomType, MasterThresholdMinValue, MasterThresholdMaxValue, MasterThresholdUnit, MasterThresholdRemarks, MasterThresholdIsActive) VALUES
(1, 1, 1, 'Administrasi', 20.00, 25.00, '°C', 'Ruang kerja administrasi dan perkantoran', TRUE),
(2, 1, 1, 'Ruangan Khusus', 18.00, 24.00, '°C', 'Ruang server, laboratorium, dll', TRUE),
(3, 1, 1, 'Produksi', 23.00, 26.00, '°C', 'Ruang produksi', TRUE),
@@ -241,43 +270,43 @@ INSERT INTO master_nilai_ambang_batas (nab_id, regulasi_id, parameter_id, tipe_r
(6, 1, 1, 'Gudang', 16.00, 30.00, '°C', 'Ruang penyimpanan, gudang', TRUE);
-- Insert Master Pelanggan
INSERT INTO master_pelanggan (pelanggan_id, kode_pelanggan, nama_pelanggan, alamat, kota, provinsi, kode_pos, no_telepon, email, contact_person, jabatan_contact, bidang_usaha, is_active) VALUES
INSERT INTO master_customers (MasterCustomerID, MasterCustomerCode, MasterCustomerName, MasterCustomerAddress, MasterCustomerCity, MasterCustomerProvince, MasterCustomerPostalCode, MasterCustomerPhone, MasterCustomerEmail, MasterCustomerContactPerson, MasterCustomerContactPosition, MasterCustomerBusinessField, MasterCustomerIsActive) VALUES
(1, 'PLG-001', 'PT. Industri Manufaktur Indonesia', 'Jl. Industri Raya No. 123', 'Jakarta', 'DKI Jakarta', '12950', '021-5551234', 'contact@manufakturindonesia.com', 'Budi Santoso', 'HSE Manager', 'Manufaktur', TRUE),
(2, 'PLG-002', 'PT. Teknologi Digital Nusantara', 'Jl. Gatot Subroto Kav. 52-53', 'Jakarta', 'DKI Jakarta', '12710', '021-5552345', 'hrd@tdn.co.id', 'Siti Rahma', 'HR Director', 'Teknologi Informasi', TRUE),
(3, 'PLG-003', 'RSUD Kota Sehat', 'Jl. Kesehatan No. 45', 'Bandung', 'Jawa Barat', '40112', '022-7654321', 'info@rsudkotasehat.go.id', 'dr. Ahmad Hidayat', 'Direktur', 'Kesehatan', TRUE);
-- Insert Master Personel
INSERT INTO master_personel (personel_id, nik, nama, jabatan, departemen, email, no_telepon, sertifikasi, is_active) VALUES
INSERT INTO master_personnel (MasterPersonnelID, MasterPersonnelNIK, MasterPersonnelName, MasterPersonnelPosition, MasterPersonnelDepartment, MasterPersonnelEmail, MasterPersonnelPhone, MasterPersonnelCertification, MasterPersonnelIsActive) VALUES
(1, 'EMP-001', 'Hendra Wijaya', 'Supervisor Pengujian', 'Laboratorium', 'hendra@lab-env.co.id', '081234567890', 'Sertifikasi Pengambilan Contoh Uji Lingkungan Kerja', TRUE),
(2, 'EMP-002', 'Ratna Dewi', 'Analis Senior', 'Laboratorium', 'ratna@lab-env.co.id', '081234567891', 'Sertifikasi Analis Laboratorium, Ahli K3 Umum', TRUE),
(3, 'EMP-003', 'Deni Hermawan', 'Petugas Sampling', 'Laboratorium', 'deni@lab-env.co.id', '081234567892', 'Sertifikasi Pengambilan Contoh Uji', TRUE),
(4, 'EMP-004', 'Farida Nurhasanah', 'Manager Laboratorium', 'Laboratorium', 'farida@lab-env.co.id', '081234567893', 'Sertifikasi Manager Mutu, Sertifikasi Ahli K3', TRUE);
-- Insert Master Peralatan Pengukuran
INSERT INTO master_peralatan (peralatan_id, kode_peralatan, nama_peralatan, merk, model, nomor_seri, tanggal_kalibrasi, tanggal_kalibrasi_selanjutnya, parameter_id, spesifikasi, is_active) VALUES
-- Insert Master Peralatan
INSERT INTO master_equipment (MasterEquipmentID, MasterEquipmentCode, MasterEquipmentName, MasterEquipmentBrand, MasterEquipmentModel, MasterEquipmentSerialNumber, MasterEquipmentCalibrationDate, MasterEquipmentNextCalibrationDate, MasterParameterID, MasterEquipmentSpecification, MasterEquipmentIsActive) VALUES
(1, 'EQP-TH001', 'Thermohygrometer', 'Lutron', 'PHB-318', 'LT12345678', '2023-11-10', '2024-05-10', 1, 'Range suhu: -20°C hingga 60°C, akurasi ±0.8°C', TRUE),
(2, 'EQP-TH002', 'Thermohygrometer', 'Extech', 'RHT50', 'EX87654321', '2023-10-15', '2024-04-15', 1, 'Range suhu: -30°C hingga 70°C, akurasi ±0.5°C', TRUE),
(3, 'EQP-WBGT001', 'WBGT Meter', 'Lutron', 'WBGT-2010SD', 'LW12348765', '2023-11-05', '2024-05-05', 3, 'Range WBGT: 15°C hingga 59°C, akurasi ±0.8°C', TRUE),
(4, 'EQP-ANM001', 'Anemometer', 'Lutron', 'AM-4214SD', 'LA23456789', '2023-09-20', '2024-03-20', 4, 'Range kecepatan udara: 0.2 m/s hingga 35 m/s, akurasi ±2%', TRUE);
-- Insert Master Lokasi Sampling untuk PT. Industri Manufaktur Indonesia
INSERT INTO master_lokasi_sampling (lokasi_id, pelanggan_id, nama_lokasi, alamat, jenis_ruangan, deskripsi, is_active) VALUES
(1, 1, 'Ruang Meeting Utama', 'Lantai 2, Gedung Utama', 'Administrasi', 'Ruang meeting dengan kapasitas 20 orang', TRUE),
(2, 1, 'Ruang Kerja HRD', 'Lantai 2, Gedung Utama', 'Administrasi', 'Ruang kerja staff HRD', TRUE),
(3, 1, 'Ruang Server', 'Lantai 1, Gedung Utama', 'Ruangan Khusus', 'Ruang server dengan pendingin khusus', TRUE),
(4, 1, 'Area Produksi Line A', 'Lantai 1, Gedung Produksi', 'Produksi', 'Area produksi utama line A', TRUE),
(5, 1, 'Area Kantin', 'Lantai 1, Gedung Pendukung', 'Ruang Umum', 'Kantin karyawan dengan kapasitas 100 orang', TRUE);
INSERT INTO master_sampling_locations (MasterSamplingLocationID, MasterCustomerID, MasterSamplingLocationName, MasterSamplingLocationAddress, MasterSamplingLocationLatitude, MasterSamplingLocationLongitude, MasterSamplingLocationRoomType, MasterSamplingLocationDescription, MasterSamplingLocationIsActive) VALUES
(1, 1, 'Ruang Meeting Utama', 'Lantai 2, Gedung Utama', 0.00000000, 0.00000000, 'Administrasi', 'Ruang meeting dengan kapasitas 20 orang', TRUE),
(2, 1, 'Ruang Kerja HRD', 'Lantai 2, Gedung Utama', 0.00000000, 0.00000000, 'Administrasi', 'Ruang kerja staff HRD', TRUE),
(3, 1, 'Ruang Server', 'Lantai 1, Gedung Utama', 0.00000000, 0.00000000, 'Ruangan Khusus', 'Ruang server dengan pendingin khusus', TRUE),
(4, 1, 'Area Produksi Line A', 'Lantai 1, Gedung Produksi', 0.00000000, 0.00000000, 'Produksi', 'Area produksi utama line A', TRUE),
(5, 1, 'Area Kantin', 'Lantai 1, Gedung Pendukung', 0.00000000, 0.00000000, 'Ruang Umum', 'Kantin karyawan dengan kapasitas 100 orang', TRUE);
-- ================================
-- CONTOH DATA TRANSAKSI
-- ================================
-- Contoh Permintaan Pengukuran
INSERT INTO permintaan_pengukuran (permintaan_id, nomor_permintaan, pelanggan_id, tanggal_permintaan, tanggal_rencana_sampling, contact_person, status, catatan, dibuat_oleh, disetujui_oleh) VALUES
INSERT INTO measurement_requests (MeasurementRequestID, MeasurementRequestNumber, MasterCustomerID, MeasurementRequestDate, MeasurementRequestPlanDate, MeasurementRequestContactPerson, MeasurementRequestStatus, MeasurementRequestNotes, MeasurementRequestCreatedBy, MeasurementRequestApprovedBy) VALUES
(1, 'REQ/2024/04/001', 1, '2024-04-05', '2024-04-25', 'Budi Santoso', 'approved', 'Pengukuran rutin triwulanan untuk parameter iklim kerja', 3, 4);
-- Contoh Detail Permintaan Pengukuran
INSERT INTO detail_permintaan_pengukuran (detail_permintaan_id, permintaan_id, parameter_id, lokasi_id, jumlah_titik, harga_satuan, subtotal) VALUES
INSERT INTO measurement_request_details (MeasurementRequestDetailID, MeasurementRequestID, MasterParameterID, MasterSamplingLocationID, MeasurementRequestDetailPointCount, MeasurementRequestDetailUnitPrice, MeasurementRequestDetailSubtotal) 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),
@@ -285,15 +314,15 @@ INSERT INTO detail_permintaan_pengukuran (detail_permintaan_id, permintaan_id, p
(5, 1, 1, 5, 1, 75000.00, 75000.00);
-- Contoh Jadwal Pengukuran
INSERT INTO jadwal_pengukuran (jadwal_id, nomor_jadwal, permintaan_id, tanggal_pengukuran, petugas_id, status, catatan) VALUES
INSERT INTO measurement_schedules (MeasurementScheduleID, MeasurementScheduleNumber, MeasurementRequestID, MeasurementScheduleDate, MasterPersonnelID, MeasurementScheduleStatus, MeasurementScheduleNotes) VALUES
(1, 'SCH/2024/04/001', 1, '2024-04-25', 3, 'completed', 'Pengukuran dilakukan pada jam operasional normal');
-- Contoh Laporan Hasil Uji
INSERT INTO laporan_hasil_uji (laporan_id, nomor_laporan, permintaan_id, jadwal_id, tanggal_pengukuran, tanggal_terbit, pelanggan_id, petugas_id, diverifikasi_oleh, disetujui_oleh, status, halaman_jumlah, catatan) VALUES
INSERT INTO test_reports (TestReportID, TestReportNumber, MeasurementRequestID, MeasurementScheduleID, TestReportMeasurementDate, TestReportIssueDate, MasterCustomerID, MasterPersonnelID, TestReportVerifiedBy, TestReportApprovedBy, TestReportStatus, TestReportPageCount, TestReportNotes) VALUES
(1, 'LHU/KLIM/04/2024/001', 1, 1, '2024-04-25', '2024-04-28', 1, 3, 2, 4, 'published', 2, 'Hasil pengukuran menunjukkan semua parameter dalam batas normal');
-- Contoh Hasil Pengukuran Suhu
INSERT INTO hasil_pengukuran_suhu (hasil_id, laporan_id, lokasi_id, kode_sampel, waktu_pengukuran_mulai, waktu_pengukuran_selesai, parameter_id, hasil_pengukuran, satuan, metode, nab_id, keterangan, peralatan_id) VALUES
INSERT INTO temperature_measurements (TemperatureMeasurementID, TestReportID, MasterSamplingLocationID, TemperatureMeasurementCode, TemperatureMeasurementStartTime, TemperatureMeasurementEndTime, MasterParameterID, TemperatureMeasurementValue, TemperatureMeasurementUnit, TemperatureMeasurementMethod, MasterThresholdID, TemperatureMeasurementRemarks, MasterEquipmentID) 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),