@bslau/hmm_prisma_schema 1.22.0 → 1.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bslau/hmm_prisma_schema",
3
- "version": "1.22.0",
3
+ "version": "1.23.1",
4
4
  "main": "index.js",
5
5
  "author": "CIPA Development Team",
6
6
  "license": "ISC",
@@ -0,0 +1,49 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- AlterTable
6
+ ALTER TABLE [dbo].[Torpedo] ADD [fillLevelPercentage] INT NOT NULL CONSTRAINT [Torpedo_fillLevelPercentage_df] DEFAULT 0;
7
+
8
+ -- AlterTable
9
+ ALTER TABLE [dbo].[TorpedoTrip] ADD [totalMass] FLOAT(53) NOT NULL CONSTRAINT [TorpedoTrip_totalMass_df] DEFAULT 0;
10
+
11
+ -- CreateTable
12
+ CREATE TABLE [dbo].[HotMetalMass] (
13
+ [id] INT NOT NULL IDENTITY(1,1),
14
+ [mass] FLOAT(53) NOT NULL,
15
+ [hotMetalId] INT NOT NULL,
16
+ [hotMetalMassTypeId] INT NOT NULL,
17
+ [createdAt] DATETIME2 NOT NULL CONSTRAINT [HotMetalMass_createdAt_df] DEFAULT CURRENT_TIMESTAMP,
18
+ [updatedAt] DATETIME2 NOT NULL,
19
+ CONSTRAINT [HotMetalMass_pkey] PRIMARY KEY CLUSTERED ([id])
20
+ );
21
+
22
+ -- CreateTable
23
+ CREATE TABLE [dbo].[HotMetalMassType] (
24
+ [id] INT NOT NULL IDENTITY(1,1),
25
+ [name] NVARCHAR(1000) NOT NULL,
26
+ [label] NVARCHAR(1000) NOT NULL,
27
+ [type] NVARCHAR(1000) NOT NULL,
28
+ CONSTRAINT [HotMetalMassType_pkey] PRIMARY KEY CLUSTERED ([id]),
29
+ CONSTRAINT [HotMetalMassType_name_key] UNIQUE NONCLUSTERED ([name])
30
+ );
31
+
32
+ -- AddForeignKey
33
+ ALTER TABLE [dbo].[HotMetalMass] ADD CONSTRAINT [HotMetalMass_hotMetalId_fkey] FOREIGN KEY ([hotMetalId]) REFERENCES [dbo].[HotMetal]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
34
+
35
+ -- AddForeignKey
36
+ ALTER TABLE [dbo].[HotMetalMass] ADD CONSTRAINT [HotMetalMass_hotMetalMassTypeId_fkey] FOREIGN KEY ([hotMetalMassTypeId]) REFERENCES [dbo].[HotMetalMassType]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
37
+
38
+ COMMIT TRAN;
39
+
40
+ END TRY
41
+ BEGIN CATCH
42
+
43
+ IF @@TRANCOUNT > 0
44
+ BEGIN
45
+ ROLLBACK TRAN;
46
+ END;
47
+ THROW
48
+
49
+ END CATCH
@@ -0,0 +1,19 @@
1
+ BEGIN TRY
2
+
3
+ BEGIN TRAN;
4
+
5
+ -- AlterTable
6
+ ALTER TABLE [dbo].[HotMetalMass] ADD [steelmakingGradeName] NVARCHAR(1000);
7
+
8
+ COMMIT TRAN;
9
+
10
+ END TRY
11
+ BEGIN CATCH
12
+
13
+ IF @@TRANCOUNT > 0
14
+ BEGIN
15
+ ROLLBACK TRAN;
16
+ END;
17
+ THROW
18
+
19
+ END CATCH
@@ -271,6 +271,7 @@ model HotMetal {
271
271
  segmentResponseId String @unique
272
272
  hotMetalState HotMetalState? @relation(fields: [hotMetalStateId], references: [id])
273
273
  hotMetalStateId Int?
274
+ hotMetalMassCollection HotMetalMass[]
274
275
  hotMetalPouredCollection HotMetalPoured[]
275
276
  createdAt DateTime @default(now())
276
277
  updatedAt DateTime @updatedAt
@@ -308,6 +309,36 @@ model HotMetalLabResult {
308
309
  updatedAt DateTime @updatedAt
309
310
  }
310
311
 
312
+ /// **HOT METAL MASS**
313
+ ///
314
+ /// Provides information about when a _HotMetal_ batch mass is altered, what
315
+ /// type of change it was, and the mass of material that has been accounted
316
+ /// for. The intent is that these records form a history of a _HotMetal_
317
+ /// batch's mass alterations (whatever that may have been).
318
+ model HotMetalMass {
319
+ id Int @id @default(autoincrement())
320
+ mass Float
321
+ steelmakingGradeName String?
322
+ hotMetalId Int
323
+ hotMetal HotMetal @relation(references: [id], fields: [hotMetalId])
324
+ hotMetalMassType HotMetalMassType @relation(fields: [hotMetalMassTypeId], references: [id], onDelete: NoAction, onUpdate: Cascade)
325
+ hotMetalMassTypeId Int
326
+ createdAt DateTime @default(now())
327
+ updatedAt DateTime @updatedAt
328
+ }
329
+
330
+ /// **HOT METAL MASS TYPE**
331
+ ///
332
+ /// Defines the type of a _HotMetalMass_, which also indicates the type of
333
+ /// change to the batch - i.e. Addition, Subtraction, or new Total.
334
+ model HotMetalMassType {
335
+ id Int @id @default(autoincrement())
336
+ name String @unique
337
+ label String
338
+ type String // e.g. ADD, SUB, TOTAL
339
+ hotMetalMasses HotMetalMass[]
340
+ }
341
+
311
342
  /// **HOT METAL POURED**
312
343
  ///
313
344
  /// Provides information about when a _Hot Metal_ batch is poured, which _Pot_ it is poured into,
@@ -456,12 +487,9 @@ model Torpedo {
456
487
  sixPitRestrictionFlag Boolean @default(false)
457
488
  sixPitRestrictionEndTime DateTime? @db.DateTimeOffset
458
489
  status Int @default(2)
459
- // sixPitStart DateTime?
460
490
  capacityAverage Float?
461
491
  capacityNominal Float @default(200)
462
- // comments String?
463
- // emptyWeight Float?
464
- // gasStart DateTime?
492
+ fillLevelPercentage Int @default(0) // e.g. 0, 50, 80, 100
465
493
  hotMetalCollection HotMetal[]
466
494
  torpedoLocation TorpedoLocation?
467
495
  torpedoComments TorpedoComment[]
@@ -587,9 +615,9 @@ model TorpedoTimer {
587
615
  @@unique(name: "torpedo_torpedoTimerType_id", [torpedoId, torpedoTimerTypeId])
588
616
  }
589
617
 
590
- /// **TORPEDO TIMER**
618
+ /// **TORPEDO TIMER TYPE**
591
619
  ///
592
- /// Defines the type of a _TorpedoTimer_, can be HeatUp, OnGas, 6-Pit Swap, or 6-Pit Restriction
620
+ /// Defines the type of a _TorpedoTimer_, can be HeatUp, OnGas, 6-Pit Swap, or 6-Pit Restriction.
593
621
  model TorpedoTimerType {
594
622
  id Int @id @default(autoincrement())
595
623
  name String
@@ -612,6 +640,7 @@ model TorpedoTrip {
612
640
  torpedoId Int
613
641
  torpedoCampaign TorpedoCampaign @relation(fields: [torpedoCampaignId], references: [id], onDelete: NoAction, onUpdate: NoAction)
614
642
  torpedoCampaignId Int
643
+ totalMass Float @default(0)
615
644
  eventTorpedoCapacity EventTorpedoCapacity?
616
645
  eventsTorpedoMovement EventTorpedoMovement[]
617
646
  startTime DateTime @default(now()) @db.DateTimeOffset
package/prisma/seed.ts CHANGED
@@ -590,15 +590,15 @@ async function main() {
590
590
  }
591
591
 
592
592
  // SEED: TorpedoTimerType
593
- if ((await prisma.torpedoTimerType.count()>0)) {
593
+ if ((await prisma.torpedoTimerType.count()) > 0) {
594
594
  console.log("SEED: TorpedoTimerType - skipped.");
595
595
  } else {
596
596
  console.log("SEED: TorpedoTimerType - generating...");
597
597
 
598
- const createTorpedoTimeTypes = await prisma.torpedoTimerType.createMany({
598
+ const createTorpedoTimerTypes = await prisma.torpedoTimerType.createMany({
599
599
  data: [
600
600
  {
601
- name:"Heat Up",
601
+ name: "Heat Up",
602
602
  label: "Heat Up"
603
603
  },
604
604
  {
@@ -616,7 +616,51 @@ async function main() {
616
616
  ]
617
617
  })
618
618
 
619
- console.log({createTorpedoTimeTypes})
619
+ console.log({createTorpedoTimerTypes})
620
+ }
621
+
622
+ // SEED: HotMetalMassType
623
+ if ((await prisma.hotMetalMassType.count()) > 0) {
624
+ console.log("SEED: HotMetalMassType - skipped.");
625
+ } else {
626
+ console.log("SEED: HotMetalMassType - generating...");
627
+
628
+ const createHotMetalMassTypes = await prisma.hotMetalMassType.createMany({
629
+ data: [
630
+ {
631
+ name: "6PIT_ReturnedSteel",
632
+ label: "6-Pit - Returned Steel",
633
+ type: "ADD",
634
+ },
635
+ {
636
+ name: "BF_EstimatedMassLevel",
637
+ label: "Blast Furnace - Estimated Mass (Level Calculation)",
638
+ type: "TOTAL",
639
+ },
640
+ {
641
+ name: "BF_EstimatedMassSupplied",
642
+ label: "Blast Furnace - Estimated Mass (Supplied Value)",
643
+ type: "TOTAL",
644
+ },
645
+ {
646
+ name: "DUMP_TorpedoEmpty",
647
+ label: "21 Dump - Torpedo Empty",
648
+ type: "SUB",
649
+ },
650
+ {
651
+ name: "WB_TorpedoPour",
652
+ label: "Weighbridge - Torpedo Pour",
653
+ type: "SUB",
654
+ },
655
+ {
656
+ name: "WB_TorpedoPourManual",
657
+ label: "Weighbridge - Torpedo Pour (Manual)",
658
+ type: "SUB",
659
+ },
660
+ ],
661
+ });
662
+
663
+ console.log({createHotMetalMassTypes});
620
664
  }
621
665
 
622
666
  if (await prisma.messageType.count()>0) {