虫情数据

dev
Jing Li 2023-08-28 16:39:51 +08:00
parent 61dc022054
commit cd9a6bc3d0
3 changed files with 6 additions and 6 deletions

View File

@ -5,7 +5,7 @@ namespace App\Console\Commands\BiAng;
use App\Enums\DeviceStatus;
use App\Enums\DeviceType;
use App\Models\Device;
use App\Models\WormStatisticsReport;
use App\Models\WormReport;
use App\Services\BiAngDeviceService;
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
@ -53,7 +53,7 @@ class WormStatisticsSyncCommand extends Command
foreach ($devices as $device) {
$this->info('==================================');
$latestReportedAt = WormStatisticsReport::Where('device_id', $device->id)->latest('reported_at')->value('reported_at');
$latestReportedAt = WormReport::Where('device_id', $device->id)->latest('reported_at')->value('reported_at');
$start = $latestReportedAt ? $latestReportedAt->copy() : $today->copy()->subDays(179);
@ -76,7 +76,7 @@ class WormStatisticsSyncCommand extends Command
foreach (data_get($statistics, 'data.records', []) as $item) {
$data = collect(Arr::except($item, '日期'))->map(fn ($v, $k) => ['name' => $k, 'num' => $v]);
WormStatisticsReport::updateOrCreate([
WormReport::updateOrCreate([
'device_id' => $device->id,
'reported_at' => $item['日期'],
], [

View File

@ -5,7 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class WormStatisticsReport extends Model
class WormReport extends Model
{
use HasFactory;

View File

@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('worm_statistics_reports', function (Blueprint $table) {
Schema::create('worm_reports', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('device_id');
$table->unsignedBigInteger('agricultural_base_id')->comment('农业基地ID');
@ -31,6 +31,6 @@ return new class extends Migration
*/
public function down()
{
Schema::dropIfExists('worm_statistics_reports');
Schema::dropIfExists('worm_reports');
}
};