|
|
|
@ -3,30 +3,18 @@ package com.rehome.zhdcoa.ui.activity
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
|
import android.annotation.SuppressLint
|
|
|
|
import android.content.Intent
|
|
|
|
import android.content.Intent
|
|
|
|
import android.text.TextUtils
|
|
|
|
|
|
|
|
import android.view.View
|
|
|
|
import android.view.View
|
|
|
|
import android.widget.TextView
|
|
|
|
|
|
|
|
import androidx.activity.result.ActivityResultLauncher
|
|
|
|
|
|
|
|
import androidx.activity.result.contract.ActivityResultContracts
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.Contans
|
|
|
|
import com.rehome.zhdcoa.Contans
|
|
|
|
import com.rehome.zhdcoa.R
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.adapter.WeatherHistoryAdapter
|
|
|
|
import com.rehome.zhdcoa.adapter.WeatherHistoryAdapter
|
|
|
|
import com.rehome.zhdcoa.adapter.WorkRiskLevelListAdapter
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarTwoViewBinding
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
|
|
|
|
import com.rehome.zhdcoa.bean.WeatherHistoryBean
|
|
|
|
import com.rehome.zhdcoa.bean.WeatherHistoryBean
|
|
|
|
import com.rehome.zhdcoa.bean.WeatherRealDataBean
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.bean.WorkRiskLevelListBean
|
|
|
|
import com.rehome.zhdcoa.bean.WorkRiskLevelListBean
|
|
|
|
import com.rehome.zhdcoa.completionUtil.ReplaceSpan
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.completionUtil.ReplaceSpan.OnClickListener
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.databinding.ActivityWeatherBinding
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.databinding.ActivityWeatherHistoryBinding
|
|
|
|
import com.rehome.zhdcoa.databinding.ActivityWeatherHistoryBinding
|
|
|
|
import com.rehome.zhdcoa.databinding.ActivityWorkRiskListBinding
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.AuthenticationLoginAIUtils
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.GsonUtils
|
|
|
|
import com.rehome.zhdcoa.utils.GsonUtils
|
|
|
|
import com.rehome.zhdcoa.utils.HttpListener
|
|
|
|
import com.rehome.zhdcoa.utils.HttpListener
|
|
|
|
import com.rehome.zhdcoa.utils.NohttpUtils
|
|
|
|
import com.rehome.zhdcoa.utils.NohttpUtils
|
|
|
|
import com.rehome.zhdcoa.utils.RSAAndroid
|
|
|
|
import com.rehome.zhdcoa.weiget.DateTimeMinutePickDialog
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.weiget.LoadListView
|
|
|
|
import com.yolanda.nohttp.NoHttp
|
|
|
|
import com.yolanda.nohttp.NoHttp
|
|
|
|
import com.yolanda.nohttp.RequestMethod
|
|
|
|
import com.yolanda.nohttp.RequestMethod
|
|
|
|
import com.yolanda.nohttp.rest.Response
|
|
|
|
import com.yolanda.nohttp.rest.Response
|
|
|
|
@ -66,6 +54,12 @@ class WeatherHistoryActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherH
|
|
|
|
private var page = 1
|
|
|
|
private var page = 1
|
|
|
|
private var pageSize = 500
|
|
|
|
private var pageSize = 500
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lateinit var calendarSt: Calendar
|
|
|
|
|
|
|
|
private lateinit var calendarEt: Calendar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//格式化日期的对象(转化成习惯的时间格式)
|
|
|
|
|
|
|
|
private val sdFormat = SimpleDateFormat("yyyy-MM-dd HH:mm")
|
|
|
|
|
|
|
|
|
|
|
|
override fun getViewBinding() = ActivityWeatherHistoryBinding.inflate(layoutInflater)
|
|
|
|
override fun getViewBinding() = ActivityWeatherHistoryBinding.inflate(layoutInflater)
|
|
|
|
|
|
|
|
|
|
|
|
override fun getToolbar() = binding.toolbarView.toolbar
|
|
|
|
override fun getToolbar() = binding.toolbarView.toolbar
|
|
|
|
@ -78,6 +72,8 @@ class WeatherHistoryActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherH
|
|
|
|
dataType = intent.getStringExtra("dataType").toString()
|
|
|
|
dataType = intent.getStringExtra("dataType").toString()
|
|
|
|
binding.itemHead.tvDataType.text = dataType
|
|
|
|
binding.itemHead.tvDataType.text = dataType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resetToday()
|
|
|
|
|
|
|
|
|
|
|
|
// item_weather_list
|
|
|
|
// item_weather_list
|
|
|
|
// item_weather_header
|
|
|
|
// item_weather_header
|
|
|
|
|
|
|
|
|
|
|
|
@ -94,21 +90,76 @@ class WeatherHistoryActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherH
|
|
|
|
mAdapter = WeatherHistoryAdapter(this, datas)
|
|
|
|
mAdapter = WeatherHistoryAdapter(this, datas)
|
|
|
|
binding.lv.adapter = mAdapter
|
|
|
|
binding.lv.adapter = mAdapter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.lv.setInterface(LoadListView.ILoadListener {
|
|
|
|
|
|
|
|
loadMoreData()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.tvSt.setOnClickListener(View.OnClickListener { view: View? ->
|
|
|
|
|
|
|
|
val dialog = DateTimeMinutePickDialog(
|
|
|
|
|
|
|
|
context, calendarSt, true,true,
|
|
|
|
|
|
|
|
) { outPutDate: String?, outPutDate1: String?, outPutDate2: String? ->
|
|
|
|
|
|
|
|
binding.tvSt.text = outPutDate
|
|
|
|
|
|
|
|
val st = sdFormat.format(calendarSt.time)
|
|
|
|
|
|
|
|
val et = sdFormat.format(calendarEt.time)
|
|
|
|
|
|
|
|
page = 1
|
|
|
|
|
|
|
|
requestData(st, et);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog.show()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
binding.tvEt.setOnClickListener(View.OnClickListener { view: View? ->
|
|
|
|
|
|
|
|
val dialog = DateTimeMinutePickDialog(
|
|
|
|
|
|
|
|
context, calendarEt, true,true,
|
|
|
|
|
|
|
|
) { outPutDate: String?, outPutDate1: String?, outPutDate2: String? ->
|
|
|
|
|
|
|
|
binding.tvEt.text = outPutDate
|
|
|
|
|
|
|
|
val st = sdFormat.format(calendarSt.time)
|
|
|
|
|
|
|
|
val et = sdFormat.format(calendarEt.time)
|
|
|
|
|
|
|
|
page = 1
|
|
|
|
|
|
|
|
requestData(st, et);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog.show()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
|
override fun initData() {
|
|
|
|
override fun initData() {
|
|
|
|
//格式化日期的对象(转化成习惯的时间格式)
|
|
|
|
//格式化日期的对象(转化成习惯的时间格式)
|
|
|
|
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
|
|
|
//val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
|
|
|
//静态方法getInstance()使用默认时区和语言环境获得一个日历。
|
|
|
|
//静态方法getInstance()使用默认时区和语言环境获得一个日历。
|
|
|
|
val calendarSt = Calendar.getInstance()
|
|
|
|
// calendarSt = Calendar.getInstance()
|
|
|
|
val calendarEt = Calendar.getInstance()
|
|
|
|
// calendarEt = Calendar.getInstance()
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// calendarSt.add(Calendar.HOUR, -2)
|
|
|
|
|
|
|
|
val st = sdFormat.format(calendarSt.time)
|
|
|
|
|
|
|
|
val et = sdFormat.format(calendarEt.time)
|
|
|
|
|
|
|
|
requestData(st, et)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun resetToday(){
|
|
|
|
|
|
|
|
//开始时间
|
|
|
|
|
|
|
|
calendarSt = Calendar.getInstance()
|
|
|
|
calendarSt.add(Calendar.HOUR, -2)
|
|
|
|
calendarSt.add(Calendar.HOUR, -2)
|
|
|
|
val st = sdf.format(calendarSt.time)
|
|
|
|
calendarSt.set(
|
|
|
|
val et = sdf.format(calendarEt.time)
|
|
|
|
calendarSt.get(Calendar.YEAR), calendarSt.get(Calendar.MONTH),
|
|
|
|
|
|
|
|
calendarSt.get(Calendar.DAY_OF_MONTH), calendarSt.get(Calendar.HOUR_OF_DAY),
|
|
|
|
|
|
|
|
calendarSt.get(Calendar.MINUTE), 0)
|
|
|
|
|
|
|
|
val startDateStr = sdFormat.format(calendarSt.time)
|
|
|
|
|
|
|
|
binding.tvSt.text = startDateStr
|
|
|
|
|
|
|
|
//结束时间
|
|
|
|
|
|
|
|
calendarEt = Calendar.getInstance()
|
|
|
|
|
|
|
|
calendarEt.set(
|
|
|
|
|
|
|
|
calendarEt.get(Calendar.YEAR), calendarEt.get(Calendar.MONTH),
|
|
|
|
|
|
|
|
calendarEt.get(Calendar.DAY_OF_MONTH), calendarEt.get(Calendar.HOUR_OF_DAY),
|
|
|
|
|
|
|
|
calendarEt.get(Calendar.MINUTE), 0)
|
|
|
|
|
|
|
|
val endDateStr = sdFormat.format(calendarEt.time)
|
|
|
|
|
|
|
|
binding.tvEt.text = endDateStr
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
requestData(st, et);
|
|
|
|
private fun loadMoreData() {
|
|
|
|
|
|
|
|
val st = sdFormat.format(calendarSt.time)
|
|
|
|
|
|
|
|
val et = sdFormat.format(calendarEt.time)
|
|
|
|
|
|
|
|
requestLoadMoreData(st, et)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun requestData(st: String, et: String) {
|
|
|
|
private fun requestData(st: String, et: String) {
|
|
|
|
@ -167,6 +218,7 @@ class WeatherHistoryActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherH
|
|
|
|
datas.clear()
|
|
|
|
datas.clear()
|
|
|
|
datas.addAll(bean.data)
|
|
|
|
datas.addAll(bean.data)
|
|
|
|
mAdapter.notifyDataSetChanged()
|
|
|
|
mAdapter.notifyDataSetChanged()
|
|
|
|
|
|
|
|
page++
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
binding.tvNodata.visibility = View.VISIBLE
|
|
|
|
binding.tvNodata.visibility = View.VISIBLE
|
|
|
|
binding.lv.visibility = View.GONE
|
|
|
|
binding.lv.visibility = View.GONE
|
|
|
|
@ -179,6 +231,71 @@ class WeatherHistoryActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherH
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun requestLoadMoreData(st: String, et: String) {
|
|
|
|
|
|
|
|
val request = NoHttp.createStringRequest(
|
|
|
|
|
|
|
|
Contans.BASE_URL + Contans.GET_WEATHER_HISTORY_DATA,
|
|
|
|
|
|
|
|
RequestMethod.GET
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
request.add("page", page)
|
|
|
|
|
|
|
|
request.add("pageSize", pageSize)
|
|
|
|
|
|
|
|
// request.add("dataType",dataType)
|
|
|
|
|
|
|
|
request.add("times", st)
|
|
|
|
|
|
|
|
request.add("timee", et)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("大气温度" == dataType) {
|
|
|
|
|
|
|
|
request.add("dataType", "E16")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("大气湿度" == dataType) {
|
|
|
|
|
|
|
|
request.add("dataType", "E14")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("大气气压" == dataType) {
|
|
|
|
|
|
|
|
request.add("dataType", "E15")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("实时风速" == dataType) {
|
|
|
|
|
|
|
|
request.add("dataType", "E1")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("实时风向" == dataType) {
|
|
|
|
|
|
|
|
request.add("dataType", "E12")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("日雨量累计" == dataType) {
|
|
|
|
|
|
|
|
request.add("dataType", "E4")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 数据类型:
|
|
|
|
|
|
|
|
// E1:风速(米/秒)
|
|
|
|
|
|
|
|
// E4:日雨量(毫米)
|
|
|
|
|
|
|
|
// E12:风向(度)
|
|
|
|
|
|
|
|
// E14:湿度(%)
|
|
|
|
|
|
|
|
// E15:气压(hPa)
|
|
|
|
|
|
|
|
// E16:气温(摄氏度)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onSucceed(what: Int, response: Response<String?>?) {
|
|
|
|
|
|
|
|
val result = response?.get()
|
|
|
|
|
|
|
|
showLog("----------------")
|
|
|
|
|
|
|
|
showLog(result)
|
|
|
|
|
|
|
|
val bean = GsonUtils.GsonToBean(
|
|
|
|
|
|
|
|
result,
|
|
|
|
|
|
|
|
WeatherHistoryBean::class.java
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
binding.lv.loadComplete()
|
|
|
|
|
|
|
|
if (bean != null && bean.code == 1 && bean.data != null && bean.data.size > 0) {
|
|
|
|
|
|
|
|
datas.addAll(bean.data)
|
|
|
|
|
|
|
|
mAdapter.notifyDataSetChanged()
|
|
|
|
|
|
|
|
page++
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
showToast("没有更多数据啦")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onFailed(what: Int, response: Response<String?>?) {
|
|
|
|
|
|
|
|
binding.lv.loadComplete()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun toWorkRiskListHuiBaoActivity(type: String) {
|
|
|
|
private fun toWorkRiskListHuiBaoActivity(type: String) {
|
|
|
|
//工作情况汇报
|
|
|
|
//工作情况汇报
|
|
|
|
|