LD 5 anni fa
parent
commit
44f5e17eb7

+ 42 - 5
app/Services/StationTaskMaterialBoxService.php

@@ -103,6 +103,8 @@ class StationTaskMaterialBoxService
     function markHasTaken(StationTaskMaterialBox $stationTaskMaterialBox){
         $this->instant($this->stationTaskBatchService,'StationTaskBatchService');
         $this->instant($this->stationTaskCommodityService,'StationTaskCommodityService');
+        $this->instant($this->stationTaskService,'StationTaskService');
+        $this->instant($this->stationService,'StationService');
         try{
             $taskType=$this->getServingTaskType($stationTaskMaterialBox);
             switch ($taskType){
@@ -111,6 +113,7 @@ class StationTaskMaterialBoxService
                     $this->stationTaskBatchService->markProcessing_byIds($stationTaskMaterialBox['station_task_batch_id']);
                     $this->stationTaskCommodityService->markProcessing($stationTaskMaterialBox['stationTaskCommodities']);
                     $this->stationTaskService->markProcessing_byIds(data_get($stationTaskMaterialBox['stationTaskCommodities'],'*.station_task_id'));
+                    $this->stationService->broadcastBinMonitor($stationTaskMaterialBox['station_id'],$stationTaskMaterialBox['stationTask']);
                     break;
                 case '入立库':
 
@@ -132,21 +135,55 @@ class StationTaskMaterialBoxService
         $stationTaskMaterialBox->update();
     }
 
+    /**
+     * 每波次仅将最老的作务标为“处理中”,其他置入队列;
+     * 如某波次已经有“处理中“,则他部置入队列
+     * @param $stationTaskMaterialBox_orBoxes Collection 单个或多个
+     */
     function markProcessing($stationTaskMaterialBox_orBoxes)
     {
         $this->instant($this->stationTaskService,'StationTaskService');
-        if (get_class($stationTaskMaterialBox_orBoxes)==StationTaskMaterialBox::class){
-            $stationTaskMaterialBox_orBoxes = collect([$stationTaskMaterialBox_orBoxes]);
-        }
+        $stationTaskMaterialBoxes =
+            (function()use($stationTaskMaterialBox_orBoxes){
+            if (get_class($stationTaskMaterialBox_orBoxes)==StationTaskMaterialBox::class){
+                return collect([$stationTaskMaterialBox_orBoxes]);
+            }
+            return collect($stationTaskMaterialBox_orBoxes);
+        })();
+        ($按时间从前往后排出顺序=function ()use(&$stationTaskMaterialBoxes){
+            $stationTaskMaterialBoxes=$stationTaskMaterialBoxes
+                ->orderBy('id','asc')
+                ->groupBy('station_task_batch_id')
+                ->get();
+        })();
+        $stationTaskMaterialBoxes->each(function($groupByBatch){
+            $taskBatchId=$groupByBatch[0]['station_task_batch_id'];
+            $processing=$this->getProcessing_byTaskBatch($taskBatchId);
+            if(!$processing){
+                $groupByBatch->each(function ($stationTaskMaterialBox){
+
+                });
+            }
+        });
         StationTaskMaterialBox::query()
-            ->whereIn('id', data_get($stationTaskMaterialBox_orBoxes, '*.id'))
+            ->whereIn('id', data_get($stationTaskMaterialBoxes, '*.id'))
             ->update(['status'=>'处理中']);
         $this->stationTaskService
             ->markProcessing_byIds(
-                data_get($stationTaskMaterialBox_orBoxes, '*.station_id')
+                data_get($stationTaskMaterialBoxes, '*.station_id')
             );
     }
 
+    function getProcessing_byTaskBatch($stationTaskBatch_id)
+    {
+        //这里不能用缓存,因为更新会非常快
+        return StationTaskMaterialBox::query()
+            ->where('station_task_batch_id',$stationTaskBatch_id)
+            ->where('status','处理中')
+            ->first();
+
+    }
+
     function excepted($stationTaskMaterialBoxes_orBox){
         if (get_class($stationTaskMaterialBoxes_orBox)==StationTaskMaterialBox::class){
             $stationTaskMaterialBoxes_orBox = collect([$stationTaskMaterialBoxes_orBox]);

+ 33 - 0
database/migrations/2021_02_24_131916_add_process_list_type_to_status.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Support\Facades\DB;
+
+class AddProcessListTypeToStatus extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        DB::statement("ALTER TABLE station_tasks MODIFY COLUMN status enum ('待处理','挂起','处理队列','处理中','完成','异常','取消') default '待处理'");
+        DB::statement("ALTER TABLE station_task_batches MODIFY COLUMN status enum ('待处理','挂起','处理队列','处理中','完成','异常','取消') default '待处理'");
+        DB::statement("ALTER TABLE station_task_material_boxes MODIFY COLUMN status enum ('待处理','挂起','处理队列','处理中','完成','异常','取消') default '待处理'");
+        DB::statement("ALTER TABLE station_task_commodities MODIFY COLUMN status enum ('待处理','挂起','处理队列','处理中','完成','异常','取消') default '待处理'");
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        DB::statement("ALTER TABLE station_tasks MODIFY COLUMN status enum ('待处理','挂起','处理中','完成','异常','取消') default '待处理'");
+        DB::statement("ALTER TABLE station_task_batches MODIFY COLUMN status enum ('待处理','挂起','处理中','完成','异常','取消') default '待处理'");
+        DB::statement("ALTER TABLE station_task_material_boxes MODIFY COLUMN status enum ('待处理','挂起','处理中','完成','异常','取消') default '待处理'");
+        DB::statement("ALTER TABLE station_task_commodities MODIFY COLUMN status enum ('待处理','挂起','处理中','完成','异常','取消') default '待处理'");
+    }
+}

+ 2 - 1
resources/views/station/monitor/show.blade.php

@@ -59,7 +59,7 @@
                         </div>
                         <div class="row mb-1">
                             <div class="col-1 text-left font-weight-bold">数量:</div>
-                            <div class="col-2 text-left">@{{ task.sum }}/@{{ task.currentSum }}</div>
+                            <div class="col-2 text-left">@{{ task.currentSum }}/@{{ task.sum }}</div>
                             <div class="col-1 offset-2 text-muted" v-if="error">异常:</div>
                             <div class="col-6" v-if="error">@{{ error }}</div>
                         </div>
@@ -166,6 +166,7 @@
                     });
                     task.taskBatch=obj.station_task_batches[0];
                     setBarcode(task.taskBatch.batch.code,"#barcode",2,50,false);
