Procházet zdrojové kódy

monitor枚举没0的错误

LD před 4 roky
rodič
revize
757c3c7224

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

@@ -72,6 +72,7 @@ class StationController extends Controller
             $station->load("stationTypeBinMonitor");
         }
 //        dd(data_get($station['stationTasks_today'],'*.id'),data_get($station['stationTasks_today'],'*.status'));
+//        $station=$station->toJson();
         return view('station.monitor.show',compact('station'));
     }
 

+ 6 - 1
app/Http/Controllers/api/thirdPart/haiq/HaiRoboticsController.php

@@ -16,10 +16,15 @@ class HaiRoboticsController
     private $stationTaskBatchService=null;
 
     function runTaskBatch(Request $request){
+        $this->instant($this->stationTaskBatchService,'StationTaskBatchService');
         $request->validate(
             ['station_task_batch_id'=>'required|exists:station_task_batches,id']
         );
-        $batchTask=StationTaskBatch::query()->first($request['id']);
+        if(!$request['station_task_batch_id'])return [
+            'success'=>false,
+            'errorMsg'=>'波次任务不能为空'
+        ];
+        $batchTask=StationTaskBatch::query()->find($request['station_task_batch_id']);
         $batchesFailed=$this->stationTaskBatchService->runMany(collect([$batchTask]));//执行波次任务
         if($batchesFailed && $batchesFailed->isNotEmpty()){
             return [

+ 3 - 0
app/MaterialBox.php

@@ -14,6 +14,7 @@ class MaterialBox extends Model
 
     static public $enums=[
         'status'=>[
+            ''=>0,
             '在库外'=>1,
             '在U型线'=>2,
             '在缓存架'=>3,
@@ -34,10 +35,12 @@ class MaterialBox extends Model
 
     public function getStatusAttribute($value)
     {
+        if(!$value)return '';
         return self::$enums['status'][$value];
     }
     public function setStatusAttribute($value)
     {
+        if(!$value)return 0;
         $this->attributes['status']=self::$enums['status'][$value];
     }
 }

+ 37 - 17
resources/views/station/monitor/show.blade.php

@@ -50,7 +50,15 @@
                                         </div>
                                     </div>
                                     <div class="col">
-                                        <button class="btn btn-info btn-lg mt-4" @click="runTheTaskBatch(current_stationTaskBatch)">
+                                        <button class="btn btn-lg mt-4" @click="runTheTaskBatch()"
+                                                :class="[
+                                            (current_stationTaskBatch.runningStatus==='')?'btn-info':'',
+                                            (current_stationTaskBatch.runningStatus==='请求中')?'btn-dark':'',
+                                            (current_stationTaskBatch.runningStatus==='请求失败')?'btn-danger':'',
+                                            (current_stationTaskBatch.runningStatus==='请求成功')?'btn-success':'',
+                                            (current_stationTaskBatch.runningStatus==='请求异常')?'btn-danger':'',
+                                         ]"
+                                        >
                                             <span v-if="!current_stationTaskBatch.runningStatus">执行</span>
                                             <span v-if="current_stationTaskBatch.runningStatus==='请求中'">请求中</span>
                                             <span v-if="current_stationTaskBatch.runningStatus==='请求失败'">(失败)重新执行</span>
@@ -67,7 +75,7 @@
                                 <div class="text-center my-2" style="overflow-y: scroll;max-height:200px;">
                                     <div class="flex flex-column flex-wrap" v-if="stationTaskBatches">
                                         <button v-for="stationTaskBatch in stationTaskBatches"
-                                                @click="current_stationTaskBatch=stationTaskBatch"
+                                                @click="selectBatch(stationTaskBatch)"
                                                 class="btn"
                                                 :class="[
                                                     (current_stationTaskBatch&&current_stationTaskBatch.id===stationTaskBatch.id)?'btn-outline-info':'btn-outline-dark',
@@ -331,7 +339,7 @@
                 broadcastName : "{{config('database.redis.options.prefix').'station-'.$station->id}}",
                 channelName : ".App\\Events\\BroadcastToStation",
                 error:"",
-                station:{!! $station??[] !!},
+                station:{!! $station !!},
                 inputs:{
                     manuallyTakeBox:{
                         visible:false,
@@ -339,6 +347,8 @@
                     }
                 },
                 current_stationTaskBatch: null,
+                stationTask_indexByBatch: [],
+                stationTaskBatch_index: [],
                 grids:{
                     single:{status:'',},
                     half:{
@@ -379,12 +389,17 @@
                         this.station['current_station_task']=json;
                     });
                 },
+                selectBatch(stationTaskBatch){
+                    this.current_stationTaskBatch=stationTaskBatch;
+                    if(typeof(this.current_stationTaskBatch.runningStatus)==='undefined')
+                        this.current_stationTaskBatch.runningStatus=''
+                },
                 manuallyTakeBoxOut(){
                     let text = this.inputs.manuallyTakeBox.text.trim();
                     if(!text){
                         alert('请输入料箱号')
                         return
-                    };
+                    }
                     axios.post('{{url('/api/thirdPart/haiq/storage/takeOutToULine')}}',{codes:text})
                         .then(function(response){
                             tempTip.okWindow(response.data.result,'确定')
@@ -394,25 +409,29 @@
                         this.inputs.manuallyTakeBox.text='';
                     })
                 },
-                runTheTaskBatch(stationTaskBatch){
-                    stationTaskBatch.runningStatus='请求中'
-                    axios.post('{{url('/api/thirdPart/haiq/runTaskBatch')}}',{station_task_batch_id:stationTaskBatch.id})
+                runTheTaskBatch(){
+                    let _this=this;
+                    _this.current_stationTaskBatch.runningStatus='请求中';
+                    _this.$forceUpdate();
+                    axios.post('{{url('/api/thirdPart/haiq/runTaskBatch')}}',{station_task_batch_id:_this.current_stationTaskBatch.id})
                         .then(function(response){
                             if(!response.data.success){
-                                stationTaskBatch.runningStatus='请求失败';
+                                _this.current_stationTaskBatch.runningStatus='请求失败';
                                 return;
                             }
-                            stationTaskBatch.runningStatus='请求成功'
+                            _this.current_stationTaskBatch.runningStatus='请求成功'
                         }).catch(function(err){
-                        stationTaskBatch.runningStatus='请求异常'
-                        tempTip.okWindow(err,'确定')
-                    })
+                        _this.current_stationTaskBatch.runningStatus='请求异常'
+                        tempTip.okWindow(err+': 服务器代码出错,请联系开发部门负责人','确定')
+                    }).finally(function(){
+                        _this.$forceUpdate();
+                    });
                 },
             },
             computed:{
                 task(){
-                    if(!this.station['current_station_task'])return null;
-                    return this.station['current_station_task'];
+                    if(!this.current_stationTaskBatch||typeof(this.current_stationTaskBatch['_'+this.current_stationTaskBatch.batch_id])==='undefined')return null;
+                    return this.stationTask_indexByBatch['_'+this.current_stationTaskBatch.batch_id]
                 },
                 stationTasks(){
                     if(!this.station)return;
@@ -420,16 +439,17 @@
                 },
                 stationTaskBatches(){
                     if(!this.stationTasks)return;
+                    let _this=this;
                     let stationTaskBatches=[];
-                    let stationTaskBatch_index=[];
                     this.stationTasks.forEach(function(stationTask){
                         if(!stationTask.station_task_batches)return;
                         stationTask.station_task_batches.forEach(function(stationTaskBatch){
-                            if(typeof(stationTaskBatch_index['_'+stationTaskBatch.batch_id])==='undefined'){
+                            if(typeof(_this.stationTaskBatch_index['_'+stationTaskBatch.batch_id])==='undefined'){
                                 // if(stationTaskBatch_index['_'+stationTaskBatch.batch_id]['status']==='完成')return;
                                 stationTaskBatches.push(stationTaskBatch)
+                                _this.stationTaskBatch_index['_'+stationTaskBatch.batch_id]=stationTaskBatch;
+                                _this.stationTask_indexByBatch['_'+stationTaskBatch.batch_id]=stationTask;
                             }
-                            stationTaskBatch_index['_'+stationTaskBatch.batch_id]=stationTaskBatch;
                         })
                     });
                     return stationTaskBatches;