Переглянути джерело

Added Productcode transformation 4 laser, added WA-NR scanning capabilities 4 process

Manuel Gall 2 роки тому
батько
коміт
627249390a

+ 41 - 12
server/was.rb

@@ -545,16 +545,16 @@ class GetRealImage < Riddl::Implementation
     
     if false #Currently replacements are done on the client side
       if(@p[0].nil?)
-        puts "Undefined p"
+        #puts "Undefined p"
         else
         if(@p[0].name == "video" && @p[0].value)
           
           xml = Nokogiri.parse img
-          puts "Width " + xml.xpath("string(//xmlns:image/@width)")
-          puts "Height " + xml.xpath("string(//xmlns:image/@height)")
+          #puts "Width " + xml.xpath("string(//xmlns:image/@width)")
+          #puts "Height " + xml.xpath("string(//xmlns:image/@height)")
           #puts "Posi " + xml.xpath("string(//xmlns:clipPath/path/@height)")
-          puts "Posi " + xml.xpath("string(//xmlns:image/following-sibling::clipPath/@id)")
-          puts xml.xpath("string(//xmlns:text[starts-with(text(), 'url')])").sub("url=", "")
+          #puts "Posi " + xml.xpath("string(//xmlns:image/following-sibling::clipPath/@id)")
+          #puts xml.xpath("string(//xmlns:text[starts-with(text(), 'url')])").sub("url=", "")
           
           #     text
           img = img.sub! "</svg>", '
@@ -639,7 +639,7 @@ class SearchImages < Riddl::Implementation
     searchstring = searchstring + " AND " + pattern.map{ |key, val| key + ".type == '" + key + "' AND (" + key + ".value == '"+ val +"' or " + key + ".value == '*')"}.join(' AND ') + " ORDER BY ID ASC" 
     result = $db.execute searchstring;
     
-    puts searchstring
+    #puts searchstring
     
     #Search for images with one or multiple found patternIDs
     ret = []
@@ -902,7 +902,6 @@ end
 
 class ListAssignmentSearch < Riddl::Implementation
   
-  
     def self::prepare(appconf, pat, pat_station, pat_value)
     #https://centurio.work/customers/evva/was/ui/TransformProductCode.php?ProductCode=E.A.PZ.DZ-S.31.31.MP.SEP
     pattern = JSON.parse(Net::HTTP.get URI(appconf + "ui/TransformProductCode.php?ProductCode=" + pat))
@@ -941,6 +940,8 @@ class ListAssignmentSearch < Riddl::Implementation
       
       
       searchstring = searchstring + " , patternassignments STATION , patternassignments ValText"    
+      
+      
       searchstring = searchstring + " WHERE " + pattern.map{ |key, val| pattern.keys[0] + ".AssID == " + key + ".AssID"}.join(' AND ');
       searchstring = searchstring + " AND " + pattern.map{ |key, val| pattern.keys[0] + ".ID == " + key + ".ID"}.join(' AND ')
       
@@ -949,10 +950,10 @@ class ListAssignmentSearch < Riddl::Implementation
       searchstring = searchstring + " AND " + emptypatternparts.map{ |key| pattern.keys[0] + ".ID == " + key + ".ID"}.join(' AND ')
       searchstring = searchstring + " AND " + emptypatternparts.map{ |key| key + ".type == '" + key + "' AND " + key + ".value == ''" }.join(' AND ')
       
-      searchstring = searchstring + " AND " + pattern.keys[0] + ".AssID == STATION.AssID"   
-      searchstring = searchstring + " AND " + pattern.keys[0] + ".AssID == ValText.AssID"   
-      searchstring = searchstring + " AND " + pattern.keys[0] + ".ID == STATION.ID"   
-      searchstring = searchstring + " AND " + pattern.keys[0] + ".ID == ValText.ID"   
+      searchstring = searchstring + " AND " + pattern.keys[0] + ".AssID == STATION.AssID"
+      searchstring = searchstring + " AND " + pattern.keys[0] + ".AssID == ValText.AssID"
+      searchstring = searchstring + " AND " + pattern.keys[0] + ".ID == STATION.ID"
+      searchstring = searchstring + " AND " + pattern.keys[0] + ".ID == ValText.ID"
       
       
       searchstring = searchstring + " AND STATION.type == 'STATION'" + " AND STATION.value == '" + pat_station + "'"
@@ -979,10 +980,13 @@ class ListAssignmentSearch < Riddl::Implementation
       searchstring = searchstring + " ORDER BY ID ASC"
     end
     
-    
+    #pp searchstring
     
     result = $db.execute searchstring;
     
+    #count entries
+    #result2 = $db.execute "SELECT COUNT(*) FROM patternassignments";
+    #pp result2;
     
     #Search for images with one or multiple found patternIDs
     ret = []
@@ -1005,6 +1009,28 @@ class ListAssignmentSearch < Riddl::Implementation
 end
 
 
+class ListAssignmentSearchMultiple < Riddl::Implementation
+  def response
+    #pattern station text
+    
+    pattern = JSON.parse(@p[0].value)
+    station = JSON.parse(@p[1].value)
+    text = JSON.parse(@p[2].value)
+    
+    ret = []
+    pattern.each_with_index {|val, index| 
+      #puts "#{val} => #{index} : #{station[index]} : #{text[index]}"
+      ret = ret.push(ListAssignmentSearch::prepare(@a[0][:appconf]["wasurl"], val, station[index], text[index]))
+    }
+    
+    #ret = ListAssignmentSearch::prepare(@a[0][:appconf]["wasurl"], @p[0].value, @p[1].value, @p[2].value)
+    Riddl::Parameter::Complex.new('list','application/json',JSON::pretty_generate(ret))
+  end
+end
+
+
+
+
 
 def createDB(opts)
   $db.execute("PRAGMA foreign_keys=ON");
@@ -1118,6 +1144,9 @@ server = Riddl::Server.new(File.join(__dir__,'/was.xml'), :host => 'localhost')
       on resource 'search' do
         run ListAssignmentSearch, opts if get
       end
+      on resource 'searchMultiple' do
+        run ListAssignmentSearchMultiple, opts if post
+      end
       on resource '\d+' do
         run GetAssignment if get
         run RenameAssignmentImagePath if put 'list'

+ 3 - 0
server/was.xml

@@ -166,6 +166,9 @@
       <resource relative="search">
         <get out="list"/>
       </resource>
+      <resource relative="searchMultiple">
+        <post out="list"/>
+      </resource>
       <resource relative="\d+">
         <get out="list"/>
         <put in="list"/>

+ 6 - 0
ui/TransformProductCode.php

@@ -22,6 +22,12 @@
     for($i = 0; $i < $fixwerte; ++$i){
       if(isset($productarray[$i])){
         $asocarray[$json->pattern[$i]->abk] = $productarray[$i];
+        /*
+        if($json->pattern[$i]->abk == "Zi" && $productarray[$i] == "NI" ){
+        $asocarray[$json->pattern[$i]->abk] = "";
+          
+        }
+        */
       }
       else{
         $asocarray[$json->pattern[$i]->abk] = "";

+ 21 - 0
ui/TransformProductCode2LaserFile.php

@@ -0,0 +1,21 @@
+<?php
+  ini_set('display_errors', 1);
+  ini_set('display_startup_errors', 1);
+  error_reporting(E_ALL);
+  
+  //header('Content-Type: application/json');
+  header("Content-Type: text/plain");
+
+  
+  $productcode = json_decode($_GET["ProductCode"]);
+  
+  if ($productcode->Ba == "RKZ-S" || $productcode->Ba == "RHZ-S" || $productcode->Ba == "RDZ-S"){
+    echo "CE_SerNr_SlotT1_RP." . $productcode->Za . ".rotiert.xml";
+  }
+  elseif  (($productcode->Ba == "KZ-S" || $productcode->Ba == "HZ-S" || $productcode->Ba == "DZ-S") && $productcode->Pf == "FLU"){
+    echo "CE_SerNr_FLU_SlotT1_EP." . $productcode->Za . ".rotiert.xml";
+  }
+  elseif  ($productcode->Ba == "KZ-S" || $productcode->Ba == "HZ-S" || $productcode->Ba == "DZ-S"){
+    echo "CE_SerNr_SlotT1_EP." . $productcode->Za . ".rotiert.xml";
+  }
+?>

+ 2 - 0
ui/WaNrCheck/CreateImage.php

@@ -6,6 +6,7 @@
 header("Content-type: image/png");
 $string = htmlspecialchars($_GET["WaNr"]);
 $posi = htmlspecialchars($_GET["Posi"]);
+$nfcid = htmlspecialchars($_GET["Nfcid"]);
 //$stringposi = htmlspecialchars($_GET["Position"]);
 
 $im     = imagecreatefrompng("background_klein.png");
@@ -21,6 +22,7 @@ $font = './OpenSans.ttf';
 imagettftext($im, 40, 0, 20, 50, $grey, $font, "Bitte eine Seriennummer zu diesen Daten scannen:");
 imagettftext($im, 40, 0, 20, 180, $grey, $font, "WA-NR:      " . $string);
 imagettftext($im, 40, 0, 20, 250, $grey, $font, "Position:    " . $posi);
+imagettftext($im, 20, 0, 20, 350, $grey, $font, "NFC ID:    " . $nfcid);
 //imagettftext($im, 50, 0, 200, 630, $grey, $font, "Stimmt die Position:  " . $stringposi);
 
 imagepng($im);

+ 11 - 0
ui/WaNrCheck/scanWaNr.html

@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="de">
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Titel</title>
+  </head>
+  <body>
+	<h1>Bitte WA-NR scannen.</h1>
+  </body>
+</html>

+ 53 - 9
ui/imageReplacement.php

@@ -85,7 +85,9 @@
     }
   } 
   
