package com.tofly.data.sql.dao;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.tofly.ghrq_route.module.plan.domain.PlanBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "DB_OFFLINE_PLAN".
*/
public class PlanBeanDao extends AbstractDao<PlanBean, String> {

    public static final String TABLENAME = "DB_OFFLINE_PLAN";

    /**
     * Properties of entity PlanBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Plan_id = new Property(0, String.class, "plan_id", true, "PLAN_ID");
        public final static Property Plan_state = new Property(1, int.class, "plan_state", false, "PLAN_STATE");
        public final static Property Plan_overdate = new Property(2, String.class, "plan_overdate", false, "PLAN_OVERDATE");
        public final static Property Plan_begindate = new Property(3, String.class, "plan_begindate", false, "PLAN_BEGINDATE");
        public final static Property Plan_enddate = new Property(4, String.class, "plan_enddate", false, "PLAN_ENDDATE");
        public final static Property Create_time = new Property(5, String.class, "create_time", false, "CREATE_TIME");
        public final static Property Download_time = new Property(6, String.class, "download_time", false, "DOWNLOAD_TIME");
        public final static Property Percent = new Property(7, String.class, "percent", false, "PERCENT");
        public final static Property Percent1 = new Property(8, String.class, "percent1", false, "PERCENT1");
        public final static Property Percent2 = new Property(9, String.class, "percent2", false, "PERCENT2");
        public final static Property Plan_name = new Property(10, String.class, "plan_name", false, "PLAN_NAME");
        public final static Property Region_id = new Property(11, String.class, "region_id", false, "REGION_ID");
        public final static Property Region_name = new Property(12, String.class, "region_name", false, "REGION_NAME");
        public final static Property Period_id = new Property(13, String.class, "period_id", false, "PERIOD_ID");
        public final static Property Period_name = new Property(14, String.class, "period_name", false, "PERIOD_NAME");
        public final static Property User_id = new Property(15, String.class, "user_id", false, "USER_ID");
        public final static Property User_name = new Property(16, String.class, "user_name", false, "USER_NAME");
        public final static Property Isvalid = new Property(17, int.class, "isvalid", false, "ISVALID");
        public final static Property Type = new Property(18, int.class, "type", false, "TYPE");
        public final static Property Plan_mode = new Property(19, int.class, "plan_mode", false, "PLAN_MODE");
        public final static Property Point_num = new Property(20, int.class, "point_num", false, "POINT_NUM");
        public final static Property Total = new Property(21, double.class, "total", false, "TOTAL");
        public final static Property Total1 = new Property(22, double.class, "total1", false, "TOTAL1");
        public final static Property Isovertototal = new Property(23, String.class, "isovertototal", false, "ISOVERTOTOTAL");
        public final static Property Isovertototal1 = new Property(24, String.class, "isovertototal1", false, "ISOVERTOTOTAL1");
        public final static Property Plan_process_name = new Property(25, String.class, "plan_process_name", false, "PLAN_PROCESS_NAME");
        public final static Property IsNeedOperate = new Property(26, int.class, "isNeedOperate", false, "IS_NEED_OPERATE");
        public final static Property IsUpload = new Property(27, int.class, "isUpload", false, "IS_UPLOAD");
        public final static Property PointInfo = new Property(28, String.class, "pointInfo", false, "POINT_INFO");
        public final static Property CheckContent = new Property(29, String.class, "checkContent", false, "CHECK_CONTENT");
        public final static Property Tolerance = new Property(30, double.class, "tolerance", false, "TOLERANCE");
        public final static Property Device_type_id = new Property(31, int.class, "device_type_id", false, "DEVICE_TYPE_ID");
        public final static Property Device_type_name = new Property(32, String.class, "device_type_name", false, "DEVICE_TYPE_NAME");
        public final static Property State = new Property(33, int.class, "state", false, "STATE");
    }


    public PlanBeanDao(DaoConfig config) {
        super(config);
    }
    
    public PlanBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"DB_OFFLINE_PLAN\" (" + //
                "\"PLAN_ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: plan_id
                "\"PLAN_STATE\" INTEGER NOT NULL ," + // 1: plan_state
                "\"PLAN_OVERDATE\" TEXT," + // 2: plan_overdate
                "\"PLAN_BEGINDATE\" TEXT," + // 3: plan_begindate
                "\"PLAN_ENDDATE\" TEXT," + // 4: plan_enddate
                "\"CREATE_TIME\" TEXT," + // 5: create_time
                "\"DOWNLOAD_TIME\" TEXT," + // 6: download_time
                "\"PERCENT\" TEXT," + // 7: percent
                "\"PERCENT1\" TEXT," + // 8: percent1
                "\"PERCENT2\" TEXT," + // 9: percent2
                "\"PLAN_NAME\" TEXT," + // 10: plan_name
                "\"REGION_ID\" TEXT," + // 11: region_id
                "\"REGION_NAME\" TEXT," + // 12: region_name
                "\"PERIOD_ID\" TEXT," + // 13: period_id
                "\"PERIOD_NAME\" TEXT," + // 14: period_name
                "\"USER_ID\" TEXT," + // 15: user_id
                "\"USER_NAME\" TEXT," + // 16: user_name
                "\"ISVALID\" INTEGER NOT NULL ," + // 17: isvalid
                "\"TYPE\" INTEGER NOT NULL ," + // 18: type
                "\"PLAN_MODE\" INTEGER NOT NULL ," + // 19: plan_mode
                "\"POINT_NUM\" INTEGER NOT NULL ," + // 20: point_num
                "\"TOTAL\" REAL NOT NULL ," + // 21: total
                "\"TOTAL1\" REAL NOT NULL ," + // 22: total1
                "\"ISOVERTOTOTAL\" TEXT," + // 23: isovertototal
                "\"ISOVERTOTOTAL1\" TEXT," + // 24: isovertototal1
                "\"PLAN_PROCESS_NAME\" TEXT," + // 25: plan_process_name
                "\"IS_NEED_OPERATE\" INTEGER NOT NULL ," + // 26: isNeedOperate
                "\"IS_UPLOAD\" INTEGER NOT NULL ," + // 27: isUpload
                "\"POINT_INFO\" TEXT," + // 28: pointInfo
                "\"CHECK_CONTENT\" TEXT," + // 29: checkContent
                "\"TOLERANCE\" REAL NOT NULL ," + // 30: tolerance
                "\"DEVICE_TYPE_ID\" INTEGER NOT NULL ," + // 31: device_type_id
                "\"DEVICE_TYPE_NAME\" TEXT," + // 32: device_type_name
                "\"STATE\" INTEGER NOT NULL );"); // 33: state
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"DB_OFFLINE_PLAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, PlanBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getPlan_id());
        stmt.bindLong(2, entity.getPlan_state());
 
        String plan_overdate = entity.getPlan_overdate();
        if (plan_overdate != null) {
            stmt.bindString(3, plan_overdate);
        }
 
        String plan_begindate = entity.getPlan_begindate();
        if (plan_begindate != null) {
            stmt.bindString(4, plan_begindate);
        }
 
        String plan_enddate = entity.getPlan_enddate();
        if (plan_enddate != null) {
            stmt.bindString(5, plan_enddate);
        }
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(6, create_time);
        }
 
        String download_time = entity.getDownload_time();
        if (download_time != null) {
            stmt.bindString(7, download_time);
        }
 
        String percent = entity.getPercent();
        if (percent != null) {
            stmt.bindString(8, percent);
        }
 
        String percent1 = entity.getPercent1();
        if (percent1 != null) {
            stmt.bindString(9, percent1);
        }
 
        String percent2 = entity.getPercent2();
        if (percent2 != null) {
            stmt.bindString(10, percent2);
        }
 
        String plan_name = entity.getPlan_name();
        if (plan_name != null) {
            stmt.bindString(11, plan_name);
        }
 
        String region_id = entity.getRegion_id();
        if (region_id != null) {
            stmt.bindString(12, region_id);
        }
 
        String region_name = entity.getRegion_name();
        if (region_name != null) {
            stmt.bindString(13, region_name);
        }
 
        String period_id = entity.getPeriod_id();
        if (period_id != null) {
            stmt.bindString(14, period_id);
        }
 
        String period_name = entity.getPeriod_name();
        if (period_name != null) {
            stmt.bindString(15, period_name);
        }
 
        String user_id = entity.getUser_id();
        if (user_id != null) {
            stmt.bindString(16, user_id);
        }
 
        String user_name = entity.getUser_name();
        if (user_name != null) {
            stmt.bindString(17, user_name);
        }
        stmt.bindLong(18, entity.getIsvalid());
        stmt.bindLong(19, entity.getType());
        stmt.bindLong(20, entity.getPlan_mode());
        stmt.bindLong(21, entity.getPoint_num());
        stmt.bindDouble(22, entity.getTotal());
        stmt.bindDouble(23, entity.getTotal1());
 
        String isovertototal = entity.getIsovertototal();
        if (isovertototal != null) {
            stmt.bindString(24, isovertototal);
        }
 
        String isovertototal1 = entity.getIsovertototal1();
        if (isovertototal1 != null) {
            stmt.bindString(25, isovertototal1);
        }
 
        String plan_process_name = entity.getPlan_process_name();
        if (plan_process_name != null) {
            stmt.bindString(26, plan_process_name);
        }
        stmt.bindLong(27, entity.getIsNeedOperate());
        stmt.bindLong(28, entity.getIsUpload());
 
        String pointInfo = entity.getPointInfo();
        if (pointInfo != null) {
            stmt.bindString(29, pointInfo);
        }
 
        String checkContent = entity.getCheckContent();
        if (checkContent != null) {
            stmt.bindString(30, checkContent);
        }
        stmt.bindDouble(31, entity.getTolerance());
        stmt.bindLong(32, entity.getDevice_type_id());
 
        String device_type_name = entity.getDevice_type_name();
        if (device_type_name != null) {
            stmt.bindString(33, device_type_name);
        }
        stmt.bindLong(34, entity.getState());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, PlanBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getPlan_id());
        stmt.bindLong(2, entity.getPlan_state());
 
        String plan_overdate = entity.getPlan_overdate();
        if (plan_overdate != null) {
            stmt.bindString(3, plan_overdate);
        }
 
        String plan_begindate = entity.getPlan_begindate();
        if (plan_begindate != null) {
            stmt.bindString(4, plan_begindate);
        }
 
        String plan_enddate = entity.getPlan_enddate();
        if (plan_enddate != null) {
            stmt.bindString(5, plan_enddate);
        }
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(6, create_time);
        }
 
        String download_time = entity.getDownload_time();
        if (download_time != null) {
            stmt.bindString(7, download_time);
        }
 
        String percent = entity.getPercent();
        if (percent != null) {
            stmt.bindString(8, percent);
        }
 
        String percent1 = entity.getPercent1();
        if (percent1 != null) {
            stmt.bindString(9, percent1);
        }
 
        String percent2 = entity.getPercent2();
        if (percent2 != null) {
            stmt.bindString(10, percent2);
        }
 
        String plan_name = entity.getPlan_name();
        if (plan_name != null) {
            stmt.bindString(11, plan_name);
        }
 
        String region_id = entity.getRegion_id();
        if (region_id != null) {
            stmt.bindString(12, region_id);
        }
 
        String region_name = entity.getRegion_name();
        if (region_name != null) {
            stmt.bindString(13, region_name);
        }
 
        String period_id = entity.getPeriod_id();
        if (period_id != null) {
            stmt.bindString(14, period_id);
        }
 
        String period_name = entity.getPeriod_name();
        if (period_name != null) {
            stmt.bindString(15, period_name);
        }
 
        String user_id = entity.getUser_id();
        if (user_id != null) {
            stmt.bindString(16, user_id);
        }
 
        String user_name = entity.getUser_name();
        if (user_name != null) {
            stmt.bindString(17, user_name);
        }
        stmt.bindLong(18, entity.getIsvalid());
        stmt.bindLong(19, entity.getType());
        stmt.bindLong(20, entity.getPlan_mode());
        stmt.bindLong(21, entity.getPoint_num());
        stmt.bindDouble(22, entity.getTotal());
        stmt.bindDouble(23, entity.getTotal1());
 
        String isovertototal = entity.getIsovertototal();
        if (isovertototal != null) {
            stmt.bindString(24, isovertototal);
        }
 
        String isovertototal1 = entity.getIsovertototal1();
        if (isovertototal1 != null) {
            stmt.bindString(25, isovertototal1);
        }
 
        String plan_process_name = entity.getPlan_process_name();
        if (plan_process_name != null) {
            stmt.bindString(26, plan_process_name);
        }
        stmt.bindLong(27, entity.getIsNeedOperate());
        stmt.bindLong(28, entity.getIsUpload());
 
        String pointInfo = entity.getPointInfo();
        if (pointInfo != null) {
            stmt.bindString(29, pointInfo);
        }
 
        String checkContent = entity.getCheckContent();
        if (checkContent != null) {
            stmt.bindString(30, checkContent);
        }
        stmt.bindDouble(31, entity.getTolerance());
        stmt.bindLong(32, entity.getDevice_type_id());
 
        String device_type_name = entity.getDevice_type_name();
        if (device_type_name != null) {
            stmt.bindString(33, device_type_name);
        }
        stmt.bindLong(34, entity.getState());
    }

    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.getString(offset + 0);
    }    

    @Override
    public PlanBean readEntity(Cursor cursor, int offset) {
        PlanBean entity = new PlanBean( //
            cursor.getString(offset + 0), // plan_id
            cursor.getInt(offset + 1), // plan_state
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // plan_overdate
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // plan_begindate
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // plan_enddate
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // create_time
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // download_time
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // percent
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // percent1
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // percent2
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // plan_name
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // region_id
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // region_name
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // period_id
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // period_name
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // user_id
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // user_name
            cursor.getInt(offset + 17), // isvalid
            cursor.getInt(offset + 18), // type
            cursor.getInt(offset + 19), // plan_mode
            cursor.getInt(offset + 20), // point_num
            cursor.getDouble(offset + 21), // total
            cursor.getDouble(offset + 22), // total1
            cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // isovertototal
            cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // isovertototal1
            cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // plan_process_name
            cursor.getInt(offset + 26), // isNeedOperate
            cursor.getInt(offset + 27), // isUpload
            cursor.isNull(offset + 28) ? null : cursor.getString(offset + 28), // pointInfo
            cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29), // checkContent
            cursor.getDouble(offset + 30), // tolerance
            cursor.getInt(offset + 31), // device_type_id
            cursor.isNull(offset + 32) ? null : cursor.getString(offset + 32), // device_type_name
            cursor.getInt(offset + 33) // state
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, PlanBean entity, int offset) {
        entity.setPlan_id(cursor.getString(offset + 0));
        entity.setPlan_state(cursor.getInt(offset + 1));
        entity.setPlan_overdate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setPlan_begindate(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setPlan_enddate(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setCreate_time(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setDownload_time(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setPercent(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setPercent1(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setPercent2(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setPlan_name(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setRegion_id(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setRegion_name(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setPeriod_id(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setPeriod_name(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setUser_id(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setUser_name(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setIsvalid(cursor.getInt(offset + 17));
        entity.setType(cursor.getInt(offset + 18));
        entity.setPlan_mode(cursor.getInt(offset + 19));
        entity.setPoint_num(cursor.getInt(offset + 20));
        entity.setTotal(cursor.getDouble(offset + 21));
        entity.setTotal1(cursor.getDouble(offset + 22));
        entity.setIsovertototal(cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23));
        entity.setIsovertototal1(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24));
        entity.setPlan_process_name(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25));
        entity.setIsNeedOperate(cursor.getInt(offset + 26));
        entity.setIsUpload(cursor.getInt(offset + 27));
        entity.setPointInfo(cursor.isNull(offset + 28) ? null : cursor.getString(offset + 28));
        entity.setCheckContent(cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29));
        entity.setTolerance(cursor.getDouble(offset + 30));
        entity.setDevice_type_id(cursor.getInt(offset + 31));
        entity.setDevice_type_name(cursor.isNull(offset + 32) ? null : cursor.getString(offset + 32));
        entity.setState(cursor.getInt(offset + 33));
     }
    
    @Override
    protected final String updateKeyAfterInsert(PlanBean entity, long rowId) {
        return entity.getPlan_id();
    }
    
    @Override
    public String getKey(PlanBean entity) {
        if(entity != null) {
            return entity.getPlan_id();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(PlanBean entity) {
        throw new UnsupportedOperationException("Unsupported for entities with a non-null key");
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
