优化,一次可以测多组
This commit is contained in:
parent
9a769ae9cd
commit
50144a2290
File diff suppressed because it is too large
Load Diff
|
|
@ -10,11 +10,17 @@ import android.util.Log;
|
|||
|
||||
public class DBHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final String DB_NAME = "wrj.db"; // 数据库名称
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private static final String DB_NAME = "wrj.db";
|
||||
|
||||
private static final int version = 1; // 数据库版本
|
||||
/**
|
||||
* 数据库版本
|
||||
*/
|
||||
private static final int version = 1;
|
||||
|
||||
private final String[] CREATABLE = new String[]{MeasureDataDao.CREATE_TABLE};
|
||||
private final String[] CREATABLE = new String[]{MeasureDataDao.CREATE_TABLE, MeasurementDataDao.CREATE_TABLE};
|
||||
|
||||
public DBHelper(Context context) {
|
||||
super(context, DB_NAME, null, version);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,352 @@
|
|||
package com.bonus.wrjtest.db;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import com.bonus.wrjtest.entity.MeasurementDataBean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MeasurementDataDao {
|
||||
private static final String TAG = "MeasurementDataDao";
|
||||
|
||||
private DBHelper dbHelper;
|
||||
|
||||
public MeasurementDataDao(DBHelper dbHelper) {
|
||||
this.dbHelper = dbHelper;
|
||||
}
|
||||
|
||||
// 创建测量数据表的SQL语句
|
||||
public static final String CREATE_TABLE = "CREATE TABLE `bm_measurement_data` (" +
|
||||
"`id` INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
"`splitType` varchar(100)," +
|
||||
"`span` varchar(100)," +
|
||||
"`h` varchar(100)," +
|
||||
"`loopType` INTEGER," +
|
||||
"`wirePosition` INTEGER," +
|
||||
"`wirePositionName` varchar(100)," +
|
||||
"`rollAngle` varchar(100)," +
|
||||
"`pitchAngle` varchar(100)," +
|
||||
"`yawAngle` varchar(100)," +
|
||||
"`radarLongitude` varchar(100)," +
|
||||
"`radarLatitude` varchar(100)," +
|
||||
"`radarElevation` varchar(100)," +
|
||||
"`wire1Data` varchar(100)," +
|
||||
"`wire2Data` varchar(100)," +
|
||||
"`wire3Data` varchar(100)," +
|
||||
"`wire4Data` varchar(100)," +
|
||||
"`sagValue` varchar(100)," +
|
||||
"`time` varchar(100)" +
|
||||
")";
|
||||
|
||||
/**
|
||||
* 新增或更新测量数据
|
||||
*
|
||||
* @param measurementData 测量数据对象
|
||||
* @return 是否成功
|
||||
*/
|
||||
public boolean insertData(MeasurementDataBean measurementData) {
|
||||
String sql = "INSERT OR REPLACE INTO `bm_measurement_data` (" +
|
||||
"`splitType`,`span`,`h`,`loopType`, `wirePosition`, `wirePositionName`, `rollAngle`, `pitchAngle`, `yawAngle`, " +
|
||||
"`radarLongitude`, `radarLatitude`, `radarElevation`, `wire1Data`, `wire2Data`, `wire3Data`, " +
|
||||
"`wire4Data`, `sagValue`, `time`) " +
|
||||
"VALUES (?, ?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
try {
|
||||
this.dbHelper.execSQL(sql, new Object[]{
|
||||
measurementData.getSplitType(),
|
||||
measurementData.getSpan(),
|
||||
measurementData.getH(),
|
||||
measurementData.getLoopType(),
|
||||
measurementData.getWirePosition(),
|
||||
measurementData.getWirePositionName(),
|
||||
measurementData.getRollAngle(),
|
||||
measurementData.getPitchAngle(),
|
||||
measurementData.getYawAngle(),
|
||||
measurementData.getRadarLongitude(),
|
||||
measurementData.getRadarLatitude(),
|
||||
measurementData.getRadarElevation(),
|
||||
measurementData.getWire1Data(),
|
||||
measurementData.getWire2Data(),
|
||||
measurementData.getWire3Data(),
|
||||
measurementData.getWire4Data(),
|
||||
measurementData.getSagValue(),
|
||||
measurementData.getTime()
|
||||
});
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Insert failed: " + e.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有测量数据
|
||||
*
|
||||
* @return 测量数据列表
|
||||
*/
|
||||
public List<MeasurementDataBean> selectAll() {
|
||||
String sql = "SELECT * FROM bm_measurement_data";
|
||||
Cursor cr = null;
|
||||
List<MeasurementDataBean> dataList = new ArrayList<>();
|
||||
try {
|
||||
cr = this.dbHelper.query(sql, new String[]{});
|
||||
while (cr.moveToNext()) {
|
||||
MeasurementDataBean data = new MeasurementDataBean();
|
||||
data.setId(cr.getInt(cr.getColumnIndex("id")));
|
||||
data.setSplitType(cr.getString(cr.getColumnIndex("splitType")));
|
||||
data.setSpan(Double.parseDouble(cr.getString(cr.getColumnIndex("span"))));
|
||||
data.setH(Double.parseDouble(cr.getString(cr.getColumnIndex("h"))));
|
||||
data.setLoopType(cr.getInt(cr.getColumnIndex("loopType")));
|
||||
data.setWirePosition(cr.getInt(cr.getColumnIndex("wirePosition")));
|
||||
data.setWirePositionName(cr.getString(cr.getColumnIndex("wirePositionName")));
|
||||
data.setRollAngle(Double.parseDouble(cr.getString(cr.getColumnIndex("rollAngle"))));
|
||||
data.setPitchAngle(Double.parseDouble(cr.getString(cr.getColumnIndex("pitchAngle"))));
|
||||
data.setYawAngle(Double.parseDouble(cr.getString(cr.getColumnIndex("yawAngle"))));
|
||||
data.setRadarLongitude(Double.parseDouble(cr.getString(cr.getColumnIndex("radarLongitude"))));
|
||||
data.setRadarLatitude(Double.parseDouble(cr.getString(cr.getColumnIndex("radarLatitude"))));
|
||||
data.setRadarElevation(Double.parseDouble(cr.getString(cr.getColumnIndex("radarElevation"))));
|
||||
data.setWire1Data(cr.getString(cr.getColumnIndex("wire1Data")));
|
||||
data.setWire2Data(cr.getString(cr.getColumnIndex("wire2Data")));
|
||||
data.setWire3Data(cr.getString(cr.getColumnIndex("wire3Data")));
|
||||
data.setWire4Data(cr.getString(cr.getColumnIndex("wire4Data")));
|
||||
data.setSagValue(cr.getString(cr.getColumnIndex("sagValue")));
|
||||
data.setTime(cr.getString(cr.getColumnIndex("time")));
|
||||
dataList.add(data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Select all failed: " + e.toString());
|
||||
} finally {
|
||||
if (cr != null) {
|
||||
cr.close();
|
||||
}
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询单条记录
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 测量数据对象
|
||||
*/
|
||||
public MeasurementDataBean selectById(int id) {
|
||||
String sql = "SELECT * FROM bm_measurement_data WHERE id = ?";
|
||||
Cursor cr = null;
|
||||
MeasurementDataBean data = null;
|
||||
try {
|
||||
cr = this.dbHelper.query(sql, new String[]{String.valueOf(id)});
|
||||
if (cr.moveToFirst()) {
|
||||
data = new MeasurementDataBean();
|
||||
data.setId(cr.getInt(cr.getColumnIndex("id")));
|
||||
data.setSplitType(cr.getString(cr.getColumnIndex("splitType")));
|
||||
data.setSpan(Double.parseDouble(cr.getString(cr.getColumnIndex("span"))));
|
||||
data.setH(Double.parseDouble(cr.getString(cr.getColumnIndex("h"))));
|
||||
data.setLoopType(cr.getInt(cr.getColumnIndex("loopType")));
|
||||
data.setWirePosition(cr.getInt(cr.getColumnIndex("wirePosition")));
|
||||
data.setWirePositionName(cr.getString(cr.getColumnIndex("wirePositionName")));
|
||||
data.setRollAngle(Double.parseDouble(cr.getString(cr.getColumnIndex("rollAngle"))));
|
||||
data.setPitchAngle(Double.parseDouble(cr.getString(cr.getColumnIndex("pitchAngle"))));
|
||||
data.setYawAngle(Double.parseDouble(cr.getString(cr.getColumnIndex("yawAngle"))));
|
||||
data.setRadarLongitude(Double.parseDouble(cr.getString(cr.getColumnIndex("radarLongitude"))));
|
||||
data.setRadarLatitude(Double.parseDouble(cr.getString(cr.getColumnIndex("radarLatitude"))));
|
||||
data.setRadarElevation(Double.parseDouble(cr.getString(cr.getColumnIndex("radarElevation"))));
|
||||
data.setWire1Data(cr.getString(cr.getColumnIndex("wire1Data")));
|
||||
data.setWire2Data(cr.getString(cr.getColumnIndex("wire2Data")));
|
||||
data.setWire3Data(cr.getString(cr.getColumnIndex("wire3Data")));
|
||||
data.setWire4Data(cr.getString(cr.getColumnIndex("wire4Data")));
|
||||
data.setSagValue(cr.getString(cr.getColumnIndex("sagValue")));
|
||||
data.setTime(cr.getString(cr.getColumnIndex("time")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Select by ID failed: " + e.toString());
|
||||
} finally {
|
||||
if (cr != null) {
|
||||
cr.close();
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据导线位置(wirePosition)分组,统计每组数据条数
|
||||
*
|
||||
* @return Map<wirePosition, count> 导线位置与对应数据条数的映射
|
||||
*/
|
||||
public List<MeasurementDataBean> getWirePositionCount() {
|
||||
String sql = "SELECT wirePosition, COUNT(*) AS num FROM bm_measurement_data GROUP BY wirePosition";
|
||||
Cursor cr = null;
|
||||
List<MeasurementDataBean> dataList = new ArrayList<>();
|
||||
try {
|
||||
cr = this.dbHelper.query(sql, new String[]{});
|
||||
while (cr.moveToNext()) {
|
||||
MeasurementDataBean data = new MeasurementDataBean();
|
||||
data.setWirePosition(cr.getInt(cr.getColumnIndex("wirePosition")));
|
||||
data.setNum(cr.getInt(cr.getColumnIndex("num")));
|
||||
dataList.add(data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Get wire position count failed: " + e.toString());
|
||||
} finally {
|
||||
if (cr != null) {
|
||||
cr.close();
|
||||
}
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 wirePosition 查询数据,并按时间正序排序
|
||||
*
|
||||
* @param wirePosition 导线位置
|
||||
* @return 满足条件的数据列表
|
||||
*/
|
||||
public List<MeasurementDataBean> getDataByWirePosition(int wirePosition) {
|
||||
String sql = "SELECT * FROM bm_measurement_data WHERE wirePosition = ? ORDER BY time ASC";
|
||||
Cursor cr = null;
|
||||
List<MeasurementDataBean> dataList = new ArrayList<>();
|
||||
try {
|
||||
cr = this.dbHelper.query(sql, new String[]{String.valueOf(wirePosition)});
|
||||
while (cr.moveToNext()) {
|
||||
MeasurementDataBean data = new MeasurementDataBean();
|
||||
data.setSplitType(cr.getString(cr.getColumnIndex("splitType")));
|
||||
data.setSpan(Double.parseDouble(cr.getString(cr.getColumnIndex("span"))));
|
||||
data.setH(Double.parseDouble(cr.getString(cr.getColumnIndex("h"))));
|
||||
data.setLoopType(cr.getInt(cr.getColumnIndex("loopType")));
|
||||
data.setWirePosition(cr.getInt(cr.getColumnIndex("wirePosition")));
|
||||
data.setWirePositionName(cr.getString(cr.getColumnIndex("wirePositionName")));
|
||||
data.setRollAngle(Double.parseDouble(cr.getString(cr.getColumnIndex("rollAngle"))));
|
||||
data.setPitchAngle(Double.parseDouble(cr.getString(cr.getColumnIndex("pitchAngle"))));
|
||||
data.setYawAngle(Double.parseDouble(cr.getString(cr.getColumnIndex("yawAngle"))));
|
||||
data.setRadarLongitude(Double.parseDouble(cr.getString(cr.getColumnIndex("radarLongitude"))));
|
||||
data.setRadarLatitude(Double.parseDouble(cr.getString(cr.getColumnIndex("radarLatitude"))));
|
||||
data.setRadarElevation(Double.parseDouble(cr.getString(cr.getColumnIndex("radarElevation"))));
|
||||
data.setWire1Data(cr.getString(cr.getColumnIndex("wire1Data")));
|
||||
data.setWire2Data(cr.getString(cr.getColumnIndex("wire2Data")));
|
||||
data.setWire3Data(cr.getString(cr.getColumnIndex("wire3Data")));
|
||||
data.setWire4Data(cr.getString(cr.getColumnIndex("wire4Data")));
|
||||
data.setSagValue(cr.getString(cr.getColumnIndex("sagValue")));
|
||||
data.setTime(cr.getString(cr.getColumnIndex("time")));
|
||||
// 根据实际字段补充其他 setter 方法
|
||||
dataList.add(data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Get data by wire position failed: " + e.toString());
|
||||
} finally {
|
||||
if (cr != null) {
|
||||
cr.close();
|
||||
}
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 wirePosition 分组,查询 wirePositionName 和 sagValue 的值,
|
||||
* 并且保证 sagValue 的值不为空字符串或 null
|
||||
*
|
||||
* @return 查询结果列表
|
||||
*/
|
||||
public List<MeasurementDataBean> getWirePositionWithSagValue() {
|
||||
String sql = "SELECT wirePosition, wirePositionName, sagValue " +
|
||||
"FROM bm_measurement_data " +
|
||||
"WHERE sagValue IS NOT NULL AND sagValue != '' " +
|
||||
"GROUP BY wirePosition";
|
||||
Cursor cursor = null;
|
||||
List<MeasurementDataBean> dataList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
cursor = dbHelper.query(sql, new String[]{});
|
||||
while (cursor.moveToNext()) {
|
||||
MeasurementDataBean data = new MeasurementDataBean();
|
||||
data.setWirePosition(cursor.getInt(cursor.getColumnIndex("wirePosition")));
|
||||
data.setWirePositionName(cursor.getString(cursor.getColumnIndex("wirePositionName")));
|
||||
data.setSagValue(cursor.getString(cursor.getColumnIndex("sagValue")));
|
||||
dataList.add(data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("MeasurementDataDao", "Get wire position with sag value failed: " + e.toString());
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
return dataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照时间降序查询最后一条的雷达经纬度和高度
|
||||
*
|
||||
* @return 雷达数据对象(包含经度、纬度和高度),如果没有数据则返回 null
|
||||
*/
|
||||
public MeasurementDataBean getLastRadarData() {
|
||||
String sql = "SELECT radarLongitude, radarLatitude, radarElevation " +
|
||||
"FROM bm_measurement_data " +
|
||||
"ORDER BY time DESC " +
|
||||
"LIMIT 1";
|
||||
Cursor cursor = null;
|
||||
MeasurementDataBean radarData = new MeasurementDataBean();
|
||||
|
||||
try {
|
||||
cursor = dbHelper.query(sql, new String[]{});
|
||||
if (cursor.moveToFirst()) {
|
||||
radarData = new MeasurementDataBean();
|
||||
radarData.setRadarLongitude(cursor.getDouble(cursor.getColumnIndex("radarLongitude")));
|
||||
radarData.setRadarLatitude(cursor.getDouble(cursor.getColumnIndex("radarLatitude")));
|
||||
radarData.setRadarElevation(cursor.getDouble(cursor.getColumnIndex("radarElevation")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("RadarDataDao", "Get last radar data failed: " + e.toString());
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
return radarData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 wirePosition 修改所有满足条件的数据的 sagValue 值
|
||||
*
|
||||
* @param wirePosition 导线位置
|
||||
* @param sagValue 新的 sagValue 值
|
||||
* @return 受影响的行数
|
||||
*/
|
||||
public void updateSagValueByWirePosition(int wirePosition, String sagValue) {
|
||||
String sql = "UPDATE bm_measurement_data SET sagValue = ? WHERE wirePosition = ?";
|
||||
try {
|
||||
this.dbHelper.execSQL(sql, new Object[]{sagValue, wirePosition});
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Update sag value by wire position failed: " + e.toString());
|
||||
// 返回受影响行数为 0 表示失败
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空测量数据表
|
||||
*/
|
||||
public void clearTable() {
|
||||
String sql = "DELETE FROM bm_measurement_data";
|
||||
try {
|
||||
this.dbHelper.execSQL(sql, new Object[]{});
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Clear table failed: " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定ID的记录
|
||||
*
|
||||
* @param id 主键ID
|
||||
*/
|
||||
public void deleteById(int id) {
|
||||
String sql = "DELETE FROM bm_measurement_data WHERE id = ?";
|
||||
try {
|
||||
this.dbHelper.execSQL(sql, new Object[]{id});
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Delete by ID failed: " + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
package com.bonus.wrjtest.entity;
|
||||
|
||||
public class MeasurementDataBean {
|
||||
|
||||
/**
|
||||
* 主键ID,自增
|
||||
*/
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 分裂类型
|
||||
*/
|
||||
private String splitType;
|
||||
|
||||
/**
|
||||
* 档距
|
||||
*/
|
||||
private double span;
|
||||
|
||||
/**
|
||||
* 高差
|
||||
*/
|
||||
private double h;
|
||||
|
||||
/**
|
||||
* 回路类型(1表示单回路,2表示双回路)
|
||||
*/
|
||||
private int loopType;
|
||||
|
||||
/**
|
||||
* 导线位置编号(如1-左地线/光缆,2-右地线/光缆等)
|
||||
*/
|
||||
private int wirePosition;
|
||||
|
||||
/**
|
||||
* 导线位置描述(如"左地线/光缆","右相"等)
|
||||
*/
|
||||
private String wirePositionName;
|
||||
|
||||
/**
|
||||
* 横滚角(单位:度)
|
||||
*/
|
||||
private double rollAngle;
|
||||
|
||||
/**
|
||||
* 俯仰角(单位:度)
|
||||
*/
|
||||
private double pitchAngle;
|
||||
|
||||
/**
|
||||
* 方位角(单位:度)
|
||||
*/
|
||||
private double yawAngle;
|
||||
|
||||
/**
|
||||
* 雷达点经度(单位:度)
|
||||
*/
|
||||
private double radarLongitude;
|
||||
|
||||
/**
|
||||
* 雷达点纬度(单位:度)
|
||||
*/
|
||||
private double radarLatitude;
|
||||
|
||||
/**
|
||||
* 雷达点高程(单位:米)
|
||||
*/
|
||||
private double radarElevation;
|
||||
|
||||
/**
|
||||
* 1号线经纬度高程
|
||||
*/
|
||||
private String wire1Data;
|
||||
|
||||
|
||||
/**
|
||||
* 2号线经纬度高程
|
||||
*/
|
||||
private String wire2Data;
|
||||
|
||||
/**
|
||||
* 3号线经纬度高程
|
||||
*/
|
||||
private String wire3Data;
|
||||
|
||||
/**
|
||||
* 4号线经纬度高程
|
||||
*/
|
||||
private String wire4Data;
|
||||
|
||||
|
||||
/**
|
||||
* 弧垂值(单位:米)
|
||||
*/
|
||||
private String sagValue;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private String time;
|
||||
|
||||
private int num;
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getLoopType() {
|
||||
return loopType;
|
||||
}
|
||||
|
||||
public void setLoopType(int loopType) {
|
||||
this.loopType = loopType;
|
||||
}
|
||||
|
||||
public int getWirePosition() {
|
||||
return wirePosition;
|
||||
}
|
||||
|
||||
public void setWirePosition(int wirePosition) {
|
||||
this.wirePosition = wirePosition;
|
||||
}
|
||||
|
||||
public String getWirePositionName() {
|
||||
return wirePositionName;
|
||||
}
|
||||
|
||||
public void setWirePositionName(String wirePositionName) {
|
||||
this.wirePositionName = wirePositionName;
|
||||
}
|
||||
|
||||
public double getRollAngle() {
|
||||
return rollAngle;
|
||||
}
|
||||
|
||||
public void setRollAngle(double rollAngle) {
|
||||
this.rollAngle = rollAngle;
|
||||
}
|
||||
|
||||
public double getPitchAngle() {
|
||||
return pitchAngle;
|
||||
}
|
||||
|
||||
public void setPitchAngle(double pitchAngle) {
|
||||
this.pitchAngle = pitchAngle;
|
||||
}
|
||||
|
||||
public double getYawAngle() {
|
||||
return yawAngle;
|
||||
}
|
||||
|
||||
public void setYawAngle(double yawAngle) {
|
||||
this.yawAngle = yawAngle;
|
||||
}
|
||||
|
||||
public double getRadarLongitude() {
|
||||
return radarLongitude;
|
||||
}
|
||||
|
||||
public void setRadarLongitude(double radarLongitude) {
|
||||
this.radarLongitude = radarLongitude;
|
||||
}
|
||||
|
||||
public double getRadarLatitude() {
|
||||
return radarLatitude;
|
||||
}
|
||||
|
||||
public void setRadarLatitude(double radarLatitude) {
|
||||
this.radarLatitude = radarLatitude;
|
||||
}
|
||||
|
||||
public double getRadarElevation() {
|
||||
return radarElevation;
|
||||
}
|
||||
|
||||
public void setRadarElevation(double radarElevation) {
|
||||
this.radarElevation = radarElevation;
|
||||
}
|
||||
|
||||
public String getWire1Data() {
|
||||
return wire1Data;
|
||||
}
|
||||
|
||||
public void setWire1Data(String wire1Data) {
|
||||
this.wire1Data = wire1Data;
|
||||
}
|
||||
|
||||
public String getWire2Data() {
|
||||
return wire2Data;
|
||||
}
|
||||
|
||||
public void setWire2Data(String wire2Data) {
|
||||
this.wire2Data = wire2Data;
|
||||
}
|
||||
|
||||
public String getWire3Data() {
|
||||
return wire3Data;
|
||||
}
|
||||
|
||||
public void setWire3Data(String wire3Data) {
|
||||
this.wire3Data = wire3Data;
|
||||
}
|
||||
|
||||
public String getWire4Data() {
|
||||
return wire4Data;
|
||||
}
|
||||
|
||||
public void setWire4Data(String wire4Data) {
|
||||
this.wire4Data = wire4Data;
|
||||
}
|
||||
|
||||
public String getSagValue() {
|
||||
return sagValue;
|
||||
}
|
||||
|
||||
public void setSagValue(String sagValue) {
|
||||
this.sagValue = sagValue;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getSplitType() {
|
||||
return splitType;
|
||||
}
|
||||
|
||||
public void setSplitType(String splitType) {
|
||||
this.splitType = splitType;
|
||||
}
|
||||
|
||||
public double getSpan() {
|
||||
return span;
|
||||
}
|
||||
|
||||
public void setSpan(double span) {
|
||||
this.span = span;
|
||||
}
|
||||
|
||||
public double getH() {
|
||||
return h;
|
||||
}
|
||||
|
||||
public void setH(double h) {
|
||||
this.h = h;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
package com.bonus.wrjtest.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class StringHelper {
|
||||
|
||||
public static boolean isEmpty(String str) {
|
||||
if (str == null || str.trim().equals("") || str.trim().equals("null")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 判断字符串 不为空
|
||||
*/
|
||||
public static boolean isEmptyAndOrder(String str) {
|
||||
if (str == null || str.trim().equals("") || str.trim().equals("null") || str.trim().equals("-.--")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEmptyAndNull(String str) {
|
||||
if (str == null || str.trim().equals("") || str.trim().equals("null")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String fillPrefixZero(int v, int len) {
|
||||
String vStr = v + "";
|
||||
while (vStr.length() < len) {
|
||||
vStr = "0" + vStr;
|
||||
}
|
||||
return vStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取32位uuid
|
||||
* @return
|
||||
*/
|
||||
public static String getUUID() {
|
||||
String uuid = UUID.randomUUID().toString(); //转化为String对象
|
||||
uuid = uuid.replace("-", "");
|
||||
return uuid;
|
||||
}
|
||||
private static final char[] hexCode = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
/**
|
||||
* md5加密
|
||||
* @param input
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static String md5(String input){
|
||||
try {
|
||||
byte[] bytes = MessageDigest.getInstance("MD5").digest(input.getBytes());
|
||||
return printHexBinary(bytes);
|
||||
}catch (NoSuchAlgorithmException e){
|
||||
Log.e("StringHelper",e.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String printHexBinary(byte[] data) {
|
||||
StringBuilder r = new StringBuilder(data.length * 2);
|
||||
for (byte b : data) {
|
||||
r.append(hexCode[(b >> 4) & 0xF]);
|
||||
r.append(hexCode[(b & 0xF)]);
|
||||
}
|
||||
return r.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* String 转数字
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static int strToInt(String str) {
|
||||
if(isEmptyAndNull(str)){
|
||||
return 0;
|
||||
}else if("/".equals(str) || "\\".equals(str)){
|
||||
return 0;
|
||||
}else{
|
||||
return Integer.parseInt(str);
|
||||
}
|
||||
}
|
||||
public static double strToDouble(String str) {
|
||||
if(isEmptyAndNull(str)){
|
||||
return 0.0;
|
||||
}else if("/".equals(str) || "\\".equals(str)){
|
||||
return 0.0;
|
||||
}else{
|
||||
double parseDouble;
|
||||
try{
|
||||
parseDouble = Double.parseDouble(str);
|
||||
return parseDouble;
|
||||
}catch (Exception e){
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回double型 保留两位
|
||||
*/
|
||||
public static Double roundDouble(double d) {
|
||||
d = (double) Math.round(d * 100) / 100;
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回double型 保留两位
|
||||
*/
|
||||
public static int roundInt(double d) {
|
||||
int i = Integer.parseInt(new java.text.DecimalFormat("0").format(d));
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param d 数据
|
||||
* @param i 1 四舍五入 2 五舍六入 3 直接舍去
|
||||
* @return
|
||||
*/
|
||||
public static Double roundDouble(double d,int i) {
|
||||
BigDecimal b = new BigDecimal(d);
|
||||
if(i == 1){
|
||||
d = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}else if(i == 2){
|
||||
d = b.setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue();
|
||||
}else if(i == 3){
|
||||
d = b.setScale(2, BigDecimal.ROUND_UP).doubleValue();
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保留有效数字
|
||||
*
|
||||
* @param f
|
||||
* @param size 保留几位
|
||||
* @return
|
||||
*/
|
||||
public static Double keepDouble(Double f, int size) {
|
||||
/*1.先判断当前数据是否为0*/
|
||||
int zeroRe = 0;
|
||||
if (f == 0.0) {
|
||||
zeroRe = 1;
|
||||
}
|
||||
switch (zeroRe) {
|
||||
case 1: /*数据为0,直接将数据保留小数点后一位*/
|
||||
return new BigDecimal(f).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
default: /*数据不为0,将数据保留至有效位数*/
|
||||
return new BigDecimal(f).setScale(size, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#FFFFFF" /> <!-- 白色背景 -->
|
||||
<corners android:radius="4dp" /> <!-- 圆角 -->
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#BDBDBD" /> <!-- 边框颜色 -->
|
||||
|
||||
<!-- 添加一点内边距 -->
|
||||
<padding
|
||||
android:left="4dp"
|
||||
android:top="4dp"
|
||||
android:right="4dp"
|
||||
android:bottom="4dp" />
|
||||
</shape>
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue