调整数据模型,增加位置任务数据模型。
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Mon Sep 29 18:33:47 GMT 2025
|
#Mon Sep 29 19:30:19 GMT 2025
|
||||||
stageCount=3
|
stageCount=3
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.0
|
baseVersion=15.0
|
||||||
publishVersion=15.0.2
|
publishVersion=15.0.2
|
||||||
buildCount=15
|
buildCount=17
|
||||||
baseBetaVersion=15.0.3
|
baseBetaVersion=15.0.3
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ public class LocationActivity extends AppCompatActivity {
|
|||||||
double longitude = currentLocation.getLongitude();
|
double longitude = currentLocation.getLongitude();
|
||||||
double latitude = currentLocation.getLatitude();
|
double latitude = currentLocation.getLatitude();
|
||||||
PositionModel newPosition = new PositionModel(
|
PositionModel newPosition = new PositionModel(
|
||||||
|
PositionModel.genPositionId(),
|
||||||
longitude,
|
longitude,
|
||||||
latitude,
|
latitude,
|
||||||
inputRemark,
|
inputRemark,
|
||||||
|
|||||||
@@ -9,10 +9,13 @@ import android.util.JsonReader;
|
|||||||
import android.util.JsonWriter;
|
import android.util.JsonWriter;
|
||||||
import cc.winboll.studio.libappbase.BaseBean;
|
import cc.winboll.studio.libappbase.BaseBean;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PositionModel extends BaseBean {
|
public class PositionModel extends BaseBean {
|
||||||
|
|
||||||
public static final String TAG = "PositionModel";
|
public static final String TAG = "PositionModel";
|
||||||
|
// 位置标识符
|
||||||
|
String positionId;
|
||||||
// 经度
|
// 经度
|
||||||
double longitude;
|
double longitude;
|
||||||
// 纬度
|
// 纬度
|
||||||
@@ -24,7 +27,8 @@ public class PositionModel extends BaseBean {
|
|||||||
// 是否是简单视图
|
// 是否是简单视图
|
||||||
boolean isSimpleView = true;
|
boolean isSimpleView = true;
|
||||||
|
|
||||||
public PositionModel(double longitude, double latitude, String memo, boolean isEnableRealPositionDistance) {
|
public PositionModel(String positionId, double longitude, double latitude, String memo, boolean isEnableRealPositionDistance) {
|
||||||
|
this.positionId = positionId;
|
||||||
this.longitude = longitude;
|
this.longitude = longitude;
|
||||||
this.latitude = latitude;
|
this.latitude = latitude;
|
||||||
this.memo = memo;
|
this.memo = memo;
|
||||||
@@ -32,12 +36,21 @@ public class PositionModel extends BaseBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PositionModel() {
|
public PositionModel() {
|
||||||
|
this.positionId = "";
|
||||||
this.longitude = 0.0f;
|
this.longitude = 0.0f;
|
||||||
this.latitude = 0.0f;
|
this.latitude = 0.0f;
|
||||||
this.memo = "";
|
this.memo = "";
|
||||||
this.isEnableRealPositionDistance = false;
|
this.isEnableRealPositionDistance = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPositionId(String positionId) {
|
||||||
|
this.positionId = positionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositionId() {
|
||||||
|
return positionId;
|
||||||
|
}
|
||||||
|
|
||||||
public void setIsEnableRealPositionDistance(boolean isEnableRealPositionDistance) {
|
public void setIsEnableRealPositionDistance(boolean isEnableRealPositionDistance) {
|
||||||
this.isEnableRealPositionDistance = isEnableRealPositionDistance;
|
this.isEnableRealPositionDistance = isEnableRealPositionDistance;
|
||||||
}
|
}
|
||||||
@@ -82,10 +95,19 @@ public class PositionModel extends BaseBean {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return PositionModel.class.getName();
|
return PositionModel.class.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String genPositionId() {
|
||||||
|
// 生成唯一UUID(版本4,随机型)
|
||||||
|
UUID uniqueUuid = UUID.randomUUID();
|
||||||
|
// 转成字符串(标准格式,含横杠,共36位)
|
||||||
|
String uuidStr = uniqueUuid.toString();
|
||||||
|
return uuidStr;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||||
super.writeThisToJsonWriter(jsonWriter);
|
super.writeThisToJsonWriter(jsonWriter);
|
||||||
|
jsonWriter.name("positionId").value(getPositionId());
|
||||||
jsonWriter.name("longitude").value(getLongitude());
|
jsonWriter.name("longitude").value(getLongitude());
|
||||||
jsonWriter.name("latitude").value(getLatitude());
|
jsonWriter.name("latitude").value(getLatitude());
|
||||||
jsonWriter.name("memo").value(getMemo());
|
jsonWriter.name("memo").value(getMemo());
|
||||||
@@ -95,7 +117,9 @@ public class PositionModel extends BaseBean {
|
|||||||
@Override
|
@Override
|
||||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||||
if (name.equals("longitude")) {
|
if (name.equals("positionId")) {
|
||||||
|
setPositionId(jsonReader.nextString());
|
||||||
|
} else if (name.equals("longitude")) {
|
||||||
setLongitude(jsonReader.nextDouble());
|
setLongitude(jsonReader.nextDouble());
|
||||||
} else if (name.equals("latitude")) {
|
} else if (name.equals("latitude")) {
|
||||||
setLatitude(jsonReader.nextDouble());
|
setLatitude(jsonReader.nextDouble());
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
package cc.winboll.studio.positions.models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||||
|
* @Date 2025/09/30 02:48
|
||||||
|
* @Describe 位置任务数据模型
|
||||||
|
*/
|
||||||
|
import android.util.JsonReader;
|
||||||
|
import android.util.JsonWriter;
|
||||||
|
import cc.winboll.studio.libappbase.BaseBean;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class PositionTaskModel extends BaseBean {
|
||||||
|
|
||||||
|
public static final String TAG = "PositionTaskModel";
|
||||||
|
// 任务标识符
|
||||||
|
String taskId;
|
||||||
|
// 位置标识符
|
||||||
|
String positionId;
|
||||||
|
// 任务描述
|
||||||
|
String taskDescription;
|
||||||
|
// 任务距离条件是否大于
|
||||||
|
boolean isGreaterThan;
|
||||||
|
// 任务距离条件是否小于
|
||||||
|
boolean isLessThan;
|
||||||
|
// 任务条件商议距离
|
||||||
|
int discussDistance;
|
||||||
|
// 是否启用任务
|
||||||
|
boolean isEnable;
|
||||||
|
|
||||||
|
public PositionTaskModel(String taskId, String positionId, String taskDescription, boolean isGreaterThan, int discussDistance, boolean isEnable) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
this.positionId = positionId;
|
||||||
|
this.taskDescription = taskDescription;
|
||||||
|
this.isGreaterThan = isGreaterThan;
|
||||||
|
this.isLessThan = !this.isGreaterThan;
|
||||||
|
this.discussDistance = discussDistance;
|
||||||
|
this.isEnable = isEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PositionTaskModel() {
|
||||||
|
this.taskId = "";
|
||||||
|
this.positionId = "";
|
||||||
|
this.taskDescription = "";
|
||||||
|
this.isGreaterThan = true;
|
||||||
|
this.isLessThan = !this.isGreaterThan ;
|
||||||
|
this.discussDistance = 0;
|
||||||
|
this.isEnable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskId(String taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPositionId(String positionId) {
|
||||||
|
this.positionId = positionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPositionId() {
|
||||||
|
return positionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskDescription(String taskDescription) {
|
||||||
|
this.taskDescription = taskDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskDescription() {
|
||||||
|
return taskDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsGreaterThan(boolean isGreaterThan) {
|
||||||
|
this.isGreaterThan = isGreaterThan;
|
||||||
|
this.isLessThan = this.isGreaterThan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGreaterThan() {
|
||||||
|
return isGreaterThan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsLessThan(boolean isLessThan) {
|
||||||
|
this.isLessThan = isLessThan;
|
||||||
|
this.isGreaterThan = !this.isLessThan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLessThan() {
|
||||||
|
return isLessThan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscussDistance(int discussDistance) {
|
||||||
|
this.discussDistance = discussDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDiscussDistance() {
|
||||||
|
return discussDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsEnable(boolean isEnable) {
|
||||||
|
this.isEnable = isEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnable() {
|
||||||
|
return isEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return PositionTaskModel.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||||
|
super.writeThisToJsonWriter(jsonWriter);
|
||||||
|
jsonWriter.name("taskId").value(getTaskId());
|
||||||
|
jsonWriter.name("positionId").value(getPositionId());
|
||||||
|
jsonWriter.name("taskDescription").value(getTaskDescription());
|
||||||
|
jsonWriter.name("isGreaterThan").value(isGreaterThan());
|
||||||
|
jsonWriter.name("isLessThan").value(isLessThan());
|
||||||
|
jsonWriter.name("discussDistance").value(getDiscussDistance());
|
||||||
|
jsonWriter.name("isEnable").value(isEnable());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||||
|
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||||
|
if (name.equals("taskId")) {
|
||||||
|
setTaskId(jsonReader.nextString());
|
||||||
|
} else if (name.equals("positionId")) {
|
||||||
|
setPositionId(jsonReader.nextString());
|
||||||
|
} else if (name.equals("taskDescription")) {
|
||||||
|
setTaskDescription(jsonReader.nextString());
|
||||||
|
} else if (name.equals("isGreaterThan")) {
|
||||||
|
setIsGreaterThan(jsonReader.nextBoolean());
|
||||||
|
} else if (name.equals("isLessThan")) {
|
||||||
|
setIsLessThan(jsonReader.nextBoolean());
|
||||||
|
} else if (name.equals("discussDistance")) {
|
||||||
|
setDiscussDistance(jsonReader.nextInt());
|
||||||
|
} else if (name.equals("isEnable")) {
|
||||||
|
setIsEnable(jsonReader.nextBoolean());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||||
|
jsonReader.beginObject();
|
||||||
|
while (jsonReader.hasNext()) {
|
||||||
|
String name = jsonReader.nextName();
|
||||||
|
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||||
|
jsonReader.skipValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 结束 JSON 对象
|
||||||
|
jsonReader.endObject();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user