-  $url =  (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https://" : "http://") . $_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF']) . "/TransformProductCode.php" . "?ProductCode=" . $_GET["ProductCode"];
+  
+  $url =  (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https://" : "http://") . $_SERVER['HTTP_HOST']. dirname($_SERVER['PHP_SELF']) . "/TransformProductCode.php" . "?ProductCode=" . $_GET["ProductCode"] . "&Semantic=true";
+  
   
   $json = file_get_contents($url);
   $asocarray = json_decode($json, true);
@@ -94,8 +96,16 @@
   
   
   
+  //echo "Test für Perfomance:<br>";
   
   $curstation = $_GET["Station"];
+  
+  
+  
+  $allAssignmentsPattern=array();
+  $allAssignmentsStation=array();
+  $allAssignmentsText=array();
+  
   //Einzelbilder vom Universal Storage laden
   foreach ($keyValueStore as $key => $value) {
   
@@ -130,11 +140,19 @@
       }
     }
     $fullfilename = substr($fullfilename, 1); 
+    $fullfilename2 = substr($fullfilename, 1); 
     $fullfilename = $universalStorageEinzelbilder . "Station" . $curstation . "/Station". $curstation.     "_" . $fullfilename . ".jpg";
     
-    //if Real image was not found
-    $file_headers = @get_headers($fullfilename);
-    if(!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') {
+    
+    
+    $url = realpath("./../../universal-storage/storage/Stationsbilder/Einzelbilder/" . "Station" . $curstation . "/Station". $curstation.     "_" . $fullfilename2 . ".jpg");
+    
+    //echo "URL: " . $url . " filename" . $fullfilename . "<br>";
+    
+    //if Real image was not found search for Assignments
+    //$file_headers = @get_headers($fullfilename);
+    //if(!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') {
+    if(!$url) {
       //echo $fullfilename;
       //echo $key . " ";
       //echo json_encode($asocarray);
@@ -152,8 +170,11 @@
       //echo implode (".", $onlyUsedParts);
       //echo "<br>";
       
-      
+
         
+      array_push($allAssignmentsPattern, implode (".", $onlyUsedParts));
+      array_push($allAssignmentsStation, $curstation);
+      array_push($allAssignmentsText, $textentry);
       
       $fullfilename = $wasUrl . "server/assignments/search?pattern=". implode (".", $onlyUsedParts) ."&station=". $curstation ."&Text=" .  $textentry;
       $json = json_decode(file_get_contents($fullfilename));
@@ -164,9 +185,6 @@
       else{
         continue;
       }
-
-      
-      
     }
     else{
       //echo $fullfilename;
@@ -174,7 +192,6 @@
 
 
     //echo $fullfilename . "<br>";
-  
     
     $element3 = $doc->createElement('pattern');
     $element3->setAttribute("id", $fullfilename);
@@ -207,6 +224,33 @@
   
   
   
+  
+  
+    
+  /*
+  $url = $wasUrl . "server/assignments/searchMultiple";
+  $data = array('key1' => json_encode($allAssignmentsPattern), 'key2' => json_encode($allAssignmentsStation), 'key3' => json_encode($allAssignmentsText));
+
+  // use key 'http' even if you send the request to https://...
+  $options = array(
+      'http' => array(
+          'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
+          'method'  => 'POST',
+          'content' => http_build_query($data)
+      )
+  );
+  $context  = stream_context_create($options);
+  $result = file_get_contents($url, false, $context);
+  if ($result === FALSE) {}
+  else{
+    //var_dump($result);
+  }
+*/
+  
+  
+  
+  
+  
   //replace text from URL GET within image
   foreach($_GET as $key => $value){
     if($key != "___image___"){