diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index ac9f1bf..aa9fa10 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -135,7 +135,7 @@ // }, true); //TODO 暂时先用默认点代替定位点 - Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4490)); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); addPictureMarker(point); mapView.setViewpointCenterAsync(point, 2800);//标注到指定经纬度并放大地图显示 @@ -465,7 +465,7 @@ double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); addPictureMarker(point); - mapView.setViewpointCenterAsync((point), 2800); + mapView.setViewpointCenterAsync(point, 2800); OtherUtils.dismissLoadingDialog(); } } diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index ac9f1bf..aa9fa10 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -135,7 +135,7 @@ // }, true); //TODO 暂时先用默认点代替定位点 - Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4490)); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); addPictureMarker(point); mapView.setViewpointCenterAsync(point, 2800);//标注到指定经纬度并放大地图显示 @@ -465,7 +465,7 @@ double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); addPictureMarker(point); - mapView.setViewpointCenterAsync((point), 2800); + mapView.setViewpointCenterAsync(point, 2800); OtherUtils.dismissLoadingDialog(); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java index 902e0af..0a7cb19 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java @@ -184,7 +184,7 @@ @Override public void obtainDataFail() { - ToastHelper.showToast("获取用户信息超时", ToastHelper.ERROR); + ToastHelper.showToast("获取用户信息失败,请重试", ToastHelper.ERROR); } @Override diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index ac9f1bf..aa9fa10 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -135,7 +135,7 @@ // }, true); //TODO 暂时先用默认点代替定位点 - Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4490)); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); addPictureMarker(point); mapView.setViewpointCenterAsync(point, 2800);//标注到指定经纬度并放大地图显示 @@ -465,7 +465,7 @@ double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); addPictureMarker(point); - mapView.setViewpointCenterAsync((point), 2800); + mapView.setViewpointCenterAsync(point, 2800); OtherUtils.dismissLoadingDialog(); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java index 902e0af..0a7cb19 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java @@ -184,7 +184,7 @@ @Override public void obtainDataFail() { - ToastHelper.showToast("获取用户信息超时", ToastHelper.ERROR); + ToastHelper.showToast("获取用户信息失败,请重试", ToastHelper.ERROR); } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java index b1f2ebb..3b8dfd2 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java @@ -53,8 +53,6 @@ private boolean isRefresh, isLoadMore = false; private static WeakReferenceHandler weakReferenceHandler; private LightControlPresenterImpl controlPresenter; - private long lampId; - private int adapterPosition; @Override protected int initLayoutView() { @@ -92,7 +90,7 @@ public void onLoadMore(@NonNull final RefreshLayout refreshLayout) { isLoadMore = true; pageIndex++; - lightListPresenter.onReadyRetrofitRequest(Constant.PAGE_LIMIT, pageIndex); + lightListPresenter.onReadyRetrofitRequest(2 * Constant.PAGE_LIMIT, pageIndex); } }); } @@ -162,11 +160,9 @@ @Override public void onClick(int position) { LightListBean.DataBean.RowsBean rowsBean = fragment.dataBeans.get(position); - fragment.lampId = Long.parseLong(rowsBean.getLampId()); - fragment.adapterPosition = position; List lampIds = new ArrayList<>(); - lampIds.add(fragment.lampId); + lampIds.add(Long.parseLong(rowsBean.getLampId())); String statusName = rowsBean.getStatusName(); String controlType; @@ -202,7 +198,7 @@ public void obtainControlResult(ActionResultBean resultBean) { if (resultBean.isSuccess()) { //开灯指令发下去之后,虽然返回成功,但仅仅表示app发送指令到后台成功,但是开没开灯无法确定,所以,只能延迟几秒再刷新列表 - Log.d(TAG, "APP发送指令到后台成功,3s后即将刷新列表"); + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); weakReferenceHandler.sendEmptyMessageDelayed(20210624, 3000); } } diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index ac9f1bf..aa9fa10 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -135,7 +135,7 @@ // }, true); //TODO 暂时先用默认点代替定位点 - Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4490)); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); addPictureMarker(point); mapView.setViewpointCenterAsync(point, 2800);//标注到指定经纬度并放大地图显示 @@ -465,7 +465,7 @@ double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); addPictureMarker(point); - mapView.setViewpointCenterAsync((point), 2800); + mapView.setViewpointCenterAsync(point, 2800); OtherUtils.dismissLoadingDialog(); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java index 902e0af..0a7cb19 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java @@ -184,7 +184,7 @@ @Override public void obtainDataFail() { - ToastHelper.showToast("获取用户信息超时", ToastHelper.ERROR); + ToastHelper.showToast("获取用户信息失败,请重试", ToastHelper.ERROR); } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java index b1f2ebb..3b8dfd2 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java @@ -53,8 +53,6 @@ private boolean isRefresh, isLoadMore = false; private static WeakReferenceHandler weakReferenceHandler; private LightControlPresenterImpl controlPresenter; - private long lampId; - private int adapterPosition; @Override protected int initLayoutView() { @@ -92,7 +90,7 @@ public void onLoadMore(@NonNull final RefreshLayout refreshLayout) { isLoadMore = true; pageIndex++; - lightListPresenter.onReadyRetrofitRequest(Constant.PAGE_LIMIT, pageIndex); + lightListPresenter.onReadyRetrofitRequest(2 * Constant.PAGE_LIMIT, pageIndex); } }); } @@ -162,11 +160,9 @@ @Override public void onClick(int position) { LightListBean.DataBean.RowsBean rowsBean = fragment.dataBeans.get(position); - fragment.lampId = Long.parseLong(rowsBean.getLampId()); - fragment.adapterPosition = position; List lampIds = new ArrayList<>(); - lampIds.add(fragment.lampId); + lampIds.add(Long.parseLong(rowsBean.getLampId())); String statusName = rowsBean.getStatusName(); String controlType; @@ -202,7 +198,7 @@ public void obtainControlResult(ActionResultBean resultBean) { if (resultBean.isSuccess()) { //开灯指令发下去之后,虽然返回成功,但仅仅表示app发送指令到后台成功,但是开没开灯无法确定,所以,只能延迟几秒再刷新列表 - Log.d(TAG, "APP发送指令到后台成功,3s后即将刷新列表"); + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); weakReferenceHandler.sendEmptyMessageDelayed(20210624, 3000); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java index 5494f1b..a7bee54 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java @@ -1,9 +1,88 @@ package com.casic.dcms.ui.fragment; -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.location.Location; +import android.os.Handler; +import android.os.Message; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; -public class LightOnMapFragment extends BaseFragment { +import androidx.annotation.NonNull; + +import com.amap.api.location.AMapLocation; +import com.casic.dcms.R; +import com.casic.dcms.base.BaseApplication; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.bean.StreetLightLocalBean; +import com.casic.dcms.greendao.DaoSession; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; +import com.casic.dcms.mvp.presenter.LightControlPresenterImpl; +import com.casic.dcms.mvp.presenter.LightMapPresenterImpl; +import com.casic.dcms.mvp.view.ILightControlView; +import com.casic.dcms.mvp.view.ILightMapView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.HttpRequestHelper; +import com.casic.dcms.utils.LocationHelper; +import com.casic.dcms.utils.OtherUtils; +import com.casic.dcms.utils.ToastHelper; +import com.casic.dcms.utils.callback.IHttpRequestListener; +import com.casic.dcms.utils.callback.ILocationListener; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.geometry.SpatialReference; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; +import butterknife.OnClick; +import okhttp3.ResponseBody; + +public class LightOnMapFragment extends BaseFragment implements View.OnClickListener, ILightMapView, + ILightControlView { + + private static final String TAG = "LightOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private Context context; + private LightMapPresenterImpl lightMapPresenter; + private DaoSession daoSession; + private ListenableList graphicsOverlays; + private ListenableList graphics; + private double DELTA_L = Constant.DELTA_LNG_75; + private StreetLightLocalBeanDao lightLocalBeanDao; + private WeakReferenceHandler weakReferenceHandler; + private LightControlPresenterImpl controlPresenter; @Override protected int initLayoutView() { @@ -12,16 +91,409 @@ @Override protected void setupTopBarLayout() { - + context = getContext(); + daoSession = BaseApplication.getStreetLightDaoSession(); + lightLocalBeanDao = daoSession.getStreetLightLocalBeanDao(); + lightMapPresenter = new LightMapPresenterImpl(this); + weakReferenceHandler = new WeakReferenceHandler(this); + controlPresenter = new LightControlPresenterImpl(this); } @Override protected void initData() { + lightMapPresenter.onReadyRetrofitRequest(); + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(3000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); + mapView.setViewpointCenterAsync(point, 3000);//标注到指定经纬度并放大地图显示 + mapView.setMap(arcGISMap); + + //Marker相关Layer + graphicsOverlays = mapView.getGraphicsOverlays(); + //显示定位点附近路灯 + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + + List streetLightBeans = lightLocalBeanDao.loadAll(); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : streetLightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); +// if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && +// Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { +// pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } + if (Math.abs(longitude - Constant.DEFAULT_LNG) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - Constant.DEFAULT_LAT) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + } + } + }, true); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + protected void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + List lightBeans = lightLocalBeanDao.loadAll(); + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (StreetLightLocalBean dataBean : lightBeans) { + if (Math.abs(dataBean.getLongitude() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(dataBean.getLatitude() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021062401; + message.obj = dataBean.getLampId(); + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021062402); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); } @Override - protected void initEvent() { + public void showProgress() { + OtherUtils.showLoadingDialog(context, "处理中,请稍后..."); + } + @Override + public void hideProgress() { + OtherUtils.dismissLoadingDialog(); + } + + @Override + public void obtainControlResult(ActionResultBean resultBean) { + if (resultBean.isSuccess()) { + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); + } + } + + @Override + public void obtainDataFail() { + ToastHelper.showToast("操作失败", ToastHelper.ERROR); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(LightOnMapFragment fragment) { + reference = new WeakReference<>(fragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + LightOnMapFragment fragment = reference.get(); + Context context = fragment.context; + switch (msg.what) { + case 2021062401: + String lampId = (String) msg.obj; + + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_street_light, null); + TextView lightStateView = popupView.findViewById(R.id.lightStateView); + TextView lightAddressView = popupView.findViewById(R.id.lightAddressView); + TextView lightStreetView = popupView.findViewById(R.id.lightStreetView); + TextView lightElecView = popupView.findViewById(R.id.lightElecView); + TextView lightVolView = popupView.findViewById(R.id.lightVolView); + TextView lightTimeView = popupView.findViewById(R.id.lightTimeView); + ImageView lightSwitch = popupView.findViewById(R.id.lightSwitch); + + OtherUtils.showLoadingDialog(context, "路灯详情获取中,请稍后..."); + HttpRequestHelper.doRequest(Constant.LIGHT_DETAIL, lampId, new IHttpRequestListener() { + @Override + public void onSuccess(ResponseBody resultBean) { + OtherUtils.dismissLoadingDialog(); + try { + String string = resultBean.string(); + JSONObject jsonObject = new JSONObject(string); + int code = jsonObject.getInt("code"); + if (code == 200) { + JSONObject dataObject = jsonObject.getJSONObject("data"); + + String statusName = dataObject.getString("statusName"); + lightStateView.setText(statusName); + lightAddressView.setText(dataObject.getString("address")); + lightStreetView.setText(dataObject.getString("streetName")); + lightElecView.setText(String.valueOf(dataObject.getDouble("latestElec"))); + lightVolView.setText(String.valueOf(dataObject.getDouble("latestVol"))); + lightTimeView.setText(dataObject.getString("latestTime")); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 280)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(fragment.mapView); + + lightSwitch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + List lampIds = new ArrayList<>(); + lampIds.add(Long.parseLong(lampId)); + + String controlType; + if (statusName.equals("离线")) { + controlType = "1"; + } else { + controlType = "0"; + } + fragment.controlPresenter.onReadyRetrofitRequest(lampIds, controlType); + } + }); + } else { + ToastHelper.showToast("服务器异常,请重新选点", ToastHelper.ERROR); + } + } catch (JSONException | IOException e) { + ToastHelper.showToast("解析失败,请重新选点", ToastHelper.ERROR); + } + } + + @Override + public void onFailure(Throwable throwable) { + OtherUtils.dismissLoadingDialog(); + ToastHelper.showToast("网络连接失败,请重新选点", ToastHelper.ERROR); + } + }); + break; + case 2021062402: + ToastHelper.showToast("此附近无路灯,请重新选点", ToastHelper.ERROR); + break; + default: + break; + } + } + } + + private void addPictureMarker(List points) { + for (Point point : points) { + Bitmap caseBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.location_verify); + BitmapDrawable caseDrawable = new BitmapDrawable(getResources(), caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(24); + pictureMarker.setHeight(24); + pictureMarker.loadAsync(); + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(point, pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + private void clearPictureMarker() { + if (graphics != null && graphicsOverlays != null) { + graphics.clear(); + graphicsOverlays.clear(); + } + } + + @OnClick({R.id.expandMapView, R.id.minusMapView, R.id.removeToLocalView}) + @Override + public void onClick(View v) { + List lightBeans = lightLocalBeanDao.loadAll(); + switch (v.getId()) { + case R.id.expandMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 0.5); + clearPictureMarker(); + //计算比例尺 + DELTA_L -= 0.0001; + if (DELTA_L < 0) { + DELTA_L = 0; + } +// List minusList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(minusList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List minusList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(minusList); + } + } + }, true); + break; + case R.id.minusMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 2); + clearPictureMarker(); + //计算比例尺 + DELTA_L += 0.0001; + if (DELTA_L > 0.01) { + DELTA_L = Constant.DELTA_LNG_75; + } +// List expandList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(expandList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List expandList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(expandList); + } + } + }, true); + break; + case R.id.removeToLocalView: + clearPictureMarker(); + OtherUtils.showLoadingDialog(context, "定位中,请稍后"); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + mapView.setViewpointCenterAsync(point, 3000); + OtherUtils.dismissLoadingDialog(); + } + } + }, true); + break; + default: + break; + } + } + + @Override + public void obtainLightResult(LightMapBean resultBean) { + if (resultBean.isSuccess()) { + for (LightMapBean.DataBean dataBean : resultBean.getData()) { + StreetLightLocalBean bean = new StreetLightLocalBean(); + bean.setControllerCode(dataBean.getControllerCode()); + bean.setLampCode(dataBean.getLampCode()); + String lampId = dataBean.getLampId(); + bean.setLampId(lampId); + bean.setLatitude(dataBean.getLatitude()); + bean.setDeptId(dataBean.getDeptId()); + bean.setStatusName(dataBean.getStatusName()); + bean.setLampName(dataBean.getLampName()); + bean.setLatestTime(dataBean.getLatestTime()); + bean.setLongitude(dataBean.getLongitude()); + bean.setStatus(dataBean.getStatus()); + + StreetLightLocalBean uniqueBean = daoSession.queryBuilder(StreetLightLocalBean.class) + .where(StreetLightLocalBeanDao.Properties.LampId.eq(lampId)).unique(); + if (uniqueBean == null) { + daoSession.insert(bean); + } else { + daoSession.update(bean); + } + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (mapView != null) { + mapView.dispose(); + } + if (lightMapPresenter != null) { + lightMapPresenter.disposeRetrofitRequest(); + } + if (controlPresenter != null) { + controlPresenter.disposeRetrofitRequest(); + } } } diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index ac9f1bf..aa9fa10 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -135,7 +135,7 @@ // }, true); //TODO 暂时先用默认点代替定位点 - Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4490)); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); addPictureMarker(point); mapView.setViewpointCenterAsync(point, 2800);//标注到指定经纬度并放大地图显示 @@ -465,7 +465,7 @@ double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); addPictureMarker(point); - mapView.setViewpointCenterAsync((point), 2800); + mapView.setViewpointCenterAsync(point, 2800); OtherUtils.dismissLoadingDialog(); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java index 902e0af..0a7cb19 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java @@ -184,7 +184,7 @@ @Override public void obtainDataFail() { - ToastHelper.showToast("获取用户信息超时", ToastHelper.ERROR); + ToastHelper.showToast("获取用户信息失败,请重试", ToastHelper.ERROR); } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java index b1f2ebb..3b8dfd2 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java @@ -53,8 +53,6 @@ private boolean isRefresh, isLoadMore = false; private static WeakReferenceHandler weakReferenceHandler; private LightControlPresenterImpl controlPresenter; - private long lampId; - private int adapterPosition; @Override protected int initLayoutView() { @@ -92,7 +90,7 @@ public void onLoadMore(@NonNull final RefreshLayout refreshLayout) { isLoadMore = true; pageIndex++; - lightListPresenter.onReadyRetrofitRequest(Constant.PAGE_LIMIT, pageIndex); + lightListPresenter.onReadyRetrofitRequest(2 * Constant.PAGE_LIMIT, pageIndex); } }); } @@ -162,11 +160,9 @@ @Override public void onClick(int position) { LightListBean.DataBean.RowsBean rowsBean = fragment.dataBeans.get(position); - fragment.lampId = Long.parseLong(rowsBean.getLampId()); - fragment.adapterPosition = position; List lampIds = new ArrayList<>(); - lampIds.add(fragment.lampId); + lampIds.add(Long.parseLong(rowsBean.getLampId())); String statusName = rowsBean.getStatusName(); String controlType; @@ -202,7 +198,7 @@ public void obtainControlResult(ActionResultBean resultBean) { if (resultBean.isSuccess()) { //开灯指令发下去之后,虽然返回成功,但仅仅表示app发送指令到后台成功,但是开没开灯无法确定,所以,只能延迟几秒再刷新列表 - Log.d(TAG, "APP发送指令到后台成功,3s后即将刷新列表"); + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); weakReferenceHandler.sendEmptyMessageDelayed(20210624, 3000); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java index 5494f1b..a7bee54 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java @@ -1,9 +1,88 @@ package com.casic.dcms.ui.fragment; -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.location.Location; +import android.os.Handler; +import android.os.Message; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; -public class LightOnMapFragment extends BaseFragment { +import androidx.annotation.NonNull; + +import com.amap.api.location.AMapLocation; +import com.casic.dcms.R; +import com.casic.dcms.base.BaseApplication; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.bean.StreetLightLocalBean; +import com.casic.dcms.greendao.DaoSession; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; +import com.casic.dcms.mvp.presenter.LightControlPresenterImpl; +import com.casic.dcms.mvp.presenter.LightMapPresenterImpl; +import com.casic.dcms.mvp.view.ILightControlView; +import com.casic.dcms.mvp.view.ILightMapView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.HttpRequestHelper; +import com.casic.dcms.utils.LocationHelper; +import com.casic.dcms.utils.OtherUtils; +import com.casic.dcms.utils.ToastHelper; +import com.casic.dcms.utils.callback.IHttpRequestListener; +import com.casic.dcms.utils.callback.ILocationListener; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.geometry.SpatialReference; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; +import butterknife.OnClick; +import okhttp3.ResponseBody; + +public class LightOnMapFragment extends BaseFragment implements View.OnClickListener, ILightMapView, + ILightControlView { + + private static final String TAG = "LightOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private Context context; + private LightMapPresenterImpl lightMapPresenter; + private DaoSession daoSession; + private ListenableList graphicsOverlays; + private ListenableList graphics; + private double DELTA_L = Constant.DELTA_LNG_75; + private StreetLightLocalBeanDao lightLocalBeanDao; + private WeakReferenceHandler weakReferenceHandler; + private LightControlPresenterImpl controlPresenter; @Override protected int initLayoutView() { @@ -12,16 +91,409 @@ @Override protected void setupTopBarLayout() { - + context = getContext(); + daoSession = BaseApplication.getStreetLightDaoSession(); + lightLocalBeanDao = daoSession.getStreetLightLocalBeanDao(); + lightMapPresenter = new LightMapPresenterImpl(this); + weakReferenceHandler = new WeakReferenceHandler(this); + controlPresenter = new LightControlPresenterImpl(this); } @Override protected void initData() { + lightMapPresenter.onReadyRetrofitRequest(); + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(3000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); + mapView.setViewpointCenterAsync(point, 3000);//标注到指定经纬度并放大地图显示 + mapView.setMap(arcGISMap); + + //Marker相关Layer + graphicsOverlays = mapView.getGraphicsOverlays(); + //显示定位点附近路灯 + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + + List streetLightBeans = lightLocalBeanDao.loadAll(); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : streetLightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); +// if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && +// Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { +// pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } + if (Math.abs(longitude - Constant.DEFAULT_LNG) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - Constant.DEFAULT_LAT) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + } + } + }, true); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + protected void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + List lightBeans = lightLocalBeanDao.loadAll(); + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (StreetLightLocalBean dataBean : lightBeans) { + if (Math.abs(dataBean.getLongitude() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(dataBean.getLatitude() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021062401; + message.obj = dataBean.getLampId(); + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021062402); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); } @Override - protected void initEvent() { + public void showProgress() { + OtherUtils.showLoadingDialog(context, "处理中,请稍后..."); + } + @Override + public void hideProgress() { + OtherUtils.dismissLoadingDialog(); + } + + @Override + public void obtainControlResult(ActionResultBean resultBean) { + if (resultBean.isSuccess()) { + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); + } + } + + @Override + public void obtainDataFail() { + ToastHelper.showToast("操作失败", ToastHelper.ERROR); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(LightOnMapFragment fragment) { + reference = new WeakReference<>(fragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + LightOnMapFragment fragment = reference.get(); + Context context = fragment.context; + switch (msg.what) { + case 2021062401: + String lampId = (String) msg.obj; + + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_street_light, null); + TextView lightStateView = popupView.findViewById(R.id.lightStateView); + TextView lightAddressView = popupView.findViewById(R.id.lightAddressView); + TextView lightStreetView = popupView.findViewById(R.id.lightStreetView); + TextView lightElecView = popupView.findViewById(R.id.lightElecView); + TextView lightVolView = popupView.findViewById(R.id.lightVolView); + TextView lightTimeView = popupView.findViewById(R.id.lightTimeView); + ImageView lightSwitch = popupView.findViewById(R.id.lightSwitch); + + OtherUtils.showLoadingDialog(context, "路灯详情获取中,请稍后..."); + HttpRequestHelper.doRequest(Constant.LIGHT_DETAIL, lampId, new IHttpRequestListener() { + @Override + public void onSuccess(ResponseBody resultBean) { + OtherUtils.dismissLoadingDialog(); + try { + String string = resultBean.string(); + JSONObject jsonObject = new JSONObject(string); + int code = jsonObject.getInt("code"); + if (code == 200) { + JSONObject dataObject = jsonObject.getJSONObject("data"); + + String statusName = dataObject.getString("statusName"); + lightStateView.setText(statusName); + lightAddressView.setText(dataObject.getString("address")); + lightStreetView.setText(dataObject.getString("streetName")); + lightElecView.setText(String.valueOf(dataObject.getDouble("latestElec"))); + lightVolView.setText(String.valueOf(dataObject.getDouble("latestVol"))); + lightTimeView.setText(dataObject.getString("latestTime")); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 280)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(fragment.mapView); + + lightSwitch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + List lampIds = new ArrayList<>(); + lampIds.add(Long.parseLong(lampId)); + + String controlType; + if (statusName.equals("离线")) { + controlType = "1"; + } else { + controlType = "0"; + } + fragment.controlPresenter.onReadyRetrofitRequest(lampIds, controlType); + } + }); + } else { + ToastHelper.showToast("服务器异常,请重新选点", ToastHelper.ERROR); + } + } catch (JSONException | IOException e) { + ToastHelper.showToast("解析失败,请重新选点", ToastHelper.ERROR); + } + } + + @Override + public void onFailure(Throwable throwable) { + OtherUtils.dismissLoadingDialog(); + ToastHelper.showToast("网络连接失败,请重新选点", ToastHelper.ERROR); + } + }); + break; + case 2021062402: + ToastHelper.showToast("此附近无路灯,请重新选点", ToastHelper.ERROR); + break; + default: + break; + } + } + } + + private void addPictureMarker(List points) { + for (Point point : points) { + Bitmap caseBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.location_verify); + BitmapDrawable caseDrawable = new BitmapDrawable(getResources(), caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(24); + pictureMarker.setHeight(24); + pictureMarker.loadAsync(); + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(point, pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + private void clearPictureMarker() { + if (graphics != null && graphicsOverlays != null) { + graphics.clear(); + graphicsOverlays.clear(); + } + } + + @OnClick({R.id.expandMapView, R.id.minusMapView, R.id.removeToLocalView}) + @Override + public void onClick(View v) { + List lightBeans = lightLocalBeanDao.loadAll(); + switch (v.getId()) { + case R.id.expandMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 0.5); + clearPictureMarker(); + //计算比例尺 + DELTA_L -= 0.0001; + if (DELTA_L < 0) { + DELTA_L = 0; + } +// List minusList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(minusList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List minusList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(minusList); + } + } + }, true); + break; + case R.id.minusMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 2); + clearPictureMarker(); + //计算比例尺 + DELTA_L += 0.0001; + if (DELTA_L > 0.01) { + DELTA_L = Constant.DELTA_LNG_75; + } +// List expandList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(expandList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List expandList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(expandList); + } + } + }, true); + break; + case R.id.removeToLocalView: + clearPictureMarker(); + OtherUtils.showLoadingDialog(context, "定位中,请稍后"); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + mapView.setViewpointCenterAsync(point, 3000); + OtherUtils.dismissLoadingDialog(); + } + } + }, true); + break; + default: + break; + } + } + + @Override + public void obtainLightResult(LightMapBean resultBean) { + if (resultBean.isSuccess()) { + for (LightMapBean.DataBean dataBean : resultBean.getData()) { + StreetLightLocalBean bean = new StreetLightLocalBean(); + bean.setControllerCode(dataBean.getControllerCode()); + bean.setLampCode(dataBean.getLampCode()); + String lampId = dataBean.getLampId(); + bean.setLampId(lampId); + bean.setLatitude(dataBean.getLatitude()); + bean.setDeptId(dataBean.getDeptId()); + bean.setStatusName(dataBean.getStatusName()); + bean.setLampName(dataBean.getLampName()); + bean.setLatestTime(dataBean.getLatestTime()); + bean.setLongitude(dataBean.getLongitude()); + bean.setStatus(dataBean.getStatus()); + + StreetLightLocalBean uniqueBean = daoSession.queryBuilder(StreetLightLocalBean.class) + .where(StreetLightLocalBeanDao.Properties.LampId.eq(lampId)).unique(); + if (uniqueBean == null) { + daoSession.insert(bean); + } else { + daoSession.update(bean); + } + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (mapView != null) { + mapView.dispose(); + } + if (lightMapPresenter != null) { + lightMapPresenter.disposeRetrofitRequest(); + } + if (controlPresenter != null) { + controlPresenter.disposeRetrofitRequest(); + } } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 9bbbdb0..9a50b53 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -69,12 +69,15 @@ public static final double DEFAULT_LAT = 27.759547805536418; public static final double DELTA_LNG_10 = 0.00002536; // 10米范围经度值偏移量(大约) public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) + public static final double DELTA_LNG_75 = 0.00075; + public static final double DELTA_LAT_75 = 0.00075; //单独网络请求接口名 public static final String SHOP_DETAIL = "/shop/merchant/detail?merchantId="; public static final String SHOP_PUNISH_LIST = "/shop/punish/listByMerchant?merchantId="; public static final String SHOP_PUNISH_TYPE = "/shop/punish/statisticByMerchant?merchantId="; public static final String SHOP_MERCHANT_ID = "/shop/merchant/getIdByCode?shopCode="; + public static final String LIGHT_DETAIL = "/lightCr/overview/lampDetail?lampId="; //生产环境 public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index ac9f1bf..aa9fa10 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -135,7 +135,7 @@ // }, true); //TODO 暂时先用默认点代替定位点 - Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4490)); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); addPictureMarker(point); mapView.setViewpointCenterAsync(point, 2800);//标注到指定经纬度并放大地图显示 @@ -465,7 +465,7 @@ double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); addPictureMarker(point); - mapView.setViewpointCenterAsync((point), 2800); + mapView.setViewpointCenterAsync(point, 2800); OtherUtils.dismissLoadingDialog(); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java index 902e0af..0a7cb19 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java @@ -184,7 +184,7 @@ @Override public void obtainDataFail() { - ToastHelper.showToast("获取用户信息超时", ToastHelper.ERROR); + ToastHelper.showToast("获取用户信息失败,请重试", ToastHelper.ERROR); } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java index b1f2ebb..3b8dfd2 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java @@ -53,8 +53,6 @@ private boolean isRefresh, isLoadMore = false; private static WeakReferenceHandler weakReferenceHandler; private LightControlPresenterImpl controlPresenter; - private long lampId; - private int adapterPosition; @Override protected int initLayoutView() { @@ -92,7 +90,7 @@ public void onLoadMore(@NonNull final RefreshLayout refreshLayout) { isLoadMore = true; pageIndex++; - lightListPresenter.onReadyRetrofitRequest(Constant.PAGE_LIMIT, pageIndex); + lightListPresenter.onReadyRetrofitRequest(2 * Constant.PAGE_LIMIT, pageIndex); } }); } @@ -162,11 +160,9 @@ @Override public void onClick(int position) { LightListBean.DataBean.RowsBean rowsBean = fragment.dataBeans.get(position); - fragment.lampId = Long.parseLong(rowsBean.getLampId()); - fragment.adapterPosition = position; List lampIds = new ArrayList<>(); - lampIds.add(fragment.lampId); + lampIds.add(Long.parseLong(rowsBean.getLampId())); String statusName = rowsBean.getStatusName(); String controlType; @@ -202,7 +198,7 @@ public void obtainControlResult(ActionResultBean resultBean) { if (resultBean.isSuccess()) { //开灯指令发下去之后,虽然返回成功,但仅仅表示app发送指令到后台成功,但是开没开灯无法确定,所以,只能延迟几秒再刷新列表 - Log.d(TAG, "APP发送指令到后台成功,3s后即将刷新列表"); + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); weakReferenceHandler.sendEmptyMessageDelayed(20210624, 3000); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java index 5494f1b..a7bee54 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java @@ -1,9 +1,88 @@ package com.casic.dcms.ui.fragment; -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.location.Location; +import android.os.Handler; +import android.os.Message; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; -public class LightOnMapFragment extends BaseFragment { +import androidx.annotation.NonNull; + +import com.amap.api.location.AMapLocation; +import com.casic.dcms.R; +import com.casic.dcms.base.BaseApplication; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.bean.StreetLightLocalBean; +import com.casic.dcms.greendao.DaoSession; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; +import com.casic.dcms.mvp.presenter.LightControlPresenterImpl; +import com.casic.dcms.mvp.presenter.LightMapPresenterImpl; +import com.casic.dcms.mvp.view.ILightControlView; +import com.casic.dcms.mvp.view.ILightMapView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.HttpRequestHelper; +import com.casic.dcms.utils.LocationHelper; +import com.casic.dcms.utils.OtherUtils; +import com.casic.dcms.utils.ToastHelper; +import com.casic.dcms.utils.callback.IHttpRequestListener; +import com.casic.dcms.utils.callback.ILocationListener; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.geometry.SpatialReference; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; +import butterknife.OnClick; +import okhttp3.ResponseBody; + +public class LightOnMapFragment extends BaseFragment implements View.OnClickListener, ILightMapView, + ILightControlView { + + private static final String TAG = "LightOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private Context context; + private LightMapPresenterImpl lightMapPresenter; + private DaoSession daoSession; + private ListenableList graphicsOverlays; + private ListenableList graphics; + private double DELTA_L = Constant.DELTA_LNG_75; + private StreetLightLocalBeanDao lightLocalBeanDao; + private WeakReferenceHandler weakReferenceHandler; + private LightControlPresenterImpl controlPresenter; @Override protected int initLayoutView() { @@ -12,16 +91,409 @@ @Override protected void setupTopBarLayout() { - + context = getContext(); + daoSession = BaseApplication.getStreetLightDaoSession(); + lightLocalBeanDao = daoSession.getStreetLightLocalBeanDao(); + lightMapPresenter = new LightMapPresenterImpl(this); + weakReferenceHandler = new WeakReferenceHandler(this); + controlPresenter = new LightControlPresenterImpl(this); } @Override protected void initData() { + lightMapPresenter.onReadyRetrofitRequest(); + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(3000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); + mapView.setViewpointCenterAsync(point, 3000);//标注到指定经纬度并放大地图显示 + mapView.setMap(arcGISMap); + + //Marker相关Layer + graphicsOverlays = mapView.getGraphicsOverlays(); + //显示定位点附近路灯 + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + + List streetLightBeans = lightLocalBeanDao.loadAll(); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : streetLightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); +// if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && +// Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { +// pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } + if (Math.abs(longitude - Constant.DEFAULT_LNG) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - Constant.DEFAULT_LAT) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + } + } + }, true); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + protected void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + List lightBeans = lightLocalBeanDao.loadAll(); + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (StreetLightLocalBean dataBean : lightBeans) { + if (Math.abs(dataBean.getLongitude() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(dataBean.getLatitude() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021062401; + message.obj = dataBean.getLampId(); + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021062402); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); } @Override - protected void initEvent() { + public void showProgress() { + OtherUtils.showLoadingDialog(context, "处理中,请稍后..."); + } + @Override + public void hideProgress() { + OtherUtils.dismissLoadingDialog(); + } + + @Override + public void obtainControlResult(ActionResultBean resultBean) { + if (resultBean.isSuccess()) { + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); + } + } + + @Override + public void obtainDataFail() { + ToastHelper.showToast("操作失败", ToastHelper.ERROR); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(LightOnMapFragment fragment) { + reference = new WeakReference<>(fragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + LightOnMapFragment fragment = reference.get(); + Context context = fragment.context; + switch (msg.what) { + case 2021062401: + String lampId = (String) msg.obj; + + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_street_light, null); + TextView lightStateView = popupView.findViewById(R.id.lightStateView); + TextView lightAddressView = popupView.findViewById(R.id.lightAddressView); + TextView lightStreetView = popupView.findViewById(R.id.lightStreetView); + TextView lightElecView = popupView.findViewById(R.id.lightElecView); + TextView lightVolView = popupView.findViewById(R.id.lightVolView); + TextView lightTimeView = popupView.findViewById(R.id.lightTimeView); + ImageView lightSwitch = popupView.findViewById(R.id.lightSwitch); + + OtherUtils.showLoadingDialog(context, "路灯详情获取中,请稍后..."); + HttpRequestHelper.doRequest(Constant.LIGHT_DETAIL, lampId, new IHttpRequestListener() { + @Override + public void onSuccess(ResponseBody resultBean) { + OtherUtils.dismissLoadingDialog(); + try { + String string = resultBean.string(); + JSONObject jsonObject = new JSONObject(string); + int code = jsonObject.getInt("code"); + if (code == 200) { + JSONObject dataObject = jsonObject.getJSONObject("data"); + + String statusName = dataObject.getString("statusName"); + lightStateView.setText(statusName); + lightAddressView.setText(dataObject.getString("address")); + lightStreetView.setText(dataObject.getString("streetName")); + lightElecView.setText(String.valueOf(dataObject.getDouble("latestElec"))); + lightVolView.setText(String.valueOf(dataObject.getDouble("latestVol"))); + lightTimeView.setText(dataObject.getString("latestTime")); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 280)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(fragment.mapView); + + lightSwitch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + List lampIds = new ArrayList<>(); + lampIds.add(Long.parseLong(lampId)); + + String controlType; + if (statusName.equals("离线")) { + controlType = "1"; + } else { + controlType = "0"; + } + fragment.controlPresenter.onReadyRetrofitRequest(lampIds, controlType); + } + }); + } else { + ToastHelper.showToast("服务器异常,请重新选点", ToastHelper.ERROR); + } + } catch (JSONException | IOException e) { + ToastHelper.showToast("解析失败,请重新选点", ToastHelper.ERROR); + } + } + + @Override + public void onFailure(Throwable throwable) { + OtherUtils.dismissLoadingDialog(); + ToastHelper.showToast("网络连接失败,请重新选点", ToastHelper.ERROR); + } + }); + break; + case 2021062402: + ToastHelper.showToast("此附近无路灯,请重新选点", ToastHelper.ERROR); + break; + default: + break; + } + } + } + + private void addPictureMarker(List points) { + for (Point point : points) { + Bitmap caseBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.location_verify); + BitmapDrawable caseDrawable = new BitmapDrawable(getResources(), caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(24); + pictureMarker.setHeight(24); + pictureMarker.loadAsync(); + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(point, pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + private void clearPictureMarker() { + if (graphics != null && graphicsOverlays != null) { + graphics.clear(); + graphicsOverlays.clear(); + } + } + + @OnClick({R.id.expandMapView, R.id.minusMapView, R.id.removeToLocalView}) + @Override + public void onClick(View v) { + List lightBeans = lightLocalBeanDao.loadAll(); + switch (v.getId()) { + case R.id.expandMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 0.5); + clearPictureMarker(); + //计算比例尺 + DELTA_L -= 0.0001; + if (DELTA_L < 0) { + DELTA_L = 0; + } +// List minusList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(minusList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List minusList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(minusList); + } + } + }, true); + break; + case R.id.minusMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 2); + clearPictureMarker(); + //计算比例尺 + DELTA_L += 0.0001; + if (DELTA_L > 0.01) { + DELTA_L = Constant.DELTA_LNG_75; + } +// List expandList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(expandList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List expandList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(expandList); + } + } + }, true); + break; + case R.id.removeToLocalView: + clearPictureMarker(); + OtherUtils.showLoadingDialog(context, "定位中,请稍后"); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + mapView.setViewpointCenterAsync(point, 3000); + OtherUtils.dismissLoadingDialog(); + } + } + }, true); + break; + default: + break; + } + } + + @Override + public void obtainLightResult(LightMapBean resultBean) { + if (resultBean.isSuccess()) { + for (LightMapBean.DataBean dataBean : resultBean.getData()) { + StreetLightLocalBean bean = new StreetLightLocalBean(); + bean.setControllerCode(dataBean.getControllerCode()); + bean.setLampCode(dataBean.getLampCode()); + String lampId = dataBean.getLampId(); + bean.setLampId(lampId); + bean.setLatitude(dataBean.getLatitude()); + bean.setDeptId(dataBean.getDeptId()); + bean.setStatusName(dataBean.getStatusName()); + bean.setLampName(dataBean.getLampName()); + bean.setLatestTime(dataBean.getLatestTime()); + bean.setLongitude(dataBean.getLongitude()); + bean.setStatus(dataBean.getStatus()); + + StreetLightLocalBean uniqueBean = daoSession.queryBuilder(StreetLightLocalBean.class) + .where(StreetLightLocalBeanDao.Properties.LampId.eq(lampId)).unique(); + if (uniqueBean == null) { + daoSession.insert(bean); + } else { + daoSession.update(bean); + } + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (mapView != null) { + mapView.dispose(); + } + if (lightMapPresenter != null) { + lightMapPresenter.disposeRetrofitRequest(); + } + if (controlPresenter != null) { + controlPresenter.disposeRetrofitRequest(); + } } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 9bbbdb0..9a50b53 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -69,12 +69,15 @@ public static final double DEFAULT_LAT = 27.759547805536418; public static final double DELTA_LNG_10 = 0.00002536; // 10米范围经度值偏移量(大约) public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) + public static final double DELTA_LNG_75 = 0.00075; + public static final double DELTA_LAT_75 = 0.00075; //单独网络请求接口名 public static final String SHOP_DETAIL = "/shop/merchant/detail?merchantId="; public static final String SHOP_PUNISH_LIST = "/shop/punish/listByMerchant?merchantId="; public static final String SHOP_PUNISH_TYPE = "/shop/punish/statisticByMerchant?merchantId="; public static final String SHOP_MERCHANT_ID = "/shop/merchant/getIdByCode?shopCode="; + public static final String LIGHT_DETAIL = "/lightCr/overview/lampDetail?lampId="; //生产环境 public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java index beb5345..b1a4429 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java @@ -21,6 +21,7 @@ import com.casic.dcms.bean.HighEventBean; import com.casic.dcms.bean.HomePageBean; import com.casic.dcms.bean.LightListBean; +import com.casic.dcms.bean.LightMapBean; import com.casic.dcms.bean.LoginResultBean; import com.casic.dcms.bean.MaintainContentBean; import com.casic.dcms.bean.MaintainRecordBean; @@ -662,7 +663,7 @@ @Query("offset") int offset); /** - * 路灯列表数据 + * 路灯分页列表数据 *

