|
|
@@ -78,55 +78,6 @@ class ManDeviceJobHc implements ShouldQueue
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Execute the job.
|
|
|
- *
|
|
|
- * @return void
|
|
|
- */
|
|
|
-// public function handle()
|
|
|
-// {
|
|
|
-// try {
|
|
|
-// if (empty($this->data['data'])) return;
|
|
|
-//
|
|
|
-// $deviceId = $this->data['data']['deviceId'];
|
|
|
-// $dataPoints = $this->data['data']['dataPoints'] ?? [];
|
|
|
-//
|
|
|
-// if ($this->data['type'] == "dataPoint") {
|
|
|
-// $redisKey = 'buffer:hengchang_data';
|
|
|
-// $batchSize = 500;
|
|
|
-//
|
|
|
-// // 1. 整理数据并推入 Redis 列表
|
|
|
-// $records = [];
|
|
|
-// foreach ($dataPoints as $value) {
|
|
|
-// if (empty($value['value'])) continue;
|
|
|
-//
|
|
|
-// $records[] = json_encode([
|
|
|
-// 'machine_code' => $deviceId . $value['dataPointId'],
|
|
|
-// 'param_value' => floatval($value['value']),
|
|
|
-// 'time' => $this->getNowDay()
|
|
|
-// ]);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (!empty($records)) {
|
|
|
-// // 批量推入 Redis
|
|
|
-// \Illuminate\Support\Facades\Redis::rpush($redisKey, ...$records);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 2. 检查 Redis 里的总条数
|
|
|
-// $currentCount = \Illuminate\Support\Facades\Redis::llen($redisKey);
|
|
|
-//
|
|
|
-// // 3. 达到 500 条,执行批量发送
|
|
|
-//
|
|
|
-// if ($currentCount >= $batchSize) {
|
|
|
-// $this->processBatchSend($redisKey, $batchSize);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } catch (\Exception $exception) {
|
|
|
-// Log::channel('apiLog')->info('hc开始位置', ["param" => $exception->getMessage()]);
|
|
|
-// $this->delete();
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
/**
|
|
|
* 批量处理发送逻辑
|
|
|
*/
|
|
|
@@ -139,7 +90,7 @@ class ManDeviceJobHc implements ShouldQueue
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- $batchData = array_map(fn($item) => json_decode($item, true), array_filter($rawRecords));
|
|
|
+ $batchData = array_values(array_map(fn($item) => json_decode($item, true), array_filter($rawRecords)));
|
|
|
|
|
|
if (empty($batchData)) return;
|
|
|
|