Просмотр исходного кода

海柔波次任务重复的避免

LD 4 лет назад
Родитель
Сommit
9703f3787c

+ 2 - 2
app/Http/Controllers/StationController.php

@@ -58,7 +58,7 @@ class StationController extends Controller
         $station->loadMissing([
             "stationTasks_today.stationTaskCommodities.commodity.barcodes",
             "stationTasks_today.stationTaskCommodities.materialBox",
-            "stationTasks_today.stationTaskBatches.batch",
+            "stationTasks_today.stationTaskBatches.batch.owner",
             "stationTasks_today.stationTaskMaterialBoxes.materialBox",
             "stationTypeBinMonitor",
         ]);
@@ -71,7 +71,7 @@ class StationController extends Controller
             ]);
             $station->load("stationTypeBinMonitor");
         }
-//        dd(data_get($station['stationTasks_today'],'*.id'),data_get($station['stationTasks_today'],'*.batch_id'));
+//        dd(data_get($station['stationTasks_today'],'*.id'),data_get($station['stationTasks_today'],'*.status'));
         return view('station.monitor.show',compact('station'));
     }
 

+ 4 - 4
app/Http/Controllers/ForeignHaiRoboticsController.php → app/Http/Controllers/api/thirdPart/haiq/HaiRoboticsController.php

@@ -1,23 +1,23 @@
 <?php
 
 
-namespace App\Http\Controllers;
+namespace App\Http\Controllers\api\thirdPart\haiq;
 
 
 use App\Services\StationTaskBatchService;
 use App\StationTaskBatch;
 use Illuminate\Http\Request;
 use App\Traits\TestableInstant;
-class ForeignHaiRoboticsController
+class HaiRoboticsController
 {
     use TestableInstant;
 
     /** @var StationTaskBatchService $stationTaskBatchService */
     private $stationTaskBatchService=null;
 
-    function runBatch(Request $request){
+    function runTaskBatch(Request $request){
         $request->validate(
-            ['id'=>'required|exists:station_task_batches,id']
+            ['station_task_batch_id'=>'required|exists:station_task_batches,id']
         );
         $batchTask=StationTaskBatch::query()->first($request['id']);
         $batchesFailed=$this->stationTaskBatchService->runMany(collect([$batchTask]));//执行波次任务

+ 3 - 3
app/Services/StationRuleBatchService.php

@@ -61,9 +61,9 @@ class StationRuleBatchService
     {
         LogService::log(__METHOD__,'shouldProcess','波次任务分配1.1:'.json_encode($batches));
         $batches_toProcess=collect();
-        $batches_inTask=StationTaskBatch::query()->whereIn('batch_id',data_get($batches,'*.id'))->get();
-        LogService::log(__METHOD__,'shouldProcess','波次任务分配1.2:'.json_encode($batches_inTask));
-        $batches=$batches->whereNotIn('id',data_get($batches_inTask,'*.id')??[]);
+        $stationTaskBatches_inTask=StationTaskBatch::query()->whereIn('batch_id',data_get($batches,'*.id'))->get();
+        LogService::log(__METHOD__,'shouldProcess','波次任务分配1.2:'.json_encode($stationTaskBatches_inTask));
+        $batches=$batches->whereNotIn('id',data_get($stationTaskBatches_inTask,'*.batch_id')??[]);
         foreach ($batches as $batch){
             $stationRuleBatch=$this->getByBatch($batch);
             if(!$stationRuleBatch)continue;

+ 2 - 2
app/Station.php

@@ -31,8 +31,8 @@ class Station extends Model
     public function stationTasks_today(){
         return $this->hasMany(StationTask::class)
             ->where('created_at','>=',now()->format('Y-m-d'))
-            ->orderByDesc('status')
-            ->orderBy('id')
+            ->orderBy('status')
+            ->orderByDesc('id')
             ;
     }
     public function stationTypeBinMonitor(){

+ 1 - 1
config/haiRou.php

@@ -1,5 +1,5 @@
 <?php
 
 return [
-    "波次防重叠时间_秒" => 1200,
+    "波次防重叠时间_秒" => 1800,
 ];

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

@@ -30,16 +30,26 @@
                                     <div class="col">选择执行波次:</div>
                                 </div>
                                 <div class="row" v-if="current_stationTaskBatch">
-                                    <div class="col font-weight-bold text-right text-info"
+                                    <div class="col font-weight-bold text-center text-info position-relative"
                                          :style="[
                                                     {opacity:
                                                         current_stationTaskBatch.status==='完成'?'0.5':'1'
                                                     },
-                                                ]"
-                                    >@{{ current_stationTaskBatch.batch.code }}</div>
-                                    <div class="col"><button class="btn btn-info">执行</button></div>
+                                                ]"runningStatus
+                                         :class="[
+
+                                         ]"
+                                    >
+                                        <div class="text-center">@{{ current_stationTaskBatch.batch.code }}</div>
+                                            <div class="text-center" style="font-size: 12px;">
+                                                @{{ current_stationTaskBatch.batch.owner.name }}
+                                            </div>
+                                    </div>
+                                    <div class="col">
+                                        <button class="btn btn-info" @click="runTheTaskBatch(current_stationTaskBatch)">执行</button>
+                                    </div>
                                 </div>
-                                <div class="text-center mt-2" style="overflow: scroll;height:200px;">
+                                <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"
@@ -374,6 +384,20 @@
                         this.inputs.manuallyTakeBox.text='';
                     })
                 },
+                runTheTaskBatch($taskBatch){
+                    $taskBatch.runningStatus='请求中'
+                    axios.post('{{url('/api/thirdPart/haiq/runTaskBatch')}}',{station_task_batch_id:$taskBatch.id})
+                        .then(function(response){
+                            if(!response.data.success){
+                                $taskBatch.runningStatus='请求失败';
+                                return;
+                            }
+                            $taskBatch.runningStatus='请求成功'
+                        }).catch(function(err){
+                        $taskBatch.runningStatus='请求异常'
+                        tempTip.okWindow(err,'确定')
+                    })
+                },
             },
             computed:{
                 task(){
@@ -391,8 +415,10 @@
                     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')return;
-                            stationTaskBatches.push(stationTaskBatch)
+                            if(typeof(stationTaskBatch_index['_'+stationTaskBatch.batch_id])!=='undefined'){
+                                if(stationTaskBatch_index['_'+stationTaskBatch.batch_id]['status']==='完成')return;
+                                stationTaskBatches.push(stationTaskBatch)
+                            }
                             stationTaskBatch_index['_'+stationTaskBatch.batch_id]=stationTaskBatch;
                         })
                     });

+ 3 - 0
routes/api/thirdPart/haiq.php

@@ -27,3 +27,6 @@ Route::group(['prefix'=>'pickStation'],function(){
 Route::group(['prefix'=>'light'],function(){
     Route::post('update', "LightController@update");//移库
 });
+
+
+Route::post('runTaskBatch', "HaiRoboticsController@runTaskBatch");//启动taskBatch任务