* http://111.198.10.15:11409/lightCr/overview/lampListPage?limit=15&offset=1 */ @@ -672,7 +673,15 @@ @Query("offset") int offset); /** - * 路灯列表数据 + * 路灯全部数据 + *

+ * http://111.198.10.15:11409/lampCr/overview/lampList + */ + @GET("/lightCr/overview/lampList") + Observable obtainLightList(@Header("token") String token); + + /** + * 路灯列详情数据 *

* http://111.198.10.15:11409/lightCr/overview/lampDetail?lampId=1354712301527764999 */ diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index ac9f1bf..aa9fa10 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -135,7 +135,7 @@ // }, true); //TODO 暂时先用默认点代替定位点 - Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4490)); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); addPictureMarker(point); mapView.setViewpointCenterAsync(point, 2800);//标注到指定经纬度并放大地图显示 @@ -465,7 +465,7 @@ double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); addPictureMarker(point); - mapView.setViewpointCenterAsync((point), 2800); + mapView.setViewpointCenterAsync(point, 2800); OtherUtils.dismissLoadingDialog(); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java index 902e0af..0a7cb19 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java @@ -184,7 +184,7 @@ @Override public void obtainDataFail() { - ToastHelper.showToast("获取用户信息超时", ToastHelper.ERROR); + ToastHelper.showToast("获取用户信息失败,请重试", ToastHelper.ERROR); } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java index b1f2ebb..3b8dfd2 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java @@ -53,8 +53,6 @@ private boolean isRefresh, isLoadMore = false; private static WeakReferenceHandler weakReferenceHandler; private LightControlPresenterImpl controlPresenter; - private long lampId; - private int adapterPosition; @Override protected int initLayoutView() { @@ -92,7 +90,7 @@ public void onLoadMore(@NonNull final RefreshLayout refreshLayout) { isLoadMore = true; pageIndex++; - lightListPresenter.onReadyRetrofitRequest(Constant.PAGE_LIMIT, pageIndex); + lightListPresenter.onReadyRetrofitRequest(2 * Constant.PAGE_LIMIT, pageIndex); } }); } @@ -162,11 +160,9 @@ @Override public void onClick(int position) { LightListBean.DataBean.RowsBean rowsBean = fragment.dataBeans.get(position); - fragment.lampId = Long.parseLong(rowsBean.getLampId()); - fragment.adapterPosition = position; List lampIds = new ArrayList<>(); - lampIds.add(fragment.lampId); + lampIds.add(Long.parseLong(rowsBean.getLampId())); String statusName = rowsBean.getStatusName(); String controlType; @@ -202,7 +198,7 @@ public void obtainControlResult(ActionResultBean resultBean) { if (resultBean.isSuccess()) { //开灯指令发下去之后,虽然返回成功,但仅仅表示app发送指令到后台成功,但是开没开灯无法确定,所以,只能延迟几秒再刷新列表 - Log.d(TAG, "APP发送指令到后台成功,3s后即将刷新列表"); + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); weakReferenceHandler.sendEmptyMessageDelayed(20210624, 3000); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java index 5494f1b..a7bee54 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java @@ -1,9 +1,88 @@ package com.casic.dcms.ui.fragment; -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.location.Location; +import android.os.Handler; +import android.os.Message; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; -public class LightOnMapFragment extends BaseFragment { +import androidx.annotation.NonNull; + +import com.amap.api.location.AMapLocation; +import com.casic.dcms.R; +import com.casic.dcms.base.BaseApplication; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.bean.StreetLightLocalBean; +import com.casic.dcms.greendao.DaoSession; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; +import com.casic.dcms.mvp.presenter.LightControlPresenterImpl; +import com.casic.dcms.mvp.presenter.LightMapPresenterImpl; +import com.casic.dcms.mvp.view.ILightControlView; +import com.casic.dcms.mvp.view.ILightMapView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.HttpRequestHelper; +import com.casic.dcms.utils.LocationHelper; +import com.casic.dcms.utils.OtherUtils; +import com.casic.dcms.utils.ToastHelper; +import com.casic.dcms.utils.callback.IHttpRequestListener; +import com.casic.dcms.utils.callback.ILocationListener; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.geometry.SpatialReference; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; +import butterknife.OnClick; +import okhttp3.ResponseBody; + +public class LightOnMapFragment extends BaseFragment implements View.OnClickListener, ILightMapView, + ILightControlView { + + private static final String TAG = "LightOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private Context context; + private LightMapPresenterImpl lightMapPresenter; + private DaoSession daoSession; + private ListenableList graphicsOverlays; + private ListenableList graphics; + private double DELTA_L = Constant.DELTA_LNG_75; + private StreetLightLocalBeanDao lightLocalBeanDao; + private WeakReferenceHandler weakReferenceHandler; + private LightControlPresenterImpl controlPresenter; @Override protected int initLayoutView() { @@ -12,16 +91,409 @@ @Override protected void setupTopBarLayout() { - + context = getContext(); + daoSession = BaseApplication.getStreetLightDaoSession(); + lightLocalBeanDao = daoSession.getStreetLightLocalBeanDao(); + lightMapPresenter = new LightMapPresenterImpl(this); + weakReferenceHandler = new WeakReferenceHandler(this); + controlPresenter = new LightControlPresenterImpl(this); } @Override protected void initData() { + lightMapPresenter.onReadyRetrofitRequest(); + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(3000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); + mapView.setViewpointCenterAsync(point, 3000);//标注到指定经纬度并放大地图显示 + mapView.setMap(arcGISMap); + + //Marker相关Layer + graphicsOverlays = mapView.getGraphicsOverlays(); + //显示定位点附近路灯 + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + + List streetLightBeans = lightLocalBeanDao.loadAll(); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : streetLightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); +// if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && +// Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { +// pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } + if (Math.abs(longitude - Constant.DEFAULT_LNG) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - Constant.DEFAULT_LAT) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + } + } + }, true); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + protected void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + List lightBeans = lightLocalBeanDao.loadAll(); + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (StreetLightLocalBean dataBean : lightBeans) { + if (Math.abs(dataBean.getLongitude() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(dataBean.getLatitude() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021062401; + message.obj = dataBean.getLampId(); + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021062402); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); } @Override - protected void initEvent() { + public void showProgress() { + OtherUtils.showLoadingDialog(context, "处理中,请稍后..."); + } + @Override + public void hideProgress() { + OtherUtils.dismissLoadingDialog(); + } + + @Override + public void obtainControlResult(ActionResultBean resultBean) { + if (resultBean.isSuccess()) { + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); + } + } + + @Override + public void obtainDataFail() { + ToastHelper.showToast("操作失败", ToastHelper.ERROR); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(LightOnMapFragment fragment) { + reference = new WeakReference<>(fragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + LightOnMapFragment fragment = reference.get(); + Context context = fragment.context; + switch (msg.what) { + case 2021062401: + String lampId = (String) msg.obj; + + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_street_light, null); + TextView lightStateView = popupView.findViewById(R.id.lightStateView); + TextView lightAddressView = popupView.findViewById(R.id.lightAddressView); + TextView lightStreetView = popupView.findViewById(R.id.lightStreetView); + TextView lightElecView = popupView.findViewById(R.id.lightElecView); + TextView lightVolView = popupView.findViewById(R.id.lightVolView); + TextView lightTimeView = popupView.findViewById(R.id.lightTimeView); + ImageView lightSwitch = popupView.findViewById(R.id.lightSwitch); + + OtherUtils.showLoadingDialog(context, "路灯详情获取中,请稍后..."); + HttpRequestHelper.doRequest(Constant.LIGHT_DETAIL, lampId, new IHttpRequestListener() { + @Override + public void onSuccess(ResponseBody resultBean) { + OtherUtils.dismissLoadingDialog(); + try { + String string = resultBean.string(); + JSONObject jsonObject = new JSONObject(string); + int code = jsonObject.getInt("code"); + if (code == 200) { + JSONObject dataObject = jsonObject.getJSONObject("data"); + + String statusName = dataObject.getString("statusName"); + lightStateView.setText(statusName); + lightAddressView.setText(dataObject.getString("address")); + lightStreetView.setText(dataObject.getString("streetName")); + lightElecView.setText(String.valueOf(dataObject.getDouble("latestElec"))); + lightVolView.setText(String.valueOf(dataObject.getDouble("latestVol"))); + lightTimeView.setText(dataObject.getString("latestTime")); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 280)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(fragment.mapView); + + lightSwitch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + List lampIds = new ArrayList<>(); + lampIds.add(Long.parseLong(lampId)); + + String controlType; + if (statusName.equals("离线")) { + controlType = "1"; + } else { + controlType = "0"; + } + fragment.controlPresenter.onReadyRetrofitRequest(lampIds, controlType); + } + }); + } else { + ToastHelper.showToast("服务器异常,请重新选点", ToastHelper.ERROR); + } + } catch (JSONException | IOException e) { + ToastHelper.showToast("解析失败,请重新选点", ToastHelper.ERROR); + } + } + + @Override + public void onFailure(Throwable throwable) { + OtherUtils.dismissLoadingDialog(); + ToastHelper.showToast("网络连接失败,请重新选点", ToastHelper.ERROR); + } + }); + break; + case 2021062402: + ToastHelper.showToast("此附近无路灯,请重新选点", ToastHelper.ERROR); + break; + default: + break; + } + } + } + + private void addPictureMarker(List points) { + for (Point point : points) { + Bitmap caseBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.location_verify); + BitmapDrawable caseDrawable = new BitmapDrawable(getResources(), caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(24); + pictureMarker.setHeight(24); + pictureMarker.loadAsync(); + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(point, pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + private void clearPictureMarker() { + if (graphics != null && graphicsOverlays != null) { + graphics.clear(); + graphicsOverlays.clear(); + } + } + + @OnClick({R.id.expandMapView, R.id.minusMapView, R.id.removeToLocalView}) + @Override + public void onClick(View v) { + List lightBeans = lightLocalBeanDao.loadAll(); + switch (v.getId()) { + case R.id.expandMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 0.5); + clearPictureMarker(); + //计算比例尺 + DELTA_L -= 0.0001; + if (DELTA_L < 0) { + DELTA_L = 0; + } +// List minusList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(minusList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List minusList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(minusList); + } + } + }, true); + break; + case R.id.minusMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 2); + clearPictureMarker(); + //计算比例尺 + DELTA_L += 0.0001; + if (DELTA_L > 0.01) { + DELTA_L = Constant.DELTA_LNG_75; + } +// List expandList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(expandList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List expandList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(expandList); + } + } + }, true); + break; + case R.id.removeToLocalView: + clearPictureMarker(); + OtherUtils.showLoadingDialog(context, "定位中,请稍后"); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + mapView.setViewpointCenterAsync(point, 3000); + OtherUtils.dismissLoadingDialog(); + } + } + }, true); + break; + default: + break; + } + } + + @Override + public void obtainLightResult(LightMapBean resultBean) { + if (resultBean.isSuccess()) { + for (LightMapBean.DataBean dataBean : resultBean.getData()) { + StreetLightLocalBean bean = new StreetLightLocalBean(); + bean.setControllerCode(dataBean.getControllerCode()); + bean.setLampCode(dataBean.getLampCode()); + String lampId = dataBean.getLampId(); + bean.setLampId(lampId); + bean.setLatitude(dataBean.getLatitude()); + bean.setDeptId(dataBean.getDeptId()); + bean.setStatusName(dataBean.getStatusName()); + bean.setLampName(dataBean.getLampName()); + bean.setLatestTime(dataBean.getLatestTime()); + bean.setLongitude(dataBean.getLongitude()); + bean.setStatus(dataBean.getStatus()); + + StreetLightLocalBean uniqueBean = daoSession.queryBuilder(StreetLightLocalBean.class) + .where(StreetLightLocalBeanDao.Properties.LampId.eq(lampId)).unique(); + if (uniqueBean == null) { + daoSession.insert(bean); + } else { + daoSession.update(bean); + } + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (mapView != null) { + mapView.dispose(); + } + if (lightMapPresenter != null) { + lightMapPresenter.disposeRetrofitRequest(); + } + if (controlPresenter != null) { + controlPresenter.disposeRetrofitRequest(); + } } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 9bbbdb0..9a50b53 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -69,12 +69,15 @@ public static final double DEFAULT_LAT = 27.759547805536418; public static final double DELTA_LNG_10 = 0.00002536; // 10米范围经度值偏移量(大约) public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) + public static final double DELTA_LNG_75 = 0.00075; + public static final double DELTA_LAT_75 = 0.00075; //单独网络请求接口名 public static final String SHOP_DETAIL = "/shop/merchant/detail?merchantId="; public static final String SHOP_PUNISH_LIST = "/shop/punish/listByMerchant?merchantId="; public static final String SHOP_PUNISH_TYPE = "/shop/punish/statisticByMerchant?merchantId="; public static final String SHOP_MERCHANT_ID = "/shop/merchant/getIdByCode?shopCode="; + public static final String LIGHT_DETAIL = "/lightCr/overview/lampDetail?lampId="; //生产环境 public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java index beb5345..b1a4429 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java @@ -21,6 +21,7 @@ import com.casic.dcms.bean.HighEventBean; import com.casic.dcms.bean.HomePageBean; import com.casic.dcms.bean.LightListBean; +import com.casic.dcms.bean.LightMapBean; import com.casic.dcms.bean.LoginResultBean; import com.casic.dcms.bean.MaintainContentBean; import com.casic.dcms.bean.MaintainRecordBean; @@ -662,7 +663,7 @@ @Query("offset") int offset); /** - * 路灯列表数据 + * 路灯分页列表数据 *

