From 3f7aec848eb575031541b464a9ed93d463a04cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?old=E6=98=93?= <156663459@qq.com> Date: Sun, 10 Dec 2023 19:22:02 +0800 Subject: [PATCH] bug fixed --- .../Controllers/Front/LibraryController.cs | 113 ++++++++- .../Front/PcVolunteerController.cs | 23 +- New_College.Api/New_College.Model.xml | 115 +++++++++ New_College.Api/New_College.xml | 28 +++ .../Helper/HtmlHeplerFetcher.cs | 44 ++++ .../Helper/HtmlToPdfConverter.cs | 55 +++++ .../Helper/MajorPlanScoreTool.cs | 39 ++- New_College.Common/New_College.Common.csproj | 1 + .../ViewModels/OtherUniversityDetailView.cs | 222 ++++++++++++++++++ .../ViewModels/Query/OneSubmitGoRequest.cs | 11 +- New_College.Services/D_LongIdMapServices.cs | 1 + .../D_PlanMajorDescServices.cs | 5 +- 12 files changed, 623 insertions(+), 34 deletions(-) create mode 100644 New_College.Common/Helper/HtmlHeplerFetcher.cs create mode 100644 New_College.Common/Helper/HtmlToPdfConverter.cs create mode 100644 New_College.Model/ViewModels/OtherUniversityDetailView.cs diff --git a/New_College.Api/Controllers/Front/LibraryController.cs b/New_College.Api/Controllers/Front/LibraryController.cs index 90f2a75..f51156d 100644 --- a/New_College.Api/Controllers/Front/LibraryController.cs +++ b/New_College.Api/Controllers/Front/LibraryController.cs @@ -373,7 +373,7 @@ namespace New_College.Api.Controllers.Front success = true, }; - + } @@ -515,5 +515,116 @@ namespace New_College.Api.Controllers.Front { return await iD_LongIdMapServices.GetRequestEnrollmentinproductionDetailResult(query); } + + + + + + + /// + /// 获取学科评估 + /// + /// + /// + [HttpGet] + public async Task> GetSubjectEvaluate([FromQuery] SubjectEvaluateRequest request) + { + request.extTypeId = "第四轮"; + var info = HttpHelper.PostApi("http://192.168.104.104:3000/youzy.dms.basiclib.api.college.subjectevaluate.byexttypeid.query", request); + if (info == null) + { + return new MessageModel + { + msg = "暂无数据", + success = false + }; + } + if (info.isSuccess) + { + return new MessageModel() + { + success = true, + msg = "ok", + response = info.result + }; + } + return new MessageModel + { + msg = "暂无数据", + success = false + }; + } + + + /// + /// 特色专业 + /// + /// + /// + [HttpGet] + public async Task> GetFeaturedMajor([FromQuery] FeaturedMajorRequest request) + { + var info = HttpHelper.GetApi("http://192.168.104.104:3000/", string.Format("youzy.dms.basiclib.api.college.profession.bycollege.get?collegeCode={0}", request.collegeCode)); + if (info == null) + { + return new MessageModel + { + msg = "暂无数据", + success = false + }; + } + if (info.isSuccess) + { + return new MessageModel() + { + success = true, + msg = "ok", + response = info.result + }; + } + return new MessageModel + { + msg = "暂无数据", + success = false + }; + } + + + /// + /// 院系设置 + /// + /// + /// + [HttpGet] + public async Task>> GetDepartment([FromQuery] DepartmentRequest request) + { + var info = HttpHelper.GetApi("http://192.168.104.104:3000/", string.Format("youzy.dms.basiclib.api.college.department.bycollege.get?collegeCode={0}", request.collegeCode)); + if (info == null) + { + return new MessageModel> + { + msg = "暂无数据", + success = false + }; + } + if (info.isSuccess) + { + return new MessageModel>() + { + success = true, + msg = "ok", + response = info.result.ToList() + }; + } + return new MessageModel> + { + msg = "暂无数据", + success = false + }; + } + + + + } } diff --git a/New_College.Api/Controllers/Front/PcVolunteerController.cs b/New_College.Api/Controllers/Front/PcVolunteerController.cs index 90dd145..8bbb168 100644 --- a/New_College.Api/Controllers/Front/PcVolunteerController.cs +++ b/New_College.Api/Controllers/Front/PcVolunteerController.cs @@ -369,17 +369,18 @@ namespace New_College.Api.Controllers.Front /// /// /// - //[AllowAnonymous] - //[HttpGet("downloadpdf")] - //public IActionResult DownloadPdf(string url) - //{ - // // 假设pdfBytes是已存在的PDF文件字节流 - // // byte[] pdfBytes = HelperHtmlConvertPdf.DoHtmlToByte(url); - // // 设置响应头,指定Content-Type和文件名 - // Response.Headers.Add("Content-Disposition", string.Format("attachment; filename={0}.pdf", DateTime.Now.ToString("MMddHHmmssfff"))); - // Response.ContentType = "application/pdf"; - // return File(pdfBytes, "application/pdf"); - //} + [AllowAnonymous] + [HttpGet("downloadpdf")] + public async Task DownloadPdf(string url) + { + var htmlContent = await HtmlHeplerFetcher.GetHtmlContentAsync(url); + // 假设pdfBytes是已存在的PDF文件字节流 + byte[] pdfBytes = new HtmlToPdfConverter().ConvertHtmlToPdf(htmlContent); + // 设置响应头,指定Content-Type和文件名 + Response.Headers.Add("Content-Disposition", string.Format("attachment; filename={0}.pdf", DateTime.Now.ToString("MMddHHmmssfff"))); + Response.ContentType = "application/pdf"; + return File(pdfBytes, "application/pdf"); + } } diff --git a/New_College.Api/New_College.Model.xml b/New_College.Api/New_College.Model.xml index 94882a2..2f2a9b1 100644 --- a/New_College.Api/New_College.Model.xml +++ b/New_College.Api/New_College.Model.xml @@ -3625,6 +3625,116 @@ + + + + + + + + 第四轮 + + + + + 是否有子项目 + + + + + 专业名称 + + + + + 专业编号 + + + + + A|B|C|评级 等级 + + + + + 是否有内容介绍 + + + + + 特色专业 + + + + + 国家级 + + + + + 省级 + + + + + 省重点 + + + + + 学科专业名称 + + + + + 国家级/省重点/省级 + + + + + 是否有专业介绍 + + + + + 院系编号 + + + + + 院系名称 + + + + + 对应专业数量 + + + + + 专业名称 + + + + + 专业code + + + + + 本/专 + + + + + 显示名称 + + + + + 是否有专业介绍 + + 院校Id @@ -4165,6 +4275,11 @@ 冲稳保 类型:冲2,稳1,保0 + + + 百分比 + + 排名 diff --git a/New_College.Api/New_College.xml b/New_College.Api/New_College.xml index 4c6f087..0f86df7 100644 --- a/New_College.Api/New_College.xml +++ b/New_College.Api/New_College.xml @@ -473,6 +473,27 @@ + + + 获取学科评估 + + + + + + + 特色专业 + + + + + + + 院系设置 + + + + 获取高薪推荐 @@ -571,6 +592,13 @@ + + + + + + + 获取省市区 diff --git a/New_College.Common/Helper/HtmlHeplerFetcher.cs b/New_College.Common/Helper/HtmlHeplerFetcher.cs new file mode 100644 index 0000000..3050077 --- /dev/null +++ b/New_College.Common/Helper/HtmlHeplerFetcher.cs @@ -0,0 +1,44 @@ +using Microsoft.DotNet.PlatformAbstractions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Common +{ + public static class HtmlHeplerFetcher + { + public static async Task GetHtmlContentAsync(string url) + { + using (HttpClient client = new HttpClient()) + { + try + { + + client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"); + client.DefaultRequestHeaders.Add("Sec-Ch-Ua","'Google Chrome';v='119','Chromium';v='119','Not?A_Brand';v='24'"); + client.DefaultRequestHeaders.Add("Sec-Ch-Ua-Mobile", "?0"); + client.DefaultRequestHeaders.Add("Sec-Ch-Ua-Platform", "Windows"); + HttpResponseMessage response = await client.GetAsync(url); + + if (response.IsSuccessStatusCode) + { + return await response.Content.ReadAsStringAsync(); + } + else + { + throw new HttpRequestException($"Failed to retrieve HTML. Status code: {response.StatusCode}"); + } + } + catch (Exception ex) + { + throw new HttpRequestException($"Failed to retrieve HTML. {ex.Message}"); + } + } + } + + } +} diff --git a/New_College.Common/Helper/HtmlToPdfConverter.cs b/New_College.Common/Helper/HtmlToPdfConverter.cs new file mode 100644 index 0000000..d86d955 --- /dev/null +++ b/New_College.Common/Helper/HtmlToPdfConverter.cs @@ -0,0 +1,55 @@ +using DinkToPdf.Contracts; +using DinkToPdf; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using System.Net.Http; + +namespace New_College.Common +{ + + public class HtmlToPdfConverter + { + private readonly IConverter _pdfConverter; + public HtmlToPdfConverter() + { + var globalSettings = new GlobalSettings + { + ColorMode = ColorMode.Color, + Orientation = Orientation.Portrait, + PaperSize = PaperKind.A4, + }; + + var objectSettings = new ObjectSettings + { + PagesCount = true, + HtmlContent = "

Hello World

", + WebSettings = { DefaultEncoding = "utf-8" }, + }; + + _pdfConverter = new SynchronizedConverter(new PdfTools()); + } + + public byte[] ConvertHtmlToPdf(string htmlContent) + { + try + { + var document = new HtmlToPdfDocument() + { + GlobalSettings = { PaperSize = PaperKind.A4, Orientation = Orientation.Portrait, DPI = 300 }, + Objects = { new ObjectSettings { HtmlContent = htmlContent } } + }; + byte[] pdfBytes = _pdfConverter.Convert(document); + return pdfBytes; + } + catch (Exception ex) + { + + return null; + } + } + } +} diff --git a/New_College.Common/Helper/MajorPlanScoreTool.cs b/New_College.Common/Helper/MajorPlanScoreTool.cs index de3ec34..1e5b1e6 100644 --- a/New_College.Common/Helper/MajorPlanScoreTool.cs +++ b/New_College.Common/Helper/MajorPlanScoreTool.cs @@ -7,6 +7,25 @@ namespace New_College.Common { public class MajorPlanScoreTool { + + + /// + /// 冲稳保百分比 + /// + /// + /// + /// + public static int GetPlanPercentage(int LowScore, int requestScore) + { + int minscore = requestScore - 15;//最小 + int constscore = requestScore;//中位数 + int maxscore = requestScore + 15;//最大 + + int percentage = LowScore <= minscore ? new Random().Next(90, 99) : minscore < LowScore && LowScore <= constscore ? new Random().Next(65, 89) : LowScore > constscore && LowScore <= maxscore ? new Random().Next(30, 64) : new Random().Next(1, 29); + + return percentage; + } + /// /// 冲稳保计算 /// @@ -17,28 +36,8 @@ namespace New_College.Common int minscore = requestScore - 15;//最小 int constscore = requestScore;//中位数 int maxscore = requestScore + 15;//最大 - int type = LowScore <= minscore ? 0 : minscore < LowScore && LowScore <= constscore ? 1 : LowScore > constscore && LowScore <= maxscore ? 2 : -1; - //if (LowScore <= minscore) - //{ - // return "保"; - //} - //else if (minscore < LowScore && LowScore <= constscore) - //{ - // return "稳"; - //} - //else if (LowScore > constscore && LowScore <= maxscore) - //{ - - // return "冲"; - - //} - //else - //{ - // return ""; - //} - return type; } diff --git a/New_College.Common/New_College.Common.csproj b/New_College.Common/New_College.Common.csproj index 5037f12..e6037b9 100644 --- a/New_College.Common/New_College.Common.csproj +++ b/New_College.Common/New_College.Common.csproj @@ -12,6 +12,7 @@ + diff --git a/New_College.Model/ViewModels/OtherUniversityDetailView.cs b/New_College.Model/ViewModels/OtherUniversityDetailView.cs new file mode 100644 index 0000000..031f97a --- /dev/null +++ b/New_College.Model/ViewModels/OtherUniversityDetailView.cs @@ -0,0 +1,222 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.ViewModels +{ + public class OtherUniversityDetailView + { + + + } + + public class SubjectEvaluateRequest + { + /// + /// + /// + public string collegeCode { get; set; } + + /// + /// 第四轮 + /// + public string extTypeId { get; set; } + + } + + public class SubjectEvaluateResponse + { + + public SubjectEvaluateResult result { get; set; } + public string code { get; set; } + public string message { get; set; } + public string fullMessage { get; set; } + public DateTime timestamp { get; set; } + public bool isSuccess { get; set; } + + } + + + + + public class SubjectEvaluateResult + { + /// + /// 是否有子项目 + /// + public int childCount { get; set; } + public string extTypeId { get; set; } + public string extTypeName { get; set; } + public string[] extTypeNames { get; set; } + public Subjectevaluate[] subjectEvaluates { get; set; } + } + + public class Subjectevaluate + { + public string code { get; set; } + + /// + /// 专业名称 + /// + public string name { get; set; } + + /// + /// 专业编号 + /// + public object majorCode { get; set; } + + /// + /// A|B|C|评级 等级 + /// + public string level { get; set; } + public int sort { get; set; } + + /// + /// 是否有内容介绍 + /// + public bool isHasIntroduce { get; set; } + } + + + + /// + /// 特色专业 + /// + public class FeaturedMajorRequest + { + + public string collegeCode { get; set; } + } + + + public class FeaturedMajorResponse + { + public FeaturedMajorResult result { get; set; } + public string code { get; set; } + public string message { get; set; } + public string fullMessage { get; set; } + public DateTime timestamp { get; set; } + public bool isSuccess { get; set; } + + } + + public class FeaturedMajorResult + { + + /// + /// 国家级 + /// + public Country[] countries { get; set; } + + /// + /// 省级 + /// + public object[] provinces { get; set; } + + /// + /// 省重点 + /// + public object[] provincePoints { get; set; } + } + + public class Country + { + /// + /// 学科专业名称 + /// + public string name { get; set; } + public string code { get; set; } + + /// + /// 国家级/省重点/省级 + /// + public string professionType { get; set; } + + /// + /// 是否有专业介绍 + /// + public bool isHasIntroduce { get; set; } + } + + + public class DepartmentRequest + { + + public string collegeCode { get; set; } + + } + + public class DepartmentResponse + { + public DepartmentResult[] result { get; set; } + public string code { get; set; } + public string message { get; set; } + public string fullMessage { get; set; } + public DateTime timestamp { get; set; } + public bool isSuccess { get; set; } + + } + + + + public class DepartmentResult + { + /// + /// 院系编号 + /// + public string collegeCode { get; set; } + + /// + /// 院系名称 + /// + public string name { get; set; } + + /// + /// 对应专业数量 + /// + public int majorCount { get; set; } + public string website { get; set; } + public Departmentmajor[] departmentMajors { get; set; } + } + + public class Departmentmajor + { + public string id { get; set; } + public string departmentId { get; set; } + + /// + /// 专业名称 + /// + public string name { get; set; } + + /// + /// 专业code + /// + public string code { get; set; } + public string level { get; set; } + + /// + /// 本/专 + /// + public string levelText { get; set; } + + /// + /// 显示名称 + /// + public string majorDisplayName { get; set; } + public object largeClassName { get; set; } + public object middleClassName { get; set; } + public object departmentName { get; set; } + public object evaluateLevel { get; set; } + public string[] featuredLabel { get; set; } + + /// + /// 是否有专业介绍 + /// + public bool isHasIntroduce { get; set; } + } + + +} diff --git a/New_College.Model/ViewModels/Query/OneSubmitGoRequest.cs b/New_College.Model/ViewModels/Query/OneSubmitGoRequest.cs index 612b40b..8c1157f 100644 --- a/New_College.Model/ViewModels/Query/OneSubmitGoRequest.cs +++ b/New_College.Model/ViewModels/Query/OneSubmitGoRequest.cs @@ -109,6 +109,8 @@ namespace New_College.Model.ViewModels /// 冲稳保 类型:冲2,稳1,保0 ///
public int Type { get; set; } + + public int Percentage { get; set; } /// /// 排名 /// @@ -173,7 +175,7 @@ namespace New_College.Model.ViewModels public class AIGoPlanMajorItem { - + /// /// 计划数 /// @@ -208,6 +210,8 @@ namespace New_College.Model.ViewModels ///
public string SubjectClam { get; set; } + public int Percentage { get; set; } + /// /// /// @@ -230,6 +234,11 @@ namespace New_College.Model.ViewModels /// 冲稳保 类型:冲2,稳1,保0 ///
public int Type { get; set; } + + /// + /// 百分比 + /// + public int Percentage { get; set; } /// /// 排名 /// diff --git a/New_College.Services/D_LongIdMapServices.cs b/New_College.Services/D_LongIdMapServices.cs index 08bf3c0..957c8cc 100644 --- a/New_College.Services/D_LongIdMapServices.cs +++ b/New_College.Services/D_LongIdMapServices.cs @@ -381,6 +381,7 @@ namespace New_College.Services QJJH = university.QJJH == 1 ? true : false, UniversityType = university.Type, SubjectLevel = university.Subject_Level, + BuildDate=university.Build_Date, Imglist = imgs, DoctorateCount = university.Doctorate_Count, MasterCount = university.Master_Count, diff --git a/New_College.Services/D_PlanMajorDescServices.cs b/New_College.Services/D_PlanMajorDescServices.cs index 3684e92..b824b90 100644 --- a/New_College.Services/D_PlanMajorDescServices.cs +++ b/New_College.Services/D_PlanMajorDescServices.cs @@ -113,6 +113,7 @@ namespace New_College.Services //_frank = c.LowScoreRank, // SubjectClam = c.SelectSubject, Type = MajorPlanScoreTool.GetPlanScore(c.LowScore, request.Score),//冲稳保院校 + Percentage = MajorPlanScoreTool.GetPlanPercentage(c.LowScore, request.Score), planCount = list.Where(w => w.Years == DateTime.Now.Year && w.UId == c.UId).Sum(c => c.PlanCount), iGoPlanMajorItems = list.Where(w => w.Years == DateTime.Now.Year && w.UId == c.UId).Select(t => new AIGoPlanMajorItem() { @@ -124,6 +125,7 @@ namespace New_College.Services MajorRemark = t.Remark, planCount = t.PlanCount, SubjectClam = t.SelectSubject, + Percentage = MajorPlanScoreTool.GetPlanPercentage(t.LowScore, request.Score), PlanItems = list.Where(ss => ss.UId == c.UId && ss.Major == t.Major).Select(k => new PlanItem() { PlanCount = k.PlanCount, @@ -194,7 +196,7 @@ namespace New_College.Services .AndIF(!string.IsNullOrWhiteSpace(request.SubjectClaim), c => SqlFunc.Contains(c.SelectSubject, claim[0]) || SqlFunc.Contains(c.SelectSubject, claim[1]) || SqlFunc.Contains(c.SelectSubject, claim[2])) .AndIF(!string.IsNullOrWhiteSpace(request.Major), c => SqlFunc.Contains(c.Major, request.Major)) .AndIF(!string.IsNullOrWhiteSpace(request.BatchName), c => c.BatchName.Equals(request.BatchName)) - .AndIF(!string.IsNullOrWhiteSpace(request.Province), c => SqlFunc.Contains(request.Province,c.AreaName)) + .AndIF(!string.IsNullOrWhiteSpace(request.Province), c => SqlFunc.Contains(request.Province, c.AreaName)) .And(c => c.Years == request.Year) .AndIF(!string.IsNullOrWhiteSpace(request.SchoolType), c => c.SchoolType == request.SchoolType) .AndIF(request.Score > 0, c => SqlFunc.Between(c.LowScore, request.Score - 15, request.Score + 15)) @@ -256,6 +258,7 @@ namespace New_College.Services UniversityName = c.UniversityName, SubjectClam = c.SelectSubject, Type = MajorPlanScoreTool.GetPlanScore(c.LowScore, request.Score),//还缺冲稳保 + Percentage = MajorPlanScoreTool.GetPlanPercentage(c.LowScore, request.Score), PlanId = c.Id, UniversityCode = c.EnrollmentCode, MajorCode = c.MajorCode,