diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
index 30a70c5..127c247 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -372,6 +372,26 @@
return api.obtainDeviceType(AuthenticationHelper.token!!)
}
+ /**
+ * 获取设备模型
+ */
+ suspend fun obtainDeviceModel(deviceType: String): String {
+ return api.obtainDeviceModel(AuthenticationHelper.token!!, deviceType)
+ }
+
+ /**
+ * 编辑更新设备信息
+ */
+ suspend fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ): String {
+ return api.updateDeviceDetail(
+ AuthenticationHelper.token!!,
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ }
+
// /**
// * 获取工单详情
// */
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
index 30a70c5..127c247 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -372,6 +372,26 @@
return api.obtainDeviceType(AuthenticationHelper.token!!)
}
+ /**
+ * 获取设备模型
+ */
+ suspend fun obtainDeviceModel(deviceType: String): String {
+ return api.obtainDeviceModel(AuthenticationHelper.token!!, deviceType)
+ }
+
+ /**
+ * 编辑更新设备信息
+ */
+ suspend fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ): String {
+ return api.updateDeviceDetail(
+ AuthenticationHelper.token!!,
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ }
+
// /**
// * 获取工单详情
// */
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
new file mode 100644
index 0000000..5275d0e
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
@@ -0,0 +1,38 @@
+package com.casic.app.smartwell.sanxi.view
+
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import kotlinx.android.synthetic.main.activity_device_list_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class DeviceListDetailActivity : BaseActivity() {
+
+ override fun initLayoutView(): Int = R.layout.activity_device_list_detail
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "设备详情"
+ }
+
+ override fun initData() {
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ val deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ if (deviceBean != null) {
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.text = deviceBean.wellCode
+ installDateView.text = deviceBean.installDate
+ }
+ }
+
+ override fun initEvent() {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
index 30a70c5..127c247 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -372,6 +372,26 @@
return api.obtainDeviceType(AuthenticationHelper.token!!)
}
+ /**
+ * 获取设备模型
+ */
+ suspend fun obtainDeviceModel(deviceType: String): String {
+ return api.obtainDeviceModel(AuthenticationHelper.token!!, deviceType)
+ }
+
+ /**
+ * 编辑更新设备信息
+ */
+ suspend fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ): String {
+ return api.updateDeviceDetail(
+ AuthenticationHelper.token!!,
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ }
+
// /**
// * 获取工单详情
// */
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
new file mode 100644
index 0000000..5275d0e
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
@@ -0,0 +1,38 @@
+package com.casic.app.smartwell.sanxi.view
+
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import kotlinx.android.synthetic.main.activity_device_list_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class DeviceListDetailActivity : BaseActivity() {
+
+ override fun initLayoutView(): Int = R.layout.activity_device_list_detail
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "设备详情"
+ }
+
+ override fun initData() {
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ val deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ if (deviceBean != null) {
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.text = deviceBean.wellCode
+ installDateView.text = deviceBean.installDate
+ }
+ }
+
+ override fun initEvent() {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
index 40d95ba..6b92bb2 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
@@ -12,8 +12,10 @@
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.adapter.DeviceListAdapter
import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.showEmptyPage
+import com.casic.app.smartwell.sanxi.extensions.toJson
import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
import com.casic.app.smartwell.sanxi.model.OwnerShipModel
import com.casic.app.smartwell.sanxi.utils.WeakReferenceHandler
@@ -208,7 +210,7 @@
deviceListAdapter.setOnItemClickListener(object :
DeviceListAdapter.OnItemClickListener {
override fun onClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onHistoryClicked(position: Int) {
@@ -216,11 +218,11 @@
}
override fun onEditClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onWellDetailClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].wellId)
}
})
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
index 30a70c5..127c247 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -372,6 +372,26 @@
return api.obtainDeviceType(AuthenticationHelper.token!!)
}
+ /**
+ * 获取设备模型
+ */
+ suspend fun obtainDeviceModel(deviceType: String): String {
+ return api.obtainDeviceModel(AuthenticationHelper.token!!, deviceType)
+ }
+
+ /**
+ * 编辑更新设备信息
+ */
+ suspend fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ): String {
+ return api.updateDeviceDetail(
+ AuthenticationHelper.token!!,
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ }
+
// /**
// * 获取工单详情
// */
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
new file mode 100644
index 0000000..5275d0e
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
@@ -0,0 +1,38 @@
+package com.casic.app.smartwell.sanxi.view
+
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import kotlinx.android.synthetic.main.activity_device_list_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class DeviceListDetailActivity : BaseActivity() {
+
+ override fun initLayoutView(): Int = R.layout.activity_device_list_detail
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "设备详情"
+ }
+
+ override fun initData() {
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ val deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ if (deviceBean != null) {
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.text = deviceBean.wellCode
+ installDateView.text = deviceBean.installDate
+ }
+ }
+
+ override fun initEvent() {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
index 40d95ba..6b92bb2 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
@@ -12,8 +12,10 @@
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.adapter.DeviceListAdapter
import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.showEmptyPage
+import com.casic.app.smartwell.sanxi.extensions.toJson
import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
import com.casic.app.smartwell.sanxi.model.OwnerShipModel
import com.casic.app.smartwell.sanxi.utils.WeakReferenceHandler
@@ -208,7 +210,7 @@
deviceListAdapter.setOnItemClickListener(object :
DeviceListAdapter.OnItemClickListener {
override fun onClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onHistoryClicked(position: Int) {
@@ -216,11 +218,11 @@
}
override fun onEditClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onWellDetailClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].wellId)
}
})
}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
new file mode 100644
index 0000000..9ed5aad
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
@@ -0,0 +1,129 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.util.Log
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.convertColor
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.extensions.timestampToDate
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.DialogHelper
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.vm.DeviceViewModel
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.jzxiang.pickerview.TimePickerDialog
+import com.jzxiang.pickerview.data.Type
+import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet
+import kotlinx.android.synthetic.main.activity_edit_device.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class EditDeviceActivity : BaseActivity() {
+
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceBean: DeviceListPageModel.DataBean.RowsBean
+ private lateinit var deviceType: String
+ private var modelId = ""
+
+ override fun initLayoutView(): Int = R.layout.activity_edit_device
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "编辑设备信息"
+ }
+
+ override fun initData() {
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.setText(deviceBean.wellCode)
+ installDateView.text = deviceBean.installDate
+
+ this.deviceType = deviceBean.deviceType
+ this.modelId = deviceBean.modelId
+ }
+
+ override fun initEvent() {
+ deviceCodeView.setOnClickListener {
+ "设备编号无法编辑".show()
+ }
+
+ deviceTypeView.setOnClickListener {
+ "设备类型无法编辑".show()
+ }
+
+ deviceModelView.setOnClickListener {
+ deviceViewModel.obtainDeviceModel(deviceType)
+ }
+ deviceViewModel.deviceModel.observe(this, {
+ if (it.code == 200) {
+ val sheetBuilder = QMUIBottomSheet.BottomListSheetBuilder(this)
+ sheetBuilder.setTitle("设备型号")
+ it.data.forEach { type ->
+ sheetBuilder.addItem(type.name)
+ }
+ sheetBuilder.setGravityCenter(true)
+ .setOnSheetItemClickListener { dialog, _, position, tag ->
+ this.modelId = it.data[position].value
+ deviceModelView.text = tag
+
+ dialog.dismiss()
+ }.build().show()
+ }
+ })
+
+ installDateView.setOnClickListener {
+ TimePickerDialog.Builder()
+ .setThemeColor(R.color.mainThemeColor.convertColor(this))
+ .setTitleStringId("请选择安装日期")
+ .setWheelItemTextSize(16)
+ .setCyclic(false)
+ .setMinMillseconds(System.currentTimeMillis() - Constant.FIVE_YEARS)
+ .setMaxMillseconds(System.currentTimeMillis())
+ .setType(Type.YEAR_MONTH_DAY)
+ .setCallBack { _: TimePickerDialog?, millSeconds: Long ->
+ installDateView.text = millSeconds.timestampToDate()
+ }.build().show(supportFragmentManager, "year_month_day")
+ }
+
+ saveButton.setOnClickListener {
+ if (modelId.isBlank()) {
+ "设备模型ID为空,无法修改".show()
+ return@setOnClickListener
+ }
+ deviceViewModel.updateDeviceDetail(
+ id = deviceBean.id,
+ deviceName = deviceBean.deviceName,
+ devcode = deviceBean.devcode,
+ deviceType = deviceBean.deviceType,
+ modelId = modelId,
+ wellCode = wellCodeView.text.toString(),
+ concenCode = concentratorView.text.toString(),
+ installDate = installDateView.text.toString()
+ )
+ }
+
+ deviceViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "保存中,请稍后...")
+ }
+ is LoadState.Success -> {
+ DialogHelper.dismissLoadingDialog()
+ finish()
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
index 30a70c5..127c247 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -372,6 +372,26 @@
return api.obtainDeviceType(AuthenticationHelper.token!!)
}
+ /**
+ * 获取设备模型
+ */
+ suspend fun obtainDeviceModel(deviceType: String): String {
+ return api.obtainDeviceModel(AuthenticationHelper.token!!, deviceType)
+ }
+
+ /**
+ * 编辑更新设备信息
+ */
+ suspend fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ): String {
+ return api.updateDeviceDetail(
+ AuthenticationHelper.token!!,
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ }
+
// /**
// * 获取工单详情
// */
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
new file mode 100644
index 0000000..5275d0e
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
@@ -0,0 +1,38 @@
+package com.casic.app.smartwell.sanxi.view
+
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import kotlinx.android.synthetic.main.activity_device_list_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class DeviceListDetailActivity : BaseActivity() {
+
+ override fun initLayoutView(): Int = R.layout.activity_device_list_detail
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "设备详情"
+ }
+
+ override fun initData() {
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ val deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ if (deviceBean != null) {
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.text = deviceBean.wellCode
+ installDateView.text = deviceBean.installDate
+ }
+ }
+
+ override fun initEvent() {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
index 40d95ba..6b92bb2 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
@@ -12,8 +12,10 @@
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.adapter.DeviceListAdapter
import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.showEmptyPage
+import com.casic.app.smartwell.sanxi.extensions.toJson
import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
import com.casic.app.smartwell.sanxi.model.OwnerShipModel
import com.casic.app.smartwell.sanxi.utils.WeakReferenceHandler
@@ -208,7 +210,7 @@
deviceListAdapter.setOnItemClickListener(object :
DeviceListAdapter.OnItemClickListener {
override fun onClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onHistoryClicked(position: Int) {
@@ -216,11 +218,11 @@
}
override fun onEditClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onWellDetailClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].wellId)
}
})
}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
new file mode 100644
index 0000000..9ed5aad
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
@@ -0,0 +1,129 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.util.Log
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.convertColor
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.extensions.timestampToDate
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.DialogHelper
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.vm.DeviceViewModel
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.jzxiang.pickerview.TimePickerDialog
+import com.jzxiang.pickerview.data.Type
+import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet
+import kotlinx.android.synthetic.main.activity_edit_device.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class EditDeviceActivity : BaseActivity() {
+
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceBean: DeviceListPageModel.DataBean.RowsBean
+ private lateinit var deviceType: String
+ private var modelId = ""
+
+ override fun initLayoutView(): Int = R.layout.activity_edit_device
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "编辑设备信息"
+ }
+
+ override fun initData() {
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.setText(deviceBean.wellCode)
+ installDateView.text = deviceBean.installDate
+
+ this.deviceType = deviceBean.deviceType
+ this.modelId = deviceBean.modelId
+ }
+
+ override fun initEvent() {
+ deviceCodeView.setOnClickListener {
+ "设备编号无法编辑".show()
+ }
+
+ deviceTypeView.setOnClickListener {
+ "设备类型无法编辑".show()
+ }
+
+ deviceModelView.setOnClickListener {
+ deviceViewModel.obtainDeviceModel(deviceType)
+ }
+ deviceViewModel.deviceModel.observe(this, {
+ if (it.code == 200) {
+ val sheetBuilder = QMUIBottomSheet.BottomListSheetBuilder(this)
+ sheetBuilder.setTitle("设备型号")
+ it.data.forEach { type ->
+ sheetBuilder.addItem(type.name)
+ }
+ sheetBuilder.setGravityCenter(true)
+ .setOnSheetItemClickListener { dialog, _, position, tag ->
+ this.modelId = it.data[position].value
+ deviceModelView.text = tag
+
+ dialog.dismiss()
+ }.build().show()
+ }
+ })
+
+ installDateView.setOnClickListener {
+ TimePickerDialog.Builder()
+ .setThemeColor(R.color.mainThemeColor.convertColor(this))
+ .setTitleStringId("请选择安装日期")
+ .setWheelItemTextSize(16)
+ .setCyclic(false)
+ .setMinMillseconds(System.currentTimeMillis() - Constant.FIVE_YEARS)
+ .setMaxMillseconds(System.currentTimeMillis())
+ .setType(Type.YEAR_MONTH_DAY)
+ .setCallBack { _: TimePickerDialog?, millSeconds: Long ->
+ installDateView.text = millSeconds.timestampToDate()
+ }.build().show(supportFragmentManager, "year_month_day")
+ }
+
+ saveButton.setOnClickListener {
+ if (modelId.isBlank()) {
+ "设备模型ID为空,无法修改".show()
+ return@setOnClickListener
+ }
+ deviceViewModel.updateDeviceDetail(
+ id = deviceBean.id,
+ deviceName = deviceBean.deviceName,
+ devcode = deviceBean.devcode,
+ deviceType = deviceBean.deviceType,
+ modelId = modelId,
+ wellCode = wellCodeView.text.toString(),
+ concenCode = concentratorView.text.toString(),
+ installDate = installDateView.text.toString()
+ )
+ }
+
+ deviceViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "保存中,请稍后...")
+ }
+ is LoadState.Success -> {
+ DialogHelper.dismissLoadingDialog()
+ finish()
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
index 9acaebe..d87e7c0 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
@@ -6,9 +6,8 @@
import com.casic.app.smartwell.sanxi.extensions.separateResponseCode
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.toErrorMessage
-import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeDataModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeModel
+import com.casic.app.smartwell.sanxi.model.*
+import com.casic.app.smartwell.sanxi.utils.LoadState
import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -21,6 +20,8 @@
val deviceTypeDataModel = MutableLiveData()
val deviceListPageModel = MutableLiveData()
val deviceTypeModel = MutableLiveData()
+ val deviceModel = MutableLiveData()
+ val commonResultModel = MutableLiveData()
fun countDeviceByState() = launch({
val response = RetrofitServiceManager.countDeviceByState()
@@ -86,4 +87,45 @@
}, {
it.printStackTrace()
})
+
+ fun obtainDeviceModel(deviceType: String) = launch({
+ val response = RetrofitServiceManager.obtainDeviceModel(deviceType)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ deviceModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show()
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 编辑更新设备信息
+ * */
+ fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ) = launch({
+ loadState.value = LoadState.Loading
+ val response = RetrofitServiceManager.updateDeviceDetail(
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ loadState.value = LoadState.Success
+ "更新成功".show()
+ commonResultModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ loadState.value = LoadState.Fail
+ response.toErrorMessage().show()
+ }
+ }, {
+ loadState.value = LoadState.Fail
+ it.printStackTrace()
+ })
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
index 30a70c5..127c247 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -372,6 +372,26 @@
return api.obtainDeviceType(AuthenticationHelper.token!!)
}
+ /**
+ * 获取设备模型
+ */
+ suspend fun obtainDeviceModel(deviceType: String): String {
+ return api.obtainDeviceModel(AuthenticationHelper.token!!, deviceType)
+ }
+
+ /**
+ * 编辑更新设备信息
+ */
+ suspend fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ): String {
+ return api.updateDeviceDetail(
+ AuthenticationHelper.token!!,
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ }
+
// /**
// * 获取工单详情
// */
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
new file mode 100644
index 0000000..5275d0e
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
@@ -0,0 +1,38 @@
+package com.casic.app.smartwell.sanxi.view
+
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import kotlinx.android.synthetic.main.activity_device_list_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class DeviceListDetailActivity : BaseActivity() {
+
+ override fun initLayoutView(): Int = R.layout.activity_device_list_detail
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "设备详情"
+ }
+
+ override fun initData() {
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ val deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ if (deviceBean != null) {
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.text = deviceBean.wellCode
+ installDateView.text = deviceBean.installDate
+ }
+ }
+
+ override fun initEvent() {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
index 40d95ba..6b92bb2 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
@@ -12,8 +12,10 @@
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.adapter.DeviceListAdapter
import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.showEmptyPage
+import com.casic.app.smartwell.sanxi.extensions.toJson
import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
import com.casic.app.smartwell.sanxi.model.OwnerShipModel
import com.casic.app.smartwell.sanxi.utils.WeakReferenceHandler
@@ -208,7 +210,7 @@
deviceListAdapter.setOnItemClickListener(object :
DeviceListAdapter.OnItemClickListener {
override fun onClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onHistoryClicked(position: Int) {
@@ -216,11 +218,11 @@
}
override fun onEditClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onWellDetailClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].wellId)
}
})
}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
new file mode 100644
index 0000000..9ed5aad
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
@@ -0,0 +1,129 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.util.Log
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.convertColor
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.extensions.timestampToDate
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.DialogHelper
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.vm.DeviceViewModel
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.jzxiang.pickerview.TimePickerDialog
+import com.jzxiang.pickerview.data.Type
+import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet
+import kotlinx.android.synthetic.main.activity_edit_device.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class EditDeviceActivity : BaseActivity() {
+
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceBean: DeviceListPageModel.DataBean.RowsBean
+ private lateinit var deviceType: String
+ private var modelId = ""
+
+ override fun initLayoutView(): Int = R.layout.activity_edit_device
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "编辑设备信息"
+ }
+
+ override fun initData() {
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.setText(deviceBean.wellCode)
+ installDateView.text = deviceBean.installDate
+
+ this.deviceType = deviceBean.deviceType
+ this.modelId = deviceBean.modelId
+ }
+
+ override fun initEvent() {
+ deviceCodeView.setOnClickListener {
+ "设备编号无法编辑".show()
+ }
+
+ deviceTypeView.setOnClickListener {
+ "设备类型无法编辑".show()
+ }
+
+ deviceModelView.setOnClickListener {
+ deviceViewModel.obtainDeviceModel(deviceType)
+ }
+ deviceViewModel.deviceModel.observe(this, {
+ if (it.code == 200) {
+ val sheetBuilder = QMUIBottomSheet.BottomListSheetBuilder(this)
+ sheetBuilder.setTitle("设备型号")
+ it.data.forEach { type ->
+ sheetBuilder.addItem(type.name)
+ }
+ sheetBuilder.setGravityCenter(true)
+ .setOnSheetItemClickListener { dialog, _, position, tag ->
+ this.modelId = it.data[position].value
+ deviceModelView.text = tag
+
+ dialog.dismiss()
+ }.build().show()
+ }
+ })
+
+ installDateView.setOnClickListener {
+ TimePickerDialog.Builder()
+ .setThemeColor(R.color.mainThemeColor.convertColor(this))
+ .setTitleStringId("请选择安装日期")
+ .setWheelItemTextSize(16)
+ .setCyclic(false)
+ .setMinMillseconds(System.currentTimeMillis() - Constant.FIVE_YEARS)
+ .setMaxMillseconds(System.currentTimeMillis())
+ .setType(Type.YEAR_MONTH_DAY)
+ .setCallBack { _: TimePickerDialog?, millSeconds: Long ->
+ installDateView.text = millSeconds.timestampToDate()
+ }.build().show(supportFragmentManager, "year_month_day")
+ }
+
+ saveButton.setOnClickListener {
+ if (modelId.isBlank()) {
+ "设备模型ID为空,无法修改".show()
+ return@setOnClickListener
+ }
+ deviceViewModel.updateDeviceDetail(
+ id = deviceBean.id,
+ deviceName = deviceBean.deviceName,
+ devcode = deviceBean.devcode,
+ deviceType = deviceBean.deviceType,
+ modelId = modelId,
+ wellCode = wellCodeView.text.toString(),
+ concenCode = concentratorView.text.toString(),
+ installDate = installDateView.text.toString()
+ )
+ }
+
+ deviceViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "保存中,请稍后...")
+ }
+ is LoadState.Success -> {
+ DialogHelper.dismissLoadingDialog()
+ finish()
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
index 9acaebe..d87e7c0 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
@@ -6,9 +6,8 @@
import com.casic.app.smartwell.sanxi.extensions.separateResponseCode
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.toErrorMessage
-import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeDataModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeModel
+import com.casic.app.smartwell.sanxi.model.*
+import com.casic.app.smartwell.sanxi.utils.LoadState
import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -21,6 +20,8 @@
val deviceTypeDataModel = MutableLiveData()
val deviceListPageModel = MutableLiveData()
val deviceTypeModel = MutableLiveData()
+ val deviceModel = MutableLiveData()
+ val commonResultModel = MutableLiveData()
fun countDeviceByState() = launch({
val response = RetrofitServiceManager.countDeviceByState()
@@ -86,4 +87,45 @@
}, {
it.printStackTrace()
})
+
+ fun obtainDeviceModel(deviceType: String) = launch({
+ val response = RetrofitServiceManager.obtainDeviceModel(deviceType)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ deviceModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show()
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 编辑更新设备信息
+ * */
+ fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ) = launch({
+ loadState.value = LoadState.Loading
+ val response = RetrofitServiceManager.updateDeviceDetail(
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ loadState.value = LoadState.Success
+ "更新成功".show()
+ commonResultModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ loadState.value = LoadState.Fail
+ response.toErrorMessage().show()
+ }
+ }, {
+ loadState.value = LoadState.Fail
+ it.printStackTrace()
+ })
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_device_list_detail.xml b/app/src/main/res/layout/activity_device_list_detail.xml
new file mode 100644
index 0000000..7ccea67
--- /dev/null
+++ b/app/src/main/res/layout/activity_device_list_detail.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
index 30a70c5..127c247 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -372,6 +372,26 @@
return api.obtainDeviceType(AuthenticationHelper.token!!)
}
+ /**
+ * 获取设备模型
+ */
+ suspend fun obtainDeviceModel(deviceType: String): String {
+ return api.obtainDeviceModel(AuthenticationHelper.token!!, deviceType)
+ }
+
+ /**
+ * 编辑更新设备信息
+ */
+ suspend fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ): String {
+ return api.updateDeviceDetail(
+ AuthenticationHelper.token!!,
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ }
+
// /**
// * 获取工单详情
// */
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
new file mode 100644
index 0000000..5275d0e
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
@@ -0,0 +1,38 @@
+package com.casic.app.smartwell.sanxi.view
+
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import kotlinx.android.synthetic.main.activity_device_list_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class DeviceListDetailActivity : BaseActivity() {
+
+ override fun initLayoutView(): Int = R.layout.activity_device_list_detail
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "设备详情"
+ }
+
+ override fun initData() {
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ val deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ if (deviceBean != null) {
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.text = deviceBean.wellCode
+ installDateView.text = deviceBean.installDate
+ }
+ }
+
+ override fun initEvent() {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
index 40d95ba..6b92bb2 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
@@ -12,8 +12,10 @@
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.adapter.DeviceListAdapter
import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.showEmptyPage
+import com.casic.app.smartwell.sanxi.extensions.toJson
import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
import com.casic.app.smartwell.sanxi.model.OwnerShipModel
import com.casic.app.smartwell.sanxi.utils.WeakReferenceHandler
@@ -208,7 +210,7 @@
deviceListAdapter.setOnItemClickListener(object :
DeviceListAdapter.OnItemClickListener {
override fun onClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onHistoryClicked(position: Int) {
@@ -216,11 +218,11 @@
}
override fun onEditClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onWellDetailClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].wellId)
}
})
}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
new file mode 100644
index 0000000..9ed5aad
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
@@ -0,0 +1,129 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.util.Log
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.convertColor
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.extensions.timestampToDate
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.DialogHelper
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.vm.DeviceViewModel
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.jzxiang.pickerview.TimePickerDialog
+import com.jzxiang.pickerview.data.Type
+import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet
+import kotlinx.android.synthetic.main.activity_edit_device.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class EditDeviceActivity : BaseActivity() {
+
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceBean: DeviceListPageModel.DataBean.RowsBean
+ private lateinit var deviceType: String
+ private var modelId = ""
+
+ override fun initLayoutView(): Int = R.layout.activity_edit_device
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "编辑设备信息"
+ }
+
+ override fun initData() {
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.setText(deviceBean.wellCode)
+ installDateView.text = deviceBean.installDate
+
+ this.deviceType = deviceBean.deviceType
+ this.modelId = deviceBean.modelId
+ }
+
+ override fun initEvent() {
+ deviceCodeView.setOnClickListener {
+ "设备编号无法编辑".show()
+ }
+
+ deviceTypeView.setOnClickListener {
+ "设备类型无法编辑".show()
+ }
+
+ deviceModelView.setOnClickListener {
+ deviceViewModel.obtainDeviceModel(deviceType)
+ }
+ deviceViewModel.deviceModel.observe(this, {
+ if (it.code == 200) {
+ val sheetBuilder = QMUIBottomSheet.BottomListSheetBuilder(this)
+ sheetBuilder.setTitle("设备型号")
+ it.data.forEach { type ->
+ sheetBuilder.addItem(type.name)
+ }
+ sheetBuilder.setGravityCenter(true)
+ .setOnSheetItemClickListener { dialog, _, position, tag ->
+ this.modelId = it.data[position].value
+ deviceModelView.text = tag
+
+ dialog.dismiss()
+ }.build().show()
+ }
+ })
+
+ installDateView.setOnClickListener {
+ TimePickerDialog.Builder()
+ .setThemeColor(R.color.mainThemeColor.convertColor(this))
+ .setTitleStringId("请选择安装日期")
+ .setWheelItemTextSize(16)
+ .setCyclic(false)
+ .setMinMillseconds(System.currentTimeMillis() - Constant.FIVE_YEARS)
+ .setMaxMillseconds(System.currentTimeMillis())
+ .setType(Type.YEAR_MONTH_DAY)
+ .setCallBack { _: TimePickerDialog?, millSeconds: Long ->
+ installDateView.text = millSeconds.timestampToDate()
+ }.build().show(supportFragmentManager, "year_month_day")
+ }
+
+ saveButton.setOnClickListener {
+ if (modelId.isBlank()) {
+ "设备模型ID为空,无法修改".show()
+ return@setOnClickListener
+ }
+ deviceViewModel.updateDeviceDetail(
+ id = deviceBean.id,
+ deviceName = deviceBean.deviceName,
+ devcode = deviceBean.devcode,
+ deviceType = deviceBean.deviceType,
+ modelId = modelId,
+ wellCode = wellCodeView.text.toString(),
+ concenCode = concentratorView.text.toString(),
+ installDate = installDateView.text.toString()
+ )
+ }
+
+ deviceViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "保存中,请稍后...")
+ }
+ is LoadState.Success -> {
+ DialogHelper.dismissLoadingDialog()
+ finish()
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
index 9acaebe..d87e7c0 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
@@ -6,9 +6,8 @@
import com.casic.app.smartwell.sanxi.extensions.separateResponseCode
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.toErrorMessage
-import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeDataModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeModel
+import com.casic.app.smartwell.sanxi.model.*
+import com.casic.app.smartwell.sanxi.utils.LoadState
import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -21,6 +20,8 @@
val deviceTypeDataModel = MutableLiveData()
val deviceListPageModel = MutableLiveData()
val deviceTypeModel = MutableLiveData()
+ val deviceModel = MutableLiveData()
+ val commonResultModel = MutableLiveData()
fun countDeviceByState() = launch({
val response = RetrofitServiceManager.countDeviceByState()
@@ -86,4 +87,45 @@
}, {
it.printStackTrace()
})
+
+ fun obtainDeviceModel(deviceType: String) = launch({
+ val response = RetrofitServiceManager.obtainDeviceModel(deviceType)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ deviceModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show()
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 编辑更新设备信息
+ * */
+ fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ) = launch({
+ loadState.value = LoadState.Loading
+ val response = RetrofitServiceManager.updateDeviceDetail(
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ loadState.value = LoadState.Success
+ "更新成功".show()
+ commonResultModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ loadState.value = LoadState.Fail
+ response.toErrorMessage().show()
+ }
+ }, {
+ loadState.value = LoadState.Fail
+ it.printStackTrace()
+ })
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_device_list_detail.xml b/app/src/main/res/layout/activity_device_list_detail.xml
new file mode 100644
index 0000000..7ccea67
--- /dev/null
+++ b/app/src/main/res/layout/activity_device_list_detail.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_device.xml b/app/src/main/res/layout/activity_edit_device.xml
new file mode 100644
index 0000000..e1d35f3
--- /dev/null
+++ b/app/src/main/res/layout/activity_edit_device.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
index 30a70c5..127c247 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -372,6 +372,26 @@
return api.obtainDeviceType(AuthenticationHelper.token!!)
}
+ /**
+ * 获取设备模型
+ */
+ suspend fun obtainDeviceModel(deviceType: String): String {
+ return api.obtainDeviceModel(AuthenticationHelper.token!!, deviceType)
+ }
+
+ /**
+ * 编辑更新设备信息
+ */
+ suspend fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ): String {
+ return api.updateDeviceDetail(
+ AuthenticationHelper.token!!,
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ }
+
// /**
// * 获取工单详情
// */
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
new file mode 100644
index 0000000..5275d0e
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
@@ -0,0 +1,38 @@
+package com.casic.app.smartwell.sanxi.view
+
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import kotlinx.android.synthetic.main.activity_device_list_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class DeviceListDetailActivity : BaseActivity() {
+
+ override fun initLayoutView(): Int = R.layout.activity_device_list_detail
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "设备详情"
+ }
+
+ override fun initData() {
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ val deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ if (deviceBean != null) {
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.text = deviceBean.wellCode
+ installDateView.text = deviceBean.installDate
+ }
+ }
+
+ override fun initEvent() {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
index 40d95ba..6b92bb2 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
@@ -12,8 +12,10 @@
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.adapter.DeviceListAdapter
import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.showEmptyPage
+import com.casic.app.smartwell.sanxi.extensions.toJson
import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
import com.casic.app.smartwell.sanxi.model.OwnerShipModel
import com.casic.app.smartwell.sanxi.utils.WeakReferenceHandler
@@ -208,7 +210,7 @@
deviceListAdapter.setOnItemClickListener(object :
DeviceListAdapter.OnItemClickListener {
override fun onClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onHistoryClicked(position: Int) {
@@ -216,11 +218,11 @@
}
override fun onEditClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onWellDetailClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].wellId)
}
})
}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
new file mode 100644
index 0000000..9ed5aad
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
@@ -0,0 +1,129 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.util.Log
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.convertColor
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.extensions.timestampToDate
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.DialogHelper
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.vm.DeviceViewModel
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.jzxiang.pickerview.TimePickerDialog
+import com.jzxiang.pickerview.data.Type
+import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet
+import kotlinx.android.synthetic.main.activity_edit_device.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class EditDeviceActivity : BaseActivity() {
+
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceBean: DeviceListPageModel.DataBean.RowsBean
+ private lateinit var deviceType: String
+ private var modelId = ""
+
+ override fun initLayoutView(): Int = R.layout.activity_edit_device
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "编辑设备信息"
+ }
+
+ override fun initData() {
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.setText(deviceBean.wellCode)
+ installDateView.text = deviceBean.installDate
+
+ this.deviceType = deviceBean.deviceType
+ this.modelId = deviceBean.modelId
+ }
+
+ override fun initEvent() {
+ deviceCodeView.setOnClickListener {
+ "设备编号无法编辑".show()
+ }
+
+ deviceTypeView.setOnClickListener {
+ "设备类型无法编辑".show()
+ }
+
+ deviceModelView.setOnClickListener {
+ deviceViewModel.obtainDeviceModel(deviceType)
+ }
+ deviceViewModel.deviceModel.observe(this, {
+ if (it.code == 200) {
+ val sheetBuilder = QMUIBottomSheet.BottomListSheetBuilder(this)
+ sheetBuilder.setTitle("设备型号")
+ it.data.forEach { type ->
+ sheetBuilder.addItem(type.name)
+ }
+ sheetBuilder.setGravityCenter(true)
+ .setOnSheetItemClickListener { dialog, _, position, tag ->
+ this.modelId = it.data[position].value
+ deviceModelView.text = tag
+
+ dialog.dismiss()
+ }.build().show()
+ }
+ })
+
+ installDateView.setOnClickListener {
+ TimePickerDialog.Builder()
+ .setThemeColor(R.color.mainThemeColor.convertColor(this))
+ .setTitleStringId("请选择安装日期")
+ .setWheelItemTextSize(16)
+ .setCyclic(false)
+ .setMinMillseconds(System.currentTimeMillis() - Constant.FIVE_YEARS)
+ .setMaxMillseconds(System.currentTimeMillis())
+ .setType(Type.YEAR_MONTH_DAY)
+ .setCallBack { _: TimePickerDialog?, millSeconds: Long ->
+ installDateView.text = millSeconds.timestampToDate()
+ }.build().show(supportFragmentManager, "year_month_day")
+ }
+
+ saveButton.setOnClickListener {
+ if (modelId.isBlank()) {
+ "设备模型ID为空,无法修改".show()
+ return@setOnClickListener
+ }
+ deviceViewModel.updateDeviceDetail(
+ id = deviceBean.id,
+ deviceName = deviceBean.deviceName,
+ devcode = deviceBean.devcode,
+ deviceType = deviceBean.deviceType,
+ modelId = modelId,
+ wellCode = wellCodeView.text.toString(),
+ concenCode = concentratorView.text.toString(),
+ installDate = installDateView.text.toString()
+ )
+ }
+
+ deviceViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "保存中,请稍后...")
+ }
+ is LoadState.Success -> {
+ DialogHelper.dismissLoadingDialog()
+ finish()
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
index 9acaebe..d87e7c0 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
@@ -6,9 +6,8 @@
import com.casic.app.smartwell.sanxi.extensions.separateResponseCode
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.toErrorMessage
-import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeDataModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeModel
+import com.casic.app.smartwell.sanxi.model.*
+import com.casic.app.smartwell.sanxi.utils.LoadState
import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -21,6 +20,8 @@
val deviceTypeDataModel = MutableLiveData()
val deviceListPageModel = MutableLiveData()
val deviceTypeModel = MutableLiveData()
+ val deviceModel = MutableLiveData()
+ val commonResultModel = MutableLiveData()
fun countDeviceByState() = launch({
val response = RetrofitServiceManager.countDeviceByState()
@@ -86,4 +87,45 @@
}, {
it.printStackTrace()
})
+
+ fun obtainDeviceModel(deviceType: String) = launch({
+ val response = RetrofitServiceManager.obtainDeviceModel(deviceType)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ deviceModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show()
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 编辑更新设备信息
+ * */
+ fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ) = launch({
+ loadState.value = LoadState.Loading
+ val response = RetrofitServiceManager.updateDeviceDetail(
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ loadState.value = LoadState.Success
+ "更新成功".show()
+ commonResultModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ loadState.value = LoadState.Fail
+ response.toErrorMessage().show()
+ }
+ }, {
+ loadState.value = LoadState.Fail
+ it.printStackTrace()
+ })
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_device_list_detail.xml b/app/src/main/res/layout/activity_device_list_detail.xml
new file mode 100644
index 0000000..7ccea67
--- /dev/null
+++ b/app/src/main/res/layout/activity_device_list_detail.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_device.xml b/app/src/main/res/layout/activity_edit_device.xml
new file mode 100644
index 0000000..e1d35f3
--- /dev/null
+++ b/app/src/main/res/layout/activity_edit_device.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_well.xml b/app/src/main/res/layout/activity_edit_well.xml
index a2cd1c0..e986e71 100644
--- a/app/src/main/res/layout/activity_edit_well.xml
+++ b/app/src/main/res/layout/activity_edit_well.xml
@@ -29,14 +29,12 @@
+ style="@style/RelativeEditTextStyle" />
@@ -86,14 +84,12 @@
+ style="@style/RelativeEditTextStyle" />
@@ -101,14 +97,12 @@
+ style="@style/RelativeEditTextStyle" />
@@ -116,14 +110,12 @@
+ style="@style/RelativeEditTextStyle" />
@@ -166,14 +158,12 @@
+ style="@style/RelativeEditTextStyle" />
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f64caf4..7aa9893 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
+
+
data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ 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 static class DataBean {
+ private String deviceType;
+ private String name;
+ private String value;
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
index 73f6e9e..b7f83db 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitService.kt
@@ -388,6 +388,34 @@
suspend fun obtainDeviceType(@Header("token") token: String): String
/**
+ * 获取设备模型
+ */
+ @GET("/device/model")
+ suspend fun obtainDeviceModel(
+ @Header("token") token: String,
+ @Query("deviceType") deviceType: String
+ ): String
+
+ /**
+ * 编辑更新设备信息
+ *
+ * @param id
+ */
+ @FormUrlEncoded
+ @POST("/device/update")
+ suspend fun updateDeviceDetail(
+ @Header("token") token: String,
+ @Field("id") id: String,
+ @Field("deviceName") deviceName: String,
+ @Field("devcode") devcode: String,
+ @Field("deviceType") deviceType: String,
+ @Field("modelId") modelId: String,
+ @Field("wellCode") wellCode: String,
+ @Field("concenCode") concenCode: String,
+ @Field("installDate") installDate: String
+ ): String
+
+ /**
* 获取工单详情
*
* @param id 工单id
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
index 30a70c5..127c247 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/utils/retrofit/RetrofitServiceManager.kt
@@ -372,6 +372,26 @@
return api.obtainDeviceType(AuthenticationHelper.token!!)
}
+ /**
+ * 获取设备模型
+ */
+ suspend fun obtainDeviceModel(deviceType: String): String {
+ return api.obtainDeviceModel(AuthenticationHelper.token!!, deviceType)
+ }
+
+ /**
+ * 编辑更新设备信息
+ */
+ suspend fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ): String {
+ return api.updateDeviceDetail(
+ AuthenticationHelper.token!!,
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ }
+
// /**
// * 获取工单详情
// */
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
new file mode 100644
index 0000000..5275d0e
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceListDetailActivity.kt
@@ -0,0 +1,38 @@
+package com.casic.app.smartwell.sanxi.view
+
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import kotlinx.android.synthetic.main.activity_device_list_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class DeviceListDetailActivity : BaseActivity() {
+
+ override fun initLayoutView(): Int = R.layout.activity_device_list_detail
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "设备详情"
+ }
+
+ override fun initData() {
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ val deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ if (deviceBean != null) {
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.text = deviceBean.wellCode
+ installDateView.text = deviceBean.installDate
+ }
+ }
+
+ override fun initEvent() {
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
index 40d95ba..6b92bb2 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/DeviceManageActivity.kt
@@ -12,8 +12,10 @@
import com.casic.app.smartwell.sanxi.R
import com.casic.app.smartwell.sanxi.adapter.DeviceListAdapter
import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.navigatePageTo
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.showEmptyPage
+import com.casic.app.smartwell.sanxi.extensions.toJson
import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
import com.casic.app.smartwell.sanxi.model.OwnerShipModel
import com.casic.app.smartwell.sanxi.utils.WeakReferenceHandler
@@ -208,7 +210,7 @@
deviceListAdapter.setOnItemClickListener(object :
DeviceListAdapter.OnItemClickListener {
override fun onClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onHistoryClicked(position: Int) {
@@ -216,11 +218,11 @@
}
override fun onEditClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].toJson())
}
override fun onWellDetailClicked(position: Int) {
-
+ navigatePageTo(dataBeans[position].wellId)
}
})
}
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
new file mode 100644
index 0000000..9ed5aad
--- /dev/null
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/view/EditDeviceActivity.kt
@@ -0,0 +1,129 @@
+package com.casic.app.smartwell.sanxi.view
+
+import android.util.Log
+import androidx.lifecycle.ViewModelProvider
+import com.casic.app.smartwell.sanxi.R
+import com.casic.app.smartwell.sanxi.base.BaseActivity
+import com.casic.app.smartwell.sanxi.extensions.convertColor
+import com.casic.app.smartwell.sanxi.extensions.show
+import com.casic.app.smartwell.sanxi.extensions.timestampToDate
+import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
+import com.casic.app.smartwell.sanxi.utils.Constant
+import com.casic.app.smartwell.sanxi.utils.DialogHelper
+import com.casic.app.smartwell.sanxi.utils.LoadState
+import com.casic.app.smartwell.sanxi.vm.DeviceViewModel
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.jzxiang.pickerview.TimePickerDialog
+import com.jzxiang.pickerview.data.Type
+import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet
+import kotlinx.android.synthetic.main.activity_edit_device.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+class EditDeviceActivity : BaseActivity() {
+
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceBean: DeviceListPageModel.DataBean.RowsBean
+ private lateinit var deviceType: String
+ private var modelId = ""
+
+ override fun initLayoutView(): Int = R.layout.activity_edit_device
+
+ override fun setupTopBarLayout() {
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "编辑设备信息"
+ }
+
+ override fun initData() {
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+
+ val deviceBeanJson = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ deviceBean = Gson().fromJson(
+ deviceBeanJson, object : TypeToken() {}.type
+ )
+ deviceCodeView.text = deviceBean.devcode
+ deviceTypeView.text = deviceBean.deviceTypeName
+ deviceModelView.text = deviceBean.modelName
+ wellCodeView.setText(deviceBean.wellCode)
+ installDateView.text = deviceBean.installDate
+
+ this.deviceType = deviceBean.deviceType
+ this.modelId = deviceBean.modelId
+ }
+
+ override fun initEvent() {
+ deviceCodeView.setOnClickListener {
+ "设备编号无法编辑".show()
+ }
+
+ deviceTypeView.setOnClickListener {
+ "设备类型无法编辑".show()
+ }
+
+ deviceModelView.setOnClickListener {
+ deviceViewModel.obtainDeviceModel(deviceType)
+ }
+ deviceViewModel.deviceModel.observe(this, {
+ if (it.code == 200) {
+ val sheetBuilder = QMUIBottomSheet.BottomListSheetBuilder(this)
+ sheetBuilder.setTitle("设备型号")
+ it.data.forEach { type ->
+ sheetBuilder.addItem(type.name)
+ }
+ sheetBuilder.setGravityCenter(true)
+ .setOnSheetItemClickListener { dialog, _, position, tag ->
+ this.modelId = it.data[position].value
+ deviceModelView.text = tag
+
+ dialog.dismiss()
+ }.build().show()
+ }
+ })
+
+ installDateView.setOnClickListener {
+ TimePickerDialog.Builder()
+ .setThemeColor(R.color.mainThemeColor.convertColor(this))
+ .setTitleStringId("请选择安装日期")
+ .setWheelItemTextSize(16)
+ .setCyclic(false)
+ .setMinMillseconds(System.currentTimeMillis() - Constant.FIVE_YEARS)
+ .setMaxMillseconds(System.currentTimeMillis())
+ .setType(Type.YEAR_MONTH_DAY)
+ .setCallBack { _: TimePickerDialog?, millSeconds: Long ->
+ installDateView.text = millSeconds.timestampToDate()
+ }.build().show(supportFragmentManager, "year_month_day")
+ }
+
+ saveButton.setOnClickListener {
+ if (modelId.isBlank()) {
+ "设备模型ID为空,无法修改".show()
+ return@setOnClickListener
+ }
+ deviceViewModel.updateDeviceDetail(
+ id = deviceBean.id,
+ deviceName = deviceBean.deviceName,
+ devcode = deviceBean.devcode,
+ deviceType = deviceBean.deviceType,
+ modelId = modelId,
+ wellCode = wellCodeView.text.toString(),
+ concenCode = concentratorView.text.toString(),
+ installDate = installDateView.text.toString()
+ )
+ }
+
+ deviceViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "保存中,请稍后...")
+ }
+ is LoadState.Success -> {
+ DialogHelper.dismissLoadingDialog()
+ finish()
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
index 9acaebe..d87e7c0 100644
--- a/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
+++ b/app/src/main/java/com/casic/app/smartwell/sanxi/vm/DeviceViewModel.kt
@@ -6,9 +6,8 @@
import com.casic.app.smartwell.sanxi.extensions.separateResponseCode
import com.casic.app.smartwell.sanxi.extensions.show
import com.casic.app.smartwell.sanxi.extensions.toErrorMessage
-import com.casic.app.smartwell.sanxi.model.DeviceListPageModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeDataModel
-import com.casic.app.smartwell.sanxi.model.DeviceTypeModel
+import com.casic.app.smartwell.sanxi.model.*
+import com.casic.app.smartwell.sanxi.utils.LoadState
import com.casic.app.smartwell.sanxi.utils.retrofit.RetrofitServiceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -21,6 +20,8 @@
val deviceTypeDataModel = MutableLiveData()
val deviceListPageModel = MutableLiveData()
val deviceTypeModel = MutableLiveData()
+ val deviceModel = MutableLiveData()
+ val commonResultModel = MutableLiveData()
fun countDeviceByState() = launch({
val response = RetrofitServiceManager.countDeviceByState()
@@ -86,4 +87,45 @@
}, {
it.printStackTrace()
})
+
+ fun obtainDeviceModel(deviceType: String) = launch({
+ val response = RetrofitServiceManager.obtainDeviceModel(deviceType)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ deviceModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show()
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 编辑更新设备信息
+ * */
+ fun updateDeviceDetail(
+ id: String, deviceName: String, devcode: String, deviceType: String, modelId: String,
+ wellCode: String, concenCode: String, installDate: String
+ ) = launch({
+ loadState.value = LoadState.Loading
+ val response = RetrofitServiceManager.updateDeviceDetail(
+ id, deviceName, devcode, deviceType, modelId, wellCode, concenCode, installDate
+ )
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ loadState.value = LoadState.Success
+ "更新成功".show()
+ commonResultModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ loadState.value = LoadState.Fail
+ response.toErrorMessage().show()
+ }
+ }, {
+ loadState.value = LoadState.Fail
+ it.printStackTrace()
+ })
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_device_list_detail.xml b/app/src/main/res/layout/activity_device_list_detail.xml
new file mode 100644
index 0000000..7ccea67
--- /dev/null
+++ b/app/src/main/res/layout/activity_device_list_detail.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_device.xml b/app/src/main/res/layout/activity_edit_device.xml
new file mode 100644
index 0000000..e1d35f3
--- /dev/null
+++ b/app/src/main/res/layout/activity_edit_device.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_well.xml b/app/src/main/res/layout/activity_edit_well.xml
index a2cd1c0..e986e71 100644
--- a/app/src/main/res/layout/activity_edit_well.xml
+++ b/app/src/main/res/layout/activity_edit_well.xml
@@ -29,14 +29,12 @@
+ style="@style/RelativeEditTextStyle" />
@@ -86,14 +84,12 @@
+ style="@style/RelativeEditTextStyle" />
@@ -101,14 +97,12 @@
+ style="@style/RelativeEditTextStyle" />
@@ -116,14 +110,12 @@
+ style="@style/RelativeEditTextStyle" />
@@ -166,14 +158,12 @@
+ style="@style/RelativeEditTextStyle" />
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 3e89bc4..7aa9fb1 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -85,7 +85,7 @@