Browse Source

优化队列

huangsanjia 1 year ago
parent
commit
b0d88804d3
1 changed files with 12 additions and 8 deletions
  1. 12 8
      application/api/controller/StaffSalary.php

+ 12 - 8
application/api/controller/StaffSalary.php

@@ -7,7 +7,6 @@ use think\Db;
 use app\job\InsertDataJob;
 use think\Queue;
 use think\Cache;
-
 /**
  * 员工计件工资核算
 */
@@ -468,14 +467,19 @@ class StaffSalary extends Api
             $data[$key]['法定天数'] = $params['days'];
             $data[$key]['sczl_type'] = trim($item['sczl_type']);
         }
-        $num = round(count($data)/10000);
-        for ($i = 0; $i <= $num; $i++){
-            $start = $i * 10000;
-            $res = array_slice($data,$start,10000);
-            $job = new InsertDataJob($res); // 创建任务实例
-            Queue::push($job,'','default'.$i); // 推送任务到队列
-        }
+//        $num = round(count($data)/10000);
+//        for ($i = 0; $i <= $num; $i++){
+//            $start = $i * 10000;
+//            $res = array_slice($data,$start,10000);
+//            $job = new InsertDataJob($res); // 创建任务实例
+//            Queue::push($job,'','default'.$i); // 推送任务到队列
+//        }
+
+        $job = new InsertDataJob($data); // 创建任务实例
+        Queue::push($job,'','default0'); // 推送任务到队列
         $this->success('数据正在处理中,请等待...');
+
+
     }
 
 }