Fixed counting homes in Rimo Import
This commit is contained in:
@@ -182,7 +182,10 @@ class AddressHelper
|
|||||||
|
|
||||||
$addr_dbg_str = "strasse_hausnummer: $strasse_hausnummer | zusatz: $addresszusatz | gemkz: $gem_kz | gem_name: $gem_name | ort_name: $ort_name | plz_name: $plz_name | adrcd: $adr | $rimo_id";
|
$addr_dbg_str = "strasse_hausnummer: $strasse_hausnummer | zusatz: $addresszusatz | gemkz: $gem_kz | gem_name: $gem_name | ort_name: $ort_name | plz_name: $plz_name | adrcd: $adr | $rimo_id";
|
||||||
|
|
||||||
if (!$hausnummer_name || !$gem_name || !$plz_name || !$ort_name || !$strasse_name) {
|
// try to find by rimo_id
|
||||||
|
$hausnummer = ADBHausnummerModel::getFirst(["rimo_id" => $rimo_id]);
|
||||||
|
|
||||||
|
if (!$hausnummer && (!$hausnummer_name || !$gem_name || !$plz_name || !$ort_name || !$strasse_name)) {
|
||||||
$this->logFindAddressError("[WW] Adressbestandteil fehlt ($addr_dbg_str)");
|
$this->logFindAddressError("[WW] Adressbestandteil fehlt ($addr_dbg_str)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -214,13 +217,6 @@ class AddressHelper
|
|||||||
}
|
}
|
||||||
$gemeinde_id = $gemeinde->id;
|
$gemeinde_id = $gemeinde->id;
|
||||||
|
|
||||||
|
|
||||||
$hausnummer = ADBHausnummerModel::getFirst(["rimo_id" => $rimo_id]);
|
|
||||||
|
|
||||||
/*if($hausnummer) {
|
|
||||||
echo "found hausnummer from rimo_id $rimo_id\n";
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$force_subcd = false;
|
$force_subcd = false;
|
||||||
$force_no_subcd = false;
|
$force_no_subcd = false;
|
||||||
|
|
||||||
|
|||||||
@@ -307,10 +307,13 @@ foreach ($clusters as $cluster_data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$plannedTU = $building->plannedTU;
|
$rimo_home_count = 0;
|
||||||
$to_create_count = $building->plannedTU - count($existing_units);
|
if (property_exists($building->homes, "item") && is_array($building->homes->item) && count($building->homes->item)) {
|
||||||
|
$rimo_home_count = count($building->homes->item);
|
||||||
|
}
|
||||||
|
$to_create_count = $rimo_home_count - count($existing_units);
|
||||||
|
|
||||||
if ($plannedTU && $to_create_count > 0) {
|
if ($rimo_home_count && $to_create_count > 0) {
|
||||||
for ($i = 0; $i < $to_create_count; $i++) {
|
for ($i = 0; $i < $to_create_count; $i++) {
|
||||||
$unit = \ADBWohneinheitModel::create([
|
$unit = \ADBWohneinheitModel::create([
|
||||||
"hausnummer_id" => $hausnummer->id,
|
"hausnummer_id" => $hausnummer->id,
|
||||||
@@ -375,12 +378,12 @@ foreach ($clusters as $cluster_data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$unit = new \ADBWohneinheit($unit->id);
|
//$unit = new \ADBWohneinheit($unit->id);
|
||||||
\mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$hausnummer->id, 0);
|
\mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$hausnummer->id, 0);
|
||||||
\mfValuecache::singleton()->set("adbwohneinheit-save-nesting-level-".$unit->id, 0);
|
\mfValuecache::singleton()->set("adbwohneinheit-save-nesting-level-".$unit->id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$unit = new \ADBWohneinheit($unit->id);
|
//$unit = new \ADBWohneinheit($unit->id);
|
||||||
if($unit->rimo_deleted) {
|
if($unit->rimo_deleted) {
|
||||||
$unit->rimo_deleted = 0;
|
$unit->rimo_deleted = 0;
|
||||||
$unit->save(["no_updates" => 1]);
|
$unit->save(["no_updates" => 1]);
|
||||||
@@ -391,7 +394,7 @@ foreach ($clusters as $cluster_data) {
|
|||||||
if (!$unit->save()) {
|
if (!$unit->save()) {
|
||||||
die("Error saving new extref on unit\n" . print_r($home, true));
|
die("Error saving new extref on unit\n" . print_r($home, true));
|
||||||
}
|
}
|
||||||
$unit = new \ADBWohneinheit($unit->id);
|
//$unit = new \ADBWohneinheit($unit->id);
|
||||||
\mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$hausnummer->id, 0);
|
\mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$hausnummer->id, 0);
|
||||||
\mfValuecache::singleton()->set("adbwohneinheit-save-nesting-level-".$unit->id, 0);
|
\mfValuecache::singleton()->set("adbwohneinheit-save-nesting-level-".$unit->id, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user