Browse Source

* RC2: reset display after import from as400

Giancarlo Voci 8 years ago
parent
commit
59636a9f57

+ 1 - 0
cfg/labels.ini

@@ -1,5 +1,6 @@
 [LABELS.TEMPLATES]
 DT31=dimatec2_2
+DEFAULT=dimatec_default
 
 [BARCODE_COMMANDS]
 ANOMALIACODE=5

+ 1 - 0
index.php

@@ -31,5 +31,6 @@ $frameworkUtils->LoadEncryptedConfig('cfg/config.bin');
 // Dynamic Module Loading
 $frameworkUtils->PluginLoader('src/');
 
+
 // Run Framework!!
 $f3->run();

+ 2 - 2
src/Modules/Dimatec/Dimatec.php

@@ -23,12 +23,12 @@ class Dimatec extends PluginStrategy
     $this->AddRoute('GET|POST /pick2light/@step', __NAMESPACE__ . '\Pages->Pick2Light');
     $this->AddRoute("GET|POST /bind", __NAMESPACE__ . '\Pages->Bind');
     $this->AddRoute("GET /dualframe", __NAMESPACE__ . '\Dimatec->IcamControlIFrame');
-    $this->AddRoute("GET /mav2as400", __NAMESPACE__ . '\Pages->MAV2AS400');
+    $this->AddRoute("GET /mav2as400/@step", __NAMESPACE__ . '\Pages->MAV2AS400');
     $this->AddRoute('GET /importfromas400', __NAMESPACE__ . '\Pages->ImportFromAS400');
 
     $imgClass = 'shadow p-3 rounded bg-white';
 
-    $this->AddMenuItem('mav2as400', ['order' => 1, 'url' => 'mav2as400', 'imgClass' => $imgClass, 'image' => 'ui/images/mav2as400.png', 'permissionName' => 'importdata']);
+    $this->AddMenuItem('mav2as400', ['order' => 1, 'url' => 'mav2as400/1', 'imgClass' => $imgClass, 'image' => 'ui/images/mav2as400.png', 'permissionName' => 'importdata']);
     $this->AddMenuItem('ImportFromAS400', ['order' => 2, 'url' => 'importfromas400', 'imgClass' => $imgClass, 'image' => 'ui/images/import.png', 'permissionName' => 'importdata']);
     $this->AddMenuItem('bind', ['url' => 'bind', 'imgClass' => $imgClass, 'image' => 'ui/images/bind.png']);
     $this->AddMenuItem('pick2light', ['url' => 'pick2light/1', 'imgClass' => $imgClass, 'image' => 'ui/images/magazzinoverticale.png']);

+ 6 - 1
src/Modules/Dimatec/Distinta.php

@@ -59,10 +59,14 @@ class Distinta
 
   public function UnbindAll()
   {
+    global $f3;
+    
     $labels = $this->dbHandle->exec('SELECT label_id FROM label_bindings');
     foreach($labels as $label) {
-      $msgReset = new QueueCommand($label['label_id']);
+      $msgDisplay = new QueueCommand($label['label_id']);
+      $msgDisplay->setDisplay($f3->get("LABELS.TEMPLATES.DEFAULT"), $label['label_id']);
 
+      $msgReset = new QueueCommand($label['label_id']);
       $msgReset->saveProducts('', [
         'Q.ta' => '',
         'Commessa' => $label['label_id']
@@ -70,6 +74,7 @@ class Distinta
 
       $qm = new QueueSystem('FindBoxService');
       $qm->send($msgReset);
+      $qm->send($msgDisplay);
     }
     $this->dbHandle->exec('TRUNCATE TABLE label_bindings');
   }

+ 22 - 0
src/Modules/Dimatec/MigrationData.php

@@ -394,4 +394,26 @@ EOF;
     return $this->dbMAVHandle->exec('SELECT item_id, container_id, subcontainer_id from dbo.vw_item_positions');
   }
 
+  /**
+   * Transfer product list from MAV to as400
+   *
+   * @return int count
+   */
+  public function transferFromMAV_as400(): int
+  {
+    $this->dbHandle->query("TRUNCATE TABLE SMEDAT_DIM.INTMUB0F");
+    $mavArticles = $this->dbMAVHandle->query('SELECT item_id AS UXCOAP, max_load_unit AS UXQTMA, position_quantity AS UXQTGC FROM vw_item_positions');
+    $count = 0;
+    foreach($mavArticles as $key => $value) {
+      $success = $this->dbHandle->query(
+        "INSERT INTO SMEDAT_DIM.INTMUB0F (UXSTAT, UXCOAP, UXQTGC, UXQTMA) VALUES (10, '${value['UXCOAP']}', ${value['UXQTGC']}, ${value['UXQTMA']})"
+      );
+      if ($success === FALSE) {
+        return -1;
+      }
+      $count++;
+    }
+    return $count;
+  }
+
 }

+ 19 - 2
src/Modules/Dimatec/Pages.php

