Explorar o código

观察monitor logs

LD %!s(int64=4) %!d(string=hai) anos
pai
achega
2b56968b9e

+ 7 - 1
app/Services/StationService.php

@@ -60,16 +60,20 @@ class StationService
 
 
 
 
     function broadcast($station_id, ?StationTask $stationTask){
     function broadcast($station_id, ?StationTask $stationTask){
+        LogService::log('海柔请求in2','broadcast',
+            $station_id.'|'.json_encode($stationTask));
         if($stationTask)
         if($stationTask)
             $json = $stationTask->toJson();
             $json = $stationTask->toJson();
         else
         else
             $json =[];
             $json =[];
-        LogService::log('海柔请求','broadcastBinMonitor',
+        LogService::log('海柔请求done2','broadcast',
             $station_id.'|'.$json);
             $station_id.'|'.$json);
         broadcast(new BroadcastToStation($station_id, $json));
         broadcast(new BroadcastToStation($station_id, $json));
     }
     }
 
 
     function broadcastBinMonitor($station_id, ?StationTask $stationTask){
     function broadcastBinMonitor($station_id, ?StationTask $stationTask){
+        LogService::log('海柔请求in1','broadcastBinMonitor',
+            $station_id.'|'.json_encode($stationTask));
         if(!$stationTask)return;
         if(!$stationTask)return;
         $this->instant($this->stationTaskService,'StationTaskService');
         $this->instant($this->stationTaskService,'StationTaskService');
         if($stationTask['status']=='完成')
         if($stationTask['status']=='完成')
@@ -81,6 +85,8 @@ class StationService
                 "stationTaskBatches.batch",
                 "stationTaskBatches.batch",
                 "stationTaskMaterialBoxes.materialBox",
                 "stationTaskMaterialBoxes.materialBox",
             ]);
             ]);
+        LogService::log('海柔请求done1','broadcastBinMonitor',
+            $station_id.'|'.json_encode($stationTask));
         $this->broadcast($station_id, $stationTask);
         $this->broadcast($station_id, $stationTask);
     }
     }
 
 

+ 7 - 4
resources/views/station/monitor/show.blade.php

@@ -382,10 +382,12 @@
                     });
                     });
                 },
                 },
                 _listenTaskBroadcast(){
                 _listenTaskBroadcast(){
+                    let _this=this;
+                    console.log(this.taskBroadcastName,this.channelName);
                     window.Echo.channel(this.taskBroadcastName).listen(this.channelName,(msg)=> {
                     window.Echo.channel(this.taskBroadcastName).listen(this.channelName,(msg)=> {
-                        console.log((new Date()).toTimeString(),msg);
-                        let json = JSON.parse(msg.json);
-                        if(!json||json.length===0)return;
+                        console.log('1:',(new Date()).toTimeString(),msg);
+                        let taskIn = JSON.parse(msg.json);
+                        if(!taskIn||taskIn.length===0)return;
                         taskIn['station_task_batches'].forEach(function(station_task_batch){
                         taskIn['station_task_batches'].forEach(function(station_task_batch){
                             let taskOld=_this.stationTask_indexByBatch[station_task_batch['batch_id']];
                             let taskOld=_this.stationTask_indexByBatch[station_task_batch['batch_id']];
                             if(typeof(taskOld)==='undefined')return;
                             if(typeof(taskOld)==='undefined')return;
@@ -401,8 +403,9 @@
                 },
                 },
                 _listenAllTaskBroadcast(){
                 _listenAllTaskBroadcast(){
                     let _this=this;
                     let _this=this;
+                    console.log(this.allTaskBroadcastName,this.channelName);
                     window.Echo.channel(this.allTaskBroadcastName).listen(this.channelName,(msg)=> {
                     window.Echo.channel(this.allTaskBroadcastName).listen(this.channelName,(msg)=> {
-                        console.log((new Date()).toTimeString(),msg);
+                        console.log('2:',(new Date()).toTimeString(),msg);
                         let stationTasksIn = JSON.parse(msg.json);
                         let stationTasksIn = JSON.parse(msg.json);
                         if(!stationTasksIn||stationTasksIn.length===0)return;
                         if(!stationTasksIn||stationTasksIn.length===0)return;
                         stationTasksIn.forEach(function(stationTaskIn){
                         stationTasksIn.forEach(function(stationTaskIn){