* http://111.198.10.15:11409/lightCr/overview/lampListPage?limit=15&offset=1 */ @@ -672,7 +673,15 @@ @Query("offset") int offset); /** - * 路灯列表数据 + * 路灯全部数据 + *

+ * http://111.198.10.15:11409/lampCr/overview/lampList + */ + @GET("/lightCr/overview/lampList") + Observable obtainLightList(@Header("token") String token); + + /** + * 路灯列详情数据 *

* http://111.198.10.15:11409/lightCr/overview/lampDetail?lampId=1354712301527764999 */ diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java index f6f33c8..6503d64 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java @@ -23,6 +23,7 @@ import com.casic.dcms.bean.HighEventBean; import com.casic.dcms.bean.HomePageBean; import com.casic.dcms.bean.LightListBean; +import com.casic.dcms.bean.LightMapBean; import com.casic.dcms.bean.LoginResultBean; import com.casic.dcms.bean.MaintainContentBean; import com.casic.dcms.bean.MaintainRecordBean; @@ -682,7 +683,7 @@ } /** - * 路灯列表数据 + * 路灯分页列表数据 */ public static Observable getLightListResult(int limit, int offset) { Retrofit retrofit = createRetrofit(); @@ -691,6 +692,15 @@ } /** + * 路灯全部数据 + */ + public static Observable getLightListResult() { + Retrofit retrofit = createRetrofit(); + RetrofitService service = retrofit.create(RetrofitService.class); + return service.obtainLightList(AuthenticationHelper.getToken()); + } + + /** * 路灯详情数据 * 因为返回的数据会出现结构不一致的问题,不能用实体类接收改为ResponseBody接收,然后在手动解析 */ diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index ac9f1bf..aa9fa10 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -135,7 +135,7 @@ // }, true); //TODO 暂时先用默认点代替定位点 - Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4490)); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); addPictureMarker(point); mapView.setViewpointCenterAsync(point, 2800);//标注到指定经纬度并放大地图显示 @@ -465,7 +465,7 @@ double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); addPictureMarker(point); - mapView.setViewpointCenterAsync((point), 2800); + mapView.setViewpointCenterAsync(point, 2800); OtherUtils.dismissLoadingDialog(); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java index 902e0af..0a7cb19 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java @@ -184,7 +184,7 @@ @Override public void obtainDataFail() { - ToastHelper.showToast("获取用户信息超时", ToastHelper.ERROR); + ToastHelper.showToast("获取用户信息失败,请重试", ToastHelper.ERROR); } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java index b1f2ebb..3b8dfd2 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java @@ -53,8 +53,6 @@ private boolean isRefresh, isLoadMore = false; private static WeakReferenceHandler weakReferenceHandler; private LightControlPresenterImpl controlPresenter; - private long lampId; - private int adapterPosition; @Override protected int initLayoutView() { @@ -92,7 +90,7 @@ public void onLoadMore(@NonNull final RefreshLayout refreshLayout) { isLoadMore = true; pageIndex++; - lightListPresenter.onReadyRetrofitRequest(Constant.PAGE_LIMIT, pageIndex); + lightListPresenter.onReadyRetrofitRequest(2 * Constant.PAGE_LIMIT, pageIndex); } }); } @@ -162,11 +160,9 @@ @Override public void onClick(int position) { LightListBean.DataBean.RowsBean rowsBean = fragment.dataBeans.get(position); - fragment.lampId = Long.parseLong(rowsBean.getLampId()); - fragment.adapterPosition = position; List lampIds = new ArrayList<>(); - lampIds.add(fragment.lampId); + lampIds.add(Long.parseLong(rowsBean.getLampId())); String statusName = rowsBean.getStatusName(); String controlType; @@ -202,7 +198,7 @@ public void obtainControlResult(ActionResultBean resultBean) { if (resultBean.isSuccess()) { //开灯指令发下去之后,虽然返回成功,但仅仅表示app发送指令到后台成功,但是开没开灯无法确定,所以,只能延迟几秒再刷新列表 - Log.d(TAG, "APP发送指令到后台成功,3s后即将刷新列表"); + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); weakReferenceHandler.sendEmptyMessageDelayed(20210624, 3000); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java index 5494f1b..a7bee54 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java @@ -1,9 +1,88 @@ package com.casic.dcms.ui.fragment; -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.location.Location; +import android.os.Handler; +import android.os.Message; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; -public class LightOnMapFragment extends BaseFragment { +import androidx.annotation.NonNull; + +import com.amap.api.location.AMapLocation; +import com.casic.dcms.R; +import com.casic.dcms.base.BaseApplication; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.bean.StreetLightLocalBean; +import com.casic.dcms.greendao.DaoSession; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; +import com.casic.dcms.mvp.presenter.LightControlPresenterImpl; +import com.casic.dcms.mvp.presenter.LightMapPresenterImpl; +import com.casic.dcms.mvp.view.ILightControlView; +import com.casic.dcms.mvp.view.ILightMapView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.HttpRequestHelper; +import com.casic.dcms.utils.LocationHelper; +import com.casic.dcms.utils.OtherUtils; +import com.casic.dcms.utils.ToastHelper; +import com.casic.dcms.utils.callback.IHttpRequestListener; +import com.casic.dcms.utils.callback.ILocationListener; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.geometry.SpatialReference; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; +import butterknife.OnClick; +import okhttp3.ResponseBody; + +public class LightOnMapFragment extends BaseFragment implements View.OnClickListener, ILightMapView, + ILightControlView { + + private static final String TAG = "LightOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private Context context; + private LightMapPresenterImpl lightMapPresenter; + private DaoSession daoSession; + private ListenableList graphicsOverlays; + private ListenableList graphics; + private double DELTA_L = Constant.DELTA_LNG_75; + private StreetLightLocalBeanDao lightLocalBeanDao; + private WeakReferenceHandler weakReferenceHandler; + private LightControlPresenterImpl controlPresenter; @Override protected int initLayoutView() { @@ -12,16 +91,409 @@ @Override protected void setupTopBarLayout() { - + context = getContext(); + daoSession = BaseApplication.getStreetLightDaoSession(); + lightLocalBeanDao = daoSession.getStreetLightLocalBeanDao(); + lightMapPresenter = new LightMapPresenterImpl(this); + weakReferenceHandler = new WeakReferenceHandler(this); + controlPresenter = new LightControlPresenterImpl(this); } @Override protected void initData() { + lightMapPresenter.onReadyRetrofitRequest(); + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(3000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); + mapView.setViewpointCenterAsync(point, 3000);//标注到指定经纬度并放大地图显示 + mapView.setMap(arcGISMap); + + //Marker相关Layer + graphicsOverlays = mapView.getGraphicsOverlays(); + //显示定位点附近路灯 + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + + List streetLightBeans = lightLocalBeanDao.loadAll(); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : streetLightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); +// if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && +// Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { +// pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } + if (Math.abs(longitude - Constant.DEFAULT_LNG) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - Constant.DEFAULT_LAT) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + } + } + }, true); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + protected void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + List lightBeans = lightLocalBeanDao.loadAll(); + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (StreetLightLocalBean dataBean : lightBeans) { + if (Math.abs(dataBean.getLongitude() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(dataBean.getLatitude() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021062401; + message.obj = dataBean.getLampId(); + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021062402); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); } @Override - protected void initEvent() { + public void showProgress() { + OtherUtils.showLoadingDialog(context, "处理中,请稍后..."); + } + @Override + public void hideProgress() { + OtherUtils.dismissLoadingDialog(); + } + + @Override + public void obtainControlResult(ActionResultBean resultBean) { + if (resultBean.isSuccess()) { + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); + } + } + + @Override + public void obtainDataFail() { + ToastHelper.showToast("操作失败", ToastHelper.ERROR); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(LightOnMapFragment fragment) { + reference = new WeakReference<>(fragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + LightOnMapFragment fragment = reference.get(); + Context context = fragment.context; + switch (msg.what) { + case 2021062401: + String lampId = (String) msg.obj; + + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_street_light, null); + TextView lightStateView = popupView.findViewById(R.id.lightStateView); + TextView lightAddressView = popupView.findViewById(R.id.lightAddressView); + TextView lightStreetView = popupView.findViewById(R.id.lightStreetView); + TextView lightElecView = popupView.findViewById(R.id.lightElecView); + TextView lightVolView = popupView.findViewById(R.id.lightVolView); + TextView lightTimeView = popupView.findViewById(R.id.lightTimeView); + ImageView lightSwitch = popupView.findViewById(R.id.lightSwitch); + + OtherUtils.showLoadingDialog(context, "路灯详情获取中,请稍后..."); + HttpRequestHelper.doRequest(Constant.LIGHT_DETAIL, lampId, new IHttpRequestListener() { + @Override + public void onSuccess(ResponseBody resultBean) { + OtherUtils.dismissLoadingDialog(); + try { + String string = resultBean.string(); + JSONObject jsonObject = new JSONObject(string); + int code = jsonObject.getInt("code"); + if (code == 200) { + JSONObject dataObject = jsonObject.getJSONObject("data"); + + String statusName = dataObject.getString("statusName"); + lightStateView.setText(statusName); + lightAddressView.setText(dataObject.getString("address")); + lightStreetView.setText(dataObject.getString("streetName")); + lightElecView.setText(String.valueOf(dataObject.getDouble("latestElec"))); + lightVolView.setText(String.valueOf(dataObject.getDouble("latestVol"))); + lightTimeView.setText(dataObject.getString("latestTime")); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 280)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(fragment.mapView); + + lightSwitch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + List lampIds = new ArrayList<>(); + lampIds.add(Long.parseLong(lampId)); + + String controlType; + if (statusName.equals("离线")) { + controlType = "1"; + } else { + controlType = "0"; + } + fragment.controlPresenter.onReadyRetrofitRequest(lampIds, controlType); + } + }); + } else { + ToastHelper.showToast("服务器异常,请重新选点", ToastHelper.ERROR); + } + } catch (JSONException | IOException e) { + ToastHelper.showToast("解析失败,请重新选点", ToastHelper.ERROR); + } + } + + @Override + public void onFailure(Throwable throwable) { + OtherUtils.dismissLoadingDialog(); + ToastHelper.showToast("网络连接失败,请重新选点", ToastHelper.ERROR); + } + }); + break; + case 2021062402: + ToastHelper.showToast("此附近无路灯,请重新选点", ToastHelper.ERROR); + break; + default: + break; + } + } + } + + private void addPictureMarker(List points) { + for (Point point : points) { + Bitmap caseBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.location_verify); + BitmapDrawable caseDrawable = new BitmapDrawable(getResources(), caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(24); + pictureMarker.setHeight(24); + pictureMarker.loadAsync(); + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(point, pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + private void clearPictureMarker() { + if (graphics != null && graphicsOverlays != null) { + graphics.clear(); + graphicsOverlays.clear(); + } + } + + @OnClick({R.id.expandMapView, R.id.minusMapView, R.id.removeToLocalView}) + @Override + public void onClick(View v) { + List lightBeans = lightLocalBeanDao.loadAll(); + switch (v.getId()) { + case R.id.expandMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 0.5); + clearPictureMarker(); + //计算比例尺 + DELTA_L -= 0.0001; + if (DELTA_L < 0) { + DELTA_L = 0; + } +// List minusList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(minusList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List minusList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(minusList); + } + } + }, true); + break; + case R.id.minusMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 2); + clearPictureMarker(); + //计算比例尺 + DELTA_L += 0.0001; + if (DELTA_L > 0.01) { + DELTA_L = Constant.DELTA_LNG_75; + } +// List expandList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(expandList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List expandList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(expandList); + } + } + }, true); + break; + case R.id.removeToLocalView: + clearPictureMarker(); + OtherUtils.showLoadingDialog(context, "定位中,请稍后"); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + mapView.setViewpointCenterAsync(point, 3000); + OtherUtils.dismissLoadingDialog(); + } + } + }, true); + break; + default: + break; + } + } + + @Override + public void obtainLightResult(LightMapBean resultBean) { + if (resultBean.isSuccess()) { + for (LightMapBean.DataBean dataBean : resultBean.getData()) { + StreetLightLocalBean bean = new StreetLightLocalBean(); + bean.setControllerCode(dataBean.getControllerCode()); + bean.setLampCode(dataBean.getLampCode()); + String lampId = dataBean.getLampId(); + bean.setLampId(lampId); + bean.setLatitude(dataBean.getLatitude()); + bean.setDeptId(dataBean.getDeptId()); + bean.setStatusName(dataBean.getStatusName()); + bean.setLampName(dataBean.getLampName()); + bean.setLatestTime(dataBean.getLatestTime()); + bean.setLongitude(dataBean.getLongitude()); + bean.setStatus(dataBean.getStatus()); + + StreetLightLocalBean uniqueBean = daoSession.queryBuilder(StreetLightLocalBean.class) + .where(StreetLightLocalBeanDao.Properties.LampId.eq(lampId)).unique(); + if (uniqueBean == null) { + daoSession.insert(bean); + } else { + daoSession.update(bean); + } + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (mapView != null) { + mapView.dispose(); + } + if (lightMapPresenter != null) { + lightMapPresenter.disposeRetrofitRequest(); + } + if (controlPresenter != null) { + controlPresenter.disposeRetrofitRequest(); + } } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 9bbbdb0..9a50b53 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -69,12 +69,15 @@ public static final double DEFAULT_LAT = 27.759547805536418; public static final double DELTA_LNG_10 = 0.00002536; // 10米范围经度值偏移量(大约) public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) + public static final double DELTA_LNG_75 = 0.00075; + public static final double DELTA_LAT_75 = 0.00075; //单独网络请求接口名 public static final String SHOP_DETAIL = "/shop/merchant/detail?merchantId="; public static final String SHOP_PUNISH_LIST = "/shop/punish/listByMerchant?merchantId="; public static final String SHOP_PUNISH_TYPE = "/shop/punish/statisticByMerchant?merchantId="; public static final String SHOP_MERCHANT_ID = "/shop/merchant/getIdByCode?shopCode="; + public static final String LIGHT_DETAIL = "/lightCr/overview/lampDetail?lampId="; //生产环境 public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java index beb5345..b1a4429 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java @@ -21,6 +21,7 @@ import com.casic.dcms.bean.HighEventBean; import com.casic.dcms.bean.HomePageBean; import com.casic.dcms.bean.LightListBean; +import com.casic.dcms.bean.LightMapBean; import com.casic.dcms.bean.LoginResultBean; import com.casic.dcms.bean.MaintainContentBean; import com.casic.dcms.bean.MaintainRecordBean; @@ -662,7 +663,7 @@ @Query("offset") int offset); /** - * 路灯列表数据 + * 路灯分页列表数据 *

