| | |
| | | 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.base.MainActivity;
|
| | | import cn.com.basic.face.discern.entity.Device;
|
| | | import cn.com.basic.face.discern.entity.Dictionary;
|
| | | import cn.com.basic.face.discern.query.item.DeviceQueryItem;
|
| | |
|
| | | /**
|
| | | * 设备Dao
|
| | |
| | | public List<Device> loadMainDevice(String type, String sn) {
|
| | |
|
| | | 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, ").
|
| | |
| | |
|
| | |
|
| | | Device aqi = null;
|
| | | Cursor c = db.rawQuery(sb.toString(), new String[]{});
|
| | |
|
| | | Cursor c = MainActivity.getInstance().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.setInstallAddress(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")));
|
| | |
| | |
|
| | | list.add(aqi);
|
| | | }
|
| | | c.close();
|
| | | db.setTransactionSuccessful();
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }finally {
|
| | | db.endTransaction();
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
| | | * @param belongId 所属设备Id(主设备)
|
| | | * @return
|
| | | */
|
| | | public List<Device> loadCamera(String type, String belongId) {
|
| | | public List<DeviceQueryItem> loadCamera(String type, String belongId) {
|
| | |
|
| | | List<Device> list = new ArrayList<Device>();
|
| | | SQLiteDatabase db = Config.sqlMap.getDb();
|
| | | db.beginTransaction();
|
| | | List<DeviceQueryItem> list = new ArrayList<DeviceQueryItem>();
|
| | |
|
| | |
|
| | | try {
|
| | | StringBuilder sb = new StringBuilder(40);
|
| | |
|
| | |
| | | sb.append(" AND a.belong_id = ").append(belongId) ;
|
| | | }
|
| | |
|
| | | DeviceQueryItem aqi = null;
|
| | |
|
| | |
|
| | | Device aqi = null;
|
| | | Cursor c = db.rawQuery(sb.toString(), new String[]{});
|
| | | Cursor c = MainActivity.getInstance().db.rawQuery(sb.toString(), new String[]{});
|
| | | while (c.moveToNext()) {
|
| | | aqi = new Device();
|
| | | aqi = new DeviceQueryItem();
|
| | | 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.setInstallAddress(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")));
|
| | |
| | | list.add(aqi);
|
| | | }
|
| | | c.close();
|
| | | db.setTransactionSuccessful();
|
| | |
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }finally {
|
| | | db.endTransaction();
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | public List<Device> getDeviceList(String deviceCompanyId){
|
| | | String sql="select * from device WHERE is_synchron='N' and device_company_id="+Integer.parseInt(deviceCompanyId);
|
| | | Cursor c =MainActivity.getInstance().db.rawQuery(sql,new String[]{});
|
| | | List<Device> result=new ArrayList<Device>();
|
| | | Device device=null;
|
| | | if(c.moveToFirst()){
|
| | | device=new Device();
|
| | | device.setUpdateTime(c.getString(c.getColumnIndex("update_time")));
|
| | | device.setIsSynchron(c.getString(c.getColumnIndex("is_synchron")));
|
| | | device.setDeviceCompanyId(c.getString(c.getColumnIndex("device_company_id")));
|
| | | device.setBelongId(c.getString(c.getColumnIndex("belong_id")));
|
| | | device.setBrandId(c.getString(c.getColumnIndex("brand_id")));
|
| | | device.setCompanyId(c.getString(c.getColumnIndex("company_id")));
|
| | | device.setDeviceName(c.getString(c.getColumnIndex("device_name")));
|
| | | device.setDeviceId(c.getString(c.getColumnIndex("device_id")));
|
| | | device.setInstallAddress(c.getString(c.getColumnIndex("install_address")));
|
| | | device.setInstallCompany(c.getString(c.getColumnIndex("install_company")));
|
| | | device.setInstallTime(c.getString(c.getColumnIndex("install_time")));
|
| | | device.setIp(c.getString(c.getColumnIndex("ip")));
|
| | | device.setManufacturer(c.getString(c.getColumnIndex("manufacturer")));
|
| | | device.setPassword(c.getString(c.getColumnIndex("password")));
|
| | | device.setPort(c.getString(c.getColumnIndex("port")));
|
| | | device.setPrincipal(c.getString(c.getColumnIndex("principal")));
|
| | | device.setRemark(c.getString(c.getColumnIndex("remark")));
|
| | | device.setResolutionId(c.getString(c.getColumnIndex("resolution_id")));
|
| | | device.setProductionDate(c.getString(c.getColumnIndex("production_date")));
|
| | | device.setProtocolId(c.getString(c.getColumnIndex("protocol_id")));
|
| | | device.setUsername(c.getString(c.getColumnIndex("username")));
|
| | | device.setSn(c.getString(c.getColumnIndex("sn")));
|
| | | device.setType(c.getString(c.getColumnIndex("type")));
|
| | | device.setSchoolName(c.getString(c.getColumnIndex("school_name")));
|
| | | device.setScrappedDate(c.getString(c.getColumnIndex("scrapped_date")));
|
| | | device.setIsValid(c.getString(c.getColumnIndex("is_valid")));
|
| | | device.setCreateTime(c.getString(c.getColumnIndex("create_time")));
|
| | | result.add(device);
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
|
| | |
|
| | | //删除已经上传到服务器的同步数据
|
| | | public void delDevice(){
|
| | | String sql="delete from device where is_synchron='N'";
|
| | | MainActivity.getInstance().db.execSQL(sql);
|
| | |
|
| | | }
|
| | |
|
| | | //获取未同步数据总数
|
| | | public int getSynDataCount(){
|
| | | String sql="select count(*) from device where is_synchron='N' ";
|
| | | Cursor c =MainActivity.getInstance().db.rawQuery(sql,new String[]{});
|
| | | c.moveToFirst();
|
| | | return c.getInt(0);
|
| | | }
|
| | |
|
| | | }
|