/*
 * 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.ViewEpguNoticeSentRecord;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>journal_log.view_epgu_notice_sent</code>
     */
    public static final ViewEpguNoticeSent VIEW_EPGU_NOTICE_SENT = new ViewEpguNoticeSent();

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

    /**
     * The column
     * <code>journal_log.view_epgu_notice_sent.epgu_notice_sent_id</code>.
     */
    public final TableField<ViewEpguNoticeSentRecord, Long> EPGU_NOTICE_SENT_ID = createField(DSL.name("epgu_notice_sent_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>journal_log.view_epgu_notice_sent.percent_notice_1</code>.
     */
    public final TableField<ViewEpguNoticeSentRecord, BigDecimal> PERCENT_NOTICE_1 = createField(DSL.name("percent_notice_1"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_epgu_notice_sent.percent_notice_2</code>.
     */
    public final TableField<ViewEpguNoticeSentRecord, BigDecimal> PERCENT_NOTICE_2 = createField(DSL.name("percent_notice_2"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_epgu_notice_sent.percent_notice_3</code>.
     */
    public final TableField<ViewEpguNoticeSentRecord, BigDecimal> PERCENT_NOTICE_3 = createField(DSL.name("percent_notice_3"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_epgu_notice_sent.percent_notice_4</code>.
     */
    public final TableField<ViewEpguNoticeSentRecord, BigDecimal> PERCENT_NOTICE_4 = createField(DSL.name("percent_notice_4"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>journal_log.view_epgu_notice_sent.count_without_notice_1</code>.
     */
    public final TableField<ViewEpguNoticeSentRecord, Long> COUNT_WITHOUT_NOTICE_1 = createField(DSL.name("count_without_notice_1"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>journal_log.view_epgu_notice_sent.count_without_notice_2</code>.
     */
    public final TableField<ViewEpguNoticeSentRecord, Long> COUNT_WITHOUT_NOTICE_2 = createField(DSL.name("count_without_notice_2"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>journal_log.view_epgu_notice_sent.count_without_notice_3</code>.
     */
    public final TableField<ViewEpguNoticeSentRecord, Long> COUNT_WITHOUT_NOTICE_3 = createField(DSL.name("count_without_notice_3"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>journal_log.view_epgu_notice_sent.count_without_notice_4</code>.
     */
    public final TableField<ViewEpguNoticeSentRecord, Long> COUNT_WITHOUT_NOTICE_4 = createField(DSL.name("count_without_notice_4"), SQLDataType.BIGINT, this, "");

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

    private ViewEpguNoticeSent(Name alias, Table<ViewEpguNoticeSentRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_epgu_notice_sent" as  SELECT t.epgu_notice_sent_id,
         t.count_all,
         round((((t.count_notice_1)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_notice_1,
         round((((t.count_notice_2)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_notice_2,
         round((((t.count_notice_3)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_notice_3,
         round((((t.count_notice_4)::numeric * (100)::numeric) / (t.count_all)::numeric)) AS percent_notice_4,
         (t.count_all - t.count_notice_1) AS count_without_notice_1,
         (t.count_all - t.count_notice_2) AS count_without_notice_2,
         (t.count_all - t.count_notice_3) AS count_without_notice_3,
         (t.count_all - t.count_notice_4) AS count_without_notice_4
        FROM ( SELECT (((epgu_notice_sent.count_notice_1 + epgu_notice_sent.count_notice_2) + epgu_notice_sent.count_notice_3) + epgu_notice_sent.count_notice_4) AS count_all,
                 epgu_notice_sent.epgu_notice_sent_id,
                 epgu_notice_sent.recruitment_id,
                 epgu_notice_sent.update_date,
                 epgu_notice_sent.info_date,
                 epgu_notice_sent.count_notice_1,
                 epgu_notice_sent.count_notice_2,
                 epgu_notice_sent.count_notice_3,
                 epgu_notice_sent.count_notice_4,
                 epgu_notice_sent.notice_name_1,
                 epgu_notice_sent.notice_name_2,
                 epgu_notice_sent.notice_name_3,
                 epgu_notice_sent.notice_name_4
                FROM journal_log.epgu_notice_sent) t;
        """), where);
    }

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

    /**
     * Create an aliased <code>journal_log.view_epgu_notice_sent</code> table
     * reference
     */
    public ViewEpguNoticeSent(Name alias) {
        this(alias, VIEW_EPGU_NOTICE_SENT);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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