Fixed not creating OAID in rimo-import when requested
This commit is contained in:
@@ -57,7 +57,7 @@ class ADBNetzgebietModel {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAll() {
|
public static function getAll($indexed_by_id = false) {
|
||||||
$items = [];
|
$items = [];
|
||||||
|
|
||||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||||
@@ -65,7 +65,12 @@ class ADBNetzgebietModel {
|
|||||||
$res = $db->select("Netzgebiet", "*", "1=1 ORDER BY name");
|
$res = $db->select("Netzgebiet", "*", "1=1 ORDER BY name");
|
||||||
if($db->num_rows($res)) {
|
if($db->num_rows($res)) {
|
||||||
while($data = $db->fetch_object($res)) {
|
while($data = $db->fetch_object($res)) {
|
||||||
$items[] = new ADBNetzgebiet($data);
|
if($indexed_by_id) {
|
||||||
|
$items[$data->id] = new ADBNetzgebiet($data);
|
||||||
|
} else {
|
||||||
|
$items[] = new ADBNetzgebiet($data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $items;
|
return $items;
|
||||||
@@ -102,7 +107,7 @@ class ADBNetzgebietModel {
|
|||||||
if(is_array($limit) && count($limit)) {
|
if(is_array($limit) && count($limit)) {
|
||||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||||
} elseif(is_numeric($count)) {
|
} elseif(is_numeric($limit['count'])) {
|
||||||
$sql .= " LIMIT ".$limit['count'];
|
$sql .= " LIMIT ".$limit['count'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -651,6 +651,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$addresses = [];
|
$addresses = [];
|
||||||
|
$netzgebiete = ADBNetzgebietModel::getAll(true);
|
||||||
|
|
||||||
$where = "1=1";
|
$where = "1=1";
|
||||||
|
|
||||||
@@ -699,6 +700,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
|||||||
if($this->db()->num_rows($res)) {
|
if($this->db()->num_rows($res)) {
|
||||||
$tmp_addresses = [];
|
$tmp_addresses = [];
|
||||||
while($data = $this->db()->fetch_object($res)) {
|
while($data = $this->db()->fetch_object($res)) {
|
||||||
|
|
||||||
|
// never return addresses without OAID if OAID is required in Network
|
||||||
|
if((!$data->hausnummer_oaid || !$data->wohneinheit_oaid) && $netzgebiete[$data->netzgebiet_id]->unit_create_oaid) continue;
|
||||||
|
|
||||||
$address_key = $data->hausnummer_id;
|
$address_key = $data->hausnummer_id;
|
||||||
if($this->hausnummer_add_zusatz) {
|
if($this->hausnummer_add_zusatz) {
|
||||||
$address_key = $data->hausnummer_id . "-" . $data->zusatz;
|
$address_key = $data->hausnummer_id . "-" . $data->zusatz;
|
||||||
|
|||||||
@@ -418,6 +418,10 @@ class AddressHelper
|
|||||||
$hausnummer->save();
|
$hausnummer->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$hausnummer->oaid && $this->netzgebiet->unit_create_oaid) {
|
||||||
|
$hausnummer->getNewOAID();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//echo ">>>>>>>>>>>>>>>>>>>\nupdating hausnummer:\n";
|
//echo ">>>>>>>>>>>>>>>>>>>\nupdating hausnummer:\n";
|
||||||
//print_r($hausnummer);exit;
|
//print_r($hausnummer);exit;
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
//require 'vendor/autoload.php';
|
||||||
|
require("../../config/config.php");
|
||||||
|
|
||||||
|
define('FRONKDB_SQLDEBUG', false);
|
||||||
|
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||||
|
|
||||||
|
require_once(LIBDIR . "/mvcfronk/mfRouter/mfRouter.php");
|
||||||
|
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseModel.php");
|
||||||
|
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseController.php");
|
||||||
|
|
||||||
|
$me = new User(1);
|
||||||
|
define("INTERNAL_USER_ID", $me->id);
|
||||||
|
define("INTERNAL_USER_USERNAME", $me->username);
|
||||||
|
define("MFBASE_BYPASS_LOGIN", true);
|
||||||
|
|
||||||
|
$h = 0;
|
||||||
|
$u = 0;
|
||||||
|
|
||||||
|
foreach(ADBNetzgebietModel::getAll() as $netzgebiet) {
|
||||||
|
if(!$netzgebiet->unit_create_oaid) continue;
|
||||||
|
if(!$netzgebiet->rimo_id) continue;
|
||||||
|
|
||||||
|
//echo $netzgebiet->name."\n";continue;
|
||||||
|
|
||||||
|
foreach(ADBHausnummerModel::search(["netzgebiet_id" => $netzgebiet->id]) as $hausnummer) {
|
||||||
|
if(!$hausnummer->oaid) {
|
||||||
|
echo "h ".$hausnummer->id." = ".$hausnummer->oaid."\n";
|
||||||
|
$hausnummer->oaid = $hausnummer->getNewOaid();
|
||||||
|
if(!$hausnummer->save()) die("Error saving hausnummer\n");
|
||||||
|
echo "h ".$hausnummer->id." => ".$hausnummer->oaid."\n";
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
|
foreach($hausnummer->wohneinheiten as $unit) {
|
||||||
|
if(!$unit->oaid) {
|
||||||
|
echo "u ".$unit->id." = ".$unit->oaid."\n";
|
||||||
|
$unit->oaid = $unit->getNewOaid();
|
||||||
|
if(!$unit->save()) die("Error saving unit\n");
|
||||||
|
echo "u ".$unit->id." => ".$unit->oaid."\n";
|
||||||
|
$u++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Updated $h Buildings and $u Wohneinheiten\n";
|
||||||
@@ -20,6 +20,7 @@ $me = new \User(TT_RIMO_IMPORT_USER_ID);
|
|||||||
|
|
||||||
define("INTERNAL_USER_ID", $me->id);
|
define("INTERNAL_USER_ID", $me->id);
|
||||||
define("INTERNAL_USER_USERNAME", $me->username);
|
define("INTERNAL_USER_USERNAME", $me->username);
|
||||||
|
define("MFBASE_BYPASS_LOGIN", true);
|
||||||
|
|
||||||
$mainlog = \mfLoghandler::singleton();
|
$mainlog = \mfLoghandler::singleton();
|
||||||
$log = new \mfLog_File();
|
$log = new \mfLog_File();
|
||||||
@@ -311,6 +312,12 @@ foreach ($clusters as $cluster_data) {
|
|||||||
if (!$unit->save()) {
|
if (!$unit->save()) {
|
||||||
die("Error saving new unit\n" . print_r($unit, true));
|
die("Error saving new unit\n" . print_r($unit, true));
|
||||||
}
|
}
|
||||||
|
if(!$unit->oaid && $adb_netzgebiet->unit_create_oaid) {
|
||||||
|
$unit->oaid = $unit->getNewOAID();
|
||||||
|
if(!$unit->save()) {
|
||||||
|
die("Error saving new unit OAID\n" . print_r($unit, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,6 +355,13 @@ foreach ($clusters as $cluster_data) {
|
|||||||
if (!$unit->save()) {
|
if (!$unit->save()) {
|
||||||
die("Error saving new unit\n" . print_r($home, true));
|
die("Error saving new unit\n" . print_r($home, true));
|
||||||
}
|
}
|
||||||
|
if(!$unit->oaid && $adb_netzgebiet->unit_create_oaid) {
|
||||||
|
$unit->oaid = $unit->getNewOAID();
|
||||||
|
if(!$unit->save()) {
|
||||||
|
die("Error saving new unit OAID\n" . print_r($unit, 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