| | |
| | | package cn.com.basic.face.service.sqlite;
|
| | |
|
| | | import android.database.Cursor;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | | import cn.com.basic.face.discern.entity.Device;
|
| | | import cn.com.basic.face.discern.query.item.DeviceQueryItem;
|
| | |
|
| | | /**
|
| | | * 设备Dao
|
| | |
| | | * @param sn 设备序列号
|
| | | * @param type 设备类型
|
| | | */
|
| | | public Device loadMainDevice(String type, String sn) {
|
| | | public List<Device> loadMainDevice(String type, String sn) {
|
| | |
|
| | | return null;
|
| | | List<Device> list = new ArrayList<Device>();
|
| | |
|
| | | 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 = 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.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")));
|
| | | 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);
|
| | | }
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param belongId 所属设备Id(主设备)
|
| | | * @return
|
| | | */
|
| | | public Device loadCamera(String type, String belongId) {
|
| | | public List<DeviceQueryItem> loadCamera(String type, String belongId) {
|
| | |
|
| | | return null;
|
| | | List<DeviceQueryItem> list = new ArrayList<DeviceQueryItem>();
|
| | |
|
| | |
|
| | | 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) ;
|
| | | }
|
| | |
|
| | | DeviceQueryItem aqi = null;
|
| | |
|
| | | Cursor c = MainActivity.getInstance().db.rawQuery(sb.toString(), new String[]{});
|
| | | while (c.moveToNext()) {
|
| | | 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.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")));
|
| | | 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();
|
| | |
|
| | | }catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | 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);
|
| | | }
|
| | |
|
| | | public void updateDevice(Device camera) {
|
| | |
|
| | | }
|
| | |
|
| | | }
|