VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/query/item/OfflineAttenderRegisterItem.java
@@ -1,6 +1,8 @@ package cn.com.basic.face.discern.query.item; public class OfflineAttenderRegisterItem { import cn.com.basic.face.discern.entity.Register; public class OfflineAttenderRegisterItem extends Register { private String attenderId; VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/discern/query/item/OfflineVisitorRegisterItem.java
@@ -2,276 +2,60 @@ import java.io.File; import cn.com.basic.face.discern.entity.Register; import cn.com.basic.face.util.FileUtil; public class OfflineVisitorRegisterItem { public class OfflineVisitorRegisterItem extends Register { private String visitorId; private String username; private String mobilePhone; private String genderId; private String identityTypeId; private String countryId; private String visitorTypeId; private String identifyNum; private String companyId; private String birthday; private String remark; private String rawSurveillancePhotoPath; private String rawSurveillancePhotoWidth; private String rawSurveillancePhotoHeight; private String surveillancePhotoPath; private String surveillancePhotoWidth; private String surveillancePhotoHeight; private String uploadCustomPhotoPath; private String uploadCustomPhotoWidth; private String uploadCustomPhotoHeight; private String idCardPhotoPath; private String idCardPhotoWidth; private String idCardPhotoHeight; private String createTime; private File rawSurveillancePhotoFile; private File SurveillancePhotoFile; private File uploadCustomPhotoFile; private File idCardPhotoFile; private File rawSurveillancePhoto; private File surveillancePhoto; private File uploadCustomPhoto; private File idCardPhoto; public String getUsername() { return username; public File getRawSurveillancePhotoFile() { return rawSurveillancePhotoFile; } public void setUsername(String username) { this.username = username; public void setRawSurveillancePhotoFile(File rawSurveillancePhotoFile) { this.rawSurveillancePhotoFile = rawSurveillancePhotoFile; } public String getMobilePhone() { return mobilePhone; public File getSurveillancePhotoFile() { return SurveillancePhotoFile; } public void setMobilePhone(String mobilePhone) { this.mobilePhone = mobilePhone; public void setSurveillancePhotoFile(File surveillancePhotoFile) { SurveillancePhotoFile = surveillancePhotoFile; } public String getGenderId() { return genderId; public File getUploadCustomPhotoFile() { return uploadCustomPhotoFile; } public void setGenderId(String genderId) { this.genderId = genderId; public void setUploadCustomPhotoFile(File uploadCustomPhotoFile) { this.uploadCustomPhotoFile = uploadCustomPhotoFile; } public String getIdentityTypeId() { return identityTypeId; public File getIdCardPhotoFile() { return idCardPhotoFile; } public void setIdentityTypeId(String identityTypeId) { this.identityTypeId = identityTypeId; } public String getCountryId() { return countryId; } public void setCountryId(String countryId) { this.countryId = countryId; } public String getVisitorTypeId() { return visitorTypeId; } public void setVisitorTypeId(String visitorTypeId) { this.visitorTypeId = visitorTypeId; } public String getIdentifyNum() { return identifyNum; } public void setIdentifyNum(String identifyNum) { this.identifyNum = identifyNum; } public String getCompanyId() { return companyId; } public void setCompanyId(String companyId) { this.companyId = companyId; } public String getBirthday() { return birthday; } public void setBirthday(String birthday) { this.birthday = birthday; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } public String getRawSurveillancePhotoPath() { return rawSurveillancePhotoPath; } public void setRawSurveillancePhotoPath(String rawSurveillancePhotoPath) { this.rawSurveillancePhotoPath = rawSurveillancePhotoPath; } public String getRawSurveillancePhotoWidth() { return rawSurveillancePhotoWidth; } public void setRawSurveillancePhotoWidth(String rawSurveillancePhotoWidth) { this.rawSurveillancePhotoWidth = rawSurveillancePhotoWidth; } public String getRawSurveillancePhotoHeight() { return rawSurveillancePhotoHeight; } public void setRawSurveillancePhotoHeight(String rawSurveillancePhotoHeight) { this.rawSurveillancePhotoHeight = rawSurveillancePhotoHeight; } public String getSurveillancePhotoPath() { return surveillancePhotoPath; } public void setSurveillancePhotoPath(String surveillancePhotoPath) { this.surveillancePhotoPath = surveillancePhotoPath; } public String getSurveillancePhotoWidth() { return surveillancePhotoWidth; } public void setSurveillancePhotoWidth(String surveillancePhotoWidth) { this.surveillancePhotoWidth = surveillancePhotoWidth; } public String getSurveillancePhotoHeight() { return surveillancePhotoHeight; } public void setSurveillancePhotoHeight(String surveillancePhotoHeight) { this.surveillancePhotoHeight = surveillancePhotoHeight; } public String getUploadCustomPhotoPath() { return uploadCustomPhotoPath; } public void setUploadCustomPhotoPath(String uploadCustomPhotoPath) { this.uploadCustomPhotoPath = uploadCustomPhotoPath; } public String getUploadCustomPhotoWidth() { return uploadCustomPhotoWidth; } public void setUploadCustomPhotoWidth(String uploadCustomPhotoWidth) { this.uploadCustomPhotoWidth = uploadCustomPhotoWidth; } public String getUploadCustomPhotoHeight() { return uploadCustomPhotoHeight; } public void setUploadCustomPhotoHeight(String uploadCustomPhotoHeight) { this.uploadCustomPhotoHeight = uploadCustomPhotoHeight; } public String getIdCardPhotoPath() { return idCardPhotoPath; } public void setIdCardPhotoPath(String idCardPhotoPath) { this.idCardPhotoPath = idCardPhotoPath; } public String getIdCardPhotoWidth() { return idCardPhotoWidth; } public void setIdCardPhotoWidth(String idCardPhotoWidth) { this.idCardPhotoWidth = idCardPhotoWidth; } public String getIdCardPhotoHeight() { return idCardPhotoHeight; } public void setIdCardPhotoHeight(String idCardPhotoHeight) { this.idCardPhotoHeight = idCardPhotoHeight; } public String getVisitorId() { return visitorId; } public void setVisitorId(String visitorId) { this.visitorId = visitorId; } public File getRawSurveillancePhoto() { return rawSurveillancePhoto; } public void setRawSurveillancePhoto(File rawSurveillancePhoto) { this.rawSurveillancePhoto = rawSurveillancePhoto; } public File getSurveillancePhoto() { return surveillancePhoto; } public void setSurveillancePhoto(File surveillancePhoto) { this.surveillancePhoto = surveillancePhoto; } public File getUploadCustomPhoto() { return uploadCustomPhoto; } public void setUploadCustomPhoto(File uploadCustomPhoto) { this.uploadCustomPhoto = uploadCustomPhoto; } public File getIdCardPhoto() { return idCardPhoto; } public void setIdCardPhoto(File idCardPhoto) { this.idCardPhoto = idCardPhoto; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; public void setIdCardPhotoFile(File idCardPhotoFile) { this.idCardPhotoFile = idCardPhotoFile; } public void loadFiles() { setRawSurveillancePhoto(FileUtil.getFile(getRawSurveillancePhotoPath())); setSurveillancePhoto(FileUtil.getFile(getSurveillancePhotoPath())); setUploadCustomPhoto(FileUtil.getFile(getUploadCustomPhotoPath())); setIdCardPhoto(FileUtil.getFile(getIdCardPhotoPath())); setRawSurveillancePhotoFile(FileUtil.getFile(getRawSurveillancePhotoPath())); setSurveillancePhotoFile(FileUtil.getFile(getSurveillancePhoto())); setUploadCustomPhotoFile(FileUtil.getFile(getUploadCustomPhoto())); setIdCardPhotoFile(FileUtil.getFile(getIdCardPhoto())); } public void deleteFiles() { FileUtil.deleteFile(getRawSurveillancePhotoPath()); FileUtil.deleteFile(getSurveillancePhotoPath()); FileUtil.deleteFile(getUploadCustomPhotoPath()); FileUtil.deleteFile(getIdCardPhotoPath()); FileUtil.deleteFile(getSurveillancePhoto()); FileUtil.deleteFile(getUploadCustomPhoto()); FileUtil.deleteFile(getIdCardPhoto()); } } VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/VisitorRegisterFragment.java
@@ -168,7 +168,7 @@ return; } OfflineVisitorRegisterItem offlineVisitorRegisterItem = new OfflineVisitorRegisterItem(); Register offlineVisitorRegisterItem = new Register(); if (BaseApplication.getInstance().networkAvailable()) { params.addBodyParameter(Register.FieldNames.username, name); params.addBodyParameter(Register.FieldNames.mobilePhone, phone); @@ -257,7 +257,7 @@ surveillancePhotoBytes = byteArrayOutputStream.toByteArray(); } FileUtil.writeToFile(surveillancePhotoPath, surveillancePhotoBytes); offlineVisitorRegisterItem.setSurveillancePhotoPath(surveillancePhotoPath); offlineVisitorRegisterItem.setSurveillancePhoto(surveillancePhotoPath); String uploadCustomPhotoPath = UUID.randomUUID().toString()+".bmp"; byte[] uploadCustomPhotoBytes = new byte[]{}; @@ -267,7 +267,7 @@ uploadCustomPhotoBytes = byteArrayOutputStream.toByteArray(); } FileUtil.writeToFile(uploadCustomPhotoPath, uploadCustomPhotoBytes); offlineVisitorRegisterItem.setUploadCustomPhotoPath(uploadCustomPhotoPath); offlineVisitorRegisterItem.setUploadCustomPhoto(uploadCustomPhotoPath); String idCardPhotoPath = UUID.randomUUID().toString()+".bmp"; byte[] idCardPhotoBytes = new byte[]{}; @@ -277,7 +277,7 @@ idCardPhotoBytes = byteArrayOutputStream.toByteArray(); } FileUtil.writeToFile(idCardPhotoPath, idCardPhotoBytes); offlineVisitorRegisterItem.setIdCardPhotoPath(idCardPhotoPath); offlineVisitorRegisterItem.setIdCardPhoto(idCardPhotoPath); } RegisterMng.getInstance().add(params, idCardHeadPath, offlineVisitorRegisterItem); } VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java
@@ -40,7 +40,7 @@ return instance; } public void add(RequestParams params, String idCardHeadPhoto, OfflineVisitorRegisterItem offlineVisitorRegisterItem) { public void add(RequestParams params, String idCardHeadPhoto, Register offlineVisitorRegisterItem) { if (!BaseApplication.deviceAvailable) { return; } @@ -255,7 +255,7 @@ item.loadFiles(); params.addBodyParameter("rawSurveillancePhoto", item.getRawSurveillancePhoto()); params.addBodyParameter("rawSurveillancePhoto", item.getRawSurveillancePhotoPath()); params.addBodyParameter("surveillancePhoto", item.getSurveillancePhoto()); params.addBodyParameter("uploadCustomPhoto", item.getUploadCustomPhoto()); params.addBodyParameter("idCardPhoto", item.getIdCardPhoto()); VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/CheckInDao.java
@@ -1,6 +1,7 @@ package cn.com.basic.face.service.sqlite; import android.database.Cursor; import android.database.CursorJoiner; import android.database.sqlite.SQLiteDatabase; import org.xutils.http.RequestParams; @@ -160,5 +161,76 @@ return c.getInt(0) > 0 ? true : false; } public ResultBean findCheckInLeftListById(long registerId) { SQLiteDatabase db = MainActivity.getInstance().db; ResultBean resultBean = new ResultBean(); try { String sql="SELECT" + " a.register_id," + "a.username," + "a.surveillance_photo," + "d.company_name," + "a.tel," + "a.identify_num," + "b.dept_name," + "d.company_id," + "e.post_name," + "a.mobile_phone," + "a.warning" + " FROM" + " register a" + " LEFT JOIN company d ON d.company_id = a.company_id" + " LEFT JOIN department b ON a.department_id = b.dept_id" + " LEFT JOIN post e ON e.post_id = a.post_id" + " LEFT JOIN ( SELECT register_id, device_company_id from employee ) f ON f.register_id = a.register_id" + " WHERE" + " 1 = 1"; String deviceCompanyId = BaseApplication.getInstance().getAndroidDevice().getCompanyId(); if(true) { sql += " AND f.device_company_id = " + deviceCompanyId; }else{ sql += " AND ( f.device_company_id != " + deviceCompanyId+" OR f.device_company_id IS NULL"+")"; } if("" != null && !"".trim().isEmpty()) { sql += " AND a.register_id='"+ registerId + "'"; } sql+=" order by a.name_en"; String count = "select count(*) as count from (" + sql + " ) _table"; sql += " LIMIT " + getStartIndex(1) + "," + CommonVariables.Page.DEFAULT_PAGE_SIZE; List<CheckInQueryItem> list = new ArrayList<CheckInQueryItem>(); int b = list.size(); CheckInQueryItem cqi = null; Cursor c = db.rawQuery(sql,new String[]{}); Cursor c_count = db.rawQuery(count,new String[]{}); while (c.moveToNext()) { cqi = new CheckInQueryItem(); cqi.setRegisterId(c.getString(c.getColumnIndex("register_id"))); cqi.setUsername(c.getString(c.getColumnIndex("username"))); cqi.setSurveillancePhoto(c.getString(c.getColumnIndex("surveillance_photo"))); cqi.setCompanyName(c.getString(c.getColumnIndex("company_name"))); cqi.setTel(c.getString(c.getColumnIndex("tel"))); cqi.setIdentifyNum(c.getString(c.getColumnIndex("identify_num"))); cqi.setDeptName(c.getString(c.getColumnIndex("dept_name"))); cqi.setCompanyId(c.getString(c.getColumnIndex("company_id"))); cqi.setPostName(c.getString(c.getColumnIndex("post_name"))); cqi.setMobilePhone(c.getString(c.getColumnIndex("mobile_phone"))); cqi.setWarning(c.getString(c.getColumnIndex("warning"))); list.add(cqi); } Integer total = null; while (c_count.moveToNext()) { total = c_count.getInt(c_count.getColumnIndex("count")); } resultBean.setTotalPages(getTotalPageSize(total)); resultBean.setPageNum(1); resultBean.setData(list); c.close(); return resultBean; } catch (Exception e) { e.printStackTrace(); } return resultBean; } } VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/sqlite/RegisterDao.java
@@ -1,15 +1,20 @@ package cn.com.basic.face.service.sqlite; import android.content.ContentValues; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import org.xutils.http.RequestParams; import java.io.File; import java.util.List; import cn.com.basic.face.base.BaseApplication; import cn.com.basic.face.base.Config; import cn.com.basic.face.base.MainActivity; import cn.com.basic.face.discern.common.CommonVariables; import cn.com.basic.face.discern.entity.Register; import cn.com.basic.face.discern.query.item.CheckInQueryItem; import cn.com.basic.face.discern.query.item.OfflineAttenderRegisterItem; import cn.com.basic.face.discern.query.item.OfflineVisitorRegisterItem; import cn.com.basic.face.discern.query.item.UnknownQueryItem; @@ -26,79 +31,44 @@ * 访客注册 * @return */ public boolean add(OfflineVisitorRegisterItem item) { String sql = "INSERT INTO register (\n" + " register_id,\n" + " username,\n" + " name_en,\n" + " gender_id,\n" + " country_id,\n" + " province,\n" + " city,\n" + " birthday,\n" + " tel,\n" + " mobile_phone,\n" + " identity_type_id,\n" + " identify_num,\n" + " company_id,\n" + " department_id,\n" + " post_id,\n" + " remark,\n" + " warning,\n" + " id_card_photo,\n" + " upload_custom_photo,\n" + " surveillance_photo,\n" + " surveillance_photo_id,\n" + " visitor_type_id,\n" + " authentication,\n" + " id_card_head_photo,\n" + " attender_type_id,\n" + " card_number,\n" + " update_time,\n" + " is_synchron,\n" + " device_company_id,\n" + " raw_surveillance_photo_path,\n" + " raw_surveillance_photo_width,\n" + " raw_surveillance_photo_height,\n" + " create_time\n" + ")\n" + "VALUES\n" + " (\n" + " '"+item.getVisitorId()+"', "+ " '"+item.getUsername()+"', "+ " '', "+ " '"+item.getGenderId()+"', "+ " '"+item.getCountryId()+"', "+ " '', "+ " '', "+ " '"+item.getBirthday()+"', "+ " '', "+ " '"+item.getMobilePhone()+"', "+ " '"+item.getIdentityTypeId()+"', "+ " '"+item.getIdentifyNum()+"', "+ " '"+item.getCompanyId()+"', "+ " null, "+ " null, "+ " '"+item.getRemark()+"', "+ " '', "+ " '"+item.getIdCardPhotoPath()+"', "+ " '"+item.getUploadCustomPhotoPath()+"', "+ " '"+item.getSurveillancePhotoPath()+"', "+ " null, "+ " '"+item.getVisitorTypeId()+"', "+ " '', "+ " '"+item.getIdCardPhotoPath()+"', "+ " null, "+ " '', "+ " null, "+ " 'N', "+ " '"+ BaseApplication.getInstance().getAndroidDevice().getCompanyId()+"', "+ " '"+item.getRawSurveillancePhotoPath()+"', "+ " '"+item.getRawSurveillancePhotoWidth()+"', "+ " '"+item.getRawSurveillancePhotoHeight()+"', "+ " '"+item.getCreateTime()+"')"; MainActivity.getInstance().db.execSQL(sql); return true; public List<CheckInQueryItem> add(Register item) { 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.getCompanyId()); 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()); long registerId = MainActivity.getInstance().db.insert("register", "", contentValues); List<CheckInQueryItem> checkInQueryItemList = (List<CheckInQueryItem>)CheckInDao.getInstance().findCheckInLeftListById(registerId).getData(); return checkInQueryItemList; } /** @@ -112,13 +82,13 @@ } public boolean hasOfflineVisitorRegisterData() { Cursor c = Config.sqlMap.getDb().rawQuery("select count(*) from offline_visitor_register", new String[]{}); Cursor c = Config.sqlMap.getDb().rawQuery("select count(*) from register", new String[]{}); c.moveToFirst(); return c.getInt(0) > 0 ? true : false; } public boolean hasOfflineAttenderRegisterData() { Cursor c = Config.sqlMap.getDb().rawQuery("select count(*) from offline_attender_register", new String[]{}); Cursor c = Config.sqlMap.getDb().rawQuery("select count(*) from register", new String[]{}); c.moveToFirst(); return c.getInt(0) > 0 ? true : false; } @@ -164,7 +134,7 @@ Cursor c = MainActivity.getInstance().db.rawQuery(sql, new String[]{}); if (c.moveToFirst()) { item = new OfflineVisitorRegisterItem(); item.setVisitorId(c.getString(c.getColumnIndex("register_id"))); 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"))); @@ -175,9 +145,9 @@ item.setCompanyId(c.getString(c.getColumnIndex("company_id"))); item.setBirthday(c.getString(c.getColumnIndex("birthday"))); item.setRemark(c.getString(c.getColumnIndex("remark"))); item.setSurveillancePhotoPath(c.getString(c.getColumnIndex("surveillance_photo"))); item.setUploadCustomPhotoPath(c.getString(c.getColumnIndex("upload_custom_photo"))); item.setIdCardPhotoPath(c.getString(c.getColumnIndex("id_card_head_photo"))); 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"))); @@ -193,7 +163,7 @@ public void removeOfflineVisitorRegister(OfflineVisitorRegisterItem item) { try { String sql = "delete from register where visitor_id='"+item.getVisitorId()+"' AND a.is_synchron = 'N'"; String sql = "delete from register where visitor_id='"+item.getRegisterId()+"' AND a.is_synchron = 'N'"; SQLiteDatabase db = Config.sqlMap.getDb(); db.beginTransaction(); db.execSQL(sql);