19 changed files with 782 additions and 386 deletions
-
4app/src/main/java/com/iflytop/profilometer/api/auth/AuthApi.java
-
6app/src/main/java/com/iflytop/profilometer/api/measure/MeasureApi.java
-
2app/src/main/java/com/iflytop/profilometer/api/record/RecordApi.java
-
6app/src/main/java/com/iflytop/profilometer/api/system/SystemApi.java
-
105app/src/main/java/com/iflytop/profilometer/core/db/helper/MyDatabaseHelper.java
-
112app/src/main/java/com/iflytop/profilometer/dao/BaseProfileRecordPointSetDao.java
-
58app/src/main/java/com/iflytop/profilometer/dao/BluetoothDao.java
-
240app/src/main/java/com/iflytop/profilometer/dao/ProfileRecordDao.java
-
104app/src/main/java/com/iflytop/profilometer/dao/ProfileRecordPointSetDao.java
-
123app/src/main/java/com/iflytop/profilometer/dao/SystemConfigDao.java
-
25app/src/main/java/com/iflytop/profilometer/dao/UserDao.java
-
4app/src/main/java/com/iflytop/profilometer/model/entity/AppUser.java
-
42app/src/main/java/com/iflytop/profilometer/model/entity/BaseProfileRecordPointSet.java
-
2app/src/main/java/com/iflytop/profilometer/model/entity/ProfileRecordDescription.java
-
24app/src/main/java/com/iflytop/profilometer/model/entity/ProfileRecordPointSet.java
-
21app/src/main/java/com/iflytop/profilometer/model/entity/SystemConfig.java
-
26app/src/main/java/com/iflytop/profilometer/model/entiy/DefaultBluetooth.java
@ -0,0 +1,112 @@ |
|||||
|
package com.iflytop.profilometer.dao; |
||||
|
|
||||
|
import android.annotation.SuppressLint; |
||||
|
import android.content.ContentValues; |
||||
|
import android.content.Context; |
||||
|
import android.database.Cursor; |
||||
|
import android.database.sqlite.SQLiteDatabase; |
||||
|
|
||||
|
import com.iflytop.profilometer.core.db.helper.MyDatabaseHelper; |
||||
|
import com.iflytop.profilometer.model.entity.BaseProfileRecordPointSet; |
||||
|
|
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.Locale; |
||||
|
|
||||
|
public class BaseProfileRecordPointSetDao { |
||||
|
private final MyDatabaseHelper dbHelper; |
||||
|
|
||||
|
public BaseProfileRecordPointSetDao(Context context) { |
||||
|
dbHelper = new MyDatabaseHelper(context); |
||||
|
} |
||||
|
|
||||
|
// 插入基础测量点集记录 |
||||
|
public long insertBaseProfileRecordPointSet(BaseProfileRecordPointSet entity) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
ContentValues values = new ContentValues(); |
||||
|
String currentTime = getCurrentTime(); |
||||
|
values.put("create_time", currentTime); |
||||
|
values.put("update_time", currentTime); |
||||
|
values.put("name", entity.getName()); |
||||
|
values.put("code", entity.getCode()); |
||||
|
values.put("points", entity.getPoints()); |
||||
|
values.put("cal_points", entity.getCalPoints()); |
||||
|
long id = db.insert(MyDatabaseHelper.TABLE_BASE_PROFILE_RECORD_POINT_SET, null, values); |
||||
|
db.close(); |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
// 更新基础测量点集记录 |
||||
|
public int updateBaseProfileRecordPointSet(BaseProfileRecordPointSet entity) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
ContentValues values = new ContentValues(); |
||||
|
values.put("update_time", getCurrentTime()); |
||||
|
values.put("name", entity.getName()); |
||||
|
values.put("code", entity.getCode()); |
||||
|
values.put("points", entity.getPoints()); |
||||
|
values.put("cal_points", entity.getCalPoints()); |
||||
|
int rows = db.update(MyDatabaseHelper.TABLE_BASE_PROFILE_RECORD_POINT_SET, values, "id = ?", new String[]{String.valueOf(entity.getId())}); |
||||
|
db.close(); |
||||
|
return rows; |
||||
|
} |
||||
|
|
||||
|
// 删除基础测量点集记录 |
||||
|
public int deleteBaseProfileRecordPointSet(long id) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
int rows = db.delete(MyDatabaseHelper.TABLE_BASE_PROFILE_RECORD_POINT_SET, "id = ?", new String[]{String.valueOf(id)}); |
||||
|
db.close(); |
||||
|
return rows; |
||||
|
} |
||||
|
|
||||
|
// 查询所有基础测量点集记录 |
||||
|
@SuppressLint("Range") |
||||
|
public List<BaseProfileRecordPointSet> getAllBaseProfileRecordPointSets() { |
||||
|
List<BaseProfileRecordPointSet> list = new ArrayList<>(); |
||||
|
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
||||
|
Cursor cursor = db.query(MyDatabaseHelper.TABLE_BASE_PROFILE_RECORD_POINT_SET, null, null, null, null, null, "id DESC"); |
||||
|
if (cursor.moveToFirst()) { |
||||
|
do { |
||||
|
BaseProfileRecordPointSet entity = new BaseProfileRecordPointSet(); |
||||
|
entity.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
||||
|
entity.setName(cursor.getString(cursor.getColumnIndex("name"))); |
||||
|
entity.setCode(cursor.getString(cursor.getColumnIndex("code"))); |
||||
|
entity.setPoints(cursor.getString(cursor.getColumnIndex("points"))); |
||||
|
entity.setCalPoints(cursor.getString(cursor.getColumnIndex("cal_points"))); |
||||
|
entity.setCreateTime(cursor.getString(cursor.getColumnIndex("create_time"))); |
||||
|
entity.setUpdateTime(cursor.getString(cursor.getColumnIndex("update_time"))); |
||||
|
list.add(entity); |
||||
|
} while (cursor.moveToNext()); |
||||
|
cursor.close(); |
||||
|
} |
||||
|
db.close(); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
// 根据 id 查询基础测量点集记录 |
||||
|
@SuppressLint("Range") |
||||
|
public BaseProfileRecordPointSet getBaseProfileRecordPointSetById(long id) { |
||||
|
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
||||
|
Cursor cursor = db.query(MyDatabaseHelper.TABLE_BASE_PROFILE_RECORD_POINT_SET, null, "id = ?", new String[]{String.valueOf(id)}, null, null, null); |
||||
|
BaseProfileRecordPointSet entity = null; |
||||
|
if (cursor.moveToFirst()) { |
||||
|
entity = new BaseProfileRecordPointSet(); |
||||
|
entity.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
||||
|
entity.setName(cursor.getString(cursor.getColumnIndex("name"))); |
||||
|
entity.setCode(cursor.getString(cursor.getColumnIndex("code"))); |
||||
|
entity.setPoints(cursor.getString(cursor.getColumnIndex("points"))); |
||||
|
entity.setCalPoints(cursor.getString(cursor.getColumnIndex("cal_points"))); |
||||
|
entity.setCreateTime(cursor.getString(cursor.getColumnIndex("create_time"))); |
||||
|
entity.setUpdateTime(cursor.getString(cursor.getColumnIndex("update_time"))); |
||||
|
cursor.close(); |
||||
|
} |
||||
|
db.close(); |
||||
|
return entity; |
||||
|
} |
||||
|
|
||||
|
private String getCurrentTime() { |
||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); |
||||
|
return sdf.format(new Date()); |
||||
|
} |
||||
|
} |
@ -1,58 +0,0 @@ |
|||||
//package com.iflytop.profilometer.dao; |
|
||||
// |
|
||||
//import android.annotation.SuppressLint; |
|
||||
//import android.content.ContentValues; |
|
||||
//import android.content.Context; |
|
||||
//import android.database.Cursor; |
|
||||
//import android.database.sqlite.SQLiteDatabase; |
|
||||
// |
|
||||
//import com.iflytop.profilometer.core.db.helper.MyDatabaseHelper; |
|
||||
//import com.iflytop.profilometer.model.entiy.DefaultBluetooth; |
|
||||
// |
|
||||
//import java.text.SimpleDateFormat; |
|
||||
//import java.util.Date; |
|
||||
//import java.util.Locale; |
|
||||
// |
|
||||
//public class BluetoothDao { |
|
||||
// private final MyDatabaseHelper dbHelper; |
|
||||
// |
|
||||
// public BluetoothDao(Context context) { |
|
||||
// dbHelper = new MyDatabaseHelper(context); |
|
||||
// } |
|
||||
// |
|
||||
// // 插入默认蓝牙设备数据 |
|
||||
// public long insertBluetooth(DefaultBluetooth bt) { |
|
||||
// SQLiteDatabase db = dbHelper.getWritableDatabase(); |
|
||||
// ContentValues values = new ContentValues(); |
|
||||
// String currentTime = getCurrentTime(); |
|
||||
// values.put("create_time", currentTime); |
|
||||
// values.put("update_time", currentTime); |
|
||||
// values.put("bluetooth_id", bt.getBluetoothId()); |
|
||||
// values.put("bluetooth_name", bt.getBluetoothName()); |
|
||||
// long id = db.insert(MyDatabaseHelper.TABLE_DEFAULT_BLUETOOTH, null, values); |
|
||||
// db.close(); |
|
||||
// return id; |
|
||||
// } |
|
||||
// |
|
||||
// // 查询最近设置的默认蓝牙设备 |
|
||||
// @SuppressLint("Range") |
|
||||
// public DefaultBluetooth getDefaultBluetooth() { |
|
||||
// DefaultBluetooth bt = null; |
|
||||
// SQLiteDatabase db = dbHelper.getReadableDatabase(); |
|
||||
// Cursor cursor = db.query(MyDatabaseHelper.TABLE_DEFAULT_BLUETOOTH, null, null, null, null, null, "id DESC", "1"); |
|
||||
// if(cursor.moveToFirst()){ |
|
||||
// bt = new DefaultBluetooth(); |
|
||||
// bt.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
|
||||
// bt.setBluetoothId(cursor.getString(cursor.getColumnIndex("bluetooth_id"))); |
|
||||
// bt.setBluetoothName(cursor.getString(cursor.getColumnIndex("bluetooth_name"))); |
|
||||
// cursor.close(); |
|
||||
// } |
|
||||
// db.close(); |
|
||||
// return bt; |
|
||||
// } |
|
||||
// |
|
||||
// private String getCurrentTime() { |
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); |
|
||||
// return sdf.format(new Date()); |
|
||||
// } |
|
||||
//} |
|
@ -1,112 +1,128 @@ |
|||||
//package com.iflytop.profilometer.dao; |
|
||||
// |
|
||||
//import android.annotation.SuppressLint; |
|
||||
//import android.content.ContentValues; |
|
||||
//import android.content.Context; |
|
||||
//import android.database.Cursor; |
|
||||
//import android.database.sqlite.SQLiteDatabase; |
|
||||
// |
|
||||
//import com.iflytop.profilometer.core.db.helper.MyDatabaseHelper; |
|
||||
//import com.iflytop.profilometer.model.entiy.ProfileRecordDescription; |
|
||||
// |
|
||||
//import java.text.SimpleDateFormat; |
|
||||
//import java.util.ArrayList; |
|
||||
//import java.util.Date; |
|
||||
//import java.util.List; |
|
||||
//import java.util.Locale; |
|
||||
// |
|
||||
//public class ProfileRecordDao { |
|
||||
// private final MyDatabaseHelper dbHelper; |
|
||||
// |
|
||||
// public ProfileRecordDao(Context context) { |
|
||||
// dbHelper = new MyDatabaseHelper(context); |
|
||||
// } |
|
||||
// |
|
||||
// // 插入测量记录 |
|
||||
// public long insertProfileRecord(ProfileRecordDescription record) { |
|
||||
// SQLiteDatabase db = dbHelper.getWritableDatabase(); |
|
||||
// ContentValues values = new ContentValues(); |
|
||||
// String currentTime = getCurrentTime(); |
|
||||
// values.put("create_time", currentTime); |
|
||||
// values.put("update_time", currentTime); |
|
||||
// values.put("uuid", record.getUuid()); |
|
||||
// values.put("operator_name", record.getOperatorName()); |
|
||||
// values.put("track_shape_code", record.getTrackShapeCode()); |
|
||||
// values.put("verification_method_code", record.getVerificationMethodCode()); |
|
||||
// values.put("name", record.getName()); |
|
||||
// values.put("line_name", record.getLineName()); |
|
||||
// values.put("location", record.getLocation()); |
|
||||
// values.put("direction", record.getDirection()); |
|
||||
// long id = db.insert(MyDatabaseHelper.TABLE_PROFILE_RECORD, null, values); |
|
||||
// db.close(); |
|
||||
// return id; |
|
||||
// } |
|
||||
// |
|
||||
// // 查询所有测量记录 |
|
||||
// @SuppressLint("Range") |
|
||||
// public List<ProfileRecordDescription> getAllProfileRecords() { |
|
||||
// List<ProfileRecordDescription> records = new ArrayList<>(); |
|
||||
// SQLiteDatabase db = dbHelper.getReadableDatabase(); |
|
||||
// Cursor cursor = db.query(MyDatabaseHelper.TABLE_PROFILE_RECORD, null, null, null, null, null, "id DESC"); |
|
||||
// if(cursor.moveToFirst()){ |
|
||||
// do{ |
|
||||
// ProfileRecordDescription record = new ProfileRecordDescription(); |
|
||||
// record.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
|
||||
// record.setUuid(cursor.getString(cursor.getColumnIndex("uuid"))); |
|
||||
// record.setOperatorName(cursor.getString(cursor.getColumnIndex("operator_name"))); |
|
||||
// record.setTrackShapeCode(cursor.getString(cursor.getColumnIndex("track_shape_code"))); |
|
||||
// record.setVerificationMethodCode(cursor.getString(cursor.getColumnIndex("verification_method_code"))); |
|
||||
// record.setName(cursor.getString(cursor.getColumnIndex("name"))); |
|
||||
// record.setLineName(cursor.getString(cursor.getColumnIndex("line_name"))); |
|
||||
// record.setLocation(cursor.getString(cursor.getColumnIndex("location"))); |
|
||||
// record.setDirection(cursor.getString(cursor.getColumnIndex("direction"))); |
|
||||
// records.add(record); |
|
||||
// } while(cursor.moveToNext()); |
|
||||
// cursor.close(); |
|
||||
// } |
|
||||
// db.close(); |
|
||||
// return records; |
|
||||
// } |
|
||||
// |
|
||||
// @SuppressLint("Range") |
|
||||
// public List<ProfileRecordDescription> getProfileRecords(int page, int pageSize) { |
|
||||
// List<ProfileRecordDescription> records = new ArrayList<>(); |
|
||||
// SQLiteDatabase db = dbHelper.getReadableDatabase(); |
|
||||
// // 计算偏移量 |
|
||||
// int offset = (page - 1) * pageSize; |
|
||||
// // 使用 LIMIT 与 OFFSET 分页查询 |
|
||||
// String limitClause = offset + ", " + pageSize; |
|
||||
// Cursor cursor = db.query( |
|
||||
// MyDatabaseHelper.TABLE_PROFILE_RECORD, // 表名 |
|
||||
// null, // 查询所有列 |
|
||||
// null, null, // selection 及 selectionArgs |
|
||||
// null, null, // groupBy 和 having |
|
||||
// "id DESC", // orderBy |
|
||||
// limitClause // limit 子句:offset, pageSize |
|
||||
// ); |
|
||||
// if (cursor.moveToFirst()) { |
|
||||
// do { |
|
||||
// ProfileRecordDescription record = new ProfileRecordDescription(); |
|
||||
// record.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
|
||||
// record.setUuid(cursor.getString(cursor.getColumnIndex("uuid"))); |
|
||||
// record.setOperatorName(cursor.getString(cursor.getColumnIndex("operator_name"))); |
|
||||
// record.setTrackShapeCode(cursor.getString(cursor.getColumnIndex("track_shape_code"))); |
|
||||
// record.setVerificationMethodCode(cursor.getString(cursor.getColumnIndex("verification_method_code"))); |
|
||||
// record.setName(cursor.getString(cursor.getColumnIndex("name"))); |
|
||||
// record.setLineName(cursor.getString(cursor.getColumnIndex("line_name"))); |
|
||||
// record.setLocation(cursor.getString(cursor.getColumnIndex("location"))); |
|
||||
// record.setDirection(cursor.getString(cursor.getColumnIndex("direction"))); |
|
||||
// records.add(record); |
|
||||
// } while (cursor.moveToNext()); |
|
||||
// cursor.close(); |
|
||||
// } |
|
||||
// db.close(); |
|
||||
// return records; |
|
||||
// } |
|
||||
// |
|
||||
// |
|
||||
// private String getCurrentTime() { |
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); |
|
||||
// return sdf.format(new Date()); |
|
||||
// } |
|
||||
//} |
|
||||
|
package com.iflytop.profilometer.dao; |
||||
|
|
||||
|
import android.annotation.SuppressLint; |
||||
|
import android.content.ContentValues; |
||||
|
import android.content.Context; |
||||
|
import android.database.Cursor; |
||||
|
import android.database.sqlite.SQLiteDatabase; |
||||
|
|
||||
|
import com.iflytop.profilometer.core.db.helper.MyDatabaseHelper; |
||||
|
import com.iflytop.profilometer.model.entity.ProfileRecordDescription; |
||||
|
|
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.Locale; |
||||
|
|
||||
|
public class ProfileRecordDao { |
||||
|
private final MyDatabaseHelper dbHelper; |
||||
|
|
||||
|
public ProfileRecordDao(Context context) { |
||||
|
dbHelper = new MyDatabaseHelper(context); |
||||
|
} |
||||
|
|
||||
|
// 插入测量记录 |
||||
|
public long insertProfileRecord(ProfileRecordDescription record) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
ContentValues values = new ContentValues(); |
||||
|
String currentTime = getCurrentTime(); |
||||
|
values.put("create_time", currentTime); |
||||
|
values.put("update_time", currentTime); |
||||
|
values.put("uuid", record.getUuid()); |
||||
|
values.put("operator_name", record.getOperatorName()); |
||||
|
values.put("track_shape_code", record.getTrackShapeCode()); |
||||
|
values.put("verification_method_code", record.getVerificationMethodCode()); |
||||
|
values.put("name", record.getName()); |
||||
|
values.put("line_name", record.getLineName()); |
||||
|
values.put("location", record.getLocation()); |
||||
|
values.put("direction", record.getDirection()); |
||||
|
long id = db.insert(MyDatabaseHelper.TABLE_PROFILE_RECORD, null, values); |
||||
|
db.close(); |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
// 更新测量记录 |
||||
|
public int updateProfileRecord(ProfileRecordDescription record) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
ContentValues values = new ContentValues(); |
||||
|
values.put("update_time", getCurrentTime()); |
||||
|
values.put("uuid", record.getUuid()); |
||||
|
values.put("operator_name", record.getOperatorName()); |
||||
|
values.put("track_shape_code", record.getTrackShapeCode()); |
||||
|
values.put("verification_method_code", record.getVerificationMethodCode()); |
||||
|
values.put("name", record.getName()); |
||||
|
values.put("line_name", record.getLineName()); |
||||
|
values.put("location", record.getLocation()); |
||||
|
values.put("direction", record.getDirection()); |
||||
|
int rows = db.update(MyDatabaseHelper.TABLE_PROFILE_RECORD, values, "id = ?", new String[]{String.valueOf(record.getId())}); |
||||
|
db.close(); |
||||
|
return rows; |
||||
|
} |
||||
|
|
||||
|
// 删除测量记录 |
||||
|
public int deleteProfileRecord(long id) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
int rows = db.delete(MyDatabaseHelper.TABLE_PROFILE_RECORD, "id = ?", new String[]{String.valueOf(id)}); |
||||
|
db.close(); |
||||
|
return rows; |
||||
|
} |
||||
|
|
||||
|
// 查询所有测量记录 |
||||
|
@SuppressLint("Range") |
||||
|
public List<ProfileRecordDescription> getAllProfileRecords() { |
||||
|
List<ProfileRecordDescription> records = new ArrayList<>(); |
||||
|
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
||||
|
Cursor cursor = db.query(MyDatabaseHelper.TABLE_PROFILE_RECORD, null, null, null, null, null, "id DESC"); |
||||
|
if (cursor.moveToFirst()) { |
||||
|
do { |
||||
|
ProfileRecordDescription record = new ProfileRecordDescription(); |
||||
|
record.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
||||
|
record.setUuid(cursor.getString(cursor.getColumnIndex("uuid"))); |
||||
|
record.setOperatorName(cursor.getString(cursor.getColumnIndex("operator_name"))); |
||||
|
record.setTrackShapeCode(cursor.getString(cursor.getColumnIndex("track_shape_code"))); |
||||
|
record.setVerificationMethodCode(cursor.getString(cursor.getColumnIndex("verification_method_code"))); |
||||
|
record.setName(cursor.getString(cursor.getColumnIndex("name"))); |
||||
|
record.setLineName(cursor.getString(cursor.getColumnIndex("line_name"))); |
||||
|
record.setLocation(cursor.getString(cursor.getColumnIndex("location"))); |
||||
|
record.setDirection(cursor.getString(cursor.getColumnIndex("direction"))); |
||||
|
record.setCreateTime(cursor.getString(cursor.getColumnIndex("create_time"))); |
||||
|
record.setUpdateTime(cursor.getString(cursor.getColumnIndex("update_time"))); |
||||
|
records.add(record); |
||||
|
} while (cursor.moveToNext()); |
||||
|
cursor.close(); |
||||
|
} |
||||
|
db.close(); |
||||
|
return records; |
||||
|
} |
||||
|
|
||||
|
// 根据 id 查询测量记录 |
||||
|
@SuppressLint("Range") |
||||
|
public ProfileRecordDescription getProfileRecordById(long id) { |
||||
|
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
||||
|
Cursor cursor = db.query(MyDatabaseHelper.TABLE_PROFILE_RECORD, null, "id = ?", new String[]{String.valueOf(id)}, null, null, null); |
||||
|
ProfileRecordDescription record = null; |
||||
|
if (cursor.moveToFirst()) { |
||||
|
record = new ProfileRecordDescription(); |
||||
|
record.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
||||
|
record.setUuid(cursor.getString(cursor.getColumnIndex("uuid"))); |
||||
|
record.setOperatorName(cursor.getString(cursor.getColumnIndex("operator_name"))); |
||||
|
record.setTrackShapeCode(cursor.getString(cursor.getColumnIndex("track_shape_code"))); |
||||
|
record.setVerificationMethodCode(cursor.getString(cursor.getColumnIndex("verification_method_code"))); |
||||
|
record.setName(cursor.getString(cursor.getColumnIndex("name"))); |
||||
|
record.setLineName(cursor.getString(cursor.getColumnIndex("line_name"))); |
||||
|
record.setLocation(cursor.getString(cursor.getColumnIndex("location"))); |
||||
|
record.setDirection(cursor.getString(cursor.getColumnIndex("direction"))); |
||||
|
record.setCreateTime(cursor.getString(cursor.getColumnIndex("create_time"))); |
||||
|
record.setUpdateTime(cursor.getString(cursor.getColumnIndex("update_time"))); |
||||
|
cursor.close(); |
||||
|
} |
||||
|
db.close(); |
||||
|
return record; |
||||
|
} |
||||
|
|
||||
|
private String getCurrentTime() { |
||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); |
||||
|
return sdf.format(new Date()); |
||||
|
} |
||||
|
} |
@ -0,0 +1,104 @@ |
|||||
|
package com.iflytop.profilometer.dao; |
||||
|
|
||||
|
import android.annotation.SuppressLint; |
||||
|
import android.content.ContentValues; |
||||
|
import android.content.Context; |
||||
|
import android.database.Cursor; |
||||
|
import android.database.sqlite.SQLiteDatabase; |
||||
|
|
||||
|
import com.iflytop.profilometer.core.db.helper.MyDatabaseHelper; |
||||
|
import com.iflytop.profilometer.model.entity.ProfileRecordPointSet; |
||||
|
|
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.Locale; |
||||
|
|
||||
|
public class ProfileRecordPointSetDao { |
||||
|
private final MyDatabaseHelper dbHelper; |
||||
|
|
||||
|
public ProfileRecordPointSetDao(Context context) { |
||||
|
dbHelper = new MyDatabaseHelper(context); |
||||
|
} |
||||
|
|
||||
|
// 插入测量点集记录 |
||||
|
public long insertProfileRecordPointSet(ProfileRecordPointSet pointSet) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
ContentValues values = new ContentValues(); |
||||
|
String currentTime = getCurrentTime(); |
||||
|
values.put("create_time", currentTime); |
||||
|
values.put("update_time", currentTime); |
||||
|
values.put("profile_record_uuid", pointSet.getProfileRecordUuid()); |
||||
|
values.put("points", pointSet.getPoints()); |
||||
|
long id = db.insert(MyDatabaseHelper.TABLE_PROFILE_RECORD_POINT_SET, null, values); |
||||
|
db.close(); |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
// 更新测量点集记录 |
||||
|
public int updateProfileRecordPointSet(ProfileRecordPointSet pointSet) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
ContentValues values = new ContentValues(); |
||||
|
values.put("update_time", getCurrentTime()); |
||||
|
values.put("profile_record_uuid", pointSet.getProfileRecordUuid()); |
||||
|
values.put("points", pointSet.getPoints()); |
||||
|
int rows = db.update(MyDatabaseHelper.TABLE_PROFILE_RECORD_POINT_SET, values, "id = ?", new String[]{String.valueOf(pointSet.getId())}); |
||||
|
db.close(); |
||||
|
return rows; |
||||
|
} |
||||
|
|
||||
|
// 删除测量点集记录 |
||||
|
public int deleteProfileRecordPointSet(long id) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
int rows = db.delete(MyDatabaseHelper.TABLE_PROFILE_RECORD_POINT_SET, "id = ?", new String[]{String.valueOf(id)}); |
||||
|
db.close(); |
||||
|
return rows; |
||||
|
} |
||||
|
|
||||
|
// 查询所有测量点集记录 |
||||
|
@SuppressLint("Range") |
||||
|
public List<ProfileRecordPointSet> getAllProfileRecordPointSets() { |
||||
|
List<ProfileRecordPointSet> list = new ArrayList<>(); |
||||
|
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
||||
|
Cursor cursor = db.query(MyDatabaseHelper.TABLE_PROFILE_RECORD_POINT_SET, null, null, null, null, null, "id DESC"); |
||||
|
if (cursor.moveToFirst()) { |
||||
|
do { |
||||
|
ProfileRecordPointSet pointSet = new ProfileRecordPointSet(); |
||||
|
pointSet.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
||||
|
pointSet.setProfileRecordUuid(cursor.getString(cursor.getColumnIndex("profile_record_uuid"))); |
||||
|
pointSet.setPoints(cursor.getString(cursor.getColumnIndex("points"))); |
||||
|
pointSet.setCreateTime(cursor.getString(cursor.getColumnIndex("create_time"))); |
||||
|
pointSet.setUpdateTime(cursor.getString(cursor.getColumnIndex("update_time"))); |
||||
|
list.add(pointSet); |
||||
|
} while (cursor.moveToNext()); |
||||
|
cursor.close(); |
||||
|
} |
||||
|
db.close(); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
// 根据 id 查询测量点集记录 |
||||
|
@SuppressLint("Range") |
||||
|
public ProfileRecordPointSet getProfileRecordPointSetById(long id) { |
||||
|
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
||||
|
Cursor cursor = db.query(MyDatabaseHelper.TABLE_PROFILE_RECORD_POINT_SET, null, "id = ?", new String[]{String.valueOf(id)}, null, null, null); |
||||
|
ProfileRecordPointSet pointSet = null; |
||||
|
if (cursor.moveToFirst()) { |
||||
|
pointSet = new ProfileRecordPointSet(); |
||||
|
pointSet.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
||||
|
pointSet.setProfileRecordUuid(cursor.getString(cursor.getColumnIndex("profile_record_uuid"))); |
||||
|
pointSet.setPoints(cursor.getString(cursor.getColumnIndex("points"))); |
||||
|
pointSet.setCreateTime(cursor.getString(cursor.getColumnIndex("create_time"))); |
||||
|
pointSet.setUpdateTime(cursor.getString(cursor.getColumnIndex("update_time"))); |
||||
|
cursor.close(); |
||||
|
} |
||||
|
db.close(); |
||||
|
return pointSet; |
||||
|
} |
||||
|
|
||||
|
private String getCurrentTime() { |
||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); |
||||
|
return sdf.format(new Date()); |
||||
|
} |
||||
|
} |
@ -0,0 +1,123 @@ |
|||||
|
package com.iflytop.profilometer.dao; |
||||
|
|
||||
|
import android.annotation.SuppressLint; |
||||
|
import android.content.ContentValues; |
||||
|
import android.content.Context; |
||||
|
import android.database.Cursor; |
||||
|
import android.database.sqlite.SQLiteDatabase; |
||||
|
|
||||
|
import com.iflytop.profilometer.core.db.helper.MyDatabaseHelper; |
||||
|
import com.iflytop.profilometer.model.entity.SystemConfig; |
||||
|
|
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.Locale; |
||||
|
|
||||
|
public class SystemConfigDao { |
||||
|
private final MyDatabaseHelper dbHelper; |
||||
|
|
||||
|
public SystemConfigDao(Context context) { |
||||
|
dbHelper = new MyDatabaseHelper(context); |
||||
|
} |
||||
|
|
||||
|
// 插入系统配置 |
||||
|
public long insertSystemConfig(SystemConfig config) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
ContentValues values = new ContentValues(); |
||||
|
String currentTime = getCurrentTime(); |
||||
|
values.put("create_time", currentTime); |
||||
|
values.put("update_time", currentTime); |
||||
|
values.put("config_key", config.getConfigKey()); |
||||
|
values.put("config_value", config.getConfigValue()); |
||||
|
long id = db.insert(MyDatabaseHelper.TABLE_SYSTEM_CONFIG, null, values); |
||||
|
db.close(); |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
// 更新系统配置 |
||||
|
public int updateSystemConfig(SystemConfig config) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
ContentValues values = new ContentValues(); |
||||
|
values.put("update_time", getCurrentTime()); |
||||
|
values.put("config_key", config.getConfigKey()); |
||||
|
values.put("config_value", config.getConfigValue()); |
||||
|
int rows = db.update(MyDatabaseHelper.TABLE_SYSTEM_CONFIG, values, "id = ?", new String[]{String.valueOf(config.getId())}); |
||||
|
db.close(); |
||||
|
return rows; |
||||
|
} |
||||
|
|
||||
|
// 删除系统配置 |
||||
|
public int deleteSystemConfig(long id) { |
||||
|
SQLiteDatabase db = dbHelper.getWritableDatabase(); |
||||
|
int rows = db.delete(MyDatabaseHelper.TABLE_SYSTEM_CONFIG, "id = ?", new String[]{String.valueOf(id)}); |
||||
|
db.close(); |
||||
|
return rows; |
||||
|
} |
||||
|
|
||||
|
// 查询所有系统配置 |
||||
|
@SuppressLint("Range") |
||||
|
public List<SystemConfig> getAllSystemConfigs() { |
||||
|
List<SystemConfig> list = new ArrayList<>(); |
||||
|
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
||||
|
Cursor cursor = db.query(MyDatabaseHelper.TABLE_SYSTEM_CONFIG, null, null, null, null, null, "id DESC"); |
||||
|
if (cursor.moveToFirst()) { |
||||
|
do { |
||||
|
SystemConfig config = new SystemConfig(); |
||||
|
config.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
||||
|
config.setConfigKey(cursor.getString(cursor.getColumnIndex("config_key"))); |
||||
|
config.setConfigValue(cursor.getString(cursor.getColumnIndex("config_value"))); |
||||
|
config.setCreateTime(cursor.getString(cursor.getColumnIndex("create_time"))); |
||||
|
config.setUpdateTime(cursor.getString(cursor.getColumnIndex("update_time"))); |
||||
|
list.add(config); |
||||
|
} while (cursor.moveToNext()); |
||||
|
cursor.close(); |
||||
|
} |
||||
|
db.close(); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
// 根据 id 查询系统配置 |
||||
|
@SuppressLint("Range") |
||||
|
public SystemConfig getSystemConfigById(long id) { |
||||
|
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
||||
|
Cursor cursor = db.query(MyDatabaseHelper.TABLE_SYSTEM_CONFIG, null, "id = ?", new String[]{String.valueOf(id)}, null, null, null); |
||||
|
SystemConfig config = null; |
||||
|
if (cursor.moveToFirst()) { |
||||
|
config = new SystemConfig(); |
||||
|
config.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
||||
|
config.setConfigKey(cursor.getString(cursor.getColumnIndex("config_key"))); |
||||
|
config.setConfigValue(cursor.getString(cursor.getColumnIndex("config_value"))); |
||||
|
config.setCreateTime(cursor.getString(cursor.getColumnIndex("create_time"))); |
||||
|
config.setUpdateTime(cursor.getString(cursor.getColumnIndex("update_time"))); |
||||
|
cursor.close(); |
||||
|
} |
||||
|
db.close(); |
||||
|
return config; |
||||
|
} |
||||
|
|
||||
|
//根据 key 查询系统配置 |
||||
|
@SuppressLint("Range") |
||||
|
public SystemConfig getSystemConfigByKey(String key) { |
||||
|
SQLiteDatabase db = dbHelper.getReadableDatabase(); |
||||
|
Cursor cursor = db.query(MyDatabaseHelper.TABLE_SYSTEM_CONFIG, null, "config_key = ?", new String[]{key}, null, null, null); |
||||
|
SystemConfig config = null; |
||||
|
if (cursor.moveToFirst()) { |
||||
|
config = new SystemConfig(); |
||||
|
config.setId(cursor.getLong(cursor.getColumnIndex("id"))); |
||||
|
config.setConfigKey(cursor.getString(cursor.getColumnIndex("config_key"))); |
||||
|
config.setConfigValue(cursor.getString(cursor.getColumnIndex("config_value"))); |
||||
|
config.setCreateTime(cursor.getString(cursor.getColumnIndex("create_time"))); |
||||
|
config.setUpdateTime(cursor.getString(cursor.getColumnIndex("update_time"))); |
||||
|
cursor.close(); |
||||
|
} |
||||
|
db.close(); |
||||
|
return config; |
||||
|
} |
||||
|
|
||||
|
private String getCurrentTime() { |
||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); |
||||
|
return sdf.format(new Date()); |
||||
|
} |
||||
|
} |
@ -1,9 +1,7 @@ |
|||||
package com.iflytop.profilometer.model.entiy; |
|
||||
|
package com.iflytop.profilometer.model.entity; |
||||
|
|
||||
import com.iflytop.profilometer.common.base.BaseEntity; |
import com.iflytop.profilometer.common.base.BaseEntity; |
||||
|
|
||||
import java.io.Serializable; |
|
||||
|
|
||||
public class AppUser extends BaseEntity { |
public class AppUser extends BaseEntity { |
||||
public enum UsrRole { |
public enum UsrRole { |
||||
User, Admin, Dev; |
User, Admin, Dev; |
@ -0,0 +1,42 @@ |
|||||
|
package com.iflytop.profilometer.model.entity; |
||||
|
|
||||
|
import com.iflytop.profilometer.common.base.BaseEntity; |
||||
|
|
||||
|
public class BaseProfileRecordPointSet extends BaseEntity { |
||||
|
private String name; |
||||
|
private String code; |
||||
|
private String points; |
||||
|
private String calPoints; |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public void setName(String name) { |
||||
|
this.name = name; |
||||
|
} |
||||
|
|
||||
|
public String getCode() { |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
public void setCode(String code) { |
||||
|
this.code = code; |
||||
|
} |
||||
|
|
||||
|
public String getPoints() { |
||||
|
return points; |
||||
|
} |
||||
|
|
||||
|
public void setPoints(String points) { |
||||
|
this.points = points; |
||||
|
} |
||||
|
|
||||
|
public String getCalPoints() { |
||||
|
return calPoints; |
||||
|
} |
||||
|
|
||||
|
public void setCalPoints(String calPoints) { |
||||
|
this.calPoints = calPoints; |
||||
|
} |
||||
|
} |
@ -1,4 +1,4 @@ |
|||||
package com.iflytop.profilometer.model.entiy; |
|
||||
|
package com.iflytop.profilometer.model.entity; |
||||
|
|
||||
import com.iflytop.profilometer.common.base.BaseEntity; |
import com.iflytop.profilometer.common.base.BaseEntity; |
||||
|
|
@ -0,0 +1,24 @@ |
|||||
|
package com.iflytop.profilometer.model.entity; |
||||
|
|
||||
|
import com.iflytop.profilometer.common.base.BaseEntity; |
||||
|
|
||||
|
public class ProfileRecordPointSet extends BaseEntity { |
||||
|
private String profileRecordUuid; |
||||
|
private String points; |
||||
|
|
||||
|
public String getProfileRecordUuid() { |
||||
|
return profileRecordUuid; |
||||
|
} |
||||
|
|
||||
|
public void setProfileRecordUuid(String profileRecordUuid) { |
||||
|
this.profileRecordUuid = profileRecordUuid; |
||||
|
} |
||||
|
|
||||
|
public String getPoints() { |
||||
|
return points; |
||||
|
} |
||||
|
|
||||
|
public void setPoints(String points) { |
||||
|
this.points = points; |
||||
|
} |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
package com.iflytop.profilometer.model.entity; |
||||
|
|
||||
|
import com.iflytop.profilometer.common.base.BaseEntity; |
||||
|
|
||||
|
public class SystemConfig extends BaseEntity { |
||||
|
private String configKey; // 配置项键 |
||||
|
private String configValue; // 配置项值 |
||||
|
|
||||
|
public String getConfigKey() { |
||||
|
return configKey; |
||||
|
} |
||||
|
public void setConfigKey(String configKey) { |
||||
|
this.configKey = configKey; |
||||
|
} |
||||
|
public String getConfigValue() { |
||||
|
return configValue; |
||||
|
} |
||||
|
public void setConfigValue(String configValue) { |
||||
|
this.configValue = configValue; |
||||
|
} |
||||
|
} |
@ -1,26 +0,0 @@ |
|||||
package com.iflytop.profilometer.model.entiy; |
|
||||
|
|
||||
import com.iflytop.profilometer.common.base.BaseEntity; |
|
||||
|
|
||||
public class DefaultBluetooth extends BaseEntity { |
|
||||
|
|
||||
private String bluetoothId; |
|
||||
private String bluetoothName; |
|
||||
|
|
||||
|
|
||||
public String getBluetoothId() { |
|
||||
return bluetoothId; |
|
||||
} |
|
||||
|
|
||||
public void setBluetoothId(String bluetoothId) { |
|
||||
this.bluetoothId = bluetoothId; |
|
||||
} |
|
||||
|
|
||||
public String getBluetoothName() { |
|
||||
return bluetoothName; |
|
||||
} |
|
||||
|
|
||||
public void setBluetoothName(String bluetoothName) { |
|
||||
this.bluetoothName = bluetoothName; |
|
||||
} |
|
||||
} |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue