气象 历史数据 页面完成部分

master
wenfei 3 months ago
parent d4a66fc7e3
commit d0a99cd4d1

@ -1209,7 +1209,11 @@
<activity
android:name=".ui.activity.WeatherActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" /> <!-- 作业风险清单 -->
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name=".ui.activity.WeatherHistoryActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" />
<service
android:name=".service.PushService"
android:exported="false" />

@ -0,0 +1,60 @@
package com.rehome.zhdcoa.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.rehome.zhdcoa.base.BaseViewBindingAdapter;
import com.rehome.zhdcoa.bean.WeatherHistoryBean;
import com.rehome.zhdcoa.databinding.AdapterWeatherHistoryBinding;
import java.util.List;
public class WeatherHistoryAdapter extends BaseViewBindingAdapter<AdapterWeatherHistoryBinding> {
private List<WeatherHistoryBean.DataBean> datas;
public WeatherHistoryAdapter(Context context, List<WeatherHistoryBean.DataBean> datas) {
super(context);
this.datas = datas;
}
@Override
protected void handleData(int position, AdapterWeatherHistoryBinding binding) {
WeatherHistoryBean.DataBean item = datas.get(position);
if (item != null) {
binding.tvTime.setText(item.getTime());
binding.tvValue.setText(item.getVal());
}
}
@Override
protected AdapterWeatherHistoryBinding getBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup parent) {
return AdapterWeatherHistoryBinding.inflate(inflater, parent, false);
}
@Override
public int getCount() {
return datas.size();
}
@Override
public Object getItem(int position) {
return datas.get(position);
}
@Override
public long getItemId(int position) {
return Long.valueOf(position);
}
public interface OnWorkRiskLevelClickListener {
void onItemClick(int position);
}
public interface OnWorkRiskContentlickListener {
void onItemClick(int position);
}
public interface OnPaoHaolickListener {
void onItemClick(int position);
}
}

@ -0,0 +1,54 @@
package com.rehome.zhdcoa.bean;
import java.util.List;
public class WeatherHistoryBean extends AIBaseBean{
private int TotalPage;
private int Total;
private List<DataBean> data;
public int getTotalPage() {
return TotalPage;
}
public void setTotalPage(int totalPage) {
TotalPage = totalPage;
}
public int getTotal() {
return Total;
}
public void setTotal(int total) {
Total = total;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean {
private String time;
private String val;
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getVal() {
return val;
}
public void setVal(String val) {
this.val = val;
}
}
}

@ -37,30 +37,6 @@ import javax.net.ssl.HostnameVerifier
*/
class WeatherActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherBinding>() {
private lateinit var headView: View
private var datas: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private lateinit var mAdapter: WorkRiskLevelListAdapter
private var selectList: MutableList<Int> = mutableListOf()
private var jobNoList: MutableList<String> = mutableListOf()
private var selectListAssistant: MutableList<Int> = mutableListOf()
private var jobNoListAssistant: MutableList<String> = mutableListOf()
private var selectListCustom: MutableList<Int> = mutableListOf()
private var jobNoListCustom: MutableList<String> = mutableListOf()
private var dataA: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataB: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataC1: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataC2: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataC3: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataLowRisk: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
override fun getViewBinding() = ActivityWeatherBinding.inflate(layoutInflater)
override fun getToolbar() = binding.toolbarView.toolbar
@ -106,13 +82,13 @@ class WeatherActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherBinding>
binding.rlQiya.setOnClickListener {
showHistoryPage("大气气压")
}
binding.rlFengqiang.setOnClickListener {
binding.rlFengshu.setOnClickListener {
showHistoryPage("实时风速")
}
binding.rlYuliang.setOnClickListener {
binding.rlFengqiang.setOnClickListener {
showHistoryPage("实时风向")
}
binding.rlFengshu.setOnClickListener {
binding.rlYuliang.setOnClickListener {
showHistoryPage("日雨量累计")
}
}
@ -122,10 +98,9 @@ class WeatherActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherBinding>
}
private fun showHistoryPage(type: String) {
val intent = Intent(context, WorkTickerAssistantSelectListActivity::class.java)
val intent = Intent(context, WeatherHistoryActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("selectList", GsonUtils.GsonString(selectListAssistant))
intent.putExtra("jobNoList", GsonUtils.GsonString(jobNoListAssistant))
intent.putExtra("dataType", type)
startActivity(intent)
}
@ -173,14 +148,4 @@ class WeatherActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherBinding>
}
})
}
private fun toWorkRiskListHuiBaoActivity(type:String){
//工作情况汇报
val intent = Intent(context, WorkRiskListHuiBaoActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("type",type)
startActivity(intent)
}
}

