tuiwucarrer/Admin.NET/Admin.NET.Application/Service/CePing/BusStudentsReports/BusStudentsReportsService.cs

174 lines
7.5 KiB
C#

using Admin.NET.Core;
using Flurl.Http;
using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.NET.Application.Service
{
/// <summary>
/// 学生报告服务
/// </summary>
[ApiDescriptionSettings("测评服务", Name = "BusStudentsReportsService", Order = 100)]
public class BusStudentsReportsService : IDynamicApiController, ITransient
{
private readonly IConfiguration _configuration;
private readonly SqlSugarRepository<BusFramilyMapStudents> _busFramilyMapStudentsRep;
private readonly SqlSugarRepository<BusStudentsFramily> _busStudentsRep;
private readonly static string SeKey = "3c1cbc3f546eda35168c3aa3cb91780fbe703f0996c6d123ea96dc85c70bbc0a8e70006ae6b35eb3962ad057f41a1690";
/// <summary>
///
/// </summary>
public BusStudentsReportsService(IConfiguration configuration, SqlSugarRepository<BusFramilyMapStudents> framilyMapStudentsRep, SqlSugarRepository<BusStudentsFramily> busStudentsRep)
{
_configuration = configuration;
_busFramilyMapStudentsRep = framilyMapStudentsRep;
_busStudentsRep = busStudentsRep;
}
/// <summary>
/// 获取报告列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("list")]
public async Task<List<BusStudentsReportResult>> List([FromQuery] BusStudentsReportsInputDto input)
{
var res = new List<BusStudentsReportResult>();
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetMobileResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == input.UuId);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == input.StudentId);
if (framilysingle == null)
{
return new List<BusStudentsReportResult>()
{
};
}
string guid = input.StudentId.ToString().ToUpper();
var flurlresponse = await ulrs.PostJsonAsync(new MobileStudentsReportsRequestDto { Key = SeKey, Type = input.Type, StudentId = guid });
var response = await flurlresponse.GetJsonAsync<List<BusStudentsReportResult>>();
return response;
}
/// <summary>
/// 获取生涯报告
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpGet("GetCarrerReport")]
public async Task<BusCarrerReports> GetCarrerReport([FromQuery] ReportInputDto inputDto)
{
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetCarrerResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == inputDto.UUID);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == inputDto.StudentId);
if (framilysingle == null)
{
return new BusCarrerReports()
{
};
}
string guid = inputDto.StudentId.ToString().ToUpper();
var flurlResponse = await ulrs.PostJsonAsync(new ReportInputDto { Key = SeKey, Type = inputDto.Type, StudentId = guid, ReportId = inputDto.ReportId, CycName = inputDto.CycName });
var response = await flurlResponse.GetJsonAsync<BusCarrerReports>();
return response;
}
/// <summary>
/// 专业定位报告
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpGet("GetMajorPostionResult")]
public async Task<HollandReportDTO> GetMajorPostionResult([FromQuery] ReportInputDto inputDto)
{
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetMajorPostionResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == inputDto.UUID);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == inputDto.StudentId);
if (framilysingle == null)
{
return new HollandReportDTO()
{
};
}
string guid = inputDto.StudentId.ToString().ToUpper();
var flUrlResponse = await ulrs.PostJsonAsync(new ReportInputDto { Key = SeKey, Type = inputDto.Type, StudentId = guid, ReportId = inputDto.ReportId });
var response = await flUrlResponse.GetJsonAsync<HollandReportDTO>();
return response;
}
/// <summary>
/// 学生发展报告
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpGet("GetStudentDevelopMentResult")]
public async Task<DevelopMentReportDto> GetStudentDevelopMentResult([FromQuery] ReportInputDto inputDto)
{
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetStudentDevelopMentResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == inputDto.UUID);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == inputDto.StudentId);
if (framilysingle == null)
{
return new DevelopMentReportDto()
{
};
}
string guid = inputDto.StudentId.ToString().ToUpper();
var flUrlresponse = await ulrs.PostJsonAsync(new ReportInputDto { Key = SeKey, Type = inputDto.Type, StudentId = guid, ReportId = inputDto.ReportId, CycName = inputDto.CycName });
var response = await flUrlresponse.GetJsonAsync<DevelopMentReportDto>();
return response;
}
/// <summary>
/// 心理健康报告
/// </summary>
/// <param name="inputDto"></param>
/// <returns></returns>
[HttpGet("GetMentalHealthResult")]
public async Task<DevelopMentReportDto> GetMentalHealthResult([FromQuery] ReportInputDto inputDto)
{
var ulrs = _configuration["WebApi:url"].ToString() + "/UserCenters/GetMentalHealthResult";
var framilyInfo = await _busStudentsRep.AsQueryable().FirstAsync(c => c.Uuid == inputDto.UUID);
var framilysingle = await _busFramilyMapStudentsRep.AsQueryable().SingleAsync(x => x.FramilyId == framilyInfo.Id && x.StudentId.ToString() == inputDto.StudentId);
if (framilysingle == null)
{
return new DevelopMentReportDto()
{
};
}
string guid = inputDto.StudentId.ToString().ToUpper();
var flurResponse = await ulrs.PostJsonAsync(new ReportInputDto { Key = SeKey, Type = inputDto.Type, StudentId = guid, ReportId = inputDto.ReportId, CycName = inputDto.CycName });
var response = await flurResponse.GetJsonAsync<DevelopMentReportDto>();
return response;
}
}
}