148 lines
5.3 KiB
C#
148 lines
5.3 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using YD_AllHeartRates.Api.Services.Impl;
|
|
using YD_AllHeartRates.Api.Services.Interface;
|
|
using YD_AllHeartRates.Commons.Dto;
|
|
using YD_AllHeartRates.Commons.Dto.DataPush;
|
|
using YD_AllHeartRates.Commons.Dto.Device;
|
|
|
|
namespace YD_AllHeartRates.Api.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 数据上报
|
|
/// </summary>
|
|
[ApiVersion("1.0")]
|
|
[AllowAnonymous]
|
|
[Route("api/[controller]")]
|
|
public class DataPushController : ControllerBase
|
|
{
|
|
private readonly IDataPushService _dataPushService;
|
|
|
|
public DataPushController(IDataPushService dataPushService)
|
|
{
|
|
_dataPushService = dataPushService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取Token
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(GetToken))]
|
|
public async Task<string> GetToken()
|
|
{
|
|
var res = await _dataPushService.GetToken();
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取学生EduId
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(GetStudentEduId))]
|
|
public async Task<List<StudentEduDto>> GetStudentEduId(string schoolName, string gradeName, string className, string realName, string xsId)
|
|
{
|
|
var res = await _dataPushService.GetStudentEduId(schoolName, gradeName, className, realName, xsId);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 常规数据上报
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(SportsRoutineReport))]
|
|
public async Task<SportsRoutineReportResponse> SportsRoutineReport()
|
|
{
|
|
var data = new List<StudentData>
|
|
{
|
|
new StudentData
|
|
{
|
|
SBID = "1234567",
|
|
XSEDUID = "d1cd4ff5-6511-58b8-809f-22d102b3c20d",
|
|
HDSJ = new List<HeartRateRecordDto>
|
|
{
|
|
new HeartRateRecordDto { SJSJ = "2025-11-11 14:50:00", XL = 90, JXXL = 80 },
|
|
new HeartRateRecordDto { SJSJ = "2025-11-11 14:51:00", XL = 92, JXXL = 80 }
|
|
}
|
|
},
|
|
new StudentData
|
|
{
|
|
SBID = "5678934",
|
|
XSEDUID = "d1cd4ff5-6511-58b8-809f-22d102b3c20e",
|
|
HDSJ = new List<HeartRateRecordDto>
|
|
{
|
|
new HeartRateRecordDto { SJSJ = "2025-11-11 14:50:00", XL = 88, JXXL = 78 }
|
|
}
|
|
}
|
|
};
|
|
var res = await _dataPushService.SportsRoutineReport(data);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 异常数据上报
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(SportsAbnormalReport))]
|
|
public async Task<SportsRoutineReportResponse> SportsAbnormalReport()
|
|
{
|
|
var data = new List<SportsAbnormalReportDto>
|
|
{
|
|
new SportsAbnormalReportDto
|
|
{
|
|
SBID = "1234567",
|
|
XSEDUID = "d1cd4ff5-6511-58b8-809f-22d102b3c20d",
|
|
HDSJ = new List<AbnormalHeartRateRecordDto>
|
|
{
|
|
new AbnormalHeartRateRecordDto { SJSJ = "2025-11-11 15:50:00", XL = 90, JXXL = 80, YCXX="心率过高", YCYY="持续剧烈运动" }
|
|
}
|
|
},
|
|
new SportsAbnormalReportDto
|
|
{
|
|
SBID = "5678934",
|
|
XSEDUID = "d1cd4ff5-6511-58b8-809f-22d102b3c20e",
|
|
HDSJ = new List<AbnormalHeartRateRecordDto>
|
|
{
|
|
new AbnormalHeartRateRecordDto { SJSJ = "2025-11-11 15:50:00", XL = 88, JXXL = 78, YCXX="心率过高", YCYY="持续剧烈运动" }
|
|
}
|
|
}
|
|
};
|
|
var res = await _dataPushService.SportsAbnormalReport(data);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 补传数据上报
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(SportsDataReplay))]
|
|
public async Task<SportsRoutineReportResponse> SportsDataReplay()
|
|
{
|
|
var data = new List<StudentData>
|
|
{
|
|
new StudentData
|
|
{
|
|
SBID = "1234567",
|
|
XSEDUID = "d1cd4ff5-6511-58b8-809f-22d102b3c20d",
|
|
HDSJ = new List<HeartRateRecordDto>
|
|
{
|
|
new HeartRateRecordDto { SJSJ = "2025-11-10 14:50:00", XL = 90, JXXL = 80 },
|
|
new HeartRateRecordDto { SJSJ = "2025-11-10 14:51:00", XL = 92, JXXL = 80 }
|
|
}
|
|
},
|
|
new StudentData
|
|
{
|
|
SBID = "5678934",
|
|
XSEDUID = "d1cd4ff5-6511-58b8-809f-22d102b3c20e",
|
|
HDSJ = new List<HeartRateRecordDto>
|
|
{
|
|
new HeartRateRecordDto { SJSJ = "2025-11-10 14:50:00", XL = 88, JXXL = 78 }
|
|
}
|
|
}
|
|
};
|
|
var res = await _dataPushService.SportsDataReplay(data);
|
|
return res;
|
|
}
|
|
}
|
|
}
|