* http://111.198.10.15:11409/lightCr/overview/lampListPage?limit=15&offset=1 */ @@ -672,7 +673,15 @@ @Query("offset") int offset); /** - * 路灯列表数据 + * 路灯全部数据 + *

+ * http://111.198.10.15:11409/lampCr/overview/lampList + */ + @GET("/lightCr/overview/lampList") + Observable obtainLightList(@Header("token") String token); + + /** + * 路灯列详情数据 *

* http://111.198.10.15:11409/lightCr/overview/lampDetail?lampId=1354712301527764999 */ diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java index f6f33c8..6503d64 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java @@ -23,6 +23,7 @@ import com.casic.dcms.bean.HighEventBean; import com.casic.dcms.bean.HomePageBean; import com.casic.dcms.bean.LightListBean; +import com.casic.dcms.bean.LightMapBean; import com.casic.dcms.bean.LoginResultBean; import com.casic.dcms.bean.MaintainContentBean; import com.casic.dcms.bean.MaintainRecordBean; @@ -682,7 +683,7 @@ } /** - * 路灯列表数据 + * 路灯分页列表数据 */ public static Observable getLightListResult(int limit, int offset) { Retrofit retrofit = createRetrofit(); @@ -691,6 +692,15 @@ } /** + * 路灯全部数据 + */ + public static Observable getLightListResult() { + Retrofit retrofit = createRetrofit(); + RetrofitService service = retrofit.create(RetrofitService.class); + return service.obtainLightList(AuthenticationHelper.getToken()); + } + + /** * 路灯详情数据 * 因为返回的数据会出现结构不一致的问题,不能用实体类接收改为ResponseBody接收,然后在手动解析 */ diff --git a/app/src/main/res/layout/fragment_light_map.xml b/app/src/main/res/layout/fragment_light_map.xml index ac8cd4e..e4babdb 100644 --- a/app/src/main/res/layout/fragment_light_map.xml +++ b/app/src/main/res/layout/fragment_light_map.xml @@ -1,5 +1,5 @@ - @@ -8,4 +8,45 @@ android:id="@+id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" /> - \ No newline at end of file + + + + + + + + + + diff --git a/app/src/main/java/com/casic/dcms/base/BaseApplication.java b/app/src/main/java/com/casic/dcms/base/BaseApplication.java index b142196..e8f9ad7 100644 --- a/app/src/main/java/com/casic/dcms/base/BaseApplication.java +++ b/app/src/main/java/com/casic/dcms/base/BaseApplication.java @@ -16,7 +16,7 @@ public class BaseApplication extends Application { - private static DaoSession daoSession; + private static DaoSession daoSession, streetLightDaoSession; private volatile static BaseApplication instance; @Override @@ -33,6 +33,7 @@ //个推初始化 com.igexin.sdk.PushManager.getInstance().initialize(this); initDataBase(); + initStreetLightDataBase(); CrashReport.initCrashReport(this, getString(R.string.bugly_app_id), true); } @@ -60,4 +61,15 @@ public static DaoSession getDaoSession() { return daoSession; } + + private void initStreetLightDataBase() { + DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "StreetLight.db"); + SQLiteDatabase db = helper.getWritableDatabase(); + DaoMaster daoMaster = new DaoMaster(db); + streetLightDaoSession = daoMaster.newSession(); + } + + public static DaoSession getStreetLightDaoSession() { + return streetLightDaoSession; + } } diff --git a/app/src/main/java/com/casic/dcms/bean/LightListBean.java b/app/src/main/java/com/casic/dcms/bean/LightListBean.java index baf53f4..7c59a15 100644 --- a/app/src/main/java/com/casic/dcms/bean/LightListBean.java +++ b/app/src/main/java/com/casic/dcms/bean/LightListBean.java @@ -63,18 +63,6 @@ } public static class RowsBean { - /** - * controllerCode : 732020010001 - * lampCode : ld-001-test - * lampId : 1354712301393547265 - * latitude : 27.754315 - * deptId : 1344118138553909250 - * statusName : 离线 - * lampName : 测试路灯001 - * latestTime : 2021-05-28 01:59:10 - * longitude : 116.0714497 - * status : 4 - */ private String controllerCode; private String lampCode; diff --git a/app/src/main/java/com/casic/dcms/bean/LightMapBean.java b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java new file mode 100644 index 0000000..15d574d --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/LightMapBean.java @@ -0,0 +1,137 @@ +package com.casic.dcms.bean; + +import java.util.List; + +public class LightMapBean { + + private int code; + private String message; + private boolean success; + private List data; + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataBean { + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + public String getControllerCode() { + return controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java new file mode 100644 index 0000000..bce8a6c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/StreetLightLocalBean.java @@ -0,0 +1,134 @@ +package com.casic.dcms.bean; + +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.annotation.Id; + +/** + * 路灯数据本地持久化实体类 + */ +@Entity +public class StreetLightLocalBean { + @Id(autoincrement = true) + private Long id;//主键ID + + private String controllerCode; + private String lampCode; + private String lampId; + private double latitude; + private String deptId; + private String statusName; + private String lampName; + private String latestTime; + private double longitude; + private String status; + + @Generated(hash = 1610766011) + public StreetLightLocalBean(Long id, String controllerCode, String lampCode, + String lampId, double latitude, String deptId, String statusName, + String lampName, String latestTime, double longitude, String status) { + this.id = id; + this.controllerCode = controllerCode; + this.lampCode = lampCode; + this.lampId = lampId; + this.latitude = latitude; + this.deptId = deptId; + this.statusName = statusName; + this.lampName = lampName; + this.latestTime = latestTime; + this.longitude = longitude; + this.status = status; + } + + @Generated(hash = 6875869) + public StreetLightLocalBean() { + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getControllerCode() { + return this.controllerCode; + } + + public void setControllerCode(String controllerCode) { + this.controllerCode = controllerCode; + } + + public String getLampCode() { + return this.lampCode; + } + + public void setLampCode(String lampCode) { + this.lampCode = lampCode; + } + + public String getLampId() { + return this.lampId; + } + + public void setLampId(String lampId) { + this.lampId = lampId; + } + + public double getLatitude() { + return this.latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getDeptId() { + return this.deptId; + } + + public void setDeptId(String deptId) { + this.deptId = deptId; + } + + public String getStatusName() { + return this.statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getLampName() { + return this.lampName; + } + + public void setLampName(String lampName) { + this.lampName = lampName; + } + + public String getLatestTime() { + return this.latestTime; + } + + public void setLatestTime(String latestTime) { + this.latestTime = latestTime; + } + + public double getLongitude() { + return this.longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public String getStatus() { + return this.status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java index ba0fc72..daadd2e 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoMaster.java @@ -22,11 +22,13 @@ /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { NoticeBeanDao.createTable(db, ifNotExists); + StreetLightLocalBeanDao.createTable(db, ifNotExists); } /** Drops underlying database table using DAOs. */ public static void dropAllTables(Database db, boolean ifExists) { NoticeBeanDao.dropTable(db, ifExists); + StreetLightLocalBeanDao.dropTable(db, ifExists); } /** @@ -46,6 +48,7 @@ public DaoMaster(Database db) { super(db, SCHEMA_VERSION); registerDaoClass(NoticeBeanDao.class); + registerDaoClass(StreetLightLocalBeanDao.class); } public DaoSession newSession() { diff --git a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java index 9d00d6e..73c72cc 100644 --- a/app/src/main/java/com/casic/dcms/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/dcms/greendao/DaoSession.java @@ -9,8 +9,10 @@ import org.greenrobot.greendao.internal.DaoConfig; import com.casic.dcms.bean.NoticeBean; +import com.casic.dcms.bean.StreetLightLocalBean; import com.casic.dcms.greendao.NoticeBeanDao; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. @@ -22,8 +24,10 @@ public class DaoSession extends AbstractDaoSession { private final DaoConfig noticeBeanDaoConfig; + private final DaoConfig streetLightLocalBeanDaoConfig; private final NoticeBeanDao noticeBeanDao; + private final StreetLightLocalBeanDao streetLightLocalBeanDao; public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> daoConfigMap) { @@ -32,17 +36,27 @@ noticeBeanDaoConfig = daoConfigMap.get(NoticeBeanDao.class).clone(); noticeBeanDaoConfig.initIdentityScope(type); + streetLightLocalBeanDaoConfig = daoConfigMap.get(StreetLightLocalBeanDao.class).clone(); + streetLightLocalBeanDaoConfig.initIdentityScope(type); + noticeBeanDao = new NoticeBeanDao(noticeBeanDaoConfig, this); + streetLightLocalBeanDao = new StreetLightLocalBeanDao(streetLightLocalBeanDaoConfig, this); registerDao(NoticeBean.class, noticeBeanDao); + registerDao(StreetLightLocalBean.class, streetLightLocalBeanDao); } public void clear() { noticeBeanDaoConfig.clearIdentityScope(); + streetLightLocalBeanDaoConfig.clearIdentityScope(); } public NoticeBeanDao getNoticeBeanDao() { return noticeBeanDao; } + public StreetLightLocalBeanDao getStreetLightLocalBeanDao() { + return streetLightLocalBeanDao; + } + } diff --git a/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java new file mode 100644 index 0000000..02f8bb6 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/greendao/StreetLightLocalBeanDao.java @@ -0,0 +1,239 @@ +package com.casic.dcms.greendao; + +import android.database.Cursor; +import android.database.sqlite.SQLiteStatement; + +import org.greenrobot.greendao.AbstractDao; +import org.greenrobot.greendao.Property; +import org.greenrobot.greendao.internal.DaoConfig; +import org.greenrobot.greendao.database.Database; +import org.greenrobot.greendao.database.DatabaseStatement; + +import com.casic.dcms.bean.StreetLightLocalBean; + +// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. +/** + * DAO for table "STREET_LIGHT_LOCAL_BEAN". +*/ +public class StreetLightLocalBeanDao extends AbstractDao { + + public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN"; + + /** + * Properties of entity StreetLightLocalBean.
+ * Can be used for QueryBuilder and for referencing column names. + */ + public static class Properties { + public final static Property Id = new Property(0, Long.class, "id", true, "_id"); + public final static Property ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE"); + public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE"); + public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID"); + public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE"); + public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID"); + public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME"); + public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME"); + public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME"); + public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE"); + public final static Property Status = new Property(10, String.class, "status", false, "STATUS"); + } + + + public StreetLightLocalBeanDao(DaoConfig config) { + super(config); + } + + public StreetLightLocalBeanDao(DaoConfig config, DaoSession daoSession) { + super(config, daoSession); + } + + /** Creates the underlying database table. */ + public static void createTable(Database db, boolean ifNotExists) { + String constraint = ifNotExists? "IF NOT EXISTS ": ""; + db.execSQL("CREATE TABLE " + constraint + "\"STREET_LIGHT_LOCAL_BEAN\" (" + // + "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id + "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode + "\"LAMP_CODE\" TEXT," + // 2: lampCode + "\"LAMP_ID\" TEXT," + // 3: lampId + "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude + "\"DEPT_ID\" TEXT," + // 5: deptId + "\"STATUS_NAME\" TEXT," + // 6: statusName + "\"LAMP_NAME\" TEXT," + // 7: lampName + "\"LATEST_TIME\" TEXT," + // 8: latestTime + "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude + "\"STATUS\" TEXT);"); // 10: status + } + + /** Drops the underlying database table. */ + public static void dropTable(Database db, boolean ifExists) { + String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"STREET_LIGHT_LOCAL_BEAN\""; + db.execSQL(sql); + } + + @Override + protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) { + stmt.clearBindings(); + + Long id = entity.getId(); + if (id != null) { + stmt.bindLong(1, id); + } + + String controllerCode = entity.getControllerCode(); + if (controllerCode != null) { + stmt.bindString(2, controllerCode); + } + + String lampCode = entity.getLampCode(); + if (lampCode != null) { + stmt.bindString(3, lampCode); + } + + String lampId = entity.getLampId(); + if (lampId != null) { + stmt.bindString(4, lampId); + } + stmt.bindDouble(5, entity.getLatitude()); + + String deptId = entity.getDeptId(); + if (deptId != null) { + stmt.bindString(6, deptId); + } + + String statusName = entity.getStatusName(); + if (statusName != null) { + stmt.bindString(7, statusName); + } + + String lampName = entity.getLampName(); + if (lampName != null) { + stmt.bindString(8, lampName); + } + + String latestTime = entity.getLatestTime(); + if (latestTime != null) { + stmt.bindString(9, latestTime); + } + stmt.bindDouble(10, entity.getLongitude()); + + String status = entity.getStatus(); + if (status != null) { + stmt.bindString(11, status); + } + } + + @Override + public Long readKey(Cursor cursor, int offset) { + return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); + } + + @Override + public StreetLightLocalBean readEntity(Cursor cursor, int offset) { + StreetLightLocalBean entity = new StreetLightLocalBean( // + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId + cursor.getDouble(offset + 4), // latitude + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime + cursor.getDouble(offset + 9), // longitude + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status + ); + return entity; + } + + @Override + public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) { + entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); + entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); + entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); + entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); + entity.setLatitude(cursor.getDouble(offset + 4)); + entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); + entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); + entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); + entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); + entity.setLongitude(cursor.getDouble(offset + 9)); + entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10)); + } + + @Override + protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) { + entity.setId(rowId); + return rowId; + } + + @Override + public Long getKey(StreetLightLocalBean entity) { + if(entity != null) { + return entity.getId(); + } else { + return null; + } + } + + @Override + public boolean hasKey(StreetLightLocalBean entity) { + return entity.getId() != null; + } + + @Override + protected final boolean isEntityUpdateable() { + return true; + } + +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java new file mode 100644 index 0000000..ed1f25a --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/ILightMapModel.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.model; + +import rx.Subscription; + +public interface ILightMapModel { + Subscription sendRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java new file mode 100644 index 0000000..7a2fc5c --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/model/LightMapModelImpl.java @@ -0,0 +1,50 @@ +package com.casic.dcms.mvp.model; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.utils.retrofit.RetrofitServiceManager; + +import rx.Observable; +import rx.Observer; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; + +public class LightMapModelImpl implements ILightMapModel { + + private OnGetListListener listener; + + public LightMapModelImpl(OnGetListListener listListener) { + this.listener = listListener; + } + + public interface OnGetListListener { + void onSuccess(LightMapBean resultBean); + + void onFailure(Throwable throwable); + } + + @Override + public Subscription sendRetrofitRequest() { + Observable observable = RetrofitServiceManager.getLightListResult(); + return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer() { + @Override + public void onCompleted() { + + } + + @Override + public void onError(Throwable e) { + if (e.getCause() != null) { + listener.onFailure(e); + } + } + + @Override + public void onNext(LightMapBean resultBean) { + if (resultBean != null) { + listener.onSuccess(resultBean); + } + } + }); + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java new file mode 100644 index 0000000..c7c1378 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/ILightMapPresenter.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.presenter; + +public interface ILightMapPresenter { + void onReadyRetrofitRequest(); + + void disposeRetrofitRequest(); +} diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java index 7baa33c..32dc019 100644 --- a/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightListPresenterImpl.java @@ -10,8 +10,8 @@ private ILightListView view; private LightListModelImpl actionModel; - public LightListPresenterImpl(ILightListView caseListView) { - this.view = caseListView; + public LightListPresenterImpl(ILightListView lightListView) { + this.view = lightListView; actionModel = new LightListModelImpl(this); } diff --git a/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java new file mode 100644 index 0000000..878aaa8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/presenter/LightMapPresenterImpl.java @@ -0,0 +1,37 @@ +package com.casic.dcms.mvp.presenter; + +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.mvp.BasePresenter; +import com.casic.dcms.mvp.model.LightMapModelImpl; +import com.casic.dcms.mvp.view.ILightMapView; + +public class LightMapPresenterImpl extends BasePresenter implements ILightMapPresenter, LightMapModelImpl.OnGetListListener { + + private ILightMapView view; + private LightMapModelImpl actionModel; + + public LightMapPresenterImpl(ILightMapView lightMapView) { + this.view = lightMapView; + actionModel = new LightMapModelImpl(this); + } + + @Override + public void onReadyRetrofitRequest() { + addSubscription(actionModel.sendRetrofitRequest()); + } + + @Override + public void disposeRetrofitRequest() { + unSubscription(); + } + + @Override + public void onSuccess(LightMapBean resultBean) { + view.obtainLightResult(resultBean); + } + + @Override + public void onFailure(Throwable throwable) { + + } +} diff --git a/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java new file mode 100644 index 0000000..2f39966 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/mvp/view/ILightMapView.java @@ -0,0 +1,7 @@ +package com.casic.dcms.mvp.view; + +import com.casic.dcms.bean.LightMapBean; + +public interface ILightMapView { + void obtainLightResult(LightMapBean resultBean); +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index ac9f1bf..aa9fa10 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -135,7 +135,7 @@ // }, true); //TODO 暂时先用默认点代替定位点 - Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4490)); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); addPictureMarker(point); mapView.setViewpointCenterAsync(point, 2800);//标注到指定经纬度并放大地图显示 @@ -465,7 +465,7 @@ double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); addPictureMarker(point); - mapView.setViewpointCenterAsync((point), 2800); + mapView.setViewpointCenterAsync(point, 2800); OtherUtils.dismissLoadingDialog(); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java index 902e0af..0a7cb19 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/HomePageFragment.java @@ -184,7 +184,7 @@ @Override public void obtainDataFail() { - ToastHelper.showToast("获取用户信息超时", ToastHelper.ERROR); + ToastHelper.showToast("获取用户信息失败,请重试", ToastHelper.ERROR); } @Override diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java index b1f2ebb..3b8dfd2 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnListFragment.java @@ -53,8 +53,6 @@ private boolean isRefresh, isLoadMore = false; private static WeakReferenceHandler weakReferenceHandler; private LightControlPresenterImpl controlPresenter; - private long lampId; - private int adapterPosition; @Override protected int initLayoutView() { @@ -92,7 +90,7 @@ public void onLoadMore(@NonNull final RefreshLayout refreshLayout) { isLoadMore = true; pageIndex++; - lightListPresenter.onReadyRetrofitRequest(Constant.PAGE_LIMIT, pageIndex); + lightListPresenter.onReadyRetrofitRequest(2 * Constant.PAGE_LIMIT, pageIndex); } }); } @@ -162,11 +160,9 @@ @Override public void onClick(int position) { LightListBean.DataBean.RowsBean rowsBean = fragment.dataBeans.get(position); - fragment.lampId = Long.parseLong(rowsBean.getLampId()); - fragment.adapterPosition = position; List lampIds = new ArrayList<>(); - lampIds.add(fragment.lampId); + lampIds.add(Long.parseLong(rowsBean.getLampId())); String statusName = rowsBean.getStatusName(); String controlType; @@ -202,7 +198,7 @@ public void obtainControlResult(ActionResultBean resultBean) { if (resultBean.isSuccess()) { //开灯指令发下去之后,虽然返回成功,但仅仅表示app发送指令到后台成功,但是开没开灯无法确定,所以,只能延迟几秒再刷新列表 - Log.d(TAG, "APP发送指令到后台成功,3s后即将刷新列表"); + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); weakReferenceHandler.sendEmptyMessageDelayed(20210624, 3000); } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java index 5494f1b..a7bee54 100644 --- a/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java +++ b/app/src/main/java/com/casic/dcms/ui/fragment/LightOnMapFragment.java @@ -1,9 +1,88 @@ package com.casic.dcms.ui.fragment; -import com.casic.dcms.R; -import com.casic.dcms.base.BaseFragment; +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.location.Location; +import android.os.Handler; +import android.os.Message; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; -public class LightOnMapFragment extends BaseFragment { +import androidx.annotation.NonNull; + +import com.amap.api.location.AMapLocation; +import com.casic.dcms.R; +import com.casic.dcms.base.BaseApplication; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.ActionResultBean; +import com.casic.dcms.bean.LightMapBean; +import com.casic.dcms.bean.StreetLightLocalBean; +import com.casic.dcms.greendao.DaoSession; +import com.casic.dcms.greendao.StreetLightLocalBeanDao; +import com.casic.dcms.mvp.presenter.LightControlPresenterImpl; +import com.casic.dcms.mvp.presenter.LightMapPresenterImpl; +import com.casic.dcms.mvp.view.ILightControlView; +import com.casic.dcms.mvp.view.ILightMapView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.HttpRequestHelper; +import com.casic.dcms.utils.LocationHelper; +import com.casic.dcms.utils.OtherUtils; +import com.casic.dcms.utils.ToastHelper; +import com.casic.dcms.utils.callback.IHttpRequestListener; +import com.casic.dcms.utils.callback.ILocationListener; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.geometry.SpatialReference; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; +import butterknife.OnClick; +import okhttp3.ResponseBody; + +public class LightOnMapFragment extends BaseFragment implements View.OnClickListener, ILightMapView, + ILightControlView { + + private static final String TAG = "LightOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private Context context; + private LightMapPresenterImpl lightMapPresenter; + private DaoSession daoSession; + private ListenableList graphicsOverlays; + private ListenableList graphics; + private double DELTA_L = Constant.DELTA_LNG_75; + private StreetLightLocalBeanDao lightLocalBeanDao; + private WeakReferenceHandler weakReferenceHandler; + private LightControlPresenterImpl controlPresenter; @Override protected int initLayoutView() { @@ -12,16 +91,409 @@ @Override protected void setupTopBarLayout() { - + context = getContext(); + daoSession = BaseApplication.getStreetLightDaoSession(); + lightLocalBeanDao = daoSession.getStreetLightLocalBeanDao(); + lightMapPresenter = new LightMapPresenterImpl(this); + weakReferenceHandler = new WeakReferenceHandler(this); + controlPresenter = new LightControlPresenterImpl(this); } @Override protected void initData() { + lightMapPresenter.onReadyRetrofitRequest(); + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(3000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + Point point = new Point(Constant.DEFAULT_LNG, Constant.DEFAULT_LAT, SpatialReference.create(4326)); + mapView.setViewpointCenterAsync(point, 3000);//标注到指定经纬度并放大地图显示 + mapView.setMap(arcGISMap); + + //Marker相关Layer + graphicsOverlays = mapView.getGraphicsOverlays(); + //显示定位点附近路灯 + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + + List streetLightBeans = lightLocalBeanDao.loadAll(); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : streetLightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); +// if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && +// Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { +// pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } + if (Math.abs(longitude - Constant.DEFAULT_LNG) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - Constant.DEFAULT_LAT) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + } + } + }, true); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + protected void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + List lightBeans = lightLocalBeanDao.loadAll(); + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (StreetLightLocalBean dataBean : lightBeans) { + if (Math.abs(dataBean.getLongitude() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(dataBean.getLatitude() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021062401; + message.obj = dataBean.getLampId(); + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021062402); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); } @Override - protected void initEvent() { + public void showProgress() { + OtherUtils.showLoadingDialog(context, "处理中,请稍后..."); + } + @Override + public void hideProgress() { + OtherUtils.dismissLoadingDialog(); + } + + @Override + public void obtainControlResult(ActionResultBean resultBean) { + if (resultBean.isSuccess()) { + ToastHelper.showToast("指令发送成功", ToastHelper.SUCCESS); + } + } + + @Override + public void obtainDataFail() { + ToastHelper.showToast("操作失败", ToastHelper.ERROR); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(LightOnMapFragment fragment) { + reference = new WeakReference<>(fragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + LightOnMapFragment fragment = reference.get(); + Context context = fragment.context; + switch (msg.what) { + case 2021062401: + String lampId = (String) msg.obj; + + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_street_light, null); + TextView lightStateView = popupView.findViewById(R.id.lightStateView); + TextView lightAddressView = popupView.findViewById(R.id.lightAddressView); + TextView lightStreetView = popupView.findViewById(R.id.lightStreetView); + TextView lightElecView = popupView.findViewById(R.id.lightElecView); + TextView lightVolView = popupView.findViewById(R.id.lightVolView); + TextView lightTimeView = popupView.findViewById(R.id.lightTimeView); + ImageView lightSwitch = popupView.findViewById(R.id.lightSwitch); + + OtherUtils.showLoadingDialog(context, "路灯详情获取中,请稍后..."); + HttpRequestHelper.doRequest(Constant.LIGHT_DETAIL, lampId, new IHttpRequestListener() { + @Override + public void onSuccess(ResponseBody resultBean) { + OtherUtils.dismissLoadingDialog(); + try { + String string = resultBean.string(); + JSONObject jsonObject = new JSONObject(string); + int code = jsonObject.getInt("code"); + if (code == 200) { + JSONObject dataObject = jsonObject.getJSONObject("data"); + + String statusName = dataObject.getString("statusName"); + lightStateView.setText(statusName); + lightAddressView.setText(dataObject.getString("address")); + lightStreetView.setText(dataObject.getString("streetName")); + lightElecView.setText(String.valueOf(dataObject.getDouble("latestElec"))); + lightVolView.setText(String.valueOf(dataObject.getDouble("latestVol"))); + lightTimeView.setText(dataObject.getString("latestTime")); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 280)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(fragment.mapView); + + lightSwitch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + List lampIds = new ArrayList<>(); + lampIds.add(Long.parseLong(lampId)); + + String controlType; + if (statusName.equals("离线")) { + controlType = "1"; + } else { + controlType = "0"; + } + fragment.controlPresenter.onReadyRetrofitRequest(lampIds, controlType); + } + }); + } else { + ToastHelper.showToast("服务器异常,请重新选点", ToastHelper.ERROR); + } + } catch (JSONException | IOException e) { + ToastHelper.showToast("解析失败,请重新选点", ToastHelper.ERROR); + } + } + + @Override + public void onFailure(Throwable throwable) { + OtherUtils.dismissLoadingDialog(); + ToastHelper.showToast("网络连接失败,请重新选点", ToastHelper.ERROR); + } + }); + break; + case 2021062402: + ToastHelper.showToast("此附近无路灯,请重新选点", ToastHelper.ERROR); + break; + default: + break; + } + } + } + + private void addPictureMarker(List points) { + for (Point point : points) { + Bitmap caseBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.location_verify); + BitmapDrawable caseDrawable = new BitmapDrawable(getResources(), caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(24); + pictureMarker.setHeight(24); + pictureMarker.loadAsync(); + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(point, pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + private void clearPictureMarker() { + if (graphics != null && graphicsOverlays != null) { + graphics.clear(); + graphicsOverlays.clear(); + } + } + + @OnClick({R.id.expandMapView, R.id.minusMapView, R.id.removeToLocalView}) + @Override + public void onClick(View v) { + List lightBeans = lightLocalBeanDao.loadAll(); + switch (v.getId()) { + case R.id.expandMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 0.5); + clearPictureMarker(); + //计算比例尺 + DELTA_L -= 0.0001; + if (DELTA_L < 0) { + DELTA_L = 0; + } +// List minusList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(minusList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List minusList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + minusList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(minusList); + } + } + }, true); + break; + case R.id.minusMapView: + mapView.setViewpointScaleAsync(mapView.getMapScale() * 2); + clearPictureMarker(); + //计算比例尺 + DELTA_L += 0.0001; + if (DELTA_L > 0.01) { + DELTA_L = Constant.DELTA_LNG_75; + } +// List expandList = new ArrayList<>(); +// for (StreetLightLocalBean bean : lightBeans) { +// double longitude = bean.getLongitude(); +// double latitude = bean.getLatitude(); +// if (Math.abs(longitude - Constant.DEFAULT_LNG) > DELTA_L || +// Math.abs(latitude - Constant.DEFAULT_LAT) > DELTA_L) { +// continue; +// } +// expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); +// } +// addPictureMarker(expandList); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List expandList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= DELTA_L && + Math.abs(latitude - gcjToWgs[1]) <= DELTA_L) { + expandList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(expandList); + } + } + }, true); + break; + case R.id.removeToLocalView: + clearPictureMarker(); + OtherUtils.showLoadingDialog(context, "定位中,请稍后"); + LocationHelper.obtainCurrentLocationByGD(context, new ILocationListener() { + @Override + public void onLocationGet(Location location) { + + } + + @Override + public void onAMapLocationGet(AMapLocation aMapLocation) { + if (aMapLocation != null) { + double[] gcjToWgs = LocationHelper.gcjToWgs(aMapLocation.getLongitude(), aMapLocation.getLatitude()); + Point point = new Point(gcjToWgs[0], gcjToWgs[1], SpatialReference.create(4326)); + List pointList = new ArrayList<>(); + for (StreetLightLocalBean bean : lightBeans) { + double longitude = bean.getLongitude(); + double latitude = bean.getLatitude(); + if (Math.abs(longitude - gcjToWgs[0]) <= Constant.DELTA_LNG_75 && + Math.abs(latitude - gcjToWgs[1]) <= Constant.DELTA_LAT_75) { + pointList.add(new Point(longitude, latitude, SpatialReference.create(4326))); + } + } + addPictureMarker(pointList); + mapView.setViewpointCenterAsync(point, 3000); + OtherUtils.dismissLoadingDialog(); + } + } + }, true); + break; + default: + break; + } + } + + @Override + public void obtainLightResult(LightMapBean resultBean) { + if (resultBean.isSuccess()) { + for (LightMapBean.DataBean dataBean : resultBean.getData()) { + StreetLightLocalBean bean = new StreetLightLocalBean(); + bean.setControllerCode(dataBean.getControllerCode()); + bean.setLampCode(dataBean.getLampCode()); + String lampId = dataBean.getLampId(); + bean.setLampId(lampId); + bean.setLatitude(dataBean.getLatitude()); + bean.setDeptId(dataBean.getDeptId()); + bean.setStatusName(dataBean.getStatusName()); + bean.setLampName(dataBean.getLampName()); + bean.setLatestTime(dataBean.getLatestTime()); + bean.setLongitude(dataBean.getLongitude()); + bean.setStatus(dataBean.getStatus()); + + StreetLightLocalBean uniqueBean = daoSession.queryBuilder(StreetLightLocalBean.class) + .where(StreetLightLocalBeanDao.Properties.LampId.eq(lampId)).unique(); + if (uniqueBean == null) { + daoSession.insert(bean); + } else { + daoSession.update(bean); + } + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (mapView != null) { + mapView.dispose(); + } + if (lightMapPresenter != null) { + lightMapPresenter.disposeRetrofitRequest(); + } + if (controlPresenter != null) { + controlPresenter.disposeRetrofitRequest(); + } } } diff --git a/app/src/main/java/com/casic/dcms/utils/Constant.java b/app/src/main/java/com/casic/dcms/utils/Constant.java index 9bbbdb0..9a50b53 100644 --- a/app/src/main/java/com/casic/dcms/utils/Constant.java +++ b/app/src/main/java/com/casic/dcms/utils/Constant.java @@ -69,12 +69,15 @@ public static final double DEFAULT_LAT = 27.759547805536418; public static final double DELTA_LNG_10 = 0.00002536; // 10米范围经度值偏移量(大约) public static final double DELTA_LAT_10 = 0.00002256;// 10米范围纬度值偏移量(大约) + public static final double DELTA_LNG_75 = 0.00075; + public static final double DELTA_LAT_75 = 0.00075; //单独网络请求接口名 public static final String SHOP_DETAIL = "/shop/merchant/detail?merchantId="; public static final String SHOP_PUNISH_LIST = "/shop/punish/listByMerchant?merchantId="; public static final String SHOP_PUNISH_TYPE = "/shop/punish/statisticByMerchant?merchantId="; public static final String SHOP_MERCHANT_ID = "/shop/merchant/getIdByCode?shopCode="; + public static final String LIGHT_DETAIL = "/lightCr/overview/lampDetail?lampId="; //生产环境 public static final String BASE_MAP_SERVICE_URL = "http://111.198.10.15:13002/arcgis/rest/services/crdt/MapServer";//崇仁城管地图底图 diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java index beb5345..b1a4429 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitService.java @@ -21,6 +21,7 @@ import com.casic.dcms.bean.HighEventBean; import com.casic.dcms.bean.HomePageBean; import com.casic.dcms.bean.LightListBean; +import com.casic.dcms.bean.LightMapBean; import com.casic.dcms.bean.LoginResultBean; import com.casic.dcms.bean.MaintainContentBean; import com.casic.dcms.bean.MaintainRecordBean; @@ -662,7 +663,7 @@ @Query("offset") int offset); /** - * 路灯列表数据 + * 路灯分页列表数据 *

