diff --git a/New_College.Api/Startup.cs b/New_College.Api/Startup.cs index d92f0a7..ea641a1 100644 --- a/New_College.Api/Startup.cs +++ b/New_College.Api/Startup.cs @@ -195,7 +195,7 @@ namespace New_College }); // 生成种子数据 - // app.UseSeedDataMildd(myContext, Env.WebRootPath); + app.UseSeedDataMildd(myContext, Env.WebRootPath); // 开启QuartzNetJob调度服务 app.UseQuartzJobMildd(tasksQzServices, schedulerCenter); //服务注册 diff --git a/New_College.Model/ViewModels/Result/UniversityResult.cs b/New_College.Model/ViewModels/Result/UniversityResult.cs index e107b25..d47c275 100644 --- a/New_College.Model/ViewModels/Result/UniversityResult.cs +++ b/New_College.Model/ViewModels/Result/UniversityResult.cs @@ -266,7 +266,7 @@ namespace New_College.Model.ViewModels /// /// 预估分数 /// - public float EstimateScore { get; set; } + public double EstimateScore { get; set; } /// /// 历年最低分 diff --git a/New_College.Services/T_EnrollmentPlanedescServices.cs b/New_College.Services/T_EnrollmentPlanedescServices.cs index 8ad715c..d8071f8 100644 --- a/New_College.Services/T_EnrollmentPlanedescServices.cs +++ b/New_College.Services/T_EnrollmentPlanedescServices.cs @@ -41,6 +41,8 @@ namespace New_College.Services private readonly IV_CustomerInfoRepository _CustomerInfoRepository; private readonly ID_PlanMajorDescRepository _PlanMajorDescRepository; private readonly ID_PlanMajorScoreLineRepository _PlanMajorScoreLineRepository; + private readonly ID_QualificationLineRepository _QualificationLineRepository; + private readonly ID_ScoreLineRepository _ScoreLineRepository; public T_EnrollmentPlanedescServices(IBaseRepository dal , ID_UniversityRepository ID_UniversityRepository , IT_EnrollmentBatchRepository IT_EnrollmentBatchRepository @@ -55,7 +57,9 @@ namespace New_College.Services , IU_VolunteerTableRepository IU_VolunteerTableRepository , IU_VolunteerTableDetailRepository IU_VolunteerTableDetailRepository , ID_UniversityCollectionRepository ID_UniversityCollectionRepository - , IT_GearInfoRepository IT_GearInfoRepository, IT_EnrollmentPlanedescRepository t_EnrollmentPlanedescServices, IV_CustomerInfoRepository v_CustomerInfoRepository, ID_PlanMajorDescRepository planMajorDescRepository, ID_PlanMajorScoreLineRepository planMajorScoreLineRepository) + , IT_GearInfoRepository IT_GearInfoRepository, IT_EnrollmentPlanedescRepository t_EnrollmentPlanedescServices, + IV_CustomerInfoRepository v_CustomerInfoRepository, ID_PlanMajorDescRepository planMajorDescRepository, + ID_PlanMajorScoreLineRepository planMajorScoreLineRepository, ID_QualificationLineRepository qualificationLineRepository, ID_ScoreLineRepository scoreLineRepository) { this._dal = dal; d_UniversityRepository = ID_UniversityRepository; @@ -76,6 +80,8 @@ namespace New_College.Services this._CustomerInfoRepository = v_CustomerInfoRepository; _PlanMajorDescRepository = planMajorDescRepository; _PlanMajorScoreLineRepository = planMajorScoreLineRepository; + _QualificationLineRepository = qualificationLineRepository; + _ScoreLineRepository = scoreLineRepository; } public List permut = new List(); @@ -89,91 +95,7 @@ namespace New_College.Services { return await t_EnrollmentPlanedesc.GetRecommendUniversity(query); - //var maxscore = query.Score + 10; - //var minscore = query.Score - 10; - //var custome = (await this._CustomerInfoRepository.QueryById(query.CustomerId)); - - //int planId = (await t_EnrollmentPlaneRepository.Query(e => e.Years == custome.Year && e.Area_Id == custome.AreaId)).FirstOrDefault().Id; - - //StringBuilder sb = new StringBuilder(); - //sb.AppendFormat("select Scoreline,UniversityId from T_EnrollmentPlanedesc where IsDelete=0 and Scoreline<={0} and Scoreline>{1} and PlanId={2}", maxscore, minscore, planId); - //if (!string.IsNullOrWhiteSpace(query.SubjectClaim)) - //{ - // var sp = query.SubjectClaim.Split(","); - // sb.AppendFormat(" and ( "); - // for (var i = 0; i < sp.Length; i++) - // { - // sb.AppendFormat(" SubjectClaim in('{0}') or ", sp[i]); - // } - - // sb.AppendFormat(") "); - // sb = sb.Replace("or )", ")"); - //} - - - - //var desc = await _dal.QuerySql(sb.ToString()); - ////降序求出所符合院校 - //var orderdesc = desc.OrderByDescending(x => x.Scoreline).Select(x => x.UniversityId).Distinct().ToList(); - //var nearids = desc.Select(x => x.UniversityId).Distinct().ToList(); - - //var wheres = PredicateBuilder.New(); - //wheres = wheres.And(x => x.IsDelete == false && orderdesc.Contains(x.Id)); - //if (!string.IsNullOrEmpty(query.AreaName) && query.AreaName != "全国") - // wheres = wheres.And(x => x.Area_Name.Contains(query.AreaName)); - //if (query.SubjectLevel < 2) - // wheres = wheres.And(x => x.Subject_Level == query.SubjectLevel); - //if (query.Type >= 0) - // wheres = wheres.And(x => x.Type == query.Type); - //if (query.Nhef < 2) - // wheres = wheres.And(x => x.Nhef == query.Nhef); - //if (query.Sff < 2) - // wheres = wheres.And(x => x.Sff == query.Sff); - //if (query.Syl < 2) - // wheres = wheres.And(x => x.Syl == query.Syl); - //if (query.Nature > 0) - // wheres = wheres.And(x => x.Nature == query.Nature); - - //var info = await d_UniversityRepository.QueryPage(wheres, query.PageIndex, query.PageSize, "Rank Asc"); - //if (info.data.Count <= 0) - // return new PageModel() { }; - //var collectionuniversity = await d_UniversityCollectionRepository.Query(x => x.CustomerId == query.CustomerId && x.IsDelete == false); - //List list = new List() { }; - //foreach (var c in info.data) - //{ - // string attribute = ""; - // if (c.Nhef == 1) - // attribute += "985"; - // if (c.Sff == 1) - // attribute += "211"; - // if (c.Syl == 1) - // attribute += "双一流"; - // list.Add(new UniversityResult - // { - // Id = c.Id, - // Name = c.Name, - // Nature = c.Nature, - // AscriptionName = c.AscriptionName, - // AreaName = c.Area_Name, - // Logo = c.Logo, - // Syl = c.Syl == 1 ? true : false, - // Nhef = c.Nhef == 1 ? true : false, - // Sff = c.Sff == 1 ? true : false, - // UniversityType = c.Type, - // IsNearScore = nearids.Contains(c.Id), - - // IsContrast = collectionuniversity.Count(x => x.Type == 2 && x.UniversityId == c.Id) > 0 - // }); - //} - //return new PageModel() - //{ - // data = list, - // dataCount = info.dataCount, - // page = info.page, - // pageCount = info.pageCount, - // PageSize = info.PageSize - //}; } /// @@ -1279,113 +1201,6 @@ namespace New_College.Services return await this.t_EnrollmentPlanedesc.GetCWBUniversityDetail(query); //var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); - //if (planinfo == null || planinfo.Count() <= 0) - // return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; - //var wheres = PredicateBuilder.New(); - //wheres.And(x => x.IsDelete == false && x.PlanId == planinfo.FirstOrDefault().Id && x.UniversityId > 0); - //wheres.And(x => x.Scoreline > 0); - //if (query.UniversityIds != null && query.UniversityIds.Any()) - //{ - // wheres.And(x => query.UniversityIds.Contains(x.UniversityId)); - //} - - //此处需加冲稳保 - //if (query.AreaId != 821 && query.AreaId != 1047 && query.AreaId != 1965) - //{ - // if (query.BatchId > 0) - // { - // wheres.And(x => x.BatchtypeId == query.BatchId); - // } - //} - //wheres.And(x => x.Scoreline > 0 && (query.Score >= x.Scoreline && query.Score - 25 <= x.Scoreline)); - //if (string.IsNullOrWhiteSpace(query.Type)) - //{ - // wheres.And(x => x.Scoreline > 0 && (x.Scoreline <= query.Score + 15)); - //} - //else - //{ - // if (query.Type == "冲") - // { - // wheres.And(x => x.Scoreline > 0 && (x.Scoreline <= query.Score + 15 && x.Scoreline > query.Score + 5)); - // } - // else if (query.Type == "稳") - // { - // wheres.And(x => x.Scoreline > 0 && (x.Scoreline <= query.Score + 5 && x.Scoreline > query.Score - 15)); - // } - // else if (query.Type == "保") - // { - // wheres.And(x => x.Scoreline > 0 && (x.Scoreline < query.Score - 15)); - // } - //} - //().Id && batchids.Contains(x.BatchtypeId) && x.UniversityId > 0); - //if (query.MajorIds != null && query.MajorIds.Count > 0) - //{ - // 所选专业增加majorids筛选 - // query.MajorIds - // var major = await d_MajorRepository.Query(x => x.IsDelete == false && query.MajorIds.Contains(x.CategoryClass_Id)); - // if (major.Count() <= 0) - // return new MessageModel>() { success = false, msg = "所选专业大类数据完善中..." }; - // var majornames = major.Select(x => x.MajorName).ToList(); - // wheres.And(x => majornames.Contains(x.MajorName)); - //} - //根据上述所有筛选 求出招生计划 - //var plandesc = await _dal.Query(wheres, "Scoreline desc"); - //int universityidcount = 0; - //var start = query.PageSize * (query.PageIndex - 1); - //var end = query.PageIndex * query.PageSize; - - //var stringBuilderinfo = new StringBuilder(); - - //stringBuilderinfo.AppendFormat("select Rank,Id,Name,Logo,Nhef,Sff,Syl,Area_Name,AscriptionName from D_University where IsDelete=0"); - //if (query.UniversityIds != null && query.UniversityIds.Count > 0) - //{ - // universityidcount = query.UniversityIds.Count; - // string ids = string.Join(",", query.UniversityIds); - // stringBuilderinfo.AppendFormat(" and Id in ({0}) ", ids); - //} - //else - //{ - // universityidcount = plandesc.Select(x => x.UniversityId).Distinct().Count(); - // string ids = string.Join(",", plandesc.Select(x => x.UniversityId).Distinct().ToList()); - // stringBuilderinfo.AppendFormat(" and Id in ({0}) ", ids); - //} - //stringBuilderinfo.AppendFormat(" limit {0},{1}", start, end); - - //var sqldata = await d_UniversityRepository.QuerySql(stringBuilderinfo.ToString()); - //if (sqldata.Count <= 0) - // return new MessageModel>() { success = false, msg = "获取失败,数据为空" }; - //var Type = query.Type; - //var list = sqldata.Select(item => new UniversityEnrollmentPlanResult() - //{ - // UniversityName = item.Name, - // UniversityId = item.Id, - // Logo = item.Logo, - // Nhef = item.Nhef, - // Sff = item.Sff, - // Syl = item.Syl, - // planCount = plandesc.Where(x => x.UniversityId == item.Id).Sum(x => x.Plancount), - // PlanIds = plandesc.Where(x => x.UniversityId == item.Id).Select(x => x.Id).ToList(), - // AreaName = item.Area_Name, - // AscriptionName = item.AscriptionName, - // MjaorPlan = plandesc.Count(x => x.UniversityId == item.Id), - // Rank = item.Rank <= 0 ? "-" : item.Rank.ToString(), - // Type = plandesc.Where(x => x.UniversityId == item.Id && x.Scoreline <= query.Score + 15 && x.Scoreline > query.Score + 5).Any() ? "冲" : (plandesc.Where(x => x.Scoreline <= query.Score + 5 && x.Scoreline > query.Score - 15)).Any() ? "稳" : plandesc.Where(x => x.UniversityId == item.Id && x.Scoreline > 0 && query.Score > x.Scoreline).Any() ? "保" : "其他" - //}).ToList(); - //return new MessageModel>() - //{ - // success = true, - // msg = "获取成功", - // response = new PageModel() - // { - // data = list, - // dataCount = universityidcount, - // page = query.PageIndex, - // PageSize = query.PageSize, - // pageCount = (int)Math.Ceiling(universityidcount / Convert.ToDecimal(query.PageSize)) - // } - //}; - - @@ -1475,162 +1290,33 @@ namespace New_College.Services public async Task> GetUniversityProbability(UniversityProbabilityQuery query) { query.Year = query.Year > 2023 ? 2023 : query.Year; - var universityinfo = await d_UniversityRepository.QueryById(query.UniversityId); - if (universityinfo == null) + var universityinfoline = await _QualificationLineRepository.Query(c => c.UId == query.UniversityId); + if (universityinfoline == null) return new MessageModel() { success = false, msg = "院校信息不存在" }; UniversityProbabilityResult model = new UniversityProbabilityResult() { }; - #region 院校信息 - model.Logo = universityinfo.Logo; - model.Name = universityinfo.Name; - model.Nature = universityinfo.Nature; - model.Nhef = universityinfo.Nhef > 0; - model.Sff = universityinfo.Sff > 0; - model.Syl = universityinfo.Syl > 0; - model.AscriptionName = universityinfo.AscriptionName; - model.Rank = universityinfo.Rank; - model.AreaName = universityinfo.Area_Name; - model.SubjectLevel = universityinfo.Subject_Level; - #endregion - var planinfobyarea = await t_EnrollmentPlaneRepository.Query(w => w.Area_Id == query.AreaId); - var planinfo = planinfobyarea.Where(w => w.Years == query.Year); - if (planinfo.Count() <= 0) - return new MessageModel() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; - var planallids = planinfobyarea.Select(x => x.Id).ToList(); - var planid = planinfo.Select(x => x.Id).FirstOrDefault(); - var descinfobyuniv = await _dal.Query(x => planallids.Contains(x.PlanId) && x.UniversityId == query.UniversityId && x.IsDelete == false); - float universityminimum = 0; - //省份的80%分数 - var regionscore = (await t_RegionScoreRepository.Query(x => x.IsDelete == false && x.AreaId == query.AreaId && x.Year == query.Year)).FirstOrDefault(); - var descinfo = descinfobyuniv.Where(x => x.PlanId == planid).ToList(); - if (descinfo.Count <= 0) - { - return new MessageModel() - { - success = false, - msg = "此学校最新招生分数线暂未估测成功" - }; - //Random random = new Random() { }; - //var randomcc = random.Next(6, 8); - //var newrendom = randomcc / float.Parse(10.ToString()); ; - //universityminimum = random.Next(6, 8); - } - else - { - universityminimum = descinfo.OrderByDescending(x => x.Scoreline).Select(x => x.Scoreline).FirstOrDefault(); - } - //return new MessageModel() { success = false, msg = "招生计划为空,正在完善中..." }; - var isprobab = await u_ProbabilityHistoryRepository.Query(x => x.CustomerId == query.CustomerId && x.UniversityId == query.UniversityId); - if (isprobab.Count <= 0) - { - //没得话测试 - //院校对该省份的招生最低分 - if (regionscore == null) - return new MessageModel() - { - success = false, - msg = "获取失败,当前省份满分数据为空" - }; - var now80score = regionscore.Score * (float)0.8; - if (universityminimum >= now80score) - { - float num = 50; - if (query.Score >= universityminimum) - { - var cha = query.Score - universityminimum; - var add = cha * 2; - if (add >= 46) - { - num = 96; - } - else - { - num += add; - } - } - else - { - var cha = universityminimum - query.Score; - if (cha >= 49) - { - num = 1; - } - else - { - num -= cha; - } - } - model.Probability = num; - //每 + 0.5分,成功率增加1 %,最高96 % - //每 - 1分,成功率减少1 %,最低1 % - } - else - { - float num = 50; - if (query.Score >= universityminimum) - { - var cha = query.Score - universityminimum; - if (cha >= 46) - { - num = 96; - } - else - { - num += cha; - } - } - else - { - var cha = universityminimum - query.Score; - if (cha >= 49) - { - num = 1; - } - else - { - num -= cha; - } - } - model.Probability = num; - //每 + 1分,成功率增加1 %,最高96 % - //每 - 1分,成功率减少1 %,最低1 % - } - var random = RadomHelper.RandNumZF(1); - model.EstimateScore = universityminimum + float.Parse(random); - var addresult = await u_ProbabilityHistoryRepository.Add(new U_ProbabilityHistory() - { - CustomerId = query.CustomerId, - EstimateScore = model.EstimateScore, - Probability = Convert.ToInt32(model.Probability), - UniversityId = query.UniversityId, - AreaId = query.AreaId, - Year = query.Year - }); - } - else + var scoreline = await _ScoreLineRepository.Query(c => c.Years == query.Year.ToString() && c.Province == query.AreaName && c.Score == query.Score); + + + model.YearBatchScores = universityinfoline.Select(c => new YearBatchScore() { - //有的话从历史数据拿 - var oldinfo = isprobab.FirstOrDefault(); - model.EstimateScore = oldinfo.EstimateScore; - model.Probability = oldinfo.Probability; - } - var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.IsDelete == false); - var YearBatchScores = new List() { }; - foreach (var item in planinfobyarea.OrderByDescending(x => x.Years).ToList()) + BatchName = c.BatchName, + Score = c.LowScore, + Year = c.Years + }).ToList(); + + model.EstimateScore = Math.Round(model.YearBatchScores.Average(c => c.Score), 0); + double tmpscore = 0; + if (scoreline.Any()) { - var lowscore = descinfobyuniv.Where(x => x.PlanId == item.Id).OrderBy(x => x.Scoreline).FirstOrDefault(); - if (lowscore != null && lowscore.Scoreline > 0) - { - YearBatchScores.Add(new YearBatchScore() - { - Year = item.Years, - Score = lowscore.Scoreline, - BatchName = batchinfo.Where(x => x.Id == lowscore.BatchtypeId).Select(x => x.Batch_name).FirstOrDefault() - }); - } + tmpscore = scoreline.FirstOrDefault().Score; + + // model.Probability = tmpscore >= model.EstimateScore ? "" : ""; } - model.YearBatchScores = YearBatchScores; - model.Proposal = GetProposal(model.Probability); + + + + model.Proposal = tmpscore + 5 > model.EstimateScore ? "成功几率较好,建议可以填报" : tmpscore + 5 == model.EstimateScore ? "成功几率较低,建议谨慎考虑" : tmpscore < model.EstimateScore ? "风险过高,建议谨慎考虑" : "风险过高,不建议填报"; return new MessageModel() { success = true, @@ -1921,7 +1607,7 @@ namespace New_College.Services /// public async Task>> GetAutoVolunteerTableDetail(VolunteerTableQuery query) { - + if (query.details == null) return new MessageModel>() { success = false, msg = "选择专业院校为空..." }; List list = new List() { };