应急预案完成
parent
6d620ed42d
commit
08347a810c
@ -0,0 +1,5 @@
|
||||
package com.rehome.dywoa.Listener;
|
||||
|
||||
public interface OnActionClickListener {
|
||||
void onActionClick(int position);
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package com.rehome.dywoa.adapter
|
||||
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.rehome.dywoa.Listener.OnActionClickListener
|
||||
import com.rehome.dywoa.base.BaseViewBindingAdapter
|
||||
import com.rehome.dywoa.bean.YjyaActionBean
|
||||
import com.rehome.dywoa.databinding.AdapterYjyaActionListBinding
|
||||
import com.rehome.dywoa.ui.activity.RunLogBaseActivity
|
||||
|
||||
class YjyaActionListAdapter(var context: Context,
|
||||
var data: MutableList<YjyaActionBean.Row>,var mOnClickListener: OnActionClickListener
|
||||
) : BaseViewBindingAdapter<AdapterYjyaActionListBinding>(context) {
|
||||
|
||||
|
||||
override fun getCount(): Int {
|
||||
return data.count()
|
||||
}
|
||||
|
||||
override fun getItem(position: Int): Any {
|
||||
return data[position]
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return position.toLong()
|
||||
}
|
||||
|
||||
override fun getBinding(
|
||||
inflater: LayoutInflater,
|
||||
parent: ViewGroup?
|
||||
) = AdapterYjyaActionListBinding.inflate(inflater, parent, false)
|
||||
|
||||
override fun handleData(position: Int, binding: AdapterYjyaActionListBinding) {
|
||||
val item: YjyaActionBean.Row = data[position]
|
||||
binding.tvTitle.text = item.title
|
||||
binding.tvYjlx.text = item.type
|
||||
binding.tvYjbz.text = item.yjbz
|
||||
binding.tvWorkContent.text = item.workContent
|
||||
if(!TextUtils.isEmpty(item.zxzt)){
|
||||
if("0" == item.zxzt){
|
||||
binding.tvZxzt.text = "未执行"
|
||||
}
|
||||
if("1" == item.zxzt){
|
||||
binding.tvZxzt.text = "已执行"
|
||||
}
|
||||
}
|
||||
|
||||
binding.tvStatus.setOnClickListener {
|
||||
mOnClickListener.onActionClick(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package com.rehome.dywoa.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class YjyaActionBean extends BaseListBean{
|
||||
|
||||
private List<Row> Rows;
|
||||
|
||||
public List<Row> getRows() {
|
||||
return Rows;
|
||||
}
|
||||
|
||||
public void setRows(List<Row> rows) {
|
||||
Rows = rows;
|
||||
}
|
||||
|
||||
public static class Row {
|
||||
private String zxid;
|
||||
private String title;
|
||||
private String type;
|
||||
private String yjbz;
|
||||
private String workContent;
|
||||
private String zxzt;
|
||||
|
||||
public String getZxid() {
|
||||
return zxid;
|
||||
}
|
||||
|
||||
public void setZxid(String zxid) {
|
||||
this.zxid = zxid;
|
||||
}
|
||||
|
||||
public String getZxzt() {
|
||||
return zxzt;
|
||||
}
|
||||
|
||||
public void setZxzt(String zxzt) {
|
||||
this.zxzt = zxzt;
|
||||
}
|
||||
|
||||
public String getWorkContent() {
|
||||
return workContent;
|
||||
}
|
||||
|
||||
public void setWorkContent(String workContent) {
|
||||
this.workContent = workContent;
|
||||
}
|
||||
|
||||
public String getYjbz() {
|
||||
return yjbz;
|
||||
}
|
||||
|
||||
public void setYjbz(String yjbz) {
|
||||
this.yjbz = yjbz;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,174 @@
|
||||
package com.rehome.dywoa.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.AdapterView
|
||||
import com.rehome.dywoa.App
|
||||
import com.rehome.dywoa.Contans
|
||||
import com.rehome.dywoa.adapter.YjyaActionListAdapter
|
||||
import com.rehome.dywoa.base.BaseActivityOaToolbarViewBinding
|
||||
import com.rehome.dywoa.bean.StatusInfo
|
||||
import com.rehome.dywoa.bean.YjyaActionBean
|
||||
import com.rehome.dywoa.databinding.ActivityYjyaActionBinding
|
||||
import com.rehome.dywoa.utils.GsonUtils
|
||||
import com.rehome.dywoa.utils.HttpListener
|
||||
import com.rehome.dywoa.utils.NoProgresshttpUtils
|
||||
import com.rehome.dywoa.utils.NohttpUtils
|
||||
import com.yolanda.nohttp.NoHttp
|
||||
import com.yolanda.nohttp.RequestMethod
|
||||
import com.yolanda.nohttp.rest.Response
|
||||
|
||||
class YjyaActionActivity : BaseActivityOaToolbarViewBinding<ActivityYjyaActionBinding>() {
|
||||
|
||||
private lateinit var adapter: YjyaActionListAdapter
|
||||
private var datas: MutableList<YjyaActionBean.Row> = mutableListOf()
|
||||
private lateinit var username: String
|
||||
|
||||
|
||||
override fun getViewBinding() = ActivityYjyaActionBinding.inflate(layoutInflater)
|
||||
|
||||
override fun getToolbar() = binding.toolbarView.toolbar
|
||||
|
||||
override fun initView() {
|
||||
initToolbar("应急预案执行状态", "") {
|
||||
|
||||
}
|
||||
|
||||
username = App.getInstance().userInfo.manid
|
||||
adapter = YjyaActionListAdapter(context, datas
|
||||
) { position ->
|
||||
var item = datas[position]
|
||||
getActionTrigger(item)
|
||||
}
|
||||
|
||||
binding.lv.adapter = adapter
|
||||
binding.tvNodata.visibility= View.VISIBLE
|
||||
binding.lv.visibility= View.GONE
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
//检查服务器连接状态
|
||||
checkServerConnectStatus()
|
||||
}
|
||||
|
||||
//检查服务器连接状态
|
||||
private fun checkServerConnectStatus() {
|
||||
var param = HashMap<String,String>()
|
||||
param["login"] = "dywoa";
|
||||
val json = GsonUtils.GsonString(param)
|
||||
val url = Contans.IP + Contans.check_server_connect
|
||||
Log.i("app",url)
|
||||
Log.i("app",json)
|
||||
val request = NoHttp.createStringRequest(
|
||||
url,
|
||||
RequestMethod.POST
|
||||
)
|
||||
request.setDefineRequestBodyForJson(json)
|
||||
NoProgresshttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
|
||||
override fun onSucceed(what: Int, response: Response<String?>?) {
|
||||
val result = response?.get()
|
||||
if (result != null) {
|
||||
showLog("-----onSucceed----")
|
||||
showLog(result)
|
||||
if(result == "1"){
|
||||
showLog("connect server success")
|
||||
//获取数据
|
||||
getListData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(what: Int, response: Response<String?>?) {
|
||||
showLog("connect server onFailed")
|
||||
showToast("无法连接到服务器,请检查网络环境")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun getListData() {
|
||||
|
||||
var yaid = intent.getStringExtra("YAID");
|
||||
if(yaid==null){
|
||||
showLog("预案id不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
var param = HashMap<String,String>()
|
||||
param["GH"] = username
|
||||
param["YAID"] = yaid
|
||||
val json = GsonUtils.GsonString(param)
|
||||
|
||||
val url: String = Contans.IP + Contans.YJYA_GET_ACTION_LIST
|
||||
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
||||
request.setDefineRequestBodyForJson(json)
|
||||
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String> {
|
||||
override fun onSucceed(what: Int, response: Response<String>?) {
|
||||
if (response != null) {
|
||||
val result = response.get()
|
||||
showLog(result)
|
||||
val bean = GsonUtils.GsonToBean(result, YjyaActionBean::class.java)
|
||||
if (bean != null && bean.total != 0) {
|
||||
if (bean.rows != null && bean.rows.size>0) {
|
||||
datas.clear()
|
||||
datas.addAll(bean.rows)
|
||||
adapter.notifyDataSetChanged()
|
||||
binding.tvNodata.visibility= View.GONE
|
||||
binding.lv.visibility=View.VISIBLE
|
||||
}else {
|
||||
datas.clear()
|
||||
adapter.notifyDataSetChanged()
|
||||
binding.tvNodata.visibility= View.VISIBLE
|
||||
binding.lv.visibility=View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(what: Int, response: Response<String>?) {
|
||||
|
||||
}
|
||||
|
||||
}, true, true, "正在加载数据...")
|
||||
}
|
||||
|
||||
private fun getActionTrigger(item:YjyaActionBean.Row) {
|
||||
|
||||
var param = HashMap<String,String>()
|
||||
param["ZXID"] = item.zxid
|
||||
param["YHID"] = username
|
||||
val json = GsonUtils.GsonString(param)
|
||||
|
||||
val url: String = Contans.IP + Contans.YJYA_ACTION_URL
|
||||
val request = NoHttp.createStringRequest(url, RequestMethod.POST)
|
||||
request.setDefineRequestBodyForJson(json)
|
||||
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String> {
|
||||
override fun onSucceed(what: Int, response: Response<String>?) {
|
||||
if (response != null) {
|
||||
val result = response.get()
|
||||
showLog(result)
|
||||
val bean = GsonUtils.GsonToBean(result, StatusInfo::class.java)
|
||||
if (bean != null) {
|
||||
if (bean.state == 1) {
|
||||
|
||||
showToast("执行成功")
|
||||
//检查服务器连接状态
|
||||
checkServerConnectStatus()
|
||||
}
|
||||
if (bean.state == 2) {
|
||||
showToast("执行失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(what: Int, response: Response<String>?) {
|
||||
|
||||
}
|
||||
|
||||
}, true, true, "正在加载数据...")
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
<?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.YjyaActionActivity">>
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbarView"
|
||||
android:visibility="visible"
|
||||
layout="@layout/layout_base" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/lv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@color/gray"
|
||||
android:dividerHeight="1dp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_nodata"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="暂无数据" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@ -0,0 +1,224 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/ll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10px"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60px">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50px"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center"
|
||||
android:text="标题:"
|
||||
android:textSize="30px" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center|left"
|
||||
android:minHeight="50px"
|
||||
android:textSize="30px" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60px">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50px"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center"
|
||||
android:text="应急预案类型:"
|
||||
android:textSize="30px" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_yjlx"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center|left"
|
||||
android:minHeight="50px"
|
||||
android:textSize="30px" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60px">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50px"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center"
|
||||
android:text="应急班组:"
|
||||
android:textSize="30px" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_yjbz"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center|left"
|
||||
android:minHeight="50px"
|
||||
android:textSize="30px" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60px">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50px"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center"
|
||||
android:text="工作内容:"
|
||||
android:textSize="30px" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_work_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center|left"
|
||||
android:minHeight="50px"
|
||||
android:textSize="30px" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:minHeight="60px">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50px"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center"
|
||||
android:text="执行人:"
|
||||
android:textSize="30px" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_factoryInCharge"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center|left"
|
||||
android:minHeight="50px"
|
||||
android:textSize="30px" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="60px">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50px"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center"
|
||||
android:text="执行状态:"
|
||||
android:textSize="30px" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_zxzt"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/green"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center|left"
|
||||
android:minHeight="50px"
|
||||
android:textSize="30px" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:minHeight="60px">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50px"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center"
|
||||
android:text="录入人:"
|
||||
android:textSize="30px" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_requestPersion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center|left"
|
||||
android:minHeight="50px"
|
||||
android:textSize="30px" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:minHeight="60px">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50px"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center"
|
||||
android:text="录入时间:"
|
||||
android:textSize="30px" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_applyTime"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5px"
|
||||
android:gravity="center|left"
|
||||
android:minHeight="50px"
|
||||
android:textSize="30px" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="7">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginRight="10dp"
|
||||
android:background="@drawable/btn_selector"
|
||||
android:gravity="center"
|
||||
android:padding="15px"
|
||||
android:text="执行"
|
||||
android:textColor="@color/textstatus1" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
Loading…
Reference in New Issue