From 7eaa5b917e3686982b86a77cd676b1c4f27a31a2 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Sat, 8 Jan 2022 17:35:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=B9=E7=AA=97=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=8B=E7=8E=AF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/icons/sos.png | Bin 0 -> 5380 bytes lib/constants/api.dart | 6 + lib/gen/assets.gen.dart | 3 + lib/models/bracelet/bracelet_model.dart | 48 ++++++++ lib/models/bracelet/bracelet_model.g.dart | 21 ++++ .../old_age/old_age_support_page_simple.dart | 103 ++++++++++++------ lib/utils/websocket/AlarmModel.dart | 36 ------ .../websocket/alarm_models/fall_model.dart | 24 ++++ .../websocket/alarm_models/fall_model.g.dart | 16 +++ .../websocket/alarm_models/fire_model.dart | 25 +++++ .../websocket/alarm_models/fire_model.g.dart | 16 +++ lib/utils/websocket/fire_dialog.dart | 59 +++++++--- lib/utils/websocket/web_socket_util.dart | 2 +- 13 files changed, 273 insertions(+), 86 deletions(-) create mode 100644 assets/icons/sos.png create mode 100644 lib/models/bracelet/bracelet_model.dart create mode 100644 lib/models/bracelet/bracelet_model.g.dart delete mode 100644 lib/utils/websocket/AlarmModel.dart create mode 100644 lib/utils/websocket/alarm_models/fall_model.dart create mode 100644 lib/utils/websocket/alarm_models/fall_model.g.dart create mode 100644 lib/utils/websocket/alarm_models/fire_model.dart create mode 100644 lib/utils/websocket/alarm_models/fire_model.g.dart diff --git a/assets/icons/sos.png b/assets/icons/sos.png new file mode 100644 index 0000000000000000000000000000000000000000..33569c785ec16e7592d9dc436c5c30badbc1b4ce GIT binary patch literal 5380 zcmX9?2UJr_*9|0^(85iKfDj=GK|m=%5u&sNf`l&UXMrc}DNP<4LFq^d5|9>DiqgC9 zDI%bN)Ib1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S7lS`FG z(D;GKPB3-E0SZ*&JALeG7$q0M_5t%$5wN^M<7I$lmMoqmnGo`fP)IlP5gW{-BPcH1 zJUW>0QE+OLdPD#Y-YX?a&Z1di*8qeWnCWmiS_o#ddlYQK{y0p}Qyr8cfki0DV^Ahp zD1^j}1ZCPIDB|2)Q0D#;B3jk=xQ1+aD!v1cT&Lg!Py3$pw)#PbG32)^v%1GjJGn02TI0AErf*Xf&fOb@NtB|k{X*m z@?tE{FBwggeHwZ@^C**Ji(ndbN~u_E>XGyzhJe^7xJ$D '/user/aqg/getData'; } class _Login { diff --git a/lib/gen/assets.gen.dart b/lib/gen/assets.gen.dart index cee00ca0..4dc06765 100644 --- a/lib/gen/assets.gen.dart +++ b/lib/gen/assets.gen.dart @@ -730,6 +730,9 @@ class $AssetsIconsGen { AssetGenImage get shoppingMall => const AssetGenImage('assets/icons/shopping_mall.png'); + /// File path: assets/icons/sos.png + AssetGenImage get sos => const AssetGenImage('assets/icons/sos.png'); + /// File path: assets/icons/system_notice.png AssetGenImage get systemNotice => const AssetGenImage('assets/icons/system_notice.png'); diff --git a/lib/models/bracelet/bracelet_model.dart b/lib/models/bracelet/bracelet_model.dart new file mode 100644 index 00000000..f51660d2 --- /dev/null +++ b/lib/models/bracelet/bracelet_model.dart @@ -0,0 +1,48 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'bracelet_model.g.dart'; + +@JsonSerializable() +class BraceletModel { + final int sbp; + final int todaySteps; + final int bloodOxygen; + final int switchType; + final int dbp; + final int heartRate; + final int remainingPower; + final int detectionDays; + final int alarmNums; + final int fallNums; + + factory BraceletModel.fromJson(Map json) => + _$BraceletModelFromJson(json); + + String get switchTypeString { + switch (switchType) { + case 0: + return '开机'; + case 1: + return '关机'; + case 2: + return '开机'; + case 3: + return '低电通知'; + default: + return ''; + } + } + + const BraceletModel({ + required this.sbp, + required this.todaySteps, + required this.bloodOxygen, + required this.switchType, + required this.dbp, + required this.heartRate, + required this.remainingPower, + required this.detectionDays, + required this.alarmNums, + required this.fallNums, + }); +} diff --git a/lib/models/bracelet/bracelet_model.g.dart b/lib/models/bracelet/bracelet_model.g.dart new file mode 100644 index 00000000..c53c1495 --- /dev/null +++ b/lib/models/bracelet/bracelet_model.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'bracelet_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +BraceletModel _$BraceletModelFromJson(Map json) => + BraceletModel( + sbp: json['sbp'] as int, + todaySteps: json['todaySteps'] as int, + bloodOxygen: json['bloodOxygen'] as int, + switchType: json['switchType'] as int, + dbp: json['dbp'] as int, + heartRate: json['heartRate'] as int, + remainingPower: json['remainingPower'] as int, + detectionDays: json['detectionDays'] as int, + alarmNums: json['alarmNums'] as int, + fallNums: json['fallNums'] as int, + ); diff --git a/lib/pages/services/old_age/old_age_support_page_simple.dart b/lib/pages/services/old_age/old_age_support_page_simple.dart index c3fd6730..b5b5c071 100644 --- a/lib/pages/services/old_age/old_age_support_page_simple.dart +++ b/lib/pages/services/old_age/old_age_support_page_simple.dart @@ -1,6 +1,12 @@ +import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; +import 'package:aku_new_community/models/bracelet/bracelet_model.dart'; +import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/widget/bee_divider.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:dio/dio.dart'; +import 'package:flustars/flustars.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -15,6 +21,23 @@ class OldAgeSupportPageSimple extends StatefulWidget { } class _OldAgeSupportPageSimpleState extends State { + BraceletModel? _model; + DateTime? _date; + + @override + void initState() { + var cancel = BotToast.showLoading(); + getData(); + cancel(); + super.initState(); + } + + @override + void dispose() { + BotToast.closeAllLoading(); + super.dispose(); + } + @override Widget build(BuildContext context) { var open = Row( @@ -27,7 +50,7 @@ class _OldAgeSupportPageSimpleState extends State { color: Color(0xFF57DAD2), ), 4.w.widthBox, - '设备 已开机' + '设备 ${_model?.switchTypeString}' .text .size(26.sp) .lineHeight(1.2) @@ -50,35 +73,49 @@ class _OldAgeSupportPageSimpleState extends State { end: Alignment.bottomCenter, colors: [Colors.white, Color(0xFFC0E5DC).withOpacity(0.355)]), ), - child: ListView( - padding: EdgeInsets.symmetric(horizontal: 32.w), - children: [ - 550.w.heightBox, - open, - 16.w.heightBox, - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - '数据更新自 2022年1月1日 18:21:15' - .text - .size(22.sp) - .color(Colors.black.withOpacity(0.25)) - .make(), - 40.w.heightBox, - ], - ), - 40.w.heightBox, - overview(), - 24.w.heightBox, - statusCard(), - 40.w.heightBox, - bottomCard(), - ], - ), + child: _model == null + ? Container() + : ListView( + padding: EdgeInsets.symmetric(horizontal: 32.w), + children: [ + 550.w.heightBox, + open, + 16.w.heightBox, + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + '数据更新自 ${DateUtil.formatDate(_date!, format: DateFormats.full)}' + .text + .size(22.sp) + .color(Colors.black.withOpacity(0.25)) + .make(), + 40.w.heightBox, + ], + ), + 40.w.heightBox, + overview(), + 24.w.heightBox, + statusCard(), + 40.w.heightBox, + bottomCard(), + ], + ), ), ); } + Future getData() async { + Response base = + await NetUtil().dio!.get(API.bracelet.data, queryParameters: { + 'imei': 863204050238280, + }); + if (base.data != null) { + _model = BraceletModel.fromJson(base.data); + _date = DateTime.now(); + } + setState(() {}); + } + Container bottomCard() { var left = Column( children: [ @@ -204,7 +241,7 @@ class _OldAgeSupportPageSimpleState extends State { ], ), Spacer(), - '141' + '${_model?.heartRate}' .richText .withTextSpanChildren([ ' 次/分' @@ -248,7 +285,7 @@ class _OldAgeSupportPageSimpleState extends State { ], ), Spacer(), - '3' + '${_model?.fallNums}' .richText .withTextSpanChildren([ ' 次' @@ -292,7 +329,7 @@ class _OldAgeSupportPageSimpleState extends State { ], ), Spacer(), - '1042' + '${_model?.todaySteps}' .richText .withTextSpanChildren([ ' 步' @@ -332,7 +369,7 @@ class _OldAgeSupportPageSimpleState extends State { Spacer(), Row( children: [ - '98' + '${_model?.bloodOxygen}' .richText .withTextSpanChildren([ ' %' @@ -375,7 +412,7 @@ class _OldAgeSupportPageSimpleState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ '剩余电量'.text.size(28.sp).color(Colors.black.withOpacity(0.65)).make(), - '58' + '${_model?.remainingPower}' .richText .withTextSpanChildren([ ' %' @@ -401,7 +438,7 @@ class _OldAgeSupportPageSimpleState extends State { .size(28.sp) .color(Colors.black.withOpacity(0.45)) .make(), - '58' + '${_model?.detectionDays}' .richText .withTextSpanChildren([ ' 天' @@ -427,7 +464,7 @@ class _OldAgeSupportPageSimpleState extends State { .size(28.sp) .color(Colors.black.withOpacity(0.45)) .make(), - '5' + '${_model?.alarmNums}' .richText .withTextSpanChildren([ ' 次' diff --git a/lib/utils/websocket/AlarmModel.dart b/lib/utils/websocket/AlarmModel.dart deleted file mode 100644 index 90fe198b..00000000 --- a/lib/utils/websocket/AlarmModel.dart +++ /dev/null @@ -1,36 +0,0 @@ -class AlarmModel { - String? alarmNo; - String? alarmType; - String? deviceName; - String? deviceNo; - String? time; - int? type; - - AlarmModel( - {this.alarmNo, - this.alarmType, - this.deviceName, - this.deviceNo, - this.time, - this.type}); - - AlarmModel.fromJson(Map json) { - alarmNo = json['alarmNo']; - alarmType = json['alarmType']; - deviceName = json['deviceName']; - deviceNo = json['deviceNo']; - time = json['time']; - type = json['type']; - } - - Map toJson() { - final Map data = new Map(); - data['alarmNo'] = this.alarmNo; - data['alarmType'] = this.alarmType; - data['deviceName'] = this.deviceName; - data['deviceNo'] = this.deviceNo; - data['time'] = this.time; - data['type'] = this.type; - return data; - } -} diff --git a/lib/utils/websocket/alarm_models/fall_model.dart b/lib/utils/websocket/alarm_models/fall_model.dart new file mode 100644 index 00000000..87b2cb5c --- /dev/null +++ b/lib/utils/websocket/alarm_models/fall_model.dart @@ -0,0 +1,24 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'fall_model.g.dart'; + +@JsonSerializable() +class FallModel { + final String? userName; + final String? tel; + final String? address; + final num? lon; + final num? lat; + final int? type; + factory FallModel.fromJson(Map json) => + _$FallModelFromJson(json); + + const FallModel({ + this.userName, + this.tel, + this.address, + this.lon, + this.lat, + this.type, + }); +} diff --git a/lib/utils/websocket/alarm_models/fall_model.g.dart b/lib/utils/websocket/alarm_models/fall_model.g.dart new file mode 100644 index 00000000..7af23b29 --- /dev/null +++ b/lib/utils/websocket/alarm_models/fall_model.g.dart @@ -0,0 +1,16 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fall_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +FallModel _$FallModelFromJson(Map json) => FallModel( + userName: json['userName'] as String?, + tel: json['tel'] as String?, + address: json['address'] as String?, + lon: json['lon'] as num?, + lat: json['lat'] as num?, + type: json['type'] as int?, + ); diff --git a/lib/utils/websocket/alarm_models/fire_model.dart b/lib/utils/websocket/alarm_models/fire_model.dart new file mode 100644 index 00000000..751b55cc --- /dev/null +++ b/lib/utils/websocket/alarm_models/fire_model.dart @@ -0,0 +1,25 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'fire_model.g.dart'; + +@JsonSerializable() +class FireModel { + String? alarmNo; + String? alarmType; + String? deviceName; + String? deviceNo; + String? time; + int? type; + + factory FireModel.fromJson(Map json) => + _$FireModelFromJson(json); + + FireModel({ + this.alarmNo, + this.alarmType, + this.deviceName, + this.deviceNo, + this.time, + this.type, + }); +} diff --git a/lib/utils/websocket/alarm_models/fire_model.g.dart b/lib/utils/websocket/alarm_models/fire_model.g.dart new file mode 100644 index 00000000..092a4003 --- /dev/null +++ b/lib/utils/websocket/alarm_models/fire_model.g.dart @@ -0,0 +1,16 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fire_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +FireModel _$FireModelFromJson(Map json) => FireModel( + alarmNo: json['alarmNo'] as String?, + alarmType: json['alarmType'] as String?, + deviceName: json['deviceName'] as String?, + deviceNo: json['deviceNo'] as String?, + time: json['time'] as String?, + type: json['type'] as int?, + ); diff --git a/lib/utils/websocket/fire_dialog.dart b/lib/utils/websocket/fire_dialog.dart index 39cce13e..8e04959e 100644 --- a/lib/utils/websocket/fire_dialog.dart +++ b/lib/utils/websocket/fire_dialog.dart @@ -1,29 +1,27 @@ import 'dart:convert'; -import 'package:aku_new_community/extensions/num_ext.dart'; +import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/pages/tab_navigator.dart'; import 'package:aku_new_community/utils/developer_util.dart'; import 'package:aku_new_community/utils/headers.dart'; +import 'package:aku_new_community/utils/websocket/alarm_models/fall_model.dart'; +import 'package:aku_new_community/utils/websocket/alarm_models/fire_model.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'AlarmModel.dart'; - class FireDialog { static fireAlarm(String content) async { var json = jsonDecode(content); - AlarmModel alarmModel = AlarmModel.fromJson(json); + int type = json['type'] as int; await Get.dialog( CupertinoAlertDialog( - title: getImage(alarmModel), + title: getImage(type), content: Column( children: [ - Text(getTitle(alarmModel)), + Text(getTitle(type)), 10.hb, - Text(getContent(alarmModel)), + Text(getContent(json, type)), ], ), actions: [ @@ -44,37 +42,52 @@ class FireDialog { ); } - static String getTitle(AlarmModel alarmModel) { - switch (alarmModel.type) { + static String getTitle(int type) { + switch (type) { case 1: return '发现火灾!请立刻组织疏散人群!'; case 2: return '设备故障'; case 3: return '管家端APP报警'; + case 4: + return '跌倒报警'; + case 45: + return 'SOS紧急联系报警'; default: return ''; } } - static String getContent(AlarmModel alarmModel) { - switch (alarmModel.type) { + static String getContent(dynamic json, int type) { + switch (type) { case 1: + var alarmModel = FireModel.fromJson(json); return '于${alarmModel.time},${alarmModel.deviceName}附近出现了火灾报警,请各位业主、租户保持镇静,不要慌乱,有序开始撤离!'; case 2: + var alarmModel = FireModel.fromJson(json); return '于${alarmModel.time},小区内有设备${alarmModel.deviceName}发生了报警,请物业负责人员尽快前往现场排查故障!'; case 3: + var alarmModel = FireModel.fromJson(json); return '注意:\n于${alarmModel.time},${alarmModel.deviceNo}${alarmModel.deviceName}' + '在管家端app上点击了"一键报警",请尽快联系他沟通情况。\n' + '${alarmModel.deviceName}联系方式:${alarmModel.alarmNo}\n' + '如未能联系到${alarmModel.deviceName}。可择情报警'; + case 4: + var alarmModel = FallModel.fromJson(json); + return '注意:\n\n有住户 ${alarmModel.userName} 发生跌倒情况,请及时上门或联系人员前往查看,住户联系方式:${alarmModel.tel}\n\n' + + '跌倒位置————\n${alarmModel.address},经度${alarmModel.lon},纬度${alarmModel.lat}\n\n如未能联系到住户,可择情报警'; + case 5: + var alarmModel = FallModel.fromJson(json); + return '注意:\n\n有住户 ${alarmModel.userName} 使用了SOS紧急联系报警,请及时上门或联系人员前往查看,住户联系方式:${alarmModel.tel}\n\n' + + '跌倒位置————\n${alarmModel.address},经度${alarmModel.lon},纬度${alarmModel.lat}\n\n如未能联系到住户,可择情报警'; default: return ''; } } - static Widget getImage(AlarmModel alarmModel) { - switch (alarmModel.type) { + static Widget getImage(int type) { + switch (type) { case 1: return Image.asset( R.ASSETS_ICONS_FIRE_ALARM_PNG, @@ -96,8 +109,22 @@ class FireDialog { height: 110.w, fit: BoxFit.fill, ); + case 4: + return Image.asset( + R.ASSETS_ICONS_APP_ALARM_PNG, + width: 110.w, + height: 110.w, + fit: BoxFit.fill, + ); + case 5: + return Image.asset( + Assets.icons.sos.path, + width: 110.w, + height: 110.w, + fit: BoxFit.fill, + ); default: - return SizedBox(); + return SizedBox(width: 110.w, height: 110.w); } } } diff --git a/lib/utils/websocket/web_socket_util.dart b/lib/utils/websocket/web_socket_util.dart index fe5e00f4..e8892c37 100644 --- a/lib/utils/websocket/web_socket_util.dart +++ b/lib/utils/websocket/web_socket_util.dart @@ -6,7 +6,7 @@ import 'package:power_logger/power_logger.dart'; import 'package:web_socket_channel/io.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; -const String baseUri = 'wss://test.kaidalai.cn/websocket/app'; +const String baseUri = 'wss://shop.kaidalai.cn/websocket/app'; enum SOCKETSTATUS { CONNECTED, //已连接 BREAKOFF, //已断开