citycom import now saves service_number and status to PreorderCtag

This commit is contained in:
Frank Schubert
2025-08-05 14:52:29 +02:00
parent fd9f47315f
commit 9aecd18da5
2 changed files with 74 additions and 22 deletions

View File

@@ -200,8 +200,6 @@ class CitycomImporter {
$services = $ccapi->getServices();
foreach($services as $service) {
if(!property_exists($service, "ont") || !$service->ont || !$service->ont->id) continue;
if(!property_exists($service, "location") || !$service->location || !$service->location->id) continue;
if(!property_exists($service->location, "sublocation") || !$service->location->sublocation || !$service->location->sublocation->id) continue;
//var_dump($service);
@@ -213,28 +211,49 @@ class CitycomImporter {
$preorder = \PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id]);
if(!$preorder) continue;
$pco = \PreorderCitycomOan::getFirst(["preorder_id" => $preorder->id]);
if(!$pco) {
$pco = \PreorderCitycomOan::create([
"preorder_id" => $preorder->id
]);
}
$ont_sn = $service->ont->serial;
$ont_gpid = $service->ont->fsan;
if($ont_sn || $ont_gpid) {
$status_300 = \PreorderstatusModel::getFirst(["code" => 300]);
if($preorder->status->code < 300) {
$preorder->status_id = $status_300->id;
$preorder->save();
if(property_exists($service, "ont") && !$service->ont && !$service->ont->id) {
$pco = \PreorderCitycomOan::getFirst(["preorder_id" => $preorder->id]);
if(!$pco) {
$pco = \PreorderCitycomOan::create([
"preorder_id" => $preorder->id
]);
}
$ont_sn = $service->ont->serial;
$ont_gpid = $service->ont->fsan;
if($ont_sn || $ont_gpid) {
$status_300 = \PreorderstatusModel::getFirst(["code" => 300]);
if($preorder->status->code < 300) {
$preorder->status_id = $status_300->id;
$preorder->save();
}
}
if($pco->ont_sn != $ont_sn || $pco->ont_gpid != $ont_gpid) {
$pco->ont_sn = $ont_sn;
$pco->ont_gpid = $ont_gpid;
$pco->save();
}
}
if($pco->ont_sn != $ont_sn || $pco->ont_gpid != $ont_gpid) {
$pco->ont_sn = $ont_sn;
$pco->ont_gpid = $ont_gpid;
$pco->save();
// find ctag and update ext id and status if changed
$stypes = array_flip(CITYCOM_OAN_API_SERVICES_FOR_ORDER);
$stag = $unit->hausnummer->vlan_stag;
if(!$stag) continue;
$ctag = \PreorderCtag::getFirstActive(["preorder_id" => $preorder->id, "stag" => $stag, "service_type" => $stypes[$service->service_type]]);
//echo "====\n";
//echo $preorder->id." - ".$service->service_number." - ".$service->location->sublocation->id." - ".$service->service_type." - $stag\n";
if($ctag->ext_id != $service->service_number) {
$ctag->ext_id = $service->service_number;
$ctag->save();
}
if($ctag->ext_status != $service->state) {
$ctag->ext_status = $service->state;
$ctag->save();
}
}