Merge branch 'ADBRimoFCP/update-for-rml' into 'master'
updated importing fcps for rml compatibility See merge request fronk/thetool!1611
This commit is contained in:
@@ -28,6 +28,10 @@ class ADBRimoFcpController extends TTCrud {
|
||||
$this->columns[0]['modal']['items'] = $netzgebiete;
|
||||
}
|
||||
|
||||
public function afterInit() {
|
||||
$this->model = ADBRimoFcp::class;
|
||||
}
|
||||
|
||||
public function ImportFCPsAction() {
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$fcpList = $input['data'] ?? [];
|
||||
@@ -37,20 +41,30 @@ class ADBRimoFcpController extends TTCrud {
|
||||
$now = date('U');
|
||||
|
||||
foreach ($fcpList as $fcpIn) {
|
||||
$rimoId = $fcpIn['ExternalID'] ?? null;
|
||||
if ($rimoId === null) $rimoId = $fcpIn['External ID'] ?? null;
|
||||
$rimoId = $fcpIn['ExternalID'] ?? $fcpIn['External ID'] ?? $fcpIn['Externe ID'] ?? null;
|
||||
if ($rimoId === null) continue;
|
||||
if (!is_numeric($networkAreaId)) {
|
||||
$netzgebiet = ADBNetzgebietModel::getFirst(['extref' =>
|
||||
explode(':', $fcpIn['FCP Cluster'] ?? '')[0] ?? 'DEFINETLY_NOT_A_VALID_EXTREF'
|
||||
]);
|
||||
|
||||
if ($netzgebiet) {
|
||||
$networkAreaId = $netzgebiet->id;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'netzgebiet_id' => $networkAreaId,
|
||||
'name' => $fcpIn['Name'] ?? null,
|
||||
'name' => $fcpIn['Name'] ?? $fcpIn['Name/ID'] ?? null,
|
||||
'rimo_id' => $rimoId,
|
||||
'label' => $fcpIn['User label'] ?? null,
|
||||
'building_type' => $fcpIn['Building type'] ?? null,
|
||||
'rimo_ex_state' => $fcpIn['Execution state'] ?? null,
|
||||
'rimo_op_state' => $fcpIn['Operational state'] ?? null,
|
||||
'gps_lat' => floatval(str_replace(',', '.', $fcpIn['Latitude'] ?? '0')),
|
||||
'gps_long' => floatval(str_replace(',', '.', $fcpIn['Longitude'] ?? '0')),
|
||||
'label' => $fcpIn['User label'] ?? $fcpIn['Bezeichnung'] ?? null,
|
||||
'building_type' => $fcpIn['Building type'] ?? $fcpIn['Typ'] ?? null,
|
||||
'rimo_ex_state' => $fcpIn['Execution state'] ?? $fcpIn['Ausführungsstatus'] ?? null,
|
||||
'rimo_op_state' => $fcpIn['Operational state'] ?? $fcpIn['Betriebszustand'] ?? null,
|
||||
'gps_lat' => isset($fcpIn['Latitude']) ? floatval(str_replace(',', '.', $fcpIn['Latitude'] ?? '0')) : null,
|
||||
'gps_long' => isset($fcpIn['Latitude']) ? floatval(str_replace(',', '.', $fcpIn['Longitude'] ?? '0')) : null,
|
||||
'edit' => $now
|
||||
];
|
||||
|
||||
@@ -79,9 +93,20 @@ class ADBRimoFcpController extends TTCrud {
|
||||
$counts = ['upd' => 0, 'fcpNF' => 0, 'noFCP' => 0, 'noExtId' => 0];
|
||||
|
||||
foreach ($input['data'] as $loc) {
|
||||
$fcpName = trim($loc['FCP cluster name'] ?? '');
|
||||
$extId = $loc['ExternalID'] ?? null;
|
||||
if ($extId === null) $extId = $loc['External ID'] ?? null;
|
||||
if (empty($fcpsByName)) {
|
||||
$fcpCluster = explode(':', $loc['FCP Cluster'] ?? '');
|
||||
$network = ADBNetzgebietModel::getFirst(['extref' => $fcpCluster[0] ?? '']);
|
||||
if ($network) {
|
||||
$fcpsByName = array_column(ADBRimoFcp::getAll(['netzgebiet_id' => $network->id]), null, 'name');
|
||||
} else {
|
||||
$counts['fcpNF']++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$fcpName = trim($loc['FCP cluster name'] ?? $loc['FCP Clustername'] ?? '');
|
||||
$extId = $loc['ExternalID'] ?? $loc['Externe ID'] ?? null;
|
||||
if ($extId === null) $extId = $loc['External ID'] ?? $loc['Externe ID'] ?? null;
|
||||
|
||||
|
||||
if ($fcpName === '') { $counts['noFCP']++; continue; }
|
||||
@@ -92,7 +117,7 @@ class ADBRimoFcpController extends TTCrud {
|
||||
if ($hn = ADBHausnummerModel::getFirst(['rimo_id' => $extId])) {
|
||||
$hn->fcp_id = $fcp->id;
|
||||
$hn->rimo_fcp_name = $fcp->name;
|
||||
$hn->save();
|
||||
$hn->save(["no_aftersave" => true]);
|
||||
$counts['upd']++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +81,10 @@ Vue.component('csv-import-modal', {
|
||||
this.errorMessage = 'Bitte wählen Sie zuerst eine Datei aus.';
|
||||
return;
|
||||
}
|
||||
if (this.showNetworkAreas && !this.selectedNetworkArea) {
|
||||
this.errorMessage = 'Bitte wählen Sie einen Netzbereich aus.';
|
||||
return;
|
||||
}
|
||||
// if (this.showNetworkAreas && !this.selectedNetworkArea) {
|
||||
// this.errorMessage = 'Bitte wählen Sie einen Netzbereich aus.';
|
||||
// return;
|
||||
// }
|
||||
this.errorMessage = null;
|
||||
this.loading = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user