|
|
@@ -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,
|