LingxinMeng před 1 rokem
rodič
revize
3f6ec0d570
1 změnil soubory, kde provedl 23 přidání a 22 odebrání
  1. 23 22
      amd64/score_server/handler/h_exam.go

+ 23 - 22
amd64/score_server/handler/h_exam.go

@@ -76,31 +76,32 @@ func Tick(c *gin.Context) {
 				})
 				return
 			}
-		} else {
-			sqlTemplate, _ := util.ReadFile(c_db.SqlFilesMap["exam-insert-begin_time-and-topic-and-equipment_no-by-team_name.sql"])
+			{
+				sqlTemplate, _ := util.ReadFile(c_db.SqlFilesMap["exam-insert-begin_time-and-topic-and-equipment_no-by-team_name.sql"])
 
-			stage := ""
-			if time.Now().Before(trialBegin) {
-				stage = "表演赛"
-			} else if time.Now().After(trialBegin) && time.Now().Before(trialEnd) {
-				stage = "预赛"
-			} else {
-				stage = "决赛"
-			}
-			competitionBegin := time.Now()
-			// 添加队伍名到缓存中
-			cacheTeamName.Store(teamName, competitionBegin)
-			c_log.GlobalLogger.Infof("当前比赛阶段为 %v ,队伍 %v 在起始点范围内第一次启动,保存新一条比赛记录的开始时间 %v", stage, teamName, competitionBegin)
-			if err := c_db.DoTx(sqlTemplate, []any{param.TeamName, stage, competitionBegin, param.EquipmentNo}); err != nil {
-				c_log.GlobalLogger.Error("保存比赛开始时间报错:", err)
-				c.JSON(http.StatusBadRequest, commonEntity.Response{Code: 500, Msg: "保存比赛开始时间报错。"})
+				stage := ""
+				if time.Now().Before(trialBegin) {
+					stage = "表演赛"
+				} else if time.Now().After(trialBegin) && time.Now().Before(trialEnd) {
+					stage = "预赛"
+				} else {
+					stage = "决赛"
+				}
+				competitionBegin := time.Now()
+				// 添加队伍名到缓存中
+				cacheTeamName.Store(teamName, competitionBegin)
+				c_log.GlobalLogger.Infof("当前比赛阶段为 %v ,队伍 %v 在起始点范围内第一次启动,保存新一条比赛记录的开始时间 %v", stage, teamName, competitionBegin)
+				if err := c_db.DoTx(sqlTemplate, []any{param.TeamName, stage, competitionBegin, param.EquipmentNo}); err != nil {
+					c_log.GlobalLogger.Error("保存比赛开始时间报错:", err)
+					c.JSON(http.StatusBadRequest, commonEntity.Response{Code: 500, Msg: "保存比赛开始时间报错。"})
+					return
+				}
+				c.JSON(http.StatusOK, commonEntity.Response{
+					Code: 200,
+					Msg:  "队伍 " + teamName + " 的考试开始。",
+				})
 				return
 			}
-			c.JSON(http.StatusOK, commonEntity.Response{
-				Code: 200,
-				Msg:  "队伍 " + teamName + " 的考试开始。",
-			})
-			return
 		}
 
 	} else if !util.ContainsKey(&cacheTeamName, teamName) && (math.Abs(positionX-InitialPositionX) > 5.00 || math.Abs(positionY-InitialPositionY) > 5.00) { // 不在起点(开始)