@ -0,0 +1,190 @@
package com.rehome.zhdcoa.ui.activity
import android.annotation.SuppressLint
import android.content.Intent
import android.text.TextUtils
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.R
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.bean.WeatherHistoryBean
import com.rehome.zhdcoa.bean.WeatherRealDataBean
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.ActivityWorkRiskListBinding
import com.rehome.zhdcoa.utils.AuthenticationLoginAIUtils
import com.rehome.zhdcoa.utils.GsonUtils
import com.rehome.zhdcoa.utils.HttpListener
import com.rehome.zhdcoa.utils.NohttpUtils
import com.rehome.zhdcoa.utils.RSAAndroid
import com.yolanda.nohttp.NoHttp
import com.yolanda.nohttp.RequestMethod
import com.yolanda.nohttp.rest.Response
import java.text.SimpleDateFormat
import java.util.Calendar
/**
* Create By HuangWenFei
* 创建日期2025-09-19 16:51
* 描述气象 历史数据
*/
class WeatherHistoryActivity : BaseActivityOaToolbarViewBinding<ActivityWeatherHistoryBinding>() {
private lateinit var headView: View
private var datas: MutableList<WeatherHistoryBean.DataBean> = mutableListOf()
private lateinit var mAdapter: WeatherHistoryAdapter
private lateinit var dataType: String
private var selectList: MutableList<Int> = mutableListOf()
private var jobNoList: MutableList<String> = mutableListOf()
private var selectListAssistant: MutableList<Int> = mutableListOf()
private var jobNoListAssistant: MutableList<String> = mutableListOf()
private var selectListCustom: MutableList<Int> = mutableListOf()
private var jobNoListCustom: MutableList<String> = mutableListOf()
private var dataA: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataB: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataC1: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataC2: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataC3: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var dataLowRisk: MutableList<WorkRiskLevelListBean.RowsBean> = mutableListOf()
private var page = 1
private var pageSize = 500
override fun getViewBinding() = ActivityWeatherHistoryBinding.inflate(layoutInflater)
override fun getToolbar() = binding.toolbarView.toolbar
override fun initView() {
initToolbar("历史数据", "", {
})
dataType = intent.getStringExtra("dataType").toString()
binding.itemHead.tvDataType.text = dataType
// item_weather_list
// item_weather_header
//格式化日期的对象(转化成习惯的时间格式)
val sdFormat = SimpleDateFormat("yyyy.MM.dd HH:mm:ss")
//静态方法getInstance()使用默认时区和语言环境获得一个日历。
val calendar = Calendar.getInstance()
//输出当前系统时间;
//binding.tvTime.text = sdFormat.format(calendar.time)
binding.lv.emptyView = binding.tvNodata
binding.tvNodata.visibility = View.VISIBLE
binding.lv.visibility = View.GONE
mAdapter = WeatherHistoryAdapter(this, datas)
binding.lv.adapter = mAdapter
}
@SuppressLint("SimpleDateFormat")
override fun initData() {
//格式化日期的对象(转化成习惯的时间格式)
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
//静态方法getInstance()使用默认时区和语言环境获得一个日历。
val calendarSt = Calendar.getInstance()
val calendarEt = Calendar.getInstance()
calendarSt.add(Calendar.HOUR, -2)
val st = sdf.format(calendarSt.time)
val et = sdf.format(calendarEt.time)
requestData(st, et);
}
private fun requestData(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
)
if (bean != null && bean.code == 1 && bean.data != null && bean.data.size > 0) {
binding.tvNodata.visibility = View.GONE
binding.lv.visibility = View.VISIBLE
datas.clear()
datas.addAll(bean.data)
mAdapter.notifyDataSetChanged()
} else {
binding.tvNodata.visibility = View.VISIBLE
binding.lv.visibility = View.GONE
}
}
override fun onFailed(what: Int, response: Response<String?>?) {
}
})
}
private fun toWorkRiskListHuiBaoActivity(type: String) {
//工作情况汇报
val intent = Intent(context, WorkRiskListHuiBaoActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("type", type)
startActivity(intent)
}
}

@ -283,7 +283,7 @@
android:layout_marginStart="12dp"
android:text="0"
android:textColor="#000000"
android:textSize="20sp" />
android:textSize="15sp" />
<TextView
android:layout_width="match_parent"
@ -294,7 +294,7 @@
android:layout_marginEnd="12dp"
android:text="hpa"
android:textColor="#000000"
android:textSize="18sp" />
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.activity.WeatherHistoryActivity">
<include
android:id="@+id/toolbarView"
layout="@layout/layout_base" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:background="#cccccc"
android:minHeight="40dp">
<TextView
android:id="@+id/tv_st"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5px"
android:layout_weight="1"
android:gravity="center"
android:text="点击选择开始时间"
android:textSize="18sp" />
<TextView
android:layout_width="30dp"
android:layout_height="match_parent"
android:layout_margin="5px"
android:gravity="center"
android:textStyle="bold"
android:text="-"
android:textSize="20sp" />
<TextView
android:id="@+id/tv_et"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5px"
android:layout_weight="1"
android:gravity="center"
android:text="点击选择结束时间"
android:textSize="18sp" />
</LinearLayout>
<include
android:id="@+id/item_head"
layout="@layout/item_weather_header"
android:layout_width="match_parent"
android:layout_marginTop="5dp"
android:layout_height="40dp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp">
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
android:dividerHeight="0px"/>
<TextView
android:id="@+id/tv_nodata"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/viewfinder_mask"
android:gravity="center"
android:text="暂无数据"/>
</FrameLayout>
</LinearLayout>

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:orientation="vertical">
<View
android:id="@+id/head"
android:layout_width="match_parent"
android:layout_height="2dp"
android:visibility="gone"
android:background="#999999"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_time"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.7"
android:gravity="center"
android:textColor="#666666"
android:text="2025-09-18 09:45:09" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#999999" />
<TextView
android:id="@+id/tv_value"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="0.7"
android:textColor="#333333"
android:text="31.6" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#999999" />
</LinearLayout>

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:orientation="vertical">
<View
android:id="@+id/head"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#999999"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_paiHao"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.7"
android:gravity="center"
android:textColor="#666666"
android:textSize="18sp"
android:text="更新时间" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#999999" />
<TextView
android:id="@+id/tv_data_type"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="0.7"
android:textColor="#333333"
android:textSize="18sp"
android:text="大气温度" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#999999" />
</LinearLayout>

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:orientation="vertical">
<View
android:id="@+id/head"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#999999"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_time"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.7"
android:gravity="center"
android:textColor="#666666"
android:text="2025-09-18 09:45:09" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#999999" />
<TextView
android:id="@+id/tv_value"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="0.7"
android:textColor="#333333"
android:text="31.6" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#999999" />
</LinearLayout>
Loading…
Cancel
Save