监视部分提交

This commit is contained in:
Daisy 2024-01-08 11:28:22 +08:00
parent 2c94fb9310
commit 8957756a0f
6 changed files with 148 additions and 90 deletions

View File

@ -26,7 +26,8 @@ class LockDetailPage extends StatefulWidget {
State<LockDetailPage> createState() => _LockDetailPageState();
}
class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStateMixin, RouteAware {
class _LockDetailPageState extends State<LockDetailPage>
with TickerProviderStateMixin, RouteAware {
// with RouteAware
final logic = Get.put(LockDetailLogic());
final state = Get.find<LockDetailLogic>().state;
@ -41,22 +42,27 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
state.lockUserNo = state.keyInfos.value.lockUserNo!;
state.senderUserId = state.keyInfos.value.senderUserId!;
state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!;
state.isOpenLockNeedOnline.value = state.keyInfos.value.lockSetting!.appUnlockOnline!;
state.isOpenLockNeedOnline.value =
state.keyInfos.value.lockSetting!.appUnlockOnline!;
state.electricQuantity.value = state.keyInfos.value.electricQuantity!;
BlueManage().connectDeviceName = state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
BlueManage().connectDeviceName =
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
List<int> publicKeyData = state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
List<int> publicKeyData =
state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
var saveStrList = changeIntListToStringList(publicKeyData);
Storage.setStringList(saveBluePublicKey, saveStrList);
//
List<int> privateKeyData = state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
List<int> privateKeyData =
state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
// signKey
List<int> signKeyData = state.keyInfos.value.bluetooth!.signKey!.cast<int>();
List<int> signKeyData =
state.keyInfos.value.bluetooth!.signKey!.cast<int>();
var saveSignKeyList = changeIntListToStringList(signKeyData);
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
@ -74,10 +80,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
height: 1.sh - ScreenUtil().statusBarHeight * 2,
color: Colors.white,
child: Column(
children: [
topWidget(),
Expanded(child: Obx(() => bottomWidget()))
],
children: [topWidget(), Expanded(child: Obx(() => bottomWidget()))],
),
);
}
@ -93,20 +96,27 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
SizedBox(
width: 1.sw - 120.w * 2,
child: Center(
child:
Text(widget.lockListInfoItemEntity.lockAlias!, style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
child: Text(
widget.lockListInfoItemEntity.lockAlias!,
style:
TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400),
))),
Positioned(
child: Obx(() => Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text("${state.electricQuantity.value}%", style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor)),
SizedBox(width: 2.w),
Image.asset(showElectricIcon(state.electricQuantity.value), width: 30.w, height: 24.w),
SizedBox(width: 30.w),
],
))
)
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text("${state.electricQuantity.value}%",
style: TextStyle(
fontSize: 18.sp,
color: AppColors.darkGrayTextColor)),
SizedBox(width: 2.w),
Image.asset(
showElectricIcon(state.electricQuantity.value),
width: 30.w,
height: 24.w),
SizedBox(width: 30.w),
],
)))
],
),
SizedBox(height: 30.h),
@ -118,7 +128,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
children: [
Center(
child: GestureDetector(
child: Obx(() => Stack(
child: Obx(() => Stack(
children: [
Image.asset(
// state.connectState.value == 0 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png',
@ -136,14 +146,14 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
)),
],
)),
onTap: () {
// Get.log("点击开锁");
logic.startOpenLock();
},
onLongPressStart: (details) {
Get.log("长按开锁");
// logic.startConnect();
},
onTap: () {
// Get.log("点击开锁");
logic.startOpenLock();
},
onLongPressStart: (details) {
Get.log("长按开锁");
// logic.startConnect();
},
)),
],
),
@ -196,7 +206,9 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
Text(
state.keyInfos.value.isLockOwner == 1
? TranslationLoader.lanKeys!.superAdmin!.tr
: (state.keyInfos.value.keyRight == 1 ? TranslationLoader.lanKeys!.authorizedAdmin!.tr: TranslationLoader.lanKeys!.normalUser!.tr),
: (state.keyInfos.value.keyRight == 1
? TranslationLoader.lanKeys!.authorizedAdmin!.tr
: TranslationLoader.lanKeys!.normalUser!.tr),
style: TextStyle(
fontSize: 20.sp, color: AppColors.darkGrayTextColor),
),
@ -272,11 +284,12 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
}
//
List<Widget> getBottomWidget(){
if(state.keyInfos.value.isLockOwner == 1 || state.keyInfos.value.keyRight == 1){
List<Widget> getBottomWidget() {
if (state.keyInfos.value.isLockOwner == 1 ||
state.keyInfos.value.keyRight == 1) {
//
return getAllWidget();
}else{
} else {
return getNormalWidget();
}
}
@ -287,12 +300,14 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
//
bottomItem('images/main/icon_main_operatingRecord.png',
TranslationLoader.lanKeys!.operatingRecord!.tr, () {
Get.toNamed(Routers.lockOperatingRecordPage,
arguments: {"keyInfo": widget.lockListInfoItemEntity});
}),
Get.toNamed(Routers.lockOperatingRecordPage,
arguments: {"keyInfo": widget.lockListInfoItemEntity});
}),
//
bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () {
bottomItem(
'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr,
() {
// BlueManage().stopScan();
Get.toNamed(Routers.lockSetPage,
arguments: {"lockId": widget.lockListInfoItemEntity.lockId});
@ -358,7 +373,8 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
//->
if (state.keyInfos.value.lockFeature!.d3Face == 1) {
showWidgetArr.add(
bottomItem('images/main/icon_face.png', TranslationLoader.lanKeys!.humanFace!.tr, () {
bottomItem('images/main/icon_face.png',
TranslationLoader.lanKeys!.humanFace!.tr, () {
Get.toNamed(Routers.faceList, arguments: {
"lockId": widget.lockListInfoItemEntity.lockId,
}); // Toast.show(msg: "功能暂未开放");
@ -377,7 +393,7 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
bottomItem('images/main/icon_catEyes.png',
TranslationLoader.lanKeys!.monitoring!.tr, () {
Get.toNamed(Routers.realTimePicturePage, arguments: {
"lockId": widget.lockListInfoItemEntity.lockId,
"lockName": widget.lockListInfoItemEntity.lockName,
"isMonitoring": true
});
}),
@ -398,16 +414,20 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
arguments: {"keyInfo": widget.lockListInfoItemEntity});
}),
//
bottomItem('images/main/icon_lockDetail_videoLog.png', TranslationLoader.lanKeys!.videoLog!.tr, () {
bottomItem('images/main/icon_lockDetail_videoLog.png',
TranslationLoader.lanKeys!.videoLog!.tr, () {
//
Get.toNamed(Routers.videoLogPage);
}),
//
bottomItem('images/main/icon_lockDetail_messageReminding.png', TranslationLoader.lanKeys!.messageReminding!.tr, () {
bottomItem('images/main/icon_lockDetail_messageReminding.png',
TranslationLoader.lanKeys!.messageReminding!.tr, () {
Get.toNamed(Routers.msgNotificationPage);
}),
//
bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () {
bottomItem(
'images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr,
() {
// BlueManage().stopScan();
Get.toNamed(Routers.lockSetPage,
arguments: {"lockId": widget.lockListInfoItemEntity.lockId});
@ -466,16 +486,16 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
// logic.connectBlueAndAnimationController();
}
String showElectricIcon (int electricnumber){
if(electricnumber >= 100){
String showElectricIcon(int electricnumber) {
if (electricnumber >= 100) {
return 'images/main/icon_lockElectricLevel_5.png';
}else if((electricnumber > 50) && (electricnumber < 100)){
} else if ((electricnumber > 50) && (electricnumber < 100)) {
return 'images/main/icon_lockElectricLevel_4.png';
}else if((electricnumber > 25) && (electricnumber <= 50)){
} else if ((electricnumber > 25) && (electricnumber <= 50)) {
return 'images/main/icon_lockElectricLevel_3.png';
}else if((electricnumber > 5) && (electricnumber <= 25)){
} else if ((electricnumber > 5) && (electricnumber <= 25)) {
return 'images/main/icon_lockElectricLevel_2.png';
}else if(electricnumber <= 5){
} else if (electricnumber <= 5) {
return 'images/main/icon_lockElectricLevel_1.png';
}
return 'images/main/icon_lockElectricLevel_5.png';
@ -612,6 +632,4 @@ class _LockDetailPageState extends State<LockDetailPage> with TickerProviderStat
state.animationController.reset();
state.animationController.forward();
}
}

View File

@ -58,7 +58,7 @@ class RealTimePictureLogic extends BaseGetXController {
command: 150,
commandTypeIsCalling: 1,
subCommand: 30,
lockID: state.getLockID.value,
lockID: state.getLockName.value,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
@ -79,7 +79,7 @@ class RealTimePictureLogic extends BaseGetXController {
command: 152,
commandTypeIsCalling: 1,
subCommand: 20,
lockID: state.getLockID.value,
lockID: state.getLockName.value,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
@ -92,11 +92,12 @@ class RealTimePictureLogic extends BaseGetXController {
command: 152,
commandTypeIsCalling: 1,
subCommand: 1,
lockID: state.getLockID.value,
lockID: state.getLockName.value,
lockIP: UDPManage().host,
userMobile: await state.userMobile,
userMobileIP: await state.userMobileIP,
endData: []);
// print('得到lockName------${state.getLockName.value}');
}
///

View File

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -40,12 +42,24 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
}
});
// 10
Future.delayed(const Duration(seconds: 10), () {
state.animationController.stop();
});
initiateUdpMonitorAction();
}
logic.udpMonitorAction();
//
void initiateUdpMonitorAction() {
// udpMonitorAction
state.realTimePicTimer =
Timer.periodic(const Duration(seconds: 1), (timer) {
state.elapsedSeconds++;
logic.udpMonitorAction();
// 30
if (state.elapsedSeconds >= 30) {
state.realTimePicTimer.cancel(); //
_handleFailure();
}
});
}
@override
@ -70,12 +84,14 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
height: 1.sh,
fit: BoxFit.cover,
)),
Positioned(
bottom: 300.h,
child: Text(
'正在创建安全连接...',
style: TextStyle(color: Colors.black, fontSize: 26.sp),
)),
Obx(() => state.listData.value.isEmpty
? Positioned(
bottom: 300.h,
child: Text(
'正在创建安全连接...',
style: TextStyle(color: Colors.black, fontSize: 26.sp),
))
: Container()),
Positioned(
bottom: 10.w,
child: Container(
@ -95,7 +111,9 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
],
),
)),
buildRotationTransition()
Obx(() => state.listData.value.isEmpty
? buildRotationTransition()
: Container())
],
),
);
@ -193,10 +211,9 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
})),
bottomBtnItemWidget(
"images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async {
logic.stopProcessing();
CallTalk().stopPcmSound();
//
logic.udpHangUpAction();
Get.back();
}),
bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png",
"开锁", AppColors.mainColor, () {
@ -314,11 +331,18 @@ class _RealTimePicturePageState extends State<RealTimePicturePage>
),
onTap: () {
state.animationController.forward();
initiateUdpMonitorAction();
},
),
);
}
void _handleFailure() {
//
print('Failed to get response within 30 seconds.');
state.animationController.stop();
}
@override
void dispose() {
state.animationController.dispose();

View File

@ -29,7 +29,7 @@ class RealTimePictureState {
Timer(const Duration(seconds: 1), () {}); // 60
var oneMinuteTime = 0.obs; //
var getLockID = ''.obs; //lockID
var getLockName = ''.obs; //lockName
// 10
late Timer answerTimer;
@ -37,7 +37,11 @@ class RealTimePictureState {
late Timer openDoorTimer;
late AnimationController animationController;
late Timer realTimePicTimer =
Timer(const Duration(seconds: 1), () {}); //
var elapsedSeconds = 0.obs;
RealTimePictureState() {
getLockID.value = Get.arguments["lockId"].toString();
getLockName.value = Get.arguments["lockName"].toString();
}
}

View File

@ -1,6 +1,6 @@
abstract class Api {
static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //
// static String baseAddress = "http://192.168.56.101:8099"; //
// static String baseAddress = "https://pre.lock.star-lock.cn:8093"; //
static String baseAddress = "http://192.168.56.101:8099"; //
// static String baseAddress = "http://192.168.1.15:8022"; //
final String baseUrl = "$baseAddress/api";
@ -27,7 +27,8 @@ abstract class Api {
'/room/uploadElectricQuantity'; //
final String lockRecordUploadURL = '/lockRecords/fromLock'; //
final String getLockRecordLastUploadDataTimeURL = '/lockRecords/getLastRecordTime'; //
final String getLockRecordLastUploadDataTimeURL =
'/lockRecords/getLastRecordTime'; //
final String getLockNetTokenURL = '/lock/getLockNetToken'; //token
final String updateLockUserNoURL = '/key/updateLockUserNo'; //NO
@ -60,12 +61,14 @@ abstract class Api {
final String lockGroupAddLockURL = '/keyGroup/addLockGroup'; //
final String lockGroupDeletLockURL = '/keyGroup/deleteLockGroup'; //
final String listLockByGroupURL = '/authorizedAdmin/listLockByGroup'; //
final String listLockByGroupURL =
'/authorizedAdmin/listLockByGroup'; //
final String setRoomStatusURL = '/lock/updateLockStatus'; //
// final String keyGroupListURL = '/keyGroup/list'; //
// final String lockListByGroupURL = '/room/listByGroup'; //
final String getWifiServiceIpURL = '/wifiLock/getWifiServiceIp'; // Wifi锁服务器
final String updateLockSettingUrl = '/lockSetting/updateLockSetting'; //
final String updateLockSettingUrl =
'/lockSetting/updateLockSetting'; //
final String roomQueryDateUrl = '/room/queryDate'; //
final String lockDiagnoseUrl = '/room/uploadLockInfo'; //
@ -76,12 +79,18 @@ abstract class Api {
final String setCheckInCreateCompanyURL =
'/attendanceCompany/add'; //
final String getAttendanceRecordListByDateURL = '/attendanceRecord/listByDate'; // -
final String getAttendanceRecordListByMonthURL = '/attendanceRecord/earlyListByMonth'; // -
final String getAttendanceRecordListLateTimesByDateURL = '/attendanceRecord/lateListByDate'; // -
final String getAttendanceRecordListLateTimesByMonthURL = '/attendanceRecord/lateEarlyListByMonth'; // -
final String getAttendanceRecordHardworkingListURL = '/attendanceRecord/listForHardworking'; // -
final String getAttendanceRecordDtailURL = '/attendanceRecord/listByMonth'; //
final String getAttendanceRecordListByDateURL =
'/attendanceRecord/listByDate'; // -
final String getAttendanceRecordListByMonthURL =
'/attendanceRecord/earlyListByMonth'; // -
final String getAttendanceRecordListLateTimesByDateURL =
'/attendanceRecord/lateListByDate'; // -
final String getAttendanceRecordListLateTimesByMonthURL =
'/attendanceRecord/lateEarlyListByMonth'; // -
final String getAttendanceRecordHardworkingListURL =
'/attendanceRecord/listForHardworking'; // -
final String getAttendanceRecordDtailURL =
'/attendanceRecord/listByMonth'; //
final String getStaffListURL = '/staff/list'; //
final String addStaffURL = '/staff/add'; //
final String editStaffURL = '/staff/update'; //
@ -96,20 +105,23 @@ abstract class Api {
final String addFingerprintURL = '/fingerprint/add'; //
final String editFingerprintURL = '/fingerprint/changePeriod'; //
final String deleteFingerprintURL = '/fingerprint/delete'; //
final String updateFingerprintUserNoURL = '/fingerprint/updateFingerprintUserNo'; //
final String updateFingerprintUserNoURL =
'/fingerprint/updateFingerprintUserNo'; //
final String getICCardListURL = '/identityCard/list'; // IC卡列表
final String addICCardURL = '/identityCard/add'; // IC卡
final String editICCardURL = '/identityCard/update'; // IC卡
final String deleteICCardURL = '/identityCard/delete'; // IC卡
final String updateICCardUserNoURL = '/identityCard/updateCardUserNo'; // ic卡用户序号
final String updateICCardUserNoURL =
'/identityCard/updateCardUserNo'; // ic卡用户序号
final String transferLockListURL = '/room/listForTransfer'; //
final String transferLockConfirmURL = '/room/transferLockConfirm'; //
final String transferLockURL = '/room/transfer'; //
final String gatewaykListURL = '/plug/list'; //
final String transferGatewayConfirmURL = '/plug/transferPlugConfirm'; //
final String transferGatewayConfirmURL =
'/plug/transferPlugConfirm'; //
final String transferGatewayURL = '/plug/transfer'; //
final String getKeyDetailURL = '/key/get'; //

View File

@ -10,8 +10,6 @@ import '../call/callTalk.dart';
import 'udp_talkClass.dart';
class CommandUDPReciverManager {
static void appDataReceive(List<int> data) async {
///
if (data.isEmpty) {
@ -33,7 +31,6 @@ class CommandUDPReciverManager {
if (data[6] == 4) {
if (data[7] == 2) {
// print("心跳包反馈 在线状态");
} else if (data[7] == 3) {
[Toast.show(msg: "您已在其他设备登录")];
}
@ -52,7 +49,7 @@ class CommandUDPReciverManager {
//
// lockId
var lockId = data.sublist(9, 29);
var lockIdStr = utf8String(lockId);
var lockIdStr = utf8String(lockId);
UDPManage().lockId = lockIdStr;
UDPTalkClass().status = 0;
UDPTalkClass().beCallW(data: data);
@ -115,10 +112,10 @@ class CommandUDPReciverManager {
}
UDPTalkClass().status = 0;
UDPTalkClass().isBeCall = false;
Get.back();
UDPTalkClass().stopLocalAudio();
CallTalk().stopPcmSound();
eventBus.fire(GetUDPStatusRefreshUI(UDPTalkClass().status));
Get.back();
}
break;
case 140:
@ -164,7 +161,9 @@ class CommandUDPReciverManager {
case 8:
{
//
//print("音视频数据");
// print("音视频数据");
CallTalk cllTalk = CallTalk();
cllTalk.getAVData(data1, data1.length);
}
break;
case 9: