Explorar o código

料箱分布监视器

Zhouzhendong %!s(int64=4) %!d(string=hai) anos
pai
achega
089eaa6a65

+ 58 - 1
app/Http/Controllers/StationController.php

@@ -2,13 +2,17 @@
 
 namespace App\Http\Controllers;
 
+use App\Components\AsyncResponse;
 use App\Station;
 use App\StationTypeBinMonitor;
 use Illuminate\Database\Eloquent\Builder;
-use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\DB;
 
 class StationController extends Controller
 {
+    use AsyncResponse;
+
     public function monitorIndex()
     {
         $stations = Station::query()->with('stationType:name','parent:name')->whereHas('stationType',function($query){
@@ -39,4 +43,57 @@ class StationController extends Controller
         return view('station.monitor.show',compact('station'));
     }
 
+    public function getVisual()
+    {
+        $arr = \request("arr");
+        $cacheKey = "loadBoxMonitor_".$arr[0][0];
+        if (Cache::tags("loadBoxMonitor")->has($cacheKey))$this->success(Cache::tags("loadBoxMonitor")->get($cacheKey));
+        $res = [];
+        foreach ($arr as $item){
+            $query = DB::connection("mysql_haiRobotics")->table("ks_bin")->select("ks_bin_code");
+            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;
+            });
+            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;
+        }
+        Cache::tags("loadBoxMonitor")->put($cacheKey,$res,1800);
+        $this->success($res);
+    }
+
+    public function getDetail()
+    {
+        $arr = \request("arr");
+        $cacheKey = "loadBoxMonitorDetail_".$arr[0];
+        if (Cache::tags("loadBoxMonitor")->has($cacheKey))$this->success(Cache::tags("loadBoxMonitor")->get($cacheKey));
+        $ks = DB::connection("mysql_haiRobotics")->table("ks_bin")->select("ks_bin_code","ks_bin_space_code")
+            ->whereIn("ks_bin_space_code",$arr)->get();
+        $res = [];
+        $codes = [];
+        foreach ($ks as $k){
+            $res[$k->ks_bin_code] = $k->ks_bin_space_code;
+            $codes[] = $k->ks_bin_code;
+        }
+        $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){
+                $locations[] = [
+                    "location"  => $res[$inv->locationid],
+                    "status"    => $inv->qty>0,
+                ];
+                unset($res[$inv->locationid]);
+            });
+        if ($res)foreach ($res as $item)$locations[] = [
+            "location"  => $item,
+            "status"    => false,
+        ];
+        Cache::tags("loadBoxMonitor")->put($cacheKey,$locations,1800);
+        $this->success($locations);
+    }
 }

+ 3 - 50
app/Http/Controllers/TestController.php

@@ -151,56 +151,9 @@ class TestController extends Controller
     {
        return view("station.monitor.visual");
     }
-    public function orderCreateBill()
-    {
-
-        $order = Order::query()->find(\request("id"));
-        $ser = new OrderService();
-        $ser->createInstantBill($order);
-        dd("order create bill success");
-    }
-
-    public function supplementMarchOwnerReport()
-    {
-        $ows = OwnerAreaReport::query()->select("owner_id")->where("counting_month", 'like', "2021-03%")->get();
-        $owners = Owner::query()->whereNotIn("id", array_column($ows->toArray(), "owner_id"))->get();
-        $createOwnerAreaReport = [];
-        foreach ($owners as $owner) {
-            if (!$owner->ownerStoragePriceModels) continue;
-            foreach ($owner->ownerStoragePriceModels as $model) {
-                $key = $owner->id . "_" . $model->id;
-                if (!isset($sign[$key])) $createOwnerAreaReport[] = [
-                    "owner_id" => $owner->id,
-                    "counting_month" => "2021-03-01",
-                    "user_owner_group_id" => $owner->user_owner_group_id,
-                    "created_at" => "2021-04-15 00:00:00",
-                    "owner_storage_price_model_id" => $model->id,
-                ];
-            }
-        }
-        if ($createOwnerAreaReport) DB::table("owner_area_reports")->insert($createOwnerAreaReport);
-    }
-
-    public function assignBatch()
-    {
-        $batches = collect([
-            [
-                "id" => 87255,
-                "code" => "W210312000317",
-                "status" => "\u672a\u5904\u7406",
-                "type" => null,
-                "wms_type" => "09.[BAOSHI]\u622a\u5355\u6ce2\u6b21\u3010\u65e0\u5907\u6ce8\u3011",
-                "wms_status" => "\u90e8\u5206\u6536\u8d27",
-                "wms_created_at" => "0000-00-00 00=>00 =>00",
-                "created_at" => "2021-03-12T09=>10=>44.000000Z",
-                "updated_at" => "2021-03-12T09=>10=>44.000000Z",
-                "remark" => null,
-                "owner_id" => "42",
-                "station_task_batch" => null
-            ]
-        ]);
-        $batches = Batch::query()->where('id', data_get($batches, '*.id'))->get();
-        app('BatchService')->assignTasks($batches);
+    public function test1()
+    {
+        dd(Cache::tags("loadBoxMonitor")->flush());
     }
 
     public function updateLaborRemark()

+ 25 - 0
resources/views/station/monitor/_loadDetail.blade.php

@@ -0,0 +1,25 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="modal">
+    <div class="modal-dialog modal-lg modal-dialog-centered">
+        <div class="modal-content">
+            <div class="modal-body">
+                <div class="w-100 h-100 d-inline-block text-center h2" v-if="loadStatus">
+                    <i class="fa fa-spinner fa-pulse"></i>
+                </div>
+                <table class="w-100 h-100 table table-bordered" v-else>
+                    <tr v-for="arr in detail">
+                        <td v-for="obj in arr" class="p-0">
+                            <div class="container">
+                                <div class="row justify-content-center" style="min-width: 50px;min-height: 50px"
+                                     :class="obj.status===undefined ? '' : (obj.status ? 'bg-danger' : 'bg-success')">
+                                    <div class="align-self-center">
+                                        @{{ obj.location }}
+                                    </div>
+                                </div>
+                            </div>
+                        </td>
+                    </tr>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>

+ 77 - 3
resources/views/station/monitor/visual.blade.php

@@ -3,6 +3,14 @@
 
 @section('content')
     <div class="container-fluid d-none" id="container">
+        <div class="row mt-5 mb-5 text-center">
+            <div class="col-6 offset-3 row">
+                <div class="col-1 bg-success"></div>
+                <div class="col-1">空箱</div>
+                <div class="col-1 bg-danger offset-5"></div>
+                <div class="col-1">非空</div>
+            </div>
+        </div>
         <div class="row bg-dark">
             <div class="col-6 row mt-2 mb-2" v-for="(arr,i) in data">
                 <div class="offset-1 col-10 row">
@@ -10,7 +18,7 @@
                         <div class="progress mr-2" v-if="val===undefined">
                             <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>
+                        <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>
@@ -18,6 +26,7 @@
                 </div>
             </div>
         </div>
+        @include("station.monitor._loadDetail")
     </div>
 @endsection
 
@@ -32,6 +41,10 @@
                 maxLoadSize:18,//最大加载大小 X排
                 data:[],//数据池
                 prefix:"HAI",
+                mapping:[],
+                details:{}, //详情池
+                detail:[],  //当前详情
+                loadStatus:false,
             },
             mounted() {
                 let data = [];
@@ -41,15 +54,76 @@
                         arr.push(undefined);
                     }
                     data.push(arr);