+                    console.log(task)
                     this.task = task;
                 },
                 //渲染墙格口

+ 52 - 2
tests/Services/ForeignHaiRoboticsService/TempMarkBinProcessedTest.php

@@ -51,7 +51,7 @@ class MarkBinProcessedTest extends TestCase
 
     }
 
-    public function testReturned()
+    public function testMarkBinProcessed()
     {
         $this->service->markBinProcessed(
             '',
@@ -62,10 +62,60 @@ class MarkBinProcessedTest extends TestCase
             true);
         $this->assertTrue(true);
     }
+    public function testMarkBinProcessed2()
+    {
+        $this->service->markBinProcessed(
+            '',
+            "8c2ae097-dad7-314c-b586-2d0eb2709b62",
+            true,
+            '',
+            '',
+            true);
+        $this->assertTrue(true);
+    }
+    public function testTaskUpdate()
+    {
+        $this->service->taskUpdate(
+            '1739',
+            0,
+            0,
+            "8b839c28-f2e3-3d56-b34a-d9ac4fd81fa2"
+        );
+        $this->assertTrue(true);
+    }
+    public function testTaskUpdate2()
+    {
+        $this->service->taskUpdate(
+            '1738',
+            0,
+            0,
+            "8c2ae097-dad7-314c-b586-2d0eb2709b62"
+        );
+        $this->assertTrue(true);
+    }
+    public function testTaskUpdate3()
+    {
+        $this->service->taskUpdate(
+            '1737',
+            0,
+            0,
+            "fa61ad33-6598-339b-9a32-a73a4720b46b"
+        );
+        $this->assertTrue(true);
+    }
+    public function testTaskUpdate4()
+    {
+        $this->service->taskUpdate(
+            '1736',
+            0,
+            0,
+            "03c0bde8-b5d7-393d-918e-383d38a1efe9"
+        );
+        $this->assertTrue(true);
+    }
 
     function tearDown(): void
     {
-
         parent::tearDown();
     }
 }