|
|
|
|
@ -0,0 +1,252 @@
|
|
|
|
|
package com.rehome.zhdcoa.ui.activity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.WorkRiskLevelListAdapter
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarTwoViewBinding
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
|
|
|
|
|
import com.rehome.zhdcoa.bean.WorkRiskLevelListBean
|
|
|
|
|
import com.rehome.zhdcoa.completionUtil.ReplaceSpan
|
|
|
|
|
import com.rehome.zhdcoa.completionUtil.ReplaceSpan.OnClickListener
|
|
|
|
|
import com.rehome.zhdcoa.databinding.ActivityDeviceAlarmInfofoBinding
|
|
|
|
|
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
|
|
|
|
|
import javax.net.ssl.HostnameVerifier
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create By HuangWenFei
|
|
|
|
|
* 创建日期:2024-04-02 14:34
|
|
|
|
|
* 描述:每日作业风险清单
|
|
|
|
|
*/
|
|
|
|
|
class DeviceAlarmInfofoActivity : BaseActivityOaToolbarViewBinding<ActivityDeviceAlarmInfofoBinding>() {
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
private var isNetworkNormal = false
|
|
|
|
|
|
|
|
|
|
private lateinit var launcherResultQRCode: ActivityResultLauncher<Intent>
|
|
|
|
|
|
|
|
|
|
override fun getViewBinding() = ActivityDeviceAlarmInfofoBinding.inflate(layoutInflater)
|
|
|
|
|
|
|
|
|
|
override fun getToolbar() = binding.toolbarView.toolbar
|
|
|
|
|
|
|
|
|
|
override fun initView() {
|
|
|
|
|
|
|
|
|
|
initToolbar("设备预警信息", "",{
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
launcherResultQRCode = createQRCodeActivityResultLauncher()
|
|
|
|
|
|
|
|
|
|
binding.lv.emptyView = binding.tvNodata
|
|
|
|
|
headView = View.inflate(this, R.layout.item_work_risk_list, null)
|
|
|
|
|
|
|
|
|
|
mAdapter = WorkRiskLevelListAdapter(this,datas,
|
|
|
|
|
{ position ->
|
|
|
|
|
val item = datas[position]
|
|
|
|
|
if(item.hazardList!=null&&item.hazardList.size>0){
|
|
|
|
|
//进入风险提示页面
|
|
|
|
|
val intent = Intent(context, WorkRiskListTipActivity::class.java)
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
|
|
|
intent.putExtra("hazardList", GsonUtils.GsonString(item.hazardList))
|
|
|
|
|
startActivity(intent)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ position ->
|
|
|
|
|
val item = datas[position]
|
|
|
|
|
if(item.hazardList!=null&&item.hazardList.size>0){
|
|
|
|
|
//进入修改风险等级
|
|
|
|
|
val intent = Intent(context, CustomDialogChangeLevelActivity::class.java)
|
|
|
|
|
intent.putExtra("id",item.id)
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
|
|
|
intent.putExtra("level", item.level)
|
|
|
|
|
intent.putExtra("type", item.type)
|
|
|
|
|
launcherResultQRCode.launch(intent)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ position ->
|
|
|
|
|
val item = datas[position]
|
|
|
|
|
showLog("---------")
|
|
|
|
|
showLog(GsonUtils.GsonString(item))
|
|
|
|
|
//工作情况汇报
|
|
|
|
|
val intent = Intent(context, WorkRiskListHuiBaoActivity::class.java)
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
|
|
|
intent.putExtra("level",item.level)
|
|
|
|
|
intent.putExtra("type",item.type)
|
|
|
|
|
intent.putExtra("id",item.id)
|
|
|
|
|
startActivity(intent)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
//binding.lv.addHeaderView(headView, null, false)
|
|
|
|
|
binding.lv.adapter = mAdapter
|
|
|
|
|
|
|
|
|
|
//格式化日期的对象(转化成习惯的时间格式)
|
|
|
|
|
val sdFormat = SimpleDateFormat("yyyy.MM.dd")
|
|
|
|
|
//静态方法getInstance()使用默认时区和语言环境获得一个日历。
|
|
|
|
|
val calendar = Calendar.getInstance()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun initData() {
|
|
|
|
|
authenticationLoginDeviceAlermInfo()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onRestart() {
|
|
|
|
|
super.onRestart()
|
|
|
|
|
authenticationLoginDeviceAlermInfo()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建一个ActivityResultLauncher
|
|
|
|
|
private fun createQRCodeActivityResultLauncher(): ActivityResultLauncher<Intent> {
|
|
|
|
|
//kotlin写法
|
|
|
|
|
return registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
|
|
|
|
val data = it.data
|
|
|
|
|
val resultCode = it.resultCode
|
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
|
if (data != null) {
|
|
|
|
|
val qrCodeStr = data.getStringExtra("code") ?: ""
|
|
|
|
|
showLog(qrCodeStr)
|
|
|
|
|
if(!TextUtils.isEmpty(qrCodeStr)){
|
|
|
|
|
//刷新列表数据
|
|
|
|
|
authenticationLoginDeviceAlermInfo()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun authenticationLoginDeviceAlermInfo() {
|
|
|
|
|
try {
|
|
|
|
|
//AI三维登录接口
|
|
|
|
|
val userName = Contans.SP.DeviceAlermInfoAccount
|
|
|
|
|
val strPrivateEncode = RSAAndroid.encryptByPrivateKeyForSpiltStr(Contans.SP.DeviceAlermInfoPwd,RSAAndroid.privateRsaKeyLocal)
|
|
|
|
|
val strPublicDecode = RSAAndroid.decryptByPublicKeyForSpiltStr(
|
|
|
|
|
Contans.SP.DeviceAlermInfoPwd,
|
|
|
|
|
RSAAndroid.publicRsaKeyLocal
|
|
|
|
|
)
|
|
|
|
|
showLog(userName)
|
|
|
|
|
showLog(strPublicDecode)
|
|
|
|
|
AuthenticationLoginAIUtils.authenticationDeviceAlermInfoShowProgress(
|
|
|
|
|
this, userName, strPublicDecode
|
|
|
|
|
) { _, token ->
|
|
|
|
|
if (token != null && token == "") {
|
|
|
|
|
showToast("设备状态智能监测及分析平台登录失败")
|
|
|
|
|
isNetworkNormal = false
|
|
|
|
|
} else {
|
|
|
|
|
//getWorkRiskListData()
|
|
|
|
|
//登录成功
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun getWorkRiskListData() {
|
|
|
|
|
val request = NoHttp.createStringRequest(
|
|
|
|
|
Contans.BASE_URL_AI_3D_SERVER + Contans.DAYLY_RISK_LIST_NEW,
|
|
|
|
|
RequestMethod.GET
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
request.add("filter",true);
|
|
|
|
|
|
|
|
|
|
if (Contans.BASE_URL_AI_3D_SERVER == Contans.BASE_URL_AI_3D_SERVER_EXTRANET) {
|
|
|
|
|
val socketFactory = NohttpUtils.getSSLSocketFactory(context)
|
|
|
|
|
if (socketFactory != null) {
|
|
|
|
|
request.sslSocketFactory = socketFactory
|
|
|
|
|
request.hostnameVerifier = HostnameVerifier { _, _ -> true }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
WorkRiskLevelListBean::class.java
|
|
|
|
|
)
|
|
|
|
|
if (bean != null && bean.data != null) {
|
|
|
|
|
isNetworkNormal = true
|
|
|
|
|
val workRiskLevelLists = bean.data
|
|
|
|
|
if (workRiskLevelLists != null && workRiskLevelLists.size > 0) {
|
|
|
|
|
binding.tvNodata.visibility = View.GONE
|
|
|
|
|
headView.visibility = View.VISIBLE
|
|
|
|
|
datas.clear()
|
|
|
|
|
datas.addAll(workRiskLevelLists)
|
|
|
|
|
mAdapter.notifyDataSetChanged()
|
|
|
|
|
|
|
|
|
|
dataA.clear()
|
|
|
|
|
dataB.clear()
|
|
|
|
|
dataC1.clear()
|
|
|
|
|
dataC2.clear()
|
|
|
|
|
dataC3.clear()
|
|
|
|
|
dataLowRisk.clear()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectList.clear()
|
|
|
|
|
jobNoList.clear()
|
|
|
|
|
|
|
|
|
|
selectListAssistant.clear()
|
|
|
|
|
jobNoListAssistant.clear()
|
|
|
|
|
|
|
|
|
|
selectListCustom.clear()
|
|
|
|
|
jobNoListCustom.clear()
|
|
|
|
|
} else {
|
|
|
|
|
binding.tvNodata.visibility = View.VISIBLE
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
isNetworkNormal = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFailed(what: Int, response: Response<String?>?) {
|
|
|
|
|
isNetworkNormal = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|