Browse Source

- optimized calls to fb core server

Giancarlo 8 years ago
parent
commit
2a93105fd3
1 changed files with 29 additions and 18 deletions
  1. 29 18
      src/Modules/Pages.php

+ 29 - 18
src/Modules/Pages.php

@@ -9,6 +9,17 @@ namespace Modules;
 
 
 class Pages extends BaseController
 class Pages extends BaseController
 {
 {
+  private $CORE_SETTINGS;
+  private $findBoxCore;
+
+  public function __construct($f3)
+  {
+    parent::__construct($f3);
+    $this->CORE_SETTINGS = $f3->get('CORE.fb');
+    $this->findBoxCore = new \FindBoxCoreSystem(...array_values($this->CORE_SETTINGS));
+
+  }
+
   public function Login($f3)
   public function Login($f3)
   {
   {
     if (!is_null($this->userId)) {
     if (!is_null($this->userId)) {
@@ -45,9 +56,9 @@ class Pages extends BaseController
         $distinta->CleanDistintaTable();
         $distinta->CleanDistintaTable();
         $distinta->CopyDistinta($stepValues['consegna']);
         $distinta->CopyDistinta($stepValues['consegna']);
 
 
-        $CORE_SETTINGS = \F3::get('CORE.fb');
-        $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
-        $label = new \SmartESL($findBoxCore, [$stepValues['labelid']]);
+//        $CORE_SETTINGS = \F3::get('CORE.fb');
+//        $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
+        $label = new \SmartESL($this->findBoxCore, [$stepValues['labelid']]);
         $label->BlinkSpecial(0, 1, 1000, 8, 0);
         $label->BlinkSpecial(0, 1, 1000, 8, 0);
 
 
         $distinta->SaveProductsToFindBox('3', true, 50); // prende soltanto i primi 3 dalla tabella copia delle distinte
         $distinta->SaveProductsToFindBox('3', true, 50); // prende soltanto i primi 3 dalla tabella copia delle distinte
@@ -89,9 +100,9 @@ class Pages extends BaseController
               // BlinkOFF solo se non è lo stesso barcode precedente
               // BlinkOFF solo se non è lo stesso barcode precedente
               // if ($distinta->GetArticleCount($pickedBarcode) == 0) {
               // if ($distinta->GetArticleCount($pickedBarcode) == 0) {
               // SPEGNE LED ETICHETTA DOPO PICKING
               // SPEGNE LED ETICHETTA DOPO PICKING
-              $CORE_SETTINGS = \F3::get('CORE.fb');
-              $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
-              $label = new \SmartESL($findBoxCore, [$distinta->GetLabelIdFromBarcode($pickedBarcode)]);
+//              $CORE_SETTINGS = \F3::get('CORE.fb');
+//              $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
+              $label = new \SmartESL($this->findBoxCore, [$distinta->GetLabelIdFromBarcode($pickedBarcode)]);
               $label->BlinkOff();
               $label->BlinkOff();
             } else {
             } else {
               $f3->set('INFOTEXT', 'Barcode non riconosciuto o non associato ad alcuna etichetta elettronica');
               $f3->set('INFOTEXT', 'Barcode non riconosciuto o non associato ad alcuna etichetta elettronica');
@@ -108,9 +119,9 @@ class Pages extends BaseController
           $anomalie = $distinta->getAnomalieFromConsegne($datiCommessa['consegna']);
           $anomalie = $distinta->getAnomalieFromConsegne($datiCommessa['consegna']);
           $f3->set('LISTANOMALIE', $anomalie);
           $f3->set('LISTANOMALIE', $anomalie);
 
 
-          $CORE_SETTINGS = $f3->get('CORE.fb');
-          $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
-          $label = new \SmartESL($findBoxCore, [$datiCommessa['labelid']]);
+//          $CORE_SETTINGS = $f3->get('CORE.fb');
+//          $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
+          $label = new \SmartESL($this->findBoxCore, [$datiCommessa['labelid']]);
           $label->BlinkSpecial(0, 1, 5000, 8, 0);
           $label->BlinkSpecial(0, 1, 5000, 8, 0);
           $distinta->SaveLabelCarrello($datiCommessa['labelid'], $datiCommessa['labelid'], $datiCommessa['consegna']);
           $distinta->SaveLabelCarrello($datiCommessa['labelid'], $datiCommessa['labelid'], $datiCommessa['consegna']);
 
 
@@ -121,12 +132,12 @@ class Pages extends BaseController
           }
           }
         } else {
         } else {
           // Seleziona le prossime tre etichette
           // Seleziona le prossime tre etichette
-          foreach($rowsDistinta as $rowDist) {
-            $CORE_SETTINGS = $f3->get('CORE.fb');
-            $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
+          foreach ($rowsDistinta as $rowDist) {
+//            $CORE_SETTINGS = $f3->get('CORE.fb');
+//            $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
             $labelId = $distinta->GetLabelIdFromBarcode($rowDist['barcode']);
             $labelId = $distinta->GetLabelIdFromBarcode($rowDist['barcode']);
             if ($labelId != null) {
             if ($labelId != null) {
-              $label = new \SmartESL($findBoxCore, [$labelId]);
+              $label = new \SmartESL($this->findBoxCore, [$labelId]);
               // Se è lo stesso barcode di quello appena pickato dall'operatore, non lo blinka di nuovo
               // Se è lo stesso barcode di quello appena pickato dall'operatore, non lo blinka di nuovo
               if ($distinta->GetArticleCount($rowDist['barcode']) > 0) {
               if ($distinta->GetArticleCount($rowDist['barcode']) > 0) {
                 $label->BlinkSpecial(2, 1, 1000, 20);
                 $label->BlinkSpecial(2, 1, 1000, 20);
@@ -161,10 +172,10 @@ class Pages extends BaseController
     $f3->set('COOKIE.bind', json_encode($stepValues));
     $f3->set('COOKIE.bind', json_encode($stepValues));
 
 
     if ($args['step'] == 3) {
     if ($args['step'] == 3) {
-      $CORE_SETTINGS = $f3->get('CORE.fb');
-      $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
-      $findBoxCore->Bind($stepValues['labelid'], $stepValues['barcode']);
-      $label = new \SmartESL($findBoxCore, [$stepValues['labelid']]);
+//      $CORE_SETTINGS = $f3->get('CORE.fb');
+//      $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
+      $this->findBoxCore->Bind($stepValues['labelid'], $stepValues['barcode']);
+      $label = new \SmartESL($this->findBoxCore, [$stepValues['labelid']]);
 
 
       if ($stepValues['labelid'] == $stepValues['barcode'])
       if ($stepValues['labelid'] == $stepValues['barcode'])
         $devType = 79;
         $devType = 79;
@@ -186,7 +197,7 @@ class Pages extends BaseController
           'quantita_contenitore' => $articles['qta_contenitore'],
           'quantita_contenitore' => $articles['qta_contenitore'],
           'quantita_magazzino' => $articles['qta_riordino']
           'quantita_magazzino' => $articles['qta_riordino']
         ));
         ));
-        $findBoxCore->SaveProducts($stepValues['barcode'], $articles['descrizione'], $dataFields);
+        $this->findBoxCore->SaveProducts($stepValues['barcode'], $articles['descrizione'], $dataFields);
         if ($devType == 31 && ($articles['qta_contenitore'] == 'NO' || $articles['qta_riordino'] == 'NO'))
         if ($devType == 31 && ($articles['qta_contenitore'] == 'NO' || $articles['qta_riordino'] == 'NO'))
           $pickTemplateId = $labelTemplateId[1];
           $pickTemplateId = $labelTemplateId[1];
         else
         else