|
@@ -1,9 +1,9 @@
|
|
|
-package handler
|
|
|
+package api
|
|
|
|
|
|
import (
|
|
|
- "cicv-data-closedloop/amd64/score_server/dao/mapper"
|
|
|
- webServerEntity "cicv-data-closedloop/amd64/score_server/entity"
|
|
|
- "cicv-data-closedloop/amd64/score_server/infra"
|
|
|
+ "cicv-data-closedloop/amd64/web_server/src/domain/competition"
|
|
|
+ "cicv-data-closedloop/amd64/web_server/src/infrastructure/config"
|
|
|
+ "cicv-data-closedloop/amd64/web_server/src/infrastructure/persistence"
|
|
|
"cicv-data-closedloop/common/config/c_db"
|
|
|
"cicv-data-closedloop/common/config/c_log"
|
|
|
commonEntity "cicv-data-closedloop/common/entity"
|
|
@@ -35,7 +35,7 @@ var (
|
|
|
|
|
|
// 考试心跳
|
|
|
func Tick(c *gin.Context) {
|
|
|
- param := new(webServerEntity.ExamPao)
|
|
|
+ param := new(competition.ExamPao)
|
|
|
// 映射到结构体
|
|
|
if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
c_log.GlobalLogger.Error("请求体解析失败,错误信息为:", err)
|
|
@@ -52,7 +52,7 @@ func Tick(c *gin.Context) {
|
|
|
_, _ = fmt.Sscanf(numStr, "%e", &positionY)
|
|
|
if !util.ContainsKey(&cacheTeamName, teamName) && math.Abs(positionX-InitialPositionX) < 5.00 && math.Abs(positionY-InitialPositionY) < 5.00 { // (在起点开始)
|
|
|
|
|
|
- result := mapper.SelectLatestByTeamName(teamName)
|
|
|
+ result := persistence.SelectLatestByTeamName(teamName)
|
|
|
if len(result) == 1 {
|
|
|
// 判断上一条记录的开始时间和当前时间是否小于2分钟
|
|
|
temp := time.Since(result[0].BeginTime).Minutes()
|
|
@@ -105,7 +105,7 @@ func Tick(c *gin.Context) {
|
|
|
|
|
|
} else if !util.ContainsKey(&cacheTeamName, teamName) && (math.Abs(positionX-InitialPositionX) > 5.00 || math.Abs(positionY-InitialPositionY) > 5.00) { // 不在起点(开始)
|
|
|
// 车辆不是在起点启动的自动驾驶模式
|
|
|
- result := mapper.SelectLatestByTeamName(teamName)
|
|
|
+ result := persistence.SelectLatestByTeamName(teamName)
|
|
|
if len(result) == 1 {
|
|
|
if time.Since(result[0].EndTime).Minutes() <= 5 { // 5分钟之内重启就还算上一条数据
|
|
|
c_log.GlobalLogger.Info("上一条数据记录为:", result[0])
|
|
@@ -189,7 +189,7 @@ func ExamEndTicker() {
|
|
|
cacheTeamName.Delete(teamName)
|
|
|
//delete(cacheTeamName, teamName)
|
|
|
// 1 查询指定队伍的开始时间最新的考试是否有结束时间,如果有则不在处理,如果没有则更新
|
|
|
- var result []webServerEntity.ExamPo
|
|
|
+ var result []competition.ExamPo
|
|
|
selectSql, err := util.ReadFile(c_db.SqlFilesMap["exam-select-latest-by-team_name.sql"])
|
|
|
if err != nil {
|
|
|
c_log.GlobalLogger.Error("读取sql文件报错:", err)
|
|
@@ -247,13 +247,13 @@ func ExamEndTicker() {
|
|
|
|
|
|
// 分页查询,如果日期为默认值,则返回空""
|
|
|
func Page(c *gin.Context) {
|
|
|
- param := new(webServerEntity.ExamPagePao)
|
|
|
+ param := new(competition.ExamPagePao)
|
|
|
_ = c.ShouldBindJSON(¶m)
|
|
|
- resultPos, resultPosTotal := mapper.SelectPage(param.TeamName, param.Topic, (param.CurrentPage-1)*param.PageSize, param.PageSize)
|
|
|
- var resultVos []webServerEntity.ExamVo
|
|
|
+ resultPos, resultPosTotal := persistence.SelectPage(param.TeamName, param.Topic, (param.CurrentPage-1)*param.PageSize, param.PageSize)
|
|
|
+ var resultVos []competition.ExamVo
|
|
|
for _, po := range resultPos {
|
|
|
|
|
|
- resultVos = append(resultVos, webServerEntity.ExamVo{
|
|
|
+ resultVos = append(resultVos, competition.ExamVo{
|
|
|
Id: po.Id,
|
|
|
TeamName: po.TeamName,
|
|
|
Topic: po.Topic,
|
|
@@ -314,8 +314,8 @@ func Page(c *gin.Context) {
|
|
|
// 评分报告pdf下载
|
|
|
func Report(c *gin.Context) {
|
|
|
pdfName := util.NewShortUUID() + ".pdf"
|
|
|
- pdfPath := infra.ApplicationYaml.Pdf.LocalDir + pdfName
|
|
|
- param := new(webServerEntity.ExamReportPao)
|
|
|
+ pdfPath := config.ApplicationYaml.Pdf.LocalDir + pdfName
|
|
|
+ param := new(competition.ExamReportPao)
|
|
|
// 映射到结构体
|
|
|
if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
c_log.GlobalLogger.Error("接收请求参数报错:", err)
|
|
@@ -355,7 +355,7 @@ func Report(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
// 解析详情为数组
|
|
|
- var detailsDtos []webServerEntity.DetailsDto
|
|
|
+ var detailsDtos []competition.DetailsDto
|
|
|
_ = json.Unmarshal([]byte(details.String), &detailsDtos)
|
|
|
|
|
|
layout := "2006-01-02 15:04:05"
|
|
@@ -369,7 +369,7 @@ func Report(c *gin.Context) {
|
|
|
pdf := gopdf.GoPdf{}
|
|
|
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
|
|
|
// 添加字体文件到pdf
|
|
|
- err := pdf.AddTTFFont("simfang", infra.ApplicationYaml.Pdf.Ttf)
|
|
|
+ err := pdf.AddTTFFont("simfang", config.ApplicationYaml.Pdf.Ttf)
|
|
|
if err != nil {
|
|
|
log.Print(err.Error())
|
|
|
return
|
|
@@ -389,8 +389,8 @@ func Report(c *gin.Context) {
|
|
|
pdf.AddPage()
|
|
|
{
|
|
|
err = pdf.SetFont("simfang", "", 36)
|
|
|
- err = pdf.Image(infra.ApplicationYaml.Pdf.BackgroundPng, 0, 0, nil) // 背景图片
|
|
|
- err = pdf.Image(infra.ApplicationYaml.Pdf.LogoPng, 20, 20, &gopdf.Rect{W: 320, H: 100})
|
|
|
+ err = pdf.Image(config.ApplicationYaml.Pdf.BackgroundPng, 0, 0, nil) // 背景图片
|
|
|
+ err = pdf.Image(config.ApplicationYaml.Pdf.LogoPng, 20, 20, &gopdf.Rect{W: 320, H: 100})
|
|
|
{
|
|
|
pdf.SetXY(100, 250)
|
|
|
_ = pdf.Text("车路云一体化算法挑战赛")
|
|
@@ -553,7 +553,7 @@ func Report(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
// ------- 详情页 第二页 -------
|
|
|
- var detailsDtos2 []webServerEntity.DetailsDto // 扣分的场景
|
|
|
+ var detailsDtos2 []competition.DetailsDto // 扣分的场景
|
|
|
for _, detailsDto := range detailsDtos {
|
|
|
if detailsDto.Reason != "" {
|
|
|
detailsDtos2 = append(detailsDtos2, detailsDto)
|
|
@@ -655,7 +655,7 @@ func Report(c *gin.Context) {
|
|
|
|
|
|
// 云控展示线上评分
|
|
|
func Display(c *gin.Context) {
|
|
|
- exam := mapper.SelectAllFromExam()
|
|
|
+ exam := persistence.SelectAllFromExam()
|
|
|
if exam == nil || len(exam) == 0 {
|
|
|
c.JSON(http.StatusOK, commonEntity.Response{
|
|
|
Code: 500,
|
|
@@ -672,7 +672,7 @@ func Display(c *gin.Context) {
|
|
|
|
|
|
// 云控录入线下成绩
|
|
|
func Offline(c *gin.Context) {
|
|
|
- param := new(webServerEntity.ExamOfflinePao)
|
|
|
+ param := new(competition.ExamOfflinePao)
|
|
|
// 映射到结构体
|
|
|
if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
c_log.GlobalLogger.Error("接收请求参数报错:", err)
|
|
@@ -691,7 +691,7 @@ func Offline(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
// todo 这里可能会修改多条数据
|
|
|
- mapper.UpdateDeductScoreOffline(param)
|
|
|
+ persistence.UpdateDeductScoreOffline(param)
|
|
|
c.JSON(http.StatusOK, commonEntity.Response{
|
|
|
Code: 200,
|
|
|
Msg: "线下成绩录入成功。",
|