From 6655f97451ef9f867cac7cd823eee869b984cf04 Mon Sep 17 00:00:00 2001 From: wenfei Date: Mon, 5 Jan 2026 15:50:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E9=A2=84=E8=AD=A6=E4=BF=A1=E6=81=AF=20=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/activity/DeviceAlarmInfofoActivity.kt | 27 +++++++ .../utils/AuthenticationLoginAIUtils.java | 79 +++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/DeviceAlarmInfofoActivity.kt b/app/src/main/java/com/rehome/zhdcoa/ui/activity/DeviceAlarmInfofoActivity.kt index 8647660..c6e6707 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/DeviceAlarmInfofoActivity.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/DeviceAlarmInfofoActivity.kt @@ -176,6 +176,33 @@ class DeviceAlarmInfofoActivity : BaseActivityOaToolbarViewBinding + 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, diff --git a/app/src/main/java/com/rehome/zhdcoa/utils/AuthenticationLoginAIUtils.java b/app/src/main/java/com/rehome/zhdcoa/utils/AuthenticationLoginAIUtils.java index 969cf69..5034212 100644 --- a/app/src/main/java/com/rehome/zhdcoa/utils/AuthenticationLoginAIUtils.java +++ b/app/src/main/java/com/rehome/zhdcoa/utils/AuthenticationLoginAIUtils.java @@ -262,6 +262,85 @@ public class AuthenticationLoginAIUtils { params.put("username", account); params.put("password", password); + String json = GsonUtils.GsonString(params); + //showLog(json); + //String jsonEncrypt = RSAUtils.encryptBASE64Str(json); + //showLog(jsonEncrypt); + request.setDefineRequestBodyForJson(json); + + 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().add(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)){ + UserAuthenticationAIBean bean = GsonToBean(result, UserAuthenticationAIBean.class); + if (bean != null) { + if (bean.isSuccess()&&bean.getCode()==20000) {//登录成功 + SPUtils.put(mActivity, Contans.AUTHENTICATIONLOGINTOKENAI, bean.getData().getToken()); + 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 authenticationDeviceAlermInfoRsaShowProgress(Activity mActivity, String account, String password, OnAuthenticationLoginListener listener) { + + Request request = NoHttp.createStringRequest(Contans.IP + Contans.DeviceAlermInfoLoginUrl, RequestMethod.POST); + + Map params = new HashMap<>(); + params.put("username", account); + params.put("password", password); + String json = GsonUtils.GsonString(params); //showLog(json); String jsonEncrypt = RSAUtils.encryptBASE64Str(json);