diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/DeviceAlarmInfoDetailActivity.kt b/app/src/main/java/com/rehome/zhdcoa/ui/activity/DeviceAlarmInfoDetailActivity.kt index 1165d1c..dd4465e 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/DeviceAlarmInfoDetailActivity.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/DeviceAlarmInfoDetailActivity.kt @@ -26,6 +26,7 @@ class DeviceAlarmInfoDetailActivity : BaseActivityOaToolbarViewBinding + if (token != null && token == "") { + showToast("设备状态智能监测及分析平台登录失败") + } else { + //登录成功 + //获取区域 + getDeviceAreaListNoProgress() + } + } + } catch (e: Exception) { + e.printStackTrace() + } + } + private fun getDeviceManagerListData() { val request = NoHttp.createStringRequest( @@ -288,6 +315,103 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding { + + override fun onSucceed(what: Int, response: Response?) { + val result = response?.get() + showLog("----------------") + showLog(result) + + val bean = GsonUtils.GsonToBean( + result, + DeviceManagerListResultBean::class.java + ) + + showLog(GsonUtils.GsonString(bean)) + if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null&& bean.data.size>0) { + deviceManagerList.clear() + deviceManagerListFilter.clear() + deviceManagerList.addAll(bean.data) + + if(areaNodeList.size>0){ + for (item in deviceManagerList) { + if(!TextUtils.isEmpty(item.areaId)){ + for (itemAreaNode in areaNodeList) { + if(item.areaId==itemAreaNode.nodeKey){ + item.areaFullName=itemAreaNode.areaFullName + item.areaFullPath=itemAreaNode.areaFullPath + } + } + } + showLog(GsonUtils.GsonString(item)) + } + if(binding.rb1.isChecked){ + for (item in deviceManagerList) { + if(item.online){ + deviceManagerListFilter.add(item) + } + } + } + if(binding.rb2.isChecked){ + for (item in deviceManagerList) { + if(!item.online){ + deviceManagerListFilter.add(item) + } + } + } + if(!TextUtils.isEmpty(binding.etKey.text.toString().trim())){ + if(deviceManagerListFilter.size>0){ + val deviceManagerListFilterKeyFilter: MutableList = mutableListOf() + for (item in deviceManagerListFilter) { + if(!TextUtils.isEmpty(item.name)&&item.name.contains(binding.etKey.text.toString().trim())){ + deviceManagerListFilterKeyFilter.add(item) + } + } + deviceManagerListFilter.clear() + deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter) + } + } + } + + deviceManagerListAdapter.notifyDataSetChanged() + binding.tvNodata.visibility = View.GONE + binding.lv.visibility=View.VISIBLE + + }else{ + deviceManagerList.clear() + deviceManagerListFilter.clear() + deviceManagerListAdapter.notifyDataSetChanged() + binding.tvNodata.visibility = View.VISIBLE + binding.lv.visibility=View.GONE + } + } + + override fun onFailed(what: Int, response: Response?) { + + } + }) + } + private fun getDeviceAreaList() { //DeviceOnlineStatusAreaBean @@ -337,4 +461,55 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding { + + override fun onSucceed(what: Int, response: Response?) { + val result = response?.get() + showLog("----------------") + showLog(result) + + + val bean = GsonUtils.GsonToBean( + result, + DeviceOnlineStatusAreaBean::class.java + ) + + showLog(GsonUtils.GsonString(bean)) + if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null && bean.data.size>0) { + areaList.clear() + areaNodeList.clear() + areaList.addAll(bean.data) + //更新区域 + for (itemArea in areaList) { + if (itemArea.nodeList != null && itemArea.nodeList.size > 0) { + for (itemNodeList in itemArea.nodeList) { + if (!TextUtils.isEmpty(itemNodeList.cname)) { + itemNodeList.areaFullPath=itemArea.cname+"/"+itemNodeList.cname + itemNodeList.areaFullName=itemArea.cname+">"+itemNodeList.cname + areaNodeList.add(itemNodeList) + } + } + } + } + showLog(GsonUtils.GsonString(areaList)) + SPUtils.put(context, Contans.DeviceOnlineStatusAreaBean,result) + //获取设备管理列表 + getDeviceManagerListDataNoProgress() + } + } + + override fun onFailed(what: Int, response: Response?) { + + } + }) + } } \ No newline at end of file diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/DeviceMonitoringDetailFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/DeviceMonitoringDetailFragment.java index 19d166f..a6995ac 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/DeviceMonitoringDetailFragment.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/DeviceMonitoringDetailFragment.java @@ -3,6 +3,7 @@ package com.rehome.zhdcoa.ui.fragment; import static com.rehome.zhdcoa.utils.GsonUtils.GsonToBean; import android.annotation.SuppressLint; +import android.content.Intent; import android.graphics.Color; import android.os.Bundle; @@ -22,7 +23,9 @@ import com.rehome.zhdcoa.bean.DeviceDetailListResultBean; import com.rehome.zhdcoa.bean.DeviceOnlineStatusBean; import com.rehome.zhdcoa.databinding.FragmentDeviceMonitoringDetailBinding; import com.rehome.zhdcoa.databinding.FragmentTrainBinding; +import com.rehome.zhdcoa.ui.activity.DeviceAlarmInfoLineChartActivity; 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.OnAuthenticationLoginListener; @@ -81,6 +84,29 @@ public class DeviceMonitoringDetailFragment extends BaseViewBindingFragment request = NoHttp.createStringRequest(Contans.IP + Contans.DeviceAlermInfoLoginRsaUrl, RequestMethod.POST); + + Map params = new HashMap<>(); + params.put("username", account); + params.put("password", password); + + String json = GsonUtils.GsonString(params); + //showLog(json,mActivity); + String jsonEncrypt = RSAUtils.encryptBASE64Str(json); + showLog(jsonEncrypt, mActivity); + request.setDefineRequestBodyForJson(jsonEncrypt); + + if (Contans.IP.equals(Contans.IP_EXTRANET)) { + SSLSocketFactory socketFactory = NohttpUtils.getSSLSocketFactory(mActivity); + if (socketFactory != null) { + request.setSSLSocketFactory(socketFactory); + request.setHostnameVerifier(new HostnameVerifier() { + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + }); + } + } + + NohttpUtils.getInstance().addNoProgress(mActivity, 0, request, new HttpListener() { + + @Override + public void onSucceed(int what, Response response) { + + showLog("----------------", mActivity); + String result = response.get(); + showLog(result, mActivity); + + if (!TextUtils.isEmpty(result)) { + String jsonDecode = RSAUtils.decryptBASE64StrClient(result); + if (TextUtils.isEmpty(jsonDecode)) { + //解密失败 + showLog("APP解密失败", mActivity); + listener.onAuthenticationSuccess(false, ""); + } else { + showLog(jsonDecode, mActivity); + UserAuthenticationAIBean bean = GsonToBean(jsonDecode, UserAuthenticationAIBean.class); + //DeviceAlarmLoginResultBean bean = GsonToBean(result, DeviceAlarmLoginResultBean.class); + if (bean != null) { + if (bean.isSuccess() && bean.getCode() == 20000) {//登录成功 + listener.onAuthenticationSuccess(true, bean.getData().getToken()); + } else { + if (bean.getFlag() == -1) { + if (bean.getMsg() != null && bean.getMsg().equals("用户未注销")) { + String token = (String) SPUtils.get(mActivity, Contans.AUTHENTICATIONLOGINTOKENAI, String.valueOf("")); + listener.onAuthenticationSuccess(true, token); + } + } else { + listener.onAuthenticationSuccess(false, ""); + if (bean.getFlag() == -2) { + showLog("没有传参", mActivity); + } + if (bean.getFlag() == -3) { + showLog("服务器解密失败", mActivity); + } + if (bean.getFlag() == -4) { + showLog("Json 格式不正确", mActivity); + } + if (bean.getFlag() == -5) { + showLog("账号密码不能为空", mActivity); + } + if (bean.getFlag() == -6) { + showLog("账号或密码错误", mActivity); + } + } + } + } + } + } + } + + @Override + public void onFailed(int what, Response response) { + showLog("onFailed", mActivity); + listener.onAuthenticationSuccess(false, ""); + } + }); + } public static void showLog(String logText, Context context) { if (isApkInDebug(context)) { diff --git a/app/src/main/res/drawable-xhdpi/icon_pin_pu_tu.png b/app/src/main/res/drawable-xhdpi/icon_pin_pu_tu.png new file mode 100644 index 0000000..edf4804 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/icon_pin_pu_tu.png differ diff --git a/app/src/main/res/drawable-xhdpi/icon_qzt.png b/app/src/main/res/drawable-xhdpi/icon_qzt.png new file mode 100644 index 0000000..567c2fb Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/icon_qzt.png differ diff --git a/app/src/main/res/layout/fragment_device_monitoring_detail.xml b/app/src/main/res/layout/fragment_device_monitoring_detail.xml index f09a900..905c239 100644 --- a/app/src/main/res/layout/fragment_device_monitoring_detail.xml +++ b/app/src/main/res/layout/fragment_device_monitoring_detail.xml @@ -6,6 +6,47 @@ android:background="#242e2f" android:orientation="vertical" tools:context=".ui.fragment.DeviceMonitoringDetailFragment"> + + + + + + + + + - - - - - - - - + + + + + android:visibility="visible" + android:text="" />