Giancarlo Voci 8 years ago
parent
commit
a292ad5e0e

+ 2 - 2
cfg/config - dimatec.ini

@@ -30,8 +30,8 @@ pass=ZrgzkvJrOKnNSCnPnGz3u{A6eHSNXVvs
 
 [VERTICALSTORAGE]
 ; Magazzino verticale ICAM
-;MV_ADDRESS=192.168.0.39
-MV_ADDRESS=192.168.253.130
+MV_ADDRESS=192.168.0.39
+;MV_ADDRESS=192.168.253.130
 DB2_ADDRESS=192.168.0.100
 
 [FINDBOXSERVICE]

+ 1 - 1
cfg/config.bin

@@ -1 +1 @@
-eJx1kWtvmzAUhr9b8n9A0T5smsYl5NrI0gi4QMsl4hJFiypEiENQAVMgWZso/30mTbcP25CMwH7f4+c9Z53mdBPnzRMEShi4lqtoqNfUidCDQFVUA3OIC7wQQxCa6JAJEGh4HuqoDwF2VFczHR31wuD+24QZDFM3LLYCtGMlCQQPiseT1yqrCTqf26wgn798laWhPBJF8XJhtXwH9Yq35iW/29OmRTlN4rz7mlW0bpEsi6PZdlPGBUG0yLPymV2y3RwaUqOa0rb7qeKmQWkWl0lc5xSC2W3LtfXpZEJ3k08QLIxFtFACA6l3Qplm5atQ7atx92J0DNNWVtHcMp3HKDBtHPlYRVJfhIBV4xZxu4dgrvg49CwkvGNA4JsBdhQbIy0r4pYkEFiu7kZq6AeujT0W9/vNc7kIrG9MlZJGuKktmlK+KlMITNV1os4aBv/z5Ex8aN/lHZFPcpK03M99luy55NC0tCA1l+QsNUfKeJOzRB8cV8TtByIEa9X1ML/bsHFfGy5N+7w0mvASLw1Y4GvXh+JgIEPwTN6QKv55JGkwHoh9WRyOmbBr8Y86PT0fH2r3sXR8tVyU+kk+nJURMXxntTw21wuX2AtMVbEYj6fo+KlLYMdpfDplJeWOpG4zNnPCMY3NzuxlpGiah33/N5vIy1M2o78P+kOZl2SGrc37/3BJ4nWE63vT0ebuysfe0lQ7AN/CeNFNGkkQ/AKcAt/h
+eJx1kWtvmzAUhr9b8n9A0T5smsYl5NrI0gi4QMtNXKJoUYUIcQgqwRRI1ibKf59J0+1LhwQy9vseP+85q6yg66RoniBQotC1XEVDvaZOhR4EqqIamENc6EcYgshEh1yAQMPzSEd9CLCjuprp6KgXhfc/JsxgmLphsTdEW1aSQPCg+Dx5rfKaoPO5zffk67fvsjSUR6IoXi6sVuCg3v6teSnudrRpUUHTpOhWs4rWLZJlcTTbrMtkTxDdF3n5zC7ZrA8NqVFNadv9VEnToCxPyjSpCwrB7Lbl2vp0MqHbyRcIPMOLPSU0kHonlFlevgrVrhp3H0bHMG1lGc8t03mMQ9PGcYBVJPVFCFg1zkvaHQRzJcCRbyHhHQOCwAyxo9gYafk+aUkKgeXqbqxGQeja2Gdxf948l4vA+sZUGWmEm9qiGeWrMoPAVF0n7qxR+D9PwcSH9l3eEQWkIGnL/d7l6Y5LD01L96Tm0oKl5kiZrAuW6IPjirj5QIRgpbo+5rdrNu5rw6Vpn5dGE17ipQELfO36UBwMZAieyRtSxX+PJA3GA7Evi8MxE3Yt/lVnp+fjQ+0+lk6gll6pn+TDWRkRI3CWi2NzvXCB/dBUFYvx+IqOn7oEdpIlp1NeUu5I6jZnMycc09hsEotY0TQfB8FfNJGXp8z0yUl/KPOSzLC1ef8TmyReR7i6Nx1t7i4D7C9MtQMILIy9btJIguAPm/zf4Q==

+ 20 - 0
src/Modules/Dimatec/Distinta.php

@@ -7,6 +7,9 @@
 
 namespace Modules\Dimatec;
 
+use OpenMind\FindBox\QueueCommand;
+use OpenMind\System\QueueSystem;
+
 class Distinta
 {
   /** @var \DB\SQL $dbHandle */
@@ -54,6 +57,23 @@ class Distinta
     return $this->dbHandle->exec("SELECT * FROM `distinte` WHERE `barcode` = '{$barcode}' AND `idUtente` = '{$this->userId}' AND `deleted` = '0' ORDER BY `commessa`");
   }
 
+  public function UnbindAll()
+  {
+    $labels = $this->dbHandle->exec('SELECT label_id FROM label_bindings');
+    foreach($labels as $label) {
+      $msgReset = new QueueCommand($label['label_id']);
+
+      $msgReset->saveProducts('', [
+        'Q.ta' => '',
+        'Commessa' => $label['label_id']
+      ]);
+
+      $qm = new QueueSystem('FindBoxService');
+      $qm->send($msgReset);
+    }
+    $this->dbHandle->exec('TRUNCATE TABLE label_bindings');
+  }
+
   public function getListeToBind()
   {
     return $this->dbHandle->exec("SELECT DISTINCT commessa FROM `distinte` WHERE deleted=0 and idutente={$this->userId} AND commessa NOT IN (SELECT barcode FROM label_bindings) ORDER BY commessa");

+ 19 - 21
src/Modules/Dimatec/MigrationData.php

@@ -66,47 +66,45 @@ class MigrationData
   }
 
   /**
-   * Get all missions from DB2 without status 0
+   * Get all new missions from DB2 without status 0
    * @param string $operationType
    */
   public function selectAvailableMissions(string $operationType)
   {
-    global $System;
-
     $filter = $this->fixOperationTypeValue($operationType);
 
     $this->db2RowsId = array_column($this->query("SELECT MXIDDM FROM SMEDAT_DIM.INTMAV0F WHERE $filter AND MXSTAT=0"), 'MXIDDM');
-    $System->getCache()->set('db2RowsId', $this->db2RowsId);
-
   }
 
   /**
    * Set mission status on AS400
-   * @param int $status
    * @param $listaId
    */
-  public function MarkMissions(int $status, $listaId)
+  public function InitializeMissions($listaId)
   {
-    global $System;
-
-    $this->db2RowsId = $System->getCache()->get('db2RowsId');
     $ids = join(", ", $this->db2RowsId);
-    $this->query("UPDATE SMEDAT_DIM.INTMAV0F SET MXSTAT=$status, MXNOLS='$listaId' WHERE MXIDDM IN ($ids)");
+    $this->query("UPDATE SMEDAT_DIM.INTMAV0F SET MXSTAT=" . MigrationData::STATUS_PENDING . ", MXNOLS='$listaId' WHERE MXIDDM IN ($ids)");
   }
 
-  public function SetMissionsBarcodes(string $barcode, string $commessa)
+  public function MarkMissionDone(string $labelId, string $articleCode, string $commessa)
   {
-    global $System;
-
-    $this->db2RowsId = $System->getCache()->get('db2RowsId');
-    $ids = join(", ", $this->db2RowsId);
-    $this->query("UPDATE SMEDAT_DIM.INTMAV0F SET MXNCON='$barcode' WHERE MXCORD='$commessa' AND MXIDDM IN ($ids)");
+    $this->query(
+      "UPDATE SMEDAT_DIM.INTMAV0F SET MXSTAT=" . MigrationData::STATUS_DONE . " WHERE MXNCON='$labelId' AND MXCORD='$commessa' AND MXARTI='$articleCode' AND MXSTAT=" . MigrationData::STATUS_PENDING
+    );
   }
 
+  /**
+   * Set barcode on all missions cached by 'selectAvailableMissions'
+   * @param string $labelId
+   * @param string $commessa filter
+   */
+  public function SetMissionsBarcodes(string $labelId, string $commessa)
+  {
+    $this->query("UPDATE SMEDAT_DIM.INTMAV0F SET MXNCON='$labelId' WHERE MXCORD='$commessa'");
+  }
 
   /**
    * MAV DB constructor.
-   * @param string $serverAddress IP Address
    */
   public function MAVDatabaseConnector()
   {
@@ -119,7 +117,6 @@ class MigrationData
 
   /**
    * PDO constructor.
-   * @param string $serverAddress IP Address
    */
   public function DB2Connector()
   {
@@ -174,13 +171,14 @@ class MigrationData
 EOF;
   }
 
-  private function soapAddArticle(string $id, int $quantity, $description)
+  private function soapAddArticle(string $id, int $quantity, $description, $color)
   {
     $this->listXml .= <<<EOF
         <ser:ListDetail>
           <ser:item_id>$id</ser:item_id>
           <ser:quantity>$quantity</ser:quantity>
           <ser:description>$description</ser:description>
+          <ser:color>$color</ser:color>
         </ser:ListDetail>
 EOF;
   }
@@ -283,7 +281,7 @@ EOF;
       $descArti = trim($row['descrizione']); // trim($row['commessa']) . ' ' . trim(substr($row['codcliente'], 7)) . ' ' . trim($row['descrizione']);
 
       // List Article
-      $this->soapAddArticle($row['barcode'], $row['qta_prelevare'], $descArti);
+      $this->soapAddArticle($row['barcode'], $row['qta_prelevare'], $descArti, 1);
     }
 
     $this->finalXml = <<<EOF

+ 31 - 14
src/Modules/Dimatec/Pages.php

@@ -109,6 +109,12 @@ class Pages extends Controller
               $qm->send($obj);
 
               $distinta->DeleteCommessaArticle($stepValues['barcode_mv'], $stepValues['commessa']);
+
+              // set status 80 on DB2 for this article
+              $md = new MigrationData();
+              $md->DB2Connector();
+              $md->MarkMissionDone($labelid, $stepValues['barcode_mv'], $stepValues['commessa']);
+
             }
           }
         }
