调整数据年份数据

develop
old易 2024-01-09 13:45:03 +08:00
parent 5bbcde555b
commit 18160b0c07
7 changed files with 179 additions and 12 deletions

View File

@ -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
/// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下
/// </summary>
private readonly ID_PlanMajorScoreLineServices _d_PlanMajorScoreLineServices;
private readonly ID_PlanMajorDescServices _d_PlanMajorDescServices;
/// <summary>
///
/// </summary>
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<MessageModel<bool>> ImportMajorData(IFormFile file)
{
var rrr = new List<ScoreLineRepDto>();
var _list = new List<D_PlanMajorScoreLine>();
var list = ExcelProUtil<ImportPlanMajorScoreRequest>.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<bool>()
{
success = true,

View File

@ -7110,6 +7110,41 @@
累计人数
</summary>
</member>
<member name="P:New_College.Model.ViewModels.ScoreLineRepDto.Province">
<summary>
省份
</summary>
</member>
<member name="P:New_College.Model.ViewModels.ScoreLineRepDto.Years">
<summary>
年份
</summary>
</member>
<member name="P:New_College.Model.ViewModels.ScoreLineRepDto.Type">
<summary>
科类
</summary>
</member>
<member name="P:New_College.Model.ViewModels.ScoreLineRepDto.Score">
<summary>
分数
</summary>
</member>
<member name="P:New_College.Model.ViewModels.ScoreLineRepDto.ScoreRegion">
<summary>
分数区间
</summary>
</member>
<member name="P:New_College.Model.ViewModels.ScoreLineRepDto.Count">
<summary>
本段人数
</summary>
</member>
<member name="P:New_College.Model.ViewModels.ScoreLineRepDto.SumCountStart">
<summary>
累计人数
</summary>
</member>
<member name="T:New_College.Model.ViewModels.ServerViewModel">
<summary>
服务器VM

View File

@ -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<D_PlanMajorDesc>
{
/// <summary>
///
/// </summary>
/// <param name="majorDescs"></param>
/// <returns></returns>
Task<bool> Batchupdate(List<D_PlanMajorDesc> majorDescs);
/// <summary>
/// 一键填报
/// </summary>

View File

@ -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; }
}

View File

@ -83,4 +83,49 @@ namespace New_College.Model.ViewModels
}
public class ScoreLineRepDto
{
/// <summary>
/// 省份
/// </summary>
public string Province { get; set; }
/// <summary>
/// 年份
/// </summary>
public string Years { get; set; }
/// <summary>
/// 科类
/// </summary>
public string Type { get; set; }
/// <summary>
/// 分数
/// </summary>
public string Score { get; set; }
/// <summary>
/// 分数区间
/// </summary>
public string ScoreRegion { get; set; }
/// <summary>
/// 本段人数
/// </summary>
public int Count { get; set; }
/// <summary>
/// 累计人数
/// </summary>
public int SumCountStart { get; set; }
public int SumCountEnd { get; set; }
}
}

View File

@ -248,7 +248,7 @@ namespace New_College.Repository
RefAsync<int> 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;

View File

@ -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<D_PlanMajorDesc> _dal;
private readonly ID_QualificationLineRepository _qualificationLineRepository;
public D_PlanMajorDescServices(IBaseRepository<D_PlanMajorDesc> dal, ID_QualificationLineRepository d_QualificationLineRepository)
private readonly ID_PlanMajorDescRepository _planMajorDescRepository;
public D_PlanMajorDescServices(IBaseRepository<D_PlanMajorDesc> dal, ID_QualificationLineRepository d_QualificationLineRepository, ID_PlanMajorDescRepository planMajorDescRepository)
{
this._dal = dal;
base.BaseDal = dal;
_qualificationLineRepository = d_QualificationLineRepository;
_planMajorDescRepository = planMajorDescRepository;
}
/// <summary>
/// 批量更新
/// </summary>
/// <param name="majorDescs"></param>
/// <returns></returns>
public async Task<bool> Batchupdate(List<D_PlanMajorDesc> majorDescs)
{
return await _planMajorDescRepository.Batchupdate(majorDescs);
}
@ -45,7 +59,7 @@ namespace New_College.Services
var pagemodel = new AIGOPageModel<AIGOResponse>();
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<Func<D_QualificationLine, bool>> expression = Expressionable.Create<D_QualificationLine>()
.And(c => c.Years == qyear)
.And(c => c.IsDelete == false)