Bladeren bron

新赛事管理

周睿 1 jaar geleden
bovenliggende
commit
7724308b7d

+ 21 - 0
app_business/lib/generated/base.pbenum.dart

@@ -242,6 +242,27 @@ class GameState extends $pb.ProtobufEnum {
   const GameState._($core.int v, $core.String n) : super(v, n);
 }
 
+class CState extends $pb.ProtobufEnum {
+  static const CState ToUnSend = CState._(0, _omitEnumNames ? '' : 'ToUnSend');
+  static const CState ToUnStart = CState._(1, _omitEnumNames ? '' : 'ToUnStart');
+  static const CState ToStart = CState._(2, _omitEnumNames ? '' : 'ToStart');
+  static const CState ToFinish = CState._(3, _omitEnumNames ? '' : 'ToFinish');
+  static const CState ToOther = CState._(9, _omitEnumNames ? '' : 'ToOther');
+
+  static const $core.List<CState> values = <CState> [
+    ToUnSend,
+    ToUnStart,
+    ToStart,
+    ToFinish,
+    ToOther,
+  ];
+
+  static final $core.Map<$core.int, CState> _byValue = $pb.ProtobufEnum.initByValue(values);
+  static CState? valueOf($core.int value) => _byValue[value];
+
+  const CState._($core.int v, $core.String n) : super(v, n);
+}
+
 class GameHistorySource extends $pb.ProtobufEnum {
   static const GameHistorySource GameHistorySourcAll = GameHistorySource._(0, _omitEnumNames ? '' : 'GameHistorySourcAll');
   static const GameHistorySource GameHistorySourceOrienteer = GameHistorySource._(1, _omitEnumNames ? '' : 'GameHistorySourceOrienteer');

+ 17 - 0
app_business/lib/generated/base.pbjson.dart

@@ -198,6 +198,23 @@ final $typed_data.Uint8List gameStateDescriptor = $convert.base64Decode(
     'CglHYW1lU3RhdGUSEAoMQWxsR2FtZVN0YXRlEAASEwoPTm9ybWFsR2FtZVN0YXRlEAESFQoRYW'
     'Jub3JtYWxHYW1lU3RhdGUQAg==');
 
+@$core.Deprecated('Use cStateDescriptor instead')
+const CState$json = {
+  '1': 'CState',
+  '2': [
+    {'1': 'ToUnSend', '2': 0},
+    {'1': 'ToUnStart', '2': 1},
+    {'1': 'ToStart', '2': 2},
+    {'1': 'ToFinish', '2': 3},
+    {'1': 'ToOther', '2': 9},
+  ],
+};
+
+/// Descriptor for `CState`. Decode as a `google.protobuf.EnumDescriptorProto`.
+final $typed_data.Uint8List cStateDescriptor = $convert.base64Decode(
+    'CgZDU3RhdGUSDAoIVG9VblNlbmQQABINCglUb1VuU3RhcnQQARILCgdUb1N0YXJ0EAISDAoIVG'
+    '9GaW5pc2gQAxILCgdUb090aGVyEAk=');
+
 @$core.Deprecated('Use gameHistorySourceDescriptor instead')
 const GameHistorySource$json = {
   '1': 'GameHistorySource',

+ 39 - 36
app_business/lib/generated/track_offical.pb.dart

@@ -15,6 +15,7 @@ import 'package:fixnum/fixnum.dart' as $fixnum;
 import 'package:protobuf/protobuf.dart' as $pb;
 
 import 'base.pb.dart' as $0;
+import 'base.pbenum.dart' as $0;
 import 'google/protobuf/timestamp.pb.dart' as $2;
 
 class ToCourseChackMatchRequest extends $pb.GeneratedMessage {
@@ -546,11 +547,11 @@ class ToChackInsInfo extends $pb.GeneratedMessage {
     $core.String? nickname,
     $core.String? phone,
     $core.String? chackInsTime,
+    $core.bool? isAllowDel,
     $core.String? cName,
     $core.int? cId,
-    $core.int? mState,
-    $core.bool? isStart,
-    $core.int? punchCpNum,
+    $core.String? hrSn,
+    $0.CState? cState,
   }) {
     final $result = create();
     if (mciId != null) {
@@ -568,20 +569,20 @@ class ToChackInsInfo extends $pb.GeneratedMessage {
     if (chackInsTime != null) {
       $result.chackInsTime = chackInsTime;
     }
+    if (isAllowDel != null) {
+      $result.isAllowDel = isAllowDel;
+    }
     if (cName != null) {
       $result.cName = cName;
     }
     if (cId != null) {
       $result.cId = cId;
     }
-    if (mState != null) {
-      $result.mState = mState;
-    }
-    if (isStart != null) {
-      $result.isStart = isStart;
+    if (hrSn != null) {
+      $result.hrSn = hrSn;
     }
-    if (punchCpNum != null) {
-      $result.punchCpNum = punchCpNum;
+    if (cState != null) {
+      $result.cState = cState;
     }
     return $result;
   }
@@ -595,11 +596,11 @@ class ToChackInsInfo extends $pb.GeneratedMessage {
     ..aOS(3, _omitFieldNames ? '' : 'nickname')
     ..aOS(4, _omitFieldNames ? '' : 'phone')
     ..aOS(5, _omitFieldNames ? '' : 'chackInsTime', protoName: 'chackInsTime')
-    ..aOS(6, _omitFieldNames ? '' : 'cName', protoName: 'cName')
-    ..a<$core.int>(7, _omitFieldNames ? '' : 'cId', $pb.PbFieldType.O3, protoName: 'cId')
-    ..a<$core.int>(8, _omitFieldNames ? '' : 'mState', $pb.PbFieldType.O3, protoName: 'mState')
-    ..aOB(9, _omitFieldNames ? '' : 'isStart', protoName: 'isStart')
-    ..a<$core.int>(10, _omitFieldNames ? '' : 'punchCpNum', $pb.PbFieldType.O3, protoName: 'punchCpNum')
+    ..aOB(6, _omitFieldNames ? '' : 'isAllowDel', protoName: 'isAllowDel')
+    ..aOS(7, _omitFieldNames ? '' : 'cName', protoName: 'cName')
+    ..a<$core.int>(8, _omitFieldNames ? '' : 'cId', $pb.PbFieldType.O3, protoName: 'cId')
+    ..aOS(9, _omitFieldNames ? '' : 'hrSn', protoName: 'hrSn')
+    ..e<$0.CState>(10, _omitFieldNames ? '' : 'cState', $pb.PbFieldType.OE, protoName: 'cState', defaultOrMaker: $0.CState.ToUnSend, valueOf: $0.CState.valueOf, enumValues: $0.CState.values)
     ..hasRequiredFields = false
   ;
 
@@ -669,51 +670,53 @@ class ToChackInsInfo extends $pb.GeneratedMessage {
   @$pb.TagNumber(5)
   void clearChackInsTime() => clearField(5);
 
-  /// bool    isAllowDel = 6; //是否允许删除,如果否删除按钮是不可用
   @$pb.TagNumber(6)
-  $core.String get cName => $_getSZ(5);
+  $core.bool get isAllowDel => $_getBF(5);
   @$pb.TagNumber(6)
-  set cName($core.String v) { $_setString(5, v); }
+  set isAllowDel($core.bool v) { $_setBool(5, v); }
   @$pb.TagNumber(6)
-  $core.bool hasCName() => $_has(5);
+  $core.bool hasIsAllowDel() => $_has(5);
   @$pb.TagNumber(6)
-  void clearCName() => clearField(6);
+  void clearIsAllowDel() => clearField(6);
 
   @$pb.TagNumber(7)
-  $core.int get cId => $_getIZ(6);
+  $core.String get cName => $_getSZ(6);
   @$pb.TagNumber(7)
-  set cId($core.int v) { $_setSignedInt32(6, v); }
+  set cName($core.String v) { $_setString(6, v); }
   @$pb.TagNumber(7)
-  $core.bool hasCId() => $_has(6);
+  $core.bool hasCName() => $_has(6);
   @$pb.TagNumber(7)
-  void clearCId() => clearField(7);
+  void clearCName() => clearField(7);
 
   @$pb.TagNumber(8)
-  $core.int get mState => $_getIZ(7);
+  $core.int get cId => $_getIZ(7);
   @$pb.TagNumber(8)
-  set mState($core.int v) { $_setSignedInt32(7, v); }
+  set cId($core.int v) { $_setSignedInt32(7, v); }
   @$pb.TagNumber(8)
-  $core.bool hasMState() => $_has(7);
+  $core.bool hasCId() => $_has(7);
   @$pb.TagNumber(8)
-  void clearMState() => clearField(8);
+  void clearCId() => clearField(8);
 
+  /// int32 mState =8;//用户状态(不是场控端发送状态):0:等待出发 1: 参加比赛,没打第一点    2:比赛进行中      3:完成比赛      4:超时完成比赛  5:未完成-已过强制关门时间,系统强制退赛  6:用户主动退赛
+  /// bool  isStart  =9;//是否出发
+  /// int32  punchCpNum =10;//打开始点次数
   @$pb.TagNumber(9)
-  $core.bool get isStart => $_getBF(8);
+  $core.String get hrSn => $_getSZ(8);
   @$pb.TagNumber(9)
-  set isStart($core.bool v) { $_setBool(8, v); }
+  set hrSn($core.String v) { $_setString(8, v); }
   @$pb.TagNumber(9)
-  $core.bool hasIsStart() => $_has(8);
+  $core.bool hasHrSn() => $_has(8);
   @$pb.TagNumber(9)
-  void clearIsStart() => clearField(9);
+  void clearHrSn() => clearField(9);
 
   @$pb.TagNumber(10)
-  $core.int get punchCpNum => $_getIZ(9);
+  $0.CState get cState => $_getN(9);
   @$pb.TagNumber(10)
-  set punchCpNum($core.int v) { $_setSignedInt32(9, v); }
+  set cState($0.CState v) { setField(10, v); }
   @$pb.TagNumber(10)
-  $core.bool hasPunchCpNum() => $_has(9);
+  $core.bool hasCState() => $_has(9);
   @$pb.TagNumber(10)
-  void clearPunchCpNum() => clearField(10);
+  void clearCState() => clearField(10);
 }
 
 class ToMatchRegusterAddRequest extends $pb.GeneratedMessage {

+ 8 - 8
app_business/lib/generated/track_offical.pbjson.dart

@@ -132,11 +132,11 @@ const ToChackInsInfo$json = {
     {'1': 'nickname', '3': 3, '4': 1, '5': 9, '10': 'nickname'},
     {'1': 'phone', '3': 4, '4': 1, '5': 9, '10': 'phone'},
     {'1': 'chackInsTime', '3': 5, '4': 1, '5': 9, '10': 'chackInsTime'},
-    {'1': 'cName', '3': 6, '4': 1, '5': 9, '10': 'cName'},
-    {'1': 'cId', '3': 7, '4': 1, '5': 5, '10': 'cId'},
-    {'1': 'mState', '3': 8, '4': 1, '5': 5, '10': 'mState'},
-    {'1': 'isStart', '3': 9, '4': 1, '5': 8, '10': 'isStart'},
-    {'1': 'punchCpNum', '3': 10, '4': 1, '5': 5, '10': 'punchCpNum'},
+    {'1': 'isAllowDel', '3': 6, '4': 1, '5': 8, '10': 'isAllowDel'},
+    {'1': 'cName', '3': 7, '4': 1, '5': 9, '10': 'cName'},
+    {'1': 'cId', '3': 8, '4': 1, '5': 5, '10': 'cId'},
+    {'1': 'hrSn', '3': 9, '4': 1, '5': 9, '10': 'hrSn'},
+    {'1': 'cState', '3': 10, '4': 1, '5': 14, '6': '.base.v1.CState', '10': 'cState'},
   ],
 };
 
@@ -144,9 +144,9 @@ const ToChackInsInfo$json = {
 final $typed_data.Uint8List toChackInsInfoDescriptor = $convert.base64Decode(
     'Cg5Ub0NoYWNrSW5zSW5mbxIUCgVtY2lJZBgBIAEoBVIFbWNpSWQSEAoDb0lkGAIgASgFUgNvSW'
     'QSGgoIbmlja25hbWUYAyABKAlSCG5pY2tuYW1lEhQKBXBob25lGAQgASgJUgVwaG9uZRIiCgxj'
-    'aGFja0luc1RpbWUYBSABKAlSDGNoYWNrSW5zVGltZRIUCgVjTmFtZRgGIAEoCVIFY05hbWUSEA'
-    'oDY0lkGAcgASgFUgNjSWQSFgoGbVN0YXRlGAggASgFUgZtU3RhdGUSGAoHaXNTdGFydBgJIAEo'
-    'CFIHaXNTdGFydBIeCgpwdW5jaENwTnVtGAogASgFUgpwdW5jaENwTnVt');
+    'aGFja0luc1RpbWUYBSABKAlSDGNoYWNrSW5zVGltZRIeCgppc0FsbG93RGVsGAYgASgIUgppc0'
+    'FsbG93RGVsEhQKBWNOYW1lGAcgASgJUgVjTmFtZRIQCgNjSWQYCCABKAVSA2NJZBISCgRoclNu'
+    'GAkgASgJUgRoclNuEicKBmNTdGF0ZRgKIAEoDjIPLmJhc2UudjEuQ1N0YXRlUgZjU3RhdGU=');
 
 @$core.Deprecated('Use toMatchRegusterAddRequestDescriptor instead')
 const ToMatchRegusterAddRequest$json = {

+ 6 - 0
app_business/lib/service/api.dart

@@ -224,6 +224,12 @@ class ApiService extends IService {
       ..isQueryPwd = event.password != null
       ..queryPasswd = event.password ?? '');
   }
+
+  Future<void> eventUserAllocRoute(int checkId, int routeId) async {
+    await stub.toCourseChackMatch(pb.ToCourseChackMatchRequest()
+      ..id = checkId
+      ..cId = routeId);
+  }
 }
 
 class EventRegisterInfo {

+ 48 - 23
app_business/lib/view/home/event_manage/event_manage.dart

@@ -87,10 +87,10 @@ class EventManage extends GetView<EventManagerController> {
           width: 32),
       const LineChartTitle(title: Text('序号'), width: 42),
       const LineChartTitle(title: Text('用户名'), width: 70),
-      const LineChartTitle(title: Text('手机号'), flex: 1),
+      const LineChartTitle(title: Text('手机号'), width: 98),
       const LineChartTitle(title: Text('签到时间'), width: 78),
       const LineChartTitle(title: Text('手环'), width: 67),
-      const LineChartTitle(title: Text('路线'), width: 90),
+      const LineChartTitle(title: Text('路线'), flex: 1),
       const LineChartTitle(title: Text('状态'), width: 67),
       const LineChartTitle(title: Text('操作'), width: 67),
     ];
@@ -102,6 +102,14 @@ class EventManage extends GetView<EventManagerController> {
       var stateStr = '';
       var stateColor = Colors.white;
 
+      var optStr = '删除';
+      var optColor = Colors.red;
+      VoidCallback? opt;
+
+      if (one.isAllowDel) {
+        opt = () => controller.deleteSignIn(one);
+      }
+
       switch (one.state) {
         case UserState.idle:
           stateStr = '未分发';
@@ -110,15 +118,26 @@ class EventManage extends GetView<EventManagerController> {
         case UserState.isStart:
           stateStr = '已开始';
           stateColor = Colors.green;
+          optStr = '结束';
+          opt = () => controller.userStopGame(one);
           break;
         case UserState.isFinish:
           stateStr = '已结束';
           stateColor = Colors.orange;
+          optStr = '重赛';
+          optColor = Colors.orange;
+          opt = () => controller.userRestartGame(one);
           break;
         default:
       }
 
-      var optStr = '';
+      var snStr = '--';
+      const n = 4;
+      if (one.bandSN.length > n) {
+        snStr = '-${one.bandSN.substring(one.bandSN.length - n)}';
+      } else if (one.bandSN.isNotEmpty) {
+        snStr = one.bandSN;
+      }
 
       return LineChartElem([
         Checkbox(
@@ -136,40 +155,46 @@ class EventManage extends GetView<EventManagerController> {
         Text(one.name),
         Text(one.phone),
         Text(one.checkTime),
-        Text(one.bandSN),
+        Text(snStr),
         one.state == UserState.idle
-            ? SizedBox(
-                height: 22.78,
-                width: 51.2,
-                child: SmallButton(
-                    color: Colors.blue,
-                    onPressed: routeSelect,
-                    child: const Text('分发')))
-            : Text(one.routeName),
+            ? button(
+                color: Colors.blue,
+                onPressed: () => routeSelect(one),
+                text: '分发')
+            : Text(one.routeName, maxLines: 1),
         one.state == UserState.hasRoute
-            ? SmallButton(child: const Text('开始'), onPressed: () {})
+            ? button(
+                color: Colors.green,
+                onPressed: () => controller.userStart(one),
+                text: '开始')
             : Text(stateStr, style: TextStyle(color: stateColor)),
         SizedBox(
             width: 51.2,
             height: 22.76,
             child: SmallButton(
-              color: const Color(0xffff0000),
+              color: optColor,
               isOutline: true,
-              onPressed: () {
-                controller.deleteSignIn(one);
-              },
-              child: const Text('删除'),
+              onPressed: opt,
+              child: Text(optStr),
             ))
       ]);
     });
   }
 
-  Future<void> routeSelect() async {
-    final list = await controller.routeList();
+  Widget button({Color? color, VoidCallback? onPressed, required String text}) {
+    return SizedBox(
+        height: 22.78,
+        width: 51.2,
+        child: SmallButton(
+            color: Colors.blue, onPressed: onPressed, child: Text(text)));
+  }
+
+  Future<void> routeSelect(UserInManage user) async {
+    final list = await controller.routeList(user);
     await Get.dialog(_RouteSelectDialog(list: list));
-    final id = controller.tmpSelectRoute?.id;
-    if (id != null) {
-      await controller.routeSelect([id]);
+    final route = controller.tmpSelectRoute;
+    if (route != null) {
+      await controller.routeAlloc(user, route);
     }
   }
 }

+ 29 - 6
app_business/lib/view/home/event_manage/event_manage_controller.dart

@@ -1,5 +1,6 @@
 import 'dart:collection';
 
+import 'package:app_business/generated/base.pbenum.dart';
 import 'package:app_business/service/api.dart';
 import 'package:track_common/service/map_watch.dart';
 import 'package:track_common/track_common.dart';
@@ -101,7 +102,14 @@ class EventManagerController extends GetxController {
                   ..name = u.nickname
                   ..phone = u.phone
                   ..routeName = u.cName
-                  ..isAllowDel = u.punchCpNum == 0
+                  ..bandSN = u.hrSn
+                  ..isAllowDel = u.isAllowDel
+                  ..state = switch (u.cState) {
+                    CState.ToUnSend => UserState.idle,
+                    CState.ToUnStart => UserState.hasRoute,
+                    CState.ToStart => UserState.isStart,
+                    _ => UserState.isFinish,
+                  }
                   ..checkTime = u.chackInsTime)
                 .toList())
           .toList();
@@ -127,21 +135,26 @@ class EventManagerController extends GetxController {
     return _api.eventEdit(id, event);
   }
 
-  Future<Iterable<RouteInfo>> routeList() async {
+  Future<Iterable<RouteInfo>> routeList(UserInManage user) async {
     final r = await _api.stub
-        .toCourseSelectList(IdRequest()..id = Int64(selected!.id));
+        .toCourseSelectList(IdRequest()..id = Int64(user.checkId));
     return r.list.map((e) => RouteInfo()
       ..id = e.cId
       ..name = e.cName);
   }
 
-  Future<void> routeSelect(Iterable<int> idList) async {
-    await _api.stub.allCourseChackMatch(IdArrRequest()..idArr.addAll(idList));
+  Future<void> routeAlloc(UserInManage user, RouteInfo route) async {
+    debug('选择路线 ${route.name}');
+    await _api.eventUserAllocRoute(user.checkId, route.id);
+  }
+
+  Future<void> userStart(UserInManage user) async {
+    await _api.stub.matchChackInsStart(IdRequest()..id = Int64(user.checkId));
   }
 
   Future<void> routeSelectAll() async {
     final idList = selectedUser.value.toList();
-    await routeSelect(idList);
+    // await routeSelect(idList);
   }
 
   Future<void> deleteSignIn(UserInManage user) async {
@@ -160,4 +173,14 @@ class EventManagerController extends GetxController {
           Get.back();
         }));
   }
+
+  Future<void> userStopGame(UserInManage user) async {
+    await _api.stub
+        .matchChackInsForceFinish(IdRequest()..id = Int64(user.checkId));
+  }
+
+  Future<void> userRestartGame(UserInManage user) async {
+    await _api.stub
+        .matchChackInsForceResume(IdRequest()..id = Int64(user.checkId));
+  }
 }

+ 1 - 1
protos/app_api

@@ -1 +1 @@
-Subproject commit f70b683044fbe646e56decb55e0854d0a93cc8e3
+Subproject commit f798ccba34d38e4bb8059ebcf762b9a6d673b6a7