diff --git a/New_College.Api/Controllers/Back/PlanMajorScoreLineController.cs b/New_College.Api/Controllers/Back/PlanMajorScoreLineController.cs index e8a6385..b80025a 100644 --- a/New_College.Api/Controllers/Back/PlanMajorScoreLineController.cs +++ b/New_College.Api/Controllers/Back/PlanMajorScoreLineController.cs @@ -14,6 +14,7 @@ using SqlSugar; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using New_College.Common; +using New_College.Common.Helper; namespace New_College.Api.Controllers { @@ -30,15 +31,16 @@ namespace New_College.Api.Controllers /// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 /// private readonly ID_PlanMajorScoreLineServices _d_PlanMajorScoreLineServices; - + private readonly ID_PlanMajorDescServices _d_PlanMajorDescServices; /// /// /// private readonly ID_ScoreLineServices id_coreLineServices; - public PlanMajorScoreLineController(ID_PlanMajorScoreLineServices D_PlanMajorScoreLineServices, ID_ScoreLineServices _ScoreLineServices) + public PlanMajorScoreLineController(ID_PlanMajorScoreLineServices D_PlanMajorScoreLineServices, ID_ScoreLineServices _ScoreLineServices, ID_PlanMajorDescServices d_PlanMajorDescServices) { _d_PlanMajorScoreLineServices = D_PlanMajorScoreLineServices; id_coreLineServices = _ScoreLineServices; + _d_PlanMajorDescServices = d_PlanMajorDescServices; } @@ -52,23 +54,87 @@ namespace New_College.Api.Controllers [HttpPost] public async Task> ImportMajorData(IFormFile file) { + + var rrr = new List(); var _list = new List(); var list = ExcelProUtil.InputExcel(file); + + var planmajorlist = await _d_PlanMajorDescServices.Query(c => c.Years == 2023 && c.Location == "山东省" && c.IsDelete == false && c.BatchName.Contains("普通类")); + + //1. 查询匹配一分一段表数据 + var query = await id_coreLineServices.Query(c => c.Years == "2023" && c.Province == "山东省"); + + for (int i = 0; i < query.Count(); i++) + { + rrr.Add(new ScoreLineRepDto() + { + Count = query[i].Count, + Province = query[i].Province, + Score = query[i].Score, + Type = query[i].Type, + SumCountStart = i == 0 ? 1 : query[i - 1].SumCount + 1, + SumCountEnd = i == 0 ? query[i].SumCount : query[i].SumCount, + Years = query[i].Years, + }); + + } + list.OrderBy(c => c.LowScoreRank).ToList().ForEach(a => + { + _list.Add(new D_PlanMajorScoreLine() + { + IsDelete = false, + Location = "山东省", + Major = a.Major, + CreateTime = DateTime.Now, + ModifyTime = DateTime.Now, + OrderSort = 1, + PlanCount = a.PlanCount, + LowScoreRank = a.LowScoreRank, + Years = 2023, + UniversityName = a.UniversityName, + LowScore = a.LowScoreRank <= 62 ? 697 : rrr.Where(e => e.SumCountStart >= a.LowScoreRank || e.SumCountEnd >= a.LowScoreRank).Any() ? rrr.Where(e => e.SumCountStart >= a.LowScoreRank || e.SumCountEnd >= a.LowScoreRank).FirstOrDefault().Score.ObjToInt() : 0 + }); + }); + _list.ForEach(a => + { + var isany = planmajorlist.Where(e => e.UniversityName == a.UniversityName).Any(); + if (isany) + { + var tmpmodel = planmajorlist.Where(e => e.UniversityName == a.UniversityName && e.Major == a.Major).FirstOrDefault(); + a.SelectSubject = tmpmodel.SelectSubject; + a.UId = tmpmodel.UId; + a.FirstType = tmpmodel.FirstType == null ? "" : tmpmodel.FirstType; + a.RootType = tmpmodel.RootType==null?"" : tmpmodel.RootType; + a.PlanCount = tmpmodel.PlanCount; + } + a.BatchName = a.LowScore < 443 ? "普通类二段" : "普通类一段"; + + }); //2. 更新招生计划专业数据 + //3. 新增学校最低专业录取线 + + await _d_PlanMajorScoreLineServices.Add(_list); + + planmajorlist.ForEach(a => + { + var achany = _list.Where(e => e.Major == a.Major && e.UId == a.UId).Any(); + if (achany) + { + var achanymodel = _list.Where(e => e.Major == a.Major && e.UId == a.UId).FirstOrDefault(); + a.LowScore = achanymodel.LowScore; + a.LowScoreRank = achanymodel.LowScoreRank; + } + }); + await _d_PlanMajorDescServices.Batchupdate(planmajorlist); - //3. 更新学校最低专业录取线 - - - - // await _d_PlanMajorScoreLineServices.Add(_list); return new MessageModel() { success = true, diff --git a/New_College.Api/New_College.Model.xml b/New_College.Api/New_College.Model.xml index a56c869..72dcce2 100644 --- a/New_College.Api/New_College.Model.xml +++ b/New_College.Api/New_College.Model.xml @@ -7110,6 +7110,41 @@ 累计人数 + + + 省份 + + + + + 年份 + + + + + 科类 + + + + + 分数 + + + + + 分数区间 + + + + + 本段人数 + + + + + 累计人数 + + 服务器VM diff --git a/New_College.IServices/ID_PlanMajorDescServices.cs b/New_College.IServices/ID_PlanMajorDescServices.cs index 3242c8f..524a7ff 100644 --- a/New_College.IServices/ID_PlanMajorDescServices.cs +++ b/New_College.IServices/ID_PlanMajorDescServices.cs @@ -2,6 +2,7 @@ using New_College.Model; using New_College.Model.Models; using New_College.Model.ViewModels; +using System.Collections.Generic; using System.Threading.Tasks; namespace New_College.IServices @@ -12,6 +13,12 @@ namespace New_College.IServices public interface ID_PlanMajorDescServices : IBaseServices { + /// + /// + /// + /// + /// + Task Batchupdate(List majorDescs); /// /// 一键填报 /// diff --git a/New_College.Model/ViewModels/PlanMajorScoreLineViewModel.cs b/New_College.Model/ViewModels/PlanMajorScoreLineViewModel.cs index f8f7f25..3864e4f 100644 --- a/New_College.Model/ViewModels/PlanMajorScoreLineViewModel.cs +++ b/New_College.Model/ViewModels/PlanMajorScoreLineViewModel.cs @@ -96,8 +96,8 @@ namespace New_College.Model.ViewModels { public string Major { get; set; } public string UniversityName { get; set; } - public string PlanCount { get; set; } - public string LowScoreRank { get; set; } + public int PlanCount { get; set; } + public int LowScoreRank { get; set; } } diff --git a/New_College.Model/ViewModels/ScoreLineResponseDto.cs b/New_College.Model/ViewModels/ScoreLineResponseDto.cs index 998e0b8..90a3896 100644 --- a/New_College.Model/ViewModels/ScoreLineResponseDto.cs +++ b/New_College.Model/ViewModels/ScoreLineResponseDto.cs @@ -83,4 +83,49 @@ namespace New_College.Model.ViewModels } + + + public class ScoreLineRepDto + { + /// + /// 省份 + /// + public string Province { get; set; } + + /// + /// 年份 + /// + public string Years { get; set; } + + /// + /// 科类 + /// + public string Type { get; set; } + + /// + /// 分数 + /// + public string Score { get; set; } + + + /// + /// 分数区间 + /// + public string ScoreRegion { get; set; } + + /// + /// 本段人数 + /// + public int Count { get; set; } + + /// + /// 累计人数 + /// + public int SumCountStart { get; set; } + + public int SumCountEnd { get; set; } + + + } + } diff --git a/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs b/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs index 5254122..4886714 100644 --- a/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs +++ b/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs @@ -248,7 +248,7 @@ namespace New_College.Repository RefAsync totalNumber = 0; var maxscore = query.Score + 10; var minscore = query.Score - 10; - query.Year = query.Year > 2022 ? 2022 : query.Year; + query.Year = query.Year > 2023 ? 2023 : query.Year; //var custome = (await this.v_CustomerInfo.QueryById(query.CustomerId)); // int planId = (await t_EnrollmentPlane.Query(e => e.Years == custome.Year && e.Area_Id == custome.AreaId)).FirstOrDefault().Id; diff --git a/New_College.Services/D_PlanMajorDescServices.cs b/New_College.Services/D_PlanMajorDescServices.cs index 16af959..f4c76e5 100644 --- a/New_College.Services/D_PlanMajorDescServices.cs +++ b/New_College.Services/D_PlanMajorDescServices.cs @@ -13,6 +13,7 @@ using System.Linq; using New_College.Common; using New_College.IRepository; using LinqKit; +using System.Collections.Generic; namespace New_College.Services { @@ -24,11 +25,24 @@ namespace New_College.Services { private readonly IBaseRepository _dal; private readonly ID_QualificationLineRepository _qualificationLineRepository; - public D_PlanMajorDescServices(IBaseRepository dal, ID_QualificationLineRepository d_QualificationLineRepository) + private readonly ID_PlanMajorDescRepository _planMajorDescRepository; + public D_PlanMajorDescServices(IBaseRepository dal, ID_QualificationLineRepository d_QualificationLineRepository, ID_PlanMajorDescRepository planMajorDescRepository) { this._dal = dal; base.BaseDal = dal; _qualificationLineRepository = d_QualificationLineRepository; + _planMajorDescRepository = planMajorDescRepository; + } + + + /// + /// 批量更新 + /// + /// + /// + public async Task Batchupdate(List majorDescs) + { + return await _planMajorDescRepository.Batchupdate(majorDescs); } @@ -45,7 +59,7 @@ namespace New_College.Services var pagemodel = new AIGOPageModel(); int startscore = request.Score - 15; int endscore = request.Score + 15; - int qyear = request.Year >= DateTime.Now.Year ? DateTime.Now.Year - 1 : 2022; + int qyear = request.Year > DateTime.Now.Year ? 2023 : DateTime.Now.Year; Expression> expression = Expressionable.Create() .And(c => c.Years == qyear) .And(c => c.IsDelete == false)