* http://111.198.10.15:11409/lightCr/overview/lampListPage?limit=15&offset=1 */ @@ -672,7 +673,15 @@ @Query("offset") int offset); /** - * 路灯列表数据 + * 路灯全部数据 + *

+ * http://111.198.10.15:11409/lampCr/overview/lampList + */ + @GET("/lightCr/overview/lampList") + Observable obtainLightList(@Header("token") String token); + + /** + * 路灯列详情数据 *

* http://111.198.10.15:11409/lightCr/overview/lampDetail?lampId=1354712301527764999 */ diff --git a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java index f6f33c8..6503d64 100644 --- a/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java +++ b/app/src/main/java/com/casic/dcms/utils/retrofit/RetrofitServiceManager.java @@ -23,6 +23,7 @@ import com.casic.dcms.bean.HighEventBean; import com.casic.dcms.bean.HomePageBean; import com.casic.dcms.bean.LightListBean; +import com.casic.dcms.bean.LightMapBean; import com.casic.dcms.bean.LoginResultBean; import com.casic.dcms.bean.MaintainContentBean; import com.casic.dcms.bean.MaintainRecordBean; @@ -682,7 +683,7 @@ } /** - * 路灯列表数据 + * 路灯分页列表数据 */ public static Observable getLightListResult(int limit, int offset) { Retrofit retrofit = createRetrofit(); @@ -691,6 +692,15 @@ } /** + * 路灯全部数据 + */ + public static Observable getLightListResult() { + Retrofit retrofit = createRetrofit(); + RetrofitService service = retrofit.create(RetrofitService.class); + return service.obtainLightList(AuthenticationHelper.getToken()); + } + + /** * 路灯详情数据 * 因为返回的数据会出现结构不一致的问题,不能用实体类接收改为ResponseBody接收,然后在手动解析 */ diff --git a/app/src/main/res/layout/fragment_light_map.xml b/app/src/main/res/layout/fragment_light_map.xml index ac8cd4e..e4babdb 100644 --- a/app/src/main/res/layout/fragment_light_map.xml +++ b/app/src/main/res/layout/fragment_light_map.xml @@ -1,5 +1,5 @@ - @@ -8,4 +8,45 @@ android:id="@+id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" /> - \ No newline at end of file + + + + + + + + + + diff --git a/app/src/main/res/layout/popu_street_light.xml b/app/src/main/res/layout/popu_street_light.xml new file mode 100644 index 0000000..d1e77dc --- /dev/null +++ b/app/src/main/res/layout/popu_street_light.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file