fix(adminui): show + clarify driver-less equipment across list/import (Task 1 review)
This commit is contained in:
+2
@@ -24,6 +24,8 @@ namespace ZB.MOM.WW.OtOpcUa.Configuration.Migrations
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
// WARNING: this rollback converts any existing NULL (driver-less) rows to "" for DriverInstanceId.
|
||||
// Only safe when no driver-less equipment exists in the database.
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "DriverInstanceId",
|
||||
table: "Equipment",
|
||||
|
||||
+8
-1
@@ -83,8 +83,15 @@ else
|
||||
await using var db = await DbFactory.CreateDbContextAsync();
|
||||
var driversInCluster = db.DriverInstances.AsNoTracking()
|
||||
.Where(d => d.ClusterId == ClusterId).Select(d => d.DriverInstanceId);
|
||||
// Driver-less equipment (DriverInstanceId == null) has no DriverInstance FK.
|
||||
// Scope it to this cluster via UnsLine → UnsArea.ClusterId instead.
|
||||
var areaIds = db.UnsAreas.AsNoTracking()
|
||||
.Where(a => a.ClusterId == ClusterId).Select(a => a.UnsAreaId);
|
||||
var linesInCluster = db.UnsLines.AsNoTracking()
|
||||
.Where(l => areaIds.Contains(l.UnsAreaId)).Select(l => l.UnsLineId);
|
||||
_rows = await db.Equipment.AsNoTracking()
|
||||
.Where(e => driversInCluster.Contains(e.DriverInstanceId))
|
||||
.Where(e => driversInCluster.Contains(e.DriverInstanceId)
|
||||
|| (e.DriverInstanceId == null && linesInCluster.Contains(e.UnsLineId)))
|
||||
.OrderBy(e => e.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@@ -108,6 +108,9 @@
|
||||
private bool _busy;
|
||||
private string? _error;
|
||||
|
||||
// Bulk import requires a DriverInstanceId by design — every CSV row must reference an existing driver.
|
||||
// Driver-less equipment (DriverInstanceId == null) is not supported via bulk import;
|
||||
// create it via the single-add editor (/clusters/{id}/equipment/new) or the SQL loader.
|
||||
private static readonly string[] RequiredColumns = ["Name", "MachineCode", "UnsLineId", "DriverInstanceId"];
|
||||
private static readonly string[] OptionalColumns = ["ZTag", "SAPID", "Manufacturer", "Model"];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user