| | |
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | 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.common.ResultBean;
|
| | | import cn.com.basic.face.discern.query.item.AttendanceQueryItem;
|
| | | import cn.com.basic.face.discern.query.item.VisitQueryItem;
|
| | |
|
| | | public class VisitDao extends BaseDao{
|
| | |
|
| | |
| | | */
|
| | | public ResultBean findLeftVisitorList(String searchText, int pageNum) {
|
| | | ResultBean resultBean = new ResultBean();
|
| | | SQLiteDatabase db = Config.sqlMap.getDb();
|
| | | db.beginTransaction();
|
| | | SQLiteDatabase db = MainActivity.getInstance().db;
|
| | | try {
|
| | | StringBuilder sb = new StringBuilder(40);
|
| | | sb.append("SELECT a.register_id,a.username,a.surveillance_photo,d.company_name,a.tel,a.identify_num,b.dept_name,")
|
| | |
| | | StringBuilder count = new StringBuilder(sb.length());
|
| | | count.append("select count(*) as count from (").append(sb).append(" ) _table");
|
| | | sb.append(" LIMIT ").append(getStartIndex(pageNum)).append(",").append(CommonVariables.Page.DEFAULT_PAGE_SIZE);
|
| | | List<AttendanceQueryItem> list = new ArrayList<AttendanceQueryItem>();
|
| | | AttendanceQueryItem aqi = null;
|
| | | List<VisitQueryItem> list = new ArrayList<VisitQueryItem>();
|
| | | VisitQueryItem aqi = null;
|
| | | Cursor c = db.rawQuery(sb.toString(),new String[]{});
|
| | | Cursor c_count = db.rawQuery(count.toString(),new String[]{});
|
| | | while (c.moveToNext()) {
|
| | | aqi = new AttendanceQueryItem();
|
| | | aqi = new VisitQueryItem();
|
| | | aqi.setRegisterId(c.getString(c.getColumnIndex("register_id")));
|
| | | aqi.setUsername(c.getString(c.getColumnIndex("username")));
|
| | | aqi.setSurveillancePhoto(c.getString(c.getColumnIndex("surveillance_photo")));
|
| | |
| | | }
|
| | | Integer total = null;
|
| | | while (c_count.moveToNext()) {
|
| | | total = c.getInt(c.getColumnIndex("count"));
|
| | | total = c_count.getInt(0);
|
| | | }
|
| | | resultBean.setTotalPages(getTotalPageSize(total));
|
| | | resultBean.setPageNum(pageNum);
|
| | | resultBean.setData(list);
|
| | | c.close();
|
| | | c_count.close();
|
| | | db.setTransactionSuccessful();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | db.endTransaction();
|
| | | }
|
| | | return resultBean;
|
| | | }
|