Zhouzhendong пре 4 година
родитељ
комит
672bffd092

+ 10 - 6
app/Http/Controllers/StationController.php

@@ -54,13 +54,17 @@ class StationController extends Controller
             foreach ($item as $value)$query->orWhere("ks_bin_space_code",'like',$value);
             $codes = [];
             $query->get()->each(function ($bin)use(&$codes){
-                $codes[] = $bin->ks_bin_code;
+                $codes[] = "'".$bin->ks_bin_code."'";
             });
             if (!$codes){$res[] = 100;continue;}
-            $count = DB::connection("oracle")->table("INV_LOT_LOC_ID")->selectRaw("1")
-                ->where("traceid","*")->whereRaw("SUM(qty) = 0")
-                ->whereIn("locationid",$codes)->groupBy("locationid")->count();
-            $res[] =number_format($count/count($codes),1)*100;
+            $len = count($codes);
+            $codes = "(".implode(",",$codes).")";
+            $sql = <<<SQL
+SELECT COUNT(*) count FROM (SELECT SUM(QTY) qty FROM INV_LOT_LOC_ID WHERE
+TRACEID = '*' AND LOCATIONID IN {$codes} GROUP BY LOCATIONID) inv WHERE INV.qty!=0
+SQL;
+            $count = DB::connection("oracle")->selectOne(DB::raw($sql))->count;
+            $res[] = intval($count/$len*1000)/10;
         }
         Cache::tags("loadBoxMonitor")->put($cacheKey,$res,1800);
         $this->success($res);
@@ -82,7 +86,7 @@ class StationController extends Controller
         $locations = [];
         DB::connection("oracle")->table("INV_LOT_LOC_ID")->selectRaw("locationid,SUM(qty) qty")
             ->where("traceid","*")
-            ->whereIn("locationid",$codes)->groupBy("locationid")->get()->each(function ($inv)use(&$locations,&$res){
+            ->whereIn("locationid",$codes)->groupByRaw("locationid")->get()->each(function ($inv)use(&$locations,&$res){
                 $locations[] = [
                     "location"  => $res[$inv->locationid],
                     "status"    => $inv->qty>0,

+ 2 - 2
resources/views/station/monitor/visual.blade.php

@@ -19,8 +19,8 @@
                             <div class="w-100 text-center d-inline-block"><i class="fa fa-spinner fa-pulse"></i></div>
                         </div>
                         <div class="progress mr-2" style="cursor: pointer" v-else @click="loadDetail(i,j)">
-                            <div class="progress-bar bg-danger" :style="{width:(100-val)+'%'}">@{{(100-val)+'%'}}</div>
-                            <div class="progress-bar bg-success" :style="{width:val+'%'}">@{{ val+'%' }}</div>
+                            <div class="progress-bar bg-danger" :style="{width:val+'%'}">@{{ val+'%' }}</div>
+                            <div class="progress-bar bg-success" :style="{width:(100-val)+'%'}">@{{(100-val)+'%'}}</div>
                         </div>
                     </div>
                 </div>