/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.journal_log.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.journal_log.JournalLog;
import ru.micord.webbpm.ervu.business_metrics.db_beans.journal_log.tables.records.ViewSummonsesListDataExchangeRecord;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>journal_log.view_summonses_list_data_exchange</code>
     */
    public static final ViewSummonsesListDataExchange VIEW_SUMMONSES_LIST_DATA_EXCHANGE = new ViewSummonsesListDataExchange();

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

    /**
     * The column
     * <code>journal_log.view_summonses_list_data_exchange.summonses_list_data_exchange_id</code>.
     */
    public final TableField<ViewSummonsesListDataExchangeRecord, Long> SUMMONSES_LIST_DATA_EXCHANGE_ID = createField(DSL.name("summonses_list_data_exchange_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>journal_log.view_summonses_list_data_exchange.percent_entry_system</code>.
     */
    public final TableField<ViewSummonsesListDataExchangeRecord, BigDecimal> PERCENT_ENTRY_SYSTEM = createField(DSL.name("percent_entry_system"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_summonses_list_data_exchange.percent_entry_system_error</code>.
     */
    public final TableField<ViewSummonsesListDataExchangeRecord, BigDecimal> PERCENT_ENTRY_SYSTEM_ERROR = createField(DSL.name("percent_entry_system_error"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_summonses_list_data_exchange.count_without_entry_system</code>.
     */
    public final TableField<ViewSummonsesListDataExchangeRecord, Long> COUNT_WITHOUT_ENTRY_SYSTEM = createField(DSL.name("count_without_entry_system"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>journal_log.view_summonses_list_data_exchange.percent_request_extract</code>.
     */
    public final TableField<ViewSummonsesListDataExchangeRecord, BigDecimal> PERCENT_REQUEST_EXTRACT = createField(DSL.name("percent_request_extract"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_summonses_list_data_exchange.percent_request_extract_error</code>.
     */
    public final TableField<ViewSummonsesListDataExchangeRecord, BigDecimal> PERCENT_REQUEST_EXTRACT_ERROR = createField(DSL.name("percent_request_extract_error"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_summonses_list_data_exchange.count_without_request_extract</code>.
     */
    public final TableField<ViewSummonsesListDataExchangeRecord, Long> COUNT_WITHOUT_REQUEST_EXTRACT = createField(DSL.name("count_without_request_extract"), SQLDataType.BIGINT, this, "");

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

    private ViewSummonsesListDataExchange(Name alias, Table<ViewSummonsesListDataExchangeRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_summonses_list_data_exchange" as  SELECT t.summonses_list_data_exchange_id,
         t.count_all,
         round((((t.count_entry_system)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_entry_system,
         round((((t.count_entry_system_error)::numeric * (100)::numeric) / (t.count_entry_system)::numeric)) AS percent_entry_system_error,
         (t.count_all - t.count_entry_system) AS count_without_entry_system,
         round((((t.count_request_extract)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_request_extract,
         round((((t.count_request_extract_error)::numeric * (100)::numeric) / (t.count_request_extract)::numeric)) AS percent_request_extract_error,
         (t.count_all - t.count_request_extract) AS count_without_request_extract
        FROM ( SELECT (summonses_list_data_exchange.count_entry_system + summonses_list_data_exchange.count_request_extract) AS count_all,
                 summonses_list_data_exchange.summonses_list_data_exchange_id,
                 summonses_list_data_exchange.recruitment_id,
                 summonses_list_data_exchange.update_date,
                 summonses_list_data_exchange.info_date,
                 summonses_list_data_exchange.count_entry_system,
                 summonses_list_data_exchange.count_entry_system_error,
                 summonses_list_data_exchange.count_request_extract,
                 summonses_list_data_exchange.count_request_extract_error
                FROM journal_log.summonses_list_data_exchange) t;
        """), where);
    }

    /**
     * Create an aliased
     * <code>journal_log.view_summonses_list_data_exchange</code> table
     * reference
     */
    public ViewSummonsesListDataExchange(String alias) {
        this(DSL.name(alias), VIEW_SUMMONSES_LIST_DATA_EXCHANGE);
    }

    /**
     * Create an aliased
     * <code>journal_log.view_summonses_list_data_exchange</code> table
     * reference
     */
    public ViewSummonsesListDataExchange(Name alias) {
        this(alias, VIEW_SUMMONSES_LIST_DATA_EXCHANGE);
    }

    /**
     * Create a <code>journal_log.view_summonses_list_data_exchange</code> table
     * reference
     */
    public ViewSummonsesListDataExchange() {
        this(DSL.name("view_summonses_list_data_exchange"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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