302 lines
17 KiB
C#
302 lines
17 KiB
C#
|
|
using New_College.IServices;
|
|
using New_College.Model.Models;
|
|
using New_College.Services.BASE;
|
|
using New_College.IRepository.Base;
|
|
using System.Threading.Tasks;
|
|
using New_College.Model.ViewModels;
|
|
using New_College.Model;
|
|
using SqlSugar;
|
|
using System.Linq.Expressions;
|
|
using System;
|
|
using System.Linq;
|
|
using New_College.Common;
|
|
using New_College.IRepository;
|
|
using LinqKit;
|
|
using System.Collections.Generic;
|
|
using New_College.Repository;
|
|
using System.Data.Entity.Infrastructure;
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
namespace New_College.Services
|
|
{
|
|
|
|
/// <summary>
|
|
/// 填报数据整合
|
|
/// </summary>
|
|
public class D_PlanMajorDescServices : BaseServices<D_PlanMajorDesc>, ID_PlanMajorDescServices
|
|
{
|
|
private readonly IBaseRepository<D_PlanMajorDesc> _dal;
|
|
private readonly ID_QualificationLineRepository _qualificationLineRepository;
|
|
private readonly ID_PlanMajorDescRepository _planMajorDescRepository;
|
|
private readonly IT_BatchlineRepository _batchlineRepository;
|
|
private readonly IT_TbSNeedDataInfoServices sNeedDataInfoServices;
|
|
private readonly ID_UniversityServices _UniversityServices;
|
|
public D_PlanMajorDescServices(IBaseRepository<D_PlanMajorDesc> dal, ID_QualificationLineRepository d_QualificationLineRepository,
|
|
ID_PlanMajorDescRepository planMajorDescRepository, IT_BatchlineRepository batchlineRepository,
|
|
IT_TbSNeedDataInfoServices sNeedDataInfoServices, ID_UniversityServices d_UniversityServices)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
_qualificationLineRepository = d_QualificationLineRepository;
|
|
_planMajorDescRepository = planMajorDescRepository;
|
|
_batchlineRepository = batchlineRepository;
|
|
this.sNeedDataInfoServices = sNeedDataInfoServices;
|
|
_UniversityServices = d_UniversityServices;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 批量更新
|
|
/// </summary>
|
|
/// <param name="majorDescs"></param>
|
|
/// <returns></returns>
|
|
public async Task<bool> Batchupdate(List<D_PlanMajorDesc> majorDescs)
|
|
{
|
|
return await _planMajorDescRepository.Batchupdate(majorDescs);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public async Task<AIGOPageModel<AIGOResponse>> GetAIGoList(OneSubmitGoRequest request)
|
|
{
|
|
request.PageSize = request.PageSize > 50 ? 50 : request.PageSize;
|
|
var claim = request.SubjectClaim.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList();
|
|
var pagemodel = new AIGOPageModel<AIGOResponse>();
|
|
int startscore = request.Score - 15;
|
|
int endscore = request.Score + 15;
|
|
int qyear = request.Year >= 2023 ? 2023 : request.Year;
|
|
var batlist = await _batchlineRepository.Query(c => c.Year == request.Year && c.Type_name == "综合");
|
|
request.BatchName = batlist.Where(c => c.Average <= request.Score && c.Batch_name == "普通类一段").Any() ? "普通类一段" : "普通类二段";
|
|
Expression<Func<D_QualificationLine, bool>> expression = Expressionable.Create<D_QualificationLine>()
|
|
.And(c => c.Years == qyear)
|
|
.And(c => c.IsDelete == false)
|
|
.And(c => c.Location == request.Location)
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.BatchName), c => c.BatchName.Equals(request.BatchName))
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Name), c => SqlFunc.Contains(c.UniversityName, request.Name))
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Province), c => SqlFunc.Contains(request.Province, c.AreaName))
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.SchoolType), c => c.SubjectType == request.SchoolType)
|
|
.AndIF(request.Score > 0 && (request.EndScore <= endscore && request.StartScore >= startscore), c => SqlFunc.Between(c.LowScore, startscore, endscore))
|
|
.AndIF(request.EndScore > endscore || request.StartScore < startscore, c => SqlFunc.Between(c.LowScore, request.StartScore, request.EndScore))
|
|
.AndIF(request.Syl.HasValue && request.Syl == 1, c => c._SYL == "是")
|
|
.AndIF(request._211.HasValue && request._211 == 1, c => c._211 == "是")
|
|
.AndIF(request._985.HasValue && request._985 == 1, c => c._985 == "是")
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Ownership), c => c.Ownership == request.Ownership)
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Nature), c => c.Nature == request.Nature)
|
|
.ToExpression();
|
|
//var query = await _qualificationLineRepository.QueryPage(expression, request.PageIndex, request.PageSize, " LowScoreRank desc ");
|
|
var query = await _qualificationLineRepository.QueryPage(expression, request.PageIndex, request.PageSize, " LowScoreRank desc ");
|
|
|
|
//var majorarry = query.data.Select(c => c.Major).Distinct().ToArray();
|
|
var universityarry = query.data.Select(c => c.UniversityName).Distinct().ToArray();//
|
|
|
|
Expression<Func<T_TbSNeedDataInfo, bool>> expression3 = Expressionable.Create<T_TbSNeedDataInfo>()
|
|
.And(c => c.Location == request.Location)
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Major), c => SqlFunc.Contains(c.MajorName, request.Major))
|
|
// .AndIF(!string.IsNullOrWhiteSpace(request.SubjectClaim), c => SqlFunc.Contains(c.SelectSubject, request.SubjectClaim)) //此条件不带
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.SubjectClaim), c => SqlFunc.Contains(c._24subject, claim[0]) || SqlFunc.Contains(c._24subject, claim[1]) || SqlFunc.Contains(c._24subject, claim[2]) || c._24subject == "不限")
|
|
//.AndIF(!string.IsNullOrWhiteSpace(request.BatchName), c => c.BatchName == request.BatchName)
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Province), c => SqlFunc.Contains(request.Province, c.Province))
|
|
// .AndIF(!string.IsNullOrWhiteSpace(request.SchoolType), c => c.SchoolType == request.SchoolType)
|
|
.AndIF(request.Syl.HasValue && request.Syl == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "双一流"))
|
|
.AndIF(request._211.HasValue && request._211 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "211"))
|
|
.AndIF(request._985.HasValue && request._985 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "985"))
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Ownership), c => c.Ownership == request.Ownership)
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Nature), c => c.Nature == request.Nature)
|
|
.AndIF(universityarry.Any(), c => SqlFunc.ContainsArray(universityarry, c.UniversityName))
|
|
.AndIF(request.EndScore > endscore || request.StartScore < startscore, c => SqlFunc.Between(c._23Score, request.StartScore, request.EndScore))
|
|
.ToExpression();
|
|
var querylist = await this.sNeedDataInfoServices.Query(expression3);
|
|
|
|
var responselist = query.data.Select(c => new AIGOResponse()
|
|
{
|
|
AreaName = c.AreaName,
|
|
Rank = c.Rank > 9999 ? "--" : c.Rank.ToString(),
|
|
_985 = c._985,
|
|
_211 = c._211,
|
|
_SYL = c._SYL,
|
|
UniversityId = c.UId,
|
|
UniversityName = c.UniversityName,
|
|
UniversityCode = UniversityCodeConvertRules.UniversityCodeConvertRulesMap(c.RecruitCode.ToString()),
|
|
collegeCode = c.RecruitCode.ToString(),
|
|
LowScoreRank = c.LowScoreRank,
|
|
Ownership = c.Ownership,
|
|
Type = MajorPlanScoreTool.GetPlanScore(c.LowScore, request.Score),//冲稳保院校
|
|
Percentage = MajorPlanScoreTool.GetPlanPercentage(c.LowScore, request.Score),
|
|
planCount = querylist.Where(w => w.UniversityName == c.UniversityName).Sum(c => int.Parse(c._23Count)),
|
|
}).OrderByDescending(c => c.Type).OrderBy(c => c.LowScoreRank).ToList();
|
|
|
|
responselist.ToList().ForEach(c =>
|
|
{
|
|
var items = querylist.Where(e => e.UniversityName == c.UniversityName);
|
|
c._fcount = items.Select(e => int.Parse(e._23Count)).Sum();
|
|
c._scount = items.Select(e => int.Parse(e._22Count)).Sum();
|
|
c._tcount = items.Select(e => int.Parse(e._21Count)).Sum();
|
|
c._fscore = items.Min(e => int.Parse(e._23SchoolScore));
|
|
c._frank = items.Min(e => int.Parse(e._23SchoolScoreLine));
|
|
c._sscore = items.Min(e => int.Parse(e._22Score));
|
|
c._srank = items.Min(e => int.Parse(e._22ScoreLine));
|
|
c._tscore = items.Min(e => int.Parse(e._22Score));
|
|
c._trank = items.Min(e => int.Parse(e._22ScoreLine));
|
|
c.iGoPlanMajorItems = items.Select(t => new AIGoPlanMajorItem()
|
|
{
|
|
|
|
PlanId = t.ID,
|
|
MajorCode = t.MajorCode,
|
|
fee = t.Fee,
|
|
Major = t.MajorName,
|
|
// MajorGroup = t.MajorGroup,//山东无专业组
|
|
MajorRemark = t.Remark,
|
|
planCount = int.Parse(t._23Count),
|
|
SubjectClam = t._23subject,
|
|
Type = MajorPlanScoreTool.GetPlanScore(int.Parse(t._23Score), request.Score),//冲稳保院校
|
|
Percentage = MajorPlanScoreTool.GetPlanPercentage(int.Parse(t._23Score), request.Score),
|
|
PlanItems = new List<PlanItem>()
|
|
{
|
|
new PlanItem() {
|
|
PlanCount=int.Parse(t._23Count),
|
|
RankLine=int.Parse(t._23ScoreLine),
|
|
Scoreline=int.Parse(t._23Score),
|
|
Year="2023"
|
|
},
|
|
new PlanItem() {
|
|
PlanCount=int.Parse(t._22Count),
|
|
RankLine=int.Parse(t._22ScoreLine),
|
|
Scoreline=int.Parse(t._22Score),
|
|
Year="2022"
|
|
},
|
|
new PlanItem() {
|
|
PlanCount=int.Parse(t._21Count),
|
|
RankLine=int.Parse(t._21ScoreLine),
|
|
Scoreline=int.Parse(t._21Score),
|
|
Year="2021"
|
|
},
|
|
}
|
|
}).ToList();
|
|
|
|
});
|
|
return new AIGOPageModel<AIGOResponse>()
|
|
{
|
|
data = responselist,
|
|
c = responselist.Where(c => c.Type == 2).Count(),
|
|
w = responselist.Where(c => c.Type == 1).Count(),
|
|
b = responselist.Where(c => c.Type == 0).Count(),
|
|
dataCount = query.dataCount,
|
|
page = query.page,
|
|
pageCount = query.pageCount,
|
|
PageSize = query.PageSize
|
|
};
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 一键填报招生计划展示
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public async Task<PageModel<OneSubmitGoResponse>> GetPlanMajorList(OneSubmitGoRequest request)
|
|
{
|
|
|
|
var pagemodel = new PageModel<OneSubmitGoResponse>();
|
|
|
|
request.PageSize = request.PageSize < 100 ? 100 : request.PageSize;
|
|
//request.PageSize = 150;//山东省
|
|
|
|
request.Year = request.Year > 2023 ? 2023 : request.Year;
|
|
var claim = request.SubjectClaim.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList();
|
|
Expression<Func<T_TbSNeedDataInfo, bool>> expression3 = Expressionable.Create<T_TbSNeedDataInfo>()
|
|
|
|
.And(c => c.Location == request.Location)
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.SubjectClaim), c => SqlFunc.Contains(c._24subject, claim[0]) || SqlFunc.Contains(c._24subject, claim[1]) || SqlFunc.Contains(c._24subject, claim[2]) || c._24subject == "不限")
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Major), c => SqlFunc.Contains(c.MajorName, request.Major))
|
|
//.AndIF(!string.IsNullOrWhiteSpace(request.BatchName), c => c.BatchName.Equals(request.BatchName))
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Province), c => SqlFunc.Contains(request.Province, c.Province))
|
|
//.And(c => c.Years == request.Year)
|
|
//.AndIF(!string.IsNullOrWhiteSpace(request.SchoolType), c => c.SchoolType == request.SchoolType)
|
|
.AndIF(request.Score > 0, c => SqlFunc.Between(c._23Score, request.Score - 25, request.Score + 15))
|
|
.AndIF(request.Syl.HasValue && request.Syl == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "双一流"))
|
|
.AndIF(request._211.HasValue && request._211 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "211"))
|
|
.AndIF(request._985.HasValue && request._985 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "985"))
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Ownership), c => c.Ownership == request.Ownership)
|
|
.AndIF(!string.IsNullOrWhiteSpace(request.Nature), c => c.Nature == request.Nature)
|
|
//.AndIF(request. > 0, c => SqlFunc.Between(c.LowScore, request.Score, request.Score)) 位次区间
|
|
.ToExpression();
|
|
|
|
var querylist = await this.sNeedDataInfoServices.Query(expression3);
|
|
|
|
var universitymaps = (await _UniversityServices.Query(c => c.IsDelete == false)).Select(c => new D_University()
|
|
{
|
|
Id = c.Id,
|
|
Name = c.Name,
|
|
}).ToList();
|
|
|
|
var responselist = querylist.Select(c => new OneSubmitGoResponse()
|
|
{
|
|
|
|
AreaName = c.Province,
|
|
fee = c.Fee,
|
|
Major = c.MajorName,
|
|
// MajorGroup = c.MajorGroup,
|
|
AcademicYear = c.AcademicYear,
|
|
MajorRemark = c.Remark,
|
|
planCount = int.Parse(c._23Count),
|
|
Ownership = c.Ownership,
|
|
Rank = c.UniversityRank,
|
|
_985 = c.LnstitutionalLevel!=null?(c.LnstitutionalLevel.Contains("985") ? "是" : "否") : "否",
|
|
_211 = c.LnstitutionalLevel != null ? (c.LnstitutionalLevel.Contains("211") ? "是" : "否") : "否",
|
|
_SYL = c.LnstitutionalLevel != null ? (c.LnstitutionalLevel.Contains("双一流") ? "是" : "否"): "否",
|
|
UniversityId = universitymaps.Where(e => e.Name == c.UniversityName).Any() ? universitymaps.FirstOrDefault(e => e.Name == c.UniversityName).Id : 0,
|
|
UniversityName = c.UniversityName,
|
|
SubjectClam = c._23subject,
|
|
Type = MajorPlanScoreTool.GetPlanScore(int.Parse(c._23Score), request.Score),//还缺冲稳保
|
|
Percentage = MajorPlanScoreTool.GetPlanPercentage(int.Parse(c._23Score), request.Score),
|
|
PlanId = (int)c.ID,
|
|
UniversityCode = c.EnrollmentCode,
|
|
collegeCode = c.EnrollmentCode,
|
|
MajorCode = c.MajorCode,
|
|
LowScoreRank = int.Parse(c._23SchoolScoreLine),
|
|
LowScore = int.Parse(c._23SchoolScore),
|
|
PlanItems = new List<PlanItem>()
|
|
{
|
|
new PlanItem() {
|
|
PlanCount=int.Parse(c._23Count),
|
|
RankLine=int.Parse(c._23ScoreLine),
|
|
Scoreline=int.Parse(c._23Score),
|
|
Year="2023"
|
|
},
|
|
new PlanItem() {
|
|
PlanCount=int.Parse(c._22Count),
|
|
RankLine=int.Parse(c._22ScoreLine),
|
|
Scoreline=int.Parse(c._22Score),
|
|
Year="2022"
|
|
},
|
|
new PlanItem() {
|
|
PlanCount=int.Parse(c._21Count),
|
|
RankLine=int.Parse(c._21ScoreLine),
|
|
Scoreline=int.Parse(c._21Score),
|
|
Year="2021"
|
|
},
|
|
}
|
|
}).ToList();
|
|
////冲稳保比例--待定
|
|
var newlist = responselist.Where(c => c.Type == 2).OrderByDescending(c => c.SubjectClam).OrderByDescending(c => c.LowScore).Take(25).ToList();
|
|
newlist.AddRange(responselist.Where(c => c.Type == 1).OrderByDescending(c => c.SubjectClam).OrderByDescending(c => c.LowScore).Take(45).ToList());
|
|
newlist.AddRange(responselist.Where(c => c.Type == 0).OrderByDescending(c => c.SubjectClam).OrderByDescending(c => c.LowScore).Take(30).ToList());
|
|
pagemodel.page = request.PageIndex;
|
|
pagemodel.data = newlist;
|
|
pagemodel.dataCount = responselist.Count;
|
|
pagemodel.PageSize = request.PageSize;
|
|
pagemodel.pageCount= pagemodel.data.Count();
|
|
return pagemodel;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
} |