@@ -117,13 +123,13 @@ class Pages extends Controller
           $f3->set('INFOTEXT', "Ventilazione terminata");
           $f3->set('RESTART_VENTILAZIONE', TRUE);
         }
-/*        foreach($commesse as $commessa) {
-          $labelid = $distinta->GetLabelIdFromBarcode($commessa['commessa']);
-          if ($labelid == null) {
-            $f3->set('INFOTEXT', "Alcune etichette non accenderano il led in quanto non associate.");
-            continue;
-          }
-        }*/
+        /*        foreach($commesse as $commessa) {
+                  $labelid = $distinta->GetLabelIdFromBarcode($commessa['commessa']);
+                  if ($labelid == null) {
+                    $f3->set('INFOTEXT', "Alcune etichette non accenderano il led in quanto non associate.");
+                    continue;
+                  }
+                }*/
         $f3->set('COMMESSE', $commesse);
         break;
     }
@@ -150,12 +156,19 @@ class Pages extends Controller
       $labelTemplateId = $f3->get("LABELS.TEMPLATES.DT31");
 
       $err = $label->Display($labelTemplateId, $bindData['labelid']);
-      $eslData = array(
+
+      //
+      $msgReset = new QueueCommand($bindData['labelid']);
+
+      $j_eslData = [
         'Q.ta' => 0,
         'Commessa' => $bindData['commessa']
-      );
-      $j_eslData = json_encode($eslData);
-      $err = $this->findBoxCore->SaveProducts($bindData['labelid'], '', $eslData);
+      ];
+
+      $msgReset->saveProducts('', $j_eslData);
+
+      $qm = new QueueSystem('FindBoxService');
+      $qm->send($msgReset);
 
       // Add or Update label
       $label = new SQL\Mapper($f3->get('DB'), 'label_bindings');
