From 70125903eb0c58b81b37bc6e590b87ad92d9bce5 Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期日, 23 七月 2017 17:50:52 +0800
Subject: [PATCH] 

---
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/RegisterDao.java |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 111 insertions(+), 7 deletions(-)

diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/RegisterDao.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/RegisterDao.java
index 8cfdf8c..ee0b95a 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/RegisterDao.java
+++ b/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) {

--
Gitblit v1.8.0