package sql.com.yz.db;

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.sxyz.rfid.greendao.model.WmsInventory;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "wms_inventory".
*/
public class WmsInventoryDao extends AbstractDao<WmsInventory, Long> {

    public static final String TABLENAME = "wms_inventory";

    /**
     * Properties of entity WmsInventory.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property InventoryId = new Property(0, Long.class, "inventoryId", true, "inventory_id");
        public final static Property MaterialId = new Property(1, Integer.class, "materialId", false, "material_id");
        public final static Property WarehouseId = new Property(2, Integer.class, "warehouseId", false, "warehouse_id");
        public final static Property AreaId = new Property(3, Integer.class, "areaId", false, "area_id");
        public final static Property LocationId = new Property(4, Integer.class, "locationId", false, "location_id");
        public final static Property BatchNo = new Property(5, String.class, "batchNo", false, "batch_no");
        public final static Property LotNo = new Property(6, String.class, "lotNo", false, "lot_no");
        public final static Property ProductionDate = new Property(7, String.class, "productionDate", false, "production_date");
        public final static Property ExpirationDate = new Property(8, String.class, "expirationDate", false, "expiration_date");
        public final static Property Quantity = new Property(9, Float.class, "quantity", false, "quantity");
        public final static Property AvailableQuantity = new Property(10, Float.class, "availableQuantity", false, "available_quantity");
        public final static Property LockedQuantity = new Property(11, Float.class, "lockedQuantity", false, "locked_quantity");
        public final static Property UnitCost = new Property(12, Float.class, "unitCost", false, "unit_cost");
        public final static Property TotalCost = new Property(13, Float.class, "totalCost", false, "total_cost");
        public final static Property QualityStatus = new Property(14, String.class, "qualityStatus", false, "quality_status");
        public final static Property InventoryStatus = new Property(15, String.class, "inventoryStatus", false, "inventory_status");
        public final static Property LastInboundTime = new Property(16, String.class, "lastInboundTime", false, "last_inbound_time");
        public final static Property LastOutboundTime = new Property(17, String.class, "lastOutboundTime", false, "last_outbound_time");
        public final static Property RfidTag = new Property(18, String.class, "rfidTag", false, "rfid_tag");
        public final static Property Barcode = new Property(19, String.class, "barcode", false, "barcode");
        public final static Property IsFifo = new Property(20, String.class, "isFifo", false, "is_fifo");
        public final static Property RfidBindingCount = new Property(21, Integer.class, "rfidBindingCount", false, "rfid_binding_count");
        public final static Property LastRfidDetectTime = new Property(22, String.class, "lastRfidDetectTime", false, "last_rfid_detect_time");
        public final static Property RfidCoverageRate = new Property(23, Float.class, "rfidCoverageRate", false, "rfid_coverage_rate");
        public final static Property DelFlag = new Property(24, String.class, "delFlag", false, "del_flag");
        public final static Property CreateTime = new Property(25, String.class, "createTime", false, "create_time");
        public final static Property UpdateTime = new Property(26, String.class, "updateTime", false, "update_time");
        public final static Property Remark = new Property(27, String.class, "remark", false, "remark");
    }


    public WmsInventoryDao(DaoConfig config) {
        super(config);
    }
    
    public WmsInventoryDao(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 + "\"wms_inventory\" (" + //
                "\"inventory_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: inventoryId
                "\"material_id\" INTEGER," + // 1: materialId
                "\"warehouse_id\" INTEGER," + // 2: warehouseId
                "\"area_id\" INTEGER," + // 3: areaId
                "\"location_id\" INTEGER," + // 4: locationId
                "\"batch_no\" TEXT," + // 5: batchNo
                "\"lot_no\" TEXT," + // 6: lotNo
                "\"production_date\" TEXT," + // 7: productionDate
                "\"expiration_date\" TEXT," + // 8: expirationDate
                "\"quantity\" REAL," + // 9: quantity
                "\"available_quantity\" REAL," + // 10: availableQuantity
                "\"locked_quantity\" REAL," + // 11: lockedQuantity
                "\"unit_cost\" REAL," + // 12: unitCost
                "\"total_cost\" REAL," + // 13: totalCost
                "\"quality_status\" TEXT," + // 14: qualityStatus
                "\"inventory_status\" TEXT," + // 15: inventoryStatus
                "\"last_inbound_time\" TEXT," + // 16: lastInboundTime
                "\"last_outbound_time\" TEXT," + // 17: lastOutboundTime
                "\"rfid_tag\" TEXT," + // 18: rfidTag
                "\"barcode\" TEXT," + // 19: barcode
                "\"is_fifo\" TEXT," + // 20: isFifo
                "\"rfid_binding_count\" INTEGER," + // 21: rfidBindingCount
                "\"last_rfid_detect_time\" TEXT," + // 22: lastRfidDetectTime
                "\"rfid_coverage_rate\" REAL," + // 23: rfidCoverageRate
                "\"del_flag\" TEXT," + // 24: delFlag
                "\"create_time\" TEXT," + // 25: createTime
                "\"update_time\" TEXT," + // 26: updateTime
                "\"remark\" TEXT);"); // 27: remark
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, WmsInventory entity) {
        stmt.clearBindings();
 
        Long inventoryId = entity.getInventoryId();
        if (inventoryId != null) {
            stmt.bindLong(1, inventoryId);
        }
 
        Integer materialId = entity.getMaterialId();
        if (materialId != null) {
            stmt.bindLong(2, materialId);
        }
 
        Integer warehouseId = entity.getWarehouseId();
        if (warehouseId != null) {
            stmt.bindLong(3, warehouseId);
        }
 
        Integer areaId = entity.getAreaId();
        if (areaId != null) {
            stmt.bindLong(4, areaId);
        }
 
        Integer locationId = entity.getLocationId();
        if (locationId != null) {
            stmt.bindLong(5, locationId);
        }
 
        String batchNo = entity.getBatchNo();
        if (batchNo != null) {
            stmt.bindString(6, batchNo);
        }
 
        String lotNo = entity.getLotNo();
        if (lotNo != null) {
            stmt.bindString(7, lotNo);
        }
 
        String productionDate = entity.getProductionDate();
        if (productionDate != null) {
            stmt.bindString(8, productionDate);
        }
 
        String expirationDate = entity.getExpirationDate();
        if (expirationDate != null) {
            stmt.bindString(9, expirationDate);
        }
 
        Float quantity = entity.getQuantity();
        if (quantity != null) {
            stmt.bindDouble(10, quantity);
        }
 
        Float availableQuantity = entity.getAvailableQuantity();
        if (availableQuantity != null) {
            stmt.bindDouble(11, availableQuantity);
        }
 
        Float lockedQuantity = entity.getLockedQuantity();
        if (lockedQuantity != null) {
            stmt.bindDouble(12, lockedQuantity);
        }
 
        Float unitCost = entity.getUnitCost();
        if (unitCost != null) {
            stmt.bindDouble(13, unitCost);
        }
 
        Float totalCost = entity.getTotalCost();
        if (totalCost != null) {
            stmt.bindDouble(14, totalCost);
        }
 
        String qualityStatus = entity.getQualityStatus();
        if (qualityStatus != null) {
            stmt.bindString(15, qualityStatus);
        }
 
        String inventoryStatus = entity.getInventoryStatus();
        if (inventoryStatus != null) {
            stmt.bindString(16, inventoryStatus);
        }
 
        String lastInboundTime = entity.getLastInboundTime();
        if (lastInboundTime != null) {
            stmt.bindString(17, lastInboundTime);
        }
 
        String lastOutboundTime = entity.getLastOutboundTime();
        if (lastOutboundTime != null) {
            stmt.bindString(18, lastOutboundTime);
        }
 
        String rfidTag = entity.getRfidTag();
        if (rfidTag != null) {
            stmt.bindString(19, rfidTag);
        }
 
        String barcode = entity.getBarcode();
        if (barcode != null) {
            stmt.bindString(20, barcode);
        }
 
        String isFifo = entity.getIsFifo();
        if (isFifo != null) {
            stmt.bindString(21, isFifo);
        }
 
        Integer rfidBindingCount = entity.getRfidBindingCount();
        if (rfidBindingCount != null) {
            stmt.bindLong(22, rfidBindingCount);
        }
 
        String lastRfidDetectTime = entity.getLastRfidDetectTime();
        if (lastRfidDetectTime != null) {
            stmt.bindString(23, lastRfidDetectTime);
        }
 
        Float rfidCoverageRate = entity.getRfidCoverageRate();
        if (rfidCoverageRate != null) {
            stmt.bindDouble(24, rfidCoverageRate);
        }
 
        String delFlag = entity.getDelFlag();
        if (delFlag != null) {
            stmt.bindString(25, delFlag);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(26, createTime);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(27, updateTime);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(28, remark);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, WmsInventory entity) {
        stmt.clearBindings();
 
        Long inventoryId = entity.getInventoryId();
        if (inventoryId != null) {
            stmt.bindLong(1, inventoryId);
        }
 
        Integer materialId = entity.getMaterialId();
        if (materialId != null) {
            stmt.bindLong(2, materialId);
        }
 
        Integer warehouseId = entity.getWarehouseId();
        if (warehouseId != null) {
            stmt.bindLong(3, warehouseId);
        }
 
        Integer areaId = entity.getAreaId();
        if (areaId != null) {
            stmt.bindLong(4, areaId);
        }
 
        Integer locationId = entity.getLocationId();
        if (locationId != null) {
            stmt.bindLong(5, locationId);
        }
 
        String batchNo = entity.getBatchNo();
        if (batchNo != null) {
            stmt.bindString(6, batchNo);
        }
 
        String lotNo = entity.getLotNo();
        if (lotNo != null) {
            stmt.bindString(7, lotNo);
        }
 
        String productionDate = entity.getProductionDate();
        if (productionDate != null) {
            stmt.bindString(8, productionDate);
        }
 
        String expirationDate = entity.getExpirationDate();
        if (expirationDate != null) {
            stmt.bindString(9, expirationDate);
        }
 
        Float quantity = entity.getQuantity();
        if (quantity != null) {
            stmt.bindDouble(10, quantity);
        }
 
        Float availableQuantity = entity.getAvailableQuantity();
        if (availableQuantity != null) {
            stmt.bindDouble(11, availableQuantity);
        }
 
        Float lockedQuantity = entity.getLockedQuantity();
        if (lockedQuantity != null) {
            stmt.bindDouble(12, lockedQuantity);
        }
 
        Float unitCost = entity.getUnitCost();
        if (unitCost != null) {
            stmt.bindDouble(13, unitCost);
        }
 
        Float totalCost = entity.getTotalCost();
        if (totalCost != null) {
            stmt.bindDouble(14, totalCost);
        }
 
        String qualityStatus = entity.getQualityStatus();
        if (qualityStatus != null) {
            stmt.bindString(15, qualityStatus);
        }
 
        String inventoryStatus = entity.getInventoryStatus();
        if (inventoryStatus != null) {
            stmt.bindString(16, inventoryStatus);
        }
 
        String lastInboundTime = entity.getLastInboundTime();
        if (lastInboundTime != null) {
            stmt.bindString(17, lastInboundTime);
        }
 
        String lastOutboundTime = entity.getLastOutboundTime();
        if (lastOutboundTime != null) {
            stmt.bindString(18, lastOutboundTime);
        }
 
        String rfidTag = entity.getRfidTag();
        if (rfidTag != null) {
            stmt.bindString(19, rfidTag);
        }
 
        String barcode = entity.getBarcode();
        if (barcode != null) {
            stmt.bindString(20, barcode);
        }
 
        String isFifo = entity.getIsFifo();
        if (isFifo != null) {
            stmt.bindString(21, isFifo);
        }
 
        Integer rfidBindingCount = entity.getRfidBindingCount();
        if (rfidBindingCount != null) {
            stmt.bindLong(22, rfidBindingCount);
        }
 
        String lastRfidDetectTime = entity.getLastRfidDetectTime();
        if (lastRfidDetectTime != null) {
            stmt.bindString(23, lastRfidDetectTime);
        }
 
        Float rfidCoverageRate = entity.getRfidCoverageRate();
        if (rfidCoverageRate != null) {
            stmt.bindDouble(24, rfidCoverageRate);
        }
 
        String delFlag = entity.getDelFlag();
        if (delFlag != null) {
            stmt.bindString(25, delFlag);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(26, createTime);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(27, updateTime);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(28, remark);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public WmsInventory readEntity(Cursor cursor, int offset) {
        WmsInventory entity = new WmsInventory( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // inventoryId
            cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1), // materialId
            cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2), // warehouseId
            cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3), // areaId
            cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4), // locationId
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // batchNo
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // lotNo
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // productionDate
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // expirationDate
            cursor.isNull(offset + 9) ? null : cursor.getFloat(offset + 9), // quantity
            cursor.isNull(offset + 10) ? null : cursor.getFloat(offset + 10), // availableQuantity
            cursor.isNull(offset + 11) ? null : cursor.getFloat(offset + 11), // lockedQuantity
            cursor.isNull(offset + 12) ? null : cursor.getFloat(offset + 12), // unitCost
            cursor.isNull(offset + 13) ? null : cursor.getFloat(offset + 13), // totalCost
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // qualityStatus
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // inventoryStatus
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lastInboundTime
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lastOutboundTime
            cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // rfidTag
            cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // barcode
            cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // isFifo
            cursor.isNull(offset + 21) ? null : cursor.getInt(offset + 21), // rfidBindingCount
            cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // lastRfidDetectTime
            cursor.isNull(offset + 23) ? null : cursor.getFloat(offset + 23), // rfidCoverageRate
            cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // delFlag
            cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // createTime
            cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26), // updateTime
            cursor.isNull(offset + 27) ? null : cursor.getString(offset + 27) // remark
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, WmsInventory entity, int offset) {
        entity.setInventoryId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setMaterialId(cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1));
        entity.setWarehouseId(cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2));
        entity.setAreaId(cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3));
        entity.setLocationId(cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4));
        entity.setBatchNo(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setLotNo(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setProductionDate(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setExpirationDate(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setQuantity(cursor.isNull(offset + 9) ? null : cursor.getFloat(offset + 9));
        entity.setAvailableQuantity(cursor.isNull(offset + 10) ? null : cursor.getFloat(offset + 10));
        entity.setLockedQuantity(cursor.isNull(offset + 11) ? null : cursor.getFloat(offset + 11));
        entity.setUnitCost(cursor.isNull(offset + 12) ? null : cursor.getFloat(offset + 12));
        entity.setTotalCost(cursor.isNull(offset + 13) ? null : cursor.getFloat(offset + 13));
        entity.setQualityStatus(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setInventoryStatus(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setLastInboundTime(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setLastOutboundTime(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
        entity.setRfidTag(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
        entity.setBarcode(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
        entity.setIsFifo(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
        entity.setRfidBindingCount(cursor.isNull(offset + 21) ? null : cursor.getInt(offset + 21));
        entity.setLastRfidDetectTime(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22));
        entity.setRfidCoverageRate(cursor.isNull(offset + 23) ? null : cursor.getFloat(offset + 23));
        entity.setDelFlag(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24));
        entity.setCreateTime(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25));
        entity.setUpdateTime(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26));
        entity.setRemark(cursor.isNull(offset + 27) ? null : cursor.getString(offset + 27));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(WmsInventory entity, long rowId) {
        entity.setInventoryId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(WmsInventory entity) {
        if(entity != null) {
            return entity.getInventoryId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(WmsInventory entity) {
        return entity.getInventoryId() != null;
    }

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