@@ -121,7 +121,7 @@ class Pages extends Controller
         $commesse = $distinta->getCommesseFromProduct($f3->get('SESSION.barcode_mv'));
         if (count($commesse) == 0) {
           $f3->set('INFOTEXT', "Ventilazione terminata");
-          $f3->set('RESTART_VENTILAZIONE', TRUE);
+          $this->setRedirect('pick2light/1', 5000);
         }
         /*        foreach($commesse as $commessa) {
                   $labelid = $distinta->GetLabelIdFromBarcode($commessa['commessa']);
@@ -285,9 +285,26 @@ class Pages extends Controller
   /**
    * Send list of all goods loaded into MAV to as400
    * @param $f3
+   * @param $args page parameters
    */
-  public function MAV2AS400($f3)
+  public function MAV2AS400($f3, $args)
   {
+    switch ($args['step']) {
+      case 1:
+        $f3->set('IMPORT_RESULT', "Importazione in corso, attendere qualche secondo per la conferma.");
+        $url = ltrim(rtrim($args[0], '1'), '/') . '2';
+        $this->setRedirect($url, 0);
+        break;
+      case 2:
+        // Esegue il trasferimento dei dati
+        $migData = new MigrationData();
+        $migData->DB2Connector();
+        $migData->MAVDatabaseConnector();
+        $inserted = $migData->transferFromMAV_as400();
+        $f3->set('IMPORT_RESULT', "Sono stati inviati $inserted articoli dal MAV ad as400.");
+        break;
+    }
+    $f3->set('CONTENT', 'import.tpl');
     echo \Template::instance()->render('masterpage.tpl');
   }
 }

+ 6 - 0
src/OpenMind/FindBox/FindBoxService.php

@@ -58,6 +58,12 @@ class FindBoxService
           $esl->BlinkOff();
           unset($this->labelToBlink[$qCommand->id]);
           break;
+        case Q_DISPLAY:
+          echo "Change display for label {$qCommand->id} requested\n";
+          $esl = new SmartESL($this->findBoxCore, [$qCommand->id]);
+          $esl->Display($qCommand->params['templateId'], $qCommand->params['barcode']);
+          unset($this->labelToBlink[$qCommand->id]);
+          break;
       }
       $table->erase();
       $table->next();

+ 16 - 0
src/OpenMind/FindBox/QueueCommand.php

@@ -11,6 +11,7 @@ namespace OpenMind\FindBox;
 define('Q_BLINK_ON', 1);
 define('Q_BLINK_OFF', 2);
 define('Q_SAVEPRODUCT', 3);
+define('Q_DISPLAY', 4);
 
 class QueueCommand
 {
@@ -62,4 +63,19 @@ class QueueCommand
   {
     return (($this->params['iter_time'] / 1000) * $this->params['iterations']) * $this->params['repeat'];
   }
+
+  /**
+   * Set Display ID
+   *
+   * @param string $templateId
+   * @param string $barcode
+   */
+  public function setDisplay(string $templateId, string $barcode)
+  {
+    $this->operation = Q_DISPLAY;
+    list(
+      $this->params['templateId'],
+      $this->params['barcode']
+      ) = func_get_args();
+  }
 }

+ 15 - 1
src/OpenMind/Web/Controller.php

@@ -43,8 +43,22 @@ class Controller
    *
    * @return mixed
    */
-  public function getSanitizedPostRequest()
+  protected function getSanitizedPostRequest()
   {
     return $this->sanitizedPostRequest;
   }
+
+  /**
+   * Use setTimeout to request a change url
+   *
+   * @param string $url to change to
+   * @param int $msdelay
+   */
+  protected function setRedirect(string $url, int $msdelay)
+  {
+    global $f3;
+
+    $f3->set('REQ_REDIRECT', $url);
+    $f3->set('REQ_REDIRECT_MS', $msdelay);
+  }
 }

+ 12 - 1
ui/masterpage.tpl

@@ -8,7 +8,7 @@
 	<link rel="shortcut icon" type="image/x-icon" href="{{@BASEURL}}/ui/favicon_{{@CUSTOMERNAME}}.ico">
 
 	<script type="text/javascript">
-		const BASEURL = '{{@BASEURL}}';
+    const BASEURL = '{{@BASEURL}}';
 	</script>
 </head>
 <body>
@@ -23,5 +23,16 @@
 
 <script src="{{@BASEURL}}/bundle.js"></script>
 
+
+<check if="{{isset(@REQ_REDIRECT}})">
+	<true>
+		<script>
+      setTimeout(() => {
+        window.location.href = "{{@BASEURL}}/{{@REQ_REDIRECT}}";
+      }, {{@REQ_REDIRECT_MS}});
+		</script>
+	</true>
+</check>
+
 </body>
 </html>

+ 0 - 10
ui/pick2light.tpl

@@ -69,13 +69,3 @@
 		</div>
 	</div>
 </div>
-
-<check if="{{@RESTART_VENTILAZIONE}}">
-	<true>
-		<script>
-      setTimeout(() => {
-        window.location.href = "{{@BASEURL}}/pick2light/1";
-      }, 5000);
-		</script>
-	</true>
-</check>