-                    loadData
+                    this.loadData(i,data.length);
                 }
                 this.data = data;
                 $("#container").removeClass("d-none");
             },
             methods:{
-                loadData(row){
+                loadData(row,index){
                     let size = this.rowSize*this.columnSize;
                     if (row%2!==0)size *= 2;
+                    row = row/2;
+                    let len = row.toString().length;
+                    let before = "00";
+                    let location = (this.prefix+(len===2 ? (Math.ceil(row)).toString() :
+                        before.substr(0,2-len)+(Math.ceil(row)).toString()))+'-';
+                    let arr = [];
+                    let temp = [];
+                    for (let i=size-(this.rowSize*this.columnSize)+1;i<=size;i++){
+                        temp.push(location+(before.substr(0,3-(i.toString().length))+i.toString())+"-%");
+                        if (i%this.columnSize===0){arr.push(temp);temp = [];}
+                    }
+                    this.mapping.push(arr);
+                    window.tempTip.postBasicRequest("{{url('station/monitor/visual/getData')}}",{arr:arr},res=>{
+                        this.$set(this.data,index-1,res);
+                    });
+                },
+                loadDetail(index,j){
+                    $("#modal").modal('show');
+                    let key = index+'-'+j;
+                    if (this.details[key]){ //缓存池存在取缓存池 转为即时后关闭缓存池即可
+                        this.detail = this.details[key];
+                        return;
+                    }
+                    let arr = this.mapping[index][j];
+                    let res = []; //扁平化的库位参数  一维数组
+                    let before = "00";//前缀
+                    let maxLen = 2;//最大高度 位数
+                    let rowIndex = 0;//行下标记录
+                    let mapping = {};//库位与数据池的下标映射
+                    let detail = [];//数据池
+                    for (let i=this.heightSize;i>0;i--){
+                        let columnIndex = 0;//列下标记录
+                        let detailTemp = [];//数据池第二维数组
+                        let suffix = i.toString().length<maxLen ? before.substr(0,maxLen-i.toString().length)+i.toString() : i.toString();
+                        for (let k=arr.length-1;k>=0;k--){
+                            let val = arr[k].substr(0,arr[k].length-1)+suffix;
+                            res.push(val);
+                            detailTemp.push({location:val,status:undefined});
+                            mapping[val] = [rowIndex,columnIndex];
+                            columnIndex++;
+                        }
+                        detail.push(detailTemp);
+                        rowIndex++;
+                    }//用对象将数据池结构组装占位,用mapping来映射库位与其应在数据池内的实际下标,拿到真实数据后根据映射进行填充
+                    this.loadStatus = true;//开启加载动画
+                    //启异步请求数据
+                    window.tempTip.postBasicRequest("{{url('station/monitor/visual/getDetail')}}",{arr:res},res=>{
+                        if (res){
+                            res.forEach(obj=>{
+                                if (mapping[obj.location]){
+                                    detail[mapping[obj.location][0]][mapping[obj.location][1]] = obj;
+                                }
+                            });//真实数据查找映射填充
+                        }
+                        this.detail = detail;//扔进当前详情列表
+                        this.details[key] = detail;//缓存结果
+                        setTimeout(()=>{
+                            this.details[key] = undefined;
+                        },1800000);//缓存池半小时后清除
+                        this.loadStatus = false;//加载完毕
+                    });
                 },
             }
         });

+ 5 - 0
routes/web.php

@@ -849,6 +849,11 @@ Route::group(['middleware'=>'auth'],function ($route){
         Route::group(['prefix'=>'monitor'],function(){
             Route::get('/','StationController@monitorIndex');
             Route::get('/index','StationController@monitorIndex');
+            /** 料箱分布监视器 */
+            Route::group(['prefix'=>'visual'],function(){
+                Route::post('getData','StationController@getVisual');
+                Route::post('getDetail','StationController@getDetail');
+            });
         });
         /** 缓存架 */
         Route::group(['prefix'=>'cachingShelf'],function(){