添加巡更管理定位sdk

hmxc
张萌 4 years ago
parent 4d1dd0686b
commit 9535d7664c

@ -182,6 +182,10 @@ class _Manage {
/// ///
String get borrowinsertArticleDetail => '/user/borrow/insertArticleDetail'; String get borrowinsertArticleDetail => '/user/borrow/insertArticleDetail';
///n
String get uploadLocation => '/user/inspection/uploadLocation';
} }
class _Upload { class _Upload {

@ -1,22 +1,29 @@
// Flutter imports: // Flutter imports:
import 'dart:async';
import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/manager/inspection/inspection_detail_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_detail_model.dart';
import 'package:aku_community_manager/models/manager/inspection/inspection_point_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_point_model.dart';
import 'package:aku_community_manager/models/manager/inspection/inspection_qrcode_model.dart'; import 'package:aku_community_manager/models/manager/inspection/inspection_qrcode_model.dart';
import 'package:aku_community_manager/provider/app_provider.dart';
import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_point_detail_page.dart'; import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_point_detail_page.dart';
import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_point_input_page.dart'; import 'package:aku_community_manager/ui/manage_pages/inspection_manage/inspection_point_input_page.dart';
import 'package:aku_community_manager/ui/manage_pages/inspection_manage/qr_code_parase.dart'; import 'package:aku_community_manager/ui/manage_pages/inspection_manage/qr_code_parase.dart';
import 'package:aku_community_manager/ui/manage_pages/inspection_manage/qr_scanner_page.dart'; import 'package:aku_community_manager/ui/manage_pages/inspection_manage/qr_scanner_page.dart';
import 'package:aku_community_manager/ui/sub_pages/manage_func.dart'; import 'package:aku_community_manager/ui/sub_pages/manage_func.dart';
import 'package:aku_community_manager/ui/tool_pages/warning/warning_page.dart';
import 'package:aku_community_manager/utils/network/base_model.dart'; import 'package:aku_community_manager/utils/network/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:aku_ui/aku_ui.dart'; import 'package:aku_ui/aku_ui.dart';
import 'package:amap_flutter_base/amap_flutter_base.dart';
import 'package:amap_flutter_map/amap_flutter_map.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart'; import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart'; import 'package:qr_code_scanner/qr_code_scanner.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community_manager/utils/extension/list_extension.dart'; import 'package:aku_community_manager/utils/extension/list_extension.dart';
@ -60,19 +67,29 @@ class _InspectionManageDetailsPageState
} }
} }
AMapController _aMapController;
Timer _timer;
bool _canUploadLocation = false;
InspectionDetailModel _detailModel; InspectionDetailModel _detailModel;
List<InspectionPointModel> _pointModels; List<InspectionPointModel> _pointModels;
bool _onload = true; bool _onload = true;
EasyRefreshController _refreshController; EasyRefreshController _refreshController;
bool _exit = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_refreshController = EasyRefreshController(); _refreshController = EasyRefreshController();
PermissonUtil.getLocationPermisson();
} }
@override @override
void dispose() { void dispose() {
_refreshController?.dispose(); _refreshController?.dispose();
_aMapController?.disponse();
_timer?.cancel();
_timer = null;
super.dispose(); super.dispose();
} }
@ -82,98 +99,133 @@ class _InspectionManageDetailsPageState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AkuScaffold( return WillPopScope(
title: '巡检详情', onWillPop: () async {
body: EasyRefresh( await showCupertinoDialog(
controller: _refreshController, context: context,
firstRefresh: true, builder: (context) {
header: return exitDialog();
MaterialHeader(valueColor: AlwaysStoppedAnimation(kPrimaryColor)), });
onRefresh: () async { return _exit;
_detailModel = },
await ManageFunc.getInspectionDetail(widget.executeId); child: AkuScaffold(
_pointModels = await (_detailModel.status == 1 title: '巡检详情',
? ManageFunc.getInspectionPointByPlanId( body: EasyRefresh(
planId: _detailModel.inspectionPlanId) controller: _refreshController,
: ManageFunc.getInspectionPointByExcuteId( firstRefresh: true,
excuteId: widget.executeId)); header: MaterialHeader(
_onload = false; valueColor: AlwaysStoppedAnimation(kPrimaryColor)),
setState(() {}); onRefresh: () async {
}, _detailModel =
child: _onload await ManageFunc.getInspectionDetail(widget.executeId);
? _emptyWidget() _pointModels = await (_detailModel.status == 1
: Column( ? ManageFunc.getInspectionPointByPlanId(
children: [ planId: _detailModel.inspectionPlanId)
_inspectionHeadCard(), : ManageFunc.getInspectionPointByExcuteId(
16.w.heightBox, excuteId: widget.executeId));
Container( _onload = false;
padding: EdgeInsets.symmetric( setState(() {});
horizontal: 32.w, vertical: 24.w), },
decoration: BoxDecoration(color: Color(0xFFFFFFFF)), child: _onload
width: double.infinity, ? _emptyWidget()
constraints: BoxConstraints( : Column(
minHeight: 85.w, children: [
), _inspectionHeadCard(),
child: Column( 16.w.heightBox,
crossAxisAlignment: CrossAxisAlignment.start, Container(
children: <Widget>[ padding: EdgeInsets.symmetric(
'巡检站点'.text.black.size(32.sp).bold.make(), horizontal: 32.w, vertical: 24.w),
..._pointModels decoration: BoxDecoration(color: Color(0xFFFFFFFF)),
.map((e) => _buildInspectionTile( width: double.infinity,
e, _pointModels.indexOf(e))) constraints: BoxConstraints(
.toList() minHeight: 85.w,
].sepWidget(separate: 16.w.heightBox), ),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
'巡检站点'.text.black.size(32.sp).bold.make(),
..._pointModels
.map((e) => _buildInspectionTile(
e, _pointModels.indexOf(e)))
.toList(),
].sepWidget(separate: 16.w.heightBox),
),
), ),
) 16.w.heightBox,
], _locationWidget(),
), ],
), ),
bottom: (!_onload) && ),
(_detailModel.status != 2) && bottom: (!_onload) &&
(_detailModel.status != 4) (_detailModel.status != 2) &&
? AkuButton( (_detailModel.status != 4)
onPressed: _detailModel.status == 1 ? AkuButton(
? () async { onPressed: _detailModel.status == 1
BaseModel _baseModel = await NetUtil().get( ? () async {
API.manage.inspectionStart, BaseModel _baseModel = await NetUtil().get(
params: {"executeId": widget.executeId}); API.manage.inspectionStart,
if (_baseModel.status) { params: {"executeId": widget.executeId});
BotToast.showText(text: _baseModel.message); if (_baseModel.status) {
_refreshController.callRefresh(); BotToast.showText(text: _baseModel.message);
} else { _refreshController.callRefresh();
BotToast.showText(text: _baseModel.message); _startTimer(5000);
} } else {
} BotToast.showText(text: _baseModel.message);
: () async { }
Barcode result = await Get.to(() => QrScannerPage());
BaseModel baseModel =
await ManageFunc.getInspectionFindCheckDetailByQr(
_detailModel.id,
QRCodeParase.getExecutePointId(result.code));
if (baseModel.status) {
Get.to(() => InspectionPointInputPage(
inspectionName: _detailModel.name,
qrModel: InspectionQRCodeModel.fromJson(
baseModel.data),
));
} else {
showCupertinoDialog(
context: context,
builder: (context) {
return _errorDialog();
});
} }
}, : () async {
padding: EdgeInsets.symmetric(vertical: 26.w), Barcode result = await Get.to(() => QrScannerPage());
color: kPrimaryColor, BaseModel baseModel =
child: (_detailModel.status == 1 ? '开始巡检' : '立即扫码') await ManageFunc.getInspectionFindCheckDetailByQr(
.text _detailModel.id,
.black QRCodeParase.getExecutePointId(result.code));
.bold if (baseModel.status) {
.size(32.sp) Get.to(() => InspectionPointInputPage(
.make(), inspectionName: _detailModel.name,
).pOnly(bottom: MediaQuery.of(context).padding.bottom) qrModel: InspectionQRCodeModel.fromJson(
: SizedBox()); baseModel.data),
));
} else {
showCupertinoDialog(
context: context,
builder: (context) {
return _errorDialog();
});
}
},
padding: EdgeInsets.symmetric(vertical: 26.w),
color: kPrimaryColor,
child: (_detailModel.status == 1 ? '开始巡检' : '立即扫码')
.text
.black
.bold
.size(32.sp)
.make(),
).pOnly(bottom: MediaQuery.of(context).padding.bottom)
: SizedBox()),
);
}
Widget exitDialog() {
return CupertinoAlertDialog(
content:
'退出此页面将失去定位信息,确认退出吗?'.text.size(30.sp).black.bold.isIntrinsic.make(),
actions: [
CupertinoDialogAction(
child: '确认'.text.size(28.sp).black.isIntrinsic.bold.make(),
onPressed: () {
_exit = true;
Get.back();
},
),
CupertinoDialogAction(
child: '取消'.text.size(28.sp).black.light.isIntrinsic.bold.make(),
onPressed: () {
Get.back();
},
)
],
);
} }
Widget _errorDialog() { Widget _errorDialog() {
@ -207,6 +259,17 @@ class _InspectionManageDetailsPageState
); );
} }
_startTimer(int milliseconds) {
_timer = Timer.periodic(Duration(milliseconds: milliseconds), (event) {
_canUploadLocation = true;
});
}
_stopTimer() {
_timer?.cancel();
_timer = null;
}
Widget _inspectionHeadCard() { Widget _inspectionHeadCard() {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -419,117 +482,66 @@ class _InspectionManageDetailsPageState
)); ));
}); });
} }
}
// Widget _inspectionPersons(){
// return Container(
// width: double.infinity,
// color: Color(0xFFFFFFFF),
// margin: EdgeInsets.only(top: 16.w),
// padding: EdgeInsets.only(
// top: 24.w, left: 32.w, right: 86.w, bottom: 40.w),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// '巡检人员',
// style: TextStyle(
// color: AppStyle.primaryTextColor,
// fontSize: 32.sp,
// fontWeight: FontWeight.bold),
// ),
// AkuBox.h(16),
// GridView(
// shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 3,
// childAspectRatio: 250 / 40,
// mainAxisSpacing: 16.w),
// children: widget.cardModel.persons
// .map((e) => _person(widget.cardModel.persons.indexOf(e)))
// .toList(),
// ),
// ],
// ),
// ),
// AkuBox.h(16),
// Container(
// color: Color(0xFFFFFFFF),
// padding: EdgeInsets.only(top: 24.w, left: 32.w, right: 32.w),
// width: double.infinity,
// child:
// Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
// Text('巡检站点',
// style: TextStyle(
// color: AppStyle.primaryTextColor,
// fontSize: 32.sp,
// fontWeight: FontWeight.bold)),
// AkuBox.h(16),
// Wrap(
// runSpacing: 16.w,
// children: widget.cardModel.stations
// .map((e) => _station(widget.cardModel.stations.indexOf(e)))
// .toList(),
// ),
// AkuBox.h(24),
// Image.asset(
// R.ASSETS_INSPECTION_INSPECTION_STATION_PNG,
// width: 686.w,
// height: 343.w,
// ),
// ]),
// );
// Widget _station(index) { Widget _locationWidget() {
// return Row( AppProvider appProvider = Provider.of<AppProvider>(context, listen: false);
// mainAxisSize: MainAxisSize.min, return Column(
// children: [ crossAxisAlignment: CrossAxisAlignment.start,
// Container( children: [
// padding: '巡检地图'.text.color(Color(0xFF333333)).size(32.sp).bold.make(),
// EdgeInsets.only(top: 16.w, left: 24.w, bottom: 15.w, right: 24.w), 16.w.heightBox,
// color: Color(0xFFF9F9F9), SizedBox(
// height: 64.w, width: double.infinity,
// alignment: Alignment.center, height: 343.w,
// child: Row( child: AMapWidget(
// mainAxisSize: MainAxisSize.min, rotateGesturesEnabled: false,
// children: [ scaleEnabled: false,
// Text( scrollGesturesEnabled: false,
// widget.cardModel.stations[index], tiltGesturesEnabled: false,
// style: TextStyle( zoomGesturesEnabled: false,
// color: AppStyle.primaryTextColor, fontSize: 24.sp), onMapCreated: (controller) {
// ), _aMapController = controller;
// ], LatLng _target = LatLng(appProvider.location['latitude'],
// ), appProvider.location['longitude']);
// ), _aMapController.moveCamera(CameraUpdate.newCameraPosition(
// AkuBox.w(8), CameraPosition(target: _target, zoom: 19)));
// (widget.cardModel.stations.length - 1) != index },
// ? Container( myLocationStyleOptions: MyLocationStyleOptions(true,
// width: 56.w, circleFillColor: Colors.yellow.withOpacity(0.1),
// height: 3.w, circleStrokeColor: Colors.transparent,
// color: Color(0xFFE8E8E8), icon: BitmapDescriptor.defaultMarkerWithHue(210)),
// ) onLocationChanged: (argument) async {
// : SizedBox(), _aMapController.moveCamera(CameraUpdate.newCameraPosition(
// ], CameraPosition(target: argument.latLng,zoom: 19)));
// ); if (_canUploadLocation) {
// } BaseModel baseModel = await _uploadLocation(widget.executeId,
argument.latLng.longitude, argument.latLng.latitude);
if (!baseModel.status) {
BotToast.showText(text: baseModel.message);
} else {
_canUploadLocation = false;
}
}
},
),
),
],
)
.box
.width(double.infinity)
.color(Colors.white)
.padding(EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w))
.make();
}
// Widget _person(index) { Future _uploadLocation(
// return Container( int executeId, double longitude, double latitude) async {
// height: 40.w, BaseModel baseModel = await NetUtil().post(API.manage.uploadLocation,
// child: Row(mainAxisSize: MainAxisSize.min, children: [ params: {
// Image.asset( "executeId": executeId,
// R.ASSETS_MESSAGE_IC_PEOPLE_PNG, "longitude": longitude,
// width: 40.w, "latitude": latitude
// height: 40.w, });
// ), return baseModel;
// AkuBox.w(8), }
// Text( }
// widget.cardModel.persons[index],
// style: TextStyle(
// color: AppStyle.primaryTextColor,
// fontSize: 28.sp,
// ),
// ),
// ]),
// );
// }

Loading…
Cancel
Save