xuxiuxi
2017-07-24 61a09a058a4963aa203ae2ef4f67477370a35ca2
VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/RegisterDao.java
@@ -68,28 +68,66 @@
        contentValues.put("raw_surveillance_photo_width", item.getRawSurveillancePhotoWidth());
        contentValues.put("raw_surveillance_photo_height", item.getRawSurveillancePhotoHeight());
        contentValues.put("create_time", item.getCreateTime());
        contentValues.put("visitor_or_attender", "visitor");
        long registerId = MainActivity.getInstance().db.insert("register", "", contentValues);
        return registerId;
    }
    /**
     * 考勤注册
     * @param params
     * @param idCardHeadPhoto
     * @return
     */
    public boolean addAttender(RequestParams params, String idCardHeadPhoto) {
        return true;
    public long addAttender(OfflineAttenderRegisterItem item, String idCardHeadPhoto) {
        ContentValues contentValues = new ContentValues();
        contentValues.put("register_id",item.getRegisterId());
        contentValues.put("username",item.getUsername());
        contentValues.put("name_en", item.getNameEn());
        contentValues.put("gender_id", item.getGenderId());
        contentValues.put("country_id", item.getCountryId());
        contentValues.put("province", item.getProvince());
        contentValues.put("city", item.getCity());
        contentValues.put("company_id", item.getCompanyId());
        contentValues.put("company", item.getCompany());
        contentValues.put("birthday", item.getBirthday());
        contentValues.put("tel", item.getTel());
        contentValues.put("mobile_phone", item.getMobilePhone());
        contentValues.put("identity_type_id", item.getIdentityTypeId());
        contentValues.put("identify_num", item.getIdentifyNum());
        contentValues.put("company_id", item.getCountryId());
        contentValues.put("department_id", item.getDepartmentId());
        contentValues.put("post_id", item.getPostId());
        contentValues.put("remark", item.getRemark());
        contentValues.put("warning", item.getWarning());
        contentValues.put("id_card_photo", item.getIdCardPhoto());
        contentValues.put("upload_custom_photo", item.getUploadCustomPhoto());
        contentValues.put("surveillance_photo", item.getSurveillancePhoto());
        contentValues.put("surveillance_photo_id", item.getSurveillancePhotoId());
        contentValues.put("visitor_type_id", item.getVisitorTypeId());
        contentValues.put("authentication", item.getAuthentication());
        contentValues.put("id_card_head_photo", item.getIdCardHeadPhoto());
        contentValues.put("attender_type_id", item.getAttenderTypeId());
        contentValues.put("card_number", item.getCardNumber());
        contentValues.put("update_time", item.getUpdateTime());
        contentValues.put("is_synchron", item.getIsSynchron());
        contentValues.put("device_company_id", item.getDeviceCompanyId());
        contentValues.put("raw_surveillance_photo_path", item.getRawSurveillancePhotoPath());
        contentValues.put("raw_surveillance_photo_width", item.getRawSurveillancePhotoWidth());
        contentValues.put("raw_surveillance_photo_height", item.getRawSurveillancePhotoHeight());
        contentValues.put("create_time", item.getCreateTime());
        contentValues.put("visitor_or_attender", "attender");
        long registerId = MainActivity.getInstance().db.insert("register", "", contentValues);
        return registerId;
    }
    public boolean hasOfflineVisitorRegisterData() {
        Cursor c = MainActivity.getInstance().db.rawQuery("select count(*) from register", new String[]{});
        Cursor c = MainActivity.getInstance().db.rawQuery("select count(*) from register where 1=1 and visitor_or_attender='visitor'", new String[]{});
        c.moveToFirst();
        return c.getInt(0) > 0 ? true : false;
    }
    public boolean hasOfflineAttenderRegisterData() {
        Cursor c = MainActivity.getInstance().db.rawQuery("select count(*) from register", new String[]{});
        Cursor c = MainActivity.getInstance().db.rawQuery("select count(*) from register where 1=1 and visitor_or_attender='attender", new String[]{});
        c.moveToFirst();
        return c.getInt(0) > 0 ? true : false;
    }
@@ -131,7 +169,10 @@
                "   register a\n" +
                "WHERE\n" +
                "   1 = 1\n" +
                "AND a.is_synchron = 'N'";
                "AND a.is_synchron = 'N'"+
                " and visitor_or_attender='visitor'"+
                " order by a.create_time "
                ;
        Cursor c = MainActivity.getInstance().db.rawQuery(sql, new String[]{});
        if (c.moveToFirst()) {
            item = new OfflineVisitorRegisterItem();
@@ -159,7 +200,70 @@
    }
    public OfflineAttenderRegisterItem readOfflineAttenderRegister() {
        return null;
        OfflineAttenderRegisterItem item = null;
        String sql =
                "SELECT\n" +
                        "   a.register_id,\n" +
                        "   a.username,\n" +
                        "   a.name_en,\n" +
                        "   a.gender_id,\n" +
                        "   a.country_id,\n" +
                        "   a.province,\n" +
                        "   a.city,\n" +
                        "   a.birthday,\n" +
                        "   a.tel,\n" +
                        "   a.mobile_phone,\n" +
                        "   a.identity_type_id,\n" +
                        "   a.identify_num,\n" +
                        "   a.company_id,\n" +
                        "   a.department_id,\n" +
                        "   a.post_id,\n" +
                        "   a.remark,\n" +
                        "   a.warning,\n" +
                        "   a.id_card_photo,\n" +
                        "   a.upload_custom_photo,\n" +
                        "   a.surveillance_photo,\n" +
                        "   a.surveillance_photo_id,\n" +
                        "   a.visitor_type_id,\n" +
                        "   a.authentication,\n" +
                        "   a.id_card_head_photo,\n" +
                        "   a.attender_type_id,\n" +
                        "   a.card_number,\n" +
                        "   a.update_time,\n" +
                        "   a.is_synchron,\n" +
                        "   a.device_company_id\n" +
                        "FROM\n" +
                        "   register a\n" +
                        "WHERE\n" +
                        "   1 = 1\n" +
                        "AND a.is_synchron = 'N'"+
                        " and visitor_or_attender='attender'"+
                        " order by a.create_time "
                ;
        Cursor c = MainActivity.getInstance().db.rawQuery(sql, new String[]{});
        if (c.moveToFirst()) {
            item = new OfflineAttenderRegisterItem();
            item.setRegisterId(c.getString(c.getColumnIndex("register_id")));
            item.setUsername(c.getString(c.getColumnIndex("username")));
            item.setMobilePhone(c.getString(c.getColumnIndex("mobile_phone")));
            item.setGenderId(c.getString(c.getColumnIndex("gender_id")));
            item.setIdentityTypeId(c.getString(c.getColumnIndex("identity_type_id")));
            item.setCountryId(c.getString(c.getColumnIndex("country_id")));
            item.setVisitorTypeId(c.getString(c.getColumnIndex("visitor_type_id")));
            item.setIdentifyNum(c.getString(c.getColumnIndex("identify_num")));
            item.setCompanyId(c.getString(c.getColumnIndex("company_id")));
            item.setBirthday(c.getString(c.getColumnIndex("birthday")));
            item.setRemark(c.getString(c.getColumnIndex("remark")));
            item.setSurveillancePhoto(c.getString(c.getColumnIndex("surveillance_photo")));
            item.setUploadCustomPhoto(c.getString(c.getColumnIndex("upload_custom_photo")));
            item.setIdCardPhoto(c.getString(c.getColumnIndex("id_card_head_photo")));
            item.setCreateTime(c.getString(c.getColumnIndex("create_time")));
            item.setRawSurveillancePhotoPath(c.getString(c.getColumnIndex("raw_surveillance_photo_path")));
            item.setRawSurveillancePhotoWidth(c.getString(c.getColumnIndex("raw_surveillance_photo_width")));
            item.setRawSurveillancePhotoHeight(c.getString(c.getColumnIndex("raw_surveillance_photo_height")));
        }
        return item;
    }
    public void removeOfflineVisitorRegister(OfflineVisitorRegisterItem item) {
@@ -174,4 +278,23 @@
        }
    }
    public boolean hasMoreVisitorRegisters() {
        boolean hasMore = false;
        String sql = "select count(*) from register where is_synchron = 'N' and visitor_or_attender='visitor'";
        Cursor c = MainActivity.getInstance().db.rawQuery(sql, new String[]{});
        if (c.moveToFirst()) {
            hasMore = c.getInt(0) > 0;
        }
        return hasMore;
    }
    public boolean hasMoreAttenderRegisters() {
        boolean hasMore = false;
        String sql = "select count(*) from register where is_synchron = 'N' and visitor_or_attender='attender'";
        Cursor c = MainActivity.getInstance().db.rawQuery(sql, new String[]{});
        if (c.moveToFirst()) {
            hasMore = c.getInt(0) > 0;
        }
        return hasMore;
    }
}