add aha blatt parsing
This commit is contained in:
@@ -16,6 +16,7 @@ class WorkorderModel extends TTCrudBaseModel
|
||||
public ?string $additionalInfo;
|
||||
public ?string $cableLength;
|
||||
public ?string $cableType;
|
||||
public ?string $metadata;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
|
||||
@@ -199,4 +200,62 @@ class WorkorderModel extends TTCrudBaseModel
|
||||
$result = $db->query($sql);
|
||||
return $result ? $result->fetch_assoc()['count'] : 0;
|
||||
}
|
||||
|
||||
public static function getTechnicalData(int $workorderId): ?array {
|
||||
$workorder = self::get($workorderId);
|
||||
if (!$workorder || !$workorder->preorderId) return null;
|
||||
|
||||
$preorder = new Preorder($workorder->preorderId);
|
||||
if (!$preorder->id || !$preorder->adb_wohneinheit_id) return null;
|
||||
|
||||
$wohneinheit = $preorder->adb_wohneinheit;
|
||||
if (!$wohneinheit) return null;
|
||||
|
||||
$defaultCluster = '';
|
||||
if ($preorder->adb_hausnummer && $preorder->adb_hausnummer->netzgebiet) {
|
||||
$defaultCluster = $preorder->adb_hausnummer->netzgebiet->extref ?? '';
|
||||
}
|
||||
|
||||
$patchposition = [
|
||||
'equipmentName' => $wohneinheit->getPatchEqString(),
|
||||
'equipmentPort' => $wohneinheit->patch_port,
|
||||
'cluster' => $wohneinheit->patch_cluster ?: $defaultCluster,
|
||||
'shelf' => $wohneinheit->patch_shelf,
|
||||
'module' => $wohneinheit->patch_module,
|
||||
];
|
||||
|
||||
// Get dropcable data from metadata
|
||||
$dropkabelData = [];
|
||||
$ahaParsed = null;
|
||||
$mapFile = null;
|
||||
if (!empty($workorder->metadata)) {
|
||||
$metadata = json_decode($workorder->metadata, true);
|
||||
if (!empty($metadata['dropcable'])) {
|
||||
$ahaParsed = $metadata['dropcable']['parsed_at'] ?? null;
|
||||
$dropkabelData = $metadata['dropcable']['entries'] ?? [];
|
||||
if ($mapFileId = $metadata['dropcable']['map_file_id'] ?? null) {
|
||||
$file = new File($mapFileId);
|
||||
if ($file->id) {
|
||||
$mapFile = ['id' => $file->id, 'name' => $file->name, 'download_url' => '/File/show?id=' . $file->id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rimoWorkorders = [];
|
||||
if (is_array($wohneinheit->rimo_workorders) && count($wohneinheit->rimo_workorders)) {
|
||||
foreach ($wohneinheit->rimo_workorders as $wo) {
|
||||
$rimoWorkorders[] = [
|
||||
'id' => $wo->id, 'rimoName' => $wo->rimo_name, 'rimoId' => $wo->rimo_id,
|
||||
'rimoStatus' => $wo->rimo_status, 'downloadUrl' => "/RimoWorkorder/downloadAha?id=" . $wo->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'patchposition' => $patchposition,
|
||||
'rimoWorkorders' => $rimoWorkorders,
|
||||
'dropcable' => ['parsed_at' => $ahaParsed, 'entries' => $dropkabelData, 'map_file' => $mapFile],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user