@@ -163,7 +176,7 @@ class Pages extends Controller
       $label->label_id = $bindData['labelid'];
       $label->barcode = $bindData['commessa'];
       $label->template_id = $labelTemplateId;
-      $label->esl_datafields = $j_eslData;
+      $label->esl_datafields = json_encode($j_eslData);
       $label->descrizione = $bindData['codcliente'];
       $label->save();
 
@@ -238,12 +251,16 @@ class Pages extends Controller
     if (count($dataFullMaxed) == 0)
       $f3->set('IMPORT_RESULT', "Non ci sono nuove missioni da elaborare.");
     else {
+      // Clean all bind table
+      $d = new Distinta();
+      $d->UnbindAll();
+
       $dataFullMaxed_Elaborata = $migData->prepareDistinta($dataFullMaxed, $mavUDS);
 
       // Compile xml for SOAP
       $idList = $migData->soapCompileFrom($dataFullMaxed_Elaborata, 'SCARICO');
 
-      if (false/*!$migData->sendToIcam()*/) {
+      if (!$migData->sendToIcam()) {
         $f3->set('IMPORT_RESULT', "Errore durante l'invio della lista al Magazzino Verticale.<br/><br/>Controllare la console ICAM per gli errori.");
       } else {
         // Importo la lista nel database di OM-Link solamente se non ci sono stati errori nell'invio al Magazzino Verticale
@@ -257,7 +274,7 @@ class Pages extends Controller
         $f3->set('IMPORT_RESULT', "Liste inviate correttamente al Magazzino Verticale<br/><br/>Righe con massimizzazione importate: $count");
 
         $migData->selectAvailableMissions('SCARICO');
-        $migData->MarkMissions(50, $idList);
+        $migData->InitializeMissions($idList);
       }
     }
 

+ 1 - 1
src/OpenMind/System/Notifications.php

@@ -47,7 +47,7 @@ class Notifications extends Mapper
     $this->f3->get('DB')->exec('TRUNCATE TABLE notifications');
   }
 
