ranjith-dev #249
298
app/Filament/Resources/CncMonitorDataResource.php
Normal file
298
app/Filament/Resources/CncMonitorDataResource.php
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||||
|
use App\Filament\Resources\CncMonitorDataResource\RelationManagers;
|
||||||
|
use App\Models\CncMonitorData;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Hidden;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
|
||||||
|
class CncMonitorDataResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = CncMonitorData::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'CNC Monitoring';
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
Forms\Components\TextInput::make('machine_id')
|
||||||
|
->label('Machine ID'),
|
||||||
|
Forms\Components\DateTimePicker::make('ts')
|
||||||
|
->label('TS'),
|
||||||
|
Forms\Components\TextInput::make('state')
|
||||||
|
->label('State'),
|
||||||
|
Forms\Components\TextInput::make('mode')
|
||||||
|
->label('Mode'),
|
||||||
|
Forms\Components\TextInput::make('run_status')
|
||||||
|
->label('Run Status'),
|
||||||
|
Forms\Components\TextInput::make('state_duration_s')
|
||||||
|
->label('Status Duration S'),
|
||||||
|
Forms\Components\TextInput::make('program')
|
||||||
|
->label('Program'),
|
||||||
|
Forms\Components\TextInput::make('feed_rate')
|
||||||
|
->label('Feed Rate'),
|
||||||
|
Forms\Components\TextInput::make('feed_override')
|
||||||
|
->label('Feed OverRide'),
|
||||||
|
Forms\Components\TextInput::make('spindle_speed')
|
||||||
|
->label('Spindle Speed'),
|
||||||
|
Forms\Components\TextInput::make('spindle_override')
|
||||||
|
->label('Spindle OverRide'),
|
||||||
|
Forms\Components\TextInput::make('spindle_load')
|
||||||
|
->label('Spindle Load'),
|
||||||
|
Forms\Components\TextInput::make('axis_load_x')
|
||||||
|
->label('Axis Load X'),
|
||||||
|
Forms\Components\TextInput::make('axis_load_z')
|
||||||
|
->label('Axis Load Z'),
|
||||||
|
Forms\Components\TextInput::make('tool_no')
|
||||||
|
->label('Tool No'),
|
||||||
|
Forms\Components\TextInput::make('tool_offset_no')
|
||||||
|
->label('Tool Offset No'),
|
||||||
|
Forms\Components\TextInput::make('wear_x')
|
||||||
|
->label('Wear X')
|
||||||
|
->default(null),
|
||||||
|
Forms\Components\TextInput::make('wear_z')
|
||||||
|
->label('Wear Z')
|
||||||
|
->default(null),
|
||||||
|
Forms\Components\TextInput::make('geom_x')
|
||||||
|
->label('Geom X')
|
||||||
|
->default(null),
|
||||||
|
Forms\Components\TextInput::make('geom_z')
|
||||||
|
->label('Geom Z')
|
||||||
|
->default(null),
|
||||||
|
Forms\Components\TextInput::make('cycle_time_s')
|
||||||
|
->label('Cycle Time S'),
|
||||||
|
Forms\Components\TextInput::make('last_cycle_time_s')
|
||||||
|
->label('Last Cycle Time S'),
|
||||||
|
Forms\Components\TextInput::make('part_count')
|
||||||
|
->label('Part Count'),
|
||||||
|
Forms\Components\TextInput::make('alarm_no')
|
||||||
|
->label('Alaram No'),
|
||||||
|
Forms\Components\TextInput::make('alarm_msg')
|
||||||
|
->label('Alaram Msg'),
|
||||||
|
Forms\Components\TextInput::make('total_run_s')
|
||||||
|
->label('Total Run S'),
|
||||||
|
Forms\Components\TextInput::make('total_idle_s')
|
||||||
|
->label('Total Idle S'),
|
||||||
|
Forms\Components\TextInput::make('total_alarm_s')
|
||||||
|
->label('Total Alaram S'),
|
||||||
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->default(Filament::auth()->user()->name),
|
||||||
|
Forms\Components\Hidden::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->default(Filament::auth()->user()->name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('No.')
|
||||||
|
->label('No.')
|
||||||
|
->alignCenter()
|
||||||
|
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||||
|
$paginator = $livewire->getTableRecords();
|
||||||
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
|
}),
|
||||||
|
Tables\Columns\TextColumn::make('ts')
|
||||||
|
->label('TS')
|
||||||
|
->dateTime()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('state')
|
||||||
|
->label('State')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('mode')
|
||||||
|
->label('Mode')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('run_status')
|
||||||
|
->label('Run Status')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('state_duration_s')
|
||||||
|
->label('State Duration S')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('program')
|
||||||
|
->label('Program')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('feed_rate')
|
||||||
|
->label('Feed Rate')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('feed_override')
|
||||||
|
->label('Feed OverRide')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('spindle_speed')
|
||||||
|
->label('Spindle Speed')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('spindle_override')
|
||||||
|
->label('Spindle OverRide')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('spindle_load')
|
||||||
|
->label('Spindle Load')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('axis_load_x')
|
||||||
|
->label('Axis Load X')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('axis_load_z')
|
||||||
|
->label('Axis Load Z')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('tool_no')
|
||||||
|
->label('Tool No')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('tool_offset_no')
|
||||||
|
->label('Tool OffSet No')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('wear_x')
|
||||||
|
->label('Wear X')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('wear_z')
|
||||||
|
->label('Wear Z')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('geom_x')
|
||||||
|
->label('Geom X')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('geom_z')
|
||||||
|
->label('Geom Z')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('cycle_time_s')
|
||||||
|
->label('Cycle Time S')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('last_cycle_time_s')
|
||||||
|
->label('Last Cycle Time S')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('part_count')
|
||||||
|
->label('Part Count')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('total_run_s')
|
||||||
|
->label('Total Run S')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('total_idle_s')
|
||||||
|
->label('Total Idle S')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('total_alarm_s')
|
||||||
|
->label('Total Alaram S')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->label('Created At')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->label('Updated At')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\ViewAction::make(),
|
||||||
|
Tables\Actions\EditAction::make(),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Tables\Actions\BulkActionGroup::make([
|
||||||
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListCncMonitorData::route('/'),
|
||||||
|
'create' => Pages\CreateCncMonitorData::route('/create'),
|
||||||
|
'view' => Pages\ViewCncMonitorData::route('/{record}'),
|
||||||
|
'edit' => Pages\EditCncMonitorData::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CncMonitorDataResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateCncMonitorData extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CncMonitorDataResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CncMonitorDataResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditCncMonitorData extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CncMonitorDataResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\ViewAction::make(),
|
||||||
|
Actions\DeleteAction::make(),
|
||||||
|
Actions\ForceDeleteAction::make(),
|
||||||
|
Actions\RestoreAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CncMonitorDataResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListCncMonitorData extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = CncMonitorDataResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CncMonitorDataResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewCncMonitorData extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CncMonitorDataResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
48
app/Models/CncMonitorData.php
Normal file
48
app/Models/CncMonitorData.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class CncMonitorData extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'machine_id',
|
||||||
|
'ts',
|
||||||
|
'state',
|
||||||
|
'mode',
|
||||||
|
'run_status',
|
||||||
|
'state_duration_s',
|
||||||
|
'program',
|
||||||
|
'feed_rate',
|
||||||
|
'feed_override',
|
||||||
|
'spindle_speed',
|
||||||
|
'spindle_override',
|
||||||
|
'spindle_load',
|
||||||
|
'axis_load_x',
|
||||||
|
'axis_load_z',
|
||||||
|
'tool_no',
|
||||||
|
'tool_offset_no',
|
||||||
|
'wear_x',
|
||||||
|
'wear_z',
|
||||||
|
'geom_x',
|
||||||
|
'geom_z',
|
||||||
|
'cycle_time_s',
|
||||||
|
'last_cycle_time_s',
|
||||||
|
'part_count',
|
||||||
|
'alarm_no',
|
||||||
|
'alarm_msg',
|
||||||
|
'total_run_s',
|
||||||
|
'total_idle_s',
|
||||||
|
'total_alarm_s',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'scanned_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'scanned_by',
|
||||||
|
];
|
||||||
|
}
|
||||||
106
app/Policies/CncMonitorDataPolicy.php
Normal file
106
app/Policies/CncMonitorDataPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Access\Response;
|
||||||
|
use App\Models\CncMonitorData;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class CncMonitorDataPolicy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view any models.
|
||||||
|
*/
|
||||||
|
public function viewAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('view-any CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view the model.
|
||||||
|
*/
|
||||||
|
public function view(User $user, CncMonitorData $cncmonitordata): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('view CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can create models.
|
||||||
|
*/
|
||||||
|
public function create(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('create CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can update the model.
|
||||||
|
*/
|
||||||
|
public function update(User $user, CncMonitorData $cncmonitordata): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('update CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete the model.
|
||||||
|
*/
|
||||||
|
public function delete(User $user, CncMonitorData $cncmonitordata): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('delete CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete any models.
|
||||||
|
*/
|
||||||
|
public function deleteAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('delete-any CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can restore the model.
|
||||||
|
*/
|
||||||
|
public function restore(User $user, CncMonitorData $cncmonitordata): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('restore CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can restore any models.
|
||||||
|
*/
|
||||||
|
public function restoreAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('restore-any CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can replicate the model.
|
||||||
|
*/
|
||||||
|
public function replicate(User $user, CncMonitorData $cncmonitordata): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('replicate CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can reorder the models.
|
||||||
|
*/
|
||||||
|
public function reorder(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('reorder CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can permanently delete the model.
|
||||||
|
*/
|
||||||
|
public function forceDelete(User $user, CncMonitorData $cncmonitordata): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('force-delete CncMonitorData');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can permanently delete any models.
|
||||||
|
*/
|
||||||
|
public function forceDeleteAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('force-delete-any CncMonitorData');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$sql = <<<'SQL'
|
||||||
|
CREATE TABLE cnc_monitor_data (
|
||||||
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
machine_id TEXT DEFAULT NULL,
|
||||||
|
ts TIMESTAMPTZ DEFAULT NULL,
|
||||||
|
state TEXT DEFAULT NULL,
|
||||||
|
mode TEXT DEFAULT NULL,
|
||||||
|
run_status TEXT DEFAULT NULL,
|
||||||
|
state_duration_s TEXT DEFAULT NULL,
|
||||||
|
program TEXT DEFAULT NULL,
|
||||||
|
feed_rate INT DEFAULT NULL,
|
||||||
|
feed_override SMALLINT DEFAULT NULL,
|
||||||
|
spindle_speed INT DEFAULT NULL,
|
||||||
|
spindle_override SMALLINT DEFAULT NULL,
|
||||||
|
spindle_load SMALLINT DEFAULT NULL,
|
||||||
|
axis_load_x SMALLINT DEFAULT NULL,
|
||||||
|
axis_load_z SMALLINT DEFAULT NULL,
|
||||||
|
tool_no SMALLINT DEFAULT NULL,
|
||||||
|
tool_offset_no SMALLINT DEFAULT NULL,
|
||||||
|
wear_x NUMERIC(10,3) DEFAULT NULL,
|
||||||
|
wear_z NUMERIC(10,3) DEFAULT NULL,
|
||||||
|
geom_x NUMERIC(10,3) DEFAULT NULL,
|
||||||
|
geom_z NUMERIC(10,3) DEFAULT NULL,
|
||||||
|
cycle_time_s INT DEFAULT NULL,
|
||||||
|
last_cycle_time_s INT DEFAULT NULL,
|
||||||
|
part_count INT DEFAULT NULL,
|
||||||
|
alarm_no TEXT DEFAULT NULL,
|
||||||
|
alarm_msg TEXT DEFAULT NULL,
|
||||||
|
total_run_s INT DEFAULT NULL,
|
||||||
|
total_idle_s INT DEFAULT NULL,
|
||||||
|
total_alarm_s INT DEFAULT NULL,
|
||||||
|
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
created_by TEXT DEFAULT NULL,
|
||||||
|
updated_by TEXT DEFAULT NULL,
|
||||||
|
deleted_at TIMESTAMP
|
||||||
|
);
|
||||||
|
SQL;
|
||||||
|
DB::statement($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cnc_monitor_data');
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user