液压夯分支
This commit is contained in:
parent
94abe69ac5
commit
b300935498
@ -1,4 +1,5 @@
|
||||
# This is a generated file; do not edit or check into version control.
|
||||
device_info_plus=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\device_info_plus-11.1.1\\
|
||||
flutter_webrtc=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\flutter_webrtc-0.9.48+hotfix.1\\
|
||||
libserialport=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\git\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\
|
||||
open_settings=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\open_settings-2.0.2\\
|
||||
@ -12,6 +13,6 @@ permission_handler_android=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\
|
||||
permission_handler_apple=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\permission_handler_apple-9.4.5\\
|
||||
permission_handler_html=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\permission_handler_html-0.1.3+2\\
|
||||
permission_handler_windows=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\permission_handler_windows-0.2.1\\
|
||||
quick_blue=D:\\ly\\dart\\A\\new\\pile_nav_new\\plugins\\quick_blue\\
|
||||
quick_blue=D:\\ly\\dart\\A\\new\\hy_tamping\\plugins\\quick_blue\\
|
||||
wifi_iot=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\wifi_iot-0.3.19+1\\
|
||||
wifi_scan=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\wifi_scan-0.4.1+1\\
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'dart:developer' as dev;
|
||||
import 'package:cpnav/pages/setting/setting_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -30,8 +29,8 @@ class GnssController extends GetxController {
|
||||
var offsetangle = 0.0.obs; //主副连线与车身夹角
|
||||
late final CoordTrans coordTrans;
|
||||
RecordEntity? lastPilePoint;
|
||||
var _dx = 0.0;
|
||||
var _dy = 0.0;
|
||||
// var _dx = 0.0;
|
||||
// var _dy = 0.0;
|
||||
Timer? timer;
|
||||
checkDistance() {
|
||||
if (DateTime.now().millisecondsSinceEpoch -
|
||||
@ -84,10 +83,10 @@ class GnssController extends GetxController {
|
||||
image: "",
|
||||
);
|
||||
}
|
||||
if (device.x.value == 0 && device.y.value == 0) {
|
||||
device.x.value = 3790621.123;
|
||||
device.y.value = 577052.547;
|
||||
}
|
||||
// if (device.x.value == 0 && device.y.value == 0) {
|
||||
// device.x.value = 3790621.123;
|
||||
// device.y.value = 577052.547;
|
||||
// }
|
||||
// device = DeviceItem(
|
||||
// name: 'GNSS',
|
||||
// tid: 1001,
|
||||
@ -108,40 +107,40 @@ class GnssController extends GetxController {
|
||||
// pilerCenter = Pos3D(4196544.959, 517639.709, 0.0);
|
||||
|
||||
// 插入定时器测试代码
|
||||
timer = Timer.periodic(const Duration(seconds: 1), (Timer timer) {
|
||||
if (lastPilePoint != aimcontroller.selectedPilePoint) {
|
||||
lastPilePoint = aimcontroller.selectedPilePoint;
|
||||
if (aimcontroller.selectedPilePoint != null) {
|
||||
var dx = device.x.value - aimcontroller.selectedPilePoint!.x;
|
||||
var dy = device.y.value - aimcontroller.selectedPilePoint!.y;
|
||||
var distance = sqrt(dx * dx + dy * dy);
|
||||
if (distance > 2) {
|
||||
dx = (aimcontroller.selectedPilePoint!.x - device.x.value) /
|
||||
(distance / 2);
|
||||
dy = (aimcontroller.selectedPilePoint!.y - device.y.value) /
|
||||
(distance / 2);
|
||||
device.x.value = aimcontroller.selectedPilePoint!.x + dx;
|
||||
device.y.value = aimcontroller.selectedPilePoint!.y + dy;
|
||||
}
|
||||
_dx = -dx / 10;
|
||||
_dy = -dy / 10;
|
||||
}
|
||||
}
|
||||
// timer = Timer.periodic(const Duration(seconds: 1), (Timer timer) {
|
||||
// if (lastPilePoint != aimcontroller.selectedPilePoint) {
|
||||
// lastPilePoint = aimcontroller.selectedPilePoint;
|
||||
// if (aimcontroller.selectedPilePoint != null) {
|
||||
// var dx = device.x.value - aimcontroller.selectedPilePoint!.x;
|
||||
// var dy = device.y.value - aimcontroller.selectedPilePoint!.y;
|
||||
// var distance = sqrt(dx * dx + dy * dy);
|
||||
// if (distance > 2) {
|
||||
// dx = (aimcontroller.selectedPilePoint!.x - device.x.value) /
|
||||
// (distance / 2);
|
||||
// dy = (aimcontroller.selectedPilePoint!.y - device.y.value) /
|
||||
// (distance / 2);
|
||||
// device.x.value = aimcontroller.selectedPilePoint!.x + dx;
|
||||
// device.y.value = aimcontroller.selectedPilePoint!.y + dy;
|
||||
// }
|
||||
// _dx = -dx / 10;
|
||||
// _dy = -dy / 10;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ((aimcontroller.selectedPilePoint!.x - device.x).abs() > _dx.abs()) {
|
||||
device.x.value += _dx;
|
||||
device.y.value += _dy;
|
||||
// } else {
|
||||
// device.x = aimcontroller.selectedPilePoint!.x;
|
||||
// device.y = aimcontroller.selectedPilePoint!.y;
|
||||
// }
|
||||
// // if ((aimcontroller.selectedPilePoint!.x - device.x).abs() > _dx.abs()) {
|
||||
// device.x.value += _dx;
|
||||
// device.y.value += _dy;
|
||||
// // } else {
|
||||
// // device.x = aimcontroller.selectedPilePoint!.x;
|
||||
// // device.y = aimcontroller.selectedPilePoint!.y;
|
||||
// // }
|
||||
|
||||
// device.x += 0.05;
|
||||
// device.y += 0.05;
|
||||
device.rotation.value += pi / 180; // 确保旋转角度在0-360度之间
|
||||
device.update.value++;
|
||||
checkDistance();
|
||||
});
|
||||
// // device.x += 0.05;
|
||||
// // device.y += 0.05;
|
||||
// device.rotation.value += pi / 180; // 确保旋转角度在0-360度之间
|
||||
// device.update.value++;
|
||||
// checkDistance();
|
||||
// });
|
||||
|
||||
gnss = Gnss(port: "/dev/ttysWK2", baudrate: 115200);
|
||||
// gnss = Gnss(port: "COM1", baudrate: 115200);
|
||||
@ -150,7 +149,7 @@ class GnssController extends GetxController {
|
||||
} catch (e) {
|
||||
scaffoldMessengerKey.currentState?.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('发生错误: ${e.toString()}'),
|
||||
content: Text('发生错误gnss: ${e.toString()}'),
|
||||
duration: const Duration(seconds: 25),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
|
@ -13,13 +13,12 @@ import 'pages/history/history_record.dart';
|
||||
import 'pages/login/login_page.dart';
|
||||
import 'pages/login/my_routes.dart';
|
||||
import 'pages/pass_track/view.dart';
|
||||
import 'pages/real/index.dart';
|
||||
|
||||
import 'pages/real/real_controller.dart';
|
||||
import 'pages/setting/child_pages/antenna/antenna_setting.dart';
|
||||
import 'pages/setting/child_pages/connect/config/socket_setting.dart';
|
||||
import 'pages/setting/setting_controller.dart';
|
||||
import 'pages/setting/setting_page.dart';
|
||||
import 'pages/setting/child_pages/XyChange/connect.dart';
|
||||
import 'pages/task/taskcontroller.dart';
|
||||
import 'service/user/loginprefs.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
@ -31,8 +30,8 @@ import '../../controllers/gnss_controller.dart';
|
||||
final AppController appcontroller = Get.put(AppController());
|
||||
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =
|
||||
GlobalKey<ScaffoldMessengerState>();
|
||||
Connect connect = Connect();
|
||||
|
||||
// Connect connect = Connect();
|
||||
SocketSetting socket = SocketSetting();
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); //设置全屏
|
||||
@ -42,11 +41,12 @@ void main() async {
|
||||
Get.put(PhoneLoginController());
|
||||
Get.put(ScenceMapController());
|
||||
Get.put(AimPointerController());
|
||||
Get.put(RealController());
|
||||
LoginPrefs loginPrefs = LoginPrefs();
|
||||
String value =
|
||||
await loginPrefs.init(); // await 关键字必须用在异步方法中 await等待异步方法执行完毕 异步方法必须用变量接收
|
||||
if ('ok' == value) {
|
||||
// connect.init();
|
||||
socket.connect();
|
||||
// loginPrefs.removeToken(); //注释掉即能实现短时间二次登录不需要再重新登录
|
||||
runApp(const MyApp());
|
||||
}
|
||||
@ -100,13 +100,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
SettingController settingController = Get.put(SettingController());
|
||||
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||||
settingController.getDeviceId(context);
|
||||
await loadData(settingController);
|
||||
setState(() {
|
||||
isInitialized = settingController.isInitialized;
|
||||
Get.put(PlumDataController());
|
||||
Get.put(AntennaController());
|
||||
Get.put(TaskController());
|
||||
Get.put(RealController());
|
||||
Get.put(GnssController());
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../real/component/chart.dart';
|
||||
|
||||
class MyLineChart extends StatefulWidget {
|
||||
final int pileId;
|
||||
@ -32,9 +31,10 @@ class _MyLineChartState extends State<MyLineChart> {
|
||||
),
|
||||
body: SizedBox(
|
||||
height: size.height - 30,
|
||||
child: ProcessChart(
|
||||
pileId: widget.pileId,
|
||||
)),
|
||||
// child: ProcessChart(
|
||||
// pileId: widget.pileId,
|
||||
// )
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import 'package:intl/intl.dart';
|
||||
import 'package:scence_map/record_entity.dart';
|
||||
import '../../service/base.dart';
|
||||
import '../setting/project/model.dart';
|
||||
import 'line_chart.dart';
|
||||
|
||||
class RecordDataSourceAsync extends AsyncDataTableSource {
|
||||
bool _empty = false;
|
||||
|
@ -51,7 +51,7 @@ class PassTrackController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
loadCoorTrans() async {}
|
||||
|
||||
|
||||
loadSideLine() async {
|
||||
mapController.sideLinListeMap.clear();
|
||||
@ -136,7 +136,7 @@ class PassTrackController extends GetxController {
|
||||
String now = DateFormat('yyyy-MM-dd').format(DateTime.now());
|
||||
if ((currentPoint == null && date.value == now) ||
|
||||
(DateFormat('yyyy-MM-dd').format(currentPoint!.startTime) == now)) {
|
||||
log("${currentPoint?.startTime},now:$now");
|
||||
// log("${currentPoint?.startTime},now:$now");
|
||||
scaffoldMessengerKey.currentState?.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('提示: ${date.value}暂无施工数据'),
|
||||
|
@ -1,368 +1,368 @@
|
||||
import 'dart:math';
|
||||
import 'dart:developer' as dev;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../../service/base.dart';
|
||||
import '../../setting/project/model.dart';
|
||||
import '../process.dart';
|
||||
// import 'dart:math';
|
||||
// import 'dart:developer' as dev;
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter/scheduler.dart';
|
||||
// import 'package:flutter/services.dart';
|
||||
// import 'package:fl_chart/fl_chart.dart';
|
||||
// import 'package:intl/intl.dart';
|
||||
// import '../../../service/base.dart';
|
||||
// import '../../setting/project/model.dart';
|
||||
// import '../process.dart';
|
||||
|
||||
class ProcessChart extends StatefulWidget {
|
||||
final int pileId;
|
||||
const ProcessChart({super.key, required this.pileId});
|
||||
// class ProcessChart extends StatefulWidget {
|
||||
// final int pileId;
|
||||
// const ProcessChart({super.key, required this.pileId});
|
||||
|
||||
@override
|
||||
State<ProcessChart> createState() => _ProcessChartState();
|
||||
}
|
||||
// @override
|
||||
// State<ProcessChart> createState() => _ProcessChartState();
|
||||
// }
|
||||
|
||||
class _ProcessChartState extends State<ProcessChart> {
|
||||
List<ProcessEntity> processList = [];
|
||||
List<Widget> chartTitleWidget = [];
|
||||
// class _ProcessChartState extends State<ProcessChart> {
|
||||
// List<ProcessEntity> processList = [];
|
||||
// List<Widget> chartTitleWidget = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
fetchData();
|
||||
}
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// fetchData();
|
||||
// }
|
||||
|
||||
int maxX = 5;
|
||||
int maxYL = 14; //深度
|
||||
int maxYR = 0; //10cm
|
||||
ChartData chartData = ChartData([]);
|
||||
void fetchData() async {
|
||||
try {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||||
ProjectModel project = settingController.currentProject.value!;
|
||||
String projType = settingController.projType;
|
||||
//获取点的数据
|
||||
List detailCdate = await services.getProcessData(
|
||||
widget.pileId,
|
||||
project.projCode,
|
||||
projType,
|
||||
);
|
||||
// int maxX = 5;
|
||||
// int maxYL = 14; //深度
|
||||
// int maxYR = 0; //10cm
|
||||
// ChartData chartData = ChartData([]);
|
||||
// void fetchData() async {
|
||||
// try {
|
||||
// SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||||
// ProjectModel project = settingController.currentProject.value!;
|
||||
// String projType = settingController.projType;
|
||||
// //获取点的数据
|
||||
// List detailCdate = await services.getProcessData(
|
||||
// widget.pileId,
|
||||
// project.projCode,
|
||||
// projType,
|
||||
// );
|
||||
|
||||
setState(() {
|
||||
double ten1Max = 0;
|
||||
double ten2Max = 0;
|
||||
for (var i = 0; i < detailCdate.length; i++) {
|
||||
ProcessEntity process = ProcessEntity.fromJson(detailCdate[i]);
|
||||
processList.add(process);
|
||||
// 左(深度)右(10cm流量)标题栏最大值计算
|
||||
maxYL = max(maxYL, process.depth.ceil());
|
||||
ten1Max = max(ten1Max, process.subtotalFlow1);
|
||||
ten2Max = max(ten2Max, process.subtotalFlow2);
|
||||
maxYR = max(ten2Max.ceil(), ten1Max.ceil());
|
||||
}
|
||||
int radtio = (maxYR / maxYL).ceil();
|
||||
chartData = ChartData(processList, maxX, maxYL, maxYR, radtio);
|
||||
chartTitleWidget = chartData.chartTitleWeidget();
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
dev.log("错误");
|
||||
setState(() {
|
||||
processList = [];
|
||||
});
|
||||
}
|
||||
}
|
||||
// setState(() {
|
||||
// double ten1Max = 0;
|
||||
// double ten2Max = 0;
|
||||
// for (var i = 0; i < detailCdate.length; i++) {
|
||||
// ProcessEntity process = ProcessEntity.fromJson(detailCdate[i]);
|
||||
// processList.add(process);
|
||||
// // 左(深度)右(10cm流量)标题栏最大值计算
|
||||
// maxYL = max(maxYL, process.depth.ceil());
|
||||
// ten1Max = max(ten1Max, process.subtotalFlow1);
|
||||
// ten2Max = max(ten2Max, process.subtotalFlow2);
|
||||
// maxYR = max(ten2Max.ceil(), ten1Max.ceil());
|
||||
// }
|
||||
// int radtio = (maxYR / maxYL).ceil();
|
||||
// chartData = ChartData(processList, maxX, maxYL, maxYR, radtio);
|
||||
// chartTitleWidget = chartData.chartTitleWeidget();
|
||||
// });
|
||||
// });
|
||||
// } catch (e) {
|
||||
// dev.log("错误");
|
||||
// setState(() {
|
||||
// processList = [];
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
SystemChrome.setPreferredOrientations([]);
|
||||
}
|
||||
// @override
|
||||
// void dispose() {
|
||||
// super.dispose();
|
||||
// SystemChrome.setPreferredOrientations([]);
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: chartTitleWidget)),
|
||||
LineChart(chartData.lineChart)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Stack(
|
||||
// children: [
|
||||
// Positioned(
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: chartTitleWidget)),
|
||||
// LineChart(chartData.lineChart)
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
class ChartTileModel {
|
||||
String title;
|
||||
Color colors;
|
||||
ChartTileModel(
|
||||
this.title,
|
||||
this.colors,
|
||||
);
|
||||
}
|
||||
// class ChartTileModel {
|
||||
// String title;
|
||||
// Color colors;
|
||||
// ChartTileModel(
|
||||
// this.title,
|
||||
// this.colors,
|
||||
// );
|
||||
// }
|
||||
|
||||
class ChartData {
|
||||
List<ProcessEntity> processList;
|
||||
int maxX;
|
||||
// 这3个值变化
|
||||
int maxYL;
|
||||
int maxYR;
|
||||
int radtio;
|
||||
List<ChartTileModel> chartTitle = [
|
||||
ChartTileModel("深度:", Colors.green),
|
||||
ChartTileModel("10cm流量1:", Colors.pink),
|
||||
ChartTileModel("10cm流量2:", Colors.cyan),
|
||||
];
|
||||
ChartData(this.processList,
|
||||
[this.maxX = 5, this.maxYL = 14, this.maxYR = 100, this.radtio = 8]);
|
||||
// class ChartData {
|
||||
// List<ProcessEntity> processList;
|
||||
// int maxX;
|
||||
// // 这3个值变化
|
||||
// int maxYL;
|
||||
// int maxYR;
|
||||
// int radtio;
|
||||
// List<ChartTileModel> chartTitle = [
|
||||
// ChartTileModel("深度:", Colors.green),
|
||||
// ChartTileModel("10cm流量1:", Colors.pink),
|
||||
// ChartTileModel("10cm流量2:", Colors.cyan),
|
||||
// ];
|
||||
// ChartData(this.processList,
|
||||
// [this.maxX = 5, this.maxYL = 14, this.maxYR = 100, this.radtio = 8]);
|
||||
|
||||
List<Widget> chartTitleWeidget() {
|
||||
List<Widget> chartTitleWidget = [];
|
||||
for (var i = 0; i < chartTitle.length; i++) {
|
||||
ChartTileModel tileModel = chartTitle[i];
|
||||
List<Widget> item = [
|
||||
Text(tileModel.title),
|
||||
Container(
|
||||
width: 13,
|
||||
height: 8,
|
||||
margin: const EdgeInsets.only(right: 5),
|
||||
decoration: BoxDecoration(color: tileModel.colors),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
height: 10,
|
||||
),
|
||||
];
|
||||
chartTitleWidget.addAll(item);
|
||||
}
|
||||
return chartTitleWidget;
|
||||
}
|
||||
// List<Widget> chartTitleWeidget() {
|
||||
// List<Widget> chartTitleWidget = [];
|
||||
// for (var i = 0; i < chartTitle.length; i++) {
|
||||
// ChartTileModel tileModel = chartTitle[i];
|
||||
// List<Widget> item = [
|
||||
// Text(tileModel.title),
|
||||
// Container(
|
||||
// width: 13,
|
||||
// height: 8,
|
||||
// margin: const EdgeInsets.only(right: 5),
|
||||
// decoration: BoxDecoration(color: tileModel.colors),
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// width: 10,
|
||||
// height: 10,
|
||||
// ),
|
||||
// ];
|
||||
// chartTitleWidget.addAll(item);
|
||||
// }
|
||||
// return chartTitleWidget;
|
||||
// }
|
||||
|
||||
LineChartData get lineChart => LineChartData(
|
||||
lineTouchData: lineTouchData,
|
||||
gridData: gridData,
|
||||
titlesData: titlesData,
|
||||
borderData: borderData,
|
||||
lineBarsData: lineBarsData,
|
||||
minX: 0,
|
||||
maxX: maxX.toDouble(),
|
||||
maxY: maxYR.toDouble(),
|
||||
minY: 0,
|
||||
);
|
||||
// LineChartData get lineChart => LineChartData(
|
||||
// lineTouchData: lineTouchData,
|
||||
// gridData: gridData,
|
||||
// titlesData: titlesData,
|
||||
// borderData: borderData,
|
||||
// lineBarsData: lineBarsData,
|
||||
// minX: 0,
|
||||
// maxX: maxX.toDouble(),
|
||||
// maxY: maxYR.toDouble(),
|
||||
// minY: 0,
|
||||
// );
|
||||
|
||||
LineTouchData get lineTouchData => LineTouchData(
|
||||
handleBuiltInTouches: true,
|
||||
touchTooltipData: LineTouchTooltipData(
|
||||
fitInsideHorizontally: true,
|
||||
fitInsideVertically: true,
|
||||
// tooltipBgColor: Colors.black38.withOpacity(0.8),
|
||||
getTooltipItems: (List<LineBarSpot> touchedSpots) {
|
||||
// 自定义提示框内容
|
||||
return touchedSpots.map((LineBarSpot touchedSpot) {
|
||||
// 找到对应的数据点的索引
|
||||
final x = touchedSpot.x;
|
||||
int index = (x / maxX * processList.length).round();
|
||||
ProcessEntity process = processList[index];
|
||||
String lineToolValue = "";
|
||||
TextStyle lineToolStyle = const TextStyle(
|
||||
color: Colors.green,
|
||||
);
|
||||
// LineTouchData get lineTouchData => LineTouchData(
|
||||
// handleBuiltInTouches: true,
|
||||
// touchTooltipData: LineTouchTooltipData(
|
||||
// fitInsideHorizontally: true,
|
||||
// fitInsideVertically: true,
|
||||
// // tooltipBgColor: Colors.black38.withOpacity(0.8),
|
||||
// getTooltipItems: (List<LineBarSpot> touchedSpots) {
|
||||
// // 自定义提示框内容
|
||||
// return touchedSpots.map((LineBarSpot touchedSpot) {
|
||||
// // 找到对应的数据点的索引
|
||||
// final x = touchedSpot.x;
|
||||
// int index = (x / maxX * processList.length).round();
|
||||
// ProcessEntity process = processList[index];
|
||||
// String lineToolValue = "";
|
||||
// TextStyle lineToolStyle = const TextStyle(
|
||||
// color: Colors.green,
|
||||
// );
|
||||
|
||||
if (touchedSpot.barIndex == 0) {
|
||||
lineToolValue =
|
||||
"时间:${DateFormat('HH:mm:ss').format(DateTime.parse(process.recvTime)).toString()}\n深度:${process.depth}\n累计流量:${process.toatalFlow1}";
|
||||
lineToolStyle = const TextStyle(color: Colors.green);
|
||||
} else if (touchedSpot.barIndex == 1) {
|
||||
lineToolValue = "10cm流量1:${process.subtotalFlow1}";
|
||||
lineToolStyle = const TextStyle(color: Colors.pink);
|
||||
} else if (touchedSpot.barIndex == 2) {
|
||||
lineToolValue = "10cm流量2:${process.subtotalFlow2}";
|
||||
lineToolStyle = const TextStyle(color: Colors.cyan);
|
||||
}
|
||||
// if (touchedSpot.barIndex == 0) {
|
||||
// lineToolValue =
|
||||
// "时间:${DateFormat('HH:mm:ss').format(DateTime.parse(process.recvTime)).toString()}\n深度:${process.depth}\n累计流量:${process.toatalFlow1}";
|
||||
// lineToolStyle = const TextStyle(color: Colors.green);
|
||||
// } else if (touchedSpot.barIndex == 1) {
|
||||
// lineToolValue = "10cm流量1:${process.subtotalFlow1}";
|
||||
// lineToolStyle = const TextStyle(color: Colors.pink);
|
||||
// } else if (touchedSpot.barIndex == 2) {
|
||||
// lineToolValue = "10cm流量2:${process.subtotalFlow2}";
|
||||
// lineToolStyle = const TextStyle(color: Colors.cyan);
|
||||
// }
|
||||
|
||||
return LineTooltipItem(lineToolValue, lineToolStyle,
|
||||
textAlign: TextAlign.left);
|
||||
}).toList();
|
||||
},
|
||||
),
|
||||
);
|
||||
// FlGridData get gridData => const FlGridData(show: false);
|
||||
//网格
|
||||
FlGridData get gridData => const FlGridData(drawHorizontalLine: true);
|
||||
//设置标题
|
||||
FlTitlesData get titlesData => FlTitlesData(
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: bottomTitles,
|
||||
),
|
||||
rightTitles: AxisTitles(
|
||||
sideTitles: rightTitles(),
|
||||
),
|
||||
topTitles: const AxisTitles(
|
||||
sideTitles: SideTitles(showTitles: false),
|
||||
),
|
||||
leftTitles: AxisTitles(
|
||||
sideTitles: leftTitles(),
|
||||
),
|
||||
);
|
||||
// return LineTooltipItem(lineToolValue, lineToolStyle,
|
||||
// textAlign: TextAlign.left);
|
||||
// }).toList();
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// // FlGridData get gridData => const FlGridData(show: false);
|
||||
// //网格
|
||||
// FlGridData get gridData => const FlGridData(drawHorizontalLine: true);
|
||||
// //设置标题
|
||||
// FlTitlesData get titlesData => FlTitlesData(
|
||||
// bottomTitles: AxisTitles(
|
||||
// sideTitles: bottomTitles,
|
||||
// ),
|
||||
// rightTitles: AxisTitles(
|
||||
// sideTitles: rightTitles(),
|
||||
// ),
|
||||
// topTitles: const AxisTitles(
|
||||
// sideTitles: SideTitles(showTitles: false),
|
||||
// ),
|
||||
// leftTitles: AxisTitles(
|
||||
// sideTitles: leftTitles(),
|
||||
// ),
|
||||
// );
|
||||
|
||||
SideTitles get bottomTitles => SideTitles(
|
||||
showTitles: true,
|
||||
reservedSize: 32,
|
||||
interval: 1,
|
||||
getTitlesWidget: bottomTitleWidgets,
|
||||
);
|
||||
SideTitles leftTitles() => SideTitles(
|
||||
getTitlesWidget: leftTitleWidgets,
|
||||
showTitles: true,
|
||||
interval: 1,
|
||||
reservedSize: 40,
|
||||
);
|
||||
SideTitles rightTitles() => SideTitles(
|
||||
getTitlesWidget: rightTitleWidgets,
|
||||
showTitles: true,
|
||||
interval: 1,
|
||||
reservedSize: 40,
|
||||
);
|
||||
// SideTitles get bottomTitles => SideTitles(
|
||||
// showTitles: true,
|
||||
// reservedSize: 32,
|
||||
// interval: 1,
|
||||
// getTitlesWidget: bottomTitleWidgets,
|
||||
// );
|
||||
// SideTitles leftTitles() => SideTitles(
|
||||
// getTitlesWidget: leftTitleWidgets,
|
||||
// showTitles: true,
|
||||
// interval: 1,
|
||||
// reservedSize: 40,
|
||||
// );
|
||||
// SideTitles rightTitles() => SideTitles(
|
||||
// getTitlesWidget: rightTitleWidgets,
|
||||
// showTitles: true,
|
||||
// interval: 1,
|
||||
// reservedSize: 40,
|
||||
// );
|
||||
|
||||
//x轴
|
||||
Widget bottomTitleWidgets(double value, TitleMeta meta) {
|
||||
const style = TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
);
|
||||
// //x轴
|
||||
// Widget bottomTitleWidgets(double value, TitleMeta meta) {
|
||||
// const style = TextStyle(
|
||||
// fontWeight: FontWeight.bold,
|
||||
// fontSize: 14,
|
||||
// );
|
||||
|
||||
String getTimeFromIndex(int index) {
|
||||
if (processList.isEmpty || index < 0 || index >= processList.length) {
|
||||
return '';
|
||||
}
|
||||
return processList[index].recvTime.toString().split(" ")[1];
|
||||
}
|
||||
// String getTimeFromIndex(int index) {
|
||||
// if (processList.isEmpty || index < 0 || index >= processList.length) {
|
||||
// return '';
|
||||
// }
|
||||
// return processList[index].recvTime.toString().split(" ")[1];
|
||||
// }
|
||||
|
||||
int index;
|
||||
// int index;
|
||||
|
||||
switch (value.toInt()) {
|
||||
case 0:
|
||||
index = 0;
|
||||
break;
|
||||
case 1:
|
||||
index = (processList.length / 5).round();
|
||||
break;
|
||||
case 2:
|
||||
index = (processList.length * 2 / 5).round();
|
||||
break;
|
||||
case 3:
|
||||
index = (processList.length * 3 / 5).round();
|
||||
break;
|
||||
case 4:
|
||||
index = (processList.length * 4 / 5).round();
|
||||
break;
|
||||
case 5:
|
||||
index = processList.length - 1;
|
||||
break;
|
||||
default:
|
||||
return SideTitleWidget(
|
||||
axisSide: meta.axisSide,
|
||||
space: 10,
|
||||
child: const Text(''),
|
||||
);
|
||||
}
|
||||
// switch (value.toInt()) {
|
||||
// case 0:
|
||||
// index = 0;
|
||||
// break;
|
||||
// case 1:
|
||||
// index = (processList.length / 5).round();
|
||||
// break;
|
||||
// case 2:
|
||||
// index = (processList.length * 2 / 5).round();
|
||||
// break;
|
||||
// case 3:
|
||||
// index = (processList.length * 3 / 5).round();
|
||||
// break;
|
||||
// case 4:
|
||||
// index = (processList.length * 4 / 5).round();
|
||||
// break;
|
||||
// case 5:
|
||||
// index = processList.length - 1;
|
||||
// break;
|
||||
// default:
|
||||
// return SideTitleWidget(
|
||||
// axisSide: meta.axisSide,
|
||||
// space: 10,
|
||||
// child: const Text(''),
|
||||
// );
|
||||
// }
|
||||
|
||||
return SideTitleWidget(
|
||||
axisSide: meta.axisSide,
|
||||
space: 10,
|
||||
child: Text(
|
||||
getTimeFromIndex(index),
|
||||
style: style,
|
||||
),
|
||||
);
|
||||
}
|
||||
// return SideTitleWidget(
|
||||
// axisSide: meta.axisSide,
|
||||
// space: 10,
|
||||
// child: Text(
|
||||
// getTimeFromIndex(index),
|
||||
// style: style,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
final style = const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
);
|
||||
//左y轴
|
||||
Widget leftTitleWidgets(double value, TitleMeta meta) {
|
||||
String text;
|
||||
int intValue = (value).ceil();
|
||||
if (intValue % (2 * radtio) == 0 && intValue <= maxYR) {
|
||||
text = (intValue / radtio).floor().toString();
|
||||
if (maxYR - intValue < 2 * radtio) {
|
||||
text = "深度(m)";
|
||||
}
|
||||
} else {
|
||||
return const Text("");
|
||||
}
|
||||
// final style = const TextStyle(
|
||||
// fontWeight: FontWeight.bold,
|
||||
// fontSize: 14,
|
||||
// );
|
||||
// //左y轴
|
||||
// Widget leftTitleWidgets(double value, TitleMeta meta) {
|
||||
// String text;
|
||||
// int intValue = (value).ceil();
|
||||
// if (intValue % (2 * radtio) == 0 && intValue <= maxYR) {
|
||||
// text = (intValue / radtio).floor().toString();
|
||||
// if (maxYR - intValue < 2 * radtio) {
|
||||
// text = "深度(m)";
|
||||
// }
|
||||
// } else {
|
||||
// return const Text("");
|
||||
// }
|
||||
|
||||
return Text(text, style: style, textAlign: TextAlign.center);
|
||||
}
|
||||
// return Text(text, style: style, textAlign: TextAlign.center);
|
||||
// }
|
||||
|
||||
//右y轴
|
||||
Widget rightTitleWidgets(double value, TitleMeta meta) {
|
||||
String text;
|
||||
int intValue = value.toInt();
|
||||
// //右y轴
|
||||
// Widget rightTitleWidgets(double value, TitleMeta meta) {
|
||||
// String text;
|
||||
// int intValue = value.toInt();
|
||||
|
||||
if (intValue >= 0 && intValue % (2 * radtio) == 0 && intValue <= maxYR) {
|
||||
text = (intValue.ceil()).toString();
|
||||
if (maxYR - intValue < 2 * radtio) {
|
||||
text = "流量(L)";
|
||||
}
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
// if (intValue >= 0 && intValue % (2 * radtio) == 0 && intValue <= maxYR) {
|
||||
// text = (intValue.ceil()).toString();
|
||||
// if (maxYR - intValue < 2 * radtio) {
|
||||
// text = "流量(L)";
|
||||
// }
|
||||
// } else {
|
||||
// return Container();
|
||||
// }
|
||||
|
||||
return Text(text, style: style, textAlign: TextAlign.center);
|
||||
}
|
||||
// return Text(text, style: style, textAlign: TextAlign.center);
|
||||
// }
|
||||
|
||||
//边界数据
|
||||
FlBorderData get borderData => FlBorderData(
|
||||
show: true,
|
||||
border: const Border(
|
||||
bottom: BorderSide(color: Colors.grey, width: 4),
|
||||
left: BorderSide(color: Colors.transparent),
|
||||
right: BorderSide(color: Colors.transparent),
|
||||
top: BorderSide(color: Colors.transparent),
|
||||
),
|
||||
);
|
||||
//数据
|
||||
List<LineChartBarData> get lineBarsData => [
|
||||
lineChartBarDataTen1,
|
||||
lineChartBarDataTen2,
|
||||
lineChartBarDataDepth,
|
||||
];
|
||||
LineChartBarData get lineChartBarDataDepth => LineChartBarData(
|
||||
isCurved: false,
|
||||
color: Colors.green,
|
||||
barWidth: 3,
|
||||
isStrokeCapRound: true,
|
||||
dotData: const FlDotData(show: false),
|
||||
belowBarData: BarAreaData(show: false),
|
||||
spots: processList.map((item) {
|
||||
int index = processList.indexOf(item);
|
||||
return FlSpot(
|
||||
(maxX / processList.length) * index, (item.depth * radtio));
|
||||
}).toList());
|
||||
// //边界数据
|
||||
// FlBorderData get borderData => FlBorderData(
|
||||
// show: true,
|
||||
// border: const Border(
|
||||
// bottom: BorderSide(color: Colors.grey, width: 4),
|
||||
// left: BorderSide(color: Colors.transparent),
|
||||
// right: BorderSide(color: Colors.transparent),
|
||||
// top: BorderSide(color: Colors.transparent),
|
||||
// ),
|
||||
// );
|
||||
// //数据
|
||||
// List<LineChartBarData> get lineBarsData => [
|
||||
// lineChartBarDataTen1,
|
||||
// lineChartBarDataTen2,
|
||||
// lineChartBarDataDepth,
|
||||
// ];
|
||||
// LineChartBarData get lineChartBarDataDepth => LineChartBarData(
|
||||
// isCurved: false,
|
||||
// color: Colors.green,
|
||||
// barWidth: 3,
|
||||
// isStrokeCapRound: true,
|
||||
// dotData: const FlDotData(show: false),
|
||||
// belowBarData: BarAreaData(show: false),
|
||||
// spots: processList.map((item) {
|
||||
// int index = processList.indexOf(item);
|
||||
// return FlSpot(
|
||||
// (maxX / processList.length) * index, (item.depth * radtio));
|
||||
// }).toList());
|
||||
|
||||
LineChartBarData get lineChartBarDataTen1 => LineChartBarData(
|
||||
isCurved: false,
|
||||
color: Colors.pink,
|
||||
barWidth: 3,
|
||||
isStrokeCapRound: true,
|
||||
dotData: const FlDotData(show: false),
|
||||
belowBarData: BarAreaData(
|
||||
show: false,
|
||||
color: Colors.pink,
|
||||
),
|
||||
spots: processList.map((item) {
|
||||
int index = processList.indexOf(item);
|
||||
return FlSpot((maxX / processList.length) * index, item.subtotalFlow1);
|
||||
}).toList());
|
||||
// LineChartBarData get lineChartBarDataTen1 => LineChartBarData(
|
||||
// isCurved: false,
|
||||
// color: Colors.pink,
|
||||
// barWidth: 3,
|
||||
// isStrokeCapRound: true,
|
||||
// dotData: const FlDotData(show: false),
|
||||
// belowBarData: BarAreaData(
|
||||
// show: false,
|
||||
// color: Colors.pink,
|
||||
// ),
|
||||
// spots: processList.map((item) {
|
||||
// int index = processList.indexOf(item);
|
||||
// return FlSpot((maxX / processList.length) * index, item.subtotalFlow1);
|
||||
// }).toList());
|
||||
|
||||
LineChartBarData get lineChartBarDataTen2 => LineChartBarData(
|
||||
isCurved: false,
|
||||
color: Colors.cyan,
|
||||
barWidth: 3,
|
||||
isStrokeCapRound: true,
|
||||
dotData: const FlDotData(show: false),
|
||||
belowBarData: BarAreaData(show: false),
|
||||
spots: processList.map((item) {
|
||||
int index = processList.indexOf(item);
|
||||
return FlSpot((maxX / processList.length) * index, item.subtotalFlow2);
|
||||
}).toList());
|
||||
}
|
||||
// LineChartBarData get lineChartBarDataTen2 => LineChartBarData(
|
||||
// isCurved: false,
|
||||
// color: Colors.cyan,
|
||||
// barWidth: 3,
|
||||
// isStrokeCapRound: true,
|
||||
// dotData: const FlDotData(show: false),
|
||||
// belowBarData: BarAreaData(show: false),
|
||||
// spots: processList.map((item) {
|
||||
// int index = processList.indexOf(item);
|
||||
// return FlSpot((maxX / processList.length) * index, item.subtotalFlow2);
|
||||
// }).toList());
|
||||
// }
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'line_chart.dart';
|
||||
import 'real_controller.dart';
|
||||
import 'real_data.dart';
|
||||
|
||||
@ -30,21 +29,21 @@ class Real extends StatelessWidget {
|
||||
),
|
||||
space,
|
||||
// lineChart
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(child: RealChart()),
|
||||
Obx(() => Slider(
|
||||
value: realController.startIndex.toDouble(),
|
||||
onChanged: (newvalue) =>
|
||||
realController.updateSlider(newvalue),
|
||||
min: 0,
|
||||
max: realController.processList.length.toDouble(),
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
// Expanded(
|
||||
// flex: 1,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Expanded(child: RealChart()),
|
||||
// Obx(() => Slider(
|
||||
// value: realController.startIndex.toDouble(),
|
||||
// onChanged: (newvalue) =>
|
||||
// realController.updateSlider(newvalue),
|
||||
// min: 0,
|
||||
// max: realController.processList.length.toDouble(),
|
||||
// )),
|
||||
// ],
|
||||
// ),
|
||||
// )
|
||||
];
|
||||
if (isPortrait) {
|
||||
return Container(
|
||||
|
@ -1,113 +1,113 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
// // ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
// import 'package:fl_chart/fl_chart.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:get/get.dart';
|
||||
// import 'package:intl/intl.dart';
|
||||
|
||||
import 'component/chart.dart';
|
||||
import 'process.dart';
|
||||
import 'real_controller.dart';
|
||||
// import 'component/chart.dart';
|
||||
// import 'process.dart';
|
||||
// import 'real_controller.dart';
|
||||
|
||||
|
||||
|
||||
// 深度
|
||||
class RealChart extends StatelessWidget {
|
||||
RealChart({super.key});
|
||||
ChartData chartData = ChartData(
|
||||
[],
|
||||
);
|
||||
final RealController realController = Get.put(RealController());
|
||||
List<ProcessEntity> processList = [];
|
||||
format(double value, [int fix = 2]) {
|
||||
return double.parse(value.toStringAsFixed(fix));
|
||||
}
|
||||
// // 深度
|
||||
// class RealChart extends StatelessWidget {
|
||||
// RealChart({super.key});
|
||||
// ChartData chartData = ChartData(
|
||||
// [],
|
||||
// );
|
||||
// final RealController realController = Get.put(RealController());
|
||||
// List<ProcessEntity> processList = [];
|
||||
// format(double value, [int fix = 2]) {
|
||||
// return double.parse(value.toStringAsFixed(fix));
|
||||
// }
|
||||
|
||||
List<ProcessEntity> cache = [];
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 显示长度
|
||||
int showlength = 30;
|
||||
ever(realController.depth, (newValue) {
|
||||
ProcessEntity process = ProcessEntity(
|
||||
recvTime: DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
|
||||
pileId: realController.pileId.value,
|
||||
utc: 0,
|
||||
tid: 100,
|
||||
toatalFlow1: format(realController.totalFlow1.value),
|
||||
toatalFlow2: format(realController.totalFlow2.value),
|
||||
subtotalFlow1: format(realController.subtotalFlow1.value),
|
||||
subtotalFlow2: format(realController.subtotalFlow2.value),
|
||||
depth: format(realController.depth.value),
|
||||
);
|
||||
// List<ProcessEntity> cache = [];
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// // 显示长度
|
||||
// int showlength = 30;
|
||||
// ever(realController.depth, (newValue) {
|
||||
// ProcessEntity process = ProcessEntity(
|
||||
// recvTime: DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
|
||||
// pileId: realController.pileId.value,
|
||||
// utc: 0,
|
||||
// tid: 100,
|
||||
// toatalFlow1: format(realController.totalFlow1.value),
|
||||
// toatalFlow2: format(realController.totalFlow2.value),
|
||||
// subtotalFlow1: format(realController.subtotalFlow1.value),
|
||||
// subtotalFlow2: format(realController.subtotalFlow2.value),
|
||||
// depth: format(realController.depth.value),
|
||||
// );
|
||||
|
||||
processList.add(process);
|
||||
// processList.add(process);
|
||||
|
||||
if (realController.sliderTime != null) {
|
||||
if (DateTime.now().difference(realController.sliderTime!).inSeconds >
|
||||
10) {
|
||||
realController.updateProcessList(processList);
|
||||
realController.updateSlider(processList.length.toDouble(), false);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
realController.updateProcessList(processList);
|
||||
if (realController.startIndex.value != processList.length) {
|
||||
realController.updateSlider(processList.length.toDouble(), false);
|
||||
}
|
||||
}
|
||||
});
|
||||
ever(realController.pileId, (newValue) {
|
||||
ProcessEntity process = ProcessEntity(
|
||||
recvTime: DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
|
||||
pileId: realController.pileId.value,
|
||||
utc: 0,
|
||||
tid: 100,
|
||||
toatalFlow1: format(realController.totalFlow1.value),
|
||||
toatalFlow2: format(realController.totalFlow2.value),
|
||||
subtotalFlow1: format(realController.subtotalFlow1.value),
|
||||
subtotalFlow2: format(realController.subtotalFlow2.value),
|
||||
depth: format(realController.depth.value),
|
||||
);
|
||||
processList.length = 0;
|
||||
processList.add(process);
|
||||
realController.updateProcessList(processList.toList());
|
||||
realController.startIndex.value = 0;
|
||||
});
|
||||
// if (realController.sliderTime != null) {
|
||||
// if (DateTime.now().difference(realController.sliderTime!).inSeconds >
|
||||
// 10) {
|
||||
// realController.updateProcessList(processList);
|
||||
// realController.updateSlider(processList.length.toDouble(), false);
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
// realController.updateProcessList(processList);
|
||||
// if (realController.startIndex.value != processList.length) {
|
||||
// realController.updateSlider(processList.length.toDouble(), false);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// ever(realController.pileId, (newValue) {
|
||||
// ProcessEntity process = ProcessEntity(
|
||||
// recvTime: DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
|
||||
// pileId: realController.pileId.value,
|
||||
// utc: 0,
|
||||
// tid: 100,
|
||||
// toatalFlow1: format(realController.totalFlow1.value),
|
||||
// toatalFlow2: format(realController.totalFlow2.value),
|
||||
// subtotalFlow1: format(realController.subtotalFlow1.value),
|
||||
// subtotalFlow2: format(realController.subtotalFlow2.value),
|
||||
// depth: format(realController.depth.value),
|
||||
// );
|
||||
// processList.length = 0;
|
||||
// processList.add(process);
|
||||
// realController.updateProcessList(processList.toList());
|
||||
// realController.startIndex.value = 0;
|
||||
// });
|
||||
|
||||
List<Widget> chartTitleWidget = chartData.chartTitleWeidget();
|
||||
Widget chartWidget(List<ProcessEntity> processList) {
|
||||
int startIndex = 0;
|
||||
// List<Widget> chartTitleWidget = chartData.chartTitleWeidget();
|
||||
// Widget chartWidget(List<ProcessEntity> processList) {
|
||||
// int startIndex = 0;
|
||||
|
||||
if ((realController.startIndex.value + showlength) < processList.length &&
|
||||
realController.startIndex.value != 0) {
|
||||
startIndex = realController.startIndex.value;
|
||||
} else {
|
||||
startIndex = ((processList.length - showlength < 0)
|
||||
? 0
|
||||
: (processList.length - showlength));
|
||||
}
|
||||
int endIndex = startIndex + showlength > processList.length
|
||||
? processList.length
|
||||
: startIndex + showlength;
|
||||
ChartData chartData = ChartData(
|
||||
processList.sublist(startIndex, endIndex),
|
||||
);
|
||||
return LineChart(chartData.lineChart);
|
||||
}
|
||||
// if ((realController.startIndex.value + showlength) < processList.length &&
|
||||
// realController.startIndex.value != 0) {
|
||||
// startIndex = realController.startIndex.value;
|
||||
// } else {
|
||||
// startIndex = ((processList.length - showlength < 0)
|
||||
// ? 0
|
||||
// : (processList.length - showlength));
|
||||
// }
|
||||
// int endIndex = startIndex + showlength > processList.length
|
||||
// ? processList.length
|
||||
// : startIndex + showlength;
|
||||
// ChartData chartData = ChartData(
|
||||
// processList.sublist(startIndex, endIndex),
|
||||
// );
|
||||
// return LineChart(chartData.lineChart);
|
||||
// }
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: chartTitleWidget,
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Obx(
|
||||
() => SizedBox(child: chartWidget(realController.processList))))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
// return Column(
|
||||
// children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: chartTitleWidget,
|
||||
// ),
|
||||
// Expanded(
|
||||
// flex: 1,
|
||||
// child: Obx(
|
||||
// () => SizedBox(child: chartWidget(realController.processList))))
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
@ -1,107 +1,134 @@
|
||||
import 'dart:core';
|
||||
|
||||
class ProcessEntity {
|
||||
double speed;
|
||||
double depth;
|
||||
double tiltX;
|
||||
double tiltY;
|
||||
double current1;
|
||||
double current2;
|
||||
double toatalFlow2;
|
||||
double toatalFlow1;
|
||||
double subtotalFlow2;
|
||||
double subtotalFlow1;
|
||||
String recvTime;
|
||||
// double? azimuth;
|
||||
double alt = 0;
|
||||
double lng = 0;
|
||||
double lat = 0;
|
||||
String pileId;
|
||||
int utc;
|
||||
int tid;
|
||||
int? id;
|
||||
ProcessEntity(
|
||||
{this.speed = 0,
|
||||
this.depth = 0,
|
||||
this.tiltX = 0,
|
||||
this.tiltY = 0,
|
||||
this.current1 = 0,
|
||||
this.current2 = 0,
|
||||
this.toatalFlow2 = 0,
|
||||
this.toatalFlow1 = 0,
|
||||
this.subtotalFlow2 = 0,
|
||||
this.subtotalFlow1 = 0,
|
||||
required this.recvTime,
|
||||
// this.azimuth,
|
||||
this.alt = 0,
|
||||
this.lng = 0,
|
||||
this.lat = 0,
|
||||
required this.pileId,
|
||||
required this.utc,
|
||||
required this.tid,
|
||||
this.id});
|
||||
factory ProcessEntity.fromJson(Map<String, dynamic> json) {
|
||||
return ProcessEntity(
|
||||
speed: (json["speed"] ?? "0").toDouble(),
|
||||
depth: (json["depth"] ?? "0").toDouble(),
|
||||
tiltX: (json["tilt_x"] ?? "0").toDouble(),
|
||||
tiltY: (json["tilt_y"] ?? "0").toDouble(),
|
||||
current1: (json["current1"] ?? "0").toDouble(),
|
||||
current2: (json["current2"] ?? "0").toDouble(),
|
||||
toatalFlow2: (json["toatal_flow2"] ?? "0").toDouble(),
|
||||
toatalFlow1: (json["toatal_flow1"] ?? "0").toDouble(),
|
||||
subtotalFlow2: (json["subtotal_flow2"] ?? "0").toDouble(),
|
||||
subtotalFlow1: (json["subtotal_flow1"] ?? "0").toDouble(),
|
||||
recvTime: json["recv_time"] ?? DateTime.now(),
|
||||
// azimuth: (json["azimuth"] ?? "0").toDouble(),
|
||||
alt: (json["ALT"] ?? "0").toDouble(),
|
||||
lng: (json["LNG"] ?? "0").toDouble(),
|
||||
lat: (json["LAT"] ?? "0").toDouble(),
|
||||
pileId: json["pile_id"].toString(),
|
||||
utc: json["UTC"],
|
||||
tid: json['tid'],
|
||||
id: json["id"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// class ProcessEntity {
|
||||
// // String recvTime;
|
||||
// double? azimuth;
|
||||
// double speed;
|
||||
// double depth;
|
||||
// double tiltX;
|
||||
// double tiltY;
|
||||
// double current1;
|
||||
// double current2;
|
||||
// double toatalFlow2;
|
||||
// double toatalFlow1;
|
||||
// double subtotalFlow2;
|
||||
// double subtotalFlow1;
|
||||
// String recvTime;
|
||||
// // double? azimuth;
|
||||
// double alt = 0;
|
||||
// double lng = 0;
|
||||
// double lat = 0;
|
||||
// int tp_id;
|
||||
// String pileId;
|
||||
// int utc;
|
||||
// int tid;
|
||||
// int? id;
|
||||
// int times;
|
||||
// // impact_force
|
||||
// // distance;
|
||||
// // pith
|
||||
// ProcessEntity(
|
||||
// {this.times = 0,
|
||||
|
||||
// // required this.recvTime,
|
||||
// this.azimuth,
|
||||
// {this.speed = 0,
|
||||
// this.depth = 0,
|
||||
// this.tiltX = 0,
|
||||
// this.tiltY = 0,
|
||||
// this.current1 = 0,
|
||||
// this.current2 = 0,
|
||||
// this.toatalFlow2 = 0,
|
||||
// this.toatalFlow1 = 0,
|
||||
// this.subtotalFlow2 = 0,
|
||||
// this.subtotalFlow1 = 0,
|
||||
// required this.recvTime,
|
||||
// // this.azimuth,
|
||||
// this.alt = 0,
|
||||
// this.lng = 0,
|
||||
// this.lat = 0,
|
||||
// required this.tp_id,
|
||||
// required this.pileId,
|
||||
// required this.utc,
|
||||
// required this.tid,
|
||||
// this.id});
|
||||
// factory ProcessEntity.fromJson(Map<String, dynamic> json) {
|
||||
// return ProcessEntity(
|
||||
// // recvTime: json["recv_time"] ?? DateTime.now(),
|
||||
// speed: (json["speed"] ?? "0").toDouble(),
|
||||
// depth: (json["depth"] ?? "0").toDouble(),
|
||||
// tiltX: (json["tilt_x"] ?? "0").toDouble(),
|
||||
// tiltY: (json["tilt_y"] ?? "0").toDouble(),
|
||||
// current1: (json["current1"] ?? "0").toDouble(),
|
||||
// current2: (json["current2"] ?? "0").toDouble(),
|
||||
// toatalFlow2: (json["toatal_flow2"] ?? "0").toDouble(),
|
||||
// toatalFlow1: (json["toatal_flow1"] ?? "0").toDouble(),
|
||||
// subtotalFlow2: (json["subtotal_flow2"] ?? "0").toDouble(),
|
||||
// subtotalFlow1: (json["subtotal_flow1"] ?? "0").toDouble(),
|
||||
// recvTime: json["recv_time"] ?? DateTime.now(),
|
||||
// // azimuth: (json["azimuth"] ?? "0").toDouble(),
|
||||
// alt: (json["ALT"] ?? "0").toDouble(),
|
||||
// lng: (json["LNG"] ?? "0").toDouble(),
|
||||
// lat: (json["LAT"] ?? "0").toDouble(),
|
||||
// tp_id: json["tp_id"],
|
||||
// pileId: json["pile_id"].toString(),
|
||||
// utc: json["UTC"],
|
||||
// tid: json['tid'],
|
||||
// id: json["id"],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
class ProcessEntity {
|
||||
// String recvTime;
|
||||
double? azimuth;
|
||||
double alt = 0;
|
||||
double lng = 0;
|
||||
double lat = 0;
|
||||
int tp_id;
|
||||
int utc;
|
||||
int tid;
|
||||
int? id;
|
||||
int times;
|
||||
double height;
|
||||
double speed;
|
||||
// double impact_force;
|
||||
List<double> impact_force;
|
||||
// distance;
|
||||
// pith
|
||||
ProcessEntity(
|
||||
{this.times = 0,
|
||||
|
||||
// required this.recvTime,
|
||||
this.azimuth,
|
||||
this.alt = 0,
|
||||
this.lng = 0,
|
||||
this.lat = 0,
|
||||
this.height = 0,
|
||||
this.speed = 0,
|
||||
required this.impact_force,
|
||||
required this.tp_id,
|
||||
required this.utc,
|
||||
required this.tid,
|
||||
this.id});
|
||||
factory ProcessEntity.fromJson(Map<String, dynamic> json) {
|
||||
return ProcessEntity(
|
||||
// recvTime: json["recv_time"] ?? DateTime.now(),
|
||||
// azimuth: (json["azimuth"] ?? "0").toDouble(),
|
||||
alt: (json["ALT"] ?? "0").toDouble(),
|
||||
lng: (json["LNG"] ?? "0").toDouble(),
|
||||
lat: (json["LAT"] ?? "0").toDouble(),
|
||||
tp_id: json["tp_id"],
|
||||
utc: json["UTC"],
|
||||
tid: json['tid'],
|
||||
id: json["id"],
|
||||
times: json["times"],
|
||||
impact_force: json["impact_force"].cast<double>(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
factory ProcessEntity.fromString(String str) {
|
||||
List<String> list = str.split(",");
|
||||
return ProcessEntity(
|
||||
utc:int.parse( list[2]),
|
||||
lat: double.parse(list[3]),
|
||||
lng: double.parse(list[4]),
|
||||
height: double.parse(list[5]),
|
||||
speed: double.parse(list[6]),
|
||||
tp_id: 0, tid: 0,
|
||||
impact_force: []
|
||||
|
||||
// impact_force: double.parse(list[7]),
|
||||
|
||||
// recvTime: json["recv_time"] ?? DateTime.now(),
|
||||
// tp_id: ,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,183 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
import 'package:cpnav/pages/setting/child_pages/XyChange/xy_change.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
// import 'package:flutter_webrtc/flutter_webrtc.dart';
|
||||
|
||||
import '../../models/pilePoint/coord_trans.dart';
|
||||
import '../setting/child_pages/XyChange/coor_trans.dart';
|
||||
import '../setting/setting_controller.dart';
|
||||
import 'process.dart';
|
||||
// pile_cm
|
||||
// class RealController extends GetxController {
|
||||
// var sightOffset1 = const Offset(3, 3).obs;
|
||||
// var sightOffsetInit1 = const Offset(0, 0).obs;
|
||||
// var sightInit1 = const Offset(0, 0).obs;
|
||||
// var initDx = 0.0.obs;
|
||||
// reset() {
|
||||
// sightOffset1.value = const Offset(3, 3);
|
||||
// sightOffsetInit1.value = const Offset(0, 0);
|
||||
// sightInit1.value = const Offset(0, 0);
|
||||
|
||||
// initDx.value = 0.0;
|
||||
// update();
|
||||
// }
|
||||
|
||||
// // RTCPeerConnection? peerConnection;
|
||||
// // RTCDataChannel? dataChannel;
|
||||
// final speed = 0.0.obs;
|
||||
// final depth = 0.0.obs;
|
||||
// final tiltX = 0.0.obs;
|
||||
// final tiltY = 0.0.obs;
|
||||
// final centerX = 0.0.obs;
|
||||
// final centerY = 0.0.obs;
|
||||
// final current1 = 0.0.obs;
|
||||
// final current2 = 0.0.obs;
|
||||
// final totalFlow2 = 0.0.obs;
|
||||
// final totalFlow1 = 0.0.obs;
|
||||
// final flow10cm1 = 0.0.obs;
|
||||
// final flow10cm2 = 0.0.obs;
|
||||
// final subtotalFlow2 = 0.0.obs;
|
||||
// final subtotalFlow1 = 0.0.obs;
|
||||
// final recvTime = ''.obs;
|
||||
// final alt = 0.0.obs;
|
||||
// final lng = 0.0.obs;
|
||||
// final lat = 0.0.obs;
|
||||
// final pileId = ''.obs;
|
||||
// final time = "0".obs;
|
||||
// final startIndex = 0.obs;
|
||||
// // 折线数组
|
||||
|
||||
// final processList = <ProcessEntity>[].obs;
|
||||
// var isDataVisible = false.obs;
|
||||
|
||||
// void updateProcessList(List<ProcessEntity> newList) {
|
||||
// processList.assignAll(newList); // 使用 assignAll 方法更新 RxList
|
||||
// }
|
||||
|
||||
// DateTime? sliderTime;
|
||||
// updateSlider(double newValue, [isHand = true]) {
|
||||
// if (isHand) {
|
||||
// sliderTime = DateTime.now();
|
||||
// }
|
||||
// startIndex.value = newValue.toInt();
|
||||
// update();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void onInit() {
|
||||
// super.onInit();
|
||||
// // 定时器每秒更新时间
|
||||
// // Timer.periodic(const Duration(milliseconds: 1000), (_) {
|
||||
// // time.value = DateTime.now();
|
||||
// // });
|
||||
// initializePeerConnection();
|
||||
// }
|
||||
|
||||
// void initializePeerConnection() async {
|
||||
// // final configuration = <String, dynamic>{
|
||||
// // 'iceServers': [
|
||||
// // {'url': 'stun:stun.l.google.com:19302'},
|
||||
// // ],
|
||||
// // };
|
||||
// // peerConnection = await createPeerConnection(configuration);
|
||||
// // initializeDataChannel();
|
||||
// }
|
||||
|
||||
// // void initializeDataChannel() async {
|
||||
// // // 创建数据通道
|
||||
// // dataChannel = await peerConnection!
|
||||
// // .createDataChannel('dataChannel', RTCDataChannelInit()..id = 1);
|
||||
|
||||
// // // 监听数据通道的消息事件
|
||||
// // dataChannel!.onMessage = (RTCDataChannelMessage message) {
|
||||
// // // 处理接收到的消息
|
||||
// // if (message.isBinary) {
|
||||
// // onBleData(message.binary);
|
||||
// // }
|
||||
// // };
|
||||
// // }
|
||||
|
||||
// onBleData(Uint8List data) {
|
||||
// ByteData byteData = data.buffer.asByteData();
|
||||
// int tag = byteData.getUint8(0);
|
||||
// // int length = byteData.getUint8(1);
|
||||
// if (tag == 161) {
|
||||
// speed.value = byteData.getInt16(2, Endian.little) * 0.1;
|
||||
// int timeInt = byteData.getUint16(4, Endian.little);
|
||||
// // log(timeInt);
|
||||
// time.value = convertSecondsToMinSec(timeInt);
|
||||
// depth.value = byteData.getInt16(6, Endian.little) * 0.001;
|
||||
// pileId.value = byteData.getUint16(8, Endian.little).toString();
|
||||
// subtotalFlow1.value = byteData.getInt16(10, Endian.little) * 0.01;
|
||||
// flow10cm1.value = byteData.getUint16(12, Endian.little) * 0.01;
|
||||
// totalFlow1.value = byteData.getInt32(14, Endian.little) * 0.01;
|
||||
// subtotalFlow2.value = byteData.getInt16(18, Endian.little) * 0.01;
|
||||
// flow10cm2.value = byteData.getUint16(20, Endian.little) * 0.01;
|
||||
// totalFlow2.value = byteData.getInt32(22, Endian.little) * 0.01;
|
||||
// current1.value = byteData.getUint16(26, Endian.little) * 0.01;
|
||||
// current2.value = byteData.getUint16(28, Endian.little) * 0.01;
|
||||
// // current3.value = byteData.getUint16(30, Endian.little) * 0.01;
|
||||
// int tag1 = byteData.getUint8(34);
|
||||
// // int length = byteData.getUint8(35);
|
||||
// if (tag1 == 162) {
|
||||
// // var gpsStatus = byteData.getUint8(36);
|
||||
// // var gpsView = byteData.getUint8(37);
|
||||
|
||||
// // var gpsUse = byteData.getUint8(38);
|
||||
// // var reg = byteData.getUint8(39);
|
||||
// // var utc = byteData.getUint32(40, Endian.little);
|
||||
// // 中心坐标
|
||||
// centerX.value = byteData.getFloat64(44, Endian.little);
|
||||
// centerY.value = byteData.getFloat64(52, Endian.little);
|
||||
// // log("中心---$centerX,$centerY");
|
||||
// // tiltX.value = byteData.getFloat64(44, Endian.little);
|
||||
// // tiltY.value = byteData.getFloat64(52, Endian.little);
|
||||
// // var direction = byteData.getFloat64(60, Endian.little);
|
||||
// // var pitch = byteData.getFloat64(68, Endian.little);
|
||||
// // log("$gpsUse,$gpsView,$utc,$direction,$pitch");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// String convertSecondsToMinSec(int totalSeconds) {
|
||||
// int minutes = totalSeconds ~/ 60;
|
||||
// int seconds = totalSeconds % 60;
|
||||
|
||||
// String formattedTime = '$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||
|
||||
// return formattedTime;
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void dispose() {
|
||||
// // dataChannel?.close(); // 关闭数据通道
|
||||
// // peerConnection?.close(); // 关闭对等连接
|
||||
// super.dispose();
|
||||
// }
|
||||
// }
|
||||
|
||||
final ScenceMapController mapController = Get.find<ScenceMapController>();
|
||||
SettingController settingController = Get.find<SettingController>();
|
||||
XYChangeController xyChangeController = Get.put(XYChangeController());
|
||||
|
||||
class RealController extends GetxController {
|
||||
var sightOffset1 = const Offset(3, 3).obs;
|
||||
var sightOffsetInit1 = const Offset(0, 0).obs;
|
||||
var sightInit1 = const Offset(0, 0).obs;
|
||||
var initDx = 0.0.obs;
|
||||
var processdata = ProcessEntity(
|
||||
tid: 0,
|
||||
speed: 0,
|
||||
alt: 0,
|
||||
lng: 0,
|
||||
lat: 0,
|
||||
tp_id: 0,
|
||||
utc: DateTime.now().millisecond,
|
||||
impact_force: []).obs;
|
||||
var dataCount = 0.obs;
|
||||
CoordTrans? coordTrans;
|
||||
reset() {
|
||||
sightOffset1.value = const Offset(3, 3);
|
||||
sightOffsetInit1.value = const Offset(0, 0);
|
||||
@ -19,136 +187,35 @@ class RealController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
// RTCPeerConnection? peerConnection;
|
||||
// RTCDataChannel? dataChannel;
|
||||
final speed = 0.0.obs;
|
||||
final depth = 0.0.obs;
|
||||
final tiltX = 0.0.obs;
|
||||
final tiltY = 0.0.obs;
|
||||
final centerX = 0.0.obs;
|
||||
final centerY = 0.0.obs;
|
||||
final current1 = 0.0.obs;
|
||||
final current2 = 0.0.obs;
|
||||
final totalFlow2 = 0.0.obs;
|
||||
final totalFlow1 = 0.0.obs;
|
||||
final flow10cm1 = 0.0.obs;
|
||||
final flow10cm2 = 0.0.obs;
|
||||
final subtotalFlow2 = 0.0.obs;
|
||||
final subtotalFlow1 = 0.0.obs;
|
||||
final recvTime = ''.obs;
|
||||
final alt = 0.0.obs;
|
||||
final lng = 0.0.obs;
|
||||
final lat = 0.0.obs;
|
||||
final pileId = ''.obs;
|
||||
final time = "0".obs;
|
||||
final startIndex = 0.obs;
|
||||
// 折线数组
|
||||
|
||||
final processList = <ProcessEntity>[].obs;
|
||||
var isDataVisible = false.obs;
|
||||
|
||||
void updateProcessList(List<ProcessEntity> newList) {
|
||||
processList.assignAll(newList); // 使用 assignAll 方法更新 RxList
|
||||
}
|
||||
|
||||
DateTime? sliderTime;
|
||||
updateSlider(double newValue, [isHand = true]) {
|
||||
if (isHand) {
|
||||
sliderTime = DateTime.now();
|
||||
}
|
||||
startIndex.value = newValue.toInt();
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
// 定时器每秒更新时间
|
||||
// Timer.periodic(const Duration(milliseconds: 1000), (_) {
|
||||
// time.value = DateTime.now();
|
||||
// });
|
||||
initializePeerConnection();
|
||||
}
|
||||
|
||||
void initializePeerConnection() async {
|
||||
// final configuration = <String, dynamic>{
|
||||
// 'iceServers': [
|
||||
// {'url': 'stun:stun.l.google.com:19302'},
|
||||
// ],
|
||||
// };
|
||||
// peerConnection = await createPeerConnection(configuration);
|
||||
// initializeDataChannel();
|
||||
}
|
||||
|
||||
// void initializeDataChannel() async {
|
||||
// // 创建数据通道
|
||||
// dataChannel = await peerConnection!
|
||||
// .createDataChannel('dataChannel', RTCDataChannelInit()..id = 1);
|
||||
|
||||
// // 监听数据通道的消息事件
|
||||
// dataChannel!.onMessage = (RTCDataChannelMessage message) {
|
||||
// // 处理接收到的消息
|
||||
// if (message.isBinary) {
|
||||
// onBleData(message.binary);
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
|
||||
onBleData(Uint8List data) {
|
||||
ByteData byteData = data.buffer.asByteData();
|
||||
int tag = byteData.getUint8(0);
|
||||
// int length = byteData.getUint8(1);
|
||||
if (tag == 161) {
|
||||
speed.value = byteData.getInt16(2, Endian.little) * 0.1;
|
||||
int timeInt = byteData.getUint16(4, Endian.little);
|
||||
// log(timeInt);
|
||||
time.value = convertSecondsToMinSec(timeInt);
|
||||
depth.value = byteData.getInt16(6, Endian.little) * 0.001;
|
||||
pileId.value = byteData.getUint16(8, Endian.little).toString();
|
||||
subtotalFlow1.value = byteData.getInt16(10, Endian.little) * 0.01;
|
||||
flow10cm1.value = byteData.getUint16(12, Endian.little) * 0.01;
|
||||
totalFlow1.value = byteData.getInt32(14, Endian.little) * 0.01;
|
||||
subtotalFlow2.value = byteData.getInt16(18, Endian.little) * 0.01;
|
||||
flow10cm2.value = byteData.getUint16(20, Endian.little) * 0.01;
|
||||
totalFlow2.value = byteData.getInt32(22, Endian.little) * 0.01;
|
||||
current1.value = byteData.getUint16(26, Endian.little) * 0.01;
|
||||
current2.value = byteData.getUint16(28, Endian.little) * 0.01;
|
||||
// current3.value = byteData.getUint16(30, Endian.little) * 0.01;
|
||||
int tag1 = byteData.getUint8(34);
|
||||
// int length = byteData.getUint8(35);
|
||||
if (tag1 == 162) {
|
||||
// var gpsStatus = byteData.getUint8(36);
|
||||
// var gpsView = byteData.getUint8(37);
|
||||
String str = String.fromCharCodes(data);
|
||||
|
||||
// var gpsUse = byteData.getUint8(38);
|
||||
// var reg = byteData.getUint8(39);
|
||||
// var utc = byteData.getUint32(40, Endian.little);
|
||||
// 中心坐标
|
||||
centerX.value = byteData.getFloat64(44, Endian.little);
|
||||
centerY.value = byteData.getFloat64(52, Endian.little);
|
||||
// log("中心---$centerX,$centerY");
|
||||
// tiltX.value = byteData.getFloat64(44, Endian.little);
|
||||
// tiltY.value = byteData.getFloat64(52, Endian.little);
|
||||
// var direction = byteData.getFloat64(60, Endian.little);
|
||||
// var pitch = byteData.getFloat64(68, Endian.little);
|
||||
// log("$gpsUse,$gpsView,$utc,$direction,$pitch");
|
||||
}
|
||||
ProcessEntity process = ProcessEntity.fromString(str);
|
||||
processdata.value = process;
|
||||
dataCount.value++;
|
||||
CoorTransModel trans = xyChangeController.coorTrans.value;
|
||||
coordTrans ??= CoordTrans(TransOptions(
|
||||
L0: trans.L0,
|
||||
// dstEllipsoid: trans.dstEllipsoid,
|
||||
// srcEllipsoid: trans.srcEllipsoid,
|
||||
dx: trans.dx,
|
||||
dy: trans.dy,
|
||||
type: trans.type));
|
||||
var xyh = coordTrans!
|
||||
.d2p(CoordBLH(B: process.lat, L: process.lng, H: process.alt));
|
||||
Offset offset = Offset(xyh.X, xyh.Y);
|
||||
if ((mapController.centerXY - offset).distance > 40) {
|
||||
mapController.centerXY = offset;
|
||||
mapController.updateCount++;
|
||||
}
|
||||
var centerDev =
|
||||
mapController.deviceList[settingController.currentDevice.value?.tid];
|
||||
if (centerDev != null) {
|
||||
// log("center${xyh.X},${xyh.Y}");
|
||||
centerDev.x.value = xyh.X;
|
||||
centerDev.y.value = xyh.Y;
|
||||
centerDev.update.value++;
|
||||
}
|
||||
}
|
||||
|
||||
String convertSecondsToMinSec(int totalSeconds) {
|
||||
int minutes = totalSeconds ~/ 60;
|
||||
int seconds = totalSeconds % 60;
|
||||
|
||||
String formattedTime = '$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||
|
||||
return formattedTime;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// dataChannel?.close(); // 关闭数据通道
|
||||
// peerConnection?.close(); // 关闭对等连接
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -22,97 +22,98 @@ class RealData extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 设备获取
|
||||
late TextStyle titleFontstyle;
|
||||
late TextStyle valueFontstyle;
|
||||
final deviceType = getDeviceType(context);
|
||||
if (deviceType == DeviceType.mobile) {
|
||||
titleFontstyle = const TextStyle(fontSize: 15);
|
||||
valueFontstyle = const TextStyle(fontSize: 36);
|
||||
} else {
|
||||
titleFontstyle = const TextStyle(fontSize: 22);
|
||||
valueFontstyle = const TextStyle(fontSize: 45);
|
||||
}
|
||||
Widget space = const SizedBox(
|
||||
height: 5,
|
||||
width: 5,
|
||||
);
|
||||
return Expanded(
|
||||
// late TextStyle titleFontstyle;
|
||||
// late TextStyle valueFontstyle;
|
||||
// final deviceType = getDeviceType(context);
|
||||
// if (deviceType == DeviceType.mobile) {
|
||||
// titleFontstyle = const TextStyle(fontSize: 15);
|
||||
// valueFontstyle = const TextStyle(fontSize: 36);
|
||||
// } else {
|
||||
// titleFontstyle = const TextStyle(fontSize: 22);
|
||||
// valueFontstyle = const TextStyle(fontSize: 45);
|
||||
// }
|
||||
// Widget space = const SizedBox(
|
||||
// height: 5,
|
||||
// width: 5,
|
||||
// );
|
||||
return const Expanded(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
children: [
|
||||
RealItem(children: [
|
||||
RealItemChild(
|
||||
// flex: 2,
|
||||
title: "速度(m/min)",
|
||||
titleFontstyle: titleFontstyle,
|
||||
child: Obx(() {
|
||||
return Text(
|
||||
realController.speed.abs() >= 100
|
||||
? realController.speed.toStringAsFixed(1)
|
||||
: realController.speed.toStringAsFixed(2),
|
||||
style: valueFontstyle,
|
||||
);
|
||||
}),
|
||||
),
|
||||
space,
|
||||
RealItemChild(
|
||||
// flex: 3,
|
||||
title: "时间(min:s)",
|
||||
titleFontstyle: titleFontstyle,
|
||||
child: Obx(() => Text(
|
||||
realController.time.value,
|
||||
style: valueFontstyle,
|
||||
))),
|
||||
space,
|
||||
RealItemChild(
|
||||
// flex: 2,
|
||||
title: "深度(m)",
|
||||
titleFontstyle: titleFontstyle,
|
||||
child: Obx(() => Text(
|
||||
realController.depth.toStringAsFixed(2),
|
||||
style: valueFontstyle,
|
||||
))),
|
||||
]),
|
||||
space,
|
||||
RealItem(children: [
|
||||
RealItemChild(
|
||||
// flex: 1,
|
||||
title: "1#瞬时流量(L/min)",
|
||||
titleFontstyle: titleFontstyle,
|
||||
child: Obx(() => Text(
|
||||
realController.subtotalFlow1.toStringAsFixed(2),
|
||||
style: valueFontstyle,
|
||||
))),
|
||||
space,
|
||||
RealItemChild(
|
||||
// flex: 1,
|
||||
title: "2#瞬时流量(L/min)",
|
||||
titleFontstyle: titleFontstyle,
|
||||
child: Obx(() => Text(
|
||||
realController.subtotalFlow2.toStringAsFixed(2),
|
||||
style: valueFontstyle,
|
||||
))),
|
||||
]),
|
||||
space,
|
||||
RealItem(children: [
|
||||
RealItemChild(
|
||||
// flex: 1,
|
||||
title: "1#累计流量(L)",
|
||||
titleFontstyle: titleFontstyle,
|
||||
child: Obx(() => Text(
|
||||
realController.totalFlow1.toStringAsFixed(2),
|
||||
style: valueFontstyle,
|
||||
))),
|
||||
space,
|
||||
RealItemChild(
|
||||
// flex: 1,
|
||||
title: "2#累计流量(L)",
|
||||
titleFontstyle: titleFontstyle,
|
||||
child: Obx(() => Text(
|
||||
realController.totalFlow2.toStringAsFixed(2),
|
||||
style: valueFontstyle,
|
||||
))),
|
||||
])
|
||||
// RealItem(children: [
|
||||
// RealItemChild(
|
||||
// // flex: 2,
|
||||
// title: "速度(m/min)",
|
||||
// titleFontstyle: titleFontstyle,
|
||||
// child: Obx(() {
|
||||
// return Text(
|
||||
// realController.speed.abs() >= 100
|
||||
// ? realController.speed.toStringAsFixed(1)
|
||||
// : realController.speed.toStringAsFixed(2),
|
||||
// style: valueFontstyle,
|
||||
// );
|
||||
// }),
|
||||
// ),
|
||||
// space,
|
||||
// RealItemChild(
|
||||
// // flex: 3,
|
||||
// title: "时间(min:s)",
|
||||
// titleFontstyle: titleFontstyle,
|
||||
// child: Obx(() => Text(
|
||||
// realController.time.value,
|
||||
// style: valueFontstyle,
|
||||
// ))),
|
||||
// space,
|
||||
// RealItemChild(
|
||||
// // flex: 2,
|
||||
// title: "深度(m)",
|
||||
// titleFontstyle: titleFontstyle,
|
||||
// child: Obx(() => Text(
|
||||
// realController.depth.toStringAsFixed(2),
|
||||
// style: valueFontstyle,
|
||||
// ))),
|
||||
// ]),
|
||||
// space,
|
||||
// RealItem(children: [
|
||||
// RealItemChild(
|
||||
// // flex: 1,
|
||||
// title: "1#瞬时流量(L/min)",
|
||||
// titleFontstyle: titleFontstyle,
|
||||
// child: Obx(() => Text(
|
||||
// realController.subtotalFlow1.toStringAsFixed(2),
|
||||
// style: valueFontstyle,
|
||||
// ))),
|
||||
// space,
|
||||
// RealItemChild(
|
||||
// // flex: 1,
|
||||
// title: "2#瞬时流量(L/min)",
|
||||
// titleFontstyle: titleFontstyle,
|
||||
// child: Obx(() => Text(
|
||||
// realController.subtotalFlow2.toStringAsFixed(2),
|
||||
// style: valueFontstyle,
|
||||
// ))),
|
||||
// ]),
|
||||
// space,
|
||||
// RealItem(children: [
|
||||
// RealItemChild(
|
||||
// // flex: 1,
|
||||
// title: "1#累计流量(L)",
|
||||
// titleFontstyle: titleFontstyle,
|
||||
// child: Obx(() => Text(
|
||||
// realController.totalFlow1.toStringAsFixed(2),
|
||||
// style: valueFontstyle,
|
||||
// ))),
|
||||
// space,
|
||||
// RealItemChild(
|
||||
// // flex: 1,
|
||||
// title: "2#累计流量(L)",
|
||||
// titleFontstyle: titleFontstyle,
|
||||
// child: Obx(() => Text(
|
||||
// realController.totalFlow2.toStringAsFixed(2),
|
||||
// style: valueFontstyle,
|
||||
// ))),
|
||||
// ])
|
||||
|
||||
],
|
||||
));
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
//实时数据卡片
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'real_controller.dart';
|
||||
|
||||
@ -74,7 +75,12 @@ class RealDataShow extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
..._buildRealTimeDataList(context),
|
||||
Obx(() {
|
||||
controller1.dataCount;
|
||||
return Column(children: [
|
||||
..._buildRealTimeDataList(context, controller1)
|
||||
]);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -114,9 +120,8 @@ class RealDataShow extends StatelessWidget {
|
||||
// );
|
||||
// }
|
||||
|
||||
List<Widget> _buildRealTimeDataList(BuildContext context) {
|
||||
// 获取实时控制器
|
||||
final RealController realController = Get.find();
|
||||
List<Widget> _buildRealTimeDataList(
|
||||
BuildContext context, RealController controller) {
|
||||
bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
// final orientation = MediaQuery.of(context).orientation;
|
||||
@ -142,7 +147,11 @@ class RealDataShow extends StatelessWidget {
|
||||
// ];
|
||||
// hydraulic_tamping
|
||||
List<DataItem> dataItems = [
|
||||
DataItem("时间(min:s):", () => realController.time.value),
|
||||
DataItem(
|
||||
"时间(min:s):",
|
||||
() => DateFormat('HH:mm:ss').format(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
controller.processdata.value.utc * 1000))),
|
||||
// DataItem("夯击次数:", () => realController.times.value)
|
||||
];
|
||||
// 返回数据项的列表
|
||||
@ -157,11 +166,11 @@ class RealDataShow extends StatelessWidget {
|
||||
fontSize: 13,
|
||||
color: isDarkMode ? Colors.white : Colors.black,
|
||||
)),
|
||||
Obx(() => Text(item.value(),
|
||||
Text(item.value(),
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
color: isDarkMode ? Colors.white : Colors.black,
|
||||
))),
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -511,8 +511,8 @@ class XYChangeController extends GetxController {
|
||||
project.projCode,
|
||||
);
|
||||
if (coordTransmap.isNotEmpty) {
|
||||
var mianBelt =
|
||||
coordTransmap.firstWhere((element) => element['belt'] == 'main');
|
||||
var mianBelt = coordTransmap.firstWhere(
|
||||
(element) => element['belt'] == 'main' || element["name"] == "主带");
|
||||
coorTrans.value = CoorTransModel.fromJson(mianBelt);
|
||||
} else {
|
||||
log("当前项目没有设置中央子午线");
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
@ -5,74 +7,83 @@ import '../../../../real/index.dart';
|
||||
import '../bluetooth_page.dart';
|
||||
|
||||
class SocketSetting {
|
||||
int port = 6000;
|
||||
String ip = "192.168.4.1";
|
||||
int port = 6060;
|
||||
String ip = "192.168.1.206";
|
||||
bool isConnected = false;
|
||||
int times = 0;
|
||||
RawDatagramSocket? socket;
|
||||
Socket? socket;
|
||||
int reconnectCount = 0;
|
||||
Duration _reconnectDelay = const Duration(seconds: 5);
|
||||
connect() async {
|
||||
// tcp连接
|
||||
// try {
|
||||
// socket = await Socket.connect(ip, port);
|
||||
// // 订阅
|
||||
// socket!.add([0xf2]);
|
||||
try {
|
||||
socket = await Socket.connect(ip, port);
|
||||
// 订阅
|
||||
// socket!.add([0xf2]);
|
||||
|
||||
// // 监听服务器回复
|
||||
// socket!.listen(
|
||||
// (Uint8List data) {
|
||||
// realController.onBleData(data);
|
||||
// // log('收到服务器回复:$data');
|
||||
// },
|
||||
// onError: (error) async {
|
||||
// disConnect();
|
||||
// 监听服务器回复
|
||||
socket!.listen(
|
||||
(Uint8List data) {
|
||||
realController.onBleData(data);
|
||||
if (isConnected == false) {
|
||||
isConnected = true;
|
||||
reconnectCount = 0;
|
||||
_reconnectDelay = const Duration(seconds: 5);
|
||||
}
|
||||
// log('收到服务器回复:$data');
|
||||
},
|
||||
onError: (error) async {
|
||||
disConnect();
|
||||
reconnect();
|
||||
log('与服务器的连接发生错误:$error');
|
||||
socket = await Socket.connect(ip, port);
|
||||
return;
|
||||
},
|
||||
);
|
||||
|
||||
// log('与服务器的连接发生错误:$error');
|
||||
// socket = await Socket.connect(ip, port);
|
||||
// return;
|
||||
// },
|
||||
// );
|
||||
// 监听服务器断开连接
|
||||
socket!.done.then((_) {
|
||||
log('与服务器的连接已断开');
|
||||
|
||||
// // 监听服务器断开连接
|
||||
// socket!.done.then((_) {
|
||||
// log('与服务器的连接已断开');
|
||||
|
||||
// disConnect();
|
||||
// });
|
||||
// } catch (e) {
|
||||
// log("----------$e");
|
||||
// disConnect();
|
||||
// }
|
||||
disConnect();
|
||||
reconnect();
|
||||
});
|
||||
} catch (e) {
|
||||
log("----------$e");
|
||||
disConnect();
|
||||
reconnect();
|
||||
}
|
||||
|
||||
// udp连接
|
||||
|
||||
socket = await RawDatagramSocket.bind(
|
||||
InternetAddress.anyIPv4, 6000); //InternetAddress(ip)
|
||||
// socket = await RawDatagramSocket.bind(
|
||||
// InternetAddress.anyIPv4, 6000); //InternetAddress(ip)
|
||||
|
||||
// // 订阅
|
||||
socket!.send([0xf2], InternetAddress(ip), 6000);
|
||||
// socket!.send([0xf2], InternetAddress(ip), 6000);
|
||||
|
||||
socket!.listen((RawSocketEvent e) {
|
||||
times++;
|
||||
if (times == 20) {
|
||||
times = 0;
|
||||
socket!.send([0xf2], InternetAddress(ip), 6000);
|
||||
}
|
||||
Datagram? dg = socket!.receive();
|
||||
if (dg != null) {
|
||||
realController.onBleData(dg.data);
|
||||
// log('从 ${dg.address.address}:${dg.port} 接收:');
|
||||
// 发送响应给客户端
|
||||
// socket.send("已收到".codeUnits, dg.address, dg.port);
|
||||
}
|
||||
});
|
||||
// socket!.listen((RawSocketEvent e) {
|
||||
// times++;
|
||||
// if (times == 20) {
|
||||
// times = 0;
|
||||
// socket!.send([0xf2], InternetAddress(ip), 6000);
|
||||
// }
|
||||
// Datagram? dg = socket!.receive();
|
||||
// if (dg != null) {
|
||||
// realController.onBleData(dg.data);
|
||||
// // log('从 ${dg.address.address}:${dg.port} 接收:');
|
||||
// // 发送响应给客户端
|
||||
// // socket.send("已收到".codeUnits, dg.address, dg.port);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
write(Uint8List data) async {
|
||||
try {
|
||||
// socket ??= await Socket.connect(ip, port);
|
||||
Datagram? dg = socket!.receive();
|
||||
socket!.send(data, dg!.address, dg.port);
|
||||
// socket!.add(data);
|
||||
// Datagram? dg = socket!.receive();
|
||||
// socket!.send(data, dg!.address, dg.port);
|
||||
socket!.add(data);
|
||||
// ignore: empty_catches
|
||||
} catch (e) {}
|
||||
}
|
||||
@ -86,4 +97,21 @@ class SocketSetting {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
void reconnect() {
|
||||
if (socket != null) {
|
||||
socket!.close();
|
||||
socket = null;
|
||||
}
|
||||
|
||||
log('Reconnecting in ${_reconnectDelay.inSeconds} seconds...');
|
||||
Timer(_reconnectDelay, () {
|
||||
reconnectCount++;
|
||||
if (reconnectCount > 20) {
|
||||
_reconnectDelay = const Duration(seconds: 60);
|
||||
}
|
||||
isConnected = false;
|
||||
connect();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
import 'package:cpnav/pages/pass_track/controller.dart';
|
||||
import 'package:cpnav/pages/setting/project/model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import '../../models/user.dart';
|
||||
import '../../service/base.dart';
|
||||
import '../../service/user/loginprefs.dart';
|
||||
@ -26,9 +27,28 @@ class SettingController extends GetxController {
|
||||
// @override
|
||||
// void onInit() async {
|
||||
// super.onInit();
|
||||
|
||||
// }
|
||||
|
||||
Future<void> getDeviceId(context) async {
|
||||
final DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
|
||||
String id;
|
||||
|
||||
// 根据不同平台获取设备信息
|
||||
if (Theme.of(context).platform == TargetPlatform.android) {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
|
||||
id = androidInfo.brand; // 仔细确认你需要的设备编号
|
||||
}
|
||||
// else if (Theme.of(context).platform == TargetPlatform.iOS) {
|
||||
// IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
|
||||
// // id = iosInfo.identifierForVendor; // iOS设备编号
|
||||
// }
|
||||
else {
|
||||
id = 'Unknown platform';
|
||||
}
|
||||
}
|
||||
|
||||
init() async {
|
||||
isInitialized = false;
|
||||
UserModel? getUser = UserController().getUser();
|
||||
@ -55,9 +75,8 @@ class SettingController extends GetxController {
|
||||
currentProject.value = projectList[0];
|
||||
setProject(currentProject.value!.toJson());
|
||||
// services.projCode = currentProject.value!.projCode;
|
||||
await getBindService(services);
|
||||
}
|
||||
|
||||
await getBindService(services);
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
|
@ -197,6 +197,9 @@ class DrawDirection extends CustomPainter {
|
||||
}
|
||||
|
||||
getRect(List<Offset> list) {
|
||||
if (list.isEmpty) {
|
||||
return [Offset.zero, Offset.zero, Offset.zero, Offset.zero];
|
||||
}
|
||||
List<Offset> rect = [];
|
||||
double minx = double.infinity;
|
||||
double maxx = double.negativeInfinity;
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
@ -41,12 +42,11 @@ class BaseService {
|
||||
loginPrefs.clearLogin();
|
||||
return;
|
||||
}
|
||||
if (res['code'] == 1000) {
|
||||
return res;
|
||||
} else {
|
||||
log(res);
|
||||
int code = res['code'];
|
||||
if (code != 1000) {
|
||||
// log(res);
|
||||
String msg = res['message'].toString();
|
||||
if (res['code'] == 404) {
|
||||
if (code == 404) {
|
||||
msg = "当前接口不存在:$msg";
|
||||
}
|
||||
scaffoldMessengerKey.currentState?.showSnackBar(
|
||||
@ -56,9 +56,14 @@ class BaseService {
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
} catch (e) {
|
||||
log(" catch error: ${e.toString()}");
|
||||
if (e is TimeoutException) {
|
||||
return {};
|
||||
}
|
||||
} catch (e) {
|
||||
scaffoldMessengerKey.currentState?.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('发生错误: ${e.toString()}'),
|
||||
@ -66,7 +71,7 @@ class BaseService {
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
log(e.toString());
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@ -102,9 +107,9 @@ class BaseService {
|
||||
|
||||
checkExpire() {
|
||||
int old = loginPrefs.getRefreshExpire();
|
||||
int now = DateTime.now().millisecond;
|
||||
int now = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
if (now - old <= 2000) {
|
||||
if (old - now <= 2000) {
|
||||
//2s
|
||||
refreshToken();
|
||||
}
|
||||
@ -117,22 +122,21 @@ class BaseService {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Uri fullUrl = Uri.parse(
|
||||
"$baseUrl/admin/base/open/refreshToken?refreshToken=$refreshToken");
|
||||
http.Response response = await _client.get(fullUrl).timeout(timeout);
|
||||
var res = json.decode(response.body);
|
||||
Uri fullUrl = Uri.parse(
|
||||
"$baseUrl/admin/base/open/refreshToken?refreshToken=$refreshToken");
|
||||
http.Response response = await _client.get(fullUrl).timeout(timeout);
|
||||
var res = json.decode(response.body);
|
||||
|
||||
if (res['code'] == 1000 && res["data"] != null) {
|
||||
token = res["data"]["token"];
|
||||
loginPrefs.saveExpire(res["data"]["expire"]);
|
||||
loginPrefs.saveToken(token);
|
||||
loginPrefs.saveRefreshToken(res["data"]["refreshToken"]);
|
||||
loginPrefs.saveRefreshExpire(res["data"]["refreshExpire"]);
|
||||
}
|
||||
if (res['code'] == 1000 && res["data"] != null) {
|
||||
token = res["data"]["token"];
|
||||
loginPrefs.saveExpire(res["data"]["expire"]);
|
||||
loginPrefs.saveToken(token);
|
||||
loginPrefs.saveRefreshToken(res["data"]["refreshToken"]);
|
||||
loginPrefs.saveRefreshExpire(res["data"]["refreshExpire"]);
|
||||
}
|
||||
} catch (e) {
|
||||
log("refreshToken error: $e");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,7 +318,7 @@ class GetServices {
|
||||
dateEnd ??= date;
|
||||
Map? res = await service.getClient(
|
||||
"/api/$projType/record/list?org_code=$org_code&proj_code=$projCode&date=$date&dateEnd=$dateEnd"); //&tid=1000
|
||||
if (res != null && res['data'] != null) {
|
||||
if (res != null && res.isNotEmpty && res['data'] != null) {
|
||||
return res['data'];
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit cc9ee2fe1abf30613fe191794e841cf0399f8d58
|
||||
Subproject commit 2832f031e1f01b2a0b1f285bc44d80121ecbddb6
|
40
pubspec.lock
40
pubspec.lock
@ -121,6 +121,22 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.7.10"
|
||||
device_info_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: device_info_plus
|
||||
sha256: f545ffbadee826f26f2e1a0f0cbd667ae9a6011cc0f77c0f8f00a969655e6e95
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "11.1.1"
|
||||
device_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: device_info_plus_platform_interface
|
||||
sha256: "282d3cf731045a2feb66abfe61bbc40870ae50a3ed10a4d3d217556c35c8c2ba"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "7.0.1"
|
||||
dylib:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -153,6 +169,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "7.0.1"
|
||||
fl_chart:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -698,6 +722,22 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.4.1+1"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "5.8.0"
|
||||
win32_registry:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32_registry
|
||||
sha256: "21ec76dfc731550fd3e2ce7a33a9ea90b828fdf19a5c3bcf556fa992cfa99852"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.5"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -63,6 +63,7 @@ dependencies:
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
searchfield: ^1.1.7
|
||||
device_info_plus: ^11.1.1
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user