浏览代码

修改站任务唯一索引

LD 5 年之前
父节点
当前提交
71222d2d73

+ 2 - 2
app/Services/StationRuleBatchService.php

@@ -65,8 +65,8 @@ class StationRuleBatchService
         $batches=$batches->whereNotIn('id',data_get($batches_inTask,'*.id')??[]);
         foreach ($batches as $batch){
             $stationRuleBatch=$this->getByBatch($batch);
-            if($stationRuleBatch)
-                $batches_toProcess->push($batch);
+            if(!$stationRuleBatch)continue;
+            $batches_toProcess->push($batch);
         }
         LogService::log(__METHOD__,'shouldProcess','波次任务分配1.3:'.json_encode($batches_inTask));
         return $batches_toProcess;

+ 32 - 0
database/migrations/2021_04_25_185620_change_index_of_station_task_batches_field_batch_id.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeIndexOfStationTaskBatchesFieldBatchId extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('station_task_batches', function (Blueprint $table) {
+            $table->unique(['batch_id','status'],'s_t_b_unique_batch_id_status');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('station_task_batches', function (Blueprint $table) {
+            $table->dropColumn('s_t_b_unique_batch_id_status');
+        });
+    }
+}