<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProcessStatisticsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * 二次加工统计表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('process_statistics', function (Blueprint $table) {
            $table->bigInteger('process_id')->unique()->comment('外键二次加工单');
            $table->timestamp('started_at')->nullable()->comment('开始日期');
            $table->timestamp('ended_at')->nullable()->comment('结束日期');
            $table->decimal('revenue')->nullable()->comment('收入合计');
            $table->integer('duration_days')->nullable()->comment('完成天数');
            $table->integer('duration_man_hours')->nullable()->comment('总工时');
            $table->integer('top_capacity')->nullable()->comment('最高日产能');
            $table->integer('bottom_capacity')->nullable()->comment('最低日产能');
            $table->integer('average_capacity')->nullable()->comment('平均日产能');
            $table->decimal('total_cost')->nullable()->comment('合计成本');
            $table->decimal('gross_profit')->nullable()->comment('毛利润');
            $table->decimal('gross_profit_rate',7,3)->nullable()->comment('毛利率');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('process_statistics');
    }
}
