RTR Reporting A10 done
This commit is contained in:
@@ -42,11 +42,16 @@ class Admin_RtrReporting {
|
||||
$rasterpunkte = [];
|
||||
foreach(BuildingModel::getAll() as $building) {
|
||||
$raster = $building->laea;
|
||||
if(!$raster) continue;
|
||||
|
||||
$prod_code = 14310;
|
||||
$bb = "1000,00"; // glas = 1000, funk = 50
|
||||
$user_count = TerminationModel::count(["building_id" => $building->id]);
|
||||
|
||||
//$user_count = TerminationModel::count(["building_id" => $building->id]);
|
||||
$rtr100m = Rtr100mRaster::getFirst(["raster" => $raster]);
|
||||
if(!$rtr100m) {
|
||||
die("RTR Raster fehlt ".$raster);
|
||||
}
|
||||
$user_count = $rtr100m->unit_count;
|
||||
|
||||
if(!array_key_exists($raster, $rasterpunkte)) {
|
||||
$rasterpunkte[$raster] = [];
|
||||
@@ -67,11 +72,12 @@ class Admin_RtrReporting {
|
||||
|
||||
$address = $contract->owner;
|
||||
if(!$address->gps_lat || !$address->gps_long || !$address->laea) {
|
||||
//$address->getCoords();
|
||||
$address->save();
|
||||
$address->save(); // gets gps and laea
|
||||
}
|
||||
|
||||
$raster = $address->laea;
|
||||
if(!$raster) continue;
|
||||
|
||||
$rtr_code = $contract->product->attributes["rtr_tech_code"]->value;
|
||||
if(substr($rtr_code, 0, 4) == 1431) {
|
||||
$prod_code = 14310;
|
||||
@@ -82,8 +88,6 @@ class Admin_RtrReporting {
|
||||
} else {
|
||||
continue; // incompatible product
|
||||
}
|
||||
$user_count = 1;
|
||||
// get laea
|
||||
|
||||
if(!array_key_exists($raster, $rasterpunkte)) {
|
||||
$rasterpunkte[$raster] = [];
|
||||
@@ -94,7 +98,14 @@ class Admin_RtrReporting {
|
||||
"user_count" => 0
|
||||
];
|
||||
}
|
||||
$rasterpunkte[$raster][$prod_code]["user_count"] += $user_count;
|
||||
|
||||
$rtr100m = Rtr100mRaster::getFirst(["raster" => $raster]);
|
||||
if(!$rtr100m) {
|
||||
$this->log->warn(__METHOD__.": RTR Raster fehlt ".$raster);
|
||||
continue;
|
||||
}
|
||||
|
||||
$rasterpunkte[$raster][$prod_code]["user_count"] += $rtr100m->unit_count;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,15 @@ $bundeslaender = [
|
||||
$db = FronkDB::singleton();
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$start = date("U");
|
||||
$last_ts = $start;
|
||||
echo "Begin: ".date("Y-m-d H:i:s")."\n";
|
||||
|
||||
$c = 0;
|
||||
|
||||
$queries = [];
|
||||
$insert_values = [];
|
||||
|
||||
foreach($bundeslaender as $bland) {
|
||||
$filename = __DIR__ . "/csv/StatistikAustria_100mRaster_Anschlusspotential2022_$bland.csv";
|
||||
|
||||
@@ -37,6 +46,7 @@ foreach($bundeslaender as $bland) {
|
||||
die("File $filename not found!\n");
|
||||
}
|
||||
|
||||
echo "$bland\n";
|
||||
|
||||
$input = fopen($filename, "r");
|
||||
|
||||
@@ -67,14 +77,32 @@ foreach($bundeslaender as $bland) {
|
||||
$raster = trim($csv[$headers["rasterid"]]);
|
||||
$unit_count = trim($csv[$headers["anschlusspotential"]]);
|
||||
|
||||
$sql = "INSERT INTO `Rtr100mRaster` (`raster`,`unit_count`,`create_by`,`edit_by`,`create`,`edit`) VALUES('$raster',$unit_count,1,1,1733431100,1733431100)";
|
||||
$db->query($sql);
|
||||
$sql = "INSERT INTO `Rtr100mRaster` (`raster`,`unit_count`,`create_by`,`edit_by`,`create`,`edit`) VALUES";
|
||||
$insert_values[] = "('$raster',$unit_count,1,1,1733431100,1733431100)";
|
||||
|
||||
/*
|
||||
$rtr100mraster = Rtr100mRaster::create([
|
||||
"raster" => $raster,
|
||||
"unit_count" => $unit_count,
|
||||
]);
|
||||
$rtr100mraster->save()*/
|
||||
$c++;
|
||||
|
||||
|
||||
if($c % 100000 == 0) {
|
||||
runQuery($sql.implode(",", $insert_values), $c);
|
||||
$insert_values = [];
|
||||
}
|
||||
}
|
||||
if(count($insert_values)) {
|
||||
runQuery($sql . implode(",", $insert_values), $c);
|
||||
$insert_values = [];
|
||||
$c = 0;
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
function runQuery($sql, $c) {
|
||||
global $db;
|
||||
global $last_ts;
|
||||
|
||||
mysqli_query($db->link, $sql);
|
||||
|
||||
$now = date("U");
|
||||
echo "$c: ".date("Y-m-d H:i:s")." - delta ".($now - $last_ts)."\n";
|
||||
$last_ts = $now;
|
||||
}
|
||||
Reference in New Issue
Block a user