更新英文语言相关问题。
This commit is contained in:
@@ -9,8 +9,9 @@ allprojects {
|
||||
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven { url 'https://developer.huawei.com/repo/'}
|
||||
// maven { url "https://repo.jiguang.cn/repository/maven2/" }
|
||||
google()
|
||||
mavenCentral()
|
||||
// mavenCentral()
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
|
||||
systemProp.http.proxyHost=pp.it.real.he-info.cn
|
||||
systemProp.http.proxyPort=7897
|
||||
systemProp.https.proxyHost=pp.it.real.he-info.cn
|
||||
systemProp.https.proxyPort=7897
|
||||
# systemProp.http.proxyHost=pp.it.real.he-info.cn
|
||||
# systemProp.http.proxyPort=7897
|
||||
# systemProp.https.proxyHost=pp.it.real.he-info.cn
|
||||
# systemProp.https.proxyPort=7897
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,11 +1,23 @@
|
||||
# 太和e护
|
||||
# storePassword=taihe601
|
||||
# keyPassword=taihe601
|
||||
# keyAlias=testalias
|
||||
# storeFile=test.keystore
|
||||
storePassword=taihe601
|
||||
keyPassword=taihe601
|
||||
keyAlias=testalias
|
||||
storeFile=test.keystore
|
||||
|
||||
# 眠花糖
|
||||
storePassword=mht@123456
|
||||
keyPassword=mht@123456
|
||||
keyAlias=mianhuatang
|
||||
storeFile=AppKeys.jks
|
||||
# storePassword=mht@123456
|
||||
# keyPassword=mht@123456
|
||||
# keyAlias=mianhuatang
|
||||
# storeFile=AppKeys.jks
|
||||
|
||||
# 东华
|
||||
# storePassword=taihe601
|
||||
# keyPassword=taihe601
|
||||
# keyAlias=donghua
|
||||
# storeFile=donghua.jks
|
||||
|
||||
# 沃棣
|
||||
# storePassword=taihe601
|
||||
# keyPassword=taihe601
|
||||
# keyAlias=wodi
|
||||
# storeFile=wodi.jks
|
||||
@@ -1,9 +1,10 @@
|
||||
sdk.dir=C:\\Users\\wyf\\AppData\\Local\\Android\\sdk
|
||||
flutter.sdk=D:\\flutter_res\\flutter
|
||||
flutter.buildMode=debug
|
||||
flutter.buildMode=release
|
||||
flutter.versionName=1.0.0
|
||||
flutter.versionCode=1
|
||||
flutter.minSdkVersion=22
|
||||
flutter.targetSdkVersion=35
|
||||
flutter.compileSdkVersion=35
|
||||
flutter.ndkVersion=28.0.12433566
|
||||
app.type=3
|
||||
@@ -1,7 +1,7 @@
|
||||
# 太和版本信息
|
||||
# flutter.android.versionName=2.0.5
|
||||
# flutter.android.versionCode=11
|
||||
# 太和版本信息(未提交)
|
||||
flutter.android.versionName=2.0.8
|
||||
flutter.android.versionCode=14
|
||||
|
||||
# 智慧眠花糖版本信息【最新,未提交商店】
|
||||
flutter.android.versionName=2.0.9
|
||||
flutter.android.versionCode=13
|
||||
# 智慧眠花糖版本信息【最新,已提交商店】
|
||||
# flutter.android.versionName=2.0.11
|
||||
# flutter.android.versionCode=17
|
||||
@@ -653,6 +653,16 @@
|
||||
"快检中...": "Quick Checking...",
|
||||
"体验异常结束": "Abnormal experience ended",
|
||||
"是否确认结束?": "Are you sure to end?",
|
||||
"蓝牙未开启": "Bluetooth Off",
|
||||
"请保持身体静止": "Please stay still",
|
||||
"请先打开蓝牙在进行设备扫描": "Enable Bluetooth first",
|
||||
"重新校准": "Recalibrate",
|
||||
"选择时区": "Select Time Zone",
|
||||
"请求成功": "Request Successful",
|
||||
"设备校准完成": "Calibration Complete",
|
||||
"请校准人员保持在床状态": "Please stay on bed",
|
||||
"请校准人员暂时离开床铺": "Please leave the bed",
|
||||
"获得位置信息,连接附近的蓝牙设备": "Obtain location information, connect to nearby Bluetooth devices",
|
||||
"当前设备已离线,无法快检!": "The current device is offline and cannot be checked!",
|
||||
"设备正在快检中,请稍后再试!": "The device is currently checking, please try again later!",
|
||||
"使用方式:人员使用健康快检功能时,只需平躺或坐在正常运行中的体征传感器传感器上方,保持静止,然后点击“启动快检”,待进度条完成,即可得出快检报告。": "Usage Instructions:When using the Health Quick Check function, the user only needs to lie flat or sit above the vital signs sensor while it is operating normally, remain still, and then tap **“Start Quick Check.”",
|
||||
|
||||
@@ -652,10 +652,20 @@
|
||||
"快检时间:": "快检时间:",
|
||||
"快检中...": "快检中...",
|
||||
"体验异常结束": "体验异常结束",
|
||||
"蓝牙未开启": "蓝牙未开启",
|
||||
"当前设备已离线,无法快检!": "当前设备已离线,无法快检!",
|
||||
"设备正在快检中,请稍后再试!": "设备正在快检中,请稍后再试!",
|
||||
"是否确认结束?": "是否确认结束?",
|
||||
"请保持身体静止": "请保持身体静止",
|
||||
"请先打开蓝牙在进行设备扫描": "请先打开蓝牙在进行设备扫描",
|
||||
"重新校准": "重新校准",
|
||||
"选择时区": "选择时区",
|
||||
"设备校准完成": "设备校准完成",
|
||||
"请校准人员保持在床状态": "请校准人员保持在床状态",
|
||||
"请校准人员暂时离开床铺": "请校准人员暂时离开床铺",
|
||||
"请求成功": "请求成功",
|
||||
"获得位置信息,连接附近的蓝牙设备": "获得位置信息,连接附近的蓝牙设备",
|
||||
"使用方式:人员使用健康快检功能时,只需平躺或坐在正常运行中的体征传感器传感器上方,保持静止,然后点击“启动快检”,待进度条完成,即可得出快检报告。": "使用方式:人员使用健康快检功能时,只需平躺或坐在正常运行中的体征传感器传感器上方,保持静止,然后点击“启动快检”,待进度条完成,即可得出快检报告。",
|
||||
"注:本页报告是基于心率、呼吸等体征波形数据,通过AI算法模型分析完成,其结果仅供参考;其中报告未见数据异常部分,并不代表没有潜在性的疾病风险,如有不适请及时就医。":"注:本页报告是基于心率、呼吸等体征波形数据,通过AI算法模型分析完成,其结果仅供参考;其中报告未见数据异常部分,并不代表没有潜在性的疾病风险,如有不适请及时就医。",
|
||||
"注:本页报告是基于心率、呼吸等体征波形数据,通过AI算法模型分析完成,其结果仅供参考;其中报告未见数据异常部分,并不代表没有潜在性的疾病风险,如有不适请及时就医。": "注:本页报告是基于心率、呼吸等体征波形数据,通过AI算法模型分析完成,其结果仅供参考;其中报告未见数据异常部分,并不代表没有潜在性的疾病风险,如有不适请及时就医。",
|
||||
"Copyright © 2020-2030 东华智能睡眠中心 版权所有": "Copyright © 2020-2030 东华智能睡眠中心 版权所有"
|
||||
}
|
||||
@@ -651,8 +651,18 @@
|
||||
"快检中...": "快檢中...",
|
||||
"体验异常结束": "體驗異常結束",
|
||||
"是否确认结束?": "是否確認結束?",
|
||||
"蓝牙未开启": "藍牙未開啟",
|
||||
"设备校准完成": "設備校準完成",
|
||||
"重新校准": "重新校準",
|
||||
"请求成功": "請求成功",
|
||||
"选择时区": "選擇時區",
|
||||
"请校准人员保持在床状态": "請校準人員保持在床狀態",
|
||||
"请校准人员暂时离开床铺": "請校準人員暫時離開床鋪",
|
||||
"请保持身体静止": "請保持身體靜止",
|
||||
"获得位置信息,连接附近的蓝牙设备": "獲得位置信息,連接附近的藍牙設備",
|
||||
"当前设备已离线,无法快检!": "當前設備已離線,無法快檢! ",
|
||||
"设备正在快检中,请稍后再试!": "當前設備正在快檢中,請稍後再試!",
|
||||
"请先打开蓝牙在进行设备扫描": "請先打開藍牙在進行設備掃描",
|
||||
"注:本页报告是基于心率、呼吸等体征波形数据,通过AI算法模型分析完成,其结果仅供参考;其中报告未见数据异常部分,并不代表没有潜在性的疾病风险,如有不适请及时就医。": "注意:本頁報告基於心率、呼吸等體徵波形數據,通過AI算法模型分析完成,其結果僅供參考;其中報告未見數據異常部分,並不表示沒有潛在的疾病風險,如有不適請即時就医。",
|
||||
"使用方式:人员使用健康快检功能时,只需平躺或坐在正常运行中的体征传感器传感器上方,保持静止,然后点击“启动快检”,待进度条完成,即可得出快检报告。": "使用方式:人员使用健康快检功能時,只需平躺或坐在正常運行中的體徵传感器传感器上方,保持靜止,然後點擊“啟動快檢”,待進度條完成,即可得出快檢報告。",
|
||||
"Copyright © 2020-2030 东华智能睡眠中心 版权所有": " 版權所有©2020-2030 東華智能睡眠中心"
|
||||
|
||||
@@ -8,8 +8,8 @@ import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
class AppConstants {
|
||||
// App-related constants
|
||||
|
||||
static const String zhmht_app_version = "SWES_1.2026.3.12"; //眠花糖
|
||||
static const String theh_app_version = "1.2603.11"; //太和
|
||||
static const String zhmht_app_version = "SWES_1.2026.3.17"; //眠花糖
|
||||
static const String theh_app_version = "1.2603.23"; //太和
|
||||
|
||||
// 1. 纯字符串列表格式
|
||||
static const List<String> integerTimeZones = [
|
||||
|
||||
@@ -697,7 +697,8 @@ void initEasyDartModule() {
|
||||
try {
|
||||
EasyDartModule.init(
|
||||
loggerConfig: LoggerConfig(
|
||||
host: "https://zhmht.swes.com.cn:27020/vsbs_log", serviceName: "眠花糖在线2026-03-03"),
|
||||
host: "https://zhmht.swes.com.cn:27020/vsbs_log",
|
||||
serviceName: "太和e护test2026-03-23"),
|
||||
webSocketConfig:
|
||||
WebSocketConfig(ServiceConstant.webSocketService, (data) {
|
||||
// 接收到服务消息
|
||||
|
||||
@@ -113,7 +113,8 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
final menuWidth = _calculateMaxMenuItemWidth(allTexts, textStyle);
|
||||
popupWidth = menuWidth;
|
||||
// 计算弹窗需要的实际高度(估算)
|
||||
final estimatedItemHeight = 66.rpx; // 每个菜单项的估算高度
|
||||
// final estimatedItemHeight = 66.rpx; // 每个菜单项的估算高度
|
||||
final estimatedItemHeight = 100.rpx; // 每个菜单项的估算高度
|
||||
//todo 更新菜单项,需要在此添加数量
|
||||
// final itemCount =
|
||||
// widget.device['bind_type'] == BindType.active.code ? 9 : 5;
|
||||
@@ -151,7 +152,7 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
// 确保弹窗不会超出屏幕边界
|
||||
popupTop = math.max(paddingOffset, popupTop);
|
||||
actualPopupHeight =
|
||||
math.min(actualPopupHeight, screenHeight * 0.7); // 限制最大高度为屏幕的70%
|
||||
math.min(actualPopupHeight, screenHeight * 1); // 限制最大高度为屏幕的70%
|
||||
|
||||
// 计算左侧位置,确保不会超出屏幕右侧
|
||||
double popupLeft = position.dx + size.width - popupWidth;
|
||||
@@ -699,7 +700,7 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
maxWidth: MediaQuery.sizeOf(context).width * 0.6,
|
||||
),
|
||||
child: Text(
|
||||
'${(widget.device['person']?['name'] as String?)?.isNotEmpty == true ? widget.device['person']!['name'] : '体征检测设备'.tr}',
|
||||
'${(widget.device['person']?['name'] as String?)?.isNotEmpty == true ? widget.device['person']!['name'] : '体征监测设备'.tr}',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 30.rpx,
|
||||
|
||||
@@ -543,13 +543,12 @@ class _AfterCalibrationPersonPageState
|
||||
),
|
||||
|
||||
// 床头文字
|
||||
Positioned(
|
||||
top: 23.rpx,
|
||||
left: (MediaQuery.sizeOf(context)
|
||||
.width *
|
||||
0.65) /
|
||||
2 -
|
||||
26.rpx,
|
||||
Align(
|
||||
alignment:
|
||||
Alignment.topCenter, // 顶部居中
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 23.rpx), // 距离顶部的距离
|
||||
child: Text(
|
||||
'床头'.tr,
|
||||
style: TextStyle(
|
||||
@@ -559,6 +558,7 @@ class _AfterCalibrationPersonPageState
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -420,13 +420,12 @@ class _CalibrationPageState extends State<CalibrationPage> {
|
||||
),
|
||||
|
||||
// 床头文字
|
||||
Positioned(
|
||||
top: 23.rpx,
|
||||
left: (MediaQuery.sizeOf(context)
|
||||
.width *
|
||||
0.65) /
|
||||
2 -
|
||||
26.rpx,
|
||||
Align(
|
||||
alignment:
|
||||
Alignment.topCenter, // 顶部居中
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 23.rpx), // 距离顶部的距离
|
||||
child: Text(
|
||||
'床头'.tr,
|
||||
style: TextStyle(
|
||||
@@ -436,6 +435,7 @@ class _CalibrationPageState extends State<CalibrationPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -414,13 +414,29 @@ class _CalibrationPersonPageState extends State<CalibrationPersonPage> {
|
||||
),
|
||||
|
||||
// 床头文字
|
||||
Positioned(
|
||||
top: 23.rpx,
|
||||
left: (MediaQuery.sizeOf(context)
|
||||
.width *
|
||||
0.65) /
|
||||
2 -
|
||||
26.rpx,
|
||||
// Positioned(
|
||||
// top: 23.rpx,
|
||||
// left: (MediaQuery.sizeOf(context)
|
||||
// .width *
|
||||
// 0.65) /
|
||||
// 2 -
|
||||
// 26.rpx,
|
||||
// child: Text(
|
||||
// '床头'.tr,
|
||||
// style: TextStyle(
|
||||
// fontSize: 26.rpx,
|
||||
// color: themeController
|
||||
// .currentColor.sc4,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// 床头文字 - 自动居中版本
|
||||
Align(
|
||||
alignment:
|
||||
Alignment.topCenter, // 顶部居中
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 23.rpx), // 距离顶部的距离
|
||||
child: Text(
|
||||
'床头'.tr,
|
||||
style: TextStyle(
|
||||
@@ -430,6 +446,7 @@ class _CalibrationPersonPageState extends State<CalibrationPersonPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -21,6 +21,7 @@ import 'package:vbvs_app/controller/time/countdown_controller.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/controller/weather/weather_controller.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/main.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
import 'package:vbvs_app/pages/person/select_time.dart';
|
||||
import 'dart:ui' as ui;
|
||||
@@ -710,7 +711,7 @@ class _OtherLoginPageState extends State<OtherLoginPage> {
|
||||
themeController.currentColor.sc9,
|
||||
);
|
||||
} else {
|
||||
// await dealBindProcess();
|
||||
await dealBindProcess();
|
||||
CountdownController countdownController =
|
||||
Get.find();
|
||||
countdownController.countdown.value = 0;
|
||||
|
||||
@@ -1355,8 +1355,12 @@ class _HomePageState extends State<HomePage> {
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {},
|
||||
onFailure: (res) {},
|
||||
onSuccess: (res) {
|
||||
ef.log("更新绑定流程成功");
|
||||
},
|
||||
onFailure: (res) {
|
||||
ef.log("更新绑定流程失败");
|
||||
},
|
||||
);
|
||||
},
|
||||
onFailure: (res) {},
|
||||
|
||||
@@ -432,47 +432,121 @@ class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
||||
}
|
||||
|
||||
//下发wifi指令
|
||||
sendCommand(Map<String, dynamic> commandData) async {
|
||||
// sendCommand(Map<String, dynamic> commandData) async {
|
||||
// if (commandData == null || commandData.isEmpty) {
|
||||
// throw "指令数据不能为空";
|
||||
// }
|
||||
// if (commandData['data'] == "FFFFFFFF00031000010014FD") {
|
||||
// return;
|
||||
// }
|
||||
// ef.log("下发指令内容为: ${commandData['data']}");
|
||||
// commandData['data'] = Base64Tool.encode(commandData['data']);
|
||||
// if (Base64Tool.decode(commandData['data']) != "FFFFFFFF00031000010014FD" &&
|
||||
// Base64Tool.decode(commandData['data']).length <= 24) {
|
||||
// ef.log("下发指令: ${Base64Tool.decode(commandData['data'])}");
|
||||
// } else {
|
||||
// // ef.log("下发指令: ${Base64Tool.decode(commandData['data'])}");
|
||||
// }
|
||||
// ef.log("全部指令");
|
||||
// ef.log("wifi指令控制下发时间-->${DateTime.now()}");
|
||||
// commandData['wfr'] = true; //是否等待响应 true: 等待 false:不等待(默认)
|
||||
// commandData['type'] = 0; //0 base64数据 1 二进制数据
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.sendWifiCommand;
|
||||
// String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
// await requestWithLog(
|
||||
// logTitle: "下发wifi控制指令",
|
||||
// method: MyHttpMethod.post,
|
||||
// queryUrl: queryUrl,
|
||||
// data: commandData,
|
||||
// onSuccess: (res) {
|
||||
// ef.log("下发指令成功: ${res.msg}");
|
||||
// EasyDartModule.logger.info("下发wifi控制指令成功: $res");
|
||||
// },
|
||||
// onFailure: (res) {
|
||||
// ef.log("下发指令失败: ${res.msg}");
|
||||
// EasyDartModule.logger.info("下发wifi控制指令失败: $res");
|
||||
// throw "下发wifi控制指令失败: ${res.msg}";
|
||||
// },
|
||||
// );
|
||||
// await Future.delayed(Duration(milliseconds: 100));
|
||||
// }
|
||||
|
||||
//下发wifi指令
|
||||
Future<void> sendCommand(Map<String, dynamic> commandData,
|
||||
{int maxRetryCount = 3}) async {
|
||||
if (commandData == null || commandData.isEmpty) {
|
||||
throw "指令数据不能为空";
|
||||
throw Exception("指令数据不能为空");
|
||||
}
|
||||
if (commandData['data'] == "FFFFFFFF00031000010014FD") {
|
||||
return;
|
||||
}
|
||||
ef.log("下发指令内容为: ${commandData['data']}");
|
||||
|
||||
// ef.log("下发指令内容为: ${commandData['data']}");
|
||||
commandData['data'] = Base64Tool.encode(commandData['data']);
|
||||
if (Base64Tool.decode(commandData['data']) != "FFFFFFFF00031000010014FD" &&
|
||||
Base64Tool.decode(commandData['data']).length <= 24) {
|
||||
ef.log("下发指令: ${Base64Tool.decode(commandData['data'])}");
|
||||
} else {
|
||||
// ef.log("下发指令: ${Base64Tool.decode(commandData['data'])}");
|
||||
}
|
||||
|
||||
ef.log("全部指令");
|
||||
ef.log("wifi指令控制下发时间-->${DateTime.now()}");
|
||||
commandData['wfr'] = false;
|
||||
EasyDartModule.logger.info("设备mac:${commandData['mac']}" +"wifi指令控制下发时间-->${DateTime.now()}");
|
||||
commandData['wfr'] = true; //是否等待响应 true: 等待 false:不等待(默认)
|
||||
commandData['type'] = 0; //0 base64数据 1 二进制数据
|
||||
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.sendWifiCommand;
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
|
||||
int retryCount = 0;
|
||||
bool success = false;
|
||||
dynamic lastError;
|
||||
|
||||
while (retryCount < maxRetryCount && !success) {
|
||||
try {
|
||||
if (retryCount > 0) {
|
||||
ef.log("第 $retryCount 次重试下发wifi控制指令");
|
||||
await Future.delayed(
|
||||
Duration(milliseconds: 500 * retryCount)); // 递增延迟
|
||||
}
|
||||
ef.log("下发指令时间: ");
|
||||
await requestWithLog(
|
||||
logTitle: "下发wifi控制指令",
|
||||
logTitle:
|
||||
"下发wifi控制指令${retryCount > 0 ? '(重试 $retryCount/$maxRetryCount)' : ''}",
|
||||
method: MyHttpMethod.post,
|
||||
queryUrl: queryUrl,
|
||||
data: commandData,
|
||||
onSuccess: (res) {
|
||||
ef.log("下发指令成功: ${res.msg}");
|
||||
EasyDartModule.logger.info("下发wifi控制指令成功: $res");
|
||||
success = true;
|
||||
},
|
||||
onFailure: (res) {
|
||||
ef.log("下发指令失败: ${res.msg}");
|
||||
EasyDartModule.logger.info("下发wifi控制指令失败: $res");
|
||||
throw "下发wifi控制指令失败: ${res.msg}";
|
||||
lastError = "下发wifi控制指令失败: ${res.msg}";
|
||||
throw Exception(lastError); // 抛出异常触发重试
|
||||
},
|
||||
);
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
}
|
||||
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
} catch (e) {
|
||||
lastError = e;
|
||||
retryCount++;
|
||||
|
||||
if (retryCount >= maxRetryCount) {
|
||||
ef.log("下发wifi控制指令失败,已重试 $maxRetryCount 次");
|
||||
EasyDartModule.logger.info("下发wifi控制指令失败,已重试 $maxRetryCount 次: $e");
|
||||
DailyLogUtils.writeLog("下发wifi控制指令失败,已重试 $maxRetryCount 次: $e");
|
||||
throw Exception("下发wifi控制指令失败,已重试 $maxRetryCount 次: ${e.toString()}");
|
||||
} else {
|
||||
ef.log("下发wifi控制指令失败,准备第 $retryCount 次重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//todo 解绑的时候删除自己所拥有的所有设备的睡眠习惯
|
||||
}
|
||||
|
||||
@@ -492,641 +566,3 @@ void safeShowNotification(String msg) {
|
||||
// print("TopSlideNotification 显示异常: $e\n$stack");
|
||||
}
|
||||
}
|
||||
|
||||
// import 'dart:async';
|
||||
// import 'dart:convert';
|
||||
|
||||
// import 'package:EasyDartModule/EasyDartModule.dart';
|
||||
// import 'package:easydevice/src/app/thapp.dart';
|
||||
// import 'package:ef/ef.dart';
|
||||
// import 'package:flutter/src/widgets/framework.dart';
|
||||
// import 'package:json_annotation/json_annotation.dart';
|
||||
// import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
// import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
// import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
// import 'package:vbvs_app/common/util/FirmwareVersionService.dart';
|
||||
// import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
// import 'package:vbvs_app/common/util/base64Tool.dart';
|
||||
// import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
// import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
// import 'package:vbvs_app/model/api_response.dart';
|
||||
// import 'package:vbvs_app/pages/mh_page/device/model/BlueToothDataModel.dart';
|
||||
// import 'package:vbvs_app/pages/mh_page/user/controller/mht_register_controller.dart';
|
||||
|
||||
// part 'mht_bluetooth_controller.g.dart';
|
||||
|
||||
// @JsonSerializable()
|
||||
// class MHTBlueToothModel {
|
||||
// bool? bluetooth = false; //蓝牙开关
|
||||
// double? singal = -100;
|
||||
|
||||
// @JsonKey(ignore: true)
|
||||
// List<BlueToothDataModel>? blueRawData = []; //蓝牙原始数据
|
||||
// @JsonKey(ignore: true)
|
||||
// List<BlueToothDataModel>? deviceDataStatus; //已经请求过状态的数据
|
||||
|
||||
// int? read = 0;
|
||||
// int? deviceType; //绑定设备类型
|
||||
|
||||
// bool wifiPassShow = false;
|
||||
// String? wifiPass;
|
||||
|
||||
// MHTBlueToothModel();
|
||||
|
||||
// static MHTBlueToothModel fromJson(Map<String, dynamic> json) =>
|
||||
// _$MHTBlueToothModelFromJson(json);
|
||||
// Map<String, dynamic> toJson() => _$MHTBlueToothModelToJson(this);
|
||||
// }
|
||||
|
||||
// class MHTBlueToothController extends GetControllerEx<MHTBlueToothModel> {
|
||||
// MHTBlueToothController() {
|
||||
// attr = GetModel(MHTBlueToothModel()).obs;
|
||||
// }
|
||||
|
||||
// Timer? _statusTimer;
|
||||
// MHTRegisterController registerController = Get.find();
|
||||
|
||||
// RxString search = "".obs;
|
||||
|
||||
// RxString currentDeviceMac = "".obs; //当前正在绑定的设备,用来显示loading
|
||||
|
||||
// THapp? currentDevice; //当前连接的设备
|
||||
// BlueToothDataModel? currentFullDevice; //当前连接的设备
|
||||
|
||||
// RxInt blueConnectFlag = 0.obs; //当前蓝牙连接状态 0.正在连接 1.未连接 2.已连接
|
||||
|
||||
// RxBool bluetoothStatus = false.obs; //蓝牙开启状态
|
||||
// RxInt connectStatus = 0.obs; //当前wifi连接状态 0:未连接 1:已连接
|
||||
// RxInt netType = 0.obs; //当前网络类型 0.正在检测 1.wifi 2.4g设备 3.未知
|
||||
// RxInt wifiConnectStatus = 1.obs; //获取wifi状态 0.正在检测 1.已检测完
|
||||
|
||||
// RxMap selectWifi = {}.obs; //正在连接wifi信息
|
||||
|
||||
// int returnPage = 0; //0返回首页 1.返回设备列表
|
||||
|
||||
// RxInt wifiStatus = 0.obs; //wifi连接状态 0:未连接 1:已连接
|
||||
// RxList wifiList = [].obs;
|
||||
// RxMap connect_wifi = {}.obs;
|
||||
// RxString? cid = "".obs;
|
||||
|
||||
// RxBool isScanning = false.obs;
|
||||
// RxMap<String, Map> localUpgradeMac = <String, Map>{}.obs; //mac 进度
|
||||
// String? currentUpgradeVersion; //最新版本号
|
||||
// String? currentUpgradeName; //最新固件名
|
||||
// String? currentUpgradeUrl; //最新固件下载地址
|
||||
// List<FirmwareVersionInfo> firmwareList = []; //固件版本列表
|
||||
// RxBool allSelect = false.obs; //升级是否全选
|
||||
// RxBool autoUpgrade = false.obs; //是否自动升级
|
||||
|
||||
// // wifi下发指令队列相关
|
||||
// final List<Map<String, dynamic>> _commandQueue = []; // 指令队列
|
||||
// bool _isSendingCommand = false; // 是否正在发送指令
|
||||
// Timer? _commandTimeoutTimer; // 指令超时定时器
|
||||
// int _currentRetryCount = 0; // 当前重试次数
|
||||
// Map<String, dynamic>? _currentCommand; // 当前正在发送的指令
|
||||
|
||||
// // 最大重试次数
|
||||
// static const int _maxRetryCount = 3;
|
||||
// // 超时时间(秒)
|
||||
// static const int _commandTimeoutSeconds = 10;
|
||||
|
||||
// void startStatusPolling() {
|
||||
// updateDeviceStatus().then((res) {
|
||||
// if (res.code == HttpStatusCodes.ok) {
|
||||
// updateAll();
|
||||
// } else {
|
||||
// safeShowNotification(res.msg ?? "获取设备状态异常".tr);
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
// }
|
||||
// });
|
||||
|
||||
// if (_statusTimer == null) {
|
||||
// _statusTimer = Timer.periodic(Duration(seconds: 2), (timer) {
|
||||
// updateDeviceStatus().then((res) {
|
||||
// if (res.code == HttpStatusCodes.ok) {
|
||||
// updateAll();
|
||||
// } else {
|
||||
// safeShowNotification(res.msg ?? "获取设备状态异常".tr);
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $res");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $res");
|
||||
// }
|
||||
// }).catchError((e, stack) {
|
||||
// print("updateDeviceStatus 执行异常: $e\n$stack");
|
||||
// safeShowNotification("设备状态请求失败".tr);
|
||||
// EasyDartModule.logger.info("设备状态异常: $e");
|
||||
// DailyLogUtils.writeLog("设备状态异常: $e");
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// void stopStatusPolling() {
|
||||
// _statusTimer?.cancel();
|
||||
// _statusTimer = null;
|
||||
// }
|
||||
|
||||
// var shouldScan = true.obs;
|
||||
|
||||
// void pauseScanning() {
|
||||
// shouldScan.value = false;
|
||||
// update();
|
||||
// }
|
||||
|
||||
// // 恢复扫描
|
||||
// void resumeScanning() {
|
||||
// shouldScan.value = true;
|
||||
// update();
|
||||
// }
|
||||
|
||||
// Future<ApiResponse> updateDeviceStatus() async {
|
||||
// try {
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.get_bluetooth_device_status;
|
||||
// String queryUrl = "$serviceAddress$serviceName$serviceApi";
|
||||
|
||||
// if (model.blueRawData != null && model.blueRawData!.isNotEmpty) {
|
||||
// final macParams = model.blueRawData!
|
||||
// .map((device) =>
|
||||
// "mac=${Uri.encodeQueryComponent(device.mac!.replaceAll(':', ''))}")
|
||||
// .join("&");
|
||||
|
||||
// if (queryUrl.contains('?')) {
|
||||
// queryUrl += '&$macParams';
|
||||
// } else {
|
||||
// queryUrl += '?$macParams';
|
||||
// }
|
||||
|
||||
// String? language = "";
|
||||
// if (mhLanguageController.selectLanguage != null) {
|
||||
// language = mhLanguageController.selectLanguage.value!.language_code;
|
||||
// }
|
||||
// if (language != null && language.isNotEmpty) {
|
||||
// if (queryUrl.contains("?")) {
|
||||
// queryUrl += "&lang=$language";
|
||||
// } else {
|
||||
// queryUrl += "?lang=$language";
|
||||
// }
|
||||
// }
|
||||
|
||||
// var response = await EasyDartModule.dio.get(queryUrl);
|
||||
// var responseData =
|
||||
// response.data is String ? jsonDecode(response.data) : response.data;
|
||||
// ApiResponse res =
|
||||
// ApiResponse.fromJson(responseData, (object) => object);
|
||||
// if (res.code != HttpStatusCodes.ok) return res;
|
||||
|
||||
// if (response.data['data'] != null && response.data['data'] is List) {
|
||||
// List<dynamic> responseList = response.data['data'];
|
||||
|
||||
// // 新建一个 Map,便于快速通过 mac 查找返回的设备状态
|
||||
// final Map<String, dynamic> responseMap = {
|
||||
// for (var item in responseList)
|
||||
// item['mac'.tr].toString().toUpperCase(): item
|
||||
// };
|
||||
|
||||
// // 遍历 blueRawData,更新 bind 状态
|
||||
// for (var device in model.blueRawData!) {
|
||||
// final macKey = device.mac!.replaceAll(':', '').toUpperCase();
|
||||
// if (responseMap.containsKey(macKey)) {
|
||||
// var item = responseMap[macKey];
|
||||
// // 更新 device 绑定状态等信息
|
||||
// device.bind = item['bind'] ?? device.bind;
|
||||
// device.mac = item['bindMac'] ?? device.mac;
|
||||
// }
|
||||
// }
|
||||
// model.deviceDataStatus =
|
||||
// List<BlueToothDataModel>.from(model.blueRawData!);
|
||||
// } else {
|
||||
// model.deviceDataStatus = [];
|
||||
// }
|
||||
|
||||
// updateAll();
|
||||
// return res;
|
||||
// } else {
|
||||
// model.deviceDataStatus = [];
|
||||
// return ApiResponse(code: 1, msg: "".tr);
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print("获取设备状态异常: $e");
|
||||
// EasyDartModule.logger.info("获取设备状态异常: $e");
|
||||
// DailyLogUtils.writeLog("获取设备状态异常: $e");
|
||||
// return ApiResponse(code: -1, msg: "请求失败".tr);
|
||||
// }
|
||||
// return ApiResponse(code: -1, msg: "未知错误".tr);
|
||||
// }
|
||||
|
||||
// bindDeviceAndMAC(BlueToothDataModel bleDevice, BuildContext context) async {
|
||||
// try {
|
||||
// if ((bleDevice.macA == null || bleDevice.macA.isEmpty) &&
|
||||
// (bleDevice.macB == null || bleDevice.macB.isEmpty)) {
|
||||
// TopSlideNotification.show(context,
|
||||
// text: "传感器mac读取失败".tr, textColor: themeController.currentColor.sc9);
|
||||
// currentDeviceMac.value = "";
|
||||
// return;
|
||||
// }
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.device_bind;
|
||||
// String queryUrl = "$serviceAddress$serviceName$serviceApi";
|
||||
// var data = {
|
||||
// "deviceType": model.deviceType,
|
||||
// "mac".tr: bleDevice.mac,
|
||||
// "macA": bleDevice.macA,
|
||||
// if (bleDevice.macB != null && bleDevice.macB!.isNotEmpty)
|
||||
// "macB": bleDevice.macB,
|
||||
// if (bleDevice.name != null && bleDevice.name!.isNotEmpty)
|
||||
// 'param': {
|
||||
// 'name': bleDevice.name,
|
||||
// },
|
||||
// };
|
||||
// EasyDartModule.logger.info("绑定传感器数据: $data");
|
||||
// var response =
|
||||
// await EasyDartModule.dio.post(queryUrl, data: jsonEncode(data));
|
||||
// if (response != null) {
|
||||
// var responseData =
|
||||
// response.data is String ? jsonDecode(response.data) : response.data;
|
||||
// ApiResponse res =
|
||||
// ApiResponse.fromJson(responseData, (object) => object);
|
||||
// MyUtils.formatResponse(res, "绑定成功".tr, "绑定成功".tr);
|
||||
// if (res.code == HttpStatusCodes.ok) {
|
||||
// // PersonController personController = Get.find();
|
||||
// // personController.currentPersonId.value = res.data['id'];
|
||||
// //todo 绑定成功需要返回传感器id
|
||||
// currentDeviceMac.value = "";
|
||||
// if (res.data != null) {
|
||||
// if (currentFullDevice != null) {
|
||||
// currentFullDevice!.macAID = res.data['macA'];
|
||||
// currentFullDevice!.macBID = res.data['macB'];
|
||||
// currentFullDevice!.deviceID = res.data['id'];
|
||||
// }
|
||||
// }
|
||||
// return res;
|
||||
// } else {
|
||||
// return res;
|
||||
// }
|
||||
// } else {
|
||||
// return ApiResponse(code: -1, msg: "服务器失败".tr);
|
||||
// }
|
||||
// } catch (e) {
|
||||
// EasyDartModule.logger.info("绑定异常: $e");
|
||||
// DailyLogUtils.writeLog("蓝牙绑定: $e");
|
||||
// }
|
||||
// return ApiResponse(code: -1, msg: "未知错误".tr);
|
||||
// }
|
||||
|
||||
// Future<bool> saveHabitData(sleepData) async {
|
||||
// bool resFlag = false;
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.user_setting;
|
||||
// String type = "sleep_habit_${sleepData['mac']}";
|
||||
// String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
// var data = {
|
||||
// "type": type,
|
||||
// "mac".tr: sleepData['mac'.tr],
|
||||
// "time": DateTime.now().millisecondsSinceEpoch,
|
||||
// "data": sleepData,
|
||||
// };
|
||||
// await requestWithLog(
|
||||
// logTitle: "更新睡眠习惯".tr,
|
||||
// method: MyHttpMethod.put,
|
||||
// queryUrl: queryUrl,
|
||||
// data: data,
|
||||
// onSuccess: (res) {
|
||||
// resFlag = true;
|
||||
// },
|
||||
// onFailure: (res) {
|
||||
// resFlag = false;
|
||||
// },
|
||||
// );
|
||||
// return resFlag;
|
||||
// }
|
||||
|
||||
// Future<Map> loadHabitDataApi(String mac, {int time = 3}) async {
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.user_setting;
|
||||
// String type = "sleep_habit_${mac}";
|
||||
// String queryUrl =
|
||||
// "${serviceAddress}${serviceName}${serviceApi}?type=${type}";
|
||||
|
||||
// // 使用 Future 来等待异步操作完成
|
||||
// Map<String, dynamic> result = {};
|
||||
|
||||
// await requestWithLog(
|
||||
// logTitle: "更新睡眠习惯".tr,
|
||||
// method: MyHttpMethod.get,
|
||||
// queryUrl: queryUrl,
|
||||
// onSuccess: (res) {
|
||||
// ef.log("加载睡眠习惯成功: ${res.data}");
|
||||
// result = res.data; // 将返回的数据存入 result
|
||||
// },
|
||||
// onFailure: (res) {
|
||||
// ef.log("加载睡眠习惯失败: ${res.msg}");
|
||||
// result = {}; // 如果失败,可以返回空的 Map
|
||||
// },
|
||||
// );
|
||||
|
||||
// return result; // 在 requestWithLog 完成之后返回 result
|
||||
// }
|
||||
|
||||
// saveJiYiData(sleepData) async {
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.user_setting;
|
||||
// String type = "sleep_jiyi_${sleepData['mac']}";
|
||||
// String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
// var data = {
|
||||
// "type": type,
|
||||
// "mac": sleepData['mac'],
|
||||
// "time": DateTime.now().millisecondsSinceEpoch,
|
||||
// "data": sleepData,
|
||||
// };
|
||||
// await requestWithLog(
|
||||
// logTitle: "更新睡眠记忆",
|
||||
// method: MyHttpMethod.put,
|
||||
// queryUrl: queryUrl,
|
||||
// data: data,
|
||||
// );
|
||||
// }
|
||||
|
||||
// loadJiYiData(String mac, {int time = 3}) async {
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.user_setting;
|
||||
// String type = "sleep_jiyi_${mac}";
|
||||
// String queryUrl =
|
||||
// "${serviceAddress}${serviceName}${serviceApi}?type=${type}";
|
||||
// // 使用 Future 来等待异步操作完成
|
||||
// Map<String, dynamic> result = {};
|
||||
// await requestWithLog(
|
||||
// logTitle: "更新记忆",
|
||||
// method: MyHttpMethod.get,
|
||||
// queryUrl: queryUrl,
|
||||
// onSuccess: (res) {
|
||||
// ef.log("加载记忆成功: ${res.data}");
|
||||
// result = res.data; // 将返回的数据存入 result
|
||||
// },
|
||||
// onFailure: (res) {
|
||||
// ef.log("加载记忆失败: ${res.msg}");
|
||||
// result = {}; // 如果失败,可以返回空的 Map
|
||||
// },
|
||||
// );
|
||||
|
||||
// return result; // 在 requestWithLog 完成之后返回 result
|
||||
// }
|
||||
|
||||
// saveMattressTimeData(sleepData) async {
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.user_setting;
|
||||
// String type = "sleep_new_time_${sleepData['mac']}";
|
||||
// String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
// var data = {
|
||||
// "type": type,
|
||||
// "mac": sleepData['mac'],
|
||||
// "time": DateTime.now().millisecondsSinceEpoch,
|
||||
// "data": sleepData,
|
||||
// };
|
||||
// await requestWithLog(
|
||||
// logTitle: "更新新版倒计时",
|
||||
// method: MyHttpMethod.put,
|
||||
// queryUrl: queryUrl,
|
||||
// data: data,
|
||||
// );
|
||||
// }
|
||||
|
||||
// loadMattressTimeData(String mac, {int time = 3}) async {
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.user_setting;
|
||||
// String type = "sleep_new_time_${mac}";
|
||||
// String queryUrl =
|
||||
// "${serviceAddress}${serviceName}${serviceApi}?type=${type}";
|
||||
|
||||
// // 使用 Future 来等待异步操作完成
|
||||
// Map<String, dynamic> result = {};
|
||||
|
||||
// await requestWithLog(
|
||||
// logTitle: "更新新版倒计时",
|
||||
// method: MyHttpMethod.get,
|
||||
// queryUrl: queryUrl,
|
||||
// onSuccess: (res) {
|
||||
// ef.log("更新新版倒计时成功: ${res.data}");
|
||||
// result = res.data; // 将返回的数据存入 result
|
||||
// },
|
||||
// onFailure: (res) {
|
||||
// ef.log("更新新版倒计时失败: ${res.msg}");
|
||||
// result = {}; // 如果失败,可以返回空的 Map
|
||||
// },
|
||||
// );
|
||||
|
||||
// return result; // 在 requestWithLog 完成之后返回 result
|
||||
// }
|
||||
|
||||
// // 修改后的下发wifi指令方法(带队列、重试和超时机制)
|
||||
// void sendCommand(Map<String, dynamic> commandData) {
|
||||
// if (commandData == null || commandData.isEmpty) {
|
||||
// throw "指令数据不能为空";
|
||||
// }
|
||||
|
||||
// // 忽略特定的空指令
|
||||
// if (commandData['data'] == "FFFFFFFF00031000010014FD") {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 将指令添加到队列
|
||||
// _commandQueue.add(commandData);
|
||||
// ef.log("指令已加入队列,当前队列长度: ${_commandQueue.length}");
|
||||
|
||||
// // 如果没有正在发送的指令,开始处理队列
|
||||
// if (!_isSendingCommand) {
|
||||
// _processNextCommand();
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 处理下一条指令
|
||||
// void _processNextCommand() {
|
||||
// if (_commandQueue.isEmpty) {
|
||||
// _isSendingCommand = false;
|
||||
// _currentCommand = null;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// _isSendingCommand = true;
|
||||
// _currentRetryCount = 0;
|
||||
// _currentCommand = _commandQueue.removeAt(0);
|
||||
|
||||
// _sendCommandWithRetry();
|
||||
// }
|
||||
|
||||
// // 带重试机制的指令发送
|
||||
// void _sendCommandWithRetry() {
|
||||
// if (_currentCommand == null) return;
|
||||
|
||||
// ef.log(
|
||||
// "开始发送指令,第 ${_currentRetryCount + 1} 次尝试,指令内容: ${_currentCommand!['data']}");
|
||||
|
||||
// // 设置超时定时器
|
||||
// _commandTimeoutTimer?.cancel();
|
||||
// _commandTimeoutTimer = Timer(Duration(seconds: _commandTimeoutSeconds), () {
|
||||
// _handleCommandTimeout();
|
||||
// });
|
||||
|
||||
// // 复制指令数据,避免修改原始数据
|
||||
// Map<String, dynamic> commandToSend = Map.from(_currentCommand!);
|
||||
|
||||
// // 调用原有的发送逻辑
|
||||
// _executeSendCommand(commandToSend);
|
||||
// }
|
||||
|
||||
// // 执行实际的指令发送
|
||||
// void _executeSendCommand(Map<String, dynamic> commandData) async {
|
||||
// ef.log("下发指令内容为: ${commandData['data']}");
|
||||
|
||||
// // Base64编码处理
|
||||
// commandData['data'] = Base64Tool.encode(commandData['data']);
|
||||
|
||||
// // 调试日志
|
||||
// if (Base64Tool.decode(commandData['data']) != "FFFFFFFF00031000010014FD" &&
|
||||
// Base64Tool.decode(commandData['data']).length <= 24) {
|
||||
// ef.log("下发指令: ${Base64Tool.decode(commandData['data'])}");
|
||||
// }
|
||||
|
||||
// ef.log("全部指令");
|
||||
// commandData['wfr'] = false;
|
||||
// commandData['type'] = 0; //0 base64数据 1 二进制数据
|
||||
|
||||
// String serviceAddress = ServiceConstant.service_address;
|
||||
// String serviceName = ServiceConstant.server_service;
|
||||
// String serviceApi = ServiceConstant.sendWifiCommand;
|
||||
// String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
// ef.log("wifi指令控制下发时间-->${DateTime.now()}");
|
||||
// try {
|
||||
// await requestWithLog(
|
||||
// logTitle: "下发wifi控制指令",
|
||||
// method: MyHttpMethod.post,
|
||||
// queryUrl: queryUrl,
|
||||
// data: commandData,
|
||||
// onSuccess: (res) {
|
||||
// // 取消超时定时器
|
||||
// _commandTimeoutTimer?.cancel();
|
||||
// _commandTimeoutTimer = null;
|
||||
|
||||
// ef.log("下发指令成功: ${res.msg}");
|
||||
// EasyDartModule.logger.info("下发wifi控制指令成功: $res");
|
||||
|
||||
// // 指令发送成功,但还需要等待设备回复
|
||||
// // 注意:需要在收到设备回复时调用 onCommandResponse(true)
|
||||
// // 如果设备回复通过其他方式通知,则在这里不处理,等待回调
|
||||
|
||||
// },
|
||||
// onFailure: (res) {
|
||||
// // 取消超时定时器
|
||||
// _commandTimeoutTimer?.cancel();
|
||||
// _commandTimeoutTimer = null;
|
||||
|
||||
// ef.log("下发指令失败: ${res.msg}");
|
||||
// EasyDartModule.logger.info("下发wifi指令控制失败: ${res.msg}");
|
||||
|
||||
// // 处理失败,进行重试
|
||||
// _handleCommandFailure("下发指令失败: ${res.msg}");
|
||||
// },
|
||||
// );
|
||||
// } catch (e) {
|
||||
// // 捕获未知异常
|
||||
// _commandTimeoutTimer?.cancel();
|
||||
// _commandTimeoutTimer = null;
|
||||
|
||||
// ef.log("下发指令异常: $e");
|
||||
// EasyDartModule.logger.info("下发wifi控制指令异常: $e");
|
||||
|
||||
// _handleCommandFailure("下发指令异常: $e");
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 处理指令超时
|
||||
// void _handleCommandTimeout() {
|
||||
// ef.log("指令发送超时");
|
||||
// EasyDartModule.logger.info("指令发送超时");
|
||||
|
||||
// _commandTimeoutTimer = null;
|
||||
// _handleCommandFailure("指令发送超时");
|
||||
// }
|
||||
|
||||
// // 处理指令失败(重试逻辑)
|
||||
// void _handleCommandFailure(String error) {
|
||||
// _currentRetryCount++;
|
||||
|
||||
// if (_currentRetryCount < _maxRetryCount) {
|
||||
// // 未达到最大重试次数,继续重试
|
||||
// ef.log("指令失败,准备第 ${_currentRetryCount + 1} 次重试,失败原因: $error");
|
||||
// _sendCommandWithRetry();
|
||||
// } else {
|
||||
// // 已达到最大重试次数,放弃当前指令,处理下一条
|
||||
// ef.log("指令重试已达最大次数,放弃当前指令,失败原因: $error");
|
||||
// EasyDartModule.logger.info("指令发送失败,已重试 $_maxRetryCount 次: $error");
|
||||
|
||||
// // 可以在这里显示错误通知
|
||||
// safeShowNotification("指令发送失败: $error");
|
||||
|
||||
// // 继续处理下一条指令
|
||||
// _processNextCommand();
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 设备回复回调(需要在收到设备回复时调用此方法)
|
||||
// void onCommandResponse(bool success, {String? error}) {
|
||||
// if (!_isSendingCommand || _currentCommand == null) {
|
||||
// ef.log("收到设备回复,但当前没有正在发送的指令");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 取消超时定时器
|
||||
// _commandTimeoutTimer?.cancel();
|
||||
// _commandTimeoutTimer = null;
|
||||
|
||||
// if (success) {
|
||||
// ef.log("设备回复成功,继续发送下一条指令");
|
||||
// // 指令成功,重置重试计数,处理下一条
|
||||
// _currentRetryCount = 0;
|
||||
// _processNextCommand();
|
||||
// } else {
|
||||
// ef.log("设备回复失败: $error");
|
||||
// // 设备回复失败,按失败处理(进行重试)
|
||||
// _handleCommandFailure(error ?? "设备回复失败");
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 清空指令队列(可用于页面退出时)
|
||||
// void clearCommandQueue() {
|
||||
// _commandQueue.clear();
|
||||
// _commandTimeoutTimer?.cancel();
|
||||
// _commandTimeoutTimer = null;
|
||||
// _isSendingCommand = false;
|
||||
// _currentCommand = null;
|
||||
// _currentRetryCount = 0;
|
||||
// ef.log("指令队列已清空");
|
||||
// }
|
||||
|
||||
// //todo 解绑的时候删除自己所拥有的所有设备的睡眠习惯
|
||||
// }
|
||||
|
||||
// void safeShowNotification(String msg) {
|
||||
// try {
|
||||
// final ctx = Get.context;
|
||||
// if (ctx != null && ctx.mounted) {
|
||||
// TopSlideNotification.show(
|
||||
// ctx,
|
||||
// text: msg,
|
||||
// textColor: themeController.currentColor.sc9,
|
||||
// );
|
||||
// } else {
|
||||
// print("TopSlideNotification 未显示:context 不可用或未挂载".tr);
|
||||
// }
|
||||
// } catch (e, stack) {
|
||||
// // print("TopSlideNotification 显示异常: $e\n$stack");
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -22,6 +22,7 @@ import 'package:vbvs_app/pages/mh_page/device/controller/mht_bluetooth_controlle
|
||||
import 'package:vbvs_app/pages/mh_page/device/mht_blueteeth_device_page.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as edm;
|
||||
|
||||
class WebviewTestModel {
|
||||
WebviewTestModel();
|
||||
@@ -494,15 +495,22 @@ class WebviewTestController extends GetControllerEx<WebviewTestModel> {
|
||||
return;
|
||||
}
|
||||
if (tmp['data'] != null && tmp['data'] is Map) {
|
||||
var newData = tmp['data'];
|
||||
MHTBlueToothController mhtBlueToothController = Get.find();
|
||||
edm.EasyDartModule.logger.info("收到设备数据:${newData['mac']}" +"wifi指令控制回复时间-->${DateTime.now()}");
|
||||
ef.log("wifi指令控制回复时间-->${DateTime.now()}");
|
||||
// mhtBlueToothController.onCommandResponse(true);
|
||||
var newData = tmp['data'];
|
||||
|
||||
var mac = newData['mac'];
|
||||
ef.log("收到设备数据:${newData['mac']}");
|
||||
String order = Base64Tool.decode(newData['data']);
|
||||
final webviewTestController = Get.find<WebviewTestController>();
|
||||
if (mac != selectDevice['mac']) {
|
||||
return;
|
||||
}
|
||||
// ef.log("切换设备调试:" + "当前选中设备:${selectDevice['mac']}" +""+"收到设备数据:${mac}");
|
||||
webviewTestController.web.jsbridge?.dart
|
||||
?.updateDeviceStatusByWifi(order);
|
||||
?.updateDeviceStatusByWifi(order,mac);
|
||||
}
|
||||
} catch (e) {
|
||||
ef.log("ws error =>$e");
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
|
||||
import 'package:vbvs_app/component/tool/NewTopSlideNotification.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/date/CalendarController.dart';
|
||||
import 'package:vbvs_app/controller/sleep/sleep_report_controller.dart';
|
||||
import 'package:vbvs_app/controller/sleep/sleep_time_convert.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/QcReportWidget.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/StatusBarWithIndicator.dart';
|
||||
|
||||
@@ -52,30 +48,16 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
if (!Get.isRegistered<SleepReportController>(tag: widget.data["tag"])) {
|
||||
Get.put(tag: widget.data["tag"], SleepReportController());
|
||||
}
|
||||
sleepReportController = Get.find(tag: widget.data["tag"]);
|
||||
// sleepReportController.sleepReport.value = {};
|
||||
|
||||
if (widget.data['date'] == null) {
|
||||
widget.data['date'] = DateTime.now().millisecondsSinceEpoch;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Future.microtask(() {
|
||||
// _initSleepReportData();
|
||||
// });
|
||||
final healthLevelInfo = getHealthLevelInfo(widget.data);
|
||||
|
||||
double lineWidth = 150.rpx;
|
||||
try {
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
// onTap: () => FocusScope.of(context).unfocus(),,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: (widget.data['noBackImg'] != null &&
|
||||
@@ -135,16 +117,12 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
),
|
||||
body: SafeArea(
|
||||
top: true,
|
||||
child: Obx(() {
|
||||
try {
|
||||
var sleepReport = sleepReportController.sleepReport.value;
|
||||
if (sleepReport == null || sleepReport.isEmpty) {
|
||||
return SingleChildScrollView(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
30.rpx, 30.rpx, 30.rpx, 26.rpx),
|
||||
padding:
|
||||
EdgeInsets.fromLTRB(30.rpx, 30.rpx, 30.rpx, 26.rpx),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(
|
||||
@@ -157,8 +135,7 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// 左侧图标
|
||||
Container(
|
||||
@@ -166,16 +143,14 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
child: Icon(
|
||||
Icons.info_outline,
|
||||
size: 26.rpx,
|
||||
color:
|
||||
themeController.currentColor.sc8,
|
||||
color: themeController.currentColor.sc8,
|
||||
),
|
||||
),
|
||||
|
||||
// 中间可换行文字
|
||||
Expanded(
|
||||
child: Container(
|
||||
margin:
|
||||
EdgeInsets.only(right: 69.rpx),
|
||||
margin: EdgeInsets.only(right: 69.rpx),
|
||||
child: Text(
|
||||
'5分钟快速检测可能受到用户当前状态、过程中说话动作、精神紧张等情况影响,数据仅供参考。'
|
||||
.tr,
|
||||
@@ -183,8 +158,7 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants()
|
||||
.smaller_text_fontSize,
|
||||
color: themeController
|
||||
.currentColor.sc8,
|
||||
color: themeController.currentColor.sc8,
|
||||
height: 1.4,
|
||||
),
|
||||
softWrap: true,
|
||||
@@ -197,8 +171,7 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.fromLTRB(30.rpx, 0, 30.rpx, 0),
|
||||
padding: EdgeInsets.fromLTRB(30.rpx, 0, 30.rpx, 0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
@@ -212,12 +185,10 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
padding: EdgeInsets.all(30.rpx),
|
||||
decoration: BoxDecoration(
|
||||
// color: themeController.currentColor.sc5,
|
||||
borderRadius:
|
||||
BorderRadius.circular(16.rpx),
|
||||
borderRadius: BorderRadius.circular(16.rpx),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// 左边的Column,包含五行文字
|
||||
Expanded(
|
||||
@@ -263,8 +234,8 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
style: TextStyle(
|
||||
fontSize: AppConstants()
|
||||
.small_an_text_fontSize,
|
||||
color: healthLevelInfo[
|
||||
'color'],
|
||||
color:
|
||||
healthLevelInfo['color'],
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -322,34 +293,28 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
// height: 220.rpx,
|
||||
decoration: BoxDecoration(
|
||||
// color: themeController.currentColor.sc5,
|
||||
borderRadius:
|
||||
BorderRadius.circular(16.rpx),
|
||||
borderRadius: BorderRadius.circular(16.rpx),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 20.rpx, 30.rpx, 20.rpx),
|
||||
child: StatusBarWithIndicator(
|
||||
selectKey: widget.data['score']
|
||||
['level']
|
||||
selectKey: widget.data['score']['level']
|
||||
.toInt(), // 这里传入对应的 level 值
|
||||
showLabel: (widget.data['type']
|
||||
['score'] as List)
|
||||
.map<Map<String, dynamic>>(
|
||||
(item) {
|
||||
showLabel:
|
||||
(widget.data['type']['score'] as List)
|
||||
.map<Map<String, dynamic>>((item) {
|
||||
return {
|
||||
'key': item['level']?.toInt() ??
|
||||
0, // 使用 level 作为 key
|
||||
'name': item['name'] ?? '',
|
||||
'color': stringToColor(
|
||||
item['color'] ??
|
||||
'color': stringToColor(item['color'] ??
|
||||
''), // 将颜色字符串转换为 Color
|
||||
'range':
|
||||
item['range'] ?? '', // 添加范围数据
|
||||
'range': item['range'] ?? '', // 添加范围数据
|
||||
};
|
||||
}).toList(),
|
||||
showCurrentValue: true, // 显示当前值
|
||||
currentValueText:
|
||||
'当前属于'.tr, // 或者根据实际值动态生成
|
||||
currentValueText: '当前属于'.tr, // 或者根据实际值动态生成
|
||||
showRange: true, // 显示范围
|
||||
),
|
||||
),
|
||||
@@ -361,8 +326,7 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.fromLTRB(30.rpx, 0, 30.rpx, 0),
|
||||
padding: EdgeInsets.fromLTRB(30.rpx, 0, 30.rpx, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
// padding: EdgeInsets.all(30.rpx),
|
||||
@@ -374,8 +338,7 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.fromLTRB(46.rpx, 0, 46.rpx, 0),
|
||||
padding: EdgeInsets.fromLTRB(46.rpx, 0, 46.rpx, 0),
|
||||
child: Column(
|
||||
children: [
|
||||
// Text(
|
||||
@@ -395,8 +358,7 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize:
|
||||
AppConstants().smaller_text_fontSize,
|
||||
fontSize: AppConstants().smaller_text_fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -411,15 +373,7 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
))
|
||||
.addToEnd(SizedBox(height: 25.rpx)),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
} catch (e, s) {
|
||||
ef.log('ERROR:$e$s');
|
||||
}
|
||||
return NullDataWidget();
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -434,42 +388,6 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadSleepReport(int type) async {
|
||||
if (sleepReportController.isLoading.value) return;
|
||||
sleepReportController.model.type = type;
|
||||
sleepReportController.isLoading.value = true;
|
||||
String data = MyUtils.formatDate(calendarController.selectedDate.value!);
|
||||
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.sleep_report;
|
||||
String queryUrl =
|
||||
"$serviceAddress$serviceName$serviceApi?mac=${widget.data['mac']}&time=$data&type=$type&sleepType=2";
|
||||
await requestWithLog(
|
||||
logTitle: "查询睡眠报告",
|
||||
method: MyHttpMethod.get,
|
||||
// queryUrl:
|
||||
// "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=$data&type=$type",
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
final sleepData = Map<String, dynamic>.from(res.data);
|
||||
// 处理时区转换
|
||||
applyTimezoneConversion(sleepData);
|
||||
sleepReportController.sleepReport.value = sleepData;
|
||||
},
|
||||
onFailure: (res) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: res.msg!,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
sleepReportController.sleepReport.value = {};
|
||||
},
|
||||
);
|
||||
sleepReportController.isLoading.value = false;
|
||||
sleepReportController.updateAll();
|
||||
}
|
||||
|
||||
// 获取健康等级信息的方法
|
||||
Map<String, dynamic> getHealthLevelInfo(Map data) {
|
||||
// 默认值
|
||||
|
||||
Reference in New Issue
Block a user