From ce88de4891b87c3b7b2750575e15d6e48d518852 Mon Sep 17 00:00:00 2001 From: hxb <hxb@hdlchina.com.cn> Date: 星期四, 24 十月 2024 10:39:12 +0800 Subject: [PATCH] 增加云端库 --- HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/ConditionBean.java | 53 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/SecurityInfoBean.java | 177 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/BasePageInfoBean.java | 48 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateDeviceExtInfoBean.java | 35 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/SlaveGatewayCloudBean.java | 49 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLLinkCopyException.java | 63 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLSDKLog.java | 69 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DebugConfigBean.java | 53 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateSceneBean.java | 222 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IMemberInfoBack.java | 14 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/QuestionListInfo.java | 63 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/HDLLinkPMHome.java | 191 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLSDKSPUtils.java | 147 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/code/HDLCloudCode.java | 33 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLSmartHeader.java | 18 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateSecurityCallBack.java | 17 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/GatewayCloudBean.java | 244 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/LogicInfoBean.java | 203 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLEncryptInterceptor.java | 235 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/controller/HDLPMHomeController.java | 493 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceBrandBean.java | 46 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoBean.java | 245 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/GsonUtils.java | 243 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/callback/IAddRoomListCallBack.java | 16 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/HDLLinkPMOta.java | 176 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionActionBean.java | 47 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/FirmwareBean.java | 105 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateLogicBean.java | 338 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/RoomInfoBean.java | 95 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveTypeBean.java | 132 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudUserApi.java | 133 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/HDLLinkPMScene.java | 82 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/controller/HDLPMUserController.java | 658 ++ HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateFunctionsCallBack.java | 16 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/spk/BrandType.java | 20 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/PushNoticeInfo.java | 74 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/NewVersionBean.java | 184 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/controller/HDLPMDeviceController.java | 733 ++ HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateBean.java | 314 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/controller/HDLPMOtaController.java | 475 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLUserRegionBean.java | 71 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/HousePageRequestBean.java | 94 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/NewProjectRequestBean.java | 110 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/GatewayBindBean.java | 124 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectInfoBean.java | 370 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionAttributesBean.java | 66 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IRegionByAccountCallBack.java | 14 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/controller/DataBackupController.java | 377 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/StatusBean.java | 32 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/OutputBean.java | 50 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectHouseListBean.java | 28 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoBaseBean.java | 127 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectHouseBean.java | 321 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/ImageSubmitInfo.java | 20 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IDefaultCallBack.java | 11 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/ProductInfo.java | 49 HDLLinkPMSdk/build.gradle | 74 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/controller/HDLTemplateController.java | 642 ++ HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/HomeInfoBean.java | 82 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveDetailListBean.java | 63 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/QuestionInfo.java | 145 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/DeviceFirmwareBean.java | 92 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/HomeType.java | 22 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateSpatialInfoCallBack.java | 16 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IProjectInfoListCallBack.java | 17 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/ILoginCallBack.java | 14 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceTypeBean.java | 36 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudHomeApi.java | 126 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IProjectHouseListCallBack.java | 15 local.properties | 4 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/response/BaseInfo.java | 96 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/CloudGatewayDriversBean.java | 161 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/HDLLinkPMProject.java | 378 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateFunctionBean.java | 172 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLLoginInterceptor.java | 194 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/RoomType.java | 20 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveTypeListBean.java | 63 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLGsonUtils.java | 158 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/DebugStatusIntType.java | 25 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateGatewayListCallBack.java | 17 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLUserInfoBean.java | 114 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/MqttInfo.java | 47 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/HDLLinkPMTemplate.java | 630 ++ HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoListBean.java | 27 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/controller/HDLPMSceneController.java | 189 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/GatewayType.java | 24 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateDeviceBean.java | 0 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateSpatialInfoCallBack.java | 16 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/EmployeeInfoBean.java | 64 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/BaseRequestPageBean.java | 27 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/bean/SceneInfoBean.java | 138 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/HDLLinkPMDevice.java | 272 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/bean/BackupListBean.java | 117 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/ProtocolType.java | 22 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/HDLLinkPMSdk.java | 174 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLException.java | 163 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverTypeListCallBack.java | 17 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ICreateTemplateCallBack.java | 11 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/DeviceOidInfoBean.java | 186 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudProjectApi.java | 143 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLSmartHeaderInterceptor.java | 30 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLErrorCode.java | 40 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateSecurityBean.java | 275 app/build.gradle | 1 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectInfoListBean.java | 29 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IBaseCallBack.java | 14 HDLLinkPMSdk/consumer-rules.pro | 0 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateLogicCallBack.java | 17 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/PassDataBean.java | 76 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/HDLPMDataBackup.java | 127 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceCodeBean.java | 46 HDLLinkPMSdk/src/main/AndroidManifest.xml | 7 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateRoomPackBean.java | 89 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/controller/HDLPMProjectController.java | 1092 +++ HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/UploadImageRequest.java | 56 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IOnReloginListener.java | 13 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/ProjectType.java | 25 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/PageInfoListBean.java | 28 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/DebugStatusType.java | 26 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/RoomInfoListBean.java | 29 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateListCallBack.java | 17 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/HDLLinkPMUser.java | 542 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLMD5Utils.java | 185 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLMemberInfoBean.java | 121 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateGatewayBean.java | 95 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/CategoryInfo.java | 72 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverDownLoadCallBack.java | 16 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/CloudTemplateSpatialInfo.java | 79 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLLoginBean.java | 187 settings.gradle | 1 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateScenesCallBack.java | 17 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/GatewayDriverBean.java | 84 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/bean/GatewayBackupBean.java | 62 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverDetailListCallBack.java | 15 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveDetailBean.java | 215 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/GatewayInfoBean.java | 283 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IResponseCallBack.java | 12 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateListResponseBean.java | 59 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateDeviceListCallBack.java | 17 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/DownloadUrlBean.java | 20 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IEmployeeInfoCallBack.java | 16 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/CloudDeviceFirmwaresBean.java | 147 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/spk/SPK.java | 353 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectLocationBean.java | 71 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/callback/IRoomListCallBack.java | 14 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLFileUtils.java | 324 + HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLExceptionSubmitUtils.java | 65 HDLLinkPMSdk/proguard-rules.pro | 21 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/response/HDLResponse.java | 63 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IDefaultStrCallBack.java | 11 HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/CloudTemplateDevice.java | 144 151 files changed, 18,782 insertions(+), 2 deletions(-) diff --git a/HDLLinkPMSdk/build.gradle b/HDLLinkPMSdk/build.gradle new file mode 100644 index 0000000..2e6d768 --- /dev/null +++ b/HDLLinkPMSdk/build.gradle @@ -0,0 +1,74 @@ +plugins { + id 'com.android.library' +} + +android { + + compileSdkVersion 29 + + defaultConfig { + minSdkVersion 21 + targetSdkVersion 29 + versionCode 10007 + versionName "1.0.7" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + /** + * 鎵撳寘鑷姩鍛藉悕 + */ + android.libraryVariants.all { variant -> + variant.outputs.all { + outputFileName = "HDLLinkPMSdk-V" + defaultConfig.versionName + ".aar" + } + } +} + +apply plugin: 'maven-publish' +afterEvaluate { + publishing { + publications { + plugin(MavenPublication) { + from components.release + group 'com.hdl.android' + version '1.0.7' + artifactId = 'pmsdk' + } + } + repositories { + maven { + url = 'https://packages.aliyun.com/maven/repository/2012126-release-Mc0DNo/' + credentials { + username rootProject.ext.ALIYUN_USER_NAME + password rootProject.ext.ALIYUN_PASSWORD + } + } + maven { + url = 'https://packages.aliyun.com/maven/repository/2012126-snapshot-yySdeX/' + credentials { + username rootProject.ext.ALIYUN_USER_NAME + password rootProject.ext.ALIYUN_PASSWORD + } + } + } + } +} + +dependencies { + //缃戠粶璇锋眰搴� + implementation 'com.alibaba:fastjson:1.2.66' + api 'com.hdl.hdlhttp:hxhttp:1.0.4' + api 'com.hdl.android:log:+' + +} diff --git a/HDLLinkPMSdk/consumer-rules.pro b/HDLLinkPMSdk/consumer-rules.pro new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/HDLLinkPMSdk/consumer-rules.pro diff --git a/HDLLinkPMSdk/proguard-rules.pro b/HDLLinkPMSdk/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/HDLLinkPMSdk/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/AndroidManifest.xml b/HDLLinkPMSdk/src/main/AndroidManifest.xml new file mode 100644 index 0000000..cf2dda0 --- /dev/null +++ b/HDLLinkPMSdk/src/main/AndroidManifest.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.hdl.linkpm.sdk"> + <!--鐩稿叧蹇呰鏉冮檺--> + <uses-permission android:name="android.permission.INTERNET" /> + <!--鐩稿叧蹇呰鏉冮檺--> +</manifest> \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/HDLLinkPMSdk.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/HDLLinkPMSdk.java new file mode 100644 index 0000000..938a708 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/HDLLinkPMSdk.java @@ -0,0 +1,174 @@ +package com.hdl.linkpm.sdk; + +import android.app.Application; +import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; +import android.os.Looper; +import android.widget.Toast; + +import com.hdl.hdlhttp.HxHttpConfig; +import com.hdl.linkpm.sdk.core.interceptor.HDLEncryptInterceptor; +import com.hdl.linkpm.sdk.core.interceptor.HDLLoginInterceptor; +import com.hdl.linkpm.sdk.core.interceptor.HDLSmartHeaderInterceptor; +import com.hdl.linkpm.sdk.utils.HDLSDKLog; + +import java.util.Locale; + +import static android.content.Context.MODE_PRIVATE; + +/** + * Created by jlchen on 12/2/21. + * HDLLinkPMSdk 璋冭瘯瀹濄�佽皟璇曡蒋浠堕」鐩鐞哠DK + * 閽堝B绔处鍙� + */ +public class HDLLinkPMSdk { + public static final String SDK_NAME = "HDLLinkPMSdk"; + private static String appKey; + private static String appSecret; + private static String userRegionUrl; + private static String initUrl; + private static Application context; + private static String language = "zh";//閰嶇疆鎺ュ彛璇锋眰鍝嶅簲鐨勮瑷�锛屼笉閰嶇疆榛樿涓枃 + + /** + * 鑾峰彇褰撳墠Context + * @return + */ + public Application getApplication() + { + return context; + } + /** + * 鍒濆鍖朣DK + * @param appKeyStr + * @param appSecretStr + */ + public static void initWithAppKey(Application ctx, String appKeyStr, String appSecretStr,String url){ + context = ctx; + appKey = appKeyStr; + appSecret = appSecretStr; + initUrl = url; + userRegionUrl=url; + initHxHttpConfig(); +// HDLSDKLog.i("init HDLLinkPMSdk锛�"+regionUrlStr); + } + + + public static boolean isDebugVersion() { + try { + ApplicationInfo info = context.getApplicationInfo(); + return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + public static void showToast(String msg){ +// runOnUiThread(new Runnable() { +// @Override +// public void run() { +// try { +// if (toast == null) { +// toast = Toast.makeText(HDLGlobal.getInstance().getContext(), message, Toast.LENGTH_SHORT); +// } else { +// toast.setText(message); +// } +// toast.show(); +// } catch (Exception ignored) { +// +// } +// } +// +// }); + Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); + } + + public static void runOnUiThread(Runnable run) { + //鍒よ鏄惁宸茬粡鍦ㄤ富绾跨▼ + if (Looper.getMainLooper() == Looper.myLooper()) { + run.run(); + } + } + + + public static String getInitUrl() { + return initUrl == null ? "" : initUrl; + } + + public static String get_USER_REGIONURL_ONLINE(){ + SharedPreferences sp1 = context.getSharedPreferences("USER_REGIONURL_ONLINE", MODE_PRIVATE); + //濡傛灉SoundCode,鑾峰彇鐨勫�兼槸绌虹殑,鍒欎細寮瑰嚭鍚庨潰鐨勯粯璁ゅ�� + String obtain = sp1.getString("USER_REGIONURL_ONLINE", "https://nearest.hdlcontrol.com"); + + return obtain; + } + + public static void edit_USER_REGIONURL_ONLINE(String url){ + userRegionUrl =url; + SharedPreferences sp = context.getSharedPreferences("USER_REGIONURL_ONLINE", MODE_PRIVATE); + sp.edit().putString("USER_REGIONURL_ONLINE",url).apply();//apply鎵嶄細鍐欏叆鍒皒ml閰嶇疆鏂囦欢閲岄潰 + } + + /** + * 鍒濆垵濮嬪寲缃戠粶璇锋眰搴撻厤缃� + * 娉ㄦ剰锛侊紒锛� + * 璇锋眰鍙傛暟涓嶆槸鏁扮粍鎴栧璞$被鍨嬬殑涓嶈兘鐢ㄨ〃鍗�.params(XXX)鐨勬柟寮忔坊鍔犺姹傚弬鏁� + */ + static void initHxHttpConfig(){ + HxHttpConfig.getInstance().init(context, userRegionUrl) + //.setConnectTimeout()//閰嶇疆榛樿璇锋眰瓒呮椂鏃堕棿 + .addInterceptor(new HDLLoginInterceptor(), + new HDLEncryptInterceptor(), + new HDLSmartHeaderInterceptor()); + } + + public static void destroy() { + + } + + + /** + * 璁剧疆鎵撳嵃鏄惁寮�鍚� + * @param enable- + */ + public static void setLogEnabled(boolean enable){ + HDLSDKLog.setHDLSDKLogOpen(enable); + } + + public static String getAppKey() { + return appKey; + } + + public static String getAppSecret() { + return appSecret; + } + + public static String getUserRegionUrl() { + if (userRegionUrl == null) { + userRegionUrl = get_USER_REGIONURL_ONLINE(); + } + return userRegionUrl; + } + + public static boolean isZh() { + Locale locale = getContext().getResources().getConfiguration().locale; + String language = locale.getLanguage(); + if (language.endsWith("zh")) + return true; + else + return false; + } + + public static Application getContext() { + return context; + } + + public static String getLanguage() { + return language; + } + + public static void setLanguage(String language) { + HDLLinkPMSdk.language = language; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudHomeApi.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudHomeApi.java new file mode 100644 index 0000000..65492ce --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudHomeApi.java @@ -0,0 +1,126 @@ +package com.hdl.linkpm.sdk.core.api; + +import com.hdl.linkpm.sdk.user.HDLLinkPMUser; + +/** + * Created by jlchen on 12/3/21. + * B绔� 浣忓畢鐩稿叧鐨凙PI鎺ュ彛 + */ +public class HDLCloudHomeApi { + /***************1.鎴垮眿绠$悊***************/ + //house琛ㄧ殑鏁版嵁娌℃湁鍚屾鍒癶ome琛ㄣ�佹暟鎹瓨鍦ㄤ袱寮犺〃閲岄潰锛岄渶瑕佸鎴风璋冩帴鍙e悓姝� + public static final String POST_PROGRAM_HOME_ADD = "/home-wisdom/program/home/add"; + /***************2.鎴块棿绠$悊***************/ + //鑾峰彇鎴块棿鍒楄〃 + public static final String POST_ROOM_GET_LIST = "/home-wisdom/program/room/list"; + //鎴块棿鍒楄〃鍏ㄩ噺鏇存柊銆佹坊鍔犮�佺紪杈戙�佸垹闄ら兘鐢ㄨ鎺ュ彛 + public static final String POST_ROOM_FULL_ADD_OR_EDIT = "/home-wisdom/program/room/add"; + /***************3.缃戝叧绠$悊***************/ + //缁戝畾缃戝叧 + public static final String POST_GATEWAY_BIND = "/home-wisdom/program/gateway/bindGateway"; + //寮哄埗缁戝畾缃戝叧 濡傛灉缁戝畾缃戝叧杩斿洖10510 宸茬粡琚粦瀹氫簡,鍒欒皟杩欎釜鎺ュ彛寮哄埗鎹㈢粦 + public static final String POST_GATEWAY_FORCE_BIND = "/home-wisdom/app/gateway/forceBind"; + //缃戝叧鏄惁缁戝畾浣忓畢 + public static final String POST_GATEWAY_HOMEINFO = "/home-wisdom/program/gateway/getGatewayByMac"; + //瑙g粦缃戝叧 + public static final String POST_GATEWAY_UNBIND = "/home-wisdom/program/gateway/untieGateway"; + //鑾峰彇缃戝叧鍒楄〃 + public static final String POST_GATEWAY_GET_LIST = "/home-wisdom/app/gateway/getGatewayList"; + //鑾峰彇缃戝叧淇℃伅 + public static final String POST_GATEWAY_GET_INFO = "/home-wisdom/program/gateway/info"; + //缃戝叧鏇挎崲 + public static final String POST_GATEWAY_REPLACE = "/home-wisdom/program/gateway/replace"; + /***************4.璁惧銆佸姛鑳藉鍒犳敼鏌ョ鐞�***************/ + //璁惧鍩烘湰淇℃伅鍒楄〃(oid)鍏ㄩ噺娣诲姞 + public static final String POST_DEVICE_OID_LIST_FULL_ADD = "/home-wisdom/program/device/oid/add"; + //璁惧鍩烘湰淇℃伅鍒楄〃(oid)鑾峰彇 + public static final String POST_DEVICE_OID_LIST_GET = "/home-wisdom/program/device/oid/list"; + //璁惧鍩烘湰淇℃伅(oid)鍒犻櫎 + public static final String POST_DEVICE_OID_REMOVE = "/home-wisdom/program/device/oid/remove"; + //璁惧锛堝姛鑳斤級鍏ㄩ噺鏇存柊 + public static final String POST_FUNCTION_LIST_FULL_ADD= "/home-wisdom/program/device/add"; + //鑾峰彇浜у搧鍒嗙被鏍� + public static final String POST_CATEGORY_LIST_ALLTREE= "/iot-cloud/mgmt/product/category/allTree"; + //鑾峰彇缃戝叧鍒楄〃 + public static final String POST_GATEWAY_LIST= "/home-wisdom/program/gateway/getGatewayList"; + //鑾峰彇浜у搧鍒嗙被涓嬩骇鍝� + public static final String POST_CATEGORY_DEVICE_LIST= "/iot-cloud/product/hardware/list"; + //璁惧锛堝姛鑳斤級鍒楄〃鑾峰彇 + public static final String POST_FUNCTION_LIST_GET= "/home-wisdom/program/device/list"; + //璁惧锛堝姛鑳斤級鍒犻櫎锛屾敮鎸佹壒閲� + public static final String POST_FUNCTION_BATCH_DELETE= "/home-wisdom/program/device/delete"; + //璁惧锛堝姛鑳斤級淇敼锛屾敮鎸佹壒閲� + public static final String POST_FUNCTION_BATCH_EDIT= "/home-wisdom/program/device/edit"; + //璁惧鎺у埗 C绔敤鎴锋帴鍙� + public static final String POST_FUNCTION_CONTROL= "/home-wisdom/app/device/control"; + //璁惧缁戝畾鎴块棿 + public static final String POST_DEVICE_BINDROOM="/home-wisdom/app/device/bindRoom"; + //璁惧鍚嶇О淇敼 + public static final String POST_DEVICE_RENAME="/home-wisdom/app/device/rename"; + + //缁戝畾/缂栬緫鐙珛璁惧(姣背娉�) + public static final String POST_DEVICE_INDEPENDENT_REGISTER= "/home-wisdom/program/device/independentRegister"; + //瑙g粦鐙珛璁惧(姣背娉�) + public static final String POST_DEVICE_INDEPENDENT_UNBIND= "/home-wisdom/program/device/independentUnbind"; + //璁惧锛堝姛鑳斤級鍒楄〃鑾峰彇(鍙互鑾峰彇鍗曚釜spk) + public static final String POST_DEVICE_LIST_GET= "/home-wisdom/app/device/list"; + //鑾峰彇姣背娉�(鑾峰彇璁惧杩滅▼閫氳淇℃伅) + public static final String POST_DEVICE_REMOTEINFO_GET= "/home-wisdom/program/device/remoteInfo"; + /***************5.鍦烘櫙澧炲垹鏀规煡绠$悊***************/ + //鑾峰彇鍦烘櫙鍒楄〃 + public static final String POST_SCENE_LIST_GET= "/home-wisdom/program/scene/list"; + //鍏ㄩ噺鍚屾鍦烘櫙 + public static final String POST_SCENE_LIST_FULL_SYNC= "/home-wisdom/program/scene/sync"; + //鍒犻櫎鍦烘櫙 + public static final String POST_SCENE_DELETE= "/home-wisdom/program/scene/delete"; + //鍦烘櫙鎵ц + public static final String POST_SCENE_EXECUTE= "/home-wisdom/program/scene/execute"; + /***************6.鑷姩鍖栧鍒犳敼鏌ョ鐞�***************/ + //鍏ㄩ噺鏇存柊鍚屾鑷姩鍖栥�佸瓨鍦ㄤ笉鍙�,涓嶅瓨鍦ㄦ柊澧� + public static final String POST_LOGIC_FULL_SYNC= "/home-wisdom/program/logic/sync"; + + /***************7.瀹夐槻鍖栧鍒犳敼鏌ョ鐞�***************/ + //鍏ㄩ噺鏇存柊鍚屾瀹夐槻鏁版嵁銆佸瓨鍦ㄤ笉鍙�,涓嶅瓨鍦ㄦ柊澧� + public static final String POST_SECURITY_FULL_SYNC= "/home-wisdom/program/security/sync"; + + /***************8.OTA 鍥轰欢鍜屽崌绾х鐞�***************/ + //鍘熺敓璁惧鑾峰彇鍥轰欢鍗囩骇鍖呬笅杞藉湴鍧� + public static final String POST_OTA_GET_NativeDeviceFirmwareDownloadUrl = "/smart-footstone/mgmt/device/ota/getNativeDeviceFirmwareDownloadUrl"; + /**椹卞姩**/ + //Link缃戝叧椹卞姩鍒楄〃鑾峰彇 + public static final String POST_OTA_GET_GatewayDrivers = "/home-wisdom/program/device/ota/getGatewayDrivers"; + //Link缃戝叧浜戠鐨勯┍鍔ㄥ垎椤靛垪琛ㄨ幏鍙� + public static final String POST_OTA_GET_CloudGatewayDrivers = "/smart-footstone/driver/buspro/download"; + //Link缃戝叧椹卞姩鍗囩骇OTA鍛戒护涓嬪彂 + public static final String POST_OTA_GatewayDriverUpgrade = "/home-wisdom/program/device/ota/gatewayDriverUpgrade"; + //LINK缃戝叧鑾峰彇椹卞姩鍗囩骇鍖呬笅杞藉湴鍧� + public static final String POST_OTA_GET_LinkDeviceDriverDownloadUrl = "/smart-footstone/mgmt/device/ota/getLinkDeviceDriverDownloadUrl"; + /**鍥轰欢**/ + //璁惧鍥轰欢鍒楄〃鑾峰彇 + public static final String POST_OTA_GET_DeviceFirmwares = "/home-wisdom/program/device/ota/getDeviceFirmwares"; + //璁惧鍥轰欢浜戠鐨勯┍鍔ㄥ垎椤靛垪琛ㄨ幏鍙� + public static final String POST_OTA_GET_CloudDeviceFirmwares = "/smart-footstone/firmware/firmwareVersion/getLastOne"; + //璁惧鍥轰欢鍗囩骇OTA鍛戒护 + public static final String POST_OTA_DeviceFirmwareUpgrade = "/home-wisdom/program/device/ota/deviceFirmwareUpgrade"; + //璁惧鑾峰彇鍥轰欢鍗囩骇鍖呬笅杞藉湴鍧� + public static final String POST_OTA_GET_LinkDeviceFirmwareDownloadUrl = "/smart-footstone/mgmt/device/ota/getLinkDeviceFirmwareDownloadUrl"; + + //鑾峰彇IARCC涓夋柟鍥轰欢鍒嗛〉 + public static final String POST_OTA_GET_FIRMWARE_PAGE = "/iot-cloud/mgmt/third/firmware/page"; + //鑾峰彇IARCC涓夋柟鍥轰欢鍒嗙被 + public static final String POST_OTA_GET_FIRMWARE_LIST = "/iot-cloud/mgmt/third/firmware/list"; + + //甯姪涓績闂瓟鍒楄〃 + public static final String POST_QUESTION_GET_LIST = "/crm-wisdom/support/center/list"; + + + /** + * 鑾峰彇浣忓畢瀹屾暣鐨勮姹傚湴鍧� + * @param api + * @return + */ + public static String getRequestUrl(String api){ + return HDLLinkPMUser.getInstance().getHomeRegionUrl() + api; + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudProjectApi.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudProjectApi.java new file mode 100644 index 0000000..abc8349 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudProjectApi.java @@ -0,0 +1,143 @@ +package com.hdl.linkpm.sdk.core.api; + +import com.hdl.linkpm.sdk.user.HDLLinkPMUser; + +/** + * Created by jlchen on 12/3/21. + * B绔� 鐢ㄦ埛鐩稿叧鐨凙PI鎺ュ彛 + */ +public class HDLCloudProjectApi { + /***************椤圭洰绠$悊***************/ + //鑾峰彇鎸囧畾鍏徃鍛樺伐鍒楄〃 鏀寔鍚嶇О妯$硦鏌ヨ + public static final String POST_DEBUGGER_GET = "/basis-footstone/mgmt/user/manage/getUserByCompanyIdAndUserName"; + //鏂板椤圭洰 + public static final String POST_PROJECT_CREATE = "/smart-footstone/mgmt/community/project/create"; + //鍒犻櫎椤圭洰 + public static final String POST_PROJECT_DELETE_BY_ID = "/smart-footstone/mgmt/community/project/deleteById"; + //鑾峰彇椤圭洰鍒楄〃 + public static final String POST_PROJECT_GET_PAGE = "/smart-footstone/mgmt/community/project/page"; + //鑾峰彇浜屾璋冭瘯 + public static final String POST_REDEBUG_GET_PAGE = "/smart-footstone/mgmt/community/project/getDebugInfoList"; + //缂栬緫椤圭洰 + public static final String POST_PROJECT_UPDATE = "/smart-footstone/mgmt/community/project/update"; +// //鍒嗛厤璋冭瘯浜哄憳 +// public static final String POST_PROJECT_ARRANGE_DEBUG_USER = "/smart-footstone/mgmt/community/project/arrangeDebugUser"; + //鏍规嵁椤圭洰璋冭瘯鐘舵�佽幏鍙栭」鐩粺璁℃暟鎹� + public static final String POST_PROJECT_GET_SUMMARY_LIST = "/smart-footstone/mgmt/community/project/getSummaryList"; + //鏍规嵁椤圭洰ID鑾峰彇椤圭洰淇℃伅 + public static final String POST_PROJECT_GET_INFO = "/smart-footstone/mgmt/community/project/getInfo"; + //鍒嗛厤涓氬姟浜哄憳鍚� 淇敼涓鸿窡杩涗腑鐘舵�� + public static final String POST_PROJECT_ARRANGE_BUSINESS_USER = "/smart-footstone/mgmt/community/project/arrangeBusinessUser"; + //浜や粯椤圭洰 鎵�鏈夋埧灞嬪浜庡凡浜や粯鐘舵�佹墠閫氳繃 鍚﹀垯鎻愮ず灏氭湭鏈夋湭浜や粯鐨勬埧灞� + public static final String POST_PROJECT_DELIVERY_ROJECT = "/smart-footstone/mgmt/community/project/deliveryProject"; + //鎾ゅ洖浜や粯鐨勯」鐩� 宸蹭氦浠樼殑椤圭洰鍙樹负寰呬氦浠� 閽堝閰掑簵鍜屽湴浜ч」鐩� + public static final String POST_PROJECT_WITHDRAW_DELIVERY_PROJECT = "/smart-footstone/mgmt/community/project/withdrawDeliveryProject"; + + + /***************鎴垮眿绠$悊***************/ + //鏌ヨ鎴垮眿淇℃伅鍒楄〃锛屽垎椤垫煡璇� :鏍规嵁鏌ヨ鏉′欢锛岃繑鍥炴煡璇㈢粨鏋滅殑鎴垮眿璇︾粏淇℃伅鍒楄〃 + public static final String POST_PROJECT_GET_HOUSE_PAGE = "/smart-footstone/mgmt/community/houseExtend/getHousePage"; + //娣诲姞鍒嗛厤璋冭瘯浜哄憳 :缁欐埧灞嬫坊鍔犺皟璇曚汉鍛橈紝璋冭瘯浜哄憳璐﹀彿蹇呴』瀛樺湪锛屾洿鏂拌皟璇曚汉鍛樿皟璇曡繖涓帴鍙e氨濂斤紝浼氳繘琛岃鐩� + public static final String POST_HOUSE_DEBUGGER_ADD = "/smart-footstone/mgmt/community/houseExtend/add"; + //鎵归噺娣诲姞璋冭瘯浜哄憳 :澶氫釜鎴垮眿鍚屾椂鍒嗛厤缁欎竴涓皟璇曚汉鍛� + public static final String POST_HOUSE_DEBUGGER_BATCHADD = "/smart-footstone/mgmt/community/houseExtend/batchAdd"; + //鎵归噺鏇存柊璋冭瘯鐘舵�� + public static final String POST_HOUSE_BATCH_UPDATE_STATUS = "/smart-footstone/mgmt/community/houseExtend/batchUpdateStatus"; + + + /***************鏁版嵁涓婁紶浜戠***************/ + /** + * 鏇存柊oid 鍏ㄩ噺 + */ + public static final String POST_HOUSE_DEVICE_FULL_UPDATE = "/home-wisdom/program/device/oid/add"; + /** + * 鍔熻兘鍏ㄩ噺鏇存柊 + */ + public static final String POST_HOUSE_FUNCTION_FULL_UPDATE = "/home-wisdom/program/device/add"; + /** + * 鎴块棿Uid鍏ㄩ噺鏇存柊 + */ + public static final String POST_HOUSE_ROOM_FULL_UPDATE = "/home-wisdom/program/room/add"; + /** + * 鍦烘櫙鍏ㄩ噺鏇存柊 + */ + public static final String POST_HOUSE_SCENE_FULL_UPDATE = "/home-wisdom/program/scene/sync"; + /** + * 鑷姩鍖栧叏閲忔洿鏂� + */ + public static final String POST_HOUSE_LOGIC_FULL_UPDATE = "/home-wisdom/program/logic/sync"; + /** + * 瀹夐槻鍏ㄩ噺鏇存柊 + */ + public static final String POST_HOUSE_SECURITY_FULL_UPDATE = "/home-wisdom/program/security/sync"; + /** + * 缇ゆ帶鍏ㄩ噺鏇存柊 + */ + public static final String POST_HOUSE_GROUPCONTROL_FULL_UPDATE = "/home-wisdom/program/device/groupcontrol/syncData"; + /** + * 鏇存敼浣忓畢鍚嶇О + */ + public static final String POST_HOUSENAME_UPDATE = "/home-wisdom/program/home/updateName"; + /** + * 娣诲姞鎺ㄩ�乀oken + */ + public static final String POST_JPUSH_BIND = "/smart-footstone/app/push-information/add"; + /** + * 鍒犻櫎鎺ㄩ�乀oken + */ + public static final String POST_JPUSH_UNBIND = "/smart-footstone/app/push-information/delete"; + + /***************缃戝叧椹卞姩***************/ + /** + * 鑾峰彇椹卞姩鍒嗛〉鍒楄〃 + */ + public static final String POST_GET_DRIVERLIST = "/smart-footstone/driver/driverList"; + + /** + * 鑾峰彇椹卞姩鐗堟湰鍒嗛〉鍒楄〃 + */ + public static final String POST_GET_VERSIONLIST = "/smart-footstone/driver/versionList"; + + /** + * 绾㈠璁惧绫诲瀷鍒楄〃 + */ + public static final String POST_GET_IR_DEVICETYPELIST = "/smart-footstone/app/ir/device-type/list"; + + /** + * 鏌ヨ绾㈠璁惧绫诲瀷鐨勫搧鐗屽垪琛� + */ + public static final String POST_GET_IR_DEVICEBRANDLIST = "/smart-footstone/app/ir/brand/list"; + + /** + * 鏌ヨ绾㈠璁惧绫诲瀷鐨勫搧鐗岀孩澶栫爜搴撳垪琛� + */ + public static final String POST_GET_IR_DEVICECODELIST = "/smart-footstone/app/ir/code/list"; + + /** + * 娣诲姞椹卞姩涓嬭浇娆℃暟 + */ + public static final String POST_ADD_DOWNLOADCOUNT= "/smart-footstone/driver/addDownloadCount"; + + /** + * 娣诲姞鍥轰欢涓嬭浇娆℃暟 + */ + public static final String POST_ADD_FIRMWARE_DOWNLOADCOUNT= "/smart-footstone/firmware/firmwareVersion/updateDownload"; + + /** + * 娣诲姞涓夋柟涓嬭浇娆℃暟 + */ + public static final String POST_ADD_THIRD_DOWNLOADCOUNT= "/iot-cloud/mgmt/third/firmware/version/downOverlay"; + + + + + + /** + * 鑾峰彇瀹屾暣鐨勮姹傚湴鍧� + * @param api + * @return + */ + public static String getRequestUrl(String api){ + return HDLLinkPMUser.getInstance().getUserRegionUrl() + api; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudUserApi.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudUserApi.java new file mode 100644 index 0000000..e5b0c0a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/api/HDLCloudUserApi.java @@ -0,0 +1,133 @@ +package com.hdl.linkpm.sdk.core.api; + +import com.hdl.linkpm.sdk.user.HDLLinkPMUser; + +/** + * Created by jlchen on 12/3/21. + * B绔� 鐢ㄦ埛鐩稿叧鐨凙PI鎺ュ彛 + */ +public class HDLCloudUserApi { + /***************鐢ㄦ埛绠$悊***************/ + //鑾峰彇璐﹀彿鎵�鍦ㄥ尯鍩�(B绔�) + public static final String POST_RegionByAccount = "/smart-footstone/region/regionByUserAccount"; + //鑾峰彇璐﹀彿鎵�鍦ㄥ尯鍩燂紙C绔級 + public static final String C_POST_RegionByAccount = "/smart-footstone/region/regionByAccount"; + //鐧诲綍鎺ュ彛(B绔�) + public static final String POST_LOGIN = "/smart-footstone/user/oauth/login"; + //鐧诲綍鎺ュ彛锛圕绔級 + public static final String C_POST_LOGIN = "/smart-footstone/member/oauth/login"; + //鍙戦�佹秷鎭獙璇佺爜 + public static final String POST_VERIFICATION_CODE_SEND = "/smart-footstone/verification/message/send"; + //鐢ㄦ埛鎵惧洖瀵嗙爜 蹇樿瀵嗙爜,閫氳繃閭鍜屾墜鏈哄彿鎵惧洖 + public static final String POST_FORGET_PROGRAM_PWD = "/smart-footstone/user/oauth/forgetProgramPwd"; + //鏇存敼涓汉瀵嗙爜 + public static final String POST_UPDATE_PROGRAM_PASSWORD = "/smart-footstone/user/userInfo/updateProgramPassword"; + //鑾峰彇鍛樺伐鍒楄〃 + public static final String POST_GET_USER_LIST = "/smart-footstone/user/userInfo/getUserList"; + //鑾峰彇鐢ㄦ埛涓汉淇℃伅 C绔� + public static final String POST_GET_MEMBER_INFO = "/smart-footstone/member/memberInfo/getMemberInfo"; + //鏇存柊涓汉淇℃伅 C绔� + public static final String POST_UPDATE_MEMBER_INFO = "/smart-footstone/member/memberInfo/updateMemberInfo"; + //涓婁紶鍥剧墖 + public static final String POST_UPLOAD_IMAGE = "/home-wisdom/app/images/upload_image"; + //涓婁紶鍥剧墖锛堟柊锛� + public static final String POST_UPLOAD_IMAGE_NEW = "/basis-cosmos/file/upload"; + //鏌ヨ鍥剧墖璺緞 + public static final String POST_GET_IMAGE_URL = "/home-wisdom/app/images/get_image_url"; + // //鐗堟湰妫�娴嬫洿鏂� +// public static final String POST_APP_APPVERSION_CHECK = "/smart-footstone/app/appVersion/check"; + //鏀寔APP鍜屽皬绋嬪簭妫�娴� + public static final String POST_APP_APPVERSION_CHECK = "/basis-footstone/app/appVersion/check"; + //mqtt杩炴帴闇�瑕佺殑鏁版嵁 + public static final String MQTT_INFO_URL = "/home-wisdom/app/mqtt/getRemoteInfo"; + + + /***************椤圭洰绠$悊***************/ + /** + * 鑾峰彇瀹屾暣鐨勮姹傚湴鍧� + * + * @param api + * @return + */ + public static String getRequestUrl(String api) { + return HDLLinkPMUser.getInstance().getUserRegionUrl() + api; + } + + + /***************妯℃澘绠$悊***************/ + //鍒涘缓妯℃澘 + public static final String POST_TEMPLATE_CREATE = "/smart-footstone/mgmt/template/extends/debug/create"; + //鑾峰彇妯℃澘鍒楄〃 + public static final String POST_TEMPLATE_GET_LIST = "/smart-footstone/mgmt/template/extends/debug/page"; + //鍒犻櫎妯℃澘 + public static final String POST_TEMPLATE_DELETE = "/smart-footstone/mgmt/template/extends/debug/delete"; + //娣诲姞缃戝叧(鍏ㄩ噺) + public static final String POST_TEMPLATE_UPDATE_GATEWAY = "/smart-footstone/mgmt/template/detail/gateway/fullUpdate"; + //娣诲姞鎴块棿(鍏ㄩ噺) + public static final String POST_TEMPLATE_UPDATE_ROOM = "/smart-footstone/mgmt/template/detail/room/fullUpdate"; + //娣诲姞璁惧(鍏ㄩ噺) + public static final String POST_TEMPLATE_UPDATE_DEVICES = "/smart-footstone/mgmt/template/detail/oid/fullUpdate"; + //鑾峰彇璁惧鍒楄〃 + public static final String POST_TEMPALTE_GET_DEVICES = "/smart-footstone/mgmt/template/detail/oid/list"; + //娣诲姞鍔熻兘(鍏ㄩ噺) + public static final String POST_TEMPLATE_UPDATE_FUNCTIONS = "/smart-footstone/mgmt/template/detail/sid/fullUpdate"; + //娣诲姞鍦烘櫙(鍏ㄩ噺) + public static final String POST_TEMPLATE_UPDATE_SCENES = "/smart-footstone/mgmt/template/detail/scene/fullUpdate"; + //娣诲姞鑷姩鍖�(鍏ㄩ噺) + public static final String POST_TEMPLATE_UPDATE_LOGIC = "/smart-footstone/mgmt/template/detail/logic/fullUpdate"; + //娣诲姞瀹夐槻 + public static final String POST_TEMPLATE_UPDATE_SECURITY = "/smart-footstone/mgmt/template/detail/security/fullUpdate"; + //鑾峰彇绌洪棿淇℃伅 + public static final String POST_GET_TEMPLATE_SPATIAL_INFO = "/smart-footstone/mgmt/template/detail/room/list"; + //鑾峰彇缃戝叧淇℃伅 + public static final String POST_GET_TEMPLATE_GATEWAY_LIST = "/smart-footstone/mgmt/template/detail/gateway/list"; + //鑾峰彇鍔熻兘鍒楄〃 + public static final String POST_GET_TEMPLATE_FUNCTION_LIST = "/smart-footstone/mgmt/template/detail/sid/list"; + //鑾峰彇鍦烘櫙鍒楄〃 + public static final String POST_GET_TEMPLATE_SCENE_LIST = "/smart-footstone/mgmt/template/detail/scene/list"; + //鑾峰彇瀹夐槻鍒楄〃 + public static final String POST_GET_TEMPLATE_SECURITY_LIST = "/smart-footstone/mgmt/template/detail/security/list"; + //鑾峰彇鑷姩鍖栧垪琛� + public static final String POST_GET_TEMPLATE_LOGIC_LIST = "/smart-footstone/mgmt/template/detail/logic/list"; + + + /***************鏁版嵁澶囦唤***************/ + /** + * 涓婁紶鏁版嵁澶囦唤 + */ + public static final String POST_BACKUP_UPLOAD = "/smart-footstone/debug/backup/file/upload"; + /** + * 鑾峰彇鏂囦欢涓嬭浇鍦板潃 + */ + public static final String POST_BACKUP_DOWNLOAD_URL = "/smart-footstone/debug/backup/file/newestUrl"; + /** + * 鍒犻櫎澶囦唤鏁版嵁 + */ + public static final String POST_BACKUP_DEL = "/smart-footstone/debug/backup/file/deleteByHouseIds"; + + /** + * 鑾峰彇澶囦唤鍒楄〃 + */ + public static final String POST_BACKUP_LIST = "/smart-footstone/mgmt/community/houseExtend/getHouseDebugPage"; + + /** + * 鑾峰彇缃戝叧鏈�鏂扮殑涓変唤澶囦唤鏁版嵁 + */ + public static final String POST_GATEWAY_BACKUP_LIST = "/iot-cloud/file/device/backup/threeLatest"; + /** + * 鑾峰彇璋冭瘯瀹屾垚鐨勫浠芥枃浠跺洖澶� + */ + public static final String POST_GATEWAY_BACKUP_DEBUGCOMPLETEBACKUPFILE = "/iot-cloud/file/device/backup/debugCompleteBackupFile"; + /** + * 缃戝叧鎭㈠鐨勫浠芥枃浠� + */ + public static final String POST_GATEWAY_BACKUP_RECOVER = "/iot-cloud/file/device/backup/recover"; + + + /** + * 鏇挎崲缃戝叧 + */ + public static final String POST_GATEWAY_REPLACE = "/home-wisdom/program/gateway/replace"; + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/BasePageInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/BasePageInfoBean.java new file mode 100644 index 0000000..d8fb74e --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/BasePageInfoBean.java @@ -0,0 +1,48 @@ +package com.hdl.linkpm.sdk.core.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/9/21. + */ +public class BasePageInfoBean implements Serializable { + + private int totalCount; + private int totalPage; + private int pageNo;//褰撳墠椤� + private int pageSize;//椤甸潰澶у皬 + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getTotalPage() { + return totalPage; + } + + public void setTotalPage(int totalPage) { + this.totalPage = totalPage; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/BaseRequestPageBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/BaseRequestPageBean.java new file mode 100644 index 0000000..83d2f4a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/BaseRequestPageBean.java @@ -0,0 +1,27 @@ +package com.hdl.linkpm.sdk.core.bean; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/9/21. + */ +public class BaseRequestPageBean implements Serializable { + private int pageNo = 1;//鍝竴椤� (榛樿 1) + private int pageSize = 100;//椤靛ぇ灏� + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/PageInfoListBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/PageInfoListBean.java new file mode 100644 index 0000000..1cb59bf --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/bean/PageInfoListBean.java @@ -0,0 +1,28 @@ +package com.hdl.linkpm.sdk.core.bean; + +import androidx.annotation.NonNull; + +import com.hdl.linkpm.sdk.home.bean.RoomInfoBean; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by hxb on 2022/2/28. + */ +public class PageInfoListBean<T> extends BasePageInfoBean { + + private List<T> list = new ArrayList<>(); + + @NonNull + public List<T> getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(@NonNull List<T> list) { + this.list = list; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IBaseCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IBaseCallBack.java new file mode 100644 index 0000000..4332b08 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IBaseCallBack.java @@ -0,0 +1,14 @@ +package com.hdl.linkpm.sdk.core.callback; + +import com.hdl.linkpm.sdk.core.exception.HDLException; + +/** + * Created by jlchen on 12/3/21. + */ +public interface IBaseCallBack { + /** + * 澶辫触 + * @param error 閿欒 + */ + void onFailure(HDLException error); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IDefaultCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IDefaultCallBack.java new file mode 100644 index 0000000..1fa1979 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IDefaultCallBack.java @@ -0,0 +1,11 @@ +package com.hdl.linkpm.sdk.core.callback; + +/** + * Created by jlchen on 12/2/21. + */ +public interface IDefaultCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IDefaultStrCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IDefaultStrCallBack.java new file mode 100644 index 0000000..22c8e80 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IDefaultStrCallBack.java @@ -0,0 +1,11 @@ +package com.hdl.linkpm.sdk.core.callback; + +/** + * Created by jlchen on 12/2/21. + */ +public interface IDefaultStrCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(String data); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IResponseCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IResponseCallBack.java new file mode 100644 index 0000000..da6a342 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/callback/IResponseCallBack.java @@ -0,0 +1,12 @@ +package com.hdl.linkpm.sdk.core.callback; + +/** + * Created by jlchen on 12/2/21. + * 閫氶厤鍥炶皟 + */ +public interface IResponseCallBack<T> extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(T objects); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/code/HDLCloudCode.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/code/HDLCloudCode.java new file mode 100644 index 0000000..f601014 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/code/HDLCloudCode.java @@ -0,0 +1,33 @@ +package com.hdl.linkpm.sdk.core.code; + +/** + * Created by jlchen on 12/3/21. + */ +public @interface HDLCloudCode { + //鎴愬姛 + int SUCCEED = 0; + + //绯荤粺绻佸繖 + int SYSTEM_BUSY = 1; + + //绯荤粺缁存姢 2 + + //鏈嶅姟寮傚父 3 + + //绛惧悕閿欒 4 + + //鍙傛暟寮傚父 5 + + //token瓒呮椂 + int TOKEN_TIMEOUT = 10001; + //璇烽噸鏂扮櫥褰� + int RE_LOGIN = 10002; + //涓嶅悎娉曠殑token锛岃璁ょ湡姣斿token鐨勭鍚� + int TOKEN_NOT_STANDARD = 10003; + //缂哄皯token鍙傛暟 + int NO_TOKEN = 10004; + //瑙f瀽鐢ㄦ埛韬唤閿欒锛岃閲嶆柊鐧诲綍 + int CODE_TOKEN_ERROR_10006 = 10006; + //鐢ㄦ埛宸茬粡琚鐢� + int CODE_TOKEN_ERROR_10009 = 10009; +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLErrorCode.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLErrorCode.java new file mode 100644 index 0000000..8a58163 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLErrorCode.java @@ -0,0 +1,40 @@ +package com.hdl.linkpm.sdk.core.exception; + + +import com.hdl.linkpm.sdk.HDLLinkPMSdk; + +/** + * Created by jlchen on 12/2/21. + */ +public enum HDLErrorCode { + /***缃戠粶璇锋眰閫氫俊鑷畾涔夐敊璇爜**/ + HDL_DATA_PARSING_ERROR(-1000, HDLLinkPMSdk.isZh() == true ? "鏁版嵁瑙f瀽寮傚父" : "Data parsing error"), + /***鏈湴閫氫俊鑷畾涔夐敊璇爜**/ + HDL_DATA_ERROR(-2000, HDLLinkPMSdk.isZh() == true ? "鍙傛暟寮傚父" : "Parameter exception"), + HDL_DATA_NULL_ERROR(-2001, HDLLinkPMSdk.isZh() == true ? "鍙傛暟涓嶈兘涓虹┖" : "Parameter cannot be empty"), + HDL_TIMEOUT_ERROR(-2002, HDLLinkPMSdk.isZh() == true ? "瓒呮椂" : "timeout"); + + private String msg; + private int code; + + private HDLErrorCode(int code, String msg) { + this.msg = msg; + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLException.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLException.java new file mode 100644 index 0000000..9a9b3e9 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLException.java @@ -0,0 +1,163 @@ +package com.hdl.linkpm.sdk.core.exception; + +import android.text.TextUtils; + +import androidx.annotation.IntDef; +import androidx.annotation.Nullable; + +import com.hdl.hdlhttp.HxHttpConfig; +import com.hdl.hdlhttp.callback.HxException; +import com.hdl.linkpm.sdk.R; +import com.hdl.linkpm.sdk.core.response.BaseInfo; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Created by Tong on 2021/11/8. + */ +public class HDLException extends RuntimeException { + + private Throwable rawThrowable; + private int code; + private String msg; + + private BaseInfo.Extra mExtra; + + @Retention(RetentionPolicy.SOURCE) + @Target({ElementType.FIELD, ElementType.PARAMETER}) + @IntDef({ + ErrorCode.UNKNOWN, + ErrorCode.PARSE_ERROR, + ErrorCode.NETWORK_ERROR, + ErrorCode.HTTP_ERROR, + ErrorCode.SSL_ERROR, + ErrorCode.TIMEOUT_ERROR + }) + public @interface ErrorCode { + //鏈煡閿欒 + int UNKNOWN = -40000; + //瑙f瀽閿欒 + int PARSE_ERROR = -40001; + //缃戠粶閿欒 + int NETWORK_ERROR = -40002; + //鍗忚鍑洪敊 + int HTTP_ERROR = -40003; + //璇佷功鍑洪敊 + int SSL_ERROR = -40004; + //杩炴帴瓒呮椂 + int TIMEOUT_ERROR = -40005; + + } + + + private int getHxToErrorCode(@HxException.ErrorCode int hxCode) { + switch (hxCode) { + case HxException.ErrorCode.UNKNOWN: + return ErrorCode.UNKNOWN; + case HxException.ErrorCode.PARSE_ERROR: + return ErrorCode.PARSE_ERROR; + case HxException.ErrorCode.NETWORK_ERROR: + return ErrorCode.NETWORK_ERROR; + case HxException.ErrorCode.HTTP_ERROR: + return ErrorCode.HTTP_ERROR; + case HxException.ErrorCode.SSL_ERROR: + return ErrorCode.SSL_ERROR; + case HxException.ErrorCode.TIMEOUT_ERROR: + return ErrorCode.TIMEOUT_ERROR; + } + return ErrorCode.NETWORK_ERROR; + } + + public HDLException(HxException exception) { + this.code = getHxToErrorCode(exception.getCode()); + this.msg = exception.getMsg(); + this.rawThrowable = exception.getRawThrowable(); + } + + + public HDLException(int code, String msg) { + this.code = code; + this.msg = msg; + if (!TextUtils.isEmpty(msg)) { + this.msg = msg; + } else { + this.msg = HxHttpConfig.getInstance().getString(com.hdl.hdlhttp.R.string.network_error); + } + } + + public BaseInfo.Extra getmExtra() { + return mExtra; + } + + public void setExtra(BaseInfo.Extra mExtra) { + this.mExtra = mExtra; + } + + public HDLException(int code, String msg, BaseInfo.Extra extra) { + this.code = code; + this.msg = msg; + if (extra != null) { + this.mExtra = extra; + } + if (!TextUtils.isEmpty(msg)) { + this.msg = msg; + } else { + this.msg = HxHttpConfig.getInstance().getString(com.hdl.hdlhttp.R.string.network_error); + } + } + + + public boolean isNetError() { + return getCode() < 0; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + @Nullable + @Override + public String getMessage() { + if (rawThrowable != null) { + String message = rawThrowable.getMessage(); + if (!TextUtils.isEmpty(message)) { + return message; + } + if (!TextUtils.isEmpty(msg)) { + return msg; + } + } + return super.getMessage(); + } + + @Override + public String toString() { + return "HDLException{" + + "rawThrowable=" + rawThrowable + + ", code=" + code + + ", msg='" + msg + '\'' + + '}'; + } + + public static HDLException getErrorWithCode(HDLErrorCode code) { + return new HDLException(code.getCode(), code.getMsg()); + } + +} + + diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLLinkCopyException.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLLinkCopyException.java new file mode 100644 index 0000000..bed9cfd --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/exception/HDLLinkCopyException.java @@ -0,0 +1,63 @@ +package com.hdl.linkpm.sdk.core.exception; + +import androidx.annotation.NonNull; + +/** + * Created by Tong on 2021/11/11. + */ +public class HDLLinkCopyException extends RuntimeException { + + private int code = 0; + private String msg = ""; + private Throwable rawThrowable; + + public HDLLinkCopyException() { + } + + public HDLLinkCopyException(String msg) { + this.msg = msg; + } + + public HDLLinkCopyException(int code, String msg) { + this.code = code; + this.msg = msg; + } + + public HDLLinkCopyException(int code) { + this.code = code; + } + + public HDLLinkCopyException(Throwable rawThrowable) { + this.rawThrowable = rawThrowable; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public @NonNull + String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public Throwable getRawThrowable() { + return rawThrowable; + } + + public void setRawThrowable(Throwable rawThrowable) { + this.rawThrowable = rawThrowable; + } + + public static HDLLinkCopyException getErrorWithCode(int code, String msg){ + return new HDLLinkCopyException(code,msg); + } +} + diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLEncryptInterceptor.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLEncryptInterceptor.java new file mode 100644 index 0000000..50f0dad --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLEncryptInterceptor.java @@ -0,0 +1,235 @@ +package com.hdl.linkpm.sdk.core.interceptor; + +import android.net.Uri; +import android.text.TextUtils; + +import androidx.annotation.NonNull; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; +import com.hdl.hdlhttp.utils.GsonConvert; +import com.hdl.linkpm.sdk.HDLLinkPMSdk; +import com.hdl.linkpm.sdk.core.interceptor.HDLSmartHeader; +import com.hdl.linkpm.sdk.template.GsonUtils; +import com.hdl.linkpm.sdk.utils.HDLMD5Utils; +import com.hdl.linkpm.sdk.utils.HDLSDKLog; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import okhttp3.FormBody; +import okhttp3.Headers; +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okio.Buffer; + +/** + * Created by Tong on 2021/11/4. + * 鍔犲瘑骞惰嚜鍔ㄨˉ鍏呭弬鏁�,appKey銆乼imestamp + * 鍙敮鎸佽〃鍗曘�乯son + * 鏈�缁坖son鏂瑰紡鎻愪氦 + */ +public class HDLEncryptInterceptor implements Interceptor { + + + @NonNull + @Override + public Response intercept(@NonNull Chain chain) throws IOException { + Request request = chain.request(); + Headers headers = request.headers(); + if (!isIgnoreSignHeader(headers)) { + return chain.proceed(encrypt(request)); + } + + return chain.proceed(request); + } + + + /** + * 娣诲姞sign瀛楁 + */ + private Request encrypt(Request request) { + final String timestamp = String.valueOf(System.currentTimeMillis()); + final String appKey = HDLLinkPMSdk.getAppKey(); + final String appSecret = HDLLinkPMSdk.getAppSecret(); + final JsonObject json = getBodyJson(request); + if (json != null) { + json.addProperty("appKey", appKey); + json.addProperty("timestamp", timestamp); + json.addProperty("sign", getSign(json, appSecret)); + final RequestBody requestBody = RequestBody.create(json.toString(), MediaType.parse("application/json;charset=UTF-8")); + return request.newBuilder().post(requestBody) + .build(); + } + return request; + } + + + /** + * 鏄惁蹇界暐鑷畾涔夌殑鍔犲瘑澶� + */ + private boolean isIgnoreSignHeader(Headers headers) { + String signHeader = headers.get(HDLSmartHeader.IGNORE_SIGN_HEADER); + + return !TextUtils.isEmpty(signHeader); + } + + private JsonObject getBodyJson(Request request) { + + RequestBody body = request.body(); + if (body instanceof FormBody) { + JsonObject object = new JsonObject(); + FormBody formBody = (FormBody) body; + for (int i = 0; i < formBody.size(); i++) { + object.addProperty(formBody.encodedName(i), formBody.value(i)); + } + return object; + } else { + //json鏍煎紡 + try { + String bodyString = getBodyString(request); + if (!TextUtils.isEmpty(bodyString)) { + final JsonElement parseString = JsonParser.parseString(bodyString); + return parseString.getAsJsonObject(); + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + return null; + } + + private String getBodyString(Request request) { + try { + RequestBody body = request.body(); + if (body != null) { + Buffer buffer = new Buffer(); + body.writeTo(buffer); + Charset charset = Charset.forName("UTF-8"); + MediaType contentType = body.contentType(); + charset = contentType.charset(charset); + return buffer.readString(charset); + } + } catch (IOException e) { + e.printStackTrace(); + } + return ""; + } + + + /** + * 闇�瑕佹寜瀛楁瘝鎺掑簭 + * + * @param json 鎵�鏈夊瓧娈典娇鐢╱rlParameter鎷兼帴锛岄櫎浜哸ppSecret + */ + private String getSign(JsonObject json, String appSecret) { + String builder = jsonToUrlParameter(json) + + appSecret; + return HDLMD5Utils.encodeMD5(builder); + } + + + private String jsonToUrlParameter(JsonObject object) { +// final Map<String, String> map = GsonUtils.getGson().fromJson(object, new TypeToken<Map<String, String>>() { +// }.getType()); +// final Uri.Builder builder = new Uri.Builder(); +// List<String> list = new ArrayList<>(map.keySet()); +// Collections.sort(list); +// for (String key : list) { +// String value = map.get(key); +// if (valueNeedSign(value)) { +// builder.appendQueryParameter(key, value); +// } +// } +// return builder.build().getQuery(); + final Uri.Builder builder = new Uri.Builder(); + try { + JSONObject jsonobject = JSON.parseObject(object.toString()); + List<String> list = new ArrayList<>(jsonobject.keySet()); + Collections.sort(list); + for (String key : list) { + Object obj = jsonobject.get(key); + if (isSignValue(obj)) + builder.appendQueryParameter(key, obj.toString()); + + } + } catch (Exception e) { + e.printStackTrace(); + } + return builder.build().getQuery(); + } + + private static boolean isSignValue(Object value) { + if (value == null) return false; + if (value instanceof Number) return true; + String className = value.getClass().getSimpleName(); + switch (className) { + case "String": + case "Integer": + case "Boolean": + case "Long": + case "Short": + case "Float": + case "Double": + case "Character": + case "Byte": + if (TextUtils.isEmpty(value.toString())) return false; + return true; + default: + return false; + + } + + } + + + /** + * 鍩烘湰绫诲瀷鍔犲瘑 + * <p> + * 鍒ゆ柇褰撳墠鍊兼槸鍚﹂渶瑕佸弬涓庣鍚嶏紝淇濇寔璺熶簯绔竴鑷� + * 绌哄瓧绗︿覆涓嶅弬涓� + * 鏁扮粍,闆嗗悎涓嶅弬涓� + * + * @return ture 闇�瑕佸姞瀵� + */ + private static boolean valueNeedSign(String valueStr) { + try { + if (!TextUtils.isEmpty(valueStr)) { + JsonElement json = JsonParser.parseString(valueStr); + if (json != null && (json.isJsonPrimitive() || json.getAsJsonPrimitive().isString())) { + return true; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + public static boolean isPrimitive(String type) { + return (type.equals("char") + || type.equals("double") || type.equals("float") + || type.equals("integer") || type.equals("string") + || type.equals("boolean")) || (type.equals("Char") + || type.equals("Double") || type.equals("Float") + || type.equals("Integer") || type.equals("String") + || type.equals("Boolean") || type.equals("int") + || type.equals("long") || type.equals("Int") || type + .equals("Long")); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLLoginInterceptor.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLLoginInterceptor.java new file mode 100644 index 0000000..f702e2d --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLLoginInterceptor.java @@ -0,0 +1,194 @@ +package com.hdl.linkpm.sdk.core.interceptor; + +import android.text.TextUtils; +import android.util.Log; + +import androidx.annotation.NonNull; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; +import com.hdl.hdlhttp.HxHttpConfig; +import com.hdl.linkpm.sdk.core.api.HDLCloudUserApi; +import com.hdl.linkpm.sdk.core.code.HDLCloudCode; +import com.hdl.linkpm.sdk.core.response.BaseInfo; +import com.hdl.linkpm.sdk.user.HDLLinkPMUser; +import com.hdl.linkpm.sdk.user.bean.HDLLoginBean; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; + +import java.io.IOException; +import java.nio.charset.Charset; + +import okhttp3.Headers; +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import okio.Buffer; +import okio.BufferedSource; + +/** + * Created by Tong on 2021/11/2. + */ +public class HDLLoginInterceptor implements Interceptor { + + @NonNull + @Override + public Response intercept(@NonNull Chain chain) throws IOException { + Request request = chain.request(); + if (!isRefreshTokenHeader(request.headers())) { + String token = HDLLinkPMUser.getInstance().getAccessToken(); + if (!TextUtils.isEmpty(token)) { + Request processRequest = addToken(request, token); + Response processResponse = chain.proceed(processRequest); + return disposeToken(chain, processRequest, processResponse); + } + } + return chain.proceed(request); + } + + @NonNull + private Response disposeToken(Chain chain, Request request, Response response) { + try { + +// ResponseBody responseBody2 = response.body(); +// BufferedSource source2 = responseBody2.source(); +// source2.request(Long.MAX_VALUE); +// Buffer buffer2 = source2.getBuffer().clone(); +// String respString2 = buffer2.readString(Charset.defaultCharset()); + //http鏍囧噯鐘舵�佺爜 + if (401 == response.code() || 402 == response.code() || 403 == response.code()) { + final String token = refreshToken(); + if (!TextUtils.isEmpty(token)) { + return chain.proceed(addToken(request, token)); + } + + } else if (response.isSuccessful()) { + ResponseBody responseBody = response.body(); + if (responseBody != null) { + BufferedSource source = responseBody.source(); + source.request(Long.MAX_VALUE); + Buffer buffer = source.getBuffer().clone(); + String respString = buffer.readString(Charset.defaultCharset()); + JsonObject object = JsonParser.parseString(respString).getAsJsonObject(); + int code = object.get("code").getAsInt(); + //1.鍒ゆ柇token鏄惁杩囨湡鏄惁闇�瑕佸埛鏂皌oken + if (isTokenTimeoutByCode(code)) { + final String token = refreshToken(); + if (!TextUtils.isEmpty(token)) { + return chain.proceed(addToken(request, token)); + } + } + //2.鍒ゆ柇Token鏄惁閿欒 鍙戦�佺櫥鍑哄鐞嗛�氱煡 + if (isTokenNeedReLoginByCode(code)) { + //3.娓呯┖鐧诲綍淇℃伅骞跺彂鍑洪噸鏂扮櫥褰曢�氱煡 + HDLLinkPMUser.getInstance().logout(0); + } + } + + } + + } catch (Exception e) { + Log.d("HDL===>", "disposeToken: 澶辫触," + e); + } + return response; + } + + /** + * 鏍规嵁code鍒ゆ柇token鏄惁澶辨晥 闇�瑕佸埛鏂伴噸鏂皌oken + * + * @param code 涓氬姟code + * @return ture 澶辨晥 + */ + private boolean isTokenTimeoutByCode(int code) { + return HDLCloudCode.TOKEN_TIMEOUT == code; + } + + /** + * 鏍规嵁code鍒ゆ柇token鏄惁澶辨晥 闇�瑕侀噸鏂扮櫥褰曠殑 + * + * @param code 涓氬姟code + * @return ture 澶辨晥 + */ + private boolean isTokenNeedReLoginByCode(int code) { + return HDLCloudCode.RE_LOGIN == code + || HDLCloudCode.TOKEN_NOT_STANDARD == code + || HDLCloudCode.NO_TOKEN == code + || HDLCloudCode.CODE_TOKEN_ERROR_10006 == code + || HDLCloudCode.CODE_TOKEN_ERROR_10009 == code; + } + + + /** + * 鏄惁瀛樺湪鍒锋柊澶� + */ + private boolean isRefreshTokenHeader(Headers headers) { + String signHeader = headers.get(HDLSmartHeader.REFRESH_TOKEN_HEADER); + return !TextUtils.isEmpty(signHeader); + } + + private Request addToken(Request request, String token) { + return request.newBuilder() + .removeHeader("Authorization") + .build() + .newBuilder() + .method(request.method(), request.body()) + .addHeader("Authorization", token) + .build(); + } + + /** + * 鎷︽埅鍣‥ncryptInterceptor浼氬鐞嗗姞瀵� + * + * @return token + */ + private String refreshToken() { + final String cacheRefreshToken = HDLLinkPMUser.getInstance().getRefreshToken(); + final String regionUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_LOGIN); + final OkHttpClient client = HxHttpConfig.getInstance().getClient(); + Request.Builder builder = new Request.Builder(); + + final JsonObject json = new JsonObject(); + json.addProperty("refreshToken", cacheRefreshToken); + json.addProperty("grantType", "refresh_token"); + + final RequestBody requestBody = RequestBody.create(json.toString(), MediaType.parse("application/json;charset=UTF-8")); + builder.post(requestBody); + builder.url(regionUrl); + builder.addHeader(HDLSmartHeader.REFRESH_TOKEN_HEADER, "0"); + try { + Response response = client.newCall(builder.build()).execute(); + if (response.isSuccessful()) { + ResponseBody responseBody = response.body(); + if (responseBody != null) { + BufferedSource source = responseBody.source(); + source.request(Long.MAX_VALUE); + Buffer buffer = source.getBuffer().clone(); + String respString = buffer.readString(Charset.defaultCharset()); + BaseInfo<HDLLoginBean> baseInfo = HDLGsonUtils.fromJson(respString, new TypeToken<BaseInfo<HDLLoginBean>>() { + }.getType()); + if (baseInfo != null) { + if (baseInfo.getCode() == HDLCloudCode.SUCCEED) { + if (baseInfo.getData() != null) { + HDLLoginBean loginBean = baseInfo.getData(); + HDLLinkPMUser.getInstance().updateRefreshToken(loginBean); + return loginBean.getHeaderPrefix() + loginBean.getAccessToken(); + } + } else { + //refreshToken涔熻繃鏈熺殑璇濓紝鍒欏彂鍑虹櫥鍑哄鐞嗛�氱煡锛岄噸鏂扮櫥褰� + //娓呯┖鐧诲綍淇℃伅骞跺彂鍑洪噸鏂扮櫥褰曢�氱煡 + HDLLinkPMUser.getInstance().logout(0); + } + } + } + } + } catch (Exception ignored) { + Log.d("HDL===>", "refreshToken: 澶辫触"); + } + return ""; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLSmartHeader.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLSmartHeader.java new file mode 100644 index 0000000..261d0a1 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLSmartHeader.java @@ -0,0 +1,18 @@ +package com.hdl.linkpm.sdk.core.interceptor; + +/** + * Created by Tong on 2021/11/8. + * 鎷︽埅鍣ㄦ爣璇� + */ +public class HDLSmartHeader { + + //榛樿鎼哄甫鍔犲瘑銆佽В瀵嗕互鍙婃椂闂存埑锛屼娇鐢�"IGNORE_SIGN_HEADER"鍙互灞忚斀 + public static final String IGNORE_SIGN_HEADER = "IgnoreSignHeader"; + + //鍦ㄥ埛鏂癟oken + public static final String REFRESH_TOKEN_HEADER = "RefreshTokenHeader"; + + //璇锋眰璇█ + public static final String LANGUAGE_HEADER = "language"; + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLSmartHeaderInterceptor.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLSmartHeaderInterceptor.java new file mode 100644 index 0000000..0cf27a9 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/interceptor/HDLSmartHeaderInterceptor.java @@ -0,0 +1,30 @@ +package com.hdl.linkpm.sdk.core.interceptor; + +import androidx.annotation.NonNull; + +import com.hdl.linkpm.sdk.HDLLinkPMSdk; + +import java.io.IOException; + +import okhttp3.Interceptor; +import okhttp3.Request; +import okhttp3.Response; + +/** + * Created by Tong on 2021/11/9. + * 鑷畾涔夊ご鍒犻櫎鎴栨坊鍔犲鐞� + */ +public class HDLSmartHeaderInterceptor implements Interceptor { + + + @NonNull + @Override + public Response intercept(@NonNull Chain chain) throws IOException { + Request request = chain.request().newBuilder() + .addHeader(HDLSmartHeader.LANGUAGE_HEADER, HDLLinkPMSdk.getLanguage())//閰嶇疆鎺ュ彛鍝嶅簲璇█ + .removeHeader(HDLSmartHeader.IGNORE_SIGN_HEADER) + .removeHeader(HDLSmartHeader.REFRESH_TOKEN_HEADER).build(); + return chain.proceed(request); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/response/BaseInfo.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/response/BaseInfo.java new file mode 100644 index 0000000..c807bcc --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/response/BaseInfo.java @@ -0,0 +1,96 @@ +package com.hdl.linkpm.sdk.core.response; + + +import androidx.annotation.NonNull; + +import java.io.Serializable; + + +/** + * @Author : Zoro. + * @Date : 2019/6/9. + * @Describe : + */ +public class BaseInfo<T> implements Serializable { + + private int code; + private T data; + private String message; + + //杩欎釜鏄瘑鐮佽緭閿欒秴鍑烘鏁�,鎵嶆湁杩欎釜瀛楁; + private Extra extra; + + public BaseInfo(int code, T data) { + this.code = code; + this.data = data; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public T getData() { + return data; + } + + @NonNull + public String getMessage() { + return message == null ? "" : message; + } + + public void setMessage(String message) { + this.message = message; + } + + public void setData(T data) { + this.data = data; + } + + public Extra getExtra() { + return extra; + } + + public void setExtra(Extra extra) { + this.extra = extra; + } + + public static class Extra { + + public int getMaxPwdErrorNum() { + return maxPwdErrorNum; + } + + public void setMaxPwdErrorNum(int maxPwdErrorNum) { + this.maxPwdErrorNum = maxPwdErrorNum; + } + + public long getUnlockTime() { + return unlockTime; + } + + public void setUnlockTime(long unlockTime) { + this.unlockTime = unlockTime; + } + + public int getCurrentPwdErrorNum() { + return currentPwdErrorNum; + } + + public void setCurrentPwdErrorNum(int currentPwdErrorNum) { + this.currentPwdErrorNum = currentPwdErrorNum; + } + + private int maxPwdErrorNum; + private long unlockTime; + + private int currentPwdErrorNum; + + } + + +} + diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/response/HDLResponse.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/response/HDLResponse.java new file mode 100644 index 0000000..5cc6fcd --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/core/response/HDLResponse.java @@ -0,0 +1,63 @@ +package com.hdl.linkpm.sdk.core.response; + + +import android.content.pm.ApplicationInfo; +import android.provider.Settings; +import android.widget.Toast; + +import com.hdl.hdlhttp.callback.HxException; +import com.hdl.hdlhttp.response.GsonSubscribe; +import com.hdl.hdlhttp.utils.ParameterizedTypeImpl; +import com.hdl.linkpm.sdk.HDLLinkPMSdk; +import com.hdl.linkpm.sdk.core.code.HDLCloudCode; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + + +/** + * Created by Tong on 2021/11/8. + */ +public abstract class HDLResponse<K> extends GsonSubscribe<BaseInfo<K>> { + + public abstract void onResponse(K response); + + public abstract void onFailure(HDLException e); + + @Override + public void onNext(String s) { + try { + Type type = getClass().getGenericSuperclass(); + if (type instanceof ParameterizedType) { + Type[] types = ((ParameterizedType) type).getActualTypeArguments(); + Type parameterizedType = new ParameterizedTypeImpl(BaseInfo.class, types, BaseInfo.class); + BaseInfo<K> data = HDLGsonUtils.fromJson(s, parameterizedType); + onSuccess(data); + } + } catch (Exception e) { + e.printStackTrace(); + this.onError(HxException.handleException(e)); + } + } + + @Override + public final void onSuccess(BaseInfo<K> response) { + if (response.getCode() == HDLCloudCode.SUCCEED) { + onResponse(response.getData()); + } else { + HDLLinkPMSdk.showToast(response.getMessage()); + onFailure(new HDLException(response.getCode(), response.getMessage(), response.getExtra())); + } + } + + @Override + public final void onError(HxException e) { +// if(HDLLinkPMSdk.isDebugVersion()){ +// HDLLinkPMSdk.showToast(e.getRawThrowable().getMessage()); +// } + onFailure(new HDLException(e.getCode(), e.getRawThrowable().getMessage(), null)); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/HDLLinkPMDevice.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/HDLLinkPMDevice.java new file mode 100644 index 0000000..f579697 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/HDLLinkPMDevice.java @@ -0,0 +1,272 @@ +package com.hdl.linkpm.sdk.device; + +import android.text.TextUtils; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.linkpm.sdk.core.api.HDLCloudHomeApi; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.device.bean.CategoryInfo; +import com.hdl.linkpm.sdk.device.bean.DeviceOidInfoBean; +import com.hdl.linkpm.sdk.device.bean.FunctionActionBean; +import com.hdl.linkpm.sdk.device.bean.FunctionInfoBaseBean; +import com.hdl.linkpm.sdk.device.bean.FunctionInfoListBean; +import com.hdl.linkpm.sdk.device.bean.GatewayCloudBean; +import com.hdl.linkpm.sdk.device.bean.ProductInfo; +import com.hdl.linkpm.sdk.device.controller.HDLPMDeviceController; +import com.hdl.linkpm.sdk.home.bean.QuestionInfo; +import com.hdl.linkpm.sdk.home.bean.QuestionListInfo; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; + +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; + +/** + * Created by jlchen on 12/2/21. + */ +public class HDLLinkPMDevice { + //instance + private volatile static HDLLinkPMDevice instance; + + /** + * getInstance + * + * @return HDLLinkDevice + */ + public static synchronized HDLLinkPMDevice getInstance() { + if (instance == null) { + synchronized (HDLLinkPMDevice.class) { + if (instance == null) { + instance = new HDLLinkPMDevice(); + } + } + } + return instance; + } + + /***************4.璁惧銆佸姛鑳藉鍒犳敼鏌ョ鐞�***************/ + /** + * 璁惧鍩烘湰淇℃伅鍒楄〃(oid)鍏ㄩ噺娣诲姞 + * + * @param homeId 浣忓畢id + * @param oidDeviceList 鏈�鏂扮殑璁惧Oid鍒楄〃 + * @param callBack + * @return + */ + public void fullAddDeviceOidList(String homeId, List<DeviceOidInfoBean> oidDeviceList, IDefaultCallBack callBack) { + HDLPMDeviceController.getInstance().fullAddDeviceOidList(homeId, oidDeviceList, callBack); + } + + /** + * 璁惧鍩烘湰淇℃伅鍒楄〃(oid)鑾峰彇 + * + * @param homeId 浣忓畢id + * @param callBack + * @return + */ + public void getDeviceOidList(String homeId, IResponseCallBack<List<DeviceOidInfoBean>> callBack) { + HDLPMDeviceController.getInstance().getDeviceOidList(homeId, callBack); + } + + /** + * 璁惧缃戝叧鍒楄〃 + * + * @param homeId 浣忓畢id + * @param callBack + * @return + */ + public void getGatewayList(String homeId, IResponseCallBack<List<GatewayCloudBean>> callBack) { + HDLPMDeviceController.getInstance().getGatewayList(homeId, callBack); + } + + + /** + * 璁惧鍩烘湰淇℃伅(oid)鍒犻櫎 + * 鍒犻櫎璁惧鎴栬�呬粠缃戝叧绛塷id + * + * @param homeId 浣忓畢id + * @param oid 璁惧鐨刼id + * @param callBack + * @return + */ + public void removeDeviceOid(String homeId, String oid, IDefaultCallBack callBack) { + HDLPMDeviceController.getInstance().removeDeviceOid(homeId, oid, callBack); + } + + /** + * 璁惧锛堝姛鑳斤級鍏ㄩ噺鏇存柊 + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧Id + * @param functionList 鏈�鏂扮殑鍔熻兘鍒楄〃 + * @param callBack + * @return + */ + public void fullAddFunctionList(String homeId, String gatewayId, List<FunctionInfoBaseBean> functionList, IDefaultCallBack callBack) { + HDLPMDeviceController.getInstance().fullAddFunctionList(homeId, gatewayId, functionList, callBack); + } + + /** + * 鑾峰彇绫荤洰 + * + * @param callBack + * @return + */ + public void getCategoryAllTree(IResponseCallBack<List<CategoryInfo>> callBack) { + HDLPMDeviceController.getInstance().getCategoryList(callBack); + } + + /** + * 鑾峰彇绫荤洰涓嬭澶囧垪琛ㄦ牴鎹悕瀛� + * + * @param callBack + * @return + */ + public void getCategoryListByName(String productName, IResponseCallBack<List<ProductInfo>> callBack) { + HDLPMDeviceController.getInstance().getCategoryListByName(productName, callBack); + } + + /** + * 鑾峰彇绫荤洰涓嬭澶囧垪琛ㄦ牴鎹被鐩� + * + * @param callBack + * @return + */ + public void getCategoryListByCode(String categorySecondCode, IResponseCallBack<List<ProductInfo>> callBack) { + HDLPMDeviceController.getInstance().getCategoryListByCode(categorySecondCode, callBack); + } + + /** + * 璁惧锛堝姛鑳斤級鍒楄〃鑾峰彇 + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧Id + * @param callBack + * @return + */ + public void getFunctionList(String homeId, String gatewayId, IResponseCallBack<FunctionInfoListBean> callBack) { + HDLPMDeviceController.getInstance().getFunctionList(homeId, gatewayId, callBack); + } + + /** + * 璁惧锛堝姛鑳斤級鍒犻櫎锛屾敮鎸佹壒閲� + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧Id + * @param devices 浜戠璁惧ID闆嗗悎 + * @param callBack + * @return + */ + public void batchDeleteFunctionList(String homeId, String gatewayId, List<String> devices, IDefaultCallBack callBack) { + HDLPMDeviceController.getInstance().batchDeleteFunctionList(homeId, gatewayId, devices, callBack); + } + + /** + * 鎺у埗璁惧 + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧Id + * @param actions 鍔ㄤ綔 + * @param callBack + * @return + */ + public void controlFunction(String homeId, String gatewayId, List<FunctionActionBean> actions, IDefaultCallBack callBack) { + HDLPMDeviceController.getInstance().controlFunction(homeId, gatewayId, actions, callBack); + } + + + /** + * 缁戝畾姣背娉㈣澶� + * + * @param homeId 浣忓畢Id + * @param name 璁惧鍚嶇О + * @param spk 浜у搧spk + * @param oid 璁惧oid + * @param mac 璁惧mac + * @param sid 璁惧sid + * @param uidList 鎴块棿uid鍒楄〃 + * @param callBack 鍥炶皟 + */ + public void bindMillimeterDevice(String homeId, String name, String spk, String oid, String mac, String sid, List<String> uidList, IResponseCallBack<String> callBack) { + HDLPMDeviceController.getInstance().bindMillimeterDevice(homeId, name, spk, oid, mac, sid, uidList, callBack); + } + + /** + * 瑙g粦姣背娉㈣澶� + * + * @param homeId 浣忓畢Id + * @param spk 浜у搧spk + * @param mac 璁惧mac + * @param callBack 鍥炶皟 + */ + public void unBindMillimeterDevice(String homeId, String spk, String mac, IResponseCallBack<String> callBack) { + HDLPMDeviceController.getInstance().unBindMillimeterDevice(homeId, spk, mac, callBack); + } + + /** + * 鑾峰彇link鍔熻兘鍒楄〃 + * + * @param homeId 浣忓畢Id + * @param spk spk + * @param callBack 鍥炶皟 + */ + public void getDeviceList(String homeId, String spk, IResponseCallBack<FunctionInfoListBean> callBack) { + HDLPMDeviceController.getInstance().getDeviceList(homeId, spk, callBack); + } + + /** + * 鑾峰彇姣背娉�(鑾峰彇璁惧杩滅▼閫氳淇℃伅) + * + * @param homeId 浣忓畢Id + * @param spk spk + * @param mac 璁惧mac + * @param callBack 鍥炶皟 + */ + public void getDeviceRemoteInfo(String homeId, String spk, String mac, IResponseCallBack<String> callBack) { + HDLPMDeviceController.getInstance().getDeviceRemoteInfo(homeId, spk, mac, callBack); + } + + /** + * 璁惧锛堝姛鑳斤級淇敼澶囨敞 + * + * @param homeId 浣忓畢id + * @param deviceId 璁惧Id + * @param name 璁惧鍚嶇О + */ + public void rename(String homeId, long deviceId,String name, IResponseCallBack<String> callBack) { + HDLPMDeviceController.getInstance().rename( homeId, deviceId, name, callBack); + } + + + /** + * 璁惧锛堝姛鑳斤級缁戝畾鎴块棿 + * + * @param homeId 浣忓畢id + * @param deviceIds 璁惧id鍒楄〃 + * @param roomIds 鎴块棿id鍒楄〃 + */ + public void bindRoom(String homeId, List<String> deviceIds,List<String> roomIds, IResponseCallBack<String> callBack) { + HDLPMDeviceController.getInstance().bindRoom( homeId, deviceIds, roomIds, callBack); + } + + + + /** + * 鑾峰彇甯歌闂鍒楄〃 + * + * @param languageType 0:涓枃 1:鑻辨枃,鍙敤鍊�:CHINESE,ENGLISH + * @param pageNo 褰撳墠椤� + * @param pageSize 椤甸潰澶у皬 + * @param question 闂 + * @param callBack + * @return + */ + public void getQuestionList(String languageType, String question, String pageNo, String pageSize, IResponseCallBack<QuestionListInfo> callBack) { + HDLPMDeviceController.getInstance().getQuestionList(languageType, question, pageNo, pageSize, callBack); + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/CategoryInfo.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/CategoryInfo.java new file mode 100644 index 0000000..f57b6a1 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/CategoryInfo.java @@ -0,0 +1,72 @@ +package com.hdl.linkpm.sdk.device.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2022/11/1 + * description: + */ +public class CategoryInfo implements Serializable { + private String categoryId; + private String categoryCode; + private String categoryName; + private String categoryType; + private String categoryIcon; + private List<CategoryInfo> children = new ArrayList<>(); + + public String getCategoryIcon() { + return categoryIcon == null ? "" : categoryIcon; + } + + public void setCategoryIcon(@NonNull String categoryIcon) { + this.categoryIcon = categoryIcon; + } + + public String getCategoryId() { + return categoryId == null ? "" : categoryId; + } + + public void setCategoryId(@NonNull String categoryId) { + this.categoryId = categoryId; + } + + public String getCategoryCode() { + return categoryCode == null ? "" : categoryCode; + } + + public void setCategoryCode(@NonNull String categoryCode) { + this.categoryCode = categoryCode; + } + + public String getCategoryName() { + return categoryName == null ? "" : categoryName; + } + + public void setCategoryName(@NonNull String categoryName) { + this.categoryName = categoryName; + } + + public String getCategoryType() { + return categoryType == null ? "" : categoryType; + } + + public void setCategoryType(@NonNull String categoryType) { + this.categoryType = categoryType; + } + + public List<CategoryInfo> getChildren() { + if (children == null) { + return children = new ArrayList<>(); + } + return children; + } + + public void setChildren(@NonNull List<CategoryInfo> children) { + this.children = children; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/DeviceOidInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/DeviceOidInfoBean.java new file mode 100644 index 0000000..da48397 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/DeviceOidInfoBean.java @@ -0,0 +1,186 @@ +package com.hdl.linkpm.sdk.device.bean; + +import androidx.annotation.NonNull; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/11/21. + * 璁惧鍩烘湰淇℃伅(oid) + */ +public class DeviceOidInfoBean implements Serializable { + private String deviceOidId;//涓婁紶鍚庝簯绔垎閰嶇殑鍞竴ID + private String oid;//璁惧鐨刼id + @SerializedName(value = "mac", alternate = {"device_mac"}) + private String mac;//璁惧mac + private String protocolType;//鍗忚绫诲瀷(bus銆乲nx銆亃igbee) + private String deviceType;//璁惧绫诲瀷 + private String device_name;//璁惧鍚嶇О +// @SerializedName(value = "parentOid", alternate = {"from"}) + private String parentOid;//鐖惰澶噊id + private String device_model;//璁惧鍨嬪彿 + private String fw_version;//鍥轰欢鐗堟湰 + private String hw_info;//纭欢鐗堟湰 + private List<ImageInfoBean> image_info;//鐗堟湰淇℃伅 + /** + * WAIT_CONFIG锛氬緟閰嶇疆 + * IN_CONFIG锛氶厤缃腑 + * CONFIGURED锛氬凡閰嶇疆 + */ + private String configStatus;//閰嶇疆鐘舵�� + private String configStatusName;//閰嶇疆鐘舵�佸悕绉� + private String modifyTime;//淇敼鏃堕棿 + +// private String addresses;//瀛愮綉鍙疯澶囧彿 + + public String getConfigStatus() { + return configStatus == null ? "" : configStatus; + } + + public void setConfigStatus(@NonNull String configStatus) { + this.configStatus = configStatus; + } + + public String getConfigStatusName() { + return configStatusName == null ? "" : configStatusName; + } + + public void setConfigStatusName(@NonNull String configStatusName) { + this.configStatusName = configStatusName; + } + + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } + + public void setModifyTime(@NonNull String modifyTime) { + this.modifyTime = modifyTime; + } + + @NonNull + public String getDeviceOidId() { + return deviceOidId == null ? "" : deviceOidId; + } + + public void setDeviceOidId(@NonNull String deviceOidId) { + this.deviceOidId = deviceOidId; + } + + @NonNull + public String getOid() { + return oid == null ? "" : oid; + } + + public void setOid(@NonNull String oid) { + this.oid = oid; + } + + @NonNull + public String getMac() { + return mac == null ? "" : mac; + } + + public void setMac(@NonNull String mac) { + this.mac = mac; + } + + @NonNull + public String getProtocolType() { + return protocolType == null ? "" : protocolType; + } + + public void setProtocolType(@NonNull String protocolType) { + this.protocolType = protocolType; + } + + @NonNull + public String getDeviceType() { + return deviceType == null ? "" : deviceType; + } + + public void setDeviceType(@NonNull String deviceType) { + this.deviceType = deviceType; + } + + @NonNull + public String getDevice_name() { + return device_name == null ? "" : device_name; + } + + public void setDevice_name(@NonNull String device_name) { + this.device_name = device_name; + } + + @NonNull + public String getParentOid() { + return parentOid == null ? "" : parentOid; + } + + public void setParentOid(@NonNull String parentOid) { + this.parentOid = parentOid; + } + + @NonNull + public String getDevice_model() { + return device_model == null ? "" : device_model; + } + + public void setDevice_model(@NonNull String device_model) { + this.device_model = device_model; + } + + @NonNull + public String getFw_version() { + return fw_version == null ? "" : fw_version; + } + + public void setFw_version(@NonNull String fw_version) { + this.fw_version = fw_version; + } + + @NonNull + public String getHw_info() { + return hw_info == null ? "" : hw_info; + } + + public void setHw_info(@NonNull String hw_info) { + this.hw_info = hw_info; + } + + public static class ImageInfoBean implements Serializable { + private String imageId;//闀滃儚id + private String fw_version;//鍥轰欢鐗堟湰 + private String hw_version;//纭欢鐗堟湰 + + @NonNull + public String getImageId() { + return imageId == null ? "" : imageId; + } + + public void setImageId(@NonNull String imageId) { + this.imageId = imageId; + } + + @NonNull + public String getFw_version() { + return fw_version == null ? "" : fw_version; + } + + public void setFw_version(@NonNull String fw_version) { + this.fw_version = fw_version; + } + + @NonNull + public String getHw_version() { + return hw_version == null ? "" : hw_version; + } + + public void setHw_version(@NonNull String hw_version) { + this.hw_version = hw_version; + } + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionActionBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionActionBean.java new file mode 100644 index 0000000..0845ff7 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionActionBean.java @@ -0,0 +1,47 @@ +package com.hdl.linkpm.sdk.device.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/11/21. + */ +public class FunctionActionBean implements Serializable{ + + private String deviceId;//璁惧涓婚敭id + private String spk;//spk + private List<StatusBean> attributes = new ArrayList<>();//鎺у埗鍔ㄤ綔 + + @NonNull + public String getDeviceId() { + return deviceId == null ? "" : deviceId; + } + + public void setDeviceId(@NonNull String deviceId) { + this.deviceId = deviceId; + } + + @NonNull + public String getSpk() { + return spk == null ? "" : spk; + } + + public void setSpk(@NonNull String spk) { + this.spk = spk; + } + + @NonNull + public List<StatusBean> getAttributes() { + if (attributes == null) { + return new ArrayList<>(); + } + return attributes; + } + + public void setAttributes(@NonNull List<StatusBean> attributes) { + this.attributes = attributes; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionAttributesBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionAttributesBean.java new file mode 100644 index 0000000..22d07c6 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionAttributesBean.java @@ -0,0 +1,66 @@ +package com.hdl.linkpm.sdk.device.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/11/21. + */ +public class FunctionAttributesBean implements Serializable{ + + private String key; + private String data_type; + private String max; + private String min; + private List<String> value = new ArrayList<>(); + + public String getMax() { + return max == null ? "" : max; + } + + public void setMax(@NonNull String max) { + this.max = max; + } + + public String getMin() { + return min == null ? "" : min; + } + + public void setMin(@NonNull String min) { + this.min = min; + } + + @NonNull + public String getKey() { + return key == null ? "" : key; + } + + public void setKey(@NonNull String key) { + this.key = key; + } + + @NonNull + public String getData_type() { + return data_type == null ? "" : data_type; + } + + public void setData_type(@NonNull String data_type) { + this.data_type = data_type; + } + + @NonNull + public List<String> getValue() { + if (value == null) { + return new ArrayList<>(); + } + return value; + } + + public void setValue(@NonNull List<String> value) { + this.value = value; + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoBaseBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoBaseBean.java new file mode 100644 index 0000000..ebe0d66 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoBaseBean.java @@ -0,0 +1,127 @@ +package com.hdl.linkpm.sdk.device.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/11/21. + * 鍔熻兘鍩虹鍙傛暟锛屾湰鍦伴�氫俊浣跨敤 + */ +public class FunctionInfoBaseBean implements Serializable { + + private String sid;//鍔熻兘Id + private List<String> uids = new ArrayList<>();//鎵�鍒嗛厤鐨勬埧闂磚id闆嗗悎 + private String name;//鍔熻兘鍚嶇О + private String spk;//鍔熻兘绫诲瀷 + private String oid;//璁惧瀵瑰簲鐨刼id + private String omodel;//鐗╃悊璁惧(妯″潡)鍨嬪彿 + private List<FunctionAttributesBean> attributes = new ArrayList<>();//灞炴�� + private String extend;//鎵╁睍淇℃伅 + + + + private String src;//璁惧鏉ユ簮 + + /** + * 1:灞曠ず 2:涓嶅睍绀� + */ + private String show; + + public String getSrc() { + return src; + } + + public void setSrc(String src) { + this.src = src; + } + + public String getShow() { + return show == null ? "1" : show; + } + + public void setShow(@NonNull String show) { + this.show = show; + } + + + @NonNull + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(@NonNull String sid) { + this.sid = sid; + } + + @NonNull + public List<String> getUids() { + if (uids == null) { + return new ArrayList<>(); + } + return uids; + } + + public void setUids(@NonNull List<String> uids) { + this.uids = uids; + } + + @NonNull + public String getName() { + return name == null ? "" : name; + } + + public void setName(@NonNull String name) { + this.name = name; + } + + @NonNull + public String getSpk() { + return spk == null ? "" : spk; + } + + public void setSpk(@NonNull String spk) { + this.spk = spk; + } + + @NonNull + public String getOid() { + return oid == null ? "" : oid; + } + + public void setOid(@NonNull String oid) { + this.oid = oid; + } + + @NonNull + public String getOmodel() { + return omodel == null ? "" : omodel; + } + + public void setOmodel(@NonNull String omodel) { + this.omodel = omodel; + } + + @NonNull + public List<FunctionAttributesBean> getAttributes() { + if (attributes == null) { + return new ArrayList<>(); + } + return attributes; + } + + public void setAttributes(@NonNull List<FunctionAttributesBean> attributes) { + this.attributes = attributes; + } + + @NonNull + public String getExtend() { + return extend == null ? "" : extend; + } + + public void setExtend(@NonNull String extend) { + this.extend = extend; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoBean.java new file mode 100644 index 0000000..af59704 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoBean.java @@ -0,0 +1,245 @@ +package com.hdl.linkpm.sdk.device.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/11/21. + */ +public class FunctionInfoBean extends FunctionInfoBaseBean { +// +// private String sid;//鍔熻兘Id +// private List<String> uids;//鎵�鍒嗛厤鐨勬埧闂磚id闆嗗悎 +// private String name;//鍔熻兘鍚嶇О +// private String spk;//鍔熻兘绫诲瀷 +// private String oid;//璁惧瀵瑰簲鐨刼id +// private String omodel;//鐗╃悊璁惧(妯″潡)鍨嬪彿 +// private List<FunctionInfoBaseBean.AttributesBean> attributes;//灞炴�� +// private String extend;//鎵╁睍淇℃伅 +// + + private String deviceId; + private String homeId; + private List<String> roomIds = new ArrayList<>(); + private List<RoomInfosBean> roomInfos = new ArrayList<>(); + private String gatewayId; + private String gatewayName; + private boolean collect; + private boolean online; + private String controlCounter; + private List<StatusBean> status = new ArrayList<>(); + private String createTime; + private String modifyTime; + private String productBrand; + private String productPic; + private String deviceMac;//姣背娉㈢嫭鏈� + + + public String getDeviceMac() { + return deviceMac == null ? "" : this.deviceMac; + } + + public void setDeviceMac(String deviceMac) { + this.deviceMac = deviceMac; + } + + @NonNull + public String getDeviceId() { + return deviceId == null ? "" : deviceId; + } + + public void setDeviceId(@NonNull String deviceId) { + this.deviceId = deviceId; + } + + @NonNull + public String getHomeId() { + return homeId == null ? "" : homeId; + } + + public void setHomeId(@NonNull String homeId) { + this.homeId = homeId; + } + + @NonNull + public List<String> getRoomIds() { + if (roomIds == null) { + return new ArrayList<>(); + } + return roomIds; + } + + public void setRoomIds(@NonNull List<String> roomIds) { + this.roomIds = roomIds; + } + + @NonNull + public List<RoomInfosBean> getRoomInfos() { + if (roomInfos == null) { + return new ArrayList<>(); + } + return roomInfos; + } + + public void setRoomInfos(@NonNull List<RoomInfosBean> roomInfos) { + this.roomInfos = roomInfos; + } + + @NonNull + public String getGatewayId() { + return gatewayId == null ? "" : gatewayId; + } + + public void setGatewayId(@NonNull String gatewayId) { + this.gatewayId = gatewayId; + } + + @NonNull + public String getGatewayName() { + return gatewayName == null ? "" : gatewayName; + } + + public void setGatewayName(@NonNull String gatewayName) { + this.gatewayName = gatewayName; + } + + public boolean isCollect() { + return collect; + } + + public void setCollect(boolean collect) { + this.collect = collect; + } + + public boolean isOnline() { + return online; + } + + public void setOnline(boolean online) { + this.online = online; + } + + @NonNull + public String getControlCounter() { + return controlCounter == null ? "" : controlCounter; + } + + public void setControlCounter(@NonNull String controlCounter) { + this.controlCounter = controlCounter; + } + + @NonNull + public List<StatusBean> getStatus() { + if (status == null) { + return new ArrayList<>(); + } + return status; + } + + public void setStatus(@NonNull List<StatusBean> status) { + this.status = status; + } + + @NonNull + public String getCreateTime() { + return createTime == null ? "" : createTime; + } + + public void setCreateTime(@NonNull String createTime) { + this.createTime = createTime; + } + + @NonNull + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } + + public void setModifyTime(@NonNull String modifyTime) { + this.modifyTime = modifyTime; + } + + @NonNull + public String getProductBrand() { + return productBrand == null ? "" : productBrand; + } + + public void setProductBrand(@NonNull String productBrand) { + this.productBrand = productBrand; + } + + @NonNull + public String getProductPic() { + return productPic == null ? "" : productPic; + } + + public void setProductPic(@NonNull String productPic) { + this.productPic = productPic; + } + + public static class RoomInfosBean implements Serializable { + private String floorId; + private String floorUid; + private String floorName; + private String roomId; + private String roomUid; + private String roomName; + + @NonNull + public String getFloorId() { + return floorId == null ? "" : floorId; + } + + public void setFloorId(@NonNull String floorId) { + this.floorId = floorId; + } + + @NonNull + public String getFloorUid() { + return floorUid == null ? "" : floorUid; + } + + public void setFloorUid(@NonNull String floorUid) { + this.floorUid = floorUid; + } + + @NonNull + public String getFloorName() { + return floorName == null ? "" : floorName; + } + + public void setFloorName(@NonNull String floorName) { + this.floorName = floorName; + } + + @NonNull + public String getRoomId() { + return roomId == null ? "" : roomId; + } + + public void setRoomId(@NonNull String roomId) { + this.roomId = roomId; + } + + @NonNull + public String getRoomUid() { + return roomUid == null ? "" : roomUid; + } + + public void setRoomUid(@NonNull String roomUid) { + this.roomUid = roomUid; + } + + @NonNull + public String getRoomName() { + return roomName == null ? "" : roomName; + } + + public void setRoomName(@NonNull String roomName) { + this.roomName = roomName; + } + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoListBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoListBean.java new file mode 100644 index 0000000..3368bcf --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/FunctionInfoListBean.java @@ -0,0 +1,27 @@ +package com.hdl.linkpm.sdk.device.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/11/21. + */ +public class FunctionInfoListBean implements Serializable{ + + private List<FunctionInfoBean> list = new ArrayList<>(); + + @NonNull + public List<FunctionInfoBean> getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(@NonNull List<FunctionInfoBean> list) { + this.list = list; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/GatewayCloudBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/GatewayCloudBean.java new file mode 100644 index 0000000..e3539fb --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/GatewayCloudBean.java @@ -0,0 +1,244 @@ +package com.hdl.linkpm.sdk.device.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2022/11/7 + * description: + */ +public class GatewayCloudBean implements Serializable { + private String aesKey; + private String createTime; + private String deviceId; + /** + * 0.SM4 1.AES 2.涓嶅姞瀵� + */ + private String encryptionType; + private String gatewayName; + /** + * 缃戝叧绫诲瀷 + * BUSUDPGATEWAY + * AGATEWAY + * ZIGBEEGATEWAY + * KNXGATEWAY + */ + private String gatewayType; + private String groupName; + private String gwFirmwareVersion; + private String homeId; + private String gatewayId; + private String mac; + private String oid; + private String modifyPeople; + private String deviceModel; + private String modifyTime; + private String primaryKey; + private String projectName; + private String region; + private String subnetId; + private String userName; + private boolean gatewayStatus; + private String lastHeartbeatTime; + private String localSecret; + private List<SlaveGatewayCloudBean> slaveDevices = new ArrayList<>(); + + public String getOid() { + return oid == null ? "" : oid; + } + + public void setOid(@NonNull String oid) { + this.oid = oid; + } + + public String getDeviceModel() { + return deviceModel == null ? "" : deviceModel; + } + + public void setDeviceModel(@NonNull String deviceModel) { + this.deviceModel = deviceModel; + } + + public String getAesKey() { + return aesKey == null ? "" : aesKey; + } + + public void setAesKey(@NonNull String aesKey) { + this.aesKey = aesKey; + } + + public boolean isGatewayStatus() { + return gatewayStatus; + } + + public void setGatewayStatus(@NonNull boolean gatewayStatus) { + this.gatewayStatus = gatewayStatus; + } + + public String getCreateTime() { + return createTime == null ? "" : createTime; + } + + public void setCreateTime(@NonNull String createTime) { + this.createTime = createTime; + } + + public String getDeviceId() { + return deviceId == null ? "" : deviceId; + } + + public void setDeviceId(@NonNull String deviceId) { + this.deviceId = deviceId; + } + + public String getEncryptionType() { + return encryptionType == null ? "" : encryptionType; + } + + public void setEncryptionType(@NonNull String encryptionType) { + this.encryptionType = encryptionType; + } + + public String getGatewayName() { + return gatewayName == null ? "" : gatewayName; + } + + public void setGatewayName(@NonNull String gatewayName) { + this.gatewayName = gatewayName; + } + + public String getGatewayType() { + return gatewayType == null ? "" : gatewayType; + } + + public void setGatewayType(@NonNull String gatewayType) { + this.gatewayType = gatewayType; + } + + public String getGroupName() { + return groupName == null ? "" : groupName; + } + + public void setGroupName(@NonNull String groupName) { + this.groupName = groupName; + } + + public String getGwFirmwareVersion() { + return gwFirmwareVersion == null ? "" : gwFirmwareVersion; + } + + public void setGwFirmwareVersion(@NonNull String gwFirmwareVersion) { + this.gwFirmwareVersion = gwFirmwareVersion; + } + + public String getHomeId() { + return homeId == null ? "" : homeId; + } + + public void setHomeId(@NonNull String homeId) { + this.homeId = homeId; + } + + public String getGatewayId() { + return gatewayId == null ? "" : gatewayId; + } + + public void setGatewayId(@NonNull String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getMac() { + return mac == null ? "" : mac; + } + + public void setMac(@NonNull String mac) { + this.mac = mac; + } + + public String getModifyPeople() { + return modifyPeople == null ? "" : modifyPeople; + } + + public void setModifyPeople(@NonNull String modifyPeople) { + this.modifyPeople = modifyPeople; + } + + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } + + public void setModifyTime(@NonNull String modifyTime) { + this.modifyTime = modifyTime; + } + + public String getPrimaryKey() { + return primaryKey == null ? "" : primaryKey; + } + + public void setPrimaryKey(@NonNull String primaryKey) { + this.primaryKey = primaryKey; + } + + public String getProjectName() { + return projectName == null ? "" : projectName; + } + + public void setProjectName(@NonNull String projectName) { + this.projectName = projectName; + } + + public String getRegion() { + return region == null ? "" : region; + } + + public void setRegion(@NonNull String region) { + this.region = region; + } + + public String getSubnetId() { + return subnetId == null ? "" : subnetId; + } + + public void setSubnetId(@NonNull String subnetId) { + this.subnetId = subnetId; + } + + public String getUserName() { + return userName == null ? "" : userName; + } + + public void setUserName(@NonNull String userName) { + this.userName = userName; + } + + public String getLastHeartbeatTime() { + return lastHeartbeatTime == null ? "" : lastHeartbeatTime; + } + + public void setLastHeartbeatTime(@NonNull String lastHeartbeatTime) { + this.lastHeartbeatTime = lastHeartbeatTime; + } + + public String getLocalSecret() { + return localSecret == null ? "" : localSecret; + } + + public void setLocalSecret(@NonNull String localSecret) { + this.localSecret = localSecret; + } + + public List<SlaveGatewayCloudBean> getSlaveDevices() { + if (slaveDevices == null) { + return slaveDevices = new ArrayList<>(); + } + return slaveDevices; + } + + public void setSlaveDevices(@NonNull List<SlaveGatewayCloudBean> slaveDevices) { + this.slaveDevices = slaveDevices; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/ProductInfo.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/ProductInfo.java new file mode 100644 index 0000000..5c1fd7c --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/ProductInfo.java @@ -0,0 +1,49 @@ +package com.hdl.linkpm.sdk.device.bean; + +import java.io.Serializable; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2022/11/1 + * description: + */ +public class ProductInfo implements Serializable { + private String productName; + private String productModel; + private String imageUrl; + + public String getImageUrl() { + return imageUrl == null ? "" : imageUrl; + } + + public void setImageUrl(@NonNull String imageUrl) { + this.imageUrl = imageUrl; + } + + public String getProductName() { + return productName == null ? "" : productName; + } + + public void setProductName(@NonNull String productName) { + this.productName = productName; + } + + public String getProductModel() { + return productModel == null ? "" : productModel; + } + + public void setProductModel(@NonNull String productModel) { + this.productModel = productModel; + } + + public ProductInfo() { + } + + public ProductInfo(String productName, String productModel, String imageUrl) { + this.productName = productName; + this.productModel = productModel; + this.imageUrl = imageUrl; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/SlaveGatewayCloudBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/SlaveGatewayCloudBean.java new file mode 100644 index 0000000..9f0d6e3 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/SlaveGatewayCloudBean.java @@ -0,0 +1,49 @@ +package com.hdl.linkpm.sdk.device.bean; + +import java.io.Serializable; + +/** + * Created by Zoro + * Created on 2022/11/7 + * description: + */ +public class SlaveGatewayCloudBean implements Serializable { + /** + * 鍗忚绫诲瀷(bus銆乲nx銆亃igbee) + */ + private String protocolType; + private String deviceName; + private String deviceType; + private String oid; + private String addresses; + private String deviceModel; + private String mac; + + public String getProtocolType() { + return protocolType == null ? "" : protocolType; + } + + public String getDeviceName() { + return deviceName == null ? "" : deviceName; + } + + public String getDeviceType() { + return deviceType == null ? "" : deviceType; + } + + public String getOid() { + return oid == null ? "" : oid; + } + + public String getAddresses() { + return addresses == null ? "" : addresses; + } + + public String getDeviceModel() { + return deviceModel == null ? "" : deviceModel; + } + + public String getMac() { + return mac == null ? "" : mac; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/StatusBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/StatusBean.java new file mode 100644 index 0000000..72190a7 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/bean/StatusBean.java @@ -0,0 +1,32 @@ +package com.hdl.linkpm.sdk.device.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/14/21. + * 鐘舵�佹垨鑰卆ttributes鎺у埗鍔ㄤ綔 + */ +public class StatusBean implements Serializable { + private String key;//灞炴�у悕 + private String value;//灞炴�у�� + + @NonNull + public String getKey() { + return key == null ? "" : key; + } + + public void setKey(@NonNull String key) { + this.key = key; + } + + @NonNull + public String getValue() { + return value == null ? "" : value; + } + + public void setValue(@NonNull String value) { + this.value = value; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/controller/HDLPMDeviceController.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/controller/HDLPMDeviceController.java new file mode 100644 index 0000000..fbcd40c --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/controller/HDLPMDeviceController.java @@ -0,0 +1,733 @@ +package com.hdl.linkpm.sdk.device.controller; + +import android.text.TextUtils; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.linkpm.sdk.core.api.HDLCloudHomeApi; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.device.bean.CategoryInfo; +import com.hdl.linkpm.sdk.device.bean.DeviceOidInfoBean; +import com.hdl.linkpm.sdk.device.bean.FunctionActionBean; +import com.hdl.linkpm.sdk.device.bean.FunctionInfoBaseBean; +import com.hdl.linkpm.sdk.device.bean.FunctionInfoListBean; +import com.hdl.linkpm.sdk.device.bean.GatewayCloudBean; +import com.hdl.linkpm.sdk.device.bean.ProductInfo; +import com.hdl.linkpm.sdk.home.bean.QuestionListInfo; +import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; + +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; + +/** + * Created by jlchen on 12/3/21. + * 璁惧鐩稿叧鐨勭綉缁滆姹� + */ +public class HDLPMDeviceController { + /** + * instance + */ + private volatile static HDLPMDeviceController instance; + + /** + * getInstance + * + * @return HDLDeviceController + */ + public static synchronized HDLPMDeviceController getInstance() { + if (instance == null) { + synchronized (HDLPMDeviceController.class) { + if (instance == null) { + instance = new HDLPMDeviceController(); + } + } + } + return instance; + } + + /***************4.璁惧銆佸姛鑳藉鍒犳敼鏌ョ鐞�***************/ + /** + * 璁惧鍩烘湰淇℃伅鍒楄〃(oid)鍏ㄩ噺娣诲姞 + * + * @param homeId 浣忓畢id + * @param oidDeviceList 鏈�鏂扮殑璁惧Oid鍒楄〃 + * @param callBack + * @return + */ + public Disposable fullAddDeviceOidList(String homeId, List<DeviceOidInfoBean> oidDeviceList, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("devices", HDLGsonUtils.toJsonArray(oidDeviceList)); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_DEVICE_OID_LIST_FULL_ADD); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 璁惧鍩烘湰淇℃伅鍒楄〃(oid)鑾峰彇 + * + * @param homeId 浣忓畢id + * @param callBack + * @return + */ + public Disposable getDeviceOidList(String homeId, IResponseCallBack<List<DeviceOidInfoBean>> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_DEVICE_OID_LIST_GET); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<DeviceOidInfoBean>>() { + @Override + public void onResponse(List<DeviceOidInfoBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 璁惧鍩烘湰淇℃伅(oid)鍒犻櫎 + * 鍒犻櫎璁惧鎴栬�呬粠缃戝叧绛塷id + * + * @param homeId 浣忓畢id + * @param oid 璁惧鐨刼id + * @param callBack + * @return + */ + public Disposable removeDeviceOid(String homeId, String oid, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("oid", oid); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_DEVICE_OID_REMOVE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 璁惧锛堝姛鑳斤級鍏ㄩ噺鏇存柊 + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧Id + * @param functionList 鏈�鏂扮殑鍔熻兘鍒楄〃 + * @param callBack + * @return + */ + public Disposable fullAddFunctionList(String homeId, String gatewayId, List<FunctionInfoBaseBean> functionList, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + json.add("devices", HDLGsonUtils.toJsonArray(functionList)); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_FUNCTION_LIST_FULL_ADD); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇浜у搧鍒嗙被鏍� + * + * @param callBack + * @return + */ + public Disposable getCategoryList(IResponseCallBack<List<CategoryInfo>> callBack) { + JsonObject json = new JsonObject(); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_CATEGORY_LIST_ALLTREE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<CategoryInfo>>() { + @Override + public void onResponse(List<CategoryInfo> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇缃戝叧鍒楄〃 + * + * @param callBack + * @return + */ + public Disposable getGatewayList(String homeId, IResponseCallBack<List<GatewayCloudBean>> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_GATEWAY_LIST); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<GatewayCloudBean>>() { + @Override + public void onResponse(List<GatewayCloudBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 鑾峰彇绫荤洰涓嬭澶囧垪琛� + * + * @param callBack + * @return + */ + public Disposable getCategoryListByName(String productName, IResponseCallBack<List<ProductInfo>> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("productName", productName); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_CATEGORY_DEVICE_LIST); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<ProductInfo>>() { + @Override + public void onResponse(List<ProductInfo> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇绫荤洰涓嬭澶囧垪琛� + * + * @param callBack + * @return + */ + public Disposable getCategoryListByCode(String categorySecondCode, IResponseCallBack<List<ProductInfo>> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("categorySecondCode", categorySecondCode); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_CATEGORY_DEVICE_LIST); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<ProductInfo>>() { + @Override + public void onResponse(List<ProductInfo> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 璁惧锛堝姛鑳斤級鍒楄〃鑾峰彇 + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧Id + * @param callBack + * @return + */ + public Disposable getFunctionList(String homeId, String gatewayId, IResponseCallBack<FunctionInfoListBean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_FUNCTION_LIST_GET); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<FunctionInfoListBean>() { + @Override + public void onResponse(FunctionInfoListBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 璁惧锛堝姛鑳斤級鍒犻櫎锛屾敮鎸佹壒閲� + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧Id + * @param devices 浜戠璁惧ID闆嗗悎 + * @param callBack + * @return + */ + public Disposable batchDeleteFunctionList(String homeId, String gatewayId, List<String> devices, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + json.add("devices", HDLGsonUtils.toJsonArray(devices)); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_FUNCTION_BATCH_DELETE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鎺у埗璁惧 + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧Id + * @param actions 鍔ㄤ綔 + * @param callBack + * @return + */ + public Disposable controlFunction(String homeId, String gatewayId, List<FunctionActionBean> actions, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + json.add("actions", HDLGsonUtils.toJsonArray(actions)); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_FUNCTION_CONTROL); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 鑾峰彇甯歌闂鍒楄〃 + * + * @param languageType 0:涓枃 1:鑻辨枃,鍙敤鍊�:CHINESE,ENGLISH + * @param pageNo 褰撳墠椤� + * @param pageSize 椤甸潰澶у皬 + * @param question 闂 + * @param callBack + * @return + */ + public Disposable getQuestionList(String languageType, String question, String pageNo, String pageSize, IResponseCallBack<QuestionListInfo> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("zoneType", languageType); + json.addProperty("question", question); + json.addProperty("pageNo", pageNo); + json.addProperty("pageSize", pageSize); + json.addProperty("softwareType", "DEBUGGING_TREASURE"); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_QUESTION_GET_LIST); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<QuestionListInfo>() { + @Override + public void onResponse(QuestionListInfo response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 缁戝畾姣背娉㈣澶� + * + * @param homeId 浣忓畢Id + * @param name 璁惧鍚嶇О + * @param apk 浜у搧spk + * @param oid 璁惧oid + * @param mac 璁惧mac + * @param sid 璁惧sid + * @param uidList 鎴块棿uid鍒楄〃 + * @param callBack 鍥炶皟 + * @return - + */ + public Disposable bindMillimeterDevice(String homeId, String name, String apk, String oid, String mac, String sid, List<String> uidList, IResponseCallBack<String> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("name", name); + json.addProperty("spk", apk); + json.addProperty("oid", oid); + json.addProperty("mac", mac); + json.addProperty("sid", sid); + if(uidList!=null) { + json.add("uids", HDLGsonUtils.toJsonArray(uidList)); + } + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_DEVICE_INDEPENDENT_REGISTER); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String str) { + if (callBack != null) { + callBack.onSuccess(str); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 瑙g粦姣背娉㈣澶� + * + * @param homeId 浣忓畢Id + * @param spk 浜у搧spk + * @param mac 璁惧mac + * @param callBack 鍥炶皟 + * @return - + */ + public Disposable unBindMillimeterDevice(String homeId, String spk, String mac, IResponseCallBack<String> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("spk", spk); + json.addProperty("mac", mac); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_DEVICE_INDEPENDENT_UNBIND); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String str) { + if (callBack != null) { + callBack.onSuccess(str); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇link鍔熻兘鍒楄〃 + * + * @param homeId 浣忓畢Id + * @param spk spk(鎸囧畾鑾峰彇鍗曚釜鍔熻兘) + * @param callBack 鍥炶皟 + * @return - + */ + public Disposable getDeviceList(String homeId, String spk, IResponseCallBack<FunctionInfoListBean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + if(!TextUtils.isEmpty(spk)) { + json.addProperty("spk", spk); + } + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_FUNCTION_LIST_GET); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<FunctionInfoListBean>() { + @Override + public void onResponse(FunctionInfoListBean functionInfoListBean) { + if (callBack != null) { + callBack.onSuccess(functionInfoListBean); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇姣背娉�(鑾峰彇璁惧杩滅▼閫氳淇℃伅) + * + * @param homeId 浣忓畢Id + * @param spk spk + * @param mac 璁惧mac + * @param callBack 鍥炶皟 + * @return - + */ + public Disposable getDeviceRemoteInfo(String homeId, String spk,String mac, IResponseCallBack<String> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("spk", spk); + json.addProperty("mac", mac); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_DEVICE_REMOTEINFO_GET); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String str) { + if (callBack != null) { + callBack.onSuccess(str); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 璁惧锛堝姛鑳斤級淇敼澶囨敞 + * + * @param homeId 浣忓畢id + * @param deviceId 璁惧Id + * @param name 璁惧鍚嶇О + * @return callBack + */ + public Disposable rename(String homeId, long deviceId,String name, IResponseCallBack<String> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("deviceId", deviceId); + json.addProperty("name", name); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_DEVICE_RENAME); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String string) { + if (callBack != null) { + callBack.onSuccess(string); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 璁惧锛堝姛鑳斤級缁戝畾鎴块棿 + * + * @param homeId 浣忓畢id + * @param deviceIds 璁惧id鍒楄〃 + * @param roomIds 鎴块棿id鍒楄〃 + * @return callBack + */ + public Disposable bindRoom(String homeId, List<String> deviceIds,List<String> roomIds, IResponseCallBack<String> callBack) { + JsonObject json = new JsonObject(); + JsonArray deviceIdsArray=new JsonArray(); + JsonArray roomIdsArray=new JsonArray(); + for (int i = 0; i < deviceIds.size(); i++) { + deviceIdsArray.add(deviceIdsArray.get(i)); + } + for (int i = 0; i < roomIds.size(); i++) { + roomIdsArray.add(roomIdsArray.get(i)); + } + json.addProperty("homeId", homeId); + json.add("deviceIds", deviceIdsArray); + json.add("roomIds", roomIdsArray); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_DEVICE_BINDROOM); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String string) { + if (callBack != null) { + callBack.onSuccess(string); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/spk/BrandType.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/spk/BrandType.java new file mode 100644 index 0000000..2a01258 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/spk/BrandType.java @@ -0,0 +1,20 @@ +package com.hdl.linkpm.sdk.device.spk; + +import androidx.annotation.IntDef; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.SOURCE; + + +/** + * Created by jlchen on 12/16/21. + * 绗笁鏂瑰搧鐗屽垪琛� + */ +@Retention(SOURCE) +@IntDef({BrandType.All, BrandType.Hdl, BrandType.Tuya, BrandType.Megahealth, BrandType.All3tyBrand}) +public @interface BrandType { + int All = 0; + int Hdl = 1; + int Tuya = 2; + int Megahealth = 3; + int All3tyBrand = 99; +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/spk/SPK.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/spk/SPK.java new file mode 100644 index 0000000..2352f3c --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/device/spk/SPK.java @@ -0,0 +1,353 @@ +package com.hdl.linkpm.sdk.device.spk; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/16/21. + * LINK鍗忚鐨凷PK + */ +public class SPK { + + /** + * 1.security + */ + //鐚溂銆佽悿鐭� + public final static String SecurityEz = "security.peephole.ez"; + //闂ㄩ攣 + public final static String SecurityDoor = "security.door"; + /** + * 2.panel + */ + //闈㈡澘銆佹彃搴с�侀潰鏉� + public final static String PanelSocket = "panel.socket"; + //鍦烘櫙闈㈡澘 + + /** + * 3.鐏厜 + */ + // 锛堝紑鍏崇伅锛� + public final static String LightSwitch = "light.switch"; + // 锛堣皟鍏夌伅锛� + public final static String LightDimming = "light.dimming"; + // 锛圧GB鐏級 + public final static String LightRGB = "light.rgb"; + // 锛圕CT鐏級 + public final static String LightCCT = "light.cct"; + // 锛圧GBW鐏級 + public final static String LightRGBW = "light.rgbw"; + + // 鐏厜spk鍒楄〃 + public static List<String> LightSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(LightSwitch); + spkList.add(LightDimming); + spkList.add(LightRGB); + spkList.add(LightCCT); + spkList.add(LightRGBW); + return spkList; + } + + /** + * 4.sensor 浼犳劅鍣� + */ + //鐜浼犳劅鍣� + // 浜屾哀鍖栫⒊浼犳劅鍣� + public final static String SensorCO2 = "sensor.co2"; + // PM2.5浼犳劅鍣� + public final static String SensorPm25 = "sensor.pm25"; + // tvoc浼犳劅鍣� + public final static String SensorTVOC = "sensor.tvoc"; + // 娓╁害浼犳劅鍣� + public final static String SensorTemperature = "sensor.temperature"; + // 婀垮害浼犳劅鍣� + public final static String SensorHumidity = "sensor.humidity"; + // 鐜浼犳劅鍣� + // 鐜妫�娴嬩紶鎰熷櫒 + // 鐗规畩绫籹pk + // 璇pk鍔熻兘鏄幆澧冧紶鎰熷櫒鍔熻兘鐨勯泦鎴� + public final static String SensorEnvironment = "sensor.environment"; + // 闈掕悕鐜浼犳劅鍣� + public final static String SensorEnvironment2 = "sensor.environment2"; + // 闈掕悕鐜浼犳劅鍣� + public final static String SensorEnvironment3 = "sensor.environment3"; + //鐜浼犳劅鍣� 娴锋灄 + public final static String SensorEnvironmentHailin = "sensor.environment.hailin"; + // 鐢查啗 + public final static String SensorHcho = "sensor.hcho"; + //region 瀹夐槻浼犳劅鍣� + // 浜害浼犳劅鍣� + public final static String SensorLight = "sensor.light"; + // (绾㈠绉诲姩浼犳劅鍣�) + public final static String SensorPir = "sensor.pir"; + // 锛堥棬绐椾紶鎰熷櫒锛� + public final static String SensorDoorWindow = "sensor.doorwindow"; + // 鐑熼浘浼犳劅鍣� + public final static String SensorSmoke = "sensor.smoke"; + // 姘存蹈浼犳劅鍣� + public final static String SensorWater = "sensor.water"; + // 鐕冩皵浼犳劅鍣� + public final static String SensorGas = "sensor.gas"; + // 绾㈠鐝婃爮浼犳劅鍣� + public final static String SensorShanLan = "sensor.shanlan"; + // 绾㈠瀵瑰皠浼犳劅鍣� + public final static String SensorDuiShe = "sensor.duishe"; + // 瓒呭0娉紶鎰熷櫒 + public final static String SensorUtrasonic = "sensor.ultrasonic"; + // 锛堝共鎺ョ偣锛� + public final static String SensorDryContact = "sensor.dryContact"; + public final static String SensorDryContact2 = "dryContact.standard"; + // 姣背娉紶鎰熷櫒 + public final static String SenesorMegahealth = "sensor.megahealth"; + public final static String SenesorMegahealth2 = "sensor.megahealth.zg"; + + // 瀹夐槻浼犳劅鍣╯pk鍒楄〃 + public static List<String> ArmSensorSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(SensorPir); + spkList.add(SensorDoorWindow); + spkList.add(SensorSmoke); + spkList.add(SensorWater); + spkList.add(SensorGas); + spkList.add(SensorDryContact); + spkList.add(SensorDryContact2); + spkList.add(SenesorMegahealth); + spkList.add(SenesorMegahealth2); + return spkList; + } + + // 鐜浼犳劅鍣ㄨ澶噑pk鍒楄〃 + public static List<String> EnvironDeviceSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(SensorTemperature); + spkList.add(SensorPm25); + spkList.add(SensorCO2); + spkList.add(SensorTVOC); + spkList.add(SensorHumidity); + spkList.add(SensorEnvironment); + spkList.add(SensorEnvironment2); + spkList.add(SensorEnvironment3); + spkList.add(SensorHcho); + return spkList; + } + + // 鐜浼犳劅鍣╯pk鍒楄〃 + public static List<String> EnvironSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(SensorTemperature); + spkList.add(SensorPm25); + spkList.add(SensorCO2); + spkList.add(SensorTVOC); + spkList.add(SensorHumidity); + spkList.add(SensorHcho); + return spkList; + } + + // 鐜浼犳劅鍣ㄨ澶囧垪琛� + public static List<String> EvironmentSensorList() { + List<String> spkList = new ArrayList<>(); + spkList.add(SensorEnvironment); + spkList.add(SensorEnvironment2); + spkList.add(SensorEnvironment3); + return spkList; + } + + /** + * 5.绐楀笜 + */ + // 锛堝紑鍏崇獥甯橈級 + public final static String CurtainSwitch = "curtain.switch"; + // 锛堝紑鍚堝笜锛� + public final static String CurtainTrietex = "curtain.trietex"; + // 锛堢櫨鍙跺笜锛� + public final static String CurtainShades = "curtain.shades"; + // 锛堝嵎甯橈級 + public final static String CurtainRoller = "curtain.roller"; + + /** + * 绐楀笜spk鍒楄〃 + * + * @return + */ + public static List<String> CurtainSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(CurtainRoller); + spkList.add(CurtainSwitch); + spkList.add(CurtainShades); + spkList.add(CurtainTrietex); + return spkList; + } + + /** + * 6.HAVA + */ + // 绌鸿皟 + public final static String HvacAC = "hvac.ac"; + + // 绌鸿皟spk鍒楄〃 + public static List<String> AcSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(HvacAC); + return spkList; + } + + // 鍦版殩 + public final static String HvacFloorHeat = "hvac.floorHeat"; + + // 鍦扮儹spk鍒楄〃 + public static List<String> FhSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(HvacFloorHeat); + return spkList; + } + + // 鏂伴 + public final static String HvacAirFresh = "hvac.airFresh"; + // 鏂伴 鈥斺�旈噾鑼傚畾鍒� + public final static String HvacAirFreshJinmao = "hvac.airFresh.jinmao"; + + // 鏂伴spk鍒楄〃 + public static List<String> AirFreshSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(HvacAirFresh); + spkList.add(HvacAirFreshJinmao); + return spkList; + } + + /** + * 鑳芥簮 + */ + // 鑳芥簮妯″潡 + public final static String EnergyStandard = "energy.standard"; + // 鑳芥簮-鐢佃兘 + public final static String ElectricEnergy = "energy.electric"; + + // 鑳芥簮spk鍒楄〃 + public static List<String> EnergySpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(ElectricEnergy); + return spkList; + } + + + //region 闊充箰 + // 闊充箰 + public final static String AvMusic = "av.music"; + + // 闊充箰spk鍒楄〃 + public static List<String> MusicSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(AvMusic); + return spkList; + } + + //region 瀹剁數 + // 绾㈠銆佺數瑙� + public final static String TvIr = "ir.tv"; + // 绾㈠銆佸皬绫崇數瑙� + public final static String TvXmIr = "ir.tvxm"; + // 瀹剁數銆侀鎵� + public final static String HvacFan = "hvac.fan"; + // 鍑夐湼 + public final static String ClothesHanger = "electrical.racks"; + // 绾㈠閬ユ帶鍣� + public final static String IrLearn = "ir.learn"; + // 绾㈠鎶曞奖浠� + public final static String PjtIr = "ir.pjt"; + // 绾㈠鏈洪《鐩� + public final static String StbIr = "ir.stb"; + // 绾㈠褰辩鏈� + public final static String DvDIr = "ir.dvd"; + // 绾㈠绌烘皵鍑�鍖栧櫒 + public final static String PurifierIr = "ir.air_purifier"; + // 绾㈠鐑按鍣� + public final static String HeaterIr = " ir.water_heater"; + // 绾㈠椋庢墖 + public final static String FanIr = "ir.fan"; + // 鏅鸿兘绌哄紑 + // public final static String AirSwitch = "electrical.breaker"; + public final static String AirSwitch = "electrical.airSwitch"; + + //region 娑傞甫 + // 瀹剁數銆佹秱楦︾┖姘斿噣鍖栧櫒 + public final static String ElectricTuyaAirCleaner2 = "hvac.air.tuya_epi345"; + // 瀹剁數銆佹秱楦︾數椋庢墖 + public final static String ElectricTuyaFan2 = "hvac.fan.tuya_ef101"; + // 瀹剁數銆佹秱楦︽壂鍦版満鍣ㄤ汉 + public final static String ElectricTuyaWeepRobot2 = "electrical.sweep.tuya"; + // 瀹剁數銆佹秱楦︽按闃� + public final static String ElectricTuyaWaterValve2 = "electrical.watervalve.tuya_aw713"; + + + // 瀹剁數spk鍒楄〃 + public static List<String> ElectricalSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(PanelSocket); + spkList.add(TvIr); + spkList.add(TvXmIr); + spkList.add(HvacFan); + spkList.add(FanIr); + spkList.add(ClothesHanger); + spkList.add(IrLearn); + spkList.add(PjtIr); + spkList.add(StbIr); + spkList.add(ElectricTuyaAirCleaner2); + spkList.add(ElectricTuyaFan2); + spkList.add(ElectricTuyaWeepRobot2); + spkList.add(ElectricTuyaWaterValve2); + spkList.add(AirSwitch); + return spkList; + } + + //region 璁惧绫� + // 绾㈠瀹� + public final static String IrModule = "ir.module"; + + // 璁惧绫籹pk鍒楄〃 + public static List<String> DeviceSpkList() { + List<String> spkList = new ArrayList<>(); + spkList.add(IrModule); + return spkList; + } + + //region 绗笁鏂箂pk鍒楄〃 + // 鑾峰彇鎵�鏈夌涓夋柟鍝佺墝鍔熻兘鐨剆pk + public static List<String> GetAll3tySPK() { + List<String> spkList = new ArrayList<>(); + spkList.add(ElectricTuyaAirCleaner2); + spkList.add(ElectricTuyaFan2); + spkList.add(ElectricTuyaWaterValve2); + spkList.add(ElectricTuyaWeepRobot2); + spkList.add(SenesorMegahealth); + spkList.add(SenesorMegahealth2); + return spkList; + } + + // 鑾峰彇绗笁鏂硅澶噑pk + public static List<String> Get3tySpk(int brandType) { + List<String> list = new ArrayList<>(); + if (BrandType.Tuya == brandType) { + list.add(ElectricTuyaAirCleaner2); + list.add(ElectricTuyaFan2); + list.add(ElectricTuyaWaterValve2); + list.add(ElectricTuyaWeepRobot2); + } else if (BrandType.All3tyBrand == brandType) { + list.add(SenesorMegahealth);//鍏嗚 + } + return list; + } + + // 娌℃湁鐘舵�佹樉绀虹殑鍔熻兘spk鍒楄〃 + public static List<String> NotStatusSpkList() { + List<String> list = new ArrayList<>(); + list.add(FanIr); + list.add(TvIr); + list.add(TvXmIr); + list.add(StbIr); + list.add(PjtIr); + list.add(IrLearn); + return list; + } + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/HDLLinkPMHome.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/HDLLinkPMHome.java new file mode 100644 index 0000000..78c3b41 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/HDLLinkPMHome.java @@ -0,0 +1,191 @@ +package com.hdl.linkpm.sdk.home; + + +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.home.bean.GatewayBindBean; +import com.hdl.linkpm.sdk.home.bean.GatewayInfoBean; +import com.hdl.linkpm.sdk.home.bean.HomeInfoBean; +import com.hdl.linkpm.sdk.home.bean.RoomInfoBean; +import com.hdl.linkpm.sdk.home.bean.logic.LogicInfoBean; +import com.hdl.linkpm.sdk.home.bean.logic.SecurityInfoBean; +import com.hdl.linkpm.sdk.home.callback.IAddRoomListCallBack; +import com.hdl.linkpm.sdk.home.callback.IRoomListCallBack; +import com.hdl.linkpm.sdk.home.controller.HDLPMHomeController; + +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; + +/** + * Created by jlchen on 12/2/21. + */ +public class HDLLinkPMHome { + //instance + private volatile static HDLLinkPMHome instance; + + /** + * getInstance + * + * @return HDLLinkPMHome + */ + public static synchronized HDLLinkPMHome getInstance() { + if (instance == null) { + synchronized (HDLLinkPMHome.class) { + if (instance == null) { + instance = new HDLLinkPMHome(); + } + } + } + return instance; + } + + + /** + * house琛ㄧ殑鏁版嵁娌℃湁鍚屾鍒癶ome琛ㄣ�佹暟鎹瓨鍦ㄤ袱寮犺〃閲岄潰锛岄渶瑕佸鎴风璋冩帴鍙e悓姝� + * + * @param homeInfoBean 浣忓畢Info + * @param callBack + * @return + */ + public void synchHouseToHome(HomeInfoBean homeInfoBean, IDefaultCallBack callBack) { + HDLPMHomeController.getInstance().synchHouseToHome(homeInfoBean, callBack); + } + + /** + * 鑾峰彇浣忓畢涓嬫埧闂磋〃 + * + * @param homeId 浣忓畢ID + * @param roomType 鎴垮眿绫诲瀷 FLOOR ROOM銆佷负绌虹殑鏃跺�欐煡鍏ㄩ儴 + * @param pageNo 鍝竴椤� + * @param pageSize 椤甸潰澶у皬 + * @param callBack + * @return + */ + public void getRoomList(String homeId, String roomType, int pageNo, int pageSize, IRoomListCallBack callBack) { + HDLPMHomeController.getInstance().getRoomList(homeId, roomType, pageNo, pageSize, callBack); + } + + /** + * 鎴块棿鍒楄〃鍏ㄩ噺鏇存柊銆佹坊鍔犮�佺紪杈戙�佸垹闄ら兘鐢ㄨ鎺ュ彛 + * + * @param homeId 浣忓畢ID + * @param roomList 鏈�鏂扮殑鎴块棿鍒楄〃 + * @param callBack + * @return + */ + public void fullAddOrEditRoomList(String homeId, List<RoomInfoBean> roomList, IAddRoomListCallBack callBack) { + HDLPMHomeController.getInstance().fullAddOrEditRoomList(homeId, roomList, callBack); + } + + + /***************3.缃戝叧绠$悊***************/ + /** + * 缁戝畾缃戝叧鍒颁綇瀹� + * + * @param bean 缃戝叧淇℃伅 + * @param callBack + * @return + */ + public void bindGateway(GatewayBindBean bean, IResponseCallBack<GatewayInfoBean> callBack) { + HDLPMHomeController.getInstance().bindGateway(bean, callBack); + } + + /** + * 寮哄埗缁戝畾缃戝叧 + * 濡傛灉缁戝畾缃戝叧杩斿洖10510 宸茬粡琚粦瀹氫簡,鍒欒皟杩欎釜鎺ュ彛寮哄埗鎹㈢粦 + * + * @param homeId 浣忓畢ID + * @param mac 缃戝叧MAC + * @param callBack + * @return + */ + public void forceBindGateway(String homeId, String mac, IResponseCallBack<GatewayInfoBean> callBack) { + HDLPMHomeController.getInstance().forceBindGateway(homeId, mac, callBack); + } + + /** + * 瑙g粦缃戝叧 + * + * @param homeId 浣忓畢id + * @param gateWayId gatewayId + * @param callBack + * @return + */ + public void unbindGateway(String homeId, String gateWayId, IResponseCallBack<Boolean> callBack) { + HDLPMHomeController.getInstance().unbindGateway(homeId, gateWayId, callBack); + } + /** + * 瑙g粦浠庣綉鍏� + * + * @param homeId 浣忓畢id + * @param oid 璁惧oid + * @param callBack + * @return + */ + public void unbindFalseGateway(String homeId, String oid, IResponseCallBack<Boolean> callBack) { + HDLPMHomeController.getInstance().unbindFalseGateway(homeId, oid, callBack); + } + /** + * 缃戝叧缁戝畾浣忓畢淇℃伅 + * + * @param mac 缃戝叧mac + * @param callBack + * @return + */ + public void getGatewayHomeInfo(String mac,IResponseCallBack<GatewayInfoBean> callBack) { + HDLPMHomeController.getInstance().getGatewayHomeInfo(mac, callBack); + } + + /** + * 鑾峰彇缃戝叧鍒楄〃 + * + * @param homeId 浣忓畢id + * @param callBack + * @return + */ + public void getGatewayList(String homeId, IResponseCallBack<List<GatewayInfoBean>> callBack) { + HDLPMHomeController.getInstance().getGatewayList(homeId, callBack); + } + + /** + * 缃戝叧鏇挎崲 + * + * @param homeId 浣忓畢id + * @param gatewayId 鏃х綉鍏砳d + * @param newMac 鏂扮綉鍏砿ac + * @param callBack + * @return + */ + public void replaceGateway(String homeId, String gatewayId, String newMac, IDefaultCallBack callBack) { + HDLPMHomeController.getInstance().replaceGateway(homeId, gatewayId, newMac, callBack); + } + + /***************6.鑷姩鍖栧鍒犳敼鏌ョ鐞�***************/ + /** + * 鍏ㄩ噺鏇存柊鍚屾鑷姩鍖栥�佸瓨鍦ㄤ笉鍙�,涓嶅瓨鍦ㄦ柊澧� + * + * @param homeId 浣忓畢id + * @param logics 鑷姩鍖栧垪琛� + * @param callBack + * @return + */ + public void fullAddLogicList(String homeId, List<LogicInfoBean> logics, IDefaultCallBack callBack) { + HDLPMHomeController.getInstance().fullAddLogicList(homeId, logics, callBack); + } + + /***************7.瀹夐槻鍖栧鍒犳敼鏌ョ鐞�***************/ + /** + * 鍏ㄩ噺鏇存柊鍚屾瀹夐槻銆佸瓨鍦ㄤ笉鍙�,涓嶅瓨鍦ㄦ柊澧� + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧ID + * @param securitys 瀹夐槻鍒楄〃 + * @param callBack + * @return + */ + public void fullAddSecurityList(String homeId, String gatewayId, List<SecurityInfoBean> securitys, IDefaultCallBack callBack) { + HDLPMHomeController.getInstance().fullAddSecurityList(homeId, gatewayId, securitys, callBack); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/GatewayBindBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/GatewayBindBean.java new file mode 100644 index 0000000..462e6ca --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/GatewayBindBean.java @@ -0,0 +1,124 @@ +package com.hdl.linkpm.sdk.home.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/10/21. + * 缁戝畾缃戝叧鎻愪氦鐨勫弬鏁板璞� + */ +public class GatewayBindBean implements Serializable { + + private String homeId; + private String mac; + private String gwFirmwareVersion; + private String gatewayName; + private String gatewayType; + private String encryptionType;//0.SM4(鍥藉瘑) 1.AES 2.NONE(涓嶅姞瀵�) (榛樿1) + //涓嬮潰鏄竴绔彛闇�瑕佹彁浜ょ殑鍙傛暟 + private String projectName; + private String userName; + private String subnetId; + private String deviceId; + private String groupName; + + @NonNull + public String getHomeId() { + return homeId == null ? "" : homeId; + } + + public void setHomeId(@NonNull String homeId) { + this.homeId = homeId; + } + + @NonNull + public String getMac() { + return mac == null ? "" : mac; + } + + public void setMac(@NonNull String mac) { + this.mac = mac; + } + + @NonNull + public String getGwFirmwareVersion() { + return gwFirmwareVersion == null ? "" : gwFirmwareVersion; + } + + public void setGwFirmwareVersion(@NonNull String gwFirmwareVersion) { + this.gwFirmwareVersion = gwFirmwareVersion; + } + + @NonNull + public String getGatewayName() { + return gatewayName == null ? "" : gatewayName; + } + + public void setGatewayName(@NonNull String gatewayName) { + this.gatewayName = gatewayName; + } + + @NonNull + public String getGatewayType() { + return gatewayType == null ? "" : gatewayType; + } + + public void setGatewayType(@NonNull String gatewayType) { + this.gatewayType = gatewayType; + } + + @NonNull + public String getEncryptionType() { + return encryptionType == null ? "" : encryptionType; + } + + public void setEncryptionType(@NonNull String encryptionType) { + this.encryptionType = encryptionType; + } + + @NonNull + public String getProjectName() { + return projectName == null ? "" : projectName; + } + + public void setProjectName(@NonNull String projectName) { + this.projectName = projectName; + } + + @NonNull + public String getUserName() { + return userName == null ? "" : userName; + } + + public void setUserName(@NonNull String userName) { + this.userName = userName; + } + + @NonNull + public String getSubnetId() { + return subnetId == null ? "" : subnetId; + } + + public void setSubnetId(@NonNull String subnetId) { + this.subnetId = subnetId; + } + + @NonNull + public String getDeviceId() { + return deviceId == null ? "" : deviceId; + } + + public void setDeviceId(@NonNull String deviceId) { + this.deviceId = deviceId; + } + + @NonNull + public String getGroupName() { + return groupName == null ? "" : groupName; + } + + public void setGroupName(@NonNull String groupName) { + this.groupName = groupName; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/GatewayInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/GatewayInfoBean.java new file mode 100644 index 0000000..a9c4579 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/GatewayInfoBean.java @@ -0,0 +1,283 @@ +package com.hdl.linkpm.sdk.home.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/10/21. + * 缃戝叧淇℃伅璇︽儏 + */ +public class GatewayInfoBean implements Serializable { + + private String gatewayId;//缃戝叧id + private String mac;//缃戝叧mac鍦板潃 + private String homeId;//浣忓畢id + private String primaryKey;//绉侀挜 + private String aesKey;//mqtt閫氫俊瀵嗛挜 + private String localSecret;//鏈湴瀵嗛挜 2021.7.5鏂板 + private String gatewayStatus;//缃戝叧鐘舵�� true false + private int encryptionType;//0.SM4 1.AES 2.涓嶅姞瀵� + private String gatewayName;//缃戝叧鍚嶇О + private String gatewayType;//BUSUDPGATEWAY銆丄GATEWAY銆乑IGBEEGATEWAY銆並NXGATEWAY + private String gwFirmwareVersion;//缃戝叧鍥轰欢鐗堟湰 + private String onlineLatestTime;// + private List<SlaveDevicesBean> slaveDevices = new ArrayList<>();//浠庤澶囦俊鎭� 2021.10.18 鏂板 + //涓嬮潰鍙傛暟涓�绔彛缃戝叧鐨勬椂鍊欐墠鏈� + private String userName;//鐢ㄦ埛鍚� + private String groupName;//缁勫悕 + private String projectName;//宸ョ▼鍚� + private String region;//鏈嶅姟鍖哄煙 + private int subnetId;//瀛愮綉鍙� + private int deviceId;//璁惧鍙� + // private String createPeople;// +// private String createTime;// +// private String modifyPeople;// +// private String modifyTime;// + + + @NonNull + public String getGatewayId() { + return gatewayId == null ? "" : gatewayId; + } + + public void setGatewayId(@NonNull String gatewayId) { + this.gatewayId = gatewayId; + } + + @NonNull + public String getMac() { + return mac == null ? "" : mac; + } + + public void setMac(@NonNull String mac) { + this.mac = mac; + } + + @NonNull + public String getHomeId() { + return homeId == null ? "" : homeId; + } + + public void setHomeId(@NonNull String homeId) { + this.homeId = homeId; + } + + @NonNull + public String getPrimaryKey() { + return primaryKey == null ? "" : primaryKey; + } + + public void setPrimaryKey(@NonNull String primaryKey) { + this.primaryKey = primaryKey; + } + + @NonNull + public String getAesKey() { + return aesKey == null ? "" : aesKey; + } + + public void setAesKey(@NonNull String aesKey) { + this.aesKey = aesKey; + } + + @NonNull + public String getLocalSecret() { + return localSecret == null ? "" : localSecret; + } + + public void setLocalSecret(@NonNull String localSecret) { + this.localSecret = localSecret; + } + + @NonNull + public String getGatewayStatus() { + return gatewayStatus == null ? "" : gatewayStatus; + } + + public void setGatewayStatus(@NonNull String gatewayStatus) { + this.gatewayStatus = gatewayStatus; + } + + public int getEncryptionType() { + return encryptionType; + } + + public void setEncryptionType(int encryptionType) { + this.encryptionType = encryptionType; + } + + @NonNull + public String getGatewayName() { + return gatewayName == null ? "" : gatewayName; + } + + public void setGatewayName(@NonNull String gatewayName) { + this.gatewayName = gatewayName; + } + + @NonNull + public String getGatewayType() { + return gatewayType == null ? "" : gatewayType; + } + + public void setGatewayType(@NonNull String gatewayType) { + this.gatewayType = gatewayType; + } + + @NonNull + public String getGwFirmwareVersion() { + return gwFirmwareVersion == null ? "" : gwFirmwareVersion; + } + + public void setGwFirmwareVersion(@NonNull String gwFirmwareVersion) { + this.gwFirmwareVersion = gwFirmwareVersion; + } + + @NonNull + public String getOnlineLatestTime() { + return onlineLatestTime == null ? "" : onlineLatestTime; + } + + public void setOnlineLatestTime(@NonNull String onlineLatestTime) { + this.onlineLatestTime = onlineLatestTime; + } + + @NonNull + public List<SlaveDevicesBean> getSlaveDevices() { + if (slaveDevices == null) { + return new ArrayList<>(); + } + return slaveDevices; + } + + public void setSlaveDevices(@NonNull List<SlaveDevicesBean> slaveDevices) { + this.slaveDevices = slaveDevices; + } + + @NonNull + public String getUserName() { + return userName == null ? "" : userName; + } + + public void setUserName(@NonNull String userName) { + this.userName = userName; + } + + @NonNull + public String getGroupName() { + return groupName == null ? "" : groupName; + } + + public void setGroupName(@NonNull String groupName) { + this.groupName = groupName; + } + + @NonNull + public String getProjectName() { + return projectName == null ? "" : projectName; + } + + public void setProjectName(@NonNull String projectName) { + this.projectName = projectName; + } + + @NonNull + public String getRegion() { + return region == null ? "" : region; + } + + public void setRegion(@NonNull String region) { + this.region = region; + } + + public int getSubnetId() { + return subnetId; + } + + public void setSubnetId(int subnetId) { + this.subnetId = subnetId; + } + + public int getDeviceId() { + return deviceId; + } + + public void setDeviceId(int deviceId) { + this.deviceId = deviceId; + } + + public static class SlaveDevicesBean implements Serializable { + private String protocolType; + private int deviceType; + private String device_name; + private String oid; + private String addresses; + private String deviceModel; + private String mac; + + @NonNull + public String getProtocolType() { + return protocolType == null ? "" : protocolType; + } + + public void setProtocolType(@NonNull String protocolType) { + this.protocolType = protocolType; + } + + public int getDeviceType() { + return deviceType; + } + + public void setDeviceType(int deviceType) { + this.deviceType = deviceType; + } + + @NonNull + public String getDevice_name() { + return device_name == null ? "" : device_name; + } + + public void setDevice_name(@NonNull String device_name) { + this.device_name = device_name; + } + + @NonNull + public String getOid() { + return oid == null ? "" : oid; + } + + public void setOid(@NonNull String oid) { + this.oid = oid; + } + + @NonNull + public String getAddresses() { + return addresses == null ? "" : addresses; + } + + public void setAddresses(@NonNull String addresses) { + this.addresses = addresses; + } + + @NonNull + public String getDeviceModel() { + return deviceModel == null ? "" : deviceModel; + } + + public void setDeviceModel(@NonNull String deviceModel) { + this.deviceModel = deviceModel; + } + + @NonNull + public String getMac() { + return mac == null ? "" : mac; + } + + public void setMac(@NonNull String mac) { + this.mac = mac; + } + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/HomeInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/HomeInfoBean.java new file mode 100644 index 0000000..9a575a6 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/HomeInfoBean.java @@ -0,0 +1,82 @@ +package com.hdl.linkpm.sdk.home.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/10/21. + */ +public class HomeInfoBean implements Serializable { + + private String homeId; + private String homeName; + private String homeType; + private String homeAddress; + private String latitude; + private String longitude; + + public HomeInfoBean() { + + } + + public HomeInfoBean(String homeId, String homeName, String homeType) { + this.homeId = homeId; + this.homeName = homeName; + this.homeType = homeType; + } + + @NonNull + public String getHomeId() { + return homeId == null ? "" : homeId; + } + + public void setHomeId(@NonNull String homeId) { + this.homeId = homeId; + } + + @NonNull + public String getHomeName() { + return homeName == null ? "" : homeName; + } + + public void setHomeName(@NonNull String homeName) { + this.homeName = homeName; + } + + @NonNull + public String getHomeType() { + return homeType == null ? "" : homeType; + } + + public void setHomeType(@NonNull String homeType) { + this.homeType = homeType; + } + + @NonNull + public String getHomeAddress() { + return homeAddress == null ? "" : homeAddress; + } + + public void setHomeAddress(@NonNull String homeAddress) { + this.homeAddress = homeAddress; + } + + @NonNull + public String getLatitude() { + return latitude == null ? "" : latitude; + } + + public void setLatitude(@NonNull String latitude) { + this.latitude = latitude; + } + + @NonNull + public String getLongitude() { + return longitude == null ? "" : longitude; + } + + public void setLongitude(@NonNull String longitude) { + this.longitude = longitude; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/QuestionInfo.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/QuestionInfo.java new file mode 100644 index 0000000..16d60e0 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/QuestionInfo.java @@ -0,0 +1,145 @@ +package com.hdl.linkpm.sdk.home.bean; + +import java.io.Serializable; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2022/6/8 + * description: + */ +public class QuestionInfo implements Serializable { + /** + * 瑙g瓟鍐呭 + */ + private String answerContent; + /** + * 鍐呭鍒嗙被 0锛氳秴鏂囨湰 1锛氳棰�,鍙敤鍊�:HYPERTEXT,VIDEO + */ + private String contentType; + /** + * 鍐呭鍒嗙被鍚嶇О + */ + private String coverUrl; + /** + * 灏侀潰鍦板潃 + */ + private String questionDesc; + /** + * 鎻忚堪 + */ + private String languageType; + private String modifyTime; + /** + * 闂鏍囬 + */ + private String question; + private String sort; + private String contentTypeName; + private String languageTypeName; + /** + * 甯姪涓績id + */ + private String supportCenterId; + /** + * 瑙嗛鍦板潃 + */ + private String videoUrl; + + public String getAnswerContent() { + return answerContent == null ? "" : answerContent; + } + + public void setAnswerContent(@NonNull String answerContent) { + this.answerContent = answerContent; + } + + public String getContentType() { + return contentType == null ? "" : contentType; + } + + public void setContentType(@NonNull String contentType) { + this.contentType = contentType; + } + + public String getCoverUrl() { + return coverUrl == null ? "" : coverUrl; + } + + public void setCoverUrl(@NonNull String coverUrl) { + this.coverUrl = coverUrl; + } + + public String getQuestionDesc() { + return questionDesc == null ? "" : questionDesc; + } + + public void setQuestionDesc(@NonNull String questionDesc) { + this.questionDesc = questionDesc; + } + + public String getLanguageType() { + return languageType == null ? "" : languageType; + } + + public void setLanguageType(@NonNull String languageType) { + this.languageType = languageType; + } + + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } + + public void setModifyTime(@NonNull String modifyTime) { + this.modifyTime = modifyTime; + } + + public String getQuestion() { + return question == null ? "" : question; + } + + public void setQuestion(@NonNull String question) { + this.question = question; + } + + public String getSort() { + return sort == null ? "" : sort; + } + + public void setSort(@NonNull String sort) { + this.sort = sort; + } + + public String getContentTypeName() { + return contentTypeName == null ? "" : contentTypeName; + } + + public void setContentTypeName(@NonNull String contentTypeName) { + this.contentTypeName = contentTypeName; + } + + public String getLanguageTypeName() { + return languageTypeName == null ? "" : languageTypeName; + } + + public void setLanguageTypeName(@NonNull String languageTypeName) { + this.languageTypeName = languageTypeName; + } + + public String getSupportCenterId() { + return supportCenterId == null ? "" : supportCenterId; + } + + public void setSupportCenterId(@NonNull String supportCenterId) { + this.supportCenterId = supportCenterId; + } + + public String getVideoUrl() { + return videoUrl == null ? "" : videoUrl; + } + + public void setVideoUrl(@NonNull String videoUrl) { + this.videoUrl = videoUrl; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/QuestionListInfo.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/QuestionListInfo.java new file mode 100644 index 0000000..f348159 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/QuestionListInfo.java @@ -0,0 +1,63 @@ +package com.hdl.linkpm.sdk.home.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2022/6/8 + * description: + */ +public class QuestionListInfo implements Serializable { + private List<QuestionInfo> list = new ArrayList<>(); + private String pageNo; + private String pageSize; + private String totalCount; + private String totalPage; + + public List<QuestionInfo> getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(@NonNull List<QuestionInfo> list) { + this.list = list; + } + + public String getPageNo() { + return pageNo == null ? "" : pageNo; + } + + public void setPageNo(@NonNull String pageNo) { + this.pageNo = pageNo; + } + + public String getPageSize() { + return pageSize == null ? "" : pageSize; + } + + public void setPageSize(@NonNull String pageSize) { + this.pageSize = pageSize; + } + + public String getTotalCount() { + return totalCount == null ? "" : totalCount; + } + + public void setTotalCount(@NonNull String totalCount) { + this.totalCount = totalCount; + } + + public String getTotalPage() { + return totalPage == null ? "" : totalPage; + } + + public void setTotalPage(@NonNull String totalPage) { + this.totalPage = totalPage; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/RoomInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/RoomInfoBean.java new file mode 100644 index 0000000..4f1976a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/RoomInfoBean.java @@ -0,0 +1,95 @@ +package com.hdl.linkpm.sdk.home.bean; + +import androidx.annotation.NonNull; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/10/21. + */ +public class RoomInfoBean implements Serializable { + private String uid;//璋冭瘯杞欢鐢熸垚鐨勫敮涓�Id + private String roomType;//鎴块棿绫诲瀷 FLOOR ROOM + //娣诲姞鎴栬�呬慨鏀规埧闂寸殑鏃跺�欙紝涓嬪垪鍙傛暟鍏佽淇敼 + private String roomName;//鎴块棿鍚嶇О + private String roomImage;//鎴块棿鍥剧墖杩滅▼鎴栬�呮湰鍦拌矾寰勫湴鍧� + private String parentId;//鐖惰妭鐐笽d锛屾埧闂村垎閰嶇殑妤煎眰鐨処D + //涓嬮潰鍙傛暟浜戠鍥哄畾杩斿洖鐨勶紝涓嶈兘淇敼鐨� + private String roomId;//娣诲姞鍒颁簯绔墠浼氱敓鎴� + private String homeId;//浣忓畢id + private String floorRoomName;//鎴垮眿鍏ㄧ▼ 渚嬶細2妤�-娆″崸 + + @NonNull + public String getUid() { + return uid == null ? "" : uid; + } + + public void setUid(@NonNull String uid) { + this.uid = uid; + } + + @NonNull + public String getRoomType() { + return roomType == null ? "" : roomType; + } + + public void setRoomType(@NonNull String roomType) { + this.roomType = roomType; + } + + @NonNull + public String getRoomName() { + return roomName == null ? "" : roomName; + } + + public void setRoomName(@NonNull String roomName) { + this.roomName = roomName; + } + + @NonNull + public String getRoomImage() { + return roomImage == null ? "" : roomImage; + } + + public void setRoomImage(@NonNull String roomImage) { + this.roomImage = roomImage; + } + + @NonNull + public String getParentId() { + return parentId == null ? "" : parentId; + } + + public void setParentId(@NonNull String parentId) { + this.parentId = parentId; + } + + @NonNull + public String getRoomId() { + return roomId == null ? "" : roomId; + } + + public void setRoomId(@NonNull String roomId) { + this.roomId = roomId; + } + + @NonNull + public String getHomeId() { + return homeId == null ? "" : homeId; + } + + public void setHomeId(@NonNull String homeId) { + this.homeId = homeId; + } + + @NonNull + public String getFloorRoomName() { + return floorRoomName == null ? "" : floorRoomName; + } + + public void setFloorRoomName(@NonNull String floorRoomName) { + this.floorRoomName = floorRoomName; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/RoomInfoListBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/RoomInfoListBean.java new file mode 100644 index 0000000..9feaed0 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/RoomInfoListBean.java @@ -0,0 +1,29 @@ +package com.hdl.linkpm.sdk.home.bean; + +import androidx.annotation.NonNull; + +import com.hdl.linkpm.sdk.core.bean.BasePageInfoBean; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/10/21. + * 椤圭洰鍒楄〃瀵硅薄 + */ +public class RoomInfoListBean extends BasePageInfoBean { + + private List<RoomInfoBean> list = new ArrayList<>(); + + @NonNull + public List<RoomInfoBean> getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(@NonNull List<RoomInfoBean> list) { + this.list = list; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/ConditionBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/ConditionBean.java new file mode 100644 index 0000000..6fc9b37 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/ConditionBean.java @@ -0,0 +1,53 @@ +package com.hdl.linkpm.sdk.home.bean.logic; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/14/21. + * 鏉′欢 + */ +public class ConditionBean implements Serializable { + + private String key;//灞炴�у悕绉� + private String comparator;//鎿嶄綔 < 灏忎簬 > 澶т簬 ==绛変簬 + private String data_type;//鍊肩被鍨� int \float\ string + private String value;//鍊� + + @NonNull + public String getKey() { + return key == null ? "" : key; + } + + public void setKey(@NonNull String key) { + this.key = key; + } + + @NonNull + public String getComparator() { + return comparator == null ? "" : comparator; + } + + public void setComparator(@NonNull String comparator) { + this.comparator = comparator; + } + + @NonNull + public String getData_type() { + return data_type == null ? "" : data_type; + } + + public void setData_type(@NonNull String data_type) { + this.data_type = data_type; + } + + @NonNull + public String getValue() { + return value == null ? "" : value; + } + + public void setValue(@NonNull String value) { + this.value = value; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/LogicInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/LogicInfoBean.java new file mode 100644 index 0000000..f03d6e1 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/LogicInfoBean.java @@ -0,0 +1,203 @@ +package com.hdl.linkpm.sdk.home.bean.logic; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/10/21. + * 鑷姩鍖� 璇︽儏瀵硅薄 + */ +public class LogicInfoBean implements Serializable { + + private String sid;//鑷姩鍖杋d + private String gatewayId;//缃戝叧ID + private String name;//鑷姩鍖栧悕瀛� + private List<String> conditionLabel = new ArrayList<>();//瑙﹀彂鏉′欢鏍囩 1:鏃堕棿鐐规潯浠� 2:鏃堕棿娈�+寰幆鏂瑰紡 3:璁惧鐘舵�� + private String tag;//鈥� tag 鏍囩 + private String push_customer_message;//娑堟伅鎺ㄩ�佸唴瀹� + private String relation;//鍏崇郴 and/or + private String enable;//true:鍚敤(榛樿) false:绂佺敤 + private CycleBean cycle;//寰幆鏃堕棿 + private List<InputBean> input = new ArrayList<>();//瑙﹀彂鏉′欢 + private List<OutputBean> output = new ArrayList<>();//鎵ц鍔ㄤ綔 + private String output_delay;//杈撳嚭寤舵椂 + + @NonNull + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(@NonNull String sid) { + this.sid = sid; + } + + @NonNull + public String getGatewayId() { + return gatewayId == null ? "" : gatewayId; + } + + public void setGatewayId(@NonNull String gatewayId) { + this.gatewayId = gatewayId; + } + + @NonNull + public String getName() { + return name == null ? "" : name; + } + + public void setName(@NonNull String name) { + this.name = name; + } + + @NonNull + public List<String> getConditionLabel() { + if (conditionLabel == null) { + return new ArrayList<>(); + } + return conditionLabel; + } + + public void setConditionLabel(@NonNull List<String> conditionLabel) { + this.conditionLabel = conditionLabel; + } + + @NonNull + public String getTag() { + return tag == null ? "" : tag; + } + + public void setTag(@NonNull String tag) { + this.tag = tag; + } + + @NonNull + public String getPush_customer_message() { + return push_customer_message == null ? "" : push_customer_message; + } + + public void setPush_customer_message(@NonNull String push_customer_message) { + this.push_customer_message = push_customer_message; + } + + @NonNull + public String getRelation() { + return relation == null ? "" : relation; + } + + public void setRelation(@NonNull String relation) { + this.relation = relation; + } + + @NonNull + public String getEnable() { + return enable == null ? "" : enable; + } + + public void setEnable(@NonNull String enable) { + this.enable = enable; + } + + public CycleBean getCycle() { + return cycle; + } + + public void setCycle(CycleBean cycle) { + this.cycle = cycle; + } + + @NonNull + public List<InputBean> getInput() { + if (input == null) { + return new ArrayList<>(); + } + return input; + } + + public void setInput(@NonNull List<InputBean> input) { + this.input = input; + } + + @NonNull + public List<OutputBean> getOutput() { + if (output == null) { + return new ArrayList<>(); + } + return output; + } + + public void setOutput(@NonNull List<OutputBean> output) { + this.output = output; + } + + @NonNull + public String getOutput_delay() { + return output_delay == null ? "" : output_delay; + } + + public void setOutput_delay(@NonNull String output_delay) { + this.output_delay = output_delay; + } + + /** + * 寰幆鏃堕棿 + */ + public static class CycleBean implements Serializable{ + private String type;//鏃堕棿绫诲瀷 + private List<String> value;//鍊� + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List<String> getValue() { + return value; + } + + public void setValue(List<String> value) { + this.value = value; + } + } + + /** + * 瑙﹀彂鏉′欢 + */ + public static class InputBean implements Serializable{ + private String sid;//璁惧sid 浠呭湪condition_type:3 璁惧瑙﹀彂蹇呭~ + private String condition_type;//1:鏃堕棿鐐规潯浠� 2:鏃堕棿娈�+寰幆鏂瑰紡 3:璁惧鐘舵�� + private List<ConditionBean> condition;//鏉′欢 + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getCondition_type() { + return condition_type; + } + + public void setCondition_type(String condition_type) { + this.condition_type = condition_type; + } + + public List<ConditionBean> getCondition() { + return condition; + } + + public void setCondition(List<ConditionBean> condition) { + this.condition = condition; + } + + } + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/OutputBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/OutputBean.java new file mode 100644 index 0000000..f0957a7 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/OutputBean.java @@ -0,0 +1,50 @@ +package com.hdl.linkpm.sdk.home.bean.logic; + +import androidx.annotation.NonNull; + +import com.hdl.linkpm.sdk.device.bean.StatusBean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/14/21. + * 鎵ц鍔ㄤ綔 + */ +public class OutputBean implements Serializable { + + private String target_type;//鎺у埗鐩爣绫诲瀷 璁惧锛�0锛屽満鏅�1锛岃嚜鍔ㄥ寲2 + private String sid;//璁惧鎴栧満鏅痠d + private List<StatusBean> status = new ArrayList<>();//鐘舵�� + + @NonNull + public String getTarget_type() { + return target_type == null ? "" : target_type; + } + + public void setTarget_type(@NonNull String target_type) { + this.target_type = target_type; + } + + @NonNull + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(@NonNull String sid) { + this.sid = sid; + } + + @NonNull + public List<StatusBean> getStatus() { + if (status == null) { + return new ArrayList<>(); + } + return status; + } + + public void setStatus(@NonNull List<StatusBean> status) { + this.status = status; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/SecurityInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/SecurityInfoBean.java new file mode 100644 index 0000000..20aac71 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/bean/logic/SecurityInfoBean.java @@ -0,0 +1,177 @@ +package com.hdl.linkpm.sdk.home.bean.logic; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/10/21. + * 瀹夐槻 璇︽儏瀵硅薄 + */ +public class SecurityInfoBean implements Serializable { + + private String sid;//瀹夐槻id + private String name;//瀹夐槻鍚嶇О + private String delay;//寤舵椂(姣) + private String status;//鐘舵�� enable甯冮槻銆乨isable鎾掗槻 + private String type;//绫诲瀷 "all"--鍏ㄥ畢甯冮槻锛�"normal"--鏅�氭ā寮�,"all_day":24灏忔椂,"mute"锛氶潤闊� + private List<InPutBean> input = new ArrayList<>();//杈撳叆鏉′欢 浼犳劅鍣� + private List<OutputBean> output = new ArrayList<>();//鎺у埗鐩爣 +// private NoticeConfigBean noticeConfig;//閫氱煡閰嶇疆 +// private List<PushConfigsBean> pushConfigs;//鎺ㄩ�侀厤缃� + + + @NonNull + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(@NonNull String sid) { + this.sid = sid; + } + + @NonNull + public String getName() { + return name == null ? "" : name; + } + + public void setName(@NonNull String name) { + this.name = name; + } + + @NonNull + public String getDelay() { + return delay == null ? "" : delay; + } + + public void setDelay(@NonNull String delay) { + this.delay = delay; + } + + @NonNull + public String getStatus() { + return status == null ? "" : status; + } + + public void setStatus(@NonNull String status) { + this.status = status; + } + + @NonNull + public String getType() { + return type == null ? "" : type; + } + + public void setType(@NonNull String type) { + this.type = type; + } + + @NonNull + public List<InPutBean> getInput() { + if (input == null) { + return new ArrayList<>(); + } + return input; + } + + public void setInput(@NonNull List<InPutBean> input) { + this.input = input; + } + + @NonNull + public List<OutputBean> getOutput() { + if (output == null) { + return new ArrayList<>(); + } + return output; + } + + public void setOutput(@NonNull List<OutputBean> output) { + this.output = output; + } + + /** + * 瑙﹀彂鏉′欢 + */ + public static class InPutBean implements Serializable{ + private String sid;////璁惧sid 浠呭湪condition_type:3 璁惧瑙﹀彂蹇呭~ + private String bypass;//#Bypass璁剧疆 true:鍚敤涓�乫alse:涓存椂bypass涓� + private List<ConditionBean> condition;//鏉′欢 + + @NonNull + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(@NonNull String sid) { + this.sid = sid; + } + + @NonNull + public String getBypass() { + return bypass == null ? "" : bypass; + } + + public void setBypass(@NonNull String bypass) { + this.bypass = bypass; + } + + @NonNull + public List<ConditionBean> getCondition() { + if (condition == null) { + return new ArrayList<>(); + } + return condition; + } + + public void setCondition(@NonNull List<ConditionBean> condition) { + this.condition = condition; + } + } + + + +// public static class NoticeConfigBean implements Serializable{ +// private boolean enable; +// private String noticeContent; +// +// public boolean isEnable() { +// return enable; +// } +// +// public void setEnable(boolean enable) { +// this.enable = enable; +// } +// +// public String getNoticeContent() { +// return noticeContent; +// } +// +// public void setNoticeContent(String noticeContent) { +// this.noticeContent = noticeContent; +// } +// } + +// public static class PushConfigsBean implements Serializable{ +// private String pushMethod; +// private List<String> pushTarget; +// +// public String getPushMethod() { +// return pushMethod; +// } +// +// public void setPushMethod(String pushMethod) { +// this.pushMethod = pushMethod; +// } +// +// public List<String> getPushTarget() { +// return pushTarget; +// } +// +// public void setPushTarget(List<String> pushTarget) { +// this.pushTarget = pushTarget; +// } +// } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/callback/IAddRoomListCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/callback/IAddRoomListCallBack.java new file mode 100644 index 0000000..0ecb2c7 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/callback/IAddRoomListCallBack.java @@ -0,0 +1,16 @@ +package com.hdl.linkpm.sdk.home.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.home.bean.RoomInfoBean; + +import java.util.List; + +/** + * Created by jlchen on 12/10/21. + */ +public interface IAddRoomListCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(Boolean bean); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/callback/IRoomListCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/callback/IRoomListCallBack.java new file mode 100644 index 0000000..d509585 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/callback/IRoomListCallBack.java @@ -0,0 +1,14 @@ +package com.hdl.linkpm.sdk.home.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.home.bean.RoomInfoListBean; + +/** + * Created by jlchen on 12/10/21. + */ +public interface IRoomListCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(RoomInfoListBean bean); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/controller/HDLPMHomeController.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/controller/HDLPMHomeController.java new file mode 100644 index 0000000..153959e --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/controller/HDLPMHomeController.java @@ -0,0 +1,493 @@ +package com.hdl.linkpm.sdk.home.controller; + +import android.text.TextUtils; + +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.linkpm.sdk.core.api.HDLCloudHomeApi; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.home.bean.GatewayInfoBean; +import com.hdl.linkpm.sdk.home.bean.GatewayBindBean; +import com.hdl.linkpm.sdk.home.bean.HomeInfoBean; +import com.hdl.linkpm.sdk.home.bean.logic.LogicInfoBean; +import com.hdl.linkpm.sdk.home.bean.RoomInfoBean; +import com.hdl.linkpm.sdk.home.bean.RoomInfoListBean; +import com.hdl.linkpm.sdk.home.bean.logic.SecurityInfoBean; +import com.hdl.linkpm.sdk.home.callback.IAddRoomListCallBack; +import com.hdl.linkpm.sdk.home.callback.IRoomListCallBack; +import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; + +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; + +/** + * Created by jlchen on 12/3/21. + * 浣忓畢鐩稿叧鐨勭綉缁滆姹� + */ +public class HDLPMHomeController { + /** + * instance + */ + private volatile static HDLPMHomeController instance; + + /** + * getInstance + * + * @return HDLHomeController + */ + public static synchronized HDLPMHomeController getInstance() { + if (instance == null) { + synchronized (HDLPMHomeController.class) { + if (instance == null) { + instance = new HDLPMHomeController(); + } + } + } + return instance; + } + + /** + * house琛ㄧ殑鏁版嵁娌℃湁鍚屾鍒癶ome琛ㄣ�佹暟鎹瓨鍦ㄤ袱寮犺〃閲岄潰锛岄渶瑕佸鎴风璋冩帴鍙e悓姝� + * + * @param homeInfoBean 浣忓畢Info + * @param callBack + * @return + */ + public Disposable synchHouseToHome(HomeInfoBean homeInfoBean, IDefaultCallBack callBack) { + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_PROGRAM_HOME_ADD); + return HxHttp.builder() + .url(requestUrl) + .raw(HDLGsonUtils.toJson(homeInfoBean)) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,homeInfoBean,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /***************2.鎴块棿绠$悊***************/ + /** + * 鑾峰彇浣忓畢涓嬫埧闂磋〃 + * + * @param homeId 浣忓畢ID + * @param roomType 鎴垮眿绫诲瀷 FLOOR ROOM銆佷负绌虹殑鏃跺�欐煡鍏ㄩ儴 + * @param pageNo 鍝竴椤� + * @param pageSize 椤甸潰澶у皬 + * @param callBack + * @return + */ + public Disposable getRoomList(String homeId, String roomType, int pageNo, int pageSize, IRoomListCallBack callBack) { + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_ROOM_GET_LIST); + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + if (!TextUtils.isEmpty(roomType)) { + json.addProperty("roomType", roomType); + } + json.addProperty("pageNo", pageNo); + json.addProperty("pageSize", pageSize); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<RoomInfoListBean>() { + @Override + public void onResponse(RoomInfoListBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鎴块棿鍒楄〃鍏ㄩ噺鏇存柊銆佹坊鍔犮�佺紪杈戙�佸垹闄ら兘鐢ㄨ鎺ュ彛 + * + * @param homeId 浣忓畢ID + * @param roomList 鏈�鏂扮殑鎴块棿鍒楄〃 + * @param callBack + * @return + */ + public Disposable fullAddOrEditRoomList(String homeId, List<RoomInfoBean> roomList, IAddRoomListCallBack callBack) { + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_ROOM_FULL_ADD_OR_EDIT); + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("rooms", HDLGsonUtils.toJsonArray(roomList)); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<Boolean>() { + @Override + public void onResponse(Boolean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /***************3.缃戝叧绠$悊***************/ + /** + * 缁戝畾缃戝叧鍒颁綇瀹� + * + * @param bean 缃戝叧淇℃伅 + * @param callBack + * @return + */ + public Disposable bindGateway(GatewayBindBean bean, IResponseCallBack<GatewayInfoBean> callBack) { + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_GATEWAY_BIND); + return HxHttp.builder() + .url(requestUrl) + .raw(HDLGsonUtils.toJson(bean)) + .build() + .post() + .subscribeWith(new HDLResponse<GatewayInfoBean>() { + @Override + public void onResponse(GatewayInfoBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,bean,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 寮哄埗缁戝畾缃戝叧 + * 濡傛灉缁戝畾缃戝叧杩斿洖10510 宸茬粡琚粦瀹氫簡,鍒欒皟杩欎釜鎺ュ彛寮哄埗鎹㈢粦 + * + * @param homeId 浣忓畢ID + * @param mac 缃戝叧MAC + * @param callBack + * @return + */ + public Disposable forceBindGateway(String homeId, String mac, IResponseCallBack<GatewayInfoBean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("mac", mac); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_GATEWAY_FORCE_BIND); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<GatewayInfoBean>() { + @Override + public void onResponse(GatewayInfoBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 瑙g粦缃戝叧 + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧gatewayId + * @param callBack + * @return + */ + public Disposable unbindGateway(String homeId, String gatewayId, IResponseCallBack<Boolean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_GATEWAY_UNBIND); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<Boolean>() { + @Override + public void onResponse(Boolean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 瑙g粦缃戝叧 + * + * @param mac 缃戝叧mac鍦板潃 + * @param callBack + * @return + */ + public Disposable getGatewayHomeInfo(String mac, IResponseCallBack<GatewayInfoBean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("mac", mac); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_GATEWAY_HOMEINFO); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<GatewayInfoBean>() { + @Override + public void onResponse(GatewayInfoBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + /** + * 瑙g粦浠庣綉鍏� + * + * @param homeId 浣忓畢id + * @param oid 璁惧oid + * @param callBack + * @return + */ + public Disposable unbindFalseGateway(String homeId, String oid,IResponseCallBack<Boolean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("oid", oid); + + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_DEVICE_OID_REMOVE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<Boolean>() { + @Override + public void onResponse(Boolean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + /** + * 鑾峰彇缃戝叧鍒楄〃 + * + * @param homeId 浣忓畢id + * @param callBack + * @return + */ + public Disposable getGatewayList(String homeId, IResponseCallBack<List<GatewayInfoBean>> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_GATEWAY_GET_LIST); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<GatewayInfoBean>>() { + @Override + public void onResponse(List<GatewayInfoBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 缃戝叧鏇挎崲 + * + * @param homeId 浣忓畢id + * @param gatewayId 鏃х綉鍏砳d + * @param newMac 鏂扮綉鍏砿ac + * @param callBack + * @return + */ + public Disposable replaceGateway(String homeId, String gatewayId, String newMac, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + json.addProperty("newMac", newMac); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_GATEWAY_REPLACE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<String>>() { + @Override + public void onResponse(List<String> response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /***************6.鑷姩鍖栧鍒犳敼鏌ョ鐞�***************/ + /** + * 鍏ㄩ噺鏇存柊鍚屾鑷姩鍖栥�佸瓨鍦ㄤ笉鍙�,涓嶅瓨鍦ㄦ柊澧� + * + * @param homeId 浣忓畢id + * @param logics 鑷姩鍖栧垪琛� + * @param callBack + * @return + */ + public Disposable fullAddLogicList(String homeId, List<LogicInfoBean> logics, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("logics", HDLGsonUtils.toJsonArray(logics)); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_LOGIC_FULL_SYNC); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /***************7.瀹夐槻鍖栧鍒犳敼鏌ョ鐞�***************/ + /** + * 鍏ㄩ噺鏇存柊鍚屾瀹夐槻銆佸瓨鍦ㄤ笉鍙�,涓嶅瓨鍦ㄦ柊澧� + * + * @param homeId 浣忓畢id + * @param gatewayId 缃戝叧ID + * @param securitys 瀹夐槻鍒楄〃 + * @param callBack + * @return + */ + public Disposable fullAddSecurityList(String homeId, String gatewayId, List<SecurityInfoBean> securitys, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + json.add("securitys", HDLGsonUtils.toJsonArray(securitys)); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_SECURITY_FULL_SYNC); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl,json,e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/GatewayType.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/GatewayType.java new file mode 100644 index 0000000..a4656e7 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/GatewayType.java @@ -0,0 +1,24 @@ +package com.hdl.linkpm.sdk.home.type; + +import androidx.annotation.StringDef; +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + +/** + * Created by jlchen on 12/10/21. + * 缃戝叧绫诲瀷 + */ +@Retention(SOURCE) +@StringDef({GatewayType.BUSUDPGATEWAY, GatewayType.AGATEWAY, GatewayType.ZIGBEEGATEWAY, GatewayType.KNXGATEWAY}) +public @interface GatewayType { + + String BUSUDPGATEWAY = "BUSUDPGATEWAY"; + + String AGATEWAY = "AGATEWAY"; + + String ZIGBEEGATEWAY = "ZIGBEEGATEWAY"; + + String KNXGATEWAY = "KNXGATEWAY"; + +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/HomeType.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/HomeType.java new file mode 100644 index 0000000..d370c4a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/HomeType.java @@ -0,0 +1,22 @@ +package com.hdl.linkpm.sdk.home.type; + +import androidx.annotation.StringDef; + +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + +/** + * Created by jlchen on 12/10/21. + * 浣忓畢绫诲瀷 ZIGBEE銆丅USPRO銆丄 + */ +@Retention(SOURCE) +@StringDef({HomeType.ZIGBEE, HomeType.BUSPRO, HomeType.A}) +public @interface HomeType { + //0锛歓IGBEE + String ZIGBEE = "ZIGBEE"; + //1锛欱USPRO + String BUSPRO = "BUSPRO"; + //2锛欰 + String A = "A"; +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/RoomType.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/RoomType.java new file mode 100644 index 0000000..02fa1a7 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/home/type/RoomType.java @@ -0,0 +1,20 @@ +package com.hdl.linkpm.sdk.home.type; + +import androidx.annotation.StringDef; + +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + +/** + * Created by jlchen on 12/10/21. + * 鎴块棿绫诲瀷锛氭ゼ灞傘�佹埧闂� + */ +@Retention(SOURCE) +@StringDef({RoomType.FLOOR, RoomType.ROOM}) +public @interface RoomType { + //0锛氭ゼ灞� + String FLOOR = "FLOOR"; + //1锛氭埧闂� + String ROOM = "ROOM"; +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/HDLLinkPMOta.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/HDLLinkPMOta.java new file mode 100644 index 0000000..d104d85 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/HDLLinkPMOta.java @@ -0,0 +1,176 @@ +package com.hdl.linkpm.sdk.ota; + +import com.google.gson.JsonObject; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.ota.bean.CloudDeviceFirmwaresBean; +import com.hdl.linkpm.sdk.ota.bean.CloudGatewayDriversBean; +import com.hdl.linkpm.sdk.ota.bean.DeviceFirmwareBean; +import com.hdl.linkpm.sdk.ota.bean.DownloadUrlBean; +import com.hdl.linkpm.sdk.ota.bean.FirmwareBean; +import com.hdl.linkpm.sdk.ota.bean.GatewayDriverBean; +import com.hdl.linkpm.sdk.ota.controller.HDLPMOtaController; + +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; +import okhttp3.ResponseBody; + + +/** + * Created by jlchen on 12/17/21. + * OTA 缃戝叧銆佽澶囧浐浠舵煡璇㈠拰涓嬭浇鐩稿叧绠$悊 + */ +public class HDLLinkPMOta { + + //instance + private volatile static HDLLinkPMOta instance; + + /** + * getInstance + * + * @return HDLLinkPMOta + */ + public static synchronized HDLLinkPMOta getInstance() { + if (instance == null) { + synchronized (HDLLinkPMOta.class) { + if (instance == null) { + instance = new HDLLinkPMOta(); + } + } + } + return instance; + } + + /** + * 鍘熺敓璁惧鑾峰彇鍥轰欢鍗囩骇鍖呬笅杞藉湴鍧� + * + * @param firmwareVersionId 鍥轰欢鐗堟湰Id + * @return + */ + public void getNativeDeviceFirmwareDownloadUrl(String firmwareVersionId, IResponseCallBack<DownloadUrlBean> callBack) { + HDLPMOtaController.getInstance().getNativeDeviceFirmwareDownloadUrl(firmwareVersionId, callBack); + } + + /** + * Link璁惧椹卞姩鍒楄〃鑾峰彇 + * + * @param homeId 浣忓畢id + * @param oid 缃戝叧璁惧oid + * @param callBack + * @return + */ + public void getGatewayDrivers(String homeId, String oid, IResponseCallBack<List<GatewayDriverBean>> callBack) { + HDLPMOtaController.getInstance().getGatewayDrivers(homeId, oid, callBack); + } + /** + * Link缃戝叧椹卞姩->鑾峰彇瀛樺偍鍦ㄤ簯绔殑椹卞姩鍒嗛〉鍒楄〃 + * + * @param driveCode 椹卞姩缂栧彿鎴栭┍鍔ㄥ悕绉� + * @param osImageId 椹卞姩绫诲瀷id + * @param callBack + * @return + */ + public void getCloudGatewayDrivers(String driveCode, String osImageId, IResponseCallBack<CloudGatewayDriversBean> callBack) { + HDLPMOtaController.getInstance().getCloudGatewayDrivers(driveCode, osImageId, callBack); + } + /** + * Link缃戝叧椹卞姩鍗囩骇OTA鍛戒护涓嬪彂 + * + * @param homeId 浣忓畢id + * @param oid 缃戝叧璁惧oid + * @param driverVersionId 椹卞姩鐗堟湰id + * @param callBack + * @return + */ + public void upgradeGatewayDriver(String homeId, String oid, String driverVersionId, IDefaultCallBack callBack) { + HDLPMOtaController.getInstance().upgradeGatewayDriver(homeId, oid, driverVersionId, callBack); + } + + /** + * 鑾峰彇IARCC涓夋柟鍥轰欢鍒嗛〉 + * @param json 璇锋眰鏁版嵁 + * @param callBack 鍥炶皟 + * @return + */ + public void getACIARCCFirmware(String json, IResponseCallBack<List<FirmwareBean>> callBack) { + HDLPMOtaController.getInstance().getACIARCCFirmware(json, callBack); + } + /** + * 鑾峰彇IARCC涓夋柟鍥轰欢鍒嗙被 + * @param json 璇锋眰鏁版嵁 + * @param callBack 鍥炶皟 + * @return + */ + public void getACIARCCFirmwareList(String json, IResponseCallBack<List<FirmwareBean>> callBack) { + HDLPMOtaController.getInstance().getACIARCCFirmwareList(json, callBack); + } + /** + * 涓嬭浇IARCC鍥轰欢 + * @param requestUrl 璇锋眰鍦板潃 + * @param callBack 鍥炶皟 + * @return + */ + public void downloadCloudACIARCCFirmware(String requestUrl, IResponseCallBack<ResponseBody> callBack) { + HDLPMOtaController.getInstance().downloadCloudACIARCCFirmware(requestUrl, callBack); + } + /** + * LINK璁惧鑾峰彇椹卞姩鍗囩骇鍖呬笅杞藉湴鍧� + * + * @param driverVersionId 椹卞姩鐗堟湰Id + * @return + */ + public void getLinkDeviceDriverDownloadUrl(String driverVersionId, IResponseCallBack<DownloadUrlBean> callBack) { + HDLPMOtaController.getInstance().getLinkDeviceDriverDownloadUrl(driverVersionId, callBack); + } + + + /** + * 鑾峰彇璁惧鍥轰欢鍒楄〃鑾峰彇 + * + * @param homeId 浣忓畢id + * @param deviceOidId oid浜戠id + * @param callBack + * @return + */ + public void getDeviceFirmwares(String homeId, String deviceOidId, IResponseCallBack<List<DeviceFirmwareBean>> callBack) { + HDLPMOtaController.getInstance().getDeviceFirmwares(homeId, deviceOidId, callBack); + } + /** + /** + * 鑾峰彇璁惧鍥轰欢鍒楄〃鑾峰彇->鑾峰彇瀛樺偍鍦ㄤ簯绔殑鍥轰欢鍒嗛〉鍒楄〃 + * + * @param hardwareModel 纭欢鍨嬪彿 + * @param osImageId 绯荤粺闀滃儚id + * @param callBack + * @return + */ + public void getCloudDeviceFirmwares(String hardwareModel, String osImageId, IResponseCallBack<List<CloudDeviceFirmwaresBean>> callBack) { + HDLPMOtaController.getInstance().getCloudDeviceFirmwares(hardwareModel, osImageId, callBack); + } + + + /** + * Link璁惧鍥轰欢鍗囩骇OTA鍛戒护涓嬪彂 + * + * @param homeId 浣忓畢id + * @param deviceOidId 璁惧id + * @param firmwareVersionId 鍥轰欢鐗堟湰id + * @param callBack + * @return + */ + public void upgradeDeviceFirmware(String homeId, String deviceOidId, String firmwareVersionId, IDefaultCallBack callBack) { + HDLPMOtaController.getInstance().upgradeDeviceFirmware(homeId, deviceOidId, firmwareVersionId, callBack); + } + + /** + * LINK璁惧鑾峰彇鍥轰欢鍗囩骇鍖呬笅杞藉湴鍧� + * + * @param firmwareVersionId 鍥轰欢鐗堟湰Id + * @return + */ + public void getLinkDeviceFirmwareDownloadUrl(String firmwareVersionId, IResponseCallBack<DownloadUrlBean> callBack) { + HDLPMOtaController.getInstance().getLinkDeviceFirmwareDownloadUrl(firmwareVersionId, callBack); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/CloudDeviceFirmwaresBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/CloudDeviceFirmwaresBean.java new file mode 100644 index 0000000..137b8e6 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/CloudDeviceFirmwaresBean.java @@ -0,0 +1,147 @@ +package com.hdl.linkpm.sdk.ota.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * 浜戠璁惧鍥轰欢瀵硅薄 + */ + public class CloudDeviceFirmwaresBean implements Serializable { + /// 鍥轰欢鐗堟湰鍔犲瘑鏂囦欢鍦板潃 + private String encryptionFileUrl; + /// 鍥轰欢涓枃鍚嶇О + private String firmwareNameCn; + /// 鍥轰欢鑻辨枃鍚嶇О + private String firmwareNameEn; + /// 鏍囩绫诲瀷 + private String firmwareTag; + /// 鍥轰欢鐗堟湰 + private String firmwareVersion; + /// 鍥轰欢鐗堟湰缂栧彿 + private String firmwareVersionCode; + /// 鏇存柊鎻忚堪 + private String firmwareVersionDesc; + /// 鍥轰欢鐗堟湰Id + private String firmwareVersionId; + /// 鍥轰欢鐗堟湰绫诲瀷,鍙敤鍊�:STANDARD,SPECIAL + private String firmwareVersionType; + /// 纭欢cpu淇℃伅 + private String hardwareCpu; + /// 纭欢鍨嬪彿 + private String hardwareModel; + /// 鍥轰欢鏂囦欢MD5 + private String md5; + /// 鏇存柊鏃堕棿 + private String modifyTime; + + @NonNull + public String getEncryptionFileUrl() { + return encryptionFileUrl == null ? "" : encryptionFileUrl; + } + + public void setEncryptionFileUrl(@NonNull String newEncryptionFileUrl) { + this.encryptionFileUrl = newEncryptionFileUrl; + } + + @NonNull + public String getFirmwareNameCn() { + return firmwareNameCn == null ? "" : firmwareNameCn; + } + + public void setFirmwareNameCn(@NonNull String newFirmwareNameCn) { + this.firmwareNameCn = newFirmwareNameCn; + } + + + @NonNull + public String getFirmwareNameEn() { + return firmwareNameEn == null ? "" : firmwareNameEn; + } + + public void setFirmwareNameEn(@NonNull String newFirmwareNameEn) { + this.firmwareNameEn = newFirmwareNameEn; + } + + @NonNull + public String getFirmwareTag() { + return firmwareTag == null ? "" : firmwareTag; + } + + public void setFirmwareTag(@NonNull String newFirmwareTag) { + this.firmwareTag = newFirmwareTag; + } + + + @NonNull + public String getFirmwareVersion() { + return firmwareVersion == null ? "" : firmwareVersion; + } + + public void setFirmwareVersion(@NonNull String newFirmwareVersion) { + this.firmwareVersion = newFirmwareVersion; + } + + @NonNull + public String getFirmwareVersionCode() { + return firmwareVersionCode == null ? "" : firmwareVersionCode; + } + + public void setFirmwareVersionCode(@NonNull String newFirmwareVersionCode) { + this.firmwareVersionCode = newFirmwareVersionCode; + } + + + @NonNull + public String getFirmwareVersionDesc() { + return firmwareVersionDesc == null ? "" : firmwareVersionDesc; + } + + public void setFirmwareVersionDesc(@NonNull String newFirmwareVersionDesc) { + this.firmwareVersionDesc = newFirmwareVersionDesc; + } + + @NonNull + public String getFirmwareVersionId() { + return firmwareVersionId == null ? "" : firmwareVersionId; + } + + public void setFirmwareVersionId(@NonNull String newFirmwareVersionId) { + this.firmwareVersionId = newFirmwareVersionId; + } + + @NonNull + public String getFirmwareVersionType() { + return firmwareVersionType == null ? "" : firmwareVersionType; + } + + public void setFirmwareVersionType(@NonNull String newFirmwareVersionType) { + this.firmwareVersionType = newFirmwareVersionType; + } + @NonNull + public String getHardwareCpu() { + return hardwareCpu == null ? "" : hardwareCpu; + } + + public void setHardwareCpu(@NonNull String newHardwareCpu) { + this.hardwareCpu = newHardwareCpu; + } + + @NonNull + public String getHardwareModel() { + return hardwareModel == null ? "" : hardwareModel; + } + + public void setHardwareModel(@NonNull String newHardwareModel) { + this.hardwareModel = newHardwareModel; + } + + @NonNull + public String getMd5() { + return md5 == null ? "" : md5; + } + + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/CloudGatewayDriversBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/CloudGatewayDriversBean.java new file mode 100644 index 0000000..b8adc53 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/CloudGatewayDriversBean.java @@ -0,0 +1,161 @@ +package com.hdl.linkpm.sdk.ota.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * 浜戠缃戝叧椹卞姩瀵硅薄 + */ +public class CloudGatewayDriversBean implements Serializable { + /// 椹卞姩Id + private String driverId; + /// 椹卞姩鐗堟湰Id + private String driverVersionId; + /// 椹卞姩鐗堟湰缂栧彿 + private String driverVersionCode; + ///涓嶇煡閬撴槸鍟� + private String driverVersionType; + /// 鏇存柊鎻忚堪 + private String driverVersionDesc; + /// 鐗堟湰绫诲瀷 鍙敤鍊硷細 鏍囧噯鐗堬細STANDARD 鐗规畩鐗堬細SPECIAL,鍙敤鍊�:STANDARD,SPECIAL + /// 鏄惁浠樿垂 鍙敤鍊� 鍏嶈垂锛欶REE锛屼粯璐逛笉鑳借瘯鐢細NOT_FREE锛屼粯璐硅瘯鐢�3涓湀锛歁ONTHS_3锛屼粯璐硅瘯鐢�6涓湀锛歁ONTHS_6,鍙敤鍊�:FREE,NOT_FREE,MONTHS_3,MONTHS_6 + private String driverFree; + /// 鏍囩绫诲瀷 + private String driverTag; + /// 鏇存柊鏃堕棿 + private String modifyTime; + /// 鍙戝竷鐘舵�� 鍙敤鍊� 涓嬫灦锛歋OLD_OUT 鍙戝竷锛歅UBLISH,鍙敤鍊�:SOLD_OUT,PUBLISH + private String saleStatus; + /// 椹卞姩鏂囦欢鍦板潃 + private String driverFileUrl; + /// 椹卞姩鐗堟湰鍙� + private String driverVersion; + /// 涓嬭浇娆℃暟 + private String downloadCount; + /// 椹卞姩鐘舵�侊紝 0寮�鍙戞澘 1姝e紡鐗�2鍋滅敤 鍙敤鍊硷細BETA锛孯ELEASE,DISABLE鍙敤鍊�:BETA,RELEASE锛孌ISABLE + private String driverStatus; + /// 鏂囦欢MD5 + private String driverMd5; + ///涓嶇煡閬撴槸鍟� + private String enable; + + + @NonNull + public String getDriverId() { + return driverId == null ? "" : driverId; + } + + public void setDriverId(@NonNull String newDriverId) { + this.driverId = newDriverId; + } + + @NonNull + public String getDriverVersionId() { + return driverVersionId == null ? "" : driverVersionId; + } + + public void setDriverVersionId(@NonNull String newDriverVersionId) { + this.driverVersionId = newDriverVersionId; + } + + @NonNull + public String getDriverVersionCode() { + return driverVersionCode == null ? "" : driverVersionCode; + } + + public void setDriverVersionCode(@NonNull String newDriverVersionCode) { + this.driverVersionCode = newDriverVersionCode; + } + + @NonNull + public String getDriverVersionDesc() { + return driverVersionDesc == null ? "" : driverVersionDesc; + } + + public void setDriverVersionDesc(@NonNull String newDriverVersionDesc) { + this.driverVersionDesc = newDriverVersionDesc; + } + + + public void setDriverFree(@NonNull String newDriverFree) { + this.driverFree = newDriverFree; + } + + @NonNull + public String getDriverFree() { + return driverFree == null ? "" : driverFree; + } + + @NonNull + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } + + @NonNull + public String getDriverTag() { + return driverTag == null ? "" : driverTag; + } + + public void setDriverTag(@NonNull String newDriverTag) { + this.driverTag = newDriverTag; + } + + + @NonNull + public String getSaleStatus() { + return saleStatus == null ? "" : saleStatus; + } + + public void setSaleStatus(@NonNull String newSaleStatus) { + this.saleStatus = newSaleStatus; + } + + @NonNull + public String getDriverFileUrl() { + return driverFileUrl == null ? "" : driverFileUrl; + } + + public void setDriverFileUrl(@NonNull String newDriverFileUrl) { + this.driverFileUrl = newDriverFileUrl; + } + + @NonNull + public String getDownloadCount() { + return downloadCount == null ? "" : downloadCount; + } + + public void setDriverVersion(@NonNull String newDriverVersion) { + this.driverVersion = newDriverVersion; + } + + @NonNull + public String getDriverVersion() { + return driverVersion == null ? "" : driverVersion; + } + + @NonNull + public String getDriverStatus() { + return driverStatus == null ? "" : driverStatus; + } + + public void setDriverStatus(@NonNull String newDriverStatus) { + this.driverStatus = newDriverStatus; + } + + @NonNull + public String getDriverMd5() { + return driverMd5 == null ? "" : driverMd5; + } + + @NonNull + public String getDriverVersionType() { + return driverVersionType == null ? "" : driverVersionType; + } + + @NonNull + public String getEnable() { + return enable == null ? "" : enable; + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/DeviceFirmwareBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/DeviceFirmwareBean.java new file mode 100644 index 0000000..f43c55a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/DeviceFirmwareBean.java @@ -0,0 +1,92 @@ +package com.hdl.linkpm.sdk.ota.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/17/21. + * 璁惧鍥轰欢淇℃伅 + */ +public class DeviceFirmwareBean implements Serializable { + + private String protocolType;//鍗忚绫诲瀷 + private String deviceModel;//璁惧鍨嬪彿 + private String firmwareNameEn;//鍥轰欢鑻辨枃鍚嶇О + private String firmwareNameCn;//鍥轰欢涓枃鍚嶇О + private String imageId;//imageId + private String version;//鐗堟湰鍙� + private String localUrl;//鍗囩骇鍥轰欢鏂囦欢鏈湴璺緞 + private String oid;//鍥轰欢oid + + public String getOid() { + return oid == null ? "" : oid; + } + + public void setOid(String oid) { + this.oid = oid; + } + + + public String getLocalUrl() { + return localUrl == null ? "" : localUrl; + } + + public void setLocalUrl(String localUrl) { + this.localUrl = localUrl; + } + + @NonNull + public String getProtocolType() { + return protocolType == null ? "" : protocolType; + } + + public void setProtocolType(@NonNull String protocolType) { + this.protocolType = protocolType; + } + + @NonNull + public String getDeviceModel() { + return deviceModel == null ? "" : deviceModel; + } + + public void setDeviceModel(@NonNull String deviceModel) { + this.deviceModel = deviceModel; + } + + @NonNull + public String getFirmwareNameEn() { + return firmwareNameEn == null ? "" : firmwareNameEn; + } + + public void setFirmwareNameEn(@NonNull String firmwareNameEn) { + this.firmwareNameEn = firmwareNameEn; + } + + @NonNull + public String getFirmwareNameCn() { + return firmwareNameCn == null ? "" : firmwareNameCn; + } + + public void setFirmwareNameCn(@NonNull String firmwareNameCn) { + this.firmwareNameCn = firmwareNameCn; + } + + @NonNull + public String getImageId() { + return imageId == null ? "" : imageId; + } + + public void setImageId(@NonNull String imageId) { + this.imageId = imageId; + } + + @NonNull + public String getVersion() { + return version == null ? "" : version; + } + + public void setVersion(@NonNull String version) { + this.version = version; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/DownloadUrlBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/DownloadUrlBean.java new file mode 100644 index 0000000..288d5a6 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/DownloadUrlBean.java @@ -0,0 +1,20 @@ +package com.hdl.linkpm.sdk.ota.bean; + +import androidx.annotation.NonNull; + +/** + * Created by jlchen on 12/17/21. + */ +public class DownloadUrlBean { + + private String downloadUrl;//涓嬭浇鍦板潃 + + @NonNull + public String getDownloadUrl() { + return downloadUrl == null ? "" : downloadUrl; + } + + public void setDownloadUrl(@NonNull String downloadUrl) { + this.downloadUrl = downloadUrl; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/FirmwareBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/FirmwareBean.java new file mode 100644 index 0000000..6c29327 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/FirmwareBean.java @@ -0,0 +1,105 @@ +package com.hdl.linkpm.sdk.ota.bean; + +import java.io.Serializable; +import java.util.List; + +public class FirmwareBean implements Serializable { + + /** + * firmwareName : 澶ч噾绌鸿皟 + * brandName : 澶ч噾 + * hardwareModel : MAC/GW-ZB.10 + * versions : [{"firmwareFileUrl":"http://hdl-hz-test.oss-cn-hangzhou.aliyuncs.com/20/2022/09/5566ad98-e377-4314-96d2-20ffadccf43f.bin","firmwareVersion":"1.1.0","firmwarePackageName":"coolbox_DaikinDUX200515"}] + */ + + private String firmwareName; + private String brandName; + private String hardwareModel; + private List<VersionsBean> versions; + + public String getFirmwareName() { + return firmwareName; + } + + public void setFirmwareName(String firmwareName) { + this.firmwareName = firmwareName; + } + + public String getBrandName() { + return brandName; + } + + public void setBrandName(String brandName) { + this.brandName = brandName; + } + + public String getHardwareModel() { + return hardwareModel; + } + + public void setHardwareModel(String hardwareModel) { + this.hardwareModel = hardwareModel; + } + + public List<VersionsBean> getVersions() { + return versions; + } + + public void setVersions(List<VersionsBean> versions) { + this.versions = versions; + } + + public static class VersionsBean implements Serializable { + /** + * firmwareFileUrl : http://hdl-hz-test.oss-cn-hangzhou.aliyuncs.com/20/2022/09/5566ad98-e377-4314-96d2-20ffadccf43f.bin + * firmwareVersion : 1.1.0 + * firmwarePackageName : coolbox_DaikinDUX200515 + */ + + private String firmwareFileUrl; + private String firmwareVersion; + private String firmwarePackageName; + private long thirdFirmwareVersionId; // 鍥轰欢鐗堟湰id + private String firmwareDesc; + + public long getThirdFirmwareVersionId() { + return thirdFirmwareVersionId; + } + + public void setThirdFirmwareVersionId(long thirdFirmwareVersionId) { + this.thirdFirmwareVersionId = thirdFirmwareVersionId; + } + + public String getFirmwareFileUrl() { + return firmwareFileUrl; + } + + public void setFirmwareFileUrl(String firmwareFileUrl) { + this.firmwareFileUrl = firmwareFileUrl; + } + + public String getFirmwareVersion() { + return firmwareVersion; + } + + public void setFirmwareVersion(String firmwareVersion) { + this.firmwareVersion = firmwareVersion; + } + + public String getFirmwarePackageName() { + return firmwarePackageName; + } + + public void setFirmwarePackageName(String firmwarePackageName) { + this.firmwarePackageName = firmwarePackageName; + } + + public String getFirmwareDesc() { + return firmwareDesc; + } + + public void setFirmwareDesc(String firmwareDesc) { + this.firmwareDesc = firmwareDesc; + } + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/GatewayDriverBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/GatewayDriverBean.java new file mode 100644 index 0000000..4d573f1 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/GatewayDriverBean.java @@ -0,0 +1,84 @@ +package com.hdl.linkpm.sdk.ota.bean; + + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/17/21. + * <p> + * 缃戝叧璁惧椹卞姩 + */ +public class GatewayDriverBean implements Serializable { + + private String driverCode;//椹卞姩缂栫爜 + private String driverName; + private String driverNameEn;//椹卞姩鑻辨枃鍚嶇О + private String driverNameCn;//椹卞姩涓枃鍚嶇О + private String imageId;//imageId + private String version;//鐗堟湰鍙� + private String localUrl;//鍗囩骇椹卞姩鏂囦欢鏈湴璺緞 + + public String getLocalUrl() { + return localUrl == null ? "" : localUrl; + } + + public void setLocalUrl(String localUrl) { + this.localUrl = localUrl; + } + + @NonNull + public String getDriverCode() { + return driverCode == null ? "" : driverCode; + } + + public void setDriverCode(@NonNull String driverCode) { + this.driverCode = driverCode; + } + + @NonNull + public String getDriverName() { + return driverName == null ? "" : driverName; + } + + public void setDriverName(@NonNull String driverName) { + this.driverName = driverName; + } + + @NonNull + public String getDriverNameEn() { + return driverNameEn == null ? "" : driverNameEn; + } + + public void setDriverNameEn(@NonNull String driverNameEn) { + this.driverNameEn = driverNameEn; + } + + @NonNull + public String getDriverNameCn() { + return driverNameCn == null ? "" : driverNameCn; + } + + public void setDriverNameCn(@NonNull String driverNameCn) { + this.driverNameCn = driverNameCn; + } + + @NonNull + public String getImageId() { + return imageId == null ? "" : imageId; + } + + public void setImageId(@NonNull String imageId) { + this.imageId = imageId; + } + + @NonNull + public String getVersion() { + return version == null ? "" : version; + } + + public void setVersion(@NonNull String version) { + this.version = version; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/PassDataBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/PassDataBean.java new file mode 100644 index 0000000..b595f66 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/bean/PassDataBean.java @@ -0,0 +1,76 @@ +package com.hdl.linkpm.sdk.ota.bean; + +import java.io.Serializable; + +public class PassDataBean implements Serializable { + + /** + * Device_ID : 1 + * DeviceAddr : 60a423fffe93cf89 + * Epoint : 200 + * Data_ID : 64513 + * Data : {"PassData":"07020000030b1621"} + */ + + private int Device_ID; + private String DeviceAddr; + private int Epoint; + private int Data_ID; + private DataBean Data; + + public int getDevice_ID() { + return Device_ID; + } + + public void setDevice_ID(int Device_ID) { + this.Device_ID = Device_ID; + } + + public String getDeviceAddr() { + return DeviceAddr; + } + + public void setDeviceAddr(String DeviceAddr) { + this.DeviceAddr = DeviceAddr; + } + + public int getEpoint() { + return Epoint; + } + + public void setEpoint(int Epoint) { + this.Epoint = Epoint; + } + + public int getData_ID() { + return Data_ID; + } + + public void setData_ID(int Data_ID) { + this.Data_ID = Data_ID; + } + + public DataBean getData() { + return Data; + } + + public void setData(DataBean Data) { + this.Data = Data; + } + + public static class DataBean implements Serializable { + /** + * PassData : 07020000030b1621 + */ + + private String PassData; + + public String getPassData() { + return PassData; + } + + public void setPassData(String PassData) { + this.PassData = PassData; + } + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/controller/HDLPMOtaController.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/controller/HDLPMOtaController.java new file mode 100644 index 0000000..663f873 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/ota/controller/HDLPMOtaController.java @@ -0,0 +1,475 @@ +package com.hdl.linkpm.sdk.ota.controller; + +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.linkpm.sdk.core.api.HDLCloudHomeApi; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.ota.bean.CloudDeviceFirmwaresBean; +import com.hdl.linkpm.sdk.ota.bean.CloudGatewayDriversBean; +import com.hdl.linkpm.sdk.ota.bean.DeviceFirmwareBean; +import com.hdl.linkpm.sdk.ota.bean.DownloadUrlBean; +import com.hdl.linkpm.sdk.ota.bean.FirmwareBean; +import com.hdl.linkpm.sdk.ota.bean.GatewayDriverBean; +import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; + +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; +import io.reactivex.rxjava3.schedulers.Schedulers; +import io.reactivex.rxjava3.subscribers.DisposableSubscriber; +import okhttp3.ResponseBody; + +/** + * Created by jlchen on 12/17/21. + * OTA 缃戝叧銆佽澶囧浐浠舵煡璇㈠拰涓嬭浇鐩稿叧绠$悊 + */ +public class HDLPMOtaController { + /** + * instance + */ + private volatile static HDLPMOtaController instance; + + /** + * getInstance + * + * @return HDLPMOtaController + */ + public static synchronized HDLPMOtaController getInstance() { + if (instance == null) { + synchronized (HDLPMOtaController.class) { + if (instance == null) { + instance = new HDLPMOtaController(); + } + } + } + return instance; + } + + /** + * 鍘熺敓璁惧鑾峰彇鍥轰欢鍗囩骇鍖呬笅杞藉湴鍧� + * + * @param firmwareVersionId 鍥轰欢鐗堟湰Id + * @return downloadUrl + */ + public Disposable getNativeDeviceFirmwareDownloadUrl(String firmwareVersionId, IResponseCallBack<DownloadUrlBean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("firmwareVersionId", firmwareVersionId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GET_NativeDeviceFirmwareDownloadUrl); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<DownloadUrlBean>() { + @Override + public void onResponse(DownloadUrlBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * Link缃戝叧椹卞姩鍒楄〃鑾峰彇 + * + * @param homeId 浣忓畢id + * @param oid 缃戝叧璁惧oid + * @param callBack + * @return + */ + public Disposable getGatewayDrivers(String homeId, String oid, IResponseCallBack<List<GatewayDriverBean>> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("oid", oid); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GET_GatewayDrivers); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<GatewayDriverBean>>() { + @Override + public void onResponse(List<GatewayDriverBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * Link缃戝叧椹卞姩->鑾峰彇瀛樺偍鍦ㄤ簯绔殑椹卞姩鍒嗛〉鍒楄〃 + * + * @param driveCode 椹卞姩缂栧彿鎴栭┍鍔ㄥ悕绉� + * @param osImageId 椹卞姩绫诲瀷id + * @param callBack + * @return + */ + public Disposable getCloudGatewayDrivers(String driveCode, String osImageId, IResponseCallBack<CloudGatewayDriversBean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("driveCode", driveCode); + json.addProperty("osImageId", osImageId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GET_CloudGatewayDrivers); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<CloudGatewayDriversBean>() { + @Override + public void onResponse(CloudGatewayDriversBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * Link缃戝叧椹卞姩鍗囩骇OTA鍛戒护涓嬪彂 + * + * @param homeId 浣忓畢id + * @param oid 缃戝叧璁惧oid + * @param driverVersionId 椹卞姩鐗堟湰id + * @param callBack + * @return + */ + public Disposable upgradeGatewayDriver(String homeId, String oid, String driverVersionId, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("oid", oid); + json.addProperty("driverVersionId", driverVersionId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GatewayDriverUpgrade); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 鑾峰彇IARCC涓夋柟鍥轰欢鍒嗛〉 + * + * @param json 璇锋眰鏁版嵁 + * @param callBack 鍥炶皟 + * @return + */ + public Disposable getACIARCCFirmware(String json, IResponseCallBack<List<FirmwareBean>> callBack) { + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GET_FIRMWARE_PAGE); + return HxHttp.builder() + .url(requestUrl) + .raw(json) + .build() + .post() + .subscribeWith(new HDLResponse<List<FirmwareBean>>() { + @Override + public void onResponse(List<FirmwareBean> list) { + if (callBack != null) { + callBack.onSuccess(list); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇IARCC涓夋柟鍥轰欢鍒嗙被 + * + * @param json 璇锋眰鏁版嵁 + * @param callBack 鍥炶皟 + * @return + */ + public Disposable getACIARCCFirmwareList(String json, IResponseCallBack<List<FirmwareBean>> callBack) { + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GET_FIRMWARE_LIST); + return HxHttp.builder() + .url(requestUrl) + .raw(json) + .build() + .post() + .subscribeWith(new HDLResponse<List<FirmwareBean>>() { + @Override + public void onResponse(List<FirmwareBean> list) { + if (callBack != null) { + callBack.onSuccess(list); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 涓嬭浇IARCC鍥轰欢 + * + * @param requestUrl 璇锋眰鍦板潃 + * @param callBack 鍥炶皟 + * @return + */ + public Disposable downloadCloudACIARCCFirmware(String requestUrl, IResponseCallBack<ResponseBody> callBack) { + return HxHttp.builder() + .url(requestUrl) + .build() + .download() + .observeOn(Schedulers.io()) + .subscribeWith(new DisposableSubscriber<ResponseBody>() { + @Override + public void onNext(ResponseBody responseBody) { + try { + if (callBack != null) { + callBack.onSuccess(responseBody); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void onError(Throwable t) { + HDLExceptionSubmitUtils.submit(requestUrl, null, t); + } + + @Override + public void onComplete() { + + } + }); + } + + /** + * LINK缃戝叧鑾峰彇椹卞姩鍗囩骇鍖呬笅杞藉湴鍧� + * + * @param driverVersionId 椹卞姩鐗堟湰Id + * @return + */ + public Disposable getLinkDeviceDriverDownloadUrl(String driverVersionId, IResponseCallBack<DownloadUrlBean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("driverVersionId", driverVersionId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GET_LinkDeviceDriverDownloadUrl); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<DownloadUrlBean>() { + @Override + public void onResponse(DownloadUrlBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 鑾峰彇璁惧鍥轰欢鍒楄〃鑾峰彇 + * + * @param homeId 浣忓畢id + * @param deviceOidId oid浜戠id + * @param callBack + * @return + */ + public Disposable getDeviceFirmwares(String homeId, String deviceOidId, IResponseCallBack<List<DeviceFirmwareBean>> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("deviceOidId", deviceOidId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GET_DeviceFirmwares); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<DeviceFirmwareBean>>() { + @Override + public void onResponse(List<DeviceFirmwareBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇璁惧鍥轰欢鍒楄〃鑾峰彇->鑾峰彇瀛樺偍鍦ㄤ簯绔殑鍥轰欢鍒嗛〉鍒楄〃 + * + * @param hardwareModel 纭欢鍨嬪彿 + * @param osImageId 绯荤粺闀滃儚id + * @param callBack + * @return + */ + public Disposable getCloudDeviceFirmwares(String hardwareModel, String osImageId, IResponseCallBack<List<CloudDeviceFirmwaresBean>> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("hardwareModel", hardwareModel); + json.addProperty("osImageId", osImageId); + json.addProperty("protocolType", "ZIGBEE");//鍗忚绫诲瀷,鍙敤鍊�:BUSPRO,KNX,ZIGBEE,OTHER + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GET_CloudDeviceFirmwares); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<CloudDeviceFirmwaresBean>>() { + @Override + public void onResponse(List<CloudDeviceFirmwaresBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * Link璁惧鍥轰欢鍗囩骇OTA鍛戒护涓嬪彂 + * + * @param homeId 浣忓畢id + * @param deviceOidId 璁惧id + * @param firmwareVersionId 鍥轰欢鐗堟湰id + * @param callBack + * @return + */ + public Disposable upgradeDeviceFirmware(String homeId, String deviceOidId, String firmwareVersionId, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("deviceOidId", deviceOidId); + json.addProperty("firmwareVersionId", firmwareVersionId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_DeviceFirmwareUpgrade); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * LINK璁惧鑾峰彇鍥轰欢鍗囩骇鍖呬笅杞藉湴鍧� + * + * @param firmwareVersionId 鍥轰欢鐗堟湰Id + * @return + */ + public Disposable getLinkDeviceFirmwareDownloadUrl(String firmwareVersionId, IResponseCallBack<DownloadUrlBean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("firmwareVersionId", firmwareVersionId); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_OTA_GET_LinkDeviceFirmwareDownloadUrl); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<DownloadUrlBean>() { + @Override + public void onResponse(DownloadUrlBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/HDLLinkPMProject.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/HDLLinkPMProject.java new file mode 100644 index 0000000..be995c9 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/HDLLinkPMProject.java @@ -0,0 +1,378 @@ +package com.hdl.linkpm.sdk.project; + +import com.google.gson.JsonArray; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.home.bean.GatewayBindBean; +import com.hdl.linkpm.sdk.home.bean.GatewayInfoBean; +import com.hdl.linkpm.sdk.home.bean.HomeInfoBean; +import com.hdl.linkpm.sdk.home.controller.HDLPMHomeController; +import com.hdl.linkpm.sdk.project.bean.HousePageRequestBean; +import com.hdl.linkpm.sdk.project.bean.IrDeviceBrandBean; +import com.hdl.linkpm.sdk.project.bean.IrDeviceCodeBean; +import com.hdl.linkpm.sdk.project.bean.IrDeviceTypeBean; +import com.hdl.linkpm.sdk.project.bean.NewProjectRequestBean; +import com.hdl.linkpm.sdk.project.callback.DriverDetailListCallBack; +import com.hdl.linkpm.sdk.project.callback.DriverDownLoadCallBack; +import com.hdl.linkpm.sdk.project.callback.DriverTypeListCallBack; +import com.hdl.linkpm.sdk.project.callback.IEmployeeInfoCallBack; +import com.hdl.linkpm.sdk.project.callback.IProjectHouseListCallBack; +import com.hdl.linkpm.sdk.project.callback.IProjectInfoListCallBack; +import com.hdl.linkpm.sdk.project.controller.HDLPMProjectController; + +import java.util.List; + + +/** + * Created by jlchen on 12/8/21. + * 椤圭洰绠$悊鐩稿叧 + */ +public class HDLLinkPMProject { + //instance + private volatile static HDLLinkPMProject instance; + + /** + * getInstance + * + * @return HDLLinkProject + */ + public static synchronized HDLLinkPMProject getInstance() { + if (instance == null) { + synchronized (HDLLinkPMProject.class) { + if (instance == null) { + instance = new HDLLinkPMProject(); + } + } + } + return instance; + } + + + /** + * 鑾峰彇鎸囧畾鍏徃鍛樺伐鍒楄〃 鏀寔鍚嶇О妯$硦鏌ヨ + * + * @param companyId 鍏徃ID + * @param userName 鍚嶇О妯$硦鏌ヨ + * @param callBack + * @return + */ + public void getDebuggerList(String companyId, String userName, IEmployeeInfoCallBack callBack) { + HDLPMProjectController.getInstance().getDebuggerList(companyId, userName, callBack); + } + + /** + * 娣诲姞璋冭瘯浜哄憳銆佽浆绉昏皟璇曚汉鍛� + * + * @param houseId 浣忓畢id + * @param userId 鐢ㄦ埛id + * @param callBack + * @return + */ + public void changeHomeDebugger(String houseId, String userId, IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().changeHomeDebugger(houseId, userId, callBack); + } + + /** + * 鎵归噺娣诲姞璋冭瘯浜哄憳銆佽浆绉昏皟璇曚汉鍛� + * + * @param houseIds 浣忓畢id 鍒楄〃 + * @param userId 鐢ㄦ埛id + * @param communityCode 绀惧尯code + * @param callBack + * @return + */ + public void batchChangeHomeDebugger(List<String> houseIds, String userId, String communityCode, IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().batchChangeHomeDebugger(houseIds, userId, communityCode, callBack); + } + + /** + * 鑾峰彇椤圭洰鍒楄〃銆佹寚瀹氶」鐩被鍨嬫煡璇㈡墍鏈夎皟璇曠姸鎬� + * + * @param projectTypes 鏁扮粍 椤圭洰绫诲瀷 ProjectType.Home銆丳rojectType.RealEstate銆丳rojectType.PublicBuilding銆丳rojectType.Hotel + * @param pageNo + * @param pageSize + * @param callBack + * @return + */ + public void getProjectList(List<String> projectTypes, int pageNo, int pageSize, IProjectInfoListCallBack callBack) { + HDLPMProjectController.getInstance().getProjectList(projectTypes, "", null, pageNo, pageSize, callBack); + } + + /** + * 鑾峰彇椤圭洰鍒楄〃 + * 鏀寔鏍规嵁椤圭洰绫诲瀷 + * 鏀寔鏍规嵁椤圭洰鍚嶅瓧妯$硦鏌ヨ + * 鏀寔鏇村姞璋冭瘯鐘舵�侀泦鍚堟煡璇� + * + * @param projectTypes 鏁扮粍 椤圭洰绫诲瀷 ProjectType.Home銆丳rojectType.RealEstate銆丳rojectType.PublicBuilding銆丳rojectType.Hotel + * @param communityName 閫氳繃椤圭洰鍚嶇О妯$硦鏌ヨ + * @param debugStatus 鏁扮粍 璋冭瘯鐘舵�� To_Be_Debugged(0, "寰呰皟璇�")銆丏ebugging(1, "璋冭瘯涓�")銆乄AIT_DELIVERED(3, "寰呬氦浠�")銆丏elivered(4, "宸蹭氦浠�")銆両NITIAL_TATE(5,"鍒濆鎬�") + * @param pageNo + * @param pageSize + * @param callBack + * @return + */ + public void getProjectList(List<String> projectTypes, String communityName, List<String> debugStatus, int pageNo, int pageSize, IProjectInfoListCallBack callBack) { + HDLPMProjectController.getInstance().getProjectList(projectTypes, communityName, debugStatus, pageNo, pageSize, callBack); + } + + public void getRedebugProjectList(String communityName,String companyId,String debugUserId, int pageNo, int pageSize, IProjectInfoListCallBack callBack) { + HDLPMProjectController.getInstance().getReDebugProjectList(communityName,companyId, debugUserId, pageNo, pageSize, callBack); + } + + public void getProjectListExcuse(List<String> projectTypes, String communityName, List<String> debugStatus, int pageNo, int pageSize, IProjectInfoListCallBack callBack) { + HDLPMProjectController.getInstance().getProjectListExecute(projectTypes, communityName, debugStatus, pageNo, pageSize, callBack); + } + + public void addDownloadCount(String driverVersionId) { + HDLPMProjectController.getInstance().addDownloadCount(driverVersionId); + } + + public void addDownloadFirmwareCount(String firmwareVersionId) { + HDLPMProjectController.getInstance().addDownloadFirmwareCount(firmwareVersionId); + } + + public void addDownloadThirdCount(String thirdFirmwareVersionId) { + HDLPMProjectController.getInstance().addDownloadThirdCount(thirdFirmwareVersionId); + } + + + /** + * 鏂板缓椤圭洰 + * + * @param newProjectRequestBean 椤圭洰淇℃伅瀵硅薄 + * @param callBack + * @return + */ + public void addNewHouseProject(NewProjectRequestBean newProjectRequestBean, IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().addNewHouseProject(newProjectRequestBean, callBack); + } + + /** + * 浜や粯椤圭洰 鎵�鏈夋埧灞嬪浜庡凡浜や粯鐘舵�佹墠閫氳繃 鍚﹀垯鎻愮ず灏氭湭鏈夋湭浜や粯鐨勬埧灞� + * 閽堝閰掑簵鍜屽湴浜ч」鐩� + * + * @param communityId 灏忓尯ID + * @param callBack + * @return + */ + public void deliveryRoject(String communityId, IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().deliveryRoject(communityId, callBack); + } + + /** + * 鎾ゅ洖浜や粯鐨勯」鐩� 宸蹭氦浠樼殑椤圭洰鍙樹负寰呬氦浠� 閽堝閰掑簵鍜屽湴浜ч」鐩� + * + * @param communityId 灏忓尯ID + * @param callBack + * @return + */ + public void withdrawDeliveryProject(String communityId, IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().withdrawDeliveryProject(communityId, callBack); + } + + /******************************鎴垮眿绠$悊******************************/ + /** + * 鑾峰彇椤圭洰鐨勬埧灞嬩俊鎭垪琛紝鍒嗛〉鏌ヨ + * + * @param requestBean 璇锋眰鍙傛暟瀵硅薄 + * @param callBack + * @return + */ + public void getProjecHouseList(HousePageRequestBean requestBean, IProjectHouseListCallBack callBack) { + HDLPMProjectController.getInstance().getProjecHouseList(requestBean, callBack); + } + public void getProjecHouseListExecute(HousePageRequestBean requestBean, IProjectHouseListCallBack callBack) { + HDLPMProjectController.getInstance().getProjecHouseListExecute(requestBean, callBack); + } + + /** + * 缁戝畾鏋佸厜鎺ㄩ�� + * + * @param communityCode 椤圭洰code + * @param debugStatus 璋冭瘯鐘舵�� 0锛氬緟璋冭瘯 1锛氳皟璇曚腑 2锛氬緟楠屾敹 3锛氬凡瀹屾垚 4锛氬凡浜や粯锛屼负绌哄垯涓嶈繃婊� + * @param houseIds 鎴垮眿id闆嗗悎 + * @param callBack + * @return + */ + + /** + * + * @param deviceName 璁惧鍚嶇О + * @param pushToken App鐨勬帹閫乀oken锛屽湪鏋佸厜涓篟egId 璁惧绫诲瀷锛屽彲鐢ㄥ�硷細Android銆両OS銆乄inPhone + * @param software 杞欢鏉ユ簮锛孍voyo銆丱N銆丱N_Plus銆丏ebugTreasure + * @param callBack + */ + public void bindJPushId(String deviceName, String pushToken, String software, IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().bindJPushId(deviceName, pushToken, software, callBack); + } + + /** + * + * @param homeId 浣忓畢id + * @param homeName 浣忓畢鍚嶇О + * @param callBack + */ + public void syncHome(String homeId, String homeName, IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().updateHouseName(homeId, homeName, callBack); + } + + + + /** + * 瑙g粦鏋佸厜鎺ㄩ�� + * + * @param callBack + * @return + */ + public void unBindJPushId(IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().unBindJPushId(callBack); + } + + /** + * 鎵归噺鏇存柊鎴垮眿璋冭瘯鐘舵�� + * + * @param communityCode 椤圭洰code + * @param debugStatus 璋冭瘯鐘舵�� 0锛氬緟璋冭瘯 1锛氳皟璇曚腑 2锛氬緟楠屾敹 3锛氬凡瀹屾垚 4锛氬凡浜や粯锛屼负绌哄垯涓嶈繃婊� + * @param houseIds 鎴垮眿id闆嗗悎 + * @param callBack + * @return + */ + public void batchChangeHouseDebugstatus(String communityCode, int debugStatus, List<String> houseIds, IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().batchChangeHouseDebugstatus(communityCode, debugStatus, houseIds, callBack); + } + + /** + * 鑾峰彇椹卞姩鍒嗛〉鍒楄〃 + * + * @param driverTypeId 椹卞姩绫诲瀷id + * @param callBack + * @return + */ + public void getDriverList(String driverTypeId, DriverTypeListCallBack callBack) { + HDLPMProjectController.getInstance().driverList(driverTypeId, callBack); + } + + /** + * 鑾峰彇椹卞姩鍒嗛〉鍒楄〃 + * + * @param driverId 椹卞姩绫诲瀷id + * @param callBack + * @return + */ + public void getVersionList(String driverId, DriverDetailListCallBack callBack) { + HDLPMProjectController.getInstance().versionList(driverId, callBack); + } + + + /** + * 鏌ヨ绾㈠璁惧绫诲瀷鍒楄〃 + * + * @param deviceType 璁惧绫诲瀷 + * @param callBack + * @return + */ + public void getIrDeviceTypeList(String deviceType, IResponseCallBack<List<IrDeviceTypeBean>> callBack) { + HDLPMProjectController.getInstance().getIrDeviceTypeList(deviceType, callBack); + } + + /** + * 鏌ヨ绾㈠璁惧绫诲瀷鐨勫搧鐗屽垪琛� + * + * @param deviceTypeId 璁惧绫诲瀷涓婚敭Id + * @param callBack + * @return + */ + public void getIrDeviceBrandList(String deviceTypeId, IResponseCallBack<List<IrDeviceBrandBean>> callBack) { + HDLPMProjectController.getInstance().getIrDeviceBrandList(deviceTypeId, callBack); + } + + /** + * 鏌ヨ绾㈠璁惧绫诲瀷鐨勫搧鐗岀孩澶栫爜搴撳垪琛� + * + * @param brandId 鍝佺墝涓婚敭Id + * @param callBack + * @return + */ + public void getIrDeviceCodeList(String brandId, IResponseCallBack<List<IrDeviceCodeBean>> callBack) { + HDLPMProjectController.getInstance().getIrDeviceCodeList(brandId, callBack); + } + + /** + * 椹卞姩涓婁紶 + * + * @param url 椹卞姩涓嬭浇璺緞 + * @param callBack + * @return + */ + public void downLoadDriver(String url, DriverDownLoadCallBack callBack) { + HDLPMProjectController.getInstance().downLoadDriver(url, callBack); + } + + + + + /******************************鏁版嵁涓婁紶浜戠******************************/ + /** + * house琛ㄧ殑鏁版嵁娌℃湁鍚屾鍒癶ome琛ㄣ�佹暟鎹瓨鍦ㄤ袱寮犺〃閲岄潰锛岄渶瑕佸鎴风璋冩帴鍙e悓姝� + * + * @param homeInfoBean 浣忓畢Info + * @param callBack + * @return + */ + public void synchHouseToHome(HomeInfoBean homeInfoBean, IDefaultCallBack callBack) { + HDLPMHomeController.getInstance().synchHouseToHome(homeInfoBean, callBack); + } + + /** + * 缁戝畾缃戝叧鍒颁綇瀹� + * + * @param bean 缃戝叧淇℃伅 + * @param callBack + * @return + */ + public void bindGateway(GatewayBindBean bean, IResponseCallBack<GatewayInfoBean> callBack) { + HDLPMHomeController.getInstance().bindGateway(bean, callBack); + } + + /** + * 璁惧鍩烘湰淇℃伅(oid) + * @param homeId + * @param devicesInfo + * @param callBack + */ + public void fullUpdateDeviceInfo(String homeId, JsonArray devicesInfo,IDefaultCallBack callBack){ + HDLPMProjectController.getInstance().fullUpdateDeviceInfo(homeId, devicesInfo,callBack); + } + + /** + * 鏇存柊鍔熻兘淇℃伅锛屽叏閲� + * @param homeId + * @param funtionListInfo + * @param callBack + */ + public void fullUpdateFunctionInfo(String homeId ,String gatewayId,JsonArray funtionListInfo ,IDefaultCallBack callBack){ + HDLPMProjectController.getInstance().fullUpdateFunctionListInfo(homeId,gatewayId,funtionListInfo,callBack); + } + public void fullUpdateSceneInfo(String homeId ,JsonArray data ,IDefaultCallBack callBack){ + HDLPMProjectController.getInstance().fullUpdateSceneListInfo(homeId,data,callBack); + } + public void fullUpdateLogicInfo(String homeId ,JsonArray data ,IDefaultCallBack callBack){ + HDLPMProjectController.getInstance().fullUpdateLogicListInfo(homeId,data,callBack); + } + public void fullUpdateUidInfo(String homeId ,JsonArray data ,IDefaultCallBack callBack){ + HDLPMProjectController.getInstance().fullUpdateUidInfo(homeId,data,callBack); + } + public void fullUpdateSecuritysListInfo(String homeId,String gatewayId ,JsonArray data ,IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().fullUpdateSecuritysListInfo(homeId, gatewayId, data, callBack); + } + public void fullUpdateGroupControlListInfo(String homeId,String gatewayId ,JsonArray data ,IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().fullUpdateSecuritysListInfo(homeId, gatewayId, data, callBack); + } + + public void fullAddGroupControlList(String homeId,String gatewayId ,JsonArray data ,IDefaultCallBack callBack) { + HDLPMProjectController.getInstance().fullAddGroupControlList(homeId, gatewayId, data, callBack); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DebugConfigBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DebugConfigBean.java new file mode 100644 index 0000000..9a4d861 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DebugConfigBean.java @@ -0,0 +1,53 @@ +package com.hdl.linkpm.sdk.project.bean; + +import java.io.Serializable; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2024/8/15 + * description: + */ +public class DebugConfigBean implements Serializable { + /** + * 绫诲瀷 + * SPACE锛氱┖闂� + * DEVICE_ADD锛氳澶囨坊鍔� + * DEVICE_CONFIG锛氳澶囬厤缃� + * SCENE_CONFIG锛氬満鏅厤缃� + * TEST锛氱幇鍦烘祴璇� + */ + private String type; + /** + * WAIT_CONFIG锛氬緟閰嶇疆 + * IN_CONFIG锛氶厤缃腑 + * CONFIGURED锛氬凡閰嶇疆 + */ + private String status; + private String modifyTime; + + public String getType() { + return type == null ? "" : type; + } + + public void setType(@NonNull String type) { + this.type = type; + } + + public String getStatus() { + return status == null ? "" : status; + } + + public void setStatus(@NonNull String status) { + this.status = status; + } + + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } + + public void setModifyTime(@NonNull String modifyTime) { + this.modifyTime = modifyTime; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveDetailBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveDetailBean.java new file mode 100644 index 0000000..308a17d --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveDetailBean.java @@ -0,0 +1,215 @@ + +package com.hdl.linkpm.sdk.project.bean; + +import java.io.Serializable; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2022/5/13 + * description: + */ +public class DriveDetailBean implements Serializable { + private String driverVersionId; + private String driverId; + private String driverVersionCode; + private String driverVersionType; + private String driverVersionTypeDesc; + private String driverFree; + private String driverFreeDesc; + private String driverTag; + private String driverTagDesc; + private String driverVersionDesc; + private String modifyTime; + private String saleStatus; + private String saleStatusDesc; + private String driverFileUrl; + private String driverVersion; + private String downloadCount; + private String driverStatus; + private String driverStatusDesc; + private String driverMd5; + private String enable; + private boolean isExit; + /** + * 鐢ㄤ簬鍒ゆ柇褰撳墠椹卞姩鏄惁瀹夎杩� 瀹夎杩噄tem灏卞彨鍗囩骇 娌℃湁瀹夎灏卞彨瀹夎 + */ + private boolean isInstall; + + public boolean isInstall() { + return isInstall; + } + + public void setInstall(@NonNull boolean install) { + isInstall = install; + } + + public boolean isExit() { + return isExit; + } + + public void setExit(@NonNull boolean exit) { + isExit = exit; + } + + public String getDriverVersionId() { + return driverVersionId == null ? "" : driverVersionId; + } + + public void setDriverVersionId(@NonNull String driverVersionId) { + this.driverVersionId = driverVersionId; + } + + public String getDriverId() { + return driverId == null ? "" : driverId; + } + + public void setDriverId(@NonNull String driverId) { + this.driverId = driverId; + } + + public String getDriverVersionCode() { + return driverVersionCode == null ? "" : driverVersionCode; + } + + public void setDriverVersionCode(@NonNull String driverVersionCode) { + this.driverVersionCode = driverVersionCode; + } + + public String getDriverVersionType() { + return driverVersionType == null ? "" : driverVersionType; + } + + public void setDriverVersionType(@NonNull String driverVersionType) { + this.driverVersionType = driverVersionType; + } + + public String getDriverVersionTypeDesc() { + return driverVersionTypeDesc == null ? "" : driverVersionTypeDesc; + } + + public void setDriverVersionTypeDesc(@NonNull String driverVersionTypeDesc) { + this.driverVersionTypeDesc = driverVersionTypeDesc; + } + + public String getDriverFree() { + return driverFree == null ? "" : driverFree; + } + + public void setDriverFree(@NonNull String driverFree) { + this.driverFree = driverFree; + } + + public String getDriverFreeDesc() { + return driverFreeDesc == null ? "" : driverFreeDesc; + } + + public void setDriverFreeDesc(@NonNull String driverFreeDesc) { + this.driverFreeDesc = driverFreeDesc; + } + + public String getDriverTag() { + return driverTag == null ? "" : driverTag; + } + + public void setDriverTag(@NonNull String driverTag) { + this.driverTag = driverTag; + } + + public String getDriverTagDesc() { + return driverTagDesc == null ? "" : driverTagDesc; + } + + public void setDriverTagDesc(@NonNull String driverTagDesc) { + this.driverTagDesc = driverTagDesc; + } + + public String getDriverVersionDesc() { + return driverVersionDesc == null ? "" : driverVersionDesc; + } + + public void setDriverVersionDesc(@NonNull String driverVersionDesc) { + this.driverVersionDesc = driverVersionDesc; + } + + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } + + public void setModifyTime(@NonNull String modifyTime) { + this.modifyTime = modifyTime; + } + + public String getSaleStatus() { + return saleStatus == null ? "" : saleStatus; + } + + public void setSaleStatus(@NonNull String saleStatus) { + this.saleStatus = saleStatus; + } + + public String getSaleStatusDesc() { + return saleStatusDesc == null ? "" : saleStatusDesc; + } + + public void setSaleStatusDesc(@NonNull String saleStatusDesc) { + this.saleStatusDesc = saleStatusDesc; + } + + public String getDriverFileUrl() { + return driverFileUrl == null ? "" : driverFileUrl; + } + + public void setDriverFileUrl(@NonNull String driverFileUrl) { + this.driverFileUrl = driverFileUrl; + } + + public String getDriverVersion() { + return driverVersion == null ? "" : driverVersion; + } + + public void setDriverVersion(@NonNull String driverVersion) { + this.driverVersion = driverVersion; + } + + public String getDownloadCount() { + return downloadCount == null ? "" : downloadCount; + } + + public void setDownloadCount(@NonNull String downloadCount) { + this.downloadCount = downloadCount; + } + + public String getDriverStatus() { + return driverStatus == null ? "" : driverStatus; + } + + public void setDriverStatus(@NonNull String driverStatus) { + this.driverStatus = driverStatus; + } + + public String getDriverStatusDesc() { + return driverStatusDesc == null ? "" : driverStatusDesc; + } + + public void setDriverStatusDesc(@NonNull String driverStatusDesc) { + this.driverStatusDesc = driverStatusDesc; + } + + public String getDriverMd5() { + return driverMd5 == null ? "" : driverMd5; + } + + public void setDriverMd5(@NonNull String driverMd5) { + this.driverMd5 = driverMd5; + } + + public String getEnable() { + return enable == null ? "" : enable; + } + + public void setEnable(@NonNull String enable) { + this.enable = enable; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveDetailListBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveDetailListBean.java new file mode 100644 index 0000000..c325a2c --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveDetailListBean.java @@ -0,0 +1,63 @@ +package com.hdl.linkpm.sdk.project.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2022/5/13 + * description: + */ +public class DriveDetailListBean implements Serializable { + private List<DriveDetailBean> list = new ArrayList<>(); + private String totalCount; + private String totalPage; + private String pageNo; + private String pageSize; + + public List<DriveDetailBean> getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(@NonNull List<DriveDetailBean> list) { + this.list = list; + } + + public String getTotalCount() { + return totalCount == null ? "" : totalCount; + } + + public void setTotalCount(@NonNull String totalCount) { + this.totalCount = totalCount; + } + + public String getTotalPage() { + return totalPage == null ? "" : totalPage; + } + + public void setTotalPage(@NonNull String totalPage) { + this.totalPage = totalPage; + } + + public String getPageNo() { + return pageNo == null ? "" : pageNo; + } + + public void setPageNo(@NonNull String pageNo) { + this.pageNo = pageNo; + } + + public String getPageSize() { + return pageSize == null ? "" : pageSize; + } + + public void setPageSize(@NonNull String pageSize) { + this.pageSize = pageSize; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveTypeBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveTypeBean.java new file mode 100644 index 0000000..f80d161 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveTypeBean.java @@ -0,0 +1,132 @@ +package com.hdl.linkpm.sdk.project.bean; + +import java.io.Serializable; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2022/5/13 + * description: + */ +public class DriveTypeBean implements Serializable { + private String driverId; + private String driverNameCn; + private String driverNameEn; + private String driverImgUrl; + private String driverTypeId; + private String driverTypeName; + private String driverCode; + private String brandId; + private String brandName; + private String modifyTime; + private String thirdDeviceState; + //缃戝叧涓槸鍚﹀凡缁忓畨瑁� + private boolean isExit; + //褰撳墠鐨勯┍鍔ㄧ増鏈� 浠庣綉鍏宠幏鍙� + private String driverCurrentVersion; + + public String getDriverCurrentVersion() { + return driverCurrentVersion == null ? "" : driverCurrentVersion; + } + + public void setDriverCurrentVersion(@NonNull String driverCurrentVersion) { + this.driverCurrentVersion = driverCurrentVersion; + } + + public boolean isExit() { + return isExit; + } + + public void setExit(@NonNull boolean exit) { + isExit = exit; + } + + public String getDriverId() { + return driverId == null ? "" : driverId; + } + + public void setDriverId(@NonNull String driverId) { + this.driverId = driverId; + } + + public String getDriverNameCn() { + return driverNameCn == null ? "" : driverNameCn; + } + + public void setDriverNameCn(@NonNull String driverNameCn) { + this.driverNameCn = driverNameCn; + } + + public String getDriverNameEn() { + return driverNameEn == null ? "" : driverNameEn; + } + + public void setDriverNameEn(@NonNull String driverNameEn) { + this.driverNameEn = driverNameEn; + } + + public String getDriverImgUrl() { + return driverImgUrl == null ? "" : driverImgUrl; + } + + public void setDriverImgUrl(@NonNull String driverImgUrl) { + this.driverImgUrl = driverImgUrl; + } + + public String getDriverTypeId() { + return driverTypeId == null ? "" : driverTypeId; + } + + public void setDriverTypeId(@NonNull String driverTypeId) { + this.driverTypeId = driverTypeId; + } + + public String getDriverTypeName() { + return driverTypeName == null ? "" : driverTypeName; + } + + public void setDriverTypeName(@NonNull String driverTypeName) { + this.driverTypeName = driverTypeName; + } + + public String getDriverCode() { + return driverCode == null ? "" : driverCode; + } + + public void setDriverCode(@NonNull String driverCode) { + this.driverCode = driverCode; + } + + public String getBrandId() { + return brandId == null ? "" : brandId; + } + + public void setBrandId(@NonNull String brandId) { + this.brandId = brandId; + } + + public String getBrandName() { + return brandName == null ? "" : brandName; + } + + public void setBrandName(@NonNull String brandName) { + this.brandName = brandName; + } + + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } + + public void setModifyTime(@NonNull String modifyTime) { + this.modifyTime = modifyTime; + } + + public String getThirdDeviceState() { + return thirdDeviceState == null ? "" : thirdDeviceState; + } + + public void setThirdDeviceState(@NonNull String thirdDeviceState) { + this.thirdDeviceState = thirdDeviceState; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveTypeListBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveTypeListBean.java new file mode 100644 index 0000000..77625cd --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/DriveTypeListBean.java @@ -0,0 +1,63 @@ +package com.hdl.linkpm.sdk.project.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2022/5/13 + * description: + */ +public class DriveTypeListBean implements Serializable { + private List<DriveTypeBean> list = new ArrayList<>(); + private String totalCount; + private String totalPage; + private String pageNo; + private String pageSize; + + public List<DriveTypeBean> getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(@NonNull List<DriveTypeBean> list) { + this.list = list; + } + + public String getTotalCount() { + return totalCount == null ? "" : totalCount; + } + + public void setTotalCount(@NonNull String totalCount) { + this.totalCount = totalCount; + } + + public String getTotalPage() { + return totalPage == null ? "" : totalPage; + } + + public void setTotalPage(@NonNull String totalPage) { + this.totalPage = totalPage; + } + + public String getPageNo() { + return pageNo == null ? "" : pageNo; + } + + public void setPageNo(@NonNull String pageNo) { + this.pageNo = pageNo; + } + + public String getPageSize() { + return pageSize == null ? "" : pageSize; + } + + public void setPageSize(@NonNull String pageSize) { + this.pageSize = pageSize; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/EmployeeInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/EmployeeInfoBean.java new file mode 100644 index 0000000..3b19bfb --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/EmployeeInfoBean.java @@ -0,0 +1,64 @@ +package com.hdl.linkpm.sdk.project.bean; + +import androidx.annotation.NonNull; + +import com.hdl.linkpm.sdk.user.bean.HDLLoginBean; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/8/21. + * 鍛樺伐淇℃伅 + */ +public class EmployeeInfoBean implements Serializable { + /// 鐢ㄦ埛鍞竴ID + private String userId; + /// 鍛樺伐鍚嶅瓧 + private String userName; + // 鍛樺伐澶村儚 + private String headIcon; + private String accountName; + private String userAccount; + + public String getAccountName() { + return accountName == null ? "" : accountName; + } + + public void setAccountName(@NonNull String accountName) { + this.accountName = accountName; + } + + public String getUserAccount() { + return userAccount == null ? "" : userAccount; + } + + public void setUserAccount(@NonNull String userAccount) { + this.userAccount = userAccount; + } + + public String getHeadIcon() { + return headIcon == null ? "" : headIcon; + } + + public void setHeadIcon(@NonNull String headIcon) { + this.headIcon = headIcon; + } + + @NonNull + public String getUserId() { + return userId == null ? "" : userId; + } + + public void setUserId(@NonNull String userId) { + this.userId = userId; + } + + @NonNull + public String getUserName() { + return userName == null ? "" : userName; + } + + public void setUserName(@NonNull String userName) { + this.userName = userName; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/HousePageRequestBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/HousePageRequestBean.java new file mode 100644 index 0000000..20d4f66 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/HousePageRequestBean.java @@ -0,0 +1,94 @@ +package com.hdl.linkpm.sdk.project.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/9/21. + */ +public class HousePageRequestBean implements Serializable { + //椤圭洰缂栫爜 + private String communityCode; +// //0锛氬緟璋冭瘯 1锛氳皟璇曚腑 3锛氬緟楠屾敹 4锛氬凡浜や粯锛屼负绌哄垯涓嶈繃婊� +// private String debugStatus = "1"; + //璋冭瘯鐘舵�侀泦鍚� + private List<String> statusList = new ArrayList<>();//0锛氬緟璋冭瘯 1锛氳皟璇曚腑 3锛氬緟楠屾敹 4锛氬凡浜や粯锛屼负绌哄垯涓嶈繃婊� + + //鎴峰瀷鎴垮瀷id锛屼负绌哄垯涓嶈繃婊� + private String houseLayoutId; +// //鎴垮眿鍚嶇О + private String houseName; + //褰撳墠椤� + private int pageNo = 1; + //椤甸潰澶у皬 + private int pageSize = 10; + //璋冭瘯鍛樺伐璐﹀彿id + private String debugUserId; + + @NonNull + public String getCommunityCode() { + return communityCode == null ? "" : communityCode; + } + + public void setCommunityCode(@NonNull String communityCode) { + this.communityCode = communityCode; + } + + @NonNull + public List<String> getStatusList() { + if (statusList == null) { + return new ArrayList<>(); + } + return statusList; + } + + public void setStatusList(@NonNull List<String> statusList) { + this.statusList = statusList; + } + + @NonNull + public String getHouseLayoutId() { + return houseLayoutId == null ? "" : houseLayoutId; + } + + public void setHouseLayoutId(@NonNull String houseLayoutId) { + this.houseLayoutId = houseLayoutId; + } + + @NonNull + public String getHouseName() { + return houseName == null ? "" : houseName; + } + + public void setHouseName(@NonNull String houseName) { + this.houseName = houseName; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + @NonNull + public String getDebugUserId() { + return debugUserId == null ? "" : debugUserId; + } + + public void setDebugUserId(@NonNull String debugUserId) { + this.debugUserId = debugUserId; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceBrandBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceBrandBean.java new file mode 100644 index 0000000..70a22ec --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceBrandBean.java @@ -0,0 +1,46 @@ +package com.hdl.linkpm.sdk.project.bean; + +import java.io.Serializable; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2023/3/6 + * description: + */ +public class IrDeviceBrandBean implements Serializable { + private String id; + private String brandName; + private String deviceTypeId; + + public IrDeviceBrandBean(String id, String brandName, String deviceTypeId) { + this.id = id; + this.brandName = brandName; + this.deviceTypeId = deviceTypeId; + } + + public String getId() { + return id == null ? "" : id; + } + + public void setId(@NonNull String id) { + this.id = id; + } + + public String getBrandName() { + return brandName == null ? "" : brandName; + } + + public void setBrandName(@NonNull String brandName) { + this.brandName = brandName; + } + + public String getDeviceTypeId() { + return deviceTypeId == null ? "" : deviceTypeId; + } + + public void setDeviceTypeId(@NonNull String deviceTypeId) { + this.deviceTypeId = deviceTypeId; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceCodeBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceCodeBean.java new file mode 100644 index 0000000..a7fdb9d --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceCodeBean.java @@ -0,0 +1,46 @@ +package com.hdl.linkpm.sdk.project.bean; + +import java.io.Serializable; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2023/3/6 + * description: + */ +public class IrDeviceCodeBean implements Serializable { + private String irCode; + private String brandId; + private String irIndex; + + public IrDeviceCodeBean(String irCode, String brandId, String irIndex) { + this.irCode = irCode; + this.brandId = brandId; + this.irIndex = irIndex; + } + + public String getIrCode() { + return irCode == null ? "" : irCode; + } + + public void setIrCode(@NonNull String irCode) { + this.irCode = irCode; + } + + public String getBrandId() { + return brandId == null ? "" : brandId; + } + + public void setBrandId(@NonNull String brandId) { + this.brandId = brandId; + } + + public String getIrIndex() { + return irIndex == null ? "" : irIndex; + } + + public void setIrIndex(@NonNull String irIndex) { + this.irIndex = irIndex; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceTypeBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceTypeBean.java new file mode 100644 index 0000000..8fc35b6 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/IrDeviceTypeBean.java @@ -0,0 +1,36 @@ +package com.hdl.linkpm.sdk.project.bean; + +import java.io.Serializable; + +import androidx.annotation.NonNull; + +/** + * Created by Zoro + * Created on 2023/3/6 + * description: + */ +public class IrDeviceTypeBean implements Serializable { + private String id; + private String deviceType; + + public IrDeviceTypeBean(String id, String deviceType) { + this.id = id; + this.deviceType = deviceType; + } + + public String getId() { + return id == null ? "" : id; + } + + public void setId(@NonNull String id) { + this.id = id; + } + + public String getDeviceType() { + return deviceType == null ? "" : deviceType; + } + + public void setDeviceType(@NonNull String deviceType) { + this.deviceType = deviceType; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/NewProjectRequestBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/NewProjectRequestBean.java new file mode 100644 index 0000000..bfb07b7 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/NewProjectRequestBean.java @@ -0,0 +1,110 @@ +package com.hdl.linkpm.sdk.project.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/9/21. + * 椤圭洰璇︾粏淇℃伅 + */ +public class NewProjectRequestBean implements Serializable { + private String address;//璇︾粏鍦板潃 + private String communityName;//椤圭洰鍚嶇О + private String companyId;//鍏徃ID + private String debugEndDate;//璋冭瘯缁撴潫鏃ユ湡 + private String debugStartDate;//璋冭瘯寮�濮嬫棩鏈� + private String debugUserId;//璋冭瘯鍛樺伐璐﹀彿id + private ProjectLocationBean location;//鎵�鍦ㄥ湴鍖� + private String projectType;//0锛氬灞呴」鐩� 1锛氬湴浜ч」鐩� 2锛氬叕寤洪」鐩� 3锛氶厭搴楅」鐩�,鍙敤鍊�:Home,RealEstate,PublicBuilding,Hotel + private String protocolType;//BUSPRO,KNX,ZIGBEE + private Boolean isMyProjects = true;//鏄惁鎴戠殑椤圭洰 + + @NonNull + public String getAddress() { + return address == null ? "" : address; + } + + public void setAddress(@NonNull String address) { + this.address = address; + } + + @NonNull + public String getCommunityName() { + return communityName == null ? "" : communityName; + } + + public void setCommunityName(@NonNull String communityName) { + this.communityName = communityName; + } + + @NonNull + public String getCompanyId() { + return companyId == null ? "" : companyId; + } + + public void setCompanyId(@NonNull String companyId) { + this.companyId = companyId; + } + + @NonNull + public String getDebugEndDate() { + return debugEndDate == null ? "" : debugEndDate; + } + + public void setDebugEndDate(@NonNull String debugEndDate) { + this.debugEndDate = debugEndDate; + } + + @NonNull + public String getDebugStartDate() { + return debugStartDate == null ? "" : debugStartDate; + } + + public void setDebugStartDate(@NonNull String debugStartDate) { + this.debugStartDate = debugStartDate; + } + + @NonNull + public String getDebugUserId() { + return debugUserId == null ? "" : debugUserId; + } + + public void setDebugUserId(@NonNull String debugUserId) { + this.debugUserId = debugUserId; + } + + public ProjectLocationBean getLocation() { + return location; + } + + public void setLocation(ProjectLocationBean location) { + this.location = location; + } + + @NonNull + public String getProjectType() { + return projectType == null ? "" : projectType; + } + + public void setProjectType(@NonNull String projectType) { + this.projectType = projectType; + } + + @NonNull + public String getProtocolType() { + return protocolType == null ? "" : protocolType; + } + + public void setProtocolType(@NonNull String protocolType) { + this.protocolType = protocolType; + } + + public Boolean getIsMyProjects() { + return isMyProjects; + } + + public void setIsMyProjects(Boolean myProjects) { + isMyProjects = myProjects; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectHouseBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectHouseBean.java new file mode 100644 index 0000000..7be78d3 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectHouseBean.java @@ -0,0 +1,321 @@ +package com.hdl.linkpm.sdk.project.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +import androidx.annotation.NonNull; + +/** + * Created by jlchen on 12/9/21. + * 椤圭洰浣忓畢璇︾粏淇℃伅 + */ +public class ProjectHouseBean implements Serializable { + private String houseId;//鎴垮眿ID + private String buildName;//妤兼爧鍚嶇О + private String buildNum;//妤兼爧鍙� + /** + * To_Be_Debugged(0, "寰呰皟璇�"), + * Debugging(1, "璋冭瘯涓�"), + * To_Be_Accepted(2, "寰呴獙鏀�"), + * WAIT_DELIVERED(3, "璋冭瘯瀹屾垚"), + * Delivered(4, "宸蹭氦浠�"), + * INITIAL_TATE(5,"鍒濆鎬�"), + * ACCEPTANCE(6,"楠屾敹"), + * SECONDARY_DEBUGGIN(7,"浜屾璋冭瘯"), + */ + private int debugStatus;//0锛氬緟璋冭瘯 1锛氳皟璇曚腑 2锛氬緟楠屾敹 3锛氬凡瀹屾垚 4锛氬凡浜や粯,5锛氬垵濮嬫��,6: 楠屾敹,7: 浜屾璋冭瘯 + private String houseFullName;//浣忓畢鍏ㄧ▼ + private String houseLayoutId;//鎴垮瀷鎴栨埛鍨婭D + private String houseLayoutName;//鎴垮瀷鎴栨埛鍨嬪悕绉� + private String houseDesc;//浣忓畢鎻忚堪 + private String houseName;//浣忓畢鍚嶇О + private String houseNo;//鎴峰彿 + private String housePhoneNumber;//搴ф満 + private String unitName;//鍗曞厓鍚嶇О + private String unitNum;//鍗曞厓鍙� + private String floorName;//妤煎眰鍚嶇О + private String floorNum;//妤煎眰鍙� + private String userId;//璋冭瘯鍛樺伐璐﹀彿ID + private String userName;//璋冭瘯鍛樺伐璐﹀彿鍚嶇О +// private String spaceInfo; + private String debugTime;//璋冭瘯鏃堕棿 + private String backupTime;//澶囦唤鏃堕棿 + private String configUrl;//璋冭瘯杞欢閰嶇疆url + private String qrCode;//浜岀淮鐮佸浘鐗囧湴鍧� + private String templateId;//妯℃澘id + private String communityName; + private String communityCode; + private String localSecret;//鏈湴閫氫俊鍔犲瘑瀵嗛挜 2021-12-31 鏂板 + private boolean showChoose = false;//鏄惁鏄剧ず鎵归噺鐨勯�夋嫨 + private boolean isChoose = false;//鏄惁閫変腑 + /** + * 鏄惁鍒涘缓瀹跺眳椤圭洰 + */ + private boolean homeDataSync = false; + + private boolean hasUploadDevice = false;//鏄惁宸茬粡澶囦唤鍒颁簯绔� + private String uploadDeviceTime;//澶囦唤鏃堕棿 + + public boolean isHomeDataSync() { + return homeDataSync; + } + + public void setHomeDataSync(@NonNull boolean homeDataSync) { + this.homeDataSync = homeDataSync; + } + + public String getCommunityCode() { + return communityCode == null ? "" : communityCode; + } + + public void setCommunityCode(@NonNull String communityCode) { + this.communityCode = communityCode; + } + + public boolean isHasUploadDevice() { + return hasUploadDevice; + } + + public void setHasUploadDevice(boolean hasUploadDevice) { + this.hasUploadDevice = hasUploadDevice; + } + + public String getUploadDeviceTime() { + return uploadDeviceTime == null ? "" : uploadDeviceTime; + } + + public void setUploadDeviceTime(String uploadDeviceTime) { + this.uploadDeviceTime = uploadDeviceTime; + } + + public boolean isShowChoose() { + return showChoose; + } + + public void setShowChoose(@NonNull boolean showChoose) { + this.showChoose = showChoose; + } + + public boolean isChoose() { + return isChoose; + } + + public void setChoose(@NonNull boolean choose) { + isChoose = choose; + } + + @NonNull + public String getHouseId() { + return houseId == null ? "" : houseId; + } + + public void setHouseId(@NonNull String houseId) { + this.houseId = houseId; + } + + @NonNull + public String getBuildName() { + return buildName == null ? "" : buildName; + } + + public void setBuildName(@NonNull String buildName) { + this.buildName = buildName; + } + + @NonNull + public String getBuildNum() { + return buildNum == null ? "" : buildNum; + } + + public void setBuildNum(@NonNull String buildNum) { + this.buildNum = buildNum; + } + + public int getDebugStatus() { + return debugStatus; + } + + public void setDebugStatus(int debugStatus) { + this.debugStatus = debugStatus; + } + + @NonNull + public String getHouseFullName() { + return houseFullName == null ? "" : houseFullName; + } + + public void setHouseFullName(@NonNull String houseFullName) { + this.houseFullName = houseFullName; + } + + @NonNull + public String getHouseLayoutId() { + return houseLayoutId == null ? "" : houseLayoutId; + } + + public void setHouseLayoutId(@NonNull String houseLayoutId) { + this.houseLayoutId = houseLayoutId; + } + + @NonNull + public String getHouseLayoutName() { + return houseLayoutName == null ? "" : houseLayoutName; + } + + public void setHouseLayoutName(@NonNull String houseLayoutName) { + this.houseLayoutName = houseLayoutName; + } + + @NonNull + public String getHouseDesc() { + return houseDesc == null ? "" : houseDesc; + } + + public void setHouseDesc(@NonNull String houseDesc) { + this.houseDesc = houseDesc; + } + + @NonNull + public String getHouseName() { + return houseName == null ? "" : houseName; + } + + public void setHouseName(@NonNull String houseName) { + this.houseName = houseName; + } + + @NonNull + public String getHouseNo() { + return houseNo == null ? "" : houseNo; + } + + public void setHouseNo(@NonNull String houseNo) { + this.houseNo = houseNo; + } + + @NonNull + public String getHousePhoneNumber() { + return housePhoneNumber == null ? "" : housePhoneNumber; + } + + public void setHousePhoneNumber(@NonNull String housePhoneNumber) { + this.housePhoneNumber = housePhoneNumber; + } + + @NonNull + public String getUnitName() { + return unitName == null ? "" : unitName; + } + + public void setUnitName(@NonNull String unitName) { + this.unitName = unitName; + } + + @NonNull + public String getUnitNum() { + return unitNum == null ? "" : unitNum; + } + + public void setUnitNum(@NonNull String unitNum) { + this.unitNum = unitNum; + } + + @NonNull + public String getFloorName() { + return floorName == null ? "" : floorName; + } + + public void setFloorName(@NonNull String floorName) { + this.floorName = floorName; + } + + @NonNull + public String getFloorNum() { + return floorNum == null ? "" : floorNum; + } + + public void setFloorNum(@NonNull String floorNum) { + this.floorNum = floorNum; + } + + @NonNull + public String getUserId() { + return userId == null ? "" : userId; + } + + public void setUserId(@NonNull String userId) { + this.userId = userId; + } + + @NonNull + public String getUserName() { + return userName == null ? "" : userName; + } + + public void setUserName(@NonNull String userName) { + this.userName = userName; + } + + @NonNull + public String getDebugTime() { + return debugTime == null ? "" : debugTime; + } + + public void setDebugTime(@NonNull String debugTime) { + this.debugTime = debugTime; + } + + @NonNull + public String getConfigUrl() { + return configUrl == null ? "" : configUrl; + } + + public void setConfigUrl(@NonNull String configUrl) { + this.configUrl = configUrl; + } + + @NonNull + public String getQrCode() { + return qrCode == null ? "" : qrCode; + } + + public void setQrCode(@NonNull String qrCode) { + this.qrCode = qrCode; + } + + @NonNull + public String getTemplateId() { + return templateId == null ? "" : templateId; + } + + public void setTemplateId(@NonNull String templateId) { + this.templateId = templateId; + } + + @NonNull + public String getCommunityName() { + return communityName == null ? "" : communityName; + } + + public void setCommunityName(@NonNull String communityName) { + this.communityName = communityName; + } + + public String getBackupTime() { + return backupTime == null ? "" : backupTime; + } + + public void setBackupTime(String backupTime) { + this.backupTime = backupTime; + } + + @NonNull + public String getLocalSecret() { + return localSecret == null ? "" : localSecret; + } + + public void setLocalSecret(@NonNull String localSecret) { + this.localSecret = localSecret; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectHouseListBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectHouseListBean.java new file mode 100644 index 0000000..26539f0 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectHouseListBean.java @@ -0,0 +1,28 @@ +package com.hdl.linkpm.sdk.project.bean; + +import androidx.annotation.NonNull; + +import com.hdl.linkpm.sdk.core.bean.BasePageInfoBean; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/9/21. + * 浣忓畢鍒楄〃瀵硅薄 + */ +public class ProjectHouseListBean extends BasePageInfoBean { + private List<ProjectHouseBean> list = new ArrayList<>(); + + @NonNull + public List<ProjectHouseBean> getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(@NonNull List<ProjectHouseBean> list) { + this.list = list; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectInfoBean.java new file mode 100644 index 0000000..0d8624a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectInfoBean.java @@ -0,0 +1,370 @@ +package com.hdl.linkpm.sdk.project.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/9/21. + * 椤圭洰璇︾粏淇℃伅 + */ +public class ProjectInfoBean implements Serializable { + + private String communityId;//椤圭洰ID涓婚敭 + private String projectType;//0锛氬灞呴」鐩� 1锛氬湴浜ч」鐩� 2锛氬叕寤洪」鐩� 3锛氶厭搴楅」鐩�,鍙敤鍊�:Home,RealEstate,PublicBuilding,Hotel + private String projectTypeName;//椤圭洰绫诲瀷鍚嶇О + private String projectTypeSub;//椤圭洰瀛愮被鍨� + private String projectTypeSubName;//椤圭洰瀛愮被鍨嬪悕绉� + private String communityCode;//椤圭洰缂栫爜 + private String communityName;//椤圭洰鍚嶇О + private String protocolType;//0锛歜uspro 1锛歬nx 2锛歾igbee,鍙敤鍊�:BUSPRO,KNX,ZIGBEE + /** + * To_Be_Debugged(0, "寰呰皟璇�"), + * Debugging(1, "璋冭瘯涓�"), + * To_Be_Accepted(2, "寰呴獙鏀�"), + * WAIT_DELIVERED(3, "璋冭瘯瀹屾垚"), + * Delivered(4, "宸蹭氦浠�"), + * INITIAL_TATE(5,"鍒濆鎬�"), + * ACCEPTANCE(6,"楠屾敹"), + * SECONDARY_DEBUGGIN(7,"浜屾璋冭瘯"), + */ + private String debugStatus;//0锛氬緟璋冭瘯 1锛氳皟璇曚腑 2锛氬緟楠屾敹 3锛氬凡瀹屾垚 4锛氬凡浜や粯,5锛氬垵濮嬫��,6: 楠屾敹,7: 浜屾璋冭瘯 + private ProjectLocationBean location;//鎵�鍦ㄥ湴鍖� + private String address;//璇︾粏鍦板潃 + private String debugUserName;//璋冭瘯鍛樺伐鍚嶇О + private String debugUserId;//璋冭瘯鍛樺伐璐﹀彿id + private String companyName;//鍏徃鍚嶇О + private String companyId;//鍏徃ID + private String businessType;//涓氬姟绫诲瀷锛圫IGNED_PROJECT:绛剧害椤圭洰锛� DEBUG_CENTER:璋冭瘯涓績锛� + private String businessTypeName;//涓氬姟绫诲瀷鍚嶇О + private Boolean isMyCompanyProject;//鏄惁鏄嚜宸卞叕鍙哥殑椤圭洰 true鏌ヨ嚜宸遍」鐩� + private String businessStatus;//涓氬姟绫诲瀷锛堢绾﹂」鐩�佽皟璇曢」鐩級 + private String debugStartDate;//璋冭瘯寮�濮嬫棩鏈� + private String debugEndDate;//璋冭瘯缁撴潫鏃ユ湡 + private String houseCount;//椤圭洰涓嬫埧灞嬫�绘暟 + private String deliveryHouseCount;//椤圭洰涓嬫埧灞嬩氦浠樻�绘暟 + private String residueDay;//鍓╀綑澶╂暟 + private List<String> houseIds = new ArrayList<>();//浜屾璋冭瘯杩斿洖鐨� + private String houseId;//瀹跺眳鍜屽叕寤烘墠鏈� 浣忓畢ID + private String houseName;//瀹跺眳鍜屽叕寤烘墠鏈� 鎴垮眿鍚嶅瓧 2021-12-20 鏂板 + private String localSecret;//瀹跺眳鍜屽叕寤烘墠鏈� 鏈湴閫氫俊鍔犲瘑瀵嗛挜 2021-12-31 鏂板 + /** + * 鏄惁鍒涘缓瀹跺眳椤圭洰 + */ + private boolean homeDataSync = false; + //鑱旂郴浜� + private String ownerName; + //鑱旂郴浜烘墜鏈� + private String ownerPhone; + //椤圭洰鍦板潃 + private String projectAddress; + /** + * 椤圭洰閰嶇疆琛� + */ + private List<DebugConfigBean> debugConfigs = new ArrayList(); + + public Boolean getMyCompanyProject() { + return isMyCompanyProject; + } + + public void setMyCompanyProject(@NonNull Boolean myCompanyProject) { + isMyCompanyProject = myCompanyProject; + } + + public String getOwnerName() { + return ownerName == null ? "" : ownerName; + } + + public void setOwnerName(@NonNull String ownerName) { + this.ownerName = ownerName; + } + + public String getOwnerPhone() { + return ownerPhone == null ? "" : ownerPhone; + } + + public void setOwnerPhone(@NonNull String ownerPhone) { + this.ownerPhone = ownerPhone; + } + + public List<DebugConfigBean> getDebugConfigs() { + if (debugConfigs == null) { + return debugConfigs = new ArrayList<>(); + } + return debugConfigs; + } + + public void setDebugConfigs(@NonNull List<DebugConfigBean> debugConfigs) { + this.debugConfigs = debugConfigs; + } + + public boolean isHomeDataSync() { + return homeDataSync; + } + + public void setHomeDataSync(@NonNull boolean homeDataSync) { + this.homeDataSync = homeDataSync; + } + + public List<String> getHouseIds() { + if (houseIds == null) { + return houseIds = new ArrayList<>(); + } + return houseIds; + } + + public void setHouseIds(@NonNull List<String> houseIds) { + this.houseIds = houseIds; + } + + @NonNull + public String getCommunityId() { + return communityId == null ? "" : communityId; + } + + public void setCommunityId(@NonNull String communityId) { + this.communityId = communityId; + } + + @NonNull + public String getProjectType() { + return projectType == null ? "" : projectType; + } + + public void setProjectType(@NonNull String projectType) { + this.projectType = projectType; + } + + @NonNull + public String getProjectTypeName() { + return projectTypeName == null ? "" : projectTypeName; + } + + public void setProjectTypeName(@NonNull String projectTypeName) { + this.projectTypeName = projectTypeName; + } + + @NonNull + public String getProjectTypeSub() { + return projectTypeSub == null ? "" : projectTypeSub; + } + + public void setProjectTypeSub(@NonNull String projectTypeSub) { + this.projectTypeSub = projectTypeSub; + } + + @NonNull + public String getProjectTypeSubName() { + return projectTypeSubName == null ? "" : projectTypeSubName; + } + + public void setProjectTypeSubName(@NonNull String projectTypeSubName) { + this.projectTypeSubName = projectTypeSubName; + } + + @NonNull + public String getCommunityCode() { + return communityCode == null ? "" : communityCode; + } + + public void setCommunityCode(@NonNull String communityCode) { + this.communityCode = communityCode; + } + + @NonNull + public String getCommunityName() { + return communityName == null ? "" : communityName; + } + + public void setCommunityName(@NonNull String communityName) { + this.communityName = communityName; + } + + @NonNull + public String getProtocolType() { + return protocolType == null ? "" : protocolType; + } + + public void setProtocolType(@NonNull String protocolType) { + this.protocolType = protocolType; + } + + @NonNull + public String getDebugStatus() { + return debugStatus == null ? "" : debugStatus; + } + + public void setDebugStatus(@NonNull String debugStatus) { + this.debugStatus = debugStatus; + } + + public ProjectLocationBean getLocation() { + return location; + } + + public void setLocation(ProjectLocationBean location) { + this.location = location; + } + + @NonNull + public String getAddress() { + return address == null ? "" : address; + } + + public void setAddress(@NonNull String address) { + this.address = address; + } + + @NonNull + public String getDebugUserName() { + return debugUserName == null ? "" : debugUserName; + } + + public void setDebugUserName(@NonNull String debugUserName) { + this.debugUserName = debugUserName; + } + + @NonNull + public String getDebugUserId() { + return debugUserId == null ? "" : debugUserId; + } + + public void setDebugUserId(@NonNull String debugUserId) { + this.debugUserId = debugUserId; + } + + @NonNull + public String getCompanyName() { + return companyName == null ? "" : companyName; + } + + public void setCompanyName(@NonNull String companyName) { + this.companyName = companyName; + } + + @NonNull + public String getCompanyId() { + return companyId == null ? "" : companyId; + } + + public void setCompanyId(@NonNull String companyId) { + this.companyId = companyId; + } + + @NonNull + public String getHouseId() { + return houseId == null ? "" : houseId; + } + + public void setHouseId(@NonNull String houseId) { + this.houseId = houseId; + } + + @NonNull + public String getBusinessType() { + return businessType == null ? "" : businessType; + } + + public void setBusinessType(@NonNull String businessType) { + this.businessType = businessType; + } + + @NonNull + public String getBusinessTypeName() { + return businessTypeName == null ? "" : businessTypeName; + } + + public void setBusinessTypeName(@NonNull String businessTypeName) { + this.businessTypeName = businessTypeName; + } + + public Boolean getIsMyCompanyProject() { + return isMyCompanyProject; + } + + public void setIsMyCompanyProject(Boolean myCompanyProject) { + isMyCompanyProject = myCompanyProject; + } + + @NonNull + public String getBusinessStatus() { + return businessStatus == null ? "" : businessStatus; + } + + public void setBusinessStatus(@NonNull String businessStatus) { + this.businessStatus = businessStatus; + } + + @NonNull + public String getDebugStartDate() { + return debugStartDate == null ? "" : debugStartDate; + } + + public void setDebugStartDate(@NonNull String debugStartDate) { + this.debugStartDate = debugStartDate; + } + + @NonNull + public String getDebugEndDate() { + return debugEndDate == null ? "" : debugEndDate; + } + + public void setDebugEndDate(@NonNull String debugEndDate) { + this.debugEndDate = debugEndDate; + } + + @NonNull + public String getHouseCount() { + return houseCount == null ? "" : houseCount; + } + + public void setHouseCount(@NonNull String houseCount) { + this.houseCount = houseCount; + } + + @NonNull + public String getDeliveryHouseCount() { + return deliveryHouseCount == null ? "" : deliveryHouseCount; + } + + public void setDeliveryHouseCount(@NonNull String deliveryHouseCount) { + this.deliveryHouseCount = deliveryHouseCount; + } + + @NonNull + public String getResidueDay() { + return residueDay == null ? "" : residueDay; + } + + public void setResidueDay(@NonNull String residueDay) { + this.residueDay = residueDay; + } + + @NonNull + public String getHouseName() { + return houseName == null ? "" : houseName; + } + + public void setHouseName(@NonNull String houseName) { + this.houseName = houseName; + } + + @NonNull + public String getLocalSecret() { + return localSecret == null ? "" : localSecret; + } + + public void setLocalSecret(@NonNull String localSecret) { + this.localSecret = localSecret; + } + + public String getProjectAddress() { + return projectAddress; + } + + public void setProjectAddress(String projectAddress) { + this.projectAddress = projectAddress; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectInfoListBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectInfoListBean.java new file mode 100644 index 0000000..2d99f61 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectInfoListBean.java @@ -0,0 +1,29 @@ +package com.hdl.linkpm.sdk.project.bean; + +import androidx.annotation.NonNull; + +import com.hdl.linkpm.sdk.core.bean.BasePageInfoBean; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/9/21. + * 椤圭洰鍒楄〃瀵硅薄 + */ +public class ProjectInfoListBean extends BasePageInfoBean { + + private List<ProjectInfoBean> list = new ArrayList<>(); + + @NonNull + public List<ProjectInfoBean> getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(@NonNull List<ProjectInfoBean> list) { + this.list = list; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectLocationBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectLocationBean.java new file mode 100644 index 0000000..f34e2f3 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/ProjectLocationBean.java @@ -0,0 +1,71 @@ +package com.hdl.linkpm.sdk.project.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/9/21. + */ +public class ProjectLocationBean implements Serializable { + private String cityName;//甯傚悕绉� + private String cityCode;//甯傜紪鐮� + private String provinceCode;//鐪佺紪鐮� + private String provinceName;//鐪佸悕绉� + private String nationCode;//鍥藉缂栫爜 + private String nationName;//鍥藉鍚嶇О + + @NonNull + public String getCityName() { + return cityName == null ? "" : cityName; + } + + public void setCityName(@NonNull String cityName) { + this.cityName = cityName; + } + + @NonNull + public String getCityCode() { + return cityCode == null ? "" : cityCode; + } + + public void setCityCode(@NonNull String cityCode) { + this.cityCode = cityCode; + } + + @NonNull + public String getProvinceCode() { + return provinceCode == null ? "" : provinceCode; + } + + public void setProvinceCode(@NonNull String provinceCode) { + this.provinceCode = provinceCode; + } + + @NonNull + public String getProvinceName() { + return provinceName == null ? "" : provinceName; + } + + public void setProvinceName(@NonNull String provinceName) { + this.provinceName = provinceName; + } + + @NonNull + public String getNationCode() { + return nationCode == null ? "" : nationCode; + } + + public void setNationCode(@NonNull String nationCode) { + this.nationCode = nationCode; + } + + @NonNull + public String getNationName() { + return nationName == null ? "" : nationName; + } + + public void setNationName(@NonNull String nationName) { + this.nationName = nationName; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/PushNoticeInfo.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/PushNoticeInfo.java new file mode 100644 index 0000000..12b2b46 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/bean/PushNoticeInfo.java @@ -0,0 +1,74 @@ +package com.hdl.linkpm.sdk.project.bean; + +import java.io.Serializable; + +/** + * Created by Zoro + * Created on 2021/6/8 + * description: + */ +public class PushNoticeInfo implements Serializable { + private String notificationId; + private String notificationContent; + private String msgId; + private String appkey; + private String notificationAlertType; + private String notificationTitle; + private String notificationExtras; + + public String getNotificationId() { + return notificationId == null ? "" : notificationId; + } + + public void setNotificationId(String notificationId) { + this.notificationId = notificationId; + } + + public String getNotificationContent() { + return notificationContent == null ? "" : notificationContent; + } + + public void setNotificationContent(String notificationContent) { + this.notificationContent = notificationContent; + } + + public String getMsgId() { + return msgId == null ? "" : msgId; + } + + public void setMsgId(String msgId) { + this.msgId = msgId; + } + + public String getAppkey() { + return appkey == null ? "" : appkey; + } + + public void setAppkey(String appkey) { + this.appkey = appkey; + } + + public String getNotificationAlertType() { + return notificationAlertType == null ? "" : notificationAlertType; + } + + public void setNotificationAlertType(String notificationAlertType) { + this.notificationAlertType = notificationAlertType; + } + + public String getNotificationTitle() { + return notificationTitle == null ? "" : notificationTitle; + } + + public void setNotificationTitle(String notificationTitle) { + this.notificationTitle = notificationTitle; + } + + public String getNotificationExtras() { + return notificationExtras; + } + + public void setNotificationExtras(String notificationExtras) { + this.notificationExtras = notificationExtras; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverDetailListCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverDetailListCallBack.java new file mode 100644 index 0000000..e4b9813 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverDetailListCallBack.java @@ -0,0 +1,15 @@ +package com.hdl.linkpm.sdk.project.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.project.bean.DriveDetailListBean; +import com.hdl.linkpm.sdk.project.bean.DriveTypeListBean; + +/** + * Created by zoro on 12/2/21. + */ +public interface DriverDetailListCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(DriveDetailListBean bean); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverDownLoadCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverDownLoadCallBack.java new file mode 100644 index 0000000..7f650e9 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverDownLoadCallBack.java @@ -0,0 +1,16 @@ +package com.hdl.linkpm.sdk.project.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.project.bean.DriveDetailListBean; + +import okhttp3.ResponseBody; + +/** + * Created by zoro on 12/2/21. + */ +public interface DriverDownLoadCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(ResponseBody responseBody); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverTypeListCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverTypeListCallBack.java new file mode 100644 index 0000000..7c3daaf --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/DriverTypeListCallBack.java @@ -0,0 +1,17 @@ +package com.hdl.linkpm.sdk.project.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.project.bean.DriveTypeListBean; +import com.hdl.linkpm.sdk.project.bean.EmployeeInfoBean; + +import java.util.List; + +/** + * Created by zoro on 12/2/21. + */ +public interface DriverTypeListCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(DriveTypeListBean bean); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IEmployeeInfoCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IEmployeeInfoCallBack.java new file mode 100644 index 0000000..6d0041e --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IEmployeeInfoCallBack.java @@ -0,0 +1,16 @@ +package com.hdl.linkpm.sdk.project.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.project.bean.EmployeeInfoBean; + +import java.util.List; + +/** + * Created by jlchen on 12/2/21. + */ +public interface IEmployeeInfoCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(List<EmployeeInfoBean> list); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IProjectHouseListCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IProjectHouseListCallBack.java new file mode 100644 index 0000000..1c7dfc2 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IProjectHouseListCallBack.java @@ -0,0 +1,15 @@ +package com.hdl.linkpm.sdk.project.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.project.bean.ProjectHouseListBean; +import com.hdl.linkpm.sdk.project.bean.ProjectInfoListBean; + +/** + * Created by jlchen on 12/2/21. + */ +public interface IProjectHouseListCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(ProjectHouseListBean bean); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IProjectInfoListCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IProjectInfoListCallBack.java new file mode 100644 index 0000000..0c939e6 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/callback/IProjectInfoListCallBack.java @@ -0,0 +1,17 @@ +package com.hdl.linkpm.sdk.project.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.project.bean.EmployeeInfoBean; +import com.hdl.linkpm.sdk.project.bean.ProjectInfoListBean; + +import java.util.List; + +/** + * Created by jlchen on 12/2/21. + */ +public interface IProjectInfoListCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(ProjectInfoListBean bean); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/controller/HDLPMProjectController.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/controller/HDLPMProjectController.java new file mode 100644 index 0000000..43dbbc8 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/controller/HDLPMProjectController.java @@ -0,0 +1,1092 @@ +package com.hdl.linkpm.sdk.project.controller; + +import android.text.TextUtils; + + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.linkpm.sdk.core.api.HDLCloudProjectApi; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.interceptor.HDLSmartHeader; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.project.bean.DriveDetailListBean; +import com.hdl.linkpm.sdk.project.bean.DriveTypeListBean; +import com.hdl.linkpm.sdk.project.bean.EmployeeInfoBean; +import com.hdl.linkpm.sdk.project.bean.HousePageRequestBean; +import com.hdl.linkpm.sdk.project.bean.IrDeviceBrandBean; +import com.hdl.linkpm.sdk.project.bean.IrDeviceCodeBean; +import com.hdl.linkpm.sdk.project.bean.IrDeviceTypeBean; +import com.hdl.linkpm.sdk.project.bean.ProjectHouseListBean; +import com.hdl.linkpm.sdk.project.bean.NewProjectRequestBean; +import com.hdl.linkpm.sdk.project.bean.ProjectInfoListBean; +import com.hdl.linkpm.sdk.project.callback.DriverDetailListCallBack; +import com.hdl.linkpm.sdk.project.callback.DriverDownLoadCallBack; +import com.hdl.linkpm.sdk.project.callback.DriverTypeListCallBack; +import com.hdl.linkpm.sdk.project.callback.IEmployeeInfoCallBack; +import com.hdl.linkpm.sdk.project.callback.IProjectHouseListCallBack; +import com.hdl.linkpm.sdk.project.callback.IProjectInfoListCallBack; +import com.hdl.linkpm.sdk.user.HDLLinkPMUser; +import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; + +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; +import io.reactivex.rxjava3.functions.Consumer; +import okhttp3.ResponseBody; + +/** + * Created by jlchen on 12/8/21. + * 椤圭洰绠$悊鐩稿叧鐨勭綉缁滆姹� + */ +public class HDLPMProjectController { + /** + * instance + */ + private volatile static HDLPMProjectController instance; + + /** + * getInstance + * + * @return HDLProjectController + */ + public static synchronized HDLPMProjectController getInstance() { + if (instance == null) { + synchronized (HDLPMProjectController.class) { + if (instance == null) { + instance = new HDLPMProjectController(); + } + } + } + return instance; + } + + /** + * 鑾峰彇鎸囧畾鍏徃鍛樺伐鍒楄〃 鏀寔鍚嶇О妯$硦鏌ヨ + * + * @param companyId 鍏徃ID + * @param userName 鍚嶇О妯$硦鏌ヨ + * @param callBack + * @return + */ + public Disposable getDebuggerList(String companyId, String userName, IEmployeeInfoCallBack callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_DEBUGGER_GET); + JsonObject json = new JsonObject(); + json.addProperty("companyId", companyId); + json.addProperty("userName", userName); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<EmployeeInfoBean>>() { + @Override + public void onResponse(List<EmployeeInfoBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 娣诲姞璋冭瘯浜哄憳銆佽浆绉昏皟璇曚汉鍛� + * + * @param houseId 浣忓畢id + * @param userId 鐢ㄦ埛id + * @param callBack + * @return + */ + public Disposable changeHomeDebugger(String houseId, String userId, IDefaultCallBack callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_DEBUGGER_ADD); + JsonObject json = new JsonObject(); + json.addProperty("houseId", houseId); + json.addProperty("userId", userId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鎵归噺娣诲姞璋冭瘯浜哄憳銆佽浆绉昏皟璇曚汉鍛� + * + * @param houseIds 浣忓畢id 鍒楄〃 + * @param userId 鐢ㄦ埛id + * @param communityCode 绀惧尯code + * @param callBack + * @return + */ + public Disposable batchChangeHomeDebugger(List<String> houseIds, String userId, String communityCode, IDefaultCallBack callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_DEBUGGER_BATCHADD); + JsonObject json = new JsonObject(); + json.add("houseIds", HDLGsonUtils.toJsonArray(houseIds)); + json.addProperty("userId", userId); + json.addProperty("communityCode", communityCode); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /******************************缃戝叧椹卞姩******************************/ + /** + * 鏂板缓椤圭洰 + * + * @param callBack + * @return + */ + public Disposable driverList(String driverTypeId, DriverTypeListCallBack callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_GET_DRIVERLIST); + JsonObject json = new JsonObject(); + json.addProperty("driverTypeId", driverTypeId); + json.addProperty("pageNo", "1"); + json.addProperty("pageSize", "100"); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<DriveTypeListBean>() { + @Override + public void onResponse(DriveTypeListBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鏂板缓椤圭洰 + * + * @param callBack + * @return + */ + public Disposable versionList(String driverId, DriverDetailListCallBack callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_GET_VERSIONLIST); + JsonObject json = new JsonObject(); + json.addProperty("driverId", driverId); + json.addProperty("pageNo", "1"); + json.addProperty("pageSize", "100"); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<DriveDetailListBean>() { + @Override + public void onResponse(DriveDetailListBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + + + /** + * 鏌ヨ绾㈠璁惧绫诲瀷鍒楄〃 + * + * @param callBack + * @return + */ + public Disposable getIrDeviceTypeList(String deviceType, IResponseCallBack<List<IrDeviceTypeBean>> callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_GET_IR_DEVICETYPELIST); + JsonObject json = new JsonObject(); + if (!TextUtils.isEmpty(deviceType)) { + json.addProperty("deviceType", deviceType); + } + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<IrDeviceTypeBean>>() { + @Override + public void onResponse(List<IrDeviceTypeBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鏌ヨ绾㈠璁惧绫诲瀷鐨勫搧鐗屽垪琛� + * + * @param callBack + * @return + */ + public Disposable getIrDeviceBrandList(String deviceTypeId, IResponseCallBack<List<IrDeviceBrandBean>> callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_GET_IR_DEVICEBRANDLIST); + JsonObject json = new JsonObject(); + json.addProperty("deviceTypeId", deviceTypeId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<IrDeviceBrandBean>>() { + @Override + public void onResponse(List<IrDeviceBrandBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鏌ヨ绾㈠璁惧绫诲瀷鐨勫搧鐗岀孩澶栫爜搴撳垪琛� + * + * @param callBack + * @return + */ + public Disposable getIrDeviceCodeList(String brandId, IResponseCallBack<List<IrDeviceCodeBean>> callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_GET_IR_DEVICECODELIST); + JsonObject json = new JsonObject(); + json.addProperty("brandId", brandId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<IrDeviceCodeBean>>() { + @Override + public void onResponse(List<IrDeviceCodeBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + + /** + * 涓嬭浇椹卞姩 + * + * @param callBack + * @return + */ + public Disposable downLoadDriver(String url, DriverDownLoadCallBack callBack) { + return HxHttp.builder() + .url(url) + .headers(HDLSmartHeader.IGNORE_SIGN_HEADER, 1) + .build() + .download() + .subscribe(new Consumer<ResponseBody>() { + @Override + public void accept(ResponseBody responseBody) throws Exception { + //缃戠粶璇锋眰鎴愬姛锛岃鍙栨枃浠朵繚瀛樺埌sd鍗� + callBack.onSuccess(responseBody); + } + }, new Consumer<Throwable>() { + @Override + public void accept(Throwable throwable) throws Exception { + /** + * 缃戠粶璇锋眰澶辫触 + * 鍏蜂綋鍙互鑷繁瀹炵幇 + */ + HDLExceptionSubmitUtils.submit(url, null, throwable); + if (callBack != null) { + callBack.onFailure(new HDLException(403, throwable.getMessage())); + } + } + }); + } + + + /******************************************************************/ + + + /******************************椤圭洰绠$悊******************************/ + /** + * 鑾峰彇椤圭洰鍒楄〃 + * + * @param projectTypes 鏁扮粍 椤圭洰绫诲瀷 ProjectType.Home銆丳rojectType.RealEstate銆丳rojectType.PublicBuilding銆丳rojectType.Hotel + * @param communityName 閫氳繃椤圭洰鍚嶇О妯$硦鏌ヨ + * @param debugStatus 鏁扮粍 璋冭瘯鐘舵�� To_Be_Debugged(0, "寰呰皟璇�")銆丏ebugging(1, "璋冭瘯涓�")銆乄AIT_DELIVERED(3, "寰呬氦浠�")銆丏elivered(4, "宸蹭氦浠�")銆両NITIAL_TATE(5,"鍒濆鎬�") + * @param pageNo + * @param pageSize + * @param callBack + * @return + */ + public Disposable getProjectList(List<String> projectTypes, String communityName, List<String> debugStatus, int pageNo, int pageSize, IProjectInfoListCallBack callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_PROJECT_GET_PAGE); + JsonObject json = new JsonObject(); + json.add("projectTypes", HDLGsonUtils.toJsonArray(projectTypes)); + json.addProperty("pageNo", pageNo); + json.addProperty("pageSize", pageSize); + if (debugStatus != null && debugStatus.size() > 0) { + json.add("debugStatus", HDLGsonUtils.toJsonArray(debugStatus)); + } + if (!TextUtils.isEmpty(communityName)) { + json.addProperty("communityName", communityName); + } + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<ProjectInfoListBean>() { + @Override + public void onResponse(ProjectInfoListBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /******************************椤圭洰绠$悊******************************/ + /** + * 鑾峰彇椤圭洰鍒楄〃 + * + * @param companyId 鎵�灞炰紒涓氬崟浣峣d + * @param debugUserId 璋冭瘯鍛樺伐璐﹀彿id + * @param pageNo + * @param pageSize + * @param callBack + * @return + */ + public Disposable getReDebugProjectList(String communityName, String companyId, String debugUserId, int pageNo, int pageSize, IProjectInfoListCallBack callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_REDEBUG_GET_PAGE); + JsonObject json = new JsonObject(); + json.addProperty("companyId", companyId); + json.addProperty("debugUserId", debugUserId); + json.addProperty("pageNo", pageNo); + json.addProperty("pageSize", pageSize); + if (!TextUtils.isEmpty(communityName)) { + json.addProperty("communityName", communityName); + } + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<ProjectInfoListBean>() { + @Override + public void onResponse(ProjectInfoListBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + public Disposable getProjectListExecute(List<String> projectTypes, String communityName, List<String> debugStatus, int pageNo, int pageSize, IProjectInfoListCallBack callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_PROJECT_GET_PAGE); + JsonObject json = new JsonObject(); + json.add("projectTypes", HDLGsonUtils.toJsonArray(projectTypes)); + json.addProperty("pageNo", pageNo); + json.addProperty("pageSize", pageSize); + if (debugStatus != null && debugStatus.size() > 0) { + json.add("debugStatus", HDLGsonUtils.toJsonArray(debugStatus)); + } + if (!TextUtils.isEmpty(communityName)) { + json.addProperty("communityName", communityName); + } + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .executePost() + .subscribeWith(new HDLResponse<ProjectInfoListBean>() { + @Override + public void onResponse(ProjectInfoListBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + + /** + * 鏂板缓椤圭洰 + * + * @param newProjectRequestBean 椤圭洰淇℃伅瀵硅薄 + * @param callBack + * @return + */ + public Disposable addNewHouseProject(NewProjectRequestBean newProjectRequestBean, IDefaultCallBack callBack) { + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_PROJECT_CREATE); + return HxHttp.builder() + .url(requestUrl) + .raw(HDLGsonUtils.toJson(newProjectRequestBean)) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, newProjectRequestBean, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 浜や粯椤圭洰 鎵�鏈夋埧灞嬪浜庡凡浜や粯鐘舵�佹墠閫氳繃 鍚﹀垯鎻愮ず灏氭湭鏈夋湭浜や粯鐨勬埧灞� + * 閽堝閰掑簵鍜屽湴浜ч」鐩� + * + * @param communityId 灏忓尯ID + * @param callBack + * @return + */ + public Disposable deliveryRoject(String communityId, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("communityId", communityId); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_PROJECT_DELIVERY_ROJECT); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鎾ゅ洖浜や粯鐨勯」鐩� 宸蹭氦浠樼殑椤圭洰鍙樹负寰呬氦浠� 閽堝閰掑簵鍜屽湴浜ч」鐩� + * + * @param communityId 灏忓尯ID + * @param callBack + * @return + */ + public Disposable withdrawDeliveryProject(String communityId, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("communityId", communityId); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_PROJECT_WITHDRAW_DELIVERY_PROJECT); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + + /******************************鎴垮眿绠$悊******************************/ + /** + * 鑾峰彇椤圭洰鐨勬埧灞嬩俊鎭垪琛紝鍒嗛〉鏌ヨ + * + * @param requestBean 璇锋眰鍙傛暟瀵硅薄 + * @param callBack + * @return + */ + public Disposable getProjecHouseList(HousePageRequestBean requestBean, IProjectHouseListCallBack callBack) { + String requestJsonStr = HDLGsonUtils.toJson(requestBean); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_PROJECT_GET_HOUSE_PAGE); + return HxHttp.builder() + .url(requestUrl) + .raw(requestJsonStr) + .build() + .post() + .subscribeWith(new HDLResponse<ProjectHouseListBean>() { + @Override + public void onResponse(ProjectHouseListBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, requestBean, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + public Disposable getProjecHouseListExecute(HousePageRequestBean requestBean, IProjectHouseListCallBack callBack) { + String requestJsonStr = HDLGsonUtils.toJson(requestBean); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_PROJECT_GET_HOUSE_PAGE); + return HxHttp.builder() + .url(requestUrl) + .raw(requestJsonStr) + .build() + .executePost() + .subscribeWith(new HDLResponse<ProjectHouseListBean>() { + @Override + public void onResponse(ProjectHouseListBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, requestBean, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鎵归噺鏇存柊鎴垮眿璋冭瘯鐘舵�� + * + * @param communityCode 椤圭洰code + * @param debugStatus 璋冭瘯鐘舵�� 0锛氬緟璋冭瘯 1锛氳皟璇曚腑 2锛氬緟楠屾敹 3锛氬凡瀹屾垚 4锛氬凡浜や粯锛屼负绌哄垯涓嶈繃婊� + * @param houseIds 鎴垮眿id闆嗗悎 + * @param callBack + * @return + */ + public Disposable batchChangeHouseDebugstatus(String communityCode, int debugStatus, List<String> houseIds, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("communityCode", communityCode); + json.addProperty("debugStatus", debugStatus); + json.add("houseIds", HDLGsonUtils.toJsonArray(houseIds)); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_BATCH_UPDATE_STATUS); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 璁惧鍩烘湰淇℃伅(oid) + * + * @param homeId + * @param devicesInfo + * @param callBack + * @return + */ + public Disposable fullUpdateDeviceInfo(String homeId, JsonArray devicesInfo, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("devices", devicesInfo); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_DEVICE_FULL_UPDATE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 鏇存柊鍔熻兘淇℃伅锛屽叏閲� + */ + public Disposable fullUpdateFunctionListInfo(String homeId, String gatewayId, JsonArray functionListInfo, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + json.add("devices", functionListInfo); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_FUNCTION_FULL_UPDATE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .executePost() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + public Disposable fullUpdateSceneListInfo(String homeId, JsonArray data, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("scenes", data); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_SCENE_FULL_UPDATE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .executePost() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + public Disposable fullUpdateLogicListInfo(String homeId, JsonArray data, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("logics", data); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_LOGIC_FULL_UPDATE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .executePost() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + public Disposable fullUpdateUidInfo(String homeId, JsonArray data, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("rooms", data); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_ROOM_FULL_UPDATE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .executePost() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + public Disposable fullUpdateSecuritysListInfo(String homeId, String gatewayId, JsonArray data, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + json.add("securitys", data); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_SECURITY_FULL_UPDATE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .executePost() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + public Disposable fullAddGroupControlList(String homeId, String gatewayId, JsonArray data, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId); + json.add("infos", data); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSE_GROUPCONTROL_FULL_UPDATE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .executePost() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + public Disposable updateHouseName(String homeId, String homeName, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("homeName", homeName); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_HOUSENAME_UPDATE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + public Disposable addDownloadCount(String driverVersionId) { + JsonObject json = new JsonObject(); + json.addProperty("driverVersionId", driverVersionId); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_ADD_DOWNLOADCOUNT); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + } + }); + } + + public Disposable addDownloadFirmwareCount(String firmwareVersionId) { + JsonObject json = new JsonObject(); + json.addProperty("firmwareVersionId", firmwareVersionId); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_ADD_FIRMWARE_DOWNLOADCOUNT); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + } + }); + } + + public Disposable addDownloadThirdCount(String thirdFirmwareVersionId) { + JsonObject json = new JsonObject(); + json.addProperty("thirdFirmwareVersionId", thirdFirmwareVersionId); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_ADD_THIRD_DOWNLOADCOUNT); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + } + }); + } + + + /******************************鏋佸厜鎺ㄩ��******************************/ + + public Disposable bindJPushId(String deviceName, String pushToken, String software, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("deviceName", deviceName); + json.addProperty("deviceType", "Android"); + json.addProperty("produce", "true"); + json.addProperty("pushToken", pushToken); + json.addProperty("software", software); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_JPUSH_BIND); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + HDLLinkPMUser.getInstance().saveHDLJpushId(response); + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + public Disposable unBindJPushId(IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("pushId", HDLLinkPMUser.getInstance().getHDLJpushId()); + String requestUrl = HDLCloudProjectApi.getRequestUrl(HDLCloudProjectApi.POST_JPUSH_UNBIND); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/DebugStatusIntType.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/DebugStatusIntType.java new file mode 100644 index 0000000..36b0c39 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/DebugStatusIntType.java @@ -0,0 +1,25 @@ +package com.hdl.linkpm.sdk.project.type; + +import androidx.annotation.IntDef; +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + +/** + * Created by jlchen on 12/9/21. + * 璋冭瘯鐘舵�� Int 绫诲瀷 + */ +@Retention(SOURCE) +@IntDef({DebugStatusIntType.To_Be_Debugged, DebugStatusIntType.Debugging, DebugStatusIntType.WAIT_DELIVERED, DebugStatusIntType.Delivered, DebugStatusIntType.INITIAL_TATE}) +public @interface DebugStatusIntType { + //0锛氬緟璋冭瘯 + int To_Be_Debugged = 0; + //1锛氳皟璇曚腑 + int Debugging = 1; + //3锛氬緟浜や粯 + int WAIT_DELIVERED = 3; + //4锛氬凡浜や粯 + int Delivered = 4; + //5锛氬垵濮嬫�� + int INITIAL_TATE = 5; +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/DebugStatusType.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/DebugStatusType.java new file mode 100644 index 0000000..29a08d5 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/DebugStatusType.java @@ -0,0 +1,26 @@ +package com.hdl.linkpm.sdk.project.type; + +import androidx.annotation.StringDef; + +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + +/** + * Created by jlchen on 12/9/21. + * 璋冭瘯鐘舵�佺被鍨� 瀛楃涓� + */ +@Retention(SOURCE) +@StringDef({DebugStatusType.To_Be_Debugged, DebugStatusType.Debugging, DebugStatusType.WAIT_DELIVERED, DebugStatusType.Delivered, DebugStatusType.INITIAL_TATE}) +public @interface DebugStatusType { + //0锛氬緟璋冭瘯 + String To_Be_Debugged = "To_Be_Debugged"; + //1锛氳皟璇曚腑 + String Debugging = "Debugging"; + //3锛氬緟浜や粯 + String WAIT_DELIVERED = "WAIT_DELIVERED"; + //4锛氬凡浜や粯 + String Delivered = "Delivered"; + //5锛氬垵濮嬫�� + String INITIAL_TATE = "INITIAL_TATE"; +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/ProjectType.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/ProjectType.java new file mode 100644 index 0000000..c469677 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/ProjectType.java @@ -0,0 +1,25 @@ +package com.hdl.linkpm.sdk.project.type; + +import androidx.annotation.StringDef; + +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + +/** + * Created by jlchen on 12/3/21. + * 椤圭洰绫诲瀷 Home銆丷ealEstate銆丳ublicBuilding銆丠otel + */ +@Retention(SOURCE) +@StringDef({ProjectType.Home, ProjectType.RealEstate, ProjectType.PublicBuilding, ProjectType.Hotel}) +public @interface ProjectType { + + //0: 瀹跺眳椤圭洰 + String Home = "Home"; + //1锛氬湴浜ч」鐩� + String RealEstate = "RealEstate"; + //2锛氬叕寤洪」鐩� + String PublicBuilding = "PublicBuilding"; + //3锛氶厭搴楅」鐩� + String Hotel = "Hotel"; +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/ProtocolType.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/ProtocolType.java new file mode 100644 index 0000000..0924d25 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/project/type/ProtocolType.java @@ -0,0 +1,22 @@ +package com.hdl.linkpm.sdk.project.type; + +import androidx.annotation.StringDef; + +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + +/** + * Created by jlchen on 12/3/21. + * 鍗忚绫诲瀷 BUSPRO銆並NX銆乑IGBEE + */ +@Retention(SOURCE) +@StringDef({ProtocolType.BUSPRO, ProtocolType.KNX, ProtocolType.ZIGBEE}) +public @interface ProtocolType { + //0锛歜uspro + String BUSPRO = "BUSPRO"; + //1锛欿NX + String KNX = "KNX"; + //2锛歓IGBEE + String ZIGBEE = "ZIGBEE"; +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/HDLLinkPMScene.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/HDLLinkPMScene.java new file mode 100644 index 0000000..3356360 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/HDLLinkPMScene.java @@ -0,0 +1,82 @@ +package com.hdl.linkpm.sdk.scene; + +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.scene.bean.SceneInfoBean; +import com.hdl.linkpm.sdk.scene.controller.HDLPMSceneController; + +import java.util.List; + +/** + * Created by jlchen on 12/2/21. + */ +public class HDLLinkPMScene { + + //instance + private volatile static HDLLinkPMScene instance; + /** + * getInstance + * + * @return HDLLinkPMScene + */ + public static synchronized HDLLinkPMScene getInstance() { + if (instance == null) { + synchronized (HDLLinkPMScene.class) { + if (instance == null) { + instance = new HDLLinkPMScene(); + } + } + } + return instance; + } + + /***************5.鍦烘櫙澧炲垹鏀规煡绠$悊***************/ + /** + * 鍏ㄩ噺鍚屾鍦烘櫙 + * + * @param homeId 浣忓畢id + * @param sceneInfoBeanList 鍦烘櫙鍒楄〃 + * @param callBack + * @return + */ + public void fullSyncSceneList(String homeId, List<SceneInfoBean> sceneInfoBeanList, IDefaultCallBack callBack) { + HDLPMSceneController.getInstance().fullSyncSceneList(homeId, sceneInfoBeanList, callBack); + } + + /** + * 鑾峰彇鍦烘櫙鍒楄〃 + * + * @param homeId 浣忓畢id + * @param uid 鎴块棿uid,涓嶄紶榛樿鏌ュ叏閮� + * @param callBack + * @return + */ + public void getSceneList(String homeId, String uid, IResponseCallBack<List<SceneInfoBean>> callBack) { + HDLPMSceneController.getInstance().getSceneList(homeId, uid, callBack); + } + + /** + * 鍒犻櫎鍦烘櫙 + * + * @param homeId 浣忓畢id + * @param sids 鍦烘櫙sid鍒楄〃 + * @param callBack + * @return + */ + public void deleteScene(String homeId, List<String> sids, IDefaultCallBack callBack) { + HDLPMSceneController.getInstance().deleteScene(homeId, sids, callBack); + } + + /** + * 鎵ц鍦烘櫙 + * + * @param homeId 浣忓畢id + * @param sids 鍦烘櫙IDs + * @param callBack + * @return + */ + public void controlScene(String homeId, List<String> sids, IDefaultCallBack callBack) { + HDLPMSceneController.getInstance().controlScene(homeId, sids, callBack); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/bean/SceneInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/bean/SceneInfoBean.java new file mode 100644 index 0000000..a27d2a6 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/bean/SceneInfoBean.java @@ -0,0 +1,138 @@ +package com.hdl.linkpm.sdk.scene.bean; + +import androidx.annotation.NonNull; + +import com.hdl.linkpm.sdk.device.bean.StatusBean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by jlchen on 12/11/21. + */ +public class SceneInfoBean implements Serializable { + + private String sid;//鍦烘櫙id(鏈湴妯″紡蹇呴渶) + private String gatewayId;//鍦烘櫙id(鏈湴妯″紡蹇呴渶) + private String name;//鍦烘櫙鍚嶇О + private List<String> uids = new ArrayList<>();//鎵�灞炴埧闂� + private String delay;//鍦烘櫙寤舵椂 + private String group;//鍒嗙粍 + private List<FunctionsBean> functions = new ArrayList<>();//鎵ц鍐呭 + private String userSceneId;//浜戠鍞竴Id,涓婁紶鍚庝簯绔墠浼氭湁 + + @NonNull + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(@NonNull String sid) { + this.sid = sid; + } + + @NonNull + public String getGatewayId() { + return gatewayId == null ? "" : gatewayId; + } + + public void setGatewayId(@NonNull String gatewayId) { + this.gatewayId = gatewayId; + } + + @NonNull + public String getName() { + return name == null ? "" : name; + } + + public void setName(@NonNull String name) { + this.name = name; + } + + @NonNull + public List<String> getUids() { + if (uids == null) { + return new ArrayList<>(); + } + return uids; + } + + public void setUids(@NonNull List<String> uids) { + this.uids = uids; + } + + @NonNull + public String getDelay() { + return delay == null ? "" : delay; + } + + public void setDelay(@NonNull String delay) { + this.delay = delay; + } + + @NonNull + public String getGroup() { + return group == null ? "" : group; + } + + public void setGroup(@NonNull String group) { + this.group = group; + } + + @NonNull + public List<FunctionsBean> getFunctions() { + if (functions == null) { + return new ArrayList<>(); + } + return functions; + } + + public void setFunctions(@NonNull List<FunctionsBean> functions) { + this.functions = functions; + } + + @NonNull + public String getUserSceneId() { + return userSceneId == null ? "" : userSceneId; + } + + public void setUserSceneId(@NonNull String userSceneId) { + this.userSceneId = userSceneId; + } + + public static class FunctionsBean implements Serializable{ + private String sid;//鍔熻兘id + private List<StatusBean> status = new ArrayList<>();//鎺у埗灞炴�� + private String delay;//寤舵椂 + + @NonNull + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(@NonNull String sid) { + this.sid = sid; + } + + @NonNull + public List<StatusBean> getStatus() { + if (status == null) { + return new ArrayList<>(); + } + return status; + } + + public void setStatus(@NonNull List<StatusBean> status) { + this.status = status; + } + + @NonNull + public String getDelay() { + return delay == null ? "" : delay; + } + + public void setDelay(@NonNull String delay) { + this.delay = delay; + } + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/controller/HDLPMSceneController.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/controller/HDLPMSceneController.java new file mode 100644 index 0000000..7a02243 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/scene/controller/HDLPMSceneController.java @@ -0,0 +1,189 @@ +package com.hdl.linkpm.sdk.scene.controller; + +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.linkpm.sdk.core.api.HDLCloudHomeApi; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.scene.bean.SceneInfoBean; +import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; + +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; + +/** + * Created by jlchen on 12/13/21. + * 鍦烘櫙鐩稿叧鐨勭綉缁滆姹� + */ +public class HDLPMSceneController { + /** + * instance + */ + private volatile static HDLPMSceneController instance; + + /** + * getInstance + * + * @return HDLPMSceneController + */ + public static synchronized HDLPMSceneController getInstance() { + if (instance == null) { + synchronized (HDLPMSceneController.class) { + if (instance == null) { + instance = new HDLPMSceneController(); + } + } + } + return instance; + } + +/***************5.鍦烘櫙澧炲垹鏀规煡绠$悊***************/ + /** + * 鍏ㄩ噺鍚屾鍦烘櫙 + * + * @param homeId 浣忓畢id + * @param sceneInfoBeanList 鍦烘櫙鍒楄〃 + * @param callBack + * @return + */ + public Disposable fullSyncSceneList(String homeId, List<SceneInfoBean> sceneInfoBeanList, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("scenes", HDLGsonUtils.toJsonArray(sceneInfoBeanList)); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_SCENE_LIST_FULL_SYNC); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇鍦烘櫙鍒楄〃 + * + * @param homeId 浣忓畢id + * @param uid 鎴块棿uid,涓嶄紶榛樿鏌ュ叏閮� + * @param callBack + * @return + */ + public Disposable getSceneList(String homeId, String uid, IResponseCallBack<List<SceneInfoBean>> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("uid", uid); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_SCENE_LIST_GET); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<SceneInfoBean>>() { + @Override + public void onResponse(List<SceneInfoBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鍒犻櫎鍦烘櫙 + * + * @param homeId 浣忓畢id + * @param sids 鍦烘櫙sid鍒楄〃 + * @param callBack + * @return + */ + public Disposable deleteScene(String homeId, List<String> sids, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("sids", HDLGsonUtils.toJsonArray(sids)); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_SCENE_DELETE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鎵ц鍦烘櫙 + * + * @param homeId 浣忓畢id + * @param sids 鍦烘櫙IDs + * @param callBack + * @return + */ + public Disposable controlScene(String homeId, List<String> sids, IDefaultCallBack callBack) { + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.add("sids", HDLGsonUtils.toJsonArray(sids)); + String requestUrl = HDLCloudHomeApi.getRequestUrl(HDLCloudHomeApi.POST_SCENE_EXECUTE); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/GsonUtils.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/GsonUtils.java new file mode 100644 index 0000000..80d83e0 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/GsonUtils.java @@ -0,0 +1,243 @@ +package com.hdl.linkpm.sdk.template; + +import androidx.annotation.NonNull; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonSyntaxException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.lang.reflect.Type; + +/** + * Created by Tong on 2021/11/10. + */ +public class GsonUtils { + + private static Gson gson; + + public static <T> T copy(Object o, Class<T> type) { + return copy(o, TypeToken.get(type)); + } + + public static <T> T copy(Object o, TypeToken<T> type) { + return copy(o, type.getType()); + } + + public static <T> T copy(Object o, Type type) { + try { + Gson gson = getGson(); + return gson.fromJson(gson.toJson(o), type); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + public static <T> T fromJson(String json, Type type) { + try { + Gson gson = getGson(); + return gson.fromJson(json, type); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static <T> T fromJson(String json, Class<T> type) { + try { + Gson gson = getGson(); + return gson.fromJson(json, type); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static <T> T fromJson(String json) { + try { + Gson gson = getGson(); + return gson.fromJson(json, new TypeToken<T>() { + }.getType()); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + public static String toJson(Object object) { + try { + return getGson().toJson(object); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static JsonArray toJsonArray(Object object) { + try { + return GsonUtils.fromJson(GsonUtils.toJson(object), new TypeToken<JsonArray>() { + }.getType()); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + public static Type getType(@NonNull final Type rawType, @NonNull final Type... typeArguments) { + return TypeToken.getParameterized(rawType, typeArguments).getType(); + } + + + public static Gson getGson() { + if (gson == null) { + gson = new GsonBuilder() + .disableHtmlEscaping() + .registerTypeAdapterFactory(new NullStringToEmptyAdapterFactory()) + .registerTypeAdapter(String.class, new StringAdapter()) + .registerTypeAdapter(Integer.class, new IntegerDefaultAdapter()) + .registerTypeAdapter(Double.class, new DoubleDefaultAdapter()) + .registerTypeAdapter(Long.class, new LongDefaultAdapter()) + .create(); + } + return gson; + } + + private static class StringAdapter implements JsonSerializer<String>, JsonDeserializer<String> { + @Override + public String deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + if (json instanceof JsonPrimitive) { + return json.getAsString(); + } else { + return json.toString(); + } + } + + @Override + public JsonElement serialize(String src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src); + } + } + + + private static class IntegerDefaultAdapter implements JsonSerializer<Integer>, JsonDeserializer<Integer> { + @Override + public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + try { + if (json.getAsString().equals("") || json.getAsString().equals("null")) { + return 0; + } + } catch (Exception ignore) { + } + try { + return json.getAsInt(); + } catch (NumberFormatException e) { + throw new JsonSyntaxException(e); + } + } + + @Override + public JsonElement serialize(Integer src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src); + } + } + + private static class DoubleDefaultAdapter implements JsonSerializer<Double>, JsonDeserializer<Double> { + @Override + public Double deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + try { + if (json.getAsString().equals("") || json.getAsString().equals("null")) { + return 0.00; + } + } catch (Exception ignore) { + } + try { + return json.getAsDouble(); + } catch (NumberFormatException e) { + throw new JsonSyntaxException(e); + } + } + + @Override + public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src); + } + } + + private static class LongDefaultAdapter implements JsonSerializer<Long>, JsonDeserializer<Long> { + @Override + public Long deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + try { + if (json.getAsString().equals("") || json.getAsString().equals("null")) { + return 0L; + } + } catch (Exception ignore) { + } + try { + return json.getAsLong(); + } catch (NumberFormatException e) { + throw new JsonSyntaxException(e); + } + } + + @Override + public JsonElement serialize(Long src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src); + } + } + + private static class NullStringToEmptyAdapterFactory implements TypeAdapterFactory { + + public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { + Class<T> rawType = (Class<T>) type.getRawType(); + if (rawType != String.class) { + return null; + } + return (TypeAdapter<T>) new StringNullAdapter(); + } + } + + public static class StringNullAdapter extends TypeAdapter<String> { + + @Override + public String read(JsonReader reader) throws IOException { + if (reader.peek() == JsonToken.NULL) { + reader.nextNull(); + return ""; + } + return reader.nextString(); + } + + @Override + public void write(JsonWriter writer, String value) throws IOException { + if (value == null) { + writer.nullValue(); + return; + } + writer.value(value); + } + + } + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/HDLLinkPMTemplate.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/HDLLinkPMTemplate.java new file mode 100644 index 0000000..e95f41d --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/HDLLinkPMTemplate.java @@ -0,0 +1,630 @@ +package com.hdl.linkpm.sdk.template;/* + *create by wxr + *date 2022/1/19 + */ + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.linkpm.sdk.HDLLinkPMSdk; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.interceptor.HDLSmartHeader; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.template.bean.CloudTemplateDevice; +import com.hdl.linkpm.sdk.template.bean.CloudTemplateSpatialInfo; +import com.hdl.linkpm.sdk.template.bean.TemplateDeviceBean; +import com.hdl.linkpm.sdk.template.bean.TemplateFunctionBean; +import com.hdl.linkpm.sdk.template.bean.TemplateGatewayBean; +import com.hdl.linkpm.sdk.template.bean.TemplateListResponseBean; +import com.hdl.linkpm.sdk.template.bean.TemplateLogicBean; +import com.hdl.linkpm.sdk.template.bean.TemplateRoomPackBean; +import com.hdl.linkpm.sdk.template.bean.TemplateSceneBean; +import com.hdl.linkpm.sdk.template.bean.TemplateSecurityBean; +import com.hdl.linkpm.sdk.template.callback.ICreateTemplateCallBack; +import com.hdl.linkpm.sdk.template.callback.IGetTemplateDeviceListCallBack; +import com.hdl.linkpm.sdk.template.callback.IGetTemplateGatewayListCallBack; +import com.hdl.linkpm.sdk.template.callback.IGetTemplateSpatialInfoCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateFunctionsCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateListCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateLogicCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateScenesCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateSecurityCallBack; +import com.hdl.linkpm.sdk.template.controller.HDLTemplateController; +import com.hdl.linkpm.sdk.utils.HDLFileUtils; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; +import io.reactivex.rxjava3.functions.Consumer; +import okhttp3.ResponseBody; + +public class HDLLinkPMTemplate { + + /** + * instance + */ + private volatile static HDLLinkPMTemplate instance; + + /** + * getInstance + * + * @return HDLPMTemplateController + */ + public static synchronized HDLLinkPMTemplate getInstance() { + if (instance == null) { + synchronized (HDLLinkPMTemplate.class) { + if (instance == null) { + instance = new HDLLinkPMTemplate(); + } + } + } + return instance; + } + + /** + * 鍒涘缓妯℃澘 + * @param templateName 妯℃澘鍚嶇О + * @param communityCode 绀惧尯缂栫爜 + * @param houseLayoutId 鎴峰瀷id (瑕佽皟鐢ㄦ埛鍨嬪垪琛ㄧ殑鎺ュ彛) + * @param templateDesc 妯℃澘鎻忚堪 + * @param callBack 鍥炶皟 + */ + public void CreateTemplate(String templateName,String communityCode,String houseLayoutId,String templateDesc,ICreateTemplateCallBack callBack) { + HDLTemplateController.getInstance().CreateTemplate(templateName, communityCode, houseLayoutId, templateDesc, new ICreateTemplateCallBack() { + @Override + public void onSuccess(String templateId) { + callBack.onSuccess(templateId); + } + + @Override + public void onFailure(HDLException error) { + callBack.onFailure(error); + } + }); + } + + /** + * 娣诲姞璁惧(鍏ㄩ噺) + * @param templateExtendsId + * @param beans + * @param callBack + */ + public void UpdateTemplateDevices(String templateExtendsId,List<TemplateDeviceBean> beans,IDefaultCallBack callBack){ + HDLTemplateController.getInstance().UpdateTemplateDevices(templateExtendsId, beans, new IDefaultCallBack() { + @Override + public void onSuccess() { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 涓婁紶妯℃澘zb鏁版嵁鏂囦欢鏂囦欢 + * + * @param templateExtendsId 妯℃澘ID + * @param file 涓婁紶鐨勬枃浠� + * @param callBack + * @return + */ + public Disposable TemplateZbFileUpload(String templateExtendsId, File file, IDefaultCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + "/iot-cloud/debug/backup/file/zigbeeDataUpload?templateExtendsId=" + templateExtendsId; + return HxHttp.builder() + .file(file, "file") + .url(requestUrl) + .build() + .upload() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { +// FileUtils.deleteFile(file);//涓嶇敤鍒犳帀鏈湴鏂囦欢 2022-09-28 17:24:06 + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLFileUtils.deleteFile(file); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 涓嬭浇妯℃澘zb鏁版嵁鏂囦欢鏂囦欢 + */ + public static boolean saveTempalteZbFile(ResponseBody zipData,File file) { + // 濡傛灉瀛樺湪灏卞厛鍒犻櫎鏁版嵁锛屾暟鎹細杩藉姞 + if(file.exists()){ + file.delete(); + file.deleteOnExit(); + } + InputStream is = null; + byte[] buf = new byte[4096]; + int len = 0; + FileOutputStream fos = null; + try { + is = zipData.byteStream(); + long total = zipData.contentLength(); + fos = new FileOutputStream(file); + long sum = 0; + while ((len = is.read(buf)) != -1) { + fos.write(buf, 0, len); + sum += len; + } + fos.flush(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + try { + if (is != null) + is.close(); + } catch (IOException e) { + } + try { + if (fos != null) + fos.close(); + } catch (IOException e) { + } + } + } + + /** + * 鑾峰彇妯℃澘zb鏁版嵁鏂囦欢Url + * @return + */ + public Disposable getTempalteZbFileUrl(String templateExtendsId,File file, IDefaultCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + "/iot-cloud/debug/backup/file/zigbeeDataNewestUrl"; + + + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String url) { + if (url == null) { + callBack.onSuccess(); + } else { + if (callBack != null) { + downloadTempalteZbFile(url, file, new IDefaultCallBack() { + @Override + public void onSuccess() { + callBack.onSuccess(); + + } + + @Override + public void onFailure(HDLException error) { + callBack.onFailure(error); + } + }); + } + } + } + @Override + public void onFailure(HDLException e) { + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 涓嬭浇妯℃澘zb鏁版嵁鏂囦欢鏂囦欢 + * @param callBack + * @return + */ + public Disposable downloadTempalteZbFile(String url,File file, IDefaultCallBack callBack) { + return HxHttp.builder() + .url(url) + .headers(HDLSmartHeader.IGNORE_SIGN_HEADER,1) + .build() + .download() + .subscribe(new Consumer<ResponseBody>() { + @Override + public void accept(ResponseBody responseBody) throws Exception { + //缃戠粶璇锋眰鎴愬姛锛岃鍙栨枃浠朵繚瀛樺埌sd鍗� +// callBack.onSuccess(responseBody); + //淇濆瓨鏂囦欢 +// File file = new File(getUserFilesPath() + "/" + templateBean.getTemplateExtendsId()); + + boolean saveResult = saveTempalteZbFile(responseBody,file); + if(saveResult) { + callBack.onSuccess(); + }else { + callBack.onFailure(new HDLException(0,"")); + } + } + }, new Consumer<Throwable>() { + @Override + public void accept(Throwable throwable) throws Exception { + /** + * 缃戠粶璇锋眰澶辫触 + * 鍏蜂綋鍙互鑷繁瀹炵幇 + */ + callBack.onFailure(new HDLException(404,"")); + } + }); + } + + + /** + * 鑾峰彇妯℃澘鍒楄〃 + * @param callBack + */ + public void GetTemplateList(int pageNo, int pageSize, ITemplateListCallBack callBack) { + HDLTemplateController.getInstance().GetTemplateList(pageNo,pageSize,new ITemplateListCallBack() { + @Override + public void onSuccess(TemplateListResponseBean templateListResponseBeans) { + callBack.onSuccess(templateListResponseBeans); + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鍒犻櫎妯℃澘 + * @param templateExtendsId 妯℃澘ID + * @param callBack + */ + public void DeleteTemplate(String templateExtendsId,IDefaultCallBack callBack){ + HDLTemplateController.getInstance().DeleteTemplate(templateExtendsId, new IDefaultCallBack() { + @Override + public void onSuccess() { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鏇存柊缃戝叧鏁版嵁(鍏ㄩ噺) + */ + public void UpdateTemplateGateway(String templateExtendsId , List<TemplateGatewayBean> gatewayBeans, + IDefaultCallBack callBack){ + HDLTemplateController.getInstance().UpdateTemplateGateway(templateExtendsId, gatewayBeans, new IDefaultCallBack() { + @Override + public void onSuccess() { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鏇存柊鎴块棿锛堟ゼ灞傦級淇℃伅(鍏ㄩ噺) + * @param templateExtendsId + * @param rooms + * @param callBack + * @return + */ + public void UpdateTemplateRoom(String templateExtendsId ,List<TemplateRoomPackBean.TemplateRoomInfoBean> rooms, + IDefaultCallBack callBack){ + HDLTemplateController.getInstance().UpdateTemplateRoom(templateExtendsId, rooms, new IDefaultCallBack() { + @Override + public void onSuccess() { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 娣诲姞鍔熻兘(鍏ㄩ噺) + * @param templateExtendsId 妯℃澘鍚嶇О + * @param functionInfoList 鍔熻兘鍒楄〃 + * @param callBack 鍥炶皟 + */ + public void UpdateTemplateFunctions(String templateExtendsId, List<TemplateFunctionBean> functionInfoList, + IDefaultCallBack callBack){ + HDLTemplateController.getInstance().UpdateTemplateFunctions(templateExtendsId, functionInfoList, new IDefaultCallBack() { + @Override + public void onSuccess() { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鏇存柊妯℃澘鍦烘櫙(鍏ㄩ噺) + * @param templateExtendsId + * @param sceneBeans + * @param callBack + */ + public void UpdataTemplateScenes(String templateExtendsId, List<TemplateSceneBean> sceneBeans, + IDefaultCallBack callBack){ + HDLTemplateController.getInstance().UpdataTemplateScenes(templateExtendsId, sceneBeans, new IDefaultCallBack() { + @Override + public void onSuccess() { + if(callBack != null){ + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException error) { + if(callBack != null){ + callBack.onFailure(error); + } + } + }); + } + + /** + * 鏇存柊妯℃澘鑷姩鍖� (鍏ㄩ噺) + * @param templateExtendsId + * @param logicBeansJson + * @param callBack + */ + public void UpdataTemplateLogic(String templateExtendsId, JsonElement logicBeansJson,// List<TemplateLogicBean> logicBeans, + IDefaultCallBack callBack){ + HDLTemplateController.getInstance().UpdataTemplateLogic(templateExtendsId, logicBeansJson, new IDefaultCallBack() { + @Override + public void onSuccess() { + if(callBack != null){ + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException error) { + if(callBack != null){ + callBack.onFailure(error); + } + } + }); + } + + /** + * 鏇存柊妯℃澘瀹夐槻 (鍏ㄩ噺) + * @param templateExtendsId + * @param securityInfos + * @param callBack + */ + public void UpdataTemplateSecurity(String templateExtendsId, JsonElement securityInfos ,IDefaultCallBack callBack ){ + HDLTemplateController.getInstance().UpdataTemplateSecurity(templateExtendsId, securityInfos, new IDefaultCallBack() { + @Override + public void onSuccess() { + if(callBack != null){ + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException error) { + if(callBack != null){ + callBack.onFailure(error); + } + } + }); + } + + /** + * 鑾峰彇鍖哄煙淇℃伅 + * @param templateExtendsId + * @param callBack + */ + public void GetTemplateAreaSpatialInfo(String templateExtendsId ,IGetTemplateSpatialInfoCallBack callBack){ + HDLTemplateController.getInstance().GetTemplateAreaSpatialInfo(templateExtendsId, new IGetTemplateSpatialInfoCallBack() { + @Override + public void onSuccess(List<CloudTemplateSpatialInfo> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鑾峰彇缃戝叧鍒楄〃 + * @param id + * @param callBack + */ + public void GetTemplateGatewayList(String id, IGetTemplateGatewayListCallBack callBack){ + HDLTemplateController.getInstance().GetTemplateGatewayList(id, new IGetTemplateGatewayListCallBack() { + @Override + public void onSuccess(List<TemplateGatewayBean> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鑾峰彇璁惧淇℃伅 + * @param templateId + * @param callBack + */ + public void GetTemplateDeviceList(String templateId,IGetTemplateDeviceListCallBack callBack){ + HDLTemplateController.getInstance().GetTemplateDeviceList(templateId, new IGetTemplateDeviceListCallBack() { + @Override + public void onSuccess(List<CloudTemplateDevice> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鑾峰彇鍔熻兘鍒楄〃 + * @param templateExtendsId + * @param callBack + */ + public void GetTemplateFunctions(String templateExtendsId , ITemplateFunctionsCallBack callBack){ + HDLTemplateController.getInstance().GetTemplateFunctions(templateExtendsId, new ITemplateFunctionsCallBack() { + @Override + public void onSuccess(List<TemplateFunctionBean> templateFunctionBean) { + if (callBack != null) { + callBack.onSuccess(templateFunctionBean); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鑾峰彇鍦烘櫙鍒楄〃 + * @param templateExtendsId + * @param callBack + */ + public void GetTemplateScenes(String templateExtendsId , ITemplateScenesCallBack callBack){ + HDLTemplateController.getInstance().GetTemplateScenes(templateExtendsId, new ITemplateScenesCallBack() { + @Override + public void onSuccess(List<TemplateSceneBean> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鑾峰彇瀹夐槻鍒楄〃 + * @param templateExtendsId + * @param callBack + */ + public void GetTemplateSecurity(String templateExtendsId , ITemplateSecurityCallBack callBack){ + HDLTemplateController.getInstance().GetTemplateSecurity(templateExtendsId, new ITemplateSecurityCallBack() { + @Override + public void onSuccess(List<TemplateSecurityBean> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + } + ); + } + + /** + * 鑾峰彇閫昏緫鍒楄〃 + * @param templateExtendsId + * @param callBack + */ + public void GetTemplateLogic(String templateExtendsId ,ITemplateLogicCallBack callBack){ + HDLTemplateController.getInstance().GetTemplateLogic(templateExtendsId, new ITemplateLogicCallBack() { + @Override + public void onSuccess(List<TemplateLogicBean> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + } + ); + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/CloudTemplateDevice.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/CloudTemplateDevice.java new file mode 100644 index 0000000..640dd8a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/CloudTemplateDevice.java @@ -0,0 +1,144 @@ +package com.hdl.linkpm.sdk.template.bean;/* + *create by wxr + *date 2022/2/11 + */ + +import java.io.Serializable; + +public class CloudTemplateDevice implements Serializable { + private String templateOidId;// 妯℃澘璁惧id (浜戠id) string + private String templateExtendsId;// 瀵瑰簲鐨勬ā鏉縤d long + private String templateDeviceOidModelId;// model id 妯℃澘璁惧鍨嬪彿 string + private String templateDeviceOidImageId;// 妯℃澘璁惧闀滃儚id string + private String firmwareVersion;// 鍥轰欢鐗堟湰 string + private String hardwareVersion;// 纭欢鐗堟湰 string + private String serialNumber;// 璁惧搴忓垪鍙� string + private String templateDeviceOidAddr;// 鐗╃悊璁惧 mac string + private String templateDeviceOidManufacturer;// 璁惧鍒堕�犲晢 string + private String templateDeviceOidName;// 妯℃澘璁惧鍚嶇О string + private String templateDeviceOidDesc; // 妯℃澘璁惧鎻忚堪 string + private String templateRoomId; // 妯℃澘鎴块棿id string + private String templateOidIcon; // 妯℃澘璁惧鍥剧墖 string + private String extInfo; //-- 瀛樺偍璁惧閲岄潰鐨勫姛鑳藉垪琛紝鐩墠璁ㄨ浣跨敤 json 浼犻�� (涓�鏉℃暟鎹氨鏄涓寜閿紝琛ㄧず涓�涓户鐢靛櫒) string + private String linkOid; + + public String getLinkOid() { + return linkOid; + } + + public void setLinkOid(String linkOid) { + this.linkOid = linkOid; + } + + public String getTemplateOidId() { + return templateOidId == null ? "" : templateOidId; + } + + public void setTemplateOidId(String templateOidId) { + this.templateOidId = templateOidId; + } + + public String getTemplateExtendsId() { + return templateExtendsId == null ? "" : templateExtendsId; + } + + public void setTemplateExtendsId(String templateExtendsId) { + this.templateExtendsId = templateExtendsId; + } + + public String getTemplateDeviceOidModelId() { + return templateDeviceOidModelId == null ? "" : templateDeviceOidModelId; + } + + public void setTemplateDeviceOidModelId(String templateDeviceOidModelId) { + this.templateDeviceOidModelId = templateDeviceOidModelId; + } + + public String getTemplateDeviceOidImageId() { + return templateDeviceOidImageId == null ? "" : templateDeviceOidImageId; + } + + public void setTemplateDeviceOidImageId(String templateDeviceOidImageId) { + this.templateDeviceOidImageId = templateDeviceOidImageId; + } + + public String getFirmwareVersion() { + return firmwareVersion == null ? "" : firmwareVersion; + } + + public void setFirmwareVersion(String firmwareVersion) { + this.firmwareVersion = firmwareVersion; + } + + public String getHardwareVersion() { + return hardwareVersion == null ? "" : hardwareVersion; + } + + public void setHardwareVersion(String hardwareVersion) { + this.hardwareVersion = hardwareVersion; + } + + public String getSerialNumber() { + return serialNumber == null ? "" : serialNumber; + } + + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } + + public String getTemplateDeviceOidAddr() { + return templateDeviceOidAddr == null ? "" : templateDeviceOidAddr; + } + + public void setTemplateDeviceOidAddr(String templateDeviceOidAddr) { + this.templateDeviceOidAddr = templateDeviceOidAddr; + } + + public String getTemplateDeviceOidManufacturer() { + return templateDeviceOidManufacturer == null ? "" : templateDeviceOidManufacturer; + } + + public void setTemplateDeviceOidManufacturer(String templateDeviceOidManufacturer) { + this.templateDeviceOidManufacturer = templateDeviceOidManufacturer; + } + + public String getTemplateDeviceOidName() { + return templateDeviceOidName == null ? "" : templateDeviceOidName; + } + + public void setTemplateDeviceOidName(String templateDeviceOidName) { + this.templateDeviceOidName = templateDeviceOidName; + } + + public String getTemplateDeviceOidDesc() { + return templateDeviceOidDesc == null ? "" : templateDeviceOidDesc; + } + + public void setTemplateDeviceOidDesc(String templateDeviceOidDesc) { + this.templateDeviceOidDesc = templateDeviceOidDesc; + } + + public String getTemplateRoomId() { + return templateRoomId == null ? "" : templateRoomId; + } + + public void setTemplateRoomId(String templateRoomId) { + this.templateRoomId = templateRoomId; + } + + public String getTemplateOidIcon() { + return templateOidIcon == null ? "" : templateOidIcon; + } + + public void setTemplateOidIcon(String templateOidIcon) { + this.templateOidIcon = templateOidIcon; + } + + public String getExtInfo() { + return extInfo == null ? "" : extInfo; + } + + public void setExtInfo(String extInfo) { + this.extInfo = extInfo; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/CloudTemplateSpatialInfo.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/CloudTemplateSpatialInfo.java new file mode 100644 index 0000000..f3d47bb --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/CloudTemplateSpatialInfo.java @@ -0,0 +1,79 @@ +package com.hdl.linkpm.sdk.template.bean;/* + *create by wxr + *date 2022/2/11 + */ + +import java.io.Serializable; + +public class CloudTemplateSpatialInfo implements Serializable { +// -- templateRoomId 鎴块棿浜戠id string + private String templateRoomId; +//-- templateExtendsId 妯℃澘id string + private String templateExtendsId; +//-- templateRoomName 妯℃澘鎴块棿鍚嶇О string + private String templateRoomName; +//-- templateRoomType 妯℃澘鎴块棿绫诲瀷 string + private String templateRoomType; +//-- templateRoomImage 妯℃澘鎴块棿鍥剧墖 string + private String templateRoomImage; +//-- parentId 妯℃澘鎴块棿瀵瑰簲妤煎眰id string + private String parentId; +//-- uid uid string + private String uid; + + public String getTemplateRoomId() { + return templateRoomId == null ? "" : templateRoomId; + } + + public void setTemplateRoomId(String templateRoomId) { + this.templateRoomId = templateRoomId; + } + + public String getTemplateExtendsId() { + return templateExtendsId == null ? "" : templateExtendsId; + } + + public void setTemplateExtendsId(String templateExtendsId) { + this.templateExtendsId = templateExtendsId; + } + + public String getTemplateRoomName() { + return templateRoomName == null ? "" : templateRoomName; + } + + public void setTemplateRoomName(String templateRoomName) { + this.templateRoomName = templateRoomName; + } + + public String getTemplateRoomType() { + return templateRoomType == null ? "" : templateRoomType; + } + + public void setTemplateRoomType(String templateRoomType) { + this.templateRoomType = templateRoomType; + } + + public String getTemplateRoomImage() { + return templateRoomImage == null ? "" : templateRoomImage; + } + + public void setTemplateRoomImage(String templateRoomImage) { + this.templateRoomImage = templateRoomImage; + } + + public String getParentId() { + return parentId == null ? "" : parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public String getUid() { + return uid == null ? "" : uid; + } + + public void setUid(String uid) { + this.uid = uid; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateBean.java new file mode 100644 index 0000000..064cb3d --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateBean.java @@ -0,0 +1,314 @@ + +package com.hdl.linkpm.sdk.template.bean; +/* + *create by wxr + *date 2022/1/23 + */ + +import com.hdl.linkpm.sdk.template.GsonUtils; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + +public class TemplateBean implements Serializable,Cloneable { + + @Override + public TemplateBean clone() throws CloneNotSupportedException { + try { + TemplateBean tt = GsonUtils.copy(this, TemplateBean.class); + if (tt != null) { + return tt; + } + } catch (Exception e) { + e.printStackTrace(); + return (TemplateBean) super.clone(); + } + return (TemplateBean) super.clone(); + } + + + public String getDebugFlag() { + return debugFlag; + } + + public void setDebugFlag(String debugFlag) { + this.debugFlag = debugFlag; + } + + private String debugFlag ; + + private String templateExtendsId;// 妯℃澘id string + private String templateName;// 妯℃澘鍚嶇О string + private String projectType;// 椤圭洰绫诲瀷 string + private String houseLayoutId;// 鎴峰瀷id string + private String houseLayoutName;// 鎴峰瀷鍚嶇О string + private String templateSourcePlatform;// 鏉ユ簮 string + private String templateSourceDesc;// 搴旂敤杞欢 string + private String modifyTime;// 鏇存柊鏃堕棿 long + + +// /** +// * 宸茬粡鍖归厤瀹為檯璁惧杩囩殑妯℃澘 +// */ +// List<TemplateDeviceBean> alreadyMatchedTemplateList = new ArrayList<>(); +// +// public List<TemplateDeviceBean> getAlreadyMatchedTemplateList() { +// return alreadyMatchedTemplateList; +// } +// +// public void setAlreadyMatchedTemplateList(List<TemplateDeviceBean> alreadyMatchedTemplateList) { +// this.alreadyMatchedTemplateList = alreadyMatchedTemplateList; +// } + /** + * 鐢ㄦ潵璁板綍鐪熷疄璁惧涓媠id瀵瑰簲妯℃澘鍔熻兘鐨剆id + */ + private HashMap<String,String> sidMap = new HashMap<>(); + + public HashMap<String, String> getSidMap() { + return sidMap; + } + + public void setSidMap(HashMap<String, String> sidMap) { + this.sidMap = sidMap; + } + +// /** +// * 宸茬粡閰嶇疆鐨勮澶囩殑mac鍒楄〃 鏂扮殑鏂瑰紡涓嶉渶瑕佸湪杩欓噷璁板綍锛� 鍦ㄥ叾浠栧湴鏂硅褰� 2022骞�5鏈�22鏃� 22:40:33 +// */ +// private List<String> matchMacList = new ArrayList<>(); +// +// public List<String> getMatchMacList() { +// if (matchMacList == null) { +// return new ArrayList<>(); +// } +// return matchMacList; +// } + + /** + * 淇濆瓨鏈湴鏃朵娇鐢ㄧ殑ID + */ + private String localId; + public String getLocalId() { + if(localId == null || localId.equals("")){ + localId = UUID.randomUUID().toString().replace("-",""); + } + return localId; + } + + public void setLocalId(String localId) { + this.localId = localId; + } + + + public String getTemplateExtendsId() { + return templateExtendsId == null ? "" : templateExtendsId; + } + public void setTemplateExtendsId(String templateExtendsId) { + this.templateExtendsId = templateExtendsId; + } + + public String getTemplateName() { + return templateName == null ? "" : templateName; + } + + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + public String getProjectType() { + return projectType == null ? "" : projectType; + } + + public void setProjectType(String projectType) { + this.projectType = projectType; + } + + public String getHouseLayoutId() { + return houseLayoutId == null ? "" : houseLayoutId; + } + + public void setHouseLayoutId(String houseLayoutId) { + this.houseLayoutId = houseLayoutId; + } + + public String getHouseLayoutName() { + return houseLayoutName == null ? "" : houseLayoutName; + } + + public void setHouseLayoutName(String houseLayoutName) { + this.houseLayoutName = houseLayoutName; + } + + public String getTemplateSourcePlatform() { + return templateSourcePlatform == null ? "" : templateSourcePlatform; + } + + public void setTemplateSourcePlatform(String templateSourcePlatform) { + this.templateSourcePlatform = templateSourcePlatform; + } + + public String getTemplateSourceDesc() { + return templateSourceDesc == null ? "" : templateSourceDesc; + } + + public void setTemplateSourceDesc(String templateSourceDesc) { + this.templateSourceDesc = templateSourceDesc; + } + + public String getModifyTime() { + return modifyTime == null ? "" : modifyTime; + } + + public void setModifyTime(String modifyTime) { + this.modifyTime = modifyTime; + } + + private boolean inLocal = false; + private boolean inCloud = false; + + public boolean isInLocal() { + return inLocal; + } + + public void setInLocal(boolean inLocal) { + this.inLocal = inLocal; + } + + public boolean isInCloud() { + return inCloud; + } + + public void setInCloud(boolean inCloud) { + this.inCloud = inCloud; + } + + //缃戝叧娑堟伅 + private List<TemplateGatewayBean> gatewayList = new ArrayList<>(); + //鎴块棿淇℃伅 + private List<TemplateRoomPackBean.TemplateRoomInfoBean> spatilaInfo = new ArrayList<>(); + //璁惧淇℃伅 + private List<TemplateDeviceBean> deviceList = new ArrayList<>(); + //鍔熻兘淇℃伅 + private List<TemplateFunctionBean> functionList = new ArrayList<>(); + //鍦烘櫙淇℃伅 + private List<TemplateSceneBean> sceneList = new ArrayList<>(); + //瀹夐槻淇℃伅 + private List<TemplateSecurityBean> securityList = new ArrayList<>(); + + //鑷姩鍖栦俊鎭� + private List<TemplateLogicBean> logicList = new ArrayList<>(); + + + public List<TemplateGatewayBean> getGatewayList() { + if (gatewayList == null) { + return new ArrayList<>(); + } + return gatewayList; + } + + public void setGatewayList(List<TemplateGatewayBean> gatewayList) { + this.gatewayList = gatewayList; + } + + public List<TemplateRoomPackBean.TemplateRoomInfoBean> getSpatilaInfo() { + if (spatilaInfo == null) { + return new ArrayList<>(); + } + return spatilaInfo; + } + + public List<TemplateRoomPackBean.TemplateRoomInfoBean> getRoomList() { + List<TemplateRoomPackBean.TemplateRoomInfoBean> roomInfoBeans = new ArrayList<>(); + for (TemplateRoomPackBean.TemplateRoomInfoBean bean : getSpatilaInfo()) { +// if (bean.getRoomType().equals("ROOM")) + { + roomInfoBeans.add((bean)); + } + } + return roomInfoBeans; + } + + public List<TemplateRoomPackBean.TemplateRoomInfoBean> getFloorList() { + List<TemplateRoomPackBean.TemplateRoomInfoBean> roomInfoBeans = new ArrayList<>(); + for (TemplateRoomPackBean.TemplateRoomInfoBean bean : getSpatilaInfo()) { + if (bean.getRoomType().equals("FLOOR")) + { + roomInfoBeans.add((bean)); + } + } + return roomInfoBeans; + } + + public void setSpatilaInfo(List<TemplateRoomPackBean.TemplateRoomInfoBean> spatilaInfo) { + this.spatilaInfo = spatilaInfo; + } + + /** + * 妯℃澘璁惧鍒楄〃 + * @return 妯℃澘璁惧鍒楄〃 + */ + public List<TemplateDeviceBean> getDeviceList() { + if (deviceList == null) { + return new ArrayList<>(); + } + return deviceList; + } + + public void setDeviceList(List<TemplateDeviceBean> deviceList) { + this.deviceList = deviceList; + } + + public List<TemplateFunctionBean> getFunctionList() { + if (functionList == null) { + return new ArrayList<>(); + } + return functionList; + } + + public void setFunctionList(List<TemplateFunctionBean> functionList) { + this.functionList = functionList; + } + + public List<TemplateSceneBean> getSceneList() { + if (sceneList == null) { + return new ArrayList<>(); + } + return sceneList; + } + + public void setSceneList(List<TemplateSceneBean> sceneList) { + this.sceneList = sceneList; + } + + public List<TemplateLogicBean> getLogicList() { + if (logicList == null) { + return new ArrayList<>(); + } + return logicList; + } + + public void setLogicList(List<TemplateLogicBean> logicList) { + this.logicList = logicList; + } + + + public List<TemplateSecurityBean> getSecurityList() { + if (securityList == null) { + return new ArrayList<>(); + } + return securityList; + } + + public void setSecurityList(List<TemplateSecurityBean> securityList) { + this.securityList = securityList; + } + + + + + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateDeviceBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateDeviceBean.java new file mode 100644 index 0000000..5397f61 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateDeviceBean.java Binary files differ diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateDeviceExtInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateDeviceExtInfoBean.java new file mode 100644 index 0000000..22d48f9 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateDeviceExtInfoBean.java @@ -0,0 +1,35 @@ +package com.hdl.linkpm.sdk.template.bean;/* + *create by wxr + *date 2022/3/1 + */ + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class TemplateDeviceExtInfoBean implements Serializable { + private List<String> deviceDir = new ArrayList<>(); + + private HashMap<String,String> deviceCommand = new HashMap<>(); + + public List<String> getDeviceDir() { + if (deviceDir == null) { + return new ArrayList<>(); + } + return deviceDir; + } + + public void setDeviceDir(List<String> deviceDir) { + this.deviceDir = deviceDir; + } + + public HashMap<String, String> getDeviceCommand() { + return deviceCommand; + } + + public void setDeviceCommand(HashMap<String, String> deviceCommand) { + this.deviceCommand = deviceCommand; + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateFunctionBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateFunctionBean.java new file mode 100644 index 0000000..cd7f4ff --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateFunctionBean.java @@ -0,0 +1,172 @@ +package com.hdl.linkpm.sdk.template.bean;/* + *create by wxr + *date 2022/1/19 + */ + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; + +public class TemplateFunctionBean implements Serializable { + //鎴块棿 + private List<String> uids = new ArrayList<>(); + //鍔熻兘Id + private String sid; + //鍔熻兘鍚嶇О + private String name; + //鍔熻兘绫诲瀷 + private String spk; + //璁惧瀵瑰簲鐨刼id + private String oid; + //鐗╃悊璁惧(妯″潡)鍨嬪彿 false闈炲繀椤� + private String omodel; + //-- extend 鎵╁睍淇℃伅 false闈炲繀椤� + private String extend; + + public List<String> getUids() { + return uids; + } + + public void setUids(List<String> uids) { + this.uids = uids; + } + + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSpk() { + return spk == null ? "" : spk; + } + + public void setSpk(String spk) { + this.spk = spk; + } + + public String getOid() { + return oid == null ? "" : oid; + } + + public void setOid(String oid) { + this.oid = oid; + } + + public String getOmodel() { + return omodel == null ? "" : omodel; + } + + public void setOmodel(String omodel) { + this.omodel = omodel; + } + + public String getExtend() { + return extend == null ? "" : extend; + } + + public void setExtend(String extend) { + this.extend = extend; + } + + public List<TemplateFunctionAttribute> getAttributes() { + if (attributes == null) { + return new ArrayList<>(); + } + return attributes; + } + + public void setAttributes(List<TemplateFunctionAttribute> attributes) { + this.attributes = attributes; + } + + //灞炴�� false闈炲繀椤� + private List<TemplateFunctionAttribute> attributes = new ArrayList<>(); + + + /** + * 鍔熻兘灞炴�у璞� + */ + public static class TemplateFunctionAttribute implements Serializable { + //---- key 鏍囪瘑 false闈炲繀椤� + private String key; + //---- data_type 鏁版嵁绫诲瀷 false闈炲繀椤� + private String data_type; + //---- value 鍊� false闈炲繀椤� + private List<String> value = new ArrayList<>(); + //---- max 鏈�澶� false闈炲繀椤� + private String max; + //---- min 鏈�灏� false闈炲繀椤� + private String min; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getData_type() { + return data_type; + } + + public void setData_type(String data_type) { + this.data_type = data_type; + } + + public List<String> getValue() { + if (value == null) { + return new ArrayList<>(); + } + return value; + } + + public void setValue(@NonNull List<String> value) { + this.value = value; + } + + public String getMax() { + return max; + } + + public void setMax(String max) { + this.max = max; + } + + public String getMin() { + return min; + } + + public void setMin(String min) { + this.min = min; + } + + public String getSort() { + return sort; + } + + public void setSort(String sort) { + this.sort = sort; + } + + //---- sort 鎺掑簭 false闈炲繀椤� + private String sort; + + } + + +} + diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateGatewayBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateGatewayBean.java new file mode 100644 index 0000000..b2de95e --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateGatewayBean.java @@ -0,0 +1,95 @@ +package com.hdl.linkpm.sdk.template.bean;/* + *create by wxr + *date 2022/2/15 + */ + +import java.io.Serializable; + +public class TemplateGatewayBean implements Serializable { + + /** + * 缃戝叧鍨嬪彿 + */ + private String deviceModel; + /** + * 缃戝叧澶囨敞 + */ + private String deviceName; + /** + * 缃戝叧oid + */ + private String oid; + /** + * 鏄惁涓荤綉鍏� true false + */ + private String master; + /** + * 鏄惁鍔犲瘑 + */ + private boolean isLocalEncrypt; + /** + * 鏄惁鏈湴缃戝叧 + */ + private boolean isLocalGateWay; + + /** + * 鐪熷疄鐨勮澶噈ac + */ + private String realDeviceMac = ""; + + public String getRealDeviceMac() { + return realDeviceMac == null ? "" : realDeviceMac; + } + + public void setRealDeviceMac(String realDeviceMac) { + this.realDeviceMac = realDeviceMac; + } + + public String getDeviceModel() { + return deviceModel == null ? "" : deviceModel; + } + + public void setDeviceModel(String deviceModel) { + this.deviceModel = deviceModel; + } + + public String getDeviceName() { + return deviceName == null ? "" : deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getOid() { + return oid == null ? "" : oid; + } + + public void setOid(String oid) { + this.oid = oid; + } + + public String getMaster() { + return master == null ? "" : master; + } + + public void setMaster(String master) { + this.master = master; + } + + public boolean isLocalEncrypt() { + return isLocalEncrypt; + } + + public void setLocalEncrypt(boolean localEncrypt) { + isLocalEncrypt = localEncrypt; + } + + public boolean isLocalGateWay() { + return isLocalGateWay; + } + + public void setLocalGateWay(boolean localGateWay) { + isLocalGateWay = localGateWay; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateListResponseBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateListResponseBean.java new file mode 100644 index 0000000..06eac28 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateListResponseBean.java @@ -0,0 +1,59 @@ +package com.hdl.linkpm.sdk.template.bean; +/* + *create by wxr + *date 2022/1/23 + */ + +import java.util.ArrayList; +import java.util.List; + +public class TemplateListResponseBean { + private List<TemplateBean> list = new ArrayList<>(); + private int totalCount; + private int totalPage; + private int pageNo; + private int pageSize; + + public List<TemplateBean> getList() { + if (list == null) { + return new ArrayList<>(); + } + return list; + } + + public void setList(List<TemplateBean> list) { + this.list = list; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + public int getTotalPage() { + return totalPage; + } + + public void setTotalPage(int totalPage) { + this.totalPage = totalPage; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateLogicBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateLogicBean.java new file mode 100644 index 0000000..0950b5a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateLogicBean.java @@ -0,0 +1,338 @@ +package com.hdl.linkpm.sdk.template.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import androidx.annotation.NonNull; + +public class TemplateLogicBean implements Serializable { + //-- sid 鑷姩鍖栬澶囩 true string + private String sid; + //-- name 鑷姩鍖栧悕绉� true string + private String name; + //-- image 鍦烘櫙鍥剧墖 false string + private String image; + //-- tag 鍦烘櫙绫诲瀷 false string + private String tag; + //-- conditionLable 鑷姩鍖栨爣绛� false array<string> + private ArrayList<String> conditionLable = new ArrayList<>(); + //-- push_customer_message 鑷姩鍖栨墽琛屾帹閫佷俊鎭� false string + private String push_customer_message; + //-- relation 瑙﹀彂鏉′欢鍏崇郴 false array<long> + private String relation ; + //-- enable 鍚敤绂佺敤 true string + private boolean enable; + //-- cycle 鎵ц鍛ㄦ湡 false string + private TemplateLogicCycleBean cycle; + //---- type 閿� false string + //---- value 鍊� false array<string> + + //-- input 鑷姩鍖栬Е鍙戞潯浠� false array<object> + private List<TemplateLogicInputBean> input = new ArrayList<>(); + //---- sid sid false string + //---- condition_type 鏉′欢绫诲瀷 false string + //---- condition 鏉′欢 false array<object> + //------ key 鏉′欢key false string + //------ comparator 姣旇緝 false string + //------ data_type 鏁版嵁绫诲瀷 false string + //------ value 鏉′欢鍊� false string + + //-- output 鑷姩鍖栨墽琛屽姩浣� false string + private ArrayList<TemplateLogicOutputBean> output = new ArrayList<>(); + //---- sid sid false string + //---- target_type 鐩爣绫诲瀷 false string + //----- status 鍔ㄤ綔 false array<object> + //------- key 閿� false string + //------- value 鍊� false string + + + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImage() { + return image == null ? "" : image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getTag() { + return tag == null ? "" : tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public ArrayList<String> getConditionLable() { + if (conditionLable == null) { + return new ArrayList<>(); + } + return conditionLable; + } + + public void setConditionLable(ArrayList<String> conditionLable) { + this.conditionLable = conditionLable; + } + + public String getPush_customer_message() { + return push_customer_message == null ? "" : push_customer_message; + } + + public void setPush_customer_message(String push_customer_message) { + this.push_customer_message = push_customer_message; + } + + public String getRelation() { + return relation; + } + + public void setRelation(String relation) { + this.relation = relation; + } + + public boolean isEnable() { + return enable; + } + + public void setEnable(boolean enable) { + this.enable = enable; + } + + public TemplateLogicCycleBean getCycle() { + return cycle; + } + + public void setCycle(TemplateLogicCycleBean cycle) { + this.cycle = cycle; + } + + public List<TemplateLogicInputBean> getInput() { + if (input == null) { + return new ArrayList<>(); + } + return input; + } + + public void setInput(List<TemplateLogicInputBean> input) { + this.input = input; + } + + public ArrayList<TemplateLogicOutputBean> getOutput() { + if (output == null) { + return new ArrayList<>(); + } + return output; + } + + public void setOutput(ArrayList<TemplateLogicOutputBean> output) { + this.output = output; + } + + public static class TemplateLogicCycleBean { + + //---- type 閿� false string + private String type; + + //---- value 鍊� false array<string> + private List<String> value = new ArrayList<>(); + + public String getType() { + return type == null ? "" : type; + } + + public void setType(String type) { + this.type = type; + } + + public List<String> getValue() { + if (value == null) { + return new ArrayList<>(); + } + return value; + } + + public void setValue(List<String> value) { + this.value = value; + } + } + + public static class TemplateLogicInputBean { + + //---- sid sid false string + private String sid; + + //---- condition_type 鏉′欢绫诲瀷 false string + private String condition_type; + + //---- condition 鏉′欢 false array<object> + private ArrayList<TemplateLogicInputConditionBean> condition = new ArrayList<>(); + + public String getSid() { + return sid == null ? "0301056295720F16150100080000" : sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getCondition_type() { + return condition_type == null ? "" : condition_type; + } + + public void setCondition_type(String condition_type) { + this.condition_type = condition_type; + } + + public ArrayList<TemplateLogicInputConditionBean> getCondition() { + if (condition == null) { + return new ArrayList<>(); + } + return condition; + } + + public void setCondition(ArrayList<TemplateLogicInputConditionBean> condition) { + this.condition = condition; + } + } + + public static class TemplateLogicInputConditionBean { + //------ key 鏉′欢key false string + private String key; + + //------ comparator 姣旇緝 false string + private String comparator; + + //------ data_type 鏁版嵁绫诲瀷 false string + private String data_type; + + //------ value 鏉′欢鍊� false string + private String value; + + public String getKey() { + return key == null ? "" : key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getComparator() { + return comparator == null ? "" : comparator; + } + + public void setComparator(String comparator) { + this.comparator = comparator; + } + + public String getData_type() { + return data_type == null ? "" : data_type; + } + + public void setData_type(String data_type) { + this.data_type = data_type; + } + + public String getValue() { + return value == null ? "" : value; + } + + public void setValue(String value) { + this.value = value; + } + } + + public static class TemplateLogicOutputBean { + //---- sid sid false string + private String sid; + //---- target_type 鐩爣绫诲瀷 false string + private String target_type; + //----- status 鍔ㄤ綔 false array<object> + private ArrayList<TemplateLogicOutputStatusBean> status = new ArrayList<>(); + + private String name; + + private String delay; + + + public String getDelay() { + return delay == null ? "" : delay; + } + + public void setDelay(@NonNull String delay) { + this.delay = delay; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(@NonNull String name) { + this.name = name; + } + + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getTarget_type() { + return target_type == null ? "" : target_type; + } + + public void setTarget_type(String target_type) { + this.target_type = target_type; + } + + public ArrayList<TemplateLogicOutputStatusBean> getStatus() { + if (status == null) { + return new ArrayList<>(); + } + return status; + } + + public void setStatus(ArrayList<TemplateLogicOutputStatusBean> status) { + this.status = status; + } + } + public static class TemplateLogicOutputStatusBean { + //------- key 閿� false string + private String key; + //------- value 鍊� false string + private String value; + + public String getKey() { + return key == null ? "" : key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value == null ? "" : value; + } + + public void setValue(String value) { + this.value = value; + } + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateRoomPackBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateRoomPackBean.java new file mode 100644 index 0000000..0413813 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateRoomPackBean.java @@ -0,0 +1,89 @@ + +package com.hdl.linkpm.sdk.template.bean; +/* + *create by wxr + *date 2022/2/10 + */ + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class TemplateRoomPackBean implements Serializable { + private String templateExtendsId;// 妯℃澘id string + + //鍖哄煙闆嗗悎 + private List<TemplateRoomInfoBean> roomInfos = new ArrayList<>(); + + public String getTemplateExtendsId() { + return templateExtendsId == null ? "" : templateExtendsId; + } + + public void setTemplateExtendsId(String templateExtendsId) { + this.templateExtendsId = templateExtendsId; + } + + public List<TemplateRoomInfoBean> getRoomInfos() { + if (roomInfos == null) { + return new ArrayList<>(); + } + return roomInfos; + } + + public void setRoomInfos(List<TemplateRoomInfoBean> roomInfos) { + this.roomInfos = roomInfos; + } + + public static class TemplateRoomInfoBean implements Serializable{ +// -- name 妯℃澘鎴块棿鍚嶇О true string + private String name; +// -- roomImage 妯℃澘鎴块棿鍥剧墖 false string + private String roomImage; +// -- uid 鎴块棿鍞竴鏍囪瘑 true string + private String uid; +// -- roomType 鎴块棿绫诲瀷 [ROOM,FLOOR] true string + private String roomType; +// -- parentId 妤煎眰id false string + private String parentId; + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRoomImage() { + return roomImage == null ? "" : roomImage; + } + + public void setRoomImage(String roomImage) { + this.roomImage = roomImage; + } + + public String getUid() { + return uid == null ? "" : uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getRoomType() { + return roomType == null ? "" : roomType; + } + + public void setRoomType(String roomType) { + this.roomType = roomType; + } + + public String getParentId() { + return parentId == null ? "" : parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateSceneBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateSceneBean.java new file mode 100644 index 0000000..5f0e350 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateSceneBean.java @@ -0,0 +1,222 @@ +package com.hdl.linkpm.sdk.template.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.List; + +public class TemplateSceneBean implements Serializable { + private String name;//鍦烘櫙鍚嶇О + private String sid;//link璁惧sid + private String image;//鍦烘櫙鍥剧墖 + private String sceneType;//鍦烘櫙绫诲瀷 + private List<String> uids = new ArrayList<>();//鎴块棿uid + private transient List<String> roomIds = new ArrayList<>();//鎴块棿id + private String delay;//鍦烘櫙寤舵椂 + private String group;//鍦烘櫙鍒嗙粍 + private List<TemplateSceneFunctionBean> functions = new ArrayList<>();//鍦烘櫙鍔熻兘 + private boolean can_delete; + private ArrayList<TemplateSceneImageBean> imageBeans = new ArrayList<>(); + + public boolean isCan_delete() { + return can_delete; + } + + public void setCan_delete(boolean can_delete) { + this.can_delete = can_delete; + } + + public ArrayList<TemplateSceneImageBean> getImageBeans() { + if (imageBeans == null) { + return new ArrayList<>(); + } + return imageBeans; + } + + public void setImageBeans(ArrayList<TemplateSceneImageBean> imageBeans) { + this.imageBeans = imageBeans; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getImage() { + return image == null ? "" : image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getSceneType() { + return sceneType == null ? "" : sceneType; + } + + public void setSceneType(String sceneType) { + this.sceneType = sceneType; + } + + public List<String> getUids() { + if (uids == null) { + return new ArrayList<>(); + } + return uids; + } + + public void setUids(List<String> uids) { + this.uids = uids; + } + + public List<String> getRoomIds() { + if (roomIds == null) { + return new ArrayList<>(); + } + return roomIds; + } + + public void setRoomIds(List<String> roomIds) { + this.roomIds = roomIds; + } + + public String getDelay() { + return delay == null ? "" : delay; + } + + public void setDelay(String delay) { + this.delay = delay; + } + + public String getGroup() { + return group == null ? "" : group; + } + + public void setGroup(String group) { + this.group = group; + } + + public List<TemplateSceneFunctionBean> getFunctions() { + if (functions == null) { + return new ArrayList<>(); + } + return functions; + } + + public void setFunctions(List<TemplateSceneFunctionBean> functions) { + this.functions = functions; + } + + public void addFunction(TemplateSceneFunctionBean function){ + this.functions.add(function); + } + + + /** + * 鍦烘櫙鐨勫姛鑳藉璞� + */ + public static class TemplateSceneFunctionBean implements Serializable { + private String sid;// link璁惧sid string + private String delay;// 寤惰繜鏃堕棿 string + private List<TemplateSceneFunctionStateBean> status = new ArrayList<>();// 璁惧鍔ㄤ綔 array<object> + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getDelay() { + return delay; + } + + public void setDelay(String delay) { + this.delay = delay; + } + + public List<TemplateSceneFunctionStateBean> getStatus() { + return status; + } + + public void setStatus(List<TemplateSceneFunctionStateBean> status) { + this.status = status; + } + + public void addStatus(TemplateSceneFunctionStateBean stateBean){ + this.status.add(stateBean); + } + } + + /** + * 鍦烘櫙鐨勫姛鑳界殑灞炴�ц缃姸鎬� + */ + public static class TemplateSceneFunctionStateBean implements Serializable { + private String key; + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + } + + public static class TemplateSceneImageBean + { + private String imageId; + + private String cloudUrl; + + private String localUrl; + + public String getImageId() { + return imageId == null ? "" : imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public String getCloudUrl() { + return cloudUrl == null ? "" : cloudUrl; + } + + public void setCloudUrl(String cloudUrl) { + this.cloudUrl = cloudUrl; + } + + public String getLocalUrl() { + return localUrl == null ? "" : localUrl; + } + + public void setLocalUrl(String localUrl) { + this.localUrl = localUrl; + } + } + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateSecurityBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateSecurityBean.java new file mode 100644 index 0000000..cc7a44a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/bean/TemplateSecurityBean.java @@ -0,0 +1,275 @@ +package com.hdl.linkpm.sdk.template.bean; + +import java.io.Serializable; +import java.util.ArrayList; + +import androidx.annotation.NonNull; + +public class TemplateSecurityBean implements Serializable { + // + private String sid; + //瀹夐槻鍚嶇О + private String name; + //enable甯冮槻銆乨isable鎾掗槻 + private String status; + //瀹夐槻绫诲瀷 + //"all"--鍏ㄥ畢甯冮槻锛�"normal"--鏅�氭ā寮�,"all_day":24灏忔椂,"mute"锛氶潤闊� + private String type; + + private String delay; + + private ArrayList<SecurityInput> input = new ArrayList<>(); + + private String output_delay; + + private ArrayList<SecurityOutput> output = new ArrayList<>(); + + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStatus() { + return status == null ? "" : status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getType() { + return type == null ? "" : type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDelay() { + return delay == null ? "" : delay; + } + + public void setDelay(String delay) { + this.delay = delay; + } + + public ArrayList<SecurityInput> getInput() { + if (input == null) { + return new ArrayList<>(); + } + return input; + } + + public void setInput(ArrayList<SecurityInput> input) { + this.input = input; + } + + public String getOutput_delay() { + return output_delay == null ? "" : output_delay; + } + + public void setOutput_delay(String output_delay) { + this.output_delay = output_delay; + } + + public ArrayList<SecurityOutput> getOutput() { + if (output == null) { + return new ArrayList<>(); + } + return output; + } + + public void setOutput(ArrayList<SecurityOutput> output) { + this.output = output; + } + + public class SecurityOutput implements Serializable + { + private String target_type; + + private String sid; + + private ArrayList<OutputStatus> status = new ArrayList<OutputStatus>(); + + public String getTarget_type() { + return target_type == null ? "" : target_type; + } + + private String delay; + public String getDelay() { + return delay == null ? "" : delay; + } + + public void setDelay(@NonNull String delay) { + this.delay = delay; + } + + + public void setTarget_type(String target_type) { + this.target_type = target_type; + } + + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public ArrayList<OutputStatus> getStatus() { + return status; + } + + public void setStatus(ArrayList<OutputStatus> status) { + this.status = status; + } + + public class OutputStatus + { + private String key; + + private String value; + + public String getKey() { + return key == null ? "" : key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value == null ? "" : value; + } + + public void setValue(String value) { + this.value = value; + } + } + } + + public class SecurityInput implements Serializable + { + private String sid; + + private String bypass; + + private ArrayList<InputCondition> condition = new ArrayList<>(); + + private ArrayList<InputStatus> status = new ArrayList<>(); + + public String getSid() { + return sid == null ? "" : sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getBypass() { + return bypass == null ? "" : bypass; + } + + public void setBypass(String bypass) { + this.bypass = bypass; + } + + public ArrayList<InputCondition> getCondition() { + if (condition == null) { + return new ArrayList<>(); + } + return condition; + } + + public void setCondition(ArrayList<InputCondition> condition) { + this.condition = condition; + } + + public ArrayList<InputStatus> getStatus() { + return status; + } + + public void setStatus(ArrayList<InputStatus> status) { + this.status = status; + } + + public class InputStatus implements Serializable + { + private String key; + + private String value; + + public String getKey() { + return key == null ? "" : key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value == null ? "" : value; + } + + public void setValue(String value) { + this.value = value; + } + } + + public class InputCondition implements Serializable + { + private String key; + + private String comparator; + + private String data_type; + + private String value; + + public String getKey() { + return key == null ? "" : key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getComparator() { + return comparator == null ? "" : comparator; + } + + public void setComparator(String comparator) { + this.comparator = comparator; + } + + public String getData_type() { + return data_type == null ? "" : data_type; + } + + public void setData_type(String data_type) { + this.data_type = data_type; + } + + public String getValue() { + return value == null ? "" : value; + } + + public void setValue(String value) { + this.value = value; + } + } + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ICreateTemplateCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ICreateTemplateCallBack.java new file mode 100644 index 0000000..c85f36a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ICreateTemplateCallBack.java @@ -0,0 +1,11 @@ +package com.hdl.linkpm.sdk.template.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; + +public interface ICreateTemplateCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(String templateId); + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateDeviceListCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateDeviceListCallBack.java new file mode 100644 index 0000000..e43cb9d --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateDeviceListCallBack.java @@ -0,0 +1,17 @@ +package com.hdl.linkpm.sdk.template.callback;/* + *create by wxr + *date 2022/2/11 + */ + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.template.bean.CloudTemplateDevice; +import com.hdl.linkpm.sdk.template.bean.CloudTemplateSpatialInfo; + +import java.util.List; + +public interface IGetTemplateDeviceListCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(List<CloudTemplateDevice> data); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateGatewayListCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateGatewayListCallBack.java new file mode 100644 index 0000000..33831da --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateGatewayListCallBack.java @@ -0,0 +1,17 @@ +package com.hdl.linkpm.sdk.template.callback;/* + *create by wxr + *date 2022/2/11 + */ + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.template.bean.CloudTemplateDevice; +import com.hdl.linkpm.sdk.template.bean.TemplateGatewayBean; + +import java.util.List; + +public interface IGetTemplateGatewayListCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(List<TemplateGatewayBean> data); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateSpatialInfoCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateSpatialInfoCallBack.java new file mode 100644 index 0000000..0da7fbe --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/IGetTemplateSpatialInfoCallBack.java @@ -0,0 +1,16 @@ +package com.hdl.linkpm.sdk.template.callback;/* + *create by wxr + *date 2022/2/11 + */ + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.template.bean.CloudTemplateSpatialInfo; + +import java.util.List; + +public interface IGetTemplateSpatialInfoCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(List<CloudTemplateSpatialInfo> data); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateFunctionsCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateFunctionsCallBack.java new file mode 100644 index 0000000..ff5bbd8 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateFunctionsCallBack.java @@ -0,0 +1,16 @@ +package com.hdl.linkpm.sdk.template.callback;/* + *create by wxr + *date 2022/1/19 + */ + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.template.bean.TemplateFunctionBean; + +import java.util.List; + +public interface ITemplateFunctionsCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(List<TemplateFunctionBean> templateFunctionBean); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateListCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateListCallBack.java new file mode 100644 index 0000000..92b5429 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateListCallBack.java @@ -0,0 +1,17 @@ +package com.hdl.linkpm.sdk.template.callback;/* + *create by wxr + *date 2022/1/19 + */ + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.template.bean.TemplateFunctionBean; +import com.hdl.linkpm.sdk.template.bean.TemplateListResponseBean; + +import java.util.List; + +public interface ITemplateListCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(TemplateListResponseBean templateListResponseBean); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateLogicCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateLogicCallBack.java new file mode 100644 index 0000000..598135d --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateLogicCallBack.java @@ -0,0 +1,17 @@ +package com.hdl.linkpm.sdk.template.callback;/* + *create by wxr + *date 2022/2/12 + */ + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.template.bean.TemplateLogicBean; +import com.hdl.linkpm.sdk.template.bean.TemplateSceneBean; + +import java.util.List; + +public interface ITemplateLogicCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(List<TemplateLogicBean> data); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateScenesCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateScenesCallBack.java new file mode 100644 index 0000000..0845ef6 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateScenesCallBack.java @@ -0,0 +1,17 @@ +package com.hdl.linkpm.sdk.template.callback;/* + *create by wxr + *date 2022/2/12 + */ + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.template.bean.TemplateFunctionBean; +import com.hdl.linkpm.sdk.template.bean.TemplateSceneBean; + +import java.util.List; + +public interface ITemplateScenesCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(List<TemplateSceneBean> data); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateSecurityCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateSecurityCallBack.java new file mode 100644 index 0000000..04af1ca --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateSecurityCallBack.java @@ -0,0 +1,17 @@ +package com.hdl.linkpm.sdk.template.callback;/* + *create by wxr + *date 2022/2/12 + */ + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.template.bean.TemplateLogicBean; +import com.hdl.linkpm.sdk.template.bean.TemplateSecurityBean; + +import java.util.List; + +public interface ITemplateSecurityCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(List<TemplateSecurityBean> data); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateSpatialInfoCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateSpatialInfoCallBack.java new file mode 100644 index 0000000..39739ad --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/callback/ITemplateSpatialInfoCallBack.java @@ -0,0 +1,16 @@ +package com.hdl.linkpm.sdk.template.callback;/* + *create by wxr + *date 2022/2/11 + */ + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.template.bean.TemplateRoomPackBean; + +import java.util.List; + +public interface ITemplateSpatialInfoCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(List<TemplateRoomPackBean> templateRoomPackBeans); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/controller/HDLTemplateController.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/controller/HDLTemplateController.java new file mode 100644 index 0000000..090fec5 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/template/controller/HDLTemplateController.java @@ -0,0 +1,642 @@ +package com.hdl.linkpm.sdk.template.controller;/* + *create by wxr + *date 2022/1/19 + */ + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.linkpm.sdk.HDLLinkPMSdk; +import com.hdl.linkpm.sdk.core.api.HDLCloudUserApi; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.template.bean.CloudTemplateDevice; +import com.hdl.linkpm.sdk.template.bean.CloudTemplateSpatialInfo; +import com.hdl.linkpm.sdk.template.bean.TemplateDeviceBean; +import com.hdl.linkpm.sdk.template.bean.TemplateFunctionBean; +import com.hdl.linkpm.sdk.template.bean.TemplateGatewayBean; +import com.hdl.linkpm.sdk.template.bean.TemplateListResponseBean; +import com.hdl.linkpm.sdk.template.bean.TemplateLogicBean; +import com.hdl.linkpm.sdk.template.bean.TemplateRoomPackBean; +import com.hdl.linkpm.sdk.template.bean.TemplateSceneBean; +import com.hdl.linkpm.sdk.template.bean.TemplateSecurityBean; +import com.hdl.linkpm.sdk.template.callback.ICreateTemplateCallBack; +import com.hdl.linkpm.sdk.template.callback.IGetTemplateDeviceListCallBack; +import com.hdl.linkpm.sdk.template.callback.IGetTemplateGatewayListCallBack; +import com.hdl.linkpm.sdk.template.callback.IGetTemplateSpatialInfoCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateFunctionsCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateListCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateLogicCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateScenesCallBack; +import com.hdl.linkpm.sdk.template.callback.ITemplateSecurityCallBack; +import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; + +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; + +public class HDLTemplateController { + private volatile static HDLTemplateController instance; + + public static synchronized HDLTemplateController getInstance() { + if (instance == null) { + synchronized (HDLTemplateController.class) { + if (instance == null) { + instance = new HDLTemplateController(); + } + } + } + return instance; + } + + + /** + * 鍒涘缓妯℃澘 + * @param templateName + * @param communityCode + * @param houseLayoutId + * @param templateDesc + * @param callBack + * @return + */ + public Disposable CreateTemplate(String templateName, String communityCode, String houseLayoutId, String templateDesc, ICreateTemplateCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_CREATE; + JsonObject json = new JsonObject(); + json.addProperty("templateName", templateName); + json.addProperty("templateSourcePlatform", "app"); + json.addProperty("communityCode", communityCode); + json.addProperty("houseLayoutId", houseLayoutId); + json.addProperty("templateDesc", templateDesc); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + public Disposable GetTemplateList(int pageNo,int pageSize,ITemplateListCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_GET_LIST; + JsonObject json = new JsonObject(); + json.addProperty("pageNo",pageNo); + json.addProperty("pageSize",pageSize); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<TemplateListResponseBean>() { + @Override + public void onResponse(TemplateListResponseBean beans) { + if (callBack != null) { + callBack.onSuccess(beans); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + /** + * 鍒犻櫎妯℃澘 + * @param templateExtendsId 妯℃澘ID + * @param callBack + * @return + */ + public Disposable DeleteTemplate(String templateExtendsId,IDefaultCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_DELETE; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鏇存柊缃戝叧鍒楄〃(鍏ㄩ噺) + * @param templateExtendsId + * @param gatewayBeans + * @param callBack + * @return + */ + public Disposable UpdateTemplateGateway(String templateExtendsId, List<TemplateGatewayBean> gatewayBeans,IDefaultCallBack callBack){ + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_UPDATE_GATEWAY; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + json.add("beans", HDLGsonUtils.toJsonArray(gatewayBeans)); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鏇存柊鎴块棿锛堟ゼ灞傦級淇℃伅(鍏ㄩ噺) + * @param templateExtendsId + * @param rooms + * @param callBack + * @return + */ + public Disposable UpdateTemplateRoom(String templateExtendsId ,List<TemplateRoomPackBean.TemplateRoomInfoBean> rooms, + IDefaultCallBack callBack){ + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_UPDATE_ROOM; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + json.add("roomInfos", HDLGsonUtils.toJsonArray(rooms)); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 娣诲姞璁惧(鍏ㄩ噺) + * @param templateExtendsId + * @param beans + * @param callBack + * @return + */ + public Disposable UpdateTemplateDevices(String templateExtendsId,List<TemplateDeviceBean> beans, + IDefaultCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_UPDATE_DEVICES; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + json.add("beans", HDLGsonUtils.toJsonArray(beans)); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 娣诲姞鍔熻兘(鍏ㄩ噺) + * @param templateExtendsId + * @param functionInfoList + * @param callBack + * @return + */ + public Disposable UpdateTemplateFunctions(String templateExtendsId, List<TemplateFunctionBean> functionInfoList, + IDefaultCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_UPDATE_FUNCTIONS; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + json.add("deviceInfos", HDLGsonUtils.toJsonArray(functionInfoList)); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鏇存柊妯℃澘鍦烘櫙(鍏ㄩ噺) + * @param templateExtendsId + * @param sceneBeans + * @param callBack + * @return + */ + public Disposable UpdataTemplateScenes(String templateExtendsId, List<TemplateSceneBean> sceneBeans, + IDefaultCallBack callBack){ + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_UPDATE_SCENES; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + json.add("sceneInfos", HDLGsonUtils.toJsonArray(sceneBeans)); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鏇存柊妯℃澘鑷姩鍖� (鍏ㄩ噺) + * @param templateExtendsId + * @param logicBeansJson + * @param callBack + * @return + */ + public Disposable UpdataTemplateLogic(String templateExtendsId, JsonElement logicBeansJson,// List<TemplateLogicBean> logicBeans, + IDefaultCallBack callBack){ + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_UPDATE_LOGIC; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + json.add("logicInfos", logicBeansJson); +// json.add("logicInfos", HDLGsonUtils.toJsonArray(logicBeans)); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鏇存柊妯℃澘瀹夐槻鍒楄〃 鍏ㄩ噺 + * @param templateExtendsId + * @param securityBeansJson + * @param callBack + * @return + */ + public Disposable UpdataTemplateSecurity(String templateExtendsId, JsonElement securityBeansJson,// List<TemplateLogicBean> logicBeans, + IDefaultCallBack callBack){ + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPLATE_UPDATE_SECURITY; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + json.add("securityInfos", securityBeansJson); +// json.add("logicInfos", HDLGsonUtils.toJsonArray(logicBeans)); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 鑾峰彇妯℃澘鍖哄煙淇℃伅鍒楄〃 + * @param templateExtendsId + * @param callBack + * @return + */ + public Disposable GetTemplateAreaSpatialInfo(String templateExtendsId, IGetTemplateSpatialInfoCallBack callBack){ + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GET_TEMPLATE_SPATIAL_INFO; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<CloudTemplateSpatialInfo>>() { + @Override + public void onResponse(List<CloudTemplateSpatialInfo> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇缃戝叧鍒楄〃 + * @param templateExtendsId + * @param callBack + * @return + */ + public Disposable GetTemplateGatewayList(String templateExtendsId, IGetTemplateGatewayListCallBack callBack){ + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GET_TEMPLATE_GATEWAY_LIST; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<TemplateGatewayBean>>() { + @Override + public void onResponse(List<TemplateGatewayBean> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇璁惧淇℃伅 + * @param templateExtendsId + * @param callBack + * @return + */ + public Disposable GetTemplateDeviceList(String templateExtendsId, IGetTemplateDeviceListCallBack callBack){ + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_TEMPALTE_GET_DEVICES; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<CloudTemplateDevice>>() { + @Override + public void onResponse(List<CloudTemplateDevice> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇鍔熻兘鍒楄〃 + * @param templateExtendsId + * @param callBack + * @return + */ + public Disposable GetTemplateFunctions(String templateExtendsId , ITemplateFunctionsCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GET_TEMPLATE_FUNCTION_LIST; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<TemplateFunctionBean>>() { + @Override + public void onResponse(List<TemplateFunctionBean> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇鍦烘櫙鍒楄〃 + * @param templateExtendsId + * @param callBack + * @return + */ + public Disposable GetTemplateScenes(String templateExtendsId , ITemplateScenesCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GET_TEMPLATE_SCENE_LIST; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<TemplateSceneBean>>() { + @Override + public void onResponse(List<TemplateSceneBean> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇瀹夐槻鍒楄〃 + * @param templateExtendsId + * @param callBack + * @return + */ + public Disposable GetTemplateSecurity(String templateExtendsId , ITemplateSecurityCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GET_TEMPLATE_SECURITY_LIST; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<TemplateSecurityBean>>() { + @Override + public void onResponse(List<TemplateSecurityBean> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 鑾峰彇閫昏緫鍒楄〃 + * @param templateExtendsId + * @param callBack + * @return + */ + public Disposable GetTemplateLogic(String templateExtendsId , ITemplateLogicCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GET_TEMPLATE_LOGIC_LIST; + JsonObject json = new JsonObject(); + json.addProperty("templateExtendsId", templateExtendsId); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<List<TemplateLogicBean>>() { + @Override + public void onResponse(List<TemplateLogicBean> data) { + if (callBack != null) { + callBack.onSuccess(data); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/HDLLinkPMUser.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/HDLLinkPMUser.java new file mode 100644 index 0000000..a26af67 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/HDLLinkPMUser.java @@ -0,0 +1,542 @@ +package com.hdl.linkpm.sdk.user; + +import android.text.TextUtils; + +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IDefaultStrCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLErrorCode; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.user.bean.HDLLoginBean; +import com.hdl.linkpm.sdk.user.bean.HDLUserInfoBean; +import com.hdl.linkpm.sdk.user.bean.HDLUserRegionBean; +import com.hdl.linkpm.sdk.user.bean.ImageSubmitInfo; +import com.hdl.linkpm.sdk.user.bean.MqttInfo; +import com.hdl.linkpm.sdk.user.bean.NewVersionBean; +import com.hdl.linkpm.sdk.user.callback.ILoginCallBack; +import com.hdl.linkpm.sdk.user.callback.IMemberInfoBack; +import com.hdl.linkpm.sdk.user.callback.IOnReloginListener; +import com.hdl.linkpm.sdk.user.callback.IRegionByAccountCallBack; +import com.hdl.linkpm.sdk.user.controller.HDLPMUserController; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; +import com.hdl.linkpm.sdk.utils.HDLSDKLog; +import com.hdl.linkpm.sdk.utils.HDLSDKSPUtils; + +import java.io.File; +import java.util.Map; + +import io.reactivex.rxjava3.disposables.Disposable; + + +/** + * Created by jlchen on 12/2/21. + */ +public class HDLLinkPMUser { + private static final String TAG = "HDLLinkPMUser"; + private static final String HDLLINK_ISLOGIN_KEY = "hdllink_islogin";//鐧诲綍鐘舵�� + public static final String HDLLINK_USER_KEY = "hdllink_user";//鐢ㄦ埛淇℃伅 + private static final String HDLLINK_PUSHID_KEY = "hdllink_jpush_id";//鏋佸厜鎺ㄩ�佺粦瀹氬悗绔繑鍥瀒d + private static final String HDLLINK_ACCESSTOKEN_KEY = "hdllink_access_token";//鐢ㄦ埛token + private static final String HDLLINK_REFRESHTOKEN_KEY = "hdllink_refresh_token";//鐢ㄦ埛鍒锋柊token + private static final String HDLLINK_USERURL_KEY = "hdllink_user_url";//鐢ㄦ埛璇锋眰鍩熷悕鍦板潃 + private static final String HDLLINK_HOMEURL_KEY = "hdllink_home_url";//鐢ㄦ埛璇锋眰鍩熷悕鍦板潃 + /// 鐢ㄦ埛娉ㄥ唽鎵�鍦ㄦ湇鍔″櫒鍩熷悕鍦板潃 + private String userRegionUrl; + /// 浣忓畢鎵�鍦ㄦ湇鍔″櫒鍩熷悕鍦板潃 浣忓畢鐩稿叧鎺ュ彛閮界敤杩欎釜鍦板潃 + private String homeRegionUrl; + //鏄惁鐧诲綍鐘舵�� + private boolean isLogin = false; + /// 鐢ㄦ埛鏈夋晥韬唤Token + private String accessToken; + /// 鍒锋柊Token + private String refreshToken; + //鐧诲綍鎴愬姛鍚庣殑鐢ㄦ埛淇℃伅 + private HDLUserInfoBean mUser; + //褰撶敤鎴稟ccessToken 閿欒鍚庡彂鍑虹殑閫氱煡 鐧诲嚭澶勭悊 + private IOnReloginListener mOnReloginListener; + //instance + private volatile static HDLLinkPMUser instance; + + /** + * getInstance + * + * @return HDLSmartUser + */ + public static synchronized HDLLinkPMUser getInstance() { + if (instance == null) { + synchronized (HDLLinkPMUser.class) { + if (instance == null) { + instance = new HDLLinkPMUser(); + instance.loadData();//鍔犺浇缂撳瓨鐨凥DLUserBean瀵硅薄 + } + } + } + return instance; + } + + /** + * loadData 鍔犺浇缂撳瓨鐨凥DLUser瀵硅薄 + */ + private void loadData() { + //1. + isLogin = HDLSDKSPUtils.getBoolean(HDLLINK_ISLOGIN_KEY); + //2. + accessToken = HDLSDKSPUtils.getString(HDLLINK_ACCESSTOKEN_KEY); + //3. + refreshToken = HDLSDKSPUtils.getString(HDLLINK_REFRESHTOKEN_KEY); + //4. + userRegionUrl = HDLSDKSPUtils.getString(HDLLINK_USERURL_KEY); + //5. + homeRegionUrl = HDLSDKSPUtils.getString(HDLLINK_HOMEURL_KEY); + //6. + String userJsonStr = HDLSDKSPUtils.getString(HDLLINK_USER_KEY); + if (!TextUtils.isEmpty(userJsonStr)) //闃茬┖鍒ゆ柇 + { + mUser = HDLGsonUtils.fromJson(userJsonStr, new TypeToken<HDLUserInfoBean>() { + }.getType()); + if (mUser == null) { + saveLogin(false);//閲嶆柊鏍囪涓烘湭鐧诲綍 + } + } + } + + /** + * 鐧诲綍鎴愬姛鎴栬�呭埛鏂皌oken鍚� 淇濆瓨涓�娆DLUser瀵硅薄 + */ + private void saveHDLUserBean(HDLUserInfoBean user) { + String mUserJsonStr = HDLGsonUtils.toJson(user); //灏哃ist杞崲鎴怞son + HDLSDKSPUtils.put(HDLLINK_USER_KEY, mUserJsonStr); + } + + /** + * 淇濆瓨鏋佸厜鎺ㄩ�佺粦瀹氫箣鍚庣殑id + */ + public void saveHDLJpushId(String pushId) { + HDLSDKSPUtils.put(HDLLINK_PUSHID_KEY, pushId); + } + + /** + * 鑾峰彇鏋佸厜鎺ㄩ�佺粦瀹氫箣鍚庣殑id + */ + public String getHDLJpushId() { + return HDLSDKSPUtils.getString(HDLLINK_PUSHID_KEY); + } + + /** + * 淇濆瓨鐧诲綍鐘舵�� + * + * @param isLogin + */ + private void saveLogin(Boolean isLogin) { + HDLSDKSPUtils.put(HDLLINK_ISLOGIN_KEY, isLogin); + } + + /** + * 鐧诲綍鎴愬姛鍚庯紝鍒锋柊鍜屼繚瀛樼浉鍏崇敤鎴疯韩浠藉弬鏁� + * + * @param userBean + */ + private void loginSuccess(HDLLoginBean userBean) { + //1.淇濆瓨鐧诲綍鐘舵�� + saveLogin(true); + //2.淇濆瓨token + saveAccessToken(userBean.getHeaderPrefix() + userBean.getAccessToken()); + //3.淇濆瓨鍒锋柊token + saveRefreshToken(userBean.getRefreshToken()); + //4.淇濆瓨mUser瀵硅薄鍒扮紦瀛� + this.mUser = new HDLUserInfoBean(userBean); + saveHDLUserBean(this.mUser); + } + + private void saveAccessToken(String accessToken) { + this.accessToken = accessToken; + HDLSDKSPUtils.put(HDLLINK_ACCESSTOKEN_KEY, this.accessToken); + } + + private void saveRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; + HDLSDKSPUtils.put(HDLLINK_REFRESHTOKEN_KEY, this.refreshToken); + } + + /** + * @param userBean + */ + public void updateRefreshToken(HDLLoginBean userBean) { + if (userBean == null) return; + //鍒锋柊token杩斿洖鐨勬暟鎹彲鑳戒笉甯ccount銆乽serPhone绛夌浉鍏冲弬鏁帮紝鎵�浠ヤ笉鑳芥洿鏂皍ser鍊笺�佸彧鏇存柊AccessToken鍜屽埛鏂癟oken鐨勫�煎氨濂戒簡 + //1.淇濆瓨鐧诲綍鐘舵�� + saveLogin(true); + //2.淇濆瓨token + saveAccessToken(userBean.getHeaderPrefix() + userBean.getAccessToken()); + //3.淇濆瓨鍒锋柊token + saveRefreshToken(userBean.getRefreshToken()); + } + + /** + * 娓呯┖鐧诲綍鐘舵�� + */ + private void removeAll() { + //1.璁剧疆鏈櫥褰曠姸鎬� + saveLogin(false); + //2.娓呯┖token + saveAccessToken(""); + //3.娓呯┖鍒锋柊token + saveRefreshToken(""); + //4.娓呯┖鐢ㄦ埛瀵硅薄 + saveHDLUserBean(new HDLUserInfoBean()); + } + + /** + * 閫氱煡閫�鍑洪噸鏂扮櫥褰� + * @param type: 0:姝e父閫�鍑� 1锛氭瀬鍏夋帹閫佸己鍒堕��鍑� + */ + private void notificationRelogin(int type) { + if (mOnReloginListener != null) { + mOnReloginListener.onReLogin(type); + } + } + + /** + * 閫�鍑虹櫥褰� + * @param type: 0:姝e父閫�鍑� 1锛氭瀬鍏夋帹閫佸己鍒堕��鍑� + */ + public void logout(int type) { + //1.娓呯┖鐧诲綍鐘舵�� + removeAll(); + //2.鍙戝嚭閲嶆柊鐧诲綍閫氱煡 + notificationRelogin(type); + } + + /****************************璇锋眰鎺ュ彛****************************/ + /** + * 鑾峰彇璐﹀彿鎵�鍦ㄥ尯鍩� + * + * @param account 璐﹀彿 + * @param callBack 缁撴灉鍥炶皟 + */ + public void regionByAccount(String account, IRegionByAccountCallBack callBack) { + HDLPMUserController.getInstance().regionByAccount(account, new IRegionByAccountCallBack() { + @Override + public void onSuccess(HDLUserRegionBean regionBean) { + if (regionBean != null) { + //鏌ヨ鎴愬姛璁板綍涓�娆� + setUserRegionUrl(regionBean.getRegionUrl()); + if (callBack != null) { + callBack.onSuccess(regionBean); + } + } else { + if (callBack != null) { + callBack.onFailure(HDLException.getErrorWithCode(HDLErrorCode.HDL_DATA_PARSING_ERROR)); + } + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 閫氳繃璐﹀彿鍜屽瘑鐮佺櫥褰� + * + * @param account 璐﹀彿 + * @param loginPwd 瀵嗙爜 + * @param callBack 缁撴灉鍥炶皟 + */ + public void loginByPassword(String account, String loginPwd, ILoginCallBack callBack) { + HDLPMUserController.getInstance().loginByPassword(account, loginPwd, new ILoginCallBack() { + @Override + public void onSuccess(HDLLoginBean loginBean) { + loginSuccess(loginBean); + if (callBack != null) { + callBack.onSuccess(loginBean); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /****************************璇锋眰鎺ュ彛****************************/ + /** + * 鑾峰彇璐﹀彿鎵�鍦ㄥ尯鍩� + * + * @param isBooleanB true=B,false=C + * @param account 璐﹀彿 + * @param callBack 缁撴灉鍥炶皟 + */ + public void regionByAccount(boolean isBooleanB, String account, IRegionByAccountCallBack callBack) { + HDLPMUserController.getInstance().regionByAccount(isBooleanB,account, new IRegionByAccountCallBack() { + @Override + public void onSuccess(HDLUserRegionBean regionBean) { + if (regionBean != null) { + //鏌ヨ鎴愬姛璁板綍涓�娆� + setUserRegionUrl(regionBean.getRegionUrl()); + if (callBack != null) { + callBack.onSuccess(regionBean); + } + } else { + if (callBack != null) { + callBack.onFailure(HDLException.getErrorWithCode(HDLErrorCode.HDL_DATA_PARSING_ERROR)); + } + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + + /** + * 閫氳繃璐﹀彿鍜屽瘑鐮佺櫥褰� + * + * @param isBooleanB true=B,false=C + * @param account 璐﹀彿 + * @param loginPwd 瀵嗙爜 + * @param callBack 缁撴灉鍥炶皟 + */ + public void loginByPassword(boolean isBooleanB, String account, String loginPwd, ILoginCallBack callBack) { + HDLPMUserController.getInstance().loginByPassword(isBooleanB, account, loginPwd, new ILoginCallBack() { + @Override + public void onSuccess(HDLLoginBean loginBean) { + loginSuccess(loginBean); + if (callBack != null) { + callBack.onSuccess(loginBean); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 鐧诲綍 + * 閫氳繃楠岃瘉鐮� + * + * @param account 鎵嬫満鎴栬�呴偖绠� + * @param vCode 楠岃瘉鐮� + * @param callBack 鍥炶皟 + * @return + */ + public void loginByCode(String account, String vCode, ILoginCallBack callBack) { + HDLPMUserController.getInstance().loginByCode(account, vCode, new ILoginCallBack() { + @Override + public void onSuccess(HDLLoginBean loginBean) { + loginSuccess(loginBean); + if (callBack != null) { + callBack.onSuccess(loginBean); + } + } + + @Override + public void onFailure(HDLException error) { + if (callBack != null) { + callBack.onFailure(error); + } + } + }); + } + + /** + * 閫氱敤 鍙戦�侀獙璇佺爜鏂规硶 + * LanguageTypeEnum CHINESE,ENGLISH + * + * @param verifyType 1:娉ㄥ唽 2锛氭壘鍥炲瘑鐮� 3锛氱粦瀹� 4:楠岃瘉鐮佺櫥闄� 5:鏁忔劅鏁版嵁 + * @param account 閭鎴栬�呮墜鏈哄彿 + * @param isPhone 鏄惁鎵嬫満 + * @param phoneZoneCode 鎵嬫満鍥藉鍖哄彿 + * @param languageType 璇█ + * @param callBack + * @return + */ + public void verificationCodeSend(int verifyType, String account, Boolean isPhone, String phoneZoneCode, String languageType, IDefaultCallBack callBack) { + HDLPMUserController.getInstance().verificationCodeSend(verifyType, account, isPhone, phoneZoneCode, languageType, callBack); + } + + /** + * 蹇樿瀵嗙爜锛岄噸缃瘑鐮� + * + * @param account 閭鎴栬�呮墜鏈哄彿 + * @param password 鏂板瘑鐮� + * @param vCode 楠岃瘉鐮� + * @param isPhone 鏄惁鎵嬫満 + * @param callBack 鍥炶皟 + */ + public void forgetPassword(String account, String password, String vCode, Boolean isPhone, IDefaultCallBack callBack) { + HDLPMUserController.getInstance().forgetPassword(account, password, vCode, isPhone, callBack); + } + + /** + * 鏇存敼涓汉瀵嗙爜 + * + * @param userId 褰撳墠鐢ㄦ埛ID + * @param loginOldPwd 鑰佸瘑鐮� + * @param loginPwd 鏂板瘑鐮� + * @param callBack 鍥炶皟 + */ + public void updateProgramPassword(String userId, String loginOldPwd, String loginPwd, IDefaultCallBack callBack) { + HDLPMUserController.getInstance().updateProgramPassword(userId, loginOldPwd, loginPwd, callBack); + } + + /** + * 鑾峰彇鐢ㄦ埛涓汉淇℃伅 + * + * @param callBack + */ + public void getMemberInfo(IMemberInfoBack callBack) { + HDLPMUserController.getInstance().getMemberInfo(callBack); + } + + /** + * 鏇存柊涓汉淇℃伅 + * memberHeadIcon銆乵emberName銆乵emberBirthday銆乴anguageType銆乵emberSex + * + * @param callBack + */ + public void updateMemberInfo(JsonObject updateInfo, IDefaultCallBack callBack) { + HDLPMUserController.getInstance().updateMemberInfo(updateInfo, callBack); + } + + /** + * 鑾峰彇鐢ㄦ埛澶村儚璺緞 + * + * @param memberHeadIconKey 鐢ㄦ埛澶村儚imageKey + * @param callBack + */ + public void getHeadImageUrl(String memberHeadIconKey, IDefaultStrCallBack callBack) { + HDLPMUserController.getInstance().getHeadImageUrl(memberHeadIconKey, callBack); + } + + /** + * 涓婁紶鐢ㄦ埛澶村儚 + * + * @param userId 鐢ㄦ埛id + * @param imageBytes 澶村儚鍥剧墖 + * @param callBack + * @return + */ + public void uploadUserHeadImage(String userId, byte[] imageBytes, IDefaultStrCallBack callBack) { + HDLPMUserController.getInstance().uploadUserHeadImage(userId, imageBytes, callBack); + } + + /** + * 涓婁紶鐢ㄦ埛澶村儚 + * + * @param file 鍥剧墖鏂囦欢 + * @param callBack + * @return + */ + public void uploadUserHeadImage(File file, IResponseCallBack<ImageSubmitInfo> callBack) { + HDLPMUserController.getInstance().uplfadUserHeadImage(file, callBack); + } + + + /** + * APP鐗堟湰妫�娴嬫洿鏂� + * + * @param appCode app缂栫爜 + * @param version 鐗堟湰鍙� + * @param callBack 濡傛灉onSuccess 鍥炶皟鐨刡ean涓虹┖锛屼唬琛ㄥ綋鍓嶇増鏈凡缁忔槸鏈�鏂扮増鏈紝娌℃湁鏂扮増鏈� + * @return + */ + public void checkAppVersion(String appCode, String version, IResponseCallBack<NewVersionBean> callBack) { + HDLPMUserController.getInstance().checkAppVersion(appCode, version, "Android", callBack); + } + + /** + * 灏忕▼搴弚gt鐗堟湰妫�娴嬫洿鏂� + * + * @param appCode app缂栫爜 + * @param wgtVersion 灏忕▼搴弚gt鐗堟湰鍙� + * @param callBack 濡傛灉onSuccess 鍥炶皟鐨刡ean涓虹┖锛屼唬琛ㄥ綋鍓嶇増鏈凡缁忔槸鏈�鏂扮増鏈紝娌℃湁鏂扮増鏈� + * @return + */ + public void checkWgtVersion(String appCode, String wgtVersion, IResponseCallBack<NewVersionBean> callBack) { + HDLPMUserController.getInstance().checkAppVersion(appCode, wgtVersion,"wgt", callBack); + } + + /** + * 鑾峰彇mqtt + */ + public void getMqttInfo(String attachClientId, String homeType, String deviceUuid, IResponseCallBack<MqttInfo>listener) { + HDLPMUserController.getInstance().getMqttInfo(attachClientId, homeType, deviceUuid, listener); + } + + /****************************璇锋眰鎺ュ彛****************************/ + + + public String getUserRegionUrl() { + if (TextUtils.isEmpty(userRegionUrl)) { + HDLSDKLog.e(TAG, "userRegionUrl null "); + } + return userRegionUrl; + } + + public void setUserRegionUrl(String userRegionUrl) { + this.userRegionUrl = userRegionUrl; + HDLSDKSPUtils.put(HDLLINK_USERURL_KEY, this.userRegionUrl); + } + + public boolean isLogin() { + return isLogin; + } + + public HDLUserInfoBean getUser() { + return mUser; + } + + public String getAccessToken() { + return accessToken; + } + + public String getRefreshToken() { + return refreshToken; + } + + public String getHomeRegionUrl() { + //濡傛灉娌¢厤缃綇瀹呯殑鍩熷悕璇锋眰鍦板潃鍒欓粯璁ょ敤鐢ㄦ埛鐨� + if (TextUtils.isEmpty(homeRegionUrl)) { + return getUserRegionUrl(); + } + return homeRegionUrl; + } + + /** + * 璁剧疆浣忓畢璇锋眰鐨勫湴鍧� + * + * @param homeRegionUrl + */ + public void setHomeRegionUrl(String homeRegionUrl) { + this.homeRegionUrl = homeRegionUrl; + HDLSDKSPUtils.put(HDLLINK_HOMEURL_KEY, homeRegionUrl); + } + +// private IOnReloginListener getOnReloginListener() { +// return mOnReloginListener; +// } + + public void setOnReloginListener(IOnReloginListener onReloginListener) { + mOnReloginListener = onReloginListener; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLLoginBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLLoginBean.java new file mode 100644 index 0000000..a12ee1f --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLLoginBean.java @@ -0,0 +1,187 @@ +package com.hdl.linkpm.sdk.user.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/2/21. + * 鐧诲綍鍝嶅簲瀵硅薄 + */ +public class HDLLoginBean implements Serializable { + + ///鐢ㄦ埛鏈夋晥韬唤Token(涓嶇敤璁板綍浠�涔堟湁鏁堟湡,濡傛灉鐧婚檰澶辫触,灏辨嬁RefreshToken鍘诲埛鏂�) + private String accessToken; + /// 鐢ㄦ埛鏈夋晥韬唤Token杩囨湡鏃堕棿 + private String expiration; + /// 鍒锋柊accessToken鐢ㄧ殑token(涓嶇敤璁板綍浠�涔堟湁鏁堟湡,濡傛灉鍒锋柊澶辫触,灏辫涪浜哄嵆鍙�) + private String refreshToken; + /// 鍒锋柊Token杩囨湡鏃堕棿 + private String refreshExpiration; + /// 鐢ㄦ埛鍞竴ID + private String userId; + /// 鐧诲綍甯愬彿 + private String account; + /// 娣诲姞鍒癟oken澶撮儴鐨勪笢瑗�,璁よ瘉璇锋眰澶村墠缂�(涓嶈鐞嗗畠,鍙粰搴曞眰浣跨敤) + private String headerPrefix; + private String tokenUuid; + private String tokenType; + private String expiresIn; + private String refreshExpiresIn; + private String userType; + ///鐢ㄦ埛濮撳悕 + private String name; + private String userPhone; + /// 鐢ㄦ埛閭 + private String userEmail; + ///浼佷笟鍗曚綅id + private String companyId; + + ///瑙掕壊 + private String role; + + + @NonNull + public String getAccessToken() { + return accessToken == null ? "" : accessToken; + } + + public void setAccessToken(@NonNull String accessToken) { + this.accessToken = accessToken; + } + + @NonNull + public String getExpiration() { + return expiration == null ? "" : expiration; + } + + public void setExpiration(@NonNull String expiration) { + this.expiration = expiration; + } + + @NonNull + public String getRefreshToken() { + return refreshToken == null ? "" : refreshToken; + } + + public void setRefreshToken(@NonNull String refreshToken) { + this.refreshToken = refreshToken; + } + + @NonNull + public String getRefreshExpiration() { + return refreshExpiration == null ? "" : refreshExpiration; + } + + public void setRefreshExpiration(@NonNull String refreshExpiration) { + this.refreshExpiration = refreshExpiration; + } + + @NonNull + public String getUserId() { + return userId == null ? "" : userId; + } + + public void setUserId(@NonNull String userId) { + this.userId = userId; + } + + @NonNull + public String getAccount() { + return account == null ? "" : account; + } + + public void setAccount(@NonNull String account) { + this.account = account; + } + + @NonNull + public String getHeaderPrefix() { + return headerPrefix == null ? "" : headerPrefix; + } + + public void setHeaderPrefix(@NonNull String headerPrefix) { + this.headerPrefix = headerPrefix; + } + + @NonNull + public String getTokenUuid() { + return tokenUuid == null ? "" : tokenUuid; + } + + public void setTokenUuid(@NonNull String tokenUuid) { + this.tokenUuid = tokenUuid; + } + + @NonNull + public String getTokenType() { + return tokenType == null ? "" : tokenType; + } + + public void setTokenType(@NonNull String tokenType) { + this.tokenType = tokenType; + } + + @NonNull + public String getExpiresIn() { + return expiresIn == null ? "" : expiresIn; + } + + public void setExpiresIn(@NonNull String expiresIn) { + this.expiresIn = expiresIn; + } + + @NonNull + public String getRefreshExpiresIn() { + return refreshExpiresIn == null ? "" : refreshExpiresIn; + } + + public void setRefreshExpiresIn(@NonNull String refreshExpiresIn) { + this.refreshExpiresIn = refreshExpiresIn; + } + + @NonNull + public String getUserType() { + return userType == null ? "" : userType; + } + + public void setUserType(@NonNull String userType) { + this.userType = userType; + } + + @NonNull + public String getName() { + return name == null ? "" : name; + } + + public void setName(@NonNull String name) { + this.name = name; + } + + @NonNull + public String getUserPhone() { + return userPhone == null ? "" : userPhone; + } + + public void setUserPhone(@NonNull String userPhone) { + this.userPhone = userPhone; + } + + @NonNull + public String getUserEmail() { + return userEmail == null ? "" : userEmail; + } + + public void setUserEmail(@NonNull String userEmail) { + this.userEmail = userEmail; + } + + @NonNull + public String getCompanyId() { + return companyId == null ? "" : companyId; + } + + public void setCompanyId(@NonNull String companyId) { + this.companyId = companyId; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLMemberInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLMemberInfoBean.java new file mode 100644 index 0000000..621f73a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLMemberInfoBean.java @@ -0,0 +1,121 @@ +package com.hdl.linkpm.sdk.user.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/4/21. + */ +public class HDLMemberInfoBean implements Serializable { + private String memberId; + private String memberName; + private String memberHeadIcon; + private String memberPhonePrefix; + private String memberPhone; + private String memberEmail; + private String memberSex; + private String memberBirthday; + private String languageType; + private String loginName; + private String region; + + @NonNull + public String getMemberId() { + return memberId == null ? "" : memberId; + } + + public void setMemberId(@NonNull String memberId) { + this.memberId = memberId; + } + + @NonNull + public String getMemberName() { + return memberName == null ? "" : memberName; + } + + public void setMemberName(@NonNull String memberName) { + this.memberName = memberName; + } + + @NonNull + public String getMemberHeadIcon() { + return memberHeadIcon == null ? "" : memberHeadIcon; + } + + public void setMemberHeadIcon(@NonNull String memberHeadIcon) { + this.memberHeadIcon = memberHeadIcon; + } + + @NonNull + public String getMemberPhonePrefix() { + return memberPhonePrefix == null ? "" : memberPhonePrefix; + } + + public void setMemberPhonePrefix(@NonNull String memberPhonePrefix) { + this.memberPhonePrefix = memberPhonePrefix; + } + + @NonNull + public String getMemberPhone() { + return memberPhone == null ? "" : memberPhone; + } + + public void setMemberPhone(@NonNull String memberPhone) { + this.memberPhone = memberPhone; + } + + @NonNull + public String getMemberEmail() { + return memberEmail == null ? "" : memberEmail; + } + + public void setMemberEmail(@NonNull String memberEmail) { + this.memberEmail = memberEmail; + } + + @NonNull + public String getMemberSex() { + return memberSex == null ? "" : memberSex; + } + + public void setMemberSex(@NonNull String memberSex) { + this.memberSex = memberSex; + } + + @NonNull + public String getMemberBirthday() { + return memberBirthday == null ? "" : memberBirthday; + } + + public void setMemberBirthday(@NonNull String memberBirthday) { + this.memberBirthday = memberBirthday; + } + + @NonNull + public String getLanguageType() { + return languageType == null ? "" : languageType; + } + + public void setLanguageType(@NonNull String languageType) { + this.languageType = languageType; + } + + @NonNull + public String getLoginName() { + return loginName == null ? "" : loginName; + } + + public void setLoginName(@NonNull String loginName) { + this.loginName = loginName; + } + + @NonNull + public String getRegion() { + return region == null ? "" : region; + } + + public void setRegion(@NonNull String region) { + this.region = region; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLUserInfoBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLUserInfoBean.java new file mode 100644 index 0000000..72f193a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLUserInfoBean.java @@ -0,0 +1,114 @@ +package com.hdl.linkpm.sdk.user.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/3/21. + */ +public class HDLUserInfoBean implements Serializable { + /// 鐢ㄦ埛鍞竴ID + private String userId; + /// 鐧诲綍甯愬彿 + private String account; + /// 鐢ㄦ埛绫诲瀷 + private String userType; + /// 鐢ㄦ埛鍚嶅瓧 + private String name; + /// 鐢ㄦ埛鎵嬫満鍙� + private String userPhone; + /// 鐢ㄦ埛閭 + private String userEmail; + ///浼佷笟鍗曚綅id + private String companyId; + /// headerPrefix + private String headerPrefix; + + + public HDLUserInfoBean() { + + } + public HDLUserInfoBean(HDLLoginBean loginBean) { + this.userId = loginBean.getUserId(); + this.account = loginBean.getAccount(); + this.userType = loginBean.getUserType(); + this.name = loginBean.getName(); + this.userPhone = loginBean.getUserPhone(); + this.userEmail = loginBean.getUserEmail(); + this.companyId = loginBean.getCompanyId(); + this.headerPrefix = loginBean.getHeaderPrefix(); + } + + @NonNull + public String getUserId() { + return userId == null ? "" : userId; + } + + public void setUserId(@NonNull String userId) { + this.userId = userId; + } + + @NonNull + public String getAccount() { + return account == null ? "" : account; + } + + public void setAccount(@NonNull String account) { + this.account = account; + } + + @NonNull + public String getUserType() { + return userType == null ? "" : userType; + } + + public void setUserType(@NonNull String userType) { + this.userType = userType; + } + + @NonNull + public String getName() { + return name == null ? "" : name; + } + + public void setName(@NonNull String name) { + this.name = name; + } + + @NonNull + public String getUserPhone() { + return userPhone == null ? "" : userPhone; + } + + public void setUserPhone(@NonNull String userPhone) { + this.userPhone = userPhone; + } + + @NonNull + public String getUserEmail() { + return userEmail == null ? "" : userEmail; + } + + public void setUserEmail(@NonNull String userEmail) { + this.userEmail = userEmail; + } + + @NonNull + public String getCompanyId() { + return companyId == null ? "" : companyId; + } + + public void setCompanyId(@NonNull String companyId) { + this.companyId = companyId; + } + + @NonNull + public String getHeaderPrefix() { + return headerPrefix == null ? "" : headerPrefix; + } + + public void setHeaderPrefix(@NonNull String headerPrefix) { + this.headerPrefix = headerPrefix; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLUserRegionBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLUserRegionBean.java new file mode 100644 index 0000000..1285fae --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/HDLUserRegionBean.java @@ -0,0 +1,71 @@ +package com.hdl.linkpm.sdk.user.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/3/21. + */ +public class HDLUserRegionBean implements Serializable { + private String regionId; + private String regionName; + private String regionMark; + private String regionMqttUrl; + private String regionSlbUrl; + private String regionUrl; + + @NonNull + public String getRegionId() { + return regionId == null ? "" : regionId; + } + + public void setRegionId(@NonNull String regionId) { + this.regionId = regionId; + } + + @NonNull + public String getRegionName() { + return regionName == null ? "" : regionName; + } + + public void setRegionName(@NonNull String regionName) { + this.regionName = regionName; + } + + @NonNull + public String getRegionMark() { + return regionMark == null ? "" : regionMark; + } + + public void setRegionMark(@NonNull String regionMark) { + this.regionMark = regionMark; + } + + @NonNull + public String getRegionMqttUrl() { + return regionMqttUrl == null ? "" : regionMqttUrl; + } + + public void setRegionMqttUrl(@NonNull String regionMqttUrl) { + this.regionMqttUrl = regionMqttUrl; + } + + @NonNull + public String getRegionSlbUrl() { + return regionSlbUrl == null ? "" : regionSlbUrl; + } + + public void setRegionSlbUrl(@NonNull String regionSlbUrl) { + this.regionSlbUrl = regionSlbUrl; + } + + @NonNull + public String getRegionUrl() { + return regionUrl == null ? "" : regionUrl; + } + + public void setRegionUrl(@NonNull String regionUrl) { + this.regionUrl = regionUrl; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/ImageSubmitInfo.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/ImageSubmitInfo.java new file mode 100644 index 0000000..90f1e7b --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/ImageSubmitInfo.java @@ -0,0 +1,20 @@ +package com.hdl.linkpm.sdk.user.bean; + +import java.io.Serializable; + +/** + * Created by Zoro + * Created on 2021/5/21 + * description: + */ +public class ImageSubmitInfo implements Serializable { + private String url; + + public String getUrl() { + return url == null ? "" : url; + } + + public void setUrl(String url) { + this.url = url; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/MqttInfo.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/MqttInfo.java new file mode 100644 index 0000000..18f22b1 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/MqttInfo.java @@ -0,0 +1,47 @@ +package com.hdl.linkpm.sdk.user.bean; + +import java.io.Serializable; + +/** + * Created by Zoro + * Created on 2022/11/7 + * description: + */ +public class MqttInfo implements Serializable { + private String clientId; + private String passWord; + private String url; + private String userName; + + public String getClientId() { + return clientId == null ? "" : clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getPassWord() { + return passWord == null ? "" : passWord; + } + + public void setPassWord(String passWord) { + this.passWord = passWord; + } + + public String getUrl() { + return url == null ? "" : url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUserName() { + return userName == null ? "" : userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/NewVersionBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/NewVersionBean.java new file mode 100644 index 0000000..160623c --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/NewVersionBean.java @@ -0,0 +1,184 @@ +package com.hdl.linkpm.sdk.user.bean; + +import androidx.annotation.NonNull; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/15/21. + * 鏂扮増鏈鎯� + */ +public class NewVersionBean implements Serializable { + + private String version;//鏂扮殑鐗堟湰鍙� + private String appName;//app鍚嶇О + private String appCode;//app缂栫爜 + private boolean isEnforce;//鏄惁鏄己鍒舵洿鏂� + private String appMarket;//搴旂敤甯傚満鍚嶇О + private String releaseSystem;//鍙戝竷绯荤粺锛孖OS銆丄ndroid銆亀gt + private String updateDescription;//鏇存柊璇存槑json锛屽璇█鐢卞鎴风瑙f瀽 + private String packageUrl;//涓嬭浇鍦板潃 + private String remark;//澶囨敞 + private String limitGt;//minVersion 瑕佹眰瀹夸富App鐨勬渶浣庣増鏈彿 + private String limitLe;//maxVersion 闄愬埗瀹夸富App鐨勬渶楂樼増鏈彿 + private long size;//鏂囦欢澶у皬 + private String signMethod;//鏂囦欢绛惧悕绫诲瀷锛歮d5(32浣嶅皬鍐�) + private String sign;//鏂囦欢绛惧悕 + + + @NonNull + public String getVersion() { + return version == null ? "" : version; + } + + public void setVersion(@NonNull String version) { + this.version = version; + } + + @NonNull + public String getAppName() { + return appName == null ? "" : appName; + } + + public void setAppName(@NonNull String appName) { + this.appName = appName; + } + + @NonNull + public String getAppCode() { + return appCode == null ? "" : appCode; + } + + public void setAppCode(@NonNull String appCode) { + this.appCode = appCode; + } + + public boolean getIsEnforce() { + return isEnforce; + } + + public void setIsEnforce(boolean enforce) { + isEnforce = enforce; + } + + @NonNull + public String getAppMarket() { + return appMarket == null ? "" : appMarket; + } + + public void setAppMarket(@NonNull String appMarket) { + this.appMarket = appMarket; + } + + @NonNull + public String getReleaseSystem() { + return releaseSystem == null ? "" : releaseSystem; + } + + public void setReleaseSystem(@NonNull String releaseSystem) { + this.releaseSystem = releaseSystem; + } + + @NonNull + public String getUpdateDescription() { + return updateDescription == null ? "" : updateDescription; + } + + public void setUpdateDescription(@NonNull String updateDescription) { + this.updateDescription = updateDescription; + } + + @NonNull + public String getPackageUrl() { + return packageUrl == null ? "" : packageUrl; + } + + public void setPackageUrl(@NonNull String packageUrl) { + this.packageUrl = packageUrl; + } + + @NonNull + public String getRemark() { + return remark == null ? "" : remark; + } + + public void setRemark(@NonNull String remark) { + this.remark = remark; + } + + @NonNull + public String getLimitGt() { + return limitGt == null ? "" : limitGt; + } + + public void setLimitGt(@NonNull String limitGt) { + this.limitGt = limitGt; + } + + @NonNull + public String getLimitLe() { + return limitLe == null ? "" : limitLe; + } + + public void setLimitLe(@NonNull String limitLe) { + this.limitLe = limitLe; + } + + public boolean isEnforce() { + return isEnforce; + } + + public void setEnforce(boolean enforce) { + isEnforce = enforce; + } + + public long getSize() { + return size; + } + + public void setSize(long size) { + this.size = size; + } + + public String getSignMethod() { + return signMethod == null ? "" : signMethod; + } + + public void setSignMethod(String signMethod) { + this.signMethod = signMethod; + } + + public String getSign() { + return sign == null ? "" : sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + /** + * 鏇存柊璇存槑json锛屽璇█鏈夊鎴风瑙f瀽 + */ + public static class UpdateDescriptionBean implements Serializable { + private String Chinese;//涓枃鏇存柊璇存槑 + private String English;//鑻辨枃鏇存柊璇存槑 + + @NonNull + public String getChinese() { + return Chinese == null ? "" : Chinese; + } + + public void setChinese(@NonNull String chinese) { + Chinese = chinese; + } + + @NonNull + public String getEnglish() { + return English == null ? "" : English; + } + + public void setEnglish(@NonNull String english) { + English = english; + } + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/UploadImageRequest.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/UploadImageRequest.java new file mode 100644 index 0000000..9f6a055 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/bean/UploadImageRequest.java @@ -0,0 +1,56 @@ +package com.hdl.linkpm.sdk.user.bean; + +import java.io.Serializable; + +/** + * Created by jlchen on 12/10/21. + */ +public class UploadImageRequest implements Serializable { + private String prefix; + private String uid; + private String fileName; + private byte[] content; + + public UploadImageRequest() { + + } + + public UploadImageRequest(String prefix, String uid, String fileName, byte[] content) { + this.prefix = prefix; + this.uid = uid; + this.fileName = fileName; + this.content = content; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public byte[] getContent() { + return content; + } + + public void setContent(byte[] content) { + this.content = content; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/ILoginCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/ILoginCallBack.java new file mode 100644 index 0000000..4de6b92 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/ILoginCallBack.java @@ -0,0 +1,14 @@ +package com.hdl.linkpm.sdk.user.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.user.bean.HDLLoginBean; + +/** + * Created by jlchen on 12/2/21. + */ +public interface ILoginCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(HDLLoginBean loginBean); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IMemberInfoBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IMemberInfoBack.java new file mode 100644 index 0000000..28ce51b --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IMemberInfoBack.java @@ -0,0 +1,14 @@ +package com.hdl.linkpm.sdk.user.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.user.bean.HDLMemberInfoBean; + +/** + * Created by jlchen on 12/4/21. + */ +public interface IMemberInfoBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(HDLMemberInfoBean memberInfoBean); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IOnReloginListener.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IOnReloginListener.java new file mode 100644 index 0000000..9da0b32 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IOnReloginListener.java @@ -0,0 +1,13 @@ +package com.hdl.linkpm.sdk.user.callback; + +/** + * Created by jlchen on 12/2/21. + * 褰撶敤鎴稟ccessToken 閿欒鍚庡彂鍑虹殑閫氱煡 鐧诲嚭澶勭悊 + */ +public interface IOnReloginListener { + /** + * TOKEN澶辫触 闇�瑕侀��鍑洪噸鏂扮櫥褰� + * @param type: 0:姝e父閫�鍑� 1锛氭瀬鍏夋帹閫佸己鍒堕��鍑� + */ + void onReLogin(int type); +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IRegionByAccountCallBack.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IRegionByAccountCallBack.java new file mode 100644 index 0000000..b0c2d2a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/callback/IRegionByAccountCallBack.java @@ -0,0 +1,14 @@ +package com.hdl.linkpm.sdk.user.callback; + +import com.hdl.linkpm.sdk.core.callback.IBaseCallBack; +import com.hdl.linkpm.sdk.user.bean.HDLUserRegionBean; + +/** + * Created by jlchen on 12/3/21. + */ +public interface IRegionByAccountCallBack extends IBaseCallBack { + /** + * 鎴愬姛鍥炶皟 + */ + void onSuccess(HDLUserRegionBean regionBean); +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/controller/HDLPMUserController.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/controller/HDLPMUserController.java new file mode 100644 index 0000000..b5502d4 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/user/controller/HDLPMUserController.java @@ -0,0 +1,658 @@ +package com.hdl.linkpm.sdk.user.controller; + +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.linkpm.sdk.HDLLinkPMSdk; +import com.hdl.linkpm.sdk.core.api.HDLCloudUserApi; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IDefaultStrCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.user.bean.HDLLoginBean; +import com.hdl.linkpm.sdk.user.bean.HDLMemberInfoBean; +import com.hdl.linkpm.sdk.user.bean.HDLUserRegionBean; +import com.hdl.linkpm.sdk.user.bean.ImageSubmitInfo; +import com.hdl.linkpm.sdk.user.bean.MqttInfo; +import com.hdl.linkpm.sdk.user.bean.NewVersionBean; +import com.hdl.linkpm.sdk.user.bean.UploadImageRequest; +import com.hdl.linkpm.sdk.user.callback.ILoginCallBack; +import com.hdl.linkpm.sdk.user.callback.IMemberInfoBack; +import com.hdl.linkpm.sdk.user.callback.IRegionByAccountCallBack; +import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; + +import java.io.File; + +import io.reactivex.rxjava3.disposables.Disposable; + +/** + * Created by jlchen on 12/3/21. + * B绔敤鎴风浉鍏崇殑缃戠粶璇锋眰 + */ +public class HDLPMUserController { + + /** + * instance + */ + private volatile static HDLPMUserController instance; + + /** + * getInstance + * + * @return HDLUserController + */ + public static synchronized HDLPMUserController getInstance() { + if (instance == null) { + synchronized (HDLPMUserController.class) { + if (instance == null) { + instance = new HDLPMUserController(); + } + } + } + return instance; + } + + /** + * 鑾峰彇璐﹀彿鎵�鍦ㄥ尯鍩� + * + * @param account + * @param callBack + * @return https://nearest.hdlchina.com/smart-footstone/region/regionByUserAccount + */ + public Disposable regionByAccount(String account, IRegionByAccountCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getInitUrl() + HDLCloudUserApi.POST_RegionByAccount; + return HxHttp.builder() + .url(requestUrl) + .params("account", account) + .build() + .post() + .subscribeWith(new HDLResponse<HDLUserRegionBean>() { + @Override + public void onResponse(HDLUserRegionBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, account, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鐧诲綍 + * 閫氳繃璐﹀彿鍜屽瘑鐮� + * + * @param account 鎵嬫満鎴栬�呴偖绠� + * @param loginPwd 瀵嗙爜 + * @param callBack + * @return + */ + public Disposable loginByPassword(String account, String loginPwd, ILoginCallBack callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_LOGIN); + JsonObject json = new JsonObject(); + json.addProperty("account", account); + json.addProperty("loginPwd", loginPwd); +// json.addProperty("platform", "APP"); + json.addProperty("grantType", "password"); + + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<HDLLoginBean>() { + @Override + public void onResponse(HDLLoginBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鑾峰彇璐﹀彿鎵�鍦ㄥ尯鍩� + * + * @param account + * @param callBack + * @return https://nearest.hdlcontrol.com/smart-footstone/region/regionByUserAccount + */ + public Disposable regionByAccount(boolean isBooleanB, String account, IRegionByAccountCallBack callBack) { + + + String requestUrl = HDLLinkPMSdk.getInitUrl() + HDLCloudUserApi.POST_RegionByAccount; + if (!isBooleanB) { + requestUrl = HDLLinkPMSdk.getInitUrl() + HDLCloudUserApi.C_POST_RegionByAccount; + } + String finalRequestUrl = requestUrl; + return HxHttp.builder() + .url(requestUrl) + .params("account", account) + .build() + .post() + .subscribeWith(new HDLResponse<HDLUserRegionBean>() { + @Override + public void onResponse(HDLUserRegionBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(finalRequestUrl, account, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 鐧诲綍 + * 閫氳繃璐﹀彿鍜屽瘑鐮� + * + * @param isBooleanB true=B,false=C + * @param account 鎵嬫満鎴栬�呴偖绠� + * @param loginPwd 瀵嗙爜 + * @param callBack 鍥炶皟 + * @return - + */ + public Disposable loginByPassword(boolean isBooleanB, String account, String loginPwd, ILoginCallBack callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_LOGIN); + if (!isBooleanB) { + requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.C_POST_LOGIN); + } + JsonObject json = new JsonObject(); + json.addProperty("account", account); + json.addProperty("loginPwd", loginPwd); +// json.addProperty("platform", "APP"); + json.addProperty("grantType", "password"); + + String finalRequestUrl = requestUrl; + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<HDLLoginBean>() { + @Override + public void onResponse(HDLLoginBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(finalRequestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + + /** + * 鐧诲綍 + * 閫氳繃楠岃瘉鐮� + * + * @param account 鎵嬫満鎴栬�呴偖绠� + * @param vCode 楠岃瘉鐮� + * @param callBack 鍥炶皟 + * @return + */ + public Disposable loginByCode(String account, String vCode, ILoginCallBack callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_LOGIN); + JsonObject json = new JsonObject(); + json.addProperty("account", account); + json.addProperty("verifyCode", vCode); +// json.addProperty("platform", "APP"); + json.addProperty("grantType", "verify"); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<HDLLoginBean>() { + @Override + public void onResponse(HDLLoginBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 閫氱敤 鍙戦�侀獙璇佺爜鏂规硶 + * LanguageTypeEnum CHINESE,ENGLISH + * + * @param verifyType 1:娉ㄥ唽 2锛氭壘鍥炲瘑鐮� 3锛氱粦瀹� 4:楠岃瘉鐮佺櫥闄� 5:鏁忔劅鏁版嵁 + * @param account 閭鎴栬�呮墜鏈哄彿 + * @param isPhone 鏄惁鎵嬫満 + * @param phoneZoneCode 鎵嬫満鍥藉鍖哄彿 + * @param languageType 璇█ + * @param callBack + * @return + */ + public Disposable verificationCodeSend(int verifyType, String account, Boolean isPhone, String phoneZoneCode, String languageType, IDefaultCallBack callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_VERIFICATION_CODE_SEND); + JsonObject json = new JsonObject(); + json.addProperty("verifyType", verifyType); + json.addProperty("languageType", languageType); + json.addProperty("expireSecond", 300);////楠岃瘉鐮佽繃鏈熸椂闂达紙绉掞級,榛樿5鍒嗛挓 + //鏄惁鎵嬫満 + if (isPhone) { + json.addProperty("phone", account); + json.addProperty("phonePrefix", phoneZoneCode); + } else { + json.addProperty("mail", account); + } + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + + } + + /** + * 蹇樿瀵嗙爜锛岄噸缃瘑鐮� + * + * @param account 閭鎴栬�呮墜鏈哄彿 + * @param password 鏂板瘑鐮� + * @param vCode 楠岃瘉鐮� + * @param isPhone 鏄惁鎵嬫満 + * @param callBack 鍥炶皟 + */ + public Disposable forgetPassword(String account, String password, String vCode, Boolean isPhone, IDefaultCallBack callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_FORGET_PROGRAM_PWD); + JsonObject json = new JsonObject(); + json.addProperty("loginPwd", password); + json.addProperty("verifyCode", vCode); + //鏄惁鎵嬫満 + if (isPhone) { + json.addProperty("userPhone", account); + } else { + json.addProperty("userEmail", account); + } + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鏇存敼涓汉瀵嗙爜 + * + * @param userId 褰撳墠鐢ㄦ埛ID + * @param loginOldPwd 鑰佸瘑鐮� + * @param loginPwd 鏂板瘑鐮� + * @param callBack 鍥炶皟 + */ + public Disposable updateProgramPassword(String userId, String loginOldPwd, String loginPwd, IDefaultCallBack callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_UPDATE_PROGRAM_PASSWORD); + JsonObject json = new JsonObject(); + json.addProperty("userId", userId); + json.addProperty("loginOldPwd", loginOldPwd); + json.addProperty("loginPwd", loginPwd); + json.addProperty("confirmLoginPwd", loginPwd); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇鐢ㄦ埛涓汉淇℃伅 + * + * @param callBack + */ + public Disposable getMemberInfo(IMemberInfoBack callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_GET_MEMBER_INFO); + return HxHttp.builder() + .url(requestUrl) + .build() + .post() + .subscribeWith(new HDLResponse<HDLMemberInfoBean>() { + @Override + public void onResponse(HDLMemberInfoBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, null, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鏇存柊涓汉淇℃伅 + * memberHeadIcon銆乵emberName銆乵emberBirthday銆乴anguageType銆乵emberSex + * + * @param callBack + */ + public Disposable updateMemberInfo(JsonObject updateInfo, IDefaultCallBack callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_UPDATE_MEMBER_INFO); + return HxHttp.builder() + .url(requestUrl) + .raw(updateInfo.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, updateInfo, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇鐢ㄦ埛澶村儚璺緞 + * + * @param memberHeadIconKey 鐢ㄦ埛澶村儚imageKey + * @param callBack + */ + public Disposable getHeadImageUrl(String memberHeadIconKey, IDefaultStrCallBack callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_GET_IMAGE_URL); + return HxHttp.builder() + .url(requestUrl) + .params("imageKey", memberHeadIconKey) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, memberHeadIconKey, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 涓婁紶鐢ㄦ埛澶村儚 + * + * @param userId 鐢ㄦ埛id + * @param imageBytes 澶村儚鍥剧墖 + * @param callBack + * @return + */ + public Disposable uploadUserHeadImage(String userId, byte[] imageBytes, IDefaultStrCallBack callBack) { + UploadImageRequest uploadImageRequest = new UploadImageRequest(); + uploadImageRequest.setPrefix("Icon" + System.currentTimeMillis()); + uploadImageRequest.setUid(userId); + uploadImageRequest.setFileName("HeadImage.png"); + uploadImageRequest.setContent(imageBytes); + + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_UPLOAD_IMAGE); + return HxHttp.builder() + .url(requestUrl) + .raw(HDLGsonUtils.toJson(uploadImageRequest)) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, uploadImageRequest, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 涓婁紶鐢ㄦ埛澶村儚(鏂�) + * + * @param file 鍥剧墖 + * @param callBack + * @return + */ + public Disposable uplfadUserHeadImage(File file, IResponseCallBack<ImageSubmitInfo> callBack) { + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_UPLOAD_IMAGE_NEW); + return HxHttp.builder() + .url(requestUrl) + .file(file) + .build() + .upload() + .subscribeWith(new HDLResponse<ImageSubmitInfo>() { + @Override + public void onResponse(ImageSubmitInfo response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, null, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + +// /** +// * 鐗堟湰妫�娴嬫洿鏂� +// * +// * @param appName app鍚嶇О +// * @param version 鐗堟湰鍙� +// * @param callBack 濡傛灉onSuccess 鍥炶皟鐨刡ean涓虹┖锛屼唬琛ㄥ綋鍓嶇増鏈凡缁忔槸鏈�鏂扮増鏈紝娌℃湁鏂扮増鏈� +// * @return +// */ +// public Disposable checkAppVersion(String appName, String version, IResponseCallBack<NewVersionBean> callBack) { +// JsonObject json = new JsonObject(); +// json.addProperty("appName", appName); +// json.addProperty("version", version); +// json.addProperty("version", version); +// String requestUrl = HDLLinkPMSdk.getRegionUrl() + HDLCloudUserApi.POST_APP_APPVERSION_CHECK; +// return HxHttp.builder() +// .url(requestUrl) +// .raw(json.toString()) +// .build() +// .post() +// .subscribeWith(new HDLResponse<NewVersionBean>() { +// @Override +// public void onResponse(NewVersionBean response) { +// if (callBack != null) { +// callBack.onSuccess(response); +// } +// } +// +// @Override +// public void onFailure(HDLException e) { +// if (callBack != null) { +// callBack.onFailure(e); +// } +// } +// }); +// } + + /** + * 鐗堟湰妫�娴嬫洿鏂� + * 鏀寔Android銆乮OS銆亀gt妫�娴� + * + * @param appCode app缂栫爜 + * @param version 鐗堟湰鍙� + * @param releaseSystem 鍙戝竷绯荤粺锛孖OS銆丄ndroid, wgt + * @param callBack 濡傛灉onSuccess 鍥炶皟鐨刡ean涓虹┖锛屼唬琛ㄥ綋鍓嶇増鏈凡缁忔槸鏈�鏂扮増鏈紝娌℃湁鏂扮増鏈� + * @return + */ + public Disposable checkAppVersion(String appCode, String version, String releaseSystem, IResponseCallBack<NewVersionBean> callBack) { + JsonObject json = new JsonObject(); + json.addProperty("appCode", appCode); + json.addProperty("version", version); + json.addProperty("releaseSystem", releaseSystem); + String requestUrl = HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.POST_APP_APPVERSION_CHECK); + return HxHttp.builder() + .url(requestUrl) + .raw(json.toString()) + .build() + .post() + .subscribeWith(new HDLResponse<NewVersionBean>() { + @Override + public void onResponse(NewVersionBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇mqtt淇℃伅 + * + * @return + */ + public static Disposable getMqttInfo(String attachClientId, String homeType, String deviceUuid, IResponseCallBack<MqttInfo> listener) { + return HxHttp.builder() + .url(HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.MQTT_INFO_URL)) + .params("attachClientId", attachClientId) + .params("homeType", homeType) + .params("deviceUuid", deviceUuid) + .build() + .post() + .subscribeWith(new HDLResponse<MqttInfo>() { + @Override + public void onResponse(MqttInfo response) { + if (listener != null) { + listener.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + JsonObject json = new JsonObject(); + json.addProperty("attachClientId", attachClientId); + json.addProperty("homeType", homeType); + json.addProperty("deviceUuid", deviceUuid); + HDLExceptionSubmitUtils.submit(HDLCloudUserApi.getRequestUrl(HDLCloudUserApi.MQTT_INFO_URL), json, e); + if (listener != null) { + listener.onFailure(e); + } + } + }); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLExceptionSubmitUtils.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLExceptionSubmitUtils.java new file mode 100644 index 0000000..9793b65 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLExceptionSubmitUtils.java @@ -0,0 +1,65 @@ +package com.hdl.linkpm.sdk.utils; + +import android.text.TextUtils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.gson.JsonObject; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.exception.HDLLinkCopyException; +import com.hdl.log.enums.Level; +import com.hdl.log.utils.LogUtil; + +/** + * Created by Zoro + * Created on 2023/4/7 + * description: + */ +public class HDLExceptionSubmitUtils { + public static void submit(String requestUrl, JsonObject json, HDLException e) { + try { + LogUtil.log(requestUrl, "code:" + e.getCode() + "--msg:" + e.getMsg() + "--params锛�" + HDLGsonUtils.toJson(json), null, Level.high); + } catch (Exception e1) { + + } + } + + public static void submit(String requestUrl, JsonObject json, Throwable e) { + try { + LogUtil.log(requestUrl, "code:" + e.getMessage() + "--msg:" + e.getMessage() + "--params锛�" + HDLGsonUtils.toJson(json), null, Level.high); + } catch (Exception e1) { + + } + } + + public static void submit(String requestUrl, Object json, HDLException e) { + try { + LogUtil.log(requestUrl, "code:" + e.getCode() + "--msg:" + e.getMsg() + "--params锛�" + HDLGsonUtils.toJson(json), null, Level.high); + } catch (Exception e1) { + } + } + + public static void submit(String requestUrl, Object json, HDLLinkCopyException e) { + try { + JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(json)); + String utfStr = ""; + if (jsonObject != null) { + try { + byte[] data = jsonObject.getBytes("data"); + utfStr = new String(data); + } catch (Exception e1) { + + } + } + if (!TextUtils.isEmpty(utfStr)) { + LogUtil.log(requestUrl, "code:" + e.getCode() + "--msg:" + e.getMsg() + "--params锛�" + HDLGsonUtils.toJson(json) + "--utf-8锛�" + utfStr, null, Level.high); + } else { + LogUtil.log(requestUrl, "code:" + e.getCode() + "--msg:" + e.getMsg() + "--params锛�" + HDLGsonUtils.toJson(json), null, Level.high); + + } + } catch (Exception e1) { + + } + } + +} \ No newline at end of file diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLFileUtils.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLFileUtils.java new file mode 100644 index 0000000..09e2ed4 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLFileUtils.java @@ -0,0 +1,324 @@ +package com.hdl.linkpm.sdk.utils; + +import android.content.Context; +import android.content.res.AssetManager; + +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +/** + * Created by hxb on 2022/2/24. + */ +public class HDLFileUtils { + + /** + * 鍒涘缓鏂囦欢澶� + * + * @param filesPath + * @return + */ + public static boolean createOrExistsPrivateFolder(String filesPath) { + File dir = new File(filesPath); + return createOrExistsFolder(dir); + } + + public static String getJson(String fileName, Context context) { + //灏唈son鏁版嵁鍙樻垚瀛楃涓� + StringBuilder stringBuilder = new StringBuilder(); + try { + //鑾峰彇assets璧勬簮绠$悊鍣� + AssetManager assetManager = context.getAssets(); + //閫氳繃绠$悊鍣ㄦ墦寮�鏂囦欢骞惰鍙� + BufferedReader bf = new BufferedReader(new InputStreamReader( + assetManager.open(fileName))); + String line; + while ((line = bf.readLine()) != null) { + stringBuilder.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + } + return stringBuilder.toString(); + } + + /** + * 鍒涘缓鏂囦欢澶� + * + * @param file + * @return + */ + public static boolean createOrExistsFolder(File file) { + if (file == null) + return false; + boolean result = false; + + if (isFileExists(file) && isDirectory(file)) { + // 濡傛灉file瀛樺湪涓旀槸鏂囦欢澶癸紝杩斿洖true + return true; + } + // 濡傛灉鏂囦欢澶逛笉瀛樺湪锛屽垱寤烘枃浠跺す + if (file.mkdirs()) { + // 鍒涘缓鎴愬姛杩斿洖true + result = true; + } else { + // 鍒涘缓澶辫触杩斿洖false + result = false; + } + return result; + } + + public static boolean writeFile(String path, InputStream inputStream) { + FileOutputStream fop = null; + + try { + File file = new File(path); + fop = new FileOutputStream(file); + + if (!file.exists()) { + file.createNewFile(); + } + + byte[] inBytes = new byte[1024*5]; + int len = 0; + while (0 < (len = inputStream.read(inBytes, 0, inBytes.length))) { + fop.write(inBytes, 0, len); + fop.flush(); + } + return true; + } catch (IOException e) { + e.printStackTrace(); + return false; + } finally { + try { + if (fop != null) { + fop.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + if (inputStream != null) { + inputStream.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * 鏂囦欢鏄惁瀛樺湪 + * + * @param file + * @return + */ + public static boolean isFileExists(File file) { + if (file == null) + return false; + return file.exists(); + } + + /** + * 鏂囦欢澶规槸鍚﹀瓨鍦� + * + * @param file + * @return + */ + public static boolean isDirectory(File file) { + if (file == null) + return false; + return file.isDirectory(); + } + public static void byteToFile(byte[] buf, String filePath, String fileName) { + BufferedOutputStream bos = null; + FileOutputStream fos = null; + File file; + try { + createOrExistsPrivateFolder(filePath); + file = new File(filePath + File.separator + fileName); + fos = new FileOutputStream(file); + bos = new BufferedOutputStream(fos); + bos.write(buf); + } catch (Exception ignored) { + } finally { + if (bos != null) { + try { + bos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * 鍒犻櫎鏂囦欢锛屽彲浠ユ槸鍗曚釜鏂囦欢鎴栨枃浠跺す + * + * @param fileName + * 寰呭垹闄ょ殑鏂囦欢鍚� + * @return 鏂囦欢鍒犻櫎鎴愬姛杩斿洖true,鍚﹀垯杩斿洖false + */ + public static boolean delete(String fileName) { + File file = new File(fileName); + if (!file.exists()) { + System.out.println("鍒犻櫎鏂囦欢澶辫触锛�" + fileName + "鏂囦欢涓嶅瓨鍦�"); + return false; + } else { + if (file.isFile()) { + + return deleteFile(fileName); + } else { + return deleteDirectory(fileName); + } + } + } + + /** + * 鍒犻櫎鍗曚釜鏂囦欢 + * + * @param file 琚垹闄ゆ枃浠� + * @return 鍗曚釜鏂囦欢鍒犻櫎鎴愬姛杩斿洖true,鍚﹀垯杩斿洖false + */ + public static boolean deleteFile(File file) { + if (file.isFile() && file.exists()) { + file.delete(); + System.out.println("鍒犻櫎鍗曚釜鏂囦欢" + file.getName() + "鎴愬姛锛�"); + return true; + } else { + System.out.println("鍒犻櫎鍗曚釜鏂囦欢" + file.getName() + "澶辫触锛�"); + return false; + } + } + + /** + * 鍒犻櫎鍗曚釜鏂囦欢 + * + * @param fileName + * 琚垹闄ゆ枃浠剁殑鏂囦欢鍚� + * @return 鍗曚釜鏂囦欢鍒犻櫎鎴愬姛杩斿洖true,鍚﹀垯杩斿洖false + */ + public static boolean deleteFile(String fileName) { + File file = new File(fileName); + if (file.isFile() && file.exists()) { + file.delete(); + System.out.println("鍒犻櫎鍗曚釜鏂囦欢" + fileName + "鎴愬姛锛�"); + return true; + } else { + System.out.println("鍒犻櫎鍗曚釜鏂囦欢" + fileName + "澶辫触锛�"); + return false; + } + } + + /** + * 鍒犻櫎鐩綍锛堟枃浠跺す锛変互鍙婄洰褰曚笅鐨勬枃浠� + * + * @param dir + * 琚垹闄ょ洰褰曠殑鏂囦欢璺緞 + * @return 鐩綍鍒犻櫎鎴愬姛杩斿洖true,鍚﹀垯杩斿洖false + */ + public static boolean deleteDirectory(String dir) { + // 濡傛灉dir涓嶄互鏂囦欢鍒嗛殧绗︾粨灏撅紝鑷姩娣诲姞鏂囦欢鍒嗛殧绗� + if (!dir.endsWith(File.separator)) { + dir = dir + File.separator; + } + File dirFile = new File(dir); + // 濡傛灉dir瀵瑰簲鐨勬枃浠朵笉瀛樺湪锛屾垨鑰呬笉鏄竴涓洰褰曪紝鍒欓��鍑� + if (!dirFile.exists() || !dirFile.isDirectory()) { + System.out.println("鍒犻櫎鐩綍澶辫触" + dir + "鐩綍涓嶅瓨鍦紒"); + return false; + } + boolean flag = true; + // 鍒犻櫎鏂囦欢澶逛笅鐨勬墍鏈夋枃浠�(鍖呮嫭瀛愮洰褰�) + File[] files = dirFile.listFiles(); + for (int i = 0; i < files.length; i++) { + // 鍒犻櫎瀛愭枃浠� + if (files[i].isFile()) { + flag = deleteFile(files[i].getAbsolutePath()); + if (!flag) { + break; + } + } + // 鍒犻櫎瀛愮洰褰� + else { + flag = deleteDirectory(files[i].getAbsolutePath()); + if (!flag) { + break; + } + } + } + + if (!flag) { + System.out.println("鍒犻櫎鐩綍澶辫触"); + return false; + } + + // 鍒犻櫎褰撳墠鐩綍 + if (dirFile.delete()) { + System.out.println("鍒犻櫎鐩綍" + dir + "鎴愬姛锛�"); + return true; + } else { + System.out.println("鍒犻櫎鐩綍" + dir + "澶辫触锛�"); + return false; + } + } + // 鍒犻櫎鏂囦欢澶� + // param folderPath 鏂囦欢澶瑰畬鏁寸粷瀵硅矾寰� + + public static void delFolder(String folderPath) { + try { + delAllFile(folderPath); // 鍒犻櫎瀹岄噷闈㈡墍鏈夊唴瀹� + String filePath = folderPath; + filePath = filePath.toString(); + File myFilePath = new File(filePath); + myFilePath.delete(); // 鍒犻櫎绌烘枃浠跺す + } catch (Exception e) { + e.printStackTrace(); + } + } + + // 鍒犻櫎鎸囧畾鏂囦欢澶逛笅鎵�鏈夋枃浠� + // param path 鏂囦欢澶瑰畬鏁寸粷瀵硅矾寰� + public static boolean delAllFile(String path) { + boolean flag = false; + File file = new File(path); + if (!file.exists()) { + return flag; + } + if (!file.isDirectory()) { + return flag; + } + String[] tempList = file.list(); + File temp = null; + for (int i = 0; i < tempList.length; i++) { + if (path.endsWith(File.separator)) { + temp = new File(path + tempList[i]); + } else { + temp = new File(path + File.separator + tempList[i]); + } + if (temp.isFile()) { + temp.delete(); + } + if (temp.isDirectory()) { + delAllFile(path + "/" + tempList[i]);// 鍏堝垹闄ゆ枃浠跺す閲岄潰鐨勬枃浠� + delFolder(path + "/" + tempList[i]);// 鍐嶅垹闄ょ┖鏂囦欢澶� + flag = true; + } + } + return flag; + } +} + diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLGsonUtils.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLGsonUtils.java new file mode 100644 index 0000000..81b2e1a --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLGsonUtils.java @@ -0,0 +1,158 @@ +package com.hdl.linkpm.sdk.utils; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.google.gson.JsonSyntaxException; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; + +/** + * Created by Tong on 2021/11/10. + */ +public class HDLGsonUtils { + private static Gson gson; + + + public static <T> T fromJson(String json, Type type) { + Gson gson = getGson(); + return gson.fromJson(json, type); + } + + public static String toJson(Object object) { + return getGson().toJson(object); + } + + public static Gson getGson() { + if (gson == null) { + gson = new GsonBuilder() + .disableHtmlEscaping() + .registerTypeAdapter(String.class, new StringAdapter()) + .registerTypeAdapter(Integer.class, new IntegerDefault0Adapter()) + .registerTypeAdapter(Double.class, new DoubleDefault0Adapter()) + .registerTypeAdapter(Long.class, new LongDefault0Adapter()) + .create(); + } + return gson; + } + + private static class StringAdapter implements JsonSerializer<String>, JsonDeserializer<String> { + @Override + public String deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + if (json instanceof JsonPrimitive) { + return json.getAsString(); + } else { + return json.toString(); + } + } + + @Override + public JsonElement serialize(String src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src); + } + } + + private static class IntegerDefault0Adapter implements JsonSerializer<Integer>, JsonDeserializer<Integer> { + @Override + public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + try { + if (json.getAsString().equals("") || json.getAsString().equals("null")) { + return 0; + } + } catch (Exception ignore) { + } + try { + return json.getAsInt(); + } catch (NumberFormatException e) { + throw new JsonSyntaxException(e); + } + } + + @Override + public JsonElement serialize(Integer src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src); + } + } + + private static class DoubleDefault0Adapter implements JsonSerializer<Double>, JsonDeserializer<Double> { + @Override + public Double deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + try { + if (json.getAsString().equals("") || json.getAsString().equals("null")) { + return 0.00; + } + } catch (Exception ignore) { + } + try { + return json.getAsDouble(); + } catch (NumberFormatException e) { + throw new JsonSyntaxException(e); + } + } + + @Override + public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src); + } + } + + private static class LongDefault0Adapter implements JsonSerializer<Long>, JsonDeserializer<Long> { + @Override + public Long deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + try { + if (json.getAsString().equals("") || json.getAsString().equals("null")) { + return 0L; + } + } catch (Exception ignore) { + } + try { + return json.getAsLong(); + } catch (NumberFormatException e) { + throw new JsonSyntaxException(e); + } + } + + @Override + public JsonElement serialize(Long src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src); + } + } + + /** + * + * @param o + * @param <T> + * @return + */ + public static <T> JsonArray toJsonArray(Object o) { + try { + return getGson().fromJson(HDLGsonUtils.toJson(o), new TypeToken<JsonArray>() { + }.getType()); + } catch (Exception e) { + return null; + } + } + + /** + * copyProperties + * @param o + * @param type + * @param <T> + * @return + */ + public static <T> T copyProperties(Object o, Type type) { + Gson gson = getGson(); + return gson.fromJson(gson.toJson(o), type); + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLMD5Utils.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLMD5Utils.java new file mode 100644 index 0000000..6559b86 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLMD5Utils.java @@ -0,0 +1,185 @@ +package com.hdl.linkpm.sdk.utils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Created by Tong on 2021/11/3. + */ +public final class HDLMD5Utils { + + + /** + * MD5杞瓧绗︿覆 + */ + public static String encodeMD5(byte[] f) { + try { + MessageDigest digest = MessageDigest.getInstance("MD5"); + digest.update(f); + byte[] messageDigest = digest.digest(); + return toHexString(messageDigest); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return ""; + } + /** + * MD5杞瓧绗︿覆 + */ + public static String encodeMD5(String s) { + try { + MessageDigest digest = MessageDigest.getInstance("MD5"); + digest.update(s.getBytes(StandardCharsets.UTF_8)); + byte[] messageDigest = digest.digest(); + return toHexString(messageDigest); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return ""; + } + + private static String toHexString(byte[] keyData) { + if (keyData == null) { + return null; + } + int expectedStringLen = keyData.length * 2; + StringBuilder sb = new StringBuilder(expectedStringLen); + for (byte keyDatum : keyData) { + String hexStr = Integer.toString(keyDatum & 0x00FF, 16); + if (hexStr.length() == 1) { + hexStr = "0" + hexStr; + } + sb.append(hexStr); + } + return sb.toString(); + } + + /** + * MD5杞瓧绗︿覆 + * 棰濆鍊� + */ + public static String encodeMD52(String s) { + char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + try { + byte[] btInput = s.getBytes(StandardCharsets.UTF_8); + MessageDigest digest = MessageDigest.getInstance("MD5"); + digest.update(btInput); + byte[] md = digest.digest(); + int j = md.length; + char[] str = new char[j * 2]; + int k = 0; + for (byte byte0 : md) { + str[k++] = hexDigits[byte0 >>> 4 & 0xf]; + str[k++] = hexDigits[byte0 & 0xf]; + } + return new String(str); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * MD5鏂囦欢杞瓧绗︿覆 + */ + public static String encodeMD5(File f) { + if (!f.isFile()) { + return null; + } + MessageDigest digest; + byte[] buffer = new byte[1024]; + int len; + try { + digest = MessageDigest.getInstance("MD5"); + FileInputStream in = new FileInputStream(f); + while ((len = in.read(buffer, 0, 1024)) != -1) { + digest.update(buffer, 0, len); + } + in.close(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + BigInteger bigInt = new BigInteger(1, digest.digest()); + return bigInt.toString(16); + } + + + + + + public final static String md5(String plainText) { + +// 杩斿洖瀛楃涓� + + String md5Str = null; + + try { + +// 鎿嶄綔瀛楃涓� + + StringBuffer buf = new StringBuffer(); + + MessageDigest md = + + MessageDigest.getInstance("MD5"); + +// 娣诲姞瑕佽繘琛岃绠楁憳瑕佺殑淇℃伅,浣跨敤 plainText 鐨� byte + + + md.update(plainText.getBytes()); + +// 璁$畻鍑烘憳瑕�,瀹屾垚鍝堝笇璁$畻銆� + + byte b[] = md.digest(); + + int i; + + for (int offset = 0; offset < b.length; offset++) { + + i = b[offset]; + + if (i < 0) { + + i += 256; + + } + + if (i < 16) { + + buf.append("0"); + + } + +// 灏嗘暣鍨� 鍗佽繘鍒� i + + + buf.append(Integer.toHexString(i)); + + } + +// 32浣嶇殑鍔犲瘑 + + md5Str = buf.toString(); + +// 16浣嶇殑鍔犲瘑 + +// md5Str = buf.toString().md5Strstring(8,24); + + } catch (Exception e) { + + e.printStackTrace(); + + } + + return md5Str; + + } + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLSDKLog.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLSDKLog.java new file mode 100644 index 0000000..b424884 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLSDKLog.java @@ -0,0 +1,69 @@ +package com.hdl.linkpm.sdk.utils; + +import android.util.Log; + +import com.hdl.linkpm.sdk.HDLLinkPMSdk; + +/** + * Created by jlchen on 12/2/21. + * SDK鎵撳嵃鎺у埗宸ュ叿绫� + */ +public class HDLSDKLog { + + private static boolean isEnabled = false; + + public static void d(String tag, String msg) { + if (tag != null && msg != null && isEnabled) { + Log.d(HDLLinkPMSdk.SDK_NAME, tag + "-- " + msg); + } + } + + public static void e(String tag, String msg) { + if (tag != null && msg != null && isEnabled) { + Log.e(HDLLinkPMSdk.SDK_NAME, tag + "-- " + msg); + } + } + + public static void w(String tag, String msg) { + if (tag != null && msg != null && isEnabled) { + Log.w(HDLLinkPMSdk.SDK_NAME, tag + "-- " + msg); + } + } + + public static void v(String tag, String msg) { + if (tag != null && msg != null && isEnabled) { + Log.v(HDLLinkPMSdk.SDK_NAME, tag + "-- " + msg); + } + } + + public static void i(String tag, String msg) { + if (tag != null && msg != null && isEnabled) { + Log.i(HDLLinkPMSdk.SDK_NAME, tag + "-- " + msg); + } + } + + public static void i(String msg) { + if (msg != null && isEnabled) { + Log.i(HDLLinkPMSdk.SDK_NAME, msg); + } + } + + public static void e(String msg) { + if (msg != null && isEnabled) { + Log.e(HDLLinkPMSdk.SDK_NAME, msg); + } + } + + /** + * 鏄惁寮�鍚疭DK鏃ュ織鎵撳嵃 + * @param bOpen + */ + public static void setHDLSDKLogOpen(boolean bOpen){ + isEnabled = bOpen; + } + + public static boolean isLogOpen() { + return isEnabled; + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLSDKSPUtils.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLSDKSPUtils.java new file mode 100644 index 0000000..ce21744 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/utils/HDLSDKSPUtils.java @@ -0,0 +1,147 @@ +package com.hdl.linkpm.sdk.utils; + +import android.content.Context; +import android.content.SharedPreferences; + +import androidx.annotation.NonNull; + +import com.hdl.linkpm.sdk.HDLLinkPMSdk; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +/** + * Created by Tong on 2021/11/3. + */ +public class HDLSDKSPUtils { + + private static final String APP_PREFERENCES_KEY = "com.hdl.link.sdk.profile"; + private static final SharedPreferences PREFERENCES = + HDLLinkPMSdk.getContext().getApplicationContext().getSharedPreferences(APP_PREFERENCES_KEY, Context.MODE_PRIVATE); + + private static SharedPreferences getAppPreference() { + return PREFERENCES; + } + + + //======閫氱敤瀛樺偍======== + public static void put(@NonNull final String key, final String value) { + getAppPreference().edit().putString(key, value).apply(); + } + + + public static String getString(@NonNull final String key) { + return getString(key, ""); + } + + + public static String getString(@NonNull final String key, final String defaultValue) { + return getAppPreference().getString(key, defaultValue); + } + + + public static void put(@NonNull final String key, final int value) { + put(key, value, false); + } + + + public static void put(@NonNull final String key, final int value, final boolean isCommit) { + getAppPreference().edit().putInt(key, value).apply(); + } + + + public static int getInt(@NonNull final String key) { + return getInt(key, -1); + } + + + public static int getInt(@NonNull final String key, final int defaultValue) { + return getAppPreference().getInt(key, defaultValue); + } + + + public static void put(@NonNull final String key, final long value) { + getAppPreference().edit().putLong(key, value).apply(); + } + + + public static long getLong(@NonNull final String key) { + return getLong(key, -1L); + } + + + public static long getLong(@NonNull final String key, final long defaultValue) { + return getAppPreference().getLong(key, defaultValue); + } + + + public static void put(@NonNull final String key, final float value) { + getAppPreference().edit().putFloat(key, value).apply(); + } + + + public static float getFloat(@NonNull final String key) { + return getFloat(key, -1f); + } + + + public static float getFloat(@NonNull final String key, final float defaultValue) { + return getAppPreference().getFloat(key, defaultValue); + } + + + public static void put(@NonNull final String key, final boolean value) { + getAppPreference().edit().putBoolean(key, value).apply(); + } + + + public static boolean getBoolean(@NonNull final String key) { + return getBoolean(key, false); + } + + + public static boolean getBoolean(@NonNull final String key, final boolean defaultValue) { + return getAppPreference().getBoolean(key, defaultValue); + } + + + public static void put(@NonNull final String key, final Set<String> value) { + getAppPreference().edit().putStringSet(key, value).apply(); + } + + + public static Set<String> getStringSet(@NonNull final String key) { + return getStringSet(key, Collections.emptySet()); + } + + + public static Set<String> getStringSet(@NonNull final String key, + final Set<String> defaultValue) { + return getAppPreference().getStringSet(key, defaultValue); + } + + + public static Map<String, ?> getAll() { + return getAppPreference().getAll(); + } + + + public static boolean contains(@NonNull final String key) { + return getAppPreference().contains(key); + } + + + public static void remove(@NonNull final String key) { + getAppPreference().edit().remove(key).apply(); + } + + public static void clear() { + getAppPreference() + .edit() + .clear() + .apply(); + } + + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/HDLPMDataBackup.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/HDLPMDataBackup.java new file mode 100644 index 0000000..ac3b0f9 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/HDLPMDataBackup.java @@ -0,0 +1,127 @@ +package com.hdl.linkpm.sdk.workbench.databackup; + +import com.hdl.linkpm.sdk.core.bean.PageInfoListBean; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.workbench.databackup.bean.BackupListBean; +import com.hdl.linkpm.sdk.workbench.databackup.bean.GatewayBackupBean; +import com.hdl.linkpm.sdk.workbench.databackup.controller.DataBackupController; + +import java.util.List; + +/** + * Created by hxb on 2022/2/23. + */ +public class HDLPMDataBackup { + //instance + private volatile static HDLPMDataBackup instance; + + /** + * getInstance + * + * @return HDLPMDataBackup + */ + public static synchronized HDLPMDataBackup getInstance() { + if (instance == null) { + synchronized (HDLPMDataBackup.class) { + if (instance == null) { + instance = new HDLPMDataBackup(); + } + } + } + return instance; + } + + /***************澶囦唤鏂囦欢涓婁紶涓嬭浇***************/ + /** + * 涓婁紶澶囦唤鏂囦欢 + * + * @param homeId 浣忓畢id + * @param data 鏂囦欢 澶囦唤鏂囦欢鏁版嵁 + * @param callBack + * @return + */ + public void databackupUpload(String homeId, byte[] data, IDefaultCallBack callBack) { + DataBackupController.getInstance().dataBackupUpload(homeId, data, callBack); + } + + /** + * 鍒犻櫎澶囦唤鏁版嵁 + * + * @param homeId 浣忓畢id + * @param callBack + * @return + */ + public void databackDel(String homeId, IDefaultCallBack callBack) { + DataBackupController.getInstance().databackDel(homeId, callBack); + } + + /** + * 鑾峰彇涓嬭浇鏈�鏂拌矾寰� + * + * @param homeId 浣忓畢id + * @param filePath + * @param callBack + * @return + */ + public void databackDownload(String homeId, String filePath, IDefaultCallBack callBack) { + DataBackupController.getInstance().databackDownload(homeId, filePath, callBack); + } + + /** + * 鑾峰彇浜戠澶囦唤鍒楄〃 + * + * @param userId 鐢ㄦ埛id + * @param pageNo 寮�濮嬬储寮� + * @param pageSize 椤甸潰澶у皬 + * @param callBack + * @return + */ + public void databackList(String userId, int pageNo, int pageSize, IResponseCallBack<PageInfoListBean<BackupListBean>> callBack) { + DataBackupController.getInstance().databackList(userId, pageNo, pageSize, callBack); + } + + /** + * 鑾峰彇缃戝叧鏈�鏂扮殑涓変唤澶囦唤鏁版嵁 + * + * @param homeId 浣忓畢Id + * @param gatewayId 浜戠涓婄綉鍏砱atewayId + * @param callBack 鍥炶皟 + */ + public void getGatewayBackupDataList(String homeId, String gatewayId, IResponseCallBack<List<GatewayBackupBean>> callBack) { + DataBackupController.getInstance().getGatewayBackupDataList(homeId, gatewayId, callBack); + } + /** + * 鑾峰彇璋冭瘯瀹屾垚鐨勫浠芥枃浠跺洖澶� + * + * @param homeId 浣忓畢Id + * @param gatewayId 浜戠涓婄綉鍏砱atewayId + * @param callBack 鍥炶皟 + */ + public void getDebugGatewayBackupDataList(String homeId, String gatewayId, IResponseCallBack<GatewayBackupBean> callBack) { + DataBackupController.getInstance().getDebugGatewayBackupDataList(homeId, gatewayId, callBack); + } + /** + * 璋冭瘯瀹濋�夋嫨缃戝叧鎭㈠鐨勫浠芥枃浠� + * + * @param homeId 浣忓畢Id + * @param gatewayId 浜戠涓婄綉鍏砱atewayId + * @param recordId 澶囦唤璁板綍id + * @param callBack 鍥炶皟 + */ + public void getGatewayBackupRecover(String homeId, String gatewayId,long recordId, IResponseCallBack callBack) { + DataBackupController.getInstance().getGatewayBackupRecover(homeId, gatewayId,recordId, callBack); + } + /** + * 缃戝叧鏇挎崲 + * + * @param homeId 浣忓畢Id + * @param gatewayId 浜戠涓婄綉鍏砱atewayId + * @param newMac newMac 鏂扮綉鍏砿ac + * @param callBack 鍥炶皟 + */ + public void getGatewayReplace(String homeId, String gatewayId,String newMac, IResponseCallBack callBack) { + DataBackupController.getInstance().getGatewayReplace(homeId, gatewayId,newMac, callBack); + } + +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/bean/BackupListBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/bean/BackupListBean.java new file mode 100644 index 0000000..40fa5ad --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/bean/BackupListBean.java @@ -0,0 +1,117 @@ +package com.hdl.linkpm.sdk.workbench.databackup.bean; + +/** + * Created by hxb on 2022/2/28. + */ +public class BackupListBean { + + /** + * 浣忓畢Id + */ + private String houseId; + /** + * 澶囦唤鏃堕棿 + */ + private Long backupTime; + + private String houseName;//浣忓畢鍚嶇О + private String communityName;//椤圭洰鍚嶇О + private String houseLayoutName;//鎴垮瀷鎴栨埛鍨嬪悕绉� + private String debugStatus;//璋冭瘯鐘舵�� + + /** + * 鑾峰彇浣忓畢Id + * @return + */ + public String getHouseId() { + return houseId; + } + + /** + * 璁剧疆浣忓畢Id + * @param houseId + */ + public void setHouseId(String houseId) { + this.houseId = houseId; + } + + /** + * 鑾峰彇澶囦唤鏃堕棿 + * @return + */ + public Long getBackupTime() { + return backupTime; + } + + /** + * 璁剧疆澶囦唤鏃堕棿 + * @param backupTime + */ + public void setBackupTime(Long backupTime) { + this.backupTime = backupTime; + } + + /** + * 鑾峰彇浣忓畢鍚嶇О + * @return + */ + public String getHouseName() { + return houseName; + } + + /** + * 璁剧疆浣忓畢鍚嶇О + * @param houseName + */ + public void setHouseName(String houseName) { + this.houseName = houseName; + } + + /** + * 鑾峰彇椤圭洰鍚嶇О + * @return + */ + public String getCommunityName() { + return communityName; + } + + /** + * 璁剧疆椤圭洰鍚嶇О + * @param communityName + */ + public void setCommunityName(String communityName) { + this.communityName = communityName; + } + + /** + * 鑾峰彇鎴垮瀷鎴栨埛鍨嬪悕绉� + * @return + */ + public String getHouseLayoutName() { + return houseLayoutName; + } + + /** + * 璁剧疆鎴垮瀷鎴栨埛鍨嬪悕绉� + * @param houseLayoutName + */ + public void setHouseLayoutName(String houseLayoutName) { + this.houseLayoutName = houseLayoutName; + } + + /** + * 鑾峰彇璋冭瘯鐘舵�� + * @return + */ + public String getDebugStatus() { + return debugStatus; + } + + /** + * 璁剧疆璋冭瘯鐘舵�� + * @param debugStatus + */ + public void setDebugStatus(String debugStatus) { + this.debugStatus = debugStatus; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/bean/GatewayBackupBean.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/bean/GatewayBackupBean.java new file mode 100644 index 0000000..b9be072 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/bean/GatewayBackupBean.java @@ -0,0 +1,62 @@ +package com.hdl.linkpm.sdk.workbench.databackup.bean; + +import java.io.Serializable; + +public class GatewayBackupBean implements Serializable{ + + private long recordId;//澶囦唤璁板綍id + private long createTime;//澶囦唤鏃堕棿 + private long gatewayId;//缃戝叧id + private String spaceCode;//绌洪棿缂栫爜(璋冭瘯瀹濊幏鍙栧~houseId) + private int backupOrder;//1 2 3 鏈�鏂板浠芥帓搴� + private String backupFileUrl;//澶囦唤鏂囦欢涓嬭浇鍦板潃 + + + public long getRecordId() { + return recordId; + } + + public void setRecordId(long recordId) { + this.recordId = recordId; + } + + public long getCreateTime() { + return createTime; + } + + public void setCreateTime(long createTime) { + this.createTime = createTime; + } + + public long getGatewayId() { + return gatewayId; + } + + public void setGatewayId(long gatewayId) { + this.gatewayId = gatewayId; + } + + public String getSpaceCode() { + return spaceCode; + } + + public void setSpaceCode(String spaceCode) { + this.spaceCode = spaceCode; + } + + public int getBackupOrder() { + return backupOrder; + } + + public void setBackupOrder(int backupOrder) { + this.backupOrder = backupOrder; + } + + public String getBackupFileUrl() { + return backupFileUrl; + } + + public void setBackupFileUrl(String backupFileUrl) { + this.backupFileUrl = backupFileUrl; + } +} diff --git a/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/controller/DataBackupController.java b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/controller/DataBackupController.java new file mode 100644 index 0000000..93c8e76 --- /dev/null +++ b/HDLLinkPMSdk/src/main/java/com/hdl/linkpm/sdk/workbench/databackup/controller/DataBackupController.java @@ -0,0 +1,377 @@ +package com.hdl.linkpm.sdk.workbench.databackup.controller; + + + +import android.os.Environment; + +import com.google.gson.JsonObject; +import com.hdl.hdlhttp.HxHttp; +import com.hdl.hdlhttp.callback.HxException; +import com.hdl.linkpm.sdk.HDLLinkPMSdk; +import com.hdl.linkpm.sdk.core.api.HDLCloudUserApi; +import com.hdl.linkpm.sdk.core.bean.PageInfoListBean; +import com.hdl.linkpm.sdk.core.callback.IDefaultCallBack; +import com.hdl.linkpm.sdk.core.callback.IResponseCallBack; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.linkpm.sdk.core.response.HDLResponse; +import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; +import com.hdl.linkpm.sdk.utils.HDLFileUtils; +import com.hdl.linkpm.sdk.utils.HDLGsonUtils; +import com.hdl.linkpm.sdk.workbench.databackup.bean.BackupListBean; +import com.hdl.linkpm.sdk.workbench.databackup.bean.GatewayBackupBean; + +import java.io.File; +import java.util.List; + +import io.reactivex.rxjava3.disposables.Disposable; +import io.reactivex.rxjava3.subscribers.DisposableSubscriber; +import okhttp3.ResponseBody; + +/** + * Created by hxb on 2022/2/23. + */ +public class DataBackupController { + /** + * instance + */ + private volatile static DataBackupController instance; + + /** + * getInstance + * + * @return DataBackupController + */ + public static synchronized DataBackupController getInstance() { + if (instance == null) { + synchronized (DataBackupController.class) { + if (instance == null) { + instance = new DataBackupController(); + } + } + } + return instance; + } + + /** + * 涓婁紶澶囦唤鏁版嵁 + * + * @param homeId 浣忓畢ID + * @param data 涓婁紶鐨勬暟鎹唴瀹� + * @param callBack + * @return + */ + public Disposable dataBackupUpload(String homeId, byte[] data, IDefaultCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_BACKUP_UPLOAD + "?houseId=" + homeId; + String path = HDLLinkPMSdk.getContext().getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getPath() + "/Temp/"; + String fileName = System.currentTimeMillis() + ""; + HDLFileUtils.byteToFile(data, path, fileName); + File file = new File(path + fileName); + + return HxHttp.builder() + .file(file, "file") + .url(requestUrl) + .build() + .upload() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String code) { + HDLFileUtils.deleteFile(file); + if (callBack != null) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLFileUtils.deleteFile(file); + HDLExceptionSubmitUtils.submit(requestUrl, homeId, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鍒犻櫎澶囦唤鏁版嵁 + * + * @param homeId 浣忓畢ID + * @param callBack + * @return + */ + public Disposable databackDel(String homeId, IDefaultCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_BACKUP_DEL; + JsonObject json = new JsonObject(); + json.add("houseIds", HDLGsonUtils.toJsonArray(new String[]{homeId})); + return HxHttp.builder() + .raw(json.toString()) + .url(requestUrl) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String url) { + if (null != callBack) { + callBack.onSuccess(); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇鏁版嵁鏈�鏂颁笅杞借矾寰� + * + * @param homeId 浣忓畢ID + * @param callBack + * @return + */ + public Disposable databackDownload(String homeId,String path, IDefaultCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_BACKUP_DOWNLOAD_URL; + JsonObject json = new JsonObject(); + json.addProperty("houseId", homeId); + return HxHttp.builder() + .raw(json.toString()) + .url(requestUrl) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String url) { + HxHttp.builder() + .url(url) + .build() + .download() + .subscribe(new DisposableSubscriber<ResponseBody>() { + @Override + public void onNext(ResponseBody responseBody) { + if (HDLFileUtils.writeFile(path, responseBody.byteStream())) { + if (null != callBack) { + callBack.onSuccess(); + } + } else { + if (callBack != null) { + callBack.onFailure(new HDLException(HxException.ErrorCode.UNKNOWN, "Download Fail")); + } + } + } + + @Override + public void onError(Throwable t) { + if (callBack != null) { + callBack.onFailure(new HDLException(HxException.ErrorCode.UNKNOWN, t.getMessage())); + } + } + + @Override + public void onComplete() { + + } + }); + + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 鑾峰彇澶囦唤鍒楄〃 + * + * @param userId 鐢ㄦ埛ID + * @param pageNo 寮�濮嬬储寮� + * @param pageSize 椤甸潰澶у皬 + * @param callBack + * @return + */ + public Disposable databackList(String userId,int pageNo, int pageSize, IResponseCallBack<PageInfoListBean<BackupListBean>> callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_BACKUP_LIST; + JsonObject json = new JsonObject(); + json.addProperty("pageNo", pageNo); + json.addProperty("pageSize", pageSize); + json.addProperty("debugUserId", userId); + return HxHttp.builder() + .raw(json.toString()) + .url(requestUrl) + .build() + .post() + .subscribeWith(new HDLResponse<PageInfoListBean<BackupListBean>>() { + @Override + public void onResponse(PageInfoListBean<BackupListBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + + /** + * 鑾峰彇缃戝叧鏈�鏂扮殑涓変唤澶囦唤鏁版嵁 + * + * @param homeId 浣忓畢Id + * @param gatewayId 浜戠涓婄綉鍏砱atewayId + * @param callBack + * @return + */ + public Disposable getGatewayBackupDataList(String homeId, String gatewayId, IResponseCallBack<List<GatewayBackupBean>> callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GATEWAY_BACKUP_LIST; + JsonObject json = new JsonObject(); + json.addProperty("spaceCode", homeId); + json.addProperty("gatewayId", gatewayId); + return HxHttp.builder() + .raw(json.toString()) + .url(requestUrl) + .build() + .post() + .subscribeWith(new HDLResponse<List<GatewayBackupBean>>() { + @Override + public void onResponse(List<GatewayBackupBean> response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + /** + * 鑾峰彇璋冭瘯瀹屾垚鐨勫浠芥枃浠跺洖澶� + * + * @param homeId 浣忓畢Id + * @param gatewayId 浜戠涓婄綉鍏砱atewayId + * @param callBack + * @return + */ + public Disposable getDebugGatewayBackupDataList(String homeId, String gatewayId, IResponseCallBack<GatewayBackupBean> callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GATEWAY_BACKUP_DEBUGCOMPLETEBACKUPFILE; + JsonObject json = new JsonObject(); + json.addProperty("spaceCode", homeId); + json.addProperty("gatewayId", gatewayId); + return HxHttp.builder() + .raw(json.toString()) + .url(requestUrl) + .build() + .post() + .subscribeWith(new HDLResponse<GatewayBackupBean>() { + @Override + public void onResponse(GatewayBackupBean response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + /** + * 璋冭瘯瀹濋�夋嫨缃戝叧鎭㈠鐨勫浠芥枃浠� + * + * @param homeId 浣忓畢Id + * @param gatewayId 浜戠涓婄綉鍏砱atewayId + * @param recordId 澶囦唤璁板綍id + * @param callBack 鍥炶皟 + * @return Disposable + */ + public Disposable getGatewayBackupRecover(String homeId, String gatewayId,long recordId, IResponseCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GATEWAY_BACKUP_RECOVER; + JsonObject json = new JsonObject(); + json.addProperty("spaceCode", homeId); + json.addProperty("gatewayId", gatewayId); + json.addProperty("recordId", recordId); + return HxHttp.builder() + .raw(json.toString()) + .url(requestUrl) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + /** + * 缃戝叧鏇挎崲 + * + * @param homeId 浣忓畢Id + * @param gatewayId 浜戠涓婄綉鍏砱atewayId + * @param newMac newMac 鏂扮綉鍏砿ac + * @param callBack 鍥炶皟 + * @return Disposable + */ + public Disposable getGatewayReplace(String homeId, String gatewayId,String newMac, IResponseCallBack callBack) { + String requestUrl = HDLLinkPMSdk.getUserRegionUrl() + HDLCloudUserApi.POST_GATEWAY_REPLACE; + JsonObject json = new JsonObject(); + json.addProperty("homeId", homeId); + json.addProperty("gatewayId", gatewayId);//鏃х綉鍏砳d + json.addProperty("newMac", newMac);//newMac 鏂扮綉鍏砿ac + return HxHttp.builder() + .raw(json.toString()) + .url(requestUrl) + .build() + .post() + .subscribeWith(new HDLResponse<String>() { + @Override + public void onResponse(String response) { + if (callBack != null) { + callBack.onSuccess(response); + } + } + + @Override + public void onFailure(HDLException e) { + HDLExceptionSubmitUtils.submit(requestUrl, json, e); + if (callBack != null) { + callBack.onFailure(e); + } + } + }); + } + + +} diff --git a/app/build.gradle b/app/build.gradle index 04766f4..a8bae06 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -153,6 +153,7 @@ implementation project(path: ':third-zxing') //Link鏈湴搴擄紙鍦ㄧ嚎渚濊禆缃戠粶搴擄級 implementation 'com.hdl.android:pmsdk:1.0.2' + implementation project(path: ':HDLLinkPMSdk') implementation 'com.hdl.android:debugsdk:1.0.33' testImplementation 'junit:junit:4.13.2' diff --git a/local.properties b/local.properties index cf7466a..ec07a0d 100644 --- a/local.properties +++ b/local.properties @@ -4,5 +4,5 @@ # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. -#Wed Jul 10 16:17:02 CST 2024 -sdk.dir=/Users/user/Library/Android/sdk +#Thu Oct 24 10:34:15 CST 2024 +sdk.dir=/Users/hdl/Library/Developer/Xamarin/android-sdk-macosx diff --git a/settings.gradle b/settings.gradle index 151d3ce..ed4887a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,3 +5,4 @@ include ':aa_chart_core' include ':pickerview' include ':wheelview' +include ':HDLLinkPMSdk' -- Gitblit v1.8.0