|
@@ -22,8 +22,10 @@ var (
|
|
|
cacheMutex sync.Mutex
|
|
|
cacheTeamName = make(map[string]time.Time)
|
|
|
heartBeatTimeThreshold = 5 * time.Second // 心跳时间
|
|
|
- InitialPositionX = 0.00 // 需要比赛确认起点
|
|
|
- InitialPositionY = 0.00 // 需要比赛确认起点
|
|
|
+ InitialPositionX = 0.00 // todo 需要比赛确认起点
|
|
|
+ InitialPositionY = 0.00 // todo 需要比赛确认起点
|
|
|
+ // todo 比赛阶段
|
|
|
+ trialBegin = time.Date(2006, time.January, 2, 15, 4, 5, 0, time.Local)
|
|
|
)
|
|
|
|
|
|
// 考试心跳
|
|
@@ -56,8 +58,33 @@ func Tick(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
} else if !util.ContainsKey(cacheTeamName, teamName) && math.Abs(positionX-InitialPositionX) < 5.00 && math.Abs(positionY-InitialPositionY) < 5.00 { // 不在起点(开始)
|
|
|
- // todo 查询队伍上一个记录,修改结束时间为初始时间,并添加心跳到缓存
|
|
|
-
|
|
|
+ // 车辆不是在起点启动的自动驾驶模式
|
|
|
+ selectSql, err := util.ReadFile(c_db.SqlFilesMap["exam-select-latest-by-team_name.sql"])
|
|
|
+ if err != nil {
|
|
|
+ c_log.GlobalLogger.Error("读取sql文件报错:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 可以传参数
|
|
|
+ var result []webServerEntity.ExamPo
|
|
|
+ if err = c_db.MysqlDb.Select(&result, selectSql, teamName); err != nil {
|
|
|
+ c_log.GlobalLogger.Error("数据库查询报错:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if len(result) == 1 {
|
|
|
+ c_log.GlobalLogger.Info("上一条数据记录为:", result[0])
|
|
|
+ }
|
|
|
+ // 添加队伍名到缓存中
|
|
|
+ cacheTeamName[teamName] = time.Now()
|
|
|
+ // 更新记录结束时间为默认时间
|
|
|
+ sqlTemplate, _ := util.ReadFile(c_db.SqlFilesMap["exam-update-end_time-by-team_name.sql"])
|
|
|
+ if err = c_db.DoTx(sqlTemplate, []any{
|
|
|
+ defaultTime,
|
|
|
+ teamName,
|
|
|
+ }); err != nil {
|
|
|
+ c_log.GlobalLogger.Error("插入数据报错:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c_log.GlobalLogger.Infof("队伍 %v 的考试在中途中断后重新开始。", teamName)
|
|
|
} else if util.ContainsKey(cacheTeamName, teamName) { // 进行中
|
|
|
cacheTeamName[teamName] = time.Now()
|
|
|
}
|