| | |
| | | package cn.com.basic.face.service.sqlite;
|
| | |
|
| | | import android.database.Cursor;
|
| | | import android.database.sqlite.SQLiteDatabase;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import cn.com.basic.face.base.Config;
|
| | | import cn.com.basic.face.discern.entity.Device;
|
| | | import cn.com.basic.face.discern.entity.Dictionary;
|
| | |
|
| | | /**
|
| | | * 设备Dao
|
| | |
| | | */
|
| | | public List<Device> loadMainDevice(String type, String sn) {
|
| | |
|
| | | return null;
|
| | | List<Device> list = new ArrayList<Device>();
|
| | | SQLiteDatabase db = Config.sqlMap.getDb();
|
| | | db.beginTransaction();
|
| | | try {
|
| | | StringBuilder sb = new StringBuilder(40);
|
| | | sb.append("select a.device_id, ").append("a.company_id, ").
|
| | | append("a.device_name, ").append("a.type, ").append("a.install_address, ")
|
| | | .append("a.school_name, ").append("a.brand_id, ").append("a.ip, ")
|
| | | .append("a.port, ").append("a.resolution_id, ").append("a.username, ")
|
| | | .append("a.password, ").append("a.protocol_id, ").append("a.sn, ")
|
| | | .append("a.belong_id ").append("from device a ")
|
| | | .append("where 1 = 1");
|
| | | if(type != null && !type.trim().isEmpty()) {
|
| | | sb.append(" AND a.type = '").append(type).append("'");
|
| | | }
|
| | | if(sn != null && !sn.trim().isEmpty()) {
|
| | | sb.append(" AND a.sn = ").append(sn) ;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | Device aqi = null;
|
| | | Cursor c = db.rawQuery(sb.toString(), new String[]{});
|
| | | while (c.moveToNext()) {
|
| | | aqi = new Device();
|
| | | aqi.setDeviceId(c.getString(c.getColumnIndex("device_id")));
|
| | | aqi.setCompanyId(c.getString((c.getColumnIndex("company_id"))));
|
| | | aqi.setDeviceName(c.getString((c.getColumnIndex("device_name"))));
|
| | | aqi.setType(c.getString(c.getColumnIndex("type")));
|
| | | aqi.setInstallAdress(c.getString((c.getColumnIndex("install_address"))));
|
| | | aqi.setSchoolName(c.getString((c.getColumnIndex("school_name"))));
|
| | | aqi.setBrandId(c.getString(c.getColumnIndex("brand_id")));
|
| | | aqi.setIp(c.getString(c.getColumnIndex("ip")));
|
| | | aqi.setPort(c.getString(c.getColumnIndex("port")));
|
| | | aqi.setResolutionId(c.getString(c.getColumnIndex("resolution_id")));
|
| | | aqi.setUsername(c.getString(c.getColumnIndex("username")));
|
| | | aqi.setPassword(c.getString(c.getColumnIndex("password")));
|
| | | aqi.setProtocolId(c.getString(c.getColumnIndex("protocol_id")));
|
| | | aqi.setSn(c.getString(c.getColumnIndex("sn")));
|
| | | aqi.setBelongId(c.getString(c.getColumnIndex("belong_id")));
|
| | |
|
| | | list.add(aqi);
|
| | | }
|
| | | c.close();
|
| | | db.setTransactionSuccessful();
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }finally {
|
| | | db.endTransaction();
|
| | | if(db!=null){
|
| | | db.close();
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | public List<Device> loadCamera(String type, String belongId) {
|
| | |
|
| | | return null;
|
| | | List<Device> list = new ArrayList<Device>();
|
| | | SQLiteDatabase db = Config.sqlMap.getDb();
|
| | | db.beginTransaction();
|
| | | try {
|
| | | StringBuilder sb = new StringBuilder(40);
|
| | |
|
| | | sb.append("select a.device_id, ").append("a.company_id, ").
|
| | | append("a.device_name, ").append("a.type, ").append("a.install_address, ")
|
| | | .append("a.school_name, ").append("a.brand_id, ").append("a.ip, ")
|
| | | .append("a.port, ").append("a.resolution_id, ").append("a.username, ")
|
| | | .append("a.password, ").append("a.protocol_id, ").append("a.sn, ")
|
| | | .append("a.belong_id ").append("from device a ")
|
| | | .append("where 1 = 1");
|
| | | if(type != null && !type.trim().isEmpty()) {
|
| | | sb.append(" AND a.type = '").append(type).append("'");
|
| | | }
|
| | | if(belongId != null && !belongId.trim().isEmpty()) {
|
| | | sb.append(" AND a.belong_id = ").append(belongId) ;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | Device aqi = null;
|
| | | Cursor c = db.rawQuery(sb.toString(), new String[]{});
|
| | | while (c.moveToNext()) {
|
| | | aqi = new Device();
|
| | | aqi.setDeviceId(c.getString(c.getColumnIndex("device_id")));
|
| | | aqi.setCompanyId(c.getString((c.getColumnIndex("company_id"))));
|
| | | aqi.setDeviceName(c.getString((c.getColumnIndex("device_name"))));
|
| | | aqi.setType(c.getString(c.getColumnIndex("type")));
|
| | | aqi.setInstallAdress(c.getString((c.getColumnIndex("install_address"))));
|
| | | aqi.setSchoolName(c.getString((c.getColumnIndex("school_name"))));
|
| | | aqi.setBrandId(c.getString(c.getColumnIndex("brand_id")));
|
| | | aqi.setIp(c.getString(c.getColumnIndex("ip")));
|
| | | aqi.setPort(c.getString(c.getColumnIndex("port")));
|
| | | aqi.setResolutionId(c.getString(c.getColumnIndex("resolution_id")));
|
| | | aqi.setUsername(c.getString(c.getColumnIndex("username")));
|
| | | aqi.setPassword(c.getString(c.getColumnIndex("password")));
|
| | | aqi.setProtocolId(c.getString(c.getColumnIndex("protocol_id")));
|
| | | aqi.setSn(c.getString(c.getColumnIndex("sn")));
|
| | | aqi.setBelongId(c.getString(c.getColumnIndex("belong_id")));
|
| | |
|
| | | list.add(aqi);
|
| | | }
|
| | | c.close();
|
| | | db.setTransactionSuccessful();
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }finally {
|
| | | db.endTransaction();
|
| | | if(db!=null){
|
| | | db.close();
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | }
|