diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 0fcd0a1..1961a6f 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,18 @@ ): String /** + * 根据布防状态统计闸井数量接口 + */ + @GET("/well/countByBfzt") + suspend fun countWellByState(@Header("token") token: String): String + + /** + * 根据工单状态统计工单数量 + */ + @GET("/job/countByJobStatus") + suspend fun countWorkOrderByState(@Header("token") token: String): String + + /** * 获取闸井类别 */ @GET("/dict/code/sluicewellType") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 0fcd0a1..1961a6f 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,18 @@ ): String /** + * 根据布防状态统计闸井数量接口 + */ + @GET("/well/countByBfzt") + suspend fun countWellByState(@Header("token") token: String): String + + /** + * 根据工单状态统计工单数量 + */ + @GET("/job/countByJobStatus") + suspend fun countWorkOrderByState(@Header("token") token: String): String + + /** * 获取闸井类别 */ @GET("/dict/code/sluicewellType") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index c564911..7734d7d 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -25,6 +25,20 @@ } /** + * 根据布防状态统计闸井数量接口 + */ + suspend fun countWellByState(): String { + return api.countWellByState(AuthenticationHelper.token!!) + } + + /** + * 根据工单状态统计工单数量 + */ + suspend fun countWorkOrderByState(): String { + return api.countWorkOrderByState(AuthenticationHelper.token!!) + } + + /** * 获取闸井类别 */ suspend fun obtainWellType(): WellTypeModel { diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 0fcd0a1..1961a6f 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,18 @@ ): String /** + * 根据布防状态统计闸井数量接口 + */ + @GET("/well/countByBfzt") + suspend fun countWellByState(@Header("token") token: String): String + + /** + * 根据工单状态统计工单数量 + */ + @GET("/job/countByJobStatus") + suspend fun countWorkOrderByState(@Header("token") token: String): String + + /** * 获取闸井类别 */ @GET("/dict/code/sluicewellType") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index c564911..7734d7d 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -25,6 +25,20 @@ } /** + * 根据布防状态统计闸井数量接口 + */ + suspend fun countWellByState(): String { + return api.countWellByState(AuthenticationHelper.token!!) + } + + /** + * 根据工单状态统计工单数量 + */ + suspend fun countWorkOrderByState(): String { + return api.countWorkOrderByState(AuthenticationHelper.token!!) + } + + /** * 获取闸井类别 */ suspend fun obtainWellType(): WellTypeModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index a494283..c992283 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,15 +1,22 @@ package com.casic.app.smartwell.view.fragment +import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R import com.casic.app.smartwell.adapter.HomeRecycleAdapter import com.casic.app.smartwell.extensions.navigatePageTo import com.casic.app.smartwell.view.WellManagementActivity import com.casic.app.smartwell.view.WellOperationActivity +import com.casic.app.smartwell.vm.WellCountViewModel +import com.casic.app.smartwell.vm.WorkOrderViewModel import com.pengxh.app.multilib.base.BaseFragment import kotlinx.android.synthetic.main.fragment_home.* class HomePageFragment : BaseFragment() { + + private lateinit var wellCountViewModel: WellCountViewModel + private lateinit var workOrderViewModel: WorkOrderViewModel + override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { @@ -27,9 +34,37 @@ } } }) + wellCountViewModel = ViewModelProvider(this).get(WellCountViewModel::class.java) + workOrderViewModel = ViewModelProvider(this).get(WorkOrderViewModel::class.java) } override fun initEvent() { } + + override fun onResume() { + super.onResume() + //每次页面切换都需要重新刷新不同状态的窨井数量 + wellCountViewModel.countWellByState() + wellCountViewModel.resultModel.observe(this, { + unDeployedWellView.text = it["bfWell"] + deployedWellView.text = it["cfWell"] + allWellDataView.text = it["total"] + }) + workOrderViewModel.countWorkOrderByState() + workOrderViewModel.resultModel.observe(this, { + if (it["beforeGet"]!!.length > 4 || it["beforeConfirm"]!!.length > 4 || + it["inHandle"]!!.length > 4 || it["over"]!!.length > 4 + ) { + todoDataView.textSize = 36f + undeterminedDataView.textSize = 36f + inHandleDataView.textSize = 36f + completedDataView.textSize = 36f + } + todoDataView.text = it["beforeGet"] + undeterminedDataView.text = it["beforeConfirm"] + inHandleDataView.text = it["inHandle"] + completedDataView.text = it["over"] + }) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 0fcd0a1..1961a6f 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,18 @@ ): String /** + * 根据布防状态统计闸井数量接口 + */ + @GET("/well/countByBfzt") + suspend fun countWellByState(@Header("token") token: String): String + + /** + * 根据工单状态统计工单数量 + */ + @GET("/job/countByJobStatus") + suspend fun countWorkOrderByState(@Header("token") token: String): String + + /** * 获取闸井类别 */ @GET("/dict/code/sluicewellType") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index c564911..7734d7d 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -25,6 +25,20 @@ } /** + * 根据布防状态统计闸井数量接口 + */ + suspend fun countWellByState(): String { + return api.countWellByState(AuthenticationHelper.token!!) + } + + /** + * 根据工单状态统计工单数量 + */ + suspend fun countWorkOrderByState(): String { + return api.countWorkOrderByState(AuthenticationHelper.token!!) + } + + /** * 获取闸井类别 */ suspend fun obtainWellType(): WellTypeModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index a494283..c992283 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,15 +1,22 @@ package com.casic.app.smartwell.view.fragment +import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R import com.casic.app.smartwell.adapter.HomeRecycleAdapter import com.casic.app.smartwell.extensions.navigatePageTo import com.casic.app.smartwell.view.WellManagementActivity import com.casic.app.smartwell.view.WellOperationActivity +import com.casic.app.smartwell.vm.WellCountViewModel +import com.casic.app.smartwell.vm.WorkOrderViewModel import com.pengxh.app.multilib.base.BaseFragment import kotlinx.android.synthetic.main.fragment_home.* class HomePageFragment : BaseFragment() { + + private lateinit var wellCountViewModel: WellCountViewModel + private lateinit var workOrderViewModel: WorkOrderViewModel + override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { @@ -27,9 +34,37 @@ } } }) + wellCountViewModel = ViewModelProvider(this).get(WellCountViewModel::class.java) + workOrderViewModel = ViewModelProvider(this).get(WorkOrderViewModel::class.java) } override fun initEvent() { } + + override fun onResume() { + super.onResume() + //每次页面切换都需要重新刷新不同状态的窨井数量 + wellCountViewModel.countWellByState() + wellCountViewModel.resultModel.observe(this, { + unDeployedWellView.text = it["bfWell"] + deployedWellView.text = it["cfWell"] + allWellDataView.text = it["total"] + }) + workOrderViewModel.countWorkOrderByState() + workOrderViewModel.resultModel.observe(this, { + if (it["beforeGet"]!!.length > 4 || it["beforeConfirm"]!!.length > 4 || + it["inHandle"]!!.length > 4 || it["over"]!!.length > 4 + ) { + todoDataView.textSize = 36f + undeterminedDataView.textSize = 36f + inHandleDataView.textSize = 36f + completedDataView.textSize = 36f + } + todoDataView.text = it["beforeGet"] + undeterminedDataView.text = it["beforeConfirm"] + inHandleDataView.text = it["inHandle"] + completedDataView.text = it["over"] + }) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt new file mode 100644 index 0000000..363e46b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt @@ -0,0 +1,31 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WellCountViewModel : BaseViewModel() { + private val kTag = "WellCountViewModel" + val resultModel = MutableLiveData>() + + fun countWellByState() = launch({ + val resultJson = RetrofitServiceManager.countWellByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(3) + val data = jsonObject.getJSONObject("data") + map["bfWell"] = data.getString("bfWell") + map["cfWell"] = data.getString("cfWell") + map["total"] = data.getString("total") + resultModel.value = map + } else { + Log.d(kTag, "obtainWellCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWellCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 0fcd0a1..1961a6f 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,18 @@ ): String /** + * 根据布防状态统计闸井数量接口 + */ + @GET("/well/countByBfzt") + suspend fun countWellByState(@Header("token") token: String): String + + /** + * 根据工单状态统计工单数量 + */ + @GET("/job/countByJobStatus") + suspend fun countWorkOrderByState(@Header("token") token: String): String + + /** * 获取闸井类别 */ @GET("/dict/code/sluicewellType") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index c564911..7734d7d 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -25,6 +25,20 @@ } /** + * 根据布防状态统计闸井数量接口 + */ + suspend fun countWellByState(): String { + return api.countWellByState(AuthenticationHelper.token!!) + } + + /** + * 根据工单状态统计工单数量 + */ + suspend fun countWorkOrderByState(): String { + return api.countWorkOrderByState(AuthenticationHelper.token!!) + } + + /** * 获取闸井类别 */ suspend fun obtainWellType(): WellTypeModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index a494283..c992283 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,15 +1,22 @@ package com.casic.app.smartwell.view.fragment +import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R import com.casic.app.smartwell.adapter.HomeRecycleAdapter import com.casic.app.smartwell.extensions.navigatePageTo import com.casic.app.smartwell.view.WellManagementActivity import com.casic.app.smartwell.view.WellOperationActivity +import com.casic.app.smartwell.vm.WellCountViewModel +import com.casic.app.smartwell.vm.WorkOrderViewModel import com.pengxh.app.multilib.base.BaseFragment import kotlinx.android.synthetic.main.fragment_home.* class HomePageFragment : BaseFragment() { + + private lateinit var wellCountViewModel: WellCountViewModel + private lateinit var workOrderViewModel: WorkOrderViewModel + override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { @@ -27,9 +34,37 @@ } } }) + wellCountViewModel = ViewModelProvider(this).get(WellCountViewModel::class.java) + workOrderViewModel = ViewModelProvider(this).get(WorkOrderViewModel::class.java) } override fun initEvent() { } + + override fun onResume() { + super.onResume() + //每次页面切换都需要重新刷新不同状态的窨井数量 + wellCountViewModel.countWellByState() + wellCountViewModel.resultModel.observe(this, { + unDeployedWellView.text = it["bfWell"] + deployedWellView.text = it["cfWell"] + allWellDataView.text = it["total"] + }) + workOrderViewModel.countWorkOrderByState() + workOrderViewModel.resultModel.observe(this, { + if (it["beforeGet"]!!.length > 4 || it["beforeConfirm"]!!.length > 4 || + it["inHandle"]!!.length > 4 || it["over"]!!.length > 4 + ) { + todoDataView.textSize = 36f + undeterminedDataView.textSize = 36f + inHandleDataView.textSize = 36f + completedDataView.textSize = 36f + } + todoDataView.text = it["beforeGet"] + undeterminedDataView.text = it["beforeConfirm"] + inHandleDataView.text = it["inHandle"] + completedDataView.text = it["over"] + }) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt new file mode 100644 index 0000000..363e46b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt @@ -0,0 +1,31 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WellCountViewModel : BaseViewModel() { + private val kTag = "WellCountViewModel" + val resultModel = MutableLiveData>() + + fun countWellByState() = launch({ + val resultJson = RetrofitServiceManager.countWellByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(3) + val data = jsonObject.getJSONObject("data") + map["bfWell"] = data.getString("bfWell") + map["cfWell"] = data.getString("cfWell") + map["total"] = data.getString("total") + resultModel.value = map + } else { + Log.d(kTag, "obtainWellCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWellCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt new file mode 100644 index 0000000..e28026e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt @@ -0,0 +1,32 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WorkOrderViewModel : BaseViewModel() { + private val kTag = "WorkOrderViewModel" + val resultModel = MutableLiveData>() + + fun countWorkOrderByState() = launch({ + val resultJson = RetrofitServiceManager.countWorkOrderByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(4) + val data = jsonObject.getJSONObject("data") + map["beforeGet"] = data.getString("beforeGet") + map["beforeConfirm"] = data.getString("beforeConfirm") + map["inHandle"] = data.getString("inHandle") + map["over"] = data.getString("over") + resultModel.value = map + } else { + Log.d(kTag, "obtainWorkOrderCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWorkOrderCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 0fcd0a1..1961a6f 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,18 @@ ): String /** + * 根据布防状态统计闸井数量接口 + */ + @GET("/well/countByBfzt") + suspend fun countWellByState(@Header("token") token: String): String + + /** + * 根据工单状态统计工单数量 + */ + @GET("/job/countByJobStatus") + suspend fun countWorkOrderByState(@Header("token") token: String): String + + /** * 获取闸井类别 */ @GET("/dict/code/sluicewellType") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index c564911..7734d7d 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -25,6 +25,20 @@ } /** + * 根据布防状态统计闸井数量接口 + */ + suspend fun countWellByState(): String { + return api.countWellByState(AuthenticationHelper.token!!) + } + + /** + * 根据工单状态统计工单数量 + */ + suspend fun countWorkOrderByState(): String { + return api.countWorkOrderByState(AuthenticationHelper.token!!) + } + + /** * 获取闸井类别 */ suspend fun obtainWellType(): WellTypeModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index a494283..c992283 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,15 +1,22 @@ package com.casic.app.smartwell.view.fragment +import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R import com.casic.app.smartwell.adapter.HomeRecycleAdapter import com.casic.app.smartwell.extensions.navigatePageTo import com.casic.app.smartwell.view.WellManagementActivity import com.casic.app.smartwell.view.WellOperationActivity +import com.casic.app.smartwell.vm.WellCountViewModel +import com.casic.app.smartwell.vm.WorkOrderViewModel import com.pengxh.app.multilib.base.BaseFragment import kotlinx.android.synthetic.main.fragment_home.* class HomePageFragment : BaseFragment() { + + private lateinit var wellCountViewModel: WellCountViewModel + private lateinit var workOrderViewModel: WorkOrderViewModel + override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { @@ -27,9 +34,37 @@ } } }) + wellCountViewModel = ViewModelProvider(this).get(WellCountViewModel::class.java) + workOrderViewModel = ViewModelProvider(this).get(WorkOrderViewModel::class.java) } override fun initEvent() { } + + override fun onResume() { + super.onResume() + //每次页面切换都需要重新刷新不同状态的窨井数量 + wellCountViewModel.countWellByState() + wellCountViewModel.resultModel.observe(this, { + unDeployedWellView.text = it["bfWell"] + deployedWellView.text = it["cfWell"] + allWellDataView.text = it["total"] + }) + workOrderViewModel.countWorkOrderByState() + workOrderViewModel.resultModel.observe(this, { + if (it["beforeGet"]!!.length > 4 || it["beforeConfirm"]!!.length > 4 || + it["inHandle"]!!.length > 4 || it["over"]!!.length > 4 + ) { + todoDataView.textSize = 36f + undeterminedDataView.textSize = 36f + inHandleDataView.textSize = 36f + completedDataView.textSize = 36f + } + todoDataView.text = it["beforeGet"] + undeterminedDataView.text = it["beforeConfirm"] + inHandleDataView.text = it["inHandle"] + completedDataView.text = it["over"] + }) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt new file mode 100644 index 0000000..363e46b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt @@ -0,0 +1,31 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WellCountViewModel : BaseViewModel() { + private val kTag = "WellCountViewModel" + val resultModel = MutableLiveData>() + + fun countWellByState() = launch({ + val resultJson = RetrofitServiceManager.countWellByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(3) + val data = jsonObject.getJSONObject("data") + map["bfWell"] = data.getString("bfWell") + map["cfWell"] = data.getString("cfWell") + map["total"] = data.getString("total") + resultModel.value = map + } else { + Log.d(kTag, "obtainWellCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWellCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt new file mode 100644 index 0000000..e28026e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt @@ -0,0 +1,32 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WorkOrderViewModel : BaseViewModel() { + private val kTag = "WorkOrderViewModel" + val resultModel = MutableLiveData>() + + fun countWorkOrderByState() = launch({ + val resultJson = RetrofitServiceManager.countWorkOrderByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(4) + val data = jsonObject.getJSONObject("data") + map["beforeGet"] = data.getString("beforeGet") + map["beforeConfirm"] = data.getString("beforeConfirm") + map["inHandle"] = data.getString("inHandle") + map["over"] = data.getString("over") + resultModel.value = map + } else { + Log.d(kTag, "obtainWorkOrderCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWorkOrderCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index d3ceafb..469789d 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -36,6 +36,51 @@ android:textSize="@dimen/titleFontSize" /> + + + + + + + + + + + + + + + + + + + + + + + + @@ -62,6 +107,64 @@ android:textSize="@dimen/titleFontSize" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 0fcd0a1..1961a6f 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,18 @@ ): String /** + * 根据布防状态统计闸井数量接口 + */ + @GET("/well/countByBfzt") + suspend fun countWellByState(@Header("token") token: String): String + + /** + * 根据工单状态统计工单数量 + */ + @GET("/job/countByJobStatus") + suspend fun countWorkOrderByState(@Header("token") token: String): String + + /** * 获取闸井类别 */ @GET("/dict/code/sluicewellType") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index c564911..7734d7d 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -25,6 +25,20 @@ } /** + * 根据布防状态统计闸井数量接口 + */ + suspend fun countWellByState(): String { + return api.countWellByState(AuthenticationHelper.token!!) + } + + /** + * 根据工单状态统计工单数量 + */ + suspend fun countWorkOrderByState(): String { + return api.countWorkOrderByState(AuthenticationHelper.token!!) + } + + /** * 获取闸井类别 */ suspend fun obtainWellType(): WellTypeModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index a494283..c992283 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,15 +1,22 @@ package com.casic.app.smartwell.view.fragment +import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R import com.casic.app.smartwell.adapter.HomeRecycleAdapter import com.casic.app.smartwell.extensions.navigatePageTo import com.casic.app.smartwell.view.WellManagementActivity import com.casic.app.smartwell.view.WellOperationActivity +import com.casic.app.smartwell.vm.WellCountViewModel +import com.casic.app.smartwell.vm.WorkOrderViewModel import com.pengxh.app.multilib.base.BaseFragment import kotlinx.android.synthetic.main.fragment_home.* class HomePageFragment : BaseFragment() { + + private lateinit var wellCountViewModel: WellCountViewModel + private lateinit var workOrderViewModel: WorkOrderViewModel + override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { @@ -27,9 +34,37 @@ } } }) + wellCountViewModel = ViewModelProvider(this).get(WellCountViewModel::class.java) + workOrderViewModel = ViewModelProvider(this).get(WorkOrderViewModel::class.java) } override fun initEvent() { } + + override fun onResume() { + super.onResume() + //每次页面切换都需要重新刷新不同状态的窨井数量 + wellCountViewModel.countWellByState() + wellCountViewModel.resultModel.observe(this, { + unDeployedWellView.text = it["bfWell"] + deployedWellView.text = it["cfWell"] + allWellDataView.text = it["total"] + }) + workOrderViewModel.countWorkOrderByState() + workOrderViewModel.resultModel.observe(this, { + if (it["beforeGet"]!!.length > 4 || it["beforeConfirm"]!!.length > 4 || + it["inHandle"]!!.length > 4 || it["over"]!!.length > 4 + ) { + todoDataView.textSize = 36f + undeterminedDataView.textSize = 36f + inHandleDataView.textSize = 36f + completedDataView.textSize = 36f + } + todoDataView.text = it["beforeGet"] + undeterminedDataView.text = it["beforeConfirm"] + inHandleDataView.text = it["inHandle"] + completedDataView.text = it["over"] + }) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt new file mode 100644 index 0000000..363e46b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt @@ -0,0 +1,31 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WellCountViewModel : BaseViewModel() { + private val kTag = "WellCountViewModel" + val resultModel = MutableLiveData>() + + fun countWellByState() = launch({ + val resultJson = RetrofitServiceManager.countWellByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(3) + val data = jsonObject.getJSONObject("data") + map["bfWell"] = data.getString("bfWell") + map["cfWell"] = data.getString("cfWell") + map["total"] = data.getString("total") + resultModel.value = map + } else { + Log.d(kTag, "obtainWellCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWellCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt new file mode 100644 index 0000000..e28026e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt @@ -0,0 +1,32 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WorkOrderViewModel : BaseViewModel() { + private val kTag = "WorkOrderViewModel" + val resultModel = MutableLiveData>() + + fun countWorkOrderByState() = launch({ + val resultJson = RetrofitServiceManager.countWorkOrderByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(4) + val data = jsonObject.getJSONObject("data") + map["beforeGet"] = data.getString("beforeGet") + map["beforeConfirm"] = data.getString("beforeConfirm") + map["inHandle"] = data.getString("inHandle") + map["over"] = data.getString("over") + resultModel.value = map + } else { + Log.d(kTag, "obtainWorkOrderCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWorkOrderCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index d3ceafb..469789d 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -36,6 +36,51 @@ android:textSize="@dimen/titleFontSize" /> + + + + + + + + + + + + + + + + + + + + + + + + @@ -62,6 +107,64 @@ android:textSize="@dimen/titleFontSize" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c100e72..9126849 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,7 +5,8 @@ #F7F7F7 #CCCCCC #13AD00 - #F86364 + #FF6F70 + #FFCA18 #54FFFFFF #54000000 diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 0fcd0a1..1961a6f 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,18 @@ ): String /** + * 根据布防状态统计闸井数量接口 + */ + @GET("/well/countByBfzt") + suspend fun countWellByState(@Header("token") token: String): String + + /** + * 根据工单状态统计工单数量 + */ + @GET("/job/countByJobStatus") + suspend fun countWorkOrderByState(@Header("token") token: String): String + + /** * 获取闸井类别 */ @GET("/dict/code/sluicewellType") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index c564911..7734d7d 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -25,6 +25,20 @@ } /** + * 根据布防状态统计闸井数量接口 + */ + suspend fun countWellByState(): String { + return api.countWellByState(AuthenticationHelper.token!!) + } + + /** + * 根据工单状态统计工单数量 + */ + suspend fun countWorkOrderByState(): String { + return api.countWorkOrderByState(AuthenticationHelper.token!!) + } + + /** * 获取闸井类别 */ suspend fun obtainWellType(): WellTypeModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index a494283..c992283 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,15 +1,22 @@ package com.casic.app.smartwell.view.fragment +import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R import com.casic.app.smartwell.adapter.HomeRecycleAdapter import com.casic.app.smartwell.extensions.navigatePageTo import com.casic.app.smartwell.view.WellManagementActivity import com.casic.app.smartwell.view.WellOperationActivity +import com.casic.app.smartwell.vm.WellCountViewModel +import com.casic.app.smartwell.vm.WorkOrderViewModel import com.pengxh.app.multilib.base.BaseFragment import kotlinx.android.synthetic.main.fragment_home.* class HomePageFragment : BaseFragment() { + + private lateinit var wellCountViewModel: WellCountViewModel + private lateinit var workOrderViewModel: WorkOrderViewModel + override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { @@ -27,9 +34,37 @@ } } }) + wellCountViewModel = ViewModelProvider(this).get(WellCountViewModel::class.java) + workOrderViewModel = ViewModelProvider(this).get(WorkOrderViewModel::class.java) } override fun initEvent() { } + + override fun onResume() { + super.onResume() + //每次页面切换都需要重新刷新不同状态的窨井数量 + wellCountViewModel.countWellByState() + wellCountViewModel.resultModel.observe(this, { + unDeployedWellView.text = it["bfWell"] + deployedWellView.text = it["cfWell"] + allWellDataView.text = it["total"] + }) + workOrderViewModel.countWorkOrderByState() + workOrderViewModel.resultModel.observe(this, { + if (it["beforeGet"]!!.length > 4 || it["beforeConfirm"]!!.length > 4 || + it["inHandle"]!!.length > 4 || it["over"]!!.length > 4 + ) { + todoDataView.textSize = 36f + undeterminedDataView.textSize = 36f + inHandleDataView.textSize = 36f + completedDataView.textSize = 36f + } + todoDataView.text = it["beforeGet"] + undeterminedDataView.text = it["beforeConfirm"] + inHandleDataView.text = it["inHandle"] + completedDataView.text = it["over"] + }) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt new file mode 100644 index 0000000..363e46b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt @@ -0,0 +1,31 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WellCountViewModel : BaseViewModel() { + private val kTag = "WellCountViewModel" + val resultModel = MutableLiveData>() + + fun countWellByState() = launch({ + val resultJson = RetrofitServiceManager.countWellByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(3) + val data = jsonObject.getJSONObject("data") + map["bfWell"] = data.getString("bfWell") + map["cfWell"] = data.getString("cfWell") + map["total"] = data.getString("total") + resultModel.value = map + } else { + Log.d(kTag, "obtainWellCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWellCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt new file mode 100644 index 0000000..e28026e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt @@ -0,0 +1,32 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WorkOrderViewModel : BaseViewModel() { + private val kTag = "WorkOrderViewModel" + val resultModel = MutableLiveData>() + + fun countWorkOrderByState() = launch({ + val resultJson = RetrofitServiceManager.countWorkOrderByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(4) + val data = jsonObject.getJSONObject("data") + map["beforeGet"] = data.getString("beforeGet") + map["beforeConfirm"] = data.getString("beforeConfirm") + map["inHandle"] = data.getString("inHandle") + map["over"] = data.getString("over") + resultModel.value = map + } else { + Log.d(kTag, "obtainWorkOrderCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWorkOrderCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index d3ceafb..469789d 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -36,6 +36,51 @@ android:textSize="@dimen/titleFontSize" /> + + + + + + + + + + + + + + + + + + + + + + + + @@ -62,6 +107,64 @@ android:textSize="@dimen/titleFontSize" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c100e72..9126849 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,7 +5,8 @@ #F7F7F7 #CCCCCC #13AD00 - #F86364 + #FF6F70 + #FFCA18 #54FFFFFF #54000000 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 6839610..09b76ca 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -3,6 +3,7 @@ 16sp 18sp 20sp + 50sp 3dp diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 0fcd0a1..1961a6f 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -26,6 +26,18 @@ ): String /** + * 根据布防状态统计闸井数量接口 + */ + @GET("/well/countByBfzt") + suspend fun countWellByState(@Header("token") token: String): String + + /** + * 根据工单状态统计工单数量 + */ + @GET("/job/countByJobStatus") + suspend fun countWorkOrderByState(@Header("token") token: String): String + + /** * 获取闸井类别 */ @GET("/dict/code/sluicewellType") diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt index c564911..7734d7d 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitServiceManager.kt @@ -25,6 +25,20 @@ } /** + * 根据布防状态统计闸井数量接口 + */ + suspend fun countWellByState(): String { + return api.countWellByState(AuthenticationHelper.token!!) + } + + /** + * 根据工单状态统计工单数量 + */ + suspend fun countWorkOrderByState(): String { + return api.countWorkOrderByState(AuthenticationHelper.token!!) + } + + /** * 获取闸井类别 */ suspend fun obtainWellType(): WellTypeModel { diff --git a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt index a494283..c992283 100644 --- a/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/view/fragment/HomePageFragment.kt @@ -1,15 +1,22 @@ package com.casic.app.smartwell.view.fragment +import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import com.casic.app.smartwell.R import com.casic.app.smartwell.adapter.HomeRecycleAdapter import com.casic.app.smartwell.extensions.navigatePageTo import com.casic.app.smartwell.view.WellManagementActivity import com.casic.app.smartwell.view.WellOperationActivity +import com.casic.app.smartwell.vm.WellCountViewModel +import com.casic.app.smartwell.vm.WorkOrderViewModel import com.pengxh.app.multilib.base.BaseFragment import kotlinx.android.synthetic.main.fragment_home.* class HomePageFragment : BaseFragment() { + + private lateinit var wellCountViewModel: WellCountViewModel + private lateinit var workOrderViewModel: WorkOrderViewModel + override fun initLayoutView(): Int = R.layout.fragment_home override fun initData() { @@ -27,9 +34,37 @@ } } }) + wellCountViewModel = ViewModelProvider(this).get(WellCountViewModel::class.java) + workOrderViewModel = ViewModelProvider(this).get(WorkOrderViewModel::class.java) } override fun initEvent() { } + + override fun onResume() { + super.onResume() + //每次页面切换都需要重新刷新不同状态的窨井数量 + wellCountViewModel.countWellByState() + wellCountViewModel.resultModel.observe(this, { + unDeployedWellView.text = it["bfWell"] + deployedWellView.text = it["cfWell"] + allWellDataView.text = it["total"] + }) + workOrderViewModel.countWorkOrderByState() + workOrderViewModel.resultModel.observe(this, { + if (it["beforeGet"]!!.length > 4 || it["beforeConfirm"]!!.length > 4 || + it["inHandle"]!!.length > 4 || it["over"]!!.length > 4 + ) { + todoDataView.textSize = 36f + undeterminedDataView.textSize = 36f + inHandleDataView.textSize = 36f + completedDataView.textSize = 36f + } + todoDataView.text = it["beforeGet"] + undeterminedDataView.text = it["beforeConfirm"] + inHandleDataView.text = it["inHandle"] + completedDataView.text = it["over"] + }) + } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt new file mode 100644 index 0000000..363e46b --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellCountViewModel.kt @@ -0,0 +1,31 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WellCountViewModel : BaseViewModel() { + private val kTag = "WellCountViewModel" + val resultModel = MutableLiveData>() + + fun countWellByState() = launch({ + val resultJson = RetrofitServiceManager.countWellByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(3) + val data = jsonObject.getJSONObject("data") + map["bfWell"] = data.getString("bfWell") + map["cfWell"] = data.getString("cfWell") + map["total"] = data.getString("total") + resultModel.value = map + } else { + Log.d(kTag, "obtainWellCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWellCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt new file mode 100644 index 0000000..e28026e --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/vm/WorkOrderViewModel.kt @@ -0,0 +1,32 @@ +package com.casic.app.smartwell.vm + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import com.casic.app.smartwell.base.BaseViewModel +import com.casic.app.smartwell.extensions.launch +import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager +import org.json.JSONObject + +class WorkOrderViewModel : BaseViewModel() { + private val kTag = "WorkOrderViewModel" + val resultModel = MutableLiveData>() + + fun countWorkOrderByState() = launch({ + val resultJson = RetrofitServiceManager.countWorkOrderByState() + val jsonObject = JSONObject(resultJson) + val code = jsonObject.getInt("code") + if (code == 200) { + val map = HashMap(4) + val data = jsonObject.getJSONObject("data") + map["beforeGet"] = data.getString("beforeGet") + map["beforeConfirm"] = data.getString("beforeConfirm") + map["inHandle"] = data.getString("inHandle") + map["over"] = data.getString("over") + resultModel.value = map + } else { + Log.d(kTag, "obtainWorkOrderCountByState: 错误码===>${code}") + } + }, { + Log.d(kTag, "obtainWorkOrderCountByState: ${it.printStackTrace()}") + }) +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index d3ceafb..469789d 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -36,6 +36,51 @@ android:textSize="@dimen/titleFontSize" /> + + + + + + + + + + + + + + + + + + + + + + + + @@ -62,6 +107,64 @@ android:textSize="@dimen/titleFontSize" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c100e72..9126849 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,7 +5,8 @@ #F7F7F7 #CCCCCC #13AD00 - #F86364 + #FF6F70 + #FFCA18 #54FFFFFF #54000000 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 6839610..09b76ca 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -3,6 +3,7 @@ 16sp 18sp 20sp + 50sp 3dp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 54690cb..c049162 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -92,4 +92,30 @@ @anim/activity_in @anim/activity_out + + + + + + + + +