/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.summonses_list_subsystem.tables;


import java.math.BigDecimal;
import java.util.Collection;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.PlainSQL;
import org.jooq.QueryPart;
import org.jooq.SQL;
import org.jooq.Schema;
import org.jooq.Select;
import org.jooq.Stringly;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import ru.micord.webbpm.ervu.business_metrics.db_beans.summonses_list_subsystem.SummonsesListSubsystem;
import ru.micord.webbpm.ervu.business_metrics.db_beans.summonses_list_subsystem.tables.records.ViewSummonsesDirectToPersAccRecord;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class ViewSummonsesDirectToPersAcc extends TableImpl<ViewSummonsesDirectToPersAccRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc</code>
     */
    public static final ViewSummonsesDirectToPersAcc VIEW_SUMMONSES_DIRECT_TO_PERS_ACC = new ViewSummonsesDirectToPersAcc();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<ViewSummonsesDirectToPersAccRecord> getRecordType() {
        return ViewSummonsesDirectToPersAccRecord.class;
    }

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc.summonses_direct_to_pers_acc_id</code>.
     */
    public final TableField<ViewSummonsesDirectToPersAccRecord, Long> SUMMONSES_DIRECT_TO_PERS_ACC_ID = createField(DSL.name("summonses_direct_to_pers_acc_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc.count_all</code>.
     */
    public final TableField<ViewSummonsesDirectToPersAccRecord, Long> COUNT_ALL = createField(DSL.name("count_all"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc.percent_draft_board</code>.
     */
    public final TableField<ViewSummonsesDirectToPersAccRecord, BigDecimal> PERCENT_DRAFT_BOARD = createField(DSL.name("percent_draft_board"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc.percent_recruitment_company</code>.
     */
    public final TableField<ViewSummonsesDirectToPersAccRecord, BigDecimal> PERCENT_RECRUITMENT_COMPANY = createField(DSL.name("percent_recruitment_company"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc.percent_military_registration</code>.
     */
    public final TableField<ViewSummonsesDirectToPersAccRecord, BigDecimal> PERCENT_MILITARY_REGISTRATION = createField(DSL.name("percent_military_registration"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc.percent_mobilisation</code>.
     */
    public final TableField<ViewSummonsesDirectToPersAccRecord, BigDecimal> PERCENT_MOBILISATION = createField(DSL.name("percent_mobilisation"), SQLDataType.NUMERIC, this, "");

    private ViewSummonsesDirectToPersAcc(Name alias, Table<ViewSummonsesDirectToPersAccRecord> aliased) {
        this(alias, aliased, (Field<?>[]) null, null);
    }

    private ViewSummonsesDirectToPersAcc(Name alias, Table<ViewSummonsesDirectToPersAccRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_summonses_direct_to_pers_acc" as  SELECT summonses_direct_to_pers_acc.summonses_direct_to_pers_acc_id,
         (((summonses_direct_to_pers_acc.count_draft_board + summonses_direct_to_pers_acc.count_recruitment_company) + summonses_direct_to_pers_acc.count_military_registration) + summonses_direct_to_pers_acc.count_mobilisation) AS count_all,
         COALESCE(round((((summonses_direct_to_pers_acc.count_draft_board)::numeric * (100)::numeric) / NULLIF(((((summonses_direct_to_pers_acc.count_draft_board + summonses_direct_to_pers_acc.count_recruitment_company) + summonses_direct_to_pers_acc.count_military_registration) + summonses_direct_to_pers_acc.count_mobilisation))::numeric, (0)::numeric))), (0)::numeric) AS percent_draft_board,
         COALESCE(round((((summonses_direct_to_pers_acc.count_recruitment_company)::numeric * (100)::numeric) / NULLIF(((((summonses_direct_to_pers_acc.count_draft_board + summonses_direct_to_pers_acc.count_recruitment_company) + summonses_direct_to_pers_acc.count_military_registration) + summonses_direct_to_pers_acc.count_mobilisation))::numeric, (0)::numeric))), (0)::numeric) AS percent_recruitment_company,
         COALESCE(round((((summonses_direct_to_pers_acc.count_military_registration)::numeric * (100)::numeric) / NULLIF(((((summonses_direct_to_pers_acc.count_draft_board + summonses_direct_to_pers_acc.count_recruitment_company) + summonses_direct_to_pers_acc.count_military_registration) + summonses_direct_to_pers_acc.count_mobilisation))::numeric, (0)::numeric))), (0)::numeric) AS percent_military_registration,
         COALESCE(round((((summonses_direct_to_pers_acc.count_mobilisation)::numeric * (100)::numeric) / NULLIF(((((summonses_direct_to_pers_acc.count_draft_board + summonses_direct_to_pers_acc.count_recruitment_company) + summonses_direct_to_pers_acc.count_military_registration) + summonses_direct_to_pers_acc.count_mobilisation))::numeric, (0)::numeric))), (0)::numeric) AS percent_mobilisation
        FROM summonses_list_subsystem.summonses_direct_to_pers_acc;
        """), where);
    }

    /**
     * Create an aliased
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc</code>
     * table reference
     */
    public ViewSummonsesDirectToPersAcc(String alias) {
        this(DSL.name(alias), VIEW_SUMMONSES_DIRECT_TO_PERS_ACC);
    }

    /**
     * Create an aliased
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc</code>
     * table reference
     */
    public ViewSummonsesDirectToPersAcc(Name alias) {
        this(alias, VIEW_SUMMONSES_DIRECT_TO_PERS_ACC);
    }

    /**
     * Create a
     * <code>summonses_list_subsystem.view_summonses_direct_to_pers_acc</code>
     * table reference
     */
    public ViewSummonsesDirectToPersAcc() {
        this(DSL.name("view_summonses_direct_to_pers_acc"), null);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : SummonsesListSubsystem.SUMMONSES_LIST_SUBSYSTEM;
    }

    @Override
    public ViewSummonsesDirectToPersAcc as(String alias) {
        return new ViewSummonsesDirectToPersAcc(DSL.name(alias), this);
    }

    @Override
    public ViewSummonsesDirectToPersAcc as(Name alias) {
        return new ViewSummonsesDirectToPersAcc(alias, this);
    }

    @Override
    public ViewSummonsesDirectToPersAcc as(Table<?> alias) {
        return new ViewSummonsesDirectToPersAcc(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewSummonsesDirectToPersAcc rename(String name) {
        return new ViewSummonsesDirectToPersAcc(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewSummonsesDirectToPersAcc rename(Name name) {
        return new ViewSummonsesDirectToPersAcc(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewSummonsesDirectToPersAcc rename(Table<?> name) {
        return new ViewSummonsesDirectToPersAcc(name.getQualifiedName(), null);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewSummonsesDirectToPersAcc where(Condition condition) {
        return new ViewSummonsesDirectToPersAcc(getQualifiedName(), aliased() ? this : null, null, condition);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewSummonsesDirectToPersAcc where(Collection<? extends Condition> conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewSummonsesDirectToPersAcc where(Condition... conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewSummonsesDirectToPersAcc where(Field<Boolean> condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewSummonsesDirectToPersAcc where(SQL condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewSummonsesDirectToPersAcc where(@Stringly.SQL String condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewSummonsesDirectToPersAcc where(@Stringly.SQL String condition, Object... binds) {
        return where(DSL.condition(condition, binds));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewSummonsesDirectToPersAcc where(@Stringly.SQL String condition, QueryPart... parts) {
        return where(DSL.condition(condition, parts));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewSummonsesDirectToPersAcc whereExists(Select<?> select) {
        return where(DSL.exists(select));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewSummonsesDirectToPersAcc whereNotExists(Select<?> select) {
        return where(DSL.notExists(select));
    }
}