-  public function notify(int $code, string $caption, $link = '/')
+  public function notify(int $code, string $caption, $link = '#')
   {
     $this->reset();
     $this->code = $code;

+ 3 - 2
ui/js/omlink.js

@@ -14,7 +14,7 @@ function NotificationBuilder(notifications) {
     $('#sysmsgnum').empty();
   } else {
     notifications.forEach(function (element) {
-      tplNotify += `<a class="dropdown-item" href="javascript:NotificationDelete('${element.link}', ${element.code})">${element.caption}<span class="ml-1 badge badge-danger">${element.count}</span></a>`;
+      tplNotify += `<a class="dropdown-item" href="javascript:NotificationDelete('${element.link}', ${element.code})">[${element.timestamp}] ${element.caption}<span class="ml-1 badge badge-danger">${element.count}</span></a>`;
     });
 
     htmlNotificationArea = `
@@ -48,7 +48,8 @@ function refreshNotificationArea() {
 function NotificationDelete(link, code) {
   fetch(`/omlink/api.system.removenotification/${code}`, {method: "POST"})
     .then(() => {
-      window.location.href = `${BASEURL}${link}`;
+      if (link != '#')
+        window.location.href = `${BASEURL}${link}`;
     })
     .catch(() => {
       alert('NotificationDelete error');

+ 3 - 3
ui/pick2light.tpl

@@ -46,12 +46,12 @@
 			<table class="table table-striped table-secondary" style="font-size: 10pt;">
 				<thead>
 				<tr style="font-size: 12pt" class="bg-warning">
-					<th class="text-center text-uppercase" colspan="6" scope="col">Articoli da prelevare</th>
+					<th class="text-center text-uppercase" colspan="6" scope="col">Articoli da ventilare</th>
 				</tr>
 				<tr style="font-size: 12pt" class="bg-warning">
 					<th scope="col">UDS</th>
-					<th scope="col">Art</th>
-					<th scope="col">Desc</th>
+					<th scope="col">Articoli</th>
+					<th scope="col">Descrizione</th>
 					<th scope="col">Q.ta</th>
 				</tr>
 				</thead>