467 lines
16 KiB
C#
467 lines
16 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using OpenCvSharp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Net.Http;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using VOL.Ai.IServices;
|
|
using VOL.Business.IServices.School;
|
|
using VOL.Core.Enums;
|
|
using VOL.Core.Extensions;
|
|
using VOL.Core.Filters;
|
|
using VOL.Core.ManageUser;
|
|
using VOL.Core.Services;
|
|
using VOL.Core.Utilities;
|
|
using VOL.Entity.DomainModels;
|
|
using VOL.Model;
|
|
using VOL.Model.Ai;
|
|
using VOL.Model.Ai.Request;
|
|
using VOL.Model.Ai.Response;
|
|
using VOL.Model.IOT.Request;
|
|
using VOL.Model.IOT.Response;
|
|
using VOL.Order;
|
|
using VOL.WebApi.Filter;
|
|
|
|
namespace VOL.WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// AiApp接口
|
|
/// </summary>
|
|
[Route("api")]
|
|
[ApiController]
|
|
[ApiExplorerSettings(GroupName = "v6")]
|
|
//[ServiceFilter(typeof(AISignatureValidationFilter))]
|
|
//[TypeFilter(typeof(CustomApiResponseFilter))]
|
|
[AllowAnonymous]
|
|
public class AiAppController : ControllerBase
|
|
{
|
|
#region 初始化
|
|
private readonly IFaceDetectService _faceDetectService;
|
|
private readonly IAiAppService _aiAppService;
|
|
private readonly HttpClient _httpClient;
|
|
public AiAppController(IFaceDetectService faceDetectService, IAiAppService aiAppService, HttpClient httpClient)
|
|
{
|
|
_faceDetectService = faceDetectService;
|
|
_aiAppService = aiAppService;
|
|
_httpClient = httpClient;
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// Test
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(Test))]
|
|
[ServiceFilter(typeof(AISignatureValidationFilter))]
|
|
public async Task<ActionResult> Test([FromBody] Ai_Request paramDto)
|
|
{
|
|
return Ok(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 接收AI设备的心跳
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(Heartbeat))]
|
|
public async Task<IActionResult> Heartbeat([FromBody] Ai_Request paramDto)
|
|
{
|
|
Logger.Info(LoggerType.System, paramDto.Serialize(), paramDto.Serialize(), "接收AI设备的心跳");
|
|
return Ok("ok");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取Ai设备信息
|
|
/// </summary>
|
|
/// <param name="code"></param>
|
|
/// <param name="studentNo"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(AiDeviceInfo))]
|
|
public async Task<Ai_DeviceDto> AiDeviceInfo([FromBody] Ai_Request paramDto)
|
|
{
|
|
var result = await _aiAppService.Ai_DeviceInfo(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取学校信息
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(AiSchoolDetail))]
|
|
public async Task<Ai_SchoolDto> AiSchoolDetail(Ai_SchoolRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.Ai_SchoolDetail(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 训练项目类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(ItemTypeList))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<List<Ai_ModeTypeModel>> ItemTypeList(Ai_Request paramDto)
|
|
{
|
|
return await _aiAppService.ItemTypeList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 体测项目类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(CategoryList))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<List<Ai_ModeTypeModel>> CategoryList(Ai_Request paramDto)
|
|
{
|
|
return await _aiAppService.CategoryList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 学生人脸识别
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(StudentFace))]
|
|
public async Task<Ai_StudentFaceInfo> StudentFace([FromBody] GetFaceParam paramDto)
|
|
{
|
|
var result = await _aiAppService.StudentFace(paramDto);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 老师人脸识别
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(TeacherFace))]
|
|
public async Task<Ai_TeacherFaceInfo> TeacherFace([FromBody] GetFaceParam paramDto)
|
|
{
|
|
var result = await _aiAppService.TeacherFace(paramDto);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 学生
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(StudentList))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<List<Ai_StudentListDto>> StudentList(Ai_StudentListRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.Ai_StudentList(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 学生详情
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(StudentDetail))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<AiStudentDetailsDto> StudentDetail(Ai_StudentDetailRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.Ai_StudentDetail(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取专项教学项目
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(TeachingItems))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<List<Ai_ItemTypeModel>> TeachingItems(Ai_Request paramDto)
|
|
{
|
|
var result = await _aiAppService.TeachingItems(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取专项教学项目详情
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(TeachingItemsDetail))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<Ai_TeachingItemsDetailModel> TeachingItemsDetail(Ai_TeachingItemsRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.TeachingItemsDetail(paramDto);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 阿里云OSS获取上传文件的配置信息
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(OSSInfo))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public Ai_OSSInfoDto OSSInfo(Ai_Request paramDto)
|
|
{
|
|
return _aiAppService.OSSInfo(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// AI设备上传成绩关联文件
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(ResultFiles))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public Task<ResultFilesDto> ResultFiles(ResultFilesRequest paramDto, IFormFile file)
|
|
{
|
|
var result = _aiAppService.ResultFiles(paramDto, file);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取赛事活动列表
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(ActivitiesList))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<PageDataDto<Ai_ActivitiesListDto>> ActivitiesList([FromQuery] Ai_ActivitiesListRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.ActivitiesList(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取赛事活动报告
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(ActivitiesReport))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<PageDataDto<Ai_ActivitiesRankingDto>> ActivitiesReport([FromQuery] Ai_ActivitiesRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.ActivitiesRanking(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取赛事活动排行
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(ActivitiesRanking))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<ActivitiesRankingPageDataDto<Ai_ActivitiesRankingDto>> ActivitiesRanking([FromQuery] Ai_ActivitiesRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.ActivitiesRanking(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取体育测试报告
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(SportsTestReport))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<IActionResult> SportsTestReport([FromQuery] Ai_SportsTestReportRequest paramDto)
|
|
{
|
|
return Ok();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取体测成绩排行
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(SportsTestRanking))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<PageDataDto<Ai_RankingListDto>> SportsTestRanking([FromQuery] Ai_RankingListRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.SportsTestRanking(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取体测成绩
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(SportsTestResult))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<PageDataDto<Ai_SportsTestDto>> SportsTestResult([FromQuery] Ai_SportsTestRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.SportsTestResult(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试成绩上传
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(SportsTestResultUpload))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<IActionResult> SportsTestResultUpload([FromBody] SportsTestResultUploadRequest paramDto)
|
|
{
|
|
await _aiAppService.SportsTestResultUpload(paramDto);
|
|
|
|
return Ok("上传成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测评成绩上传
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(LevelExamResultUpload))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<IActionResult> LevelExamResultUpload([FromBody] LevelExamDataUploadRequest paramDto)
|
|
{
|
|
await _aiAppService.LevelExamResultUpload(paramDto);
|
|
|
|
return Ok("上传成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 心率数据上传
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(HeartRateResultUpload))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public IActionResult HeartRateResultUpload([FromBody] AddHeartRateResultUploadRequest paramDto)
|
|
{
|
|
_aiAppService.HeartRateResultUpload(paramDto);
|
|
|
|
return Ok("上传成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增课堂记录
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(AddClassRoomRecord))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<Ai_ClassRoomRecordDto> AddClassRoomRecord([FromBody] Ai_ClassRoomRecordRequest paramDto)
|
|
{
|
|
var res = await _aiAppService.AddClassRoomRecord(paramDto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 结束授课
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(EndTeaching))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<IActionResult> EndTeaching([FromBody] EndTeachingRequest paramDto)
|
|
{
|
|
await _aiAppService.EndTeaching(paramDto);
|
|
return Ok("操作成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取学生当前等级
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(StatusLevelExam))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<StatusLevelExamDto> StatusLevelExam([FromQuery] StatusLevelExamRequest paramDto)
|
|
{
|
|
var res = await _aiAppService.StatusLevelExam(paramDto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 验证学生是否在报名列表中
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(IsActivityInList))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<IsActivityInListDto> IsActivityInList([FromBody] IsActivityInListRequest paramDto)
|
|
{
|
|
var res = await _aiAppService.IsActivityInList(paramDto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 速度跳绳数据上传
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(FastJumpRopeResultUpload))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<IActionResult> FastJumpRopeResultUpload([FromBody] AddFastJumpRopeResultUploadRequest paramDto)
|
|
{
|
|
await _aiAppService.FastJumpRopeResultUpload(paramDto);
|
|
return Ok("上传成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取速度跳绳测试列表
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(FastJumpRopeTestList))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<PageDataDto<Ai_FastJumpRopeDto>> FastJumpRopeTestList([FromQuery] Ai_FastJumpRopeRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.FastJumpRopeTestList(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取速度跳绳成绩排行
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(FastJumpRopeRanking))]
|
|
[ServiceFilter(typeof(ValidateDeviceFilter))]
|
|
public async Task<PageDataDto<Ai_FastJumpRopeStudentList>> FastJumpRopeRanking([FromQuery] Ai_FastJumpRopeRankingRequest paramDto)
|
|
{
|
|
var result = await _aiAppService.FastJumpRopeRanking(paramDto);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ai一体机扫描那登录轮询
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(ScanCodeLogin))]
|
|
public async Task<Ai_TeacherFaceInfo> ScanCodeLogin([FromBody] Ai_Request paramDto)
|
|
{
|
|
var result = await _aiAppService.ScanCodeLogin(paramDto);
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 退出登录
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(LogOut))]
|
|
public async Task<bool> LogOut([FromBody] LoginOutDto paramDto)
|
|
{
|
|
var result = await _aiAppService.LogOut(paramDto);
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|